mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
add LegendFactory class
This commit is contained in:
parent
eca9a0ba64
commit
349f2a4f32
@ -1,6 +1,8 @@
|
||||
package org.meteoinfo.geometry.colors;
|
||||
|
||||
import org.meteoinfo.common.MIMath;
|
||||
import org.meteoinfo.common.colors.ColorMap;
|
||||
import org.meteoinfo.geometry.legend.LegendFactory;
|
||||
import org.meteoinfo.geometry.legend.LegendScheme;
|
||||
import org.meteoinfo.geometry.shape.ShapeTypes;
|
||||
|
||||
@ -118,4 +120,41 @@ public class TransferFunction {
|
||||
|
||||
return new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (alpha * 255));
|
||||
}
|
||||
|
||||
/**
|
||||
* To legend scheme
|
||||
* @param min The minimum value
|
||||
* @param max The maximum value
|
||||
* @param n Legend break number
|
||||
* @return Legend scheme
|
||||
*/
|
||||
public LegendScheme toLegendScheme(double min, double max) {
|
||||
double[] values = MIMath.getIntervalValues(min, max);
|
||||
int n = values.length;
|
||||
Color[] colors = new Color[n + 1];
|
||||
colors[0] = getColor(min);
|
||||
for (int i = 1; i < n; i++) {
|
||||
colors[i] = getColor(values[i - 1]);
|
||||
}
|
||||
|
||||
return LegendFactory.createGraduatedLegendScheme(values, colors, ShapeTypes.IMAGE, min, max);
|
||||
}
|
||||
|
||||
/**
|
||||
* To legend scheme
|
||||
* @param min The minimum value
|
||||
* @param max The maximum value
|
||||
* @param n Legend break number
|
||||
* @return Legend scheme
|
||||
*/
|
||||
public LegendScheme toLegendScheme(double min, double max, int n) {
|
||||
double[] values = MIMath.getIntervalValues(min, max, n);
|
||||
Color[] colors = new Color[n + 1];
|
||||
colors[0] = getColor(min);
|
||||
for (int i = 1; i < n; i++) {
|
||||
colors[i] = getColor(values[i - 1]);
|
||||
}
|
||||
|
||||
return LegendFactory.createGraduatedLegendScheme(values, colors, ShapeTypes.IMAGE, min, max);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -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\plot_types\3d\jogl\volume">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\streamslice"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\meteo\interpolation">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\LaSW"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\wrf"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart\axis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\stats"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/>
|
||||
<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\taylor"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\text"/>
|
||||
<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\meteo"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\interpolation"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\volumeplot_perspective.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\volumeplot_perspective_2.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\volumeplot_perspective_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\meteo\interpolation\log_interpolate_1d_1.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\volumeplot_perspective.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\volumeplot_perspective_2.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\volumeplot_perspective_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\meteo\interpolation\log_interpolate_1d_1.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user