that's difficult to answer. generally there are two aspects to the compatibility.
A. syntax (new commands/structures) and compilation result (bytecode) This is a setting in your IDE and younger jdk's like e.g. java8 can compile for older java versions as well. This can be tricky, because i am 100% sure that the newer compiler output the older formatted bytecode, but not if it checks that you didn't use a new type of command or such. my guess would be, not. B. runtime API that's the base runtime classes that you can count on being avail when you run a java program. between major releases there are usually classes added/deprecated/removed , so in special cases (like the our splash using transparency or not on java6) you will have your code check for availability of some class and use it, or live w/o it. Generally we are free to stick to whatever java compatibility we want. But as java progresses and new features/commands become available we will be tempted to use them. It already happened! Just try compiling OJ with an old jdk1.5 and you'll see it choke on some classes, because they import classes introduced in 1.6. So we are de facto already baseline java1.6 and not 1.5 compatible any more. just checked. releases and snapshots are compiled with java1.6 bytecode compatibility set as well. Fun fact, both are compiled with an Oracle jdk7 on linux ;) and back to your question. java running is backward compatible. so from a users stand point there is no disadvantage running a program compiled for an older java version. ..ede On 19.11.2015 17:08, Rahkonen Jukka (MML) wrote: > Hi, > > > > Shouldn’t we rather start to compile everything with JDK 1.7? Perhaps bit too > early to switch to 1.8 yet. Is it even possible to find JDK 1.5 easily any > more? > > > > -Jukka Rahkonen- > > > > Alberto De Luca wrote: > > > > Peppe, > > > > my bad: I compiled it using JDK 1.6 instead of 1.5. Gonna fix it asap. > > > > Albertol > > > > On Thu, 19 Nov 2015 at 15:47 Giuseppe Aruta <giuseppe.ar...@gmail.com > <mailto:giuseppe.ar...@gmail.com>> wrote: > > Hi Alberto, > > it seems not working: see OpenJUMP-20151119-r4553.log, > <http://sourceforge.net/projects/jump-pilot/files/OpenJUMP_snapshots/OpenJUMP-20151119-r4553.log/download>class > SLDHandler - com.sun.xml.internal.txw2.output.IndentingXMLStreamWriter Peppe > > > > 2015-11-19 12:35 GMT+01:00 <jump-pilot-...@lists.sourceforge.net > <mailto:jump-pilot-...@lists.sourceforge.net>>: > > Revision: 4553 > http://sourceforge.net/p/jump-pilot/code/4553 > Author: bertazza > Date: 2015-11-19 11:35:44 +0000 (Thu, 19 Nov 2015) > Log Message: > ----------- > - Raster styler: added options to save and load symbology as SLD > file, added option to invert ramp for stretched symbology, added given > interval classification method, added some more default symbologies, fixed > some bugs > - esri Floating Point grid header writer: bug fixed > - RasterImageLayer: fixed few bugs related to overall and single > cell transparency > > Modified Paths: > -------------- > core/trunk/ChangeLog > core/trunk/src/org/openjump/core/rasterimage/GridFloat.java > core/trunk/src/org/openjump/core/rasterimage/RasterImageLayer.java > core/trunk/src/org/openjump/core/rasterimage/RasterSymbology.java > core/trunk/src/org/openjump/core/rasterimage/TiffUtils.java > > core/trunk/src/org/openjump/core/rasterimage/styler/RasterClassifier1D.java > > core/trunk/src/org/openjump/core/rasterimage/styler/resources/Bundle.properties > > core/trunk/src/org/openjump/core/rasterimage/styler/resources/Bundle_en.properties > > core/trunk/src/org/openjump/core/rasterimage/styler/ui/IntervalPanel.java > > core/trunk/src/org/openjump/core/rasterimage/styler/ui/RasterStylesDialog.form > > core/trunk/src/org/openjump/core/rasterimage/styler/ui/RasterStylesDialog.java > > core/trunk/src/org/openjump/core/rasterimage/styler/ui/SingleValuesPanel.java > > core/trunk/src/org/openjump/core/rasterimage/styler/ui/StandardGradientColors.java > > core/trunk/src/org/openjump/core/rasterimage/styler/ui/StretchedPanel.form > > core/trunk/src/org/openjump/core/rasterimage/styler/ui/StretchedPanel.java > > Added Paths: > ----------- > > core/trunk/src/org/openjump/core/rasterimage/styler/SLDHandler.java > > Removed Paths: > ------------- > core/trunk/src/org/openjump/core/rasterimage/styler/SLDReader.java > > Modified: core/trunk/ChangeLog > =================================================================== > --- core/trunk/ChangeLog 2015-11-15 11:31:06 UTC (rev 4552) > +++ core/trunk/ChangeLog 2015-11-19 11:35:44 UTC (rev 4553) > @@ -1,4 +1,12 @@ > # for display continuity sake please use 2 spaces instead of tabs > +2015-11-19 bertazza <berta...@gmail.com <mailto:berta...@gmail.com>> > + * Raster styler: added options to save and load symbology as SLD > file, > + added option to invert ramp for stretched symbology, added given > interval > + classification method, added some more default symbologies, fixed > some bugs > + * esri Floating Point grid header writer: bug fixed > + * RasterImageLayer: fixed few bugs related to overall and single > cell > + transparency > + > 2015-11-13 Giuseppe Arta <giuseppe_ar...@yahoo.it > <mailto:giuseppe_ar...@yahoo.it>> > * Added Measure Toolbox Extension version 11 to OpenJUMP Plus > Documentation is available here: > http://sourceforge.net/projects/opensit > > Modified: core/trunk/src/org/openjump/core/rasterimage/GridFloat.java > =================================================================== > --- core/trunk/src/org/openjump/core/rasterimage/GridFloat.java > 2015-11-15 11:31:06 UTC (rev 4552) > +++ core/trunk/src/org/openjump/core/rasterimage/GridFloat.java > 2015-11-19 11:35:44 UTC (rev 4553) > @@ -159,8 +159,8 @@ > buffWrite.write("byteorder" + " " + byteOrder); > buffWrite.newLine(); > > + buffWrite.close(); > fileWriter.close(); > - buffWrite.close(); > > } > > @@ -326,7 +326,7 @@ > > public double readCellVal(Integer col, Integer row) throws > FileNotFoundException, IOException{ > > - long offset = ((row - 1) * nCols + col - 1) * 4; > + long offset = (row * nCols + col) * 4; > > File fileFlt = new File(fltFullFileName); > FileInputStream fileInStream = new FileInputStream(fileFlt); > > Modified: > core/trunk/src/org/openjump/core/rasterimage/RasterImageLayer.java > =================================================================== > --- > core/trunk/src/org/openjump/core/rasterimage/RasterImageLayer.java > 2015-11-15 11:31:06 UTC (rev 4552) > +++ > core/trunk/src/org/openjump/core/rasterimage/RasterImageLayer.java > 2015-11-19 11:35:44 UTC (rev 4553) > @@ -570,17 +570,9 @@ > > if(symbology == null) { > if(stats.getBandCount() < 3) { > -// double value = > actualRasterData.getSampleDouble(col, row, 0); > -// if(Double.isNaN(value) || > Double.isInfinite(value) || value == noDataValue) { > -// newImage.setRGB(col, row, > Color.TRANSLUCENT); > -// continue; > -// } > -// int rgbValue = (int) ((value - > stats.getMin(0)) * 255./(stats.getMax(0) - stats.getMin(0))); > -// if(rgbValue > 255) rgbValue = 255; > -// if(rgbValue < 0) rgbValue = 0; > -// newImage.setRGB(col, row, new > Color(rgbValue, rgbValue, rgbValue).getRGB()); > > RasterSymbology rasterSymbology = new > RasterSymbology(RasterSymbology.ColorMapType.RAMP); > + > rasterSymbology.addColorMapEntry(metadata.getNoDataValue(), transparentColor); > > rasterSymbology.addColorMapEntry(metadata.getStats().getMin(0), Color.WHITE); > > rasterSymbology.addColorMapEntry(metadata.getStats().getMax(0), Color.BLACK); > setSymbology(rasterSymbology); > @@ -631,22 +623,29 @@ > symbMinValue = symbologyClassLimits[1]; > } > > - if(value < symbMinValue) { > + if(!this.isNoData(value) && value < > symbMinValue) { > value = symbMinValue; > } > > Color color = symbology.getColor(value); > > - if((Double.isNaN(value) || > Double.isInfinite(value) || value == noDataValue) > + if((Double.isNaN(value) || > Double.isInfinite(value) || this.isNoData(value)) > && color == null) { > newImage.setRGB(col, row, Color.TRANSLUCENT); > continue; > } > - > - newImage.setRGB(col, row, color.getRGB()); > - } > > - > + // Transparency is a combination of total layer > transparency > + // and single cell transparency > + int transparency = > + (int)(((1 - symbology.getTransparency()) > * > + (color.getAlpha() / 255d)) * 255); > + newImage.setRGB(col, row, new Color( > + color.getRed(), > + color.getGreen(), > + color.getBlue(), > + transparency).getRGB()); > + } > } > } > > @@ -1626,7 +1625,7 @@ > if(Double.isNaN(noDataValue) && Double.isNaN(value)) { > return true; > } > - return(value == noDataValue); > + return(value == noDataValue || (float)value == > (float)noDataValue); > } > > public Metadata getMetadata() { > > Modified: > core/trunk/src/org/openjump/core/rasterimage/RasterSymbology.java > =================================================================== > --- core/trunk/src/org/openjump/core/rasterimage/RasterSymbology.java > 2015-11-15 11:31:06 UTC (rev 4552) > +++ core/trunk/src/org/openjump/core/rasterimage/RasterSymbology.java > 2015-11-19 11:35:44 UTC (rev 4553) > @@ -1,6 +1,7 @@ > package org.openjump.core.rasterimage; > > import java.awt.Color; > +import java.util.Map; > import java.util.TreeMap; > import org.openjump.core.rasterimage.styler.ColorMapEntry; > > @@ -51,6 +52,18 @@ > return colorMapEntries_tm; > } > > + public ColorMapEntry[] getColorMapEntries() { > + > + ColorMapEntry[] colorMapEntries = new > ColorMapEntry[getColorMapEntries_tm().size()]; > + int pos = 0; > + for(Map.Entry<Double,Color> colorMapEntry : > getColorMapEntries_tm().entrySet()) { > + colorMapEntries[pos] = new > ColorMapEntry(colorMapEntry.getKey(), colorMapEntry.getValue()); > + pos++; > + } > + return colorMapEntries; > + > + } > + > public double getTransparency() { > return transparency; > } > > Modified: core/trunk/src/org/openjump/core/rasterimage/TiffUtils.java > =================================================================== > --- core/trunk/src/org/openjump/core/rasterimage/TiffUtils.java > 2015-11-15 11:31:06 UTC (rev 4552) > +++ core/trunk/src/org/openjump/core/rasterimage/TiffUtils.java > 2015-11-19 11:35:44 UTC (rev 4553) > @@ -274,7 +274,8 @@ > for(int b=0; b<bandCount; b++) { > > double value = raster.getSampleDouble(c, r, b); > - if(value != noDataValue && !Double.isNaN(value) > && !Double.isInfinite(value)) { > + if(value != noDataValue && (float)value != > (float)noDataValue && > + !Double.isNaN(value) && > !Double.isInfinite(value)) { > if(value < minValue[b]) minValue[b] = value; > if(value > maxValue[b]) maxValue[b] = value; > cellsCount[b]++; > > Modified: > core/trunk/src/org/openjump/core/rasterimage/styler/RasterClassifier1D.java > =================================================================== > --- > core/trunk/src/org/openjump/core/rasterimage/styler/RasterClassifier1D.java > 2015-11-15 11:31:06 UTC (rev 4552) > +++ > core/trunk/src/org/openjump/core/rasterimage/styler/RasterClassifier1D.java > 2015-11-19 11:35:44 UTC (rev 4553) > @@ -18,5 +18,28 @@ > > } > > + public static double[] classifyGivenInterval(RasterImageLayer > rasImgLay, int band, double interval) { > + > + double minVal = > rasImgLay.getMetadata().getStats().getMin(band); > + double maxVal = > rasImgLay.getMetadata().getStats().getMax(band); > + > + minVal = Math.floor(minVal/interval) * interval; > + maxVal = Math.ceil(maxVal/interval) * interval; > + int intvCount = (int) ((maxVal - minVal) / interval); > + > + // Following intervals > + double valEnd = minVal; > + double[] breaks = new double[intvCount]; > + for (int i = 0; i < intvCount; i++) { > + double valStart = valEnd; > + valEnd = valStart + interval; > + if (valEnd >= maxVal) { > + valEnd = maxVal; > + } > + breaks[i] = valEnd; > + > + } > + return breaks; > + } > > } > > Copied: > core/trunk/src/org/openjump/core/rasterimage/styler/SLDHandler.java (from rev > 4541, core/trunk/src/org/openjump/core/rasterimage/styler/SLDReader.java) > =================================================================== > --- > core/trunk/src/org/openjump/core/rasterimage/styler/SLDHandler.java > (rev 0) > +++ > core/trunk/src/org/openjump/core/rasterimage/styler/SLDHandler.java > 2015-11-19 11:35:44 UTC (rev 4553) > @@ -0,0 +1,182 @@ > +package org.openjump.core.rasterimage.styler; > + > +import com.sun.xml.internal.txw2.output.IndentingXMLStreamWriter; > +import java.awt.Color; > +import java.io.File; > +import java.io.FileWriter; > +import java.io.IOException; > +import java.util.Map; > +import javax.xml.parsers.DocumentBuilderFactory; > +import static javax.xml.parsers.DocumentBuilderFactory.newInstance; > +import javax.xml.parsers.ParserConfigurationException; > +import javax.xml.stream.XMLOutputFactory; > +import javax.xml.stream.XMLStreamException; > +import javax.xml.stream.XMLStreamWriter; > +import javax.xml.transform.OutputKeys; > +import javax.xml.transform.Transformer; > +import javax.xml.transform.TransformerConfigurationException; > +import javax.xml.transform.TransformerFactory; > +import org.openjump.core.rasterimage.RasterSymbology; > +import org.openjump.core.rasterimage.RasterSymbology.ColorMapType; > +import org.w3c.dom.Document; > +import org.w3c.dom.Element; > +import org.w3c.dom.NodeList; > +import org.xml.sax.SAXException; > + > +/** > + * Utility class to read a GeoServer-style SLD file into a raster > symbolizer. > + * @author AdL > + */ > +public class SLDHandler { > + > + /** > + * Reads the SLD file and creates a raster symbolizer. > + * @param SLDFile The SLD file to be read. > + * @return The raster symbolizer. > + * @throws ParserConfigurationException > + * @throws SAXException > + * @throws IOException > + * @throws Exception > + */ > + public static RasterSymbology read(File SLDFile) throws > ParserConfigurationException, SAXException, IOException, Exception { > + > + DocumentBuilderFactory dbf = newInstance(); > + dbf.setNamespaceAware(true); > + ColorMapType colorMapType = ColorMapType.RAMP; > + > + RasterSymbology rasterSymbology = null; > + > + Document doc = dbf.newDocumentBuilder().parse(SLDFile); > + NodeList rasterSymb_nl = > doc.getElementsByTagName("RasterSymbolizer"); > + if(rasterSymb_nl.getLength() == 1) { > + > + Element rasterSymb_el = (Element) rasterSymb_nl.item(0); > + > + // Type > + NodeList type_nl = > rasterSymb_el.getElementsByTagName("Type"); > + if(type_nl.getLength() == 1) { > + Element type_el = (Element) type_nl.item(0); > + String type = type_el.getTextContent(); > + colorMapType = > ColorMapType.valueOf(type.toUpperCase()); > + } > + > + rasterSymbology = new RasterSymbology(colorMapType); > + > + // Opacity > + NodeList opacity_nl = > rasterSymb_el.getElementsByTagName("Opacity"); > + if(opacity_nl.getLength() == 1) { > + Element opacity_el = (Element) opacity_nl.item(0); > + double opacity = > Double.parseDouble(opacity_el.getTextContent()); > + rasterSymbology.setTransparency(1. - opacity); > + } > + > + NodeList colorMap_nl = > doc.getElementsByTagName("ColorMap"); > + for(int me=0; me<colorMap_nl.getLength(); me++) { > + Element colorMap = (Element) colorMap_nl.item(me); > + NodeList colorMapElements_nl = > colorMap.getElementsByTagName("ColorMapEntry"); > + > + for(int cme=0; cme<colorMapElements_nl.getLength(); > cme++) { > + Element colorMapEntryElement = (Element) > colorMapElements_nl.item(cme); > + double quantity = > Double.parseDouble(colorMapEntryElement.getAttribute("quantity")); > + Color color = > hex2Rgb(colorMapEntryElement.getAttribute("Color")); > + rasterSymbology.addColorMapEntry(quantity, > color); > + } > + } > + } > + > + return rasterSymbology; > + > + } > + > + public static void write(RasterSymbology symbology, String > symbologyName, File sldFile) throws IOException, XMLStreamException, > TransformerConfigurationException { > + > + XMLOutputFactory outFactory = > XMLOutputFactory.newInstance(); > + XMLStreamWriter writer = new > IndentingXMLStreamWriter(outFactory.createXMLStreamWriter(new > FileWriter(sldFile))); > + > + writer.writeStartDocument(); > + writer.writeStartElement("StyledLayerDescriptor"); > + writer.writeAttribute("xmlns", "http://www.opengis.net/sld"); > + writer.writeAttribute("xmlns:ogc", > "http://www.opengis.net/ogc"); > + writer.writeAttribute("xmlns:xlink", > "http://www.w3.org/1999/xlink"); > + writer.writeAttribute("xmlns:xsi", > "http://www.w3.org/2001/XMLSchema-instance"); > + writer.writeAttribute("version", "1.0.0"); > + writer.writeAttribute("xsi:schemaLocation", > "http://www.opengis.net/sld StyledLayerDescriptor.xsd"); > + > + writer.writeStartElement("NamedLayer"); > + writer.writeStartElement("Name"); > + if(symbologyName != null) { > + writer.writeCharacters(symbologyName); > + } > + writer.writeStartElement("UserStyle"); > + writer.writeStartElement("Title"); > + writer.writeCharacters("OpenJUMP Raster Style"); > + writer.writeStartElement("FeatureTypeStyle"); > + writer.writeStartElement("Rule"); > + writer.writeStartElement("RasterSymbolizer"); > + > + writer.writeStartElement("Type"); > + writer.writeCharacters(symbology.getColorMapType().name()); > + writer.writeEndElement(); > + > + writer.writeStartElement("Opacity"); > + writer.writeCharacters(Double.toString(1. - > symbology.getTransparency())); > + writer.writeEndElement(); > + > + writer.writeStartElement("ColorMap"); > + > + for(Map.Entry<Double,Color> colorMapEntry : > symbology.getColorMapEntries_tm().entrySet()) { > + > + writer.writeStartElement("ColorMapEntry"); > + writer.writeAttribute("Color", > SLDHandler.rgb2Hex(colorMapEntry.getValue())); > + writer.writeAttribute("quantity", > colorMapEntry.getKey().toString()); > + writer.writeEndElement(); > + > + } > + > + writer.writeEndElement(); // ColorMap > + > + writer.writeEndElement(); // RasterSymbolizer > + writer.writeEndElement(); // Rule > + writer.writeEndElement(); // FeatureTypeStyle > + writer.writeEndElement(); // Title > + writer.writeEndElement(); // UserStyle > + writer.writeEndElement(); // Name > + writer.writeEndElement(); // NamedLayer > + writer.writeEndElement(); // StyledLayerDescriptor > + > + writer.writeEndDocument(); > + > + writer.flush(); > + writer.close(); > + > + } > + > + public static Color hex2Rgb(String colorStr) { > + > + if(colorStr.equals("")) { > + return null; > + } > + > + return new Color( > + Integer.valueOf( colorStr.substring( 1, 3 ), 16 ), > + Integer.valueOf( colorStr.substring( 3, 5 ), 16 ), > + Integer.valueOf( colorStr.substring( 5, 7 ), 16 ) ); > + } > + > + public static String rgb2Hex(Color rgbColor) { > + > + if(rgbColor == null) { > + return ""; > + } > + > + return SLDHandler.rgb2Hex(rgbColor.getRed(), > rgbColor.getGreen(), rgbColor.getBlue()); > + > + } > + > + public static String rgb2Hex(int r, int g, int b) { > + > + return String.format("#%02x%02x%02x", r, g, b); > + > + } > + > +} > > Deleted: > core/trunk/src/org/openjump/core/rasterimage/styler/SLDReader.java > =================================================================== > --- > core/trunk/src/org/openjump/core/rasterimage/styler/SLDReader.java > 2015-11-15 11:31:06 UTC (rev 4552) > +++ > core/trunk/src/org/openjump/core/rasterimage/styler/SLDReader.java > 2015-11-19 11:35:44 UTC (rev 4553) > @@ -1,81 +0,0 @@ > -package org.openjump.core.rasterimage.styler; > - > -import java.awt.Color; > -import java.io.File; > -import java.io.IOException; > -import javax.xml.parsers.DocumentBuilderFactory; > -import static javax.xml.parsers.DocumentBuilderFactory.newInstance; > -import javax.xml.parsers.ParserConfigurationException; > -import org.openjump.core.rasterimage.RasterSymbology; > -import org.openjump.core.rasterimage.RasterSymbology.ColorMapType; > -import org.w3c.dom.Document; > -import org.w3c.dom.Element; > -import org.w3c.dom.NodeList; > -import org.xml.sax.SAXException; > - > -/** > - * Utility class to read an GeoServer-style SLD file into a raster > symbolizer. > - * @author AdL > - */ > -public class SLDReader { > - > - /** > - * Reads the SLD file and creates a raster symbolizer. > - * @param SLDFile The SLD file to be read. > - * @return The raster symbolizer. > - * @throws ParserConfigurationException > - * @throws SAXException > - * @throws IOException > - * @throws Exception > - */ > - public static RasterSymbology read(File SLDFile) throws > ParserConfigurationException, SAXException, IOException, Exception { > - > - DocumentBuilderFactory dbf = newInstance(); > - dbf.setNamespaceAware(true); > - ColorMapType colorMapType = ColorMapType.RAMP; > - > - RasterSymbology rasterSymbolizer = null; > - > - Document doc = dbf.newDocumentBuilder().parse(SLDFile); > - NodeList nodeList = > doc.getElementsByTagName("RasterSymbolizer"); > - if(nodeList.getLength() == 1) { > - NodeList opacity_nl = > doc.getElementsByTagName("Opacity"); > - // TODO > - > - NodeList colorMap_nl = > doc.getElementsByTagName("ColorMap"); > - for(int me=0; me<colorMap_nl.getLength(); me++) { > - Element colorMap = (Element) colorMap_nl.item(me); > - > - /* Types: ramps, intervals, values */ > - String colorMapTypeAttribute = > colorMap.getAttribute("type"); > - if(!colorMapTypeAttribute.equals("")) { > - colorMapType = > ColorMapType.valueOf(colorMapTypeAttribute.toUpperCase()); > - } > - > - rasterSymbolizer = new RasterSymbology(colorMapType); > - > - NodeList colorMapElements_nl = > colorMap.getElementsByTagName("ColorMapEntry"); > - > - for(int cme=0; cme<colorMapElements_nl.getLength(); > cme++) { > - Element colorMapEntryElement = (Element) > colorMapElements_nl.item(cme); > - double quantity = > Double.parseDouble(colorMapEntryElement.getAttribute("quantity")); > - Color color = > hex2Rgb(colorMapEntryElement.getAttribute("color")); > - rasterSymbolizer.addColorMapEntry(quantity, > color); > - } > - > - } > - } > - > - return rasterSymbolizer; > - > - } > - > - public static Color hex2Rgb(String colorStr) { > - return new Color( > - Integer.valueOf( colorStr.substring( 1, 3 ), 16 ), > - Integer.valueOf( colorStr.substring( 3, 5 ), 16 ), > - Integer.valueOf( colorStr.substring( 5, 7 ), 16 ) ); > - } > - > - > -} > > Modified: > core/trunk/src/org/openjump/core/rasterimage/styler/resources/Bundle.properties > =================================================================== > --- > core/trunk/src/org/openjump/core/rasterimage/styler/resources/Bundle.properties > 2015-11-15 11:31:06 UTC (rev 4552) > +++ > core/trunk/src/org/openjump/core/rasterimage/styler/resources/Bundle.properties > 2015-11-19 11:35:44 UTC (rev 4553) > @@ -39,7 +39,7 @@ > > org.openjump.core.rasterimage.styler.ui.CustomGradientColorsDialog.jButton_Cancel.text=Cancel > > org.openjump.core.rasterimage.styler.ui.CustomGradientColorsDialog.jButton_Ok.text=Ok > > org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jButton_Restore.text=Restore > > -org.openjump.core.rasterimage.styler.ui.SingleValuesPanel.jButton_Ramp=Ramp > all > > +org.openjump.core.rasterimage.styler.ui.SingleValuesPanel.jButton_Ramp=Ramp > > org.openjump.core.rasterimage.styler.ui.SingleValuesPanel.jButton_Random=Random > > org.openjump.core.rasterimage.styler.ui.SingleValuesPanel.message.SelectTwoRows=You > need to selected two rows to ramp colors. > > org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.chooseNoDataColor=Choose > color for nodata > @@ -70,3 +70,16 @@ > org.openjump.core.rasterimage.styler.ui.ColorEditor.Ok=Ok > org.openjump.core.rasterimage.styler.RasterStylesExtension.Name > <http://org.openjump.core.rasterimage.styler.RasterStylesExtension.Name>=Raster > styles... > > org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jButton_OK.text=OK > > +org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jButton_Load.text=Load > > +org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jButton_Save.text=Save > > +org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.fileChooser.sld=SLD > Style files > > +org.openjump.core.rasterimage.styler.ui.StretchedPanel.jCheckBox_Invert.text=Invert > ramp > > +org.openjump.core.rasterimage.styler.ui.IntervalPanel.classMethods.GivenInterval=Given > interval > > +org.openjump.core.rasterimage.styler.ui.IntervalPanel.jLabel.classwidth=Interval > +IntervalPanel.jLabel.method=Method: > +IntervalPanel.jLabel.Classes=Classes: > +IntervalPanel.jButton.RampAll=Ramp all > +IntervalPanel.jButton.Ramp=Ramp > +IntervalPanel.jButton.AddRow=Add row > +IntervalPanel.jButton.RemoveRow=Remove row > > +org.openjump.core.rasterimage.styler.ui.SingleValuesPanel.jButton_RampAll=Ramp > all > > Modified: > core/trunk/src/org/openjump/core/rasterimage/styler/resources/Bundle_en.properties > =================================================================== > --- > core/trunk/src/org/openjump/core/rasterimage/styler/resources/Bundle_en.properties > 2015-11-15 11:31:06 UTC (rev 4552) > +++ > core/trunk/src/org/openjump/core/rasterimage/styler/resources/Bundle_en.properties > 2015-11-19 11:35:44 UTC (rev 4553) > @@ -39,7 +39,7 @@ > > org.openjump.core.rasterimage.styler.ui.CustomGradientColorsDialog.jButton_Cancel.text=Cancel > > org.openjump.core.rasterimage.styler.ui.CustomGradientColorsDialog.jButton_Ok.text=Ok > > org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jButton_Restore.text=Restore > > -org.openjump.core.rasterimage.styler.ui.SingleValuesPanel.jButton_Ramp=Ramp > all > > +org.openjump.core.rasterimage.styler.ui.SingleValuesPanel.jButton_Ramp=Ramp > > org.openjump.core.rasterimage.styler.ui.SingleValuesPanel.jButton_Random=Random > > org.openjump.core.rasterimage.styler.ui.SingleValuesPanel.message.SelectTwoRows=You > need to selected two rows to ramp colors. > > org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.chooseNoDataColor=Choose > color for nodata > @@ -69,3 +69,17 @@ > org.openjump.core.rasterimage.styler.ui.ColorEditor.Cancel=Cancel > org.openjump.core.rasterimage.styler.ui.ColorEditor.Ok=Ok > > org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jButton_OK.text=OK > > +org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jButton_Load.text=Load > > +org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jButton_Save.text=Save > > +org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.fileChooser.sld=SLD > Style files > > +org.openjump.core.rasterimage.styler.ui.StretchedPanel.jCheckBox_Invert.text=Invert > ramp > +org.openjump.core.rasterimage.styler.RasterStylesExtension.Name > <http://org.openjump.core.rasterimage.styler.RasterStylesExtension.Name>=Raster > styles... > > +org.openjump.core.rasterimage.styler.ui.IntervalPanel.classMethods.GivenInterval=Given > interval > > +org.openjump.core.rasterimage.styler.ui.IntervalPanel.jLabel.classwidth=Interval > +IntervalPanel.jButton.AddRow=Add row > +IntervalPanel.jButton.Ramp=Ramp > +IntervalPanel.jButton.RampAll=Ramp all > +IntervalPanel.jButton.RemoveRow=Remove row > +IntervalPanel.jLabel.Classes=Classes: > +IntervalPanel.jLabel.method=Method: > > +org.openjump.core.rasterimage.styler.ui.SingleValuesPanel.jButton_RampAll=Ramp > all > > Modified: > core/trunk/src/org/openjump/core/rasterimage/styler/ui/IntervalPanel.java > =================================================================== > --- > core/trunk/src/org/openjump/core/rasterimage/styler/ui/IntervalPanel.java > 2015-11-15 11:31:06 UTC (rev 4552) > +++ > core/trunk/src/org/openjump/core/rasterimage/styler/ui/IntervalPanel.java > 2015-11-19 11:35:44 UTC (rev 4553) > @@ -7,9 +7,10 @@ > import java.awt.Component; > import java.awt.GridBagConstraints; > import java.awt.GridBagLayout; > +import java.awt.event.ActionEvent; > +import java.awt.event.ActionListener; > import java.util.ArrayList; > import java.util.EnumMap; > -import java.util.HashMap; > import java.util.List; > import java.util.Map; > import java.util.Map.Entry; > @@ -17,9 +18,12 @@ > import java.util.logging.Logger; > import javax.swing.JOptionPane; > import org.openjump.core.attributeoperations.Classifier1D; > +import org.openjump.core.rasterimage.RasterImageLayer; > import org.openjump.core.rasterimage.styler.ColorMapEntry; > import org.openjump.core.rasterimage.RasterSymbology; > import > org.openjump.core.rasterimage.styler.ui.ColorsTablePanel.TableType; > +import org.openjump.core.rasterimage.styler.RasterClassifier1D; > +import org.openjump.core.rasterimage.styler.Utils; > > /** > * > @@ -30,14 +34,14 @@ > /** > * Creates new form IntervalPanel > * @param parent > - * @param rasterData > + * @param rasterImageLayer > * @param minMaxValues > * @throws java.lang.Exception > */ > - public IntervalPanel(Component parent, double[] rasterData, > Range minMaxValues) throws Exception { > + public IntervalPanel(Component parent, RasterImageLayer > rasterImageLayer, Range minMaxValues) throws Exception { > initComponents(); > this.parent = parent; > - this.rasterData = rasterData; > + this.rasterImageLayer = rasterImageLayer; > this.minMaxValues = minMaxValues; > > fixComponents(); > @@ -76,7 +80,7 @@ > setLayout(layout); > > java.util.ResourceBundle bundle = > java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle"); > // NOI18N > - > jLabel_Method.setText(bundle.getString("org.openjump.core.rasterimage.styler.ui.IntervalPanel.jLabel.method")); > // NOI18N > + > jLabel_Method.setText(bundle.getString("IntervalPanel.jLabel.method")); // > NOI18N > gridBagConstraints = new java.awt.GridBagConstraints(); > gridBagConstraints.gridx = 0; > gridBagConstraints.gridy = 0; > @@ -96,7 +100,7 @@ > gridBagConstraints.ipadx = 3; > add(jComboBox_Method, gridBagConstraints); > > - > jButton_Values.setText(bundle.getString("org.openjump.core.rasterimage.styler.ui.IntervalPanel.jButton.RampAll")); > // NOI18N > + > jButton_Values.setText(bundle.getString("IntervalPanel.jButton.RampAll")); // > NOI18N > jButton_Values.addActionListener(new > java.awt.event.ActionListener() { > public void actionPerformed(java.awt.event.ActionEvent > evt) { > jButton_ValuesActionPerformed(evt); > @@ -108,13 +112,13 @@ > gridBagConstraints.fill = > java.awt.GridBagConstraints.HORIZONTAL; > add(jButton_Values, gridBagConstraints); > > - > jLabel_Classes.setText(bundle.getString("org.openjump.core.rasterimage.styler.ui.IntervalPanel.jLabel.Classes")); > // NOI18N > + > jLabel_Classes.setText(bundle.getString("IntervalPanel.jLabel.Classes")); // > NOI18N > gridBagConstraints = new java.awt.GridBagConstraints(); > gridBagConstraints.gridx = 0; > gridBagConstraints.gridy = 2; > add(jLabel_Classes, gridBagConstraints); > > - jTextField_Classes.setText("5"); > + jTextField_Classes.setText("null"); > jTextField_Classes.setMinimumSize(new java.awt.Dimension(70, > 20)); > jTextField_Classes.setPreferredSize(new > java.awt.Dimension(70, 20)); > gridBagConstraints = new java.awt.GridBagConstraints(); > @@ -135,7 +139,7 @@ > gridBagConstraints.weighty = 0.5; > add(jPanel_Table, gridBagConstraints); > > - > jButton_AddRow.setText(bundle.getString("org.openjump.core.rasterimage.styler.ui.IntervalPanel.jButton.AddRow")); > // NOI18N > + > jButton_AddRow.setText(bundle.getString("IntervalPanel.jButton.AddRow")); // > NOI18N > jButton_AddRow.addActionListener(new > java.awt.event.ActionListener() { > public void actionPerformed(java.awt.event.ActionEvent > evt) { > jButton_AddRowActionPerformed(evt); > @@ -146,7 +150,7 @@ > gridBagConstraints.gridy = 6; > add(jButton_AddRow, gridBagConstraints); > > - > jButton_RemoveRow.setText(bundle.getString("org.openjump.core.rasterimage.styler.ui.IntervalPanel.jButton.RemoveRow")); > // NOI18N > + > jButton_RemoveRow.setText(bundle.getString("IntervalPanel.jButton.RemoveRow")); > // NOI18N > jButton_RemoveRow.addActionListener(new > java.awt.event.ActionListener() { > public void actionPerformed(java.awt.event.ActionEvent > evt) { > jButton_RemoveRowActionPerformed(evt); > @@ -157,7 +161,7 @@ > gridBagConstraints.gridy = 6; > add(jButton_RemoveRow, gridBagConstraints); > > - > jButton_Ramp.setText(bundle.getString("org.openjump.core.rasterimage.styler.ui.IntervalPanel.jButton.Ramp")); > // NOI18N > + > jButton_Ramp.setText(bundle.getString("IntervalPanel.jButton.Ramp")); // > NOI18N > jButton_Ramp.addActionListener(new > java.awt.event.ActionListener() { > public void actionPerformed(java.awt.event.ActionEvent > evt) { > jButton_RampActionPerformed(evt); > @@ -227,6 +231,7 @@ > private void fixComponents() throws Exception { > > classMethods_m.put(ClassificationMethod.EQUAL_RANGE, > java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle").getString("org.openjump.core.rasterimage.styler.ui.IntervalPanel.classMethods.EqualInterval")); > + classMethods_m.put(ClassificationMethod.GIVEN_INTERVAL, > java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle").getString("org.openjump.core.rasterimage.styler.ui.IntervalPanel.classMethods.GivenInterval")); > classMethods_m.put(ClassificationMethod.JENKS, > java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle").getString("org.openjump.core.rasterimage.styler.ui.IntervalPanel.classMethods.Jenks")); > classMethods_m.put(ClassificationMethod.MAX_BREAKS, > java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle").getString("org.openjump.core.rasterimage.styler.ui.IntervalPanel.classMethods.MaxBreaks")); > classMethods_m.put(ClassificationMethod.MEAN_STDEV, > java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle").getString("org.openjump.core.rasterimage.styler.ui.IntervalPanel.classMethods.MeanStDev")); > @@ -234,12 +239,28 @@ > > jComboBox_Method.removeAllItems(); > > jComboBox_Method.addItem(classMethods_m.get(ClassificationMethod.EQUAL_RANGE)); > + > jComboBox_Method.addItem(classMethods_m.get(ClassificationMethod.GIVEN_INTERVAL)); > > jComboBox_Method.addItem(classMethods_m.get(ClassificationMethod.JENKS)); > > jComboBox_Method.addItem(classMethods_m.get(ClassificationMethod.MAX_BREAKS)); > > jComboBox_Method.addItem(classMethods_m.get(ClassificationMethod.MEAN_STDEV)); > > jComboBox_Method.addItem(classMethods_m.get(ClassificationMethod.QUANTILE)); > > jComboBox_Method.setSelectedItem(classMethods_m.get(ClassificationMethod.JENKS)); > > + // Listener > + jComboBox_Method.addActionListener (new ActionListener () { > + @Override > + public void actionPerformed(ActionEvent e) { > + > + ClassificationMethod classMethod = > getKeyByValue(classMethods_m, jComboBox_Method.getSelectedItem().toString()); > + if(classMethod == > ClassificationMethod.GIVEN_INTERVAL) { > + > jLabel_Classes.setText(bundle.getString("org.openjump.core.rasterimage.styler.ui.IntervalPanel.jLabel.classwidth")); > + } else { > + > jLabel_Classes.setText(bundle.getString("org.openjump.core.rasterimage.styler.ui.IntervalPanel.jLabel.Classes")); > + } > + > + } > + }); > + > // Color ramps > jComboBox_Gradient = > GUIUtils.createStandardGradientComboBox(200, 18); > > @@ -259,13 +280,22 @@ > private void rampAll() throws Exception { > > int classesCount = > Integer.parseInt(jTextField_Classes.getText()); > + double classWidth = 0; > + > double[] breaks = null; > + double[] rasterData = > Utils.purgeNoData(rasterImageLayer.getActualRasterData(),rasterImageLayer); > > - switch (getKeyByValue(classMethods_m, > jComboBox_Method.getSelectedItem().toString())) { > + ClassificationMethod classMethod = > getKeyByValue(classMethods_m, jComboBox_Method.getSelectedItem().toString()); > + switch (classMethod) { > > case EQUAL_RANGE: > breaks = Classifier1D.classifyEqualRange(rasterData, > classesCount); > break; > + case GIVEN_INTERVAL: > + breaks = > RasterClassifier1D.classifyGivenInterval(rasterImageLayer, 0, classesCount); > + classWidth = classesCount; > + classesCount = breaks.length; > + break; > case JENKS: > /* Sampling needed */ > int top = 1000; > @@ -308,7 +338,12 @@ > ColorMapEntry[] colorMapEntries = new > ColorMapEntry[classesCount]; > int colorsCount = paletteColorMapEntries.length; > > - colorMapEntries[0] = new ColorMapEntry((Double) > minMaxValues.getMin(), paletteColorMapEntries[0].getColor()); > + double minVal = (Double) minMaxValues.getMin(); > + if(classMethod == ClassificationMethod.GIVEN_INTERVAL) { > + minVal = Math.floor((Double) minMaxValues.getMin() / > classWidth) * classWidth; > + } > + > + colorMapEntries[0] = new ColorMapEntry(minVal, > paletteColorMapEntries[0].getColor()); > for(int c=1; c<classesCount; c++) { > > double cellRelDistance = (double) c / (double) > (classesCount-1); > @@ -321,19 +356,8 @@ > colorMapEntries[c] = new ColorMapEntry(breaks[c-1], > color); > } > > - /* Update table */ > - if(colorsTablePanel == null) { > - colorsTablePanel = new ColorsTablePanel(parent, > TableType.INTERVALS, > - colorMapEntries, noDataValue, false); > - GridBagLayout layout = (GridBagLayout)getLayout(); > - GridBagConstraints gbc = > layout.getConstraints(jPanel_Table); > - remove(jPanel_Table); > - add(colorsTablePanel, gbc, 5); > - validate(); > - } else { > - colorsTablePanel.updateTable(colorMapEntries); > - } > - > + updateTable(colorMapEntries); > + > } > > private void addRow() { > @@ -364,6 +388,29 @@ > return null; > } > > + public void plugRasterSymbology(RasterSymbology rasterSymbology) > { > + > + updateTable(rasterSymbology.getColorMapEntries()); > + > + } > + > + private void updateTable(ColorMapEntry[] colorMapEntries) { > + > + /* Update table */ > + if(colorsTablePanel == null) { > + colorsTablePanel = new ColorsTablePanel(parent, > TableType.INTERVALS, > + colorMapEntries, > rasterImageLayer.getNoDataValue(), false); > + GridBagLayout layout = (GridBagLayout)getLayout(); > + GridBagConstraints gbc = > layout.getConstraints(jPanel_Table); > + remove(jPanel_Table); > + add(colorsTablePanel, gbc, 5); > + validate(); > + } else { > + colorsTablePanel.updateTable(colorMapEntries); > + } > + > + } > + > public RasterSymbology getRasterStyler() throws Exception{ > > RasterSymbology rasterSymbolizer = new > RasterSymbology(RasterSymbology.ColorMapType.INTERVALS); > @@ -373,19 +420,19 @@ > > return rasterSymbolizer; > } > - > + > + private final java.util.ResourceBundle bundle = > java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle"); > private final Component parent; > private final Map<ClassificationMethod,String> classMethods_m = > new EnumMap<ClassificationMethod,String>(ClassificationMethod.class); > - private double[] rasterData = null; > + private RasterImageLayer rasterImageLayer = null; > private ColorsTablePanel colorsTablePanel = null; > - private double noDataValue; > private final Range minMaxValues; > private GradientComboBox jComboBox_Gradient; > private boolean firstTimeShown = true; > > public enum ClassificationMethod { > > - UNIQUE_VALUE, EQUAL_RANGE, QUANTILE, MEAN_STDEV, > MAX_BREAKS, JENKS; > + UNIQUE_VALUE, EQUAL_RANGE, GIVEN_INTERVAL, QUANTILE, > MEAN_STDEV, MAX_BREAKS, JENKS; > > } > > > Modified: > core/trunk/src/org/openjump/core/rasterimage/styler/ui/RasterStylesDialog.form > =================================================================== > --- > core/trunk/src/org/openjump/core/rasterimage/styler/ui/RasterStylesDialog.form > 2015-11-15 11:31:06 UTC (rev 4552) > +++ > core/trunk/src/org/openjump/core/rasterimage/styler/ui/RasterStylesDialog.form > 2015-11-19 11:35:44 UTC (rev 4553) > @@ -22,7 +22,7 @@ > <AuxValue name="FormSettings_listenerGenerationStyle" > type="java.lang.Integer" value="0"/> > <AuxValue name="FormSettings_variablesLocal" > type="java.lang.Boolean" value="false"/> > <AuxValue name="FormSettings_variablesModifier" > type="java.lang.Integer" value="2"/> > - <AuxValue name="designerSize" type="java.awt.Dimension" > value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-23,0,0,1,-100"/> > + <AuxValue name="designerSize" type="java.awt.Dimension" > value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-23,0,0,1,-76"/> > </AuxValues> > > <Layout > class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> > @@ -33,7 +33,7 @@ > </Properties> > <Constraints> > <Constraint > layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" > value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> > - <GridBagConstraints gridX="-1" gridY="-1" gridWidth="4" > gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" > insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="1.0"/> > + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="6" > gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" > insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="1.0"/> > </Constraint> > </Constraints> > > @@ -55,7 +55,7 @@ > </Properties> > <Constraints> > <Constraint > layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" > value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> > - <GridBagConstraints gridX="0" gridY="1" gridWidth="4" > gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" > insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> > + <GridBagConstraints gridX="0" gridY="1" gridWidth="6" > gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" > insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> > </Constraint> > </Constraints> > > @@ -237,6 +237,30 @@ > </Component> > </SubComponents> > </Container> > + <Component class="javax.swing.JButton" name="jButton_Load"> > + <Properties> > + <Property name="text" type="java.lang.String" > editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> > + <ResourceString > bundle="com/geomaticaeambiente/openjump/rasterstyles/resources/Bundle.properties" > key="RasterStylesDialog.jButton_Load.text" > replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> > + </Property> > + </Properties> > + <Constraints> > + <Constraint > layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" > value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> > + <GridBagConstraints gridX="2" gridY="2" gridWidth="1" > gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" > insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> > + </Constraint> > + </Constraints> > + </Component> > + <Component class="javax.swing.JButton" name="jButton_Save"> > + <Properties> > + <Property name="text" type="java.lang.String" > editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> > + <ResourceString > bundle="com/geomaticaeambiente/openjump/rasterstyles/resources/Bundle.properties" > key="RasterStylesDialog.jButton_Save.text" > replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> > + </Property> > + </Properties> > + <Constraints> > + <Constraint > layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" > value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> > + <GridBagConstraints gridX="1" gridY="2" gridWidth="1" > gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" > insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> > + </Constraint> > + </Constraints> > + </Component> > <Component class="javax.swing.JButton" name="jButton_Cancel"> > <Properties> > <Property name="text" type="java.lang.String" > editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> > @@ -263,7 +287,7 @@ > </Events> > <Constraints> > <Constraint > layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" > value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> > - <GridBagConstraints gridX="1" gridY="2" gridWidth="1" > gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="5" > insetsBottom="5" insetsRight="5" anchor="10" weightX="0.0" weightY="0.0"/> > + <GridBagConstraints gridX="3" gridY="2" gridWidth="1" > gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="5" > insetsBottom="5" insetsRight="5" anchor="10" weightX="0.0" weightY="0.0"/> > </Constraint> > </Constraints> > </Component> > @@ -278,7 +302,7 @@ > </Events> > <Constraints> > <Constraint > layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" > value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> > - <GridBagConstraints gridX="2" gridY="2" gridWidth="1" > gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="5" > insetsBottom="5" insetsRight="5" anchor="10" weightX="0.0" weightY="0.0"/> > + <GridBagConstraints gridX="4" gridY="2" gridWidth="1" > gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="5" > insetsBottom="5" insetsRight="5" anchor="10" weightX="0.0" weightY="0.0"/> > </Constraint> > </Constraints> > </Component> > @@ -293,7 +317,7 @@ > </Events> > <Constraints> > <Constraint > layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" > value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> > - <GridBagConstraints gridX="3" gridY="2" gridWidth="1" > gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="5" > insetsBottom="5" insetsRight="5" anchor="10" weightX="0.0" weightY="0.0"/> > + <GridBagConstraints gridX="5" gridY="2" gridWidth="1" > gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="5" > insetsBottom="5" insetsRight="5" anchor="10" weightX="0.0" weightY="0.0"/> > </Constraint> > </Constraints> > </Component> > > Modified: > core/trunk/src/org/openjump/core/rasterimage/styler/ui/RasterStylesDialog.java > =================================================================== > --- > core/trunk/src/org/openjump/core/rasterimage/styler/ui/RasterStylesDialog.java > 2015-11-15 11:31:06 UTC (rev 4552) > +++ > core/trunk/src/org/openjump/core/rasterimage/styler/ui/RasterStylesDialog.java > 2015-11-19 11:35:44 UTC (rev 4553) > @@ -1,22 +1,31 @@ > package org.openjump.core.rasterimage.styler.ui; > > import com.vividsolutions.jump.util.Range; > +import com.vividsolutions.jump.util.StringUtil; > import com.vividsolutions.jump.workbench.WorkbenchContext; > import com.vividsolutions.jump.workbench.model.LayerEventType; > +import com.vividsolutions.jump.workbench.ui.ErrorDialog; > +import de.fho.jump.pirol.utilities.settings.PirolPlugInSettings; > import java.awt.Color; > import java.awt.event.ActionEvent; > import java.awt.event.ActionListener; > import java.awt.geom.NoninvertibleTransformException; > +import java.io.File; > +import java.io.IOException; > import java.util.logging.Level; > import java.util.logging.Logger; > import javax.swing.InputVerifier; > import javax.swing.JColorChooser; > import javax.swing.JComponent; > +import javax.swing.JFileChooser; > import org.openjump.core.rasterimage.RasterImageLayer; > import org.openjump.core.rasterimage.RasterSymbology; > import org.openjump.core.rasterimage.Stats; > import org.openjump.core.rasterimage.styler.RasterStylesExtension; > +import org.openjump.core.rasterimage.styler.SLDHandler; > import org.openjump.core.rasterimage.styler.Utils; > +import org.openjump.core.ui.io.file.FileNameExtensionFilter; > +import org.xml.sax.SAXException; > > /** > * > @@ -67,6 +76,8 @@ > jLabel_Transp_100 = new javax.swing.JLabel(); > jCheckBox_NoDataValue = new javax.swing.JCheckBox(); > jTextField_TranspValue = new javax.swing.JTextField(); > + jButton_Load = new javax.swing.JButton(); > + jButton_Save = new javax.swing.JButton(); > jButton_Cancel = new javax.swing.JButton(); > jButton_Restore = new javax.swing.JButton(); > jButton_Apply = new javax.swing.JButton(); > @@ -78,7 +89,7 @@ > > jTabbedPane_Type.setAlignmentX(1.0F); > gridBagConstraints = new java.awt.GridBagConstraints(); > - gridBagConstraints.gridwidth = 4; > + gridBagConstraints.gridwidth = 6; > gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; > gridBagConstraints.weighty = 1.0; > getContentPane().add(jTabbedPane_Type, gridBagConstraints); > @@ -198,9 +209,31 @@ > gridBagConstraints = new java.awt.GridBagConstraints(); > gridBagConstraints.gridx = 0; > gridBagConstraints.gridy = 1; > - gridBagConstraints.gridwidth = 4; > + gridBagConstraints.gridwidth = 6; > getContentPane().add(jPanel_OtherParams, gridBagConstraints); > > + > jButton_Load.setText(bundle.getString("org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jButton_Load.text")); > // NOI18N > + jButton_Load.addActionListener(new > java.awt.event.ActionListener() { > + public void actionPerformed(java.awt.event.ActionEvent > evt) { > + jButton_LoadActionPerformed(evt); > + } > + }); > + gridBagConstraints = new java.awt.GridBagConstraints(); > + gridBagConstraints.gridx = 2; > + gridBagConstraints.gridy = 2; > + getContentPane().add(jButton_Load, gridBagConstraints); > + > + > jButton_Save.setText(bundle.getString("org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jButton_Save.text")); > // NOI18N > + jButton_Save.addActionListener(new > java.awt.event.ActionListener() { > + public void actionPerformed(java.awt.event.ActionEvent > evt) { > + jButton_SaveActionPerformed(evt); > + } > + }); > + gridBagConstraints = new java.awt.GridBagConstraints(); > + gridBagConstraints.gridx = 1; > + gridBagConstraints.gridy = 2; > + getContentPane().add(jButton_Save, gridBagConstraints); > + > > jButton_Cancel.setText(bundle.getString("org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jButton_Cancel.text")); > // NOI18N > jButton_Cancel.addActionListener(new > java.awt.event.ActionListener() { > public void actionPerformed(java.awt.event.ActionEvent > evt) { > @@ -222,7 +255,7 @@ > } > }); > gridBagConstraints = new java.awt.GridBagConstraints(); > - gridBagConstraints.gridx = 1; > + gridBagConstraints.gridx = 3; > gridBagConstraints.gridy = 2; > gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); > getContentPane().add(jButton_Restore, gridBagConstraints); > @@ -234,7 +267,7 @@ > } > }); > gridBagConstraints = new java.awt.GridBagConstraints(); > - gridBagConstraints.gridx = 2; > + gridBagConstraints.gridx = 4; > gridBagConstraints.gridy = 2; > gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); > getContentPane().add(jButton_Apply, gridBagConstraints); > @@ -246,7 +279,7 @@ > } > }); > gridBagConstraints = new java.awt.GridBagConstraints(); > - gridBagConstraints.gridx = 3; > + gridBagConstraints.gridx = 5; > gridBagConstraints.gridy = 2; > gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); > getContentPane().add(jButton_OK, gridBagConstraints); > @@ -272,6 +305,18 @@ > > }//GEN-LAST:event_jCheckBox_NoDataValueActionPerformed > > + private void > jButton_LoadActionPerformed(java.awt.event.ActionEvent evt) > {//GEN-FIRST:event_jButton_LoadActionPerformed > + > + loadSld(); > + > + }//GEN-LAST:event_jButton_LoadActionPerformed > + > + private void > jButton_SaveActionPerformed(java.awt.event.ActionEvent evt) > {//GEN-FIRST:event_jButton_SaveActionPerformed > + > + saveSld(); > + > + }//GEN-LAST:event_jButton_SaveActionPerformed > + > private void > jButton_CancelActionPerformed(java.awt.event.ActionEvent evt) > {//GEN-FIRST:event_jButton_CancelActionPerformed > > closeDialog(); > @@ -328,32 +373,36 @@ > > Stats stats = rasterImageLayer.getMetadata().getStats(); > Range minMaxValues = new Range(stats.getMin(band), true, > stats.getMax(band), true); > - > -// // Load image at lowest possible resolution > -// RasterImageIO rasterImageIO = new RasterImageIO(); > -// double originalCellSize = > rasterImageLayer.getMetadata().getOriginalCellSize(); > -// int cellsCount = rasterImageLayer.getOrigImageWidth() * > rasterImageLayer.getOrigImageHeight(); > -// int sampleSize = 10000; > -// double lowResCellSize = Math.sqrt(Math.max(1, > cellsCount/(double)sampleSize)) * originalCellSize; > -// > -// ImageAndMetadata lowResImage = > rasterImageIO.loadImage(context, > -// rasterImageLayer.getImageFileName(), stats, > rasterImageLayer.getWholeImageEnvelope(), new Resolution(lowResCellSize, > lowResCellSize)); > - > + > stretchedPanel = new StretchedPanel(minMaxValues); > - intervalPanel = new IntervalPanel(this, > Utils.purgeNoData(rasterImageLayer.getActualRasterData(), rasterImageLayer), > minMaxValues); > + intervalPanel = new IntervalPanel( > + this, > + rasterImageLayer, > + minMaxValues); > singleValuesPanel = new SingleValuesPanel(this, > Utils.purgeNoData(rasterImageLayer.getActualRasterData(), rasterImageLayer), > rasterImageLayer); > > - > jTabbedPane_Type.addTab(java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle").getString("org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.tabStretched"), > stretchedPanel); > - > jTabbedPane_Type.addTab(java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle").getString("org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.tabIntervals"), > intervalPanel); > - > jTabbedPane_Type.addTab(java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle").getString("org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.tabSingleValues"), > singleValuesPanel); > + > jTabbedPane_Type.addTab(bundle.getString("org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.tabStretched"), > stretchedPanel); > + > jTabbedPane_Type.addTab(bundle.getString("org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.tabIntervals"), > intervalPanel); > + > jTabbedPane_Type.addTab(bundle.getString("org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.tabSingleValues"), > singleValuesPanel); > pack(); > > + /* Startup symbology */ > + if(rasterImageLayer.getRasterSymbology() != null) { > + > + this.finalRasterSymbolizer = > rasterImageLayer.getRasterSymbology(); > + updateGUI(); > + > + } > + > + > + //add RasterSimbolizer Object in BlackBoard, the key is the > name of raster plus suffixBBoardKey var. > + String bboardKey = > GUIUtils.getBBKey(String.valueOf(rasterImageLayer.getUUID())); > + context.getBlackboard().put(bboardKey, this); > + > } > > - > public void updateRasterImageLayer() throws > NoninvertibleTransformException, Exception{ > > -// finalRasterSymbolizer = null; > if(jTabbedPane_Type.getSelectedComponent() instanceof > StretchedPanel) { > finalRasterSymbolizer = stretchedPanel.getRasterStyler(); > } else if(jTabbedPane_Type.getSelectedComponent() instanceof > IntervalPanel) { > @@ -370,16 +419,83 @@ > } else { > > finalRasterSymbolizer.addColorMapEntry(rasterImageLayer.getNoDataValue(), > null); > } > - > - //add RasterSimbolizer Object in BlackBoard, the key is the > name of raster plus suffixBBoardKey var. > - String bboardKey = > GUIUtils.getBBKey(String.valueOf(rasterImageLayer.getUUID())); > - context.getBlackboard().put(bboardKey, this); > + > rasterImageLayer.setSymbology(finalRasterSymbolizer); > - > context.getLayerManager().fireLayerChanged(rasterImageLayer, > LayerEventType.APPEARANCE_CHANGED); > > } > > + private void saveSld() { > + > + if(finalRasterSymbolizer == null) { > + return; > + } > + > + JFileChooser chooser = new > JFileChooser(PirolPlugInSettings.configDirectory()); > + String extension = "sld"; > + FileNameExtensionFilter filter = new FileNameExtensionFilter( > + > bundle.getString("org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.fileChooser.sld"), > extension); > + chooser.setFileFilter(filter); > + int returnVal = chooser.showSaveDialog(this); > + > + if (returnVal == JFileChooser.APPROVE_OPTION) { > + > + try { > + File sldFile = chooser.getSelectedFile(); > + if(!sldFile.getAbsolutePath().endsWith(extension)){ > + sldFile = new File(sldFile + "." + extension); > + } > + > + SLDHandler.write(finalRasterSymbolizer, null, > sldFile); > + } catch (Exception ex) { > + ErrorDialog.show(this, StringUtil.toFriendlyName( > + ex.getClass().getName()), > + ex.toString(), > + StringUtil.stackTrace(ex)); > + } > + } > + > + } > + > + private void loadSld() { > + > + JFileChooser chooser = new > JFileChooser(PirolPlugInSettings.configDirectory()); > + FileNameExtensionFilter filter = new FileNameExtensionFilter( > + > bundle.getString("org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.fileChooser.sld"), > "sld"); > + chooser.setFileFilter(filter); > + chooser.setMultiSelectionEnabled(false); > + > + int returnVal = chooser.showOpenDialog(this); > + > + if (returnVal == JFileChooser.APPROVE_OPTION) { > + > + try { > + File sldFile = chooser.getSelectedFile(); > + finalRasterSymbolizer = SLDHandler.read(sldFile); > + > + // Update GUI > + updateGUI(); > + > + } catch (SAXException ex) { > + ErrorDialog.show(this, StringUtil.toFriendlyName( > + ex.getClass().getName()), > + ex.toString(), > + StringUtil.stackTrace(ex)); > + } catch (IOException ex) { > + ErrorDialog.show(this, StringUtil.toFriendlyName( > + ex.getClass().getName()), > + ex.toString(), > + StringUtil.stackTrace(ex)); > + } catch (Exception ex) { > + ErrorDialog.show(this, StringUtil.toFriendlyName( > + ex.getClass().getName()), > + ex.toString(), > + StringUtil.stackTrace(ex)); > + } > + } > + > + } > + > private void closeDialog() { > > GUIUtils.clearRasterStylerFromBlackBoard(context); > @@ -387,23 +503,40 @@ > > } > > - private void restoreToOriginal() throws > NoninvertibleTransformException { > - > + private void restoreToOriginal() throws > NoninvertibleTransformException { > rasterImageLayer.setSymbology(null); > - > } > > public double getNoDataValue() { > return rasterImageLayer.getNoDataValue(); > } > > + private void updateGUI() throws Exception { > + > + switch(finalRasterSymbolizer.getColorMapType()) { > + case RAMP: > + > stretchedPanel.plugRasterSymbology(finalRasterSymbolizer); > + jTabbedPane_Type.setSelectedIndex(0); > + break; > + case INTERVALS: > + > intervalPanel.plugRasterSymbology(finalRasterSymbolizer); > + jTabbedPane_Type.setSelectedIndex(1); > + break; > + case SINGLE: > + > singleValuesPanel.plugRasterSymbology(finalRasterSymbolizer); > + jTabbedPane_Type.setSelectedIndex(2); > + break; > + } > + } > > // Variables declaration - do not modify//GEN-BEGIN:variables > private javax.swing.JButton jButton_Apply; > private javax.swing.JButton jButton_Cancel; > + private javax.swing.JButton jButton_Load; > private javax.swing.JButton jButton_NoDataValueColor; > private javax.swing.JButton jButton_OK; > private javax.swing.JButton jButton_Restore; > + private javax.swing.JButton jButton_Save; > private javax.swing.JCheckBox jCheckBox_NoDataValue; > private javax.swing.JLabel jLabel_Transp_0; > private javax.swing.JLabel jLabel_Transp_100; > @@ -415,7 +548,7 @@ > // End of variables declaration//GEN-END:variables > > private Color noDataColor; > - > + java.util.ResourceBundle bundle = > java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle"); > // NOI18N > private final WorkbenchContext context; > private final RasterImageLayer rasterImageLayer; > private final int band; > > Modified: > core/trunk/src/org/openjump/core/rasterimage/styler/ui/SingleValuesPanel.java > =================================================================== > --- > core/trunk/src/org/openjump/core/rasterimage/styler/ui/SingleValuesPanel.java > 2015-11-15 11:31:06 UTC (rev 4552) > +++ > core/trunk/src/org/openjump/core/rasterimage/styler/ui/SingleValuesPanel.java > 2015-11-19 11:35:44 UTC (rev 4553) > @@ -87,7 +87,7 @@ > add(jPanel_Table, gridBagConstraints); > > java.util.ResourceBundle bundle = > java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle"); > // NOI18N > - > jButton_Ramp.setText(bundle.getString("org.openjump.core.rasterimage.styler.ui.SingleValuesPanel.jButton_Ramp")); > // NOI18N > + > jButton_Ramp.setText(bundle.getString("org.openjump.core.rasterimage.styler.ui.SingleValuesPanel.jButton_RampAll")); > // NOI18N > jButton_Ramp.addActionListener(new > java.awt.event.ActionListener() { > public void actionPerformed(java.awt.event.ActionEvent > evt) { > jButton_RampActionPerformed(evt); > @@ -142,7 +142,7 @@ > > private void formComponentShown(java.awt.event.ComponentEvent > evt) {//GEN-FIRST:event_formComponentShown > > - if(firstTimeShown) { > + if(firstTimeShown && rasterImageLayer.getRasterSymbology() > == null) { > firstTimeShown = false; > try { > findUniqueValues(); > @@ -231,18 +231,7 @@ > > } > > - /* Update table */ > - if(colorsTablePanel == null) { > - colorsTablePanel = new ColorsTablePanel(parent, > ColorsTablePanel.TableType.VALUES, > - colorMapEntries, > rasterImageLayer.getNoDataValue(), integerValues); > - GridBagLayout layout = (GridBagLayout)getLayout(); > - GridBagConstraints gbc = > layout.getConstraints(jPanel_Table); > - remove(jPanel_Table); > - add(colorsTablePanel, gbc); > - validate(); > - } else { > - colorsTablePanel.updateTable(colorMapEntries); > - } > + updateTable(colorMapEntries); > > } > > @@ -267,6 +256,27 @@ > return rasterSymbolizer; > } > > + public void plugRasterSymbology(RasterSymbology rasterSymbology) > { > + > + updateTable(rasterSymbology.getColorMapEntries()); > + > + } > + > + private void updateTable(ColorMapEntry[] colorMapEntries) { > + /* Update table */ > + if(colorsTablePanel == null) { > > + colorsTablePanel = new ColorsTablePanel(parent, > ColorsTablePanel.TableType.VALUES, > + colorMapEntries, > rasterImageLayer.getNoDataValue(), integerValues); > > > + GridBagLayout layout = (GridBagLayout)getLayout(); > + GridBagConstraints gbc = > layout.getConstraints(jPanel_Table); > + remove(jPanel_Table); > > + add(colorsTablePanel, gbc); > > > + validate(); > + } else { > + colorsTablePanel.updateTable(colorMapEntries); > + } > + } > + > > private final Component parent; > private double[] rasterDataNoNull; > private final RasterImageLayer rasterImageLayer; > > Modified: > core/trunk/src/org/openjump/core/rasterimage/styler/ui/StandardGradientColors.java > =================================================================== > --- > core/trunk/src/org/openjump/core/rasterimage/styler/ui/StandardGradientColors.java > 2015-11-15 11:31:06 UTC (rev 4552) > +++ > core/trunk/src/org/openjump/core/rasterimage/styler/ui/StandardGradientColors.java > 2015-11-19 11:35:44 UTC (rev 4553) > @@ -15,32 +15,73 @@ > > List<ColorMapEntry[]> colorMaps_l = new > ArrayList<ColorMapEntry[]>(); > > - ColorMapEntry[] colorRange = new ColorMapEntry[2]; > - colorRange[0] = new ColorMapEntry(0, Color.WHITE); > - colorRange[1] = new ColorMapEntry(1, Color.BLACK); > - colorMaps_l.add(colorRange); > + // White-black > + colorMaps_l.add(createRamp(new Color[]{Color.WHITE, > Color.BLACK})); > > - colorRange = new ColorMapEntry[2]; > - colorRange[0] = new ColorMapEntry(0, Color.BLUE); > - colorRange[1] = new ColorMapEntry(1, Color.WHITE); > - colorMaps_l.add(colorRange); > + // Blue-white > + colorMaps_l.add(createRamp(new Color[]{Color.BLUE, > Color.WHITE})); > > - colorRange = new ColorMapEntry[2]; > - colorRange[0] = new ColorMapEntry(0, Color.RED); > - colorRange[1] = new ColorMapEntry(1, Color.BLACK); > - colorMaps_l.add(colorRange); > + // Red-black > + colorMaps_l.add(createRamp(new Color[]{Color.RED, > Color.BLACK})); > > - colorRange = new ColorMapEntry[5]; > - colorRange[0] = new ColorMapEntry(0, Color.RED); > - colorRange[1] = new ColorMapEntry(0.25, Color.BLACK); > - colorRange[2] = new ColorMapEntry(0.5, Color.BLUE); > - colorRange[3] = new ColorMapEntry(0.8, Color.GREEN); > - colorRange[4] = new ColorMapEntry(1, Color.LIGHT_GRAY); > - colorMaps_l.add(colorRange); > + // Red-blue > + colorMaps_l.add(createRamp(new Color[]{Color.RED, > Color.BLUE})); > > + // Green-yellow-red > + colorMaps_l.add(createRamp(new Color[]{Color.GREEN, > Color.YELLOW, Color.RED})); > + > + // Blue-green-red > + colorMaps_l.add(createRamp(new Color[]{Color.BLUE, > Color.GREEN, Color.RED})); > + > + // Red-black-blue-green-gray > + colorMaps_l.add(createRamp(new Color[]{Color.RED, > Color.BLACK, Color.BLUE, Color.GREEN, Color.LIGHT_GRAY})); > + > + // Rainbow > + colorMaps_l.add(createRamp(new Color[]{ > + Color.RED, > + Color.ORANGE, > + Color.YELLOW, > + Color.GREEN, > + Color.BLUE, > + Color.decode("#4B0082"), > + Color.decode("#9400D3")})); > + > + // Aspect > + colorMaps_l.add(createRamp(new Color[]{ > + Color.decode("#ff0000"), > + Color.decode("#ff6600"), > + Color.decode("#ffff00"), > + Color.decode("#33ff33"), > + Color.decode("#00ccff"), > + Color.decode("#0066cc"), > + Color.decode("#0000cc"), > + Color.decode("#cc00ff"), > + Color.decode("#ff0000")})); > + > + // DEM > + colorMaps_l.add(createRamp(new Color[]{ > + Color.decode("#33ccff"), > + Color.decode("#aeefe8"), > + Color.decode("#ffffb2"), > + Color.decode("#007f3f"), > + Color.decode("#fcb902"), > + Color.decode("#770000"), > + Color.decode("#682f0c"), > + Color.decode("#aaaaaa"), > + Color.decode("#fffcff")})); > + > return colorMaps_l; > > } > > + private static ColorMapEntry[] createRamp(Color[] colors) { > + > + ColorMapEntry[] colorMapEntries = new > ColorMapEntry[colors.length]; > + double step = 1. / (colors.length - 1); > + for(int c=0; c<colors.length; c++) { > + colorMapEntries[c] = new ColorMapEntry(c*step, > colors[c]); > > > + } > + return colorMapEntries; > + } > > } > > \ No newline at end of file > > Modified: > core/trunk/src/org/openjump/core/rasterimage/styler/ui/StretchedPanel.form > =================================================================== > --- > core/trunk/src/org/openjump/core/rasterimage/styler/ui/StretchedPanel.form > 2015-11-15 11:31:06 UTC (rev 4552) > +++ > core/trunk/src/org/openjump/core/rasterimage/styler/ui/StretchedPanel.form > 2015-11-19 11:35:44 UTC (rev 4553) > @@ -175,5 +175,17 @@ > </Constraint> > </Constraints> > </Component> > + <Component class="javax.swing.JCheckBox" name="jCheckBox_Invert"> > > > + <Properties> > + <Property name="text" type="java.lang.String" > editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> > > + <ResourceString > bundle="com/geomaticaeambiente/openjump/rasterstyles/resources/Bundle.properties" > key="StretchedPanel.jCheckBox_Invert.text" > replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> > > > + </Property> > + </Properties> > + <Constraints> > + <Constraint > layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" > value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> > > + <GridBagConstraints gridX="0" gridY="4" gridWidth="2" > gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" > insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> > > > + </Constraint> > + </Constraints> > + </Component> > > </SubComponents> > </Form> > > Modified: > core/trunk/src/org/openjump/core/rasterimage/styler/ui/StretchedPanel.java > =================================================================== > --- > core/trunk/src/org/openjump/core/rasterimage/styler/ui/StretchedPanel.java > 2015-11-15 11:31:06 UTC (rev 4552) > +++ > core/trunk/src/org/openjump/core/rasterimage/styler/ui/StretchedPanel.java > 2015-11-19 11:35:44 UTC (rev 4553) > @@ -1,6 +1,7 @@ > package org.openjump.core.rasterimage.styler.ui; > > import com.vividsolutions.jump.util.Range; > +import java.awt.Color; > import org.openjump.core.rasterimage.styler.ColorMapEntry; > import org.openjump.core.rasterimage.RasterSymbology; > > @@ -43,6 +44,7 @@ > jLabel_MaxValue = new javax.swing.JLabel(); > jPanel_ShowGradient = new javax.swing.JPanel(); > jButton_Custom = new javax.swing.JButton(); > + jCheckBox_Invert = new javax.swing.JCheckBox(); > > setAlignmentY(0.0F); > setCursor(new > java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); > @@ -131,6 +133,13 @@ > gridBagConstraints.gridy = 3; > > > gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); > > add(jButton_Custom, gridBagConstraints); > + > + > jCheckBox_Invert.setText(bundle.getString("org.openjump.core.rasterimage.styler.ui.StretchedPanel.jCheckBox_Invert.text")); > // NOI18N > > > + gridBagConstraints = new java.awt.GridBagConstraints(); > > + gridBagConstraints.gridx = 0; > + gridBagConstraints.gridy = 4; > + gridBagConstraints.gridwidth = 2; > + add(jCheckBox_Invert, gridBagConstraints); > }// </editor-fold>//GEN-END:initComponents > > > > private void formComponentShown(java.awt.event.ComponentEvent > evt) {//GEN-FIRST:event_formComponentShown > > @@ -171,7 +180,7 @@ > GradientCanvas gradientCanvas = (GradientCanvas) > comboBox_Gradient.getItemAt(0); > colorMapEntries = gradientCanvas.getColorMapEntries(); > > - rasterStyler = new > RasterSymbology(RasterSymbology.ColorMapType.RAMP); > + rasterSymbology = new > RasterSymbology(RasterSymbology.ColorMapType.RAMP); > updateRasterStyler(colorMapEntries); > > GUIUtils utils = new GUIUtils(); > @@ -202,10 +211,10 @@ > > private void customGradient(){ > > - GradientCanvas gc = (GradientCanvas) > comboBox_Gradient.getSelectedItem(); > - ColorMapEntry[] cme = gc.getColorMapEntries(); > + GradientCanvas gradientCanvas = (GradientCanvas) > comboBox_Gradient.getSelectedItem(); > + ColorMapEntry[] coloMapEntries = > gradientCanvas.getColorMapEntries(); > > - CustomGradientColorsDialog customGradientDialog = new > CustomGradientColorsDialog(null, true, cme); > + CustomGradientColorsDialog customGradientDialog = new > CustomGradientColorsDialog(null, true, coloMapEntries); > customGradientDialog.setLocationRelativeTo(this); > customGradientDialog.setVisible(true); > > @@ -219,18 +228,46 @@ > > } > > - private void updateRasterStyler(ColorMapEntry[] > paletteColorMapEntries) throws Exception{ > + private void updateRasterStyler(ColorMapEntry[] colorMapEntries) > throws Exception{ > > - rasterStyler = new > RasterSymbology(RasterSymbology.ColorMapType.RAMP); > - for (ColorMapEntry paletteColorMapEntrie : > paletteColorMapEntries) { > + rasterSymbology = new > RasterSymbology(RasterSymbology.ColorMapType.RAMP); > + for (ColorMapEntry paletteColorMapEntrie : colorMapEntries) { > double quantity = (maxValue - minValue) * > paletteColorMapEntrie.getUpperValue() + minValue; > - rasterStyler.addColorMapEntry(quantity, > paletteColorMapEntrie.getColor()); > + rasterSymbology.addColorMapEntry(quantity, > paletteColorMapEntrie.getColor()); > } > } > > - > + public void plugRasterSymbology(RasterSymbology rasterSymbology) > throws Exception { > + > + colorMapEntries = rasterSymbology.getColorMapEntries(); > + > + // Convert values to relative values > + ColorMapEntry[] relColMapEntries = new > ColorMapEntry[rasterSymbology.getColorMapEntries().length - 1]; > + double minVal = 0; > + if(rasterSymbology.getColorMapEntries()[0].getColor() != > null) { > + minVal = > rasterSymbology.getColorMapEntries()[0].getUpperValue(); > + } else { > + minVal = > rasterSymbology.getColorMapEntries()[1].getUpperValue(); > + } > + double maxVal = > rasterSymbology.getColorMapEntries()[rasterSymbology.getColorMapEntries().length-1].getUpperValue(); > + > + for(int i=1; i<rasterSymbology.getColorMapEntries().length; > i++) { > + double relVal = > (rasterSymbology.getColorMapEntries()[i].getUpperValue() - minVal) / (maxVal > - minVal); > + relColMapEntries[i-1] = new ColorMapEntry(relVal, > rasterSymbology.getColorMapEntries()[i].getColor()); > + } > + > + > + GUIUtils.updateGradientComboBoxes(relColMapEntries, width, > height); > + > comboBox_Gradient.setSelectedIndex(comboBox_Gradient.getItemCount()-1); > + > +// rasterSymbology = rasterSymbology; > + > + } > + > + > > > // Variables declaration - do not modify//GEN-BEGIN:variables > > private javax.swing.JButton jButton_Custom; > + private javax.swing.JCheckBox jCheckBox_Invert; > private javax.swing.JLabel jLabel_MaxLabel; > private javax.swing.JLabel jLabel_MaxValue; > private javax.swing.JLabel jLabel_MinLabel; > @@ -243,12 +280,34 @@ > private final double maxValue; > private ColorMapEntry[] colorMapEntries; > private GradientComboBox comboBox_Gradient; > - private RasterSymbology rasterStyler; > + private RasterSymbology rasterSymbology; > private final int width = 200; > private final int height = 18; > > public RasterSymbology getRasterStyler(){ > - return rasterStyler; > + > + if(jCheckBox_Invert.isSelected()) { > + RasterSymbology revRasterSymbology = new > RasterSymbology(rasterSymbology.getColorMapType()); > + > + int firstEntry = 0; > + if(rasterSymbology.getColorMapEntries()[0].getColor() == > null) { > + revRasterSymbology.addColorMapEntry( > + > rasterSymbology.getColorMapEntries()[0].getUpperValue(), > + > rasterSymbology.getColorMapEntries()[0].getColor()); > + firstEntry = 1; > + } > + > + int up = rasterSymbology.getColorMapEntries().length - 1 > + firstEntry; > + for(int cme=firstEntry; > cme<rasterSymbology.getColorMapEntries().length; cme++) { > + revRasterSymbology.addColorMapEntry( > + > rasterSymbology.getColorMapEntries()[cme].getUpperValue(), > + > rasterSymbology.getColorMapEntries()[up-cme].getColor()); > + } > + return revRasterSymbology; > > > + > + } > + > + return rasterSymbology; > } > > > > > ------------------------------------------------------------------------------ > _______________________________________________ > Jump-pilot-devel mailing list > Jump-pilot-devel@lists.sourceforge.net > <mailto:Jump-pilot-devel@lists.sourceforge.net> > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > > > > > ------------------------------------------------------------------------------ > _______________________________________________ > Jump-pilot-devel mailing list > Jump-pilot-devel@lists.sourceforge.net > <mailto:Jump-pilot-devel@lists.sourceforge.net> > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > > > > ------------------------------------------------------------------------------ > > > > _______________________________________________ > Jump-pilot-devel mailing list > Jump-pilot-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > ------------------------------------------------------------------------------ _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel