Hei Benjamin, I add you text/info to the wiki - if you don't mind. https://sourceforge.net/apps/mediawiki/jump-pilot/index.php?title=OpenJUMP_and_Groovy
thanks for that stefan Benjamin Gudehus schrieb: > That's how the sentences supposed to look like. > > -> ...with Eclipse (using the amazing Groovy-Eclipse Plugin). NetBeans > and IntelliJ IDEA also support Groovy. ... > > 2010/6/3 Benjamin Gudehus <hasteb...@googlemail.com > <mailto:hasteb...@googlemail.com>> > > > 2010/6/3 Larry Becker <becker.la...@gmail.com > <mailto:becker.la...@gmail.com>> > > Hi Benjamin, > > Are you running Groovy from within OJ as we do BeanScript and > Jython, or are you importing the OJ classes to create Groovy > programs? > > > I use Groovy the same way as you use Java (importing the OJ classes). > > I put groovy-all-1.7.0.jar (ca. 5 MB) into OpenJUMP's /lib directory > and develop OJ plugins with Eclipse (using the amazing > Groovy-Eclipse Plugin, NetBeans and IntelliJ IDEA). You can use Java > classes in Groovy classes and vice versa (Groovy files are compiled > into .class files). Thus you can even use Groovy classes from the > BeanShell or Jython. > > Since my two classes (mentioned previously) require Groovy Closures > as method parameters, it is necessary to call their methods within a > groovy file (these two classes are special cases). > > Here is a HelloWorldPlugIn in Groovy: > > <pre> > import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn > import com.vividsolutions.jump.workbench.plugin.PlugInContext > import com.vividsolutions.jump.workbench.ui.plugin.FeatureInstaller > > class HelloWorldPlugIn extends AbstractPlugIn { > > void initialize(PlugInContext pluginContext) {} > > boolean execute(PlugInContext pluginContext) { > def pluginPath = > pluginContext.getWorkbenchContext().getWorkbench(). > getPlugInManager().getPlugInDirectory().getAbsolutePath() > > def htmlFrame = > pluginContext.getWorkbenchFrame().getOutputFrame() > htmlFrame.setTitle("Hello, World!") > htmlFrame.createNewDocument() > htmlFrame.addText("Hello, World!") > htmlFrame.addText(pluginPath.toString()) > htmlFrame.surface() > > return true > } > > } > </pre> > > Another funny thing is, you can copy your Java code into a Groovy > file and it compiles. > > --Benjamin > > > > Larry > > > On Wed, Jun 2, 2010 at 9:43 AM, Benjamin Gudehus > <hasteb...@googlemail.com <mailto:hasteb...@googlemail.com>> wrote: > > Hi! > > I wrote a FeatureCollectionBuilder and a > FeatureCollectionSchemaEditor for that in Groovy using the > Builder design pattern (http://groovy.codehaus.org/Builders). > > Look at this example code (from the unit tests). You can add > and remove Attributes to the FeatureSchema. > > <pre> > private featureCollection > > def setup() { > this.featureCollection = new > FeatureCollectionBuilder().build { > schema { > attribute("id", AttributeType.INTEGER) > attribute("name", AttributeType.STRING) > } > features { > feature(id: 1, name: "foo") > feature(id: 2, name: "bar") > feature(id: 3, name: "baz") > feature(id: 4, name: "quux") > } > } > } > > def "Add an attribute to the FeatureSchema"() { > when: > def collectionEditor = new > FeatureCollectionSchemaEditor(this.featureCollection) > collectionEditor.modifySchema { > addSchemaAttribute("street", AttributeType.STRING) > } > > then: > def newFeatureSchema = > collectionEditor.getFeatureCollection().getFeatureSchema() > collectionEditor.getAttributeNames(newFeatureSchema) == > ["id", "name", "street"] > } > </pre> > > If somebody wants to use it, I can upload the sourcecode > (but it depends on the groovy jar). > > 2010/6/2 Larry Becker <becker.la...@gmail.com > <mailto:becker.la...@gmail.com>> > > For tips on how to do this see: > > http://sourceforge.net/apps/mediawiki/jump-pilot/index.php?title=Extending_a_FeatureCollection_by_Adding_new_Attributes > > > On Wed, Jun 2, 2010 at 9:17 AM, Larry Becker > <becker.la...@gmail.com <mailto:becker.la...@gmail.com>> > wrote: > > Hi Caroline, > > You seem to be making progress on your project. > Your current problem is that when you alter a schema > it only affects new features. You need to replace > the old schema in each feature with the new one > before copying attributes. > > regards, > Larry > > 2010/6/2 Caroline Julliê Freitas Ribeiro > <krolj...@gmail.com <mailto:krolj...@gmail.com>> > > I tried to put a new attribute to a old Feature, > I altered the Schema but looks like the size of > the array whete stay the data of the Feature is > not actualized. > > I got the following Stack trace: > > java.lang.ArrayIndexOutOfBoundsException: 3 > at > > com.vividsolutions.jump.feature.BasicFeature.getAttribute(BasicFeature.java:82) > at > > com.vividsolutions.jump.workbench.ui.LayerTableModel$4.getValue(LayerTableModel.java:170) > at > > com.vividsolutions.jump.workbench.ui.LayerTableModel$MyColumn.getValueAt(LayerTableModel.java:75) > at > > com.vividsolutions.jump.workbench.ui.ColumnBasedTableModel.getValueAt(ColumnBasedTableModel.java:141) > at > > com.vividsolutions.jump.workbench.ui.GUIUtil.chooseGoodColumnWidths(GUIUtil.java:408) > at > > com.vividsolutions.jump.workbench.ui.AttributeTablePanel.initColumnWidths(AttributeTablePanel.java:415) > at > > com.vividsolutions.jump.workbench.ui.AttributeTablePanel.<init>(AttributeTablePanel.java:307) > at > > com.vividsolutions.jump.workbench.ui.AttributePanel.addTablePanel(AttributePanel.java:154) > at > > com.vividsolutions.jump.workbench.ui.AttributePanel.layerAdded(AttributePanel.java:136) > at > > com.vividsolutions.jump.workbench.ui.AttributeTab$5.layerAdded(AttributeTab.java:143) > at > > com.vividsolutions.jump.workbench.ui.InfoModel.add(InfoModel.java:88) > at > > com.vividsolutions.jump.workbench.ui.cursortool.FeatureInfoTool.gestureFinished(FeatureInfoTool.java:81) > at > > com.vividsolutions.jump.workbench.ui.cursortool.AbstractCursorTool.fireGestureFinished(AbstractCursorTool.java:446) > at > > com.vividsolutions.jump.workbench.ui.cursortool.SpecifyFeaturesTool.mouseClicked(SpecifyFeaturesTool.java:95) > at > > com.vividsolutions.jump.workbench.ui.cursortool.LeftClickFilter.mouseClicked(LeftClickFilter.java:81) > at > > com.vividsolutions.jump.workbench.ui.cursortool.DelegatingTool.mouseClicked(DelegatingTool.java:97) > at > > java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:253) > at > > java.awt.Component.processMouseEvent(Component.java:6266) > at > > javax.swing.JComponent.processMouseEvent(JComponent.java:3255) > at > java.awt.Component.processEvent(Component.java:6028) > at > java.awt.Container.processEvent(Container.java:2041) > at > > java.awt.Component.dispatchEventImpl(Component.java:4630) > at > > java.awt.Container.dispatchEventImpl(Container.java:2099) > at > java.awt.Component.dispatchEvent(Component.java:4460) > at > > java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574) > at > > java.awt.LightweightDispatcher.processMouseEvent(Container.java:4247) > at > > java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168) > at > > java.awt.Container.dispatchEventImpl(Container.java:2085) > at > java.awt.Window.dispatchEventImpl(Window.java:2475) > at > java.awt.Component.dispatchEvent(Component.java:4460) > at > java.awt.EventQueue.dispatchEvent(EventQueue.java:599) > at > > java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) > at > > java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) > at > > java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) > at > > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) > at > > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) > at > > java.awt.EventDispatchThread.run(EventDispatchThread.java:122) > > This is the code where I got the problem: > > Layer l = (Layer)cboLayers.getSelectedItem(); > FeatureCollectionWrapper col = > l.getFeatureCollectionWrapper(); > FeatureSchema schema = > col.getFeatureSchema(); > instalEsquema(schema,rs); > List lista =col.getFeatures(); > while (rs.next()){ > for(Object o: lista){ > Feature f = (Feature) o; > Feature fNew; > String att = > > f.getAttribute(cboAtributos.getSelectedItem().toString()).toString(); > if > (att.equals(rs.getString(txtCampo.getText()))){ > for(int i > =nroAtributosAntes;i<schema.getAttributeCount();i++){ > f.setAttribute(i, > rs.getString(schema.getAttributeName(i))); > //Here is the problem > } > } > } > } > > private void instalEsquema(FeatureSchema > schema, ResultSet rs) throws SQLException { > //Here everything works fine.... > nroAtributosAntes = > schema.getAttributeCount(); > ResultSetMetaData meta = rs.getMetaData(); > for(int i =1;i<=meta.getColumnCount();i++){ > > schema.addAttribute(meta.getColumnLabel(i), > AttributeType.STRING); > } > } > > > Thanks > > -- > Caroline Julliê de Freitas Ribeiro > Graduando em Análise e Desenvolvimento de Sistemas > > Instituto Federal Minas Gerais - IFMG > Campus Bambuí > > > ------------------------------------------------------------------------------ > > > _______________________________________________ > Jump-pilot-devel mailing list > Jump-pilot-devel@lists.sourceforge.net > <mailto: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 > <mailto: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 > <mailto:Jump-pilot-devel@lists.sourceforge.net> > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > > > > > ------------------------------------------------------------------------------ > ThinkGeek and WIRED's GeekDad team up for the Ultimate > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the > lucky parental unit. See the prize list and enter to win: > http://p.sf.net/sfu/thinkgeek-promo > > _______________________________________________ > Jump-pilot-devel mailing list > Jump-pilot-devel@lists.sourceforge.net > <mailto:Jump-pilot-devel@lists.sourceforge.net> > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > ThinkGeek and WIRED's GeekDad team up for the Ultimate > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the > lucky parental unit. See the prize list and enter to win: > http://p.sf.net/sfu/thinkgeek-promo > > > ------------------------------------------------------------------------ > > _______________________________________________ > Jump-pilot-devel mailing list > Jump-pilot-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel