Revision: 5920 http://sourceforge.net/p/jump-pilot/code/5920 Author: ma15569 Date: 2018-08-22 15:24:29 +0000 (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<Double,Color> colorMapEntries, double noDataValue, String rasterName) throws Exception { + public ColorsLabelLegendComponent(TreeMap<Double, Color> 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<Double,Color> colorMapEntry : colorMapEntries_tm.entrySet()) { - + for (final Map.Entry<Double, Color> 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<Double,Color> colorMapEntries_tm; + private final java.util.ResourceBundle bundle = java.util.ResourceBundle + .getBundle("org/openjump/core/rasterimage/styler/resources/Bundle"); // NOI18N + private final TreeMap<Double, Color> 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 06:49:20 UTC (rev 5919) +++ core/trunk/src/org/openjump/core/rasterimage/styler/ui/GradientLabelLegendComponent.java 2018-08-22 15:24:29 UTC (rev 5920) @@ -14,6 +14,8 @@ import org.openjump.core.rasterimage.styler.ColorMapEntry; +import com.vividsolutions.jump.I18N; + /** * Class to create the component formed by a JPanel and two JLabels. The JPanel * contain the gradient and the JLabels contain the values. @@ -78,8 +80,10 @@ final JLabel jLabel_MaxValue = new JLabel(); final JLabel jLabel_MinValue = new JLabel(); final JLabel jLabel_RasterName = new JLabel(rasterName); + // final JLabel jLabel_NoDataTitle = new JLabel( + // bundle.getString("LegendDialog.NoDataValue.text")); final JLabel jLabel_NoDataTitle = new JLabel( - bundle.getString("LegendDialog.NoDataValue.text")); + I18N.get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.cell.nodata")); final JLabel jLabel_NoDataColor = new JLabel(); final JLabel jLabel_NoDataValue = new JLabel( Double.toString(noDataValue)); ------------------------------------------------------------------------------ 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