update imshow function

This commit is contained in:
wyq 2021-06-05 13:46:53 +08:00
parent 10981c3f7a
commit 2a1bd391a4
12 changed files with 63 additions and 114 deletions

View File

@ -1,13 +0,0 @@
<component name="libraryTable">
<library name="Maven: com.formdev:flatlaf:1.1.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/formdev/flatlaf/1.1.1/flatlaf-1.1.1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/formdev/flatlaf/1.1.1/flatlaf-1.1.1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/formdev/flatlaf/1.1.1/flatlaf-1.1.1-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -1,13 +0,0 @@
<component name="libraryTable">
<library name="Maven: com.formdev:flatlaf-extras:1.1.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/formdev/flatlaf-extras/1.1.1/flatlaf-extras-1.1.1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/formdev/flatlaf-extras/1.1.1/flatlaf-extras-1.1.1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/formdev/flatlaf-extras/1.1.1/flatlaf-extras-1.1.1-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -2555,10 +2555,22 @@ public class GraphicFactory {
* Create image by RGB data array
*
* @param data RGB data array list
* @param extent Exent
* @param extent Extent
* @return Image graphic
*/
public static Graphic createImage(List<Array> data, List<Number> extent) {
return createImage(data, extent, false);
}
/**
* Create image by RGB data array
*
* @param data RGB data array list
* @param extent Extent
* @param yReverse Y coordinate reverse or not
* @return Image graphic
*/
public static Graphic createImage(List<Array> data, List<Number> extent, boolean yReverse) {
int width, height;
width = data.get(0).getShape()[1];
height = data.get(0).getShape()[0];
@ -2589,7 +2601,10 @@ public class GraphicFactory {
} else {
color = new Color(r, g, b, a);
}
aImage.setRGB(j, height - i - 1, color.getRGB());
if (yReverse)
aImage.setRGB(j, i, color.getRGB());
else
aImage.setRGB(j, height - i - 1, color.getRGB());
}
}
} else {
@ -2603,7 +2618,10 @@ public class GraphicFactory {
} else {
color = new Color(r, g, b);
}
aImage.setRGB(j, height - i - 1, color.getRGB());
if (yReverse)
aImage.setRGB(j, i, color.getRGB());
else
aImage.setRGB(j, height - i - 1, color.getRGB());
}
}
}
@ -2624,7 +2642,10 @@ public class GraphicFactory {
} else {
color = new Color(r, g, b, a);
}
aImage.setRGB(j, height - i - 1, color.getRGB());
if (yReverse)
aImage.setRGB(j, i, color.getRGB());
else
aImage.setRGB(j, height - i - 1, color.getRGB());
}
}
} else {
@ -2638,7 +2659,10 @@ public class GraphicFactory {
} else {
color = new Color(r, g, b);
}
aImage.setRGB(j, height - i - 1, color.getRGB());
if (yReverse)
aImage.setRGB(j, i, color.getRGB());
else
aImage.setRGB(j, height - i - 1, color.getRGB());
}
}
}

View File

@ -19,7 +19,6 @@ import org.locationtech.proj4j.datum.Grid;
import org.meteoinfo.common.DataConvert;
import org.meteoinfo.common.Extent;
import org.meteoinfo.common.MIMath;
//import org.meteoinfo.geoprocess.GeoComputation;
import java.io.BufferedWriter;
import java.io.DataOutputStream;
@ -43,7 +42,6 @@ import org.meteoinfo.common.ResampleMethods;
import org.meteoinfo.common.util.GlobalUtil;
import org.meteoinfo.ndarray.Dimension;
import org.meteoinfo.ndarray.DimensionType;
//import org.meteoinfo.geoprocess.analysis.ResampleMethods;
import org.meteoinfo.ndarray.math.ArrayUtil;
import org.meteoinfo.projection.KnownCoordinateSystems;
import org.meteoinfo.projection.ProjectionInfo;
@ -87,6 +85,13 @@ public class GridData {
// </editor-fold>
// <editor-fold desc="Constructor">
/**
* Constructor
*/
public GridData() {
}
/**
* Constructor
*
@ -3257,7 +3262,7 @@ public class GridData {
/**
* GridData.Integer class
*/
public static class Byte extends GridData {
public class Byte extends GridData {
private byte[][] data;
private int missingValue;
@ -3408,7 +3413,7 @@ public class GridData {
/**
* GridData.Integer class
*/
public static class Integer extends GridData {
public class Integer extends GridData {
private final int[][] data;
private int missingValue;
@ -3532,7 +3537,7 @@ public class GridData {
/**
* GridData.Double class
*/
public static class Double extends GridData {
public class Double extends GridData {
private double[][] data;
private double missingValue;
@ -3617,7 +3622,7 @@ public class GridData {
/**
* GridData.Integer class
*/
public static class Float extends GridData {
public class Float extends GridData {
private float[][] data;
private float missingValue;

View File

@ -682,7 +682,7 @@ public class GeoTiff {
IFDEntry heightIFD = this.findTag(Tag.ImageLength);
int width = widthIFD.value[0];
int height = heightIFD.value[0];
GridData.Integer gData = new GridData.Integer(height, width);
GridData.Integer gData = new GridData().new Integer(height, width);
int[] values1d = readData(width, height);
//int[][] values = new int[height][width];
for (int i = 0; i < height; i++) {
@ -740,7 +740,7 @@ public class GeoTiff {
IFDEntry heightIFD = this.findTag(Tag.ImageLength);
int width = widthIFD.value[0];
int height = heightIFD.value[0];
GridData.Integer gData = new GridData.Integer(height, width);
GridData.Integer gData = new GridData().new Integer(height, width);
int[] values1d = readData(width, height);
//int[][] values = new int[height][width];
for (int i = 0; i < height; i++) {

View File

@ -523,7 +523,7 @@ import org.meteoinfo.data.meteodata.Attribute;
RandomAccessFile br = new RandomAccessFile(this.getFileName(), "r");
double[] xArray = this.getXDimension().getValues();
double[] yArray = this.getYDimension().getValues();
GridData.Integer gData = new GridData.Integer(xArray, yArray);
GridData.Integer gData = new GridData().new Integer(xArray, yArray);
br.seek(this._skipbytes);
int i, j;
@ -566,7 +566,7 @@ import org.meteoinfo.data.meteodata.Attribute;
private GridData getGridData_BIL_Byte(int varIdx) {
try {
RandomAccessFile br = new RandomAccessFile(this.getFileName(), "r");
GridData.Byte gData = new GridData.Byte(this.getXDimension().getValues(),
GridData.Byte gData = new GridData().new Byte(this.getXDimension().getValues(),
this.getYDimension().getValues());
br.seek(this._skipbytes);
@ -695,7 +695,7 @@ import org.meteoinfo.data.meteodata.Attribute;
RandomAccessFile br = new RandomAccessFile(this.getFileName(), "r");
double[] xArray = this.getXDimension().getValues();
double[] yArray = this.getYDimension().getValues();
GridData.Integer gData = new GridData.Integer(xArray, yArray);
GridData.Integer gData = new GridData().new Integer(xArray, yArray);
br.seek(this._skipbytes);
int i, j;
@ -741,7 +741,7 @@ import org.meteoinfo.data.meteodata.Attribute;
RandomAccessFile br = new RandomAccessFile(this.getFileName(), "r");
double[] xArray = this.getXDimension().getValues();
double[] yArray = this.getYDimension().getValues();
GridData.Byte gData = new GridData.Byte(xArray, yArray);
GridData.Byte gData = new GridData().new Byte(xArray, yArray);
br.seek(this._skipbytes);
int i, j;

View File

@ -70,8 +70,5 @@
<orderEntry type="library" name="Maven: org.bytedeco:openblas:windows-x86:0.3.10-1.5.4" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:windows-x86_64:0.3.10-1.5.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-imaging:1.0-alpha1" level="project" />
<orderEntry type="library" name="Maven: com.formdev:flatlaf-extras:1.1.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.formdev:svgSalamander:1.1.2.4" level="project" />
<orderEntry type="library" name="Maven: com.formdev:flatlaf:1.1.1" level="project" />
</component>
</module>

View File

@ -27,16 +27,6 @@
<artifactId>commons-imaging</artifactId>
<version>1.0-alpha1</version>
</dependency>
<dependency>
<groupId>com.formdev</groupId>
<artifactId>flatlaf-extras</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.formdev</groupId>
<artifactId>flatlaf</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
<build>

View File

@ -1,41 +0,0 @@
package org.meteoinfo.image.svg;
import com.formdev.flatlaf.extras.FlatSVGIcon;
import javax.swing.*;
public class SVGUtil {
/**
* Set SVG icon
* @param button The button
* @param iconPath SVG icon path
*/
public static void setSVGIcon(AbstractButton button, String iconPath) {
try {
FlatSVGIcon icon = new FlatSVGIcon(iconPath);
if (icon.hasFound()) {
button.setIcon(icon);
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Set SVG icon
* @param button The button
* @param iconPath SVG icon path
* @param classLoader ClassLoader
*/
public static void setSVGIcon(AbstractButton button, String iconPath, ClassLoader classLoader) {
try {
FlatSVGIcon icon = new FlatSVGIcon(iconPath, classLoader);
if (icon.hasFound()) {
button.setIcon(icon);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -1,36 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<MeteoInfo File="milconfig.xml" Type="configurefile">
<Path OpenPath="D:\Working\MIScript\Jython\mis\toolbox\miml\decomposition">
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\preprocessing"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\model_persistence"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\math"/>
<Path OpenPath="D:\Working\MIScript\Jython\mis\toolbox\miml">
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\regression"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\special"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\linalg"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\classification"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\himawari"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\interpolate"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\decomposition"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\cluster"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\classification"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\decomposition"/>
</Path>
<File>
<OpenedFiles>
<OpenedFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\classification\lda_1.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\common_math\special\gamma.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\decomposition\pca_1.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\classification\knn.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\decomposition\pca_iris.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\cluster\dbscan_1.py"/>
<OpenedFile File=""/>
</OpenedFiles>
<RecentFiles>
<RecentFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\classification\lda_1.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\common_math\special\gamma.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\decomposition\pca_1.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\classification\knn.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\decomposition\pca_iris.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\cluster\dbscan_1.py"/>
<RecentFile File=""/>
</RecentFiles>
</File>
<Font>
@ -38,5 +36,5 @@
</Font>
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
<Figure DoubleBuffering="true"/>
<Startup MainFormLocation="-7,-7" MainFormSize="1293,693"/>
<Startup MainFormLocation="-7,0" MainFormSize="1393,782"/>
</MeteoInfo>

View File

@ -1222,13 +1222,15 @@ class MapAxes(Axes):
rgbd.append(d.asarray())
rgbdata = rgbd
else:
rgbdata = rgbdata.asarray()
rgbdata = rgbdata.asarray()
y_reverse = False
if x[1] < x[0]:
x = x[::-1]
if y[1] < y[0]:
y = y[::-1]
y_reverse = True
extent = [x[0],x[-1],y[0],y[-1]]
igraphic = GraphicFactory.createImage(rgbdata, extent)
igraphic = GraphicFactory.createImage(rgbdata, extent, y_reverse)
x = plotutil.getplotdata(x)
y = plotutil.getplotdata(y)
layer = DrawMeteoData.createImageLayer(x, y, igraphic, 'layer_image')