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: de490ea582 [formerly 8583386e5f [formerly a1896437f432bcb360365d28a0ee7377cec565af]]
Former-commit-id: 8583386e5f
Former-commit-id: f3f2ec8843
This commit is contained in:
Ron Anderson 2014-08-29 10:54:04 -05:00
parent 30ef2a7667
commit 0bb6076cdc
2 changed files with 18 additions and 33 deletions

View file

@ -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()

View file

@ -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;