Search in sources :

Example 1 with LineCap

use of com.revolsys.geometry.model.LineCap 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 2 with LineCap

use of com.revolsys.geometry.model.LineCap in project com.revolsys.open by revolsys.

the class BufferTest method suite.

public static Test suite() {
    final TestSuite suite = new TestSuite("Buffer");
    int i = 0;
    try (MapReader reader = MapReader.newMapReader(new ClassPathResource("/com/revolsys/jts/test/geometry/operation/buffer.csv"))) {
        for (final Map<String, Object> map : reader) {
            i++;
            final int srid = Maps.getInteger(map, "srid", 0);
            final int axisCount = Maps.getInteger(map, "axisCount", 2);
            final double scaleXy = Maps.getDouble(map, "scaleXy", 0.0);
            final double scaleZ = Maps.getDouble(map, "scaleZ", 0.0);
            final double[] scales = { scaleXy, scaleXy, scaleZ };
            final GeometryFactory geometryFactory = GeometryFactory.fixed(srid, axisCount, scales);
            final String sourceWkt = (String) map.get("sourceWkt");
            final Geometry sourceGeometry = geometryFactory.geometry(sourceWkt);
            final double distance = Maps.getDouble(map, "bufferDistance", 0.0);
            final int quadrantSegments = Maps.getInteger(map, "quadrantSegments", BufferParameters.DEFAULT_QUADRANT_SEGMENTS);
            final LineCap endCapStyle = LineCap.fromGeometryValue(Maps.getInteger(map, "endCapStyle", LineCap.ROUND.getGeometryValue()));
            final LineJoin joinStyle = LineJoin.fromGeometryValue(Maps.getInteger(map, "joinStyle", LineJoin.ROUND.getGeometryValue()));
            final double mitreLimit = Maps.getDouble(map, "mitreLimit", BufferParameters.DEFAULT_MITRE_LIMIT);
            final BufferParameters parameters = new BufferParameters(quadrantSegments, endCapStyle, joinStyle, mitreLimit);
            final Boolean expectedEmpty = Maps.getBoolean(map, "expectedEmpty");
            final Boolean expectedHoles = Maps.getBoolean(map, "expectedHoles");
            final Boolean expectedContains = Maps.getBoolean(map, "expectedContains");
            final Double expectedArea = Maps.getDouble(map, "expectedArea");
            final String expectedWkt = (String) map.get("expectedWkt");
            final Geometry expectedGeometry = geometryFactory.geometry(expectedWkt);
            final BufferTest test = new BufferTest(i, sourceGeometry, distance, parameters, expectedEmpty, expectedHoles, expectedContains, expectedArea, expectedGeometry);
            suite.addTest(test);
        }
    }
    return suite;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BufferParameters(com.revolsys.geometry.operation.buffer.BufferParameters) ClassPathResource(com.revolsys.spring.resource.ClassPathResource) Geometry(com.revolsys.geometry.model.Geometry) LineJoin(com.revolsys.geometry.model.LineJoin) TestSuite(junit.framework.TestSuite) MapReader(com.revolsys.io.map.MapReader) LineCap(com.revolsys.geometry.model.LineCap)

Aggregations

LineCap (com.revolsys.geometry.model.LineCap)2 Geometry (com.revolsys.geometry.model.Geometry)1 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 LineJoin (com.revolsys.geometry.model.LineJoin)1 BufferParameters (com.revolsys.geometry.operation.buffer.BufferParameters)1 MapReader (com.revolsys.io.map.MapReader)1 ClassPathResource (com.revolsys.spring.resource.ClassPathResource)1 CheckBox (com.revolsys.swing.field.CheckBox)1 ColorChooserField (com.revolsys.swing.field.ColorChooserField)1 ComboBox (com.revolsys.swing.field.ComboBox)1 Field (com.revolsys.swing.field.Field)1 FontChooserField (com.revolsys.swing.field.FontChooserField)1 LengthMeasureTextField (com.revolsys.swing.field.LengthMeasureTextField)1 TextField (com.revolsys.swing.field.TextField)1 MarkerField (com.revolsys.swing.map.component.MarkerField)1 AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)1 Color (java.awt.Color)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Quantity (javax.measure.Quantity)1