Re: [JPP-Devel] @Michael. Bug on LayerView and other observations
Hi Peppe, It should be almost repaired. It is still missing a fix to prevent writing the data file for the view while saving the project. Let me know if there is still something wrong. Michaël Le 19/08/2018 à 21:52, Michaël Michaud a écrit : Hi Peppe, Thanks a lot for letting me know. I'll try to check that as soon as possible. Michaël Le 19/08/2018 à 18:04, Giuseppe Aruta a écrit : Hi Michael, I gave a look at the usage of LayerView class and I found a bug on opening project if layerViews are saved into a project file This is the sequence: 1) I create a project and load (or create) a new layer 2) I create a layerView of selected layer and click to save the project 3) OpenJUMP asks to save the newly created layer (=layerView) as JMP or SHP. 4) I select to create a new layer. The the saving project is finalized and a project file is saved. 5) I try to open the project.the _project is not opened_ and an error message shows the problem is in OpenProjectWizard, possibly on loadLayers(...) method: j/ava.lang.Exception: Caricando il file progetto 'C:\Users\Beppe\Desktop\2.jmp' fallito con errore: com.vividsolutions.jump.workbench.model.LayerView. at org.openjump.core.ui.plugin.file.open.OpenProjectWizard.open(OpenProjectWizard.java:195) at org.openjump.core.ui.plugin.file.open.OpenProjectWizard.open(OpenProjectWizard.java:132) at org.openjump.core.ui.plugin.file.open.OpenProjectWizard.run(OpenProjectWizard.java:127) at org.openjump.core.ui.plugin.AbstractWizardPlugin.run(AbstractWizardPlugin.java:73)/ / .../ I opened the project file with a text editor and substitute any layer class="com.vividsolutions.jump.workbench.model.LayerView" with layer class="com.vividsolutions.jump.workbench.model.Layer" In this case I can open the project file in openjump with no problem. -- Apart from the bug, I have some observations for possible further development a) a LayerView is be a simple "view" of a layer: the modification action is syncroniozed: whenever I modified the geometries of a layer, the modification affects also the conresponding LayerView. In this case the "view" could be a parameter to save only into the project file without the need to create a clone of the layer. b) II found the LayerView can have a great positive impact on OJ style as users can create multiple views of the same layer with different styles. I explored the possibility to create subviews of a selected layer, according to defined attribute (*). The easy way was to create sub feature collections according to the attribute, create conresponding sub-layers (which are not opened into the view, create conresponding views to load into the view. Of coarse those subviews are not subviews of the original layer but subviews of sub-layers. The syncronized modification is lost. (*) This could be extremely useful as OJ lacks of a good point/linestring decoration symbology according to attribute. I am Thinking about vertex symbol rotation, the usage of wkt files, text display next to symbols - what is available in CadPlann symbology plugin available only for basic style Best regards and thanks for your job Peppe -- 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 -- 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
[JPP-Devel] SVN: [5919] core/trunk
Revision: 5919 http://sourceforge.net/p/jump-pilot/code/5919 Author: michaudm Date: 2018-08-22 06:49:20 + (Wed, 22 Aug 2018) Log Message: --- Fix LayerView to make it compatible with project persistence Modified Paths: -- core/trunk/ChangeLog core/trunk/src/com/vividsolutions/jump/workbench/model/LayerView.java core/trunk/src/com/vividsolutions/jump/workbench/ui/LayerNameRenderer.java core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/AddNewLayerViewPlugIn.java core/trunk/src/org/openjump/core/ui/plugin/file/open/OpenProjectWizard.java Added Paths: --- core/trunk/src/com/vividsolutions/jump/workbench/model/LayerView.java2xml Modified: core/trunk/ChangeLog === --- core/trunk/ChangeLog2018-08-21 20:33:57 UTC (rev 5918) +++ core/trunk/ChangeLog2018-08-22 06:49:20 UTC (rev 5919) @@ -3,6 +3,9 @@ # 2. make sure that lines break at 80 chars for constricted display situations #< 80 chars --># +2018-08-22 mmichaud + * Fix LayerView to make it compatible with project persistence + 2018-08-19 mmichaud * Add two plugins : - GenerateUniqueRandomIdPlugIn (menu tools/edit attributes) Modified: core/trunk/src/com/vividsolutions/jump/workbench/model/LayerView.java === --- core/trunk/src/com/vividsolutions/jump/workbench/model/LayerView.java 2018-08-21 20:33:57 UTC (rev 5918) +++ core/trunk/src/com/vividsolutions/jump/workbench/model/LayerView.java 2018-08-22 06:49:20 UTC (rev 5919) @@ -1,7 +1,8 @@ package com.vividsolutions.jump.workbench.model; -import com.vividsolutions.jump.feature.FeatureCollection; +import com.vividsolutions.jump.feature.*; +import java.util.ArrayList; import java.util.Collection; public class LayerView extends Layer { @@ -8,16 +9,44 @@ private Layer layer; - public LayerView(Layer layer) { -super(layer.getName(), layer.getBasicStyle().getFillColor(), layer.getFeatureCollectionWrapper(), layer.getLayerManager()); + /** + * Called by Java2XML + */ + public LayerView() { + } + + // 2018-08-22 : add layerName attribute (original name of the underlying layer) + // to increase compatibility with java2xml and to make it possible to build the + // LayerView from the xml project file before the underlying Layer is completely + // initialized + String layerName; + public String getLayerName() { +return layerName; + } + public void setLayerName(String layerName) { +this.layerName = layerName; + } + + @Override + public void setLayerManager(LayerManager layerManager) { +super.setLayerManager(layerManager); +this.layer = layerManager.getLayer(getLayerName()); + } + + public LayerView(final String layerName, LayerManager layerManager) { +super(layerName, +layerManager.generateLayerFillColor(), +layerManager.getLayer(layerName).getFeatureCollectionWrapper(), +layerManager); +this.layerName = layerName; +this.layer = layerManager.getLayer(layerName); boolean firingEvents = getLayerManager().isFiringEvents(); getLayerManager().setFiringEvents(false); try { - setName(getName().replaceAll(layer.getName(),"").trim()); + setName(getName().replaceAll(this.layer.getName(),"").trim()); } finally { getLayerManager().setFiringEvents(firingEvents); } -this.layer = layer; } @@ -43,6 +72,28 @@ super.setFeatureCollectionWrapper(observableFeatureCollection); } + + @Override + public FeatureCollectionWrapper getFeatureCollectionWrapper() { +// When the LayerView is build from the project xml file, it may be built +// before underlying Layer is defined... +if (layer != null) { + return layer.getFeatureCollectionWrapper(); +} else { + // ... in this case, try again to load data from the underlying Layer + // next time the application need to display the data. + this.layer = getLayerManager().getLayer(layerName); + if (this.layer != null) { +return layer.getFeatureCollectionWrapper(); + } else { +return new ObservableFeatureCollection( +FeatureDatasetFactory.createFromGeometry(new ArrayList()) +); + } +} + } + + public Layer getLayer() { return layer; } Added: core/trunk/src/com/vividsolutions/jump/workbench/model/LayerView.java2xml === --- core/trunk/src/com/vividsolutions/jump/workbench/model/LayerView.java2xml (rev 0) +++ core/trunk/src/com/vividsolutions/jump/workbench/model/LayerView.java2xml 2018-08-22 06:49:20 UTC (rev 5919) @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No
[JPP-Devel] SVN: [5921] core/trunk/src/org/openjump/sextante/gui/additionalResults/ AdditionalResultsFrame.java
Revision: 5921 http://sourceforge.net/p/jump-pilot/code/5921 Author: ma15569 Date: 2018-08-22 15:28:45 + (Wed, 22 Aug 2018) Log Message: --- Add generic save view to image of JPanel in a JScrollPane Modified Paths: -- core/trunk/src/org/openjump/sextante/gui/additionalResults/AdditionalResultsFrame.java Modified: core/trunk/src/org/openjump/sextante/gui/additionalResults/AdditionalResultsFrame.java === --- core/trunk/src/org/openjump/sextante/gui/additionalResults/AdditionalResultsFrame.java 2018-08-22 15:24:29 UTC (rev 5920) +++ core/trunk/src/org/openjump/sextante/gui/additionalResults/AdditionalResultsFrame.java 2018-08-22 15:28:45 UTC (rev 5921) @@ -454,8 +454,43 @@ } else if (returnVal == JFileChooser.CANCEL_OPTION) { return; } + } +// [Giuseppe Aruta 2018-08-22] add generic save view to +// image of JPanel in a JScrollPane +else if (view instanceof JPanel) { +final JPanel panel = (JPanel) pane.getViewport() +.getView(); +final int w = panel.getWidth(); +final int h = panel.getHeight(); +final BufferedImage bi = new BufferedImage(w, h, +BufferedImage.TYPE_INT_RGB); +final Graphics2D g = bi.createGraphics(); +panel.paint(g); + +filter = new FileNameExtensionFilter( +"Portable Network Graphics (png)", "png"); +final JFileChooser fc = new GUIUtil.FileChooserWithOverwritePrompting( +"png"); +fc.setFileFilter(filter); +fc.addChoosableFileFilter(filter); +final int returnVal = fc +.showSaveDialog(AdditionalResultsFrame.this); +fc.getWidth(); +fc.getHeight(); +if (returnVal == JFileChooser.APPROVE_OPTION) { +try { +file = new File(fc.getSelectedFile() + ".png"); +ImageIO.write(bi, "png", file); +saved(file); +} catch (final Exception e) { +notsaved(); +Logger(this.getClass(), e); +} +} +} + } else if (c instanceof PlotPanel) { final PlotPanel panel = (PlotPanel) c; filter = new FileNameExtensionFilter( -- 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
[JPP-Devel] SVN: [5920] core/trunk/src/org/openjump/core/rasterimage/styler/ui
Revision: 5920 http://sourceforge.net/p/jump-pilot/code/5920 Author: ma15569 Date: 2018-08-22 15:24:29 + (Wed, 22 Aug 2018) Log Message: --- Added String code to solve a bug (the absence was creating null poit exception on some ext plugins) Modified Paths: -- core/trunk/src/org/openjump/core/rasterimage/styler/ui/ColorsLabelLegendComponent.java core/trunk/src/org/openjump/core/rasterimage/styler/ui/GradientLabelLegendComponent.java Modified: core/trunk/src/org/openjump/core/rasterimage/styler/ui/ColorsLabelLegendComponent.java === --- core/trunk/src/org/openjump/core/rasterimage/styler/ui/ColorsLabelLegendComponent.java 2018-08-22 06:49:20 UTC (rev 5919) +++ core/trunk/src/org/openjump/core/rasterimage/styler/ui/ColorsLabelLegendComponent.java 2018-08-22 15:24:29 UTC (rev 5920) @@ -7,8 +7,11 @@ import java.awt.Graphics; import java.util.Map; import java.util.TreeMap; + import javax.swing.JComponent; +import com.vividsolutions.jump.I18N; + /** * * @author GeomaticaEAmbiente @@ -23,9 +26,10 @@ * @param rasterName * @throws Exception */ -public ColorsLabelLegendComponent(TreeMap colorMapEntries, double noDataValue, String rasterName) throws Exception { +public ColorsLabelLegendComponent(TreeMap colorMapEntries, +double noDataValue, String rasterName) throws Exception { -this.colorMapEntries_tm = colorMapEntries; +colorMapEntries_tm = colorMapEntries; this.noDataValue = noDataValue; this.rasterName = rasterName; } @@ -34,12 +38,12 @@ public void paintComponent(Graphics g) { super.paintComponent(g); -int x = 20; +final int x = 20; int y; -int startY = 45; -int step = 30; +final int startY = 45; +final int step = 30; int maxWidth = 100; -FontMetrics m = g.getFontMetrics(); +final FontMetrics m = g.getFontMetrics(); int i = 0, w; Color color; @@ -54,10 +58,12 @@ g.setFont(new Font("Tahoma", Font.PLAIN, 11)); -//for (int n = 0; n < colorMapEntry.length; n++) {//for (Iterator iter = pairs.iterator(); iter.hasNext();) { +// for (int n = 0; n < colorMapEntry.length; n++) {//for (Iterator iter +// = pairs.iterator(); iter.hasNext();) { -for(Map.Entry colorMapEntry : colorMapEntries_tm.entrySet()) { - +for (final Map.Entry colorMapEntry : colorMapEntries_tm +.entrySet()) { + if (colorMapEntry.getKey() == noDataValue) { noDataColor = colorMapEntry.getValue(); continue; @@ -72,8 +78,8 @@ g.setColor(Color.black); g.drawRect(x, y, 40, 25); -//g.setColor(Color.black); -String value = Double.toString(colorMapEntry.getKey()); +// g.setColor(Color.black); +final String value = Double.toString(colorMapEntry.getKey()); g.drawString(value, x + 60, y + 18); w = m.stringWidth(value); @@ -85,8 +91,10 @@ y = startY + (step * i++); g.setFont(new Font("Tahoma", Font.ITALIC, 11)); -g.drawString("NoDataValue", x, y + 20); - +// g.drawString("NoDataValue", x, y + 20); +final String jLabel_NoDataTitle = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.cell.nodata"); +g.drawString(jLabel_NoDataTitle, x, y + 20); g.setFont(new Font("Tahoma", Font.PLAIN, 11)); y = startY + (step * i++); @@ -93,11 +101,11 @@ g.setColor(Color.BLACK); g.drawRect(x, y, 40, 25); -if(noDataColor != null){ +if (noDataColor != null) { g.setColor(noDataColor); g.fillRect(x, y, 40, 25); g.setColor(Color.BLACK); -} +} g.drawString(Double.toString(noDataValue), x + 60, y + 18); dimension = new Dimension(maxWidth, startY + (step * i++)); @@ -105,9 +113,9 @@ } -private final java.util.ResourceBundle bundle -= java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle"); // NOI18N -private final TreeMap colorMapEntries_tm; +private final java.util.ResourceBundle bundle = java.util.ResourceBundle + .getBundle("org/openjump/core/rasterimage/styler/resources/Bundle"); // NOI18N +private final TreeMap colorMapEntries_tm; private final double noDataValue; private Dimension dimension; private final String rasterName; Modified: core/trunk/src/org/openjump/core/rasterimage/styler/ui/GradientLabelLegendComponent.java === --- core/trunk/src/org/openjump/core/rasterimage/styler/ui/GradientLabelLegendComponent.java 2018-08-22
[JPP-Devel] SVN: [5922] core/trunk/src/org/openjump/core/ui/plugin/wms/ WMSLegendPlugIn.java
Revision: 5922 http://sourceforge.net/p/jump-pilot/code/5922 Author: ma15569 Date: 2018-08-22 17:00:47 + (Wed, 22 Aug 2018) Log Message: --- Added capability to export WMS legend to PNG image file Modified Paths: -- core/trunk/src/org/openjump/core/ui/plugin/wms/WMSLegendPlugIn.java Modified: core/trunk/src/org/openjump/core/ui/plugin/wms/WMSLegendPlugIn.java === --- core/trunk/src/org/openjump/core/ui/plugin/wms/WMSLegendPlugIn.java 2018-08-22 15:28:45 UTC (rev 5921) +++ core/trunk/src/org/openjump/core/ui/plugin/wms/WMSLegendPlugIn.java 2018-08-22 17:00:47 UTC (rev 5922) @@ -2,27 +2,38 @@ import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Dimension; import java.awt.Font; +import java.awt.Graphics2D; import java.awt.GridBagLayout; import java.awt.Image; +import java.awt.event.ActionEvent; +import java.awt.image.BufferedImage; +import java.io.File; import java.io.IOException; import java.net.MalformedURLException; 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.JButton; +import javax.swing.JFileChooser; import javax.swing.JLabel; import javax.swing.JLayeredPane; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; import org.openjump.core.apitools.LayerTools; +import org.openjump.core.ui.io.file.FileNameExtensionFilter; import org.openjump.core.ui.swing.DetachableInternalFrame; import com.vividsolutions.jump.I18N; +import com.vividsolutions.jump.workbench.JUMPWorkbench; import com.vividsolutions.jump.workbench.WorkbenchContext; import com.vividsolutions.jump.workbench.model.WMSLayer; import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn; @@ -29,6 +40,7 @@ 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.GUIUtil; import com.vividsolutions.jump.workbench.ui.images.IconLoader; import com.vividsolutions.wms.AbstractWMSRequest; import com.vividsolutions.wms.MapLayer; @@ -47,11 +59,12 @@ private static ImageIcon ICON = IconLoader.icon("globe3_13.png"); private JScrollPane scrollPane = new JScrollPane(); +@Override public boolean execute(final PlugInContext context) throws Exception { final WMSLayer layer = (WMSLayer) LayerTools.getSelectedLayerable( context, WMSLayer.class); -DetachableInternalFrame frame = new DetachableInternalFrame(); +final DetachableInternalFrame frame = new DetachableInternalFrame(); frame.setTitle(PANEL + " (" + layer.getName() + ")"); frame.setResizable(true); frame.setClosable(true); @@ -60,13 +73,64 @@ frame.setFrameIcon(ICON); frame.setSize(200, 500); frame.setLayer(JLayeredPane.PALETTE_LAYER); -scrollPane = new JScrollPane(getLegendPanel(context)); -frame.add(scrollPane, BorderLayout.CENTER); +scrollPane = new JScrollPane(getLegendPanel(context), +JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, +JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); +final JPanel panel = new JPanel(); +panel.setLayout(new BorderLayout()); +panel.add(scrollPane, BorderLayout.CENTER); +panel.setPreferredSize(scrollPane.getPreferredSize()); +frame.add(panel, BorderLayout.NORTH); +final JPanel okPanel = new JPanel(); +final JButton saveButton = new JButton(SAVE) { +private static final long serialVersionUID = 1L; + +@Override +public Dimension getPreferredSize() { +return new Dimension(100, 25); +} +}; + +final JButton closeButton = new JButton(CLOSE) { +private static final long serialVersionUID = 2L; + +@Override +public Dimension getPreferredSize() { +return new Dimension(100, 25); +} +}; + +saveButton.addActionListener(new java.awt.event.ActionListener() { +@Override +public void actionPerformed(ActionEvent e) { +save(scrollPane); +// frame.dispose(); +return; +} +}); + +closeButton.addActionListener(new java.awt.event.ActionListener() { + +@Override +public void actionPerformed(ActionEvent e) { + +frame.dispose(); + +return; +} +}); + +okPanel.add(saveButton, BorderLayout.WEST); +okPanel.add(closeButton, BorderLayout.EAST); + +
[JPP-Devel] SVN: [5923] core/trunk/ChangeLog
Revision: 5923 http://sourceforge.net/p/jump-pilot/code/5923 Author: ma15569 Date: 2018-08-22 17:02:04 + (Wed, 22 Aug 2018) Log Message: --- Updated ChangeLog file Modified Paths: -- core/trunk/ChangeLog Modified: core/trunk/ChangeLog === --- core/trunk/ChangeLog2018-08-22 17:00:47 UTC (rev 5922) +++ core/trunk/ChangeLog2018-08-22 17:02:04 UTC (rev 5923) @@ -3,6 +3,9 @@ # 2. make sure that lines break at 80 chars for constricted display situations #< 80 chars --># +2018-08-22 Giuseppe Aruta + * WMSLegendPlugIn. Added capability to export WMS legend to PNG image file + 2018-08-22 mmichaud * Fix LayerView to make it compatible with project persistence -- 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