Revision: 4511 http://sourceforge.net/p/jump-pilot/code/4511 Author: ma15569 Date: 2015-06-25 08:55:03 +0000 (Thu, 25 Jun 2015) Log Message: ----------- 2015-06-25 Giuseppe Aruta <giuseppe_ar...@yahoo.it> * Reorganized Select Item context menu: move some plugins to a new "Other tools" submenu * Add Measure Selected Features plugin to Select Items context menu>Other tools submenu
Modified Paths: -------------- core/trunk/ChangeLog core/trunk/scripts/default-plugins.xml core/trunk/src/org/openjump/core/ui/plugin/edit/ReplicateSelectedItemsPlugIn.java core/trunk/src/org/openjump/core/ui/plugin/mousemenu/EditSelectedSidePlugIn.java core/trunk/src/org/openjump/core/ui/plugin/mousemenu/MoveAlongAnglePlugIn.java core/trunk/src/org/openjump/core/ui/plugin/mousemenu/RotatePlugIn.java Added Paths: ----------- core/trunk/src/org/openjump/core/ui/plugin/mousemenu/MeasureSelectedPlugIn.java Modified: core/trunk/ChangeLog =================================================================== --- core/trunk/ChangeLog 2015-06-25 08:41:54 UTC (rev 4510) +++ core/trunk/ChangeLog 2015-06-25 08:55:03 UTC (rev 4511) @@ -1,5 +1,9 @@ # for display continuity sake please use 2 spaces instead of tabs +2015-06-25 Giuseppe Aruta <giuseppe_ar...@yahoo.it> + * Reorganized Select Item context menu: move some plugins to a new "Other tools" submenu + * Add Measure Selected Features plugin to Select Items context menu>Other tools submenu + 2015-06-24 mmichaud <m.michael.mich...@orange.fr> * AttributeTablePanel : simplify code, avoid useless selection clearing and avoid a recursive loop [could not reproduce a case where features can be deleted from the Modified: core/trunk/scripts/default-plugins.xml =================================================================== --- core/trunk/scripts/default-plugins.xml 2015-06-25 08:41:54 UTC (rev 4510) +++ core/trunk/scripts/default-plugins.xml 2015-06-25 08:55:03 UTC (rev 4511) @@ -266,8 +266,17 @@ </plug-in> <plug-in> org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn + <menus> + <main-menu menupath="MenuNames.EDIT" install="true" /> + </menus> </plug-in> <plug-in> + org.openjump.core.ui.plugin.mousemenu.MeasureSelectedPlugIn + <menus> + <main-menu menupath="MenuNames.EDIT" install="true" /> + </menus> + </plug-in> + <plug-in> org.openjump.core.ui.plugin.layer.ExtractLayersByGeometry </plug-in> <plug-in> @@ -520,6 +529,10 @@ <main-menu menupath="MenuNames.LAYER" install="true" /> </menus> </plug-in> + + + + <!-- ====================== CUSTOMIZE menu ================================== --> <plug-in> com.vividsolutions.jump.workbench.ui.plugin.OptionsPlugIn @@ -839,10 +852,6 @@ <plug-in> org.openjump.core.ui.plugin.raster.RasterQueryPlugIn </plug-in> - - <extension> - org.openjump.core.rasterimage.styler.RasterStylesExtension - </extension> <!--- ======================= WINDOW menu =============================== --> <plug-in> @@ -1264,14 +1273,23 @@ <layername-popup-wms install="true" /> </menus> </plug-in> + <separator /> + <plug-in> org.openjump.core.ui.plugin.wms.WMSLegendPlugIn <menus> <layername-popup-wms install="true" /> </menus> </plug-in> + <plug-in> + org.openjump.core.ui.plugin.wms.WMSInfoPlugIn + <menus> + <layername-popup-wms install="true" /> + </menus> + </plug-in> + <!-- ================ Sextante Raster LayerName Popup Menu =============== --> <plug-in> org.openjump.core.ui.plugin.layer.ToggleVisibilityPlugIn @@ -1288,12 +1306,16 @@ <layername-popup-raster install="true" /> </menus> </plug-in> - <plug-in> + + + + <plug-in> org.openjump.core.ui.plugin.layer.pirolraster.ChangeRasterImagePropertiesPlugIn <menus> <layername-popup-raster install="true" /> </menus> </plug-in> + <plug-in> org.openjump.core.ui.plugin.layer.pirolraster.ExtractSelectedPartOfImage <menus> @@ -1454,25 +1476,16 @@ <separator /> + + <plug-in> - com.vividsolutions.jump.workbench.ui.plugin.VerticesInFencePlugIn - <menus> - <layerview-popup install="true" /> - </menus> - </plug-in> - <plug-in> org.openjump.core.ui.plugin.mousemenu.DuplicateItemPlugIn <menus> <layerview-popup install="true" /> </menus> </plug-in> + <plug-in> - org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn - <menus> - <layerview-popup /> - </menus> - </plug-in> - <plug-in> com.vividsolutions.jump.workbench.ui.plugin.CombineSelectedFeaturesPlugIn <menus> <layerview-popup install="true" /> @@ -1490,11 +1503,9 @@ <layerview-popup install="true" /> </menus> </plug-in> + <plug-in> - com.vividsolutions.jump.workbench.ui.plugin.clipboard.CopyThisCoordinatePlugIn - <menus> - <layerview-popup install="true" /> - </menus> + org.openjump.core.ui.plugin.mousemenu.ReverseOrientationPlugIn </plug-in> <plug-in> @@ -1521,19 +1532,52 @@ <plug-in> org.openjump.core.ui.plugin.mousemenu.SplitPolygonsNodeLinesPlugIn </plug-in> + + <plug-in> - org.openjump.core.ui.plugin.mousemenu.MoveAlongAnglePlugIn + org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn + <menus> + <layerview-popup menupath="MenuNames.TOOLS.OTHERS" install="true" /> + </menus> </plug-in> - <plug-in> + <plug-in> org.openjump.core.ui.plugin.mousemenu.RotatePlugIn + <menus> + <layerview-popup menupath="MenuNames.TOOLS.OTHERS" install="true" /> + </menus> </plug-in> <plug-in> + org.openjump.core.ui.plugin.mousemenu.MeasureSelectedPlugIn + <menus> + <layerview-popup menupath="MenuNames.TOOLS.OTHERS" install="true" /> + </menus> + </plug-in> + <plug-in> + org.openjump.core.ui.plugin.mousemenu.MoveAlongAnglePlugIn + <menus> + <layerview-popup menupath="MenuNames.TOOLS.OTHERS" install="true" /> + </menus> + </plug-in> + <plug-in> org.openjump.core.ui.plugin.mousemenu.EditSelectedSidePlugIn + <menus> + <layerview-popup menupath="MenuNames.TOOLS.OTHERS" install="true" /> + </menus> </plug-in> <plug-in> - org.openjump.core.ui.plugin.mousemenu.ReverseOrientationPlugIn + com.vividsolutions.jump.workbench.ui.plugin.clipboard.CopyThisCoordinatePlugIn + <menus> + <layerview-popup menupath="MenuNames.TOOLS.OTHERS" install="true" /> + </menus> </plug-in> + <plug-in> + com.vividsolutions.jump.workbench.ui.plugin.VerticesInFencePlugIn + <menus> + <layerview-popup menupath="MenuNames.TOOLS.OTHERS" install="true" /> + </menus> + </plug-in> + <!-- ================ AttributeTab Popup Menu ============================== --> <plug-in> @@ -1616,9 +1660,9 @@ <plug-in> org.openjump.core.ui.plugin.edittoolbox.ConstrainedMoveVertexPlugIn </plug-in> - <!--plug-in> + <plug-in> org.openjump.core.ui.plugin.edittoolbox.RotateSelectedItemPlugIn - </plug-in--> + </plug-in> <plug-in> org.openjump.core.ui.plugin.edittoolbox.SelectOneItemPlugIn </plug-in> Modified: core/trunk/src/org/openjump/core/ui/plugin/edit/ReplicateSelectedItemsPlugIn.java =================================================================== --- core/trunk/src/org/openjump/core/ui/plugin/edit/ReplicateSelectedItemsPlugIn.java 2015-06-25 08:41:54 UTC (rev 4510) +++ core/trunk/src/org/openjump/core/ui/plugin/edit/ReplicateSelectedItemsPlugIn.java 2015-06-25 08:55:03 UTC (rev 4511) @@ -39,6 +39,15 @@ package org.openjump.core.ui.plugin.edit; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +import javax.swing.ImageIcon; +import javax.swing.JComboBox; + +import org.openjump.core.ui.images.IconLoader; + import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jump.I18N; import com.vividsolutions.jump.feature.Feature; @@ -48,6 +57,8 @@ import com.vividsolutions.jump.feature.FeatureUtil; import com.vividsolutions.jump.task.TaskMonitor; import com.vividsolutions.jump.workbench.WorkbenchContext; +import com.vividsolutions.jump.workbench.model.Layer; +import com.vividsolutions.jump.workbench.model.StandardCategoryNames; import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn; import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory; import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck; @@ -55,198 +66,209 @@ import com.vividsolutions.jump.workbench.plugin.ThreadedPlugIn; import com.vividsolutions.jump.workbench.ui.EditTransaction; import com.vividsolutions.jump.workbench.ui.GUIUtil; -import com.vividsolutions.jump.workbench.ui.LayerViewPanel; -import com.vividsolutions.jump.workbench.ui.MenuNames; import com.vividsolutions.jump.workbench.ui.MultiInputDialog; -import java.util.ArrayList; -import java.util.Iterator; -import com.vividsolutions.jump.workbench.model.Layer; -import com.vividsolutions.jump.workbench.model.StandardCategoryNames; - -import java.util.Collection; - -import javax.swing.ImageIcon; -import javax.swing.JComboBox; - -import org.openjump.core.ui.images.IconLoader; - - /** * Replicates/ copys selected items in a new or existing layer - * + * * @author sstein - * + * **/ -public class ReplicateSelectedItemsPlugIn extends AbstractPlugIn implements ThreadedPlugIn{ +public class ReplicateSelectedItemsPlugIn extends AbstractPlugIn implements + ThreadedPlugIn { - public static ImageIcon ICON = IconLoader.icon("shape_replicate.png"); - private String T1 ="Replicate to new layer?"; - private String CLAYER = "otherwise select layer"; + public static ImageIcon ICON = IconLoader.icon("shape_replicate.png"); + private String T1 = "Replicate to new layer?"; + private String CLAYER = "otherwise select layer"; boolean newLayer = true; private Layer itemlayer = null; private boolean copyAsGeometry = false; + public String getName() { + return I18N + .get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn"); + } public void initialize(PlugInContext context) throws Exception { - - context.getFeatureInstaller().addPopupMenuItem( - LayerViewPanel.popupMenu(), - this, - I18N.get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn") + "...", - false, - this.getIcon(), - createEnableCheck(context.getWorkbenchContext())); - context.getFeatureInstaller().addMainMenuItem(this, - new String[] - {MenuNames.EDIT}, - I18N.get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn") + "..." + "{pos:16}", - false, - this.getIcon(), - createEnableCheck(context.getWorkbenchContext())); - - this.T1 = I18N.get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn.replicate-to-new-layer"); - this.CLAYER = I18N.get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn.otherwise-select-target-layer"); + /* + * context.getFeatureInstaller().addPopupMenuItem( + * LayerViewPanel.popupMenu(), this, + * I18N.get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn" + * ) + "...", false, this.getIcon(), + * createEnableCheck(context.getWorkbenchContext())); + */ + + /* + * context.getFeatureInstaller() .addMainMenuItem( this, new String[] { + * MenuNames.EDIT }, + * I18N.get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn" + * ) + "..." + "{pos:16}", false, this.getIcon(), + * createEnableCheck(context.getWorkbenchContext())); + */ + + this.T1 = I18N + .get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn.replicate-to-new-layer"); + this.CLAYER = I18N + .get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn.otherwise-select-target-layer"); } - - public static MultiEnableCheck createEnableCheck(WorkbenchContext workbenchContext) { - EnableCheckFactory checkFactory = new EnableCheckFactory(workbenchContext); - return new MultiEnableCheck() - .add(checkFactory.createAtLeastNItemsMustBeSelectedCheck(1)); + public static MultiEnableCheck createEnableCheck( + WorkbenchContext workbenchContext) { + EnableCheckFactory checkFactory = new EnableCheckFactory( + workbenchContext); + + return new MultiEnableCheck().add(checkFactory + .createAtLeastNItemsMustBeSelectedCheck(1)); } - - public boolean execute(PlugInContext context) throws Exception{ - this.reportNothingToUndoYet(context); - MultiInputDialog dialog = new MultiInputDialog( - context.getWorkbenchFrame(), getName(), true); - setDialogValues(dialog, context); - GUIUtil.centreOnWindow(dialog); - dialog.setVisible(true); - if (! dialog.wasOKPressed()) { return false; } - getDialogValues(dialog); - return true; - } - - private void setDialogValues(MultiInputDialog dialog, PlugInContext context) - { - String sidebarString = I18N.get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn.replicates-selected-items-if-all-have-same-attribute-schema"); - dialog.setSideBarDescription(sidebarString); - //"Replicates selected items if all have same feature schema" - dialog.addCheckBox(T1,true); - JComboBox addLayerComboBoxBuild = dialog.addLayerComboBox(this.CLAYER, context.getCandidateLayer(0), null, context.getLayerManager()); - } - private void getDialogValues(MultiInputDialog dialog) { - this.newLayer = dialog.getBoolean(T1); - this.itemlayer = dialog.getLayer(this.CLAYER); - } - - public void run(TaskMonitor monitor, PlugInContext context) throws Exception{ - this.replicate(context, monitor, this.newLayer); - System.gc(); - } - - private boolean replicate(PlugInContext context, TaskMonitor monitor, boolean newLayer) throws Exception{ - String statusMessage1 = I18N.get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn.item"); - String statusMessage2 = I18N.get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn.no-replication-because-different-attribute-schema"); - - boolean hasBeenCalled = false; - System.gc(); //flush garbage collector - // -------------------------- - //-- get selected items - final Collection features = context.getLayerViewPanel().getSelectionManager().getFeaturesWithSelectedItems(); + public boolean execute(PlugInContext context) throws Exception { + this.reportNothingToUndoYet(context); + MultiInputDialog dialog = new MultiInputDialog( + context.getWorkbenchFrame(), getName(), true); + setDialogValues(dialog, context); + GUIUtil.centreOnWindow(dialog); + dialog.setVisible(true); + if (!dialog.wasOKPressed()) { + return false; + } + getDialogValues(dialog); + return true; + } - if (newLayer == false){ + private void setDialogValues(MultiInputDialog dialog, PlugInContext context) { + String sidebarString = I18N + .get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn.replicates-selected-items-if-all-have-same-attribute-schema"); + dialog.setSideBarDescription(sidebarString); + // "Replicates selected items if all have same feature schema" + dialog.addCheckBox(T1, true); + JComboBox addLayerComboBoxBuild = dialog.addLayerComboBox(this.CLAYER, + context.getCandidateLayer(0), null, context.getLayerManager()); + } - EditTransaction transaction = new EditTransaction(new ArrayList(), this.getName(), this.itemlayer, - this.isRollingBackInvalidEdits(context), true, context.getWorkbenchFrame()); + private void getDialogValues(MultiInputDialog dialog) { + this.newLayer = dialog.getBoolean(T1); + this.itemlayer = dialog.getLayer(this.CLAYER); + } - FeatureCollection actualLayerFeatures = this.itemlayer.getFeatureCollectionWrapper().getWrappee(); - FeatureSchema fschema = this.itemlayer.getFeatureCollectionWrapper().getFeatureSchema(); - //-- check if schema is the same if yes add the feature (or change Schema) - Iterator iter = features.iterator(); - int i=0; Feature fi = null; - while (iter.hasNext()){ - i++; - fi = (Feature)iter.next(); - if(fschema.equals(fi.getSchema())){ - Feature feature = (Feature)fi.clone(); + public void run(TaskMonitor monitor, PlugInContext context) + throws Exception { + this.replicate(context, monitor, this.newLayer); + System.gc(); + } + + private boolean replicate(PlugInContext context, TaskMonitor monitor, + boolean newLayer) throws Exception { + String statusMessage1 = I18N + .get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn.item"); + String statusMessage2 = I18N + .get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn.no-replication-because-different-attribute-schema"); + + boolean hasBeenCalled = false; + System.gc(); // flush garbage collector + // -------------------------- + // -- get selected items + final Collection features = context.getLayerViewPanel() + .getSelectionManager().getFeaturesWithSelectedItems(); + + if (newLayer == false) { + + EditTransaction transaction = new EditTransaction(new ArrayList(), + this.getName(), this.itemlayer, + this.isRollingBackInvalidEdits(context), true, + context.getWorkbenchFrame()); + + FeatureCollection actualLayerFeatures = this.itemlayer + .getFeatureCollectionWrapper().getWrappee(); + FeatureSchema fschema = this.itemlayer + .getFeatureCollectionWrapper().getFeatureSchema(); + // -- check if schema is the same if yes add the feature (or change + // Schema) + Iterator iter = features.iterator(); + int i = 0; + Feature fi = null; + while (iter.hasNext()) { + i++; + fi = (Feature) iter.next(); + if (fschema.equals(fi.getSchema())) { + Feature feature = (Feature) fi.clone(); transaction.createFeature(feature); - } - else{ - context.getWorkbenchFrame().setStatusMessage( - statusMessage1 + ": " + i + " "+ statusMessage2); - if(hasBeenCalled == false){ - this.askWhatToDo(context); - hasBeenCalled = true; - } - if (this.copyAsGeometry == true){ - Geometry geom = (Geometry)fi.getGeometry().clone(); - Feature newFeature = FeatureUtil.toFeature(geom, fschema); + } else { + context.getWorkbenchFrame().setStatusMessage( + statusMessage1 + ": " + i + " " + statusMessage2); + if (hasBeenCalled == false) { + this.askWhatToDo(context); + hasBeenCalled = true; + } + if (this.copyAsGeometry == true) { + Geometry geom = (Geometry) fi.getGeometry().clone(); + Feature newFeature = FeatureUtil.toFeature(geom, + fschema); transaction.createFeature(newFeature); - } - } - } - transaction.commit(); - } - else{ - Iterator iter = features.iterator(); - Feature f = (Feature)iter.next(); - FeatureCollection myCollA = new FeatureDataset(f.getSchema()); - myCollA.add((Feature)f.clone()); //copy first Item - Feature fi = null; - int i=1; - while (iter.hasNext()){ - i++; - fi = (Feature)iter.next(); - if(f.getSchema().equals(fi.getSchema())){ - Feature feature = (Feature)fi.clone(); - myCollA.add(feature); - } - else{ - context.getWorkbenchFrame().setStatusMessage( - statusMessage1 + ": " + i + statusMessage2); - if(hasBeenCalled == false){ - this.askWhatToDo(context); - hasBeenCalled = true; - } - if (this.copyAsGeometry == true){ - Geometry geom = (Geometry)fi.getGeometry().clone(); - Feature newFeature = FeatureUtil.toFeature(geom, f.getSchema()); - myCollA.add(newFeature); - } - } - } - context.addLayer(StandardCategoryNames.WORKING, - I18N.get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn.new"), - myCollA); - } - return true; - } - - private void askWhatToDo(PlugInContext context){ - String dialog1 = I18N.get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn.attribute-schemas-are-different"); - String dialog2 = I18N.get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn.copy-only-geometry"); - String dialog3 = "(" + I18N.get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn.on-ok-attributes-will-be-lost-on-cancel-items-are-not-copied") + ")"; + } + } + } + transaction.commit(); + } else { + Iterator iter = features.iterator(); + Feature f = (Feature) iter.next(); + FeatureCollection myCollA = new FeatureDataset(f.getSchema()); + myCollA.add((Feature) f.clone()); // copy first Item + Feature fi = null; + int i = 1; + while (iter.hasNext()) { + i++; + fi = (Feature) iter.next(); + if (f.getSchema().equals(fi.getSchema())) { + Feature feature = (Feature) fi.clone(); + myCollA.add(feature); + } else { + context.getWorkbenchFrame().setStatusMessage( + statusMessage1 + ": " + i + statusMessage2); + if (hasBeenCalled == false) { + this.askWhatToDo(context); + hasBeenCalled = true; + } + if (this.copyAsGeometry == true) { + Geometry geom = (Geometry) fi.getGeometry().clone(); + Feature newFeature = FeatureUtil.toFeature(geom, + f.getSchema()); + myCollA.add(newFeature); + } + } + } + context.addLayer( + StandardCategoryNames.WORKING, + I18N.get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn.new"), + myCollA); + } + return true; + } - MultiInputDialog dialog = new MultiInputDialog( - context.getWorkbenchFrame(), getName(), true); - dialog.addLabel(dialog1); - dialog.addLabel(dialog2); - dialog.addLabel(dialog3); - GUIUtil.centreOnWindow(dialog); - dialog.setVisible(true); - if (! dialog.wasOKPressed()) { - this.copyAsGeometry=false; - } - else{ - this.copyAsGeometry=true; - } + private void askWhatToDo(PlugInContext context) { + String dialog1 = I18N + .get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn.attribute-schemas-are-different"); + String dialog2 = I18N + .get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn.copy-only-geometry"); + String dialog3 = "(" + + I18N.get("org.openjump.core.ui.plugin.edit.ReplicateSelectedItemsPlugIn.on-ok-attributes-will-be-lost-on-cancel-items-are-not-copied") + + ")"; - } - + MultiInputDialog dialog = new MultiInputDialog( + context.getWorkbenchFrame(), getName(), true); + dialog.addLabel(dialog1); + dialog.addLabel(dialog2); + dialog.addLabel(dialog3); + GUIUtil.centreOnWindow(dialog); + dialog.setVisible(true); + if (!dialog.wasOKPressed()) { + this.copyAsGeometry = false; + } else { + this.copyAsGeometry = true; + } + + } + public ImageIcon getIcon() { return ICON; } Modified: core/trunk/src/org/openjump/core/ui/plugin/mousemenu/EditSelectedSidePlugIn.java =================================================================== --- core/trunk/src/org/openjump/core/ui/plugin/mousemenu/EditSelectedSidePlugIn.java 2015-06-25 08:41:54 UTC (rev 4510) +++ core/trunk/src/org/openjump/core/ui/plugin/mousemenu/EditSelectedSidePlugIn.java 2015-06-25 08:55:03 UTC (rev 4511) @@ -32,10 +32,10 @@ */ package org.openjump.core.ui.plugin.mousemenu; + import java.util.Collection; import javax.swing.JComponent; -import javax.swing.JPopupMenu; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryCollection; @@ -50,77 +50,83 @@ import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory; import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck; import com.vividsolutions.jump.workbench.plugin.PlugInContext; -import com.vividsolutions.jump.workbench.ui.LayerViewPanel; import com.vividsolutions.jump.workbench.ui.SelectionManagerProxy; -import com.vividsolutions.jump.workbench.ui.plugin.FeatureInstaller; public class EditSelectedSidePlugIn extends AbstractPlugIn { - private final static String sEditSelectedSide = I18N.get("org.openjump.core.ui.plugin.mousemenu.EditSelectedSidePlugIn.Edit-Selected-Side"); - private final static String sPointsDoNotHaveSides = I18N.get("org.openjump.core.ui.plugin.mousemenu.EditSelectedSidePlugIn.Points-do-not-have-sides"); - private final static String sSelectOnlyOnePart = I18N.get("org.openjump.core.ui.plugin.mousemenu.EditSelectedSidePlugIn.Select-only-one-part"); - - public void initialize(PlugInContext context) throws Exception - { - WorkbenchContext workbenchContext = context.getWorkbenchContext(); - FeatureInstaller featureInstaller = new FeatureInstaller(workbenchContext); - JPopupMenu popupMenu = LayerViewPanel.popupMenu(); - featureInstaller.addPopupMenuItem(popupMenu, - this, sEditSelectedSide, - false, null, //to do: add icon - this.createEnableCheck(workbenchContext)); + private final static String sEditSelectedSide = I18N + .get("org.openjump.core.ui.plugin.mousemenu.EditSelectedSidePlugIn.Edit-Selected-Side"); + private final static String sPointsDoNotHaveSides = I18N + .get("org.openjump.core.ui.plugin.mousemenu.EditSelectedSidePlugIn.Points-do-not-have-sides"); + private final static String sSelectOnlyOnePart = I18N + .get("org.openjump.core.ui.plugin.mousemenu.EditSelectedSidePlugIn.Select-only-one-part"); + + public String getName() { + return sEditSelectedSide; } - - public boolean execute(final PlugInContext context) throws Exception - { + + /* + * public void initialize(PlugInContext context) throws Exception { + * WorkbenchContext workbenchContext = context.getWorkbenchContext(); + * FeatureInstaller featureInstaller = new + * FeatureInstaller(workbenchContext); JPopupMenu popupMenu = + * LayerViewPanel.popupMenu(); featureInstaller.addPopupMenuItem(popupMenu, + * this, sEditSelectedSide, false, null, //to do: add icon + * this.createEnableCheck(workbenchContext)); } + */ + + public boolean execute(final PlugInContext context) throws Exception { reportNothingToUndoYet(context); - EditSelectedSideDialog dialog = new EditSelectedSideDialog(context, sEditSelectedSide, false); + EditSelectedSideDialog dialog = new EditSelectedSideDialog(context, + sEditSelectedSide, false); dialog.setVisible(true); return true; } - - public EnableCheck noPointsMayBeSelectedCheck(final WorkbenchContext workbenchContext) { + + public EnableCheck noPointsMayBeSelectedCheck( + final WorkbenchContext workbenchContext) { return new EnableCheck() { public String check(JComponent component) { - Collection selectedItems = ((SelectionManagerProxy) workbenchContext - .getWorkbench() - .getFrame() - .getActiveInternalFrame()) - .getSelectionManager() - .getSelectedItems(); - Geometry selectedGeo = (Geometry) selectedItems.iterator().next(); - return (selectedGeo instanceof Point) - ? sPointsDoNotHaveSides - : null; - } + Collection selectedItems = ((SelectionManagerProxy) workbenchContext + .getWorkbench().getFrame().getActiveInternalFrame()) + .getSelectionManager().getSelectedItems(); + Geometry selectedGeo = (Geometry) selectedItems.iterator() + .next(); + return (selectedGeo instanceof Point) ? sPointsDoNotHaveSides + : null; + } }; } - public EnableCheck noMultiShapesMayBeSelectedCheck(final WorkbenchContext workbenchContext) { + public EnableCheck noMultiShapesMayBeSelectedCheck( + final WorkbenchContext workbenchContext) { return new EnableCheck() { public String check(JComponent component) { - Collection selectedItems = ((SelectionManagerProxy) workbenchContext - .getWorkbench() - .getFrame() - .getActiveInternalFrame()) - .getSelectionManager() - .getSelectedItems(); - Geometry selectedGeo = (Geometry) selectedItems.iterator().next(); + Collection selectedItems = ((SelectionManagerProxy) workbenchContext + .getWorkbench().getFrame().getActiveInternalFrame()) + .getSelectionManager().getSelectedItems(); + Geometry selectedGeo = (Geometry) selectedItems.iterator() + .next(); - return (((selectedGeo instanceof MultiPoint) || (selectedGeo instanceof MultiLineString) || (selectedGeo instanceof MultiPolygon) || (selectedGeo instanceof GeometryCollection))) - ? (sSelectOnlyOnePart) - : null; - } + return (((selectedGeo instanceof MultiPoint) + || (selectedGeo instanceof MultiLineString) + || (selectedGeo instanceof MultiPolygon) || (selectedGeo instanceof GeometryCollection))) ? (sSelectOnlyOnePart) + : null; + } }; } - - public MultiEnableCheck createEnableCheck(final WorkbenchContext workbenchContext) { - EnableCheckFactory checkFactory = new EnableCheckFactory(workbenchContext); + + public MultiEnableCheck createEnableCheck( + final WorkbenchContext workbenchContext) { + EnableCheckFactory checkFactory = new EnableCheckFactory( + workbenchContext); return new MultiEnableCheck() - .add(checkFactory.createWindowWithLayerViewPanelMustBeActiveCheck()) - .add(checkFactory.createExactlyNItemsMustBeSelectedCheck(1)) - .add(noPointsMayBeSelectedCheck(workbenchContext)) - .add(noMultiShapesMayBeSelectedCheck(workbenchContext)) - .add(checkFactory.createSelectedItemsLayersMustBeEditableCheck()); + .add(checkFactory + .createWindowWithLayerViewPanelMustBeActiveCheck()) + .add(checkFactory.createExactlyNItemsMustBeSelectedCheck(1)) + .add(noPointsMayBeSelectedCheck(workbenchContext)) + .add(noMultiShapesMayBeSelectedCheck(workbenchContext)) + .add(checkFactory + .createSelectedItemsLayersMustBeEditableCheck()); } } Added: core/trunk/src/org/openjump/core/ui/plugin/mousemenu/MeasureSelectedPlugIn.java =================================================================== --- core/trunk/src/org/openjump/core/ui/plugin/mousemenu/MeasureSelectedPlugIn.java (rev 0) +++ core/trunk/src/org/openjump/core/ui/plugin/mousemenu/MeasureSelectedPlugIn.java 2015-06-25 08:55:03 UTC (rev 4511) @@ -0,0 +1,135 @@ +package org.openjump.core.ui.plugin.mousemenu; + +import java.util.Collection; +import java.util.Iterator; + +import javax.swing.Icon; +import javax.swing.JComponent; + +import com.vividsolutions.jts.geom.Geometry; +import com.vividsolutions.jts.geom.GeometryCollection; +import com.vividsolutions.jts.geom.LineString; +import com.vividsolutions.jts.geom.MultiLineString; +import com.vividsolutions.jts.geom.Point; +import com.vividsolutions.jts.geom.Polygon; +import com.vividsolutions.jump.I18N; +import com.vividsolutions.jump.feature.Feature; +import com.vividsolutions.jump.feature.FeatureCollection; +import com.vividsolutions.jump.workbench.WorkbenchContext; +import com.vividsolutions.jump.workbench.model.Layer; +import com.vividsolutions.jump.workbench.model.MeasureLayerFinder; +import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn; +import com.vividsolutions.jump.workbench.plugin.EnableCheck; +import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory; +import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck; +import com.vividsolutions.jump.workbench.plugin.PlugInContext; +import com.vividsolutions.jump.workbench.ui.LayerViewPanel; +import com.vividsolutions.jump.workbench.ui.SelectionManager; +import com.vividsolutions.jump.workbench.ui.SelectionManagerProxy; +import com.vividsolutions.jump.workbench.ui.images.IconLoader; + +public class MeasureSelectedPlugIn extends AbstractPlugIn { + public static final String NAME = I18N + .get("org.openjump.core.ui.plugin.mousemenu.MeasureSelectedFeaturePlugIn.name"); + + public static final Icon ICON = IconLoader.icon("Ruler.gif"); + + public Icon getIcon() { + return ICON; + } + + public String getName() { + return NAME; + } + + public boolean execute(PlugInContext context) throws Exception { + reportNothingToUndoYet(context); + LayerViewPanel layerViewPanel = context.getWorkbenchContext() + .getLayerViewPanel(); + WorkbenchContext wbc = context.getWorkbenchContext(); + Collection layers = ((SelectionManagerProxy) wbc.getWorkbench() + .getFrame().getActiveInternalFrame()).getSelectionManager() + .getFeatureSelection().getLayersWithSelectedItems(); + // Giuseppe Aruta 2015-6-25 + // The code is already set for measuring multiple selected geometies. + // Enablecheck deactives that until a good solution is found for + // multigeometries (multiPolygon, multiLinestring, multipoint and + // geometry collections) + // and for points (measure coordinates) + for (Iterator li = layers.iterator(); li.hasNext();) { + Layer layer = (Layer) li.next(); + + FeatureCollection featureCollection = layer + .getFeatureCollectionWrapper(); + SelectionManager manager = context.getLayerViewPanel() + .getSelectionManager(); + // Collection feats = getFeatures(layer,context); + Collection feats = manager.createFeaturesFromSelectedItems(layer); + + for (Iterator i = feats.iterator(); i.hasNext();) { + try { + Feature feat = (Feature) i.next(); + layerViewPanel.setViewportInitialized(true); + + Geometry geom = feat.getGeometry(); + if (geom instanceof Polygon || geom instanceof LineString) { + measure(wbc, geom); + } + + else { + // Giuseppe Aruta 2015-6-25 + // Set here the code for multiplegeometries and point + + } + } catch (IllegalArgumentException e) { + context.getWorkbenchFrame().warnUser(e.toString()); + } + } + + } + + return true; + + } + + public void measure(WorkbenchContext context, Geometry geom) { + MeasureLayerFinder measureLayerFinder = new MeasureLayerFinder( + context.getLayerViewPanel(), context); + + measureLayerFinder.setMeasure(geom); + + // and set it visible + if (!measureLayerFinder.getLayer().isVisible()) { + measureLayerFinder.getLayer().setVisible(true); + } + + } + + public static EnableCheck createEnableCheck(final WorkbenchContext context) { + MultiEnableCheck mec = new MultiEnableCheck(); + + mec.add(new EnableCheckFactory(context) + .createWindowWithSelectionManagerMustBeActiveCheck()); + mec.add(new EnableCheckFactory(context) + .createExactlyNFeaturesMustBeSelectedCheck(1)); + + mec.add(new EnableCheck() { + public String check(JComponent component) { + Feature feat = + + (Feature) context.getLayerViewPanel().getSelectionManager() + .getFeaturesWithSelectedItems().iterator().next(); + Geometry geom = feat.getGeometry(); + + return geom instanceof GeometryCollection + || geom instanceof MultiLineString + || geom instanceof Point ? geom.getGeometryType() + + " - " + + I18N.get("org.openjump.core.ui.plugin.mousemenu.MeasureSelectedFeaturePlugin.message1") + : null; + } + }); + return mec; + } + +} Property changes on: core/trunk/src/org/openjump/core/ui/plugin/mousemenu/MeasureSelectedPlugIn.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Modified: core/trunk/src/org/openjump/core/ui/plugin/mousemenu/MoveAlongAnglePlugIn.java =================================================================== --- core/trunk/src/org/openjump/core/ui/plugin/mousemenu/MoveAlongAnglePlugIn.java 2015-06-25 08:41:54 UTC (rev 4510) +++ core/trunk/src/org/openjump/core/ui/plugin/mousemenu/MoveAlongAnglePlugIn.java 2015-06-25 08:55:03 UTC (rev 4511) @@ -38,7 +38,6 @@ import java.util.Iterator; import javax.swing.ImageIcon; -import javax.swing.JPopupMenu; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.CoordinateFilter; @@ -51,114 +50,142 @@ import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck; import com.vividsolutions.jump.workbench.plugin.PlugInContext; import com.vividsolutions.jump.workbench.ui.EditTransaction; -import com.vividsolutions.jump.workbench.ui.LayerViewPanel; import com.vividsolutions.jump.workbench.ui.MultiInputDialog; -import com.vividsolutions.jump.workbench.ui.plugin.FeatureInstaller; public class MoveAlongAnglePlugIn extends AbstractPlugIn { - - private final static String sMoveAlongAngle = I18N.get("org.openjump.core.ui.plugin.mousemenu.MoveAlongAnglePlugIn.Move-Along-Angle"); - private final static String sMoveSelectedFeaturesAlongAngle =I18N.get("org.openjump.core.ui.plugin.mousemenu.MoveAlongAnglePlugIn.Move-Selected-Features-Along-Angle"); - private final static String sTheDistanceInMapUnitsToMove=I18N.get("org.openjump.core.ui.plugin.mousemenu.MoveAlongAnglePlugIn.The-distance-in-map-units-to-move"); - private final static String sTheAngleInDegreesToMove = I18N.get("org.openjump.core.ui.plugin.mousemenu.MoveAlongAnglePlugIn.The-angle-in-degrees-to-move"); - private final static String sWillCovert = I18N.get("org.openjump.core.ui.plugin.mousemenu.MoveAlongAnglePlugIn.Will-convert-input-value-from-feet-to-meters"); - + + private final static String sMoveAlongAngle = I18N + .get("org.openjump.core.ui.plugin.mousemenu.MoveAlongAnglePlugIn.Move-Along-Angle"); + private final static String sMoveSelectedFeaturesAlongAngle = I18N + .get("org.openjump.core.ui.plugin.mousemenu.MoveAlongAnglePlugIn.Move-Selected-Features-Along-Angle"); + private final static String sTheDistanceInMapUnitsToMove = I18N + .get("org.openjump.core.ui.plugin.mousemenu.MoveAlongAnglePlugIn.The-distance-in-map-units-to-move"); + private final static String sTheAngleInDegreesToMove = I18N + .get("org.openjump.core.ui.plugin.mousemenu.MoveAlongAnglePlugIn.The-angle-in-degrees-to-move"); + private final static String sWillCovert = I18N + .get("org.openjump.core.ui.plugin.mousemenu.MoveAlongAnglePlugIn.Will-convert-input-value-from-feet-to-meters"); + private WorkbenchContext workbenchContext; - private final static String ANGLE = I18N.get("org.openjump.core.ui.plugin.mousemenu.MoveAlongAnglePlugIn.Move-Angle"); - private final static String DISTANCE = I18N.get("org.openjump.core.ui.plugin.mousemenu.MoveAlongAnglePlugIn.Move-Distance"); - private final double Deg2Rad = 0.0174532925199432; //pi/180 + private final static String ANGLE = I18N + .get("org.openjump.core.ui.plugin.mousemenu.MoveAlongAnglePlugIn.Move-Angle"); + private final static String DISTANCE = I18N + .get("org.openjump.core.ui.plugin.mousemenu.MoveAlongAnglePlugIn.Move-Distance"); + private final double Deg2Rad = 0.0174532925199432; // pi/180 private MultiInputDialog dialog; private double moveAngle = 0.0; private double moveDistance = 1.0; - private final static String CONVERTTOMETERS = I18N.get("org.openjump.core.ui.plugin.mousemenu.MoveAlongAnglePlugIn.Convert-Feet-to-Meters"); + private final static String CONVERTTOMETERS = I18N + .get("org.openjump.core.ui.plugin.mousemenu.MoveAlongAnglePlugIn.Convert-Feet-to-Meters"); private double conversionFactor = 1.0; - public void initialize(PlugInContext context) throws Exception - { - workbenchContext = context.getWorkbenchContext(); - FeatureInstaller featureInstaller = new FeatureInstaller(workbenchContext); - JPopupMenu popupMenu = LayerViewPanel.popupMenu(); - featureInstaller.addPopupMenuItem(popupMenu, - this, sMoveAlongAngle, - false, null, //to do: add icon - this.createEnableCheck(workbenchContext)); + public String getName() { + return sMoveAlongAngle; } - + + /* + * public void initialize(PlugInContext context) throws Exception { + * workbenchContext = context.getWorkbenchContext(); FeatureInstaller + * featureInstaller = new FeatureInstaller(workbenchContext); JPopupMenu + * popupMenu = LayerViewPanel.popupMenu(); + * featureInstaller.addPopupMenuItem(popupMenu, this, sMoveAlongAngle, + * false, null, //to do: add icon this.createEnableCheck(workbenchContext)); + * } + */ + public boolean execute(final PlugInContext context) throws Exception { final ArrayList transactions = new ArrayList(); reportNothingToUndoYet(context); MultiInputDialog dialog = new MultiInputDialog( - context.getWorkbenchFrame(), getName(), true); + context.getWorkbenchFrame(), getName(), true); setDialogValues(dialog, context); dialog.setVisible(true); - if (! dialog.wasOKPressed()) { return false; } + if (!dialog.wasOKPressed()) { + return false; + } getDialogValues(dialog); - + double angle = Deg2Rad * moveAngle; double x = Math.cos(angle) * moveDistance * conversionFactor; double y = Math.sin(angle) * moveDistance * conversionFactor; - Coordinate displacement = new Coordinate(x,y); + Coordinate displacement = new Coordinate(x, y); workbenchContext = context.getWorkbenchContext(); - for (Iterator i = workbenchContext.getLayerViewPanel().getSelectionManager().getLayersWithSelectedItems().iterator(); - i.hasNext(); - ) { + for (Iterator i = workbenchContext.getLayerViewPanel() + .getSelectionManager().getLayersWithSelectedItems().iterator(); i + .hasNext();) { Layer layerWithSelectedItems = (Layer) i.next(); - transactions.add(createTransaction(layerWithSelectedItems, displacement)); + transactions.add(createTransaction(layerWithSelectedItems, + displacement)); } EditTransaction.commit(transactions); return true; } - - private void setDialogValues(MultiInputDialog dialog, PlugInContext context) - { - dialog.setSideBarImage(new ImageIcon(getClass().getResource("Compass.png"))); + + private void setDialogValues(MultiInputDialog dialog, PlugInContext context) { + dialog.setSideBarImage(new ImageIcon(getClass().getResource( + "Compass.png"))); dialog.setSideBarDescription(sMoveSelectedFeaturesAlongAngle); - dialog.addDoubleField(DISTANCE, moveDistance, 6, sTheDistanceInMapUnitsToMove); + dialog.addDoubleField(DISTANCE, moveDistance, 6, + sTheDistanceInMapUnitsToMove); dialog.addDoubleField(ANGLE, moveAngle, 6, sTheAngleInDegreesToMove); - dialog.addCheckBox(CONVERTTOMETERS, (!(conversionFactor == 1.0)), sWillCovert); - } + dialog.addCheckBox(CONVERTTOMETERS, (!(conversionFactor == 1.0)), + sWillCovert); + } - private void getDialogValues(MultiInputDialog dialog) { - if(dialog.getCheckBox(CONVERTTOMETERS).isSelected()) - conversionFactor = 0.3048; + private void getDialogValues(MultiInputDialog dialog) { + if (dialog.getCheckBox(CONVERTTOMETERS).isSelected()) + conversionFactor = 0.3048; else - conversionFactor = 1.0; + conversionFactor = 1.0; moveDistance = dialog.getDouble(DISTANCE); moveAngle = dialog.getDouble(ANGLE); - } + } - private EditTransaction createTransaction(Layer layer, final Coordinate displacement) { - EditTransaction transaction = - EditTransaction.createTransactionOnSelection(new EditTransaction.SelectionEditor() { - public Geometry edit(Geometry geometryWithSelectedItems, Collection selectedItems) { - for (Iterator j = selectedItems.iterator(); j.hasNext();) { - Geometry item = (Geometry) j.next(); - move(item, displacement); - } + private EditTransaction createTransaction(Layer layer, + final Coordinate displacement) { + EditTransaction transaction = EditTransaction + .createTransactionOnSelection( + new EditTransaction.SelectionEditor() { + public Geometry edit( + Geometry geometryWithSelectedItems, + Collection selectedItems) { + for (Iterator j = selectedItems.iterator(); j + .hasNext();) { + Geometry item = (Geometry) j.next(); + move(item, displacement); + } - return geometryWithSelectedItems; - } - }, workbenchContext.getLayerViewPanel(), workbenchContext.getLayerViewPanel().getContext(), getName(), layer, false,false);// isRollingBackInvalidEdits(), false); + return geometryWithSelectedItems; + } + }, workbenchContext.getLayerViewPanel(), + workbenchContext.getLayerViewPanel().getContext(), + getName(), layer, false, false);// isRollingBackInvalidEdits(), + // false); return transaction; } private void move(Geometry geometry, final Coordinate displacement) { geometry.apply(new CoordinateFilter() { public void filter(Coordinate coordinate) { - //coordinate.setCoordinate(CoordUtil.add(coordinate, displacement)); + // coordinate.setCoordinate(CoordUtil.add(coordinate, + // displacement)); coordinate.x += displacement.x; coordinate.y += displacement.y; } }); } - - public MultiEnableCheck createEnableCheck(final WorkbenchContext workbenchContext) { - EnableCheckFactory checkFactory = new EnableCheckFactory(workbenchContext); + + public MultiEnableCheck createEnableCheck( + final WorkbenchContext workbenchContext) { + EnableCheckFactory checkFactory = new EnableCheckFactory( + workbenchContext); return new MultiEnableCheck() - .add(checkFactory.createWindowWithLayerViewPanelMustBeActiveCheck()) - .add(checkFactory.createAtLeastNFeaturesMustHaveSelectedItemsCheck(1)) - .add(checkFactory.createSelectedItemsLayersMustBeEditableCheck()); + .add(checkFactory + .createWindowWithLayerViewPanelMustBeActiveCheck()) + .add(checkFactory + .createAtLeastNFeaturesMustHaveSelectedItemsCheck(1)) + .add(checkFactory + .createSelectedItemsLayersMustBeEditableCheck()); } } Modified: core/trunk/src/org/openjump/core/ui/plugin/mousemenu/RotatePlugIn.java =================================================================== --- core/trunk/src/org/openjump/core/ui/plugin/mousemenu/RotatePlugIn.java 2015-06-25 08:41:54 UTC (rev 4510) +++ core/trunk/src/org/openjump/core/ui/plugin/mousemenu/RotatePlugIn.java 2015-06-25 08:55:03 UTC (rev 4511) @@ -36,8 +36,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; + import javax.swing.ImageIcon; -import javax.swing.JPopupMenu; import org.openjump.core.ui.images.IconLoader; @@ -53,137 +53,165 @@ import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck; import com.vividsolutions.jump.workbench.plugin.PlugInContext; import com.vividsolutions.jump.workbench.ui.EditTransaction; -import com.vividsolutions.jump.workbench.ui.GUIUtil; -import com.vividsolutions.jump.workbench.ui.LayerViewPanel; import com.vividsolutions.jump.workbench.ui.MultiInputDialog; -import com.vividsolutions.jump.workbench.ui.cursortool.FeatureInfoTool; -import com.vividsolutions.jump.workbench.ui.plugin.FeatureInstaller; public class RotatePlugIn extends AbstractPlugIn { - - private static final String sRotate = I18N.get("org.openjump.core.ui.plugin.mousemenu.RotatePlugIn.Rotate"); - private static final String sRotateSelectedFeatures = I18N.get("org.openjump.core.ui.plugin.mousemenu.RotatePlugIn.Rotate-Selected-Features"); - private static final String sRotateAbout = I18N.get("org.openjump.core.ui.plugin.mousemenu.RotatePlugIn.Rotate-about"); - private static final String sTheAngleInDegreesClockwise = I18N.get("org.openjump.core.ui.plugin.mousemenu.RotatePlugIn.The-angle-in-degrees-clockwise"); - - private static final String METHOD_ABOUTCENTER = I18N.get("org.openjump.core.ui.plugin.mousemenu.RotatePlugIn.Center"); - private static final String METHOD_ABOUTCLICKPOINT = I18N.get("org.openjump.core.ui.plugin.mousemenu.RotatePlugIn.Click-Point"); - private final static String ANGLE = I18N.get("org.openjump.core.ui.plugin.mousemenu.RotatePlugIn.Rotation-Angle"); - private final static String ROTATEABOUT = I18N.get("org.openjump.core.ui.plugin.mousemenu.RotatePlugIn.Rotate-About"); - private final double Deg2Rad = 0.0174532925199432; //pi/180 + + private static final String sRotate = I18N + .get("org.openjump.core.ui.plugin.mousemenu.RotatePlugIn.Rotate"); + private static final String sRotateSelectedFeatures = I18N + .get("org.openjump.core.ui.plugin.mousemenu.RotatePlugIn.Rotate-Selected-Features"); + private static final String sRotateAbout = I18N + .get("org.openjump.core.ui.plugin.mousemenu.RotatePlugIn.Rotate-about"); + private static final String sTheAngleInDegreesClockwise = I18N + .get("org.openjump.core.ui.plugin.mousemenu.RotatePlugIn.The-angle-in-degrees-clockwise"); + + private static final String METHOD_ABOUTCENTER = I18N + .get("org.openjump.core.ui.plugin.mousemenu.RotatePlugIn.Center"); + private static final String METHOD_ABOUTCLICKPOINT = I18N + .get("org.openjump.core.ui.plugin.mousemenu.RotatePlugIn.Click-Point"); + private final static String ANGLE = I18N + .get("org.openjump.core.ui.plugin.mousemenu.RotatePlugIn.Rotation-Angle"); + private final static String ROTATEABOUT = I18N + .get("org.openjump.core.ui.plugin.mousemenu.RotatePlugIn.Rotate-About"); + private final double Deg2Rad = 0.0174532925199432; // pi/180 private WorkbenchContext workbenchContext; private double rotateAngle = 45.0; private double radiansAngle = 0.0; private double cosAngle = 0.0; private double sinAngle = 0.0; - private Coordinate rotationPoint = new Coordinate(0.0,0.0); + private Coordinate rotationPoint = new Coordinate(0.0, 0.0); private Collection methodNames = new ArrayList(); private String methodNameToRun = METHOD_ABOUTCENTER; public static final ImageIcon ICON = IconLoader.icon("Rotate16.gif"); - public void initialize(PlugInContext context) throws Exception - { - workbenchContext = context.getWorkbenchContext(); - FeatureInstaller featureInstaller = new FeatureInstaller(workbenchContext); - JPopupMenu popupMenu = LayerViewPanel.popupMenu(); - featureInstaller.addPopupMenuItem(popupMenu, - this, sRotate, - false, ICON, - this.createEnableCheck(workbenchContext)); + public String getName() { + return sRotate; + } + + public void initialize(PlugInContext context) throws Exception { + /* + * workbenchContext = context.getWorkbenchContext(); FeatureInstaller + * featureInstaller = new FeatureInstaller(workbenchContext); JPopupMenu + * popupMenu = LayerViewPanel.popupMenu(); + * featureInstaller.addPopupMenuItem(popupMenu, this, sRotate, false, + * ICON, this.createEnableCheck(workbenchContext)); + */ methodNames.add(METHOD_ABOUTCENTER); - methodNames.add(METHOD_ABOUTCLICKPOINT); + methodNames.add(METHOD_ABOUTCLICKPOINT); } - + public boolean execute(final PlugInContext context) throws Exception { final ArrayList transactions = new ArrayList(); reportNothingToUndoYet(context); MultiInputDialog dialog = new MultiInputDialog( - context.getWorkbenchFrame(), getName(), true); + context.getWorkbenchFrame(), getName(), true); setDialogValues(dialog, context); - ///GUIUtil.centreOnWindow(dialog); + // /GUIUtil.centreOnWindow(dialog); dialog.setVisible(true); - if (! dialog.wasOKPressed()) { return false; } + if (!dialog.wasOKPressed()) { + return false; + } getDialogValues(dialog); - + workbenchContext = context.getWorkbenchContext(); Collection layers = workbenchContext.getLayerViewPanel() - .getSelectionManager().getLayersWithSelectedItems(); + .getSelectionManager().getLayersWithSelectedItems(); if (methodNameToRun.equals(METHOD_ABOUTCENTER)) { - //rotationPoint = getRotationPoint(layers); + // rotationPoint = getRotationPoint(layers); Envelope en = new Envelope(); - Collection geometries = context.getLayerViewPanel().getSelectionManager().getSelectedItems(); - for (Iterator j = geometries.iterator(); j.hasNext();) - { + Collection geometries = context.getLayerViewPanel() + .getSelectionManager().getSelectedItems(); + for (Iterator j = geometries.iterator(); j.hasNext();) { Geometry geometry = (Geometry) j.next(); en.expandToInclude(geometry.getEnvelopeInternal()); } - rotationPoint.x = en.getMinX()+(en.getMaxX()-en.getMinX())/2.0; - rotationPoint.y = en.getMinY()+(en.getMaxY()-en.getMinY())/2.0; + rotationPoint.x = en.getMinX() + (en.getMaxX() - en.getMinX()) + / 2.0; + rotationPoint.y = en.getMinY() + (en.getMaxY() - en.getMinY()) + / 2.0; + } else if (methodNameToRun.equals(METHOD_ABOUTCLICKPOINT)) { + rotationPoint = context + .getLayerViewPanel() + .getViewport() + .toModelCoordinate( + context.getLayerViewPanel().getLastClickedPoint()); } - else if (methodNameToRun.equals(METHOD_ABOUTCLICKPOINT)) { - rotationPoint = context.getLayerViewPanel().getViewport().toModelCoordinate( - context.getLayerViewPanel().getLastClickedPoint()); - } radiansAngle = Deg2Rad * rotateAngle; cosAngle = Math.cos(radiansAngle); sinAngle = Math.sin(radiansAngle); - for (Iterator i = layers.iterator(); - i.hasNext(); - ) { + for (Iterator i = layers.iterator(); i.hasNext();) { Layer layerWithSelectedItems = (Layer) i.next(); transactions.add(createTransaction(layerWithSelectedItems)); } EditTransaction.commit(transactions); return true; } - - private void setDialogValues(MultiInputDialog dialog, PlugInContext context) - { - dialog.setSideBarImage(new ImageIcon(getClass().getResource("Rotate.png"))); + + private void setDialogValues(MultiInputDialog dialog, PlugInContext context) { + dialog.setSideBarImage(new ImageIcon(getClass().getResource( + "Rotate.png"))); dialog.setSideBarDescription(sRotateSelectedFeatures); - dialog.addComboBox(ROTATEABOUT, methodNameToRun , methodNames, sRotateAbout); - dialog.addDoubleField(ANGLE, rotateAngle, 6, sTheAngleInDegreesClockwise); + dialog.addComboBox(ROTATEABOUT, methodNameToRun, methodNames, + sRotateAbout); + dialog.addDoubleField(ANGLE, rotateAngle, 6, + sTheAngleInDegreesClockwise); } private void getDialogValues(MultiInputDialog dialog) { - //JComboBox combobox = dialog.getComboBox(ROTATEABOUT); + // JComboBox combobox = dialog.getComboBox(ROTATEABOUT); methodNameToRun = dialog.getText(ROTATEABOUT); rotateAngle = dialog.getDouble(ANGLE); } - + private EditTransaction createTransaction(Layer layer) { - EditTransaction transaction = - EditTransaction.createTransactionOnSelection(new EditTransaction.SelectionEditor() { - public Geometry edit(Geometry geometryWithSelectedItems, Collection selectedItems) { - for (Iterator j = selectedItems.iterator(); j.hasNext();) { - Geometry item = (Geometry) j.next(); - rotate(item); - } - return geometryWithSelectedItems; - } - }, workbenchContext.getLayerViewPanel(), workbenchContext.getLayerViewPanel().getContext(), getName(), layer, false,false);// isRollingBackInvalidEdits(), false); + EditTransaction transaction = EditTransaction + .createTransactionOnSelection( + new EditTransaction.SelectionEditor() { + public Geometry edit( + Geometry geometryWithSelectedItems, + Collection selectedItems) { + for (Iterator j = selectedItems.iterator(); j + .hasNext();) { + Geometry item = (Geometry) j.next(); + rotate(item); + } + return geometryWithSelectedItems; + } + }, workbenchContext.getLayerViewPanel(), + workbenchContext.getLayerViewPanel().getContext(), + getName(), layer, false, false);// isRollingBackInvalidEdits(), + // false); return transaction; } - //rotate geometry about rotationPoint by rotationAngle degrees (+ clockwise) + // rotate geometry about rotationPoint by rotationAngle degrees (+ + // clockwise) private void rotate(Geometry geometry) { geometry.apply(new CoordinateFilter() { public void filter(Coordinate coordinate) { double x = coordinate.x - rotationPoint.x; double y = coordinate.y - rotationPoint.y; - coordinate.x = rotationPoint.x + (x*cosAngle) + (y*sinAngle); - coordinate.y = rotationPoint.y + (y*cosAngle) - (x*sinAngle); - } + coordinate.x = rotationPoint.x + (x * cosAngle) + + (y * sinAngle); + coordinate.y = rotationPoint.y + (y * cosAngle) + - (x * sinAngle); + } }); } - - public MultiEnableCheck createEnableCheck(final WorkbenchContext workbenchContext) { - EnableCheckFactory checkFactory = new EnableCheckFactory(workbenchContext); + + public MultiEnableCheck createEnableCheck( + final WorkbenchContext workbenchContext) { + EnableCheckFactory checkFactory = new EnableCheckFactory( + workbenchContext); return new MultiEnableCheck() - .add(checkFactory.createWindowWithLayerViewPanelMustBeActiveCheck()) - .add(checkFactory.createAtLeastNFeaturesMustHaveSelectedItemsCheck(1)) - .add(checkFactory.createSelectedItemsLayersMustBeEditableCheck()); + .add(checkFactory + .createWindowWithLayerViewPanelMustBeActiveCheck()) + .add(checkFactory + .createAtLeastNFeaturesMustHaveSelectedItemsCheck(1)) + .add(checkFactory + .createSelectedItemsLayersMustBeEditableCheck()); } } ------------------------------------------------------------------------------ Monitor 25 network devices or servers for free with OpManager! OpManager is web-based network management software that monitors network devices and physical & virtual servers, alerts via email & sms for fault. Monitor 25 devices for free with no restriction. Download now http://ad.doubleclick.net/ddm/clk/292181274;119417398;o _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel