Dan,

It looks like Stefan got you pointed in the correct direction. Let me
see if I can fill in a some more of the details:

1) It sounds like you will need to work with the features in a layer
selected by the user. To access the currently selected layers you need
to work with the LayerManager class. You can access the LayerManager
class from the PlugInContext class that is passed to your plug-ins
intitalize and execute methods.

2) Once you have the selected layer, you need to get the
FeatureCollection it wraps. You can do this by using the
getFeatureCollectionWrapper method of the layer class.

3) Get the FeatureSchema from the FeatureCollectionWrapper, copy it,
and add the attribute that will hold your calculated attribute values.

4) Create a new FeatureCollection with the modified schema. Then copy
the Feature objects from the FeatureCollectionWrapper into the new
FeatureCollection. When this is done, replace the original
FeatureCollectionWrapper with your new FeatureCollection. (Check out
the conform method of the PasteSelectedItemsPlugIn class. That comes
in handy when copying features from one layer to another.)

Consider wrapping all of these actions in an EditTransaction or
UndoableCommand to make the change undoable by the user.

The Sunburned Surveyor

On Tue, May 25, 2010 at 10:57 AM, Stefan Steiniger <sst...@geo.uzh.ch> wrote:
> Hei Dan,
>
> you will need to work with FeatureCollections.
> To extend a "layer" (i.e. a FeatureCollection) by an attribute requires
> to create a new FeatureCollection/FeatureDataset with a
> different/extended FeatureSchema. Then all features need to be copied
> towards the new schema and the values set.
> We have a couple of API methods that help you here, i.e. look into the
> class org.openjump.core.apitools.FeatureCollectionTools.java and
> FeatureSchemaTools.
> If you would search then the openjump sources for the method
> copyFeatureSchema or copyFeature you should certainly find PlugIn
> classes/functions that modify attributes/tables.
>
> hope that helps
>
> stefan
>
> Dan Jones schrieb:
>> Hello everyone! My name's Daniel Jones, and I'm totally new to
>> programming for OpenJUMP. I'm working on a plugin that will automate the
>> process of normalizing an attribute for a feature class, and haven't had
>> any luck finding classes or methods that will allow me to access an
>> attribute table, add a new column, and populate it with values derived
>> from another column. I read the sample code on displaying all the values
>> in an attribute table, but was wondering about how to then manipulate
>> those values and plug them back into the table.
>>
>> Any help would be appreciated!
>>
>> Dan
>>
>>
>> ------------------------------------------------------------------------
>>
>> ------------------------------------------------------------------------------
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Jump-pilot-devel mailing list
>> Jump-pilot-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Jump-pilot-devel mailing list
> Jump-pilot-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>

------------------------------------------------------------------------------

_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to