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:
Mark Peters 2014-08-05 14:30:06 -05:00
parent 824906f4e0
commit 942962b61f
9 changed files with 79 additions and 68 deletions

View file

@ -48,6 +48,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* Sep 25, 2009 3099 bsteffen Initial creation * Sep 25, 2009 3099 bsteffen Initial creation
* Sep 28, 2009 3099 bsteffen Updated to conform with common SigWxResource * Sep 28, 2009 3099 bsteffen Updated to conform with common SigWxResource
* Jul 29, 2014 3465 mapeters Updated deprecated drawStrings() calls. * Jul 29, 2014 3465 mapeters Updated deprecated drawStrings() calls.
* Aug 04, 2014 3489 mapeters Updated deprecated getStringBounds() calls.
* *
* </pre> * </pre>
* *
@ -138,15 +139,12 @@ public class SigWxCatResource extends SigWxPolygonResource {
private double[] getTextDimensions(IGraphicsTarget target, PointDataView pdv) { private double[] getTextDimensions(IGraphicsTarget target, PointDataView pdv) {
// Calculate the height and Width of the text box // Calculate the height and Width of the text box
double textWidth = 0; String[] textLines = getTextLines(pdv);
double textHeight = 0; DrawableString lines = new DrawableString(textLines);
for (String line : getTextLines(pdv)) { lines.font = font;
Rectangle2D rect = target.getStringBounds(font, line); Rectangle2D rect = target.getStringsBounds(lines);
if (rect.getWidth() > textWidth) { double textWidth = rect.getWidth();
textWidth = rect.getWidth(); double textHeight = rect.getHeight() + textLines.length;
}
textHeight += rect.getHeight() + 1;
}
return new double[] { textWidth, textHeight }; return new double[] { textWidth, textHeight };
} }

View file

@ -49,6 +49,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* Sep 25, 2009 3099 bsteffen Initial creation * Sep 25, 2009 3099 bsteffen Initial creation
* Sep 28, 2009 3099 bsteffen Updated to conform with common SigWxResource * Sep 28, 2009 3099 bsteffen Updated to conform with common SigWxResource
* Jul 29, 2014 3465 mapeters Updated deprecated drawStrings() calls. * Jul 29, 2014 3465 mapeters Updated deprecated drawStrings() calls.
* Aug 04, 2014 3489 mapeters Updated deprecated getStringBounds() calls.
* *
* </pre> * </pre>
* *
@ -236,15 +237,12 @@ public class SigWxCloudsResource extends SigWxPolygonResource {
private double[] getTextDimensions(IGraphicsTarget target, PointDataView pdv) { private double[] getTextDimensions(IGraphicsTarget target, PointDataView pdv) {
// Calculate the height and Width of the text box // Calculate the height and Width of the text box
double textWidth = 0; String[] textLines = getTextLines(pdv);
double textHeight = 0; DrawableString lines = new DrawableString(textLines);
for (String line : getTextLines(pdv)) { lines.font = font;
Rectangle2D rect = target.getStringBounds(font, line); Rectangle2D rect = target.getStringsBounds(lines);
if (rect.getWidth() > textWidth) { double textWidth = rect.getWidth();
textWidth = rect.getWidth(); double textHeight = rect.getHeight() + textLines.length;
}
textHeight += rect.getHeight() + 1;
}
return new double[] { textWidth, textHeight }; return new double[] { textWidth, textHeight };
} }

View file

@ -54,6 +54,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* Sep 28, 2009 3099 bsteffen Updated to conform with common SigWxResource * Sep 28, 2009 3099 bsteffen Updated to conform with common SigWxResource
* Jul 29, 2014 3465 mapeters Updated deprecated drawString() and * Jul 29, 2014 3465 mapeters Updated deprecated drawString() and
* drawStrings() calls. * drawStrings() calls.
* Aug 04, 2014 3489 mapeters Updated deprecated getStringBounds() calls.
* *
* *
* </pre> * </pre>
@ -339,8 +340,9 @@ public class SigWxJetStreamResource extends SigWxResource {
+ SigWxCommon.format(topHgt, format); + SigWxCommon.format(topHgt, format);
double tmpX = locationPixel[0]; double tmpX = locationPixel[0];
double width = target.getStringBounds(font, depthStr) DrawableString depth = new DrawableString(depthStr);
.getWidth() depth.font = font;
double width = target.getStringsBounds(depth).getWidth()
* getScale(paintProps)[1]; * getScale(paintProps)[1];
if (halignLevel == HorizontalAlignment.LEFT) { if (halignLevel == HorizontalAlignment.LEFT) {
tmpX += width / 2; tmpX += width / 2;

View file

@ -70,6 +70,7 @@ import com.vividsolutions.jts.geom.Point;
* Aug 23, 2012 1096 njensen Fixed memory leaks * Aug 23, 2012 1096 njensen Fixed memory leaks
* Dec 20, 2012 DCS 135 tk Changes for CCFP 2010 and 2012 TIN's * Dec 20, 2012 DCS 135 tk Changes for CCFP 2010 and 2012 TIN's
* Jul 29, 2014 3465 mapeters Updated deprecated drawStrings() calls. * Jul 29, 2014 3465 mapeters Updated deprecated drawStrings() calls.
* Aug 04, 2014 3489 mapeters Updated deprecated getStringBounds() calls.
* *
* </pre> * </pre>
* *
@ -420,15 +421,11 @@ public class CcfpResource extends
// Determine the dimensions of the text lines; // Determine the dimensions of the text lines;
String[] lines = getFormattedData(record); String[] lines = getFormattedData(record);
double maxWidth = 0; DrawableString string = new DrawableString(lines);
double height = 0; Rectangle2D rect = target.getStringsBounds(string);
for (String line : lines) { double maxWidth = rect.getWidth();
Rectangle2D rect = target.getStringBounds(null, line); double height = rect.getHeight() / lines.length + 3;
if (rect.getWidth() > maxWidth) {
maxWidth = rect.getWidth();
height = rect.getHeight() + 3;
}
}
// This point should be the center left on the box // This point should be the center left on the box
double[] pt = descriptor.worldToPixel(new double[] { double[] pt = descriptor.worldToPixel(new double[] {
record.getBoxLong(), record.getBoxLat() }); record.getBoxLong(), record.getBoxLat() });
@ -442,7 +439,7 @@ public class CcfpResource extends
{ x1, y1 } }; { x1, y1 } };
frame.zoomDependentShapes.addLineSegment(box); 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() Coordinate polyCenterLL = record.getLocation().getGeometry()
.getCentroid().getCoordinate(); .getCentroid().getCoordinate();
double[] polyCenter = descriptor.worldToPixel(new double[] { double[] polyCenter = descriptor.worldToPixel(new double[] {

View file

@ -51,6 +51,7 @@ import com.raytheon.viz.ui.editor.IMultiPaneEditor;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Dec 20, 2010 mschenke Initial creation * Dec 20, 2010 mschenke Initial creation
* Aug 04, 2014 3489 mapeters Updated deprecated getStringBounds() calls.
* *
* </pre> * </pre>
* *
@ -63,19 +64,19 @@ public class D2DSelectedPaneResource extends
protected static final int LEFT_OFFSET = 6; 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; protected IFont font;
@ -129,37 +130,39 @@ public class D2DSelectedPaneResource extends
double ratioY = extent.getHeight() double ratioY = extent.getHeight()
/ paintProps.getCanvasBounds().height; / 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() .getExtent().getMinX()
+ (LEFT_OFFSET * ratioX); + (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() .getExtent().getMaxY()
- (BOTTOM_OFFEST * ratioY); - (BOTTOM_OFFSET * ratioY);
if (editor.getNumberofPanes() > 1 if (editor.getNumberofPanes() > 1
&& editor.isSelectedPane(IMultiPaneEditor.LOAD_ACTION, && editor.isSelectedPane(IMultiPaneEditor.LOAD_ACTION,
myPane)) { myPane)) {
target.clearClippingPlane(); target.clearClippingPlane();
target.drawStrings(L); target.drawStrings(stringL);
if (editor.isSelectedPane(IMultiPaneEditor.IMAGE_ACTION, if (editor.isSelectedPane(IMultiPaneEditor.IMAGE_ACTION,
myPane)) { myPane)) {
I.basics.y -= (target.getStringBounds(font, "L") stringI.basics.y -= (target.getStringsBounds(stringL)
.getHeight() + BOTTOM_OFFEST) .getHeight() + BOTTOM_OFFSET)
* extent.getHeight() * extent.getHeight()
/ paintProps.getCanvasBounds().height; / paintProps.getCanvasBounds().height;
target.drawStrings(I); target.drawStrings(stringI);
} }
target.setupClippingPlane(extent); target.setupClippingPlane(extent);
} else if (editor.getNumberofPanes() > 1 } else if (editor.getNumberofPanes() > 1
&& editor.displayedPaneCount() == 1) { && editor.displayedPaneCount() == 1) {
target.clearClippingPlane(); target.clearClippingPlane();
target.drawStrings(Plus); target.drawStrings(plus);
target.setupClippingPlane(extent); target.setupClippingPlane(extent);
} else if (editor.getNumberofPanes() > 1 } else if (editor.getNumberofPanes() > 1
&& editor.isSelectedPane(IMultiPaneEditor.IMAGE_ACTION, && editor.isSelectedPane(IMultiPaneEditor.IMAGE_ACTION,
myPane)) { myPane)) {
target.clearClippingPlane(); target.clearClippingPlane();
target.drawStrings(I); target.drawStrings(stringI);
target.setupClippingPlane(extent); target.setupClippingPlane(extent);
} }
} }
@ -178,12 +181,14 @@ public class D2DSelectedPaneResource extends
font = target.initializeFont(Font.MONOSPACED, 24, font = target.initializeFont(Font.MONOSPACED, 24,
new Style[] { Style.BOLD }); new Style[] { Style.BOLD });
L = new DrawableString("L", Lcolor); stringL = new DrawableString("L", L_COLOR);
I = new DrawableString("I", Icolor); stringI = new DrawableString("I", I_COLOR);
Plus = new DrawableString("+", PlusColor); plus = new DrawableString("+", PLUS_COLOR);
L.font = I.font = Plus.font = font; stringL.font = stringI.font = plus.font = font;
L.textStyle = I.textStyle = Plus.textStyle = TextStyle.DROP_SHADOW; stringL.addTextStyle(TextStyle.DROP_SHADOW);
stringI.addTextStyle(TextStyle.DROP_SHADOW);
plus.addTextStyle(TextStyle.DROP_SHADOW);
} }
@Override @Override

View file

@ -32,6 +32,7 @@ import java.nio.channels.FileChannel.MapMode;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.swt.graphics.RGB;
import org.geotools.coverage.grid.GeneralGridGeometry; import org.geotools.coverage.grid.GeneralGridGeometry;
import org.opengis.referencing.crs.CoordinateReferenceSystem; 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() * Jul 28, 2014 3397 bclement switched to non deprecated version of createWireframeShape()
* now closes on FileInputStream instead of FileChannel in initInternal() * now closes on FileInputStream instead of FileChannel in initInternal()
* Jul 29, 2014 3465 mapeters Updated deprecated drawString() calls. * Jul 29, 2014 3465 mapeters Updated deprecated drawString() calls.
* Aug 04, 2014 3489 mapeters Updated deprecated getStringBounds() calls.
* *
* </pre> * </pre>
* *
@ -319,7 +321,10 @@ public class BCDResource extends
font = target.initializeFont(target.getDefaultFont() font = target.initializeFont(target.getDefaultFont()
.getFontName(), (float) (10 * magnification), null); .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 charWidth = charSize.getWidth();
double minSepDist = metersPerPixel / 1000.0 / density * charWidth; double minSepDist = metersPerPixel / 1000.0 / density * charWidth;
@ -333,14 +338,14 @@ public class BCDResource extends
IView view = paintProps.getView(); IView view = paintProps.getView();
List<DrawableString> strings = new ArrayList<DrawableString>(); List<DrawableString> strings = new ArrayList<DrawableString>();
RGB color = getCapability(ColorableCapability.class).getColor();
for (BcxLabel p : labels) { for (BcxLabel p : labels) {
if (p.pixel == null) { if (p.pixel == null) {
continue; continue;
} }
if (view.isVisible(p.pixel) && p.distance >= minSepDist) { if (view.isVisible(p.pixel) && p.distance >= minSepDist) {
DrawableString string = new DrawableString(p.label, DrawableString string = new DrawableString(p.label, color);
getCapability(ColorableCapability.class).getColor());
string.font = font; string.font = font;
string.setCoordinates(p.pixel[0], p.pixel[1]); string.setCoordinates(p.pixel[0], p.pixel[1]);
string.horizontalAlignment = HorizontalAlignment.CENTER; string.horizontalAlignment = HorizontalAlignment.CENTER;

View file

@ -53,6 +53,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* Oct 2007 njensen Major refactor * Oct 2007 njensen Major refactor
* 24Jul2014 3429 mapeters Updated deprecated drawLine() calls. * 24Jul2014 3429 mapeters Updated deprecated drawLine() calls.
* 29Jul2014 3465 mapeters Updated deprecated drawString() calls. * 29Jul2014 3465 mapeters Updated deprecated drawString() calls.
* 04Aug2014 3489 mapeters Updated deprecated getStringBounds() calls.
* *
* </pre> * </pre>
* *
@ -138,11 +139,10 @@ public class NumberAxis extends Axis {
double xPos = 0; double xPos = 0;
double yPos = 0; double yPos = 0;
for (double labelVal : keys) { DrawableString yLabels = new DrawableString(labeling
double width = target.getStringBounds(font, .getLabels().values().toArray(new String[0]));
labeling.getLabel(labelVal)).getWidth(); yLabels.font = font;
maxLabelWidth = Math.max(width, maxLabelWidth); maxLabelWidth = target.getStringsBounds(yLabels).getWidth();
}
maxLabelWidth *= paintProps.getView().getExtent().getWidth() maxLabelWidth *= paintProps.getView().getExtent().getWidth()
/ paintProps.getCanvasBounds().width; / paintProps.getCanvasBounds().width;
@ -176,9 +176,11 @@ public class NumberAxis extends Axis {
if (drawTickmarksAtLabels) { if (drawTickmarksAtLabels) {
double x = graphArea.x; double x = graphArea.x;
DrawableString string = new DrawableString(
labeling.getLabel(labelVal));
string.font = font;
double x2 = xPos double x2 = xPos
+ target.getStringBounds(font, + target.getStringsBounds(string)
labeling.getLabel(labelVal))
.getWidth(); .getWidth();
DrawableLine line = new DrawableLine(); DrawableLine line = new DrawableLine();
@ -251,10 +253,10 @@ public class NumberAxis extends Axis {
lines.add(line); lines.add(line);
} }
if (drawTickmarksAtLabels) { if (drawTickmarksAtLabels) {
DrawableString string = new DrawableString(
labeling.getLabel(labelVal));
double y = yPos double y = yPos
- target.getStringBounds(null, - target.getStringsBounds(string).getHeight();
labeling.getLabel(labelVal))
.getHeight();
DrawableLine line = new DrawableLine(); DrawableLine line = new DrawableLine();
line.setCoordinates(x, y); line.setCoordinates(x, y);

View file

@ -69,7 +69,7 @@ import com.raytheon.viz.ui.cmenu.IContextMenuContributor;
* by default. * by default.
* Mar 3, 2014 2804 mschenke Set back up clipping pane * Mar 3, 2014 2804 mschenke Set back up clipping pane
* Jul 30, 2014 3465 mapeters Updated deprecated drawString() calls. * Jul 30, 2014 3465 mapeters Updated deprecated drawString() calls.
* * Aug 04, 2014 3489 mapeters Updated deprecated getStringBounds() calls.
* </pre> * </pre>
* *
* @author mpduff * @author mpduff
@ -153,7 +153,8 @@ public class HydroColorBarResource extends
scale = (screenExtent.getHeight() / paintProps.getCanvasBounds().height); 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; padding = 3 * scale;
textSpace = textHeight + padding; textSpace = textHeight + padding;

View file

@ -61,6 +61,7 @@ import com.raytheon.viz.pointdata.StaticPlotInfoPV.SPIEntry;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* 1/10/08 562 bphillip Initial Creation. * 1/10/08 562 bphillip Initial Creation.
* 8/04/14 3489 mapeters Updated deprecated getStringBounds() calls.
* *
* </pre> * </pre>
* *
@ -147,7 +148,9 @@ public class SPIResource extends
double screenToWorldRatio = paintProps.getCanvasBounds().width double screenToWorldRatio = paintProps.getCanvasBounds().width
/ paintProps.getView().getExtent().getWidth(); / 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 charWidth = charSize.getWidth();
double charHeight = charSize.getHeight(); double charHeight = charSize.getHeight();
@ -157,7 +160,6 @@ public class SPIResource extends
double minSepDist = (displayHintSize * (metersPerPixel / 1000.0)) double minSepDist = (displayHintSize * (metersPerPixel / 1000.0))
/ getCapability(DensityCapability.class).getDensity(); / getCapability(DensityCapability.class).getDensity();
RGB color = getCapability(ColorableCapability.class).getColor();
double offsetX = charWidth / 2.0 / screenToWorldRatio; double offsetX = charWidth / 2.0 / screenToWorldRatio;
double offsetY = charHeight / screenToWorldRatio; double offsetY = charHeight / screenToWorldRatio;
HorizontalAlignment align = HorizontalAlignment.LEFT; HorizontalAlignment align = HorizontalAlignment.LEFT;
@ -181,6 +183,7 @@ public class SPIResource extends
SPIEntry entry = null; SPIEntry entry = null;
List<DrawableString> strings = new ArrayList<DrawableString>(); List<DrawableString> strings = new ArrayList<DrawableString>();
List<double[]> points = new ArrayList<double[]>(); List<double[]> points = new ArrayList<double[]>();
RGB color = getCapability(ColorableCapability.class).getColor();
for (Iterator<String> iterator = entries.keySet().iterator(); iterator for (Iterator<String> iterator = entries.keySet().iterator(); iterator
.hasNext();) { .hasNext();) {
key = iterator.next(); key = iterator.next();