Search in sources :

Example 16 with Length

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;
}
Also used : FontChooserField(com.revolsys.swing.field.FontChooserField) ComboBox(com.revolsys.swing.field.ComboBox) ColorChooserField(com.revolsys.swing.field.ColorChooserField) Color(java.awt.Color) Quantity(javax.measure.Quantity) LengthMeasureTextField(com.revolsys.swing.field.LengthMeasureTextField) FontChooserField(com.revolsys.swing.field.FontChooserField) MarkerField(com.revolsys.swing.map.component.MarkerField) JTextField(javax.swing.JTextField) Field(com.revolsys.swing.field.Field) TextField(com.revolsys.swing.field.TextField) ColorChooserField(com.revolsys.swing.field.ColorChooserField) Length(javax.measure.quantity.Length) CheckBox(com.revolsys.swing.field.CheckBox) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LengthMeasureTextField(com.revolsys.swing.field.LengthMeasureTextField) LengthMeasureTextField(com.revolsys.swing.field.LengthMeasureTextField) JTextField(javax.swing.JTextField) TextField(com.revolsys.swing.field.TextField) List(java.util.List) ArrayList(java.util.ArrayList) LineCap(com.revolsys.geometry.model.LineCap) MarkerField(com.revolsys.swing.map.component.MarkerField)

Example 17 with Length

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);
}
Also used : Length(javax.measure.quantity.Length) LengthMeasureTextField(com.revolsys.swing.field.LengthMeasureTextField)

Example 18 with Length

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);
    }
}
Also used : Area(javax.measure.quantity.Area) Length(javax.measure.quantity.Length) CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) LineString(com.revolsys.geometry.model.LineString) Unit(javax.measure.Unit) Polygon(com.revolsys.geometry.model.Polygon)

Example 19 with Length

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);
}
Also used : Length(javax.measure.quantity.Length) BoundingBox(com.revolsys.geometry.model.BoundingBox)

Example 20 with Length

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;
}
Also used : Length(javax.measure.quantity.Length) BoundingBox(com.revolsys.geometry.model.BoundingBox)

Aggregations

Length (javax.measure.quantity.Length)44 Angle (javax.measure.quantity.Angle)7 Test (org.junit.Test)7 Color (java.awt.Color)5 Unit (javax.measure.Unit)5 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)4 AffineTransform (java.awt.geom.AffineTransform)4 ArrayList (java.util.ArrayList)4 GeographicCoordinateSystem (com.revolsys.geometry.cs.GeographicCoordinateSystem)3 BoundingBox (com.revolsys.geometry.model.BoundingBox)3 LineString (com.revolsys.geometry.model.LineString)3 Point (com.revolsys.geometry.model.Point)3 Shape (java.awt.Shape)3 Rectangle2D (java.awt.geom.Rectangle2D)3 Path (java.nio.file.Path)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 Quantity (javax.measure.Quantity)3 CloseableAffineTransform (com.revolsys.awt.CloseableAffineTransform)2 ProjectedCoordinateSystem (com.revolsys.geometry.cs.ProjectedCoordinateSystem)2 ChainedCoordinatesOperation (com.revolsys.geometry.cs.projection.ChainedCoordinatesOperation)2