Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BraillePlot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Georg Graßnick
BraillePlot
Commits
77736e89
Commit
77736e89
authored
5 years ago
by
Andrey Ruzhanskiy
Browse files
Options
Downloads
Patches
Plain Diff
Catch nulls.
parent
7ba61dc2
No related branches found
No related tags found
1 merge request
!24
Feat/brailletextrasterizer 38
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/tudresden/inf/mci/brailleplot/rendering/LiblouisBrailleTextRasterizer.java
+12
-1
12 additions, 1 deletion
.../brailleplot/rendering/LiblouisBrailleTextRasterizer.java
with
12 additions
and
1 deletion
src/main/java/de/tudresden/inf/mci/brailleplot/rendering/LiblouisBrailleTextRasterizer.java
+
12
−
1
View file @
77736e89
...
...
@@ -6,12 +6,15 @@ import de.tudresden.inf.mci.brailleplot.layout.InsufficientRenderingAreaExceptio
import
de.tudresden.inf.mci.brailleplot.layout.RasterCanvas
;
import
de.tudresden.inf.mci.brailleplot.layout.Rectangle
;
import
de.tudresden.inf.mci.brailleplot.printerbackend.NotSupportedFileExtensionException
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.liblouis.DisplayException
;
import
org.liblouis.DisplayTable
;
import
org.liblouis.TranslationException
;
import
org.liblouis.TranslationResult
;
import
org.liblouis.Translator
;
import
java.util.Objects
;
import
static
java
.
lang
.
Math
.
ceil
;
/**
...
...
@@ -37,6 +40,7 @@ public class LiblouisBrailleTextRasterizer implements Rasterizer<BrailleText> {
* @param printer Needed to get the semantictable according to the printer config.
*/
public
LiblouisBrailleTextRasterizer
(
final
Printer
printer
)
{
Objects
.
requireNonNull
(
printer
,
"The given printer for the LiblouisBrailleTextRasterizer was null!"
);
try
{
mParser
=
AbstractBrailleTableParser
.
getParser
(
printer
,
"semantictable"
);
}
catch
(
NotSupportedFileExtensionException
e
)
{
...
...
@@ -53,7 +57,8 @@ public class LiblouisBrailleTextRasterizer implements Rasterizer<BrailleText> {
@Override
public
void
rasterize
(
final
BrailleText
data
,
final
RasterCanvas
canvas
)
throws
InsufficientRenderingAreaException
{
Objects
.
requireNonNull
(
data
,
"The data given to the brailletextrasterizer was null!"
);
Objects
.
requireNonNull
(
canvas
,
"The canvas given to the brailletextrasterizer was null!"
);
Rectangle
rect
=
data
.
getArea
().
intersectedWith
(
canvas
.
getDotRectangle
());
mCanvas
=
canvas
;
TranslationResult
result
=
null
;
...
...
@@ -80,6 +85,8 @@ public class LiblouisBrailleTextRasterizer implements Rasterizer<BrailleText> {
}
private
void
writeToCanvas
(
final
String
[]
braille
,
final
int
offsetX
,
final
int
offsetY
,
final
RasterCanvas
canvas
)
{
Objects
.
requireNonNull
(
braille
,
"The string array given to writeToCanvas in liblouisBraileTextRasterizer was null!"
);
Objects
.
requireNonNull
(
canvas
,
"The cancas given to writeToCanvas was null"
);
int
temp
=
0
;
for
(
int
j
=
0
;
j
<
canvas
.
getCellWidth
();
j
++)
{
for
(
int
k
=
0
;
k
<
canvas
.
getCellHeight
();
k
++)
{
...
...
@@ -92,6 +99,7 @@ public class LiblouisBrailleTextRasterizer implements Rasterizer<BrailleText> {
}
private
void
writeChar
(
final
String
s
)
throws
InsufficientRenderingAreaException
{
Objects
.
requireNonNull
(
s
,
"The given String to writeChar was null!"
);
String
[]
braille
=
mParser
.
getCharToBraille
(
s
).
split
(
""
);
writeToCanvas
(
braille
,
x
,
y
,
mCanvas
);
jumpToNextCell
();
...
...
@@ -122,6 +130,9 @@ public class LiblouisBrailleTextRasterizer implements Rasterizer<BrailleText> {
*/
public
int
calculateRequiredHeight
(
final
String
text
,
final
int
xPos
,
final
int
yPos
,
final
int
maxWidth
,
final
RasterCanvas
canvas
)
{
Objects
.
requireNonNull
(
text
,
"The given string for calculateRequiredHeight was null!"
);
Objects
.
requireNonNull
(
canvas
,
"The given canvas for calculateRequiredHeight was null!"
);
TranslationResult
result
=
null
;
try
{
result
=
mTranslator
.
translate
(
text
,
null
,
null
,
null
,
DisplayTable
.
StandardDisplayTables
.
DEFAULT
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment