From c317ab5eef9f3d482c541a880e4751eedb8a72c1 Mon Sep 17 00:00:00 2001 From: Ron Anderson Date: Fri, 29 Aug 2014 10:54:04 -0500 Subject: [PATCH] Omaha #3459 Ensure font is initialized before queryJob runs, Additional refactoring to someday allow ZoneSelectorResource to use more common code. Change-Id: I87e4d1a16b6086f4241e67bb1058bb096eb5e062 Former-commit-id: 0bb6076cdc0c065b756724a1291fddb07bf3cae2 [formerly f3f2ec8843a852717a0e9dacf739e2caa8362a8f] [formerly 8583386e5fd26b265ed7bc4265067155a13bf3e5] [formerly 0bb6076cdc0c065b756724a1291fddb07bf3cae2 [formerly f3f2ec8843a852717a0e9dacf739e2caa8362a8f] [formerly 8583386e5fd26b265ed7bc4265067155a13bf3e5] [formerly de490ea582e859082d6c4414b6d48cecce8ca496 [formerly 8583386e5fd26b265ed7bc4265067155a13bf3e5 [formerly a1896437f432bcb360365d28a0ee7377cec565af]]]] Former-commit-id: de490ea582e859082d6c4414b6d48cecce8ca496 Former-commit-id: 06dbcd69d63839183ed88c9cc2ad8510079042bc [formerly ae69665e50209bea8224ad58181dfc90fa47662e] [formerly 39b07ee71f914fcb7284dbe4733a3b9645faf975 [formerly 338672c03f2f3a45fbc415eb8e359ef9d2ecb01e]] Former-commit-id: e0bb2a385f25bd2eb5b08e0b6f5f02ee58b77b3c [formerly 39547874879882b10dc14ad1d200cbda65663ef4] Former-commit-id: 4a821c89b7ac88044d5aabd403ff855bab48ca91 --- .../gisdatastore/rsc/DataStoreResource.java | 28 ++++++++----------- .../ui/zoneselector/ZoneSelectorResource.java | 23 ++++----------- 2 files changed, 18 insertions(+), 33 deletions(-) diff --git a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/rsc/DataStoreResource.java b/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/rsc/DataStoreResource.java index 7a54ac05b0..d9f97242af 100644 --- a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/rsc/DataStoreResource.java +++ b/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/rsc/DataStoreResource.java @@ -75,7 +75,6 @@ import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle; import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle; import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment; import com.raytheon.uf.viz.core.PixelExtent; -import com.raytheon.uf.viz.core.drawables.IFont; import com.raytheon.uf.viz.core.drawables.IShadedShape; import com.raytheon.uf.viz.core.drawables.IWireframeShape; import com.raytheon.uf.viz.core.drawables.PaintProperties; @@ -841,8 +840,6 @@ public class DataStoreResource extends protected IWireframeShape highlightShape; - protected IFont font; - protected PixelExtent lastExtent; protected PixelExtent projExtent; @@ -1140,6 +1137,15 @@ public class DataStoreResource extends .getLabelField(); boolean isLabeled = labelField != null; + double labelMagnification = getCapability(MagnificationCapability.class) + .getMagnification(); + + if (font == null) { + font = aTarget.initializeFont(aTarget.getDefaultFont() + .getFontName(), (float) (10 * labelMagnification), null); + font.setSmoothing(false); + } + String shadingField = getCapability(ShadeableCapability.class) .getShadingField(); boolean isShaded = isPolygonal() && (shadingField != null); @@ -1217,12 +1223,8 @@ public class DataStoreResource extends highlightWidth, highlightStyle); } - double labelMagnification = getCapability(MagnificationCapability.class) - .getMagnification(); - if ((labels != null) && isLabeled && (labelMagnification != 0)) { - drawLabels(aTarget, paintProps, labelMagnification, - worldToScreenRatio); + drawLabels(aTarget, paintProps, worldToScreenRatio); } if (rubberBandExtent != null) { @@ -1270,14 +1272,8 @@ public class DataStoreResource extends } private void drawLabels(IGraphicsTarget aTarget, - PaintProperties paintProps, double labelMagnification, - double worldToScreenRatio) throws VizException { - if (font == null) { - font = aTarget.initializeFont(aTarget.getDefaultFont() - .getFontName(), (float) (10 * labelMagnification), null); - font.setSmoothing(false); - } - + PaintProperties paintProps, double worldToScreenRatio) + throws VizException { double offsetX = getCapability(LabelableCapability.class).getxOffset() * worldToScreenRatio; double offsetY = getCapability(LabelableCapability.class).getyOffset() diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/zoneselector/ZoneSelectorResource.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/zoneselector/ZoneSelectorResource.java index 1fb6908606..be9856a268 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/zoneselector/ZoneSelectorResource.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/zoneselector/ZoneSelectorResource.java @@ -35,7 +35,6 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.graphics.Rectangle; import org.geotools.coverage.grid.GeneralGridEnvelope; import org.geotools.coverage.grid.GridGeometry2D; import org.geotools.geometry.GeneralEnvelope; @@ -314,7 +313,7 @@ public class ZoneSelectorResource extends DbMapResource { Point point = poly.getInteriorPoint(); if (point.getCoordinate() != null) { LabelNode node = new LabelNode(zoneName, - point, req.target); + point, req.target, req.rsc.font); newLabels.add(node); } } @@ -698,21 +697,14 @@ public class ZoneSelectorResource extends DbMapResource { PaintProperties paintProps) throws VizException { this.target = aTarget; + if (font == null) { + font = GFEFonts.getFont(aTarget, 2); + } + PixelExtent screenExtent = (PixelExtent) paintProps.getView() .getExtent(); - // compute an estimate of degrees per pixel - double yc = screenExtent.getCenter()[1]; - double x1 = screenExtent.getMinX(); - double x2 = screenExtent.getMaxX(); - double[] c1 = descriptor.pixelToWorld(new double[] { x1, yc }); - double[] c2 = descriptor.pixelToWorld(new double[] { x2, yc }); - Rectangle canvasBounds = paintProps.getCanvasBounds(); - int screenWidth = canvasBounds.width; - double dppX = Math.abs(c2[0] - c1[0]) / screenWidth; - // System.out.println("c1:" + Arrays.toString(c1) + " c2:" - // + Arrays.toString(c2) + " dpp:" + dppX); - double simpLev = getSimpLev(dppX); + double simpLev = getSimpLev(paintProps); if ((simpLev < lastSimpLev) || (lastExtent == null) @@ -779,9 +771,6 @@ public class ZoneSelectorResource extends DbMapResource { } if ((labels != null) && (this.labelZones || this.labelZoneGroups)) { - if (font == null) { - font = GFEFonts.getFont(aTarget, 2); - } double worldToScreenRatio = paintProps.getView().getExtent() .getWidth() / paintProps.getCanvasBounds().width;