Revision: 4537 http://sourceforge.net/p/jump-pilot/code/4537 Author: michaudm Date: 2015-08-29 09:55:49 +0000 (Sat, 29 Aug 2015) Log Message: ----------- Improve ColorThemingStyle code and try to fix #408 bug
Modified Paths: -------------- core/trunk/ChangeLog core/trunk/src/com/vividsolutions/jump/workbench/ui/renderer/style/BasicStyleListCellRenderer.java core/trunk/src/com/vividsolutions/jump/workbench/ui/renderer/style/ColorThemingStyle.java core/trunk/src/com/vividsolutions/jump/workbench/ui/renderer/style/ColorThemingStylePanel.java Modified: core/trunk/ChangeLog =================================================================== --- core/trunk/ChangeLog 2015-07-13 19:19:43 UTC (rev 4536) +++ core/trunk/ChangeLog 2015-08-29 09:55:49 UTC (rev 4537) @@ -1,5 +1,12 @@ # for display continuity sake please use 2 spaces instead of tabs +2015-08-29 + * fix #408 bug about ColorThemingStyle + +2015-07-13 mmichaud <m.michael.mich...@orange.fr> + * Improve ColorThemingStyle : can now set transparency and lineWidth + globally or individually in ColorThemingPanel + 2015-07-12 mmichaud <m.michael.mich...@orange.fr> * improve .cpg handling for shapefile/dbf format * fix a bug with charset option (could be checked but not visible in "save dataset as" panel) Modified: core/trunk/src/com/vividsolutions/jump/workbench/ui/renderer/style/BasicStyleListCellRenderer.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/workbench/ui/renderer/style/BasicStyleListCellRenderer.java 2015-07-13 19:19:43 UTC (rev 4536) +++ core/trunk/src/com/vividsolutions/jump/workbench/ui/renderer/style/BasicStyleListCellRenderer.java 2015-08-29 09:55:49 UTC (rev 4537) @@ -122,25 +122,25 @@ colorPanel.setStyle(basicStyle); colorPanel.setLineColor( basicStyle instanceof BasicStyle - && ((BasicStyle) basicStyle).isRenderingLine() + && (basicStyle).isRenderingLine() ? GUIUtil.alphaColor( - ((BasicStyle) basicStyle).getLineColor(), + (basicStyle).getLineColor(), alpha) : (isSelected ? list.getSelectionBackground() : list.getBackground())); colorPanel.setFillColor( basicStyle instanceof BasicStyle - && ((BasicStyle) basicStyle).isRenderingFill() + && (basicStyle).isRenderingFill() ? GUIUtil.alphaColor( - ((BasicStyle) basicStyle).getFillColor(), + (basicStyle).getFillColor(), alpha) : (isSelected ? list.getSelectionBackground() : list.getBackground())); colorPanel.setLineWidth( basicStyle instanceof BasicStyle - ? basicStyle.getLineWidth() + ? Math.min(5, basicStyle.getLineWidth()) : 0); if (isSelected) { colorPanel.setForeground(list.getSelectionForeground()); Modified: core/trunk/src/com/vividsolutions/jump/workbench/ui/renderer/style/ColorThemingStyle.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/workbench/ui/renderer/style/ColorThemingStyle.java 2015-07-13 19:19:43 UTC (rev 4536) +++ core/trunk/src/com/vividsolutions/jump/workbench/ui/renderer/style/ColorThemingStyle.java 2015-08-29 09:55:49 UTC (rev 4537) @@ -123,8 +123,8 @@ private BasicStyle defaultStyle; - private boolean globalTransparencyEnabled; - private boolean globalLineWidthEnabled; + private boolean globalTransparencyEnabled = true; + private boolean globalLineWidthEnabled = true; private boolean vertexStyleEnabled; public void paint(Feature f, Graphics2D g, Viewport viewport) Modified: core/trunk/src/com/vividsolutions/jump/workbench/ui/renderer/style/ColorThemingStylePanel.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/workbench/ui/renderer/style/ColorThemingStylePanel.java 2015-07-13 19:19:43 UTC (rev 4536) +++ core/trunk/src/com/vividsolutions/jump/workbench/ui/renderer/style/ColorThemingStylePanel.java 2015-08-29 09:55:49 UTC (rev 4537) @@ -64,7 +64,6 @@ import javax.swing.SwingUtilities; import javax.swing.event.CellEditorListener; import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.event.TableModelEvent; @@ -401,19 +400,20 @@ initTable(layer); setState(state); initColorSchemeComboBox(layer.getLayerManager()); + initGlobalTransparency(layer); initTransparencySlider(layer); - if (isGlobalTransparencyEnabled()) deeRenderingStylePanel.getTransparencySlider().setValue(getAlpha()); + deeRenderingStylePanel.getTransparencySlider().setEnabled(!isGlobalTransparencyEnabled()); + initGlobalLineWidth(layer); initLineWidthSlider(layer); - if (isGlobalLineWidthEnabled()) deeRenderingStylePanel.getLineWidthSlider().setValue(getLineWidth()); + deeRenderingStylePanel.getLineWidthSlider().setEnabled(!isGlobalLineWidthEnabled()); + initVertexStyleEnabled(layer); initToolBar(); enableColorThemingCheckBox.setSelected(ColorThemingStyle.get(layer).isEnabled()); vertexStyleEnableCheckBox.setSelected(ColorThemingStyle.get(layer).isVertexStyleEnabled()); updateComponents(); - GUIUtil.sync(deeRenderingStylePanel.getTransparencySlider(), transparencySlider); - GUIUtil.sync(deeRenderingStylePanel.getLineWidthSlider(), lineWidthSlider); deeRenderingStylePanel.setSynchronizingLineColor(layer.isSynchronizingLineColor()); } catch (Exception e) { e.printStackTrace(); @@ -508,39 +508,25 @@ } private void initTransparencySlider(Layer layer) { - //transparencySlider.setValue(transparencySlider.getMaximum() - - // ColorThemingStyle.get(layer).getDefaultStyle().getAlpha()); - if (ColorThemingStyle.get(layer).isGlobalLineWidthEnabled()) { - //System.out.println("!!!" + (transparencySlider.getMaximum()-ColorThemingStyle.get(layer).getDefaultStyle().getAlpha())); - transparencySlider.setValue(transparencySlider.getMaximum()-ColorThemingStyle.get(layer).getDefaultStyle().getAlpha()); + ColorThemingStyle style = ColorThemingStyle.get(layer); + if (style != null && style.isGlobalTransparencyEnabled()) { + transparencySlider.setValue(transparencySlider.getMaximum()-style.getDefaultStyle().getAlpha()); } - transparencySlider.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - basicStyleListCellRenderer.setAlpha(getAlpha()); - } - }); basicStyleListCellRenderer.setAlpha(getAlpha()); } private void initGlobalLineWidth(Layer layer) { - Style style = layer.getStyle(ColorThemingStyle.class); + Style style = ColorThemingStyle.get(layer); if (style != null) { lineWidthCheckBox.setSelected(((ColorThemingStyle) style).isGlobalLineWidthEnabled()); } } private void initLineWidthSlider(Layer layer) { - //lineWidthSlider.setValue(lineWidthSlider.getMaximum() - - // ColorThemingStyle.get(layer).getDefaultStyle().getLineWidth()); - if (ColorThemingStyle.get(layer).isGlobalLineWidthEnabled()) { - //System.out.println("!!!" + ColorThemingStyle.get(layer).getDefaultStyle().getLineWidth()); - lineWidthSlider.setValue(ColorThemingStyle.get(layer).getDefaultStyle().getLineWidth()); + ColorThemingStyle style = ColorThemingStyle.get(layer); + if (style != null && style.isGlobalLineWidthEnabled()) { + lineWidthSlider.setValue(style.getDefaultStyle().getLineWidth()); } - lineWidthSlider.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - basicStyleListCellRenderer.setLineWidth(getLineWidth()); - } - }); basicStyleListCellRenderer.setLineWidth(getLineWidth()); } @@ -659,13 +645,20 @@ * @return null if user hits Cancel */ private BasicStyle promptBasicStyle(BasicStyle basicStyle) { - int originalTransparencySliderValue = transparencyCheckBox.isSelected() ? - transparencySlider.getMaximum()-transparencySlider.getValue() :basicStyle.getAlpha(); - int originalLineWidthSliderValue = lineWidthCheckBox.isSelected() ? - lineWidthSlider.getValue() : basicStyle.getLineWidth(); + int originalTransparencySliderValue = transparencyCheckBox.isSelected() + ? transparencySlider.getValue() + : transparencySlider.getMaximum() - basicStyle.getAlpha(); + int originalLineWidthSliderValue = lineWidthCheckBox.isSelected() + ? lineWidthSlider.getValue() + : basicStyle.getLineWidth(); deeRenderingStylePanel.setBasicStyle(basicStyle); + deeRenderingStylePanel.getTransparencySlider().setValue(originalTransparencySliderValue); + deeRenderingStylePanel.getTransparencySlider().setEnabled(!isGlobalTransparencyEnabled()); + deeRenderingStylePanel.getLineWidthSlider().setValue(originalLineWidthSliderValue); + deeRenderingStylePanel.getLineWidthSlider().setEnabled(!isGlobalLineWidthEnabled()); + //deeRenderingStylePanel.updateControls((XBasicStyle)basicStyle); OKCancelPanel okCancelPanel = new OKCancelPanel(); @@ -903,7 +896,14 @@ transparencySlider.setToolTipText(I18N.get("ui.renderer.style.ColorThemingPanel.transparency")); transparencySlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(ChangeEvent e) { - transparencySlider_stateChanged(e); + if (isGlobalTransparencyEnabled()) { + for (Object obj : tableModel().getAttributeValueToBasicStyleMap().values()) { + ((XBasicStyle) obj).setAlpha(getAlpha()); + } + tableModel().getDefaultStyle().setAlpha(getAlpha()); + basicStyleListCellRenderer.setAlpha(getAlpha()); + transparencySlider_stateChanged(e); + } } }); transparencySlider.setEnabled(false); @@ -921,7 +921,14 @@ //lineWidthSlider.setToolTipText(I18N.get("ui.style.BasicStylePanel.line-width")); lineWidthSlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(ChangeEvent e) { - lineWidthSlider_stateChanged(e); + if (isGlobalLineWidthEnabled()) { + for (Object obj : tableModel().getAttributeValueToBasicStyleMap().values()) { + ((XBasicStyle) obj).setLineWidth(getLineWidth()); + } + tableModel().getDefaultStyle().setLineWidth(getLineWidth()); + basicStyleListCellRenderer.setLineWidth(getLineWidth()); + lineWidthSlider_stateChanged(e); + } } }); lineWidthSlider.setEnabled(false); @@ -960,11 +967,6 @@ new GridBagConstraints(1, 1, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0)); - //jPanel1.add(fillerPanel, - // new GridBagConstraints(3, 0, 1, 3, 1, 0.0, - // GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - // new Insets(2, 2, 2, 2), 0, 0)); - // add classification method in row 2 jPanel1.add(classificationLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, ------------------------------------------------------------------------------ _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel