diff --git a/.idea/libraries/Maven__org_apache_commons_commons_math4_legacy_core_4_0_SNAPSHOT.xml b/.idea/libraries/Maven__org_apache_commons_commons_math4_legacy_core_4_0_SNAPSHOT.xml index 1d619a58..dbb6fd57 100644 --- a/.idea/libraries/Maven__org_apache_commons_commons_math4_legacy_core_4_0_SNAPSHOT.xml +++ b/.idea/libraries/Maven__org_apache_commons_commons_math4_legacy_core_4_0_SNAPSHOT.xml @@ -1,13 +1,13 @@ - + - + - + \ No newline at end of file diff --git a/meteoinfo-chart/pom.xml b/meteoinfo-chart/pom.xml index 9c31c69a..3087bac7 100644 --- a/meteoinfo-chart/pom.xml +++ b/meteoinfo-chart/pom.xml @@ -5,7 +5,7 @@ MeteoInfo org.meteothink - 3.4 + 3.5-SNAPSHOT 4.0.0 @@ -100,7 +100,7 @@ freehep-graphicsio-ps 2.4 - + + org.jogamp.jogl jogl-all v2.4.0-rc4 @@ -158,7 +158,7 @@ v2.4.0-rc4 - <!– GLUEGEN –> + @@ -212,7 +212,7 @@ org.jogamp.gluegen gluegen-rt-natives-windows-i586 v2.4.0-rc4 - --> + org.joml joml diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/GLChart.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/GLChart.java index 850c56c8..865ce97f 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/GLChart.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/GLChart.java @@ -4,6 +4,7 @@ import com.jogamp.opengl.GL2; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLEventListener; import com.jogamp.opengl.glu.GLU; +import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil; import com.jogamp.opengl.util.gl2.GLUT; import org.meteoinfo.chart.*; import org.meteoinfo.chart.jogl.GLPlot; @@ -15,6 +16,7 @@ import org.meteoinfo.common.PointF; import java.awt.*; import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; @@ -39,6 +41,8 @@ public class GLChart implements GLEventListener { private boolean antialias; private boolean symbolAntialias; private org.meteoinfo.chart.GLChartPanel parent; + protected boolean doScreenShot; + protected BufferedImage screenImage; // // @@ -56,6 +60,7 @@ public class GLChart implements GLEventListener { this.plots = new ArrayList<>(); this.currentPlot = -1; this.texts = new ArrayList<>(); + this.doScreenShot = false; } /** @@ -426,6 +431,53 @@ public class GLChart implements GLEventListener { this.sampleBuffers = value; } + /** + * Get if do screenshot + * @return Boolean + */ + public boolean isDoScreenShot() { + return this.doScreenShot; + } + + /** + * Set if do screenshot + * @param value Boolean + */ + public void setDoScreenShot(boolean value) { + this.doScreenShot = value; + } + + /** + * Get screen image + * + * @return Screen image + */ + public BufferedImage getScreenImage() { + return this.screenImage; + } + + /** + * Set DPI scale + * @param value DPI scale + */ + public void setDpiScale(float value) { + List glPlots = this.getGLPlots(); + for (GLPlot glPlot : glPlots) { + glPlot.setDpiScale(value); + } + } + + /** + * Set whether always update buffers + * @param value Whether always update buffers + */ + public void setAlwaysUpdateBuffers(boolean value) { + List glPlots = this.getGLPlots(); + for (GLPlot glPlot : glPlots) { + glPlot.setAlwaysUpdateBuffers(value); + } + } + // // @@ -990,44 +1042,53 @@ public class GLChart implements GLEventListener { @Override public void display(GLAutoDrawable drawable) { - float[] rgba = this.background.getRGBComponents(null); - gl.glClearColor(rgba[0], rgba[1], rgba[2], rgba[3]); - gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); + if (this.containsGLPlot()) { + float[] rgba = this.background.getRGBComponents(null); + gl.glClearColor(rgba[0], rgba[1], rgba[2], rgba[3]); + gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); - gl.glShadeModel(GL2.GL_SMOOTH); + gl.glShadeModel(GL2.GL_SMOOTH); - gl.glEnable(GL2.GL_BLEND); - gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA); - //gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE); + gl.glEnable(GL2.GL_BLEND); + gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA); + //gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE); - if (this.antialias) { - if (this.sampleBuffers) - gl.glEnable(GL2.GL_MULTISAMPLE); - else { - gl.glEnable(GL2.GL_LINE_SMOOTH); - gl.glHint(GL2.GL_LINE_SMOOTH_HINT, GL2.GL_NICEST); - gl.glEnable(GL2.GL_POINT_SMOOTH); - gl.glHint(GL2.GL_POINT_SMOOTH_HINT, GL2.GL_NICEST); - //gl.glEnable(GL2.GL_POLYGON_SMOOTH); - //gl.glHint(GL2.GL_POLYGON_SMOOTH_HINT, GL2.GL_NICEST); + if (this.antialias) { + if (this.sampleBuffers) + gl.glEnable(GL2.GL_MULTISAMPLE); + else { + gl.glEnable(GL2.GL_LINE_SMOOTH); + gl.glHint(GL2.GL_LINE_SMOOTH_HINT, GL2.GL_NICEST); + gl.glEnable(GL2.GL_POINT_SMOOTH); + gl.glHint(GL2.GL_POINT_SMOOTH_HINT, GL2.GL_NICEST); + //gl.glEnable(GL2.GL_POLYGON_SMOOTH); + //gl.glHint(GL2.GL_POLYGON_SMOOTH_HINT, GL2.GL_NICEST); + } + } else { + if (this.sampleBuffers) + gl.glDisable(GL2.GL_MULTISAMPLE); + else { + gl.glDisable(GL2.GL_LINE_SMOOTH); + gl.glHint(GL2.GL_LINE_SMOOTH_HINT, GL2.GL_FASTEST); + gl.glDisable(GL2.GL_POINT_SMOOTH); + gl.glHint(GL2.GL_POINT_SMOOTH_HINT, GL2.GL_FASTEST); + //gl.glDisable(GL2.GL_POLYGON_SMOOTH); + //gl.glHint(GL2.GL_POLYGON_SMOOTH_HINT, GL2.GL_FASTEST); + } } - } else { - if (this.sampleBuffers) - gl.glDisable(GL2.GL_MULTISAMPLE); - else { - gl.glDisable(GL2.GL_LINE_SMOOTH); - gl.glHint(GL2.GL_LINE_SMOOTH_HINT, GL2.GL_FASTEST); - gl.glDisable(GL2.GL_POINT_SMOOTH); - gl.glHint(GL2.GL_POINT_SMOOTH_HINT, GL2.GL_FASTEST); - //gl.glDisable(GL2.GL_POLYGON_SMOOTH); - //gl.glHint(GL2.GL_POLYGON_SMOOTH_HINT, GL2.GL_FASTEST); - } - } - List glPlots = getGLPlots(); - for (GLPlot glPlot : glPlots) { - glPlot.reshape(drawable, 0, 0, width, height); - glPlot.display(drawable); + List glPlots = getGLPlots(); + for (GLPlot glPlot : glPlots) { + glPlot.reshape(drawable, 0, 0, width, height); + glPlot.display(drawable); + } + + //Do screenshot + if (this.doScreenShot) { + AWTGLReadBufferUtil glReadBufferUtil = new AWTGLReadBufferUtil(drawable.getGLProfile(), false); + this.screenImage = glReadBufferUtil.readPixelsToBufferedImage(drawable.getGL(), true); + this.doScreenShot = false; + } } } diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/GLChartPanel.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/GLChartPanel.java index 2b6c8e70..6caebcb3 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/GLChartPanel.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/GLChartPanel.java @@ -20,10 +20,7 @@ import org.freehep.graphics2d.VectorGraphics; import org.freehep.graphicsio.emf.EMFGraphics2D; import org.freehep.graphicsio.pdf.PDFGraphics2D; import org.freehep.graphicsio.ps.PSGraphics2D; -import org.meteoinfo.chart.jogl.EarthGLPlot; -import org.meteoinfo.chart.jogl.EarthPlot3D; -import org.meteoinfo.chart.jogl.GLPlot; -import org.meteoinfo.chart.jogl.Plot3DGL; +import org.meteoinfo.chart.jogl.*; import org.meteoinfo.chart.plot.*; import org.meteoinfo.chart.plot3d.Projector; import org.meteoinfo.common.Extent; @@ -1382,7 +1379,12 @@ public class GLChartPanel extends GLJPanel implements IChartPanel{ } else { ImageFormats imageFormat = ImageUtil.getImageFormat(aFile); int imageType = imageFormat == ImageFormats.JPEG ? BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB; - BufferedImage image = new BufferedImage(width, height, imageType); + BufferedImage image; + if (this.chart.containsGLPlot()) { + image = JOGLUtil.paintViewImage(this.chart, width, height); + } else { + image = new BufferedImage(width, height, imageType); + } Graphics2D g = image.createGraphics(); if (this.hasWebMap()) { for (Plot plot : this.chart.getPlots()) { @@ -1424,195 +1426,6 @@ public class GLChartPanel extends GLJPanel implements IChartPanel{ } } - /** - * Save image to a picture file - * - * @param aFile File path - * @param width Width - * @param height Height - * @param sleep Sleep seconds for web map layer - * @throws FileNotFoundException - * @throws PrintException - * @throws InterruptedException - */ - public void saveImage_bak(String aFile, int width, int height, Integer sleep) throws FileNotFoundException, PrintException, IOException, InterruptedException { - if (aFile.endsWith(".ps")) { - DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; - String mimeType = "application/postscript"; - StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, mimeType); - FileOutputStream out = new FileOutputStream(aFile); - if (factories.length > 0) { - PrintService service = factories[0].getPrintService(out); - SimpleDoc doc = new SimpleDoc(new Printable() { - @Override - public int print(Graphics g, PageFormat pf, int page) { - if (page >= 1) { - return Printable.NO_SUCH_PAGE; - } else { - double sf1 = pf.getImageableWidth() / (getWidth() + 1); - double sf2 = pf.getImageableHeight() / (getHeight() + 1); - double s = Math.min(sf1, sf2); - Graphics2D g2 = (Graphics2D) g; - g2.translate((pf.getWidth() - pf.getImageableWidth()) / 2, (pf.getHeight() - pf.getImageableHeight()) / 2); - g2.scale(s, s); - - paintGraphics(g2); - return Printable.PAGE_EXISTS; - } - } - }, flavor, null); - DocPrintJob job = service.createPrintJob(); - PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet(); - job.print(doc, attributes); - out.close(); - } - } else if (aFile.endsWith(".eps")) { -// EPSGraphics2D g = new EPSGraphics2D(0.0, 0.0, width, height); -// paintGraphics(g); -// FileOutputStream file = new FileOutputStream(aFile); -// try { -// file.write(g.getBytes()); -// } finally { -// file.close(); -// g.dispose(); -// } - - Properties p = new Properties(); - p.setProperty("PageSize", "A5"); - VectorGraphics g = new PSGraphics2D(new File(aFile), new Dimension(width, height)); - //g.setProperties(p); - g.startExport(); - //this.paintGraphics(g); - this.paintGraphics(g, width, height); - g.endExport(); - g.dispose(); - } else if (aFile.endsWith(".pdf")) { - VectorGraphics g = new PDFGraphics2D(new File(aFile), new Dimension(width, height)); - //g.setProperties(p); - g.startExport(); - this.paintGraphics(g, width, height); - g.endExport(); - g.dispose(); - } else if (aFile.endsWith(".emf")) { - VectorGraphics g = new EMFGraphics2D(new File(aFile), new Dimension(width, height)); - //g.setProperties(p); - g.startExport(); - //this.paintGraphics(g); - this.paintGraphics(g, width, height); - g.endExport(); - g.dispose(); - } else { - //String extension = aFile.substring(aFile.lastIndexOf('.') + 1); - //ImageIO.write(this.mapBitmap, extension, new File(aFile)); - - String extension = aFile.substring(aFile.lastIndexOf('.') + 1); - BufferedImage aImage; - if (extension.equalsIgnoreCase("bmp")) { - aImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - } else { - aImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - } - Graphics2D g = aImage.createGraphics(); - paintGraphics(g, width, height); - - if (sleep != null) { - Thread.sleep(sleep * 1000); - } - - if (extension.equalsIgnoreCase("jpg")) { - BufferedImage newImage = new BufferedImage(aImage.getWidth(), aImage.getHeight(), BufferedImage.TYPE_INT_RGB); - newImage.createGraphics().drawImage(aImage, 0, 0, Color.BLACK, null); - ImageIO.write(newImage, extension, new File(aFile)); - } else { - ImageIO.write(aImage, extension, new File(aFile)); - } - } - } - - /** - * Save image to Jpeg file - * - * @param fileName File name - * @param dpi DPI - * @throws IOException - */ - public void saveImage_Jpeg_old(String fileName, int dpi) throws IOException { - BufferedImage image = this.mapBitmap; - Iterator i = ImageIO.getImageWritersByFormatName("jpeg"); - //are there any jpeg encoders available? - - if (i.hasNext()) //there's at least one ImageWriter, just use the first one - { - ImageWriter imageWriter = (ImageWriter) i.next(); - //get the param - ImageWriteParam param = imageWriter.getDefaultWriteParam(); - ImageTypeSpecifier its = new ImageTypeSpecifier(image.getColorModel(), image.getSampleModel()); - - //get metadata - IIOMetadata iomd = imageWriter.getDefaultImageMetadata(its, - param); - - String formatName = "javax_imageio_jpeg_image_1.0";//this is the DOCTYPE of the metadata we need - - Node node = iomd.getAsTree(formatName); - //what are child nodes? - NodeList nl = node.getChildNodes(); - for (int j = 0; j < nl.getLength(); j++) { - Node n = nl.item(j); - System.out.println("node from IOMetadata is : " - + n.getNodeName()); - - if (n.getNodeName().equals("JPEGvariety")) { - NodeList childNodes = n.getChildNodes(); - - for (int k = 0; k < childNodes.getLength(); k++) { - System.out.println("node #" + k + " is " - + childNodes.item(k).getNodeName()); - if (childNodes.item(k).getNodeName().equals("app0JFIF")) { - NamedNodeMap nnm = childNodes.item(k).getAttributes(); - //get the resUnits, Xdensity, and Ydensity attribuutes - Node resUnitsNode = getAttributeByName(childNodes.item(k), "resUnits"); - Node XdensityNode = getAttributeByName(childNodes.item(k), "Xdensity"); - Node YdensityNode = getAttributeByName(childNodes.item(k), "Ydensity"); - - //reset values for nodes - resUnitsNode.setNodeValue("1"); //indicate DPI mode - XdensityNode.setNodeValue(String.valueOf(dpi)); - YdensityNode.setNodeValue(String.valueOf(dpi)); - - System.out.println("name=" - + resUnitsNode.getNodeName() + ", value=" + resUnitsNode.getNodeValue()); - System.out.println("name=" - + XdensityNode.getNodeName() + ", value=" + XdensityNode.getNodeValue()); - System.out.println("name=" - + YdensityNode.getNodeName() + ", value=" + YdensityNode.getNodeValue()); - - } //end if (childNodes.item(k).getNodeName().equals("app0JFIF")) - } //end if (n.getNodeName().equals("JPEGvariety") - break; //we don't care about the rest of the children - } //end if (n.getNodeName().equals("JPEGvariety")) - - } //end for (int j = 0; j < nl.getLength(); j++) - - try { - iomd.setFromTree(formatName, node); - } catch (IIOInvalidTreeException e) { - e.printStackTrace(); //To change body of catch statement use Options | File Templates. - } - //attach the metadata to an image - IIOImage iioimage = new IIOImage(image, null, iomd); - FileImageOutputStream stream = new FileImageOutputStream(new File(fileName)); - try { - imageWriter.setOutput(stream); - imageWriter.write(iioimage); - } catch (IOException e) { - e.printStackTrace(); - } finally { - stream.close(); - } - } //end if (i.hasNext()) //there's at least one ImageWriter, just use the first one - } - /** * @param node * @param attributeName - name of child node to return @@ -1646,7 +1459,12 @@ public class GLChartPanel extends GLJPanel implements IChartPanel{ public boolean saveImage_Jpeg(String file, int width, int height, int dpi) { double scaleFactor = dpi / 72.0; - BufferedImage bufferedImage = new BufferedImage((int)(width * scaleFactor), (int)(height * scaleFactor), BufferedImage.TYPE_INT_RGB); + BufferedImage bufferedImage; + if (this.chart.containsGLPlot()) { + bufferedImage = JOGLUtil.paintViewImage(this.chart, width, height, dpi); + } else { + bufferedImage = new BufferedImage((int)(width * scaleFactor), (int)(height * scaleFactor), BufferedImage.TYPE_INT_RGB); + } Graphics2D g = bufferedImage.createGraphics(); AffineTransform at = g.getTransform(); at.scale(scaleFactor, scaleFactor); @@ -1737,7 +1555,12 @@ public class GLChartPanel extends GLJPanel implements IChartPanel{ ImageFormats imageFormat = ImageUtil.getImageFormat(fileName); double scaleFactor = dpi / 72.0; int imageType = imageFormat == ImageFormats.JPEG ? BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB; - BufferedImage image = new BufferedImage((int) (width * scaleFactor), (int) (height * scaleFactor), imageType); + BufferedImage image; + if (this.chart.containsGLPlot()) { + image = JOGLUtil.paintViewImage(this.chart, width, height, dpi); + } else { + image = new BufferedImage((int) (width * scaleFactor), (int) (height * scaleFactor), imageType); + } Graphics2D g = image.createGraphics(); AffineTransform at = g.getTransform(); at.scale(scaleFactor, scaleFactor); @@ -1786,64 +1609,6 @@ public class GLChartPanel extends GLJPanel implements IChartPanel{ } } - /** - * Save image - * - * @param fileName File name - * @param dpi DPI - * @param width Width - * @param height Height - * @param sleep Sleep seconds for web map layer - * @throws IOException - * @throws InterruptedException - */ - public void saveImage_bak(String fileName, int dpi, int width, int height, Integer sleep) throws IOException, InterruptedException { - File output = new File(fileName); - output.delete(); - - String formatName = fileName.substring(fileName.lastIndexOf('.') + 1); - if (formatName.equals("jpg")) { - formatName = "jpeg"; - saveImage_Jpeg(fileName, width, height, dpi); - return; - } - - double scaleFactor = dpi / 72.0; - BufferedImage image = new BufferedImage((int)(width * scaleFactor), (int)(height * scaleFactor), BufferedImage.TYPE_INT_ARGB); - Graphics2D g = image.createGraphics(); - AffineTransform at = g.getTransform(); - at.scale(scaleFactor, scaleFactor); - g.setTransform(at); - paintGraphics(g, width, height); - for (Iterator iw = ImageIO.getImageWritersByFormatName(formatName); iw.hasNext();) { - ImageWriter writer = iw.next(); - ImageWriteParam writeParam = writer.getDefaultWriteParam(); - ImageTypeSpecifier typeSpecifier = ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_ARGB); - IIOMetadata metadata = writer.getDefaultImageMetadata(typeSpecifier, writeParam); - if (metadata == null) { - metadata = writer.getDefaultImageMetadata(typeSpecifier, null); - } - if (metadata.isReadOnly() || !metadata.isStandardMetadataFormatSupported()) { - continue; - } - - ImageUtil.setDPI(metadata, dpi); - - if (sleep != null) { - Thread.sleep(sleep * 1000); - } - final ImageOutputStream stream = ImageIO.createImageOutputStream(output); - try { - writer.setOutput(stream); - writer.write(metadata, new IIOImage(image, null, metadata), writeParam); - } finally { - stream.close(); - } - break; - } - g.dispose(); - } - /** * Get view image * diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/GLPlot.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/GLPlot.java index 6e92dcfa..9ac2e917 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/GLPlot.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/GLPlot.java @@ -954,6 +954,22 @@ public class GLPlot extends Plot { this.dpiScale = value; } + /** + * Get is always update buffers or not + * @return Is always update buffers or not + */ + public boolean isAlwaysUpdateBuffers() { + return this.alwaysUpdateBuffers; + } + + /** + * Set whether always update buffers + * @param value Whether always update buffers + */ + public void setAlwaysUpdateBuffers(boolean value) { + this.alwaysUpdateBuffers = value; + } + /** * Get is orthographic or not * @return is orthographic or not @@ -1280,12 +1296,12 @@ public class GLPlot extends Plot { gl.glFlush(); - //Do screenshot + /*//Do screenshot if (this.doScreenShot) { AWTGLReadBufferUtil glReadBufferUtil = new AWTGLReadBufferUtil(drawable.getGLProfile(), false); this.screenImage = glReadBufferUtil.readPixelsToBufferedImage(drawable.getGL(), true); this.doScreenShot = false; - } + }*/ //Disable always update buffers if (this.alwaysUpdateBuffers) diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/JOGLUtil.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/JOGLUtil.java index bb33b8af..7fa8d4aa 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/JOGLUtil.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/JOGLUtil.java @@ -12,6 +12,7 @@ import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.*; import org.apache.commons.imaging.ImageWriteException; import org.joml.Vector3f; +import org.meteoinfo.chart.GLChart; import org.meteoinfo.chart.graphic.*; import org.meteoinfo.chart.jogl.mc.CallbackMC; import org.meteoinfo.chart.jogl.mc.MarchingCubes; @@ -726,56 +727,6 @@ public class JOGLUtil { return image; } - /** - * Paint view image - * - * @param plot3DGL Plot3DGL - * @param width Image width - * @param height Image height - * @return View image - */ - public static BufferedImage paintViewImage_bak(Plot3DGL plot3DGL, int width, int height) { - final GLProfile glp = GLProfile.get(GLProfile.GL2); - //final GLProfile glp = GLProfile.getDefault(); - GLCapabilities caps = new GLCapabilities(glp); - caps.setHardwareAccelerated(true); - caps.setDoubleBuffered(false); - caps.setAlphaBits(8); - caps.setRedBits(8); - caps.setBlueBits(8); - caps.setGreenBits(8); - caps.setOnscreen(false); - caps.setPBuffer(true); - - final Display display = NewtFactory.createDisplay(null); // local display - final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - final com.jogamp.newt.Window window = NewtFactory.createWindow(screen, caps); - window.setSize(width, height); - final GLWindow glWindow = GLWindow.create(window); - glWindow.setVisible(true); - - glWindow.addGLEventListener(plot3DGL); - plot3DGL.setDoScreenShot(true); - glWindow.display(); - - BufferedImage image = plot3DGL.getScreenImage(); - - if (null != glWindow) { - glWindow.destroy(); - } - if (null != window) { - window.destroy(); - } - if (null != screen) { - screen.destroy(); - } - if (null != display) { - display.destroy(); - } - - return image; - } - /** * Paint view image * @@ -795,6 +746,59 @@ public class JOGLUtil { return image; } + /** + * Paint view image + * + * @param chart The GLChart + * @param width Image width + * @param height Image height + * @return View image + */ + public static BufferedImage paintViewImage(GLChart chart, int width, int height) { + final GLProfile glp = GLProfile.get(GLProfile.GL2); + GLCapabilities caps = new GLCapabilities(glp); + caps.setHardwareAccelerated(true); + caps.setDoubleBuffered(false); + caps.setAlphaBits(8); + caps.setRedBits(8); + caps.setBlueBits(8); + caps.setGreenBits(8); + caps.setOnscreen(false); + caps.setPBuffer(true); + GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); + GLOffscreenAutoDrawable drawable = factory.createOffscreenAutoDrawable(null, caps, null, + width, height); + drawable.addGLEventListener(chart); + chart.setDoScreenShot(true); + chart.setAlwaysUpdateBuffers(true); + drawable.display(); + + BufferedImage image = chart.getScreenImage(); + drawable.destroy(); + chart.setAlwaysUpdateBuffers(true); + + return image; + } + + /** + * Paint view image + * + * @param chart The GLChart + * @param width Image width + * @param height Image height + * @param dpi Image dpi + * @return View image + */ + public static BufferedImage paintViewImage(GLChart chart, int width, int height, int dpi) { + double scaleFactor = dpi / 72.0; + width = (int) (width * scaleFactor); + height = (int) (height * scaleFactor); + chart.setDpiScale((float) scaleFactor); + BufferedImage image = paintViewImage(chart, width, height); + chart.setDpiScale(1); + return image; + } + /** * Save image file * diff --git a/meteoinfo-common/pom.xml b/meteoinfo-common/pom.xml index 8aba5b31..ae5b7ced 100644 --- a/meteoinfo-common/pom.xml +++ b/meteoinfo-common/pom.xml @@ -5,7 +5,7 @@ MeteoInfo org.meteothink - 3.4 + 3.5-SNAPSHOT 4.0.0 diff --git a/meteoinfo-common/src/main/java/org/meteoinfo/common/util/GlobalUtil.java b/meteoinfo-common/src/main/java/org/meteoinfo/common/util/GlobalUtil.java index 8051f29a..64819a37 100644 --- a/meteoinfo-common/src/main/java/org/meteoinfo/common/util/GlobalUtil.java +++ b/meteoinfo-common/src/main/java/org/meteoinfo/common/util/GlobalUtil.java @@ -67,7 +67,7 @@ import java.util.zip.ZipInputStream; public static String getVersion(){ String version = GlobalUtil.class.getPackage().getImplementationVersion(); if (version == null || version.equals("")) { - version = "3.4"; + version = "3.4.1"; } return version; } diff --git a/meteoinfo-console/pom.xml b/meteoinfo-console/pom.xml index 6b33e26e..2db2a367 100644 --- a/meteoinfo-console/pom.xml +++ b/meteoinfo-console/pom.xml @@ -5,7 +5,7 @@ MeteoInfo org.meteothink - 3.4 + 3.5-SNAPSHOT 4.0.0 diff --git a/meteoinfo-data/pom.xml b/meteoinfo-data/pom.xml index c291ea96..7acb3fdd 100644 --- a/meteoinfo-data/pom.xml +++ b/meteoinfo-data/pom.xml @@ -5,7 +5,7 @@ MeteoInfo org.meteothink - 3.4 + 3.5-SNAPSHOT 4.0.0 diff --git a/meteoinfo-dataframe/pom.xml b/meteoinfo-dataframe/pom.xml index b79ab9cc..0ed76b04 100644 --- a/meteoinfo-dataframe/pom.xml +++ b/meteoinfo-dataframe/pom.xml @@ -5,7 +5,7 @@ MeteoInfo org.meteothink - 3.4 + 3.5-SNAPSHOT 4.0.0 diff --git a/meteoinfo-geo/pom.xml b/meteoinfo-geo/pom.xml index 8d5e2d1f..29388b31 100644 --- a/meteoinfo-geo/pom.xml +++ b/meteoinfo-geo/pom.xml @@ -5,7 +5,7 @@ MeteoInfo org.meteothink - 3.4 + 3.5-SNAPSHOT 4.0.0 diff --git a/meteoinfo-geometry/pom.xml b/meteoinfo-geometry/pom.xml index edb517ba..f1cee31d 100644 --- a/meteoinfo-geometry/pom.xml +++ b/meteoinfo-geometry/pom.xml @@ -5,7 +5,7 @@ MeteoInfo org.meteothink - 3.4 + 3.5-SNAPSHOT 4.0.0 diff --git a/meteoinfo-image/pom.xml b/meteoinfo-image/pom.xml index 992cbd1e..66067e7a 100644 --- a/meteoinfo-image/pom.xml +++ b/meteoinfo-image/pom.xml @@ -5,7 +5,7 @@ MeteoInfo org.meteothink - 3.4 + 3.5-SNAPSHOT 4.0.0 diff --git a/meteoinfo-lab/milconfig.xml b/meteoinfo-lab/milconfig.xml index 7053f267..8fb348e0 100644 --- a/meteoinfo-lab/milconfig.xml +++ b/meteoinfo-lab/milconfig.xml @@ -22,11 +22,13 @@ + + @@ -34,5 +36,5 @@
- + diff --git a/meteoinfo-lab/pom.xml b/meteoinfo-lab/pom.xml index 2480a8b7..bf8ef6cf 100644 --- a/meteoinfo-lab/pom.xml +++ b/meteoinfo-lab/pom.xml @@ -4,7 +4,7 @@ org.meteothink MeteoInfo - 3.4 + 3.5-SNAPSHOT meteoinfo-lab jar diff --git a/meteoinfo-map/pom.xml b/meteoinfo-map/pom.xml index 549b48d3..cc92151a 100644 --- a/meteoinfo-map/pom.xml +++ b/meteoinfo-map/pom.xml @@ -4,7 +4,7 @@ org.meteothink MeteoInfo - 3.4 + 3.5-SNAPSHOT meteoinfo-map jar diff --git a/meteoinfo-math/pom.xml b/meteoinfo-math/pom.xml index 1fc91fab..d3c333f0 100644 --- a/meteoinfo-math/pom.xml +++ b/meteoinfo-math/pom.xml @@ -5,7 +5,7 @@ MeteoInfo org.meteothink - 3.4 + 3.5-SNAPSHOT 4.0.0 diff --git a/meteoinfo-ndarray/pom.xml b/meteoinfo-ndarray/pom.xml index 2e7bbb53..99c60e0d 100644 --- a/meteoinfo-ndarray/pom.xml +++ b/meteoinfo-ndarray/pom.xml @@ -5,7 +5,7 @@ org.meteothink MeteoInfo - 3.4 + 3.5-SNAPSHOT 4.0.0 diff --git a/meteoinfo-projection/pom.xml b/meteoinfo-projection/pom.xml index dd3b24db..ea988f9e 100644 --- a/meteoinfo-projection/pom.xml +++ b/meteoinfo-projection/pom.xml @@ -5,7 +5,7 @@ MeteoInfo org.meteothink - 3.4 + 3.5-SNAPSHOT 4.0.0 diff --git a/meteoinfo-table/pom.xml b/meteoinfo-table/pom.xml index a7eb6b65..dc84f522 100644 --- a/meteoinfo-table/pom.xml +++ b/meteoinfo-table/pom.xml @@ -5,7 +5,7 @@ MeteoInfo org.meteothink - 3.4 + 3.5-SNAPSHOT 4.0.0 diff --git a/meteoinfo-ui/pom.xml b/meteoinfo-ui/pom.xml index 329963c6..90a312d2 100644 --- a/meteoinfo-ui/pom.xml +++ b/meteoinfo-ui/pom.xml @@ -5,7 +5,7 @@ MeteoInfo org.meteothink - 3.4 + 3.5-SNAPSHOT 4.0.0 diff --git a/pom.xml b/pom.xml index a11fedae..ec6ed294 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.meteothink MeteoInfo - 3.4 + 3.5-SNAPSHOT pom