Merge "Issue #2920 Allow strings to use mulitple styles." into development
Former-commit-id: 1b07e87178947df4d579dbc32057e883b61a7de2
This commit is contained in:
commit
3fff4e77d4
8 changed files with 196 additions and 182 deletions
|
@ -62,10 +62,11 @@ import com.raytheon.uf.viz.core.exception.VizException;
|
||||||
*
|
*
|
||||||
* SOFTWARE HISTORY
|
* SOFTWARE HISTORY
|
||||||
*
|
*
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------- -------- ----------- --------------------------
|
||||||
* Jun 25, 2012 bsteffen Initial creation
|
* Jun 25, 2012 bsteffen Initial creation
|
||||||
* Jul 18, 2013 2189 mschenke Added ability to specify font type
|
* Jul 18, 2013 2189 mschenke Added ability to specify font type
|
||||||
|
* Apr 04, 2014 2920 bsteffen Allow strings to use mulitple styles.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -179,8 +180,8 @@ public abstract class AbstractGraphicsTarget implements IGraphicsTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bounds != null) {
|
if (bounds != null) {
|
||||||
if (parameters.textStyle == TextStyle.BLANKED
|
if (parameters.getTextStyles().contains(TextStyle.BOXED)
|
||||||
|| parameters.textStyle == TextStyle.BOXED) {
|
|| parameters.getTextStyles().contains(TextStyle.BLANKED)) {
|
||||||
maxWidth += 1.0f;
|
maxWidth += 1.0f;
|
||||||
}
|
}
|
||||||
bounds.setRect(0, 0, maxWidth, totalHeight);
|
bounds.setRect(0, 0, maxWidth, totalHeight);
|
||||||
|
@ -397,8 +398,14 @@ public abstract class AbstractGraphicsTarget implements IGraphicsTarget {
|
||||||
HorizontalAlignment horizontalAlignment,
|
HorizontalAlignment horizontalAlignment,
|
||||||
VerticalAlignment verticalAlignment, Double rotation)
|
VerticalAlignment verticalAlignment, Double rotation)
|
||||||
throws VizException {
|
throws VizException {
|
||||||
drawString(font, text, x, y, z, textStyle, color, horizontalAlignment,
|
DrawableString params = new DrawableString(text, color);
|
||||||
verticalAlignment, rotation, 1.0f, 1.0f);
|
params.font = font;
|
||||||
|
params.setCoordinates(x, y, z);
|
||||||
|
params.addTextStyle(textStyle);
|
||||||
|
params.horizontalAlignment = horizontalAlignment;
|
||||||
|
params.verticallAlignment = verticalAlignment;
|
||||||
|
params.rotation = rotation != null ? rotation : 0.0;
|
||||||
|
drawStrings(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -418,30 +425,12 @@ public abstract class AbstractGraphicsTarget implements IGraphicsTarget {
|
||||||
DrawableString params = new DrawableString(text, colors);
|
DrawableString params = new DrawableString(text, colors);
|
||||||
params.font = font;
|
params.font = font;
|
||||||
params.setCoordinates(x, y, z);
|
params.setCoordinates(x, y, z);
|
||||||
params.textStyle = textStyle;
|
params.addTextStyle(textStyle);
|
||||||
params.horizontalAlignment = horizontalAlignment;
|
params.horizontalAlignment = horizontalAlignment;
|
||||||
params.verticallAlignment = verticalAlignment;
|
params.verticallAlignment = verticalAlignment;
|
||||||
drawStrings(params);
|
drawStrings(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawString(IFont font, String string, double xPos, double yPos,
|
|
||||||
double zPos, TextStyle textStyle, RGB color,
|
|
||||||
HorizontalAlignment horizontalAlignment,
|
|
||||||
VerticalAlignment verticalAlignment, Double rotation, float alpha,
|
|
||||||
double magnification) throws VizException {
|
|
||||||
DrawableString params = new DrawableString(string, color);
|
|
||||||
params.font = font;
|
|
||||||
params.setCoordinates(xPos, yPos, zPos);
|
|
||||||
params.textStyle = textStyle;
|
|
||||||
params.horizontalAlignment = horizontalAlignment;
|
|
||||||
params.verticallAlignment = verticalAlignment;
|
|
||||||
params.rotation = rotation != null ? rotation : 0.0;
|
|
||||||
params.basics.alpha = alpha;
|
|
||||||
params.magnification = magnification;
|
|
||||||
drawStrings(params);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Rectangle2D getStringBounds(IFont font, String text) {
|
public Rectangle2D getStringBounds(IFont font, String text) {
|
||||||
if (font == null) {
|
if (font == null) {
|
||||||
|
@ -466,7 +455,7 @@ public abstract class AbstractGraphicsTarget implements IGraphicsTarget {
|
||||||
TextStyle style) {
|
TextStyle style) {
|
||||||
DrawableString params = new DrawableString(text, (RGB[]) null);
|
DrawableString params = new DrawableString(text, (RGB[]) null);
|
||||||
params.font = font;
|
params.font = font;
|
||||||
params.textStyle = style;
|
params.addTextStyle(style);
|
||||||
return getStringsBounds(params);
|
return getStringsBounds(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.viz.core;
|
package com.raytheon.uf.viz.core;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
import org.eclipse.swt.graphics.RGB;
|
import org.eclipse.swt.graphics.RGB;
|
||||||
|
|
||||||
import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment;
|
import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment;
|
||||||
|
@ -34,9 +36,10 @@ import com.raytheon.uf.viz.core.drawables.IFont;
|
||||||
*
|
*
|
||||||
* SOFTWARE HISTORY
|
* SOFTWARE HISTORY
|
||||||
*
|
*
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------- -------- ----------- --------------------------
|
||||||
* Dec 14, 2010 mschenke Initial creation
|
* Dec 14, 2010 mschenke Initial creation
|
||||||
|
* Apr 04, 2014 2920 bsteffen Allow strings to use mulitple styles.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -71,9 +74,12 @@ public class DrawableString extends AbstractDrawableObject {
|
||||||
/** The colors to use for the strings */
|
/** The colors to use for the strings */
|
||||||
private RGB[] colors;
|
private RGB[] colors;
|
||||||
|
|
||||||
/** The text style to use when drawing */
|
/** @deprecated use {@link #addTextStyle(TextStyle)} */
|
||||||
|
@Deprecated
|
||||||
public TextStyle textStyle = TextStyle.NORMAL;
|
public TextStyle textStyle = TextStyle.NORMAL;
|
||||||
|
|
||||||
|
private EnumSet<TextStyle> textStyles = EnumSet.noneOf(TextStyle.class);
|
||||||
|
|
||||||
/** The color of the shadow created when using TextStyle.DROP_SHADOW */
|
/** The color of the shadow created when using TextStyle.DROP_SHADOW */
|
||||||
public RGB shadowColor = new RGB(0, 0, 0);
|
public RGB shadowColor = new RGB(0, 0, 0);
|
||||||
|
|
||||||
|
@ -95,6 +101,7 @@ public class DrawableString extends AbstractDrawableObject {
|
||||||
this.verticallAlignment = that.verticallAlignment;
|
this.verticallAlignment = that.verticallAlignment;
|
||||||
this.magnification = that.magnification;
|
this.magnification = that.magnification;
|
||||||
this.rotation = that.rotation;
|
this.rotation = that.rotation;
|
||||||
|
this.textStyles = that.textStyles;
|
||||||
this.textStyle = that.textStyle;
|
this.textStyle = that.textStyle;
|
||||||
this.shadowColor = that.shadowColor;
|
this.shadowColor = that.shadowColor;
|
||||||
this.boxColor = that.boxColor;
|
this.boxColor = that.boxColor;
|
||||||
|
@ -184,4 +191,43 @@ public class DrawableString extends AbstractDrawableObject {
|
||||||
return colors;
|
return colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addTextStyle(TextStyle textStyle) {
|
||||||
|
textStyles.add(textStyle);
|
||||||
|
/*
|
||||||
|
* This check is the best we can do to support targets that don't know
|
||||||
|
* about textStyles yet.
|
||||||
|
*/
|
||||||
|
if (this.textStyle == null) {
|
||||||
|
this.textStyle = textStyle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeTextStyle(TextStyle textStyle) {
|
||||||
|
textStyles.remove(textStyle);
|
||||||
|
/*
|
||||||
|
* This check is the best we can do to support targets that don't know
|
||||||
|
* about textStyles yet.
|
||||||
|
*/
|
||||||
|
if (textStyle == this.textStyle) {
|
||||||
|
if (textStyles.isEmpty()) {
|
||||||
|
this.textStyle = null;
|
||||||
|
} else {
|
||||||
|
this.textStyle = textStyles.iterator().next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumSet<TextStyle> getTextStyles() {
|
||||||
|
EnumSet<TextStyle> textStyles = this.textStyles.clone();
|
||||||
|
/*
|
||||||
|
* Add in textStyle to support any renderables that don't know about
|
||||||
|
* textStyles yet.
|
||||||
|
*/
|
||||||
|
if (textStyle != null) {
|
||||||
|
textStyles.add(textStyle);
|
||||||
|
}
|
||||||
|
return textStyles;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,20 +46,22 @@ import com.raytheon.uf.viz.core.exception.VizException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Base for any graphics target (GL, Swing, AWT, Postscript, etc.)
|
* Base class for accessing all the drawing functionality available for
|
||||||
|
* displaying things on a renderable display.
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
*
|
||||||
* SOFTWARE HISTORY
|
* SOFTWARE HISTORY
|
||||||
*
|
*
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------- -------- ----------- --------------------------
|
||||||
* 7/1/06 chammack Initial Creation.
|
* Jul 01, 2006 chammack Initial Creation.
|
||||||
* 7/19/10 #5952 bkowal Created a new member and method that could
|
* Jul 19, 2010 5952 bkowal Created a new member and method that could
|
||||||
* track any needed updates to the Target extents.
|
* track any needed updates to the Target extents.
|
||||||
* This functionality is primarily used by the
|
* This functionality is primarily used by the
|
||||||
* Feature Following Zoom Tool at this time.
|
* Feature Following Zoom Tool at this time.
|
||||||
* 7/18/13 #2189 mschenke Added ability to specify font type
|
* Jul 18, 2013 2189 mschenke Added ability to specify font type
|
||||||
|
* Apr 04, 2014 2920 bsteffen Allow strings to use mulitple styles.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -79,7 +81,14 @@ public interface IGraphicsTarget extends IImagingExtension {
|
||||||
|
|
||||||
/** Defines text characteristics */
|
/** Defines text characteristics */
|
||||||
public static enum TextStyle {
|
public static enum TextStyle {
|
||||||
NORMAL, BLANKED, BOXED, WORD_WRAP, DROP_SHADOW, OUTLINE, UNDERLINE, OVERLINE, STRIKETHROUGH;
|
/**
|
||||||
|
* @deprecated Normal is indicated by adding no other styles to a
|
||||||
|
* {@link DrawableString}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
NORMAL,
|
||||||
|
|
||||||
|
BLANKED, BOXED, WORD_WRAP, DROP_SHADOW, UNDERLINE, OVERLINE, STRIKETHROUGH;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -858,16 +867,6 @@ public interface IGraphicsTarget extends IImagingExtension {
|
||||||
HorizontalAlignment horizontalAlignment,
|
HorizontalAlignment horizontalAlignment,
|
||||||
VerticalAlignment verticalAlignment) throws VizException;
|
VerticalAlignment verticalAlignment) throws VizException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Use drawStrings(DrawableString parameters)
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void drawString(IFont font, String string, double xPos, double yPos,
|
|
||||||
double zPos, TextStyle textStyle, RGB color,
|
|
||||||
HorizontalAlignment horizontalAlignment,
|
|
||||||
VerticalAlignment verticalAlignment, Double rotation, float alpha,
|
|
||||||
double magnification) throws VizException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use getStringsBounds(DrawableStrings...) functions
|
* Use getStringsBounds(DrawableStrings...) functions
|
||||||
*
|
*
|
||||||
|
|
|
@ -27,6 +27,7 @@ import com.raytheon.uf.viz.core.DrawableImage;
|
||||||
import com.raytheon.uf.viz.core.DrawableLine;
|
import com.raytheon.uf.viz.core.DrawableLine;
|
||||||
import com.raytheon.uf.viz.core.DrawableString;
|
import com.raytheon.uf.viz.core.DrawableString;
|
||||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||||
|
import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle;
|
||||||
import com.raytheon.uf.viz.core.IView;
|
import com.raytheon.uf.viz.core.IView;
|
||||||
import com.raytheon.uf.viz.core.PixelCoverage;
|
import com.raytheon.uf.viz.core.PixelCoverage;
|
||||||
import com.raytheon.uf.viz.core.PixelExtent;
|
import com.raytheon.uf.viz.core.PixelExtent;
|
||||||
|
@ -49,6 +50,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
||||||
* parameters, disable colormap interpolation
|
* parameters, disable colormap interpolation
|
||||||
* by default.
|
* by default.
|
||||||
* Jan 14, 2014 2313 bsteffen Add method to draw images.
|
* Jan 14, 2014 2313 bsteffen Add method to draw images.
|
||||||
|
* Apr 04, 2014 2920 bsteffen Allow strings to use mulitple styles.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
|
@ -76,7 +78,9 @@ public class GeneralCanvasRenderingExtension extends
|
||||||
mapString.magnification = screenString.magnification;
|
mapString.magnification = screenString.magnification;
|
||||||
mapString.rotation = screenString.rotation;
|
mapString.rotation = screenString.rotation;
|
||||||
mapString.shadowColor = screenString.shadowColor;
|
mapString.shadowColor = screenString.shadowColor;
|
||||||
mapString.textStyle = screenString.textStyle;
|
for (TextStyle textStyle : screenString.getTextStyles()) {
|
||||||
|
mapString.addTextStyle(textStyle);
|
||||||
|
}
|
||||||
mapString.verticallAlignment = screenString.verticallAlignment;
|
mapString.verticallAlignment = screenString.verticallAlignment;
|
||||||
mapString.basics.alpha = screenString.basics.alpha;
|
mapString.basics.alpha = screenString.basics.alpha;
|
||||||
mapString.basics.xOrColors = screenString.basics.xOrColors;
|
mapString.basics.xOrColors = screenString.basics.xOrColors;
|
||||||
|
|
|
@ -69,8 +69,9 @@ import de.micromata.opengis.kml.v_2_2_0.Vec2;
|
||||||
*
|
*
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------- -------- ----------- --------------------------
|
* ------------- -------- ----------- --------------------------
|
||||||
* Jun 26, 2012 bsteffen Initial creation
|
* Jun 26, 2012 bsteffen Initial creation
|
||||||
* Jan 14, 2013 2313 bsteffen Add image rendering
|
* Jan 14, 2013 2313 bsteffen Add image rendering
|
||||||
|
* Apr 04, 2014 2920 bsteffen Allow strings to use mulitple styles.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -309,7 +310,7 @@ public class KmlCanvasRenderingExtension extends
|
||||||
} else if (VerticalAlignment.MIDDLE == string.verticallAlignment) {
|
} else if (VerticalAlignment.MIDDLE == string.verticallAlignment) {
|
||||||
realY -= bounds.getY() / 2;
|
realY -= bounds.getY() / 2;
|
||||||
}
|
}
|
||||||
if (string.textStyle == TextStyle.BLANKED) {
|
if (string.getTextStyles().contains(TextStyle.BLANKED)) {
|
||||||
setColor(graphics, backgroundColor);
|
setColor(graphics, backgroundColor);
|
||||||
graphics.fillRect((int) realX,
|
graphics.fillRect((int) realX,
|
||||||
(int) (realY + bounds.getY()),
|
(int) (realY + bounds.getY()),
|
||||||
|
|
|
@ -107,9 +107,10 @@ import com.raytheon.uf.viz.remote.graphics.objects.DispatchingWireframeShape;
|
||||||
*
|
*
|
||||||
* SOFTWARE HISTORY
|
* SOFTWARE HISTORY
|
||||||
*
|
*
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------- -------- ----------- --------------------------
|
||||||
* Feb 28, 2012 mschenke Initial creation
|
* Feb 28, 2012 mschenke Initial creation
|
||||||
|
* Apr 04, 2014 2920 bsteffen Allow strings to use mulitple styles.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -1147,7 +1148,7 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
||||||
DrawableString string = new DrawableString(text, color);
|
DrawableString string = new DrawableString(text, color);
|
||||||
string.setCoordinates(x, y, z);
|
string.setCoordinates(x, y, z);
|
||||||
string.font = font;
|
string.font = font;
|
||||||
string.textStyle = textStyle;
|
string.addTextStyle(textStyle);
|
||||||
string.horizontalAlignment = horizontalAlignment;
|
string.horizontalAlignment = horizontalAlignment;
|
||||||
string.verticallAlignment = verticalAlignment;
|
string.verticallAlignment = verticalAlignment;
|
||||||
string.rotation = rotation;
|
string.rotation = rotation;
|
||||||
|
@ -1180,7 +1181,7 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
||||||
DrawableString string = new DrawableString(text, color);
|
DrawableString string = new DrawableString(text, color);
|
||||||
string.setCoordinates(x, y, z);
|
string.setCoordinates(x, y, z);
|
||||||
string.font = font;
|
string.font = font;
|
||||||
string.textStyle = textStyle;
|
string.addTextStyle(textStyle);
|
||||||
string.horizontalAlignment = horizontalAlignment;
|
string.horizontalAlignment = horizontalAlignment;
|
||||||
string.rotation = rotation;
|
string.rotation = rotation;
|
||||||
drawStrings(string);
|
drawStrings(string);
|
||||||
|
@ -1212,52 +1213,12 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
||||||
DrawableString string = new DrawableString(text, colors);
|
DrawableString string = new DrawableString(text, colors);
|
||||||
string.setCoordinates(x, y, z);
|
string.setCoordinates(x, y, z);
|
||||||
string.font = font;
|
string.font = font;
|
||||||
string.textStyle = textStyle;
|
string.addTextStyle(textStyle);
|
||||||
string.horizontalAlignment = horizontalAlignment;
|
string.horizontalAlignment = horizontalAlignment;
|
||||||
string.verticallAlignment = verticalAlignment;
|
string.verticallAlignment = verticalAlignment;
|
||||||
drawStrings(string);
|
drawStrings(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param font
|
|
||||||
* @param string
|
|
||||||
* @param xPos
|
|
||||||
* @param yPos
|
|
||||||
* @param zPos
|
|
||||||
* @param textStyle
|
|
||||||
* @param color
|
|
||||||
* @param horizontalAlignment
|
|
||||||
* @param verticalAlignment
|
|
||||||
* @param rotation
|
|
||||||
* @param alpha
|
|
||||||
* @param magnification
|
|
||||||
* @throws VizException
|
|
||||||
* @deprecated
|
|
||||||
* @see com.raytheon.uf.viz.core.IGraphicsTarget#drawString(com.raytheon.uf.viz.core.drawables.IFont,
|
|
||||||
* java.lang.String, double, double, double,
|
|
||||||
* com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle,
|
|
||||||
* org.eclipse.swt.graphics.RGB,
|
|
||||||
* com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment,
|
|
||||||
* com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment,
|
|
||||||
* java.lang.Double, float, double)
|
|
||||||
*/
|
|
||||||
public void drawString(IFont font, String text, double x, double y,
|
|
||||||
double z, TextStyle textStyle, RGB color,
|
|
||||||
HorizontalAlignment horizontalAlignment,
|
|
||||||
VerticalAlignment verticalAlignment, Double rotation, float alpha,
|
|
||||||
double magnification) throws VizException {
|
|
||||||
DrawableString string = new DrawableString(text, color);
|
|
||||||
string.setCoordinates(x, y, z);
|
|
||||||
string.font = font;
|
|
||||||
string.textStyle = textStyle;
|
|
||||||
string.horizontalAlignment = horizontalAlignment;
|
|
||||||
string.verticallAlignment = verticalAlignment;
|
|
||||||
string.rotation = rotation;
|
|
||||||
string.basics.alpha = alpha;
|
|
||||||
string.magnification = magnification;
|
|
||||||
drawStrings(string);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param font
|
* @param font
|
||||||
* @param text
|
* @param text
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package com.raytheon.uf.viz.remote.graphics.events.strings;
|
package com.raytheon.uf.viz.remote.graphics.events.strings;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
import org.eclipse.swt.graphics.RGB;
|
import org.eclipse.swt.graphics.RGB;
|
||||||
|
|
||||||
|
@ -40,9 +41,10 @@ import com.raytheon.uf.viz.remote.graphics.objects.DispatchingFont;
|
||||||
*
|
*
|
||||||
* SOFTWARE HISTORY
|
* SOFTWARE HISTORY
|
||||||
*
|
*
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------- -------- ----------- --------------------------
|
||||||
* May 10, 2012 mschenke Initial creation
|
* May 10, 2012 mschenke Initial creation
|
||||||
|
* Apr 04, 2014 2920 bsteffen Allow strings to use mulitple styles.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -72,7 +74,7 @@ public class DrawStringEvent extends AbstractRemoteGraphicsRenderEvent {
|
||||||
private VerticalAlignment verticalAlignment;
|
private VerticalAlignment verticalAlignment;
|
||||||
|
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private TextStyle textStyle;
|
private EnumSet<TextStyle> textStyles;
|
||||||
|
|
||||||
@DynamicSerializeElement
|
@DynamicSerializeElement
|
||||||
private RGB boxColor;
|
private RGB boxColor;
|
||||||
|
@ -126,8 +128,8 @@ public class DrawStringEvent extends AbstractRemoteGraphicsRenderEvent {
|
||||||
if (verticalAlignment != diffEvent.verticalAlignment) {
|
if (verticalAlignment != diffEvent.verticalAlignment) {
|
||||||
diffObject.verticalAlignment = diffEvent.verticalAlignment;
|
diffObject.verticalAlignment = diffEvent.verticalAlignment;
|
||||||
}
|
}
|
||||||
if (textStyle != diffEvent.textStyle) {
|
if (!textStyles.equals(diffEvent.textStyles)) {
|
||||||
diffObject.textStyle = diffEvent.textStyle;
|
diffObject.textStyles = diffEvent.textStyles;
|
||||||
}
|
}
|
||||||
return diffObject;
|
return diffObject;
|
||||||
}
|
}
|
||||||
|
@ -164,8 +166,8 @@ public class DrawStringEvent extends AbstractRemoteGraphicsRenderEvent {
|
||||||
if (diffObject.text != null) {
|
if (diffObject.text != null) {
|
||||||
text = diffObject.text;
|
text = diffObject.text;
|
||||||
}
|
}
|
||||||
if (diffObject.textStyle != null) {
|
if (diffObject.textStyles != null) {
|
||||||
textStyle = diffObject.textStyle;
|
textStyles = diffObject.textStyles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +180,7 @@ public class DrawStringEvent extends AbstractRemoteGraphicsRenderEvent {
|
||||||
this.xOrColors = string.basics.xOrColors;
|
this.xOrColors = string.basics.xOrColors;
|
||||||
this.horizontalAlignment = string.horizontalAlignment;
|
this.horizontalAlignment = string.horizontalAlignment;
|
||||||
this.verticalAlignment = string.verticallAlignment;
|
this.verticalAlignment = string.verticallAlignment;
|
||||||
this.textStyle = string.textStyle;
|
this.textStyles = string.getTextStyles();
|
||||||
this.magnification = string.magnification;
|
this.magnification = string.magnification;
|
||||||
this.point = new double[] { string.basics.x, string.basics.y,
|
this.point = new double[] { string.basics.x, string.basics.y,
|
||||||
string.basics.z };
|
string.basics.z };
|
||||||
|
@ -196,7 +198,9 @@ public class DrawStringEvent extends AbstractRemoteGraphicsRenderEvent {
|
||||||
ds.shadowColor = shadowColor;
|
ds.shadowColor = shadowColor;
|
||||||
ds.horizontalAlignment = horizontalAlignment;
|
ds.horizontalAlignment = horizontalAlignment;
|
||||||
ds.verticallAlignment = verticalAlignment;
|
ds.verticallAlignment = verticalAlignment;
|
||||||
ds.textStyle = textStyle;
|
for (TextStyle textStyle : textStyles) {
|
||||||
|
ds.addTextStyle(textStyle);
|
||||||
|
}
|
||||||
ds.magnification = magnification;
|
ds.magnification = magnification;
|
||||||
ds.setCoordinates(point[0], point[1], point[2]);
|
ds.setCoordinates(point[0], point[1], point[2]);
|
||||||
ds.rotation = rotation;
|
ds.rotation = rotation;
|
||||||
|
@ -296,16 +300,16 @@ public class DrawStringEvent extends AbstractRemoteGraphicsRenderEvent {
|
||||||
/**
|
/**
|
||||||
* @return the textStyle
|
* @return the textStyle
|
||||||
*/
|
*/
|
||||||
public TextStyle getTextStyle() {
|
public EnumSet<TextStyle> getTextStyles() {
|
||||||
return textStyle;
|
return textStyles;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param textStyle
|
* @param textStyle
|
||||||
* the textStyle to set
|
* the textStyle to set
|
||||||
*/
|
*/
|
||||||
public void setTextStyle(TextStyle textStyle) {
|
public void setTextStyle(EnumSet<TextStyle> textStyles) {
|
||||||
this.textStyle = textStyle;
|
this.textStyles = textStyles;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -435,7 +439,7 @@ public class DrawStringEvent extends AbstractRemoteGraphicsRenderEvent {
|
||||||
return false;
|
return false;
|
||||||
if (!Arrays.equals(text, other.text))
|
if (!Arrays.equals(text, other.text))
|
||||||
return false;
|
return false;
|
||||||
if (textStyle != other.textStyle)
|
if (!textStyles.equals(other.textStyles))
|
||||||
return false;
|
return false;
|
||||||
if (verticalAlignment != other.verticalAlignment)
|
if (verticalAlignment != other.verticalAlignment)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -30,6 +30,7 @@ import java.nio.FloatBuffer;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -105,41 +106,45 @@ import com.sun.opengl.util.j2d.TextRenderer;
|
||||||
*
|
*
|
||||||
* SOFTWARE HISTORY
|
* SOFTWARE HISTORY
|
||||||
*
|
*
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------- -------- ----------- -----------------------------------------
|
||||||
* 7/1/06 chammack Initial Creation.
|
* Jul 01, 2006 chammack Initial Creation.
|
||||||
* 7/24/07 njensen Colormaps can reload in drawRaster().
|
* Jul 24, 2007 njensen Colormaps can reload in drawRaster().
|
||||||
* 10/01/07 467 brockwoo Fix for disabling interpolation of plot data textures
|
* Oct 01, 2007 467 brockwoo Fix for disabling interpolation of plot
|
||||||
* 10/16/07 468 njensen drawString() supports rotation.
|
* data textures
|
||||||
* 03/18/08 chammack Improve legend rendering
|
* Oct 16, 2007 468 njensen drawString() supports rotation.
|
||||||
* 03/12/09 2092 njensen Added offscreen rendering support
|
* Mar 18, 2008 chammack Improve legend rendering
|
||||||
* 07/01/10 6146 bkowal The offset that is needed to set the "Y" coordinate
|
* Mar 12, 2009 2092 njensen Added offscreen rendering support
|
||||||
* of the legend text that is drawn is now calculated based on
|
* Jul 01, 2010 6146 bkowal The offset that is needed to set the
|
||||||
* the font size rather than being hard-coded.
|
* "Y" coordinate of the legend
|
||||||
* 07/08/10 6146 bkowal The font size will now be adjusted automatically by comparing
|
* text that is drawn is now calculated based
|
||||||
* the current size of the pane of interest to the overall
|
* on the font size rather than being
|
||||||
* size of the screen.
|
* hard-coded.
|
||||||
* 07/19/10 5952 bkowal GLTarget will now check for the existence of updated extents
|
* Jul 08, 2010 6146 bkowal The font size will now be adjusted
|
||||||
* before drawing. A method has also been added to notify
|
* automatically by comparing the current
|
||||||
* GLTarget of when there are updated extents to load.
|
* size of the pane of interest to the
|
||||||
* Feb 14, 2013 1616 bsteffen Add option for interpolation of colormap
|
* overall size of the screen.
|
||||||
* parameters, disable colormap
|
* Jul 19, 2010 5952 bkowal GLTarget will now check for the existence
|
||||||
* interpolation by default.
|
* of updated extents before drawing. A
|
||||||
* Apr 18, 2013 1638 mschenke Made string rendering always occur in canvas space so
|
* method has also been added to notify
|
||||||
* strings are always readable despite extent
|
* GLTarget of when there are updated extents
|
||||||
* May 28, 2013 1638 mschenke Made sure {@link TextStyle#BLANKED} text is drawing correct size
|
* to load.
|
||||||
* box around text
|
* Feb 14, 2013 1616 bsteffen Add option for interpolation of colormap
|
||||||
* Nov 4, 2013 2492 mschenke Switched colormap drawing to use 1D texture object for alpha mask
|
* parameters, disable colormap interpolation
|
||||||
* Mar 3, 2014 2804 mschenke Added clipping pane field to only setup if changed
|
* by default.
|
||||||
|
* Apr 18, 2013 1638 mschenke Made string rendering always occur in
|
||||||
|
* canvas space so strings are always
|
||||||
|
* readable despite extent
|
||||||
|
* May 28, 2013 1638 mschenke Made sure {@link TextStyle#BLANKED} text
|
||||||
|
* is drawing correct size box around text
|
||||||
|
* Nov 04, 2013 2492 mschenke Switched colormap drawing to use 1D
|
||||||
|
* texture object for alpha mask
|
||||||
|
* Mar 03, 2014 2804 mschenke Added clipping pane field to only setup
|
||||||
|
* if changed
|
||||||
|
* Apr 04, 2014 2920 bsteffen Allow strings to use mulitple styles.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* TODO The current code draws "flat" objects (circles, arcs, strings, etc...)
|
|
||||||
* on the plane z = the given z argument. Eventually, these objects should be
|
|
||||||
* oriented on a plane parallel to the camera's plane at the time they are
|
|
||||||
* drawn. For strings, we may want the plane they are drawn on to follow the
|
|
||||||
* camera plane as it moves, so that they are always readable to the user.
|
|
||||||
*
|
|
||||||
* @author chammack
|
* @author chammack
|
||||||
* @version 1
|
* @version 1
|
||||||
*
|
*
|
||||||
|
@ -1871,12 +1876,14 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
|
||||||
|
|
||||||
// This loop just draws the box or a blank rectangle.
|
// This loop just draws the box or a blank rectangle.
|
||||||
for (DrawableString dString : parameters) {
|
for (DrawableString dString : parameters) {
|
||||||
switch (dString.textStyle) {
|
EnumSet<TextStyle> textStyles = dString.getTextStyles();
|
||||||
case BOXED:
|
boolean boxed = textStyles.contains(TextStyle.BOXED);
|
||||||
case BLANKED:
|
boolean blanked = textStyles.contains(TextStyle.BLANKED);
|
||||||
case UNDERLINE:
|
boolean underline = textStyles.contains(TextStyle.UNDERLINE);
|
||||||
case OVERLINE:
|
boolean overline = textStyles.contains(TextStyle.OVERLINE);
|
||||||
case STRIKETHROUGH:
|
boolean strikethrough = textStyles
|
||||||
|
.contains(TextStyle.STRIKETHROUGH);
|
||||||
|
if (boxed || blanked || underline || overline || strikethrough) {
|
||||||
double yPos = dString.basics.y;
|
double yPos = dString.basics.y;
|
||||||
VerticalAlignment verticalAlignment = dString.verticallAlignment;
|
VerticalAlignment verticalAlignment = dString.verticallAlignment;
|
||||||
double fontPercentage = this
|
double fontPercentage = this
|
||||||
|
@ -1927,15 +1934,14 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
|
||||||
double x2 = xy[0] + width + scaleX;
|
double x2 = xy[0] + width + scaleX;
|
||||||
double y2 = (xy[1] - diff) + height + scaleY;
|
double y2 = (xy[1] - diff) + height + scaleY;
|
||||||
|
|
||||||
if (dString.textStyle == TextStyle.BOXED
|
if (boxed || blanked) {
|
||||||
|| dString.textStyle == TextStyle.BLANKED) {
|
|
||||||
gl.glPolygonMode(GL.GL_BACK, GL.GL_FILL);
|
gl.glPolygonMode(GL.GL_BACK, GL.GL_FILL);
|
||||||
if (dString.textStyle == TextStyle.BOXED
|
if (boxed && dString.boxColor != null) {
|
||||||
&& dString.boxColor != null) {
|
|
||||||
gl.glColor4d(dString.boxColor.red / 255.0,
|
gl.glColor4d(dString.boxColor.red / 255.0,
|
||||||
dString.boxColor.green / 255.0,
|
dString.boxColor.green / 255.0,
|
||||||
dString.boxColor.blue / 255.0, alpha);
|
dString.boxColor.blue / 255.0, alpha);
|
||||||
} else {
|
}
|
||||||
|
if (blanked) {
|
||||||
gl.glColor4d(backgroundColor.red / 255.0,
|
gl.glColor4d(backgroundColor.red / 255.0,
|
||||||
backgroundColor.green / 255.0,
|
backgroundColor.green / 255.0,
|
||||||
backgroundColor.blue / 255.0, alpha);
|
backgroundColor.blue / 255.0, alpha);
|
||||||
|
@ -1944,10 +1950,7 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
|
||||||
gl.glRectd(x1, y2, x2, y1);
|
gl.glRectd(x1, y2, x2, y1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dString.textStyle == TextStyle.BOXED
|
if (boxed || underline || overline || strikethrough) {
|
||||||
|| dString.textStyle == TextStyle.UNDERLINE
|
|
||||||
|| dString.textStyle == TextStyle.OVERLINE
|
|
||||||
|| dString.textStyle == TextStyle.STRIKETHROUGH) {
|
|
||||||
gl.glPolygonMode(GL.GL_BACK, GL.GL_LINE);
|
gl.glPolygonMode(GL.GL_BACK, GL.GL_LINE);
|
||||||
|
|
||||||
RGB color = dString.getColors()[c];
|
RGB color = dString.getColors()[c];
|
||||||
|
@ -1958,20 +1961,29 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
|
||||||
color.green / 255.0, color.blue / 255.0,
|
color.green / 255.0, color.blue / 255.0,
|
||||||
alpha);
|
alpha);
|
||||||
|
|
||||||
if (dString.textStyle == TextStyle.BOXED) {
|
if (boxed) {
|
||||||
gl.glLineWidth(2);
|
gl.glLineWidth(2);
|
||||||
gl.glRectd(x1, y2, x2, y1);
|
gl.glRectd(x1, y2, x2, y1);
|
||||||
} else {
|
}
|
||||||
|
if (underline) {
|
||||||
gl.glLineWidth(1);
|
gl.glLineWidth(1);
|
||||||
double percent;
|
double lineY = y1 + (y2 - y1) * .2;
|
||||||
if (dString.textStyle == TextStyle.UNDERLINE) {
|
gl.glBegin(GL.GL_LINES);
|
||||||
percent = .2;
|
gl.glVertex2d(x1, lineY);
|
||||||
} else if (dString.textStyle == TextStyle.OVERLINE) {
|
gl.glVertex2d(x2, lineY);
|
||||||
percent = 1.;
|
gl.glEnd();
|
||||||
} else { // TextStyle.STRIKETHROUGH
|
}
|
||||||
percent = .5;
|
if (overline) {
|
||||||
}
|
gl.glLineWidth(1);
|
||||||
double lineY = y1 + (y2 - y1) * percent;
|
double lineY = y1 + (y2 - y1);
|
||||||
|
gl.glBegin(GL.GL_LINES);
|
||||||
|
gl.glVertex2d(x1, lineY);
|
||||||
|
gl.glVertex2d(x2, lineY);
|
||||||
|
gl.glEnd();
|
||||||
|
}
|
||||||
|
if (strikethrough) {
|
||||||
|
gl.glLineWidth(1);
|
||||||
|
double lineY = y1 + (y2 - y1) * .5;
|
||||||
gl.glBegin(GL.GL_LINES);
|
gl.glBegin(GL.GL_LINES);
|
||||||
gl.glVertex2d(x1, lineY);
|
gl.glVertex2d(x1, lineY);
|
||||||
gl.glVertex2d(x2, lineY);
|
gl.glVertex2d(x2, lineY);
|
||||||
|
@ -1991,9 +2003,6 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
|
||||||
gl.glRotated(-dString.rotation, 0.0, 0.0, 1.0);
|
gl.glRotated(-dString.rotation, 0.0, 0.0, 1.0);
|
||||||
gl.glTranslated(-rotatedPoint[0], -rotatedPoint[1], 0.0);
|
gl.glTranslated(-rotatedPoint[0], -rotatedPoint[1], 0.0);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2016,7 +2025,7 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
|
||||||
"Font was not prepared using GLTarget");
|
"Font was not prepared using GLTarget");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dString.rotation != 0.0 && rotatedPoint == null) {
|
if (dString.rotation != 0.0) {
|
||||||
if (textRenderer != null) {
|
if (textRenderer != null) {
|
||||||
textRenderer.flush();
|
textRenderer.flush();
|
||||||
}
|
}
|
||||||
|
@ -2097,7 +2106,7 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
|
||||||
color.green / 255.0f, color.blue / 255.0f,
|
color.green / 255.0f, color.blue / 255.0f,
|
||||||
alpha);
|
alpha);
|
||||||
}
|
}
|
||||||
if (dString.textStyle == TextStyle.WORD_WRAP) {
|
if (dString.getTextStyles().contains(TextStyle.WORD_WRAP)) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int j = -1;
|
int j = -1;
|
||||||
float y = xy[1];
|
float y = xy[1];
|
||||||
|
@ -2119,7 +2128,8 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
|
||||||
textRenderer.draw3D(string.substring(i), x, y, 0.0f,
|
textRenderer.draw3D(string.substring(i), x, y, 0.0f,
|
||||||
scaleY);
|
scaleY);
|
||||||
|
|
||||||
} else if (dString.textStyle == TextStyle.DROP_SHADOW) {
|
} else if (dString.getTextStyles().contains(
|
||||||
|
TextStyle.DROP_SHADOW)) {
|
||||||
RGB shadowColor = dString.shadowColor;
|
RGB shadowColor = dString.shadowColor;
|
||||||
textRenderer.setColor(shadowColor.red / 255.0f,
|
textRenderer.setColor(shadowColor.red / 255.0f,
|
||||||
shadowColor.green / 255.0f,
|
shadowColor.green / 255.0f,
|
||||||
|
|
Loading…
Add table
Reference in a new issue