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;
}
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;
}
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);
}
}
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;
}
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;
}
}
Aggregations