Issue #2318 Added OVERLINE,UNDERLINE, and STRIKETHROUGH text styles
Change-Id: I8762cb2385a89941936f37e6fb65dc324d5af0e5 Former-commit-id: 6ec6a0cd016a240f9e91baef4d16ba01f9676049
This commit is contained in:
parent
ab9a38f7ce
commit
c3f6193618
2 changed files with 60 additions and 28 deletions
|
@ -79,7 +79,7 @@ public interface IGraphicsTarget extends IImagingExtension {
|
|||
|
||||
/** Defines text characteristics */
|
||||
public static enum TextStyle {
|
||||
NORMAL, BLANKED, BOXED, WORD_WRAP, DROP_SHADOW, OUTLINE
|
||||
NORMAL, BLANKED, BOXED, WORD_WRAP, DROP_SHADOW, OUTLINE, UNDERLINE, OVERLINE, STRIKETHROUGH;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -1854,9 +1854,12 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
|
|||
|
||||
// This loop just draws the box or a blank rectangle.
|
||||
for (DrawableString dString : parameters) {
|
||||
float[] rotatedPoint = null;
|
||||
if (dString.textStyle == TextStyle.BOXED
|
||||
|| dString.textStyle == TextStyle.BLANKED) {
|
||||
switch (dString.textStyle) {
|
||||
case BOXED:
|
||||
case BLANKED:
|
||||
case UNDERLINE:
|
||||
case OVERLINE:
|
||||
case STRIKETHROUGH:
|
||||
double yPos = dString.basics.y;
|
||||
VerticalAlignment verticalAlignment = dString.verticallAlignment;
|
||||
double fontPercentage = this
|
||||
|
@ -1874,6 +1877,7 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
|
|||
double scaleX = stringScaleX;
|
||||
double scaleY = stringScaleY;
|
||||
|
||||
float[] rotatedPoint = null;
|
||||
if (dString.rotation != 0.0) {
|
||||
rotatedPoint = getUpdatedCoordinates(
|
||||
new java.awt.Rectangle(0, 0, 0, 0),
|
||||
|
@ -1897,6 +1901,17 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
|
|||
dString.basics.x, yPos, dString.basics.z,
|
||||
dString.rotation, fontPercentage);
|
||||
|
||||
double width = textBounds.getWidth();
|
||||
double height = textBounds.getHeight();
|
||||
double diff = height + textBounds.getY();
|
||||
|
||||
double x1 = xy[0] - scaleX;
|
||||
double y1 = (xy[1] - diff) - scaleY;
|
||||
double x2 = xy[0] + width + scaleX;
|
||||
double y2 = (xy[1] - diff) + height + scaleY;
|
||||
|
||||
if (dString.textStyle == TextStyle.BOXED
|
||||
|| dString.textStyle == TextStyle.BLANKED) {
|
||||
gl.glPolygonMode(GL.GL_BACK, GL.GL_FILL);
|
||||
if (dString.textStyle == TextStyle.BOXED
|
||||
&& dString.boxColor != null) {
|
||||
|
@ -1909,38 +1924,48 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
|
|||
backgroundColor.blue / 255.0, alpha);
|
||||
}
|
||||
|
||||
double width = textBounds.getWidth();
|
||||
double height = textBounds.getHeight();
|
||||
double diff = height + textBounds.getY();
|
||||
|
||||
double x1 = xy[0] - scaleX;
|
||||
double y1 = (xy[1] - diff) - scaleY;
|
||||
double x2 = xy[0] + width + scaleX;
|
||||
double y2 = (xy[1] - diff) + height + scaleY;
|
||||
|
||||
gl.glRectd(x1, y2, x2, y1);
|
||||
}
|
||||
|
||||
if (dString.textStyle == TextStyle.BOXED
|
||||
|| dString.textStyle == TextStyle.UNDERLINE
|
||||
|| dString.textStyle == TextStyle.OVERLINE
|
||||
|| dString.textStyle == TextStyle.STRIKETHROUGH) {
|
||||
gl.glPolygonMode(GL.GL_BACK, GL.GL_LINE);
|
||||
|
||||
if (dString.textStyle == TextStyle.BOXED) {
|
||||
RGB color = dString.getColors()[c];
|
||||
if (color == null) {
|
||||
color = DEFAULT_LABEL_COLOR;
|
||||
}
|
||||
gl.glPolygonMode(GL.GL_BACK, GL.GL_LINE);
|
||||
gl.glColor4d(color.red / 255.0,
|
||||
color.green / 255.0, color.blue / 255.0,
|
||||
alpha);
|
||||
|
||||
if (dString.textStyle == TextStyle.BOXED) {
|
||||
gl.glLineWidth(2);
|
||||
gl.glRectd(x1, y2, x2, y1);
|
||||
|
||||
} else {
|
||||
gl.glLineWidth(1);
|
||||
double percent;
|
||||
if (dString.textStyle == TextStyle.UNDERLINE) {
|
||||
percent = .2;
|
||||
} else if (dString.textStyle == TextStyle.OVERLINE) {
|
||||
percent = 1.;
|
||||
} else { // TextStyle.STRIKETHROUGH
|
||||
percent = .5;
|
||||
}
|
||||
double lineY = y1 + (y2 - y1) * percent;
|
||||
gl.glBegin(GL.GL_LINES);
|
||||
gl.glVertex2d(x1, lineY);
|
||||
gl.glVertex2d(x2, lineY);
|
||||
gl.glEnd();
|
||||
}
|
||||
}
|
||||
gl.glPolygonMode(GL.GL_BACK, GL.GL_FILL);
|
||||
|
||||
if (verticalAlignment == VerticalAlignment.TOP) {
|
||||
yPos += textBounds.getHeight();
|
||||
} else {
|
||||
yPos -= textBounds.getHeight();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1949,7 +1974,14 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
|
|||
gl.glRotated(-dString.rotation, 0.0, 0.0, 1.0);
|
||||
gl.glTranslated(-rotatedPoint[0], -rotatedPoint[1], 0.0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gl.glPolygonMode(GL.GL_BACK, GL.GL_FILL);
|
||||
|
||||
IFont font = null;
|
||||
double magnification = -1.0;
|
||||
double fontPercentage = -1.0;
|
||||
|
|
Loading…
Add table
Reference in a new issue