[JPP-Devel] SVN: [4474] core/trunk

2015-06-04 Thread jump-pilot-svn
Revision: 4474
  http://sourceforge.net/p/jump-pilot/code/4474
Author:   ma15569
Date: 2015-06-04 13:16:46 + (Thu, 04 Jun 2015)
Log Message:
---
Add WMS Legend plugin to WMS layer context menu

Modified Paths:
--
core/trunk/ChangeLog
core/trunk/scripts/default-plugins.xml
core/trunk/src/language/jump.properties

Added Paths:
---
core/trunk/src/org/openjump/core/ui/plugin/wms/WMSLegendPlugIn.java

Modified: core/trunk/ChangeLog
===
--- core/trunk/ChangeLog2015-06-03 22:29:04 UTC (rev 4473)
+++ core/trunk/ChangeLog2015-06-04 13:16:46 UTC (rev 4474)
@@ -1,5 +1,8 @@
 # for display continuity sake please use 2 spaces instead of tabs
 
+2015-06-04 Giuseppe Aruta 
+  * Add WMS Legend plugin to WMS layer context menu
+
 2015-06-01 mmichaud 
   * new select tool to select one or several overlapping features
 

Modified: core/trunk/scripts/default-plugins.xml
===
--- core/trunk/scripts/default-plugins.xml  2015-06-03 22:29:04 UTC (rev 
4473)
+++ core/trunk/scripts/default-plugins.xml  2015-06-04 13:16:46 UTC (rev 
4474)
@@ -1260,8 +1260,14 @@



+   
+   
+   org.openjump.core.ui.plugin.wms.WMSLegendPlugIn
+   
+   
+   
+   
 
-


org.openjump.core.ui.plugin.layer.ToggleVisibilityPlugIn

Modified: core/trunk/src/language/jump.properties
===
--- core/trunk/src/language/jump.properties 2015-06-03 22:29:04 UTC (rev 
4473)
+++ core/trunk/src/language/jump.properties 2015-06-04 13:16:46 UTC (rev 
4474)
@@ -2551,3 +2551,6 @@
 ui.AttributeTablePanel.feature.view-edit=View/Edit
 
org.openjump.core.ui.plugin.file.open.OpenFileWizardState.dummy-loader-description=Dummy
 loader (ignore data)
 
org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.statistics=Statistics
+org.openjump.core.ui.plugin.wms.WMSLegendPlugIn=Show WMS Layer Legend
+org.openjump.core.ui.plugin.wms.WMSLegendPlugIn.panel=WMS Legend
+org.openjump.core.ui.plugin.wms.WMSLegendPlugIn.message=Error or no legend 
associated to selected layer
\ No newline at end of file

Added: core/trunk/src/org/openjump/core/ui/plugin/wms/WMSLegendPlugIn.java
===
--- core/trunk/src/org/openjump/core/ui/plugin/wms/WMSLegendPlugIn.java 
(rev 0)
+++ core/trunk/src/org/openjump/core/ui/plugin/wms/WMSLegendPlugIn.java 
2015-06-04 13:16:46 UTC (rev 4474)
@@ -0,0 +1,185 @@
+package org.openjump.core.ui.plugin.wms;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.GridBagLayout;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.imageio.ImageIO;
+import javax.swing.BoxLayout;
+import javax.swing.ImageIcon;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+
+import org.apache.commons.lang.StringUtils;
+import org.openjump.core.apitools.LayerTools;
+
+import com.vividsolutions.jump.I18N;
+import com.vividsolutions.jump.workbench.WorkbenchContext;
+import com.vividsolutions.jump.workbench.model.WMSLayer;
+import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;
+import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory;
+import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck;
+import com.vividsolutions.jump.workbench.plugin.PlugInContext;
+import com.vividsolutions.wms.MapLayer;
+
+/**
+ * Giuseppe Aruta 2015_6_4 Plugin that allows to show the legends of WMS layer
+ */
+
+public class WMSLegendPlugIn extends AbstractPlugIn {
+
+public WMSLegendPlugIn() {
+super();
+}
+
+public boolean execute(final PlugInContext context) throws Exception {
+
+JDialog dialogLegend = new JDialog(context.getWorkbenchFrame(), PANEL,
+false);
+dialogLegend.setSize(200, 500);
+JScrollPane sp = new JScrollPane(getLegendPanel(context));
+
+dialogLegend.add(sp);
+
+/*
+ * JPanel savePanel = new JPanel(); JButton saveButton = new JButton(
+ * I18N.get("deejump.plugin.SaveLegendPlugIn.Save-legend"));
+ * savePanel.add(saveButton);
+ * 
+ * saveButton.setAction(new SaveImageAsAction(dialogLegend,
+ * getLegendPanel(context)));// getLegendPanel(context)));
+ * 
+ * 
+ * dialogLegend.add(savePanel, BorderLayout.SOUTH);
+ */
+
+dialogLegend.setVisible(true);
+dialogLegend.validate();
+
+return true;
+}
+
+// Get the WMS legend URL by name of layer
+private String 

[JPP-Devel] New WMS Layer legend plugin on OpenJUMP

2015-06-04 Thread Giuseppe Aruta
Dear Jumpers,
I added on OpenJUMP a new plugin that displays WMS layer(s) legend (if
available) on a Dialog.
This plugin is located on WMS Layer tree context menu, as "Show WMS Layer
Legend".
The code originally came from Kosmo SAIG and it was completely rewritten in
order to adapt WMS GetLegendGraphic and GetStyle operators without modifing
OJ WMS classes.

Best Regards

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


Re: [JPP-Devel] New WMS Layer legend plugin on OpenJUMP

2015-06-04 Thread Giuseppe Aruta
The plugin will be available on OJ 4474 Night Snapshot

2015-06-04 15:24 GMT+02:00 Giuseppe Aruta :

> Dear Jumpers,
> I added on OpenJUMP a new plugin that displays WMS layer(s) legend (if
> available) on a Dialog.
> This plugin is located on WMS Layer tree context menu, as "Show WMS Layer
> Legend".
> The code originally came from Kosmo SAIG and it was completely rewritten
> in order to adapt WMS GetLegendGraphic and GetStyle operators without
> modifing OJ WMS classes.
>
> Best Regards
>
> Peppe
>
>
--
___
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel


Re: [JPP-Devel] New WMS Layer legend plugin on OpenJUMP

2015-06-04 Thread Rahkonen Jukka (MML)
Hi Peppe,

Seems to work with Geoserver and it generates also a correct URL for Mapserver 
so it should work. However, there is some little issue with sites using basic 
authentication. I think that the plugin is sending the request without 
credentials or something like that. Note that the error log shows URL as
URL: https://username:pas...@site.fi/cgi-bin/service1? and if I copy the whole 
URL into browser I get the legend graphics. However, OpenJUMP gets an http 401 
“not authorized” response.


javax.imageio.IIOException: Can't get input stream from URL!
 at javax.imageio.ImageIO.read(Unknown Source)
 at 
org.openjump.core.ui.plugin.wms.WMSLegendPlugIn.getLegendPanel(WMSLegendPlugIn.java:150)
 at 
org.openjump.core.ui.plugin.wms.WMSLegendPlugIn.execute(WMSLegendPlugIn.java:48)
 at 
com.vividsolutions.jump.workbench.plugin.AbstractPlugIn$1.actionPerformed(AbstractPlugIn.java:342)
 at 
javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
 at 
javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
 at 
javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
 at 
javax.swing.DefaultButtonModel.setPressed(Unknown Source)
 at javax.swing.AbstractButton.doClick(Unknown 
Source)
 at 
javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
 at 
javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
 at java.awt.Component.processMouseEvent(Unknown 
Source)
 at 
javax.swing.JComponent.processMouseEvent(Unknown Source)
 at java.awt.Component.processEvent(Unknown Source)
 at java.awt.Container.processEvent(Unknown Source)
 at java.awt.Component.dispatchEventImpl(Unknown 
Source)
 at java.awt.Container.dispatchEventImpl(Unknown 
Source)
 at java.awt.Component.dispatchEvent(Unknown Source)
 at 
java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
 at 
java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
 at 
java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
 at java.awt.Container.dispatchEventImpl(Unknown 
Source)
 at java.awt.Window.dispatchEventImpl(Unknown 
Source)
 at java.awt.Component.dispatchEvent(Unknown Source)
 at java.awt.EventQueue.dispatchEventImpl(Unknown 
Source)
 at java.awt.EventQueue.access$200(Unknown Source)
 at java.awt.EventQueue$3.run(Unknown Source)
 at java.awt.EventQueue$3.run(Unknown Source)
 at 
java.security.AccessController.doPrivileged(Native Method)
 at 
java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
 at 
java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
 at java.awt.EventQueue$4.run(Unknown Source)
 at java.awt.EventQueue$4.run(Unknown Source)
 at 
java.security.AccessController.doPrivileged(Native Method)
 at 
java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
 at java.awt.EventQueue.dispatchEvent(Unknown 
Source)
 at 
java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
 at 
java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
 at 
java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
 at java.awt.EventDispatchThread.pumpEvents(Unknown 
Source)
 at java.awt.EventDispatchThread.pumpEvents(Unknown 
Source)
 at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.io.IOException: Server returned HTTP response code: 401 for 
URL: 
https://username:pas...@site.fi/cgi-bin/service1?&SERVICE=WMS&REQUEST=GetLegendGraphic&VERSION=1.1.1&FORMAT=image/png&WIDTH=16&HEIGHT=16&legend_options=bgColor:0xEE;dpi:100;fontAntiAliasing:true;forceLabels:on&LAYER=tukialueet
 at 
sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
 at 
sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
 at java.net.U

Re: [JPP-Devel] New WMS Layer legend plugin on OpenJUMP

2015-06-04 Thread Rahkonen Jukka (MML)
Hi,

If you adapted GetStyle code are you going to add also this on into OpenJUMP:
org.saig.jump.plugin.wms.ChangeWMSStyleDialogPlugIn.name=Change WMS style?

-Jukka Rahkonen-

Giuseppe Aruta wrote:

Dear Jumpers,
I added on OpenJUMP a new plugin that displays WMS layer(s) legend (if 
available) on a Dialog.
This plugin is located on WMS Layer tree context menu, as "Show WMS Layer 
Legend".
The code originally came from Kosmo SAIG and it was completely rewritten in 
order to adapt WMS GetLegendGraphic and GetStyle operators without modifing OJ 
WMS classes.
Best Regards
Peppe

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