mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
add setColorMap method in VolumeGraphics class
This commit is contained in:
parent
045e399e56
commit
0160b96542
@ -31,6 +31,8 @@ public class VolumeGraphics 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};
|
||||
@ -73,6 +75,8 @@ public class VolumeGraphics extends GraphicCollection3D {
|
||||
* @param vMax Maximum value
|
||||
*/
|
||||
public VolumeGraphics(Array value, ColorMap colorMap, double vMin, double vMax) {
|
||||
this.colorMap = colorMap;
|
||||
|
||||
value = value.copyIfView();
|
||||
int[] shape = value.getShape();
|
||||
this.depth = shape[0];
|
||||
@ -119,23 +123,7 @@ public class VolumeGraphics extends GraphicCollection3D {
|
||||
}
|
||||
//buffer = Buffers.newDirectByteBuffer(data);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
setColorMap(colorMap, norm);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -169,9 +157,44 @@ public class VolumeGraphics extends GraphicCollection3D {
|
||||
this.setSingleLegend(false);
|
||||
}
|
||||
|
||||
/*public void updateColors() {
|
||||
this.colors = this.transferFunction.getColors(this.originalColors);
|
||||
}*/
|
||||
/**
|
||||
* Set color map
|
||||
* @param colorMap Color map
|
||||
*/
|
||||
public void setColorMap(ColorMap colorMap) {
|
||||
if (this.normalize == null) {
|
||||
this.normalize = new Normalize();
|
||||
}
|
||||
setColorMap(colorMap, this.normalize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set color map
|
||||
* @param colorMap Color map
|
||||
* @param norm Normalize
|
||||
*/
|
||||
public void setColorMap(ColorMap colorMap, Normalize norm) {
|
||||
this.colorMap = colorMap;
|
||||
this.normalize = norm;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public void updateColors() {
|
||||
final float cRange = colorRange[1] - colorRange[0];
|
||||
|
||||
@ -797,13 +797,30 @@ 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);
|
||||
return volume(data, xa, ya, za, colorMap, norm, transferFunction);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 transferFunction Transfer function
|
||||
* @return Volume graphics
|
||||
*/
|
||||
public static GraphicCollection volume(Array data, Array xa, Array ya, Array za, ColorMap colorMap,
|
||||
Normalize norm, TransferFunction transferFunction) {
|
||||
data = data.copyIfView();
|
||||
xa = xa.copyIfView();
|
||||
ya = ya.copyIfView();
|
||||
za = za.copyIfView();
|
||||
|
||||
VolumeGraphics graphics = new VolumeGraphics(data, colorMap, norm);
|
||||
TransferFunction transferFunction = new TransferFunction(opacityNodes, opacityLevels, norm);
|
||||
graphics.setTransferFunction(transferFunction);
|
||||
graphics.updateColors();
|
||||
|
||||
|
||||
@ -1,30 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\common_math\fitting">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\slice"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\test"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\map\maskout">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\traj"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\projection"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\plot"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\contour"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\interpolate"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\streamplot"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\quiver"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\fitting"/>
|
||||
<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"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\maskout"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth\CALIPSO_L1_3d_axis.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\quiver\quiver3_model.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth\CALIPSO_L1_3d_axis.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\quiver\quiver3_model.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
@ -32,5 +30,5 @@
|
||||
</Font>
|
||||
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
|
||||
<Figure DoubleBuffering="true"/>
|
||||
<Startup MainFormLocation="-7,0" MainFormSize="1388,801"/>
|
||||
<Startup MainFormLocation="-7,-7" MainFormSize="1293,685"/>
|
||||
</MeteoInfo>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user