Omaha #3489 Replace Raytheon plugin calls to deprecated IGraphicsTarget.getStringBounds()
Change-Id: Ie4c6093ff96e88332b719b9f88434bdd128770ea Former-commit-id:1b5b707601
[formerly 331b5994cc4bcd95138b15461b5040004f03d3fd] Former-commit-id:7d82d522e4
This commit is contained in:
parent
824906f4e0
commit
942962b61f
9 changed files with 79 additions and 68 deletions
|
@ -48,6 +48,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Sep 25, 2009 3099 bsteffen Initial creation
|
||||
* Sep 28, 2009 3099 bsteffen Updated to conform with common SigWxResource
|
||||
* Jul 29, 2014 3465 mapeters Updated deprecated drawStrings() calls.
|
||||
* Aug 04, 2014 3489 mapeters Updated deprecated getStringBounds() calls.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -138,15 +139,12 @@ public class SigWxCatResource extends SigWxPolygonResource {
|
|||
|
||||
private double[] getTextDimensions(IGraphicsTarget target, PointDataView pdv) {
|
||||
// Calculate the height and Width of the text box
|
||||
double textWidth = 0;
|
||||
double textHeight = 0;
|
||||
for (String line : getTextLines(pdv)) {
|
||||
Rectangle2D rect = target.getStringBounds(font, line);
|
||||
if (rect.getWidth() > textWidth) {
|
||||
textWidth = rect.getWidth();
|
||||
}
|
||||
textHeight += rect.getHeight() + 1;
|
||||
}
|
||||
String[] textLines = getTextLines(pdv);
|
||||
DrawableString lines = new DrawableString(textLines);
|
||||
lines.font = font;
|
||||
Rectangle2D rect = target.getStringsBounds(lines);
|
||||
double textWidth = rect.getWidth();
|
||||
double textHeight = rect.getHeight() + textLines.length;
|
||||
return new double[] { textWidth, textHeight };
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Sep 25, 2009 3099 bsteffen Initial creation
|
||||
* Sep 28, 2009 3099 bsteffen Updated to conform with common SigWxResource
|
||||
* Jul 29, 2014 3465 mapeters Updated deprecated drawStrings() calls.
|
||||
* Aug 04, 2014 3489 mapeters Updated deprecated getStringBounds() calls.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -236,15 +237,12 @@ public class SigWxCloudsResource extends SigWxPolygonResource {
|
|||
|
||||
private double[] getTextDimensions(IGraphicsTarget target, PointDataView pdv) {
|
||||
// Calculate the height and Width of the text box
|
||||
double textWidth = 0;
|
||||
double textHeight = 0;
|
||||
for (String line : getTextLines(pdv)) {
|
||||
Rectangle2D rect = target.getStringBounds(font, line);
|
||||
if (rect.getWidth() > textWidth) {
|
||||
textWidth = rect.getWidth();
|
||||
}
|
||||
textHeight += rect.getHeight() + 1;
|
||||
}
|
||||
String[] textLines = getTextLines(pdv);
|
||||
DrawableString lines = new DrawableString(textLines);
|
||||
lines.font = font;
|
||||
Rectangle2D rect = target.getStringsBounds(lines);
|
||||
double textWidth = rect.getWidth();
|
||||
double textHeight = rect.getHeight() + textLines.length;
|
||||
return new double[] { textWidth, textHeight };
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Sep 28, 2009 3099 bsteffen Updated to conform with common SigWxResource
|
||||
* Jul 29, 2014 3465 mapeters Updated deprecated drawString() and
|
||||
* drawStrings() calls.
|
||||
* Aug 04, 2014 3489 mapeters Updated deprecated getStringBounds() calls.
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
|
@ -339,8 +340,9 @@ public class SigWxJetStreamResource extends SigWxResource {
|
|||
+ SigWxCommon.format(topHgt, format);
|
||||
|
||||
double tmpX = locationPixel[0];
|
||||
double width = target.getStringBounds(font, depthStr)
|
||||
.getWidth()
|
||||
DrawableString depth = new DrawableString(depthStr);
|
||||
depth.font = font;
|
||||
double width = target.getStringsBounds(depth).getWidth()
|
||||
* getScale(paintProps)[1];
|
||||
if (halignLevel == HorizontalAlignment.LEFT) {
|
||||
tmpX += width / 2;
|
||||
|
|
|
@ -70,6 +70,7 @@ import com.vividsolutions.jts.geom.Point;
|
|||
* Aug 23, 2012 1096 njensen Fixed memory leaks
|
||||
* Dec 20, 2012 DCS 135 tk Changes for CCFP 2010 and 2012 TIN's
|
||||
* Jul 29, 2014 3465 mapeters Updated deprecated drawStrings() calls.
|
||||
* Aug 04, 2014 3489 mapeters Updated deprecated getStringBounds() calls.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -420,15 +421,11 @@ public class CcfpResource extends
|
|||
|
||||
// Determine the dimensions of the text lines;
|
||||
String[] lines = getFormattedData(record);
|
||||
double maxWidth = 0;
|
||||
double height = 0;
|
||||
for (String line : lines) {
|
||||
Rectangle2D rect = target.getStringBounds(null, line);
|
||||
if (rect.getWidth() > maxWidth) {
|
||||
maxWidth = rect.getWidth();
|
||||
height = rect.getHeight() + 3;
|
||||
}
|
||||
}
|
||||
DrawableString string = new DrawableString(lines);
|
||||
Rectangle2D rect = target.getStringsBounds(string);
|
||||
double maxWidth = rect.getWidth();
|
||||
double height = rect.getHeight() / lines.length + 3;
|
||||
|
||||
// This point should be the center left on the box
|
||||
double[] pt = descriptor.worldToPixel(new double[] {
|
||||
record.getBoxLong(), record.getBoxLat() });
|
||||
|
@ -442,7 +439,7 @@ public class CcfpResource extends
|
|||
{ x1, y1 } };
|
||||
frame.zoomDependentShapes.addLineSegment(box);
|
||||
|
||||
// Calcualte the center of the box and the polygon
|
||||
// Calculate the center of the box and the polygon
|
||||
Coordinate polyCenterLL = record.getLocation().getGeometry()
|
||||
.getCentroid().getCoordinate();
|
||||
double[] polyCenter = descriptor.worldToPixel(new double[] {
|
||||
|
|
|
@ -51,6 +51,7 @@ import com.raytheon.viz.ui.editor.IMultiPaneEditor;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 20, 2010 mschenke Initial creation
|
||||
* Aug 04, 2014 3489 mapeters Updated deprecated getStringBounds() calls.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -63,19 +64,19 @@ public class D2DSelectedPaneResource extends
|
|||
|
||||
protected static final int LEFT_OFFSET = 6;
|
||||
|
||||
protected static final int BOTTOM_OFFEST = 4;
|
||||
protected static final int BOTTOM_OFFSET = 4;
|
||||
|
||||
protected static final RGB Lcolor = new RGB(255, 255, 0);
|
||||
protected static final RGB L_COLOR = new RGB(255, 255, 0);
|
||||
|
||||
protected static final RGB Icolor = new RGB(0, 255, 0);
|
||||
protected static final RGB I_COLOR = new RGB(0, 255, 0);
|
||||
|
||||
protected static final RGB PlusColor = new RGB(111, 225, 249);
|
||||
protected static final RGB PLUS_COLOR = new RGB(111, 225, 249);
|
||||
|
||||
private DrawableString L;
|
||||
private DrawableString stringL;
|
||||
|
||||
private DrawableString I;
|
||||
private DrawableString stringI;
|
||||
|
||||
private DrawableString Plus;
|
||||
private DrawableString plus;
|
||||
|
||||
protected IFont font;
|
||||
|
||||
|
@ -129,37 +130,39 @@ public class D2DSelectedPaneResource extends
|
|||
double ratioY = extent.getHeight()
|
||||
/ paintProps.getCanvasBounds().height;
|
||||
|
||||
L.basics.x = I.basics.x = Plus.basics.x = paintProps.getView()
|
||||
stringL.basics.x = stringI.basics.x = plus.basics.x = paintProps
|
||||
.getView()
|
||||
.getExtent().getMinX()
|
||||
+ (LEFT_OFFSET * ratioX);
|
||||
L.basics.y = I.basics.y = Plus.basics.y = paintProps.getView()
|
||||
stringL.basics.y = stringI.basics.y = plus.basics.y = paintProps
|
||||
.getView()
|
||||
.getExtent().getMaxY()
|
||||
- (BOTTOM_OFFEST * ratioY);
|
||||
- (BOTTOM_OFFSET * ratioY);
|
||||
|
||||
if (editor.getNumberofPanes() > 1
|
||||
&& editor.isSelectedPane(IMultiPaneEditor.LOAD_ACTION,
|
||||
myPane)) {
|
||||
target.clearClippingPlane();
|
||||
target.drawStrings(L);
|
||||
target.drawStrings(stringL);
|
||||
if (editor.isSelectedPane(IMultiPaneEditor.IMAGE_ACTION,
|
||||
myPane)) {
|
||||
I.basics.y -= (target.getStringBounds(font, "L")
|
||||
.getHeight() + BOTTOM_OFFEST)
|
||||
stringI.basics.y -= (target.getStringsBounds(stringL)
|
||||
.getHeight() + BOTTOM_OFFSET)
|
||||
* extent.getHeight()
|
||||
/ paintProps.getCanvasBounds().height;
|
||||
target.drawStrings(I);
|
||||
target.drawStrings(stringI);
|
||||
}
|
||||
target.setupClippingPlane(extent);
|
||||
} else if (editor.getNumberofPanes() > 1
|
||||
&& editor.displayedPaneCount() == 1) {
|
||||
target.clearClippingPlane();
|
||||
target.drawStrings(Plus);
|
||||
target.drawStrings(plus);
|
||||
target.setupClippingPlane(extent);
|
||||
} else if (editor.getNumberofPanes() > 1
|
||||
&& editor.isSelectedPane(IMultiPaneEditor.IMAGE_ACTION,
|
||||
myPane)) {
|
||||
target.clearClippingPlane();
|
||||
target.drawStrings(I);
|
||||
target.drawStrings(stringI);
|
||||
target.setupClippingPlane(extent);
|
||||
}
|
||||
}
|
||||
|
@ -178,12 +181,14 @@ public class D2DSelectedPaneResource extends
|
|||
font = target.initializeFont(Font.MONOSPACED, 24,
|
||||
new Style[] { Style.BOLD });
|
||||
|
||||
L = new DrawableString("L", Lcolor);
|
||||
I = new DrawableString("I", Icolor);
|
||||
Plus = new DrawableString("+", PlusColor);
|
||||
stringL = new DrawableString("L", L_COLOR);
|
||||
stringI = new DrawableString("I", I_COLOR);
|
||||
plus = new DrawableString("+", PLUS_COLOR);
|
||||
|
||||
L.font = I.font = Plus.font = font;
|
||||
L.textStyle = I.textStyle = Plus.textStyle = TextStyle.DROP_SHADOW;
|
||||
stringL.font = stringI.font = plus.font = font;
|
||||
stringL.addTextStyle(TextStyle.DROP_SHADOW);
|
||||
stringI.addTextStyle(TextStyle.DROP_SHADOW);
|
||||
plus.addTextStyle(TextStyle.DROP_SHADOW);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,6 +32,7 @@ import java.nio.channels.FileChannel.MapMode;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.geotools.coverage.grid.GeneralGridGeometry;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
|
||||
|
@ -75,6 +76,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Jul 28, 2014 3397 bclement switched to non deprecated version of createWireframeShape()
|
||||
* now closes on FileInputStream instead of FileChannel in initInternal()
|
||||
* Jul 29, 2014 3465 mapeters Updated deprecated drawString() calls.
|
||||
* Aug 04, 2014 3489 mapeters Updated deprecated getStringBounds() calls.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -319,7 +321,10 @@ public class BCDResource extends
|
|||
font = target.initializeFont(target.getDefaultFont()
|
||||
.getFontName(), (float) (10 * magnification), null);
|
||||
}
|
||||
Rectangle2D charSize = target.getStringBounds(font, "N");
|
||||
|
||||
DrawableString stringN = new DrawableString("N");
|
||||
stringN.font = font;
|
||||
Rectangle2D charSize = target.getStringsBounds(stringN);
|
||||
double charWidth = charSize.getWidth();
|
||||
|
||||
double minSepDist = metersPerPixel / 1000.0 / density * charWidth;
|
||||
|
@ -333,14 +338,14 @@ public class BCDResource extends
|
|||
IView view = paintProps.getView();
|
||||
|
||||
List<DrawableString> strings = new ArrayList<DrawableString>();
|
||||
RGB color = getCapability(ColorableCapability.class).getColor();
|
||||
for (BcxLabel p : labels) {
|
||||
if (p.pixel == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (view.isVisible(p.pixel) && p.distance >= minSepDist) {
|
||||
DrawableString string = new DrawableString(p.label,
|
||||
getCapability(ColorableCapability.class).getColor());
|
||||
DrawableString string = new DrawableString(p.label, color);
|
||||
string.font = font;
|
||||
string.setCoordinates(p.pixel[0], p.pixel[1]);
|
||||
string.horizontalAlignment = HorizontalAlignment.CENTER;
|
||||
|
|
|
@ -53,6 +53,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Oct 2007 njensen Major refactor
|
||||
* 24Jul2014 3429 mapeters Updated deprecated drawLine() calls.
|
||||
* 29Jul2014 3465 mapeters Updated deprecated drawString() calls.
|
||||
* 04Aug2014 3489 mapeters Updated deprecated getStringBounds() calls.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -138,11 +139,10 @@ public class NumberAxis extends Axis {
|
|||
double xPos = 0;
|
||||
double yPos = 0;
|
||||
|
||||
for (double labelVal : keys) {
|
||||
double width = target.getStringBounds(font,
|
||||
labeling.getLabel(labelVal)).getWidth();
|
||||
maxLabelWidth = Math.max(width, maxLabelWidth);
|
||||
}
|
||||
DrawableString yLabels = new DrawableString(labeling
|
||||
.getLabels().values().toArray(new String[0]));
|
||||
yLabels.font = font;
|
||||
maxLabelWidth = target.getStringsBounds(yLabels).getWidth();
|
||||
|
||||
maxLabelWidth *= paintProps.getView().getExtent().getWidth()
|
||||
/ paintProps.getCanvasBounds().width;
|
||||
|
@ -176,9 +176,11 @@ public class NumberAxis extends Axis {
|
|||
|
||||
if (drawTickmarksAtLabels) {
|
||||
double x = graphArea.x;
|
||||
DrawableString string = new DrawableString(
|
||||
labeling.getLabel(labelVal));
|
||||
string.font = font;
|
||||
double x2 = xPos
|
||||
+ target.getStringBounds(font,
|
||||
labeling.getLabel(labelVal))
|
||||
+ target.getStringsBounds(string)
|
||||
.getWidth();
|
||||
|
||||
DrawableLine line = new DrawableLine();
|
||||
|
@ -251,10 +253,10 @@ public class NumberAxis extends Axis {
|
|||
lines.add(line);
|
||||
}
|
||||
if (drawTickmarksAtLabels) {
|
||||
DrawableString string = new DrawableString(
|
||||
labeling.getLabel(labelVal));
|
||||
double y = yPos
|
||||
- target.getStringBounds(null,
|
||||
labeling.getLabel(labelVal))
|
||||
.getHeight();
|
||||
- target.getStringsBounds(string).getHeight();
|
||||
|
||||
DrawableLine line = new DrawableLine();
|
||||
line.setCoordinates(x, y);
|
||||
|
|
|
@ -69,7 +69,7 @@ import com.raytheon.viz.ui.cmenu.IContextMenuContributor;
|
|||
* by default.
|
||||
* Mar 3, 2014 2804 mschenke Set back up clipping pane
|
||||
* Jul 30, 2014 3465 mapeters Updated deprecated drawString() calls.
|
||||
*
|
||||
* Aug 04, 2014 3489 mapeters Updated deprecated getStringBounds() calls.
|
||||
* </pre>
|
||||
*
|
||||
* @author mpduff
|
||||
|
@ -153,7 +153,8 @@ public class HydroColorBarResource extends
|
|||
|
||||
scale = (screenExtent.getHeight() / paintProps.getCanvasBounds().height);
|
||||
|
||||
textHeight = target.getStringBounds(null, "0").getHeight() * scale;
|
||||
DrawableString string = new DrawableString("0");
|
||||
textHeight = target.getStringsBounds(string).getHeight() * scale;
|
||||
|
||||
padding = 3 * scale;
|
||||
textSpace = textHeight + padding;
|
||||
|
|
|
@ -61,6 +61,7 @@ import com.raytheon.viz.pointdata.StaticPlotInfoPV.SPIEntry;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 1/10/08 562 bphillip Initial Creation.
|
||||
* 8/04/14 3489 mapeters Updated deprecated getStringBounds() calls.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -147,7 +148,9 @@ public class SPIResource extends
|
|||
double screenToWorldRatio = paintProps.getCanvasBounds().width
|
||||
/ paintProps.getView().getExtent().getWidth();
|
||||
|
||||
Rectangle2D charSize = target.getStringBounds(font, "N");
|
||||
DrawableString n = new DrawableString("N");
|
||||
n.font = font;
|
||||
Rectangle2D charSize = target.getStringsBounds(n);
|
||||
double charWidth = charSize.getWidth();
|
||||
double charHeight = charSize.getHeight();
|
||||
|
||||
|
@ -157,7 +160,6 @@ public class SPIResource extends
|
|||
double minSepDist = (displayHintSize * (metersPerPixel / 1000.0))
|
||||
/ getCapability(DensityCapability.class).getDensity();
|
||||
|
||||
RGB color = getCapability(ColorableCapability.class).getColor();
|
||||
double offsetX = charWidth / 2.0 / screenToWorldRatio;
|
||||
double offsetY = charHeight / screenToWorldRatio;
|
||||
HorizontalAlignment align = HorizontalAlignment.LEFT;
|
||||
|
@ -181,6 +183,7 @@ public class SPIResource extends
|
|||
SPIEntry entry = null;
|
||||
List<DrawableString> strings = new ArrayList<DrawableString>();
|
||||
List<double[]> points = new ArrayList<double[]>();
|
||||
RGB color = getCapability(ColorableCapability.class).getColor();
|
||||
for (Iterator<String> iterator = entries.keySet().iterator(); iterator
|
||||
.hasNext();) {
|
||||
key = iterator.next();
|
||||
|
|
Loading…
Add table
Reference in a new issue