use of javax.measure.quantity.Length in project com.revolsys.open by revolsys.
the class BaseStylePanel method newField.
@SuppressWarnings("unchecked")
protected Field newField(final String fieldName, final Class<?> fieldClass, final Object value) {
Field field;
if (fieldName.equals("visible")) {
this.visibleField = new CheckBox(fieldName, value);
field = this.visibleField;
} else if (fieldName.equals("textFaceName")) {
field = new FontChooserField(fieldName, (String) value);
} else if (fieldName.endsWith("HorizontalAlignment")) {
field = newHorizontalAlignmentField(fieldName, (String) value);
} else if (fieldName.endsWith("VerticalAlignment")) {
field = newVerticalAlignmentField(fieldName, (String) value);
} else if (fieldName.equals("lineCap")) {
field = newLineCapField((LineCap) value);
} else if (fieldName.equals("lineJoin")) {
field = newLineJoinField((LineJoin) value);
} else if (fieldName.equals("lineDashArray")) {
field = new DashField(fieldName, (List<Quantity<Length>>) value);
} else if (fieldName.equals("queryFilter")) {
final AbstractRecordLayer layer = getLayer();
field = new QueryFilterField(layer, fieldName, (String) value);
field.setFieldValue(value);
Property.addListener(field, fieldName, this);
} else if (fieldName.equals("marker")) {
field = new MarkerField(fieldName, value);
} else if (fieldName.endsWith("OrientationType")) {
final ComboBox<String> orientationTypeField = ComboBox.newComboBox(fieldName, "auto", "none");
orientationTypeField.setFieldValue(value);
field = orientationTypeField;
} else if (fieldName.equals("markerPlacementType")) {
final ComboBox<String> placementField = ComboBox.newComboBox(fieldName, "auto", "center", "vertex(0)", "vertex(n)", "vertices", "segment(0)", "segment(n)", "segments");
placementField.setFieldValue(value);
field = placementField;
} else if (fieldName.equals("textPlacementType")) {
final ComboBox<String> placementField = ComboBox.newComboBox(fieldName, "auto", "center", "vertex(0)", "vertex(n)", "segment(0)", "segment(n)");
placementField.setFieldValue(value);
field = placementField;
} else if (fieldName.endsWith("Scale")) {
field = newScaleField(fieldName, (Long) value);
} else if (Color.class.equals(fieldClass)) {
field = new ColorChooserField(fieldName, (Color) value);
} else if (Boolean.TYPE.equals(fieldClass) || Boolean.class.equals(fieldClass)) {
field = new CheckBox(fieldName, value);
} else if (Quantity.class.equals(fieldClass)) {
field = new LengthMeasureTextField(fieldName, (Quantity<Length>) value, CustomUnits.PIXEL);
} else {
field = new TextField(fieldName, value, 40);
}
return field;
}
use of javax.measure.quantity.Length in project com.revolsys.open by revolsys.
the class BaseStylePanel method addLengthMeasureField.
protected void addLengthMeasureField(final JPanel container, final Object object, final String fieldName) {
SwingUtil.addLabel(container, fieldName);
final Quantity<Length> value = Property.get(object, fieldName);
Unit<Length> unit;
if (value == null) {
unit = CustomUnits.PIXEL;
} else {
unit = value.getUnit();
}
final LengthMeasureTextField field = new LengthMeasureTextField(fieldName, value, unit);
Property.addListener(field, fieldName, this);
container.add(field);
}
use of javax.measure.quantity.Length in project com.revolsys.open by revolsys.
the class MeasureOverlay method setMeasureGeometry.
public void setMeasureGeometry(Geometry measureGeometry) {
if (measureGeometry == null) {
measureGeometry = EMPTY_GEOMETRY;
}
if (measureGeometry != this.measureGeometry) {
this.measureGeometry = measureGeometry;
if (measureGeometry == null) {
this.measureLabel = "";
} else {
Unit<Length> lengthUnit = Units.METRE;
final CoordinateSystem coordinateSystem = measureGeometry.getCoordinateSystem();
if (coordinateSystem instanceof ProjectedCoordinateSystem) {
lengthUnit = coordinateSystem.getLengthUnit();
}
final double length = measureGeometry.getLength(lengthUnit);
@SuppressWarnings("unchecked") final Unit<Area> areaUnit = (Unit<Area>) lengthUnit.multiply(lengthUnit);
final double area = measureGeometry.getArea(areaUnit);
final String unitString = lengthUnit.toString();
synchronized (MEASURE_FORMAT) {
final StringBuilder label = new StringBuilder();
final String lengthString = MEASURE_FORMAT.format(Doubles.makePrecise(100, length));
label.append(lengthString);
label.append(unitString);
if (this.measureDataType == DataTypes.POLYGON && measureGeometry instanceof Polygon) {
final String areaString = MEASURE_FORMAT.format(Doubles.makePrecise(100, area));
label.append(" \n");
label.append(areaString);
label.append(unitString);
label.append('\u00B2');
}
this.measureLabel = label.toString();
}
}
setXorGeometry(null);
}
}
use of javax.measure.quantity.Length in project com.revolsys.open by revolsys.
the class FixedScaleZoomMode method zoom.
/**
* Zoom the map to include the bounding box specified by the model coordinate
* pair.
*
* @param viewport The viewport.
* @param x1 The first x coordinate.
* @param y1 The first y coordinate.
* @param x2 The second x coordinate.
* @param y2 The second y coordinate.
*/
@Override
public void zoom(final ComponentViewport2D viewport, final double x1, final double y1, final double x2, final double y2) {
final double viewWidth = viewport.getViewWidthPixels();
final double viewHeight = viewport.getViewHeightPixels();
final double xc1 = Math.max(Math.min(x1, viewWidth - 1), 0);
final double yc1 = Math.max(Math.min(y1, viewHeight - 1), 0);
final double xc2 = Math.max(Math.min(x2, viewWidth - 1), 0);
final double yc2 = Math.max(Math.min(y2, viewHeight - 1), 0);
final BoundingBox boundingBox = viewport.getBoundingBox(xc1, yc1, xc2, yc2);
final double x = boundingBox.getCentreX();
final double y = boundingBox.getCentreY();
final Quantity<Length> modelWidth = boundingBox.getWidthLength();
double scale = Viewport2D.getScale(viewport.getViewWidthLength(), modelWidth);
scale = getNextScale(scale, false);
final double newScale = getBestScale(viewport, scale);
final BoundingBox boundingBox1 = viewport.getBoundingBox(x, y, newScale);
viewport.setBoundingBox(boundingBox1);
}
use of javax.measure.quantity.Length in project com.revolsys.open by revolsys.
the class ComponentViewport2D method getMaxScale.
public double getMaxScale() {
final BoundingBox areaBoundingBox = getGeometryFactory().getCoordinateSystem().getAreaBoundingBox();
final Quantity<Length> areaWidth = areaBoundingBox.getWidthLength();
final Quantity<Length> areaHeight = areaBoundingBox.getHeightLength();
final Quantity<Length> viewWidth = getViewWidthLength();
final Quantity<Length> viewHeight = getViewHeightLength();
final double maxHorizontalScale = getScale(viewWidth, areaWidth);
final double maxVerticalScale = getScale(viewHeight, areaHeight);
final double maxScale = Math.max(maxHorizontalScale, maxVerticalScale);
return maxScale;
}
Aggregations