mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
add titleSpace in ChartLegend
This commit is contained in:
parent
ed442cee10
commit
2ab2a576da
@ -61,6 +61,7 @@ public class ChartLegend {
|
||||
protected boolean drawNeatLine;
|
||||
protected Color neatLineColor;
|
||||
protected float neatLineSize;
|
||||
protected float titleSpace;
|
||||
private float breakSpace;
|
||||
private float topSpace;
|
||||
private float leftSpace;
|
||||
@ -94,6 +95,7 @@ public class ChartLegend {
|
||||
drawNeatLine = true;
|
||||
neatLineColor = Color.black;
|
||||
neatLineSize = 1;
|
||||
titleSpace = 5;
|
||||
breakSpace = 3;
|
||||
topSpace = 5;
|
||||
leftSpace = 5;
|
||||
@ -420,6 +422,22 @@ public class ChartLegend {
|
||||
public void setNeatLineSize(float size) {
|
||||
neatLineSize = size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title space
|
||||
* @return Title space
|
||||
*/
|
||||
public float getTitleSpace() {
|
||||
return this.titleSpace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title space
|
||||
* @param value Title space
|
||||
*/
|
||||
public void setTitleSpace(float value) {
|
||||
this.titleSpace = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get break space
|
||||
@ -817,9 +835,11 @@ public class ChartLegend {
|
||||
float y0 = 0;
|
||||
if (this.label != null) {
|
||||
float x0 = (float) (this.width / 2.);
|
||||
y0 += this.breakSpace * 2;
|
||||
y0 += this.titleSpace;
|
||||
this.label.draw(g, x0, y0);
|
||||
y0 += this.label.getDimension(g).height + this.breakSpace * 2;
|
||||
y0 += this.label.getDimension(g).height + this.titleSpace;
|
||||
} else {
|
||||
y0 += this.breakSpace;
|
||||
}
|
||||
|
||||
//Draw legend
|
||||
@ -827,7 +847,7 @@ public class ChartLegend {
|
||||
i = 0;
|
||||
for (int col = 0; col < rowColNum; col++) {
|
||||
x = symbolWidth / 2 + leftSpace + col * colWidth;
|
||||
y = y0 + breakHeight / 2 + breakSpace * 2;
|
||||
y = y0 + breakHeight / 2;
|
||||
for (int row = 0; row < rowNums[col]; row++) {
|
||||
if (!aLS.getLegendBreaks().get(i).isDrawShape()) {
|
||||
continue;
|
||||
@ -996,8 +1016,10 @@ public class ChartLegend {
|
||||
int titleWidth = 0;
|
||||
if (this.label != null) {
|
||||
Dimension dim = this.label.getDimension(g);
|
||||
titleHeight = dim.height + (int) (this.breakSpace * 4);
|
||||
titleHeight = dim.height + (int) (this.titleSpace * 2);
|
||||
titleWidth = dim.width;
|
||||
} else {
|
||||
titleHeight = (int) breakSpace;
|
||||
}
|
||||
switch (this.orientation) {
|
||||
case VERTICAL:
|
||||
@ -1046,8 +1068,7 @@ public class ChartLegend {
|
||||
|
||||
// this.height = (int) (rowNums[0] * (breakHeight + _breakSpace)
|
||||
// + _breakSpace * 2 + breakHeight / 2 + 5);
|
||||
this.height = (int) (rowNums[0] * (breakHeight + breakSpace)
|
||||
+ breakSpace * 3);
|
||||
this.height = (int) (rowNums[0] * (breakHeight + breakSpace));
|
||||
break;
|
||||
case HORIZONTAL:
|
||||
//Get row number
|
||||
@ -1076,7 +1097,7 @@ public class ChartLegend {
|
||||
}
|
||||
|
||||
//Get height
|
||||
this.height = (int) (breakHeight + this.breakSpace * 2) * this.rowColNum;
|
||||
this.height = (int) (breakHeight + this.breakSpace) * this.rowColNum;
|
||||
|
||||
//Get width
|
||||
//FontMetrics metrics = g.getFontMetrics(tickFont);
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<netcdf.version>5.5.4-SNAPSHOT</netcdf.version>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
@ -43,7 +44,7 @@
|
||||
<dependency>
|
||||
<groupId>edu.ucar</groupId>
|
||||
<artifactId>netcdfAll</artifactId>
|
||||
<version>5.5.4-SNAPSHOT</version>
|
||||
<version>${netcdf.version}</version>
|
||||
<!--<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/netcdfAll-5.5.3-SNAPSHOT.jar</systemPath>-->
|
||||
</dependency>
|
||||
|
||||
@ -20,6 +20,8 @@ import org.meteoinfo.ndarray.util.DataTypeUtil;
|
||||
import org.mozilla.universalchardet.UniversalDetector;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.TemporalAmount;
|
||||
import java.util.*;
|
||||
@ -2311,7 +2313,7 @@ public class DataFrame implements Iterable {
|
||||
*
|
||||
* @param fileName File name
|
||||
* @param delimiter Delimiter
|
||||
* @param skipRows Number of lines to skip at begining of the file
|
||||
* @param skipRows Number of lines to skip at beginning of the file
|
||||
* @param formatSpec Format specifiers string
|
||||
* @param encoding Fle encoding
|
||||
* @param indexCol Column to be used as index
|
||||
@ -2328,7 +2330,7 @@ public class DataFrame implements Iterable {
|
||||
encoding = UniversalDetector.detectCharset(new File(fileName));
|
||||
}
|
||||
|
||||
BufferedReader sr = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), encoding));
|
||||
BufferedReader sr = new BufferedReader(new InputStreamReader(Files.newInputStream(Paths.get(fileName)), encoding));
|
||||
if (skipRows > 0) {
|
||||
for (int i = 0; i < skipRows; i++) {
|
||||
sr.readLine();
|
||||
@ -2597,7 +2599,7 @@ public class DataFrame implements Iterable {
|
||||
encoding = UniversalDetector.detectCharset(new File(fileName));
|
||||
}
|
||||
|
||||
BufferedReader sr = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), encoding));
|
||||
BufferedReader sr = new BufferedReader(new InputStreamReader(Files.newInputStream(Paths.get(fileName)), encoding));
|
||||
if (skipRows > 0) {
|
||||
for (int i = 0; i < skipRows; i++) {
|
||||
sr.readLine();
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\funny">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\geoshow"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\slice"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\dataframe">
|
||||
<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\common_math\interpolate"/>
|
||||
@ -10,21 +8,25 @@
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\FY"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\weather"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\dataframe"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth"/>
|
||||
<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\funny"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart\legend"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\dataframe"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\dataframe\dataframe_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\dataframe\reindex_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\chart\legend\legend_title.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\dataframe\dataframe_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\dataframe\reindex_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\chart\legend\legend_title.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
@ -32,5 +34,5 @@
|
||||
</Font>
|
||||
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
|
||||
<Figure DoubleBuffering="true"/>
|
||||
<Startup MainFormLocation="-7,-7" MainFormSize="1293,685"/>
|
||||
<Startup MainFormLocation="-7,0" MainFormSize="1394,799"/>
|
||||
</MeteoInfo>
|
||||
|
||||
Binary file not shown.
@ -3733,7 +3733,7 @@ class Axes(object):
|
||||
|
||||
:param breaks: (*ColorBreak*) Legend breaks (optional).
|
||||
:param labels: (*list of string*) Legend labels (optional).
|
||||
:param orientation: (*string*) Colorbar orientation: ``vertical`` or ``horizontal``.
|
||||
:param orientation: (*string*) Legend orientation: ``vertical`` or ``horizontal``.
|
||||
:param loc: (*string*) The location of the legend, including: 'upper right', 'upper left',
|
||||
'lower left', 'lower right', 'right', 'ceter left', 'center right', lower center',
|
||||
'upper center', 'center' and 'custom'. Default is 'upper right'.
|
||||
@ -3751,7 +3751,8 @@ class Axes(object):
|
||||
:param titlefontname: (*string*) Title font name.
|
||||
:param titlefontsize: (*int*) Title font size.
|
||||
:param titlecolor: (*color*) Title color. Default is ``black`` .
|
||||
:param breakspace: (*float*) Break space.
|
||||
:param breakspace: (*float*) Break space. Default is `3`.
|
||||
:param titlespace: (*float*) Title space. Default is `5`.
|
||||
:param markerscale: (*float*) Marker symbol scale.
|
||||
:param markerwidth: (*float*) Marker symbol width.
|
||||
:param markerheight: (*float*) Marker symbol height.
|
||||
@ -3889,6 +3890,9 @@ class Axes(object):
|
||||
breakspace = kwargs.pop('breakspace', None)
|
||||
if not breakspace is None:
|
||||
clegend.setBreakSpace(breakspace)
|
||||
titlespace = kwargs.pop('titlespace', None)
|
||||
if titlespace is not None:
|
||||
clegend.setTitleSpace(titlespace)
|
||||
markerscale = kwargs.pop('markerscale', None)
|
||||
if not markerscale is None:
|
||||
clegend.setSymbolScale(markerscale)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user