mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
add Artist as base class for drawing objects
This commit is contained in:
parent
7f0b92aa7d
commit
2571a00a5e
@ -21,7 +21,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.meteoinfo.chart.jogl.GLPlot;
|
||||
import org.meteoinfo.chart.plot.MapPlot;
|
||||
import org.meteoinfo.chart.geo.MapPlot;
|
||||
import org.meteoinfo.chart.plot.Plot;
|
||||
import org.meteoinfo.common.PointF;
|
||||
|
||||
|
||||
@ -5,11 +5,7 @@
|
||||
*/
|
||||
package org.meteoinfo.chart;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Path2D;
|
||||
@ -460,6 +456,19 @@ public class ChartColorBar extends ChartLegend {
|
||||
*/
|
||||
@Override
|
||||
public void draw(Graphics2D g, PointF point) {
|
||||
if (this.antiAlias) {
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
|
||||
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
|
||||
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||
g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
|
||||
} else {
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);
|
||||
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
|
||||
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_DEFAULT);
|
||||
g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT);
|
||||
}
|
||||
|
||||
AffineTransform oldMatrix = g.getTransform();
|
||||
g.translate(point.X + this.xshift, point.Y + this.yshift);
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
package org.meteoinfo.chart;
|
||||
|
||||
import org.meteoinfo.common.PointF;
|
||||
import org.meteoinfo.geometry.graphic.Artist;
|
||||
import org.meteoinfo.ui.event.ILocationChangedListener;
|
||||
import org.meteoinfo.ui.event.ISizeChangedListener;
|
||||
import org.meteoinfo.ui.event.LocationChangedEvent;
|
||||
@ -28,7 +29,7 @@ import org.meteoinfo.geometry.graphic.ResizeAbility;
|
||||
*
|
||||
* @author yaqiang
|
||||
*/
|
||||
public abstract class ChartElement {
|
||||
public abstract class ChartElement extends Artist {
|
||||
// <editor-fold desc="Events">
|
||||
|
||||
public void addLocationChangedListener(ILocationChangedListener listener) {
|
||||
|
||||
@ -18,23 +18,19 @@ import org.meteoinfo.geo.drawing.Draw;
|
||||
import com.l2fprod.common.beans.BaseBeanInfo;
|
||||
import com.l2fprod.common.beans.ExtendedPropertyDescriptor;
|
||||
import com.l2fprod.common.beans.editor.ComboBoxPropertyEditor;
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.util.List;
|
||||
import org.meteoinfo.chart.plot.PlotOrientation;
|
||||
import org.meteoinfo.geometry.graphic.Artist;
|
||||
import org.meteoinfo.geometry.legend.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Yaqiang Wang
|
||||
*/
|
||||
public class ChartLegend {
|
||||
public class ChartLegend extends Artist {
|
||||
// <editor-fold desc="Variables">
|
||||
|
||||
//private final XY1DPlot plot;
|
||||
@ -774,6 +770,19 @@ public class ChartLegend {
|
||||
* @param point Start point
|
||||
*/
|
||||
public void draw(Graphics2D g, PointF point) {
|
||||
if (this.antiAlias) {
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
|
||||
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
|
||||
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||
g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
|
||||
} else {
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);
|
||||
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
|
||||
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_DEFAULT);
|
||||
g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT);
|
||||
}
|
||||
|
||||
AffineTransform oldMatrix = g.getTransform();
|
||||
g.translate(point.X + this.xshift, point.Y + this.yshift);
|
||||
|
||||
@ -22,7 +22,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import org.meteoinfo.chart.plot.MapPlot;
|
||||
import org.meteoinfo.chart.geo.MapPlot;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -38,7 +38,6 @@ public class ChartNorthArrow extends ChartElement {
|
||||
// <editor-fold desc="Variables">
|
||||
|
||||
private final MapPlot mapPlot;
|
||||
private final boolean antiAlias;
|
||||
private float lineWidth;
|
||||
private boolean drawNeatLine;
|
||||
private Color neatLineColor;
|
||||
|
||||
@ -22,8 +22,6 @@ import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseMotionAdapter;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.AffineTransformOp;
|
||||
@ -36,7 +34,6 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
@ -61,7 +58,6 @@ import javax.print.StreamPrintServiceFactory;
|
||||
import javax.print.attribute.HashPrintRequestAttributeSet;
|
||||
import javax.print.attribute.PrintRequestAttributeSet;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
@ -69,9 +65,7 @@ import javax.swing.JPopupMenu;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.Timer;
|
||||
import javax.swing.event.EventListenerList;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
import com.jogamp.opengl.awt.GLJPanel;
|
||||
import org.apache.commons.imaging.ImageFormats;
|
||||
import org.apache.commons.imaging.ImageWriteException;
|
||||
import org.freehep.graphics2d.VectorGraphics;
|
||||
@ -80,28 +74,17 @@ import org.freehep.graphicsio.pdf.PDFGraphics2D;
|
||||
import org.freehep.graphicsio.ps.PSGraphics2D;
|
||||
import org.meteoinfo.chart.jogl.EarthGLPlot;
|
||||
import org.meteoinfo.chart.jogl.GLPlot;
|
||||
import org.meteoinfo.chart.plot.MapPlot;
|
||||
import org.meteoinfo.chart.geo.MapPlot;
|
||||
import org.meteoinfo.chart.plot.Plot;
|
||||
import org.meteoinfo.chart.plot.XY1DPlot;
|
||||
import org.meteoinfo.chart.plot.AbstractPlot2D;
|
||||
import org.meteoinfo.chart.plot.Plot3D;
|
||||
import org.meteoinfo.chart.plot.PlotType;
|
||||
import org.meteoinfo.chart.plot3d.Projector;
|
||||
import org.meteoinfo.common.Extent;
|
||||
import org.meteoinfo.common.Extent3D;
|
||||
import org.meteoinfo.common.GenericFileFilter;
|
||||
import org.meteoinfo.common.PointF;
|
||||
import org.meteoinfo.data.mapdata.webmap.TileLoadListener;
|
||||
import org.meteoinfo.geo.layer.LayerTypes;
|
||||
import org.meteoinfo.geo.layer.MapLayer;
|
||||
import org.meteoinfo.geo.layer.RasterLayer;
|
||||
import org.meteoinfo.geo.layer.VectorLayer;
|
||||
import org.meteoinfo.ndarray.DataType;
|
||||
import org.meteoinfo.image.ImageUtil;
|
||||
import org.meteoinfo.geo.mapview.FrmIdentifer;
|
||||
import org.meteoinfo.geo.mapview.FrmIdentiferGrid;
|
||||
import org.meteoinfo.geo.mapview.MapView;
|
||||
import org.meteoinfo.table.Field;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
@ -14,7 +14,7 @@ import java.awt.Rectangle;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Line2D;
|
||||
import org.meteoinfo.chart.plot.MapPlot;
|
||||
import org.meteoinfo.chart.geo.MapPlot;
|
||||
import org.meteoinfo.common.PointF;
|
||||
|
||||
/**
|
||||
@ -44,7 +44,6 @@ public class ChartScaleBar extends ChartElement {
|
||||
// <editor-fold desc="Variables">
|
||||
|
||||
private MapPlot mapPlot;
|
||||
private boolean antiAlias;
|
||||
private float lineWidth;
|
||||
private Font font;
|
||||
private ScaleBarType scaleBarType;
|
||||
|
||||
@ -8,7 +8,7 @@ import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
|
||||
import com.jogamp.opengl.util.gl2.GLUT;
|
||||
import org.meteoinfo.chart.jogl.GLPlot;
|
||||
import org.meteoinfo.chart.jogl.Program;
|
||||
import org.meteoinfo.chart.plot.MapPlot;
|
||||
import org.meteoinfo.chart.geo.MapPlot;
|
||||
import org.meteoinfo.chart.plot.Plot;
|
||||
import org.meteoinfo.common.PointF;
|
||||
|
||||
|
||||
@ -18,43 +18,29 @@ import org.apache.commons.imaging.ImageFormats;
|
||||
import org.apache.commons.imaging.ImageWriteException;
|
||||
import org.freehep.graphics2d.VectorGraphics;
|
||||
import org.freehep.graphicsio.emf.EMFGraphics2D;
|
||||
import org.freehep.graphicsio.pdf.PDFGraphics2D;
|
||||
import org.freehep.graphicsio.ps.PSGraphics2D;
|
||||
import org.meteoinfo.chart.geo.MapPlot;
|
||||
import org.meteoinfo.chart.jogl.*;
|
||||
import org.meteoinfo.chart.plot.*;
|
||||
import org.meteoinfo.chart.plot3d.Projector;
|
||||
import org.meteoinfo.common.Extent;
|
||||
import org.meteoinfo.common.Extent3D;
|
||||
import org.meteoinfo.common.GenericFileFilter;
|
||||
import org.meteoinfo.common.PointF;
|
||||
import org.meteoinfo.data.mapdata.webmap.TileLoadListener;
|
||||
import org.meteoinfo.geo.layer.LayerTypes;
|
||||
import org.meteoinfo.geo.layer.MapLayer;
|
||||
import org.meteoinfo.geo.layer.RasterLayer;
|
||||
import org.meteoinfo.geo.layer.VectorLayer;
|
||||
import org.meteoinfo.geo.mapview.FrmIdentifer;
|
||||
import org.meteoinfo.geo.mapview.FrmIdentiferGrid;
|
||||
import org.meteoinfo.geo.mapview.MapView;
|
||||
import org.meteoinfo.image.ImageUtil;
|
||||
import org.meteoinfo.ndarray.DataType;
|
||||
import org.meteoinfo.table.Field;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import javax.imageio.*;
|
||||
import javax.imageio.metadata.IIOInvalidTreeException;
|
||||
import javax.imageio.metadata.IIOMetadata;
|
||||
import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
|
||||
import javax.imageio.stream.FileImageOutputStream;
|
||||
import javax.imageio.stream.ImageOutputStream;
|
||||
import javax.print.*;
|
||||
import javax.print.attribute.HashPrintRequestAttributeSet;
|
||||
import javax.print.attribute.PrintRequestAttributeSet;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.EventListenerList;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.geom.AffineTransform;
|
||||
@ -69,8 +55,6 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@ -14,6 +14,7 @@ import org.meteoinfo.common.XAlign;
|
||||
import org.meteoinfo.common.YAlign;
|
||||
import org.meteoinfo.common.util.JDateUtil;
|
||||
import org.meteoinfo.geo.drawing.Draw;
|
||||
import org.meteoinfo.geometry.graphic.Artist;
|
||||
import org.meteoinfo.geometry.legend.LineStyles;
|
||||
import org.meteoinfo.ndarray.util.BigDecimalUtil;
|
||||
|
||||
@ -29,7 +30,7 @@ import java.util.List;
|
||||
*
|
||||
* @author yaqiang
|
||||
*/
|
||||
public class Axis implements Cloneable {
|
||||
public class Axis extends Artist implements Cloneable {
|
||||
|
||||
// <editor-fold desc="Variables">
|
||||
protected boolean xAxis;
|
||||
@ -767,54 +768,6 @@ public class Axis implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Get if is time axis
|
||||
// *
|
||||
// * @return Boolean
|
||||
// */
|
||||
// public boolean isTimeAxis() {
|
||||
// return this.timeAxis;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set if is time axis
|
||||
// *
|
||||
// * @param value Boolean
|
||||
// */
|
||||
// public void setTimeAxis(boolean value) {
|
||||
// this.timeAxis = value;
|
||||
// }
|
||||
// /**
|
||||
// * Get time format
|
||||
// * @return Time format
|
||||
// */
|
||||
// public String getTimeFormat(){
|
||||
// return this.timeFormat;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set time format
|
||||
// * @param value
|
||||
// */
|
||||
// public void setTimeFormat(String value){
|
||||
// this.timeFormat = value;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Get time unit
|
||||
// * @return Time unit
|
||||
// */
|
||||
// public TimeUnit getTimeUnit(){
|
||||
// return this.timeUnit;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set time unit
|
||||
// * @param value Time unit
|
||||
// */
|
||||
// public void setTimeUnit(TimeUnit value){
|
||||
// this.timeUnit = value;
|
||||
// }
|
||||
/**
|
||||
* Get if is inverse
|
||||
*
|
||||
@ -833,24 +786,6 @@ public class Axis implements Cloneable {
|
||||
this.inverse = value;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Get shift
|
||||
// *
|
||||
// * @return Shift
|
||||
// */
|
||||
// public float getShift() {
|
||||
// return this.shift;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set shift
|
||||
// *
|
||||
// * @param value Shift
|
||||
// */
|
||||
// public void setShift(float value) {
|
||||
// this.shift = value;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Tick locations
|
||||
*
|
||||
@ -1485,6 +1420,21 @@ public class Axis implements Cloneable {
|
||||
if (plot.getDrawExtent() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.antiAlias) {
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
|
||||
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
|
||||
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||
g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
|
||||
} else {
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);
|
||||
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
|
||||
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_DEFAULT);
|
||||
g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT);
|
||||
}
|
||||
|
||||
if (this.xAxis) {
|
||||
this.drawXAxis(g, area, plot);
|
||||
} else {
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
package org.meteoinfo.chart.axis;
|
||||
|
||||
import org.meteoinfo.chart.ChartText;
|
||||
import org.meteoinfo.chart.plot.MapGridLine;
|
||||
import org.meteoinfo.chart.geo.MapGridLine;
|
||||
import org.meteoinfo.common.DataConvert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -5,20 +5,16 @@
|
||||
*/
|
||||
package org.meteoinfo.chart.axis;
|
||||
|
||||
import org.meteoinfo.chart.ChartText;
|
||||
import org.meteoinfo.chart.Location;
|
||||
import org.meteoinfo.chart.plot.AbstractPlot2D;
|
||||
import org.meteoinfo.chart.plot.MapGridLine;
|
||||
import org.meteoinfo.chart.geo.MapGridLine;
|
||||
import org.meteoinfo.common.*;
|
||||
import org.meteoinfo.geo.drawing.Draw;
|
||||
import org.meteoinfo.projection.KnownCoordinateSystems;
|
||||
import org.meteoinfo.projection.ProjectionInfo;
|
||||
import org.meteoinfo.projection.Reproject;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package org.meteoinfo.chart.plot;
|
||||
package org.meteoinfo.chart.geo;
|
||||
|
||||
import org.meteoinfo.chart.axis.PositionType;
|
||||
import org.meteoinfo.chart.plot.GridLabelPosition;
|
||||
import org.meteoinfo.chart.plot.GridLine;
|
||||
import org.meteoinfo.common.*;
|
||||
import org.meteoinfo.geometry.geoprocess.GeoComputation;
|
||||
import org.meteoinfo.geometry.graphic.Graphic;
|
||||
@ -1,5 +1,6 @@
|
||||
package org.meteoinfo.chart.plot;
|
||||
package org.meteoinfo.chart.geo;
|
||||
|
||||
import org.meteoinfo.chart.geo.MapGridLine;
|
||||
import org.meteoinfo.geometry.graphic.GraphicCollection3D;
|
||||
import org.meteoinfo.common.Extent;
|
||||
import org.meteoinfo.common.Extent3D;
|
||||
@ -3,34 +3,33 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.meteoinfo.chart.plot;
|
||||
package org.meteoinfo.chart.geo;
|
||||
|
||||
import org.meteoinfo.chart.*;
|
||||
import org.meteoinfo.chart.axis.Axis;
|
||||
import org.meteoinfo.chart.axis.LonLatAxis;
|
||||
import org.meteoinfo.chart.axis.ProjLonLatAxis;
|
||||
import org.meteoinfo.chart.geo.MapGridLine;
|
||||
import org.meteoinfo.chart.graphic.WebMapImage;
|
||||
import org.meteoinfo.chart.shape.PolylineErrorShape;
|
||||
import org.meteoinfo.chart.plot.Plot2D;
|
||||
import org.meteoinfo.chart.plot.PlotType;
|
||||
import org.meteoinfo.common.*;
|
||||
import org.meteoinfo.data.Dataset;
|
||||
import org.meteoinfo.data.mapdata.webmap.IWebMapPanel;
|
||||
import org.meteoinfo.data.mapdata.webmap.TileLoadListener;
|
||||
import org.meteoinfo.geo.drawing.Draw;
|
||||
import org.meteoinfo.geo.graphic.GeoGraphicCollection;
|
||||
import org.meteoinfo.geo.util.GeoProjectionUtil;
|
||||
import org.meteoinfo.geometry.graphic.Graphic;
|
||||
import org.meteoinfo.geometry.graphic.GraphicCollection;
|
||||
import org.meteoinfo.geometry.graphic.Line2DGraphic;
|
||||
import org.meteoinfo.geometry.legend.*;
|
||||
import org.meteoinfo.geometry.shape.*;
|
||||
import org.meteoinfo.geometry.shape.Polygon;
|
||||
import org.meteoinfo.geometry.shape.Shape;
|
||||
import org.meteoinfo.projection.KnownCoordinateSystems;
|
||||
import org.meteoinfo.projection.ProjectionInfo;
|
||||
import org.meteoinfo.projection.ProjectionUtil;
|
||||
import org.meteoinfo.projection.Reproject;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
@ -44,9 +43,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -436,7 +432,7 @@ public class MapPlot extends Plot2D implements IWebMapPanel {
|
||||
}
|
||||
|
||||
@Override
|
||||
void drawGraph(Graphics2D g, Rectangle2D area) {
|
||||
protected void drawGraph(Graphics2D g, Rectangle2D area) {
|
||||
//fill boundary polygon
|
||||
java.awt.Shape oldRegion = g.getClip();
|
||||
if (this.clip) {
|
||||
@ -474,7 +470,7 @@ public class MapPlot extends Plot2D implements IWebMapPanel {
|
||||
}
|
||||
|
||||
@Override
|
||||
void plotGraphics(Graphics2D g, Rectangle2D area) {
|
||||
protected void plotGraphics(Graphics2D g, Rectangle2D area) {
|
||||
int barIdx = 0;
|
||||
for (int m = 0; m < this.graphics.getNumGraphics(); m++) {
|
||||
Graphic graphic = this.graphics.get(m);
|
||||
@ -493,6 +489,12 @@ public class MapPlot extends Plot2D implements IWebMapPanel {
|
||||
if (graphic.getExtent().intersects(this.drawExtent)) {
|
||||
drawGraphics(g, graphic, area);
|
||||
}
|
||||
|
||||
if (this.isLonLatMap() && graphic instanceof GeoGraphicCollection) {
|
||||
if (this.drawExtent.maxX > 180) {
|
||||
drawGraphics(g, ((GeoGraphicCollection) graphic).xShiftCopy(360), area);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -565,7 +567,7 @@ public class MapPlot extends Plot2D implements IWebMapPanel {
|
||||
this.addGraphic(graphic);
|
||||
return graphic;
|
||||
} else {
|
||||
Graphic nGraphic = ProjectionUtil.projectClipGraphic(graphic, proj, toProj);
|
||||
Graphic nGraphic = GeoProjectionUtil.projectClipGraphic(graphic, proj, toProj);
|
||||
this.addGraphic(nGraphic);
|
||||
return nGraphic;
|
||||
}
|
||||
@ -585,61 +587,12 @@ public class MapPlot extends Plot2D implements IWebMapPanel {
|
||||
this.addGraphic(index, graphic);
|
||||
return graphic;
|
||||
} else {
|
||||
Graphic nGraphic = ProjectionUtil.projectClipGraphic(graphic, proj, toProj);
|
||||
Graphic nGraphic = GeoProjectionUtil.projectClipGraphic(graphic, proj, toProj);
|
||||
this.addGraphic(index, nGraphic);
|
||||
return nGraphic;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add graphics
|
||||
*
|
||||
* @param graphics The graphics
|
||||
* @param proj The graphic projection
|
||||
* @return Added graphics
|
||||
*/
|
||||
public GraphicCollection addGraphics(GraphicCollection graphics, ProjectionInfo proj) {
|
||||
|
||||
ProjectionInfo toProj = this.projInfo;
|
||||
if (proj.equals(toProj)) {
|
||||
for (int i = 0; i < graphics.getNumGraphics(); i++)
|
||||
this.addGraphic(graphics.getGraphicN(i));
|
||||
return graphics;
|
||||
} else {
|
||||
GraphicCollection nGraphics = new GraphicCollection();
|
||||
for (int i = 0; i < graphics.getNumGraphics(); i++) {
|
||||
Graphic nGraphic = ProjectionUtil.projectClipGraphic(graphics.getGraphicN(i), proj, toProj);
|
||||
nGraphics.add(nGraphic);
|
||||
this.addGraphic(nGraphic);
|
||||
}
|
||||
return nGraphics;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add graphics
|
||||
*
|
||||
* @param index The graphics index
|
||||
* @param graphics The graphics
|
||||
* @param proj The graphic projection
|
||||
* @return Added graphics
|
||||
*/
|
||||
public GraphicCollection addGraphics(int index, GraphicCollection graphics, ProjectionInfo proj) {
|
||||
ProjectionInfo toProj = this.projInfo;
|
||||
if (proj.equals(toProj)) {
|
||||
this.addGraphic(index, graphics);
|
||||
return graphics;
|
||||
} else {
|
||||
GraphicCollection nGraphics = new GraphicCollection();
|
||||
for (int i = 0; i < graphics.getNumGraphics(); i++) {
|
||||
Graphic nGraphic = ProjectionUtil.projectClipGraphic(graphics.getGraphicN(i), proj, toProj);
|
||||
this.addGraphic(nGraphic);
|
||||
}
|
||||
this.addGraphic(nGraphics);
|
||||
return nGraphics;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addText(ChartText text) {
|
||||
addText(text, true);
|
||||
@ -932,10 +885,25 @@ public class MapPlot extends Plot2D implements IWebMapPanel {
|
||||
return graphic;
|
||||
}
|
||||
|
||||
void drawGridLine(Graphics2D g, Rectangle2D area) {
|
||||
@Override
|
||||
protected void drawGridLine(Graphics2D g, Rectangle2D area) {
|
||||
if (this.projInfo.isLonLat()) {
|
||||
super.drawGridLine(g, area);
|
||||
} else {
|
||||
if (this.antiAlias) {
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
|
||||
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
|
||||
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||
g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
|
||||
} else {
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);
|
||||
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
|
||||
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_DEFAULT);
|
||||
g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT);
|
||||
}
|
||||
|
||||
AffineTransform oldMatrix = g.getTransform();
|
||||
java.awt.Shape oldRegion = g.getClip();
|
||||
if (this.clip) {
|
||||
@ -6,8 +6,8 @@ import org.joml.Vector3f;
|
||||
import org.meteoinfo.chart.ChartText;
|
||||
import org.meteoinfo.geometry.graphic.GraphicCollection3D;
|
||||
import org.meteoinfo.chart.graphic.GraphicProjectionUtil;
|
||||
import org.meteoinfo.chart.plot.MapGridLine;
|
||||
import org.meteoinfo.chart.plot.MapGridLine3D;
|
||||
import org.meteoinfo.chart.geo.MapGridLine;
|
||||
import org.meteoinfo.chart.geo.MapGridLine3D;
|
||||
import org.meteoinfo.common.*;
|
||||
import org.meteoinfo.geometry.graphic.Graphic;
|
||||
import org.meteoinfo.projection.ProjectionInfo;
|
||||
|
||||
@ -55,6 +55,7 @@ public abstract class AbstractPlot2D extends Plot {
|
||||
protected double aspect = 1;
|
||||
protected boolean clip = true;
|
||||
protected boolean fixDrawExtent = false;
|
||||
protected boolean antiAlias = false;
|
||||
|
||||
// </editor-fold>
|
||||
// <editor-fold desc="Constructor">
|
||||
@ -719,6 +720,22 @@ public abstract class AbstractPlot2D extends Plot {
|
||||
this.fixDrawExtent = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return antiAlias
|
||||
* @return AntiAlias
|
||||
*/
|
||||
public boolean isAntiAlias() {
|
||||
return this.antiAlias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set antiAlias
|
||||
* @param value Set antiAlias
|
||||
*/
|
||||
public void setAntiAlias(boolean value) {
|
||||
this.antiAlias = value;
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
// <editor-fold desc="Method">
|
||||
/**
|
||||
@ -1178,11 +1195,25 @@ public abstract class AbstractPlot2D extends Plot {
|
||||
}
|
||||
}
|
||||
|
||||
void drawGridLine(Graphics2D g, Rectangle2D area) {
|
||||
protected void drawGridLine(Graphics2D g, Rectangle2D area) {
|
||||
if (!this.gridLine.isDrawXLine() && !this.gridLine.isDrawYLine()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.gridLine.isAntiAlias()) {
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
|
||||
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
|
||||
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||
g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
|
||||
} else {
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);
|
||||
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
|
||||
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_DEFAULT);
|
||||
g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT);
|
||||
}
|
||||
|
||||
double[] xy;
|
||||
double x, y;
|
||||
double miny = area.getY();
|
||||
@ -1247,6 +1278,20 @@ public abstract class AbstractPlot2D extends Plot {
|
||||
abstract void drawGraph(Graphics2D g, Rectangle2D area);
|
||||
|
||||
void drawAxis(Graphics2D g, Rectangle2D area) {
|
||||
if (this.antiAlias) {
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
|
||||
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
|
||||
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||
g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
|
||||
} else {
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);
|
||||
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
|
||||
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_DEFAULT);
|
||||
g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT);
|
||||
}
|
||||
|
||||
for (Location loc : this.axis.keySet()) {
|
||||
Axis ax = this.axis.get(loc);
|
||||
if (ax.isVisible()) {
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
package org.meteoinfo.chart.plot;
|
||||
|
||||
import org.meteoinfo.common.colors.ColorUtil;
|
||||
import org.meteoinfo.geometry.graphic.Artist;
|
||||
import org.meteoinfo.geometry.legend.LineStyles;
|
||||
import org.meteoinfo.geometry.legend.PolylineBreak;
|
||||
|
||||
@ -15,7 +16,7 @@ import java.awt.*;
|
||||
*
|
||||
* @author yaqiang
|
||||
*/
|
||||
public class GridLine {
|
||||
public class GridLine extends Artist {
|
||||
// <editor-fold desc="Variables">
|
||||
protected PolylineBreak lineBreak;
|
||||
protected boolean drawXLine;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -40,7 +40,7 @@ public class PiePlot extends Plot2D {
|
||||
// </editor-fold>
|
||||
// <editor-fold desc="Methods">
|
||||
@Override
|
||||
void drawGraph(Graphics2D g, Rectangle2D area) {
|
||||
protected void drawGraph(Graphics2D g, Rectangle2D area) {
|
||||
AffineTransform oldMatrix = g.getTransform();
|
||||
//Rectangle oldRegion = g.getClipBounds();
|
||||
//g.setClip(area);
|
||||
|
||||
@ -168,7 +168,7 @@ public class Plot2D extends AbstractPlot2D {
|
||||
}
|
||||
|
||||
@Override
|
||||
void drawGraph(Graphics2D g, Rectangle2D area) {
|
||||
protected void drawGraph(Graphics2D g, Rectangle2D area) {
|
||||
AffineTransform oldMatrix = g.getTransform();
|
||||
java.awt.Shape oldRegion = g.getClip();
|
||||
if (this.clip) {
|
||||
@ -271,7 +271,7 @@ public class Plot2D extends AbstractPlot2D {
|
||||
g.setTransform(oldMatrix);
|
||||
}
|
||||
|
||||
void plotGraphics(Graphics2D g, Rectangle2D area) {
|
||||
protected void plotGraphics(Graphics2D g, Rectangle2D area) {
|
||||
int barIdx = 0;
|
||||
for (int m = 0; m < this.graphics.getNumGraphics(); m++) {
|
||||
Graphic graphic = this.graphics.get(m);
|
||||
@ -290,7 +290,21 @@ public class Plot2D extends AbstractPlot2D {
|
||||
}
|
||||
}
|
||||
|
||||
void drawGraphics(Graphics2D g, Graphic graphic, Rectangle2D area) {
|
||||
protected void drawGraphics(Graphics2D g, Graphic graphic, Rectangle2D area) {
|
||||
if (graphic.isAntiAlias()) {
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
|
||||
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
|
||||
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||
g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
|
||||
} else {
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);
|
||||
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
|
||||
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_DEFAULT);
|
||||
g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT);
|
||||
}
|
||||
|
||||
java.awt.Shape oldClip = g.getClip();
|
||||
if (graphic.isClip()) {
|
||||
GeneralPath clipPath = getClipPath(graphic.getClipGraphic(), area);
|
||||
@ -324,7 +338,7 @@ public class Plot2D extends AbstractPlot2D {
|
||||
drawGraphic(g, graphic, cb, area);
|
||||
}
|
||||
|
||||
void drawGraphic(Graphics2D g, Graphic graphic, ColorBreak cb, Rectangle2D area) {
|
||||
protected void drawGraphic(Graphics2D g, Graphic graphic, ColorBreak cb, Rectangle2D area) {
|
||||
if (graphic instanceof Line2DGraphic) {
|
||||
this.drawLine2D(g, (Line2DGraphic) graphic, area);
|
||||
return;
|
||||
@ -1189,7 +1203,7 @@ public class Plot2D extends AbstractPlot2D {
|
||||
return n;
|
||||
}
|
||||
|
||||
void drawBars(Graphics2D g, GraphicCollection bars, int barIdx, Rectangle2D area) {
|
||||
protected void drawBars(Graphics2D g, GraphicCollection bars, int barIdx, Rectangle2D area) {
|
||||
double[] xy;
|
||||
xy = this.projToScreen(0, 0, area);
|
||||
float y0 = (float) xy[1];
|
||||
@ -1336,7 +1350,7 @@ public class Plot2D extends AbstractPlot2D {
|
||||
}
|
||||
|
||||
@Override
|
||||
Extent getAutoExtent() {
|
||||
protected Extent getAutoExtent() {
|
||||
this.graphics.updateExtent();
|
||||
Extent extent = (Extent)this.graphics.getExtent().clone();
|
||||
if (extent.minX == extent.maxX) {
|
||||
|
||||
@ -292,7 +292,7 @@ public class PolarPlot extends Plot2D {
|
||||
}
|
||||
|
||||
@Override
|
||||
Extent getAutoExtent() {
|
||||
protected Extent getAutoExtent() {
|
||||
Extent extent = this.getGraphics().getExtent();
|
||||
if (extent.minX == extent.maxX) {
|
||||
extent.minX = extent.minX - Math.abs(extent.minX);
|
||||
@ -489,12 +489,12 @@ public class PolarPlot extends Plot2D {
|
||||
}
|
||||
|
||||
@Override
|
||||
void drawGraph(Graphics2D g, Rectangle2D area) {
|
||||
protected void drawGraph(Graphics2D g, Rectangle2D area) {
|
||||
super.drawGraph(g, area);
|
||||
}
|
||||
|
||||
@Override
|
||||
void drawGridLine(Graphics2D g, Rectangle2D area) {
|
||||
protected void drawGridLine(Graphics2D g, Rectangle2D area) {
|
||||
GridLine gridLine = this.getGridLine();
|
||||
if (!gridLine.isDrawXLine() && !gridLine.isDrawYLine()) {
|
||||
return;
|
||||
|
||||
@ -163,6 +163,7 @@ public class MICAPS11DataInfo extends DataInfo implements IGridDataInfo {
|
||||
_yArray[i] = YMin + i * YDelt;
|
||||
}
|
||||
|
||||
this.addAttribute(new Attribute("data_format", "MICAPS 11"));
|
||||
Dimension tdim = new Dimension(DimensionType.T);
|
||||
tdim.setShortName("time");
|
||||
double[] values = new double[1];
|
||||
|
||||
@ -27,6 +27,7 @@ import java.io.*;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParseException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -170,6 +171,7 @@ public class MICAPS4DataInfo extends DataInfo implements IGridDataInfo {
|
||||
_yArray[i] = YMin + i * YDelt;
|
||||
}
|
||||
|
||||
this.addAttribute(new Attribute("data_format", "MICAPS 4"));
|
||||
Dimension tdim = new Dimension(DimensionType.T);
|
||||
double[] values = new double[1];
|
||||
values[0] = JDateUtil.toOADate(time);
|
||||
@ -212,6 +214,17 @@ public class MICAPS4DataInfo extends DataInfo implements IGridDataInfo {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateInfoText() {
|
||||
String dataInfo;
|
||||
dataInfo = "Description: " + _description;
|
||||
DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:00");
|
||||
dataInfo += System.getProperty("line.separator") + "Time: " + format.format(this.getTimes().get(0));
|
||||
dataInfo += System.getProperty("line.separator") + super.generateInfoText();
|
||||
|
||||
return dataInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read array data of a variable
|
||||
*
|
||||
|
||||
@ -59,6 +59,18 @@ public class MICAPSDataInfo {
|
||||
dataArray = aLine.split("\\s+");
|
||||
dataType = dataArray[0] + " " + dataArray[1];
|
||||
dataType = dataType.trim().toLowerCase();
|
||||
if (dataType.equals("diamond 11")) {
|
||||
mdType = MeteoDataType.MICAPS_11;
|
||||
}
|
||||
if (dataType.equals("diamond 13")) {
|
||||
mdType = MeteoDataType.MICAPS_13;
|
||||
}
|
||||
if (dataType.contains("iamond 120")) {
|
||||
mdType = MeteoDataType.MICAPS_120;
|
||||
}
|
||||
if (dataType.contains("diamond 131")) {
|
||||
mdType = MeteoDataType.MICAPS_131;
|
||||
}
|
||||
if (dataType.contains("diamond 1")) {
|
||||
mdType = MeteoDataType.MICAPS_1;
|
||||
}
|
||||
@ -74,18 +86,6 @@ public class MICAPSDataInfo {
|
||||
if (dataType.equals("diamond 7")) {
|
||||
mdType = MeteoDataType.MICAPS_7;
|
||||
}
|
||||
if (dataType.equals("diamond 11")) {
|
||||
mdType = MeteoDataType.MICAPS_11;
|
||||
}
|
||||
if (dataType.equals("diamond 13")) {
|
||||
mdType = MeteoDataType.MICAPS_13;
|
||||
}
|
||||
if (dataType.contains("iamond 120")) {
|
||||
mdType = MeteoDataType.MICAPS_120;
|
||||
}
|
||||
if (dataType.contains("diamond 131")) {
|
||||
mdType = MeteoDataType.MICAPS_131;
|
||||
}
|
||||
if (mdType == null) {
|
||||
System.out.println(String.format("Unknown MICAPS data file type: %s", dataType));
|
||||
}
|
||||
@ -126,7 +126,15 @@ public class MICAPSDataInfo {
|
||||
StringTokenizer stoker = new StringTokenizer(line);
|
||||
if (stoker.countTokens() >= 2) {
|
||||
String dataType = stoker.nextToken() + " " + stoker.nextToken();
|
||||
if (dataType.contains("diamond 1")) {
|
||||
if (dataType.equals("diamond 11")) {
|
||||
dataInfo = new MICAPS11DataInfo();
|
||||
} else if (dataType.equals("diamond 13")) {
|
||||
dataInfo = new MICAPS13DataInfo();
|
||||
} else if (dataType.contains("iamond 120")) {
|
||||
dataInfo = new MICAPS120DataInfo();
|
||||
} else if (dataType.contains("diamond 131")) {
|
||||
dataInfo = new MICAPS131DataInfo();
|
||||
} else if (dataType.contains("diamond 1")) {
|
||||
dataInfo = new MICAPS1DataInfo();
|
||||
} else if (dataType.equals("diamond 2")) {
|
||||
dataInfo = new MICAPS2DataInfo();
|
||||
@ -136,14 +144,6 @@ public class MICAPSDataInfo {
|
||||
dataInfo = new MICAPS4DataInfo();
|
||||
} else if (dataType.equals("diamond 7")) {
|
||||
dataInfo = new MICAPS7DataInfo();
|
||||
} else if (dataType.equals("diamond 11")) {
|
||||
dataInfo = new MICAPS11DataInfo();
|
||||
} else if (dataType.equals("diamond 13")) {
|
||||
dataInfo = new MICAPS13DataInfo();
|
||||
} else if (dataType.contains("iamond 120")) {
|
||||
dataInfo = new MICAPS120DataInfo();
|
||||
} else if (dataType.contains("diamond 131")) {
|
||||
dataInfo = new MICAPS131DataInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,184 @@
|
||||
package org.meteoinfo.geo.graphic;
|
||||
|
||||
import org.meteoinfo.common.DataConvert;
|
||||
import org.meteoinfo.common.Extent;
|
||||
import org.meteoinfo.common.MIMath;
|
||||
import org.meteoinfo.common.PointD;
|
||||
import org.meteoinfo.geometry.graphic.Graphic;
|
||||
import org.meteoinfo.geometry.graphic.GraphicCollection;
|
||||
import org.meteoinfo.geometry.legend.ColorBreak;
|
||||
import org.meteoinfo.geometry.legend.LabelBreak;
|
||||
import org.meteoinfo.geometry.legend.LegendType;
|
||||
import org.meteoinfo.geometry.shape.PointShape;
|
||||
import org.meteoinfo.geometry.shape.PolylineShape;
|
||||
import org.meteoinfo.geometry.shape.Shape;
|
||||
import org.meteoinfo.projection.ProjectionInfo;
|
||||
import org.meteoinfo.table.AttributeTable;
|
||||
import org.meteoinfo.table.Field;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GeoGraphicCollection extends GraphicCollection {
|
||||
|
||||
protected AttributeTable attributeTable;
|
||||
protected ProjectionInfo projInfo;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public GeoGraphicCollection() {
|
||||
super();
|
||||
|
||||
this.attributeTable = new AttributeTable();
|
||||
this.projInfo = ProjectionInfo.LONG_LAT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attribute table
|
||||
* @return Attribute table
|
||||
*/
|
||||
public AttributeTable getAttributeTable() {
|
||||
return this.attributeTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set attribute table
|
||||
* @param value Attribute table
|
||||
*/
|
||||
public void setAttributeTable(AttributeTable value) {
|
||||
this.attributeTable = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get projection info
|
||||
* @return Projection info
|
||||
*/
|
||||
public ProjectionInfo getProjInfo() {
|
||||
return this.projInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set projection info
|
||||
* @param value Projection info
|
||||
*/
|
||||
public void setProjInfo(ProjectionInfo value) {
|
||||
this.projInfo = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell value
|
||||
*
|
||||
* @param fieldName Field name
|
||||
* @param shapeIndex Shape index
|
||||
* @return Cell value
|
||||
*/
|
||||
public Object getCellValue(String fieldName, int shapeIndex) {
|
||||
return attributeTable.getTable().getValue(shapeIndex, fieldName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get minimum data value of a field
|
||||
*
|
||||
* @param fieldName Field name
|
||||
* @return Minimum data
|
||||
*/
|
||||
public double getMinValue(String fieldName) {
|
||||
if (((Field) attributeTable.getTable().getColumns().get(fieldName)).isNumeric()) {
|
||||
double min = 0;
|
||||
int dNum = 0;
|
||||
for (int i = 0; i < this.getNumGraphics(); i++) {
|
||||
double aValue = Double.parseDouble(getCellValue(fieldName, i).toString());
|
||||
if (Math.abs(aValue / this.getLegendScheme().getUndefValue() - 1) < 0.01) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (dNum == 0) {
|
||||
min = aValue;
|
||||
} else if (min > aValue) {
|
||||
min = aValue;
|
||||
}
|
||||
dNum += 1;
|
||||
}
|
||||
return min;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add labels
|
||||
*/
|
||||
protected void addLabelsByColor() {
|
||||
int shapeIdx = -1;
|
||||
PointD aPoint;
|
||||
|
||||
String dFormat = "%1$.1f";
|
||||
boolean isData = false;
|
||||
if (((Field) attributeTable.getTable().getColumns().get(labelSet.getFieldName())).isNumeric()) {
|
||||
if (labelSet.isAutoDecimal()) {
|
||||
double min = getMinValue(labelSet.getFieldName());
|
||||
labelSet.setDecimalDigits(MIMath.getDecimalNum(min));
|
||||
}
|
||||
|
||||
dFormat = "%1$." + String.valueOf(labelSet.getDecimalDigits()) + "f";
|
||||
isData = true;
|
||||
}
|
||||
|
||||
for (Graphic graphic : this.graphics) {
|
||||
Shape shape = graphic.getShape();
|
||||
shapeIdx += 1;
|
||||
ColorBreak aCB = graphic.getLegend();
|
||||
if (!aCB.isDrawShape()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PointShape aPS = new PointShape();
|
||||
switch (this.getShapeType()) {
|
||||
case POINT:
|
||||
case POINT_M:
|
||||
case POINT_Z:
|
||||
aPS.setPoint((PointD) ((PointShape) shape).getPoint().clone());
|
||||
break;
|
||||
case POLYLINE:
|
||||
case POLYLINE_M:
|
||||
case POLYLINE_Z:
|
||||
int pIdx = ((PolylineShape) shape).getPoints().size() / 2;
|
||||
aPS.setPoint((PointD) ((PolylineShape) shape).getPoints().get(pIdx - 1).clone());
|
||||
break;
|
||||
case POLYGON:
|
||||
case POLYGON_M:
|
||||
case POLYGON_Z:
|
||||
Extent aExtent = shape.getExtent();
|
||||
aPoint = new PointD();
|
||||
aPoint.X = ((aExtent.minX + aExtent.maxX) / 2);
|
||||
aPoint.Y = ((aExtent.minY + aExtent.maxY) / 2);
|
||||
aPS.setPoint(aPoint);
|
||||
break;
|
||||
}
|
||||
|
||||
LabelBreak aLP = new LabelBreak();
|
||||
if (isData) {
|
||||
if (this.labelSet.isAutoDecimal()) {
|
||||
aLP.setText(DataConvert.removeTailingZeros(getCellValue(labelSet.getFieldName(), shapeIdx).toString()));
|
||||
} else {
|
||||
aLP.setText(String.format(dFormat, Double.parseDouble(getCellValue(labelSet.getFieldName(), shapeIdx).toString())));
|
||||
}
|
||||
} else {
|
||||
aLP.setText(getCellValue(labelSet.getFieldName(), shapeIdx).toString());
|
||||
}
|
||||
|
||||
if (labelSet.isColorByLegend()) {
|
||||
aLP.setColor(aCB.getColor());
|
||||
} else {
|
||||
aLP.setColor(labelSet.getLabelColor());
|
||||
}
|
||||
aLP.setFont(labelSet.getLabelFont());
|
||||
aLP.setAlignType(labelSet.getLabelAlignType());
|
||||
aLP.setYShift(labelSet.getYOffset());
|
||||
aLP.setXShift(labelSet.getXOffset());
|
||||
Graphic aGraphic = new Graphic(aPS, aLP);
|
||||
addLabel(aGraphic);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -14,6 +14,7 @@
|
||||
package org.meteoinfo.geo.layer;
|
||||
|
||||
import org.meteoinfo.common.*;
|
||||
import org.meteoinfo.geo.graphic.GeoGraphicCollection;
|
||||
import org.meteoinfo.geo.mapdata.ShapeFileManage;
|
||||
import org.meteoinfo.geometry.graphic.GraphicCollection;
|
||||
import org.meteoinfo.geometry.legend.*;
|
||||
@ -2830,7 +2831,7 @@ public class VectorLayer extends MapLayer {
|
||||
*
|
||||
* @return Graphics
|
||||
*/
|
||||
public GraphicCollection getGraphics() {
|
||||
public GeoGraphicCollection getGraphics() {
|
||||
return getGraphics(0);
|
||||
}
|
||||
|
||||
@ -2840,8 +2841,10 @@ public class VectorLayer extends MapLayer {
|
||||
* @param xShift X shift
|
||||
* @return Graphics
|
||||
*/
|
||||
public GraphicCollection getGraphics(double xShift) {
|
||||
GraphicCollection graphics = new GraphicCollection();
|
||||
public GeoGraphicCollection getGraphics(double xShift) {
|
||||
GeoGraphicCollection graphics = new GeoGraphicCollection();
|
||||
graphics.setAttributeTable(this._attributeTable);
|
||||
graphics.setProjInfo(this._projInfo);
|
||||
ColorBreak cb;
|
||||
if (xShift == 0) {
|
||||
for (Shape shape : this.shapes) {
|
||||
|
||||
@ -17,8 +17,11 @@ import org.meteoinfo.common.Extent;
|
||||
import org.meteoinfo.common.MIMath;
|
||||
import org.meteoinfo.common.PointD;
|
||||
import org.meteoinfo.data.GridArray;
|
||||
import org.meteoinfo.geo.graphic.GeoGraphicCollection;
|
||||
import org.meteoinfo.geo.layer.RasterLayer;
|
||||
import org.meteoinfo.geo.layer.VectorLayer;
|
||||
import org.meteoinfo.geometry.graphic.Graphic;
|
||||
import org.meteoinfo.geometry.graphic.GraphicCollection;
|
||||
import org.meteoinfo.geometry.shape.*;
|
||||
import org.meteoinfo.geometry.geoprocess.GeoComputation;
|
||||
import org.meteoinfo.geometry.geoprocess.GeometryUtil;
|
||||
@ -643,4 +646,52 @@ public class GeoProjectionUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Project graphic
|
||||
*
|
||||
* @param graphic The graphic
|
||||
* @param fromProj From projection
|
||||
* @param toProj To projection
|
||||
* @return Projected graphic
|
||||
*/
|
||||
public static Graphic projectClipGraphic(Graphic graphic, ProjectionInfo fromProj, ProjectionInfo toProj) {
|
||||
if (graphic instanceof GeoGraphicCollection) {
|
||||
GeoGraphicCollection geoGraphic = (GeoGraphicCollection) graphic;
|
||||
try {
|
||||
GeoGraphicCollection newGCollection = new GeoGraphicCollection();
|
||||
DataTable dataTable = new DataTable();
|
||||
for (DataColumn aDC : geoGraphic.getAttributeTable().getTable().getColumns()) {
|
||||
Field bDC = new Field(aDC.getColumnName(), aDC.getDataType());
|
||||
dataTable.getColumns().add(bDC);
|
||||
}
|
||||
int idx = 0;
|
||||
for (Graphic aGraphic : geoGraphic.getGraphics()) {
|
||||
List<? extends Shape> shapes = ProjectionUtil.projectClipShape(aGraphic.getShape(), fromProj, toProj);
|
||||
if (shapes != null && shapes.size() > 0) {
|
||||
aGraphic.setShape(shapes.get(0));
|
||||
newGCollection.add(aGraphic);
|
||||
DataRow aDR = geoGraphic.getAttributeTable().getTable().getRows().get(idx);
|
||||
try {
|
||||
dataTable.addRow(aDR);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(GeoProjectionUtil.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
idx += 1;
|
||||
}
|
||||
newGCollection.setLegendScheme(geoGraphic.getLegendScheme());
|
||||
newGCollection.setSingleLegend(geoGraphic.isSingleLegend());
|
||||
newGCollection.getAttributeTable().setTable(dataTable);
|
||||
newGCollection.setProjInfo(toProj);
|
||||
|
||||
return newGCollection;
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return ProjectionUtil.projectClipGraphic(graphic, fromProj, toProj);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
package org.meteoinfo.geometry.graphic;
|
||||
|
||||
public class Artist {
|
||||
|
||||
protected boolean antiAlias = false;
|
||||
|
||||
/**
|
||||
* Return antiAlias
|
||||
* @return AntiAlias
|
||||
*/
|
||||
public boolean isAntiAlias() {
|
||||
return this.antiAlias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set antiAlias
|
||||
* @param value Set antiAlias
|
||||
*/
|
||||
public void setAntiAlias(boolean value) {
|
||||
this.antiAlias = value;
|
||||
}
|
||||
}
|
||||
@ -32,7 +32,7 @@ package org.meteoinfo.geometry.graphic;
|
||||
*
|
||||
* @author Yaqiang Wang
|
||||
*/
|
||||
public class Graphic {
|
||||
public class Graphic extends Artist {
|
||||
// <editor-fold desc="Variables">
|
||||
|
||||
protected Shape shape;
|
||||
|
||||
@ -582,7 +582,7 @@ public class GraphicCollection extends Graphic implements Iterator {
|
||||
/**
|
||||
* Add labels
|
||||
*/
|
||||
private void addLabelsByColor() {
|
||||
protected void addLabelsByColor() {
|
||||
if (labelSet.isAutoDecimal()) {
|
||||
double min = getMinValue();
|
||||
labelSet.setDecimalDigits(MIMath.getDecimalNum(min));
|
||||
@ -684,6 +684,56 @@ public class GraphicCollection extends Graphic implements Iterator {
|
||||
labelSet.setDrawLabels(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a label by text
|
||||
*
|
||||
* @param text Text
|
||||
* @return Label
|
||||
*/
|
||||
public Graphic getLabel(String text) {
|
||||
for (Graphic lb : labelPoints) {
|
||||
if (((LabelBreak) lb.getLegend()).getText().equals(text)) {
|
||||
return lb;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move label
|
||||
*
|
||||
* @param text Label text
|
||||
* @param x X
|
||||
* @param y Y
|
||||
*/
|
||||
public void moveLabel(String text, float x, float y) {
|
||||
Graphic lb = this.getLabel(text);
|
||||
if (lb != null) {
|
||||
this.moveLabel(lb, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Move label
|
||||
*
|
||||
* @param lb Label
|
||||
* @param x X
|
||||
* @param y Y
|
||||
*/
|
||||
public void moveLabel(Graphic lb, float x, float y) {
|
||||
LabelBreak lbb = (LabelBreak) lb.getLegend();
|
||||
lbb.setXShift(lbb.getXShift() + x);
|
||||
lbb.setYShift(lbb.getYShift() + y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all labels
|
||||
*/
|
||||
public void removeLabels() {
|
||||
labelPoints.clear();
|
||||
labelSet.setDrawLabels(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrow zoom
|
||||
*
|
||||
@ -736,5 +786,24 @@ public class GraphicCollection extends Graphic implements Iterator {
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* X coordinate shift as a new GraphicCollection object
|
||||
* @param xs X shift value
|
||||
*/
|
||||
public GraphicCollection xShiftCopy(double xs) {
|
||||
GraphicCollection graphicCollection = new GraphicCollection();
|
||||
for (Graphic g : this.graphics) {
|
||||
Shape shape = (Shape) g.getShape().clone();
|
||||
for (PointD p : shape.getPoints()) {
|
||||
p.X += xs;
|
||||
}
|
||||
Graphic graphic = new Graphic(shape, g.legend);
|
||||
graphic.setExtent(graphic.getExtent().shift(xs, 0));
|
||||
graphicCollection.add(graphic);
|
||||
}
|
||||
|
||||
return graphicCollection;
|
||||
}
|
||||
// </editor-fold>
|
||||
}
|
||||
|
||||
@ -61,6 +61,30 @@ public abstract class Shape implements Cloneable{
|
||||
*/
|
||||
public Shape(Geometry geometry) {};
|
||||
|
||||
/**
|
||||
* Create a new Shape object
|
||||
* @param shapeType Shape type
|
||||
* @return Shape object
|
||||
*/
|
||||
public static Shape factory(ShapeTypes shapeType) {
|
||||
switch (shapeType) {
|
||||
case POINT:
|
||||
return new PointShape();
|
||||
case POINT_Z:
|
||||
return new PointZShape();
|
||||
case POLYLINE:
|
||||
return new PolylineShape();
|
||||
case POLYLINE_Z:
|
||||
return new PolylineZShape();
|
||||
case POLYGON:
|
||||
return new PolygonShape();
|
||||
case POLYGON_Z:
|
||||
return new PolygonZShape();
|
||||
default:
|
||||
throw new IllegalArgumentException("Shape type not supported");
|
||||
}
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
// <editor-fold desc="Get Set Methods">
|
||||
/**
|
||||
|
||||
@ -1,30 +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\micaps">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\violinplot"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\weather"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\contour"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\wind"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\maskout"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\projection"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\FY"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\geoshow"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\micaps"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\micaps\micaps_1_rain_contour_us.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\micaps\micaps_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\micaps\micaps_11.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\micaps\mdfs_dataframe.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\micaps\mdfs_dataframe_type12.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\micaps\micaps_1_rain_contour_us.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\micaps\micaps_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\micaps\micaps_11.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\micaps\mdfs_dataframe.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\micaps\mdfs_dataframe_type12.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
@ -32,5 +36,5 @@
|
||||
</Font>
|
||||
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
|
||||
<Figure DoubleBuffering="true"/>
|
||||
<Startup MainFormLocation="-7,-7" MainFormSize="1293,685"/>
|
||||
<Startup MainFormLocation="-7,0" MainFormSize="1430,821"/>
|
||||
</MeteoInfo>
|
||||
|
||||
72
meteoinfo-lab/pylib/mipylib/geolib/_graphic.py
Normal file
72
meteoinfo-lab/pylib/mipylib/geolib/_graphic.py
Normal file
@ -0,0 +1,72 @@
|
||||
from org.meteoinfo.geo.graphic import GeoGraphicCollection as JGeoGraphicCollection
|
||||
from java.awt import Font
|
||||
|
||||
import mipylib.miutil as miutil
|
||||
|
||||
class GeoGraphicCollection(object):
|
||||
|
||||
def __init__(self, geographic=None):
|
||||
"""
|
||||
Class init.
|
||||
|
||||
:param geographic: (*JGeoGraphicCollection*) Java GeoGraphicCollection object.
|
||||
"""
|
||||
self._geographic = geographic
|
||||
|
||||
def addlabels(self, fieldname, **kwargs):
|
||||
"""
|
||||
Add labels
|
||||
|
||||
:param fieldname: (*string*) Field name.
|
||||
:param fontname: (*string*) Font name. Default is ``Arial``.
|
||||
:param fontsize: (*string*) Font size. Default is ``14``.
|
||||
:param bold: (*boolean*) Font bold or not. Default is ``False``.
|
||||
:param color: (*color*) Label color. Default is ``None`` with black color.
|
||||
:param xoffset: (*int*) X coordinate offset. Default is ``0``.
|
||||
:param yoffset: (*int*) Y coordinate offset. Default is ``0``.
|
||||
:param avoidcoll: (*boolean*) Avoid labels collision or not. Default is ``True``.
|
||||
:param decimals: (*int*) Number of decimals of labels.
|
||||
"""
|
||||
labelset = self._geographic.getLabelSet()
|
||||
labelset.setFieldName(fieldname)
|
||||
fontname = kwargs.pop('fontname', 'Arial')
|
||||
fontsize = kwargs.pop('fontsize', 14)
|
||||
bold = kwargs.pop('bold', False)
|
||||
if bold:
|
||||
font = Font(fontname, Font.BOLD, fontsize)
|
||||
else:
|
||||
font = Font(fontname, Font.PLAIN, fontsize)
|
||||
labelset.setLabelFont(font)
|
||||
color = kwargs.pop('color', None)
|
||||
if not color is None:
|
||||
color = miutil.getcolor(color)
|
||||
labelset.setLabelColor(color)
|
||||
xoffset = kwargs.pop('xoffset', 0)
|
||||
labelset.setXOffset(xoffset)
|
||||
yoffset = kwargs.pop('yoffset', 0)
|
||||
labelset.setYOffset(yoffset)
|
||||
avoidcoll = kwargs.pop('avoidcoll', True)
|
||||
labelset.setAvoidCollision(avoidcoll)
|
||||
decimals = kwargs.pop('decimals', None)
|
||||
if not decimals is None:
|
||||
labelset.setAutoDecimal(False)
|
||||
labelset.setDecimalDigits(decimals)
|
||||
self._geographic.addLabels()
|
||||
|
||||
def getlabel(self, text):
|
||||
"""
|
||||
Get a label.
|
||||
|
||||
:param text: (*string*) The label text.
|
||||
"""
|
||||
return self._geographic.getLabel(text)
|
||||
|
||||
def movelabel(self, label, x=0, y=0):
|
||||
"""
|
||||
Move a label.
|
||||
|
||||
:param label: (*string*) The label text.
|
||||
:param x: (*float*) X shift for moving in pixel unit.
|
||||
:param y: (*float*) Y shift for moving in pixel unit.
|
||||
"""
|
||||
self._geographic.moveLabel(label, x, y)
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -10,13 +10,13 @@ import os
|
||||
import numbers
|
||||
|
||||
from org.meteoinfo.chart import ChartScaleBar, ChartNorthArrow
|
||||
from org.meteoinfo.chart.plot import MapPlot, GridLabelPosition
|
||||
from org.meteoinfo.chart.plot import GridLabelPosition
|
||||
from org.meteoinfo.chart.geo import MapPlot
|
||||
from org.meteoinfo.chart.graphic import GraphicFactory
|
||||
from org.meteoinfo.geo.meteodata import DrawMeteoData
|
||||
from org.meteoinfo.geo.mapview import MapView
|
||||
from org.meteoinfo.geo.io import GraphicUtil
|
||||
from org.meteoinfo.geometry.legend import BreakTypes, LegendScheme, LegendType, LegendManage
|
||||
#from org.meteoinfo.geo.legend import LegendManage
|
||||
from org.meteoinfo.geometry.shape import Shape, PolylineShape, PolygonShape, ShapeTypes
|
||||
from org.meteoinfo.geometry.graphic import Graphic
|
||||
from org.meteoinfo.projection import ProjectionInfo
|
||||
@ -30,6 +30,7 @@ from ._axes import Axes
|
||||
import mipylib.numeric as np
|
||||
from mipylib.numeric.core import NDArray, DimArray
|
||||
from mipylib.geolib.milayer import MILayer
|
||||
from mipylib.geolib._graphic import GeoGraphicCollection
|
||||
import mipylib.geolib.migeo as migeo
|
||||
import plotutil
|
||||
import colors
|
||||
@ -553,7 +554,7 @@ class MapAxes(Axes):
|
||||
|
||||
self._axes.setDrawExtent(graphics.getExtent().clone())
|
||||
self._axes.setExtent(graphics.getExtent().clone())
|
||||
return graphics
|
||||
return GeoGraphicCollection(graphics)
|
||||
else:
|
||||
if isinstance(args[0], Graphic):
|
||||
graphic = args[0]
|
||||
@ -1311,6 +1312,7 @@ class MapAxes(Axes):
|
||||
ls = LegendManage.createLegendScheme(cdata.min(), cdata.max(), cn, cmap)
|
||||
else:
|
||||
levs = kwargs.pop('levs', None)
|
||||
levs = kwargs.pop('levels', levs)
|
||||
if levs is None:
|
||||
ls = LegendManage.createLegendScheme(cdata.min(), cdata.max(), cmap)
|
||||
else:
|
||||
@ -1333,6 +1335,10 @@ class MapAxes(Axes):
|
||||
graphics = GraphicFactory.createArrows(x._array, y._array, u._array, v._array, cdata, ls, isuv)
|
||||
|
||||
# Add graphics
|
||||
antialias = kwargs.pop('antialias', None)
|
||||
if antialias is not None:
|
||||
graphics.setAntiAlias(antialias)
|
||||
|
||||
visible = kwargs.pop('visible', True)
|
||||
if visible:
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
@ -1401,6 +1407,7 @@ class MapAxes(Axes):
|
||||
ls = LegendManage.createLegendScheme(cdata.min(), cdata.max(), cn, cmap)
|
||||
else:
|
||||
levs = kwargs.pop('levs', None)
|
||||
levs = kwargs.pop('levels', levs)
|
||||
if levs is None:
|
||||
ls = LegendManage.createLegendScheme(cdata.min(), cdata.max(), cmap)
|
||||
else:
|
||||
@ -1420,6 +1427,10 @@ class MapAxes(Axes):
|
||||
graphics = GraphicFactory.createBarbs(x._array, y._array, u._array, v._array, cdata, ls, isuv)
|
||||
|
||||
# Add graphics
|
||||
antialias = kwargs.pop('antialias', None)
|
||||
if antialias is not None:
|
||||
graphics.setAntiAlias(antialias)
|
||||
|
||||
proj = kwargs.pop('proj', migeo.projinfo())
|
||||
visible = kwargs.pop('visible', True)
|
||||
if visible:
|
||||
|
||||
Binary file not shown.
@ -10,7 +10,8 @@ from javax.swing import WindowConstants
|
||||
from org.meteoinfo.chart import Location
|
||||
from org.meteoinfo.chart.form import ChartForm
|
||||
from org.meteoinfo.chart.jogl import JOGLUtil
|
||||
from org.meteoinfo.chart.plot import Plot2D, MapPlot, Plot3D
|
||||
from org.meteoinfo.chart.plot import Plot2D, Plot3D
|
||||
from org.meteoinfo.chart.geo import MapPlot
|
||||
from org.meteoinfo.geo.legend import LegendManage
|
||||
from org.meteoinfo.geo.meteodata import DrawMeteoData
|
||||
from org.meteoinfo.geometry.legend import LegendScheme, LegendType
|
||||
|
||||
Binary file not shown.
@ -993,7 +993,7 @@ public class ProjectionUtil {
|
||||
return newGraphics;
|
||||
}
|
||||
|
||||
private static Shape projectShape(Shape aShape, ProjectionInfo fromProj, ProjectionInfo toProj) {
|
||||
public static Shape projectShape(Shape aShape, ProjectionInfo fromProj, ProjectionInfo toProj) {
|
||||
Shape newShape;
|
||||
switch (aShape.getShapeType()) {
|
||||
case POINT:
|
||||
@ -1030,7 +1030,7 @@ public class ProjectionUtil {
|
||||
return newShape;
|
||||
}
|
||||
|
||||
private static List<? extends Shape> projectClipShape(Shape shape, ProjectionInfo fromProj, ProjectionInfo toProj) {
|
||||
public static List<? extends Shape> projectClipShape(Shape shape, ProjectionInfo fromProj, ProjectionInfo toProj) {
|
||||
List<? extends Shape> shapes = null;
|
||||
switch (shape.getShapeType()) {
|
||||
case POINT:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user