Revision: 5719 http://sourceforge.net/p/jump-pilot/code/5719 Author: ma15569 Date: 2018-03-29 13:29:18 +0000 (Thu, 29 Mar 2018) Log Message: ----------- Correct typo
Modified Paths: -------------- core/trunk/src/org/openjump/core/rasterimage/styler/ui/GradientLabelLegendComponent.java Modified: core/trunk/src/org/openjump/core/rasterimage/styler/ui/GradientLabelLegendComponent.java =================================================================== --- core/trunk/src/org/openjump/core/rasterimage/styler/ui/GradientLabelLegendComponent.java 2018-03-26 18:07:03 UTC (rev 5718) +++ core/trunk/src/org/openjump/core/rasterimage/styler/ui/GradientLabelLegendComponent.java 2018-03-29 13:29:18 UTC (rev 5719) @@ -7,79 +7,89 @@ import java.awt.GridBagLayout; import java.util.Map; import java.util.TreeMap; + import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; + import org.openjump.core.rasterimage.styler.ColorMapEntry; /** - * Class to create the component formed by a JPanel and two JLabels. - * The JPanel contain the gradient and the JLabels contain the values. + * Class to create the component formed by a JPanel and two JLabels. The JPanel + * contain the gradient and the JLabels contain the values. + * * @author GeomaticaEAmbiente */ -public class GradientLabelLegendComponent extends JComponent{ +public class GradientLabelLegendComponent extends JComponent { - public GradientLabelLegendComponent(TreeMap<Double,Color> colorMapEntries, double noDataValue, String rasterName) { - this.colorMapEntries_tm = colorMapEntries; + public GradientLabelLegendComponent(TreeMap<Double, Color> colorMapEntries, + double noDataValue, String rasterName) { + colorMapEntries_tm = colorMapEntries; this.noDataValue = noDataValue; this.rasterName = rasterName; jInit(); } - + /** * Method that initializes the component. */ - private void jInit(){ - + private void jInit() { + double minValue = Double.MAX_VALUE; double maxValue = Double.MIN_VALUE; - - //Find min and max values - for(Map.Entry<Double,Color> colorMapEntry : colorMapEntries_tm.entrySet()) { - - if(colorMapEntry.getKey() != noDataValue){ - - if(colorMapEntry.getKey() < minValue){ + + // Find min and max values + for (final Map.Entry<Double, Color> colorMapEntry : colorMapEntries_tm + .entrySet()) { + + if (colorMapEntry.getKey() != noDataValue) { + + if (colorMapEntry.getKey() < minValue) { minValue = colorMapEntry.getKey(); } - - if(colorMapEntry.getKey() > maxValue){ + + if (colorMapEntry.getKey() > maxValue) { maxValue = colorMapEntry.getKey(); } } } - - - //Set color gradient - //from Raster ColorMapEntry to Gradient colorMapEntry - ColorMapEntry[] paletteColorMapEntry = new ColorMapEntry[colorMapEntries_tm.size() - 1]; //without noDataValue + + // Set color gradient + // from Raster ColorMapEntry to Gradient colorMapEntry + final ColorMapEntry[] paletteColorMapEntry = new ColorMapEntry[colorMapEntries_tm + .size() - 1]; // without noDataValue int count = 0; Color noDataColor = null; - for(Map.Entry<Double,Color> colorMapEntry : colorMapEntries_tm.entrySet()) { - if(colorMapEntry.getKey() != noDataValue){ - double quantity = (colorMapEntry.getKey() - minValue)/(maxValue-minValue); - paletteColorMapEntry[count] = new ColorMapEntry(quantity, colorMapEntry.getValue()); + for (final Map.Entry<Double, Color> colorMapEntry : colorMapEntries_tm + .entrySet()) { + if (colorMapEntry.getKey() != noDataValue) { + final double quantity = (colorMapEntry.getKey() - minValue) + / (maxValue - minValue); + paletteColorMapEntry[count] = new ColorMapEntry(quantity, + colorMapEntry.getValue()); count++; } else { noDataColor = colorMapEntry.getValue(); } - } - - //Components - JPanel jPanel_Gradient = new JPanel(); - JLabel jLabel_MaxValue = new JLabel(); - JLabel jLabel_MinValue = new JLabel(); - JLabel jLabel_RasterName = new JLabel(rasterName); - JLabel jLabel_NoDataTitle = new JLabel(bundle.getString("LegendDialog.NoDataValue.text")); - JLabel jLabel_NoDataColor = new JLabel(); - JLabel jLabel_NoDataValue = new JLabel(Double.toString(noDataValue)); - + } + + // Components + final JPanel jPanel_Gradient = new JPanel(); + 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_NoDataColor = new JLabel(); + final JLabel jLabel_NoDataValue = new JLabel( + Double.toString(noDataValue)); + java.awt.GridBagConstraints gridBagConstraints = new GridBagConstraints(); setLayout(new GridBagLayout()); - //Set components aspect - //Raster name - jLabel_RasterName.setFont(new Font("Thaoma", Font.BOLD, 12)); + // Set components aspect + // Raster name + jLabel_RasterName.setFont(new Font("Tahoma", Font.BOLD, 12)); jLabel_RasterName.setPreferredSize(new Dimension(50, 14)); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; @@ -87,9 +97,10 @@ gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 10); add(jLabel_RasterName, gridBagConstraints); - - //Gradient panel - jPanel_Gradient.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + + // Gradient panel + jPanel_Gradient.setBorder(javax.swing.BorderFactory + .createLineBorder(new java.awt.Color(0, 0, 0))); jPanel_Gradient.setMinimumSize(new java.awt.Dimension(40, 100)); jPanel_Gradient.setPreferredSize(new java.awt.Dimension(40, 100)); gridBagConstraints.gridx = 0; @@ -99,9 +110,8 @@ gridBagConstraints.insets = new java.awt.Insets(20, 0, 11, 0); add(jPanel_Gradient, gridBagConstraints); - - //Max value label - jLabel_MaxValue.setText(Double.toString(GUIUtils.round(maxValue,3))); + // Max value label + jLabel_MaxValue.setText(Double.toString(GUIUtils.round(maxValue, 3))); jLabel_MaxValue.setMinimumSize(new java.awt.Dimension(50, 14)); jLabel_MaxValue.setPreferredSize(new java.awt.Dimension(50, 14)); gridBagConstraints.gridx = 1; @@ -111,8 +121,8 @@ gridBagConstraints.insets = new java.awt.Insets(20, 5, 0, 0); add(jLabel_MaxValue, gridBagConstraints); - //Min value label - jLabel_MinValue.setText(Double.toString(GUIUtils.round(minValue,3))); + // Min value label + jLabel_MinValue.setText(Double.toString(GUIUtils.round(minValue, 3))); jLabel_MinValue.setMinimumSize(new java.awt.Dimension(50, 14)); jLabel_MinValue.setPreferredSize(new java.awt.Dimension(50, 14)); gridBagConstraints.gridx = 1; @@ -121,8 +131,8 @@ gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; gridBagConstraints.insets = new java.awt.Insets(0, 5, 11, 0); add(jLabel_MinValue, gridBagConstraints); - - //NoData title label + + // NoData title label jLabel_NoDataTitle.setMinimumSize(new java.awt.Dimension(70, 14)); jLabel_NoDataTitle.setPreferredSize(new java.awt.Dimension(70, 14)); gridBagConstraints.gridx = 0; @@ -131,14 +141,15 @@ gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(10, 0, 0, 0); add(jLabel_NoDataTitle, gridBagConstraints); - - //NoData color label + + // NoData color label jLabel_NoDataColor.setBackground(noDataColor); - jLabel_NoDataColor.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + jLabel_NoDataColor.setBorder(javax.swing.BorderFactory + .createLineBorder(new java.awt.Color(0, 0, 0))); jLabel_NoDataColor.setMaximumSize(new java.awt.Dimension(40, 25)); jLabel_NoDataColor.setMinimumSize(new java.awt.Dimension(40, 25)); jLabel_NoDataColor.setPreferredSize(new java.awt.Dimension(40, 25)); - jLabel_NoDataColor.setOpaque(true); + jLabel_NoDataColor.setOpaque(true); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.gridwidth = 1; @@ -145,8 +156,8 @@ gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(10, 0, 0, 0); add(jLabel_NoDataColor, gridBagConstraints); - - //NoData value label + + // NoData value label jLabel_NoDataValue.setPreferredSize(new java.awt.Dimension(50, 14)); jLabel_NoDataValue.setFont(new Font("Tahoma", Font.ITALIC, 11)); gridBagConstraints = new java.awt.GridBagConstraints(); @@ -156,17 +167,17 @@ gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(10, 0, 0, 0); add(jLabel_NoDataValue, gridBagConstraints); - - //Set gradient color panel - GUIUtils updatePanel = new GUIUtils(); + + // Set gradient color panel + final GUIUtils updatePanel = new GUIUtils(); updatePanel.setGradientPanel(jPanel_Gradient, paletteColorMapEntry); setPreferredSize(new Dimension(200, 250)); } - - private final TreeMap<Double,Color> colorMapEntries_tm; + + private final TreeMap<Double, Color> colorMapEntries_tm; private final double noDataValue; private final String rasterName; - private final java.util.ResourceBundle bundle = - java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle"); // NOI18N + private final java.util.ResourceBundle bundle = java.util.ResourceBundle + .getBundle("org/openjump/core/rasterimage/styler/resources/Bundle"); // NOI18N } ------------------------------------------------------------------------------ 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