Revision: 5868
          http://sourceforge.net/p/jump-pilot/code/5868
Author:   ma15569
Date:     2018-06-09 05:49:41 +0000 (Sat, 09 Jun 2018)
Log Message:
-----------
profile plugin can define source raster using the list of raster loaded into OJ

Modified Paths:
--------------
    core/trunk/src/org/openjump/core/ui/plugin/raster/ProfileGraphPlugIn.java
    core/trunk/src/org/openjump/core/ui/plugin/raster/ProfileUtils.java

Modified: 
core/trunk/src/org/openjump/core/ui/plugin/raster/ProfileGraphPlugIn.java
===================================================================
--- core/trunk/src/org/openjump/core/ui/plugin/raster/ProfileGraphPlugIn.java   
2018-06-09 05:32:25 UTC (rev 5867)
+++ core/trunk/src/org/openjump/core/ui/plugin/raster/ProfileGraphPlugIn.java   
2018-06-09 05:49:41 UTC (rev 5868)
@@ -56,9 +56,11 @@
 import com.vividsolutions.jump.workbench.plugin.PlugInContext;
 import com.vividsolutions.jump.workbench.plugin.ThreadedBasePlugIn;
 import com.vividsolutions.jump.workbench.ui.GUIUtil;
+import com.vividsolutions.jump.workbench.ui.GenericNames;
 import com.vividsolutions.jump.workbench.ui.MenuNames;
 import com.vividsolutions.jump.workbench.ui.MultiInputDialog;
 import com.vividsolutions.jump.workbench.ui.images.IconLoader;
+import com.vividsolutions.jump.workbench.ui.plugin.FeatureInstaller;
 
 //import org.openjump.core.rasterimage.sextante.OpenJUMPSextanteRasterLayer;
 
@@ -82,7 +84,7 @@
     private final String warning = I18N
             
.get("org.openjump.core.ui.plugin.raster.ProfileGraphTool.select-one-linstring");;
     final static String MONITOR_STRING = "Calculating profile...";
-
+    public static String CLAYER = GenericNames.SELECT_LAYER;
     private boolean drawnType = true;
     private boolean selectedType = false;
     public static MultiInputDialog dialog;
@@ -93,7 +95,7 @@
     public void initialize(PlugInContext context) throws Exception {
         sName = I18N
                 
.get("org.openjump.core.ui.plugin.raster.ProfileGraphPlugIn.Profile-Graph");
-        context.getFeatureInstaller().addMainMenuPlugin(this,
+        FeatureInstaller.getInstance().addMainMenuPlugin(this,
                 new String[] { MenuNames.RASTER }, sName + "...", false,
                 getIcon(), createEnableCheck(context.getWorkbenchContext()));
     }
@@ -100,17 +102,13 @@
 
     public static MultiEnableCheck createEnableCheck(
             WorkbenchContext workbenchContext) {
-        final EnableCheckFactory checkFactory = new EnableCheckFactory(
-                workbenchContext);
-        final MultiEnableCheck multiEnableCheck = new MultiEnableCheck();
-
-        multiEnableCheck.add(
-                checkFactory.createExactlyNLayerablesMustBeSelectedCheck(1,
-                        RasterImageLayer.class)).add(
-                checkFactory
-                        .createRasterImageLayerExactlyNBandsMustExistCheck(1));
-
-        return multiEnableCheck;
+        final EnableCheckFactory checkFactory = EnableCheckFactory
+                .getInstance();
+        return new MultiEnableCheck()
+                .add(checkFactory
+                        
.createWindowWithAssociatedTaskFrameMustBeActiveCheck())
+                .add(checkFactory.createAtLeastNLayerablesOfTypeMustExistCheck(
+                        1, RasterImageLayer.class));
     }
 
     private void getDialogValues(MultiInputDialog dialog) {
@@ -120,8 +118,12 @@
     }
 
     private void setDialogValues(MultiInputDialog dialog, PlugInContext 
context) {
+        final Collection<RasterImageLayer> rlayers = context.getTask()
+                .getLayerManager().getLayerables(RasterImageLayer.class);
         final String OUTPUT_GROUP = "Match Type";
         dialog.setTitle(sName);
+        dialog.addLayerableComboBox(CLAYER, context.getLayerManager()
+                .getRasterImageLayers().get(0), "", rlayers);
         dialog.addRadioButton(drawn, OUTPUT_GROUP, drawnType, null);
 
         final Collection<Feature> features = context.getLayerViewPanel()

Modified: core/trunk/src/org/openjump/core/ui/plugin/raster/ProfileUtils.java
===================================================================
--- core/trunk/src/org/openjump/core/ui/plugin/raster/ProfileUtils.java 
2018-06-09 05:32:25 UTC (rev 5867)
+++ core/trunk/src/org/openjump/core/ui/plugin/raster/ProfileUtils.java 
2018-06-09 05:49:41 UTC (rev 5868)
@@ -2,17 +2,14 @@
 
 import java.awt.Font;
 import java.io.IOException;
-import java.text.DateFormat;
 import java.text.DecimalFormat;
 import java.text.NumberFormat;
-import java.text.SimpleDateFormat;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
 import java.util.Locale;
+import java.util.Random;
 
 import org.math.plot.render.AbstractDrawer;
-import org.openjump.core.apitools.LayerTools;
 import org.openjump.core.attributeoperations.AttributeOp;
 import org.openjump.core.rasterimage.RasterImageLayer;
 import org.openjump.core.ui.plot.Plot2DPanelOJ;
@@ -73,8 +70,9 @@
             .getFrame().getContext();
 
     public static RasterImageLayer getLayer() {
-        return (RasterImageLayer) LayerTools.getSelectedLayerable(context,
-                RasterImageLayer.class);
+        return ProfileGraphPlugIn.dialog
+                .getRasterLayer(ProfileGraphPlugIn.CLAYER);
+
     }
 
     public static GeometryFactory gf = new GeometryFactory();
@@ -83,6 +81,7 @@
     public static double dDist = 0, dHorzDist = 0;
     public static double m_dLastX, m_dLastY, m_dLastZ;
     public static int nPoints = 0;
+    public static int n = 0;
 
     public static ArrayList<Coordinate> coordinates = new 
ArrayList<Coordinate>();
     static double max, min, sum, mean, width, height, slope, cellsize,
@@ -96,31 +95,32 @@
 
         final LineString line = gf.createLineString(coords);
         if (line.within(rLayer.getWholeImageEnvelopeAsGeometry())) {
+            final Random rand = new Random();
+            n = rand.nextInt(100) + 1;
             processLine(line);
             if ((resultFC != null) && (resultFC.size() > 0)) {
+                final FeatureDataset fd = new FeatureDataset(resultFSchema);
+                fd.addAll(resultFC.getFeatures());
                 context.getLayerManager().addLayer(
-                        StandardCategoryNames.RESULT, PROFILEPTS, resultFC);
+                        StandardCategoryNames.RESULT, PROFILEPTS, fd);
             }
 
-            final DateFormat dateFormat = new SimpleDateFormat(
-                    "yyyy/MM/dd HH:mm:ss");
-            final Date date = new Date();
             final FeatureCollectionPanel fPan = new FeatureCollectionPanel(
                     resultFC);
-            fPan.getCommandPanel().setVisible(false);
-            AdditionalResults.addAdditionalResult(
-                    PLOT + "-" + dateFormat.format(date) + " " + PROFILE_INFO,
-                    getStatisticPanel(rLayer));
+            fPan.setName("" + n);
+            fPan.getSouthPanel().setVisible(false);
+            AdditionalResults.addAdditionalResult(PLOT + "-" + n + " "
+                    + PROFILE_INFO, getStatisticPanel(rLayer));
             AdditionalResults
                     .addAdditionalResult(
                             PLOT
                                     + "-"
-                                    + dateFormat.format(date)
+                                    + n
                                     + " "
                                     + 
I18N.get("org.openjump.core.ui.plugin.raster.ProfileGraphTool.values"),
                             fPan);
-            AdditionalResults.addAdditionalResultAndShow(PLOT + "-"
-                    + dateFormat.format(date), getPlotPanel(resultFC));
+            AdditionalResults.addAdditionalResultAndShow(PLOT + "-" + n,
+                    getPlotPanel(resultFC));
 
         } else {
             context.getLayerViewPanel()
@@ -331,4 +331,5 @@
         return plot2dA;
 
     }
+
 }


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to