mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
add avoidcoll argument in barbs, quiver and stationmodel functions
This commit is contained in:
parent
72fb07ad15
commit
4eefdbb7da
@ -22,6 +22,7 @@ import java.util.List;
|
||||
|
||||
import org.meteoinfo.chart.jogl.GLPlot;
|
||||
import org.meteoinfo.chart.geo.MapPlot;
|
||||
import org.meteoinfo.chart.plot.AbstractPlot2D;
|
||||
import org.meteoinfo.chart.plot.Plot;
|
||||
import org.meteoinfo.common.PointF;
|
||||
|
||||
@ -520,8 +521,8 @@ public class Chart {
|
||||
plot.setPlotShrink(this.getPlotShrink(g, plotArea, plot));
|
||||
}
|
||||
}
|
||||
if (plot instanceof MapPlot) {
|
||||
((MapPlot) plot).setAntialias(this.antiAlias);
|
||||
if (plot instanceof AbstractPlot2D) {
|
||||
((AbstractPlot2D) plot).setAntiAlias(this.antiAlias);
|
||||
}
|
||||
if (plot instanceof GLPlot) {
|
||||
Rectangle2D graphArea = plot.getPositionArea();
|
||||
|
||||
@ -9,6 +9,7 @@ import com.jogamp.opengl.util.gl2.GLUT;
|
||||
import org.meteoinfo.chart.jogl.GLPlot;
|
||||
import org.meteoinfo.chart.jogl.Program;
|
||||
import org.meteoinfo.chart.geo.MapPlot;
|
||||
import org.meteoinfo.chart.plot.AbstractPlot2D;
|
||||
import org.meteoinfo.chart.plot.Plot;
|
||||
import org.meteoinfo.common.PointF;
|
||||
|
||||
@ -576,8 +577,8 @@ public class GLChart implements GLEventListener {
|
||||
plot.setPlotShrink(this.getPlotShrink(g, plotArea, plot));
|
||||
}
|
||||
}
|
||||
if (plot instanceof MapPlot) {
|
||||
((MapPlot) plot).setAntialias(this.antialias);
|
||||
if (plot instanceof AbstractPlot2D) {
|
||||
((AbstractPlot2D) plot).setAntiAlias(this.antialias);
|
||||
}
|
||||
if (plot instanceof GLPlot) {
|
||||
Rectangle2D graphArea = plot.getPositionArea();
|
||||
|
||||
@ -54,7 +54,6 @@ public class MapPlot extends Plot2D implements IWebMapPanel {
|
||||
|
||||
// <editor-fold desc="Variables">
|
||||
private ProjectionInfo projInfo;
|
||||
private boolean antialias;
|
||||
protected TileLoadListener tileLoadListener = new TileLoadListener(this);
|
||||
private IChartPanel parent;
|
||||
private float[] lonLim;
|
||||
@ -81,7 +80,6 @@ public class MapPlot extends Plot2D implements IWebMapPanel {
|
||||
super();
|
||||
|
||||
this.projInfo = projInfo;
|
||||
this.antialias = false;
|
||||
this.aspectType = AspectType.EQUAL;
|
||||
this.gridLine = new MapGridLine(projInfo);
|
||||
this.gridLine.setTop(true);
|
||||
@ -140,24 +138,6 @@ public class MapPlot extends Plot2D implements IWebMapPanel {
|
||||
return PlotType.XY2D;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if is antialias
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
public boolean isAntialias() {
|
||||
return this.antialias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if is antialias
|
||||
*
|
||||
* @param value Boolean
|
||||
*/
|
||||
public void setAntialias(boolean value) {
|
||||
this.antialias = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get projection info
|
||||
*
|
||||
|
||||
@ -1335,6 +1335,10 @@ public abstract class AbstractPlot2D extends Plot {
|
||||
Object rendering = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
for (ChartLegend legend : this.legends) {
|
||||
if (this.antiAlias) {
|
||||
legend.setAntiAlias(true);
|
||||
}
|
||||
|
||||
if (legend.isColorbar()) {
|
||||
if (legend.getPlotOrientation() == PlotOrientation.VERTICAL) {
|
||||
legend.setHeight((int) (graphArea.getHeight() * legend.getShrink()));
|
||||
|
||||
@ -316,20 +316,73 @@ public class Plot2D extends AbstractPlot2D {
|
||||
}
|
||||
|
||||
ColorBreak cb = graphic.getLegend();
|
||||
for (int i = 0; i < graphic.getNumGraphics(); i++) {
|
||||
Graphic gg = graphic.getGraphicN(i);
|
||||
if (gg.getExtent().intersects(this.drawExtent)) {
|
||||
if (!graphic.isSingleLegend()) {
|
||||
cb = gg.getLegend();
|
||||
}
|
||||
drawGraphic(g, gg, cb, area);
|
||||
}
|
||||
}
|
||||
if (graphic instanceof GraphicCollection) {
|
||||
if (((GraphicCollection) graphic).isAvoidCollision() && graphic.getShapeType().isPoint()) {
|
||||
List<Extent> extentList = new ArrayList<>();
|
||||
Extent maxExtent = new Extent();
|
||||
Extent ext = new Extent();
|
||||
PointD point;
|
||||
double[] xy;
|
||||
float size;
|
||||
for (int i = 0; i < graphic.getNumGraphics(); i++) {
|
||||
Graphic gg = graphic.getGraphicN(i);
|
||||
if (gg.getExtent().intersects(this.drawExtent)) {
|
||||
if (!graphic.isSingleLegend()) {
|
||||
cb = gg.getLegend();
|
||||
}
|
||||
PointShape shape = (PointShape) gg.getShape();
|
||||
PointBreak pointBreak = (PointBreak) cb;
|
||||
point = shape.getPoint();
|
||||
xy = projToScreen(point.X, point.Y, area);
|
||||
size = pointBreak.getSize() / 2;
|
||||
ext.minX = xy[0] - size;
|
||||
ext.maxX = xy[0] + size;
|
||||
ext.minY = xy[1] - size;
|
||||
ext.maxY = xy[1] + size;
|
||||
if (extentList.isEmpty()) {
|
||||
maxExtent = (Extent) ext.clone();
|
||||
extentList.add((Extent) ext.clone());
|
||||
drawGraphic(g, gg, cb, area);
|
||||
} else if (!MIMath.isExtentCross(ext, maxExtent)) {
|
||||
extentList.add((Extent) ext.clone());
|
||||
maxExtent = MIMath.getLagerExtent(maxExtent, ext);
|
||||
drawGraphic(g, gg, cb, area);
|
||||
} else {
|
||||
boolean ifDraw = true;
|
||||
for (int j = 0; j < extentList.size(); j++) {
|
||||
if (MIMath.isExtentCross(ext, extentList.get(j))) {
|
||||
ifDraw = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ifDraw) {
|
||||
extentList.add((Extent) ext.clone());
|
||||
maxExtent = MIMath.getLagerExtent(maxExtent, ext);
|
||||
drawGraphic(g, gg, cb, area);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < graphic.getNumGraphics(); i++) {
|
||||
Graphic gg = graphic.getGraphicN(i);
|
||||
if (gg.getExtent().intersects(this.drawExtent)) {
|
||||
if (!graphic.isSingleLegend()) {
|
||||
cb = gg.getLegend();
|
||||
}
|
||||
drawGraphic(g, gg, cb, area);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GraphicCollection gc = (GraphicCollection) graphic;
|
||||
if (gc.getLabelSet().isDrawLabels()) {
|
||||
this.drawLabels(g, gc, area);
|
||||
}
|
||||
} else {
|
||||
if (graphic.getExtent().intersects(this.drawExtent)) {
|
||||
drawGraphic(g, graphic, cb, area);
|
||||
}
|
||||
}
|
||||
|
||||
if (graphic.isClip()) {
|
||||
|
||||
@ -258,7 +258,7 @@ package org.meteoinfo.geometry.graphic;
|
||||
* Get graphic list
|
||||
* @return Graphic list
|
||||
*/
|
||||
public List<Graphic> getGraphics(){
|
||||
public List<Graphic> getGraphics() {
|
||||
List<Graphic> gs = new ArrayList<>();
|
||||
gs.add(this);
|
||||
return gs;
|
||||
|
||||
@ -579,7 +579,11 @@ public class GraphicCollection extends Graphic implements Iterator {
|
||||
*/
|
||||
@Override
|
||||
public ShapeTypes getShapeType() {
|
||||
return this.graphics.get(0).getShape().getShapeType();
|
||||
if (this.graphics.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return this.graphics.get(0).getShape().getShapeType();
|
||||
}
|
||||
}
|
||||
|
||||
private double getMinValue() {
|
||||
|
||||
@ -1,34 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\io\geotiff">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\test"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\traj"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\dataframe"/>
|
||||
<RecentFolder Folder="D:\MyProgram\java\MeteoInfoDev\MeteoInfo\meteoinfo-lab"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\wind">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\funny"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\plot"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\burf"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\wrf"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart\legend"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\geotiff"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\wrf"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\contour"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\awx"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\weather"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\wind"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\funny\flower_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\meteo\calc\frontogenesis.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\geotiff\geotiff_dem_3.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\geotiff\geotiff_dem_2.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\awx\awx_fy2g_amv.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\weather\stationmodel.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\wind\quiverm_5.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\funny\flower_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\meteo\calc\frontogenesis.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\geotiff\geotiff_dem_3.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\geotiff\geotiff_dem_2.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\awx\awx_fy2g_amv.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\weather\stationmodel.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\wind\quiverm_5.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
@ -36,5 +36,5 @@
|
||||
</Font>
|
||||
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
|
||||
<Figure DoubleBuffering="true"/>
|
||||
<Startup MainFormLocation="-7,0" MainFormSize="1363,778"/>
|
||||
<Startup MainFormLocation="-7,-7" MainFormSize="1293,685"/>
|
||||
</MeteoInfo>
|
||||
|
||||
Binary file not shown.
@ -1270,9 +1270,9 @@ class MapAxes(Axes):
|
||||
:param size: (*float*) Base size of the arrows.
|
||||
:param proj: (*ProjectionInfo*) Map projection of the data. Default is None.
|
||||
:param zorder: (*int*) Z-order of created layer for display.
|
||||
:param select: (*boolean*) Set the return layer as selected layer or not.
|
||||
:param avoidcoll: (*boolean*) Avoid graphic collision or not.
|
||||
|
||||
:returns: (*VectoryLayer*) Created barbs VectoryLayer.
|
||||
:returns: (*graphics*) Created barbs graphics.
|
||||
"""
|
||||
cmap = plotutil.getcolormap(**kwargs)
|
||||
fill_value = kwargs.pop('fill_value', -9999.0)
|
||||
@ -1339,6 +1339,10 @@ class MapAxes(Axes):
|
||||
if antialias is not None:
|
||||
graphics.setAntiAlias(antialias)
|
||||
|
||||
avoidcoll = kwargs.pop('avoidcoll', None)
|
||||
if avoidcoll is not None:
|
||||
graphics.setAvoidCollision(avoidcoll)
|
||||
|
||||
visible = kwargs.pop('visible', True)
|
||||
if visible:
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
@ -1357,7 +1361,7 @@ class MapAxes(Axes):
|
||||
:param u: (*array_like*) U component of the arrow vectors (wind field) or wind direction.
|
||||
:param v: (*array_like*) V component of the arrow vectors (wind field) or wind speed.
|
||||
:param z: (*array_like*) Optional, 2-D z value array.
|
||||
:param levs: (*array_like*) Optional. A list of floating point numbers indicating the level
|
||||
:param levels: (*array_like*) Optional. A list of floating point numbers indicating the level
|
||||
barbs to draw, in increasing order.
|
||||
:param cmap: (*string*) Color map string.
|
||||
:param fill_value: (*float*) Fill_value. Default is ``-9999.0``.
|
||||
@ -1365,9 +1369,9 @@ class MapAxes(Axes):
|
||||
:param size: (*float*) Base size of the arrows. Default is 10.
|
||||
:param proj: (*ProjectionInfo*) Map projection of the data. Default is None.
|
||||
:param zorder: (*int*) Z-order of created layer for display.
|
||||
:param select: (*boolean*) Set the return layer as selected layer or not.
|
||||
:param avoidcoll: (*boolean*) Avoid graphic collision or not.
|
||||
|
||||
:returns: (*VectoryLayer*) Created barbs VectoryLayer.
|
||||
:returns: (*GraphicCollection*) Created barbs graphic collection.
|
||||
"""
|
||||
cmap = plotutil.getcolormap(**kwargs)
|
||||
fill_value = kwargs.pop('fill_value', -9999.0)
|
||||
@ -1431,6 +1435,10 @@ class MapAxes(Axes):
|
||||
if antialias is not None:
|
||||
graphics.setAntiAlias(antialias)
|
||||
|
||||
avoidcoll = kwargs.pop('avoidcoll', None)
|
||||
if avoidcoll is not None:
|
||||
graphics.setAvoidCollision(avoidcoll)
|
||||
|
||||
proj = kwargs.pop('proj', migeo.projinfo())
|
||||
visible = kwargs.pop('visible', True)
|
||||
if visible:
|
||||
@ -1528,7 +1536,8 @@ class MapAxes(Axes):
|
||||
:param surface: (*boolean*) Is surface data or not. Default is True.
|
||||
:param size: (*float*) Size of the station model symbols. Default is 12.
|
||||
:param proj: (*ProjectionInfo*) Map projection of the data. Default is None.
|
||||
:param order: (*int*) Z-order of created layer for display.
|
||||
:param zorder: (*int*) Z-order of created layer for display.
|
||||
:param avoidcoll: (*boolean*) Avoid graphic collision or not.
|
||||
|
||||
:returns: (*graphics*) Station model graphics.
|
||||
"""
|
||||
@ -1545,6 +1554,10 @@ class MapAxes(Axes):
|
||||
if antialias is not None:
|
||||
graphics.setAntiAlias(antialias)
|
||||
|
||||
avoidcoll = kwargs.pop('avoidcoll', None)
|
||||
if avoidcoll is not None:
|
||||
graphics.setAvoidCollision(avoidcoll)
|
||||
|
||||
visible = kwargs.pop('visible', True)
|
||||
if visible:
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user