mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
to version 3.4.1
This commit is contained in:
parent
1aab89e515
commit
4d0facb9a2
@ -1,13 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: org.apache.commons:commons-math4-legacy-core:4.0-SNAPSHOT">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy-core/4.0-SNAPSHOT/commons-math4-legacy-core-4.0-SNAPSHOT.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy-core/4.0-SNAPSHOT/commons-math4-legacy-core-4.0-20220805.195458-437.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy-core/4.0-SNAPSHOT/commons-math4-legacy-core-4.0-SNAPSHOT-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy-core/4.0-SNAPSHOT/commons-math4-legacy-core-4.0-20220805.195458-437-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy-core/4.0-SNAPSHOT/commons-math4-legacy-core-4.0-SNAPSHOT-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy-core/4.0-SNAPSHOT/commons-math4-legacy-core-4.0-20220805.195458-437-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>MeteoInfo</artifactId>
|
||||
<groupId>org.meteothink</groupId>
|
||||
<version>3.4</version>
|
||||
<version>3.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -100,7 +100,7 @@
|
||||
<artifactId>freehep-graphicsio-ps</artifactId>
|
||||
<version>2.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!--<dependency>
|
||||
<groupId>org.jogamp.gluegen</groupId>
|
||||
<artifactId>gluegen-rt-main</artifactId>
|
||||
<version>2.3.2</version>
|
||||
@ -109,8 +109,8 @@
|
||||
<groupId>org.jogamp.jogl</groupId>
|
||||
<artifactId>jogl-all-main</artifactId>
|
||||
<version>2.3.2</version>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.jogamp.jogl</groupId>
|
||||
<artifactId>jogl-all</artifactId>
|
||||
<version>v2.4.0-rc4</version>
|
||||
@ -158,7 +158,7 @@
|
||||
<version>v2.4.0-rc4</version>
|
||||
</dependency>
|
||||
|
||||
<!– GLUEGEN –>
|
||||
<!-- GLUEGEN -->
|
||||
|
||||
|
||||
<dependency>
|
||||
@ -212,7 +212,7 @@
|
||||
<groupId>org.jogamp.gluegen</groupId>
|
||||
<artifactId>gluegen-rt-natives-windows-i586</artifactId>
|
||||
<version>v2.4.0-rc4</version>
|
||||
</dependency>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.joml</groupId>
|
||||
<artifactId>joml</artifactId>
|
||||
|
||||
@ -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;
|
||||
|
||||
// </editor-fold>
|
||||
// <editor-fold desc="Constructor">
|
||||
@ -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<GLPlot> 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<GLPlot> glPlots = this.getGLPlots();
|
||||
for (GLPlot glPlot : glPlots) {
|
||||
glPlot.setAlwaysUpdateBuffers(value);
|
||||
}
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
// <editor-fold desc="Methods">
|
||||
|
||||
@ -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<GLPlot> glPlots = getGLPlots();
|
||||
for (GLPlot glPlot : glPlots) {
|
||||
glPlot.reshape(drawable, 0, 0, width, height);
|
||||
glPlot.display(drawable);
|
||||
List<GLPlot> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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<ImageWriter> 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
|
||||
*
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
*
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>MeteoInfo</artifactId>
|
||||
<groupId>org.meteothink</groupId>
|
||||
<version>3.4</version>
|
||||
<version>3.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>MeteoInfo</artifactId>
|
||||
<groupId>org.meteothink</groupId>
|
||||
<version>3.4</version>
|
||||
<version>3.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>MeteoInfo</artifactId>
|
||||
<groupId>org.meteothink</groupId>
|
||||
<version>3.4</version>
|
||||
<version>3.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>MeteoInfo</artifactId>
|
||||
<groupId>org.meteothink</groupId>
|
||||
<version>3.4</version>
|
||||
<version>3.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>MeteoInfo</artifactId>
|
||||
<groupId>org.meteothink</groupId>
|
||||
<version>3.4</version>
|
||||
<version>3.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>MeteoInfo</artifactId>
|
||||
<groupId>org.meteothink</groupId>
|
||||
<version>3.4</version>
|
||||
<version>3.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>MeteoInfo</artifactId>
|
||||
<groupId>org.meteothink</groupId>
|
||||
<version>3.4</version>
|
||||
<version>3.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -22,11 +22,13 @@
|
||||
<OpenedFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface\fimplicit3_gyroid.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\subplot_3d_cylinder.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\subplot_2_3d_1.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface\fimplicit3_gyroid.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\subplot_3d_cylinder.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\subplot_2_3d_1.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
@ -34,5 +36,5 @@
|
||||
</Font>
|
||||
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
|
||||
<Figure DoubleBuffering="true"/>
|
||||
<Startup MainFormLocation="-7,-7" MainFormSize="1293,685"/>
|
||||
<Startup MainFormLocation="-7,0" MainFormSize="1408,828"/>
|
||||
</MeteoInfo>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.meteothink</groupId>
|
||||
<artifactId>MeteoInfo</artifactId>
|
||||
<version>3.4</version>
|
||||
<version>3.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>meteoinfo-lab</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.meteothink</groupId>
|
||||
<artifactId>MeteoInfo</artifactId>
|
||||
<version>3.4</version>
|
||||
<version>3.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>meteoinfo-map</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>MeteoInfo</artifactId>
|
||||
<groupId>org.meteothink</groupId>
|
||||
<version>3.4</version>
|
||||
<version>3.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.meteothink</groupId>
|
||||
<artifactId>MeteoInfo</artifactId>
|
||||
<version>3.4</version>
|
||||
<version>3.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>MeteoInfo</artifactId>
|
||||
<groupId>org.meteothink</groupId>
|
||||
<version>3.4</version>
|
||||
<version>3.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>MeteoInfo</artifactId>
|
||||
<groupId>org.meteothink</groupId>
|
||||
<version>3.4</version>
|
||||
<version>3.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>MeteoInfo</artifactId>
|
||||
<groupId>org.meteothink</groupId>
|
||||
<version>3.4</version>
|
||||
<version>3.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user