code clean

This commit is contained in:
wyq 2024-02-05 21:15:50 +08:00
parent fc8f674e71
commit b211165322
31 changed files with 453 additions and 563 deletions

View File

@ -10,13 +10,11 @@
*/
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.RenderingHints;
import java.awt.Stroke;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
@ -26,7 +24,6 @@ import org.meteoinfo.chart.jogl.Plot3DGL;
import org.meteoinfo.chart.plot.MapPlot;
import org.meteoinfo.chart.plot.Plot;
import org.meteoinfo.common.PointF;
import org.meteoinfo.geo.drawing.Draw;
/**
*
@ -758,7 +755,7 @@ public class Chart {
plot.setPositionArea(positionArea);
Margin tightInset = plot.getTightInset(g, positionArea);
plot.setTightInset(tightInset);
double zoom1 = plot.updatePostionAreaZoom();
double zoom1 = plot.getPositionAreaZoom();
if (zoom1 < zoom) {
zoom = zoom1;
}
@ -768,7 +765,7 @@ public class Chart {
plot.setPositionArea(positionArea);
Margin tightInset = plot.getTightInset(g, positionArea);
plot.setTightInset(tightInset);
double zoom1 = plot.updatePostionAreaZoom();
double zoom1 = plot.getPositionAreaZoom();
if (zoom1 < zoom) {
zoom = zoom1;
}
@ -791,7 +788,7 @@ public class Chart {
plot.setPositionArea(positionArea);
Margin tightInset = plot.getTightInset(g, positionArea);
plot.setTightInset(tightInset);
double zoom = plot.updatePostionAreaZoom();
double zoom = plot.getPositionAreaZoom();
plot.setPositionAreaZoom(zoom);
return subPlotArea;
} else {
@ -800,7 +797,7 @@ public class Chart {
plot.setPositionArea(positionArea);
Margin tightInset = plot.getTightInset(g, positionArea);
plot.setTightInset(tightInset);
double zoom = plot.updatePostionAreaZoom();
double zoom = plot.getPositionAreaZoom();
plot.setPositionAreaZoom(zoom);
//return tightInset.getArea(positionArea);
return area;

View File

@ -23,23 +23,28 @@ import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import org.meteoinfo.chart.plot.MapPlot;
import org.meteoinfo.geo.layout.NorthArrowType;
/**
*
* @author Yaqiang Wang
*/
public class ChartNorthArrow extends ChartElement {
public enum NorthArrowType {
NORTH_ARROW_1,
NORTH_ARROW_2,
}
// <editor-fold desc="Variables">
private MapPlot mapPlot;
private boolean _antiAlias;
private final MapPlot mapPlot;
private final boolean antiAlias;
private float lineWidth;
private boolean _drawNeatLine;
private Color _neatLineColor;
private float _neatLineSize;
private NorthArrowType _northArrowType;
private float _angle;
private boolean drawNeatLine;
private Color neatLineColor;
private float neatLineSize;
private NorthArrowType northArrowType;
private float angle;
// </editor-fold>
// <editor-fold desc="Constructor">
@ -56,12 +61,12 @@ public class ChartNorthArrow extends ChartElement {
this.mapPlot = mapPlot;
this.lineWidth = 1;
_antiAlias = true;
_drawNeatLine = false;
_neatLineColor = Color.black;
_neatLineSize = 1;
_northArrowType = NorthArrowType.NORTH_ARROW_1;
_angle = 0;
antiAlias = true;
drawNeatLine = false;
neatLineColor = Color.black;
neatLineSize = 1;
northArrowType = NorthArrowType.NORTH_ARROW_1;
angle = 0;
}
// </editor-fold>
// <editor-fold desc="Get Set Methods">
@ -76,7 +81,7 @@ public class ChartNorthArrow extends ChartElement {
}
/**
* Get line widht
* Get line width
* @return Line width
*/
public float getLineWidth() {
@ -97,16 +102,16 @@ public class ChartNorthArrow extends ChartElement {
* @return If draw neat line
*/
public boolean isDrawNeatLine() {
return _drawNeatLine;
return drawNeatLine;
}
/**
* Set if draw neat line
*
* @param istrue If draw neat line
* @param value If draw neat line
*/
public void setDrawNeatLine(boolean istrue) {
_drawNeatLine = istrue;
public void setDrawNeatLine(boolean value) {
drawNeatLine = value;
}
/**
@ -115,7 +120,7 @@ public class ChartNorthArrow extends ChartElement {
* @return Neat line color
*/
public Color getNeatLineColor() {
return _neatLineColor;
return neatLineColor;
}
/**
@ -124,7 +129,7 @@ public class ChartNorthArrow extends ChartElement {
* @param color Neat line color
*/
public void setNeatLineColor(Color color) {
_neatLineColor = color;
neatLineColor = color;
}
/**
@ -133,7 +138,7 @@ public class ChartNorthArrow extends ChartElement {
* @return Neat line size
*/
public float getNeatLineSize() {
return _neatLineSize;
return neatLineSize;
}
/**
@ -142,7 +147,25 @@ public class ChartNorthArrow extends ChartElement {
* @param size Neat line size
*/
public void setNeatLineSize(float size) {
_neatLineSize = size;
neatLineSize = size;
}
/**
* Get north arrow type
*
* @return North arrow type
*/
public NorthArrowType getNorthArrowType() {
return this.northArrowType;
}
/**
* Set north arrow type
*
* @param value North arrow type
*/
public void setNorthArrowType(NorthArrowType value) {
this.northArrowType = value;
}
/**
@ -151,7 +174,7 @@ public class ChartNorthArrow extends ChartElement {
* @return Angle
*/
public float getAngle() {
return _angle;
return angle;
}
/**
@ -160,7 +183,7 @@ public class ChartNorthArrow extends ChartElement {
* @param angle The angle
*/
public void setAngle(float angle) {
_angle = angle;
this.angle = angle;
}
// </editor-fold>
@ -175,10 +198,10 @@ public class ChartNorthArrow extends ChartElement {
public void draw(Graphics2D g, float x, float y) {
AffineTransform oldMatrix = g.getTransform();
g.translate(x, y);
if (_angle != 0) {
g.rotate(_angle);
if (angle != 0) {
g.rotate(angle);
}
if (_antiAlias) {
if (antiAlias) {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
} else {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
@ -193,11 +216,11 @@ public class ChartNorthArrow extends ChartElement {
drawNorthArrow(g);
//Draw neatline
if (_drawNeatLine) {
Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1,
(this.getWidth() - _neatLineSize), (this.getHeight() - _neatLineSize));
g.setColor(_neatLineColor);
g.setStroke(new BasicStroke(_neatLineSize));
if (drawNeatLine) {
Rectangle.Float mapRect = new Rectangle.Float(neatLineSize - 1, neatLineSize - 1,
(this.getWidth() - neatLineSize), (this.getHeight() - neatLineSize));
g.setColor(neatLineColor);
g.setStroke(new BasicStroke(neatLineSize));
g.draw(mapRect);
}
@ -216,10 +239,10 @@ public class ChartNorthArrow extends ChartElement {
PointF aP = pageToScreen(this.getX(), this.getY(), pageLocation, zoom);
g.translate(aP.X, aP.Y);
g.scale(zoom, zoom);
if (_angle != 0) {
g.rotate(_angle);
if (angle != 0) {
g.rotate(angle);
}
if (_antiAlias) {
if (antiAlias) {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
} else {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
@ -234,11 +257,11 @@ public class ChartNorthArrow extends ChartElement {
drawNorthArrow(g);
//Draw neatline
if (_drawNeatLine) {
Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1,
(this.getWidth() - _neatLineSize) * zoom, (this.getHeight() - _neatLineSize) * zoom);
g.setColor(_neatLineColor);
g.setStroke(new BasicStroke(_neatLineSize));
if (drawNeatLine) {
Rectangle.Float mapRect = new Rectangle.Float(neatLineSize - 1, neatLineSize - 1,
(this.getWidth() - neatLineSize) * zoom, (this.getHeight() - neatLineSize) * zoom);
g.setColor(neatLineColor);
g.setStroke(new BasicStroke(neatLineSize));
g.draw(mapRect);
}
@ -246,7 +269,7 @@ public class ChartNorthArrow extends ChartElement {
}
private void drawNorthArrow(Graphics2D g) {
switch (_northArrowType) {
switch (northArrowType) {
case NORTH_ARROW_1:
drawNorthArrow1(g);
break;

View File

@ -16,29 +16,46 @@ import java.awt.geom.AffineTransform;
import java.awt.geom.Line2D;
import org.meteoinfo.chart.plot.MapPlot;
import org.meteoinfo.common.PointF;
import org.meteoinfo.geo.layout.ScaleBarType;
import org.meteoinfo.geo.layout.ScaleBarUnits;
/**
*
* @author Yaqiang Wang
*/
public class ChartScaleBar extends ChartElement {
public enum ScaleBarType {
SCALE_LINE_1,
SCALE_LINE_2,
// Alternating scale bar
ALTERNATING_BAR;
}
public enum ScaleBarUnits {
KILOMETERS,
METERS,
CENTIMETERS,
MILLIMETERS,
MILES,
YARDS,
FEET,
INCHES
}
// <editor-fold desc="Variables">
private MapPlot mapPlot;
private boolean _antiAlias;
private boolean antiAlias;
private float lineWidth;
private Font _font;
private ScaleBarType _scaleBarType;
private ScaleBarUnits _unit;
private String _unitText;
private int _numBreaks;
private boolean _drawNeatLine;
private Color _neatLineColor;
private float _neatLineSize;
private boolean _drawScaleText;
private float _yShiftScale = 2.0f;
private Font font;
private ScaleBarType scaleBarType;
private ScaleBarUnits unit;
private String unitText;
private int numBreaks;
private boolean drawNeatLine;
private Color neatLineColor;
private float neatLineSize;
private boolean drawScaleText;
private float yShiftScale = 2.0f;
// </editor-fold>
// <editor-fold desc="Constructor">
@ -49,23 +66,21 @@ public class ChartScaleBar extends ChartElement {
*/
public ChartScaleBar(MapPlot mapPlot) {
super();
//this.setElementType(ElementType.LayoutScaleBar);
//this.setResizeAbility(ResizeAbility.ResizeAll);
this.width = 200;
this.height = 50;
this.mapPlot = mapPlot;
_antiAlias = true;
_scaleBarType = ScaleBarType.SCALE_LINE_1;
antiAlias = true;
scaleBarType = ScaleBarType.SCALE_LINE_1;
lineWidth = 1;
_drawNeatLine = false;
_neatLineColor = Color.black;
_neatLineSize = 1;
_font = new Font("Arial", Font.PLAIN, 12);
_unit = ScaleBarUnits.KILOMETERS;
_unitText = "km";
_numBreaks = 4;
_drawScaleText = false;
drawNeatLine = false;
neatLineColor = Color.black;
neatLineSize = 1;
font = new Font("Arial", Font.PLAIN, 12);
unit = ScaleBarUnits.KILOMETERS;
unitText = "km";
numBreaks = 4;
drawScaleText = false;
}
// </editor-fold>
// <editor-fold desc="Get Set Methods">
@ -80,7 +95,7 @@ public class ChartScaleBar extends ChartElement {
}
/**
* Get line widht
* Get line width
* @return Line width
*/
public float getLineWidth() {
@ -101,7 +116,7 @@ public class ChartScaleBar extends ChartElement {
* @return Scale bar type
*/
public ScaleBarType getScaleBarType() {
return _scaleBarType;
return scaleBarType;
}
/**
@ -110,7 +125,7 @@ public class ChartScaleBar extends ChartElement {
* @param type Scale bar type
*/
public void setScaleBarType(ScaleBarType type) {
_scaleBarType = type;
scaleBarType = type;
}
/**
@ -119,7 +134,7 @@ public class ChartScaleBar extends ChartElement {
* @return If draw neat line
*/
public boolean isDrawNeatLine() {
return _drawNeatLine;
return drawNeatLine;
}
/**
@ -128,7 +143,7 @@ public class ChartScaleBar extends ChartElement {
* @param istrue If draw neat line
*/
public void setDrawNeatLine(boolean istrue) {
_drawNeatLine = istrue;
drawNeatLine = istrue;
}
/**
@ -137,7 +152,7 @@ public class ChartScaleBar extends ChartElement {
* @return Neat line color
*/
public Color getNeatLineColor() {
return _neatLineColor;
return neatLineColor;
}
/**
@ -146,7 +161,7 @@ public class ChartScaleBar extends ChartElement {
* @param color Neat line color
*/
public void setNeatLineColor(Color color) {
_neatLineColor = color;
neatLineColor = color;
}
/**
@ -155,7 +170,7 @@ public class ChartScaleBar extends ChartElement {
* @return Neat line size
*/
public float getNeatLineSize() {
return _neatLineSize;
return neatLineSize;
}
/**
@ -164,7 +179,7 @@ public class ChartScaleBar extends ChartElement {
* @param size Neat line size
*/
public void setNeatLineSize(float size) {
_neatLineSize = size;
neatLineSize = size;
}
/**
@ -173,7 +188,7 @@ public class ChartScaleBar extends ChartElement {
* @return The font
*/
public Font getFont() {
return _font;
return font;
}
/**
@ -182,7 +197,7 @@ public class ChartScaleBar extends ChartElement {
* @param font The font
*/
public void setFont(Font font) {
_font = font;
this.font = font;
}
/**
@ -191,7 +206,7 @@ public class ChartScaleBar extends ChartElement {
* @return The break number
*/
public int getBreakNumber() {
return _numBreaks;
return numBreaks;
}
/**
@ -200,7 +215,7 @@ public class ChartScaleBar extends ChartElement {
* @param num Break number
*/
public void setBreakNumber(int num) {
_numBreaks = num;
numBreaks = num;
}
/**
@ -209,7 +224,7 @@ public class ChartScaleBar extends ChartElement {
* @return If draw scale text
*/
public boolean isDrawScaleText() {
return _drawScaleText;
return drawScaleText;
}
/**
@ -218,7 +233,7 @@ public class ChartScaleBar extends ChartElement {
* @param istrue If draw scale text
*/
public void setDrawScaleText(boolean istrue) {
_drawScaleText = istrue;
drawScaleText = istrue;
}
// </editor-fold>
// <editor-fold desc="Methods">
@ -232,7 +247,7 @@ public class ChartScaleBar extends ChartElement {
public void draw(Graphics2D g, float x, float y) {
AffineTransform oldMatrix = g.getTransform();
g.translate(x, y);
if (_antiAlias) {
if (antiAlias) {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
} else {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
@ -247,11 +262,11 @@ public class ChartScaleBar extends ChartElement {
drawScaleBar(g);
//Draw neatline
if (_drawNeatLine) {
Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1,
(this.getWidth() - _neatLineSize), (this.getHeight() - _neatLineSize));
g.setColor(_neatLineColor);
g.setStroke(new BasicStroke(_neatLineSize));
if (drawNeatLine) {
Rectangle.Float mapRect = new Rectangle.Float(neatLineSize - 1, neatLineSize - 1,
(this.getWidth() - neatLineSize), (this.getHeight() - neatLineSize));
g.setColor(neatLineColor);
g.setStroke(new BasicStroke(neatLineSize));
g.draw(mapRect);
}
@ -269,7 +284,7 @@ public class ChartScaleBar extends ChartElement {
AffineTransform oldMatrix = g.getTransform();
PointF aP = pageToScreen(this.getX(), this.getY(), pageLocation, 1);
g.translate(aP.X, aP.Y);
if (_antiAlias) {
if (antiAlias) {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
} else {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
@ -284,11 +299,11 @@ public class ChartScaleBar extends ChartElement {
drawScaleBar(g);
//Draw neatline
if (_drawNeatLine) {
Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1,
(this.getWidth() - _neatLineSize), (this.getHeight() - _neatLineSize));
g.setColor(_neatLineColor);
g.setStroke(new BasicStroke(_neatLineSize));
if (drawNeatLine) {
Rectangle.Float mapRect = new Rectangle.Float(neatLineSize - 1, neatLineSize - 1,
(this.getWidth() - neatLineSize), (this.getHeight() - neatLineSize));
g.setColor(neatLineColor);
g.setStroke(new BasicStroke(neatLineSize));
g.draw(mapRect);
}
@ -296,13 +311,13 @@ public class ChartScaleBar extends ChartElement {
}
private void drawScaleBar(Graphics2D g) {
//Calculates the width of one break in greographic units
FontMetrics metrics = g.getFontMetrics(this._font);
float unitLegnth = metrics.stringWidth(_unitText) * 2;
float widthNoUnit = (this.getWidth() - unitLegnth);
long geoBreakWidth = (long) (getGeoWidth(widthNoUnit / _numBreaks));
//Calculates the width of one break in geographic units
FontMetrics metrics = g.getFontMetrics(this.font);
float unitLength = metrics.stringWidth(unitText) * 2;
float widthNoUnit = (this.getWidth() - unitLength);
long geoBreakWidth = (long) (getGeoWidth(widthNoUnit / numBreaks));
//If the geobreakWidth is less than 1 we return and don't draw anything
//If the geoBreakWidth is less than 1 we return and don't draw anything
if (geoBreakWidth < 1) {
return;
}
@ -311,21 +326,21 @@ public class ChartScaleBar extends ChartElement {
geoBreakWidth = (long) (Math.floor(geoBreakWidth / n) * n);
long breakWidth = (long) (getWidth(geoBreakWidth));
FontMetrics metrics1 = g.getFontMetrics(_font);
FontMetrics metrics1 = g.getFontMetrics(font);
float fontHeight = metrics1.getHeight();
float leftStart = metrics1.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F;
//Draw scale text
double scale = geoBreakWidth * getConversionFactor(_unit) * 100 / (breakWidth / 96 * 2.539999918);
if (_drawScaleText) {
g.setFont(this._font);
double scale = geoBreakWidth * getConversionFactor(unit) * 100 / (breakWidth / 96 * 2.539999918);
if (drawScaleText) {
g.setFont(this.font);
g.setColor(this.getForeground());
g.drawString("1 : " + String.format("{0:0,0}", scale),
leftStart - (metrics.stringWidth(String.valueOf(Math.abs(0))) / 2), fontHeight * 2.5F);
}
//Draw scale bar
switch (_scaleBarType) {
switch (scaleBarType) {
case SCALE_LINE_1:
drawScaleLine1(g, breakWidth, geoBreakWidth);
break;
@ -348,8 +363,8 @@ public class ChartScaleBar extends ChartElement {
}
private double getGeoWidth(double width) {
double geoWidth = width / mapPlot.getMapFrame().getMapView().getXScale() / getConversionFactor(_unit);
if (mapPlot.getMapFrame().getMapView().getProjection().isLonLatMap()) {
double geoWidth = width / mapPlot.getXScale() / getConversionFactor(unit);
if (mapPlot.isLonLatMap()) {
geoWidth = geoWidth * getLonDistScale();
}
@ -357,8 +372,8 @@ public class ChartScaleBar extends ChartElement {
}
private double getWidth(double geoWidth) {
double width = geoWidth * mapPlot.getMapFrame().getMapView().getXScale() * getConversionFactor(_unit);
if (mapPlot.getMapFrame().getMapView().getProjection().isLonLatMap()) {
double width = geoWidth * mapPlot.getXScale() * getConversionFactor(unit);
if (mapPlot.isLonLatMap()) {
width = width / getLonDistScale();
}
@ -367,7 +382,7 @@ public class ChartScaleBar extends ChartElement {
private double getLonDistScale() {
//Get meters of one longitude degree
double pY = (mapPlot.getMapFrame().getMapView().getViewExtent().maxY + mapPlot.getMapFrame().getMapView().getViewExtent().minY) / 2;
double pY = (mapPlot.getViewExtent().maxY + mapPlot.getViewExtent().minY) / 2;
double ProjX = 0, ProjY = pY, pProjX = 1, pProjY = pY;
double dx = Math.abs(ProjX - pProjX);
double dy = Math.abs(ProjY - pProjY);
@ -382,45 +397,45 @@ public class ChartScaleBar extends ChartElement {
}
private void drawScaleLine1(Graphics2D g, long breakWidth, long geoBreakWidth) {
FontMetrics metrics = g.getFontMetrics(_font);
FontMetrics metrics = g.getFontMetrics(font);
float fontHeight = metrics.getHeight();
float leftStart = metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F;
int yShift = 10;
g.setColor(this.getForeground());
g.setStroke(new BasicStroke(this.lineWidth));
g.draw(new Line2D.Float(leftStart, fontHeight * 1.6f + yShift, leftStart + (breakWidth * _numBreaks), fontHeight * 1.6f + yShift));
g.setFont(this._font);
for (int i = 0; i <= _numBreaks; i++) {
g.draw(new Line2D.Float(leftStart, fontHeight * 1.6f + yShift, leftStart + (breakWidth * numBreaks), fontHeight * 1.6f + yShift));
g.setFont(this.font);
for (int i = 0; i <= numBreaks; i++) {
g.draw(new Line2D.Float(leftStart, fontHeight * 1.1f + yShift, leftStart, fontHeight * 1.6f + yShift));
g.drawString(String.valueOf(Math.abs(geoBreakWidth * i)),
leftStart - (metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth * i))) / 2), yShift * _yShiftScale);
leftStart - (metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth * i))) / 2), yShift * yShiftScale);
leftStart = leftStart + breakWidth;
}
g.drawString(_unitText, leftStart - breakWidth + (fontHeight / 2), fontHeight * 1.1f + yShift * _yShiftScale);
g.drawString(unitText, leftStart - breakWidth + (fontHeight / 2), fontHeight * 1.1f + yShift * yShiftScale);
}
private void drawScaleLine2(Graphics2D g, long breakWidth, long geoBreakWidth) {
FontMetrics metrics = g.getFontMetrics(_font);
FontMetrics metrics = g.getFontMetrics(font);
float fontHeight = metrics.getHeight();
float leftStart = metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F;
int yShift = 5;
g.setColor(this.getForeground());
g.setStroke(new BasicStroke(this.lineWidth));
g.draw(new Line2D.Float(leftStart, fontHeight * 1.6f + yShift, leftStart + (breakWidth * _numBreaks), fontHeight * 1.6f + yShift));
g.setFont(this._font);
for (int i = 0; i <= _numBreaks; i++) {
g.draw(new Line2D.Float(leftStart, fontHeight * 1.6f + yShift, leftStart + (breakWidth * numBreaks), fontHeight * 1.6f + yShift));
g.setFont(this.font);
for (int i = 0; i <= numBreaks; i++) {
g.draw(new Line2D.Float(leftStart, fontHeight * 1.1f + yShift, leftStart, fontHeight + (fontHeight * 1.1f) + yShift));
g.drawString(String.valueOf(Math.abs(geoBreakWidth * i)),
leftStart - (metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth * i))) / 2), yShift * _yShiftScale);
leftStart - (metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth * i))) / 2), yShift * yShiftScale);
leftStart = leftStart + breakWidth;
}
g.drawString(_unitText, leftStart - breakWidth + (fontHeight / 2), fontHeight * 1.1f + yShift * _yShiftScale);
g.drawString(unitText, leftStart - breakWidth + (fontHeight / 2), fontHeight * 1.1f + yShift * yShiftScale);
}
private void drawAlternatingBar(Graphics2D g, long breakWidth, long geoBreakWidth) {
FontMetrics metrics = g.getFontMetrics(_font);
FontMetrics metrics = g.getFontMetrics(font);
float fontHeight = metrics.getHeight();
float leftStart = metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F;
int yShift = 5;
@ -429,21 +444,21 @@ public class ChartScaleBar extends ChartElement {
boolean isFill = false;
g.setStroke(new BasicStroke(this.lineWidth));
g.setColor(this.getForeground());
g.setFont(this._font);
for (int i = 0; i <= _numBreaks; i++) {
if (i < _numBreaks) {
g.setFont(this.font);
for (int i = 0; i <= numBreaks; i++) {
if (i < numBreaks) {
if (isFill) {
g.fill(new Rectangle.Float(leftStart, fontHeight * 1.1f + yShift, breakWidth, rHeight));
}
g.draw(new Rectangle.Float(leftStart, fontHeight * 1.1f + yShift, breakWidth, rHeight));
}
g.drawString(String.valueOf(Math.abs(geoBreakWidth * i)),
leftStart - (metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth * i))) / 2), yShift * _yShiftScale);
leftStart - (metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth * i))) / 2), yShift * yShiftScale);
leftStart = leftStart + breakWidth;
isFill = !isFill;
}
g.setColor(this.getForeground());
g.drawString(_unitText, leftStart - breakWidth + (fontHeight / 2), fontHeight * 1.1f + yShift * _yShiftScale);
g.drawString(unitText, leftStart - breakWidth + (fontHeight / 2), fontHeight * 1.1f + yShift * yShiftScale);
}
@Override

View File

@ -6,7 +6,6 @@ import com.jogamp.opengl.GLEventListener;
import com.jogamp.opengl.glu.GLU;
import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
import com.jogamp.opengl.util.gl2.GLUT;
import org.meteoinfo.chart.*;
import org.meteoinfo.chart.jogl.GLPlot;
import org.meteoinfo.chart.jogl.Plot3DGL;
import org.meteoinfo.chart.jogl.Program;
@ -813,7 +812,7 @@ public class GLChart implements GLEventListener {
plot.setPositionArea(positionArea);
Margin tightInset = plot.getTightInset(g, positionArea);
plot.setTightInset(tightInset);
double zoom1 = plot.updatePostionAreaZoom();
double zoom1 = plot.getPositionAreaZoom();
if (zoom1 < zoom) {
zoom = zoom1;
}
@ -823,7 +822,7 @@ public class GLChart implements GLEventListener {
plot.setPositionArea(positionArea);
Margin tightInset = plot.getTightInset(g, positionArea);
plot.setTightInset(tightInset);
double zoom1 = plot.updatePostionAreaZoom();
double zoom1 = plot.getPositionAreaZoom();
if (zoom1 < zoom) {
zoom = zoom1;
}
@ -846,7 +845,7 @@ public class GLChart implements GLEventListener {
plot.setPositionArea(positionArea);
Margin tightInset = plot.getTightInset(g, positionArea);
plot.setTightInset(tightInset);
double zoom = plot.updatePostionAreaZoom();
double zoom = plot.getPositionAreaZoom();
plot.setPositionAreaZoom(zoom);
return subPlotArea;
} else {
@ -855,7 +854,7 @@ public class GLChart implements GLEventListener {
plot.setPositionArea(positionArea);
Margin tightInset = plot.getTightInset(g, positionArea);
plot.setTightInset(tightInset);
double zoom = plot.updatePostionAreaZoom();
double zoom = plot.getPositionAreaZoom();
plot.setPositionAreaZoom(zoom);
//return tightInset.getArea(positionArea);
return area;

View File

@ -21,9 +21,7 @@ import org.meteoinfo.data.XYListDataset;
import org.meteoinfo.data.analysis.Statistics;
import org.meteoinfo.geo.drawing.ContourDraw;
import org.meteoinfo.geo.drawing.Draw;
import org.meteoinfo.geo.layer.ImageLayer;
import org.meteoinfo.geo.layer.VectorLayer;
import org.meteoinfo.geo.legend.LegendManage;
import org.meteoinfo.geometry.legend.LegendManage;
import org.meteoinfo.geometry.colors.ExtendType;
import org.meteoinfo.geometry.colors.Normalize;
import org.meteoinfo.geometry.colors.OpacityTransferFunction;
@ -1979,117 +1977,6 @@ public class GraphicFactory {
return graphics;
}
/**
* Create 3D graphics from a VectorLayer.
*
* @param layer The layer
* @param offset Offset of z axis.
* @param xshift X shift - to shift the graphics in x direction, normally
* for map in 180 - 360 degree east
* @return Graphics
*/
public static GraphicCollection createGraphicsFromLayer(VectorLayer layer, double offset, double xshift) {
GraphicCollection3D graphics = new GraphicCollection3D();
graphics.setFixZ(true);
graphics.setZValue(offset);
ShapeTypes shapeType = layer.getShapeType();
LegendScheme ls = layer.getLegendScheme();
PointZ pz;
ColorBreak cb;
switch (shapeType) {
case POINT:
for (PointShape shape : (List<PointShape>) layer.getShapes()) {
PointZShape s = new PointZShape();
PointD pd = shape.getPoint();
pz = new PointZ(pd.X + xshift, pd.Y, offset);
s.setPoint(pz);
cb = ls.getLegendBreaks().get(shape.getLegendIndex());
graphics.add(new Graphic(s, cb));
}
break;
case POLYLINE:
for (PolylineShape shape : (List<PolylineShape>) layer.getShapes()) {
cb = ls.getLegendBreaks().get(shape.getLegendIndex());
for (Polyline pl : (List<Polyline>) shape.getPolylines()) {
PolylineZShape s = new PolylineZShape();
List<PointZ> plist = new ArrayList<>();
for (PointD pd : pl.getPointList()) {
pz = new PointZ(pd.X + xshift, pd.Y, offset);
plist.add(pz);
}
s.setPoints(plist);
graphics.add(new Graphic(s, cb));
}
}
break;
case POLYGON:
for (PolygonShape shape : (List<PolygonShape>) layer.getShapes()) {
PolygonZShape s = new PolygonZShape();
List<PointZ> plist = new ArrayList<>();
for (PointD pd : shape.getPoints()) {
pz = new PointZ(pd.X + xshift, pd.Y, offset);
plist.add(pz);
}
s.setPartNum(shape.getPartNum());
s.setParts(shape.getParts());
s.setPoints(plist);
cb = ls.getLegendBreaks().get(shape.getLegendIndex());
graphics.add(new Graphic(s, cb));
}
break;
case POINT_Z:
case POLYLINE_Z:
case POLYGON_Z:
graphics.setFixZ(false);
switch (shapeType) {
case POINT_Z:
for (PointZShape shape : (List<PointZShape>) layer.getShapes()) {
PointZShape s = new PointZShape();
PointZ pd = (PointZ) shape.getPoint();
pz = new PointZ(pd.X + xshift, pd.Y, pd.Z + offset, pd.M);
s.setPoint(pz);
cb = ls.getLegendBreaks().get(shape.getLegendIndex());
graphics.add(new Graphic(s, cb));
}
break;
case POLYLINE_Z:
for (PolylineZShape shape : (List<PolylineZShape>) layer.getShapes()) {
cb = ls.getLegendBreaks().get(shape.getLegendIndex());
for (PolylineZ pl : (List<PolylineZ>) shape.getPolylines()) {
PolylineZShape s = new PolylineZShape();
List<PointZ> plist = new ArrayList<>();
for (PointZ pd : (List<PointZ>) pl.getPointList()) {
pz = new PointZ(pd.X + xshift, pd.Y, pd.Z + offset, pd.M);
plist.add(pz);
}
s.setPoints(plist);
graphics.add(new Graphic(s, cb));
}
}
break;
case POLYGON_Z:
for (PolygonZShape shape : (List<PolygonZShape>) layer.getShapes()) {
PolygonZShape s = new PolygonZShape();
List<PointZ> plist = new ArrayList<>();
for (PointZ pd : (List<PointZ>) shape.getPoints()) {
pz = new PointZ(pd.X + xshift, pd.Y, pd.Z + offset, pd.M);
plist.add(pz);
}
s.setPartNum(shape.getPartNum());
s.setParts(shape.getParts());
s.setPoints(plist);
cb = ls.getLegendBreaks().get(shape.getLegendIndex());
graphics.add(new Graphic(s, cb));
}
break;
}
break;
}
graphics.setLegendScheme(ls);
return graphics;
}
/**
* Create rectangle graphic
*
@ -3512,46 +3399,9 @@ public class GraphicFactory {
return graphics;
}
/**
* Create image
*
* @param layer Image layer
* @param offset Offset of z axis
* @param xshift X shift - to shift the grahpics in x direction, normally
* for map in 180 - 360 degree east
* @param interpolation Interpolation
* @return Graphics
*/
public static GraphicCollection createImage(ImageLayer layer, double offset, double xshift,
String interpolation) {
GraphicCollection3D graphics = new GraphicCollection3D();
graphics.setFixZ(true);
graphics.setZDir("z");
graphics.setZValue(offset);
ImageShape ishape = new ImageShape();
ishape.setImage(layer.getImage());
Extent extent = layer.getExtent();
Extent3D ex3 = new Extent3D(extent.minX + xshift, extent.maxX + xshift, extent.minY, extent.maxY, offset, offset);
List<PointZ> coords = new ArrayList<>();
coords.add(new PointZ(extent.minX + xshift, extent.minY, offset));
coords.add(new PointZ(extent.maxX + xshift, extent.minY, offset));
coords.add(new PointZ(extent.maxX + xshift, extent.maxY, offset));
coords.add(new PointZ(extent.minX + xshift, extent.maxY, offset));
ishape.setExtent(ex3);
ishape.setCoords(coords);
Graphic gg = new Graphic(ishape, new ColorBreak());
if (interpolation != null) {
((ImageShape) gg.getShape()).setInterpolation(interpolation);
}
graphics.add(gg);
return graphics;
}
/**
* Create Texture
*
* @param gl GL2
* @param layer Image layer
* @param offset Offset of z axis
* @param xshift X shift - to shift the grahpics in x direction, normally
@ -3560,16 +3410,15 @@ public class GraphicFactory {
* @return Graphics
* @throws IOException
*/
public static GraphicCollection createTexture(ImageLayer layer, double offset, double xshift,
public static GraphicCollection createTexture(String fileName, BufferedImage image, Extent extent, double offset, double xshift,
String interpolation) throws IOException {
GraphicCollection3D graphics = new GraphicCollection3D();
graphics.setFixZ(true);
graphics.setZDir("z");
graphics.setZValue(offset);
TextureShape ishape = new TextureShape();
ishape.setFileName(layer.getFileName());
ishape.setImage(layer.getImage());
Extent extent = layer.getExtent();
ishape.setFileName(fileName);
ishape.setImage(image);
Extent3D ex3 = new Extent3D(extent.minX + xshift, extent.maxX + xshift, extent.minY, extent.maxY, offset, offset);
List<PointZ> coords = new ArrayList<>();
coords.add(new PointZ(extent.minX + xshift, extent.minY, offset));
@ -8718,7 +8567,8 @@ public class GraphicFactory {
/**
* Create surface graphic
*
* @param layer Image layer
* @param image The image
* @param extent Then image extent
* @param offset Offset of z axis
* @param xShift X shift - to shift the graphics in x direction, normally
* for map in 180 - 360 degree east
@ -8727,9 +8577,8 @@ public class GraphicFactory {
* @return Graphics
* @throws IOException
*/
public static MeshGraphic geoSurface(ImageLayer layer, double offset, double xShift,
public static MeshGraphic geoSurface(BufferedImage image, Extent extent, double offset, double xShift,
int nLon, int nLat) throws IOException {
Extent extent = layer.getExtent();
Array lon = ArrayUtil.lineSpace(extent.minX + xShift, extent.maxX + xShift, nLon + 1, true);
Array lat = ArrayUtil.lineSpace(extent.minY, extent.maxY, nLat + 1, true);
lat = lat.flip(0).copy();
@ -8743,7 +8592,7 @@ public class GraphicFactory {
((PolygonBreak) ls.getLegendBreak(0)).setOutlineColor(Color.white);
MeshGraphic graphic = GraphicFactory.surface(lon, lat, alt, ls);
graphic.setImage(layer.getImage());
graphic.setImage(image);
return graphic;
}
@ -8751,7 +8600,8 @@ public class GraphicFactory {
/**
* Create surface graphic
*
* @param layer Image layer
* @param image The image
* @param imageExtent Then image extent
* @param offset Offset of z axis
* @param xShift X shift - to shift the graphics in x direction, normally
* for map in 180 - 360 degree east
@ -8761,10 +8611,9 @@ public class GraphicFactory {
* @return Graphics
* @throws IOException
*/
public static MeshGraphic geoSurface(ImageLayer layer, double offset, double xShift,
public static MeshGraphic geoSurface(BufferedImage image, Extent imageExtent, double offset, double xShift,
int nLon, int nLat, ProjectionInfo toProj) throws IOException {
Extent layerExtent = layer.getExtent();
Extent extent = (Extent) layerExtent.clone();
Extent extent = (Extent) imageExtent.clone();
double width = extent.getWidth();
double height = extent.getHeight();
float cutoff = toProj.getCutoff();
@ -8807,12 +8656,11 @@ public class GraphicFactory {
extentChanged = true;
}
BufferedImage image = layer.getImage();
if (extentChanged) {
int x = (int) ((extent.minX - layerExtent.minX) / width * image.getWidth());
int y = (int) ((layerExtent.maxY - extent.maxY) / height * image.getHeight());
int w = (int) (extent.getWidth() / layerExtent.getWidth() * image.getWidth());
int h = (int) (extent.getHeight() / layerExtent.getHeight() * image.getHeight());
int x = (int) ((extent.minX - imageExtent.minX) / width * image.getWidth());
int y = (int) ((imageExtent.maxY - extent.maxY) / height * image.getHeight());
int w = (int) (extent.getWidth() / imageExtent.getWidth() * image.getWidth());
int h = (int) (extent.getHeight() / imageExtent.getHeight() * image.getHeight());
BufferedImage nImage = new BufferedImage(w, h, image.getType());
if (cLon == 0) {
int[] rgb = new int[w * h];
@ -8821,7 +8669,7 @@ public class GraphicFactory {
}
else {
if (cLon > 0) {
int w1 = (int) ((layerExtent.maxX - extent.minX) / extent.getWidth() * w);
int w1 = (int) ((imageExtent.maxX - extent.minX) / extent.getWidth() * w);
int[] rgb1 = new int[w1 * h];
rgb1 = image.getRGB(x, y, w1, h, rgb1, 0, w1);
int[] rgb2 = new int[(w - w1) * h];
@ -8829,7 +8677,7 @@ public class GraphicFactory {
nImage.setRGB(0, 0, w1, h, rgb1, 0, w1);
nImage.setRGB(w1, 0, w - w1, h, rgb2, 0, w - w1);
} else {
int w1 = (int) ((extent.maxX - layerExtent.minX) / extent.getWidth() * w);
int w1 = (int) ((extent.maxX - imageExtent.minX) / extent.getWidth() * w);
int[] rgb1 = new int[w1 * h];
rgb1 = image.getRGB(x, y, w1, h, rgb1, 0, w1);
int[] rgb2 = new int[(w - w1) * h];
@ -8862,7 +8710,8 @@ public class GraphicFactory {
/**
* Create surface graphic
*
* @param layer Image layer
* @param image The image
* @param imageExtent Then image extent
* @param offset Offset of z axis
* @param xShift X shift - to shift the graphics in x direction, normally
* for map in 180 - 360 degree east
@ -8873,19 +8722,17 @@ public class GraphicFactory {
* @return Graphics
* @throws IOException
*/
public static MeshGraphic geoSurface(ImageLayer layer, double offset, double xShift,
public static MeshGraphic geoSurface(BufferedImage image, Extent imageExtent, double offset, double xShift,
int nLon, int nLat, ProjectionInfo toProj, List<Number> limits) throws IOException {
Extent layerExtent = layer.getExtent();
Extent extent = new Extent(limits.get(0).doubleValue(), limits.get(1).doubleValue(),
limits.get(2).doubleValue(), limits.get(3).doubleValue());
double width = layerExtent.getWidth();
double height = layerExtent.getHeight();
double width = imageExtent.getWidth();
double height = imageExtent.getHeight();
BufferedImage image = layer.getImage();
int x = (int) ((extent.minX - layerExtent.minX) / width * image.getWidth());
int y = (int) ((layerExtent.maxY - extent.maxY) / height * image.getHeight());
int w = (int)(extent.getWidth() / layerExtent.getWidth() * image.getWidth());
int h = (int)(extent.getHeight() / layerExtent.getHeight() * image.getHeight());
int x = (int) ((extent.minX - imageExtent.minX) / width * image.getWidth());
int y = (int) ((imageExtent.maxY - extent.maxY) / height * image.getHeight());
int w = (int)(extent.getWidth() / imageExtent.getWidth() * image.getWidth());
int h = (int)(extent.getHeight() / imageExtent.getHeight() * image.getHeight());
BufferedImage nImage = new BufferedImage(w, h, image.getType());
Graphics2D g2 = nImage.createGraphics();
g2.drawImage(image.getSubimage(x, y, w, h), 0, 0, null);

View File

@ -33,6 +33,8 @@ public abstract class AbstractPlot2D extends Plot {
private Color selectColor = Color.yellow;
private Extent extent;
private Extent drawExtent;
protected double xScale = 1.0;
protected double yScale = 1.0;
private final Map<Location, Axis> axis;
private Location xAxisLocation;
private Location yAxisLocation;
@ -62,10 +64,7 @@ public abstract class AbstractPlot2D extends Plot {
public AbstractPlot2D() {
super();
this.background = null;
//this.drawBackground = false;
this.drawExtent = new Extent(0, 1, 0, 1);
//this.xAxis = new Axis("X", true);
//this.yAxis = new Axis("Y", false);
this.axis = new HashMap<>();
this.axis.put(Location.BOTTOM, new Axis("X", true, Location.BOTTOM));
this.axis.put(Location.LEFT, new Axis("Y", false, Location.LEFT));
@ -332,6 +331,22 @@ public abstract class AbstractPlot2D extends Plot {
this.getAxis(Location.RIGHT).setMinMaxValue(drawExtent.minY, drawExtent.maxY);
}
/**
* Get x scale
* @return X scale
*/
public double getXScale() {
return this.xScale;
}
/**
* Get y scale
* @return Y scale
*/
public double getYScale() {
return this.yScale;
}
/**
* Get background
*
@ -350,24 +365,6 @@ public abstract class AbstractPlot2D extends Plot {
this.background = value;
}
// /**
// * Get if draw background
// *
// * @return Boolean
// */
// public boolean isDrawBackground() {
// return this.drawBackground;
// }
// /**
// * Set if draw background
// *
// * @param value Boolean
// */
// public void setDrawBackground(boolean value) {
// this.drawBackground = value;
// }
@Override
public PlotType getPlotType() {
return PlotType.XY;
@ -798,6 +795,19 @@ public abstract class AbstractPlot2D extends Plot {
return this.getAxis(Location.BOTTOM).isInsideTick();
}
protected void updateScale(Rectangle2D area) {
double width = drawExtent.getWidth();
double height = drawExtent.getHeight();
if (this.isLogY()) {
height = Math.log10(drawExtent.maxY) - Math.log10(drawExtent.minY);
}
if (this.isLogX()) {
width = Math.log10(drawExtent.maxX) - Math.log10(drawExtent.minX);
}
xScale = area.getWidth() / width;
yScale = area.getHeight() / height;
}
/**
* Draw plot
*
@ -815,6 +825,7 @@ public abstract class AbstractPlot2D extends Plot {
Rectangle2D graphArea = this.getPositionArea();
this.setGraphArea(graphArea);
updateScale(graphArea);
//Draw title
this.drawTitle(g, graphArea);
@ -1002,10 +1013,34 @@ public abstract class AbstractPlot2D extends Plot {
double delta = plotArea.getWidth() - w;
plotArea.setRect(plotArea.getX() + delta / 2, plotArea.getY(), w, plotArea.getHeight());
}
this.positionArea = plotArea;
return plotArea;
}
}
/**
* Set position area
*
* @param area Position area
*//*
@Override
public void setPositionArea(Rectangle2D area) {
this.positionArea = area;
if (this.aspectType != AspectType.AUTO) {
double width = this.drawExtent.getWidth();
double height = this.drawExtent.getHeight();
if (width / height / aspect > positionArea.getWidth() / positionArea.getHeight()) {
double h = positionArea.getWidth() * height * aspect / width;
double delta = positionArea.getHeight() - h;
positionArea.setRect(positionArea.getX(), positionArea.getY() + delta / 2, positionArea.getWidth(), h);
} else {
double w = width * positionArea.getHeight() / height / aspect;
double delta = positionArea.getWidth() - w;
positionArea.setRect(positionArea.getX() + delta / 2, positionArea.getY(), w, positionArea.getHeight());
}
}
}*/
/**
* Get outer position area

View File

@ -53,6 +53,7 @@ public class MapPlot extends AbstractPlot2D implements IWebMapPanel {
// <editor-fold desc="Variables">
private MapFrame mapFrame;
private MapView mapView;
private ProjectionInfo projInfo;
private boolean antialias;
private MapLayer selectedLayer;
protected TileLoadListener tileLoadListener = new TileLoadListener(this);
@ -70,7 +71,17 @@ public class MapPlot extends AbstractPlot2D implements IWebMapPanel {
* Constructor
*/
public MapPlot() {
this(KnownCoordinateSystems.geographic.world.WGS1984);
}
/**
* Constructor
* @param projInfo The projection info
*/
public MapPlot(ProjectionInfo projInfo) {
super();
this.projInfo = projInfo;
this.antialias = false;
this.aspectType = AspectType.EQUAL;
try {
@ -94,6 +105,8 @@ public class MapPlot extends AbstractPlot2D implements IWebMapPanel {
*/
public MapPlot(MapView mapView) {
this();
this.projInfo = mapView.getProjection().getProjInfo();
this.setMapView(mapView, true);
this.mapFrame = new MapFrame();
this.mapFrame.setMapView(mapView);
@ -106,6 +119,8 @@ public class MapPlot extends AbstractPlot2D implements IWebMapPanel {
*/
public MapPlot(MapFrame mapFrame) {
this();
this.projInfo = mapFrame.getMapView().getProjection().getProjInfo();
this.mapFrame = mapFrame;
this.setMapView(mapFrame.getMapView(), true);
}
@ -163,12 +178,38 @@ public class MapPlot extends AbstractPlot2D implements IWebMapPanel {
this.mapView.setMultiGlobalDraw(isGeoMap);
Extent extent = this.getAutoExtent();
this.setDrawExtent(extent);
PolygonShape bvs = this.mapView.getProjection().getProjInfo().getBoundary();
PolygonShape bvs = this.getProjInfo().getBoundary();
if (bvs != null) {
this.setBoundary(bvs);
}
}
/**
* Get view extent
* @return View extent
*/
public Extent getViewExtent() {
return this.mapView.getViewExtent();
}
/**
* Get x scale
* @return X scale
*/
@Override
public double getXScale() {
return this.mapView.getXScale();
}
/**
* Get y scale
* @return Y scale
*/
@Override
public double getYScale() {
return this.mapView.getYScale();
}
@Override
public PlotType getPlotType() {
return PlotType.XY2D;
@ -237,7 +278,7 @@ public class MapPlot extends AbstractPlot2D implements IWebMapPanel {
* @return Projection info
*/
public ProjectionInfo getProjInfo() {
return this.getMapView().getProjection().getProjInfo();
return this.projInfo;
}
/**
@ -245,6 +286,7 @@ public class MapPlot extends AbstractPlot2D implements IWebMapPanel {
* @param proj Projection info
*/
public void setProjInfo(ProjectionInfo proj) {
this.projInfo = proj;
this.getMapView().getProjection().setProjInfo(proj);
if (proj.getBoundary() != null) {
this.setBoundary(proj.getBoundary());
@ -257,7 +299,7 @@ public class MapPlot extends AbstractPlot2D implements IWebMapPanel {
* @return Boolean
*/
public boolean isLonLatMap() {
return this.getMapView().getProjection().isLonLatMap();
return this.projInfo.isLonLat();
}
/**
@ -567,7 +609,7 @@ public class MapPlot extends AbstractPlot2D implements IWebMapPanel {
* @return Added graphic
*/
public Graphic addGraphic(Graphic graphic, ProjectionInfo proj) {
ProjectionInfo toProj = this.getMapView().getProjection().getProjInfo();
ProjectionInfo toProj = this.getProjInfo();
if (proj.equals(toProj)) {
this.getMapView().addGraphic(graphic);
return graphic;
@ -711,11 +753,11 @@ public class MapPlot extends AbstractPlot2D implements IWebMapPanel {
public void addPoint(double lat, double lon, PointBreak pb) {
PointShape ps = new PointShape();
PointD lonlatp = new PointD(lon, lat);
if (this.getMapView().getProjection().isLonLatMap()) {
if (this.isLonLatMap()) {
ps.setPoint(lonlatp);
} else {
PointD xyp = Reproject.reprojectPoint(lonlatp, KnownCoordinateSystems.geographic.world.WGS1984,
this.getMapView().getProjection().getProjInfo());
this.getProjInfo());
ps.setPoint(xyp);
}
Graphic aGraphic = new Graphic(ps, pb);
@ -739,11 +781,11 @@ public class MapPlot extends AbstractPlot2D implements IWebMapPanel {
x = lon.get(i).doubleValue();
y = lat.get(i).doubleValue();
lonlatp = new PointD(x, y);
if (this.getMapView().getProjection().isLonLatMap()) {
if (this.isLonLatMap()) {
ps.setPoint(lonlatp);
} else {
xyp = Reproject.reprojectPoint(lonlatp, KnownCoordinateSystems.geographic.world.WGS1984,
this.getMapView().getProjection().getProjInfo());
this.getProjInfo());
ps.setPoint(xyp);
}
Graphic aGraphic = new Graphic(ps, pb);
@ -779,7 +821,7 @@ public class MapPlot extends AbstractPlot2D implements IWebMapPanel {
points = new ArrayList<>();
} else {
lonlatp = new PointD(x, y);
if (!this.getMapView().getProjection().isLonLatMap()) {
if (!this.isLonLatMap()) {
lonlatp = Reproject.reprojectPoint(lonlatp, KnownCoordinateSystems.geographic.world.WGS1984,
this.getMapView().getProjection().getProjInfo());
}
@ -903,36 +945,11 @@ public class MapPlot extends AbstractPlot2D implements IWebMapPanel {
public Graphic addCircle(float x, float y, float radius, PolygonBreak pgb) {
CircleShape aPGS = ShapeUtil.createCircleShape(x, y, radius);
Graphic graphic = new Graphic(aPGS, pgb);
this.mapView.addGraphic(graphic);
this.addGraphic(graphic);
return graphic;
}
// /**
// * Add a layer
// * @param idx Index
// * @param layer Layer
// */
// public void addLayer(int idx, MapLayer layer){
// this.mapFrame.addLayer(idx, layer);
// }
//
// /**
// * Add a layer
// * @param layer Layer
// */
// public void addLayer(MapLayer layer){
// this.mapFrame.addLayer(layer);
// }
//
// /**
// * Set extent
// *
// * @param extent Extent
// */
// public void setExtent(Extent extent) {
// this.mapFrame.getMapView().setViewExtent(extent);
// }
/**
* Get position area
*

View File

@ -7,7 +7,6 @@ package org.meteoinfo.chart.plot;
import org.meteoinfo.chart.Margin;
import org.meteoinfo.common.Extent;
import org.meteoinfo.common.Extent3D;
import org.meteoinfo.data.Dataset;
import java.awt.*;
@ -53,7 +52,7 @@ public abstract class Plot {
protected Rectangle2D position = new Rectangle2D.Double(0.13, 0.11, 0.775, 0.815);
protected Rectangle2D outerPosition = new Rectangle2D.Double(0, 0, 1, 1);
private Rectangle2D outerPositionArea;
protected Rectangle2D outerPositionArea;
private Margin tightInset = new Margin();
/** If is sub-plot. */
@ -180,7 +179,7 @@ public abstract class Plot {
/**
* Update position
* @param figureArea Figure areaa
* @param figureArea Figure area
*/
public void updatePosition(Rectangle2D figureArea){
double x = this.positionArea.getX() / figureArea.getWidth();
@ -463,7 +462,7 @@ public abstract class Plot {
* Update position area zoom
* @return Position area zoom
*/
public double updatePostionAreaZoom(){
public double updatePositionAreaZoom(){
Rectangle2D tightInsetArea = this.tightInset.getArea(this.positionArea);
double left = tightInsetArea.getX() - this.outerPositionArea.getX();
double right = this.outerPositionArea.getX() + this.outerPositionArea.getWidth() -

View File

@ -0,0 +1,7 @@
package org.meteoinfo.chart.render.java2d;
import org.meteoinfo.chart.render.GraphicRender;
public abstract class Java2DGraphicRender implements GraphicRender {
}

View File

@ -49,9 +49,6 @@ public class Variable {
private boolean dimVar = false;
private List<Integer> levelIdxs = new ArrayList<>();
private List<Integer> varInLevelIdxs = new ArrayList<>();
private double fill_value = -9999.0;
private double scale_factor = 1;
private double add_offset = 0;
private Array cachedData;
// </editor-fold>
// <editor-fold desc="Constructor">
@ -548,60 +545,6 @@ public class Variable {
varInLevelIdxs = value;
}
/**
* Get fill value
*
* @return Fill value
*/
public double getFillValue() {
return this.fill_value;
}
/**
* Set fill value
*
* @param value Fill value
*/
public void setFillValue(double value) {
this.fill_value = value;
}
/**
* Get scale factor
*
* @return Scale factor
*/
public double getScaleFactor() {
return this.scale_factor;
}
/**
* Set scale factor
*
* @param value Scale factor
*/
public void setScaleFactor(double value) {
this.scale_factor = value;
}
/**
* Get add offset
*
* @return Add offset
*/
public double getAddOffset() {
return this.add_offset;
}
/**
* Set add offset
*
* @param value Add offset
*/
public void setAddOffset(double value) {
this.add_offset = value;
}
/**
* Get cached data array
* @return Cached data array

View File

@ -36,6 +36,7 @@ import org.meteoinfo.ndarray.InvalidRangeException;
import org.meteoinfo.ndarray.Range;
import org.meteoinfo.ndarray.Section;
import org.meteoinfo.data.meteodata.Attribute;
import org.meteoinfo.ndarray.math.ArrayMath;
import org.meteoinfo.ndarray.util.BigDecimalUtil;
/**
@ -88,7 +89,7 @@ public class ASCIIGridDataInfo extends DataInfo implements IGridDataInfo {
String yll = dataArray[6];
yllCenter = Double.parseDouble(dataArray[7]);
cellSize = Double.parseDouble(dataArray[9]);
nodata_value = Double.parseDouble(dataArray[11]);
this.missingValue = Double.parseDouble(dataArray[11]);
if (xll.toLowerCase().equals("xllcorner")) {
xllCenter += cellSize * 0.5;
}
@ -110,7 +111,6 @@ public class ASCIIGridDataInfo extends DataInfo implements IGridDataInfo {
}
}
this.setMissingValue(nodata_value);
double[] X = new double[ncols];
X[0] = xllCenter;
for (i = 1; i < ncols; i++) {
@ -144,7 +144,6 @@ public class ASCIIGridDataInfo extends DataInfo implements IGridDataInfo {
aVar.setName("var");
aVar.addDimension(yDim);
aVar.addDimension(xDim);
aVar.setFillValue(nodata_value);
if (isInt) {
this.dataType = DataType.INT;
} else {
@ -152,7 +151,7 @@ public class ASCIIGridDataInfo extends DataInfo implements IGridDataInfo {
}
this.dataType = DataType.FLOAT;
aVar.setDataType(dataType);
aVar.addAttribute(new Attribute("fill_value", this.getMissingValue()));
aVar.addAttribute(new Attribute("fill_value", this.missingValue));
variables.add(aVar);
this.setVariables(variables);
@ -213,8 +212,8 @@ public class ASCIIGridDataInfo extends DataInfo implements IGridDataInfo {
int rangeIdx = 0;
Range yRange = section.getRange(rangeIdx++);
Range xRange = section.getRange(rangeIdx);
//IndexIterator ii = dataArray.getIndexIterator();
readXY(yRange, xRange, dataArray);
ArrayMath.missingToNaN(dataArray, this.missingValue);
return dataArray;
} catch (InvalidRangeException ex) {
@ -454,7 +453,7 @@ public class ASCIIGridDataInfo extends DataInfo implements IGridDataInfo {
ga.setData(this.read(varName));
ga.xArray = this.getXDimension().getValues();
ga.yArray = this.getYDimension().getValues();
ga.missingValue = this.getMissingValue();
ga.missingValue = this.missingValue;
return ga;
}

View File

@ -42,6 +42,7 @@ import org.meteoinfo.ndarray.InvalidRangeException;
import org.meteoinfo.ndarray.Range;
import org.meteoinfo.ndarray.Section;
import org.meteoinfo.data.meteodata.Attribute;
import org.meteoinfo.ndarray.math.ArrayMath;
/**
*
@ -216,7 +217,6 @@ import org.meteoinfo.data.meteodata.Attribute;
aVar.setDataType(dtype);
aVar.addDimension(yDim);
aVar.addDimension(xDim);
aVar.setFillValue(nodata);
variables.add(aVar);
}
this.setVariables(variables);
@ -288,6 +288,8 @@ import org.meteoinfo.data.meteodata.Attribute;
Range xRange = section.getRange(rangeIdx);
IndexIterator ii = array.getIndexIterator();
this.readArray_bil_xy(varIdx, array.getDataType(), yRange, xRange, ii);
ArrayMath.missingToNaN(array, this.missingValue);
return array;
} catch (InvalidRangeException ex) {
Logger.getLogger(BILDataInfo.class.getName()).log(Level.SEVERE, null, ex);

View File

@ -24,6 +24,7 @@ import org.meteoinfo.data.dimarray.DimensionType;
import org.meteoinfo.data.meteodata.IGridDataInfo;
import org.meteoinfo.data.meteodata.Variable;
import org.meteoinfo.common.io.EndianDataOutputStream;
import org.meteoinfo.ndarray.math.ArrayMath;
import org.meteoinfo.ndarray.util.BigDecimalUtil;
import org.meteoinfo.projection.KnownCoordinateSystems;
import org.meteoinfo.projection.ProjectionInfo;
@ -328,7 +329,7 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
int i;
boolean isEnd = false;
//Set dufault value
//Set default value
DESCRIPTOR = aFile;
boolean isReadLine = true;
boolean isNotPath = false;
@ -940,7 +941,6 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
if (this.getDataType() == MeteoDataType.GRADS_STATION) {
aVar.setStation(true);
}
aVar.setFillValue(this.getMissingValue());
VARDEF.addVar(aVar);
this.addVariable(aVar);
@ -1404,6 +1404,7 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
}
}
}
ArrayMath.missingToNaN(dataArray, this.missingValue);
return dataArray;
} catch (InvalidRangeException ex) {

View File

@ -39,6 +39,7 @@ import org.meteoinfo.ndarray.InvalidRangeException;
import org.meteoinfo.ndarray.Range;
import org.meteoinfo.ndarray.Section;
import org.meteoinfo.data.meteodata.Attribute;
import org.meteoinfo.ndarray.math.ArrayMath;
/**
*
@ -196,7 +197,6 @@ public class MICAPS11DataInfo extends DataInfo implements IGridDataInfo {
var.setDimension(zdim);
var.setDimension(ydim);
var.setDimension(xdim);
var.setFillValue(this.getMissingValue());
variables.add(var);
}
this.setVariables(variables);
@ -269,6 +269,10 @@ public class MICAPS11DataInfo extends DataInfo implements IGridDataInfo {
IndexIterator ii = dataArray.getIndexIterator();
readXY(varName, yRange, xRange, ii);
if (dataArray.getDataType().isNumeric()) {
ArrayMath.missingToNaN(dataArray, this.missingValue);
}
return dataArray;
} catch (InvalidRangeException ex) {
Logger.getLogger(MICAPS4DataInfo.class.getName()).log(Level.SEVERE, null, ex);

View File

@ -141,7 +141,6 @@ public class MICAPS120DataInfo extends DataInfo implements IStationDataInfo {
}
var.setStation(true);
var.setDimension(stdim);
var.setFillValue(this.getMissingValue());
variables.add(var);
}
this.setVariables(variables);
@ -266,6 +265,10 @@ public class MICAPS120DataInfo extends DataInfo implements IStationDataInfo {
}
}
}
if (r.getDataType().isNumeric()) {
ArrayMath.missingToNaN(r, this.missingValue);
}
return r;
}

View File

@ -173,7 +173,6 @@ public class MICAPS1DataInfo extends DataInfo implements IStationDataInfo {
var.setStation(true);
var.setDimension(tdim);
var.setDimension(stdim);
var.setFillValue(this.getMissingValue());
variables.add(var);
}
this.setVariables(variables);
@ -440,6 +439,9 @@ public class MICAPS1DataInfo extends DataInfo implements IStationDataInfo {
}
try {
r = r.section(origin, shape, stride);
if (r.getDataType().isNumeric()) {
ArrayMath.missingToNaN(r, this.missingValue);
}
} catch (InvalidRangeException ex) {
Logger.getLogger(MICAPS1DataInfo.class.getName()).log(Level.SEVERE, null, ex);
}

View File

@ -30,6 +30,7 @@ import org.meteoinfo.data.meteodata.Variable;
import org.meteoinfo.ndarray.Array;
import org.meteoinfo.ndarray.DataType;
import org.meteoinfo.data.meteodata.Attribute;
import org.meteoinfo.ndarray.math.ArrayMath;
/**
*
@ -145,7 +146,6 @@ public class MICAPS2DataInfo extends DataInfo implements IStationDataInfo {
//var.setDimension(tdim);
//var.setDimension(zdim);
var.setDimension(stdim);
var.setFillValue(this.getMissingValue());
variables.add(var);
}
this.setVariables(variables);
@ -258,6 +258,10 @@ public class MICAPS2DataInfo extends DataInfo implements IStationDataInfo {
}
}
if (r.getDataType().isNumeric()) {
ArrayMath.missingToNaN(r, this.missingValue);
}
return r;
}

View File

@ -172,7 +172,6 @@ public class MICAPS3DataInfo extends DataInfo implements IStationDataInfo {
//var.setDimension(tdim);
//var.setDimension(zdim);
var.setDimension(stdim);
var.setFillValue(this.getMissingValue());
variables.add(var);
}
this.setVariables(variables);
@ -272,6 +271,10 @@ public class MICAPS3DataInfo extends DataInfo implements IStationDataInfo {
break;
}
}
if (r.getDataType().isNumeric()) {
ArrayMath.missingToNaN(r, this.missingValue);
}
return r;
}

View File

@ -42,6 +42,7 @@ import org.meteoinfo.ndarray.InvalidRangeException;
import org.meteoinfo.ndarray.Range;
import org.meteoinfo.ndarray.Section;
import org.meteoinfo.data.meteodata.Attribute;
import org.meteoinfo.ndarray.math.ArrayMath;
/**
*
@ -195,7 +196,6 @@ public class MICAPS4DataInfo extends DataInfo implements IGridDataInfo {
var.setDimension(zdim);
var.setDimension(ydim);
var.setDimension(xdim);
var.setFillValue(this.getMissingValue());
variables.add(var);
this.setVariables(variables);
} catch (IOException ex) {
@ -256,6 +256,10 @@ public class MICAPS4DataInfo extends DataInfo implements IGridDataInfo {
IndexIterator ii = dataArray.getIndexIterator();
readXY(yRange, xRange, ii);
if (dataArray.getDataType().isNumeric()) {
ArrayMath.missingToNaN(dataArray, this.missingValue);
}
return dataArray;
} catch (InvalidRangeException ex) {
Logger.getLogger(MICAPS4DataInfo.class.getName()).log(Level.SEVERE, null, ex);

View File

@ -362,10 +362,10 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
}
//nvar.setAttributes(var.getAttributes());
double[] packData = this.getPackData(var);
/*double[] packData = this.getPackData(var);
nvar.setAddOffset(packData[0]);
nvar.setScaleFactor(packData[1]);
nvar.setFillValue(packData[2]);
nvar.setFillValue(packData[2]);*/
vars.add(nvar);
}

View File

@ -1,34 +1,32 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<MeteoInfo File="milconfig.xml" Type="configurefile">
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\animation">
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\json"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface"/>
<Path OpenPath="D:\Working\MIScript\Jython\mis\map\webmap">
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\no_opengl"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\geoshow"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\oco-2"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/>
<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\animation"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart\subplot"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\webmap"/>
</Path>
<File>
<OpenedFiles>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\geoshow\geoshow_image_2.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\map\northarrow_lcc.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\array\spacing.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\animation\surf.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\chart\subplot\subplot_3.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\chart\subplot\subplot_2.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\map\add_circle.py"/>
</OpenedFiles>
<RecentFiles>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\geoshow\geoshow_image_2.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\map\northarrow_lcc.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\array\spacing.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\animation\surf.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\chart\subplot\subplot_3.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\chart\subplot\subplot_2.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\map\add_circle.py"/>
</RecentFiles>
</File>
<Font>

View File

@ -36,9 +36,6 @@ class DimVariable(object):
self.dims = variable.getDimensions()
self.ndim = variable.getDimNumber()
self.attributes = variable.getAttributes()
self.fill_value = variable.getFillValue()
self.scale_factor = variable.getScaleFactor()
self.add_offset = variable.getAddOffset()
elif not ncvariable is None:
self.name = ncvariable.getShortName()
self.dtype = ncvariable.getDataType()
@ -300,14 +297,14 @@ class DimVariable(object):
for i in flips:
rr = rr.flip(i)
rr = rr.reduce()
ArrayMath.missingToNaN(rr, self.fill_value)
#ArrayMath.missingToNaN(rr, self.fill_value)
if len(flips) > 0:
rrr = Array.factory(rr.getDataType(), rr.getShape())
MAMath.copy(rrr, rr)
array = np.array(rrr)
else:
array = np.array(rr)
data = np.DimArray(array, dims, self.fill_value, self.dataset.proj)
data = np.DimArray(array, dims, self.dataset.proj)
return data
def read(self):
@ -589,9 +586,6 @@ class TDimVariable(object):
self.name = variable.getName()
self.dtype = np.dtype.fromjava(variable.getDataType())
self.ndim = variable.getDimNumber()
self.fill_value = variable.getFillValue()
self.scale_factor = variable.getScaleFactor()
self.add_offset = variable.getAddOffset()
dims = variable.getDimensions()
tdim = Dimension(DimensionType.T)
times = []
@ -759,5 +753,5 @@ class TDimVariable(object):
dims = aa.dims
dims[0].setDimValues(times)
r = np.DimArray(data, dims, aa.fill_value, aa.proj)
r = np.DimArray(data, dims, aa.proj)
return r

View File

@ -50,7 +50,7 @@ def dimension(value, name='null', type=None):
# Dimension array
class DimArray(NDArray):
def __init__(self, array, dims=None, fill_value=-9999.0, proj=ProjectionInfo.LONG_LAT):
def __init__(self, array, dims=None, proj=ProjectionInfo.LONG_LAT):
if isinstance(array, NDArray):
array = array._array
super(DimArray, self).__init__(array)
@ -58,9 +58,6 @@ class DimArray(NDArray):
if not dims is None:
for dim in dims:
self.adddim(dim)
self.fill_value = fill_value
if math.isnan(self.fill_value):
self.fill_value = -9999.0
self.proj = proj
def __getitem__(self, indices):
@ -310,124 +307,124 @@ class DimArray(NDArray):
for i in flips:
r = r.flip(i)
data = DimArray(r, ndims, self.fill_value, self.proj)
data = DimArray(r, ndims, self.proj)
if onlyrange:
data.base = self.get_base()
return data
def __add__(self, other):
r = super(DimArray, self).__add__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __radd__(self, other):
return DimArray.__add__(self, other)
def __sub__(self, other):
r = super(DimArray, self).__sub__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __rsub__(self, other):
r = super(DimArray, self).__rsub__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __mul__(self, other):
r = super(DimArray, self).__mul__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __rmul__(self, other):
return DimArray.__mul__(self, other)
def __div__(self, other):
r = super(DimArray, self).__div__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __rdiv__(self, other):
r = super(DimArray, self).__rdiv__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __floordiv__(self, other):
r = super(DimArray, self).__floordiv__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __rfloordiv__(self, other):
r = super(DimArray, self).__rfloordiv__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __mod__(self, other):
r = super(DimArray, self).__mod__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __rmod__(self, other):
r = super(DimArray, self).__rmod__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __divmod__(self, other):
r = super(DimArray, self).__divmod__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __rdivmod__(self, other):
r = super(DimArray, self).__rdivmod__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __pow__(self, other):
r = super(DimArray, self).__pow__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __rpow__(self, other):
r = super(DimArray, self).__rpow__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __neg__(self):
r = super(DimArray, self).__neg__()
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __lt__(self, other):
r = super(DimArray, self).__lt__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __le__(self, other):
r = super(DimArray, self).__le__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __eq__(self, other):
r = super(DimArray, self).__eq__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __ne__(self, other):
r = super(DimArray, self).__ne__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __gt__(self, other):
r = super(DimArray, self).__gt__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __ge__(self, other):
r = super(DimArray, self).__ge__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __and__(self, other):
r = super(DimArray, self).__and__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __or__(self, other):
r = super(DimArray, self).__or__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __xor__(self, other):
r = super(DimArray, self).__xor__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __invert__(self, other):
r = super(DimArray, self).__invert__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __lshift__(self, other):
r = super(DimArray, self).__lshift__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def __rshift__(self, other):
r = super(DimArray, self).__rshift__(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
@property
def array(self):
@ -477,7 +474,7 @@ class DimArray(NDArray):
raise KeyError('The member %s not exists!' % member)
a = a.extractMemberArray(m)
r = DimArray(a, self.dims, self.fill_value, self.proj)
r = DimArray(a, self.dims, self.proj)
if not indices is None:
r = r.__getitem__(indices)
@ -493,7 +490,7 @@ class DimArray(NDArray):
:returns: (*array*) The array with element value of 1 or 0.
"""
r = super(DimArray, self).in_values(other)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def astype(self, dtype):
"""
@ -504,7 +501,7 @@ class DimArray(NDArray):
:returns: (*array*) Converted array.
"""
r = super(DimArray, self).astype(dtype)
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def value(self, indices):
#print type(indices)
@ -569,14 +566,14 @@ class DimArray(NDArray):
rr = Array.factory(r.getDataType(), r.getShape());
MAMath.copy(rr, r);
array = NDArray(rr)
data = DimArray(array, dims, self.fill_value, self.proj)
data = DimArray(array, dims, self.proj)
return data
def copy(self):
"""
Copy array vlaues to a new array.
"""
return DimArray(self._array.copy(), self.dims, self.fill_value, self.proj)
return DimArray(self._array.copy(), self.dims, self.proj)
# get dimension length
def dimlen(self, idx=0):
@ -776,7 +773,7 @@ class DimArray(NDArray):
else:
return False
def asgriddata(self, xdata=None, ydata=None, fill_value=None):
def asgriddata(self, xdata=None, ydata=None, fill_value=-9999.0):
if xdata is None or ydata is None:
xdata = self.dimvalue(1)
ydata = self.dimvalue(0)
@ -787,12 +784,11 @@ class DimArray(NDArray):
if ydata[1] < ydata[0]:
ydata = ydata[::-1]
data = self.array[::-1,:]
if fill_value is None:
fill_value = self.fill_value;
gdata = GridData(data._array, xdata._array, ydata._array, fill_value, self.proj)
return PyGridData(gdata)
def asgridarray(self, xdata=None, ydata=None, fill_value=None):
def asgridarray(self, xdata=None, ydata=None, fill_value=-9999.0):
if xdata is None or ydata is None:
xdata = self.dimvalue(1)
ydata = self.dimvalue(0)
@ -803,8 +799,7 @@ class DimArray(NDArray):
if ydata[1] < ydata[0]:
ydata = ydata[::-1]
data = self.array[::-1,:]
if fill_value is None:
fill_value = self.fill_value
gdata = GridArray(data._array, xdata._array, ydata._array, fill_value, self.proj)
return gdata
@ -825,7 +820,7 @@ class DimArray(NDArray):
for i in range(0, self.ndim):
if i != axis:
dims.append(self.dims[i])
return DimArray(r, dims, self.fill_value, self.proj)
return DimArray(r, dims, self.proj)
def max(self, axis=None):
"""
@ -848,7 +843,7 @@ class DimArray(NDArray):
else:
if i != axis:
dims.append(self.dims[i])
return DimArray(r, dims, self.fill_value, self.proj)
return DimArray(r, dims, self.proj)
def min(self, axis=None):
"""
@ -871,7 +866,7 @@ class DimArray(NDArray):
else:
if i != axis:
dims.append(self.dims[i])
return DimArray(r, dims, self.fill_value, self.proj)
return DimArray(r, dims, self.proj)
def mean(self, axis=None, keepdims=False):
"""
@ -896,7 +891,7 @@ class DimArray(NDArray):
else:
if i != axis:
dims.append(self.dims[i])
return DimArray(r, dims, self.fill_value, self.proj)
return DimArray(r, dims, self.proj)
def median(self, axis=None):
"""
@ -915,7 +910,7 @@ class DimArray(NDArray):
for i in range(0, self.ndim):
if i != axis:
dims.append(self.dims[i])
return DimArray(r, dims, self.fill_value, self.proj)
return DimArray(r, dims, self.proj)
def std(self, axis=None, ddof=0):
"""
@ -936,7 +931,7 @@ class DimArray(NDArray):
for i in range(0, self.ndim):
if i != axis:
dims.append(self.dims[i])
return DimArray(r, dims, self.fill_value, self.proj)
return DimArray(r, dims, self.proj)
def var(self, axis=None, ddof=0):
"""
@ -957,7 +952,7 @@ class DimArray(NDArray):
for i in range(0, self.ndim):
if i != axis:
dims.append(self.dims[i])
return DimArray(r, dims, self.fill_value, self.proj)
return DimArray(r, dims, self.proj)
def abs(self):
"""
@ -967,7 +962,7 @@ class DimArray(NDArray):
For complex input, a + ib, the absolute value is \sqrt{ a^2 + b^2 }.
"""
r = super(DimArray, self).abs()
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def ceil(self):
"""
@ -976,7 +971,7 @@ class DimArray(NDArray):
:return: The ceiling of each element.
"""
r = super(DimArray, self).ceil()
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def floor(self):
"""
@ -985,7 +980,7 @@ class DimArray(NDArray):
:return: The floor of each element.
"""
r = super(DimArray, self).floor()
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def sqrt(self):
"""
@ -994,7 +989,7 @@ class DimArray(NDArray):
:returns: (*DimArray*) Sqrt value array.
"""
r = super(DimArray, self).sqrt()
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def sin(self):
"""
@ -1003,7 +998,7 @@ class DimArray(NDArray):
:returns: (*DimArray*) Sin value array.
"""
r = super(DimArray, self).sin()
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def sinh(self):
"""
@ -1012,11 +1007,11 @@ class DimArray(NDArray):
:returns: (*DimArray*) Hyperbolic sin value array.
"""
r = super(DimArray, self).sinh()
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def cos(self):
r = super(DimArray, self).cos()
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def cosh(self):
"""
@ -1025,11 +1020,11 @@ class DimArray(NDArray):
:returns: (*DimArray*) Hyperbolic cos value array.
"""
r = super(DimArray, self).cosh()
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def tan(self):
r = super(DimArray, self).tan()
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def tanh(self):
"""
@ -1038,11 +1033,11 @@ class DimArray(NDArray):
:returns: (*DimArray*) Hyperbolic tan value array.
"""
r = super(DimArray, self).tanh()
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def asin(self):
r = super(DimArray, self).asin()
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def acos(self):
"""
@ -1051,23 +1046,23 @@ class DimArray(NDArray):
:returns: (*DimArray*) Acos value array.
"""
r = super(DimArray, self).acos()
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def atan(self):
r = super(DimArray, self).atan()
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def exp(self):
r = super(DimArray, self).exp()
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def log(self):
r = super(DimArray, self).log()
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def log10(self):
r = super(DimArray, self).log10()
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
def maskout(self, mask):
"""
@ -1079,7 +1074,7 @@ class DimArray(NDArray):
"""
if isinstance(mask, NDArray):
r = ArrayMath.maskout(self.asarray(), mask.asarray())
return DimArray(NDArray(r), self.dims, self.fill_value, self.proj)
return DimArray(NDArray(r), self.dims, self.proj)
else:
x = self.dims[1].getDimValue()
y = self.dims[0].getDimValue()
@ -1089,7 +1084,7 @@ class DimArray(NDArray):
if not isinstance(mask, (list, ArrayList)):
mask = [mask]
r = GeometryUtil.maskout(self.asarray(), x, y, mask)
r = DimArray(NDArray(r), self.dims, self.fill_value, self.proj)
r = DimArray(NDArray(r), self.dims, self.proj)
return r
def maskin(self, mask):
@ -1102,14 +1097,14 @@ class DimArray(NDArray):
"""
if isinstance(mask, NDArray):
r = ArrayMath.maskin(self.asarray(), mask.asarray())
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
else:
x = self.dimvalue(1)
y = self.dimvalue(0)
if not isinstance(mask, (list, ArrayList)):
mask = [mask]
r = GeometryUtil.maskin(self._array, x._array, y._array, mask)
r = DimArray(r, self.dims, self.fill_value, self.proj)
r = DimArray(r, self.dims, self.proj)
return r
def transpose(self, axes=None):
@ -1133,7 +1128,7 @@ class DimArray(NDArray):
for ax in axes:
dims.append(self.dims[ax])
return DimArray(r, dims, self.fill_value, self.proj)
return DimArray(r, dims, self.proj)
T = property(transpose)
@ -1166,7 +1161,7 @@ class DimArray(NDArray):
dims.append(self.dims[axis1])
else:
dims.append(self.dims[i])
return DimArray(r, dims, self.fill_value, self.proj)
return DimArray(r, dims, self.proj)
def inv(self):
"""
@ -1175,7 +1170,7 @@ class DimArray(NDArray):
:returns: Inverse matrix array.
"""
r = super(DimArray, self).inv()
return DimArray(r, self.dims, self.fill_value, self.proj)
return DimArray(r, self.dims, self.proj)
I = property(inv)
@ -1342,7 +1337,7 @@ class DimArray(NDArray):
xdim = Dimension(DimensionType.X)
xdim.setDimValues(NDArray(x).aslist())
dims[-1] = xdim
rr = DimArray(NDArray(r), dims, self.fill_value, toproj)
rr = DimArray(NDArray(r), dims, toproj)
return rr
if method == 'bilinear':
@ -1384,7 +1379,7 @@ class DimArray(NDArray):
rdims.append(ndim)
else:
rdims.append(self.dims[i])
return DimArray(NDArray(r), rdims, self.fill_value, self.proj)
return DimArray(NDArray(r), rdims, self.proj)
def savegrid(self, fname, format='surfer', **kwargs):
"""

View File

@ -11,6 +11,7 @@ from org.meteoinfo.chart.graphic import GraphicFactory
from org.meteoinfo.chart import ChartText3D
from org.meteoinfo.chart.axis import Axis, LonLatAxis, TimeAxis, LogAxis
from org.meteoinfo.geo.legend import LegendManage
from org.meteoinfo.geo.io import GraphicUtil
from org.meteoinfo.geometry.legend import BreakTypes, PolylineBreak
from org.meteoinfo.geometry.shape import ShapeTypes
from org.meteoinfo.geometry.graphic import Graphic
@ -1641,10 +1642,10 @@ class Axes3D(Axes):
plotutil.setlegendscheme(ls, **kwargs)
layer.setLegendScheme(ls)
graphics = GraphicFactory.createGraphicsFromLayer(layer, offset, xshift)
graphics = GraphicUtil.layerToGraphics(layer, offset, xshift)
else:
interpolation = kwargs.pop('interpolation', None)
graphics = GraphicFactory.createImage(layer, offset, xshift, interpolation)
graphics = GraphicUtil.layerToGraphics(layer, offset, xshift, interpolation)
lighting = kwargs.pop('lighting', None)
if not lighting is None:

View File

@ -10,6 +10,7 @@ from org.meteoinfo.chart.graphic import GraphicFactory
from org.meteoinfo.chart import AspectType
from org.meteoinfo.geometry.legend import BreakTypes, BarBreak, LegendManage
from org.meteoinfo.geo.layer import LayerTypes
from org.meteoinfo.geo.io import GraphicUtil
from org.meteoinfo.geometry.shape import ShapeTypes
from org.meteoinfo.geometry.graphic import Graphic, GraphicCollection
from org.meteoinfo.chart.jogl import GLPlot, GLForm, JOGLUtil, EarthGLPlot, MapGLPlot
@ -912,20 +913,18 @@ class Axes3DGL(Axes3D):
else:
plotutil.setlegendscheme(ls, **kwargs)
layer.setLegendScheme(ls)
graphics = GraphicFactory.createGraphicsFromLayer(layer, offset, xshift)
graphics = GraphicUtil.layerToGraphics(layer, offset, xshift)
else:
# interpolation = kwargs.pop('interpolation', None)
# graphics = GraphicFactory.createTexture(layer, offset, xshift, interpolation)
nlat = kwargs.pop('nlat', 180)
nlon = kwargs.pop('nlon', 360)
if self._axes.getProjInfo() is None:
graphics = GraphicFactory.geoSurface(layer, offset, xshift, nlon, nlat)
graphics = GraphicFactory.geoSurface(layer.getImage(), layer.getExtent(), offset, xshift, nlon, nlat)
else:
limits = kwargs.pop('limits', None)
if limits is None:
graphics = GraphicFactory.geoSurface(layer, offset, xshift, nlon, nlat, self._axes.getProjInfo())
graphics = GraphicFactory.geoSurface(layer.getImage(), layer.getExtent(), offset, xshift, nlon, nlat, self._axes.getProjInfo())
else:
graphics = GraphicFactory.geoSurface(layer, offset, xshift, nlon, nlat, self._axes.getProjInfo(),
graphics = GraphicFactory.geoSurface(layer.getImage, layer.getExtent(), offset, xshift, nlon, nlat, self._axes.getProjInfo(),
limits)
lighting = kwargs.pop('lighting', None)

View File

@ -22,7 +22,6 @@ from org.meteoinfo.projection import ProjectionInfo
from org.meteoinfo.common import Extent
from org.meteoinfo.geo.layer import LayerTypes, WebMapLayer
from org.meteoinfo.data.mapdata.webmap import WebMapProvider, DefaultTileFactory, TileFactoryInfo
from org.meteoinfo.geo.layout import ScaleBarType
from java.awt import Font, Color
@ -278,7 +277,7 @@ class MapAxes(Axes):
sb.setY(y)
bartype = kwargs.pop('bartype', None)
if not bartype is None:
bartype = ScaleBarType.valueOf(bartype.upper())
bartype = ChartScaleBar.ScaleBarType.valueOf(bartype.upper())
sb.setScaleBarType(bartype)
linewidth = kwargs.pop('linewidth', None)
if not linewidth is None: