to version 3.2.8

This commit is contained in:
wyq 2022-01-21 16:27:18 +08:00
parent 3d279d3f1e
commit 1384750fbb
27 changed files with 196 additions and 57 deletions

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.2.7</version>
<version>3.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -37,8 +37,8 @@ import org.meteoinfo.geometry.shape.ShapeTypes;
public class ChartColorBar extends ChartLegend {
// <editor-fold desc="Variables">
private List<Double> tickLocations;
private List<ChartText> tickLabels;
private List<Double> tickLocations = new ArrayList<>();
private List<ChartText> tickLabels = new ArrayList<>();
private boolean autoTick;
private boolean insideTick;
private float tickLength;
@ -48,6 +48,8 @@ public class ChartColorBar extends ChartLegend {
private boolean drawMinLabel;
private boolean drawMaxLabel;
private ExtendType extendType;
private boolean drawMinorTick;
protected int minorTickNum;
// </editor-fold>
// <editor-fold desc="Constructor">
@ -59,10 +61,8 @@ public class ChartColorBar extends ChartLegend {
public ChartColorBar(LegendScheme ls) {
super(ls);
this.tickLocations = new ArrayList<>();
this.tickLabels = new ArrayList<>();
this.autoTick = true;
this.insideTick = true;
this.insideTick = false;
this.tickLength = 5;
this.tickVisible = true;
this.tickWidth = 1;
@ -70,6 +70,8 @@ public class ChartColorBar extends ChartLegend {
this.drawMinLabel = false;
this.drawMaxLabel = false;
this.extendType = ExtendType.NEITHER;
this.drawMinorTick = false;
this.minorTickNum = 5;
this.setLegendScheme(ls);
}
@ -290,6 +292,7 @@ public class ChartColorBar extends ChartLegend {
double[] tickValues;
if (normalize instanceof LogNorm) {
tickValues = MIMath.getIntervalValues_Log(min, max);
this.drawMinorTick = true;
} else {
tickValues = MIMath.getIntervalValues(min, max);
}
@ -368,8 +371,74 @@ public class ChartColorBar extends ChartLegend {
this.extendType = ExtendType.valueOf(value.toUpperCase());
}
/**
* Get whether draw minor ticks
* @return Whether draw minor ticks
*/
public boolean isDrawMinorTick() {
return this.drawMinorTick;
}
/**
* Set whether draw minor ticks
* @param value Whether draw minor ticks
*/
public void setDrawMinorTick(boolean value) {
this.drawMinorTick = value;
}
/**
* Get minor tick number
*
* @return Minor tick number
*/
public int getMinorTickNum() {
return this.minorTickNum;
}
/**
* Set minor tick number
*
* @param value Minor tick number
*/
public void setMinorTickNum(int value) {
this.minorTickNum = value;
}
// </editor-fold>
// <editor-fold desc="Method">
@Override
protected int getTickWidth(Graphics2D g) {
if (this.tickLabels.isEmpty()) {
return super.getTickWidth(g);
} else {
float tWidth = 0;
g.setFont(this.tickLabelFont);
for (ChartText ct : this.tickLabels) {
float labWidth = (float) Draw.getStringDimension(ct.getText(), this.tickLabelAngle, g).getWidth();
if (tWidth < labWidth)
tWidth = labWidth;
}
return (int) tWidth;
}
}
@Override
protected int getTickHeight(Graphics2D g) {
if (this.tickLabels.isEmpty()) {
return super.getTickHeight(g);
} else {
float tHeight = 0;
g.setFont(this.tickLabelFont);
for (ChartText ct : this.tickLabels) {
float labHeight = (float) Draw.getStringDimension(ct.getText(), 90 - Math.abs(this.tickLabelAngle), g).getWidth();
if (tHeight < labHeight)
tHeight = labHeight;
}
return (int) tHeight;
}
}
/**
* Draw legend
*
@ -514,7 +583,11 @@ public class ChartColorBar extends ChartLegend {
}
for (int i = 0; i < bNum; i++) {
g.setColor(colors[i]);
Rectangle2D rect = new Rectangle2D.Float(aP.X - 1, aP.Y, barWidth + 1, barHeight);
Rectangle2D rect;
if (i == bNum - 1)
rect = new Rectangle2D.Float(aP.X - 1, aP.Y, barWidth + 2, barHeight);
else
rect = new Rectangle2D.Float(aP.X - 1, aP.Y, barWidth + 1, barHeight);
g.fill(rect);
aP.X += barWidth;
}
@ -599,6 +672,25 @@ public class ChartColorBar extends ChartLegend {
} else {
Draw.drawString(g, sP.X, sP.Y, label, XAlign.RIGHT, YAlign.CENTER, this.tickLabelAngle, true);
}
//Draw minor tick lines
if (this.drawMinorTick) {
if (i == this.tickLocations.size() - 1) {
continue;
}
float minorTickLen = tickLen - 2;
double v1 = this.tickLocations.get(i);
double v2 = this.tickLocations.get(i + 1);
double step = (v2 - v1) / this.minorTickNum;
double v;
g.setColor(this.tickColor);
for (int j = 1; j < this.minorTickNum; j++) {
v = v1 + step * j;
sP.X = x_shift + minMaxWidth * normalize.apply(v).floatValue();
sP.Y = aP.Y;
this.drawTickLine(g, sP, minorTickLen, true, 0);
}
}
}
//Draw label
@ -1009,7 +1101,11 @@ public class ChartColorBar extends ChartLegend {
for (int i = 0; i < bNum; i++) {
aP.Y -= barHeight;
g.setColor(colors[i]);
Rectangle2D rect = new Rectangle2D.Float(aP.X, aP.Y, barWidth, barHeight + 1);
Rectangle2D rect;
if (i == bNum - 1)
rect = new Rectangle2D.Float(aP.X, aP.Y - 1, barWidth, barHeight + 2);
else
rect = new Rectangle2D.Float(aP.X, aP.Y, barWidth, barHeight + 1);
g.fill(rect);
}
switch (this.extendType) {
@ -1087,6 +1183,25 @@ public class ChartColorBar extends ChartLegend {
String label = this.tickLabels.get(i).getText();
g.setColor(this.tickLabelColor);
Draw.drawString(g, sP.X, sP.Y, label, XAlign.LEFT, YAlign.CENTER, this.tickLabelAngle, true);
//Draw minor tick lines
if (this.drawMinorTick) {
if (i == this.tickLocations.size() - 1) {
continue;
}
float minorTickLen = tickLen - 2;
double v1 = this.tickLocations.get(i);
double v2 = this.tickLocations.get(i + 1);
double step = (v2 - v1) / this.minorTickNum;
double v;
g.setColor(this.tickColor);
for (int j = 1; j < this.minorTickNum; j++) {
v = v1 + step * j;
sP.X = aP.X;
sP.Y = this.legendHeight - y_shift - minMaxHeight * normalize.apply(v).floatValue();
this.drawTickLine(g, sP, minorTickLen, false, 0);
}
}
}
//Draw label

View File

@ -636,7 +636,7 @@ public class ChartLegend {
/**
* Set symbol scale
*
* @param value Symble scale
* @param value Symbol scale
*/
public void setSymbolScale(float value) {
double w = this.symbolDimension.getWidth() * value;

View File

@ -90,7 +90,7 @@ public class Axis implements Cloneable {
this.tickColor = Color.black;
this.tickStroke = new BasicStroke(1.0f);
this.tickLength = 5;
this.insideTick = true;
this.insideTick = false;
this.tickLabelFont = new Font("Arial", Font.PLAIN, 14);
this.tickLabelColor = Color.black;
this.tickLabelAngle = 0;
@ -184,12 +184,26 @@ public class Axis implements Cloneable {
* @param label Axis label
* @param xAxis If is x axis
* @param loc Location
* @param drawTickLabel If draw tick label
* @param drawTickLine Whether draw tick label
*/
public Axis(String label, boolean xAxis, Location loc, boolean drawTickLabel) {
public Axis(String label, boolean xAxis, Location loc, boolean drawTickLine) {
this(label, xAxis, loc, drawTickLine, drawTickLine);
}
/**
* Constructor
*
* @param label Axis label
* @param xAxis If is x axis
* @param loc Location
* @param drawTickLine Whether draw tick lines
* @param drawTickLabel Whether draw tick labels
*/
public Axis(String label, boolean xAxis, Location loc, boolean drawTickLine, boolean drawTickLabel) {
this(label);
this.xAxis = xAxis;
this.location = loc;
this.drawTickLine = drawTickLine;
this.drawTickLabel = drawTickLabel;
}

View File

@ -78,7 +78,9 @@ public class MapPlot extends AbstractPlot2D implements IWebMapPanel {
} catch (CloneNotSupportedException ex) {
Logger.getLogger(MapPlot.class.getName()).log(Level.SEVERE, null, ex);
}
this.getAxis(Location.TOP).setDrawTickLine(false);
this.getAxis(Location.TOP).setDrawTickLabel(false);
this.getAxis(Location.RIGHT).setDrawTickLine(false);
this.getAxis(Location.RIGHT).setDrawTickLabel(false);
this.setDrawNeatLine(true);
this.getGridLine().setTop(true);

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.2.7</version>
<version>3.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -65,7 +65,7 @@ import java.util.zip.ZipInputStream;
public static String getVersion(){
String version = GlobalUtil.class.getPackage().getImplementationVersion();
if (version == null || version.equals("")) {
version = "3.2.7";
version = "3.2.8";
}
return version;
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.2.7</version>
<version>3.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.2.7</version>
<version>3.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.2.7</version>
<version>3.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.2.7</version>
<version>3.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.2.7</version>
<version>3.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.2.7</version>
<version>3.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<MeteoInfo File="milconfig.xml" Type="configurefile">
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types">
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\scatter">
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d_earth"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\scatter"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\plot"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart\latex"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
@ -16,19 +15,16 @@
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\contour"/>
<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\satellite\OMPS-NPP_LP-L2_2.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\scatter\scatterm_1.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\imshow.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\imshow_normalize.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\scatter\scatterm_2.py"/>
</OpenedFiles>
<RecentFiles>
<RecentFile File="D:\Working\MIScript\Jython\mis\satellite\OMPS-NPP_LP-L2_2.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\scatter\scatterm_1.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\imshow.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\imshow_normalize.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\scatter\scatterm_2.py"/>
</RecentFiles>
</File>
<Font>
@ -36,5 +32,5 @@
</Font>
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
<Figure DoubleBuffering="true"/>
<Startup MainFormLocation="-7,-7" MainFormSize="1293,685"/>
<Startup MainFormLocation="-7,0" MainFormSize="1417,820"/>
</MeteoInfo>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>org.meteothink</groupId>
<artifactId>MeteoInfo</artifactId>
<version>3.2.7</version>
<version>3.2.8</version>
</parent>
<artifactId>meteoinfo-lab</artifactId>
<packaging>jar</packaging>

View File

@ -115,11 +115,12 @@ class Axes(object):
self.set_xaxis_type(xaxistype)
bgcolor = plotutil.getcolor(bgcobj)
self.axes.setBackground(bgcolor)
tickline = kwargs.pop('tickline', True)
b_axis.setDrawTickLine(tickline)
t_axis.setDrawTickLine(tickline)
l_axis.setDrawTickLine(tickline)
r_axis.setDrawTickLine(tickline)
tickline = kwargs.pop('tickline', None)
if not tickline is None:
b_axis.setDrawTickLine(tickline)
t_axis.setDrawTickLine(tickline)
l_axis.setDrawTickLine(tickline)
r_axis.setDrawTickLine(tickline)
tickfontname = kwargs.pop('tickfontname', 'Arial')
tickfontsize = kwargs.pop('tickfontsize', 14)
tickbold = kwargs.pop('tickbold', False)
@ -755,9 +756,9 @@ class Axes(object):
tickwidth = kwargs.pop('tickwidth', None)
ticklength = kwargs.pop('ticklength', None)
ticklabel = kwargs.pop('ticklabel', None)
minortick = kwargs.pop('minortick', False)
minorticknum = kwargs.pop('minorticknum', 5)
tickin = kwargs.pop('tickin', True)
minortick = kwargs.pop('minortick', None)
minorticknum = kwargs.pop('minorticknum', None)
tickin = kwargs.pop('tickin', None)
axistype = kwargs.pop('axistype', None)
timetickformat = kwargs.pop('timetickformat', None)
if not axistype is None:
@ -812,9 +813,12 @@ class Axes(object):
axis.setTickLength(ticklength)
if not ticklabel is None:
axis.setDrawTickLabel(ticklabel)
axis.setMinorTickVisible(minortick)
axis.setMinorTickNum(minorticknum)
axis.setInsideTick(tickin)
if not minortick is None:
axis.setMinorTickVisible(minortick)
if not minorticknum is None:
axis.setMinorTickNum(minorticknum)
if not tickin is None:
axis.setInsideTick(tickin)
axis.setTickLabelFont(font)
def yaxis(self, **kwargs):
@ -859,9 +863,9 @@ class Axes(object):
tickwidth = kwargs.pop('tickwidth', None)
ticklength = kwargs.pop('ticklength', None)
ticklabel = kwargs.pop('ticklabel', None)
minortick = kwargs.pop('minortick', False)
minorticknum = kwargs.pop('minorticknum', 5)
tickin = kwargs.pop('tickin', True)
minortick = kwargs.pop('minortick', None)
minorticknum = kwargs.pop('minorticknum', None)
tickin = kwargs.pop('tickin', None)
axistype = kwargs.pop('axistype', None)
timetickformat = kwargs.pop('timetickformat', None)
if not axistype is None:
@ -916,9 +920,12 @@ class Axes(object):
axis.setTickLength(ticklength)
if not ticklabel is None:
axis.setDrawTickLabel(ticklabel)
axis.setMinorTickVisible(minortick)
axis.setMinorTickNum(minorticknum)
axis.setInsideTick(tickin)
if not minortick is None:
axis.setMinorTickVisible(minortick)
if not minorticknum is None:
axis.setMinorTickNum(minorticknum)
if not tickin is None:
axis.setInsideTick(tickin)
axis.setTickLabelFont(font)
def xreverse(self):
@ -3676,6 +3683,8 @@ class Axes(object):
:param yshift: (*float*) Y shift of the colorbar with pixel coordinate.
:param vmintick: (*boolean*) Draw minimum value tick or not.
:param vmaxtick: (*boolean*) Draw maximum value tick or not.
:param minortick: (*boolean*) Draw minor tick line or not.
:param minorticknum: (*int*) Minor tick line number between two adjacent major tick lines.
"""
cmap = kwargs.pop('cmap', None)
shrink = kwargs.pop('shrink', 1)
@ -3804,6 +3813,9 @@ class Axes(object):
if kwargs.has_key('edgesize'):
edgesize = kwargs.pop('edgesize')
legend.setNeatLineSize(edgesize)
minortick = kwargs.pop('minortick', None)
if not minortick is None:
legend.setDrawMinorTick(minortick)
return legend

View File

@ -632,15 +632,15 @@ class Figure(ChartPanel):
for j in range(ncols):
if axestype == '3d':
ax = Axes3D()
self.__set_axes3d(ax, **kwarg)
self.__set_axes3d(ax, **kwargs)
elif axestype == 'map':
ax = MapAxes()
self.__set_axesm(ax, **kwargs)
elif axestype == 'polar':
ax = PolarAxes()
else:
ax = Axes()
self.__set_axes(ax, **kwargs)
ax = Axes(**kwargs)
#self.__set_axes(ax, **kwargs)
ax.axes.isSubPlot = True
if not iswspace and not ishspace:
x = left + w * j

View File

@ -4,7 +4,7 @@
<parent>
<groupId>org.meteothink</groupId>
<artifactId>MeteoInfo</artifactId>
<version>3.2.7</version>
<version>3.2.8</version>
</parent>
<artifactId>meteoinfo-map</artifactId>
<packaging>jar</packaging>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.2.7</version>
<version>3.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>org.meteothink</groupId>
<artifactId>MeteoInfo</artifactId>
<version>3.2.7</version>
<version>3.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.2.7</version>
<version>3.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.2.7</version>
<version>3.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.2.7</version>
<version>3.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.meteothink</groupId>
<artifactId>MeteoInfo</artifactId>
<version>3.2.7</version>
<version>3.2.8</version>
<packaging>pom</packaging>
<parent>