mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
add collections module
This commit is contained in:
parent
b3b0e24d4f
commit
445c6879db
@ -24,7 +24,8 @@ public class VolumeGraphic extends GraphicCollection3D {
|
||||
final int width;
|
||||
final int height;
|
||||
final int depth;
|
||||
final byte[] data;
|
||||
private Array data;
|
||||
final byte[] byteData;
|
||||
private byte[] normals;
|
||||
final float[] scale = new float[]{1, 1, 1};
|
||||
private byte[] colors;
|
||||
@ -53,7 +54,7 @@ public class VolumeGraphic extends GraphicCollection3D {
|
||||
this.height = height;
|
||||
this.depth = depth;
|
||||
|
||||
this.data = data;
|
||||
this.byteData = data;
|
||||
//this.buffer = Buffers.newDirectByteBuffer(this.data);
|
||||
this.colors = colors;
|
||||
|
||||
@ -75,17 +76,18 @@ public class VolumeGraphic extends GraphicCollection3D {
|
||||
this.transferFunction.setColorMap(colorMap);
|
||||
|
||||
value = value.copyIfView();
|
||||
this.data = value;
|
||||
int[] shape = value.getShape();
|
||||
this.depth = shape[0];
|
||||
this.height = shape[1];
|
||||
this.width = shape[2];
|
||||
this.data = new byte[width * height * depth];
|
||||
this.byteData = new byte[width * height * depth];
|
||||
double range = vMax - vMin;
|
||||
for (int i = 0; i < value.getSize(); i++) {
|
||||
if (Double.isNaN(value.getDouble(i))) {
|
||||
data[i] = 0;
|
||||
byteData[i] = 0;
|
||||
} else {
|
||||
data[i] = (byte) ((int) ((value.getDouble(i) - vMin) / range * 255));
|
||||
byteData[i] = (byte) ((int) ((value.getDouble(i) - vMin) / range * 255));
|
||||
}
|
||||
}
|
||||
//buffer = Buffers.newDirectByteBuffer(data);
|
||||
@ -114,16 +116,17 @@ public class VolumeGraphic extends GraphicCollection3D {
|
||||
*/
|
||||
public VolumeGraphic(Array value, ColorMap colorMap, Normalize norm) {
|
||||
value = value.copyIfView();
|
||||
this.data = value;
|
||||
int[] shape = value.getShape();
|
||||
this.depth = shape[0];
|
||||
this.height = shape[1];
|
||||
this.width = shape[2];
|
||||
this.data = new byte[width * height * depth];
|
||||
this.byteData = new byte[width * height * depth];
|
||||
for (int i = 0; i < value.getSize(); i++) {
|
||||
if (Double.isNaN(value.getDouble(i))) {
|
||||
data[i] = 0;
|
||||
byteData[i] = 0;
|
||||
} else {
|
||||
data[i] = (byte) ((int) (norm.apply(value.getDouble(i)).floatValue() * 255));
|
||||
byteData[i] = (byte) ((int) (norm.apply(value.getDouble(i)).floatValue() * 255));
|
||||
}
|
||||
}
|
||||
//buffer = Buffers.newDirectByteBuffer(data);
|
||||
@ -138,18 +141,19 @@ public class VolumeGraphic extends GraphicCollection3D {
|
||||
*/
|
||||
public VolumeGraphic(Array value, LegendScheme ls) {
|
||||
value = value.copyIfView();
|
||||
this.data = value;
|
||||
int[] shape = value.getShape();
|
||||
this.depth = shape[0];
|
||||
this.height = shape[1];
|
||||
this.width = shape[2];
|
||||
this.data = new byte[width * height * depth];
|
||||
this.byteData = new byte[width * height * depth];
|
||||
List<Color> oColors = ls.getColors();
|
||||
int n = oColors.size();
|
||||
for (int i = 0; i < value.getSize(); i++) {
|
||||
if (Double.isNaN(value.getDouble(i))) {
|
||||
data[i] = 0;
|
||||
byteData[i] = 0;
|
||||
} else {
|
||||
data[i] = (byte) ((int) (ls.legendBreakIndex(value.getDouble(i)) * 255.0 / n));
|
||||
byteData[i] = (byte) ((int) (ls.legendBreakIndex(value.getDouble(i)) * 255.0 / n));
|
||||
}
|
||||
}
|
||||
//buffer = Buffers.newDirectByteBuffer(data);
|
||||
@ -307,6 +311,14 @@ public class VolumeGraphic extends GraphicCollection3D {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data array
|
||||
* @return Data array
|
||||
*/
|
||||
public Array getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get width
|
||||
* @return Width
|
||||
@ -335,8 +347,8 @@ public class VolumeGraphic extends GraphicCollection3D {
|
||||
* Get data array
|
||||
* @return Data array
|
||||
*/
|
||||
public byte[] getData() {
|
||||
return this.data;
|
||||
public byte[] getByteData() {
|
||||
return this.byteData;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -613,16 +625,16 @@ public class VolumeGraphic extends GraphicCollection3D {
|
||||
* Calculate normals
|
||||
*/
|
||||
public void calculateNormals() {
|
||||
this.normals = new byte[this.data.length * 3];
|
||||
this.normals = new byte[this.byteData.length * 3];
|
||||
int xn, yn, zn, i1, i2;
|
||||
int n = this.data.length;
|
||||
int n = this.byteData.length;
|
||||
for (int i = 0; i < n; i++) {
|
||||
i1 = i - 1;
|
||||
i2 = i + 1;
|
||||
if (i1 < 0 || i2 >= n)
|
||||
xn = 0;
|
||||
else
|
||||
xn = data[i1] - data[i2];
|
||||
xn = byteData[i1] - byteData[i2];
|
||||
normals[i * 3] = (byte) (xn + 128);
|
||||
|
||||
i1 = i - width;
|
||||
@ -630,7 +642,7 @@ public class VolumeGraphic extends GraphicCollection3D {
|
||||
if (i1 < 0 || i2 >= n)
|
||||
yn = 0;
|
||||
else
|
||||
yn = data[i1] - data[i2];
|
||||
yn = byteData[i1] - byteData[i2];
|
||||
normals[i * 3 + 1] = (byte) (yn + 128);
|
||||
|
||||
i1 = i - (width * height);
|
||||
@ -638,7 +650,7 @@ public class VolumeGraphic extends GraphicCollection3D {
|
||||
if (i1 < 0 || i2 >= n)
|
||||
zn = 0;
|
||||
else
|
||||
zn = data[i1] - data[i2];
|
||||
zn = byteData[i1] - byteData[i2];
|
||||
normals[i * 3 + 2] = (byte) (zn + 128);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2930,7 +2930,7 @@ public class GLPlot extends Plot {
|
||||
PointBreak pb = (PointBreak) graphic.getGraphicN(0).getLegend();
|
||||
gl.glPointSize(pb.getSize() * this.dpiScale);
|
||||
gl.glBegin(GL2.GL_POINTS);
|
||||
for (Graphic gg : graphic.getGraphics()) {
|
||||
for (Graphic gg : ((GraphicCollection) graphic).getGraphics()) {
|
||||
PointZShape shape = (PointZShape) gg.getShape();
|
||||
pb = (PointBreak) gg.getLegend();
|
||||
float[] rgba = pb.getColor().getRGBComponents(null);
|
||||
@ -2966,7 +2966,7 @@ public class GLPlot extends Plot {
|
||||
}
|
||||
|
||||
private void drawSpheres(GL2 gl, Graphic graphic) {
|
||||
for (Graphic gg : graphic.getGraphics()) {
|
||||
for (Graphic gg : ((GraphicCollection) graphic).getGraphics()) {
|
||||
drawSphere(gl, gg);
|
||||
}
|
||||
}
|
||||
@ -3083,7 +3083,7 @@ public class GLPlot extends Plot {
|
||||
0, // border
|
||||
GL_LUMINANCE, // format
|
||||
GL_UNSIGNED_BYTE, // type
|
||||
Buffers.newDirectByteBuffer(volume.getData()).rewind() // pixel
|
||||
Buffers.newDirectByteBuffer(volume.getByteData()).rewind() // pixel
|
||||
);
|
||||
|
||||
// 1st attribute buffer : vertices
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package org.meteoinfo.chart.render.jogl;
|
||||
|
||||
import com.jogamp.common.nio.Buffers;
|
||||
import com.jogamp.opengl.GL;
|
||||
import com.jogamp.opengl.GL2;
|
||||
import com.jogamp.opengl.util.GLBuffers;
|
||||
import org.meteoinfo.chart.graphic.VolumeGraphic;
|
||||
@ -178,7 +177,7 @@ public class VolumeRender extends JOGLGraphicRender {
|
||||
0, // border
|
||||
GL_LUMINANCE, // format
|
||||
GL_UNSIGNED_BYTE, // type
|
||||
((Buffer) Buffers.newDirectByteBuffer(volume.getData())).rewind() // pixel
|
||||
((Buffer) Buffers.newDirectByteBuffer(volume.getByteData())).rewind() // pixel
|
||||
);
|
||||
|
||||
//Normals 3D texture
|
||||
|
||||
@ -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.8.5";
|
||||
version = "3.8.6";
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
@ -275,14 +275,13 @@ public class JDateUtil {
|
||||
|
||||
TemporalAmount pe;
|
||||
switch (p) {
|
||||
case "H":
|
||||
case "h":
|
||||
pe = Duration.ofHours(n);
|
||||
break;
|
||||
case "T":
|
||||
case "Min":
|
||||
case "min":
|
||||
pe = Duration.ofMinutes(n);
|
||||
break;
|
||||
case "S":
|
||||
case "s":
|
||||
pe = Duration.ofSeconds(n);
|
||||
break;
|
||||
case "D":
|
||||
|
||||
@ -225,75 +225,6 @@ public class CMARadarBaseDataInfo extends DataInfo implements IGridDataInfo {
|
||||
}
|
||||
}
|
||||
|
||||
void readDataInfo(RandomAccessFile raf) {
|
||||
try {
|
||||
genericHeader = new GenericHeader(raf);
|
||||
siteConfig = new SiteConfig(raf);
|
||||
|
||||
//Add global attributes
|
||||
this.addAttribute(new Attribute("StationCode", siteConfig.siteCode));
|
||||
this.addAttribute(new Attribute("StationName", siteConfig.siteName));
|
||||
this.addAttribute(new Attribute("StationLatitude", siteConfig.latitude));
|
||||
this.addAttribute(new Attribute("StationLongitude", siteConfig.longitude));
|
||||
this.addAttribute(new Attribute("AntennaHeight", siteConfig.antennaHeight));
|
||||
this.addAttribute(new Attribute("GroundHeight", siteConfig.groundHeight));
|
||||
this.addAttribute(new Attribute("featureType", "RADIAL"));
|
||||
this.addAttribute(new Attribute("DataType", "Radial"));
|
||||
|
||||
//Read radial data
|
||||
taskConfig = new TaskConfig(raf);
|
||||
cutConfigs = new ArrayList<>();
|
||||
for (int i = 0; i < taskConfig.cutNumber; i++) {
|
||||
cutConfigs.add(new CutConfig(raf));
|
||||
}
|
||||
radialHeaders = new ArrayList<>();
|
||||
while (raf.length() - raf.getFilePointer() > RadialHeader.length) {
|
||||
RadialHeader radialHeader = new RadialHeader(raf);
|
||||
for (int i = 0; i < radialHeader.momentNumber; i++) {
|
||||
MomentHeader momentHeader = new MomentHeader(raf);
|
||||
String product = this.productMap.get(momentHeader.dataType);
|
||||
RadialRecord record;
|
||||
if (this.recordMap.containsKey(product)) {
|
||||
record = this.recordMap.get(product);
|
||||
} else {
|
||||
record = new RadialRecord(product);
|
||||
record.setBinLength(momentHeader.binLength);
|
||||
record.scale = momentHeader.scale;
|
||||
record.offset = momentHeader.offset;
|
||||
this.recordMap.put(product, record);
|
||||
}
|
||||
if (radialHeader.radialNumber == 1) {
|
||||
record.elevation.add(new ArrayList<>());
|
||||
record.azimuth.add(new ArrayList<>());
|
||||
record.distance.add(ArrayUtil.arrayRange1(0, momentHeader.dataLength / momentHeader.binLength,
|
||||
cutConfigs.get(0).logResolution));
|
||||
record.newScanData();
|
||||
}
|
||||
record.elevation.get(record.elevation.size() - 1).add(radialHeader.elevation);
|
||||
record.azimuth.get(record.azimuth.size() - 1).add(radialHeader.azimuth);
|
||||
byte[] bytes = new byte[momentHeader.dataLength];
|
||||
raf.read(bytes);
|
||||
record.addDataBytes(bytes);
|
||||
}
|
||||
radialHeaders.add(radialHeader);
|
||||
}
|
||||
raf.close();
|
||||
|
||||
//Add dimensions and variables
|
||||
Dimension xyzDim = new Dimension(DimensionType.OTHER);
|
||||
xyzDim.setShortName("xyz");
|
||||
xyzDim.setDimValue(Array.factory(DataType.INT, new int[]{3}, new int[]{1,2,3}));
|
||||
this.addDimension(xyzDim);
|
||||
for (String product : this.recordMap.keySet()) {
|
||||
this.recordMap.get(product).makeVariables(this, xyzDim);
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
void readDataInfo(InputStream raf) {
|
||||
try {
|
||||
genericHeader = new GenericHeader(raf);
|
||||
@ -310,8 +241,12 @@ public class CMARadarBaseDataInfo extends DataInfo implements IGridDataInfo {
|
||||
this.addAttribute(new Attribute("featureType", "RADIAL"));
|
||||
this.addAttribute(new Attribute("DataType", "Radial"));
|
||||
|
||||
//Read radial data
|
||||
//Read task configuration
|
||||
taskConfig = new TaskConfig(raf);
|
||||
this.addAttribute(new Attribute("TaskName", taskConfig.taskName));
|
||||
this.addAttribute(new Attribute("TaskDescription", taskConfig.taskDescription));
|
||||
|
||||
//Read radial data
|
||||
cutConfigs = new ArrayList<>();
|
||||
for (int i = 0; i < taskConfig.cutNumber; i++) {
|
||||
cutConfigs.add(new CutConfig(raf));
|
||||
|
||||
@ -6,6 +6,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class TaskConfig {
|
||||
@ -28,52 +29,6 @@ public class TaskConfig {
|
||||
public float LDRCalibration;
|
||||
public byte[] reserves;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param raf RandomAccessFile object
|
||||
*/
|
||||
public TaskConfig(RandomAccessFile raf) throws IOException {
|
||||
byte[] bytes = new byte[32];
|
||||
raf.read(bytes);
|
||||
taskName = new String(bytes).trim();
|
||||
bytes = new byte[128];
|
||||
raf.read(bytes);
|
||||
taskDescription = new String(bytes).trim();
|
||||
bytes = new byte[4];
|
||||
raf.read(bytes);
|
||||
polarizationType = DataConvert.bytes2Int(bytes, ByteOrder.LITTLE_ENDIAN);
|
||||
raf.read(bytes);
|
||||
scanType = DataConvert.bytes2Int(bytes, ByteOrder.LITTLE_ENDIAN);
|
||||
raf.read(bytes);
|
||||
pulseWidth = DataConvert.bytes2Int(bytes, ByteOrder.LITTLE_ENDIAN);
|
||||
raf.read(bytes);
|
||||
int seconds = DataConvert.bytes2Int(bytes, ByteOrder.LITTLE_ENDIAN);
|
||||
LocalDateTime dt = LocalDateTime.of(1970, 1, 1, 0, 0);
|
||||
scanStartTime = dt.plusSeconds(seconds);
|
||||
raf.read(bytes);
|
||||
cutNumber = DataConvert.bytes2Int(bytes, ByteOrder.LITTLE_ENDIAN);
|
||||
raf.read(bytes);
|
||||
horizontalNoise = DataConvert.bytes2Float(bytes, ByteOrder.LITTLE_ENDIAN);
|
||||
raf.read(bytes);
|
||||
verticalNoise = DataConvert.bytes2Float(bytes, ByteOrder.LITTLE_ENDIAN);
|
||||
raf.read(bytes);
|
||||
horizontalCalibration = DataConvert.bytes2Float(bytes, ByteOrder.LITTLE_ENDIAN);
|
||||
raf.read(bytes);
|
||||
verticalCalibration = DataConvert.bytes2Float(bytes, ByteOrder.LITTLE_ENDIAN);
|
||||
raf.read(bytes);
|
||||
horizontalNoiseTemperature = DataConvert.bytes2Float(bytes, ByteOrder.LITTLE_ENDIAN);
|
||||
raf.read(bytes);
|
||||
verticalNoiseTemperature = DataConvert.bytes2Float(bytes, ByteOrder.LITTLE_ENDIAN);
|
||||
raf.read(bytes);
|
||||
ZDRCalibration = DataConvert.bytes2Float(bytes, ByteOrder.LITTLE_ENDIAN);
|
||||
raf.read(bytes);
|
||||
PHIDRCalibration = DataConvert.bytes2Float(bytes, ByteOrder.LITTLE_ENDIAN);
|
||||
raf.read(bytes);
|
||||
LDRCalibration = DataConvert.bytes2Float(bytes, ByteOrder.LITTLE_ENDIAN);
|
||||
reserves = new byte[40];
|
||||
raf.read(reserves);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param raf InputStream object
|
||||
|
||||
@ -15,6 +15,7 @@ package org.meteoinfo.geo.legend;
|
||||
|
||||
import com.l2fprod.common.beans.BaseBeanInfo;
|
||||
import org.meteoinfo.common.colors.ColorUtil;
|
||||
import org.meteoinfo.geometry.graphic.Graphic;
|
||||
import org.meteoinfo.geometry.legend.Constants;
|
||||
import org.meteoinfo.geometry.legend.LegendScheme;
|
||||
import org.meteoinfo.geometry.legend.LineStyles;
|
||||
@ -1649,7 +1650,7 @@ public class MapFrame extends ItemNode {
|
||||
_mapView.exportMaskOutElement(m_Doc, mapFrame);
|
||||
_mapView.exportProjectionElement(m_Doc, mapFrame);
|
||||
addGroupLayerElement(m_Doc, mapFrame, projectFilePath);
|
||||
_mapView.exportGraphics(m_Doc, mapFrame, _mapView.getGraphicCollection().getGraphics());
|
||||
_mapView.exportGraphics(m_Doc, mapFrame, (List<Graphic>) _mapView.getGraphicCollection().getGraphics());
|
||||
|
||||
parent.appendChild(mapFrame);
|
||||
}
|
||||
|
||||
@ -8960,7 +8960,7 @@ public class MapView extends JPanel implements IWebMapPanel {
|
||||
* Remove selected graphics
|
||||
*/
|
||||
public void removeSelectedGraphics() {
|
||||
UndoableEdit edit = (new MapViewUndoRedo()).new RemoveGraphicsEdit(this, _selectedGraphics.getGraphics());
|
||||
UndoableEdit edit = (new MapViewUndoRedo()).new RemoveGraphicsEdit(this, (List<Graphic>)_selectedGraphics.getGraphics());
|
||||
this.fireUndoEditEvent(edit);
|
||||
for (Graphic aGraphic : _selectedGraphics.getGraphics()) {
|
||||
removeGraphic(aGraphic);
|
||||
@ -9669,7 +9669,7 @@ public class MapView extends JPanel implements IWebMapPanel {
|
||||
|
||||
//Load label graphics
|
||||
GraphicCollection gc = loadGraphicCollection((Element) aVLayer);
|
||||
aLayer.setLabelPoints(gc.getGraphics());
|
||||
aLayer.setLabelPoints((List<Graphic>) gc.getGraphics());
|
||||
|
||||
//Load chart set
|
||||
NodeList chartNodes = ((Element) aVLayer).getElementsByTagName("ChartSet");
|
||||
|
||||
@ -274,12 +274,12 @@ package org.meteoinfo.geometry.graphic;
|
||||
/**
|
||||
* Get graphic list
|
||||
* @return Graphic list
|
||||
*/
|
||||
*//*
|
||||
public List<Graphic> getGraphics() {
|
||||
List<Graphic> gs = new ArrayList<>();
|
||||
gs.add(this);
|
||||
return gs;
|
||||
}
|
||||
}*/
|
||||
|
||||
private void updateResizeAbility() {
|
||||
if (shape != null && legend != null) {
|
||||
|
||||
@ -34,7 +34,7 @@ import java.util.NoSuchElementException;
|
||||
public class GraphicCollection extends Graphic implements Iterator {
|
||||
|
||||
// <editor-fold desc="Variables">
|
||||
protected List<Graphic> graphics = new ArrayList<>();
|
||||
protected List<? extends Graphic> graphics = new ArrayList<>();
|
||||
protected Extent extent = new Extent();
|
||||
protected boolean singleLegend = true;
|
||||
protected int index;
|
||||
@ -89,8 +89,7 @@ public class GraphicCollection extends Graphic implements Iterator {
|
||||
*
|
||||
* @return Graphic list
|
||||
*/
|
||||
@Override
|
||||
public List<Graphic> getGraphics() {
|
||||
public List<? extends Graphic> getGraphics() {
|
||||
return this.graphics;
|
||||
}
|
||||
|
||||
@ -276,7 +275,7 @@ public class GraphicCollection extends Graphic implements Iterator {
|
||||
* @return Boolean
|
||||
*/
|
||||
public boolean add(Graphic aGraphic) {
|
||||
boolean istrue = this.graphics.add(aGraphic);
|
||||
boolean istrue = ((List<Graphic>) this.graphics).add(aGraphic);
|
||||
|
||||
//Update extent
|
||||
if (this.graphics.size() == 1) {
|
||||
@ -295,7 +294,7 @@ public class GraphicCollection extends Graphic implements Iterator {
|
||||
* @param aGraphic The graphic
|
||||
*/
|
||||
public void add(int index, Graphic aGraphic) {
|
||||
this.graphics.add(index, aGraphic);
|
||||
((List<Graphic>) this.graphics).add(index, aGraphic);
|
||||
|
||||
//Update extent
|
||||
if (this.graphics.size() == 1) {
|
||||
@ -380,7 +379,7 @@ public class GraphicCollection extends Graphic implements Iterator {
|
||||
* @param graphic The graphic
|
||||
*/
|
||||
public void setGraphicN(int idx, Graphic graphic) {
|
||||
this.graphics.set(idx, graphic);
|
||||
((List<Graphic>) this.graphics).set(idx, graphic);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -422,7 +421,7 @@ public class GraphicCollection extends Graphic implements Iterator {
|
||||
* @param gs Graphic list
|
||||
*/
|
||||
public void addAll(List<Graphic> gs) {
|
||||
this.graphics.addAll(gs);
|
||||
((List<Graphic>) this.graphics).addAll(gs);
|
||||
|
||||
// Update extent
|
||||
int i = 0;
|
||||
@ -453,7 +452,7 @@ public class GraphicCollection extends Graphic implements Iterator {
|
||||
extent = MIMath.getLagerExtent(extent, graphic.getExtent());
|
||||
}
|
||||
for (int i = 0; i < graphic.getNumGraphics(); i++) {
|
||||
this.graphics.add(graphic.getGraphicN(i));
|
||||
((List<Graphic>) this.graphics).add(graphic.getGraphicN(i));
|
||||
}
|
||||
} else {
|
||||
this.add(graphic);
|
||||
|
||||
@ -132,6 +132,14 @@ public class Line2DGraphic extends Graphic {
|
||||
this.curve = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get x data
|
||||
* @return X data
|
||||
*/
|
||||
public Array getXData() {
|
||||
return this.xData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set x data
|
||||
* @param xData X data
|
||||
@ -141,6 +149,14 @@ public class Line2DGraphic extends Graphic {
|
||||
updateShape();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get y data
|
||||
* @return Y data
|
||||
*/
|
||||
public Array getYData() {
|
||||
return this.yData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set y data
|
||||
* @param yData Y data
|
||||
@ -150,6 +166,14 @@ public class Line2DGraphic extends Graphic {
|
||||
updateShape();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data
|
||||
* @return Data
|
||||
*/
|
||||
public Array getData() {
|
||||
return this.cData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set data
|
||||
* @param xData X data
|
||||
|
||||
@ -0,0 +1,55 @@
|
||||
package org.meteoinfo.geometry.graphic;
|
||||
|
||||
import org.meteoinfo.geometry.legend.PointBreak;
|
||||
import org.meteoinfo.geometry.shape.PointShape;
|
||||
|
||||
public class Point2DGraphic extends Graphic {
|
||||
|
||||
double x, y;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param pointShape Point shape
|
||||
* @param pointBreak Point break
|
||||
*/
|
||||
public Point2DGraphic(PointShape pointShape, PointBreak pointBreak) {
|
||||
this.shape = pointShape;
|
||||
this.legend = pointBreak;
|
||||
this.x = pointShape.getPoint().X;
|
||||
this.y = pointShape.getPoint().Y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get x
|
||||
* @return X
|
||||
*/
|
||||
public double getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set x
|
||||
* @param value X
|
||||
*/
|
||||
public void setX(double value) {
|
||||
this.x = value;
|
||||
((PointShape) this.shape).getPoint().X = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get y
|
||||
* @return Y
|
||||
*/
|
||||
public double getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set y
|
||||
* @param value Y
|
||||
*/
|
||||
public void setY(double value) {
|
||||
this.y = value;
|
||||
((PointShape) this.shape).getPoint().Y = value;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,149 @@
|
||||
package org.meteoinfo.geometry.graphic;
|
||||
|
||||
import org.meteoinfo.common.PointD;
|
||||
import org.meteoinfo.geometry.legend.ColorBreak;
|
||||
import org.meteoinfo.geometry.legend.LegendScheme;
|
||||
import org.meteoinfo.geometry.legend.LegendType;
|
||||
import org.meteoinfo.geometry.legend.PointBreak;
|
||||
import org.meteoinfo.geometry.shape.PointShape;
|
||||
import org.meteoinfo.geometry.shape.PolylineShape;
|
||||
import org.meteoinfo.geometry.shape.Shape;
|
||||
import org.meteoinfo.ndarray.Array;
|
||||
import org.meteoinfo.ndarray.IndexIterator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Point2DGraphicCollection extends GraphicCollection {
|
||||
private Array xData;
|
||||
private Array yData;
|
||||
private Array cData;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public Point2DGraphicCollection() {
|
||||
super();
|
||||
this.graphics = new ArrayList<Point2DGraphic>();
|
||||
this.legend = new PointBreak();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param graphics Graphics
|
||||
*/
|
||||
public Point2DGraphicCollection(List<Point2DGraphic> graphics) {
|
||||
this();
|
||||
this.graphics = graphics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param xData X data
|
||||
* @param yData Y data
|
||||
* @param pointBreak Point break
|
||||
*/
|
||||
public Point2DGraphicCollection(Array xData, Array yData, PointBreak pointBreak) {
|
||||
this();
|
||||
this.xData = xData;
|
||||
this.yData = yData;
|
||||
this.legend = pointBreak;
|
||||
this.updateGraphics(pointBreak);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param xData X data
|
||||
* @param yData Y data
|
||||
* @param cData Color data
|
||||
* @param ls Legend scheme
|
||||
*/
|
||||
public Point2DGraphicCollection(Array xData, Array yData, Array cData, LegendScheme ls) {
|
||||
this();
|
||||
this.xData = xData;
|
||||
this.yData = yData;
|
||||
this.cData = cData;
|
||||
this.legendScheme = ls;
|
||||
this.updateGraphics(ls);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get x data
|
||||
* @return X data
|
||||
*/
|
||||
public Array getXData() {
|
||||
return this.xData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get y data
|
||||
* @return Y data
|
||||
*/
|
||||
public Array getYData() {
|
||||
return this.yData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set data
|
||||
* @return Data
|
||||
*/
|
||||
public Array getData() {
|
||||
return this.cData;
|
||||
}
|
||||
|
||||
protected void updateGraphics() {
|
||||
updateGraphics((PointBreak) this.legend);
|
||||
}
|
||||
|
||||
protected void updateGraphics(PointBreak pointBreak) {
|
||||
this.graphics = new ArrayList<>();
|
||||
List<PointD> points = new ArrayList<>();
|
||||
IndexIterator xIter = this.xData.getIndexIterator();
|
||||
IndexIterator yIter = this.yData.getIndexIterator();
|
||||
double x, y;
|
||||
while (xIter.hasNext()) {
|
||||
x = xIter.getDoubleNext();
|
||||
y = yIter.getDoubleNext();
|
||||
if (Double.isNaN(x) || Double.isNaN(y)) {
|
||||
continue;
|
||||
}
|
||||
PointShape shape = new PointShape(new PointD(x, y));
|
||||
this.add(new Point2DGraphic(shape, pointBreak));
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateGraphics(LegendScheme ls) {
|
||||
this.graphics = new ArrayList<Graphic>();
|
||||
PointShape ps;
|
||||
double z;
|
||||
ColorBreak cb;
|
||||
IndexIterator xIter = this.xData.getIndexIterator();
|
||||
IndexIterator yIter = this.yData.getIndexIterator();
|
||||
IndexIterator zIter = this.cData.getIndexIterator();
|
||||
if (ls.getLegendType() == LegendType.UNIQUE_VALUE && this.xData.getSize() == ls.getBreakNum()) {
|
||||
int i = 0;
|
||||
while (xIter.hasNext()) {
|
||||
ps = new PointShape();
|
||||
ps.setPoint(new PointD(xIter.getDoubleNext(), yIter.getDoubleNext()));
|
||||
z = zIter.getDoubleNext();
|
||||
ps.setValue(z);
|
||||
cb = ls.getLegendBreak(i);
|
||||
this.add(new Graphic(ps, cb));
|
||||
i += 1;
|
||||
}
|
||||
} else {
|
||||
while (xIter.hasNext()) {
|
||||
ps = new PointShape();
|
||||
ps.setPoint(new PointD(xIter.getDoubleNext(), yIter.getDoubleNext()));
|
||||
z = zIter.getDoubleNext();
|
||||
ps.setValue(z);
|
||||
cb = ls.findLegendBreak(z);
|
||||
if (cb != null) {
|
||||
this.add(new Graphic(ps, cb));
|
||||
}
|
||||
}
|
||||
}
|
||||
this.setSingleLegend(false);
|
||||
this.setLegendScheme(ls);
|
||||
}
|
||||
}
|
||||
@ -1,32 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\array">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\plot"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\polar"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\scatter"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\step"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\taylor"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\violinplot"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\weather"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\wind"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\scatter">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\fitting"/>
|
||||
<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"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\netcdf"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\radar"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\dataframe"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\scatter"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\map\geoshow\geoshow_2.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\common_math\polynomial\polyder_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\array\convolve_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\plot_cuace_3d_volume.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\scatter\scatterm_grid.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\map\geoshow\geoshow_2.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\common_math\polynomial\polyder_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\array\convolve_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\plot_cuace_3d_volume.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\scatter\scatterm_grid.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
@ -34,5 +34,5 @@
|
||||
</Font>
|
||||
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
|
||||
<Figure DoubleBuffering="true"/>
|
||||
<Startup MainFormLocation="-7,0" MainFormSize="1400,825"/>
|
||||
<Startup MainFormLocation="-7,-7" MainFormSize="1293,685"/>
|
||||
</MeteoInfo>
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<flatlaf.version>3.3</flatlaf.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@ -29,16 +28,6 @@
|
||||
<artifactId>meteoinfo-console</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.formdev</groupId>
|
||||
<artifactId>flatlaf</artifactId>
|
||||
<version>${flatlaf.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.formdev</groupId>
|
||||
<artifactId>flatlaf-extras</artifactId>
|
||||
<version>${flatlaf.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.sciss</groupId>
|
||||
<artifactId>docking-frames-common</artifactId>
|
||||
|
||||
Binary file not shown.
@ -1084,7 +1084,7 @@ class DataFrame(object):
|
||||
def to_csv(self, filepath, delimiter=',', format=None, date_format=None, \
|
||||
float_format=None, index=True):
|
||||
"""
|
||||
Save the data to an csv file.
|
||||
Save the data to a csv file.
|
||||
|
||||
:param filepath: (*string*) The output file path.
|
||||
:param delimiter: (*string*) Field delimiter character. Default is ``,``.
|
||||
|
||||
Binary file not shown.
@ -285,7 +285,7 @@ def date_range(start=None, end=None, periods=None, freq='D'):
|
||||
:param start: (*string or datetime*) Start date time.
|
||||
:param end: (*string or datetime*) End date time.
|
||||
:param periods: (*int*) Periods number.
|
||||
:param freq: (*string*) Date time frequent value [ Y | M | D | H | m | S ].
|
||||
:param freq: (*string*) Date time frequent value [ Y | M | D | h | min | s ].
|
||||
|
||||
:returns: (*DateTimeIndex*) DateTimeIndex
|
||||
"""
|
||||
|
||||
Binary file not shown.
@ -27,6 +27,7 @@ from org.meteoinfo.data.mapdata.webmap import WebMapProvider, DefaultTileFactory
|
||||
from java.awt import Font, Color
|
||||
|
||||
from ._axes import Axes
|
||||
from .graphic import Point2DCollection
|
||||
import mipylib.numeric as np
|
||||
from mipylib.numeric.core import NDArray, DimArray
|
||||
from mipylib.geolib.milayer import MILayer
|
||||
@ -838,9 +839,11 @@ class MapAxes(Axes):
|
||||
proj = kwargs.pop('proj', migeo.projinfo())
|
||||
# Create graphics
|
||||
if a.ndim == 0:
|
||||
graphics = GraphicFactory.createPoints(x._array, y._array, ls.getLegendBreak(0))
|
||||
#graphics = GraphicFactory.createPoints(x._array, y._array, ls.getLegendBreak(0))
|
||||
graphics = Point2DCollection(x._array, y._array, legend=ls.getLegendBreaks(0))
|
||||
else:
|
||||
graphics = GraphicFactory.createPoints(x._array, y._array, a._array, ls)
|
||||
#graphics = GraphicFactory.createPoints(x._array, y._array, a._array, ls)
|
||||
graphics = Point2DCollection(x._array, y._array, a._array, ls)
|
||||
|
||||
antialias = kwargs.pop('antialias', None)
|
||||
if antialias is not None:
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
from .artist import *
|
||||
from .lines import *
|
||||
from .patches import *
|
||||
from .collections import *
|
||||
|
||||
__all__ = lines.__all__
|
||||
__all__ += patches.__all__
|
||||
__all__ += artist.__all__
|
||||
__all__ += artist.__all__
|
||||
__all__ += collections.__all__
|
||||
84
meteoinfo-lab/pylib/mipylib/plotlib/graphic/collections.py
Normal file
84
meteoinfo-lab/pylib/mipylib/plotlib/graphic/collections.py
Normal file
@ -0,0 +1,84 @@
|
||||
from org.meteoinfo.geometry.graphic import GraphicCollection, Point2DGraphicCollection
|
||||
from java.awt import Font
|
||||
|
||||
from .. import plotutil
|
||||
from ... import miutil
|
||||
from artist import Artist
|
||||
import mipylib.numeric as np
|
||||
|
||||
__all__ = ['Point2DCollection']
|
||||
|
||||
|
||||
class Collection(Artist):
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Class init.
|
||||
|
||||
:param graphics: (*GraphicCollection*) Graphics
|
||||
"""
|
||||
Artist.__init__(self)
|
||||
|
||||
def addlabels(self, **kwargs):
|
||||
"""
|
||||
Add labels
|
||||
|
||||
:param fontname: (*string*) Font name. Default is ``Arial``.
|
||||
:param fontsize: (*string*) Font size. Default is ``14``.
|
||||
:param bold: (*boolean*) Font bold or not. Default is ``False``.
|
||||
:param color: (*color*) Label color. Default is ``None`` with black color.
|
||||
:param xoffset: (*int*) X coordinate offset. Default is ``0``.
|
||||
:param yoffset: (*int*) Y coordinate offset. Default is ``0``.
|
||||
:param avoidcoll: (*boolean*) Avoid labels collision or not. Default is ``True``.
|
||||
:param decimals: (*int*) Number of decimals of labels.
|
||||
"""
|
||||
labelset = self.getLabelSet()
|
||||
fontname = kwargs.pop('fontname', 'Arial')
|
||||
fontsize = kwargs.pop('fontsize', 14)
|
||||
bold = kwargs.pop('bold', False)
|
||||
if bold:
|
||||
font = Font(fontname, Font.BOLD, fontsize)
|
||||
else:
|
||||
font = Font(fontname, Font.PLAIN, fontsize)
|
||||
labelset.setLabelFont(font)
|
||||
color = kwargs.pop('color', None)
|
||||
if not color is None:
|
||||
color = miutil.getcolor(color)
|
||||
labelset.setLabelColor(color)
|
||||
xoffset = kwargs.pop('xoffset', 0)
|
||||
labelset.setXOffset(xoffset)
|
||||
yoffset = kwargs.pop('yoffset', 0)
|
||||
labelset.setYOffset(yoffset)
|
||||
avoidcoll = kwargs.pop('avoidcoll', True)
|
||||
labelset.setAvoidCollision(avoidcoll)
|
||||
decimals = kwargs.pop('decimals', None)
|
||||
if not decimals is None:
|
||||
labelset.setAutoDecimal(False)
|
||||
labelset.setDecimalDigits(decimals)
|
||||
self.addLabels()
|
||||
|
||||
|
||||
class Point2DCollection(Collection, Point2DGraphicCollection):
|
||||
|
||||
def __init__(self, xdata, ydata, cdata=None, legend=None, **kwargs):
|
||||
"""
|
||||
Class init
|
||||
|
||||
:param xdata: (*Array*) X data array.
|
||||
:param ydata: (*Array*) Y data array.
|
||||
:param cdata: (*Array*) Color data array.
|
||||
:param legend: (*Legend*) Point legend.
|
||||
"""
|
||||
Collection.__init__(self)
|
||||
|
||||
if legend is None:
|
||||
legend = plotutil.getlegendbreak('point', **kwargs)[0]
|
||||
|
||||
self._x = np.asarray(xdata)
|
||||
self._y = np.asarray(ydata)
|
||||
self._cdata = np.asarray(cdata)
|
||||
|
||||
if cdata is None:
|
||||
Point2DGraphicCollection.__init__(self, self._x._array, self._y._array, legend)
|
||||
else:
|
||||
Point2DGraphicCollection.__init__(self, self._x._array, self._y._array, self._cdata._array, legend)
|
||||
Binary file not shown.
@ -624,9 +624,7 @@ def getlegendscheme(args, min, max, **kwargs):
|
||||
ls = kwargs.pop('symbolspec', None)
|
||||
if ls is None:
|
||||
extend = kwargs.pop('extend', None)
|
||||
if extend is None:
|
||||
extend = ExtendType.NONE
|
||||
else:
|
||||
if extend is not None:
|
||||
extend = ExtendType.valueOf(extend.upper())
|
||||
cmap = getcolormap(**kwargs)
|
||||
level_arg = kwargs.pop('levels', None)
|
||||
|
||||
2
pom.xml
2
pom.xml
@ -35,7 +35,7 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<revision>3.8.5</revision>
|
||||
<revision>3.8.6</revision>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.release>8</maven.compiler.release>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user