Search in sources :

Example 6 with Attribute

use of org.opengis.feature.Attribute in project geotoolkit by Geomatys.

the class NorthArrowFieldRenderer method createValue.

@Override
public Object createValue(final JRField field, final Feature feature) {
    final String name = field.getName();
    final Attribute prop = (Attribute) feature.getProperty(name);
    final NorthArrowDef na = (NorthArrowDef) prop.getValue();
    if (na != null && na.getDelegate() == null) {
        // only create delegate if not yet assigned
        final NorthArrowRenderer renderable = new NorthArrowRenderer();
        final Attribute mapChar = (Attribute) prop.characteristics().get(MAP_ATTRIBUTE);
        final Attribute mapProp = (Attribute) feature.getProperty((String) mapChar.getValue());
        if (mapProp != null && mapProp.getValue() instanceof MapDef) {
            final MapDef md = (MapDef) mapProp.getValue();
            renderable.setRotation(md.getCanvasDef().getAzimuth());
        }
        na.setDelegate(renderable);
    }
    if (na != null && na.getDelegate() == null) {
        na.setDelegate(EmptyRenderable.INSTANCE);
    }
    return na;
}
Also used : Attribute(org.opengis.feature.Attribute) MapDef(org.geotoolkit.report.graphic.map.MapDef)

Example 7 with Attribute

use of org.opengis.feature.Attribute in project geotoolkit by Geomatys.

the class ScaleBarFieldRenderer method createValue.

@Override
public Object createValue(final JRField field, final Feature feature) {
    final String name = field.getName();
    final Attribute prop = (Attribute) feature.getProperty(name);
    final ScaleBarDef sb = (ScaleBarDef) prop.getValue();
    if (sb != null && sb.getDelegate() == null) {
        // only create delegate if not yet assigned
        final ScaleBarRenderer renderable = new ScaleBarRenderer();
        final Attribute mapChar = (Attribute) prop.characteristics().get(MAP_ATTRIBUTE);
        final Attribute mapProp = (Attribute) feature.getProperty((String) mapChar.getValue());
        if (mapProp != null && mapProp.getValue() instanceof MapDef) {
            final MapDef md = (MapDef) mapProp.getValue();
            renderable.setCanvas((CanvasRenderer) md.getDelegate());
        }
        sb.setDelegate(renderable);
    }
    if (sb != null && sb.getDelegate() == null) {
        sb.setDelegate(EmptyRenderable.INSTANCE);
    }
    return sb;
}
Also used : Attribute(org.opengis.feature.Attribute) MapDef(org.geotoolkit.report.graphic.map.MapDef)

Example 8 with Attribute

use of org.opengis.feature.Attribute in project geotoolkit by Geomatys.

the class XPathBinding method set.

@Override
public void set(final C candidate, final String xpath, final Object value) throws IllegalArgumentException {
    final Object obj = get(candidate, xpath, Property.class);
    if (obj instanceof Attribute) {
        final Attribute prop = (Attribute) obj;
        prop.setValue(value);
    } else if (obj instanceof FeatureAssociation) {
        final FeatureAssociation prop = (FeatureAssociation) obj;
        prop.setValue((Feature) value);
    } else {
        throw new IllegalArgumentException("Can not set value for xpath : " + xpath);
    }
}
Also used : FeatureAssociation(org.opengis.feature.FeatureAssociation) Attribute(org.opengis.feature.Attribute) Feature(org.opengis.feature.Feature)

Example 9 with Attribute

use of org.opengis.feature.Attribute in project geotoolkit by Geomatys.

the class FeatureExt method toProperty.

/**
 * Build a {@link Property} from a {@link ParameterValue}.
 * @param parameter {@link ParameterValue}
 * @return a {@link Property}
 */
public static Property toProperty(final ParameterValue parameter) {
    final ParameterDescriptor descriptor = parameter.getDescriptor();
    final Object value = parameter.getValue();
    final AttributeType at = (AttributeType) FeatureTypeExt.toPropertyType(descriptor);
    final Attribute property = at.newInstance();
    property.setValue(value);
    return property;
}
Also used : Attribute(org.opengis.feature.Attribute) DefaultAttributeType(org.apache.sis.feature.DefaultAttributeType) AttributeType(org.opengis.feature.AttributeType) GeneralParameterDescriptor(org.opengis.parameter.GeneralParameterDescriptor) ParameterDescriptor(org.opengis.parameter.ParameterDescriptor)

Example 10 with Attribute

use of org.opengis.feature.Attribute in project geotoolkit by Geomatys.

the class DefaultArrayFeature method setPropertyValue.

@Override
public void setPropertyValue(int index, Object value) {
    if (values[index] instanceof Operation) {
        final Operation op = (Operation) values[index];
        setOperationValue(op.getName().toString(), value);
    } else if (properties[index] instanceof Attribute) {
        ((Attribute) properties[index]).setValue(value);
    } else if (properties[index] instanceof FeatureAssociation) {
        ((FeatureAssociation) properties[index]).setValue((Feature) value);
    } else {
        values[index] = value;
    }
}
Also used : FeatureAssociation(org.opengis.feature.FeatureAssociation) Attribute(org.opengis.feature.Attribute) Operation(org.opengis.feature.Operation)

Aggregations

Attribute (org.opengis.feature.Attribute)16 AttributeType (org.opengis.feature.AttributeType)8 FeatureAssociationRole (org.opengis.feature.FeatureAssociationRole)6 FeatureType (org.opengis.feature.FeatureType)6 Feature (org.opengis.feature.Feature)5 PropertyType (org.opengis.feature.PropertyType)5 GenericName (org.opengis.util.GenericName)4 Collection (java.util.Collection)3 Map (java.util.Map)3 Entry (java.util.Map.Entry)3 MapDef (org.geotoolkit.report.graphic.map.MapDef)3 FeatureAssociation (org.opengis.feature.FeatureAssociation)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 List (java.util.List)2 JAXBElement (javax.xml.bind.JAXBElement)2 JAXBException (javax.xml.bind.JAXBException)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 DefaultAttributeType (org.apache.sis.feature.DefaultAttributeType)2