mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
update transfer function methods
This commit is contained in:
parent
c44968c874
commit
56237c6d17
@ -23,6 +23,8 @@ import org.meteoinfo.geo.layer.ImageLayer;
|
||||
import org.meteoinfo.geo.layer.VectorLayer;
|
||||
import org.meteoinfo.geo.legend.LegendManage;
|
||||
import org.meteoinfo.geometry.colors.Normalize;
|
||||
import org.meteoinfo.geometry.colors.OpacityTransferFunction;
|
||||
import org.meteoinfo.geometry.colors.TransferFunction;
|
||||
import org.meteoinfo.geometry.graphic.Graphic;
|
||||
import org.meteoinfo.geometry.graphic.GraphicCollection;
|
||||
import org.meteoinfo.geometry.graphic.ImageGraphic;
|
||||
@ -7398,6 +7400,125 @@ public class GraphicFactory {
|
||||
return sgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create slice graphics
|
||||
*
|
||||
* @param data Data array - 3D
|
||||
* @param xa X coordinate array - 1D
|
||||
* @param ya Y coordinate array - 1D
|
||||
* @param za Z coordinate array - 1D
|
||||
* @param xSlice X slice list
|
||||
* @param ySlice Y slice list
|
||||
* @param zSlice Z slice list
|
||||
* @param transferFunction Transfer function
|
||||
* @return Surface graphics
|
||||
*/
|
||||
public static List<SurfaceGraphic> slice(Array data, Array xa, Array ya, Array za, List<Number> xSlice,
|
||||
List<Number> ySlice, List<Number> zSlice, TransferFunction transferFunction) throws InvalidRangeException {
|
||||
data = data.copyIfView();
|
||||
xa = xa.copyIfView();
|
||||
ya = ya.copyIfView();
|
||||
za = za.copyIfView();
|
||||
|
||||
List<SurfaceGraphic> sgs = new ArrayList<>();
|
||||
|
||||
int dim1, dim2;
|
||||
float x, y, z;
|
||||
int idx;
|
||||
|
||||
//X slices
|
||||
dim1 = (int) za.getSize();
|
||||
dim2 = (int) ya.getSize();
|
||||
for (int s = 0; s < xSlice.size(); s++) {
|
||||
x = xSlice.get(s).floatValue();
|
||||
Array r = ArrayUtil.slice(data, 2, xa, x);
|
||||
if (r != null) {
|
||||
Index index = r.getIndex();
|
||||
SurfaceGraphic graphic = new SurfaceGraphic();
|
||||
float[] vertexPosition = new float[dim1 * dim2 * 3];
|
||||
float[] vertexValue = new float[dim1 * dim2];
|
||||
for (int i = 0; i < dim1; i++) {
|
||||
z = za.getFloat(i);
|
||||
for (int j = 0; j < dim2; j++) {
|
||||
y = ya.getFloat(j);
|
||||
idx = i * dim2 +j;
|
||||
vertexValue[idx] = r.getFloat(index.set(i, j));
|
||||
idx = idx * 3;
|
||||
vertexPosition[idx] = x;
|
||||
vertexPosition[idx+1] = y;
|
||||
vertexPosition[idx+2] = z;
|
||||
}
|
||||
}
|
||||
graphic.setVertexPosition(vertexPosition, dim1);
|
||||
graphic.setVertexValue(vertexValue);
|
||||
graphic.setTransferFunction(transferFunction);
|
||||
sgs.add(graphic);
|
||||
}
|
||||
}
|
||||
|
||||
//Y slices
|
||||
dim1 = (int) za.getSize();
|
||||
dim2 = (int) xa.getSize();
|
||||
for (int s = 0; s < ySlice.size(); s++) {
|
||||
y = ySlice.get(s).floatValue();
|
||||
Array r = ArrayUtil.slice(data, 1, ya, y);
|
||||
if (r != null) {
|
||||
Index index = r.getIndex();
|
||||
SurfaceGraphic graphic = new SurfaceGraphic();
|
||||
float[] vertexPosition = new float[dim1 * dim2 * 3];
|
||||
float[] vertexValue = new float[dim1 * dim2];
|
||||
for (int i = 0; i < dim1; i++) {
|
||||
z = za.getFloat(i);
|
||||
for (int j = 0; j < dim2; j++) {
|
||||
x = xa.getFloat(j);
|
||||
idx = i * dim2 +j;
|
||||
vertexValue[idx] = r.getFloat(index.set(i, j));
|
||||
idx = idx * 3;
|
||||
vertexPosition[idx] = x;
|
||||
vertexPosition[idx+1] = y;
|
||||
vertexPosition[idx+2] = z;
|
||||
}
|
||||
}
|
||||
graphic.setVertexPosition(vertexPosition, dim1);
|
||||
graphic.setVertexValue(vertexValue);
|
||||
graphic.setTransferFunction(transferFunction);
|
||||
sgs.add(graphic);
|
||||
}
|
||||
}
|
||||
|
||||
//Z slices
|
||||
dim1 = (int) ya.getSize();
|
||||
dim2 = (int) xa.getSize();
|
||||
for (int s = 0; s < zSlice.size(); s++) {
|
||||
z = zSlice.get(s).floatValue();
|
||||
Array r = ArrayUtil.slice(data, 0, za, z);
|
||||
if (r != null) {
|
||||
Index index = r.getIndex();
|
||||
SurfaceGraphic graphic = new SurfaceGraphic();
|
||||
float[] vertexPosition = new float[dim1 * dim2 * 3];
|
||||
float[] vertexValue = new float[dim1 * dim2];
|
||||
for (int i = 0; i < dim1; i++) {
|
||||
y = ya.getFloat(i);
|
||||
for (int j = 0; j < dim2; j++) {
|
||||
x = xa.getFloat(j);
|
||||
idx = i * dim2 +j;
|
||||
vertexValue[idx] = r.getFloat(index.set(i, j));
|
||||
idx = idx * 3;
|
||||
vertexPosition[idx] = x;
|
||||
vertexPosition[idx+1] = y;
|
||||
vertexPosition[idx+2] = z;
|
||||
}
|
||||
}
|
||||
graphic.setVertexPosition(vertexPosition, dim1);
|
||||
graphic.setVertexValue(vertexValue);
|
||||
graphic.setTransferFunction(transferFunction);
|
||||
sgs.add(graphic);
|
||||
}
|
||||
}
|
||||
|
||||
return sgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create xy slice graphics
|
||||
*
|
||||
@ -7616,4 +7737,184 @@ public class GraphicFactory {
|
||||
return meshGraphic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create volume graphics
|
||||
*
|
||||
* @param data 3d data array
|
||||
* @param xa X coordinates
|
||||
* @param ya Y coordinates
|
||||
* @param za Z coordinates
|
||||
* @param colorMap ColorMap
|
||||
* @param vMin Min value
|
||||
* @param vMax Max value
|
||||
* @param alphaMin Min alpha
|
||||
* @param alphaMax Max alpha
|
||||
* @return Particles
|
||||
*/
|
||||
public static GraphicCollection volume(Array data, Array xa, Array ya, Array za, ColorMap colorMap,
|
||||
double vMin, double vMax, float alphaMin, float alphaMax) {
|
||||
data = data.copyIfView();
|
||||
xa = xa.copyIfView();
|
||||
ya = ya.copyIfView();
|
||||
za = za.copyIfView();
|
||||
|
||||
VolumeGraphic graphics = new VolumeGraphic(data, colorMap, vMin, vMax);
|
||||
graphics.setAlphaMin(alphaMin);
|
||||
graphics.setAlphaMax(alphaMax);
|
||||
graphics.updateColors();
|
||||
|
||||
Extent3D extent3D = new Extent3D();
|
||||
extent3D.minX = xa.getDouble(0);
|
||||
extent3D.maxX = xa.getDouble((int) xa.getSize() - 1);
|
||||
extent3D.minY = ya.getDouble(0);
|
||||
extent3D.maxY = ya.getDouble((int) ya.getSize() - 1);
|
||||
extent3D.minZ = za.getDouble(0);
|
||||
extent3D.maxZ = za.getDouble((int) za.getSize() - 1);
|
||||
graphics.setExtent(extent3D);
|
||||
|
||||
return graphics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create volume graphics
|
||||
*
|
||||
* @param data 3d data array
|
||||
* @param xa X coordinates
|
||||
* @param ya Y coordinates
|
||||
* @param za Z coordinates
|
||||
* @param colorMap ColorMap
|
||||
* @param alphaMin Min alpha
|
||||
* @param alphaMax Max alpha
|
||||
* @return Particles
|
||||
*/
|
||||
public static GraphicCollection volume(Array data, Array xa, Array ya, Array za, ColorMap colorMap,
|
||||
Normalize norm, float alphaMin, float alphaMax) {
|
||||
data = data.copyIfView();
|
||||
xa = xa.copyIfView();
|
||||
ya = ya.copyIfView();
|
||||
za = za.copyIfView();
|
||||
|
||||
VolumeGraphic graphics = new VolumeGraphic(data, colorMap, norm);
|
||||
graphics.setAlphaMin(alphaMin);
|
||||
graphics.setAlphaMax(alphaMax);
|
||||
graphics.updateColors();
|
||||
|
||||
Extent3D extent3D = new Extent3D();
|
||||
extent3D.minX = xa.getDouble(0);
|
||||
extent3D.maxX = xa.getDouble((int) xa.getSize() - 1);
|
||||
extent3D.minY = ya.getDouble(0);
|
||||
extent3D.maxY = ya.getDouble((int) ya.getSize() - 1);
|
||||
extent3D.minZ = za.getDouble(0);
|
||||
extent3D.maxZ = za.getDouble((int) za.getSize() - 1);
|
||||
graphics.setExtent(extent3D);
|
||||
|
||||
return graphics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create volume graphics
|
||||
*
|
||||
* @param data 3d data array
|
||||
* @param xa X coordinates
|
||||
* @param ya Y coordinates
|
||||
* @param za Z coordinates
|
||||
* @param colorMap ColorMap
|
||||
* @param norm Normalize
|
||||
* @param opacityNodes Opacity nodes
|
||||
* @param opacityLevels Opacity levels
|
||||
* @return Volume graphics
|
||||
*/
|
||||
public static GraphicCollection volume(Array data, Array xa, Array ya, Array za, ColorMap colorMap,
|
||||
Normalize norm, List<Number> opacityNodes, List<Number> opacityLevels) {
|
||||
OpacityTransferFunction opacityTransferFunction = new OpacityTransferFunction(opacityNodes, opacityLevels, norm);
|
||||
return volume(data, xa, ya, za, colorMap, norm, opacityTransferFunction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create volume graphics
|
||||
*
|
||||
* @param data 3d data array
|
||||
* @param xa X coordinates
|
||||
* @param ya Y coordinates
|
||||
* @param za Z coordinates
|
||||
* @param transferFunction Transfer function
|
||||
* @return Volume graphics
|
||||
*/
|
||||
public static GraphicCollection volume(Array data, Array xa, Array ya, Array za,
|
||||
TransferFunction transferFunction) {
|
||||
return volume(data, xa, ya, za, transferFunction.getColorMap(), transferFunction.getNormalize(),
|
||||
transferFunction.getOpacityTransferFunction());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create volume graphics
|
||||
*
|
||||
* @param data 3d data array
|
||||
* @param xa X coordinates
|
||||
* @param ya Y coordinates
|
||||
* @param za Z coordinates
|
||||
* @param colorMap ColorMap
|
||||
* @param norm Normalize
|
||||
* @param opacityTransferFunction Opacity transfer function
|
||||
* @return Volume graphics
|
||||
*/
|
||||
public static GraphicCollection volume(Array data, Array xa, Array ya, Array za, ColorMap colorMap,
|
||||
Normalize norm, OpacityTransferFunction opacityTransferFunction) {
|
||||
data = data.copyIfView();
|
||||
xa = xa.copyIfView();
|
||||
ya = ya.copyIfView();
|
||||
za = za.copyIfView();
|
||||
|
||||
VolumeGraphic graphics = new VolumeGraphic(data, colorMap, norm);
|
||||
graphics.setOpacityTransferFunction(opacityTransferFunction);
|
||||
graphics.updateColors();
|
||||
|
||||
Extent3D extent3D = new Extent3D();
|
||||
extent3D.minX = xa.getDouble(0);
|
||||
extent3D.maxX = xa.getDouble((int) xa.getSize() - 1);
|
||||
extent3D.minY = ya.getDouble(0);
|
||||
extent3D.maxY = ya.getDouble((int) ya.getSize() - 1);
|
||||
extent3D.minZ = za.getDouble(0);
|
||||
extent3D.maxZ = za.getDouble((int) za.getSize() - 1);
|
||||
graphics.setExtent(extent3D);
|
||||
|
||||
return graphics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create volume graphics
|
||||
*
|
||||
* @param data 3d data array
|
||||
* @param xa X coordinates
|
||||
* @param ya Y coordinates
|
||||
* @param za Z coordinates
|
||||
* @param ls LegendScheme
|
||||
* @param alphaMin Min alpha
|
||||
* @param alphaMax Max alpha
|
||||
* @return Particles
|
||||
*/
|
||||
public static GraphicCollection volume(Array data, Array xa, Array ya, Array za, LegendScheme ls,
|
||||
float alphaMin, float alphaMax) {
|
||||
data = data.copyIfView();
|
||||
xa = xa.copyIfView();
|
||||
ya = ya.copyIfView();
|
||||
za = za.copyIfView();
|
||||
|
||||
VolumeGraphic graphics = new VolumeGraphic(data, ls);
|
||||
graphics.setAlphaMin(alphaMin);
|
||||
graphics.setAlphaMax(alphaMax);
|
||||
graphics.updateColors();
|
||||
|
||||
Extent3D extent3D = new Extent3D();
|
||||
extent3D.minX = xa.getDouble(0);
|
||||
extent3D.maxX = xa.getDouble((int) xa.getSize() - 1);
|
||||
extent3D.minY = ya.getDouble(0);
|
||||
extent3D.maxY = ya.getDouble((int) ya.getSize() - 1);
|
||||
extent3D.minZ = za.getDouble(0);
|
||||
extent3D.maxZ = za.getDouble((int) za.getSize() - 1);
|
||||
graphics.setExtent(extent3D);
|
||||
|
||||
return graphics;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,8 +4,14 @@ import com.jogamp.opengl.util.texture.Texture;
|
||||
import org.joml.Vector3f;
|
||||
import org.meteoinfo.chart.jogl.Transform;
|
||||
import org.meteoinfo.common.Extent3D;
|
||||
import org.meteoinfo.common.MIMath;
|
||||
import org.meteoinfo.common.colors.ColorMap;
|
||||
import org.meteoinfo.geo.legend.LegendManage;
|
||||
import org.meteoinfo.geometry.colors.Normalize;
|
||||
import org.meteoinfo.geometry.colors.TransferFunction;
|
||||
import org.meteoinfo.geometry.legend.ColorBreak;
|
||||
import org.meteoinfo.geometry.legend.LegendScheme;
|
||||
import org.meteoinfo.geometry.shape.ShapeTypes;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
@ -302,27 +308,6 @@ public class SurfaceGraphic extends GraphicCollection3D {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update vertex indices
|
||||
*/
|
||||
public void updateVertexIndices_bak() {
|
||||
int n = (rows - 1) * (columns - 1) * 6;
|
||||
vertexIndices = new int[n];
|
||||
int idx, vIdx;
|
||||
for (int i = 0; i < rows - 1; i++) {
|
||||
for (int j = 0; j < columns - 1; j++) {
|
||||
vIdx = i * columns + j;
|
||||
idx = (i * (columns - 1) + j) * 6;
|
||||
vertexIndices[idx] = vIdx;
|
||||
vertexIndices[idx + 1] = vIdx + 1;
|
||||
vertexIndices[idx + 2] = vIdx + 1 + columns;
|
||||
vertexIndices[idx + 3] = vIdx + 1 + columns;
|
||||
vertexIndices[idx + 4] = vIdx + columns;
|
||||
vertexIndices[idx + 5] = vIdx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLegendScheme(LegendScheme ls) {
|
||||
super.setLegendScheme(ls);
|
||||
@ -343,6 +328,25 @@ public class SurfaceGraphic extends GraphicCollection3D {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set transfer function
|
||||
* @param transferFunction Transfer function
|
||||
*/
|
||||
public void setTransferFunction(TransferFunction transferFunction) {
|
||||
if (vertexValue != null) {
|
||||
vertexColor = new float[getVertexNumber() * 4];
|
||||
float[] color;
|
||||
for (int i = 0; i < vertexValue.length; i++) {
|
||||
color = transferFunction.getColor(vertexValue[i]).getRGBComponents(null);
|
||||
System.arraycopy(color, 0, vertexColor, i * 4, 4);
|
||||
}
|
||||
}
|
||||
|
||||
LegendScheme ls = LegendManage.createLegendScheme(transferFunction);
|
||||
this.legendScheme = ls;
|
||||
this.setSingleLegend(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update vertex texture data
|
||||
*/
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
package org.meteoinfo.chart.graphic;
|
||||
|
||||
import org.meteoinfo.chart.jogl.Transform;
|
||||
import org.meteoinfo.geometry.colors.TransferFunction;
|
||||
import org.meteoinfo.geometry.colors.OpacityTransferFunction;
|
||||
import org.meteoinfo.chart.render.jogl.RayCastingType;
|
||||
import org.meteoinfo.common.Extent3D;
|
||||
import org.meteoinfo.common.MIMath;
|
||||
import org.meteoinfo.common.colors.ColorMap;
|
||||
import org.meteoinfo.geo.legend.LegendManage;
|
||||
import org.meteoinfo.geometry.colors.Normalize;
|
||||
import org.meteoinfo.geometry.colors.TransferFunction;
|
||||
import org.meteoinfo.geometry.legend.LegendScheme;
|
||||
import org.meteoinfo.geometry.shape.ShapeTypes;
|
||||
import org.meteoinfo.ndarray.Array;
|
||||
@ -28,8 +29,6 @@ public class VolumeGraphic extends GraphicCollection3D {
|
||||
private byte[] colors;
|
||||
private byte[] originalColors;
|
||||
private TransferFunction transferFunction = new TransferFunction();
|
||||
private Normalize normalize;
|
||||
private ColorMap colorMap;
|
||||
private float[] opacityLevels = new float[]{0, 1};
|
||||
private float[] opacityNodes = new float[]{0f, 1f};
|
||||
private float[] colorRange = new float[]{0f, 1f};
|
||||
@ -72,7 +71,7 @@ public class VolumeGraphic extends GraphicCollection3D {
|
||||
* @param vMax Maximum value
|
||||
*/
|
||||
public VolumeGraphic(Array value, ColorMap colorMap, double vMin, double vMax) {
|
||||
this.colorMap = colorMap;
|
||||
this.transferFunction.setColorMap(colorMap);
|
||||
|
||||
value = value.copyIfView();
|
||||
int[] shape = value.getShape();
|
||||
@ -159,10 +158,7 @@ public class VolumeGraphic extends GraphicCollection3D {
|
||||
* @param colorMap Color map
|
||||
*/
|
||||
public void setColorMap(ColorMap colorMap) {
|
||||
if (this.normalize == null) {
|
||||
this.normalize = new Normalize();
|
||||
}
|
||||
setColorMap(colorMap, this.normalize);
|
||||
setColorMap(colorMap, this.transferFunction.getNormalize());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -171,8 +167,8 @@ public class VolumeGraphic extends GraphicCollection3D {
|
||||
* @param norm Normalize
|
||||
*/
|
||||
public void setColorMap(ColorMap colorMap, Normalize norm) {
|
||||
this.colorMap = colorMap;
|
||||
this.normalize = norm;
|
||||
this.transferFunction.setColorMap(colorMap);
|
||||
this.transferFunction.setNormalize(norm);
|
||||
|
||||
Color[] oColors = colorMap.getColors();
|
||||
int n = oColors.length;
|
||||
@ -203,7 +199,7 @@ public class VolumeGraphic extends GraphicCollection3D {
|
||||
for (int i = 0; i < n; i++) {
|
||||
float px = ((float) i) / n;
|
||||
float a;
|
||||
a = this.transferFunction.getOpacity(px);
|
||||
a = this.transferFunction.getOpacityTransferFunction().getOpacity(px);
|
||||
/*if (px <= opacityNodes[0]) {
|
||||
a = opacityNodes[0];
|
||||
} else if (px > opacityNodes[1]) {
|
||||
@ -304,21 +300,57 @@ public class VolumeGraphic extends GraphicCollection3D {
|
||||
this.opacityNodes[1] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set opacity transfer function
|
||||
* @param value Opacity transfer function
|
||||
*/
|
||||
public void setOpacityTransferFunction(OpacityTransferFunction value) {
|
||||
this.transferFunction.setOpacityTransferFunction(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set opacity transfer function
|
||||
* @param opacityNodes Opacity nodes
|
||||
* @param opacityLevels Opacity levels
|
||||
*/
|
||||
public void setOpacityTransferFunction(List<Number> opacityNodes, List<Number> opacityLevels) {
|
||||
this.transferFunction.setOpacityTransferFunction(new OpacityTransferFunction(opacityNodes, opacityLevels));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get transfer function
|
||||
* @return Transfer function
|
||||
*/
|
||||
public TransferFunction getTransferFunction() {
|
||||
return this.transferFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set transfer function
|
||||
* @param value Transfer function
|
||||
*/
|
||||
public void setTransferFunction(TransferFunction value) {
|
||||
this.transferFunction = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set transfer function
|
||||
* @param opacityNodes Opacity nodes
|
||||
* @param opacityLevels Opacity levels
|
||||
*/
|
||||
public void setTransferFunction(List<Number> opacityNodes, List<Number> opacityLevels) {
|
||||
this.transferFunction = new TransferFunction(opacityNodes, opacityLevels);
|
||||
ColorMap colorMap = this.transferFunction.getColorMap();
|
||||
Color[] oColors = colorMap.getColors();
|
||||
int n = oColors.length;
|
||||
originalColors = new byte[n * 3];
|
||||
for (int i = 0; i < n; i++) {
|
||||
int color = oColors[i].getRGB();
|
||||
originalColors[i * 3 + 0] = (byte) ((color >> 16) & 0xff);
|
||||
originalColors[i * 3 + 1] = (byte) ((color >> 8) & 0xff);
|
||||
originalColors[i * 3 + 2] = (byte) ((color) & 0xff);
|
||||
}
|
||||
|
||||
Normalize norm = this.transferFunction.getNormalize();
|
||||
double[] values = MIMath.getIntervalValues(norm.getMinValue(), norm.getMaxValue(), n - 1);
|
||||
LegendScheme ls = LegendManage.createGraduatedLegendScheme(values, oColors, ShapeTypes.POLYGON,
|
||||
norm.getMinValue(), norm.getMaxValue());
|
||||
ls.setColorMap(colorMap);
|
||||
ls.setNormalize(norm);
|
||||
this.setLegendScheme(ls);
|
||||
this.setSingleLegend(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -126,6 +126,30 @@ public class EarthPlot3D extends Plot3DGL {
|
||||
this.setDrawExtent((Extent3D) this.graphicExtent.clone());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a graphic
|
||||
*
|
||||
* @param index The index
|
||||
* @param graphic The graphic
|
||||
*/
|
||||
@Override
|
||||
public void addGraphic(int index, Graphic graphic) {
|
||||
if (this.dataExtent == null) {
|
||||
this.dataExtent = (Extent3D) graphic.getExtent();
|
||||
} else {
|
||||
this.dataExtent = this.dataExtent.union((Extent3D) graphic.getExtent());
|
||||
}
|
||||
updateDataExtent();
|
||||
|
||||
this.graphics.add(index, SphericalTransform.transform(graphic));
|
||||
Extent ex = this.graphics.getExtent();
|
||||
if (!ex.is3D()) {
|
||||
ex = ex.to3D();
|
||||
}
|
||||
this.graphicExtent = (Extent3D) ex;
|
||||
this.setDrawExtent((Extent3D) this.graphicExtent.clone());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a graphic
|
||||
*
|
||||
@ -142,6 +166,23 @@ public class EarthPlot3D extends Plot3DGL {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a graphic
|
||||
*
|
||||
* @param index The index
|
||||
* @param graphic The graphic
|
||||
* @param proj The graphic projection
|
||||
*/
|
||||
@Override
|
||||
public void addGraphic(int index, Graphic graphic, ProjectionInfo proj) {
|
||||
if (! proj.equals(this.projInfo)) {
|
||||
Graphic nGraphic = ProjectionUtil.projectGraphic(graphic, proj, this.projInfo);
|
||||
addGraphic(index, nGraphic);
|
||||
} else {
|
||||
addGraphic(index, graphic);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set earth surface
|
||||
* @param n The sphere has n*n faces
|
||||
|
||||
@ -34,10 +34,10 @@ public class GLForm extends JFrame{
|
||||
}
|
||||
});
|
||||
|
||||
glcp.animator_start();
|
||||
//glcp.animator_start();
|
||||
}
|
||||
|
||||
private void formWindowClosing() {
|
||||
glcp.animator_stop();
|
||||
//glcp.animator_stop();
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ import org.joml.Vector3f;
|
||||
import org.meteoinfo.chart.graphic.*;
|
||||
import org.meteoinfo.chart.jogl.mc.CallbackMC;
|
||||
import org.meteoinfo.chart.jogl.mc.MarchingCubes;
|
||||
import org.meteoinfo.geometry.colors.TransferFunction;
|
||||
import org.meteoinfo.geometry.colors.OpacityTransferFunction;
|
||||
import org.meteoinfo.chart.shape.TextureShape;
|
||||
import org.meteoinfo.common.Extent;
|
||||
import org.meteoinfo.common.Extent3D;
|
||||
@ -914,7 +914,7 @@ public class JOGLUtil {
|
||||
*/
|
||||
public static GraphicCollection volume(Array data, Array xa, Array ya, Array za, ColorMap colorMap,
|
||||
Normalize norm, List<Number> opacityNodes, List<Number> opacityLevels) {
|
||||
TransferFunction transferFunction = new TransferFunction(opacityNodes, opacityLevels, norm);
|
||||
OpacityTransferFunction transferFunction = new OpacityTransferFunction(opacityNodes, opacityLevels, norm);
|
||||
return volume(data, xa, ya, za, colorMap, norm, transferFunction);
|
||||
}
|
||||
|
||||
@ -931,14 +931,14 @@ public class JOGLUtil {
|
||||
* @return Volume graphics
|
||||
*/
|
||||
public static GraphicCollection volume(Array data, Array xa, Array ya, Array za, ColorMap colorMap,
|
||||
Normalize norm, TransferFunction transferFunction) {
|
||||
Normalize norm, OpacityTransferFunction transferFunction) {
|
||||
data = data.copyIfView();
|
||||
xa = xa.copyIfView();
|
||||
ya = ya.copyIfView();
|
||||
za = za.copyIfView();
|
||||
|
||||
VolumeGraphic graphics = new VolumeGraphic(data, colorMap, norm);
|
||||
graphics.setTransferFunction(transferFunction);
|
||||
graphics.setOpacityTransferFunction(transferFunction);
|
||||
graphics.updateColors();
|
||||
|
||||
Extent3D extent3D = new Extent3D();
|
||||
|
||||
@ -69,6 +69,23 @@ public class MapPlot3D extends Plot3DGL {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a graphic
|
||||
*
|
||||
* @param index The index
|
||||
* @param graphic The graphic
|
||||
* @param proj The graphic projection
|
||||
*/
|
||||
@Override
|
||||
public void addGraphic(int index, Graphic graphic, ProjectionInfo proj) {
|
||||
if (proj.equals(this.projInfo)) {
|
||||
super.addGraphic(index, graphic);
|
||||
} else {
|
||||
Graphic nGraphic = ProjectionUtil.projectClipGraphic(graphic, proj, this.projInfo);
|
||||
super.addGraphic(index, nGraphic);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set draw extent
|
||||
*
|
||||
|
||||
@ -1061,6 +1061,25 @@ public class Plot3DGL extends Plot implements GLEventListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a graphic
|
||||
*
|
||||
* @param index Index
|
||||
* @param graphic Graphic
|
||||
*/
|
||||
public void addGraphic(int index, Graphic graphic) {
|
||||
this.graphics.add(index, graphic);
|
||||
Extent ex = this.graphics.getExtent();
|
||||
if (!ex.is3D()) {
|
||||
ex = ex.to3D();
|
||||
}
|
||||
this.graphicExtent = (Extent3D) ex;
|
||||
if (!fixExtent) {
|
||||
this.setAxesExtent((Extent3D) graphicExtent.clone());
|
||||
this.setDrawExtent((Extent3D) this.graphicExtent.clone());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a graphic
|
||||
*
|
||||
@ -1076,6 +1095,22 @@ public class Plot3DGL extends Plot implements GLEventListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a graphic
|
||||
*
|
||||
* @param index The index
|
||||
* @param graphic The graphic
|
||||
* @param proj The graphic projection
|
||||
*/
|
||||
public void addGraphic(int index, Graphic graphic, ProjectionInfo proj) {
|
||||
if (this.projInfo == null || proj.equals(this.projInfo)) {
|
||||
addGraphic(index, graphic);
|
||||
} else {
|
||||
Graphic nGraphic = ProjectionUtil.projectGraphic(graphic, proj, this.projInfo);
|
||||
addGraphic(index, nGraphic);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a graphic
|
||||
*
|
||||
|
||||
@ -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.3.12";
|
||||
version = "3.3.13";
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
@ -19,6 +19,8 @@ import org.meteoinfo.data.GridArray;
|
||||
import org.meteoinfo.data.GridData;
|
||||
import org.meteoinfo.data.StationData;
|
||||
import org.meteoinfo.geo.drawing.ContourDraw;
|
||||
import org.meteoinfo.geometry.colors.Normalize;
|
||||
import org.meteoinfo.geometry.colors.TransferFunction;
|
||||
import org.meteoinfo.geometry.legend.*;
|
||||
import org.meteoinfo.ndarray.util.BigDecimalUtil;
|
||||
import org.meteoinfo.geometry.shape.ShapeTypes;
|
||||
@ -1392,6 +1394,26 @@ public class LegendManage {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create legend scheme by transfer function
|
||||
*
|
||||
* @param transferFunction Transfer function
|
||||
* @return Legend scheme
|
||||
*/
|
||||
public static LegendScheme createLegendScheme(TransferFunction transferFunction) {
|
||||
ColorMap colorMap = transferFunction.getColorMap();
|
||||
Color[] colors = colorMap.getColors();
|
||||
int n = colors.length;
|
||||
Normalize norm = transferFunction.getNormalize();
|
||||
double[] values = MIMath.getIntervalValues(norm.getMinValue(), norm.getMaxValue(), n - 1);
|
||||
LegendScheme ls = LegendManage.createGraduatedLegendScheme(values, colors, ShapeTypes.POLYGON,
|
||||
norm.getMinValue(), norm.getMaxValue());
|
||||
ls.setColorMap(colorMap);
|
||||
ls.setNormalize(norm);
|
||||
|
||||
return ls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create image legend from grid data
|
||||
*
|
||||
|
||||
@ -1,110 +0,0 @@
|
||||
package org.meteoinfo.geometry.colors;
|
||||
|
||||
import org.meteoinfo.common.colors.ColorMap;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class ColorTransferFunction {
|
||||
private TransferFunction transferFunction;
|
||||
private ColorMap colorMap;
|
||||
private Normalize normalize;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param transferFunction Transfer function
|
||||
* @param colorMap Color map
|
||||
* @param normalize Normalize
|
||||
*/
|
||||
public ColorTransferFunction(TransferFunction transferFunction, ColorMap colorMap, Normalize normalize) {
|
||||
this.transferFunction = transferFunction;
|
||||
this.colorMap = colorMap;
|
||||
this.normalize = normalize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param transferFunction Transfer function
|
||||
* @param colorMap Color map
|
||||
*/
|
||||
public ColorTransferFunction(TransferFunction transferFunction, ColorMap colorMap) {
|
||||
this(transferFunction, colorMap, new Normalize());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param colorMap Color map
|
||||
* @param normalize Normalize
|
||||
*/
|
||||
public ColorTransferFunction(ColorMap colorMap, Normalize normalize) {
|
||||
this(new TransferFunction(), colorMap, normalize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param colorMap Color map
|
||||
*/
|
||||
public ColorTransferFunction(ColorMap colorMap) {
|
||||
this(colorMap, new Normalize());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get transfer function
|
||||
* @return Transfer function
|
||||
*/
|
||||
public TransferFunction getTransferFunction() {
|
||||
return this.transferFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set transfer function
|
||||
* @param value Transfer function
|
||||
*/
|
||||
public void setTransferFunction(TransferFunction value) {
|
||||
this.transferFunction = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get color map
|
||||
* @return Color map
|
||||
*/
|
||||
public ColorMap getColorMap() {
|
||||
return this.colorMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set color map
|
||||
* @param value Color map
|
||||
*/
|
||||
public void setColorMap(ColorMap value) {
|
||||
this.colorMap = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get normalize
|
||||
* @return Normalize
|
||||
*/
|
||||
public Normalize getNormalize() {
|
||||
return this.normalize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set normalize
|
||||
* @param value Normalize
|
||||
*/
|
||||
public void setNormalize(Normalize value) {
|
||||
this.normalize = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get color with a data value
|
||||
* @param v The data value
|
||||
* @return The color
|
||||
*/
|
||||
public Color getColor(double v) {
|
||||
float ratio = this.normalize.apply(v).floatValue();
|
||||
Color c = this.colorMap.getColor(ratio);
|
||||
float alpha = this.transferFunction.getOpacity(ratio);
|
||||
|
||||
return new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) alpha * 255);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,209 @@
|
||||
package org.meteoinfo.geometry.colors;
|
||||
|
||||
import org.meteoinfo.geometry.colors.Normalize;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class OpacityTransferFunction {
|
||||
private float[] opacityLevels;
|
||||
private float[] opacityNodes;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public OpacityTransferFunction() {
|
||||
opacityLevels = new float[]{0.0f, 1.0f};
|
||||
opacityNodes = new float[]{0.0f, 1.0f};
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param opacityNodes Opacity nodes
|
||||
* @param opacityLevels Opacity levels
|
||||
*/
|
||||
public OpacityTransferFunction(List<Number> opacityNodes, List<Number> opacityLevels) {
|
||||
this.opacityNodes = new float[opacityNodes.size()];
|
||||
this.opacityLevels = new float[opacityLevels.size()];
|
||||
for (int i = 0; i < this.opacityNodes.length; i++) {
|
||||
this.opacityNodes[i] = opacityNodes.get(i).floatValue();
|
||||
this.opacityLevels[i] = opacityLevels.get(i).floatValue();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param opacityNodes Opacity nodes
|
||||
* @param opacityLevels Opacity levels
|
||||
*/
|
||||
public OpacityTransferFunction(List<Number> opacityNodes, List<Number> opacityLevels, Normalize normalize) {
|
||||
int n = opacityLevels.size();
|
||||
this.opacityNodes = new float[n];
|
||||
this.opacityLevels = new float[n];
|
||||
if (opacityNodes == null) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
this.opacityNodes[i] = (float) i / (n - 1);
|
||||
this.opacityLevels[i] = opacityLevels.get(i).floatValue();
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < n; i++) {
|
||||
this.opacityNodes[i] = normalize.apply(opacityNodes.get(i).doubleValue()).floatValue();
|
||||
this.opacityLevels[i] = opacityLevels.get(i).floatValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get opacity nodes
|
||||
* @return Opacity nodes
|
||||
*/
|
||||
public float[] getOpacityNodes() {
|
||||
return opacityNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set opacity nodes
|
||||
* @param opacityNodes Opacity nodes
|
||||
*/
|
||||
public void setOpacityNodes(float[] opacityNodes) {
|
||||
this.opacityNodes = opacityNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get opacity levels
|
||||
* @return Opacity levels
|
||||
*/
|
||||
public float[] getOpacityLevels() {
|
||||
return opacityLevels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set opacity levels
|
||||
* @param opacityLevels Opacity levels
|
||||
*/
|
||||
public void setOpacityLevels(float[] opacityLevels) {
|
||||
this.opacityLevels = opacityLevels;
|
||||
}
|
||||
|
||||
public int getNodeIndex(float node) {
|
||||
int idx = -1;
|
||||
for (int i = 0; i < opacityNodes.length; i++) {
|
||||
if (node < opacityNodes[i]) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (idx == -1)
|
||||
idx = opacityNodes.length;
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get opacity node
|
||||
* @param i Index
|
||||
* @return Opacity node
|
||||
*/
|
||||
public float getNode(int i) {
|
||||
return opacityNodes[i];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get opacity level
|
||||
* @param i Index
|
||||
* @return Opacity level
|
||||
*/
|
||||
public float getLevel(int i) {
|
||||
return opacityLevels[i];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get opacity levels size
|
||||
* @return Opacity levels size
|
||||
*/
|
||||
public int size() {
|
||||
return this.opacityLevels.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get opacity
|
||||
* @param nodeValue The node value
|
||||
* @return Opacity
|
||||
*/
|
||||
public float getOpacity(float nodeValue) {
|
||||
int idx = getNodeIndex(nodeValue);
|
||||
int n = size();
|
||||
if (idx == 0) {
|
||||
return opacityLevels[idx];
|
||||
} else if (idx == n) {
|
||||
return opacityLevels[n - 1];
|
||||
} else {
|
||||
float node1 = opacityNodes[idx - 1];
|
||||
float node2 = opacityNodes[idx];
|
||||
float level1 = opacityLevels[idx - 1];
|
||||
float level2 = opacityLevels[idx];
|
||||
float level = level1 + (nodeValue - node1) / (node2 - node1) * (level2 - level1);
|
||||
return level;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get colors
|
||||
* @param colors Origin colors
|
||||
* @return New colors
|
||||
*/
|
||||
public byte[] getColors(Color[] colors) {
|
||||
int n = colors.length;
|
||||
byte[] nColors = new byte[n * 4];
|
||||
float node, a;
|
||||
Color color;
|
||||
int r, g, b;
|
||||
for (int i = 0; i < n; i++) {
|
||||
node = (float) i / (float) (n - 1);
|
||||
a = getOpacity(node);
|
||||
color = colors[i];
|
||||
r = color.getRed();
|
||||
g = color.getGreen();
|
||||
b = color.getBlue();
|
||||
nColors[i * 4 + 0] = (byte) r;
|
||||
nColors[i * 4 + 1] = (byte) g;
|
||||
nColors[i * 4 + 2] = (byte) b;
|
||||
nColors[i * 4 + 3] = (byte) Math.round(a * 255);
|
||||
}
|
||||
|
||||
return nColors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get colors
|
||||
* @param colors Origin colors
|
||||
* @return New colors
|
||||
*/
|
||||
public byte[] getColors(byte[] colors) {
|
||||
int n = colors.length / 3;
|
||||
byte[] nColors = new byte[n * 4];
|
||||
float node, a;
|
||||
|
||||
float r, g, b;
|
||||
for (int i = 0; i < n; i++) {
|
||||
node = (float) i / (float) n;
|
||||
a = getOpacity(node);
|
||||
|
||||
r = ((float) Byte.toUnsignedInt(colors[i * 3 + 0])) / 255;
|
||||
g = ((float) Byte.toUnsignedInt(colors[i * 3 + 1])) / 255;
|
||||
b = ((float) Byte.toUnsignedInt(colors[i * 3 + 2])) / 255;
|
||||
|
||||
r = r * r * a;
|
||||
g = g * g * a;
|
||||
b = b * b * a;
|
||||
|
||||
nColors[i * 4 + 0] = (byte) Math.round(r * 255);
|
||||
nColors[i * 4 + 1] = (byte) Math.round(g * 255);
|
||||
nColors[i * 4 + 2] = (byte) Math.round(b * 255);
|
||||
nColors[i * 4 + 3] = (byte) Math.round(a * 255);
|
||||
}
|
||||
|
||||
return nColors;
|
||||
}
|
||||
}
|
||||
@ -1,209 +1,121 @@
|
||||
package org.meteoinfo.geometry.colors;
|
||||
|
||||
import org.meteoinfo.geometry.colors.Normalize;
|
||||
import org.meteoinfo.common.colors.ColorMap;
|
||||
import org.meteoinfo.geometry.legend.LegendScheme;
|
||||
import org.meteoinfo.geometry.shape.ShapeTypes;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TransferFunction {
|
||||
private float[] opacityLevels;
|
||||
private float[] opacityNodes;
|
||||
private OpacityTransferFunction opacityTransferFunction;
|
||||
private ColorMap colorMap;
|
||||
private Normalize normalize;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public TransferFunction() {
|
||||
opacityLevels = new float[]{0.0f, 1.0f};
|
||||
opacityNodes = new float[]{0.0f, 1.0f};
|
||||
this.opacityTransferFunction = new OpacityTransferFunction();
|
||||
this.normalize = new Normalize();
|
||||
this.colorMap = new ColorMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param opacityNodes Opacity nodes
|
||||
* @param opacityLevels Opacity levels
|
||||
* @param opacityTransferFunction Transfer function
|
||||
* @param colorMap Color map
|
||||
* @param normalize Normalize
|
||||
*/
|
||||
public TransferFunction(List<Number> opacityNodes, List<Number> opacityLevels) {
|
||||
this.opacityNodes = new float[opacityNodes.size()];
|
||||
this.opacityLevels = new float[opacityLevels.size()];
|
||||
for (int i = 0; i < this.opacityNodes.length; i++) {
|
||||
this.opacityNodes[i] = opacityNodes.get(i).floatValue();
|
||||
this.opacityLevels[i] = opacityLevels.get(i).floatValue();
|
||||
}
|
||||
public TransferFunction(OpacityTransferFunction opacityTransferFunction, ColorMap colorMap, Normalize normalize) {
|
||||
this.opacityTransferFunction = opacityTransferFunction;
|
||||
this.colorMap = colorMap;
|
||||
this.normalize = normalize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param opacityNodes Opacity nodes
|
||||
* @param opacityLevels Opacity levels
|
||||
* @param opacityTransferFunction Transfer function
|
||||
* @param colorMap Color map
|
||||
*/
|
||||
public TransferFunction(List<Number> opacityNodes, List<Number> opacityLevels, Normalize normalize) {
|
||||
int n = opacityLevels.size();
|
||||
this.opacityNodes = new float[n];
|
||||
this.opacityLevels = new float[n];
|
||||
if (opacityNodes == null) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
this.opacityNodes[i] = (float) i / (n - 1);
|
||||
this.opacityLevels[i] = opacityLevels.get(i).floatValue();
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < n; i++) {
|
||||
this.opacityNodes[i] = normalize.apply(opacityNodes.get(i).doubleValue()).floatValue();
|
||||
this.opacityLevels[i] = opacityLevels.get(i).floatValue();
|
||||
}
|
||||
}
|
||||
public TransferFunction(OpacityTransferFunction opacityTransferFunction, ColorMap colorMap) {
|
||||
this(opacityTransferFunction, colorMap, new Normalize());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get opacity nodes
|
||||
* @return Opacity nodes
|
||||
* Constructor
|
||||
* @param colorMap Color map
|
||||
* @param normalize Normalize
|
||||
*/
|
||||
public float[] getOpacityNodes() {
|
||||
return opacityNodes;
|
||||
public TransferFunction(ColorMap colorMap, Normalize normalize) {
|
||||
this(new OpacityTransferFunction(), colorMap, normalize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set opacity nodes
|
||||
* @param opacityNodes Opacity nodes
|
||||
* Constructor
|
||||
* @param colorMap Color map
|
||||
*/
|
||||
public void setOpacityNodes(float[] opacityNodes) {
|
||||
this.opacityNodes = opacityNodes;
|
||||
public TransferFunction(ColorMap colorMap) {
|
||||
this(colorMap, new Normalize());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get opacity levels
|
||||
* @return Opacity levels
|
||||
* Get opacity transfer function
|
||||
* @return Opacity transfer function
|
||||
*/
|
||||
public float[] getOpacityLevels() {
|
||||
return opacityLevels;
|
||||
public OpacityTransferFunction getOpacityTransferFunction() {
|
||||
return this.opacityTransferFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set opacity levels
|
||||
* @param opacityLevels Opacity levels
|
||||
* Set opacity transfer function
|
||||
* @param value Opacity transfer function
|
||||
*/
|
||||
public void setOpacityLevels(float[] opacityLevels) {
|
||||
this.opacityLevels = opacityLevels;
|
||||
}
|
||||
|
||||
public int getNodeIndex(float node) {
|
||||
int idx = -1;
|
||||
for (int i = 0; i < opacityNodes.length; i++) {
|
||||
if (node < opacityNodes[i]) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (idx == -1)
|
||||
idx = opacityNodes.length;
|
||||
|
||||
return idx;
|
||||
public void setOpacityTransferFunction(OpacityTransferFunction value) {
|
||||
this.opacityTransferFunction = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get opacity node
|
||||
* @param i Index
|
||||
* @return Opacity node
|
||||
* Get color map
|
||||
* @return Color map
|
||||
*/
|
||||
public float getNode(int i) {
|
||||
return opacityNodes[i];
|
||||
public ColorMap getColorMap() {
|
||||
return this.colorMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get opacity level
|
||||
* @param i Index
|
||||
* @return Opacity level
|
||||
* Set color map
|
||||
* @param value Color map
|
||||
*/
|
||||
public float getLevel(int i) {
|
||||
return opacityLevels[i];
|
||||
public void setColorMap(ColorMap value) {
|
||||
this.colorMap = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get opacity levels size
|
||||
* @return Opacity levels size
|
||||
* Get normalize
|
||||
* @return Normalize
|
||||
*/
|
||||
public int size() {
|
||||
return this.opacityLevels.length;
|
||||
public Normalize getNormalize() {
|
||||
return this.normalize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get opacity
|
||||
* @param nodeValue The node value
|
||||
* @return Opacity
|
||||
* Set normalize
|
||||
* @param value Normalize
|
||||
*/
|
||||
public float getOpacity(float nodeValue) {
|
||||
int idx = getNodeIndex(nodeValue);
|
||||
int n = size();
|
||||
if (idx == 0) {
|
||||
return opacityLevels[idx];
|
||||
} else if (idx == n) {
|
||||
return opacityLevels[n - 1];
|
||||
} else {
|
||||
float node1 = opacityNodes[idx - 1];
|
||||
float node2 = opacityNodes[idx];
|
||||
float level1 = opacityLevels[idx - 1];
|
||||
float level2 = opacityLevels[idx];
|
||||
float level = level1 + (nodeValue - node1) / (node2 - node1) * (level2 - level1);
|
||||
return level;
|
||||
}
|
||||
public void setNormalize(Normalize value) {
|
||||
this.normalize = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get colors
|
||||
* @param colors Origin colors
|
||||
* @return New colors
|
||||
* Get color with a data value
|
||||
* @param v The data value
|
||||
* @return The color
|
||||
*/
|
||||
public byte[] getColors(Color[] colors) {
|
||||
int n = colors.length;
|
||||
byte[] nColors = new byte[n * 4];
|
||||
float node, a;
|
||||
Color color;
|
||||
int r, g, b;
|
||||
for (int i = 0; i < n; i++) {
|
||||
node = (float) i / (float) (n - 1);
|
||||
a = getOpacity(node);
|
||||
color = colors[i];
|
||||
r = color.getRed();
|
||||
g = color.getGreen();
|
||||
b = color.getBlue();
|
||||
nColors[i * 4 + 0] = (byte) r;
|
||||
nColors[i * 4 + 1] = (byte) g;
|
||||
nColors[i * 4 + 2] = (byte) b;
|
||||
nColors[i * 4 + 3] = (byte) Math.round(a * 255);
|
||||
}
|
||||
public Color getColor(double v) {
|
||||
float ratio = this.normalize.apply(v).floatValue();
|
||||
Color c = this.colorMap.map(ratio);
|
||||
float alpha = this.opacityTransferFunction.getOpacity(ratio);
|
||||
|
||||
return nColors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get colors
|
||||
* @param colors Origin colors
|
||||
* @return New colors
|
||||
*/
|
||||
public byte[] getColors(byte[] colors) {
|
||||
int n = colors.length / 3;
|
||||
byte[] nColors = new byte[n * 4];
|
||||
float node, a;
|
||||
|
||||
float r, g, b;
|
||||
for (int i = 0; i < n; i++) {
|
||||
node = (float) i / (float) n;
|
||||
a = getOpacity(node);
|
||||
|
||||
r = ((float) Byte.toUnsignedInt(colors[i * 3 + 0])) / 255;
|
||||
g = ((float) Byte.toUnsignedInt(colors[i * 3 + 1])) / 255;
|
||||
b = ((float) Byte.toUnsignedInt(colors[i * 3 + 2])) / 255;
|
||||
|
||||
r = r * r * a;
|
||||
g = g * g * a;
|
||||
b = b * b * a;
|
||||
|
||||
nColors[i * 4 + 0] = (byte) Math.round(r * 255);
|
||||
nColors[i * 4 + 1] = (byte) Math.round(g * 255);
|
||||
nColors[i * 4 + 2] = (byte) Math.round(b * 255);
|
||||
nColors[i * 4 + 3] = (byte) Math.round(a * 255);
|
||||
}
|
||||
|
||||
return nColors;
|
||||
return new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (alpha * 255));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,34 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\common_math\stats">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\calipso"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\mesh"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\geoshow"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\traj"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\contour">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\taylor"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\stats"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\plot"/>
|
||||
<RecentFolder Folder="D:\Temp\test"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\gui"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\slice"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\contour"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface\isosurface_2.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\volumeplot_2.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\common_math\stats\skew_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\common_math\stats\kurtosis_2.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\plot\plot_JFrame.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\slice\slice_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\slice\slice_3.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface\isosurface_2.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\volumeplot_2.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\common_math\stats\skew_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\common_math\stats\kurtosis_2.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\plot\plot_JFrame.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\slice\slice_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\slice\slice_3.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
|
||||
Binary file not shown.
@ -975,17 +975,25 @@ class Axes(object):
|
||||
self.axes.addGraphic(patch)
|
||||
self.axes.setAutoExtent()
|
||||
|
||||
def add_graphic(self, graphic, projection=None):
|
||||
'''
|
||||
def add_graphic(self, graphic, projection=None, zorder=None):
|
||||
"""
|
||||
Add a graphic
|
||||
|
||||
:param graphic: (*Graphic*) The graphic to be added.
|
||||
:param projection: (*Projection*) The projection
|
||||
'''
|
||||
:param projection: (*Projection*) The projection.
|
||||
:param zorder: (*int*) Z order of the graphic. Default is `None` that the graphic added
|
||||
to the end.
|
||||
"""
|
||||
if projection is None:
|
||||
self.axes.addGraphic(graphic)
|
||||
if zorder is None:
|
||||
self.axes.addGraphic(graphic)
|
||||
else:
|
||||
self.axes.addGraphic(zorder, graphic)
|
||||
else:
|
||||
self.axes.addGraphic(graphic, projection)
|
||||
if zorder is None:
|
||||
self.axes.addGraphic(graphic, projection)
|
||||
else:
|
||||
self.axes.addGraphic(zorder, graphic, projection)
|
||||
|
||||
def get_graphics(self):
|
||||
'''
|
||||
@ -1277,11 +1285,12 @@ class Axes(object):
|
||||
self.axes.getAxis(Location.TOP).setTimeFormat(timetickformat)
|
||||
|
||||
#Add graphics
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
iscurve = kwargs.pop('iscurve', False)
|
||||
graphics = []
|
||||
if isxylistdata:
|
||||
graphic = GraphicFactory.createLineString(dataset, lines)
|
||||
self.add_graphic(graphic)
|
||||
self.add_graphic(graphic, zorder=zorder)
|
||||
graphics.append(graphic)
|
||||
else:
|
||||
if zvalues is None:
|
||||
@ -1305,7 +1314,7 @@ class Axes(object):
|
||||
graphic = GraphicFactory.createLineString(xdata, ydata, lines[0], iscurve)
|
||||
else: #>1
|
||||
graphic = GraphicFactory.createLineString(xdata, ydata, lines, iscurve)
|
||||
self.add_graphic(graphic)
|
||||
self.add_graphic(graphic, zorder=zorder)
|
||||
graphics.append(graphic)
|
||||
else:
|
||||
for i in range(0, snum):
|
||||
@ -1320,7 +1329,7 @@ class Axes(object):
|
||||
ydata = plotutil.getplotdata(ydatalist[0])
|
||||
zdata = plotutil.getplotdata(zvalues)
|
||||
graphic = GraphicFactory.createLineString(xdata, ydata, zdata, ls, iscurve)
|
||||
self.add_graphic(graphic)
|
||||
self.add_graphic(graphic, zorder=zorder)
|
||||
graphics.append(graphic)
|
||||
self.axes.setAutoExtent()
|
||||
|
||||
@ -1330,7 +1339,7 @@ class Axes(object):
|
||||
return graphics[0]
|
||||
|
||||
def step(self, x, y, *args, **kwargs):
|
||||
'''
|
||||
"""
|
||||
Make a step plot.
|
||||
|
||||
:param x: (*array_like*) Input x data.
|
||||
@ -1342,7 +1351,7 @@ class Axes(object):
|
||||
If ‘mid’, the jumps in y occur half-way between the x-values.
|
||||
|
||||
:returns: Step lines
|
||||
'''
|
||||
"""
|
||||
label = kwargs.pop('label', 'S_0')
|
||||
xdata = plotutil.getplotdata(x)
|
||||
ydata = plotutil.getplotdata(y)
|
||||
@ -1356,7 +1365,8 @@ class Axes(object):
|
||||
|
||||
#Create graphics
|
||||
graphics = GraphicFactory.createStepLineString(xdata, ydata, fmt, where)
|
||||
self.add_graphic(graphics)
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
self.add_graphic(graphics, zorder=zorder)
|
||||
self.axes.setAutoExtent()
|
||||
return graphics
|
||||
|
||||
@ -1471,7 +1481,8 @@ class Axes(object):
|
||||
#Create graphics
|
||||
graphics = GraphicFactory.createPoints(xdata, ydata, pbs)
|
||||
|
||||
self.add_graphic(graphics)
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
self.add_graphic(graphics, zorder=zorder)
|
||||
self.axes.setAutoExtent()
|
||||
|
||||
return graphics
|
||||
@ -1722,7 +1733,8 @@ class Axes(object):
|
||||
capsize = 10
|
||||
graphics = GraphicFactory.createErrorLineString(xdata, ydata, xerrL, xerrR, yerrB, \
|
||||
yerrU, line, eline, capsize)
|
||||
self.add_graphic(graphics)
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
self.add_graphic(graphics, zorder=zorder)
|
||||
self.axes.setAutoExtent()
|
||||
|
||||
return graphics
|
||||
@ -1846,9 +1858,10 @@ class Axes(object):
|
||||
not bottom is None, bottom, barbreaks)
|
||||
else:
|
||||
graphics = GraphicFactory.createBars(x.asarray(), height.asarray(), autowidth, width, not yerr is None, yerr, \
|
||||
not bottom is None, bottom, barbreaks)
|
||||
not bottom is None, bottom, barbreaks)
|
||||
|
||||
self.add_graphic(graphics)
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
self.add_graphic(graphics, zorder=zorder)
|
||||
self.axes.setAutoExtent()
|
||||
if autowidth:
|
||||
barswidth = kwargs.pop('barswidth', 0.8)
|
||||
@ -1972,9 +1985,10 @@ class Axes(object):
|
||||
|
||||
#Create bar graphics
|
||||
graphics = GraphicFactory.createHBars(ydata, xdata, autoheight, height, not xerr is None, xerr, \
|
||||
not left is None, left, barbreaks)
|
||||
|
||||
self.add_graphic(graphics)
|
||||
not left is None, left, barbreaks)
|
||||
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
self.add_graphic(graphics, zorder=zorder)
|
||||
self.axes.setAutoExtent()
|
||||
if autoheight:
|
||||
barsheight = kwargs.pop('barsheight', 0.8)
|
||||
@ -2127,9 +2141,10 @@ class Axes(object):
|
||||
|
||||
#Create stem graphics
|
||||
graphics = GraphicFactory.createStems(xdata, ydata, linefmt, markerfmt, \
|
||||
basefmt, bottom)
|
||||
basefmt, bottom)
|
||||
|
||||
self.add_graphic(graphics)
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
self.add_graphic(graphics, zorder=zorder)
|
||||
self.axes.setAutoExtent()
|
||||
|
||||
return linefmt
|
||||
@ -2201,7 +2216,9 @@ class Axes(object):
|
||||
if not xaxistype is None:
|
||||
self.set_xaxis_type(xaxistype)
|
||||
self.axes.updateDrawExtent()
|
||||
self.add_graphic(igraphic)
|
||||
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
self.add_graphic(igraphic, zorder=zorder)
|
||||
#self.axes.setAutoExtent()
|
||||
self.axes.setExtent(igraphic.getExtent())
|
||||
self.axes.setDrawExtent(igraphic.getExtent())
|
||||
@ -2336,7 +2353,9 @@ class Axes(object):
|
||||
if not xaxistype is None:
|
||||
self.set_xaxis_type(xaxistype)
|
||||
self.axes.updateDrawExtent()
|
||||
self.add_graphic(igraphic)
|
||||
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
self.add_graphic(igraphic, zorder=zorder)
|
||||
#self.setAutoExtent()
|
||||
self.axes.setExtent(igraphic.getExtent())
|
||||
self.axes.setDrawExtent(igraphic.getExtent())
|
||||
@ -2429,7 +2448,9 @@ class Axes(object):
|
||||
if not xaxistype is None:
|
||||
self.set_xaxis_type(xaxistype)
|
||||
self.axes.updateDrawExtent()
|
||||
self.add_graphic(igraphic)
|
||||
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
self.add_graphic(igraphic, zorder=zorder)
|
||||
self.axes.setAutoExtent()
|
||||
gridline = self.axes.getGridLine()
|
||||
gridline.setTop(True)
|
||||
@ -2477,7 +2498,8 @@ class Axes(object):
|
||||
graphics = GraphicFactory.createPColorPolygons(x.asarray(), y.asarray(), a.asarray(), ls)
|
||||
visible = kwargs.pop('visible', True)
|
||||
if visible:
|
||||
self.add_graphic(graphics)
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
self.add_graphic(graphics, zorder=zorder)
|
||||
self.axes.setExtent(graphics.getExtent())
|
||||
self.axes.setDrawExtent(graphics.getExtent())
|
||||
return graphics
|
||||
@ -2519,7 +2541,8 @@ class Axes(object):
|
||||
graphics = GraphicFactory.createGridPolygons(x.asarray(), y.asarray(), a.asarray(), ls)
|
||||
visible = kwargs.pop('visible', True)
|
||||
if visible:
|
||||
self.add_graphic(graphics)
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
self.add_graphic(graphics, zorder=zorder)
|
||||
self.axes.setExtent(graphics.getExtent())
|
||||
self.axes.setDrawExtent(graphics.getExtent())
|
||||
return graphics
|
||||
@ -2546,7 +2569,7 @@ class Axes(object):
|
||||
return ctext
|
||||
|
||||
def arrow(self, x, y, dx, dy, **kwargs):
|
||||
'''
|
||||
"""
|
||||
Add an arrow to the axes.
|
||||
|
||||
:param x: (*float*) X coordinate.
|
||||
@ -2555,20 +2578,21 @@ class Axes(object):
|
||||
:param dy: (*float*) The length of arrow along y direction.
|
||||
|
||||
:returns: Arrow graphic.
|
||||
'''
|
||||
"""
|
||||
if not kwargs.has_key('facecolor'):
|
||||
kwargs['facecolor'] = (51,204,255)
|
||||
apb, isunique = plotutil.getlegendbreak('polygon', **kwargs)
|
||||
apb = plotutil.polygon2arrow(apb, **kwargs)
|
||||
graphic = GraphicFactory.createArrow(x, y, dx, dy, apb)
|
||||
|
||||
self.add_graphic(graphic)
|
||||
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
self.add_graphic(graphic, zorder=zorder)
|
||||
self.axes.setAutoExtent()
|
||||
|
||||
return graphic
|
||||
|
||||
def arrowline(self, x, y, dx=0, dy=0, **kwargs):
|
||||
'''
|
||||
"""
|
||||
Add an arrow line to the axes.
|
||||
|
||||
:param x: (*float or array_like*) X coordinates.
|
||||
@ -2577,7 +2601,7 @@ class Axes(object):
|
||||
:param dy: (*float*) The length of arrow along y direction. Only valid when y is float.
|
||||
|
||||
:returns: Arrow line graphic.
|
||||
'''
|
||||
"""
|
||||
if isinstance(x, (list, tuple)):
|
||||
x = np.array(x)
|
||||
if isinstance(y, (list, tuple)):
|
||||
@ -2590,14 +2614,15 @@ class Axes(object):
|
||||
graphic = GraphicFactory.createArrowLine(x._array, y._array, alb, iscurve)
|
||||
else:
|
||||
graphic = GraphicFactory.createArrowLine(x, y, dx, dy, alb)
|
||||
|
||||
self.add_graphic(graphic)
|
||||
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
self.add_graphic(graphic, zorder=zorder)
|
||||
self.axes.setAutoExtent()
|
||||
|
||||
return graphic
|
||||
|
||||
def annotate(self, s, xy, *args, **kwargs):
|
||||
'''
|
||||
"""
|
||||
Annotate the point xy with text s.
|
||||
|
||||
:param s: (*string*) The text of the annotation.
|
||||
@ -2607,7 +2632,7 @@ class Axes(object):
|
||||
:param arrowprops: (*dict*) Arrow properties.
|
||||
|
||||
:returns: Annotation.
|
||||
'''
|
||||
"""
|
||||
if len(args) > 0:
|
||||
xytext = args[0]
|
||||
else:
|
||||
@ -2661,13 +2686,13 @@ class Axes(object):
|
||||
pass
|
||||
|
||||
def patch(self, x, y=None, **kwargs):
|
||||
'''
|
||||
"""
|
||||
Create one or more filled polygons.
|
||||
|
||||
:param x: (*array_like*) X coordinates for each vertex. X should be PolygonShape if y
|
||||
is None.
|
||||
:param y: (*array_like*) Y coordinates for each vertex.
|
||||
'''
|
||||
"""
|
||||
lbreak, isunique = plotutil.getlegendbreak('polygon', **kwargs)
|
||||
if y is None:
|
||||
graphics = Graphic(x, lbreak)
|
||||
@ -2676,23 +2701,25 @@ class Axes(object):
|
||||
y = plotutil.getplotdata(y)
|
||||
graphics = GraphicFactory.createPolygons(x, y, lbreak)
|
||||
|
||||
self.add_graphic(graphics)
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
self.add_graphic(graphics, zorder=zorder)
|
||||
self.axes.setAutoExtent()
|
||||
return graphics
|
||||
|
||||
def rectangle(self, position, curvature=None, **kwargs):
|
||||
'''
|
||||
"""
|
||||
Create one or more filled polygons.
|
||||
|
||||
:param position: (*list*) Position of the rectangle [x, y, width, height].
|
||||
:param curvature: (*list*) Curvature of the rectangle [x, y]. Default is None.
|
||||
'''
|
||||
"""
|
||||
lbreak, isunique = plotutil.getlegendbreak('polygon', **kwargs)
|
||||
if isinstance(curvature, (int, float)):
|
||||
curvature = [curvature, curvature]
|
||||
graphic = GraphicFactory.createRectangle(position, curvature, lbreak)
|
||||
|
||||
self.add_graphic(graphic)
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
self.add_graphic(graphic, zorder=zorder)
|
||||
self.axes.setAutoExtent()
|
||||
return graphic
|
||||
|
||||
@ -2738,8 +2765,9 @@ class Axes(object):
|
||||
pb.setCaption(label)
|
||||
|
||||
#Create graphics
|
||||
graphics = GraphicFactory.createFillBetweenPolygons(xdata, y1, y2, where, pb)
|
||||
self.add_graphic(graphics)
|
||||
graphics = GraphicFactory.createFillBetweenPolygons(xdata, y1, y2, where, pb)
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
self.add_graphic(graphics, zorder=zorder)
|
||||
self.axes.setAutoExtent()
|
||||
|
||||
return pb
|
||||
@ -2786,8 +2814,9 @@ class Axes(object):
|
||||
pb.setCaption(label)
|
||||
|
||||
#Create graphics
|
||||
graphics = GraphicFactory.createFillBetweenPolygonsX(ydata, x1, x2, where, pb)
|
||||
self.add_graphic(graphics)
|
||||
graphics = GraphicFactory.createFillBetweenPolygonsX(ydata, x1, x2, where, pb)
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
self.add_graphic(graphics, zorder=zorder)
|
||||
self.axes.setAutoExtent()
|
||||
|
||||
return pb
|
||||
@ -3290,7 +3319,9 @@ class Axes(object):
|
||||
if not xaxistype is None:
|
||||
self.set_xaxis_type(xaxistype)
|
||||
self.axes.updateDrawExtent()
|
||||
self.add_graphic(igraphic)
|
||||
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
self.add_graphic(igraphic, zorder=zorder)
|
||||
self.axes.setAutoExtent()
|
||||
|
||||
return igraphic
|
||||
@ -3389,7 +3420,9 @@ class Axes(object):
|
||||
if not xaxistype is None:
|
||||
self.set_xaxis_type(xaxistype)
|
||||
self.axes.updateDrawExtent()
|
||||
self.add_graphic(igraphic)
|
||||
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
self.add_graphic(igraphic, zorder=zorder)
|
||||
self.axes.setAutoExtent()
|
||||
|
||||
return igraphic
|
||||
@ -3517,7 +3550,8 @@ class Axes(object):
|
||||
igraphic = GraphicFactory.createStreamlines(x._array, y._array, u._array, v._array,
|
||||
density, alb, isuv)
|
||||
|
||||
self.add_graphic(igraphic)
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
self.add_graphic(igraphic, zorder=zorder)
|
||||
self.axes.setAutoExtent()
|
||||
|
||||
return igraphic
|
||||
|
||||
Binary file not shown.
@ -1562,12 +1562,12 @@ class Axes3DGL(Axes3D):
|
||||
plotutil.setlegendscheme(ls, **kwargs)
|
||||
ls.setNormalize(norm._norm)
|
||||
ls.setColorMap(cmap)
|
||||
graphics = JOGLUtil.volume(data.asarray(), x.asarray(), y.asarray(), z.asarray(), ls, \
|
||||
graphics = GraphicFactory.volume(data.asarray(), x.asarray(), y.asarray(), z.asarray(), ls, \
|
||||
alpha_min, alpha_max)
|
||||
else:
|
||||
opacity_nodes = kwargs.pop('opacity_nodes', None)
|
||||
opacity_levels = kwargs.pop('opacity_levels', [0., 1.])
|
||||
graphics = JOGLUtil.volume(data.asarray(), x.asarray(), y.asarray(), z.asarray(), cmap, \
|
||||
graphics = GraphicFactory.volume(data.asarray(), x.asarray(), y.asarray(), z.asarray(), cmap, \
|
||||
norm._norm, opacity_nodes, opacity_levels)
|
||||
|
||||
ray_casting = kwargs.pop('ray_casting', None)
|
||||
@ -1582,9 +1582,9 @@ class Axes3DGL(Axes3D):
|
||||
return graphics
|
||||
|
||||
def view(self):
|
||||
'''
|
||||
"""
|
||||
Open GLForm
|
||||
'''
|
||||
"""
|
||||
form = GLForm(self.axes)
|
||||
form.setSize(600, 500)
|
||||
form.setLocationRelativeTo(None)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user