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
a54972fa
Commit
a54972fa
authored
5 years ago
by
Andrey Ruzhanskiy
Browse files
Options
Downloads
Patches
Plain Diff
Added new function.
parent
fa8b9543
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/BrailleTextRasterizer.java
+23
-4
23 additions, 4 deletions
.../inf/mci/brailleplot/rendering/BrailleTextRasterizer.java
with
23 additions
and
4 deletions
src/main/java/de/tudresden/inf/mci/brailleplot/rendering/BrailleTextRasterizer.java
+
23
−
4
View file @
a54972fa
...
@@ -4,6 +4,7 @@ import de.tudresden.inf.mci.brailleplot.brailleparser.AbstractBrailleTableParser
...
@@ -4,6 +4,7 @@ import de.tudresden.inf.mci.brailleplot.brailleparser.AbstractBrailleTableParser
import
de.tudresden.inf.mci.brailleplot.layout.InsufficientRenderingAreaException
;
import
de.tudresden.inf.mci.brailleplot.layout.InsufficientRenderingAreaException
;
import
de.tudresden.inf.mci.brailleplot.layout.RasterCanvas
;
import
de.tudresden.inf.mci.brailleplot.layout.RasterCanvas
;
//import de.tudresden.inf.mci.brailleplot.printabledata.SimpleMatrixDataImpl;
//import de.tudresden.inf.mci.brailleplot.printabledata.SimpleMatrixDataImpl;
import
de.tudresden.inf.mci.brailleplot.layout.Rectangle
;
import
de.tudresden.inf.mci.brailleplot.printerbackend.NotSupportedFileExtensionException
;
import
de.tudresden.inf.mci.brailleplot.printerbackend.NotSupportedFileExtensionException
;
/**
/**
...
@@ -37,8 +38,6 @@ public final class BrailleTextRasterizer implements Rasterizer<BrailleText> {
...
@@ -37,8 +38,6 @@ public final class BrailleTextRasterizer implements Rasterizer<BrailleText> {
textAsArray
[
i
]
=
String
.
valueOf
(
Character
.
toLowerCase
(
textAsArray
[
i
].
charAt
(
0
)));
textAsArray
[
i
]
=
String
.
valueOf
(
Character
.
toLowerCase
(
textAsArray
[
i
].
charAt
(
0
)));
}
}
// Letter to be printed to the canvas (braille string representation).
// Letter to be printed to the canvas (braille string representation).
int
j
=
data
.
getText
().
length
();
String
letter
=
textAsArray
[
i
];
letterAsBraille
=
mParser
.
getDots
(
textAsArray
[
i
]).
split
(
""
);
letterAsBraille
=
mParser
.
getDots
(
textAsArray
[
i
]).
split
(
""
);
// First cell width, then cell height.
// First cell width, then cell height.
...
@@ -80,12 +79,32 @@ public final class BrailleTextRasterizer implements Rasterizer<BrailleText> {
...
@@ -80,12 +79,32 @@ public final class BrailleTextRasterizer implements Rasterizer<BrailleText> {
final
RasterCanvas
canvas
)
{
final
RasterCanvas
canvas
)
{
// TODO: Add calculations for required height to fit the given text into the given canvas. (Linebreaks!)
// TODO: Add calculations for required height to fit the given text into the given canvas. (Linebreaks!)
// Until then we use a dummy value assuming one line of text:
// Until then we use a dummy value assuming one line of text:
return
canvas
.
getCellHeight
();
// Maximum Rectangle intersecting with real one, Leos suggestion.
Rectangle
rectToIntersect
=
new
Rectangle
(
xPos
,
yPos
,
maxWidth
,
Integer
.
MAX_VALUE
);
Rectangle
rect
=
canvas
.
getCellRectangle
().
intersectedWith
(
rectToIntersect
);
// Needed for calculating the number of chars (including space)
String
[]
textAsArray
=
text
.
split
(
""
);
int
spaceInChars
=
textAsArray
.
length
;
// Get maximum width in cells
int
availableWidth
=
rect
.
intWrapper
().
getWidth
();
// Divide them, round up
int
height
=
(
int
)
Math
.
ceil
((
double
)
spaceInChars
/
availableWidth
);
return
height
;
}
}
public
int
calculateRequiredWidth
(
final
String
text
,
final
int
xPos
,
final
int
yPos
,
final
RasterCanvas
canvas
)
{
public
int
calculateRequiredWidth
(
final
String
text
,
final
int
xPos
,
final
int
yPos
,
final
RasterCanvas
canvas
)
{
// TODO: Add calculations for required width to fit the given text into the given canvas. (Extra spacing for equidistant grid!)
// TODO: Add calculations for required width to fit the given text into the given canvas. (Extra spacing for equidistant grid!)
// Until then we use a dummy value assuming single character on braille grid:
// Until then we use a dummy value assuming single character on braille grid:
return
canvas
.
getCellWidth
();
String
mode
=
canvas
.
getPrinter
().
getProperty
(
"mode"
).
toString
();
switch
(
mode
)
{
case
"normalprinter"
:
return
calculateWidthNormal
(
text
,
xPos
,
yPos
,
canvas
);
// For the time being
default
:
throw
new
UnsupportedOperationException
();
}
}
private
int
calculateWidthNormal
(
String
text
,
int
xPos
,
int
yPos
,
RasterCanvas
canvas
)
{
String
[]
textAsArray
=
text
.
split
(
""
);
return
textAsArray
.
length
;
}
}
}
}
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