mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
add 3.0 branch
This commit is contained in:
parent
b44995be9a
commit
b8a2415501
8
.idea/compiler.xml
generated
8
.idea/compiler.xml
generated
@ -6,16 +6,20 @@
|
|||||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
<outputRelativeToContentRoot value="true" />
|
<outputRelativeToContentRoot value="true" />
|
||||||
<module name="meteoinfo-ndarray" />
|
|
||||||
<module name="MeteoInfoLab" />
|
<module name="MeteoInfoLab" />
|
||||||
<module name="MeteoInfoLib" />
|
<module name="meteoinfo-math" />
|
||||||
<module name="MeteoInfoMap" />
|
<module name="MeteoInfoMap" />
|
||||||
<module name="meteoinfo-console" />
|
<module name="meteoinfo-console" />
|
||||||
|
<module name="meteoinfo-ndarray" />
|
||||||
|
<module name="meteoinfo-common" />
|
||||||
|
<module name="MeteoInfoLib" />
|
||||||
</profile>
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
<bytecodeTargetLevel>
|
<bytecodeTargetLevel>
|
||||||
<module name="MeteoInfo" target="1.8" />
|
<module name="MeteoInfo" target="1.8" />
|
||||||
|
<module name="meteoinfo-common" target="1.8" />
|
||||||
<module name="meteoinfo-console" target="1.8" />
|
<module name="meteoinfo-console" target="1.8" />
|
||||||
|
<module name="meteoinfo-math" target="1.8" />
|
||||||
<module name="meteoinfo-ndarray" target="1.8" />
|
<module name="meteoinfo-ndarray" target="1.8" />
|
||||||
<module name="MeteoInfoLab" target="1.8" />
|
<module name="MeteoInfoLab" target="1.8" />
|
||||||
<module name="MeteoInfoLib" target="1.8" />
|
<module name="MeteoInfoLib" target="1.8" />
|
||||||
|
|||||||
4
.idea/encodings.xml
generated
4
.idea/encodings.xml
generated
@ -11,8 +11,12 @@
|
|||||||
<file url="file://$PROJECT_DIR$/MeteoInfoMap" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/MeteoInfoMap" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/MeteoInfoMap/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/MeteoInfoMap/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/MeteoInfoMap/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/MeteoInfoMap/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/meteoinfo-common/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/meteoinfo-common/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/meteoinfo-console/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/meteoinfo-console/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/meteoinfo-console/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/meteoinfo-console/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/meteoinfo-math/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/meteoinfo-math/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/meteoinfo-ndarray/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/meteoinfo-ndarray/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/meteoinfo-ndarray/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/meteoinfo-ndarray/src/main/resources" charset="UTF-8" />
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
2
.idea/modules.xml
generated
2
.idea/modules.xml
generated
@ -6,7 +6,9 @@
|
|||||||
<module fileurl="file://$PROJECT_DIR$/MeteoInfoLab/MeteoInfoLab.iml" filepath="$PROJECT_DIR$/MeteoInfoLab/MeteoInfoLab.iml" />
|
<module fileurl="file://$PROJECT_DIR$/MeteoInfoLab/MeteoInfoLab.iml" filepath="$PROJECT_DIR$/MeteoInfoLab/MeteoInfoLab.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/MeteoInfoLib/MeteoInfoLib.iml" filepath="$PROJECT_DIR$/MeteoInfoLib/MeteoInfoLib.iml" />
|
<module fileurl="file://$PROJECT_DIR$/MeteoInfoLib/MeteoInfoLib.iml" filepath="$PROJECT_DIR$/MeteoInfoLib/MeteoInfoLib.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/MeteoInfoMap/MeteoInfoMap.iml" filepath="$PROJECT_DIR$/MeteoInfoMap/MeteoInfoMap.iml" />
|
<module fileurl="file://$PROJECT_DIR$/MeteoInfoMap/MeteoInfoMap.iml" filepath="$PROJECT_DIR$/MeteoInfoMap/MeteoInfoMap.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/meteoinfo-common/meteoinfo-common.iml" filepath="$PROJECT_DIR$/meteoinfo-common/meteoinfo-common.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/meteoinfo-console/meteoinfo-console.iml" filepath="$PROJECT_DIR$/meteoinfo-console/meteoinfo-console.iml" />
|
<module fileurl="file://$PROJECT_DIR$/meteoinfo-console/meteoinfo-console.iml" filepath="$PROJECT_DIR$/meteoinfo-console/meteoinfo-console.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/meteoinfo-math/meteoinfo-math.iml" filepath="$PROJECT_DIR$/meteoinfo-math/meteoinfo-math.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/meteoinfo-ndarray/meteoinfo-ndarray.iml" filepath="$PROJECT_DIR$/meteoinfo-ndarray/meteoinfo-ndarray.iml" />
|
<module fileurl="file://$PROJECT_DIR$/meteoinfo-ndarray/meteoinfo-ndarray.iml" filepath="$PROJECT_DIR$/meteoinfo-ndarray/meteoinfo-ndarray.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@ -22,6 +22,15 @@
|
|||||||
</library>
|
</library>
|
||||||
</orderEntry>
|
</orderEntry>
|
||||||
<orderEntry type="module" module-name="MeteoInfoLib" />
|
<orderEntry type="module" module-name="MeteoInfoLib" />
|
||||||
|
<orderEntry type="module" module-name="meteoinfo-math" />
|
||||||
|
<orderEntry type="module" module-name="meteoinfo-common" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.guava:guava:28.0-jre" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.guava:failureaccess:1.0.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.checkerframework:checker-qual:2.8.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.3.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.3" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.codehaus.mojo:animal-sniffer-annotations:1.17" level="project" />
|
||||||
<orderEntry type="module" module-name="meteoinfo-ndarray" />
|
<orderEntry type="module" module-name="meteoinfo-ndarray" />
|
||||||
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
|
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
|
||||||
<orderEntry type="library" name="Maven: edu.ucar:netcdfAll:5.4.1" level="project" />
|
<orderEntry type="library" name="Maven: edu.ucar:netcdfAll:5.4.1" level="project" />
|
||||||
|
|||||||
@ -1,29 +1,32 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\netcdf">
|
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl">
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\linalg"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\calipso"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\burf"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\burf"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\grib"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\grib"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\radar"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\radar"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\wrf"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\wrf"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\interpolation"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\interpolation"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\hdf"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\hdf"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\modis"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\modis"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\netcdf"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\netcdf"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||||
</Path>
|
</Path>
|
||||||
<File>
|
<File>
|
||||||
<OpenedFiles>
|
<OpenedFiles>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\city_streamslice_zslice_index.py"/>
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\city_streamslice_zslice_index.py"/>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\netcdf\dimension_reverse.py"/>
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\meteo\hdivg.py"/>
|
||||||
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\plot_cuace_3d_particles_relief.py"/>
|
||||||
</OpenedFiles>
|
</OpenedFiles>
|
||||||
<RecentFiles>
|
<RecentFiles>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\city_streamslice_zslice_index.py"/>
|
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\city_streamslice_zslice_index.py"/>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\netcdf\dimension_reverse.py"/>
|
<RecentFile File="D:\Working\MIScript\Jython\mis\meteo\hdivg.py"/>
|
||||||
|
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\plot_cuace_3d_particles_relief.py"/>
|
||||||
</RecentFiles>
|
</RecentFiles>
|
||||||
</File>
|
</File>
|
||||||
<Font>
|
<Font>
|
||||||
|
|||||||
Binary file not shown.
@ -1,5 +1,6 @@
|
|||||||
import midata
|
import midata
|
||||||
from .midata import *
|
from .midata import *
|
||||||
|
import ncutil
|
||||||
from .dimvariable import DimVariable
|
from .dimvariable import DimVariable
|
||||||
|
|
||||||
__all__ = ['ncutil', 'DimVariable']
|
__all__ = ['ncutil', 'DimVariable']
|
||||||
|
|||||||
Binary file not shown.
@ -6,7 +6,7 @@
|
|||||||
#-----------------------------------------------------
|
#-----------------------------------------------------
|
||||||
from org.meteoinfo.ndarray import Dimension, DimensionType, Range, Array, MAMath
|
from org.meteoinfo.ndarray import Dimension, DimensionType, Range, Array, MAMath
|
||||||
from org.meteoinfo.math import ArrayMath, ArrayUtil
|
from org.meteoinfo.math import ArrayMath, ArrayUtil
|
||||||
from org.meteoinfo.global import PointD
|
from org.meteoinfo.common import PointD
|
||||||
from org.meteoinfo.projection import KnownCoordinateSystems, Reproject
|
from org.meteoinfo.projection import KnownCoordinateSystems, Reproject
|
||||||
from org.meteoinfo.data.meteodata import Attribute
|
from org.meteoinfo.data.meteodata import Attribute
|
||||||
from ucar.nc2 import Attribute as NCAttribute
|
from ucar.nc2 import Attribute as NCAttribute
|
||||||
|
|||||||
Binary file not shown.
@ -1,58 +1,58 @@
|
|||||||
#-----------------------------------------------------
|
#-----------------------------------------------------
|
||||||
# Author: Yaqiang Wang
|
# Author: Yaqiang Wang
|
||||||
# Date: 2017-11-28
|
# Date: 2017-11-28
|
||||||
# Purpose: MeteoInfo geoutil module
|
# Purpose: MeteoInfo geoutil module
|
||||||
# Note: Jython
|
# Note: Jython
|
||||||
#-----------------------------------------------------
|
#-----------------------------------------------------
|
||||||
|
|
||||||
from org.meteoinfo.shape import ShapeUtil, PointShape
|
from org.meteoinfo.shape import ShapeUtil, PointShape
|
||||||
from org.meteoinfo.global import PointD
|
from org.meteoinfo.common import PointD
|
||||||
import mipylib.numeric as np
|
import mipylib.numeric as np
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'makeshapes'
|
'makeshapes'
|
||||||
]
|
]
|
||||||
|
|
||||||
def makeshapes(x, y, type=None, z=None, m=None):
|
def makeshapes(x, y, type=None, z=None, m=None):
|
||||||
"""
|
"""
|
||||||
Make shapes by x and y coordinates.
|
Make shapes by x and y coordinates.
|
||||||
|
|
||||||
:param x: (*array_like*) X coordinates.
|
:param x: (*array_like*) X coordinates.
|
||||||
:param y: (*array_like*) Y coordinates.
|
:param y: (*array_like*) Y coordinates.
|
||||||
:param type: (*string*) Shape type [point | line | polygon].
|
:param type: (*string*) Shape type [point | line | polygon].
|
||||||
:param z: (*array_like*) Z coordinates.
|
:param z: (*array_like*) Z coordinates.
|
||||||
:param m: (*array_like*) M coordinates.
|
:param m: (*array_like*) M coordinates.
|
||||||
|
|
||||||
:returns: Shapes
|
:returns: Shapes
|
||||||
"""
|
"""
|
||||||
shapes = []
|
shapes = []
|
||||||
if isinstance(x, (int, float)):
|
if isinstance(x, (int, float)):
|
||||||
shape = PointShape()
|
shape = PointShape()
|
||||||
shape.setPoint(PointD(x, y))
|
shape.setPoint(PointD(x, y))
|
||||||
shapes.append(shape)
|
shapes.append(shape)
|
||||||
else:
|
else:
|
||||||
x = np.asarray(x)._array
|
x = np.asarray(x)._array
|
||||||
y = np.asarray(y)._array
|
y = np.asarray(y)._array
|
||||||
if not z is None:
|
if not z is None:
|
||||||
if m is None:
|
if m is None:
|
||||||
m = np.zeros(len(z))._array
|
m = np.zeros(len(z))._array
|
||||||
else:
|
else:
|
||||||
m = np.asarray(m)._array
|
m = np.asarray(m)._array
|
||||||
z = np.asarray(z)._array
|
z = np.asarray(z)._array
|
||||||
if type == 'point':
|
if type == 'point':
|
||||||
if z is None:
|
if z is None:
|
||||||
shapes = ShapeUtil.createPointShapes(x, y)
|
shapes = ShapeUtil.createPointShapes(x, y)
|
||||||
else:
|
else:
|
||||||
shapes = ShapeUtil.createPointShapes(x, y, z, m)
|
shapes = ShapeUtil.createPointShapes(x, y, z, m)
|
||||||
elif type == 'line':
|
elif type == 'line':
|
||||||
if z is None:
|
if z is None:
|
||||||
shapes = ShapeUtil.createPolylineShapes(x, y)
|
shapes = ShapeUtil.createPolylineShapes(x, y)
|
||||||
else:
|
else:
|
||||||
shapes = ShapeUtil.createPolylineShapes(x, y, z, m)
|
shapes = ShapeUtil.createPolylineShapes(x, y, z, m)
|
||||||
elif type == 'polygon':
|
elif type == 'polygon':
|
||||||
if z is None:
|
if z is None:
|
||||||
shapes = ShapeUtil.createPolygonShapes(x, y)
|
shapes = ShapeUtil.createPolygonShapes(x, y)
|
||||||
else:
|
else:
|
||||||
shapes = ShapeUtil.createPolygonShape(x, y, z, m)
|
shapes = ShapeUtil.createPolygonShape(x, y, z, m)
|
||||||
return shapes
|
return shapes
|
||||||
|
|
||||||
Binary file not shown.
@ -16,8 +16,8 @@ from org.meteoinfo.math import ArrayMath, ArrayUtil
|
|||||||
from org.meteoinfo.data.mapdata import MapDataManage, AttributeTable
|
from org.meteoinfo.data.mapdata import MapDataManage, AttributeTable
|
||||||
from org.meteoinfo.projection import KnownCoordinateSystems, Reproject
|
from org.meteoinfo.projection import KnownCoordinateSystems, Reproject
|
||||||
from org.meteoinfo.projection.info import ProjectionInfo
|
from org.meteoinfo.projection.info import ProjectionInfo
|
||||||
from org.meteoinfo.global import PointD
|
from org.meteoinfo.common import PointD
|
||||||
from org.meteoinfo.io import IOUtil
|
from org.meteoinfo.common.io import IOUtil
|
||||||
from org.meteoinfo.geoprocess.analysis import ResampleMethods
|
from org.meteoinfo.geoprocess.analysis import ResampleMethods
|
||||||
|
|
||||||
from milayer import MILayer
|
from milayer import MILayer
|
||||||
|
|||||||
Binary file not shown.
@ -5,8 +5,8 @@
|
|||||||
# Note: Jython
|
# Note: Jython
|
||||||
#-----------------------------------------------------
|
#-----------------------------------------------------
|
||||||
|
|
||||||
from org.meteoinfo.global import PointD
|
from org.meteoinfo.common import PointD
|
||||||
from org.meteoinfo.global.util import JDateUtil
|
from org.meteoinfo.common.util import JDateUtil
|
||||||
from org.meteoinfo.ndarray import Complex
|
from org.meteoinfo.ndarray import Complex
|
||||||
from org.meteoinfo.shape import PointShape, ShapeUtil
|
from org.meteoinfo.shape import PointShape, ShapeUtil
|
||||||
from java.util import Locale
|
from java.util import Locale
|
||||||
|
|||||||
Binary file not shown.
@ -9,7 +9,7 @@ from org.meteoinfo.data import GridData, GridArray
|
|||||||
from org.meteoinfo.math import ArrayMath, ArrayUtil
|
from org.meteoinfo.math import ArrayMath, ArrayUtil
|
||||||
from org.meteoinfo.geoprocess import GeometryUtil
|
from org.meteoinfo.geoprocess import GeometryUtil
|
||||||
from org.meteoinfo.geoprocess.analysis import ResampleMethods
|
from org.meteoinfo.geoprocess.analysis import ResampleMethods
|
||||||
from org.meteoinfo.global import PointD
|
from org.meteoinfo.common import PointD
|
||||||
from org.meteoinfo.ndarray import Array, Range, MAMath, DataType, Dimension, DimensionType
|
from org.meteoinfo.ndarray import Array, Range, MAMath, DataType, Dimension, DimensionType
|
||||||
from multiarray import NDArray
|
from multiarray import NDArray
|
||||||
import math
|
import math
|
||||||
|
|||||||
Binary file not shown.
@ -14,7 +14,7 @@ from org.meteoinfo.chart.axis import Axis, LonLatAxis, TimeAxis, LogAxis
|
|||||||
from org.meteoinfo.legend import LegendManage, BarBreak, PolygonBreak, PolylineBreak, \
|
from org.meteoinfo.legend import LegendManage, BarBreak, PolygonBreak, PolylineBreak, \
|
||||||
PointBreak, LineStyles, PointStyle, LegendScheme, LegendType
|
PointBreak, LineStyles, PointStyle, LegendScheme, LegendType
|
||||||
from org.meteoinfo.shape import ShapeTypes, Graphic, GraphicCollection
|
from org.meteoinfo.shape import ShapeTypes, Graphic, GraphicCollection
|
||||||
from org.meteoinfo.global import MIMath, Extent
|
from org.meteoinfo.common import MIMath, Extent
|
||||||
from org.meteoinfo.layer import MapLayer
|
from org.meteoinfo.layer import MapLayer
|
||||||
|
|
||||||
from java.awt import Font, Color, BasicStroke
|
from java.awt import Font, Color, BasicStroke
|
||||||
|
|||||||
Binary file not shown.
@ -16,7 +16,7 @@ from org.meteoinfo.map import MapView
|
|||||||
from org.meteoinfo.legend import BreakTypes, LegendManage, LegendScheme, LegendType
|
from org.meteoinfo.legend import BreakTypes, LegendManage, LegendScheme, LegendType
|
||||||
from org.meteoinfo.shape import Shape, PolylineShape, PolygonShape, ShapeTypes, Graphic
|
from org.meteoinfo.shape import Shape, PolylineShape, PolygonShape, ShapeTypes, Graphic
|
||||||
from org.meteoinfo.projection.info import ProjectionInfo
|
from org.meteoinfo.projection.info import ProjectionInfo
|
||||||
from org.meteoinfo.global import Extent
|
from org.meteoinfo.common import Extent
|
||||||
from org.meteoinfo.layer import LayerTypes, WebMapLayer
|
from org.meteoinfo.layer import LayerTypes, WebMapLayer
|
||||||
from org.meteoinfo.data.mapdata.webmap import WebMapProvider
|
from org.meteoinfo.data.mapdata.webmap import WebMapProvider
|
||||||
from org.meteoinfo.layout import ScaleBarType
|
from org.meteoinfo.layout import ScaleBarType
|
||||||
|
|||||||
@ -21,9 +21,9 @@ import com.formdev.flatlaf.FlatDarculaLaf;
|
|||||||
import com.formdev.flatlaf.FlatDarkLaf;
|
import com.formdev.flatlaf.FlatDarkLaf;
|
||||||
import com.formdev.flatlaf.FlatIntelliJLaf;
|
import com.formdev.flatlaf.FlatIntelliJLaf;
|
||||||
import com.formdev.flatlaf.FlatLightLaf;
|
import com.formdev.flatlaf.FlatLightLaf;
|
||||||
|
import org.meteoinfo.common.util.GlobalUtil;
|
||||||
import org.meteoinfo.global.DataConvert;
|
import org.meteoinfo.global.DataConvert;
|
||||||
import org.meteoinfo.global.util.FontUtil;
|
import org.meteoinfo.global.util.FontUtil;
|
||||||
import org.meteoinfo.global.util.GlobalUtil;
|
|
||||||
import org.meteoinfo.laboratory.gui.FrmMain;
|
import org.meteoinfo.laboratory.gui.FrmMain;
|
||||||
import org.meteoinfo.console.jython.MyPythonInterpreter;
|
import org.meteoinfo.console.jython.MyPythonInterpreter;
|
||||||
import org.python.core.Py;
|
import org.python.core.Py;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -22,7 +22,7 @@ import javax.swing.table.TableModel;
|
|||||||
import javax.swing.table.TableRowSorter;
|
import javax.swing.table.TableRowSorter;
|
||||||
|
|
||||||
import com.formdev.flatlaf.extras.FlatSVGIcon;
|
import com.formdev.flatlaf.extras.FlatSVGIcon;
|
||||||
import org.meteoinfo.global.util.JDateUtil;
|
import org.meteoinfo.common.util.JDateUtil;
|
||||||
import org.meteoinfo.laboratory.event.CurrentPathChangedEvent;
|
import org.meteoinfo.laboratory.event.CurrentPathChangedEvent;
|
||||||
import org.meteoinfo.laboratory.event.ICurrentPathChangedListener;
|
import org.meteoinfo.laboratory.event.ICurrentPathChangedListener;
|
||||||
import org.meteoinfo.table.IconRenderer;
|
import org.meteoinfo.table.IconRenderer;
|
||||||
|
|||||||
@ -4,6 +4,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.meteoinfo.laboratory.gui;
|
package org.meteoinfo.laboratory.gui;
|
||||||
|
|
||||||
|
import org.meteoinfo.common.util.GlobalUtil;
|
||||||
|
|
||||||
import java.awt.Cursor;
|
import java.awt.Cursor;
|
||||||
import java.awt.Desktop;
|
import java.awt.Desktop;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -11,7 +13,6 @@ import java.net.URI;
|
|||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.meteoinfo.global.util.GlobalUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@ -15,9 +15,10 @@ import java.util.logging.Logger;
|
|||||||
import javax.swing.DefaultListModel;
|
import javax.swing.DefaultListModel;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
|
import org.meteoinfo.common.util.GlobalUtil;
|
||||||
import org.meteoinfo.laboratory.application.Application;
|
import org.meteoinfo.laboratory.application.Application;
|
||||||
import org.meteoinfo.laboratory.application.AppCollection;
|
import org.meteoinfo.laboratory.application.AppCollection;
|
||||||
import org.meteoinfo.global.util.GlobalUtil;
|
|
||||||
import org.meteoinfo.plugin.IPlugin;
|
import org.meteoinfo.plugin.IPlugin;
|
||||||
import org.meteoinfo.ui.CheckBoxListEntry;
|
import org.meteoinfo.ui.CheckBoxListEntry;
|
||||||
import org.python.core.PyObject;
|
import org.python.core.PyObject;
|
||||||
|
|||||||
@ -12,6 +12,15 @@
|
|||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="module" module-name="meteoinfo-math" />
|
||||||
|
<orderEntry type="module" module-name="meteoinfo-common" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.guava:guava:28.0-jre" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.guava:failureaccess:1.0.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.checkerframework:checker-qual:2.8.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.3.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.3" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.codehaus.mojo:animal-sniffer-annotations:1.17" level="project" />
|
||||||
<orderEntry type="module" module-name="meteoinfo-ndarray" />
|
<orderEntry type="module" module-name="meteoinfo-ndarray" />
|
||||||
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
|
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
|
||||||
<orderEntry type="library" name="Maven: edu.ucar:netcdfAll:5.4.1" level="project" />
|
<orderEntry type="library" name="Maven: edu.ucar:netcdfAll:5.4.1" level="project" />
|
||||||
|
|||||||
@ -47,6 +47,11 @@
|
|||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>meteoinfo-math</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>meteoinfo-ndarray</artifactId>
|
<artifactId>meteoinfo-ndarray</artifactId>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -17,10 +17,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.meteoinfo.chart.plot.XAlign;
|
import org.meteoinfo.chart.plot.XAlign;
|
||||||
import org.meteoinfo.chart.plot.YAlign;
|
import org.meteoinfo.chart.plot.YAlign;
|
||||||
|
import org.meteoinfo.common.PointD;
|
||||||
|
import org.meteoinfo.common.PointF;
|
||||||
import org.meteoinfo.drawing.Draw;
|
import org.meteoinfo.drawing.Draw;
|
||||||
import org.meteoinfo.global.DataConvert;
|
import org.meteoinfo.global.DataConvert;
|
||||||
import org.meteoinfo.global.PointD;
|
|
||||||
import org.meteoinfo.global.PointF;
|
|
||||||
import org.meteoinfo.legend.ColorBreak;
|
import org.meteoinfo.legend.ColorBreak;
|
||||||
import org.meteoinfo.legend.LegendScheme;
|
import org.meteoinfo.legend.LegendScheme;
|
||||||
import org.meteoinfo.legend.LegendType;
|
import org.meteoinfo.legend.LegendType;
|
||||||
|
|||||||
@ -1,335 +1,336 @@
|
|||||||
/* Copyright 2012 Yaqiang Wang,
|
/* Copyright 2012 Yaqiang Wang,
|
||||||
* yaqiang.wang@gmail.com
|
* yaqiang.wang@gmail.com
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or modify it
|
* This library is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU Lesser General Public License as published by
|
* under the terms of the GNU Lesser General Public License as published by
|
||||||
* the Free Software Foundation; either version 2.1 of the License, or (at
|
* the Free Software Foundation; either version 2.1 of the License, or (at
|
||||||
* your option) any later version.
|
* your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful, but
|
* This library is distributed in the hope that it will be useful, but
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||||
* General Public License for more details.
|
* General Public License for more details.
|
||||||
*/
|
*/
|
||||||
package org.meteoinfo.chart;
|
package org.meteoinfo.chart;
|
||||||
|
|
||||||
import org.meteoinfo.global.event.ILocationChangedListener;
|
import org.meteoinfo.common.PointF;
|
||||||
import org.meteoinfo.global.event.ISizeChangedListener;
|
import org.meteoinfo.global.event.ILocationChangedListener;
|
||||||
import org.meteoinfo.global.event.LocationChangedEvent;
|
import org.meteoinfo.global.event.ISizeChangedListener;
|
||||||
import org.meteoinfo.global.event.SizeChangedEvent;
|
import org.meteoinfo.global.event.LocationChangedEvent;
|
||||||
import org.meteoinfo.global.PointF;
|
import org.meteoinfo.global.event.SizeChangedEvent;
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Rectangle;
|
import java.awt.Color;
|
||||||
import javax.swing.event.EventListenerList;
|
import java.awt.Rectangle;
|
||||||
import org.meteoinfo.layout.ResizeAbility;
|
import javax.swing.event.EventListenerList;
|
||||||
|
import org.meteoinfo.layout.ResizeAbility;
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
* @author yaqiang
|
*
|
||||||
*/
|
* @author yaqiang
|
||||||
public abstract class ChartElement {
|
*/
|
||||||
// <editor-fold desc="Events">
|
public abstract class ChartElement {
|
||||||
|
// <editor-fold desc="Events">
|
||||||
public void addLocationChangedListener(ILocationChangedListener listener) {
|
|
||||||
this._listeners.add(ILocationChangedListener.class, listener);
|
public void addLocationChangedListener(ILocationChangedListener listener) {
|
||||||
}
|
this._listeners.add(ILocationChangedListener.class, listener);
|
||||||
|
}
|
||||||
public void removeLocationChangedListener(ILocationChangedListener listener) {
|
|
||||||
this._listeners.remove(ILocationChangedListener.class, listener);
|
public void removeLocationChangedListener(ILocationChangedListener listener) {
|
||||||
}
|
this._listeners.remove(ILocationChangedListener.class, listener);
|
||||||
|
}
|
||||||
public void fireLocationChangedEvent() {
|
|
||||||
fireLocationChangedEvent(new LocationChangedEvent(this));
|
public void fireLocationChangedEvent() {
|
||||||
}
|
fireLocationChangedEvent(new LocationChangedEvent(this));
|
||||||
|
}
|
||||||
private void fireLocationChangedEvent(LocationChangedEvent event) {
|
|
||||||
Object[] listeners = _listeners.getListenerList();
|
private void fireLocationChangedEvent(LocationChangedEvent event) {
|
||||||
for (int i = 0; i < listeners.length; i = i + 2) {
|
Object[] listeners = _listeners.getListenerList();
|
||||||
if (listeners[i] == ILocationChangedListener.class) {
|
for (int i = 0; i < listeners.length; i = i + 2) {
|
||||||
((ILocationChangedListener) listeners[i + 1]).locationChangedEvent(event);
|
if (listeners[i] == ILocationChangedListener.class) {
|
||||||
}
|
((ILocationChangedListener) listeners[i + 1]).locationChangedEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void addSizeChangedListener(ISizeChangedListener listener) {
|
|
||||||
this._listeners.add(ISizeChangedListener.class, listener);
|
public void addSizeChangedListener(ISizeChangedListener listener) {
|
||||||
}
|
this._listeners.add(ISizeChangedListener.class, listener);
|
||||||
|
}
|
||||||
public void removeSizeChangedListener(ISizeChangedListener listener) {
|
|
||||||
this._listeners.remove(ISizeChangedListener.class, listener);
|
public void removeSizeChangedListener(ISizeChangedListener listener) {
|
||||||
}
|
this._listeners.remove(ISizeChangedListener.class, listener);
|
||||||
|
}
|
||||||
public void fireSizeChangedEvent() {
|
|
||||||
fireSizeChangedEvent(new SizeChangedEvent(this));
|
public void fireSizeChangedEvent() {
|
||||||
}
|
fireSizeChangedEvent(new SizeChangedEvent(this));
|
||||||
|
}
|
||||||
private void fireSizeChangedEvent(SizeChangedEvent event) {
|
|
||||||
Object[] listeners = _listeners.getListenerList();
|
private void fireSizeChangedEvent(SizeChangedEvent event) {
|
||||||
for (int i = 0; i < listeners.length; i = i + 2) {
|
Object[] listeners = _listeners.getListenerList();
|
||||||
if (listeners[i] == ISizeChangedListener.class) {
|
for (int i = 0; i < listeners.length; i = i + 2) {
|
||||||
((ISizeChangedListener) listeners[i + 1]).sizeChangedEvent(event);
|
if (listeners[i] == ISizeChangedListener.class) {
|
||||||
}
|
((ISizeChangedListener) listeners[i + 1]).sizeChangedEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// </editor-fold>
|
}
|
||||||
// <editor-fold desc="Variables">
|
// </editor-fold>
|
||||||
private final EventListenerList _listeners = new EventListenerList();
|
// <editor-fold desc="Variables">
|
||||||
protected float x;
|
private final EventListenerList _listeners = new EventListenerList();
|
||||||
protected float y;
|
protected float x;
|
||||||
protected float width;
|
protected float y;
|
||||||
protected float height;
|
protected float width;
|
||||||
protected Color _foreColor;
|
protected float height;
|
||||||
protected Color _backColor;
|
protected Color _foreColor;
|
||||||
private boolean _selected;
|
protected Color _backColor;
|
||||||
private ResizeAbility _resizeAbility;
|
private boolean _selected;
|
||||||
private boolean _visible = true;
|
private ResizeAbility _resizeAbility;
|
||||||
private boolean drawBackColor = false;
|
private boolean _visible = true;
|
||||||
// </editor-fold>
|
private boolean drawBackColor = false;
|
||||||
// <editor-fold desc="Constructor">
|
// </editor-fold>
|
||||||
|
// <editor-fold desc="Constructor">
|
||||||
public ChartElement() {
|
|
||||||
_foreColor = Color.black;
|
public ChartElement() {
|
||||||
_backColor = Color.white;
|
_foreColor = Color.black;
|
||||||
_selected = false;
|
_backColor = Color.white;
|
||||||
_resizeAbility = ResizeAbility.None;
|
_selected = false;
|
||||||
}
|
_resizeAbility = ResizeAbility.None;
|
||||||
// </editor-fold>
|
}
|
||||||
// <editor-fold desc="Get Set Methods">
|
// </editor-fold>
|
||||||
|
// <editor-fold desc="Get Set Methods">
|
||||||
/**
|
|
||||||
* Get if visible
|
/**
|
||||||
*
|
* Get if visible
|
||||||
* @return Boolean
|
*
|
||||||
*/
|
* @return Boolean
|
||||||
public boolean isVisible() {
|
*/
|
||||||
return _visible;
|
public boolean isVisible() {
|
||||||
}
|
return _visible;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set if visible
|
/**
|
||||||
*
|
* Set if visible
|
||||||
* @param istrue Boolean
|
*
|
||||||
*/
|
* @param istrue Boolean
|
||||||
public void setVisible(boolean istrue) {
|
*/
|
||||||
_visible = istrue;
|
public void setVisible(boolean istrue) {
|
||||||
}
|
_visible = istrue;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get x
|
/**
|
||||||
*
|
* Get x
|
||||||
* @return x
|
*
|
||||||
*/
|
* @return x
|
||||||
public float getX() {
|
*/
|
||||||
return x;
|
public float getX() {
|
||||||
}
|
return x;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set left
|
/**
|
||||||
*
|
* Set left
|
||||||
* @param left
|
*
|
||||||
*/
|
* @param left
|
||||||
public void setX(float left) {
|
*/
|
||||||
x = left;
|
public void setX(float left) {
|
||||||
this.fireLocationChangedEvent();
|
x = left;
|
||||||
}
|
this.fireLocationChangedEvent();
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get y
|
/**
|
||||||
*
|
* Get y
|
||||||
* @return Y
|
*
|
||||||
*/
|
* @return Y
|
||||||
public float getY() {
|
*/
|
||||||
return y;
|
public float getY() {
|
||||||
}
|
return y;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set y
|
/**
|
||||||
*
|
* Set y
|
||||||
* @param top Y
|
*
|
||||||
*/
|
* @param top Y
|
||||||
public void setY(float top) {
|
*/
|
||||||
y = top;
|
public void setY(float top) {
|
||||||
this.fireLocationChangedEvent();
|
y = top;
|
||||||
}
|
this.fireLocationChangedEvent();
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get width
|
/**
|
||||||
*
|
* Get width
|
||||||
* @return Width
|
*
|
||||||
*/
|
* @return Width
|
||||||
public float getWidth() {
|
*/
|
||||||
return width;
|
public float getWidth() {
|
||||||
}
|
return width;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set width
|
/**
|
||||||
*
|
* Set width
|
||||||
* @param width Width
|
*
|
||||||
*/
|
* @param width Width
|
||||||
public void setWidth(float width) {
|
*/
|
||||||
this.width = width;
|
public void setWidth(float width) {
|
||||||
this.fireSizeChangedEvent();
|
this.width = width;
|
||||||
}
|
this.fireSizeChangedEvent();
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get height
|
/**
|
||||||
*
|
* Get height
|
||||||
* @return Height
|
*
|
||||||
*/
|
* @return Height
|
||||||
public float getHeight() {
|
*/
|
||||||
return height;
|
public float getHeight() {
|
||||||
}
|
return height;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set height
|
/**
|
||||||
*
|
* Set height
|
||||||
* @param height Height
|
*
|
||||||
*/
|
* @param height Height
|
||||||
public void setHeight(float height) {
|
*/
|
||||||
this.height = height;
|
public void setHeight(float height) {
|
||||||
this.fireSizeChangedEvent();
|
this.height = height;
|
||||||
}
|
this.fireSizeChangedEvent();
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get right
|
/**
|
||||||
*
|
* Get right
|
||||||
* @return Right
|
*
|
||||||
*/
|
* @return Right
|
||||||
public float getRight() {
|
*/
|
||||||
return x + width;
|
public float getRight() {
|
||||||
}
|
return x + width;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get bottom
|
/**
|
||||||
*
|
* Get bottom
|
||||||
* @return Bottom
|
*
|
||||||
*/
|
* @return Bottom
|
||||||
public float getBottom() {
|
*/
|
||||||
return y + height;
|
public float getBottom() {
|
||||||
}
|
return y + height;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get bounds rectangle
|
/**
|
||||||
*
|
* Get bounds rectangle
|
||||||
* @return Bounds rectangle
|
*
|
||||||
*/
|
* @return Bounds rectangle
|
||||||
public Rectangle.Float getBounds() {
|
*/
|
||||||
return new Rectangle.Float(x, y, width, height);
|
public Rectangle.Float getBounds() {
|
||||||
}
|
return new Rectangle.Float(x, y, width, height);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get foreground color
|
/**
|
||||||
*
|
* Get foreground color
|
||||||
* @return Foreground color
|
*
|
||||||
*/
|
* @return Foreground color
|
||||||
public Color getForeground() {
|
*/
|
||||||
return _foreColor;
|
public Color getForeground() {
|
||||||
}
|
return _foreColor;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set foreground color
|
/**
|
||||||
*
|
* Set foreground color
|
||||||
* @param color Foreground color
|
*
|
||||||
*/
|
* @param color Foreground color
|
||||||
public void setForeground(Color color) {
|
*/
|
||||||
_foreColor = color;
|
public void setForeground(Color color) {
|
||||||
}
|
_foreColor = color;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get background color
|
/**
|
||||||
*
|
* Get background color
|
||||||
* @return Background color
|
*
|
||||||
*/
|
* @return Background color
|
||||||
public Color getBackground() {
|
*/
|
||||||
return _backColor;
|
public Color getBackground() {
|
||||||
}
|
return _backColor;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set background color
|
/**
|
||||||
*
|
* Set background color
|
||||||
* @param color Background color
|
*
|
||||||
*/
|
* @param color Background color
|
||||||
public void setBackground(Color color) {
|
*/
|
||||||
_backColor = color;
|
public void setBackground(Color color) {
|
||||||
}
|
_backColor = color;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get if is selected
|
/**
|
||||||
*
|
* Get if is selected
|
||||||
* @return Boolean
|
*
|
||||||
*/
|
* @return Boolean
|
||||||
public boolean isSelected() {
|
*/
|
||||||
return _selected;
|
public boolean isSelected() {
|
||||||
}
|
return _selected;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set if is selected
|
/**
|
||||||
*
|
* Set if is selected
|
||||||
* @param istrue Boolean
|
*
|
||||||
*/
|
* @param istrue Boolean
|
||||||
public void setSelected(boolean istrue) {
|
*/
|
||||||
_selected = istrue;
|
public void setSelected(boolean istrue) {
|
||||||
}
|
_selected = istrue;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get resize ability
|
/**
|
||||||
*
|
* Get resize ability
|
||||||
* @return Resize ability
|
*
|
||||||
*/
|
* @return Resize ability
|
||||||
public ResizeAbility getResizeAbility() {
|
*/
|
||||||
return _resizeAbility;
|
public ResizeAbility getResizeAbility() {
|
||||||
}
|
return _resizeAbility;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set resize ability
|
/**
|
||||||
*
|
* Set resize ability
|
||||||
* @param ra Resize ability
|
*
|
||||||
*/
|
* @param ra Resize ability
|
||||||
public void setResizeAbility(ResizeAbility ra) {
|
*/
|
||||||
_resizeAbility = ra;
|
public void setResizeAbility(ResizeAbility ra) {
|
||||||
}
|
_resizeAbility = ra;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get is draw backcolor
|
/**
|
||||||
* @return Boolean
|
* Get is draw backcolor
|
||||||
*/
|
* @return Boolean
|
||||||
public boolean isDrawBackColor(){
|
*/
|
||||||
return drawBackColor;
|
public boolean isDrawBackColor(){
|
||||||
}
|
return drawBackColor;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set is draw backcolor
|
/**
|
||||||
* @param value Boolean
|
* Set is draw backcolor
|
||||||
*/
|
* @param value Boolean
|
||||||
public void setDrawBackColor(boolean value){
|
*/
|
||||||
drawBackColor = value;
|
public void setDrawBackColor(boolean value){
|
||||||
}
|
drawBackColor = value;
|
||||||
// </editor-fold>
|
}
|
||||||
// <editor-fold desc="Methods">
|
// </editor-fold>
|
||||||
|
// <editor-fold desc="Methods">
|
||||||
/**
|
|
||||||
* Move update method
|
/**
|
||||||
*/
|
* Move update method
|
||||||
public abstract void moveUpdate();
|
*/
|
||||||
|
public abstract void moveUpdate();
|
||||||
/**
|
|
||||||
* Resize update method
|
/**
|
||||||
*/
|
* Resize update method
|
||||||
public abstract void resizeUpdate();
|
*/
|
||||||
|
public abstract void resizeUpdate();
|
||||||
/**
|
|
||||||
* Page to screen
|
/**
|
||||||
*
|
* Page to screen
|
||||||
* @param pageX Page X
|
*
|
||||||
* @param pageY Page Y
|
* @param pageX Page X
|
||||||
* @param pageLocation Page location
|
* @param pageY Page Y
|
||||||
* @param zoom Zoom
|
* @param pageLocation Page location
|
||||||
* @return Screen point
|
* @param zoom Zoom
|
||||||
*/
|
* @return Screen point
|
||||||
public PointF pageToScreen(float pageX, float pageY, PointF pageLocation, float zoom) {
|
*/
|
||||||
float x = pageX * zoom + pageLocation.X;
|
public PointF pageToScreen(float pageX, float pageY, PointF pageLocation, float zoom) {
|
||||||
float y = pageY * zoom + pageLocation.Y;
|
float x = pageX * zoom + pageLocation.X;
|
||||||
return (new PointF(x, y));
|
float y = pageY * zoom + pageLocation.Y;
|
||||||
}
|
return (new PointF(x, y));
|
||||||
// </editor-fold>
|
}
|
||||||
}
|
// </editor-fold>
|
||||||
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,298 +1,298 @@
|
|||||||
/* Copyright 2012 Yaqiang Wang,
|
/* Copyright 2012 Yaqiang Wang,
|
||||||
* yaqiang.wang@gmail.com
|
* yaqiang.wang@gmail.com
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or modify it
|
* This library is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU Lesser General Public License as published by
|
* under the terms of the GNU Lesser General Public License as published by
|
||||||
* the Free Software Foundation; either version 2.1 of the License, or (at
|
* the Free Software Foundation; either version 2.1 of the License, or (at
|
||||||
* your option) any later version.
|
* your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful, but
|
* This library is distributed in the hope that it will be useful, but
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||||
* General Public License for more details.
|
* General Public License for more details.
|
||||||
*/
|
*/
|
||||||
package org.meteoinfo.chart;
|
package org.meteoinfo.chart;
|
||||||
|
|
||||||
import com.l2fprod.common.beans.BaseBeanInfo;
|
import org.meteoinfo.common.PointF;
|
||||||
import org.meteoinfo.drawing.Draw;
|
import org.meteoinfo.drawing.Draw;
|
||||||
import org.meteoinfo.global.PointF;
|
|
||||||
import java.awt.BasicStroke;
|
import java.awt.BasicStroke;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
import java.awt.geom.AffineTransform;
|
import java.awt.geom.AffineTransform;
|
||||||
import org.meteoinfo.chart.plot.MapPlot;
|
import org.meteoinfo.chart.plot.MapPlot;
|
||||||
import org.meteoinfo.layout.NorthArrowType;
|
import org.meteoinfo.layout.NorthArrowType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Yaqiang Wang
|
* @author Yaqiang Wang
|
||||||
*/
|
*/
|
||||||
public class ChartNorthArrow extends ChartElement {
|
public class ChartNorthArrow extends ChartElement {
|
||||||
// <editor-fold desc="Variables">
|
// <editor-fold desc="Variables">
|
||||||
|
|
||||||
private MapPlot mapPlot;
|
private MapPlot mapPlot;
|
||||||
private boolean _antiAlias;
|
private boolean _antiAlias;
|
||||||
private float lineWidth;
|
private float lineWidth;
|
||||||
private boolean _drawNeatLine;
|
private boolean _drawNeatLine;
|
||||||
private Color _neatLineColor;
|
private Color _neatLineColor;
|
||||||
private float _neatLineSize;
|
private float _neatLineSize;
|
||||||
private NorthArrowType _northArrowType;
|
private NorthArrowType _northArrowType;
|
||||||
private float _angle;
|
private float _angle;
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
// <editor-fold desc="Constructor">
|
// <editor-fold desc="Constructor">
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param mapPlot The map plot
|
* @param mapPlot The map plot
|
||||||
*/
|
*/
|
||||||
public ChartNorthArrow(MapPlot mapPlot) {
|
public ChartNorthArrow(MapPlot mapPlot) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.setWidth(50);
|
this.setWidth(50);
|
||||||
this.setHeight(50);
|
this.setHeight(50);
|
||||||
|
|
||||||
this.mapPlot = mapPlot;
|
this.mapPlot = mapPlot;
|
||||||
this.lineWidth = 1;
|
this.lineWidth = 1;
|
||||||
_antiAlias = true;
|
_antiAlias = true;
|
||||||
_drawNeatLine = false;
|
_drawNeatLine = false;
|
||||||
_neatLineColor = Color.black;
|
_neatLineColor = Color.black;
|
||||||
_neatLineSize = 1;
|
_neatLineSize = 1;
|
||||||
_northArrowType = NorthArrowType.NORTHARROW_1;
|
_northArrowType = NorthArrowType.NORTHARROW_1;
|
||||||
_angle = 0;
|
_angle = 0;
|
||||||
}
|
}
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
// <editor-fold desc="Get Set Methods">
|
// <editor-fold desc="Get Set Methods">
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get map plot
|
* Get map plot
|
||||||
*
|
*
|
||||||
* @return The map plot
|
* @return The map plot
|
||||||
*/
|
*/
|
||||||
public MapPlot getMapPlot() {
|
public MapPlot getMapPlot() {
|
||||||
return this.mapPlot;
|
return this.mapPlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get line widht
|
* Get line widht
|
||||||
* @return Line width
|
* @return Line width
|
||||||
*/
|
*/
|
||||||
public float getLineWidth() {
|
public float getLineWidth() {
|
||||||
return this.lineWidth;
|
return this.lineWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set line width
|
* Set line width
|
||||||
* @param value Line width
|
* @param value Line width
|
||||||
*/
|
*/
|
||||||
public void setLineWidth(float value) {
|
public void setLineWidth(float value) {
|
||||||
this.lineWidth = value;
|
this.lineWidth = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get if draw neat line
|
* Get if draw neat line
|
||||||
*
|
*
|
||||||
* @return If draw neat line
|
* @return If draw neat line
|
||||||
*/
|
*/
|
||||||
public boolean isDrawNeatLine() {
|
public boolean isDrawNeatLine() {
|
||||||
return _drawNeatLine;
|
return _drawNeatLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set if draw neat line
|
* Set if draw neat line
|
||||||
*
|
*
|
||||||
* @param istrue If draw neat line
|
* @param istrue If draw neat line
|
||||||
*/
|
*/
|
||||||
public void setDrawNeatLine(boolean istrue) {
|
public void setDrawNeatLine(boolean istrue) {
|
||||||
_drawNeatLine = istrue;
|
_drawNeatLine = istrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get neat line color
|
* Get neat line color
|
||||||
*
|
*
|
||||||
* @return Neat line color
|
* @return Neat line color
|
||||||
*/
|
*/
|
||||||
public Color getNeatLineColor() {
|
public Color getNeatLineColor() {
|
||||||
return _neatLineColor;
|
return _neatLineColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set neat line color
|
* Set neat line color
|
||||||
*
|
*
|
||||||
* @param color Neat line color
|
* @param color Neat line color
|
||||||
*/
|
*/
|
||||||
public void setNeatLineColor(Color color) {
|
public void setNeatLineColor(Color color) {
|
||||||
_neatLineColor = color;
|
_neatLineColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get neat line size
|
* Get neat line size
|
||||||
*
|
*
|
||||||
* @return Neat line size
|
* @return Neat line size
|
||||||
*/
|
*/
|
||||||
public float getNeatLineSize() {
|
public float getNeatLineSize() {
|
||||||
return _neatLineSize;
|
return _neatLineSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set neat line size
|
* Set neat line size
|
||||||
*
|
*
|
||||||
* @param size Neat line size
|
* @param size Neat line size
|
||||||
*/
|
*/
|
||||||
public void setNeatLineSize(float size) {
|
public void setNeatLineSize(float size) {
|
||||||
_neatLineSize = size;
|
_neatLineSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get angle
|
* Get angle
|
||||||
*
|
*
|
||||||
* @return Angle
|
* @return Angle
|
||||||
*/
|
*/
|
||||||
public float getAngle() {
|
public float getAngle() {
|
||||||
return _angle;
|
return _angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set angle
|
* Set angle
|
||||||
*
|
*
|
||||||
* @param angle The angle
|
* @param angle The angle
|
||||||
*/
|
*/
|
||||||
public void setAngle(float angle) {
|
public void setAngle(float angle) {
|
||||||
_angle = angle;
|
_angle = angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
// <editor-fold desc="Methods">
|
// <editor-fold desc="Methods">
|
||||||
/**
|
/**
|
||||||
* Draw text
|
* Draw text
|
||||||
*
|
*
|
||||||
* @param g Graphics2D
|
* @param g Graphics2D
|
||||||
* @param x X
|
* @param x X
|
||||||
* @param y Y
|
* @param y Y
|
||||||
*/
|
*/
|
||||||
public void draw(Graphics2D g, float x, float y) {
|
public void draw(Graphics2D g, float x, float y) {
|
||||||
AffineTransform oldMatrix = g.getTransform();
|
AffineTransform oldMatrix = g.getTransform();
|
||||||
g.translate(x, y);
|
g.translate(x, y);
|
||||||
if (_angle != 0) {
|
if (_angle != 0) {
|
||||||
g.rotate(_angle);
|
g.rotate(_angle);
|
||||||
}
|
}
|
||||||
if (_antiAlias) {
|
if (_antiAlias) {
|
||||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
} else {
|
} else {
|
||||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
|
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Draw background color
|
//Draw background color
|
||||||
if (this.isDrawBackColor()){
|
if (this.isDrawBackColor()){
|
||||||
g.setColor(this.getBackground());
|
g.setColor(this.getBackground());
|
||||||
g.fill(new Rectangle.Float(0, 0, this.getWidth(), this.getHeight()));
|
g.fill(new Rectangle.Float(0, 0, this.getWidth(), this.getHeight()));
|
||||||
}
|
}
|
||||||
|
|
||||||
drawNorthArrow(g);
|
drawNorthArrow(g);
|
||||||
|
|
||||||
//Draw neatline
|
//Draw neatline
|
||||||
if (_drawNeatLine) {
|
if (_drawNeatLine) {
|
||||||
Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1,
|
Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1,
|
||||||
(this.getWidth() - _neatLineSize), (this.getHeight() - _neatLineSize));
|
(this.getWidth() - _neatLineSize), (this.getHeight() - _neatLineSize));
|
||||||
g.setColor(_neatLineColor);
|
g.setColor(_neatLineColor);
|
||||||
g.setStroke(new BasicStroke(_neatLineSize));
|
g.setStroke(new BasicStroke(_neatLineSize));
|
||||||
g.draw(mapRect);
|
g.draw(mapRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
g.setTransform(oldMatrix);
|
g.setTransform(oldMatrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paint graphics
|
* Paint graphics
|
||||||
*
|
*
|
||||||
* @param g Graphics
|
* @param g Graphics
|
||||||
* @param pageLocation Page location
|
* @param pageLocation Page location
|
||||||
* @param zoom Zoom
|
* @param zoom Zoom
|
||||||
*/
|
*/
|
||||||
public void paintGraphics(Graphics2D g, PointF pageLocation, float zoom) {
|
public void paintGraphics(Graphics2D g, PointF pageLocation, float zoom) {
|
||||||
AffineTransform oldMatrix = g.getTransform();
|
AffineTransform oldMatrix = g.getTransform();
|
||||||
PointF aP = pageToScreen(this.getX(), this.getY(), pageLocation, zoom);
|
PointF aP = pageToScreen(this.getX(), this.getY(), pageLocation, zoom);
|
||||||
g.translate(aP.X, aP.Y);
|
g.translate(aP.X, aP.Y);
|
||||||
g.scale(zoom, zoom);
|
g.scale(zoom, zoom);
|
||||||
if (_angle != 0) {
|
if (_angle != 0) {
|
||||||
g.rotate(_angle);
|
g.rotate(_angle);
|
||||||
}
|
}
|
||||||
if (_antiAlias) {
|
if (_antiAlias) {
|
||||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
} else {
|
} else {
|
||||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
|
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Draw background color
|
//Draw background color
|
||||||
if (this.isDrawBackColor()){
|
if (this.isDrawBackColor()){
|
||||||
g.setColor(this.getBackground());
|
g.setColor(this.getBackground());
|
||||||
g.fill(new Rectangle.Float(0, 0, this.getWidth() * zoom, this.getHeight() * zoom));
|
g.fill(new Rectangle.Float(0, 0, this.getWidth() * zoom, this.getHeight() * zoom));
|
||||||
}
|
}
|
||||||
|
|
||||||
drawNorthArrow(g);
|
drawNorthArrow(g);
|
||||||
|
|
||||||
//Draw neatline
|
//Draw neatline
|
||||||
if (_drawNeatLine) {
|
if (_drawNeatLine) {
|
||||||
Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1,
|
Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1,
|
||||||
(this.getWidth() - _neatLineSize) * zoom, (this.getHeight() - _neatLineSize) * zoom);
|
(this.getWidth() - _neatLineSize) * zoom, (this.getHeight() - _neatLineSize) * zoom);
|
||||||
g.setColor(_neatLineColor);
|
g.setColor(_neatLineColor);
|
||||||
g.setStroke(new BasicStroke(_neatLineSize));
|
g.setStroke(new BasicStroke(_neatLineSize));
|
||||||
g.draw(mapRect);
|
g.draw(mapRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
g.setTransform(oldMatrix);
|
g.setTransform(oldMatrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawNorthArrow(Graphics2D g) {
|
private void drawNorthArrow(Graphics2D g) {
|
||||||
switch (_northArrowType) {
|
switch (_northArrowType) {
|
||||||
case NORTHARROW_1:
|
case NORTHARROW_1:
|
||||||
drawNorthArrow1(g);
|
drawNorthArrow1(g);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawNorthArrow1(Graphics2D g) {
|
private void drawNorthArrow1(Graphics2D g) {
|
||||||
g.setColor(this.getForeground());
|
g.setColor(this.getForeground());
|
||||||
g.setStroke(new BasicStroke(this.lineWidth));
|
g.setStroke(new BasicStroke(this.lineWidth));
|
||||||
|
|
||||||
//Draw N symbol
|
//Draw N symbol
|
||||||
PointF[] points = new PointF[4];
|
PointF[] points = new PointF[4];
|
||||||
float x = this.getWidth() / 2;
|
float x = this.getWidth() / 2;
|
||||||
float y = this.getHeight() / 6;
|
float y = this.getHeight() / 6;
|
||||||
float w = this.getWidth() / 6;
|
float w = this.getWidth() / 6;
|
||||||
float h = this.getHeight() / 4;
|
float h = this.getHeight() / 4;
|
||||||
points[0] = new PointF(x - w / 2, y + h / 2);
|
points[0] = new PointF(x - w / 2, y + h / 2);
|
||||||
points[1] = new PointF(x - w / 2, y - h / 2);
|
points[1] = new PointF(x - w / 2, y - h / 2);
|
||||||
points[2] = new PointF(x + w / 2, y + h / 2);
|
points[2] = new PointF(x + w / 2, y + h / 2);
|
||||||
points[3] = new PointF(x + w / 2, y - h / 2);
|
points[3] = new PointF(x + w / 2, y - h / 2);
|
||||||
Draw.drawPolyline(points, g);
|
Draw.drawPolyline(points, g);
|
||||||
|
|
||||||
//Draw arrow
|
//Draw arrow
|
||||||
w = this.getWidth() / 2;
|
w = this.getWidth() / 2;
|
||||||
h = this.getHeight() * 2 / 3;
|
h = this.getHeight() * 2 / 3;
|
||||||
points = new PointF[3];
|
points = new PointF[3];
|
||||||
points[0] = new PointF(x - w / 2, this.getHeight());
|
points[0] = new PointF(x - w / 2, this.getHeight());
|
||||||
points[1] = new PointF(x, this.getHeight() - h / 2);
|
points[1] = new PointF(x, this.getHeight() - h / 2);
|
||||||
points[2] = new PointF(x, this.getHeight() - h);
|
points[2] = new PointF(x, this.getHeight() - h);
|
||||||
Draw.fillPolygon(points, g, null);
|
Draw.fillPolygon(points, g, null);
|
||||||
Draw.drawPolyline(points, g);
|
Draw.drawPolyline(points, g);
|
||||||
|
|
||||||
points = new PointF[4];
|
points = new PointF[4];
|
||||||
points[0] = new PointF(x + w / 2, this.getHeight());
|
points[0] = new PointF(x + w / 2, this.getHeight());
|
||||||
points[1] = new PointF(x, this.getHeight() - h / 2);
|
points[1] = new PointF(x, this.getHeight() - h / 2);
|
||||||
points[2] = new PointF(x, this.getHeight() - h);
|
points[2] = new PointF(x, this.getHeight() - h);
|
||||||
points[3] = points[0];
|
points[3] = points[0];
|
||||||
Draw.drawPolyline(points, g);
|
Draw.drawPolyline(points, g);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void moveUpdate() {
|
public void moveUpdate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resizeUpdate() {
|
public void resizeUpdate() {
|
||||||
}
|
}
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,11 +81,11 @@ import org.meteoinfo.chart.plot.AbstractPlot2D;
|
|||||||
import org.meteoinfo.chart.plot.Plot3D;
|
import org.meteoinfo.chart.plot.Plot3D;
|
||||||
import org.meteoinfo.chart.plot.PlotType;
|
import org.meteoinfo.chart.plot.PlotType;
|
||||||
import org.meteoinfo.chart.plot3d.Projector;
|
import org.meteoinfo.chart.plot3d.Projector;
|
||||||
|
import org.meteoinfo.common.Extent;
|
||||||
|
import org.meteoinfo.common.GenericFileFilter;
|
||||||
|
import org.meteoinfo.common.PointF;
|
||||||
import org.meteoinfo.ndarray.DataType;
|
import org.meteoinfo.ndarray.DataType;
|
||||||
import org.meteoinfo.data.mapdata.Field;
|
import org.meteoinfo.data.mapdata.Field;
|
||||||
import org.meteoinfo.global.Extent;
|
|
||||||
import org.meteoinfo.global.GenericFileFilter;
|
|
||||||
import org.meteoinfo.global.PointF;
|
|
||||||
import org.meteoinfo.image.ImageUtil;
|
import org.meteoinfo.image.ImageUtil;
|
||||||
import org.meteoinfo.layer.LayerTypes;
|
import org.meteoinfo.layer.LayerTypes;
|
||||||
import org.meteoinfo.layer.MapLayer;
|
import org.meteoinfo.layer.MapLayer;
|
||||||
|
|||||||
@ -1,457 +1,457 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package org.meteoinfo.chart;
|
package org.meteoinfo.chart;
|
||||||
|
|
||||||
import java.awt.BasicStroke;
|
import java.awt.BasicStroke;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.FontMetrics;
|
import java.awt.FontMetrics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
import java.awt.geom.AffineTransform;
|
import java.awt.geom.AffineTransform;
|
||||||
import java.awt.geom.Line2D;
|
import java.awt.geom.Line2D;
|
||||||
import org.meteoinfo.chart.plot.MapPlot;
|
import org.meteoinfo.chart.plot.MapPlot;
|
||||||
import org.meteoinfo.global.PointF;
|
import org.meteoinfo.common.PointF;
|
||||||
import org.meteoinfo.layout.ScaleBarType;
|
import org.meteoinfo.layout.ScaleBarType;
|
||||||
import org.meteoinfo.layout.ScaleBarUnits;
|
import org.meteoinfo.layout.ScaleBarUnits;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Yaqiang Wang
|
* @author Yaqiang Wang
|
||||||
*/
|
*/
|
||||||
public class ChartScaleBar extends ChartElement {
|
public class ChartScaleBar extends ChartElement {
|
||||||
// <editor-fold desc="Variables">
|
// <editor-fold desc="Variables">
|
||||||
|
|
||||||
private MapPlot mapPlot;
|
private MapPlot mapPlot;
|
||||||
private boolean _antiAlias;
|
private boolean _antiAlias;
|
||||||
private float lineWidth;
|
private float lineWidth;
|
||||||
private Font _font;
|
private Font _font;
|
||||||
private ScaleBarType _scaleBarType;
|
private ScaleBarType _scaleBarType;
|
||||||
private ScaleBarUnits _unit;
|
private ScaleBarUnits _unit;
|
||||||
private String _unitText;
|
private String _unitText;
|
||||||
private int _numBreaks;
|
private int _numBreaks;
|
||||||
private boolean _drawNeatLine;
|
private boolean _drawNeatLine;
|
||||||
private Color _neatLineColor;
|
private Color _neatLineColor;
|
||||||
private float _neatLineSize;
|
private float _neatLineSize;
|
||||||
private boolean _drawScaleText;
|
private boolean _drawScaleText;
|
||||||
private float _yShiftScale = 2.0f;
|
private float _yShiftScale = 2.0f;
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
// <editor-fold desc="Constructor">
|
// <editor-fold desc="Constructor">
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param mapPlot The map plot
|
* @param mapPlot The map plot
|
||||||
*/
|
*/
|
||||||
public ChartScaleBar(MapPlot mapPlot) {
|
public ChartScaleBar(MapPlot mapPlot) {
|
||||||
super();
|
super();
|
||||||
//this.setElementType(ElementType.LayoutScaleBar);
|
//this.setElementType(ElementType.LayoutScaleBar);
|
||||||
//this.setResizeAbility(ResizeAbility.ResizeAll);
|
//this.setResizeAbility(ResizeAbility.ResizeAll);
|
||||||
|
|
||||||
this.width = 200;
|
this.width = 200;
|
||||||
this.height = 50;
|
this.height = 50;
|
||||||
this.mapPlot = mapPlot;
|
this.mapPlot = mapPlot;
|
||||||
_antiAlias = true;
|
_antiAlias = true;
|
||||||
_scaleBarType = ScaleBarType.SCALELINE_1;
|
_scaleBarType = ScaleBarType.SCALELINE_1;
|
||||||
lineWidth = 1;
|
lineWidth = 1;
|
||||||
_drawNeatLine = false;
|
_drawNeatLine = false;
|
||||||
_neatLineColor = Color.black;
|
_neatLineColor = Color.black;
|
||||||
_neatLineSize = 1;
|
_neatLineSize = 1;
|
||||||
_font = new Font("Arial", Font.PLAIN, 12);
|
_font = new Font("Arial", Font.PLAIN, 12);
|
||||||
_unit = ScaleBarUnits.KILOMETERS;
|
_unit = ScaleBarUnits.KILOMETERS;
|
||||||
_unitText = "km";
|
_unitText = "km";
|
||||||
_numBreaks = 4;
|
_numBreaks = 4;
|
||||||
_drawScaleText = false;
|
_drawScaleText = false;
|
||||||
}
|
}
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
// <editor-fold desc="Get Set Methods">
|
// <editor-fold desc="Get Set Methods">
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get map plot
|
* Get map plot
|
||||||
*
|
*
|
||||||
* @return The map plot
|
* @return The map plot
|
||||||
*/
|
*/
|
||||||
public MapPlot getMapPlot() {
|
public MapPlot getMapPlot() {
|
||||||
return mapPlot;
|
return mapPlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get line widht
|
* Get line widht
|
||||||
* @return Line width
|
* @return Line width
|
||||||
*/
|
*/
|
||||||
public float getLineWidth() {
|
public float getLineWidth() {
|
||||||
return this.lineWidth;
|
return this.lineWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set line width
|
* Set line width
|
||||||
* @param value Line width
|
* @param value Line width
|
||||||
*/
|
*/
|
||||||
public void setLineWidth(float value) {
|
public void setLineWidth(float value) {
|
||||||
this.lineWidth = value;
|
this.lineWidth = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get scale bar type
|
* Get scale bar type
|
||||||
*
|
*
|
||||||
* @return Scale bar type
|
* @return Scale bar type
|
||||||
*/
|
*/
|
||||||
public ScaleBarType getScaleBarType() {
|
public ScaleBarType getScaleBarType() {
|
||||||
return _scaleBarType;
|
return _scaleBarType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set scale bar type
|
* Set scale bar type
|
||||||
*
|
*
|
||||||
* @param type Scale bar type
|
* @param type Scale bar type
|
||||||
*/
|
*/
|
||||||
public void setScaleBarType(ScaleBarType type) {
|
public void setScaleBarType(ScaleBarType type) {
|
||||||
_scaleBarType = type;
|
_scaleBarType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get if draw neat line
|
* Get if draw neat line
|
||||||
*
|
*
|
||||||
* @return If draw neat line
|
* @return If draw neat line
|
||||||
*/
|
*/
|
||||||
public boolean isDrawNeatLine() {
|
public boolean isDrawNeatLine() {
|
||||||
return _drawNeatLine;
|
return _drawNeatLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set if draw neat line
|
* Set if draw neat line
|
||||||
*
|
*
|
||||||
* @param istrue If draw neat line
|
* @param istrue If draw neat line
|
||||||
*/
|
*/
|
||||||
public void setDrawNeatLine(boolean istrue) {
|
public void setDrawNeatLine(boolean istrue) {
|
||||||
_drawNeatLine = istrue;
|
_drawNeatLine = istrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get neat line color
|
* Get neat line color
|
||||||
*
|
*
|
||||||
* @return Neat line color
|
* @return Neat line color
|
||||||
*/
|
*/
|
||||||
public Color getNeatLineColor() {
|
public Color getNeatLineColor() {
|
||||||
return _neatLineColor;
|
return _neatLineColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set neat line color
|
* Set neat line color
|
||||||
*
|
*
|
||||||
* @param color Neat line color
|
* @param color Neat line color
|
||||||
*/
|
*/
|
||||||
public void setNeatLineColor(Color color) {
|
public void setNeatLineColor(Color color) {
|
||||||
_neatLineColor = color;
|
_neatLineColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get neat line size
|
* Get neat line size
|
||||||
*
|
*
|
||||||
* @return Neat line size
|
* @return Neat line size
|
||||||
*/
|
*/
|
||||||
public float getNeatLineSize() {
|
public float getNeatLineSize() {
|
||||||
return _neatLineSize;
|
return _neatLineSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set neat line size
|
* Set neat line size
|
||||||
*
|
*
|
||||||
* @param size Neat line size
|
* @param size Neat line size
|
||||||
*/
|
*/
|
||||||
public void setNeatLineSize(float size) {
|
public void setNeatLineSize(float size) {
|
||||||
_neatLineSize = size;
|
_neatLineSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get font
|
* Get font
|
||||||
*
|
*
|
||||||
* @return The font
|
* @return The font
|
||||||
*/
|
*/
|
||||||
public Font getFont() {
|
public Font getFont() {
|
||||||
return _font;
|
return _font;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set font
|
* Set font
|
||||||
*
|
*
|
||||||
* @param font The font
|
* @param font The font
|
||||||
*/
|
*/
|
||||||
public void setFont(Font font) {
|
public void setFont(Font font) {
|
||||||
_font = font;
|
_font = font;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get break number
|
* Get break number
|
||||||
*
|
*
|
||||||
* @return The break number
|
* @return The break number
|
||||||
*/
|
*/
|
||||||
public int getBreakNumber() {
|
public int getBreakNumber() {
|
||||||
return _numBreaks;
|
return _numBreaks;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set break number
|
* Set break number
|
||||||
*
|
*
|
||||||
* @param num Break number
|
* @param num Break number
|
||||||
*/
|
*/
|
||||||
public void setBreakNumber(int num) {
|
public void setBreakNumber(int num) {
|
||||||
_numBreaks = num;
|
_numBreaks = num;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get if draw scale text
|
* Get if draw scale text
|
||||||
*
|
*
|
||||||
* @return If draw scale text
|
* @return If draw scale text
|
||||||
*/
|
*/
|
||||||
public boolean isDrawScaleText() {
|
public boolean isDrawScaleText() {
|
||||||
return _drawScaleText;
|
return _drawScaleText;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set if draw scale text
|
* Set if draw scale text
|
||||||
*
|
*
|
||||||
* @param istrue If draw scale text
|
* @param istrue If draw scale text
|
||||||
*/
|
*/
|
||||||
public void setDrawScaleText(boolean istrue) {
|
public void setDrawScaleText(boolean istrue) {
|
||||||
_drawScaleText = istrue;
|
_drawScaleText = istrue;
|
||||||
}
|
}
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
// <editor-fold desc="Methods">
|
// <editor-fold desc="Methods">
|
||||||
/**
|
/**
|
||||||
* Draw text
|
* Draw text
|
||||||
*
|
*
|
||||||
* @param g Graphics2D
|
* @param g Graphics2D
|
||||||
* @param x X
|
* @param x X
|
||||||
* @param y Y
|
* @param y Y
|
||||||
*/
|
*/
|
||||||
public void draw(Graphics2D g, float x, float y) {
|
public void draw(Graphics2D g, float x, float y) {
|
||||||
AffineTransform oldMatrix = g.getTransform();
|
AffineTransform oldMatrix = g.getTransform();
|
||||||
g.translate(x, y);
|
g.translate(x, y);
|
||||||
if (_antiAlias) {
|
if (_antiAlias) {
|
||||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
} else {
|
} else {
|
||||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
|
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Draw background color
|
//Draw background color
|
||||||
if (this.isDrawBackColor()){
|
if (this.isDrawBackColor()){
|
||||||
g.setColor(this.getBackground());
|
g.setColor(this.getBackground());
|
||||||
g.fill(new Rectangle.Float(0, 0, this.getWidth(), this.getHeight()));
|
g.fill(new Rectangle.Float(0, 0, this.getWidth(), this.getHeight()));
|
||||||
}
|
}
|
||||||
|
|
||||||
drawScaleBar(g);
|
drawScaleBar(g);
|
||||||
|
|
||||||
//Draw neatline
|
//Draw neatline
|
||||||
if (_drawNeatLine) {
|
if (_drawNeatLine) {
|
||||||
Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1,
|
Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1,
|
||||||
(this.getWidth() - _neatLineSize), (this.getHeight() - _neatLineSize));
|
(this.getWidth() - _neatLineSize), (this.getHeight() - _neatLineSize));
|
||||||
g.setColor(_neatLineColor);
|
g.setColor(_neatLineColor);
|
||||||
g.setStroke(new BasicStroke(_neatLineSize));
|
g.setStroke(new BasicStroke(_neatLineSize));
|
||||||
g.draw(mapRect);
|
g.draw(mapRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
g.setTransform(oldMatrix);
|
g.setTransform(oldMatrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paint graphics
|
* Paint graphics
|
||||||
*
|
*
|
||||||
* @param g Graphics
|
* @param g Graphics
|
||||||
* @param pageLocation Page location
|
* @param pageLocation Page location
|
||||||
* @param zoom Zoom
|
* @param zoom Zoom
|
||||||
*/
|
*/
|
||||||
public void paintGraphics(Graphics2D g, PointF pageLocation) {
|
public void paintGraphics(Graphics2D g, PointF pageLocation) {
|
||||||
AffineTransform oldMatrix = g.getTransform();
|
AffineTransform oldMatrix = g.getTransform();
|
||||||
PointF aP = pageToScreen(this.getX(), this.getY(), pageLocation, 1);
|
PointF aP = pageToScreen(this.getX(), this.getY(), pageLocation, 1);
|
||||||
g.translate(aP.X, aP.Y);
|
g.translate(aP.X, aP.Y);
|
||||||
if (_antiAlias) {
|
if (_antiAlias) {
|
||||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
} else {
|
} else {
|
||||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
|
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Draw background color
|
//Draw background color
|
||||||
if (this.isDrawBackColor()){
|
if (this.isDrawBackColor()){
|
||||||
g.setColor(this.getBackground());
|
g.setColor(this.getBackground());
|
||||||
g.fill(new Rectangle.Float(0, 0, this.getWidth(), this.getHeight()));
|
g.fill(new Rectangle.Float(0, 0, this.getWidth(), this.getHeight()));
|
||||||
}
|
}
|
||||||
|
|
||||||
drawScaleBar(g);
|
drawScaleBar(g);
|
||||||
|
|
||||||
//Draw neatline
|
//Draw neatline
|
||||||
if (_drawNeatLine) {
|
if (_drawNeatLine) {
|
||||||
Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1,
|
Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1,
|
||||||
(this.getWidth() - _neatLineSize), (this.getHeight() - _neatLineSize));
|
(this.getWidth() - _neatLineSize), (this.getHeight() - _neatLineSize));
|
||||||
g.setColor(_neatLineColor);
|
g.setColor(_neatLineColor);
|
||||||
g.setStroke(new BasicStroke(_neatLineSize));
|
g.setStroke(new BasicStroke(_neatLineSize));
|
||||||
g.draw(mapRect);
|
g.draw(mapRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
g.setTransform(oldMatrix);
|
g.setTransform(oldMatrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawScaleBar(Graphics2D g) {
|
private void drawScaleBar(Graphics2D g) {
|
||||||
//Calculates the width of one break in greographic units
|
//Calculates the width of one break in greographic units
|
||||||
FontMetrics metrics = g.getFontMetrics(this._font);
|
FontMetrics metrics = g.getFontMetrics(this._font);
|
||||||
float unitLegnth = metrics.stringWidth(_unitText) * 2;
|
float unitLegnth = metrics.stringWidth(_unitText) * 2;
|
||||||
float widthNoUnit = (this.getWidth() - unitLegnth);
|
float widthNoUnit = (this.getWidth() - unitLegnth);
|
||||||
long geoBreakWidth = (long) (getGeoWidth(widthNoUnit / _numBreaks));
|
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) {
|
if (geoBreakWidth < 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double n = Math.pow(10, String.valueOf(geoBreakWidth).length() - 1);
|
double n = Math.pow(10, String.valueOf(geoBreakWidth).length() - 1);
|
||||||
geoBreakWidth = (long) (Math.floor(geoBreakWidth / n) * n);
|
geoBreakWidth = (long) (Math.floor(geoBreakWidth / n) * n);
|
||||||
|
|
||||||
long breakWidth = (long) (getWidth(geoBreakWidth));
|
long breakWidth = (long) (getWidth(geoBreakWidth));
|
||||||
FontMetrics metrics1 = g.getFontMetrics(_font);
|
FontMetrics metrics1 = g.getFontMetrics(_font);
|
||||||
float fontHeight = metrics1.getHeight();
|
float fontHeight = metrics1.getHeight();
|
||||||
float leftStart = metrics1.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F;
|
float leftStart = metrics1.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F;
|
||||||
|
|
||||||
//Draw scale text
|
//Draw scale text
|
||||||
double scale = geoBreakWidth * getConversionFactor(_unit) * 100 / (breakWidth / 96 * 2.539999918);
|
double scale = geoBreakWidth * getConversionFactor(_unit) * 100 / (breakWidth / 96 * 2.539999918);
|
||||||
if (_drawScaleText) {
|
if (_drawScaleText) {
|
||||||
g.setFont(this._font);
|
g.setFont(this._font);
|
||||||
g.setColor(this.getForeground());
|
g.setColor(this.getForeground());
|
||||||
g.drawString("1 : " + String.format("{0:0,0}", scale),
|
g.drawString("1 : " + String.format("{0:0,0}", scale),
|
||||||
leftStart - (metrics.stringWidth(String.valueOf(Math.abs(0))) / 2), fontHeight * 2.5F);
|
leftStart - (metrics.stringWidth(String.valueOf(Math.abs(0))) / 2), fontHeight * 2.5F);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Draw scale bar
|
//Draw scale bar
|
||||||
switch (_scaleBarType) {
|
switch (_scaleBarType) {
|
||||||
case SCALELINE_1:
|
case SCALELINE_1:
|
||||||
drawScaleLine1(g, breakWidth, geoBreakWidth);
|
drawScaleLine1(g, breakWidth, geoBreakWidth);
|
||||||
break;
|
break;
|
||||||
case SCALELINE_2:
|
case SCALELINE_2:
|
||||||
drawScaleLine2(g, breakWidth, geoBreakWidth);
|
drawScaleLine2(g, breakWidth, geoBreakWidth);
|
||||||
break;
|
break;
|
||||||
case ALTERNATING_BAR:
|
case ALTERNATING_BAR:
|
||||||
drawAlternatingBar(g, breakWidth, geoBreakWidth);
|
drawAlternatingBar(g, breakWidth, geoBreakWidth);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getConversionFactor(ScaleBarUnits unit) {
|
private double getConversionFactor(ScaleBarUnits unit) {
|
||||||
switch (unit) {
|
switch (unit) {
|
||||||
case KILOMETERS:
|
case KILOMETERS:
|
||||||
return 1000;
|
return 1000;
|
||||||
default:
|
default:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getGeoWidth(double width) {
|
private double getGeoWidth(double width) {
|
||||||
double geoWidth = width / mapPlot.getMapFrame().getMapView().getXScale() / getConversionFactor(_unit);
|
double geoWidth = width / mapPlot.getMapFrame().getMapView().getXScale() / getConversionFactor(_unit);
|
||||||
if (mapPlot.getMapFrame().getMapView().getProjection().isLonLatMap()) {
|
if (mapPlot.getMapFrame().getMapView().getProjection().isLonLatMap()) {
|
||||||
geoWidth = geoWidth * getLonDistScale();
|
geoWidth = geoWidth * getLonDistScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
return geoWidth;
|
return geoWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getWidth(double geoWidth) {
|
private double getWidth(double geoWidth) {
|
||||||
double width = geoWidth * mapPlot.getMapFrame().getMapView().getXScale() * getConversionFactor(_unit);
|
double width = geoWidth * mapPlot.getMapFrame().getMapView().getXScale() * getConversionFactor(_unit);
|
||||||
if (mapPlot.getMapFrame().getMapView().getProjection().isLonLatMap()) {
|
if (mapPlot.getMapFrame().getMapView().getProjection().isLonLatMap()) {
|
||||||
width = width / getLonDistScale();
|
width = width / getLonDistScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getLonDistScale() {
|
private double getLonDistScale() {
|
||||||
//Get meters of one longitude degree
|
//Get meters of one longitude degree
|
||||||
double pY = (mapPlot.getMapFrame().getMapView().getViewExtent().maxY + mapPlot.getMapFrame().getMapView().getViewExtent().minY) / 2;
|
double pY = (mapPlot.getMapFrame().getMapView().getViewExtent().maxY + mapPlot.getMapFrame().getMapView().getViewExtent().minY) / 2;
|
||||||
double ProjX = 0, ProjY = pY, pProjX = 1, pProjY = pY;
|
double ProjX = 0, ProjY = pY, pProjX = 1, pProjY = pY;
|
||||||
double dx = Math.abs(ProjX - pProjX);
|
double dx = Math.abs(ProjX - pProjX);
|
||||||
double dy = Math.abs(ProjY - pProjY);
|
double dy = Math.abs(ProjY - pProjY);
|
||||||
double dist;
|
double dist;
|
||||||
double y = (ProjY + pProjY) / 2;
|
double y = (ProjY + pProjY) / 2;
|
||||||
double factor = Math.cos(y * Math.PI / 180);
|
double factor = Math.cos(y * Math.PI / 180);
|
||||||
dx *= factor;
|
dx *= factor;
|
||||||
dist = Math.sqrt(dx * dx + dy * dy);
|
dist = Math.sqrt(dx * dx + dy * dy);
|
||||||
dist = dist * 111319.5;
|
dist = dist * 111319.5;
|
||||||
|
|
||||||
return dist;
|
return dist;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawScaleLine1(Graphics2D g, long breakWidth, long geoBreakWidth) {
|
private void drawScaleLine1(Graphics2D g, long breakWidth, long geoBreakWidth) {
|
||||||
FontMetrics metrics = g.getFontMetrics(_font);
|
FontMetrics metrics = g.getFontMetrics(_font);
|
||||||
float fontHeight = metrics.getHeight();
|
float fontHeight = metrics.getHeight();
|
||||||
float leftStart = metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F;
|
float leftStart = metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F;
|
||||||
int yShift = 10;
|
int yShift = 10;
|
||||||
|
|
||||||
g.setColor(this.getForeground());
|
g.setColor(this.getForeground());
|
||||||
g.setStroke(new BasicStroke(this.lineWidth));
|
g.setStroke(new BasicStroke(this.lineWidth));
|
||||||
g.draw(new Line2D.Float(leftStart, fontHeight * 1.6f + yShift, leftStart + (breakWidth * _numBreaks), fontHeight * 1.6f + yShift));
|
g.draw(new Line2D.Float(leftStart, fontHeight * 1.6f + yShift, leftStart + (breakWidth * _numBreaks), fontHeight * 1.6f + yShift));
|
||||||
g.setFont(this._font);
|
g.setFont(this._font);
|
||||||
for (int i = 0; i <= _numBreaks; i++) {
|
for (int i = 0; i <= _numBreaks; i++) {
|
||||||
g.draw(new Line2D.Float(leftStart, fontHeight * 1.1f + yShift, leftStart, fontHeight * 1.6f + yShift));
|
g.draw(new Line2D.Float(leftStart, fontHeight * 1.1f + yShift, leftStart, fontHeight * 1.6f + yShift));
|
||||||
g.drawString(String.valueOf(Math.abs(geoBreakWidth * i)),
|
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;
|
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) {
|
private void drawScaleLine2(Graphics2D g, long breakWidth, long geoBreakWidth) {
|
||||||
FontMetrics metrics = g.getFontMetrics(_font);
|
FontMetrics metrics = g.getFontMetrics(_font);
|
||||||
float fontHeight = metrics.getHeight();
|
float fontHeight = metrics.getHeight();
|
||||||
float leftStart = metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F;
|
float leftStart = metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F;
|
||||||
int yShift = 5;
|
int yShift = 5;
|
||||||
|
|
||||||
g.setColor(this.getForeground());
|
g.setColor(this.getForeground());
|
||||||
g.setStroke(new BasicStroke(this.lineWidth));
|
g.setStroke(new BasicStroke(this.lineWidth));
|
||||||
g.draw(new Line2D.Float(leftStart, fontHeight * 1.6f + yShift, leftStart + (breakWidth * _numBreaks), fontHeight * 1.6f + yShift));
|
g.draw(new Line2D.Float(leftStart, fontHeight * 1.6f + yShift, leftStart + (breakWidth * _numBreaks), fontHeight * 1.6f + yShift));
|
||||||
g.setFont(this._font);
|
g.setFont(this._font);
|
||||||
for (int i = 0; i <= _numBreaks; i++) {
|
for (int i = 0; i <= _numBreaks; i++) {
|
||||||
g.draw(new Line2D.Float(leftStart, fontHeight * 1.1f + yShift, leftStart, fontHeight + (fontHeight * 1.1f) + yShift));
|
g.draw(new Line2D.Float(leftStart, fontHeight * 1.1f + yShift, leftStart, fontHeight + (fontHeight * 1.1f) + yShift));
|
||||||
g.drawString(String.valueOf(Math.abs(geoBreakWidth * i)),
|
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;
|
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) {
|
private void drawAlternatingBar(Graphics2D g, long breakWidth, long geoBreakWidth) {
|
||||||
FontMetrics metrics = g.getFontMetrics(_font);
|
FontMetrics metrics = g.getFontMetrics(_font);
|
||||||
float fontHeight = metrics.getHeight();
|
float fontHeight = metrics.getHeight();
|
||||||
float leftStart = metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F;
|
float leftStart = metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F;
|
||||||
int yShift = 5;
|
int yShift = 5;
|
||||||
float rHeight = fontHeight / 2;
|
float rHeight = fontHeight / 2;
|
||||||
|
|
||||||
boolean isFill = false;
|
boolean isFill = false;
|
||||||
g.setStroke(new BasicStroke(this.lineWidth));
|
g.setStroke(new BasicStroke(this.lineWidth));
|
||||||
g.setColor(this.getForeground());
|
g.setColor(this.getForeground());
|
||||||
g.setFont(this._font);
|
g.setFont(this._font);
|
||||||
for (int i = 0; i <= _numBreaks; i++) {
|
for (int i = 0; i <= _numBreaks; i++) {
|
||||||
if (i < _numBreaks) {
|
if (i < _numBreaks) {
|
||||||
if (isFill) {
|
if (isFill) {
|
||||||
g.fill(new Rectangle.Float(leftStart, fontHeight * 1.1f + yShift, breakWidth, rHeight));
|
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.draw(new Rectangle.Float(leftStart, fontHeight * 1.1f + yShift, breakWidth, rHeight));
|
||||||
}
|
}
|
||||||
g.drawString(String.valueOf(Math.abs(geoBreakWidth * i)),
|
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;
|
leftStart = leftStart + breakWidth;
|
||||||
isFill = !isFill;
|
isFill = !isFill;
|
||||||
}
|
}
|
||||||
g.setColor(this.getForeground());
|
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
|
@Override
|
||||||
public void moveUpdate() {
|
public void moveUpdate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resizeUpdate() {
|
public void resizeUpdate() {
|
||||||
}
|
}
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,127 +1,127 @@
|
|||||||
/* This library is free software; you can redistribute it and/or modify it
|
/* This library is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU Lesser General Public License as published by
|
* under the terms of the GNU Lesser General Public License as published by
|
||||||
* the Free Software Foundation; either version 2.1 of the License, or (at
|
* the Free Software Foundation; either version 2.1 of the License, or (at
|
||||||
* your option) any later version.
|
* your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful, but
|
* This library is distributed in the hope that it will be useful, but
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||||
* General Public License for more details.
|
* General Public License for more details.
|
||||||
*/
|
*/
|
||||||
package org.meteoinfo.chart;
|
package org.meteoinfo.chart;
|
||||||
|
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import org.meteoinfo.chart.plot3d.Projector;
|
import org.meteoinfo.chart.plot3d.Projector;
|
||||||
import org.meteoinfo.data.DataMath;
|
import org.meteoinfo.common.Extent3D;
|
||||||
import org.meteoinfo.global.Extent3D;
|
import org.meteoinfo.data.DataMath;
|
||||||
import org.meteoinfo.shape.PointZ;
|
import org.meteoinfo.shape.PointZ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Yaqiang Wang
|
* @author Yaqiang Wang
|
||||||
* yaqiang.wang@gmail.com
|
* yaqiang.wang@gmail.com
|
||||||
*/
|
*/
|
||||||
public class ChartText3D extends ChartText {
|
public class ChartText3D extends ChartText {
|
||||||
private double z;
|
private double z;
|
||||||
private PointZ zdir = null;
|
private PointZ zdir = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get z coordinate value
|
* Get z coordinate value
|
||||||
* @return Z coordinate value
|
* @return Z coordinate value
|
||||||
*/
|
*/
|
||||||
public double getZ(){
|
public double getZ(){
|
||||||
return this.z;
|
return this.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set z coordinate value
|
* Set z coordinate value
|
||||||
* @param value Z coordinate value
|
* @param value Z coordinate value
|
||||||
*/
|
*/
|
||||||
public void setZ(double value){
|
public void setZ(double value){
|
||||||
this.z = value;
|
this.z = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get zdir point
|
* Get zdir point
|
||||||
* @return ZDir point
|
* @return ZDir point
|
||||||
*/
|
*/
|
||||||
public PointZ getZDir(){
|
public PointZ getZDir(){
|
||||||
return zdir;
|
return zdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set zdir point
|
* Set zdir point
|
||||||
* @param value ZDir point
|
* @param value ZDir point
|
||||||
*/
|
*/
|
||||||
public void setZDir(PointZ value){
|
public void setZDir(PointZ value){
|
||||||
this.zdir = value;
|
this.zdir = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set zdir point
|
* Set zdir point
|
||||||
* @param x X coordinate value
|
* @param x X coordinate value
|
||||||
* @param y Y coordinate value
|
* @param y Y coordinate value
|
||||||
* @param z Z coordinate value
|
* @param z Z coordinate value
|
||||||
*/
|
*/
|
||||||
public void setZDir(float x, float y, float z){
|
public void setZDir(float x, float y, float z){
|
||||||
if (x == 0 && y == 0 && z == 0)
|
if (x == 0 && y == 0 && z == 0)
|
||||||
this.zdir = null;
|
this.zdir = null;
|
||||||
else
|
else
|
||||||
this.zdir = new PointZ(x, y, z);
|
this.zdir = new PointZ(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set zdir point
|
* Set zdir point
|
||||||
* @param value ZDir point
|
* @param value ZDir point
|
||||||
*/
|
*/
|
||||||
public void setZDir(String value){
|
public void setZDir(String value){
|
||||||
float x1 = 0, y1 = 0, z1 = 0;
|
float x1 = 0, y1 = 0, z1 = 0;
|
||||||
switch(value.toLowerCase()){
|
switch(value.toLowerCase()){
|
||||||
case "x":
|
case "x":
|
||||||
x1 = 1;
|
x1 = 1;
|
||||||
break;
|
break;
|
||||||
case "y":
|
case "y":
|
||||||
y1 = 1;
|
y1 = 1;
|
||||||
break;
|
break;
|
||||||
case "z":
|
case "z":
|
||||||
z1 = 1;
|
z1 = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this.setZDir(x1, y1, z1);
|
this.setZDir(x1, y1, z1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set point
|
* Set point
|
||||||
*
|
*
|
||||||
* @param x X
|
* @param x X
|
||||||
* @param y Y
|
* @param y Y
|
||||||
* @param z Z
|
* @param z Z
|
||||||
*/
|
*/
|
||||||
public void setPoint(double x, double y, double z) {
|
public void setPoint(double x, double y, double z) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
Extent3D aExtent = new Extent3D();
|
Extent3D aExtent = new Extent3D();
|
||||||
aExtent.minX = x;
|
aExtent.minX = x;
|
||||||
aExtent.maxX = x;
|
aExtent.maxX = x;
|
||||||
aExtent.minY = y;
|
aExtent.minY = y;
|
||||||
aExtent.maxY = y;
|
aExtent.maxY = y;
|
||||||
aExtent.minZ = z;
|
aExtent.minZ = z;
|
||||||
aExtent.maxZ = z;
|
aExtent.maxZ = z;
|
||||||
this.setExtent(aExtent);
|
this.setExtent(aExtent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update angle
|
* Update angle
|
||||||
* @param projector Projector
|
* @param projector Projector
|
||||||
*/
|
*/
|
||||||
public void updateAngle(Projector projector){
|
public void updateAngle(Projector projector){
|
||||||
if (this.zdir == null)
|
if (this.zdir == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Point p0 = projector.project(0, 0, 0);
|
Point p0 = projector.project(0, 0, 0);
|
||||||
Point p1 = projector.project((float)this.zdir.X, (float)this.zdir.Y, (float)this.zdir.Z);
|
Point p1 = projector.project((float)this.zdir.X, (float)this.zdir.Y, (float)this.zdir.Z);
|
||||||
double[] value = DataMath.getDSFromUV(p1.x - p0.x, p1.y - p0.y);
|
double[] value = DataMath.getDSFromUV(p1.x - p0.x, p1.y - p0.y);
|
||||||
this.angle = (float)value[0];
|
this.angle = (float)value[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,390 +1,391 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package org.meteoinfo.chart;
|
package org.meteoinfo.chart;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import org.meteoinfo.drawing.Draw;
|
|
||||||
import org.meteoinfo.global.DataConvert;
|
import org.meteoinfo.common.PointF;
|
||||||
import org.meteoinfo.global.PointF;
|
import org.meteoinfo.drawing.Draw;
|
||||||
import org.meteoinfo.layer.VectorLayer;
|
import org.meteoinfo.global.DataConvert;
|
||||||
import org.meteoinfo.legend.ArrowBreak;
|
import org.meteoinfo.layer.VectorLayer;
|
||||||
import org.meteoinfo.shape.GraphicCollection;
|
import org.meteoinfo.legend.ArrowBreak;
|
||||||
import org.meteoinfo.shape.WindArrow;
|
import org.meteoinfo.shape.GraphicCollection;
|
||||||
|
import org.meteoinfo.shape.WindArrow;
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
* @author Yaqiang Wang
|
*
|
||||||
*/
|
* @author Yaqiang Wang
|
||||||
public class ChartWindArrow {
|
*/
|
||||||
|
public class ChartWindArrow {
|
||||||
// <editor-fold desc="Variables">
|
|
||||||
private final WindArrow windArrow;
|
// <editor-fold desc="Variables">
|
||||||
private ArrowBreak arrowBreak;
|
private final WindArrow windArrow;
|
||||||
private Font font;
|
private ArrowBreak arrowBreak;
|
||||||
//private Color color;
|
private Font font;
|
||||||
private Color labelColor;
|
//private Color color;
|
||||||
private float x;
|
private Color labelColor;
|
||||||
private float y;
|
private float x;
|
||||||
private String label;
|
private float y;
|
||||||
private int labelSep;
|
private String label;
|
||||||
private Object layer;
|
private int labelSep;
|
||||||
private Color background;
|
private Object layer;
|
||||||
private boolean drawBackground;
|
private Color background;
|
||||||
private boolean drawNeatline;
|
private boolean drawBackground;
|
||||||
private Color neatLineColor;
|
private boolean drawNeatline;
|
||||||
private float neatLineSize;
|
private Color neatLineColor;
|
||||||
|
private float neatLineSize;
|
||||||
// </editor-fold>
|
|
||||||
// <editor-fold desc="Constructor">
|
// </editor-fold>
|
||||||
/**
|
// <editor-fold desc="Constructor">
|
||||||
* Constructor
|
/**
|
||||||
*/
|
* Constructor
|
||||||
public ChartWindArrow() {
|
*/
|
||||||
this.windArrow = new WindArrow();
|
public ChartWindArrow() {
|
||||||
this.windArrow.angle = 270;
|
this.windArrow = new WindArrow();
|
||||||
this.windArrow.length = 20;
|
this.windArrow.angle = 270;
|
||||||
this.arrowBreak = new ArrowBreak();
|
this.windArrow.length = 20;
|
||||||
this.font = new Font("Arial", Font.PLAIN, 12);
|
this.arrowBreak = new ArrowBreak();
|
||||||
//this.color = Color.black;
|
this.font = new Font("Arial", Font.PLAIN, 12);
|
||||||
this.labelColor = Color.black;
|
//this.color = Color.black;
|
||||||
this.labelSep = 5;
|
this.labelColor = Color.black;
|
||||||
this.background = Color.white;
|
this.labelSep = 5;
|
||||||
this.drawBackground = false;
|
this.background = Color.white;
|
||||||
this.drawNeatline = false;
|
this.drawBackground = false;
|
||||||
this.neatLineColor = Color.black;
|
this.drawNeatline = false;
|
||||||
this.neatLineSize = 1.0f;
|
this.neatLineColor = Color.black;
|
||||||
}
|
this.neatLineSize = 1.0f;
|
||||||
|
}
|
||||||
// </editor-fold>
|
|
||||||
// <editor-fold desc="Get Set Methods">
|
// </editor-fold>
|
||||||
/**
|
// <editor-fold desc="Get Set Methods">
|
||||||
* Get wind arrow
|
/**
|
||||||
*
|
* Get wind arrow
|
||||||
* @return Wind arrow
|
*
|
||||||
*/
|
* @return Wind arrow
|
||||||
public WindArrow getWindArrow() {
|
*/
|
||||||
return this.windArrow;
|
public WindArrow getWindArrow() {
|
||||||
}
|
return this.windArrow;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get arrow break
|
/**
|
||||||
* @return Arrow break
|
* Get arrow break
|
||||||
*/
|
* @return Arrow break
|
||||||
public ArrowBreak getArrowBreak() {
|
*/
|
||||||
return this.arrowBreak;
|
public ArrowBreak getArrowBreak() {
|
||||||
}
|
return this.arrowBreak;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set arrow break
|
/**
|
||||||
* @param value Arrow break
|
* Set arrow break
|
||||||
*/
|
* @param value Arrow break
|
||||||
public void setArrowBreak(ArrowBreak value) {
|
*/
|
||||||
this.arrowBreak = value;
|
public void setArrowBreak(ArrowBreak value) {
|
||||||
}
|
this.arrowBreak = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get length
|
/**
|
||||||
*
|
* Get length
|
||||||
* @return Length
|
*
|
||||||
*/
|
* @return Length
|
||||||
public float getLength() {
|
*/
|
||||||
return this.windArrow.length;
|
public float getLength() {
|
||||||
}
|
return this.windArrow.length;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set length
|
/**
|
||||||
*
|
* Set length
|
||||||
* @param value Length
|
*
|
||||||
*/
|
* @param value Length
|
||||||
public void setLength(float value) {
|
*/
|
||||||
this.windArrow.length = value;
|
public void setLength(float value) {
|
||||||
this.label = String.valueOf(value);
|
this.windArrow.length = value;
|
||||||
this.label = DataConvert.removeTailingZeros(this.label);
|
this.label = String.valueOf(value);
|
||||||
}
|
this.label = DataConvert.removeTailingZeros(this.label);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get angle
|
/**
|
||||||
*
|
* Get angle
|
||||||
* @return Angle
|
*
|
||||||
*/
|
* @return Angle
|
||||||
public double getAngle() {
|
*/
|
||||||
return this.windArrow.angle;
|
public double getAngle() {
|
||||||
}
|
return this.windArrow.angle;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set angle
|
/**
|
||||||
*
|
* Set angle
|
||||||
* @param value Angle
|
*
|
||||||
*/
|
* @param value Angle
|
||||||
public void setAngle(double value) {
|
*/
|
||||||
this.windArrow.angle = value;
|
public void setAngle(double value) {
|
||||||
}
|
this.windArrow.angle = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get layer
|
/**
|
||||||
*
|
* Get layer
|
||||||
* @return Layer
|
*
|
||||||
*/
|
* @return Layer
|
||||||
public Object getLayer() {
|
*/
|
||||||
return this.layer;
|
public Object getLayer() {
|
||||||
}
|
return this.layer;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set layer
|
/**
|
||||||
*
|
* Set layer
|
||||||
* @param value Layer
|
*
|
||||||
*/
|
* @param value Layer
|
||||||
public void setLayer(Object value) {
|
*/
|
||||||
this.layer = value;
|
public void setLayer(Object value) {
|
||||||
}
|
this.layer = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get font
|
/**
|
||||||
*
|
* Get font
|
||||||
* @return Font
|
*
|
||||||
*/
|
* @return Font
|
||||||
public Font getFont() {
|
*/
|
||||||
return font;
|
public Font getFont() {
|
||||||
}
|
return font;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set font
|
/**
|
||||||
*
|
* Set font
|
||||||
* @param value Font
|
*
|
||||||
*/
|
* @param value Font
|
||||||
public void setFont(Font value) {
|
*/
|
||||||
font = value;
|
public void setFont(Font value) {
|
||||||
}
|
font = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get label color
|
/**
|
||||||
*
|
* Get label color
|
||||||
* @return Label color
|
*
|
||||||
*/
|
* @return Label color
|
||||||
public Color getLabelColor() {
|
*/
|
||||||
return this.labelColor;
|
public Color getLabelColor() {
|
||||||
}
|
return this.labelColor;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set label color
|
/**
|
||||||
*
|
* Set label color
|
||||||
* @param value Label color
|
*
|
||||||
*/
|
* @param value Label color
|
||||||
public void setLabelColor(Color value) {
|
*/
|
||||||
this.labelColor = value;
|
public void setLabelColor(Color value) {
|
||||||
}
|
this.labelColor = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get the distance between arrow and label
|
/**
|
||||||
* @return Distance between arrow and label
|
* Get the distance between arrow and label
|
||||||
*/
|
* @return Distance between arrow and label
|
||||||
public int getLabelSep(){
|
*/
|
||||||
return this.labelSep;
|
public int getLabelSep(){
|
||||||
}
|
return this.labelSep;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set the distance between arrow and label
|
/**
|
||||||
* @param value Distance between arrow and label
|
* Set the distance between arrow and label
|
||||||
*/
|
* @param value Distance between arrow and label
|
||||||
public void setLabelSep(int value) {
|
*/
|
||||||
this.labelSep = value;
|
public void setLabelSep(int value) {
|
||||||
}
|
this.labelSep = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get x
|
/**
|
||||||
*
|
* Get x
|
||||||
* @return X
|
*
|
||||||
*/
|
* @return X
|
||||||
public float getX() {
|
*/
|
||||||
return this.x;
|
public float getX() {
|
||||||
}
|
return this.x;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set x
|
/**
|
||||||
*
|
* Set x
|
||||||
* @param value X
|
*
|
||||||
*/
|
* @param value X
|
||||||
public void setX(float value) {
|
*/
|
||||||
this.x = value;
|
public void setX(float value) {
|
||||||
}
|
this.x = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get y
|
/**
|
||||||
*
|
* Get y
|
||||||
* @return Y
|
*
|
||||||
*/
|
* @return Y
|
||||||
public float getY() {
|
*/
|
||||||
return this.y;
|
public float getY() {
|
||||||
}
|
return this.y;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set y
|
/**
|
||||||
*
|
* Set y
|
||||||
* @param value Y
|
*
|
||||||
*/
|
* @param value Y
|
||||||
public void setY(float value) {
|
*/
|
||||||
this.y = value;
|
public void setY(float value) {
|
||||||
}
|
this.y = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get label
|
/**
|
||||||
*
|
* Get label
|
||||||
* @return Label
|
*
|
||||||
*/
|
* @return Label
|
||||||
public String getLabel() {
|
*/
|
||||||
return this.label;
|
public String getLabel() {
|
||||||
}
|
return this.label;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set label
|
/**
|
||||||
*
|
* Set label
|
||||||
* @param value Label
|
*
|
||||||
*/
|
* @param value Label
|
||||||
public void setLabel(String value) {
|
*/
|
||||||
this.label = value;
|
public void setLabel(String value) {
|
||||||
}
|
this.label = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get background color
|
/**
|
||||||
*
|
* Get background color
|
||||||
* @return Background color
|
*
|
||||||
*/
|
* @return Background color
|
||||||
public Color getBackground() {
|
*/
|
||||||
return this.background;
|
public Color getBackground() {
|
||||||
}
|
return this.background;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set background color
|
/**
|
||||||
*
|
* Set background color
|
||||||
* @param value Background color
|
*
|
||||||
*/
|
* @param value Background color
|
||||||
public void setBackground(Color value) {
|
*/
|
||||||
this.background = value;
|
public void setBackground(Color value) {
|
||||||
}
|
this.background = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get if is fill background
|
/**
|
||||||
*
|
* Get if is fill background
|
||||||
* @return Boolean
|
*
|
||||||
*/
|
* @return Boolean
|
||||||
public boolean isFill() {
|
*/
|
||||||
return this.drawBackground;
|
public boolean isFill() {
|
||||||
}
|
return this.drawBackground;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set fill background or not
|
/**
|
||||||
*
|
* Set fill background or not
|
||||||
* @param value Boolean
|
*
|
||||||
*/
|
* @param value Boolean
|
||||||
public void setFill(boolean value) {
|
*/
|
||||||
this.drawBackground = value;
|
public void setFill(boolean value) {
|
||||||
}
|
this.drawBackground = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get draw neatline or not
|
/**
|
||||||
*
|
* Get draw neatline or not
|
||||||
* @return Boolean
|
*
|
||||||
*/
|
* @return Boolean
|
||||||
public boolean isDrawNeatline() {
|
*/
|
||||||
return this.drawNeatline;
|
public boolean isDrawNeatline() {
|
||||||
}
|
return this.drawNeatline;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set draw neatline or not
|
/**
|
||||||
*
|
* Set draw neatline or not
|
||||||
* @param value Boolean
|
*
|
||||||
*/
|
* @param value Boolean
|
||||||
public void setDrawNeatline(boolean value) {
|
*/
|
||||||
this.drawNeatline = value;
|
public void setDrawNeatline(boolean value) {
|
||||||
}
|
this.drawNeatline = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get neatline color
|
/**
|
||||||
*
|
* Get neatline color
|
||||||
* @return Neatline color
|
*
|
||||||
*/
|
* @return Neatline color
|
||||||
public Color getNeatlineColor() {
|
*/
|
||||||
return this.neatLineColor;
|
public Color getNeatlineColor() {
|
||||||
}
|
return this.neatLineColor;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set neatline color
|
/**
|
||||||
*
|
* Set neatline color
|
||||||
* @param value Neatline color
|
*
|
||||||
*/
|
* @param value Neatline color
|
||||||
public void setNeatlineColor(Color value) {
|
*/
|
||||||
this.neatLineColor = value;
|
public void setNeatlineColor(Color value) {
|
||||||
}
|
this.neatLineColor = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get neatline size
|
/**
|
||||||
*
|
* Get neatline size
|
||||||
* @return Neatline size
|
*
|
||||||
*/
|
* @return Neatline size
|
||||||
public float getNeatlineSize() {
|
*/
|
||||||
return this.neatLineSize;
|
public float getNeatlineSize() {
|
||||||
}
|
return this.neatLineSize;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set neatline size
|
/**
|
||||||
*
|
* Set neatline size
|
||||||
* @param value Neatline size
|
*
|
||||||
*/
|
* @param value Neatline size
|
||||||
public void setNeatlineSize(float value) {
|
*/
|
||||||
this.neatLineSize = value;
|
public void setNeatlineSize(float value) {
|
||||||
}
|
this.neatLineSize = value;
|
||||||
|
}
|
||||||
// </editor-fold>
|
|
||||||
// <editor-fold desc="Methods">
|
// </editor-fold>
|
||||||
/**
|
// <editor-fold desc="Methods">
|
||||||
* Draw text
|
/**
|
||||||
*
|
* Draw text
|
||||||
* @param g Graphics2D
|
*
|
||||||
* @param x X
|
* @param g Graphics2D
|
||||||
* @param y Y
|
* @param x X
|
||||||
*/
|
* @param y Y
|
||||||
public void draw(Graphics2D g, float x, float y) {
|
*/
|
||||||
Object rendering = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
|
public void draw(Graphics2D g, float x, float y) {
|
||||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
Object rendering = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
|
||||||
float zoom = 1.0f;
|
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
if (this.layer != null) {
|
float zoom = 1.0f;
|
||||||
if (this.layer instanceof VectorLayer) {
|
if (this.layer != null) {
|
||||||
zoom = ((VectorLayer) this.layer).getDrawingZoom();
|
if (this.layer instanceof VectorLayer) {
|
||||||
} else if (this.layer instanceof GraphicCollection) {
|
zoom = ((VectorLayer) this.layer).getDrawingZoom();
|
||||||
zoom = ((GraphicCollection) this.layer).getArrowZoom();
|
} else if (this.layer instanceof GraphicCollection) {
|
||||||
}
|
zoom = ((GraphicCollection) this.layer).getArrowZoom();
|
||||||
}
|
}
|
||||||
g.setFont(this.font);
|
}
|
||||||
//String drawStr = this.label wa.getLabel();
|
g.setFont(this.font);
|
||||||
Dimension dim = Draw.getStringDimension(this.label, g);
|
//String drawStr = this.label wa.getLabel();
|
||||||
if (this.drawBackground || this.drawNeatline) {
|
Dimension dim = Draw.getStringDimension(this.label, g);
|
||||||
Rectangle2D rect = Draw.getArrawBorder(new PointF(x, y), this.windArrow, g, zoom);
|
if (this.drawBackground || this.drawNeatline) {
|
||||||
double gap = 5;
|
Rectangle2D rect = Draw.getArrawBorder(new PointF(x, y), this.windArrow, g, zoom);
|
||||||
double width = Math.max(rect.getWidth(), dim.getWidth());
|
double gap = 5;
|
||||||
rect.setRect(rect.getX() - gap, rect.getY() - gap - 2, width + gap * 2,
|
double width = Math.max(rect.getWidth(), dim.getWidth());
|
||||||
rect.getHeight() + dim.height + this.labelSep + gap + 2);
|
rect.setRect(rect.getX() - gap, rect.getY() - gap - 2, width + gap * 2,
|
||||||
if (this.drawBackground) {
|
rect.getHeight() + dim.height + this.labelSep + gap + 2);
|
||||||
g.setColor(this.background);
|
if (this.drawBackground) {
|
||||||
g.fill(rect);
|
g.setColor(this.background);
|
||||||
}
|
g.fill(rect);
|
||||||
if (this.drawNeatline) {
|
}
|
||||||
g.setColor(this.neatLineColor);
|
if (this.drawNeatline) {
|
||||||
g.draw(rect);
|
g.setColor(this.neatLineColor);
|
||||||
}
|
g.draw(rect);
|
||||||
}
|
}
|
||||||
//Draw.drawArraw(this.color, new PointF(x, y), this.windArrow, g, zoom);
|
}
|
||||||
Draw.drawArraw(new PointF(x, y), windArrow, arrowBreak, g, zoom);
|
//Draw.drawArraw(this.color, new PointF(x, y), this.windArrow, g, zoom);
|
||||||
g.setColor(this.labelColor);
|
Draw.drawArraw(new PointF(x, y), windArrow, arrowBreak, g, zoom);
|
||||||
Draw.drawString(g, this.label, x, y + dim.height + this.labelSep);
|
g.setColor(this.labelColor);
|
||||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, rendering);
|
Draw.drawString(g, this.label, x, y + dim.height + this.labelSep);
|
||||||
}
|
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, rendering);
|
||||||
// </editor-fold>
|
}
|
||||||
}
|
// </editor-fold>
|
||||||
|
}
|
||||||
|
|||||||
@ -23,10 +23,10 @@ import org.meteoinfo.chart.Location;
|
|||||||
import org.meteoinfo.chart.plot.AbstractPlot2D;
|
import org.meteoinfo.chart.plot.AbstractPlot2D;
|
||||||
import org.meteoinfo.chart.plot.XAlign;
|
import org.meteoinfo.chart.plot.XAlign;
|
||||||
import org.meteoinfo.chart.plot.YAlign;
|
import org.meteoinfo.chart.plot.YAlign;
|
||||||
|
import org.meteoinfo.common.MIMath;
|
||||||
|
import org.meteoinfo.common.util.JDateUtil;
|
||||||
import org.meteoinfo.drawing.Draw;
|
import org.meteoinfo.drawing.Draw;
|
||||||
import org.meteoinfo.global.DataConvert;
|
import org.meteoinfo.global.DataConvert;
|
||||||
import org.meteoinfo.global.MIMath;
|
|
||||||
import org.meteoinfo.global.util.JDateUtil;
|
|
||||||
import org.meteoinfo.legend.LineStyles;
|
import org.meteoinfo.legend.LineStyles;
|
||||||
import org.meteoinfo.ndarray.util.BigDecimalUtil;
|
import org.meteoinfo.ndarray.util.BigDecimalUtil;
|
||||||
|
|
||||||
|
|||||||
@ -1,83 +1,83 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package org.meteoinfo.chart.axis;
|
package org.meteoinfo.chart.axis;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.meteoinfo.chart.ChartText;
|
import org.meteoinfo.chart.ChartText;
|
||||||
import org.meteoinfo.global.DataConvert;
|
import org.meteoinfo.common.MIMath;
|
||||||
import org.meteoinfo.global.MIMath;
|
import org.meteoinfo.global.DataConvert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Yaqiang Wang
|
* @author Yaqiang Wang
|
||||||
*/
|
*/
|
||||||
public class LogAxis extends Axis {
|
public class LogAxis extends Axis {
|
||||||
// <editor-fold desc="Variables">
|
// <editor-fold desc="Variables">
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
// <editor-fold desc="Constructor">
|
// <editor-fold desc="Constructor">
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param axis Axis
|
* @param axis Axis
|
||||||
*/
|
*/
|
||||||
public LogAxis(Axis axis){
|
public LogAxis(Axis axis){
|
||||||
super(axis);
|
super(axis);
|
||||||
}
|
}
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
// <editor-fold desc="Get Set Methods">
|
// <editor-fold desc="Get Set Methods">
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
// <editor-fold desc="Methods">
|
// <editor-fold desc="Methods">
|
||||||
/**
|
/**
|
||||||
* Update tick values
|
* Update tick values
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void updateTickValues() {
|
public void updateTickValues() {
|
||||||
double[] r = MIMath.getIntervalValues_Log(this.getMinValue(), this.getMaxValue());
|
double[] r = MIMath.getIntervalValues_Log(this.getMinValue(), this.getMaxValue());
|
||||||
this.setTickValues((double[]) r);
|
this.setTickValues((double[]) r);
|
||||||
this.setTickDeltaValue(1);
|
this.setTickDeltaValue(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTickLabels(){
|
public void updateTickLabels(){
|
||||||
List<ChartText> tls = new ArrayList<>();
|
List<ChartText> tls = new ArrayList<>();
|
||||||
String lab;
|
String lab;
|
||||||
if (this.isAutoTick()) {
|
if (this.isAutoTick()) {
|
||||||
if (this.getTickValues() == null) {
|
if (this.getTickValues() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (double value : this.getTickValues()) {
|
for (double value : this.getTickValues()) {
|
||||||
lab = String.valueOf(value);
|
lab = String.valueOf(value);
|
||||||
lab = DataConvert.removeTailingZeros(lab);
|
lab = DataConvert.removeTailingZeros(lab);
|
||||||
tls.add(new ChartText(lab));
|
tls.add(new ChartText(lab));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Double> values = new ArrayList<>();
|
List<Double> values = new ArrayList<>();
|
||||||
for (ChartText tl : tls){
|
for (ChartText tl : tls){
|
||||||
values.add(Double.parseDouble(tl.getText()));
|
values.add(Double.parseDouble(tl.getText()));
|
||||||
}
|
}
|
||||||
tls.clear();
|
tls.clear();
|
||||||
int e;
|
int e;
|
||||||
for (Double v : values){
|
for (Double v : values){
|
||||||
e = (int) Math.floor(Math.log10(v));
|
e = (int) Math.floor(Math.log10(v));
|
||||||
tls.add(new ChartText("$10^{" + String.valueOf(e) + "}$"));
|
tls.add(new ChartText("$10^{" + String.valueOf(e) + "}$"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < this.getTickLocations().size(); i++) {
|
for (int i = 0; i < this.getTickLocations().size(); i++) {
|
||||||
if (i >= this.getTickLabels().size()) {
|
if (i >= this.getTickLabels().size()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
double v = this.getTickLocations().get(i);
|
double v = this.getTickLocations().get(i);
|
||||||
if (v >= this.getMinValue() && v <= this.getMaxValue()) {
|
if (v >= this.getMinValue() && v <= this.getMaxValue()) {
|
||||||
tls.add(this.getTickLabels().get(i));
|
tls.add(this.getTickLabels().get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setTickLabels(tls);
|
this.setTickLabels(tls);
|
||||||
}
|
}
|
||||||
|
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,174 +1,174 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package org.meteoinfo.chart.axis;
|
package org.meteoinfo.chart.axis;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.meteoinfo.chart.ChartText;
|
import org.meteoinfo.chart.ChartText;
|
||||||
import org.meteoinfo.global.DataConvert;
|
import org.meteoinfo.common.MIMath;
|
||||||
import org.meteoinfo.global.MIMath;
|
import org.meteoinfo.global.DataConvert;
|
||||||
import org.meteoinfo.projection.KnownCoordinateSystems;
|
import org.meteoinfo.projection.KnownCoordinateSystems;
|
||||||
import org.meteoinfo.projection.info.ProjectionInfo;
|
import org.meteoinfo.projection.info.ProjectionInfo;
|
||||||
import org.meteoinfo.projection.Reproject;
|
import org.meteoinfo.projection.Reproject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Yaqiang Wang
|
* @author Yaqiang Wang
|
||||||
*/
|
*/
|
||||||
public class ProjLonLatAxis extends LonLatAxis{
|
public class ProjLonLatAxis extends LonLatAxis{
|
||||||
// <editor-fold desc="Variables">
|
// <editor-fold desc="Variables">
|
||||||
private ProjectionInfo proj;
|
private ProjectionInfo proj;
|
||||||
private double x_y;
|
private double x_y;
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
// <editor-fold desc="Constructor">
|
// <editor-fold desc="Constructor">
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param label Label
|
* @param label Label
|
||||||
* @param isX Is x/longitude axis or not
|
* @param isX Is x/longitude axis or not
|
||||||
* @param proj Projection
|
* @param proj Projection
|
||||||
*/
|
*/
|
||||||
public ProjLonLatAxis(String label, boolean isX, ProjectionInfo proj){
|
public ProjLonLatAxis(String label, boolean isX, ProjectionInfo proj){
|
||||||
super(label, isX, isX);
|
super(label, isX, isX);
|
||||||
this.proj = proj;
|
this.proj = proj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param label Label
|
* @param label Label
|
||||||
* @param isX Is x/longitude axis or not
|
* @param isX Is x/longitude axis or not
|
||||||
* @param proj Projection
|
* @param proj Projection
|
||||||
* @param xy X or Y value of the axis - using for projection
|
* @param xy X or Y value of the axis - using for projection
|
||||||
*/
|
*/
|
||||||
public ProjLonLatAxis(String label, boolean isX, ProjectionInfo proj, double xy){
|
public ProjLonLatAxis(String label, boolean isX, ProjectionInfo proj, double xy){
|
||||||
super(label, isX);
|
super(label, isX);
|
||||||
this.proj = proj;
|
this.proj = proj;
|
||||||
this.x_y = xy;
|
this.x_y = xy;
|
||||||
}
|
}
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
// <editor-fold desc="Get Set Methods">
|
// <editor-fold desc="Get Set Methods">
|
||||||
/**
|
/**
|
||||||
* Get projection
|
* Get projection
|
||||||
* @return Projection
|
* @return Projection
|
||||||
*/
|
*/
|
||||||
public ProjectionInfo getProject(){
|
public ProjectionInfo getProject(){
|
||||||
return this.proj;
|
return this.proj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set projection
|
* Set projection
|
||||||
* @param value Projection
|
* @param value Projection
|
||||||
*/
|
*/
|
||||||
public void setProject(ProjectionInfo value){
|
public void setProject(ProjectionInfo value){
|
||||||
this.proj = value;
|
this.proj = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get x_y value
|
* Get x_y value
|
||||||
* @return x_y value
|
* @return x_y value
|
||||||
*/
|
*/
|
||||||
public double getX_Y(){
|
public double getX_Y(){
|
||||||
return this.x_y;
|
return this.x_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set x_y value
|
* Set x_y value
|
||||||
* @param value x_y value
|
* @param value x_y value
|
||||||
*/
|
*/
|
||||||
public void setX_Y(double value){
|
public void setX_Y(double value){
|
||||||
this.x_y = value;
|
this.x_y = value;
|
||||||
//this.updateTickValues();
|
//this.updateTickValues();
|
||||||
}
|
}
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
// <editor-fold desc="Methods">
|
// <editor-fold desc="Methods">
|
||||||
/**
|
/**
|
||||||
* Update tick values
|
* Update tick values
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void updateTickValues() {
|
public void updateTickValues() {
|
||||||
if (this.proj == null)
|
if (this.proj == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
double min = this.getMinValue();
|
double min = this.getMinValue();
|
||||||
double max = this.getMaxValue();
|
double max = this.getMaxValue();
|
||||||
//Calculate min and max lon or lat
|
//Calculate min and max lon or lat
|
||||||
ProjectionInfo toproj = KnownCoordinateSystems.geographic.world.WGS1984;
|
ProjectionInfo toproj = KnownCoordinateSystems.geographic.world.WGS1984;
|
||||||
double minv, maxv;
|
double minv, maxv;
|
||||||
double[][] points = new double[2][];
|
double[][] points = new double[2][];
|
||||||
if (this.isXAxis()){
|
if (this.isXAxis()){
|
||||||
points[0] = new double[]{min, this.x_y};
|
points[0] = new double[]{min, this.x_y};
|
||||||
points[1] = new double[]{max, this.x_y};
|
points[1] = new double[]{max, this.x_y};
|
||||||
Reproject.reprojectPoints(points, this.proj, toproj);
|
Reproject.reprojectPoints(points, this.proj, toproj);
|
||||||
minv = points[0][0];
|
minv = points[0][0];
|
||||||
maxv = points[1][0];
|
maxv = points[1][0];
|
||||||
} else {
|
} else {
|
||||||
points[0] = new double[]{this.x_y, min};
|
points[0] = new double[]{this.x_y, min};
|
||||||
points[1] = new double[]{this.x_y, max};
|
points[1] = new double[]{this.x_y, max};
|
||||||
Reproject.reprojectPoints(points, this.proj, toproj);
|
Reproject.reprojectPoints(points, this.proj, toproj);
|
||||||
minv = points[0][1];
|
minv = points[0][1];
|
||||||
maxv = points[1][1];
|
maxv = points[1][1];
|
||||||
}
|
}
|
||||||
//Get tick values
|
//Get tick values
|
||||||
List<Object> r = MIMath.getIntervalValues1(minv, maxv);
|
List<Object> r = MIMath.getIntervalValues1(minv, maxv);
|
||||||
double[] values = (double[])r.get(0);
|
double[] values = (double[])r.get(0);
|
||||||
double[] tickValues = new double[values.length];
|
double[] tickValues = new double[values.length];
|
||||||
|
|
||||||
this.setTickValues((double[]) r.get(0));
|
this.setTickValues((double[]) r.get(0));
|
||||||
this.setTickDeltaValue((Double) r.get(1));
|
this.setTickDeltaValue((Double) r.get(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get tick labels
|
* Get tick labels
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void updateTickLabels() {
|
public void updateTickLabels() {
|
||||||
List<ChartText> tls = new ArrayList<>();
|
List<ChartText> tls = new ArrayList<>();
|
||||||
String lab;
|
String lab;
|
||||||
for (double v : this.getTickValues()) {
|
for (double v : this.getTickValues()) {
|
||||||
double value = v;
|
double value = v;
|
||||||
if (value > 180) {
|
if (value > 180) {
|
||||||
value = value - 360;
|
value = value - 360;
|
||||||
}
|
}
|
||||||
lab = String.valueOf(value);
|
lab = String.valueOf(value);
|
||||||
lab = DataConvert.removeTailingZeros(lab);
|
lab = DataConvert.removeTailingZeros(lab);
|
||||||
if (this.isXAxis()) {
|
if (this.isXAxis()) {
|
||||||
if (value == -180) {
|
if (value == -180) {
|
||||||
lab = "180";
|
lab = "180";
|
||||||
} else if (!(value == 0 || value == 180)) {
|
} else if (!(value == 0 || value == 180)) {
|
||||||
if (lab.substring(0, 1).equals("-")) {
|
if (lab.substring(0, 1).equals("-")) {
|
||||||
lab = lab.substring(1) + "W";
|
lab = lab.substring(1) + "W";
|
||||||
} else {
|
} else {
|
||||||
lab = lab + "E";
|
lab = lab + "E";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!(value == 0)) {
|
if (!(value == 0)) {
|
||||||
if (lab.substring(0, 1).equals("-")) {
|
if (lab.substring(0, 1).equals("-")) {
|
||||||
lab = lab.substring(1) + "S";
|
lab = lab.substring(1) + "S";
|
||||||
} else {
|
} else {
|
||||||
lab = lab + "N";
|
lab = lab + "N";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.isDrawDegreeSymbol()) {
|
if (this.isDrawDegreeSymbol()) {
|
||||||
if (lab.endsWith("E") || lab.endsWith("W") || lab.endsWith("N") || lab.endsWith("S")) {
|
if (lab.endsWith("E") || lab.endsWith("W") || lab.endsWith("N") || lab.endsWith("S")) {
|
||||||
lab = lab.substring(0, lab.length() - 1) + String.valueOf((char) 186) + lab.substring(lab.length() - 1);
|
lab = lab.substring(0, lab.length() - 1) + String.valueOf((char) 186) + lab.substring(lab.length() - 1);
|
||||||
} else {
|
} else {
|
||||||
lab = lab + String.valueOf((char) 186);
|
lab = lab + String.valueOf((char) 186);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tls.add(new ChartText(lab));
|
tls.add(new ChartText(lab));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setTickLabels(tls);
|
this.setTickLabels(tls);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
return (ProjLonLatAxis)super.clone();
|
return (ProjLonLatAxis)super.clone();
|
||||||
}
|
}
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,10 +8,9 @@ package org.meteoinfo.chart.axis;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.meteoinfo.chart.ChartText;
|
import org.meteoinfo.chart.ChartText;
|
||||||
import org.meteoinfo.global.util.JDateUtil;
|
import org.meteoinfo.common.util.JDateUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@ -18,7 +18,6 @@ import java.util.Iterator;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.imageio.*;
|
import javax.imageio.*;
|
||||||
import javax.imageio.metadata.IIOInvalidTreeException;
|
|
||||||
import javax.imageio.metadata.IIOMetadata;
|
import javax.imageio.metadata.IIOMetadata;
|
||||||
import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
|
import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
|
||||||
import javax.imageio.stream.ImageOutputStream;
|
import javax.imageio.stream.ImageOutputStream;
|
||||||
@ -26,7 +25,7 @@ import javax.swing.*;
|
|||||||
|
|
||||||
import org.meteoinfo.chart.IChartPanel;
|
import org.meteoinfo.chart.IChartPanel;
|
||||||
import org.meteoinfo.chart.MouseMode;
|
import org.meteoinfo.chart.MouseMode;
|
||||||
import org.meteoinfo.global.Extent3D;
|
import org.meteoinfo.common.Extent3D;
|
||||||
import org.meteoinfo.image.ImageUtil;
|
import org.meteoinfo.image.ImageUtil;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
|||||||
@ -1,58 +1,59 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package org.meteoinfo.chart.jogl;
|
package org.meteoinfo.chart.jogl;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.meteoinfo.chart.plot3d.GraphicCollection3D;
|
import org.meteoinfo.chart.plot3d.GraphicCollection3D;
|
||||||
import org.meteoinfo.global.Extent3D;
|
import org.meteoinfo.common.Extent3D;
|
||||||
import org.meteoinfo.global.MIMath;
|
import org.meteoinfo.common.MIMath;
|
||||||
import org.meteoinfo.shape.PointZ;
|
import org.meteoinfo.geoprocess.GeometryUtil;
|
||||||
|
import org.meteoinfo.shape.PointZ;
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
* @author yaqiang
|
*
|
||||||
*/
|
* @author yaqiang
|
||||||
public class IsosurfaceGraphics extends GraphicCollection3D {
|
*/
|
||||||
private List<PointZ[]> triangles = new ArrayList<>();
|
public class IsosurfaceGraphics extends GraphicCollection3D {
|
||||||
|
private List<PointZ[]> triangles = new ArrayList<>();
|
||||||
/**
|
|
||||||
* Constructor
|
/**
|
||||||
*/
|
* Constructor
|
||||||
public IsosurfaceGraphics() {
|
*/
|
||||||
super();
|
public IsosurfaceGraphics() {
|
||||||
this.allTriangle = true;
|
super();
|
||||||
}
|
this.allTriangle = true;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get triangles
|
/**
|
||||||
* @return Triangles
|
* Get triangles
|
||||||
*/
|
* @return Triangles
|
||||||
public List<PointZ[]> getTriangles() {
|
*/
|
||||||
return this.triangles;
|
public List<PointZ[]> getTriangles() {
|
||||||
}
|
return this.triangles;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set triangles
|
/**
|
||||||
* @param value Triangles
|
* Set triangles
|
||||||
*/
|
* @param value Triangles
|
||||||
public void setTriangles(List<PointZ[]> value) {
|
*/
|
||||||
this.triangles = value;
|
public void setTriangles(List<PointZ[]> value) {
|
||||||
}
|
this.triangles = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Add a triangle
|
/**
|
||||||
* @param triangle Triangle
|
* Add a triangle
|
||||||
*/
|
* @param triangle Triangle
|
||||||
public void addTriangle(PointZ[] triangle) {
|
*/
|
||||||
this.triangles.add(triangle);
|
public void addTriangle(PointZ[] triangle) {
|
||||||
Extent3D extent = MIMath.getExtent(triangle);
|
this.triangles.add(triangle);
|
||||||
if (this.triangles.size() == 1)
|
Extent3D extent = GeometryUtil.getExtent(triangle);
|
||||||
this.setExtent(extent);
|
if (this.triangles.size() == 1)
|
||||||
else
|
this.setExtent(extent);
|
||||||
this.setExtent(MIMath.getLagerExtent(extent, this.getExtent()));
|
else
|
||||||
}
|
this.setExtent(MIMath.getLagerExtent(extent, this.getExtent()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -15,8 +15,8 @@ import java.util.Random;
|
|||||||
import org.meteoinfo.chart.jogl.mc.MarchingCubes;
|
import org.meteoinfo.chart.jogl.mc.MarchingCubes;
|
||||||
import org.meteoinfo.chart.jogl.mc.CallbackMC;
|
import org.meteoinfo.chart.jogl.mc.CallbackMC;
|
||||||
import org.meteoinfo.chart.plot3d.GraphicCollection3D;
|
import org.meteoinfo.chart.plot3d.GraphicCollection3D;
|
||||||
import org.meteoinfo.global.Extent;
|
import org.meteoinfo.common.Extent;
|
||||||
import org.meteoinfo.global.Extent3D;
|
import org.meteoinfo.common.Extent3D;
|
||||||
import org.meteoinfo.layer.ImageLayer;
|
import org.meteoinfo.layer.ImageLayer;
|
||||||
import org.meteoinfo.legend.ColorBreak;
|
import org.meteoinfo.legend.ColorBreak;
|
||||||
import org.meteoinfo.legend.LegendScheme;
|
import org.meteoinfo.legend.LegendScheme;
|
||||||
|
|||||||
@ -6,15 +6,12 @@
|
|||||||
package org.meteoinfo.chart.jogl;
|
package org.meteoinfo.chart.jogl;
|
||||||
|
|
||||||
import com.jogamp.opengl.*;
|
import com.jogamp.opengl.*;
|
||||||
import com.jogamp.opengl.fixedfunc.GLLightingFunc;
|
|
||||||
import com.jogamp.opengl.glu.GLU;
|
import com.jogamp.opengl.glu.GLU;
|
||||||
import com.jogamp.opengl.glu.GLUquadric;
|
import com.jogamp.opengl.glu.GLUquadric;
|
||||||
import com.jogamp.opengl.glu.GLUtessellator;
|
import com.jogamp.opengl.glu.GLUtessellator;
|
||||||
import com.jogamp.opengl.glu.GLUtessellatorCallback;
|
|
||||||
import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
|
import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
|
||||||
import com.jogamp.opengl.util.awt.TextRenderer;
|
import com.jogamp.opengl.util.awt.TextRenderer;
|
||||||
import com.jogamp.opengl.util.texture.Texture;
|
import com.jogamp.opengl.util.texture.Texture;
|
||||||
import com.jogamp.opengl.util.texture.TextureCoords;
|
|
||||||
import com.jogamp.opengl.util.texture.awt.AWTTextureIO;
|
import com.jogamp.opengl.util.texture.awt.AWTTextureIO;
|
||||||
import com.jogamp.opengl.util.gl2.GLUT;
|
import com.jogamp.opengl.util.gl2.GLUT;
|
||||||
import com.jogamp.opengl.math.VectorUtil;
|
import com.jogamp.opengl.math.VectorUtil;
|
||||||
@ -33,7 +30,6 @@ import java.util.logging.Logger;
|
|||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
import jogamp.opengl.glu.tessellator.GLUtessellatorImpl;
|
|
||||||
import org.meteoinfo.chart.ChartColorBar;
|
import org.meteoinfo.chart.ChartColorBar;
|
||||||
import org.meteoinfo.chart.ChartLegend;
|
import org.meteoinfo.chart.ChartLegend;
|
||||||
import org.meteoinfo.chart.ChartText;
|
import org.meteoinfo.chart.ChartText;
|
||||||
@ -41,23 +37,18 @@ import org.meteoinfo.chart.ChartText3D;
|
|||||||
import org.meteoinfo.chart.Margin;
|
import org.meteoinfo.chart.Margin;
|
||||||
import org.meteoinfo.chart.axis.Axis;
|
import org.meteoinfo.chart.axis.Axis;
|
||||||
import org.meteoinfo.chart.jogl.tessellator.Primitive;
|
import org.meteoinfo.chart.jogl.tessellator.Primitive;
|
||||||
import org.meteoinfo.chart.jogl.tessellator.PrimitiveTessellator;
|
|
||||||
import org.meteoinfo.chart.jogl.tessellator.TessPolygon;
|
import org.meteoinfo.chart.jogl.tessellator.TessPolygon;
|
||||||
import org.meteoinfo.chart.jogl.tessellator.TriangleTessellator;
|
|
||||||
import org.meteoinfo.chart.plot.*;
|
import org.meteoinfo.chart.plot.*;
|
||||||
import org.meteoinfo.chart.plot3d.GraphicCollection3D;
|
import org.meteoinfo.chart.plot3d.GraphicCollection3D;
|
||||||
|
import org.meteoinfo.common.Extent;
|
||||||
|
import org.meteoinfo.common.Extent3D;
|
||||||
import org.meteoinfo.data.Dataset;
|
import org.meteoinfo.data.Dataset;
|
||||||
import org.meteoinfo.geoprocess.GeometryUtil;
|
import org.meteoinfo.geoprocess.GeometryUtil;
|
||||||
import org.meteoinfo.global.DataConvert;
|
import org.meteoinfo.global.DataConvert;
|
||||||
import org.meteoinfo.global.Extent;
|
|
||||||
import org.meteoinfo.global.Extent3D;
|
|
||||||
import org.meteoinfo.global.util.FontUtil;
|
|
||||||
import org.meteoinfo.legend.*;
|
import org.meteoinfo.legend.*;
|
||||||
import org.meteoinfo.math.meteo.MeteoMath;
|
import org.meteoinfo.math.meteo.MeteoMath;
|
||||||
import org.meteoinfo.shape.*;
|
import org.meteoinfo.shape.*;
|
||||||
|
|
||||||
import static org.meteoinfo.shape.ShapeTypes.PointZ;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author wyq
|
* @author wyq
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
package org.meteoinfo.chart.jogl;
|
package org.meteoinfo.chart.jogl;
|
||||||
|
|
||||||
import org.meteoinfo.chart.plot3d.GraphicCollection3D;
|
import org.meteoinfo.chart.plot3d.GraphicCollection3D;
|
||||||
import org.meteoinfo.global.Extent3D;
|
import org.meteoinfo.common.Extent3D;
|
||||||
import org.meteoinfo.legend.ColorBreak;
|
import org.meteoinfo.legend.ColorBreak;
|
||||||
import org.meteoinfo.legend.LegendScheme;
|
import org.meteoinfo.legend.LegendScheme;
|
||||||
import org.meteoinfo.legend.PolygonBreak;
|
import org.meteoinfo.legend.PolygonBreak;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
package org.meteoinfo.chart.jogl;
|
package org.meteoinfo.chart.jogl;
|
||||||
|
|
||||||
import org.meteoinfo.global.Extent3D;
|
import org.meteoinfo.common.Extent3D;
|
||||||
import org.meteoinfo.shape.PointZ;
|
import org.meteoinfo.shape.PointZ;
|
||||||
|
|
||||||
public class Transform {
|
public class Transform {
|
||||||
|
|||||||
@ -27,11 +27,9 @@ import org.meteoinfo.chart.Location;
|
|||||||
import org.meteoinfo.chart.Margin;
|
import org.meteoinfo.chart.Margin;
|
||||||
import org.meteoinfo.chart.axis.Axis;
|
import org.meteoinfo.chart.axis.Axis;
|
||||||
import org.meteoinfo.chart.axis.LogAxis;
|
import org.meteoinfo.chart.axis.LogAxis;
|
||||||
import static org.meteoinfo.chart.plot.Plot.MINIMUM_HEIGHT_TO_DRAW;
|
import org.meteoinfo.common.Extent;
|
||||||
import static org.meteoinfo.chart.plot.Plot.MINIMUM_WIDTH_TO_DRAW;
|
import org.meteoinfo.common.PointF;
|
||||||
import org.meteoinfo.drawing.Draw;
|
import org.meteoinfo.drawing.Draw;
|
||||||
import org.meteoinfo.global.Extent;
|
|
||||||
import org.meteoinfo.global.PointF;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@ -18,20 +18,19 @@ import java.util.List;
|
|||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.meteoinfo.chart.ChartText;
|
import org.meteoinfo.chart.ChartText;
|
||||||
import org.meteoinfo.chart.plot3d.GraphicCollection3D;
|
import org.meteoinfo.chart.plot3d.GraphicCollection3D;
|
||||||
import org.meteoinfo.math.ArrayMath;
|
import org.meteoinfo.common.Extent;
|
||||||
import org.meteoinfo.math.ArrayUtil;
|
import org.meteoinfo.common.Extent3D;
|
||||||
|
import org.meteoinfo.common.MIMath;
|
||||||
|
import org.meteoinfo.common.PointD;
|
||||||
import org.meteoinfo.data.GridArray;
|
import org.meteoinfo.data.GridArray;
|
||||||
import org.meteoinfo.data.GridData;
|
import org.meteoinfo.data.GridData;
|
||||||
import org.meteoinfo.data.XYListDataset;
|
import org.meteoinfo.data.XYListDataset;
|
||||||
import org.meteoinfo.data.analysis.Statistics;
|
import org.meteoinfo.data.analysis.Statistics;
|
||||||
import org.meteoinfo.drawing.ContourDraw;
|
import org.meteoinfo.drawing.ContourDraw;
|
||||||
import org.meteoinfo.drawing.Draw;
|
import org.meteoinfo.drawing.Draw;
|
||||||
|
import org.meteoinfo.geoprocess.GeometryUtil;
|
||||||
import org.meteoinfo.legend.PointStyle;
|
import org.meteoinfo.legend.PointStyle;
|
||||||
import org.meteoinfo.geoprocess.GeoComputation;
|
import org.meteoinfo.geoprocess.GeoComputation;
|
||||||
import org.meteoinfo.global.Extent;
|
|
||||||
import org.meteoinfo.global.Extent3D;
|
|
||||||
import org.meteoinfo.global.MIMath;
|
|
||||||
import org.meteoinfo.global.PointD;
|
|
||||||
import org.meteoinfo.layer.ImageLayer;
|
import org.meteoinfo.layer.ImageLayer;
|
||||||
import org.meteoinfo.layer.VectorLayer;
|
import org.meteoinfo.layer.VectorLayer;
|
||||||
import org.meteoinfo.legend.ArrowLineBreak;
|
import org.meteoinfo.legend.ArrowLineBreak;
|
||||||
@ -48,6 +47,8 @@ import org.meteoinfo.legend.PointBreak;
|
|||||||
import org.meteoinfo.legend.PolygonBreak;
|
import org.meteoinfo.legend.PolygonBreak;
|
||||||
import org.meteoinfo.legend.PolylineBreak;
|
import org.meteoinfo.legend.PolylineBreak;
|
||||||
import org.meteoinfo.legend.StreamlineBreak;
|
import org.meteoinfo.legend.StreamlineBreak;
|
||||||
|
import org.meteoinfo.math.ArrayMath;
|
||||||
|
import org.meteoinfo.math.ArrayUtil;
|
||||||
import org.meteoinfo.math.meteo.MeteoMath;
|
import org.meteoinfo.math.meteo.MeteoMath;
|
||||||
import org.meteoinfo.ndarray.*;
|
import org.meteoinfo.ndarray.*;
|
||||||
import org.meteoinfo.ndarray.util.BigDecimalUtil;
|
import org.meteoinfo.ndarray.util.BigDecimalUtil;
|
||||||
@ -3100,7 +3101,7 @@ public class GraphicFactory {
|
|||||||
}
|
}
|
||||||
aPolyline.setPoints(pList);
|
aPolyline.setPoints(pList);
|
||||||
aPolyline.setValue(v);
|
aPolyline.setValue(v);
|
||||||
aPolyline.setExtent(MIMath.getPointsExtent(pList));
|
aPolyline.setExtent(GeometryUtil.getPointsExtent(pList));
|
||||||
|
|
||||||
switch (ls.getLegendType()) {
|
switch (ls.getLegendType()) {
|
||||||
case UniqueValue:
|
case UniqueValue:
|
||||||
@ -3216,7 +3217,7 @@ public class GraphicFactory {
|
|||||||
}
|
}
|
||||||
aPolyline.setPoints(pList);
|
aPolyline.setPoints(pList);
|
||||||
aPolyline.setValue(v);
|
aPolyline.setValue(v);
|
||||||
aPolyline.setExtent(MIMath.getPointsExtent(pList));
|
aPolyline.setExtent(GeometryUtil.getPointsExtent(pList));
|
||||||
cbb = ls.findLegendBreak(v);
|
cbb = ls.findLegendBreak(v);
|
||||||
graphics.add(new Graphic(aPolyline, cbb));
|
graphics.add(new Graphic(aPolyline, cbb));
|
||||||
}
|
}
|
||||||
@ -3325,7 +3326,7 @@ public class GraphicFactory {
|
|||||||
}
|
}
|
||||||
aPolyline.setPoints(pList);
|
aPolyline.setPoints(pList);
|
||||||
aPolyline.setValue(v);
|
aPolyline.setValue(v);
|
||||||
aPolyline.setExtent(MIMath.getPointsExtent(pList));
|
aPolyline.setExtent(GeometryUtil.getPointsExtent(pList));
|
||||||
cbb = ls.findLegendBreak(v);
|
cbb = ls.findLegendBreak(v);
|
||||||
graphics.add(new Graphic(aPolyline, cbb));
|
graphics.add(new Graphic(aPolyline, cbb));
|
||||||
}
|
}
|
||||||
@ -3391,7 +3392,7 @@ public class GraphicFactory {
|
|||||||
}
|
}
|
||||||
PolygonShape aPolygonShape = new PolygonShape();
|
PolygonShape aPolygonShape = new PolygonShape();
|
||||||
aPolygonShape.setPoints(pList);
|
aPolygonShape.setPoints(pList);
|
||||||
aPolygonShape.setExtent(MIMath.getPointsExtent(pList));
|
aPolygonShape.setExtent(GeometryUtil.getPointsExtent(pList));
|
||||||
aPolygonShape.lowValue = v;
|
aPolygonShape.lowValue = v;
|
||||||
if (poly.HasHoles()) {
|
if (poly.HasHoles()) {
|
||||||
for (PolyLine holeLine : poly.HoleLines) {
|
for (PolyLine holeLine : poly.HoleLines) {
|
||||||
@ -3555,7 +3556,7 @@ public class GraphicFactory {
|
|||||||
}
|
}
|
||||||
PolygonZShape aPolygonShape = new PolygonZShape();
|
PolygonZShape aPolygonShape = new PolygonZShape();
|
||||||
aPolygonShape.setPoints(pList);
|
aPolygonShape.setPoints(pList);
|
||||||
aPolygonShape.setExtent(MIMath.getPointsExtent(pList));
|
aPolygonShape.setExtent(GeometryUtil.getPointsExtent(pList));
|
||||||
aPolygonShape.lowValue = v;
|
aPolygonShape.lowValue = v;
|
||||||
if (poly.HasHoles()) {
|
if (poly.HasHoles()) {
|
||||||
switch (zdir) {
|
switch (zdir) {
|
||||||
@ -3734,7 +3735,7 @@ public class GraphicFactory {
|
|||||||
}
|
}
|
||||||
PolygonZShape aPolygonShape = new PolygonZShape();
|
PolygonZShape aPolygonShape = new PolygonZShape();
|
||||||
aPolygonShape.setPoints(pList);
|
aPolygonShape.setPoints(pList);
|
||||||
aPolygonShape.setExtent(MIMath.getPointsExtent(pList));
|
aPolygonShape.setExtent(GeometryUtil.getPointsExtent(pList));
|
||||||
aPolygonShape.lowValue = v;
|
aPolygonShape.lowValue = v;
|
||||||
if (poly.HasHoles()) {
|
if (poly.HasHoles()) {
|
||||||
switch (zdir) {
|
switch (zdir) {
|
||||||
|
|||||||
@ -28,15 +28,14 @@ import org.meteoinfo.chart.ChartScaleBar;
|
|||||||
import org.meteoinfo.chart.ChartText;
|
import org.meteoinfo.chart.ChartText;
|
||||||
import org.meteoinfo.chart.Location;
|
import org.meteoinfo.chart.Location;
|
||||||
import org.meteoinfo.chart.axis.LonLatAxis;
|
import org.meteoinfo.chart.axis.LonLatAxis;
|
||||||
|
import org.meteoinfo.common.Extent;
|
||||||
|
import org.meteoinfo.common.MIMath;
|
||||||
|
import org.meteoinfo.common.PointD;
|
||||||
|
import org.meteoinfo.common.PointF;
|
||||||
import org.meteoinfo.data.Dataset;
|
import org.meteoinfo.data.Dataset;
|
||||||
import org.meteoinfo.data.mapdata.webmap.IWebMapPanel;
|
import org.meteoinfo.data.mapdata.webmap.IWebMapPanel;
|
||||||
import org.meteoinfo.data.mapdata.webmap.TileLoadListener;
|
import org.meteoinfo.data.mapdata.webmap.TileLoadListener;
|
||||||
import org.meteoinfo.drawing.Draw;
|
import org.meteoinfo.drawing.Draw;
|
||||||
import org.meteoinfo.global.Direction;
|
|
||||||
import org.meteoinfo.global.Extent;
|
|
||||||
import org.meteoinfo.global.MIMath;
|
|
||||||
import org.meteoinfo.global.PointD;
|
|
||||||
import org.meteoinfo.global.PointF;
|
|
||||||
import org.meteoinfo.layer.LayerCollection;
|
import org.meteoinfo.layer.LayerCollection;
|
||||||
import org.meteoinfo.layer.MapLayer;
|
import org.meteoinfo.layer.MapLayer;
|
||||||
import org.meteoinfo.legend.LabelBreak;
|
import org.meteoinfo.legend.LabelBreak;
|
||||||
|
|||||||
@ -1,160 +1,161 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package org.meteoinfo.chart.plot;
|
package org.meteoinfo.chart.plot;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.geom.AffineTransform;
|
import java.awt.geom.AffineTransform;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import org.meteoinfo.drawing.Draw;
|
|
||||||
import org.meteoinfo.global.PointF;
|
import org.meteoinfo.common.PointF;
|
||||||
import org.meteoinfo.legend.ColorBreak;
|
import org.meteoinfo.drawing.Draw;
|
||||||
import org.meteoinfo.legend.PolygonBreak;
|
import org.meteoinfo.legend.ColorBreak;
|
||||||
import org.meteoinfo.shape.ArcShape;
|
import org.meteoinfo.legend.PolygonBreak;
|
||||||
import org.meteoinfo.shape.Graphic;
|
import org.meteoinfo.shape.ArcShape;
|
||||||
import org.meteoinfo.shape.GraphicCollection;
|
import org.meteoinfo.shape.Graphic;
|
||||||
import org.meteoinfo.shape.Shape;
|
import org.meteoinfo.shape.GraphicCollection;
|
||||||
|
import org.meteoinfo.shape.Shape;
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
* @author Yaqiang Wang
|
*
|
||||||
*/
|
* @author Yaqiang Wang
|
||||||
public class PiePlot extends Plot2D {
|
*/
|
||||||
|
public class PiePlot extends Plot2D {
|
||||||
// <editor-fold desc="Variables">
|
|
||||||
// </editor-fold>
|
// <editor-fold desc="Variables">
|
||||||
// <editor-fold desc="Constructor">
|
// </editor-fold>
|
||||||
/**
|
// <editor-fold desc="Constructor">
|
||||||
* Constructor
|
/**
|
||||||
*/
|
* Constructor
|
||||||
public PiePlot(){
|
*/
|
||||||
super();
|
public PiePlot(){
|
||||||
this.setAutoAspect(false);
|
super();
|
||||||
}
|
this.setAutoAspect(false);
|
||||||
// </editor-fold>
|
}
|
||||||
// <editor-fold desc="Get Set Methods">
|
// </editor-fold>
|
||||||
// </editor-fold>
|
// <editor-fold desc="Get Set Methods">
|
||||||
// <editor-fold desc="Methods">
|
// </editor-fold>
|
||||||
@Override
|
// <editor-fold desc="Methods">
|
||||||
void drawGraph(Graphics2D g, Rectangle2D area) {
|
@Override
|
||||||
AffineTransform oldMatrix = g.getTransform();
|
void drawGraph(Graphics2D g, Rectangle2D area) {
|
||||||
//Rectangle oldRegion = g.getClipBounds();
|
AffineTransform oldMatrix = g.getTransform();
|
||||||
//g.setClip(area);
|
//Rectangle oldRegion = g.getClipBounds();
|
||||||
g.translate(area.getX(), area.getY());
|
//g.setClip(area);
|
||||||
|
g.translate(area.getX(), area.getY());
|
||||||
//Draw background
|
|
||||||
if (this.background != null) {
|
//Draw background
|
||||||
g.setColor(this.getBackground());
|
if (this.background != null) {
|
||||||
g.fill(new Rectangle2D.Double(0, 0, area.getWidth(), area.getHeight()));
|
g.setColor(this.getBackground());
|
||||||
}
|
g.fill(new Rectangle2D.Double(0, 0, area.getWidth(), area.getHeight()));
|
||||||
|
}
|
||||||
for (int m = 0; m < this.getGraphics().getNumGraphics(); m++) {
|
|
||||||
Graphic graphic = this.getGraphics().get(m);
|
for (int m = 0; m < this.getGraphics().getNumGraphics(); m++) {
|
||||||
ColorBreak cb = graphic.getLegend();
|
Graphic graphic = this.getGraphics().get(m);
|
||||||
float dist = 5;
|
ColorBreak cb = graphic.getLegend();
|
||||||
float ex = this.getExplode();
|
float dist = 5;
|
||||||
Font labelFont = ((GraphicCollection)graphic).getLabelSet().getLabelFont();
|
float ex = this.getExplode();
|
||||||
Color labelColor = ((GraphicCollection)graphic).getLabelSet().getLabelColor();
|
Font labelFont = ((GraphicCollection)graphic).getLabelSet().getLabelFont();
|
||||||
for (int i = 0; i < graphic.getNumGraphics(); i++) {
|
Color labelColor = ((GraphicCollection)graphic).getLabelSet().getLabelColor();
|
||||||
Graphic gg = graphic.getGraphicN(i);
|
for (int i = 0; i < graphic.getNumGraphics(); i++) {
|
||||||
if (!graphic.isSingleLegend()) {
|
Graphic gg = graphic.getGraphicN(i);
|
||||||
cb = gg.getLegend();
|
if (!graphic.isSingleLegend()) {
|
||||||
}
|
cb = gg.getLegend();
|
||||||
Shape shape = gg.getShape();
|
}
|
||||||
this.drawArc(g, (ArcShape) shape, (PolygonBreak) cb, area, dist, ex, labelFont,
|
Shape shape = gg.getShape();
|
||||||
labelColor);
|
this.drawArc(g, (ArcShape) shape, (PolygonBreak) cb, area, dist, ex, labelFont,
|
||||||
}
|
labelColor);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
g.setTransform(oldMatrix);
|
|
||||||
//g.setClip(oldRegion);
|
g.setTransform(oldMatrix);
|
||||||
}
|
//g.setClip(oldRegion);
|
||||||
|
}
|
||||||
private float getExplode() {
|
|
||||||
Graphic graphic = this.getGraphics().get(0);
|
private float getExplode() {
|
||||||
float ex = 0;
|
Graphic graphic = this.getGraphics().get(0);
|
||||||
for (int i = 0; i < graphic.getNumGraphics(); i++) {
|
float ex = 0;
|
||||||
Graphic gg = graphic.getGraphicN(i);
|
for (int i = 0; i < graphic.getNumGraphics(); i++) {
|
||||||
ArcShape shape = (ArcShape) gg.getShape();
|
Graphic gg = graphic.getGraphicN(i);
|
||||||
if (shape.getExplode() > 0) {
|
ArcShape shape = (ArcShape) gg.getShape();
|
||||||
ex = 10;
|
if (shape.getExplode() > 0) {
|
||||||
break;
|
ex = 10;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
return ex;
|
}
|
||||||
}
|
return ex;
|
||||||
|
}
|
||||||
private void drawArc(Graphics2D g, ArcShape aShape, PolygonBreak aPGB,
|
|
||||||
Rectangle2D area, float dist, float ex, Font labelFont, Color labelColor) {
|
private void drawArc(Graphics2D g, ArcShape aShape, PolygonBreak aPGB,
|
||||||
float startAngle = aShape.getStartAngle();
|
Rectangle2D area, float dist, float ex, Font labelFont, Color labelColor) {
|
||||||
float sweepAngle = aShape.getSweepAngle();
|
float startAngle = aShape.getStartAngle();
|
||||||
float angle = startAngle + sweepAngle / 2;
|
float sweepAngle = aShape.getSweepAngle();
|
||||||
float space = 20;
|
float angle = startAngle + sweepAngle / 2;
|
||||||
Rectangle2D rect = new Rectangle2D.Double(area.getX() + ex + space, area.getY() + ex + space, area.getWidth() - ex - space,
|
float space = 20;
|
||||||
area.getHeight() - ex - space);
|
Rectangle2D rect = new Rectangle2D.Double(area.getX() + ex + space, area.getY() + ex + space, area.getWidth() - ex - space,
|
||||||
double dx = 0, dy = 0;
|
area.getHeight() - ex - space);
|
||||||
if (aShape.getExplode() > 0) {
|
double dx = 0, dy = 0;
|
||||||
dx = ex * Math.cos((360 - angle) * Math.PI / 180);
|
if (aShape.getExplode() > 0) {
|
||||||
dy = ex * Math.sin((360 - angle) * Math.PI / 180);
|
dx = ex * Math.cos((360 - angle) * Math.PI / 180);
|
||||||
rect.setRect(rect.getX() + dx, rect.getY() + dy, rect.getWidth(), rect.getHeight());
|
dy = ex * Math.sin((360 - angle) * Math.PI / 180);
|
||||||
}
|
rect.setRect(rect.getX() + dx, rect.getY() + dy, rect.getWidth(), rect.getHeight());
|
||||||
float sx = (float) (rect.getX() - area.getX());
|
}
|
||||||
float sy = (float) (rect.getY() - area.getY());
|
float sx = (float) (rect.getX() - area.getX());
|
||||||
Draw.drawPie(new PointF(sx, sy), (float) rect.getWidth(), (float) rect.getHeight(),
|
float sy = (float) (rect.getY() - area.getY());
|
||||||
startAngle, sweepAngle, aPGB, g);
|
Draw.drawPie(new PointF(sx, sy), (float) rect.getWidth(), (float) rect.getHeight(),
|
||||||
|
startAngle, sweepAngle, aPGB, g);
|
||||||
//Draw label
|
|
||||||
//Rectangle clip = g.getClipBounds();
|
//Draw label
|
||||||
//if (clip != null) {
|
//Rectangle clip = g.getClipBounds();
|
||||||
// g.setClip(null);
|
//if (clip != null) {
|
||||||
//}
|
// g.setClip(null);
|
||||||
float x, y, w, h;
|
//}
|
||||||
PointF sPoint = new PointF((float) (rect.getWidth() * 0.5 + sx), (float) (rect.getHeight() * 0.5 + sy));
|
float x, y, w, h;
|
||||||
String label = aPGB.getCaption();
|
PointF sPoint = new PointF((float) (rect.getWidth() * 0.5 + sx), (float) (rect.getHeight() * 0.5 + sy));
|
||||||
if (angle > 360) {
|
String label = aPGB.getCaption();
|
||||||
angle = angle - 360;
|
if (angle > 360) {
|
||||||
}
|
angle = angle - 360;
|
||||||
float r = (float) (rect.getWidth() * 0.5) + dist;
|
}
|
||||||
PointF lPoint = Draw.getPieLabelPoint(sPoint, r, angle);
|
float r = (float) (rect.getWidth() * 0.5) + dist;
|
||||||
x = lPoint.X;
|
PointF lPoint = Draw.getPieLabelPoint(sPoint, r, angle);
|
||||||
y = lPoint.Y;
|
x = lPoint.X;
|
||||||
Dimension dim = Draw.getStringDimension(label, g);
|
y = lPoint.Y;
|
||||||
h = dim.height;
|
Dimension dim = Draw.getStringDimension(label, g);
|
||||||
w = dim.width;
|
h = dim.height;
|
||||||
if ((angle >= 0 && angle < 45)) {
|
w = dim.width;
|
||||||
//x = x + dis;
|
if ((angle >= 0 && angle < 45)) {
|
||||||
y = y - h;
|
//x = x + dis;
|
||||||
} else if (angle >= 45 && angle < 90) {
|
y = y - h;
|
||||||
//y = y - dis;
|
} else if (angle >= 45 && angle < 90) {
|
||||||
} else if (angle >= 90 && angle < 135) {
|
//y = y - dis;
|
||||||
x = x - w;
|
} else if (angle >= 90 && angle < 135) {
|
||||||
//y = y - dis;
|
x = x - w;
|
||||||
} else if (angle >= 135 && angle < 225) {
|
//y = y - dis;
|
||||||
x = x - w - 3;
|
} else if (angle >= 135 && angle < 225) {
|
||||||
y = y + h / 2;
|
x = x - w - 3;
|
||||||
} else if (angle >= 225 && angle < 270) {
|
y = y + h / 2;
|
||||||
x = x - w / 2;
|
} else if (angle >= 225 && angle < 270) {
|
||||||
y = y + h;
|
x = x - w / 2;
|
||||||
} else if (angle >= 270 && angle < 315) {
|
y = y + h;
|
||||||
//x = x + dis;
|
} else if (angle >= 270 && angle < 315) {
|
||||||
y = y + h;
|
//x = x + dis;
|
||||||
} else {
|
y = y + h;
|
||||||
//x = x + dis;
|
} else {
|
||||||
y = y + h / 2;
|
//x = x + dis;
|
||||||
}
|
y = y + h / 2;
|
||||||
g.setFont(labelFont);
|
}
|
||||||
g.setColor(labelColor);
|
g.setFont(labelFont);
|
||||||
//g.drawOval((int)(x - 3), (int)(y - 3), 6, 6);
|
g.setColor(labelColor);
|
||||||
g.drawString(label, x, y);
|
//g.drawOval((int)(x - 3), (int)(y - 3), 6, 6);
|
||||||
|
g.drawString(label, x, y);
|
||||||
//if (clip != null) {
|
|
||||||
// g.setClip(clip);
|
//if (clip != null) {
|
||||||
//}
|
// g.setClip(clip);
|
||||||
}
|
//}
|
||||||
// </editor-fold>
|
}
|
||||||
}
|
// </editor-fold>
|
||||||
|
}
|
||||||
|
|||||||
@ -35,16 +35,17 @@ import org.meteoinfo.chart.ChartLegend;
|
|||||||
import org.meteoinfo.chart.ChartText;
|
import org.meteoinfo.chart.ChartText;
|
||||||
import org.meteoinfo.chart.axis.LogAxis;
|
import org.meteoinfo.chart.axis.LogAxis;
|
||||||
import org.meteoinfo.chart.axis.TimeAxis;
|
import org.meteoinfo.chart.axis.TimeAxis;
|
||||||
|
import org.meteoinfo.common.Extent;
|
||||||
|
import org.meteoinfo.common.MIMath;
|
||||||
|
import org.meteoinfo.common.PointD;
|
||||||
|
import org.meteoinfo.common.PointF;
|
||||||
import org.meteoinfo.data.Dataset;
|
import org.meteoinfo.data.Dataset;
|
||||||
import org.meteoinfo.drawing.Draw;
|
import org.meteoinfo.drawing.Draw;
|
||||||
import static org.meteoinfo.drawing.Draw.getHatchImage;
|
import static org.meteoinfo.drawing.Draw.getHatchImage;
|
||||||
import org.meteoinfo.global.Extent;
|
|
||||||
import org.meteoinfo.global.MIMath;
|
import org.meteoinfo.geoprocess.GeometryUtil;
|
||||||
import org.meteoinfo.global.PointD;
|
|
||||||
import org.meteoinfo.global.PointF;
|
|
||||||
import org.meteoinfo.legend.ArrowBreak;
|
import org.meteoinfo.legend.ArrowBreak;
|
||||||
import org.meteoinfo.legend.BarBreak;
|
import org.meteoinfo.legend.BarBreak;
|
||||||
import static org.meteoinfo.legend.BreakTypes.LabelBreak;
|
|
||||||
import org.meteoinfo.legend.ColorBreak;
|
import org.meteoinfo.legend.ColorBreak;
|
||||||
import org.meteoinfo.legend.ColorBreakCollection;
|
import org.meteoinfo.legend.ColorBreakCollection;
|
||||||
import org.meteoinfo.legend.LabelBreak;
|
import org.meteoinfo.legend.LabelBreak;
|
||||||
@ -767,7 +768,7 @@ public class Plot2D extends AbstractPlot2D {
|
|||||||
aY = (float) sXY[1];
|
aY = (float) sXY[1];
|
||||||
points.add(new PointD(aX, aY));
|
points.add(new PointD(aX, aY));
|
||||||
}
|
}
|
||||||
Extent aExtent = MIMath.getPointsExtent(points);
|
Extent aExtent = GeometryUtil.getPointsExtent(points);
|
||||||
rect.x = (int) aExtent.minX;
|
rect.x = (int) aExtent.minX;
|
||||||
rect.y = (int) aExtent.minY;
|
rect.y = (int) aExtent.minY;
|
||||||
rect.width = (int) (aExtent.maxX - aExtent.minX);
|
rect.width = (int) (aExtent.maxX - aExtent.minX);
|
||||||
@ -779,7 +780,7 @@ public class Plot2D extends AbstractPlot2D {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<PointF> drawPolygon(Graphics2D g, Polygon aPG, PolygonBreak aPGB,
|
private List<PointF> drawPolygon(Graphics2D g, Polygon aPG, PolygonBreak aPGB,
|
||||||
boolean isSelected, Rectangle2D area) {
|
boolean isSelected, Rectangle2D area) {
|
||||||
int len = aPG.getOutLine().size();
|
int len = aPG.getOutLine().size();
|
||||||
GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, len);
|
GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, len);
|
||||||
PointD wPoint;
|
PointD wPoint;
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import java.awt.Color;
|
|||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.FontMetrics;
|
import java.awt.FontMetrics;
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
@ -31,13 +30,13 @@ import org.meteoinfo.chart.axis.Axis;
|
|||||||
import org.meteoinfo.chart.axis.LogAxis;
|
import org.meteoinfo.chart.axis.LogAxis;
|
||||||
import org.meteoinfo.chart.plot3d.GraphicCollection3D;
|
import org.meteoinfo.chart.plot3d.GraphicCollection3D;
|
||||||
import org.meteoinfo.chart.plot3d.Projector;
|
import org.meteoinfo.chart.plot3d.Projector;
|
||||||
|
import org.meteoinfo.common.Extent;
|
||||||
|
import org.meteoinfo.common.Extent3D;
|
||||||
|
import org.meteoinfo.common.MIMath;
|
||||||
|
import org.meteoinfo.common.PointF;
|
||||||
import org.meteoinfo.data.DataMath;
|
import org.meteoinfo.data.DataMath;
|
||||||
import org.meteoinfo.data.Dataset;
|
import org.meteoinfo.data.Dataset;
|
||||||
import org.meteoinfo.drawing.Draw;
|
import org.meteoinfo.drawing.Draw;
|
||||||
import org.meteoinfo.global.Extent;
|
|
||||||
import org.meteoinfo.global.Extent3D;
|
|
||||||
import org.meteoinfo.global.MIMath;
|
|
||||||
import org.meteoinfo.global.PointF;
|
|
||||||
import org.meteoinfo.legend.*;
|
import org.meteoinfo.legend.*;
|
||||||
import org.meteoinfo.math.sort.QuickSort;
|
import org.meteoinfo.math.sort.QuickSort;
|
||||||
import org.meteoinfo.shape.*;
|
import org.meteoinfo.shape.*;
|
||||||
|
|||||||
@ -16,11 +16,11 @@ import java.awt.geom.Rectangle2D;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.meteoinfo.chart.Margin;
|
import org.meteoinfo.chart.Margin;
|
||||||
|
import org.meteoinfo.common.Extent;
|
||||||
|
import org.meteoinfo.common.MIMath;
|
||||||
import org.meteoinfo.drawing.Draw;
|
import org.meteoinfo.drawing.Draw;
|
||||||
import static org.meteoinfo.drawing.Draw.getDashPattern;
|
import static org.meteoinfo.drawing.Draw.getDashPattern;
|
||||||
import org.meteoinfo.global.DataConvert;
|
import org.meteoinfo.global.DataConvert;
|
||||||
import org.meteoinfo.global.Extent;
|
|
||||||
import org.meteoinfo.global.MIMath;
|
|
||||||
import org.meteoinfo.legend.LineStyles;
|
import org.meteoinfo.legend.LineStyles;
|
||||||
import org.meteoinfo.shape.Graphic;
|
import org.meteoinfo.shape.Graphic;
|
||||||
import org.meteoinfo.shape.GraphicCollection;
|
import org.meteoinfo.shape.GraphicCollection;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -14,9 +14,10 @@
|
|||||||
package org.meteoinfo.data;
|
package org.meteoinfo.data;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import org.meteoinfo.global.MIMath;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.meteoinfo.common.MIMath;
|
||||||
import org.meteoinfo.table.ColumnData;
|
import org.meteoinfo.table.ColumnData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,96 +1,96 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package org.meteoinfo.data;
|
package org.meteoinfo.data;
|
||||||
|
|
||||||
import org.meteoinfo.global.MIMath;
|
import org.meteoinfo.common.MIMath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author wyq
|
* @author wyq
|
||||||
*/
|
*/
|
||||||
public class DataRange {
|
public class DataRange {
|
||||||
// <editor-fold desc="Variables">
|
// <editor-fold desc="Variables">
|
||||||
private double min;
|
private double min;
|
||||||
private double max;
|
private double max;
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
// <editor-fold desc="Constructor">
|
// <editor-fold desc="Constructor">
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public DataRange(){
|
public DataRange(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param min Minimum value
|
* @param min Minimum value
|
||||||
* @param max Maximum value
|
* @param max Maximum value
|
||||||
*/
|
*/
|
||||||
public DataRange(double min, double max){
|
public DataRange(double min, double max){
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.max = max;
|
this.max = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param value Data value
|
* @param value Data value
|
||||||
*/
|
*/
|
||||||
public DataRange(double value){
|
public DataRange(double value){
|
||||||
this.min = value;
|
this.min = value;
|
||||||
this.max = value;
|
this.max = value;
|
||||||
}
|
}
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
// <editor-fold desc="Get Set Methods">
|
// <editor-fold desc="Get Set Methods">
|
||||||
/**
|
/**
|
||||||
* Get minimum value
|
* Get minimum value
|
||||||
* @return Minimum value
|
* @return Minimum value
|
||||||
*/
|
*/
|
||||||
public double getMin(){
|
public double getMin(){
|
||||||
return this.min;
|
return this.min;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set minimum value
|
* Set minimum value
|
||||||
* @param value Minimum value
|
* @param value Minimum value
|
||||||
*/
|
*/
|
||||||
public void setMin(double value){
|
public void setMin(double value){
|
||||||
this.min = value;
|
this.min = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get maximum value
|
* Get maximum value
|
||||||
* @return Maximum value
|
* @return Maximum value
|
||||||
*/
|
*/
|
||||||
public double getMax(){
|
public double getMax(){
|
||||||
return this.max;
|
return this.max;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set maximum value
|
* Set maximum value
|
||||||
* @param value Maximum value
|
* @param value Maximum value
|
||||||
*/
|
*/
|
||||||
public void setMax(double value) {
|
public void setMax(double value) {
|
||||||
this.max = value;
|
this.max = value;
|
||||||
}
|
}
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
// <editor-fold desc="Methods">
|
// <editor-fold desc="Methods">
|
||||||
/**
|
/**
|
||||||
* Get data range
|
* Get data range
|
||||||
* @return Data range
|
* @return Data range
|
||||||
*/
|
*/
|
||||||
public double getRange(){
|
public double getRange(){
|
||||||
return this.max - this.min;
|
return this.max - this.min;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get if the data range is zero
|
* Get if the data range is zero
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
public boolean isFixed(){
|
public boolean isFixed(){
|
||||||
return MIMath.doubleEquals(max, min);
|
return MIMath.doubleEquals(max, min);
|
||||||
}
|
}
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,16 +13,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.meteoinfo.data;
|
package org.meteoinfo.data;
|
||||||
|
|
||||||
import org.meteoinfo.math.ArrayUtil;
|
|
||||||
import org.meteoinfo.math.ArrayMath;
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.meteoinfo.global.Extent;
|
|
||||||
import org.meteoinfo.global.MIMath;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -31,6 +28,10 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
|
import org.meteoinfo.common.Extent;
|
||||||
|
import org.meteoinfo.common.MIMath;
|
||||||
|
import org.meteoinfo.math.ArrayMath;
|
||||||
|
import org.meteoinfo.math.ArrayUtil;
|
||||||
import org.meteoinfo.ndarray.*;
|
import org.meteoinfo.ndarray.*;
|
||||||
import org.meteoinfo.ndarray.util.BigDecimalUtil;
|
import org.meteoinfo.ndarray.util.BigDecimalUtil;
|
||||||
import org.meteoinfo.data.meteodata.GridDataSetting;
|
import org.meteoinfo.data.meteodata.GridDataSetting;
|
||||||
|
|||||||
@ -14,10 +14,12 @@
|
|||||||
package org.meteoinfo.data;
|
package org.meteoinfo.data;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
|
||||||
|
import org.meteoinfo.common.Extent;
|
||||||
|
import org.meteoinfo.common.MIMath;
|
||||||
|
import org.meteoinfo.common.PointD;
|
||||||
import org.meteoinfo.geoprocess.GeoComputation;
|
import org.meteoinfo.geoprocess.GeoComputation;
|
||||||
import org.meteoinfo.global.Extent;
|
|
||||||
import org.meteoinfo.global.MIMath;
|
|
||||||
import org.meteoinfo.global.PointD;
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|||||||
@ -1,164 +1,165 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package org.meteoinfo.data;
|
package org.meteoinfo.data;
|
||||||
|
|
||||||
import org.meteoinfo.math.ArrayMath;
|
import java.util.ArrayList;
|
||||||
import java.util.ArrayList;
|
import java.util.Iterator;
|
||||||
import java.util.Iterator;
|
import java.util.List;
|
||||||
import java.util.List;
|
|
||||||
import org.meteoinfo.ndarray.Array;
|
import org.meteoinfo.math.ArrayMath;
|
||||||
|
import org.meteoinfo.ndarray.Array;
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
* @author Yaqiang Wang
|
*
|
||||||
*/
|
* @author Yaqiang Wang
|
||||||
public class SeriesUtil {
|
*/
|
||||||
|
public class SeriesUtil {
|
||||||
/**
|
|
||||||
* Get indices
|
/**
|
||||||
* @param index Index array
|
* Get indices
|
||||||
* @param labels Labels
|
* @param index Index array
|
||||||
* @return Indices
|
* @param labels Labels
|
||||||
*/
|
* @return Indices
|
||||||
public static Object[] getIndices(List<Object> index, Array labels) {
|
*/
|
||||||
return getIndices(index, ArrayMath.asList(labels));
|
public static Object[] getIndices(List<Object> index, Array labels) {
|
||||||
}
|
return getIndices(index, ArrayMath.asList(labels));
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get indices
|
/**
|
||||||
* @param index Index array
|
* Get indices
|
||||||
* @param labels Labels
|
* @param index Index array
|
||||||
* @return Indices
|
* @param labels Labels
|
||||||
*/
|
* @return Indices
|
||||||
public static Object[] getIndices(Array index, Array labels) {
|
*/
|
||||||
return getIndices(ArrayMath.asList(index), ArrayMath.asList(labels));
|
public static Object[] getIndices(Array index, Array labels) {
|
||||||
}
|
return getIndices(ArrayMath.asList(index), ArrayMath.asList(labels));
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get indices
|
/**
|
||||||
* @param index Index array
|
* Get indices
|
||||||
* @param labels Labels
|
* @param index Index array
|
||||||
* @return Indices
|
* @param labels Labels
|
||||||
*/
|
* @return Indices
|
||||||
public static Object[] getIndices(List<Object> index, List<Object> labels) {
|
*/
|
||||||
List<Integer> r = new ArrayList<>();
|
public static Object[] getIndices(List<Object> index, List<Object> labels) {
|
||||||
List<Object> rIndex = new ArrayList<>();
|
List<Integer> r = new ArrayList<>();
|
||||||
List<Integer> rData = new ArrayList<>();
|
List<Object> rIndex = new ArrayList<>();
|
||||||
List<Object> rrIndex = new ArrayList<>();
|
List<Integer> rData = new ArrayList<>();
|
||||||
Object[] rr;
|
List<Object> rrIndex = new ArrayList<>();
|
||||||
List<Integer> r1;
|
Object[] rr;
|
||||||
List<Object> rIndex1;
|
List<Integer> r1;
|
||||||
for (Object l : labels){
|
List<Object> rIndex1;
|
||||||
rr = getIndices(index, l);
|
for (Object l : labels){
|
||||||
r1 = (ArrayList<Integer>)rr[0];
|
rr = getIndices(index, l);
|
||||||
rIndex1 = (ArrayList<Object>)rr[1];
|
r1 = (ArrayList<Integer>)rr[0];
|
||||||
if (r1.isEmpty()){
|
rIndex1 = (ArrayList<Object>)rr[1];
|
||||||
rData.add(0);
|
if (r1.isEmpty()){
|
||||||
rrIndex.add(l);
|
rData.add(0);
|
||||||
} else {
|
rrIndex.add(l);
|
||||||
r.addAll(r1);
|
} else {
|
||||||
rIndex.addAll(rIndex1);
|
r.addAll(r1);
|
||||||
for (Iterator<Integer> it = r1.iterator(); it.hasNext();) {
|
rIndex.addAll(rIndex1);
|
||||||
it.next();
|
for (Iterator<Integer> it = r1.iterator(); it.hasNext();) {
|
||||||
rData.add(1);
|
it.next();
|
||||||
rrIndex.add(l);
|
rData.add(1);
|
||||||
}
|
rrIndex.add(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return new Object[]{r, rIndex, rData, rrIndex};
|
|
||||||
}
|
return new Object[]{r, rIndex, rData, rrIndex};
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get indices
|
/**
|
||||||
* @param index Index array
|
* Get indices
|
||||||
* @param label Label
|
* @param index Index array
|
||||||
* @return Indices
|
* @param label Label
|
||||||
*/
|
* @return Indices
|
||||||
public static Object[] getIndices(List<Object> index, Object label) {
|
*/
|
||||||
List<Integer> r = new ArrayList<>();
|
public static Object[] getIndices(List<Object> index, Object label) {
|
||||||
List<Object> rIndex = new ArrayList<>();
|
List<Integer> r = new ArrayList<>();
|
||||||
for (int i = 0; i < index.size(); i++){
|
List<Object> rIndex = new ArrayList<>();
|
||||||
if (index.get(i).equals(label)){
|
for (int i = 0; i < index.size(); i++){
|
||||||
r.add(i);
|
if (index.get(i).equals(label)){
|
||||||
rIndex.add(index.get(i));
|
r.add(i);
|
||||||
}
|
rIndex.add(index.get(i));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return new Object[]{r, rIndex};
|
|
||||||
}
|
return new Object[]{r, rIndex};
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Sub list by index
|
/**
|
||||||
* @param list The list
|
* Sub list by index
|
||||||
* @param index The index
|
* @param list The list
|
||||||
* @return Result list
|
* @param index The index
|
||||||
*/
|
* @return Result list
|
||||||
public static List subList(List list, List<Integer> index){
|
*/
|
||||||
List r = new ArrayList<>();
|
public static List subList(List list, List<Integer> index){
|
||||||
for (int i : index){
|
List r = new ArrayList<>();
|
||||||
r.add(list.get(i));
|
for (int i : index){
|
||||||
}
|
r.add(list.get(i));
|
||||||
|
}
|
||||||
return r;
|
|
||||||
}
|
return r;
|
||||||
|
}
|
||||||
// /**
|
|
||||||
// * Fill key list
|
// /**
|
||||||
// * @param data Valid data array
|
// * Fill key list
|
||||||
// * @param rrdata Result data flags
|
// * @param data Valid data array
|
||||||
// * @return Result data array with same length as key list
|
// * @param rrdata Result data flags
|
||||||
// */
|
// * @return Result data array with same length as key list
|
||||||
// public static Array fillKeyList(Array data, List<Integer> rrdata){
|
// */
|
||||||
// Array kdata = Array.factory(data.getDataType(), new int[]{rrdata.size()});
|
// public static Array fillKeyList(Array data, List<Integer> rrdata){
|
||||||
// Object nanObj = null;
|
// Array kdata = Array.factory(data.getDataType(), new int[]{rrdata.size()});
|
||||||
// switch (data.getDataType()){
|
// Object nanObj = null;
|
||||||
// case FLOAT:
|
// switch (data.getDataType()){
|
||||||
// nanObj = Float.NaN;
|
// case FLOAT:
|
||||||
// break;
|
// nanObj = Float.NaN;
|
||||||
// case DOUBLE:
|
// break;
|
||||||
// nanObj = Double.NaN;
|
// case DOUBLE:
|
||||||
// break;
|
// nanObj = Double.NaN;
|
||||||
// }
|
// break;
|
||||||
// int idx = 0;
|
// }
|
||||||
// int i = 0;
|
// int idx = 0;
|
||||||
// for (int f : rrdata){
|
// int i = 0;
|
||||||
// if (f == 0)
|
// for (int f : rrdata){
|
||||||
// kdata.setObject(i, nanObj);
|
// if (f == 0)
|
||||||
// else {
|
// kdata.setObject(i, nanObj);
|
||||||
// kdata.setObject(i, data.getObject(idx));
|
// else {
|
||||||
// idx += 1;
|
// kdata.setObject(i, data.getObject(idx));
|
||||||
// }
|
// idx += 1;
|
||||||
// i += 1;
|
// }
|
||||||
// }
|
// i += 1;
|
||||||
//
|
// }
|
||||||
// return kdata;
|
//
|
||||||
// }
|
// return kdata;
|
||||||
|
// }
|
||||||
/**
|
|
||||||
* Fill key list
|
/**
|
||||||
* @param data Valid data array
|
* Fill key list
|
||||||
* @param rrdata Result data flags
|
* @param data Valid data array
|
||||||
* @return Result data array with same length as key list
|
* @param rrdata Result data flags
|
||||||
*/
|
* @return Result data array with same length as key list
|
||||||
public static Array fillKeyList(Array data, List<Integer> rrdata){
|
*/
|
||||||
Array kdata = Array.factory(data.getDataType(), new int[]{rrdata.size()});
|
public static Array fillKeyList(Array data, List<Integer> rrdata){
|
||||||
int idx = 0;
|
Array kdata = Array.factory(data.getDataType(), new int[]{rrdata.size()});
|
||||||
int i = 0;
|
int idx = 0;
|
||||||
for (int f : rrdata){
|
int i = 0;
|
||||||
if (f == 0)
|
for (int f : rrdata){
|
||||||
kdata.setObject(i, Double.NaN);
|
if (f == 0)
|
||||||
else {
|
kdata.setObject(i, Double.NaN);
|
||||||
kdata.setObject(i, data.getObject(idx));
|
else {
|
||||||
idx += 1;
|
kdata.setObject(i, data.getObject(idx));
|
||||||
}
|
idx += 1;
|
||||||
i += 1;
|
}
|
||||||
}
|
i += 1;
|
||||||
|
}
|
||||||
return kdata;
|
|
||||||
}
|
return kdata;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|||||||
@ -17,17 +17,19 @@ import java.io.BufferedWriter;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.meteoinfo.common.Extent;
|
||||||
|
import org.meteoinfo.common.MIMath;
|
||||||
|
import org.meteoinfo.common.PointD;
|
||||||
import org.meteoinfo.data.meteodata.GridDataSetting;
|
import org.meteoinfo.data.meteodata.GridDataSetting;
|
||||||
import org.meteoinfo.geoprocess.analysis.InterpolationSetting;
|
import org.meteoinfo.geoprocess.analysis.InterpolationSetting;
|
||||||
import org.meteoinfo.global.Extent;
|
|
||||||
import org.meteoinfo.global.MIMath;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.meteoinfo.geoprocess.GeoComputation;
|
import org.meteoinfo.geoprocess.GeoComputation;
|
||||||
import org.meteoinfo.global.DataConvert;
|
import org.meteoinfo.global.DataConvert;
|
||||||
import org.meteoinfo.global.PointD;
|
|
||||||
import org.meteoinfo.layer.VectorLayer;
|
import org.meteoinfo.layer.VectorLayer;
|
||||||
import org.meteoinfo.projection.info.ProjectionInfo;
|
import org.meteoinfo.projection.info.ProjectionInfo;
|
||||||
import org.meteoinfo.projection.Reproject;
|
import org.meteoinfo.projection.Reproject;
|
||||||
|
|||||||
@ -1,202 +1,203 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package org.meteoinfo.data;
|
package org.meteoinfo.data;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import org.meteoinfo.global.util.GlobalUtil;
|
|
||||||
import org.meteoinfo.ndarray.DataType;
|
import org.meteoinfo.common.util.GlobalUtil;
|
||||||
import org.meteoinfo.projection.KnownCoordinateSystems;
|
import org.meteoinfo.ndarray.DataType;
|
||||||
import org.meteoinfo.projection.info.ProjectionInfo;
|
import org.meteoinfo.projection.KnownCoordinateSystems;
|
||||||
|
import org.meteoinfo.projection.info.ProjectionInfo;
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
* @author yaqiang
|
*
|
||||||
*/
|
* @author yaqiang
|
||||||
public class StationTableData extends TableData{
|
*/
|
||||||
// <editor-fold desc="Variables">
|
public class StationTableData extends TableData{
|
||||||
private ProjectionInfo projInfo;
|
// <editor-fold desc="Variables">
|
||||||
private int stIdx;
|
private ProjectionInfo projInfo;
|
||||||
private int lonIdx;
|
private int stIdx;
|
||||||
private int latIdx;
|
private int lonIdx;
|
||||||
// </editor-fold>
|
private int latIdx;
|
||||||
// <editor-fold desc="Constructor">
|
// </editor-fold>
|
||||||
/**
|
// <editor-fold desc="Constructor">
|
||||||
* Constructor
|
/**
|
||||||
*/
|
* Constructor
|
||||||
public StationTableData(){
|
*/
|
||||||
this.projInfo = KnownCoordinateSystems.geographic.world.WGS1984;
|
public StationTableData(){
|
||||||
stIdx = 0;
|
this.projInfo = KnownCoordinateSystems.geographic.world.WGS1984;
|
||||||
lonIdx = 1;
|
stIdx = 0;
|
||||||
latIdx = 2;
|
lonIdx = 1;
|
||||||
}
|
latIdx = 2;
|
||||||
// </editor-fold>
|
}
|
||||||
// <editor-fold desc="Get Set Methods">
|
// </editor-fold>
|
||||||
/**
|
// <editor-fold desc="Get Set Methods">
|
||||||
* Get projection info
|
/**
|
||||||
* @return Projection info
|
* Get projection info
|
||||||
*/
|
* @return Projection info
|
||||||
public ProjectionInfo getProjectionInfo(){
|
*/
|
||||||
return this.projInfo;
|
public ProjectionInfo getProjectionInfo(){
|
||||||
}
|
return this.projInfo;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set projection info
|
/**
|
||||||
* @param value Projection info
|
* Set projection info
|
||||||
*/
|
* @param value Projection info
|
||||||
public void setProjectionInfo(ProjectionInfo value){
|
*/
|
||||||
this.projInfo = value;
|
public void setProjectionInfo(ProjectionInfo value){
|
||||||
}
|
this.projInfo = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get station column index
|
/**
|
||||||
* @return Station column index
|
* Get station column index
|
||||||
*/
|
* @return Station column index
|
||||||
public int getStationIndex(){
|
*/
|
||||||
return this.stIdx;
|
public int getStationIndex(){
|
||||||
}
|
return this.stIdx;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set station column index
|
/**
|
||||||
* @param value Statin column index
|
* Set station column index
|
||||||
*/
|
* @param value Statin column index
|
||||||
public void setStationIndex(int value){
|
*/
|
||||||
this.stIdx = value;
|
public void setStationIndex(int value){
|
||||||
}
|
this.stIdx = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get longitude column index
|
/**
|
||||||
* @return Longitude column index
|
* Get longitude column index
|
||||||
*/
|
* @return Longitude column index
|
||||||
public int getLonIndex(){
|
*/
|
||||||
return this.lonIdx;
|
public int getLonIndex(){
|
||||||
}
|
return this.lonIdx;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set longitude column index
|
/**
|
||||||
* @param value Longitude column index
|
* Set longitude column index
|
||||||
*/
|
* @param value Longitude column index
|
||||||
public void setLonIndex(int value){
|
*/
|
||||||
this.latIdx = value;
|
public void setLonIndex(int value){
|
||||||
}
|
this.latIdx = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get latitude column index
|
/**
|
||||||
* @return Latitude column index
|
* Get latitude column index
|
||||||
*/
|
* @return Latitude column index
|
||||||
public int getLatIndex(){
|
*/
|
||||||
return this.latIdx;
|
public int getLatIndex(){
|
||||||
}
|
return this.latIdx;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set Latitude column index
|
/**
|
||||||
* @param value Latitude column index
|
* Set Latitude column index
|
||||||
*/
|
* @param value Latitude column index
|
||||||
public void setLatIndex(int value){
|
*/
|
||||||
this.lonIdx = value;
|
public void setLatIndex(int value){
|
||||||
}
|
this.lonIdx = value;
|
||||||
// </editor-fold>
|
}
|
||||||
// <editor-fold desc="Methods">
|
// </editor-fold>
|
||||||
/**
|
// <editor-fold desc="Methods">
|
||||||
* Read data table from ASCII file
|
/**
|
||||||
*
|
* Read data table from ASCII file
|
||||||
* @param fileName File name
|
*
|
||||||
* @param lonIdx Longitude index
|
* @param fileName File name
|
||||||
* @param latIdx Latitude index
|
* @param lonIdx Longitude index
|
||||||
* @throws java.io.FileNotFoundException
|
* @param latIdx Latitude index
|
||||||
*/
|
* @throws java.io.FileNotFoundException
|
||||||
public void readASCIIFile(String fileName, int lonIdx, int latIdx) throws FileNotFoundException, IOException, Exception {
|
*/
|
||||||
this.readASCIIFile(fileName, 0, lonIdx, latIdx);
|
public void readASCIIFile(String fileName, int lonIdx, int latIdx) throws FileNotFoundException, IOException, Exception {
|
||||||
}
|
this.readASCIIFile(fileName, 0, lonIdx, latIdx);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Read data table from ASCII file
|
/**
|
||||||
*
|
* Read data table from ASCII file
|
||||||
* @param fileName File name
|
*
|
||||||
* @param stIdx Station column index
|
* @param fileName File name
|
||||||
* @param lonIdx Longitude column index
|
* @param stIdx Station column index
|
||||||
* @param latIdx Latitude column index
|
* @param lonIdx Longitude column index
|
||||||
* @throws java.io.FileNotFoundException
|
* @param latIdx Latitude column index
|
||||||
*/
|
* @throws java.io.FileNotFoundException
|
||||||
public void readASCIIFile(String fileName, int stIdx, int lonIdx, int latIdx) throws FileNotFoundException, IOException, Exception {
|
*/
|
||||||
this.lonIdx = lonIdx;
|
public void readASCIIFile(String fileName, int stIdx, int lonIdx, int latIdx) throws FileNotFoundException, IOException, Exception {
|
||||||
this.latIdx = latIdx;
|
this.lonIdx = lonIdx;
|
||||||
//DataTable dTable = new DataTable();
|
this.latIdx = latIdx;
|
||||||
|
//DataTable dTable = new DataTable();
|
||||||
BufferedReader sr = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "utf-8"));
|
|
||||||
String title = sr.readLine().trim();
|
BufferedReader sr = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "utf-8"));
|
||||||
//Determine separator
|
String title = sr.readLine().trim();
|
||||||
String separator = GlobalUtil.getDelimiter(title);
|
//Determine separator
|
||||||
String[] titleArray = GlobalUtil.split(title, separator);
|
String separator = GlobalUtil.getDelimiter(title);
|
||||||
if (titleArray.length < 2) {
|
String[] titleArray = GlobalUtil.split(title, separator);
|
||||||
JOptionPane.showMessageDialog(null, "File Format Error!");
|
if (titleArray.length < 2) {
|
||||||
sr.close();
|
JOptionPane.showMessageDialog(null, "File Format Error!");
|
||||||
} else {
|
sr.close();
|
||||||
//Get fields
|
} else {
|
||||||
List<Integer> dataIdxs = new ArrayList<>();
|
//Get fields
|
||||||
String fieldName;
|
List<Integer> dataIdxs = new ArrayList<>();
|
||||||
for (int i = 0; i < titleArray.length; i++) {
|
String fieldName;
|
||||||
fieldName = titleArray[i];
|
for (int i = 0; i < titleArray.length; i++) {
|
||||||
if (i == lonIdx || i == latIdx)
|
fieldName = titleArray[i];
|
||||||
this.addColumn(fieldName, DataType.FLOAT);
|
if (i == lonIdx || i == latIdx)
|
||||||
else
|
this.addColumn(fieldName, DataType.FLOAT);
|
||||||
this.addColumn(fieldName, DataType.STRING);
|
else
|
||||||
dataIdxs.add(i);
|
this.addColumn(fieldName, DataType.STRING);
|
||||||
}
|
dataIdxs.add(i);
|
||||||
|
}
|
||||||
String[] dataArray;
|
|
||||||
int rn = 0;
|
String[] dataArray;
|
||||||
String line = sr.readLine();
|
int rn = 0;
|
||||||
while (line != null) {
|
String line = sr.readLine();
|
||||||
line = line.trim();
|
while (line != null) {
|
||||||
if (line.isEmpty()) {
|
line = line.trim();
|
||||||
continue;
|
if (line.isEmpty()) {
|
||||||
}
|
continue;
|
||||||
dataArray = GlobalUtil.split(line, separator);
|
}
|
||||||
this.addRow();
|
dataArray = GlobalUtil.split(line, separator);
|
||||||
int cn = 0;
|
this.addRow();
|
||||||
for (int idx : dataIdxs) {
|
int cn = 0;
|
||||||
if (idx == lonIdx || idx == latIdx)
|
for (int idx : dataIdxs) {
|
||||||
this.setValue(rn, cn, Float.parseFloat(dataArray[idx]));
|
if (idx == lonIdx || idx == latIdx)
|
||||||
else
|
this.setValue(rn, cn, Float.parseFloat(dataArray[idx]));
|
||||||
this.setValue(rn, cn, dataArray[idx]);
|
else
|
||||||
cn++;
|
this.setValue(rn, cn, dataArray[idx]);
|
||||||
}
|
cn++;
|
||||||
|
}
|
||||||
rn += 1;
|
|
||||||
line = sr.readLine();
|
rn += 1;
|
||||||
}
|
line = sr.readLine();
|
||||||
|
}
|
||||||
//dataTable = dTable;
|
|
||||||
sr.close();
|
//dataTable = dTable;
|
||||||
}
|
sr.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Clone
|
/**
|
||||||
* @return Cloned StationTableData object
|
* Clone
|
||||||
*/
|
* @return Cloned StationTableData object
|
||||||
@Override
|
*/
|
||||||
public Object clone(){
|
@Override
|
||||||
StationTableData std = new StationTableData();
|
public Object clone(){
|
||||||
std = (StationTableData)super.clone();
|
StationTableData std = new StationTableData();
|
||||||
//std.dataTable = (DataTable)this.dataTable.clone();
|
std = (StationTableData)super.clone();
|
||||||
std.missingValue = this.missingValue;
|
//std.dataTable = (DataTable)this.dataTable.clone();
|
||||||
std.projInfo = this.projInfo;
|
std.missingValue = this.missingValue;
|
||||||
std.stIdx = this.stIdx;
|
std.projInfo = this.projInfo;
|
||||||
std.lonIdx = this.lonIdx;
|
std.stIdx = this.stIdx;
|
||||||
std.latIdx = this.latIdx;
|
std.lonIdx = this.lonIdx;
|
||||||
|
std.latIdx = this.latIdx;
|
||||||
return std;
|
|
||||||
}
|
return std;
|
||||||
// </editor-fold>
|
}
|
||||||
}
|
// </editor-fold>
|
||||||
|
}
|
||||||
|
|||||||
@ -26,9 +26,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
|
import org.meteoinfo.common.MIMath;
|
||||||
|
import org.meteoinfo.common.util.GlobalUtil;
|
||||||
import org.meteoinfo.data.analysis.Statistics;
|
import org.meteoinfo.data.analysis.Statistics;
|
||||||
import org.meteoinfo.global.MIMath;
|
|
||||||
import org.meteoinfo.global.util.GlobalUtil;
|
|
||||||
import org.meteoinfo.ndarray.DataType;
|
import org.meteoinfo.ndarray.DataType;
|
||||||
import org.meteoinfo.table.DataColumn;
|
import org.meteoinfo.table.DataColumn;
|
||||||
import org.meteoinfo.table.DataRow;
|
import org.meteoinfo.table.DataRow;
|
||||||
|
|||||||
@ -15,8 +15,9 @@ import java.time.format.DateTimeFormatter;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.meteoinfo.common.util.GlobalUtil;
|
||||||
import org.meteoinfo.data.analysis.Statistics;
|
import org.meteoinfo.data.analysis.Statistics;
|
||||||
import org.meteoinfo.global.util.GlobalUtil;
|
|
||||||
import org.meteoinfo.table.DataColumn;
|
import org.meteoinfo.table.DataColumn;
|
||||||
import org.meteoinfo.table.DataRow;
|
import org.meteoinfo.table.DataRow;
|
||||||
import org.meteoinfo.table.DataTable;
|
import org.meteoinfo.table.DataTable;
|
||||||
|
|||||||
@ -17,11 +17,12 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
|
import org.meteoinfo.common.util.GlobalUtil;
|
||||||
import org.meteoinfo.data.analysis.Statistics;
|
import org.meteoinfo.data.analysis.Statistics;
|
||||||
import org.meteoinfo.table.DataColumn;
|
import org.meteoinfo.table.DataColumn;
|
||||||
import org.meteoinfo.table.DataRow;
|
import org.meteoinfo.table.DataRow;
|
||||||
import org.meteoinfo.table.DataTable;
|
import org.meteoinfo.table.DataTable;
|
||||||
import org.meteoinfo.global.util.GlobalUtil;
|
|
||||||
import org.meteoinfo.ndarray.DataType;
|
import org.meteoinfo.ndarray.DataType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,342 +1,343 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package org.meteoinfo.data;
|
package org.meteoinfo.data;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import org.meteoinfo.common.Extent;
|
||||||
import java.util.Arrays;
|
import org.meteoinfo.common.MIMath;
|
||||||
import java.util.List;
|
|
||||||
import org.meteoinfo.global.Extent;
|
import java.util.ArrayList;
|
||||||
import org.meteoinfo.global.MIMath;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
* @author wyq
|
*
|
||||||
*/
|
* @author wyq
|
||||||
public class XYArrayDataset extends XYDataset {
|
*/
|
||||||
|
public class XYArrayDataset extends XYDataset {
|
||||||
// <editor-fold desc="Variables">
|
|
||||||
|
// <editor-fold desc="Variables">
|
||||||
private final double[][] xValues;
|
|
||||||
private final double[][] yValues;
|
private final double[][] xValues;
|
||||||
private final int seriesCount;
|
private final double[][] yValues;
|
||||||
private final int itemCount;
|
private final int seriesCount;
|
||||||
private String[] seriesKeys;
|
private final int itemCount;
|
||||||
|
private String[] seriesKeys;
|
||||||
// </editor-fold>
|
|
||||||
// <editor-fold desc="Constructor">
|
// </editor-fold>
|
||||||
|
// <editor-fold desc="Constructor">
|
||||||
/**
|
|
||||||
* Constructor
|
/**
|
||||||
*
|
* Constructor
|
||||||
* @param seriesNum Series number
|
*
|
||||||
* @param itemNum Item number
|
* @param seriesNum Series number
|
||||||
*/
|
* @param itemNum Item number
|
||||||
public XYArrayDataset(int seriesNum, int itemNum) {
|
*/
|
||||||
this.seriesCount = seriesNum;
|
public XYArrayDataset(int seriesNum, int itemNum) {
|
||||||
this.itemCount = itemNum;
|
this.seriesCount = seriesNum;
|
||||||
xValues = new double[seriesNum][itemNum];
|
this.itemCount = itemNum;
|
||||||
yValues = new double[seriesNum][itemNum];
|
xValues = new double[seriesNum][itemNum];
|
||||||
seriesKeys = new String[seriesNum];
|
yValues = new double[seriesNum][itemNum];
|
||||||
}
|
seriesKeys = new String[seriesNum];
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Constructor
|
/**
|
||||||
*
|
* Constructor
|
||||||
* @param xdata X station data
|
*
|
||||||
* @param ydata Y station data
|
* @param xdata X station data
|
||||||
* @param seriesKey Series key
|
* @param ydata Y station data
|
||||||
*/
|
* @param seriesKey Series key
|
||||||
public XYArrayDataset(StationData xdata, StationData ydata, String seriesKey) {
|
*/
|
||||||
List<double[]> vdata = new ArrayList<>();
|
public XYArrayDataset(StationData xdata, StationData ydata, String seriesKey) {
|
||||||
double v1, v2;
|
List<double[]> vdata = new ArrayList<>();
|
||||||
for (int i = 0; i < xdata.getStNum(); i++) {
|
double v1, v2;
|
||||||
v1 = xdata.getValue(i);
|
for (int i = 0; i < xdata.getStNum(); i++) {
|
||||||
if (MIMath.doubleEquals(v1, xdata.missingValue)) {
|
v1 = xdata.getValue(i);
|
||||||
continue;
|
if (MIMath.doubleEquals(v1, xdata.missingValue)) {
|
||||||
}
|
continue;
|
||||||
v2 = ydata.getValue(i);
|
}
|
||||||
if (MIMath.doubleEquals(v2, ydata.missingValue)) {
|
v2 = ydata.getValue(i);
|
||||||
continue;
|
if (MIMath.doubleEquals(v2, ydata.missingValue)) {
|
||||||
}
|
continue;
|
||||||
vdata.add(new double[]{v1, v2});
|
}
|
||||||
}
|
vdata.add(new double[]{v1, v2});
|
||||||
seriesCount = 1;
|
}
|
||||||
seriesKeys = new String[seriesCount];
|
seriesCount = 1;
|
||||||
seriesKeys[0] = seriesKey;
|
seriesKeys = new String[seriesCount];
|
||||||
itemCount = vdata.size();
|
seriesKeys[0] = seriesKey;
|
||||||
xValues = new double[seriesCount][itemCount];
|
itemCount = vdata.size();
|
||||||
yValues = new double[seriesCount][itemCount];
|
xValues = new double[seriesCount][itemCount];
|
||||||
for (int i = 0; i < seriesCount; i++) {
|
yValues = new double[seriesCount][itemCount];
|
||||||
for (int j = 0; j < itemCount; j++) {
|
for (int i = 0; i < seriesCount; i++) {
|
||||||
xValues[i][j] = vdata.get(j)[0];
|
for (int j = 0; j < itemCount; j++) {
|
||||||
yValues[i][j] = vdata.get(j)[1];
|
xValues[i][j] = vdata.get(j)[0];
|
||||||
}
|
yValues[i][j] = vdata.get(j)[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Constructor
|
/**
|
||||||
*
|
* Constructor
|
||||||
* @param xdata X data
|
*
|
||||||
* @param ydata Y data
|
* @param xdata X data
|
||||||
* @param seriesKey Series key
|
* @param ydata Y data
|
||||||
*/
|
* @param seriesKey Series key
|
||||||
public XYArrayDataset(List<Number> xdata, List<Number> ydata, String seriesKey) {
|
*/
|
||||||
List<Double> nxdata = new ArrayList<>();
|
public XYArrayDataset(List<Number> xdata, List<Number> ydata, String seriesKey) {
|
||||||
List<Double> nydata = new ArrayList<>();
|
List<Double> nxdata = new ArrayList<>();
|
||||||
for (int i = 0; i < xdata.size(); i++) {
|
List<Double> nydata = new ArrayList<>();
|
||||||
nxdata.add(Double.parseDouble(xdata.get(i).toString()));
|
for (int i = 0; i < xdata.size(); i++) {
|
||||||
nydata.add(Double.parseDouble(ydata.get(i).toString()));
|
nxdata.add(Double.parseDouble(xdata.get(i).toString()));
|
||||||
}
|
nydata.add(Double.parseDouble(ydata.get(i).toString()));
|
||||||
|
}
|
||||||
List<double[]> vdata = new ArrayList<>();
|
|
||||||
double v1, v2;
|
List<double[]> vdata = new ArrayList<>();
|
||||||
for (int i = 0; i < xdata.size(); i++) {
|
double v1, v2;
|
||||||
v1 = nxdata.get(i);
|
for (int i = 0; i < xdata.size(); i++) {
|
||||||
v2 = nydata.get(i);
|
v1 = nxdata.get(i);
|
||||||
vdata.add(new double[]{v1, v2});
|
v2 = nydata.get(i);
|
||||||
}
|
vdata.add(new double[]{v1, v2});
|
||||||
seriesCount = 1;
|
}
|
||||||
seriesKeys = new String[seriesCount];
|
seriesCount = 1;
|
||||||
seriesKeys[0] = seriesKey;
|
seriesKeys = new String[seriesCount];
|
||||||
itemCount = vdata.size();
|
seriesKeys[0] = seriesKey;
|
||||||
xValues = new double[seriesCount][itemCount];
|
itemCount = vdata.size();
|
||||||
yValues = new double[seriesCount][itemCount];
|
xValues = new double[seriesCount][itemCount];
|
||||||
for (int i = 0; i < seriesCount; i++) {
|
yValues = new double[seriesCount][itemCount];
|
||||||
for (int j = 0; j < itemCount; j++) {
|
for (int i = 0; i < seriesCount; i++) {
|
||||||
xValues[i][j] = vdata.get(j)[0];
|
for (int j = 0; j < itemCount; j++) {
|
||||||
yValues[i][j] = vdata.get(j)[1];
|
xValues[i][j] = vdata.get(j)[0];
|
||||||
}
|
yValues[i][j] = vdata.get(j)[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// </editor-fold>
|
|
||||||
// <editor-fold desc="Get Set Methods">
|
// </editor-fold>
|
||||||
|
// <editor-fold desc="Get Set Methods">
|
||||||
/**
|
|
||||||
* Get series count
|
/**
|
||||||
* @return Series count
|
* Get series count
|
||||||
*/
|
* @return Series count
|
||||||
@Override
|
*/
|
||||||
public int getSeriesCount() {
|
@Override
|
||||||
return this.seriesCount;
|
public int getSeriesCount() {
|
||||||
}
|
return this.seriesCount;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get series key by index
|
/**
|
||||||
* @param seriesIdx Series index
|
* Get series key by index
|
||||||
* @return Series key
|
* @param seriesIdx Series index
|
||||||
*/
|
* @return Series key
|
||||||
@Override
|
*/
|
||||||
public String getSeriesKey(int seriesIdx) {
|
@Override
|
||||||
return seriesKeys[seriesIdx];
|
public String getSeriesKey(int seriesIdx) {
|
||||||
}
|
return seriesKeys[seriesIdx];
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set series key by index
|
/**
|
||||||
* @param seriesIdx Series index
|
* Set series key by index
|
||||||
* @param seriesKey Series key
|
* @param seriesIdx Series index
|
||||||
*/
|
* @param seriesKey Series key
|
||||||
@Override
|
*/
|
||||||
public void setSeriesKey(int seriesIdx, String seriesKey){
|
@Override
|
||||||
this.seriesKeys[seriesIdx] = seriesKey;
|
public void setSeriesKey(int seriesIdx, String seriesKey){
|
||||||
}
|
this.seriesKeys[seriesIdx] = seriesKey;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get item count
|
/**
|
||||||
* @return Item count
|
* Get item count
|
||||||
*/
|
* @return Item count
|
||||||
@Override
|
*/
|
||||||
public int getItemCount() {
|
@Override
|
||||||
return this.itemCount;
|
public int getItemCount() {
|
||||||
}
|
return this.itemCount;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get item count
|
/**
|
||||||
* @param seriesIdx Series index
|
* Get item count
|
||||||
* @return Item count
|
* @param seriesIdx Series index
|
||||||
*/
|
* @return Item count
|
||||||
@Override
|
*/
|
||||||
public int getItemCount(int seriesIdx){
|
@Override
|
||||||
return this.itemCount;
|
public int getItemCount(int seriesIdx){
|
||||||
}
|
return this.itemCount;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get x values
|
/**
|
||||||
* @param seriesIdx Series index
|
* Get x values
|
||||||
* @return X values
|
* @param seriesIdx Series index
|
||||||
*/
|
* @return X values
|
||||||
@Override
|
*/
|
||||||
public double[] getXValues(int seriesIdx){
|
@Override
|
||||||
return this.xValues[seriesIdx];
|
public double[] getXValues(int seriesIdx){
|
||||||
}
|
return this.xValues[seriesIdx];
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get y values
|
/**
|
||||||
* @param seriesIdx Series index
|
* Get y values
|
||||||
* @return Y values
|
* @param seriesIdx Series index
|
||||||
*/
|
* @return Y values
|
||||||
@Override
|
*/
|
||||||
public double[] getYValues(int seriesIdx){
|
@Override
|
||||||
return this.yValues[seriesIdx];
|
public double[] getYValues(int seriesIdx){
|
||||||
}
|
return this.yValues[seriesIdx];
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get x value
|
/**
|
||||||
* @param seriesIdx Series index
|
* Get x value
|
||||||
* @param itemIdx Item index
|
* @param seriesIdx Series index
|
||||||
* @return X value
|
* @param itemIdx Item index
|
||||||
*/
|
* @return X value
|
||||||
@Override
|
*/
|
||||||
public double getX(int seriesIdx, int itemIdx) {
|
@Override
|
||||||
return xValues[seriesIdx][itemIdx];
|
public double getX(int seriesIdx, int itemIdx) {
|
||||||
}
|
return xValues[seriesIdx][itemIdx];
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set x value
|
/**
|
||||||
* @param seriesIdx Series index
|
* Set x value
|
||||||
* @param itemIdx Item index
|
* @param seriesIdx Series index
|
||||||
* @param value X value
|
* @param itemIdx Item index
|
||||||
*/
|
* @param value X value
|
||||||
@Override
|
*/
|
||||||
public void setX(int seriesIdx, int itemIdx, double value){
|
@Override
|
||||||
xValues[seriesIdx][itemIdx] = value;
|
public void setX(int seriesIdx, int itemIdx, double value){
|
||||||
}
|
xValues[seriesIdx][itemIdx] = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get Y value
|
/**
|
||||||
* @param seriesIdx Series index
|
* Get Y value
|
||||||
* @param itemIdx Item index
|
* @param seriesIdx Series index
|
||||||
* @return Y value
|
* @param itemIdx Item index
|
||||||
*/
|
* @return Y value
|
||||||
@Override
|
*/
|
||||||
public double getY(int seriesIdx, int itemIdx) {
|
@Override
|
||||||
return yValues[seriesIdx][itemIdx];
|
public double getY(int seriesIdx, int itemIdx) {
|
||||||
}
|
return yValues[seriesIdx][itemIdx];
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set Y value
|
/**
|
||||||
* @param seriesIdx Series index
|
* Set Y value
|
||||||
* @param itemIdx Item index
|
* @param seriesIdx Series index
|
||||||
* @param value Y value
|
* @param itemIdx Item index
|
||||||
*/
|
* @param value Y value
|
||||||
@Override
|
*/
|
||||||
public void setY(int seriesIdx, int itemIdx, double value){
|
@Override
|
||||||
yValues[seriesIdx][itemIdx] = value;
|
public void setY(int seriesIdx, int itemIdx, double value){
|
||||||
}
|
yValues[seriesIdx][itemIdx] = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get series keys
|
/**
|
||||||
* @return Series keys
|
* Get series keys
|
||||||
*/
|
* @return Series keys
|
||||||
@Override
|
*/
|
||||||
public List<String> getSeriesKeys(){
|
@Override
|
||||||
return Arrays.asList(this.seriesKeys);
|
public List<String> getSeriesKeys(){
|
||||||
}
|
return Arrays.asList(this.seriesKeys);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set series keys
|
/**
|
||||||
* @param value Series keys
|
* Set series keys
|
||||||
*/
|
* @param value Series keys
|
||||||
public void setSeriesKeys(String[] value){
|
*/
|
||||||
this.seriesKeys = value;
|
public void setSeriesKeys(String[] value){
|
||||||
}
|
this.seriesKeys = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set series keys
|
/**
|
||||||
* @param value Series keys
|
* Set series keys
|
||||||
*/
|
* @param value Series keys
|
||||||
@Override
|
*/
|
||||||
public void setSeriesKeys(List<String> value){
|
@Override
|
||||||
this.seriesKeys = (String[])value.toArray(new String[value.size()]);
|
public void setSeriesKeys(List<String> value){
|
||||||
}
|
this.seriesKeys = (String[])value.toArray(new String[value.size()]);
|
||||||
|
}
|
||||||
// </editor-fold>
|
|
||||||
// <editor-fold desc="Methods">
|
// </editor-fold>
|
||||||
|
// <editor-fold desc="Methods">
|
||||||
/**
|
|
||||||
* Get data extent
|
/**
|
||||||
* @return Data extent
|
* Get data extent
|
||||||
*/
|
* @return Data extent
|
||||||
@Override
|
*/
|
||||||
public Extent getDataExtent() {
|
@Override
|
||||||
Extent cET = new Extent();
|
public Extent getDataExtent() {
|
||||||
double x, y;
|
Extent cET = new Extent();
|
||||||
int n = 0;
|
double x, y;
|
||||||
for (int i = 0; i < this.seriesCount; i++) {
|
int n = 0;
|
||||||
for (int j = 0; j < this.itemCount; j++) {
|
for (int i = 0; i < this.seriesCount; i++) {
|
||||||
x = xValues[i][j];
|
for (int j = 0; j < this.itemCount; j++) {
|
||||||
y = yValues[i][j];
|
x = xValues[i][j];
|
||||||
if (MIMath.doubleEquals(y, this.getMissingValue()) || MIMath.doubleEquals(x, this.getMissingValue()))
|
y = yValues[i][j];
|
||||||
continue;
|
if (MIMath.doubleEquals(y, this.getMissingValue()) || MIMath.doubleEquals(x, this.getMissingValue()))
|
||||||
if (n == 0) {
|
continue;
|
||||||
cET.minX = x;
|
if (n == 0) {
|
||||||
cET.maxX = x;
|
cET.minX = x;
|
||||||
cET.minY = y;
|
cET.maxX = x;
|
||||||
cET.maxY = y;
|
cET.minY = y;
|
||||||
} else {
|
cET.maxY = y;
|
||||||
if (cET.minX > x) {
|
} else {
|
||||||
cET.minX = x;
|
if (cET.minX > x) {
|
||||||
} else if (cET.maxX < x) {
|
cET.minX = x;
|
||||||
cET.maxX = x;
|
} else if (cET.maxX < x) {
|
||||||
}
|
cET.maxX = x;
|
||||||
|
}
|
||||||
if (cET.minY > y) {
|
|
||||||
cET.minY = y;
|
if (cET.minY > y) {
|
||||||
} else if (cET.maxY < y) {
|
cET.minY = y;
|
||||||
cET.maxY = y;
|
} else if (cET.maxY < y) {
|
||||||
}
|
cET.maxY = y;
|
||||||
}
|
}
|
||||||
n ++;
|
}
|
||||||
}
|
n ++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return cET;
|
|
||||||
}
|
return cET;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Select data points
|
/**
|
||||||
* @param extent Selection extent
|
* Select data points
|
||||||
* @return Selected data points
|
* @param extent Selection extent
|
||||||
*/
|
* @return Selected data points
|
||||||
@Override
|
*/
|
||||||
public List<int[]> selectPoints(Extent extent){
|
@Override
|
||||||
List<int[]> selIdxs = new ArrayList<int[]>();
|
public List<int[]> selectPoints(Extent extent){
|
||||||
double x, y;
|
List<int[]> selIdxs = new ArrayList<int[]>();
|
||||||
for (int i = 0; i < this.seriesCount; i++){
|
double x, y;
|
||||||
for (int j = 0; j < this.itemCount; j++){
|
for (int i = 0; i < this.seriesCount; i++){
|
||||||
x = this.getX(i, j);
|
for (int j = 0; j < this.itemCount; j++){
|
||||||
if (x >= extent.minX && x <= extent.maxX){
|
x = this.getX(i, j);
|
||||||
y = this.getY(i, j);
|
if (x >= extent.minX && x <= extent.maxX){
|
||||||
if (y >= extent.minY && y <= extent.maxY){
|
y = this.getY(i, j);
|
||||||
selIdxs.add(new int[]{i, j});
|
if (y >= extent.minY && y <= extent.maxY){
|
||||||
}
|
selIdxs.add(new int[]{i, j});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return selIdxs;
|
|
||||||
}
|
return selIdxs;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get missing value index list
|
/**
|
||||||
* @param seriesIdx Series index
|
* Get missing value index list
|
||||||
* @return Missing value index list
|
* @param seriesIdx Series index
|
||||||
*/
|
* @return Missing value index list
|
||||||
@Override
|
*/
|
||||||
public List<Integer> getMissingValueIndex(int seriesIdx){
|
@Override
|
||||||
List<Integer> mvidx = new ArrayList<Integer>();
|
public List<Integer> getMissingValueIndex(int seriesIdx){
|
||||||
double[] xvs = this.getXValues(seriesIdx);
|
List<Integer> mvidx = new ArrayList<Integer>();
|
||||||
double[] yvs = this.getYValues(seriesIdx);
|
double[] xvs = this.getXValues(seriesIdx);
|
||||||
for (int i = 0; i < this.itemCount; i++){
|
double[] yvs = this.getYValues(seriesIdx);
|
||||||
if (MIMath.doubleEquals(xvs[i], this.getMissingValue()) || MIMath.doubleEquals(yvs[i], this.getMissingValue()))
|
for (int i = 0; i < this.itemCount; i++){
|
||||||
mvidx.add(i);
|
if (MIMath.doubleEquals(xvs[i], this.getMissingValue()) || MIMath.doubleEquals(yvs[i], this.getMissingValue()))
|
||||||
}
|
mvidx.add(i);
|
||||||
|
}
|
||||||
return mvidx;
|
|
||||||
}
|
return mvidx;
|
||||||
// </editor-fold>
|
}
|
||||||
}
|
// </editor-fold>
|
||||||
|
}
|
||||||
|
|||||||
@ -1,155 +1,156 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package org.meteoinfo.data;
|
package org.meteoinfo.data;
|
||||||
|
|
||||||
import java.util.List;
|
import org.meteoinfo.common.Extent;
|
||||||
import org.meteoinfo.global.Extent;
|
|
||||||
|
import java.util.List;
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
* @author yaqiang
|
*
|
||||||
*/
|
* @author yaqiang
|
||||||
public abstract class XYDataset extends Dataset{
|
*/
|
||||||
|
public abstract class XYDataset extends Dataset{
|
||||||
private double missingValue = -9999.0;
|
|
||||||
|
private double missingValue = -9999.0;
|
||||||
/**
|
|
||||||
* Get missing value
|
/**
|
||||||
* @return Missing value
|
* Get missing value
|
||||||
*/
|
* @return Missing value
|
||||||
public double getMissingValue(){
|
*/
|
||||||
return this.missingValue;
|
public double getMissingValue(){
|
||||||
}
|
return this.missingValue;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set missing value
|
/**
|
||||||
* @param value Missing value
|
* Set missing value
|
||||||
*/
|
* @param value Missing value
|
||||||
public void setMissingValue(double value){
|
*/
|
||||||
this.missingValue = value;
|
public void setMissingValue(double value){
|
||||||
}
|
this.missingValue = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get dataset type
|
/**
|
||||||
* @return Dataset type
|
* Get dataset type
|
||||||
*/
|
* @return Dataset type
|
||||||
@Override
|
*/
|
||||||
public DatasetType getDatasetType() {
|
@Override
|
||||||
return DatasetType.XY;
|
public DatasetType getDatasetType() {
|
||||||
}
|
return DatasetType.XY;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get series count
|
/**
|
||||||
* @return Series count
|
* Get series count
|
||||||
*/
|
* @return Series count
|
||||||
public abstract int getSeriesCount();
|
*/
|
||||||
|
public abstract int getSeriesCount();
|
||||||
/**
|
|
||||||
* Get item count
|
/**
|
||||||
* @return Item count
|
* Get item count
|
||||||
*/
|
* @return Item count
|
||||||
public abstract int getItemCount();
|
*/
|
||||||
|
public abstract int getItemCount();
|
||||||
/**
|
|
||||||
* Get item count by series index
|
/**
|
||||||
* @param seriesIdx Series index
|
* Get item count by series index
|
||||||
* @return Item count
|
* @param seriesIdx Series index
|
||||||
*/
|
* @return Item count
|
||||||
public abstract int getItemCount(int seriesIdx);
|
*/
|
||||||
|
public abstract int getItemCount(int seriesIdx);
|
||||||
/**
|
|
||||||
* Get x value
|
/**
|
||||||
* @param seriesIdx Series index
|
* Get x value
|
||||||
* @param itemIdx Item index
|
* @param seriesIdx Series index
|
||||||
* @return X value
|
* @param itemIdx Item index
|
||||||
*/
|
* @return X value
|
||||||
public abstract double getX(int seriesIdx, int itemIdx);
|
*/
|
||||||
|
public abstract double getX(int seriesIdx, int itemIdx);
|
||||||
/**
|
|
||||||
* Get y value
|
/**
|
||||||
* @param seriesIdx Series index
|
* Get y value
|
||||||
* @param itemIdx Item index
|
* @param seriesIdx Series index
|
||||||
* @return Y value
|
* @param itemIdx Item index
|
||||||
*/
|
* @return Y value
|
||||||
public abstract double getY(int seriesIdx, int itemIdx);
|
*/
|
||||||
|
public abstract double getY(int seriesIdx, int itemIdx);
|
||||||
/**
|
|
||||||
* Set x value
|
/**
|
||||||
* @param seriesIdx Series index
|
* Set x value
|
||||||
* @param itemIdx Item index
|
* @param seriesIdx Series index
|
||||||
* @param value X value
|
* @param itemIdx Item index
|
||||||
*/
|
* @param value X value
|
||||||
public abstract void setX(int seriesIdx, int itemIdx, double value);
|
*/
|
||||||
|
public abstract void setX(int seriesIdx, int itemIdx, double value);
|
||||||
/**
|
|
||||||
* Set y value
|
/**
|
||||||
* @param seriesIdx Series index
|
* Set y value
|
||||||
* @param itemIdx Item index
|
* @param seriesIdx Series index
|
||||||
* @param value Y value
|
* @param itemIdx Item index
|
||||||
*/
|
* @param value Y value
|
||||||
public abstract void setY(int seriesIdx, int itemIdx, double value);
|
*/
|
||||||
|
public abstract void setY(int seriesIdx, int itemIdx, double value);
|
||||||
/**
|
|
||||||
* Get x values
|
/**
|
||||||
* @param seriesIdx Series index
|
* Get x values
|
||||||
* @return X values
|
* @param seriesIdx Series index
|
||||||
*/
|
* @return X values
|
||||||
public abstract double[] getXValues(int seriesIdx);
|
*/
|
||||||
|
public abstract double[] getXValues(int seriesIdx);
|
||||||
/**
|
|
||||||
* Get y values
|
/**
|
||||||
* @param seriesIdx Series index
|
* Get y values
|
||||||
* @return Y values
|
* @param seriesIdx Series index
|
||||||
*/
|
* @return Y values
|
||||||
public abstract double[] getYValues(int seriesIdx);
|
*/
|
||||||
|
public abstract double[] getYValues(int seriesIdx);
|
||||||
/**
|
|
||||||
* Get series key by index
|
/**
|
||||||
* @param seriesIdx Series index
|
* Get series key by index
|
||||||
* @return Series key
|
* @param seriesIdx Series index
|
||||||
*/
|
* @return Series key
|
||||||
public abstract String getSeriesKey(int seriesIdx);
|
*/
|
||||||
|
public abstract String getSeriesKey(int seriesIdx);
|
||||||
/**
|
|
||||||
* Set series key by index
|
/**
|
||||||
* @param seriesIdx Series index
|
* Set series key by index
|
||||||
* @param seriesKey Series key
|
* @param seriesIdx Series index
|
||||||
*/
|
* @param seriesKey Series key
|
||||||
public abstract void setSeriesKey(int seriesIdx, String seriesKey);
|
*/
|
||||||
|
public abstract void setSeriesKey(int seriesIdx, String seriesKey);
|
||||||
/**
|
|
||||||
* Get series keys
|
/**
|
||||||
* @return Series keys
|
* Get series keys
|
||||||
*/
|
* @return Series keys
|
||||||
public abstract List<String> getSeriesKeys();
|
*/
|
||||||
|
public abstract List<String> getSeriesKeys();
|
||||||
/**
|
|
||||||
* Set series keys
|
/**
|
||||||
* @param keys Keys
|
* Set series keys
|
||||||
*/
|
* @param keys Keys
|
||||||
public abstract void setSeriesKeys(List<String> keys);
|
*/
|
||||||
|
public abstract void setSeriesKeys(List<String> keys);
|
||||||
/**
|
|
||||||
* Get data extent
|
/**
|
||||||
* @return Data extent
|
* Get data extent
|
||||||
*/
|
* @return Data extent
|
||||||
public abstract Extent getDataExtent();
|
*/
|
||||||
|
public abstract Extent getDataExtent();
|
||||||
/**
|
|
||||||
* Get missing value index list
|
/**
|
||||||
* @param seriesIdx Series index
|
* Get missing value index list
|
||||||
* @return Missing value index list
|
* @param seriesIdx Series index
|
||||||
*/
|
* @return Missing value index list
|
||||||
public abstract List<Integer> getMissingValueIndex(int seriesIdx);
|
*/
|
||||||
|
public abstract List<Integer> getMissingValueIndex(int seriesIdx);
|
||||||
/**
|
|
||||||
* Select data points
|
/**
|
||||||
* @param extent Selection extent
|
* Select data points
|
||||||
* @return Selected data points
|
* @param extent Selection extent
|
||||||
*/
|
* @return Selected data points
|
||||||
public abstract List<int[]> selectPoints(Extent extent);
|
*/
|
||||||
|
public abstract List<int[]> selectPoints(Extent extent);
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|||||||
@ -1,443 +1,444 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package org.meteoinfo.data;
|
package org.meteoinfo.data;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.meteoinfo.global.Extent;
|
|
||||||
import org.meteoinfo.global.MIMath;
|
import org.meteoinfo.common.Extent;
|
||||||
import org.meteoinfo.ndarray.Array;
|
import org.meteoinfo.common.MIMath;
|
||||||
|
import org.meteoinfo.ndarray.Array;
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
* @author wyq
|
*
|
||||||
*/
|
* @author wyq
|
||||||
public class XYListDataset extends XYDataset {
|
*/
|
||||||
// <editor-fold desc="Variables">
|
public class XYListDataset extends XYDataset {
|
||||||
//private List<double[]> xValues;
|
// <editor-fold desc="Variables">
|
||||||
//private List<double[]> yValues;
|
//private List<double[]> xValues;
|
||||||
//private List<String> seriesKeys;
|
//private List<double[]> yValues;
|
||||||
private List<XYSeriesData> dataset;
|
//private List<String> seriesKeys;
|
||||||
// </editor-fold>
|
private List<XYSeriesData> dataset;
|
||||||
// <editor-fold desc="Constructor">
|
// </editor-fold>
|
||||||
/**
|
// <editor-fold desc="Constructor">
|
||||||
* Constructor
|
/**
|
||||||
*/
|
* Constructor
|
||||||
public XYListDataset(){
|
*/
|
||||||
//xValues = new ArrayList<>();
|
public XYListDataset(){
|
||||||
//yValues = new ArrayList<>();
|
//xValues = new ArrayList<>();
|
||||||
//seriesKeys = new ArrayList<>();
|
//yValues = new ArrayList<>();
|
||||||
dataset = new ArrayList<>();
|
//seriesKeys = new ArrayList<>();
|
||||||
}
|
dataset = new ArrayList<>();
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Constructor
|
/**
|
||||||
*
|
* Constructor
|
||||||
* @param seriesNum Series number
|
*
|
||||||
* @param itemNum Item number
|
* @param seriesNum Series number
|
||||||
*/
|
* @param itemNum Item number
|
||||||
public XYListDataset(int seriesNum, int itemNum) {
|
*/
|
||||||
this();
|
public XYListDataset(int seriesNum, int itemNum) {
|
||||||
|
this();
|
||||||
for (int i = 0; i < seriesNum; i++){
|
|
||||||
//xValues.add(new double[itemNum]);
|
for (int i = 0; i < seriesNum; i++){
|
||||||
//yValues.add(new double[itemNum]);
|
//xValues.add(new double[itemNum]);
|
||||||
//seriesKeys.add("");
|
//yValues.add(new double[itemNum]);
|
||||||
dataset.add(new XYSeriesData());
|
//seriesKeys.add("");
|
||||||
}
|
dataset.add(new XYSeriesData());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Constructor
|
/**
|
||||||
* @param xdata X station data
|
* Constructor
|
||||||
* @param ydata Y station data
|
* @param xdata X station data
|
||||||
* @param seriesKey Series key
|
* @param ydata Y station data
|
||||||
*/
|
* @param seriesKey Series key
|
||||||
public XYListDataset(StationData xdata, StationData ydata, String seriesKey){
|
*/
|
||||||
this();
|
public XYListDataset(StationData xdata, StationData ydata, String seriesKey){
|
||||||
List<double[]> vdata = new ArrayList<>();
|
this();
|
||||||
double v1, v2;
|
List<double[]> vdata = new ArrayList<>();
|
||||||
for (int i = 0; i < xdata.getStNum(); i++) {
|
double v1, v2;
|
||||||
v1 = xdata.getValue(i);
|
for (int i = 0; i < xdata.getStNum(); i++) {
|
||||||
if (MIMath.doubleEquals(v1, xdata.missingValue)) {
|
v1 = xdata.getValue(i);
|
||||||
continue;
|
if (MIMath.doubleEquals(v1, xdata.missingValue)) {
|
||||||
}
|
continue;
|
||||||
v2 = ydata.getValue(i);
|
}
|
||||||
if (MIMath.doubleEquals(v2, ydata.missingValue)) {
|
v2 = ydata.getValue(i);
|
||||||
continue;
|
if (MIMath.doubleEquals(v2, ydata.missingValue)) {
|
||||||
}
|
continue;
|
||||||
vdata.add(new double[]{v1, v2});
|
}
|
||||||
}
|
vdata.add(new double[]{v1, v2});
|
||||||
|
}
|
||||||
int n = vdata.size();
|
|
||||||
double[] xvs = new double[n];
|
int n = vdata.size();
|
||||||
double[] yvs = new double[n];
|
double[] xvs = new double[n];
|
||||||
for (int i = 0; i < n; i++){
|
double[] yvs = new double[n];
|
||||||
xvs[i] = vdata.get(i)[0];
|
for (int i = 0; i < n; i++){
|
||||||
yvs[i] = vdata.get(i)[1];
|
xvs[i] = vdata.get(i)[0];
|
||||||
}
|
yvs[i] = vdata.get(i)[1];
|
||||||
//this.xValues.add(xvs);
|
}
|
||||||
//this.yValues.add(yvs);
|
//this.xValues.add(xvs);
|
||||||
//this.seriesKeys.add(seriesKey);
|
//this.yValues.add(yvs);
|
||||||
XYSeriesData sdata = new XYSeriesData(seriesKey, xvs, yvs);
|
//this.seriesKeys.add(seriesKey);
|
||||||
this.dataset.add(sdata);
|
XYSeriesData sdata = new XYSeriesData(seriesKey, xvs, yvs);
|
||||||
}
|
this.dataset.add(sdata);
|
||||||
// </editor-fold>
|
}
|
||||||
// <editor-fold desc="Get Set Methods">
|
// </editor-fold>
|
||||||
|
// <editor-fold desc="Get Set Methods">
|
||||||
/**
|
|
||||||
* Get series data
|
/**
|
||||||
* @param seriesIdx Series index
|
* Get series data
|
||||||
* @return Series data
|
* @param seriesIdx Series index
|
||||||
*/
|
* @return Series data
|
||||||
public XYSeriesData getSeriesData(int seriesIdx){
|
*/
|
||||||
return this.dataset.get(seriesIdx);
|
public XYSeriesData getSeriesData(int seriesIdx){
|
||||||
}
|
return this.dataset.get(seriesIdx);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public int getSeriesCount() {
|
@Override
|
||||||
//return this.xValues.size();
|
public int getSeriesCount() {
|
||||||
return this.dataset.size();
|
//return this.xValues.size();
|
||||||
}
|
return this.dataset.size();
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public String getSeriesKey(int seriesIdx) {
|
@Override
|
||||||
//return this.seriesKeys.get(seriesIdx);
|
public String getSeriesKey(int seriesIdx) {
|
||||||
return this.dataset.get(seriesIdx).getKey();
|
//return this.seriesKeys.get(seriesIdx);
|
||||||
}
|
return this.dataset.get(seriesIdx).getKey();
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set series key by index
|
/**
|
||||||
* @param seriesIdx Series index
|
* Set series key by index
|
||||||
* @param seriesKey Series key
|
* @param seriesIdx Series index
|
||||||
*/
|
* @param seriesKey Series key
|
||||||
@Override
|
*/
|
||||||
public void setSeriesKey(int seriesIdx, String seriesKey){
|
@Override
|
||||||
//this.seriesKeys.set(seriesIdx, seriesKey);
|
public void setSeriesKey(int seriesIdx, String seriesKey){
|
||||||
this.dataset.get(seriesIdx).setKey(seriesKey);
|
//this.seriesKeys.set(seriesIdx, seriesKey);
|
||||||
}
|
this.dataset.get(seriesIdx).setKey(seriesKey);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get series keys
|
/**
|
||||||
* @return Series keys
|
* Get series keys
|
||||||
*/
|
* @return Series keys
|
||||||
@Override
|
*/
|
||||||
public List<String> getSeriesKeys(){
|
@Override
|
||||||
//return this.seriesKeys;
|
public List<String> getSeriesKeys(){
|
||||||
List<String> keys = new ArrayList<>();
|
//return this.seriesKeys;
|
||||||
for (XYSeriesData d :this.dataset){
|
List<String> keys = new ArrayList<>();
|
||||||
keys.add(d.getKey());
|
for (XYSeriesData d :this.dataset){
|
||||||
}
|
keys.add(d.getKey());
|
||||||
return keys;
|
}
|
||||||
}
|
return keys;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set series keys
|
/**
|
||||||
* @param value Series keys
|
* Set series keys
|
||||||
*/
|
* @param value Series keys
|
||||||
@Override
|
*/
|
||||||
public void setSeriesKeys(List<String> value){
|
@Override
|
||||||
//this.seriesKeys = value;
|
public void setSeriesKeys(List<String> value){
|
||||||
int i = 0;
|
//this.seriesKeys = value;
|
||||||
for (XYSeriesData d :this.dataset){
|
int i = 0;
|
||||||
d.setKey(value.get(i));
|
for (XYSeriesData d :this.dataset){
|
||||||
i++;
|
d.setKey(value.get(i));
|
||||||
}
|
i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public int getItemCount(){
|
@Override
|
||||||
int n = this.getItemCount(0);
|
public int getItemCount(){
|
||||||
if (this.getSeriesCount() > 1){
|
int n = this.getItemCount(0);
|
||||||
for (int i = 1; i < this.getSeriesCount(); i++){
|
if (this.getSeriesCount() > 1){
|
||||||
int nn = this.getItemCount(i);
|
for (int i = 1; i < this.getSeriesCount(); i++){
|
||||||
if (n < nn)
|
int nn = this.getItemCount(i);
|
||||||
n = nn;
|
if (n < nn)
|
||||||
}
|
n = nn;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return n;
|
|
||||||
}
|
return n;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public int getItemCount(int seriesIdx) {
|
@Override
|
||||||
//return this.xValues.get(seriesIdx).length;
|
public int getItemCount(int seriesIdx) {
|
||||||
return this.dataset.get(seriesIdx).dataLength();
|
//return this.xValues.get(seriesIdx).length;
|
||||||
}
|
return this.dataset.get(seriesIdx).dataLength();
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public double[] getXValues(int seriesIdx){
|
@Override
|
||||||
//return this.xValues.get(seriesIdx);
|
public double[] getXValues(int seriesIdx){
|
||||||
return this.dataset.get(seriesIdx).getXdata();
|
//return this.xValues.get(seriesIdx);
|
||||||
}
|
return this.dataset.get(seriesIdx).getXdata();
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public double[] getYValues(int seriesIdx){
|
@Override
|
||||||
//return this.yValues.get(seriesIdx);
|
public double[] getYValues(int seriesIdx){
|
||||||
return this.dataset.get(seriesIdx).getYdata();
|
//return this.yValues.get(seriesIdx);
|
||||||
}
|
return this.dataset.get(seriesIdx).getYdata();
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public double getX(int seriesIdx, int itemIdx) {
|
@Override
|
||||||
//return this.xValues.get(seriesIdx)[itemIdx];
|
public double getX(int seriesIdx, int itemIdx) {
|
||||||
return this.dataset.get(seriesIdx).getXdata()[itemIdx];
|
//return this.xValues.get(seriesIdx)[itemIdx];
|
||||||
}
|
return this.dataset.get(seriesIdx).getXdata()[itemIdx];
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public double getY(int seriesIdx, int itemIdx) {
|
@Override
|
||||||
//return this.yValues.get(seriesIdx)[itemIdx];
|
public double getY(int seriesIdx, int itemIdx) {
|
||||||
return this.dataset.get(seriesIdx).getYdata()[itemIdx];
|
//return this.yValues.get(seriesIdx)[itemIdx];
|
||||||
}
|
return this.dataset.get(seriesIdx).getYdata()[itemIdx];
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void setX(int seriesIdx, int itemIdx, double value){
|
@Override
|
||||||
//this.xValues.get(seriesIdx)[itemIdx] = value;
|
public void setX(int seriesIdx, int itemIdx, double value){
|
||||||
this.dataset.get(seriesIdx).getXdata()[itemIdx] = value;
|
//this.xValues.get(seriesIdx)[itemIdx] = value;
|
||||||
}
|
this.dataset.get(seriesIdx).getXdata()[itemIdx] = value;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void setY(int seriesIdx, int itemIdx, double value){
|
@Override
|
||||||
//this.yValues.get(seriesIdx)[itemIdx] = value;
|
public void setY(int seriesIdx, int itemIdx, double value){
|
||||||
this.dataset.get(seriesIdx).getYdata()[itemIdx] = value;
|
//this.yValues.get(seriesIdx)[itemIdx] = value;
|
||||||
}
|
this.dataset.get(seriesIdx).getYdata()[itemIdx] = value;
|
||||||
// </editor-fold>
|
}
|
||||||
// <editor-fold desc="Methods">
|
// </editor-fold>
|
||||||
/**
|
// <editor-fold desc="Methods">
|
||||||
* Add a series data
|
/**
|
||||||
* @param sdata Series data
|
* Add a series data
|
||||||
*/
|
* @param sdata Series data
|
||||||
public void addSeries(XYSeriesData sdata){
|
*/
|
||||||
this.dataset.add(sdata);
|
public void addSeries(XYSeriesData sdata){
|
||||||
}
|
this.dataset.add(sdata);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Add a series data
|
/**
|
||||||
* @param seriesKey Series key
|
* Add a series data
|
||||||
* @param xvs X value array
|
* @param seriesKey Series key
|
||||||
* @param yvs Y value array
|
* @param xvs X value array
|
||||||
*/
|
* @param yvs Y value array
|
||||||
public void addSeries(String seriesKey, double[] xvs, double[] yvs){
|
*/
|
||||||
//this.seriesKeys.add(seriesKey);
|
public void addSeries(String seriesKey, double[] xvs, double[] yvs){
|
||||||
//this.xValues.add(xvs);
|
//this.seriesKeys.add(seriesKey);
|
||||||
//this.yValues.add(yvs);
|
//this.xValues.add(xvs);
|
||||||
XYSeriesData sdata = new XYSeriesData(seriesKey, xvs, yvs);
|
//this.yValues.add(yvs);
|
||||||
this.dataset.add(sdata);
|
XYSeriesData sdata = new XYSeriesData(seriesKey, xvs, yvs);
|
||||||
}
|
this.dataset.add(sdata);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Add a series data
|
/**
|
||||||
* @param seriesKey Series key
|
* Add a series data
|
||||||
* @param xvs X value array
|
* @param seriesKey Series key
|
||||||
* @param yvs Y value array
|
* @param xvs X value array
|
||||||
*/
|
* @param yvs Y value array
|
||||||
public void addSeries(String seriesKey, List<Number> xvs, List<Number> yvs){
|
*/
|
||||||
double[] nxvs = new double[xvs.size()];
|
public void addSeries(String seriesKey, List<Number> xvs, List<Number> yvs){
|
||||||
double[] nyvs = new double[yvs.size()];
|
double[] nxvs = new double[xvs.size()];
|
||||||
double v;
|
double[] nyvs = new double[yvs.size()];
|
||||||
for (int i = 0; i < xvs.size(); i++){
|
double v;
|
||||||
v = xvs.get(i).doubleValue();
|
for (int i = 0; i < xvs.size(); i++){
|
||||||
if (Double.isNaN(v))
|
v = xvs.get(i).doubleValue();
|
||||||
nxvs[i] = this.getMissingValue();
|
if (Double.isNaN(v))
|
||||||
else
|
nxvs[i] = this.getMissingValue();
|
||||||
nxvs[i] = xvs.get(i).doubleValue();
|
else
|
||||||
}
|
nxvs[i] = xvs.get(i).doubleValue();
|
||||||
for (int i = 0; i < yvs.size(); i++){
|
}
|
||||||
v = yvs.get(i).doubleValue();
|
for (int i = 0; i < yvs.size(); i++){
|
||||||
if (Double.isNaN(v))
|
v = yvs.get(i).doubleValue();
|
||||||
nyvs[i] = this.getMissingValue();
|
if (Double.isNaN(v))
|
||||||
else
|
nyvs[i] = this.getMissingValue();
|
||||||
nyvs[i] = v;
|
else
|
||||||
}
|
nyvs[i] = v;
|
||||||
|
}
|
||||||
this.addSeries(seriesKey, nxvs, nyvs);
|
|
||||||
}
|
this.addSeries(seriesKey, nxvs, nyvs);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Add a series data
|
/**
|
||||||
* @param seriesKey Series key
|
* Add a series data
|
||||||
* @param xvs X value array
|
* @param seriesKey Series key
|
||||||
* @param yvs Y value array
|
* @param xvs X value array
|
||||||
*/
|
* @param yvs Y value array
|
||||||
public void addSeries(String seriesKey, List<Number> xvs, Array yvs){
|
*/
|
||||||
int xn = (int)xvs.size();
|
public void addSeries(String seriesKey, List<Number> xvs, Array yvs){
|
||||||
int yn = (int)yvs.getSize();
|
int xn = (int)xvs.size();
|
||||||
double[] nxvs = new double[xn];
|
int yn = (int)yvs.getSize();
|
||||||
double[] nyvs = new double[yn];
|
double[] nxvs = new double[xn];
|
||||||
double v;
|
double[] nyvs = new double[yn];
|
||||||
for (int i = 0; i < xn; i++)
|
double v;
|
||||||
nxvs[i] = xvs.get(i).doubleValue();
|
for (int i = 0; i < xn; i++)
|
||||||
for (int i = 0; i < yn; i++) {
|
nxvs[i] = xvs.get(i).doubleValue();
|
||||||
v = yvs.getDouble(i);
|
for (int i = 0; i < yn; i++) {
|
||||||
if (Double.isNaN(v))
|
v = yvs.getDouble(i);
|
||||||
nyvs[i] = this.getMissingValue();
|
if (Double.isNaN(v))
|
||||||
else
|
nyvs[i] = this.getMissingValue();
|
||||||
nyvs[i] = v;
|
else
|
||||||
}
|
nyvs[i] = v;
|
||||||
|
}
|
||||||
this.addSeries(seriesKey, nxvs, nyvs);
|
|
||||||
}
|
this.addSeries(seriesKey, nxvs, nyvs);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Add a series data
|
/**
|
||||||
* @param seriesKey Series key
|
* Add a series data
|
||||||
* @param xvs X value array
|
* @param seriesKey Series key
|
||||||
* @param yvs Y value array
|
* @param xvs X value array
|
||||||
*/
|
* @param yvs Y value array
|
||||||
public void addSeries(String seriesKey, Array xvs, Array yvs){
|
*/
|
||||||
int xn = (int)xvs.getSize();
|
public void addSeries(String seriesKey, Array xvs, Array yvs){
|
||||||
int yn = (int)yvs.getSize();
|
int xn = (int)xvs.getSize();
|
||||||
double[] nxvs = new double[xn];
|
int yn = (int)yvs.getSize();
|
||||||
double[] nyvs = new double[yn];
|
double[] nxvs = new double[xn];
|
||||||
double v;
|
double[] nyvs = new double[yn];
|
||||||
for (int i = 0; i < xn; i++)
|
double v;
|
||||||
nxvs[i] = xvs.getDouble(i);
|
for (int i = 0; i < xn; i++)
|
||||||
for (int i = 0; i < yn; i++){
|
nxvs[i] = xvs.getDouble(i);
|
||||||
v = yvs.getDouble(i);
|
for (int i = 0; i < yn; i++){
|
||||||
if (Double.isNaN(v))
|
v = yvs.getDouble(i);
|
||||||
nyvs[i] = this.getMissingValue();
|
if (Double.isNaN(v))
|
||||||
else
|
nyvs[i] = this.getMissingValue();
|
||||||
nyvs[i] = v;
|
else
|
||||||
}
|
nyvs[i] = v;
|
||||||
|
}
|
||||||
this.addSeries(seriesKey, nxvs, nyvs);
|
|
||||||
}
|
this.addSeries(seriesKey, nxvs, nyvs);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Add a series data
|
/**
|
||||||
* @param seriesKey Series key
|
* Add a series data
|
||||||
* @param xvs X value array
|
* @param seriesKey Series key
|
||||||
* @param yvs Y value array
|
* @param xvs X value array
|
||||||
*/
|
* @param yvs Y value array
|
||||||
public void addSeries(String seriesKey, Array xvs, List<Number> yvs){
|
*/
|
||||||
int xn = (int)xvs.getSize();
|
public void addSeries(String seriesKey, Array xvs, List<Number> yvs){
|
||||||
int yn = yvs.size();
|
int xn = (int)xvs.getSize();
|
||||||
double[] nxvs = new double[xn];
|
int yn = yvs.size();
|
||||||
double[] nyvs = new double[yn];
|
double[] nxvs = new double[xn];
|
||||||
double v;
|
double[] nyvs = new double[yn];
|
||||||
for (int i = 0; i < xn; i++)
|
double v;
|
||||||
nxvs[i] = xvs.getDouble(i);
|
for (int i = 0; i < xn; i++)
|
||||||
for (int i = 0; i < yn; i++){
|
nxvs[i] = xvs.getDouble(i);
|
||||||
v = yvs.get(i).doubleValue();
|
for (int i = 0; i < yn; i++){
|
||||||
if (Double.isNaN(v))
|
v = yvs.get(i).doubleValue();
|
||||||
nyvs[i] = this.getMissingValue();
|
if (Double.isNaN(v))
|
||||||
else
|
nyvs[i] = this.getMissingValue();
|
||||||
nyvs[i] = v;
|
else
|
||||||
}
|
nyvs[i] = v;
|
||||||
|
}
|
||||||
this.addSeries(seriesKey, nxvs, nyvs);
|
|
||||||
}
|
this.addSeries(seriesKey, nxvs, nyvs);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Remove a series data
|
/**
|
||||||
* @param seriesIdx Series data
|
* Remove a series data
|
||||||
*/
|
* @param seriesIdx Series data
|
||||||
public void removeSeries(int seriesIdx){
|
*/
|
||||||
//this.seriesKeys.remove(seriesIdx);
|
public void removeSeries(int seriesIdx){
|
||||||
//this.xValues.remove(seriesIdx);
|
//this.seriesKeys.remove(seriesIdx);
|
||||||
//this.yValues.remove(seriesIdx);
|
//this.xValues.remove(seriesIdx);
|
||||||
this.dataset.remove(seriesIdx);
|
//this.yValues.remove(seriesIdx);
|
||||||
}
|
this.dataset.remove(seriesIdx);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Remove a series data
|
/**
|
||||||
* @param seriesKey Series key
|
* Remove a series data
|
||||||
*/
|
* @param seriesKey Series key
|
||||||
public void removeSeries(String seriesKey){
|
*/
|
||||||
List<String> keys = this.getSeriesKeys();
|
public void removeSeries(String seriesKey){
|
||||||
int idx = keys.indexOf(seriesKey);
|
List<String> keys = this.getSeriesKeys();
|
||||||
if (idx >= 0){
|
int idx = keys.indexOf(seriesKey);
|
||||||
this.removeSeries(idx);
|
if (idx >= 0){
|
||||||
}
|
this.removeSeries(idx);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get data extent
|
/**
|
||||||
* @return Data extent
|
* Get data extent
|
||||||
*/
|
* @return Data extent
|
||||||
@Override
|
*/
|
||||||
public Extent getDataExtent() {
|
@Override
|
||||||
Extent cET = new Extent();
|
public Extent getDataExtent() {
|
||||||
double xmin, xmax, ymin, ymax;
|
Extent cET = new Extent();
|
||||||
int n = 0;
|
double xmin, xmax, ymin, ymax;
|
||||||
for (int i = 0; i < this.getSeriesCount(); i++) {
|
int n = 0;
|
||||||
XYSeriesData sdata = this.dataset.get(i);
|
for (int i = 0; i < this.getSeriesCount(); i++) {
|
||||||
for (int j = 0; j < this.getItemCount(i); j++) {
|
XYSeriesData sdata = this.dataset.get(i);
|
||||||
xmin = sdata.getX_min(j);
|
for (int j = 0; j < this.getItemCount(i); j++) {
|
||||||
xmax = sdata.getX_max(j);
|
xmin = sdata.getX_min(j);
|
||||||
ymin = sdata.getY_min(j);
|
xmax = sdata.getX_max(j);
|
||||||
ymax = sdata.getY_max(j);
|
ymin = sdata.getY_min(j);
|
||||||
if (Double.isNaN(sdata.getX(j)) || Double.isNaN(sdata.getY(j)))
|
ymax = sdata.getY_max(j);
|
||||||
continue;
|
if (Double.isNaN(sdata.getX(j)) || Double.isNaN(sdata.getY(j)))
|
||||||
if (MIMath.doubleEquals(sdata.getX(j), this.getMissingValue()) || MIMath.doubleEquals(sdata.getY(j), this.getMissingValue()))
|
continue;
|
||||||
continue;
|
if (MIMath.doubleEquals(sdata.getX(j), this.getMissingValue()) || MIMath.doubleEquals(sdata.getY(j), this.getMissingValue()))
|
||||||
if (n == 0) {
|
continue;
|
||||||
cET.minX = xmin;
|
if (n == 0) {
|
||||||
cET.maxX = xmax;
|
cET.minX = xmin;
|
||||||
cET.minY = ymin;
|
cET.maxX = xmax;
|
||||||
cET.maxY = ymax;
|
cET.minY = ymin;
|
||||||
} else {
|
cET.maxY = ymax;
|
||||||
if (cET.minX > xmin) {
|
} else {
|
||||||
cET.minX = xmin;
|
if (cET.minX > xmin) {
|
||||||
} else if (cET.maxX < xmax) {
|
cET.minX = xmin;
|
||||||
cET.maxX = xmax;
|
} else if (cET.maxX < xmax) {
|
||||||
}
|
cET.maxX = xmax;
|
||||||
|
}
|
||||||
if (cET.minY > ymin) {
|
|
||||||
cET.minY = ymin;
|
if (cET.minY > ymin) {
|
||||||
} else if (cET.maxY < ymax) {
|
cET.minY = ymin;
|
||||||
cET.maxY = ymax;
|
} else if (cET.maxY < ymax) {
|
||||||
}
|
cET.maxY = ymax;
|
||||||
}
|
}
|
||||||
n ++;
|
}
|
||||||
}
|
n ++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return cET;
|
|
||||||
}
|
return cET;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get missing value index list
|
/**
|
||||||
* @param seriesIdx Series index
|
* Get missing value index list
|
||||||
* @return Missing value index list
|
* @param seriesIdx Series index
|
||||||
*/
|
* @return Missing value index list
|
||||||
@Override
|
*/
|
||||||
public List<Integer> getMissingValueIndex(int seriesIdx){
|
@Override
|
||||||
List<Integer> mvidx = new ArrayList<>();
|
public List<Integer> getMissingValueIndex(int seriesIdx){
|
||||||
double[] xvs = this.getXValues(seriesIdx);
|
List<Integer> mvidx = new ArrayList<>();
|
||||||
double[] yvs = this.getYValues(seriesIdx);
|
double[] xvs = this.getXValues(seriesIdx);
|
||||||
for (int i = 0; i < yvs.length; i++){
|
double[] yvs = this.getYValues(seriesIdx);
|
||||||
if (MIMath.doubleEquals(xvs[i], this.getMissingValue()) || MIMath.doubleEquals(yvs[i], this.getMissingValue()))
|
for (int i = 0; i < yvs.length; i++){
|
||||||
mvidx.add(i);
|
if (MIMath.doubleEquals(xvs[i], this.getMissingValue()) || MIMath.doubleEquals(yvs[i], this.getMissingValue()))
|
||||||
}
|
mvidx.add(i);
|
||||||
|
}
|
||||||
return mvidx;
|
|
||||||
}
|
return mvidx;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Select data points
|
/**
|
||||||
* @param extent Selection extent
|
* Select data points
|
||||||
* @return Selected data points
|
* @param extent Selection extent
|
||||||
*/
|
* @return Selected data points
|
||||||
@Override
|
*/
|
||||||
public List<int[]> selectPoints(Extent extent){
|
@Override
|
||||||
List<int[]> selIdxs = new ArrayList<>();
|
public List<int[]> selectPoints(Extent extent){
|
||||||
double x, y;
|
List<int[]> selIdxs = new ArrayList<>();
|
||||||
for (int i = 0; i < this.getSeriesCount(); i++){
|
double x, y;
|
||||||
for (int j = 0; j < this.getItemCount(i); j++){
|
for (int i = 0; i < this.getSeriesCount(); i++){
|
||||||
x = this.getX(i, j);
|
for (int j = 0; j < this.getItemCount(i); j++){
|
||||||
if (x >= extent.minX && x <= extent.maxX){
|
x = this.getX(i, j);
|
||||||
y = this.getY(i, j);
|
if (x >= extent.minX && x <= extent.maxX){
|
||||||
if (y >= extent.minY && y <= extent.maxY){
|
y = this.getY(i, j);
|
||||||
selIdxs.add(new int[]{i, j});
|
if (y >= extent.minY && y <= extent.maxY){
|
||||||
}
|
selIdxs.add(new int[]{i, j});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return selIdxs;
|
|
||||||
}
|
return selIdxs;
|
||||||
// </editor-fold>
|
}
|
||||||
}
|
// </editor-fold>
|
||||||
|
}
|
||||||
|
|||||||
@ -1,258 +1,259 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package org.meteoinfo.data;
|
package org.meteoinfo.data;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.meteoinfo.global.MIMath;
|
|
||||||
import ucar.ma2.Array;
|
import org.meteoinfo.common.MIMath;
|
||||||
|
import ucar.ma2.Array;
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
* @author yaqiang
|
*
|
||||||
*/
|
* @author yaqiang
|
||||||
public class XYSeriesData {
|
*/
|
||||||
// <editor-fold desc="Variables">
|
public class XYSeriesData {
|
||||||
private String key;
|
// <editor-fold desc="Variables">
|
||||||
private double[] xdata;
|
private String key;
|
||||||
private double[] ydata;
|
private double[] xdata;
|
||||||
private double missingValue = -9999.0;
|
private double[] ydata;
|
||||||
// </editor-fold>
|
private double missingValue = -9999.0;
|
||||||
// <editor-fold desc="Constructor">
|
// </editor-fold>
|
||||||
/**
|
// <editor-fold desc="Constructor">
|
||||||
* Constructor
|
/**
|
||||||
*/
|
* Constructor
|
||||||
public XYSeriesData(){
|
*/
|
||||||
|
public XYSeriesData(){
|
||||||
}
|
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Constructor
|
/**
|
||||||
* @param key Key
|
* Constructor
|
||||||
*/
|
* @param key Key
|
||||||
public XYSeriesData(String key){
|
*/
|
||||||
this.key = key;
|
public XYSeriesData(String key){
|
||||||
}
|
this.key = key;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Constructor
|
/**
|
||||||
* @param key Series key
|
* Constructor
|
||||||
* @param xdata X data
|
* @param key Series key
|
||||||
* @param ydata Y data
|
* @param xdata X data
|
||||||
*/
|
* @param ydata Y data
|
||||||
public XYSeriesData(String key, double[] xdata, double[] ydata){
|
*/
|
||||||
this.key = key;
|
public XYSeriesData(String key, double[] xdata, double[] ydata){
|
||||||
this.xdata = xdata;
|
this.key = key;
|
||||||
this.ydata = ydata;
|
this.xdata = xdata;
|
||||||
}
|
this.ydata = ydata;
|
||||||
// </editor-fold>
|
}
|
||||||
// <editor-fold desc="Get Set Methods">
|
// </editor-fold>
|
||||||
/**
|
// <editor-fold desc="Get Set Methods">
|
||||||
* Get series key
|
/**
|
||||||
* @return Series key
|
* Get series key
|
||||||
*/
|
* @return Series key
|
||||||
public String getKey(){
|
*/
|
||||||
return key;
|
public String getKey(){
|
||||||
}
|
return key;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set series key
|
/**
|
||||||
* @param value Series key
|
* Set series key
|
||||||
*/
|
* @param value Series key
|
||||||
public void setKey(String value){
|
*/
|
||||||
key = value;
|
public void setKey(String value){
|
||||||
}
|
key = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get X data
|
/**
|
||||||
* @return X data
|
* Get X data
|
||||||
*/
|
* @return X data
|
||||||
public double[] getXdata(){
|
*/
|
||||||
return this.xdata;
|
public double[] getXdata(){
|
||||||
}
|
return this.xdata;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set X data
|
/**
|
||||||
* @param value X data
|
* Set X data
|
||||||
*/
|
* @param value X data
|
||||||
public void setXdata(double[] value){
|
*/
|
||||||
this.xdata = value;
|
public void setXdata(double[] value){
|
||||||
}
|
this.xdata = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set X data
|
/**
|
||||||
* @param value X data
|
* Set X data
|
||||||
*/
|
* @param value X data
|
||||||
public void setXdata(List<Number> value){
|
*/
|
||||||
this.xdata = new double[value.size()];
|
public void setXdata(List<Number> value){
|
||||||
double v;
|
this.xdata = new double[value.size()];
|
||||||
for (int i = 0; i < value.size(); i++){
|
double v;
|
||||||
v = value.get(i).doubleValue();
|
for (int i = 0; i < value.size(); i++){
|
||||||
if (Double.isNaN(v))
|
v = value.get(i).doubleValue();
|
||||||
xdata[i] = this.missingValue;
|
if (Double.isNaN(v))
|
||||||
else
|
xdata[i] = this.missingValue;
|
||||||
xdata[i] = v;
|
else
|
||||||
}
|
xdata[i] = v;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set X data
|
/**
|
||||||
* @param value X data
|
* Set X data
|
||||||
*/
|
* @param value X data
|
||||||
public void setXdata(Array value){
|
*/
|
||||||
this.xdata = new double[(int)value.getSize()];
|
public void setXdata(Array value){
|
||||||
double v;
|
this.xdata = new double[(int)value.getSize()];
|
||||||
for (int i = 0; i < xdata.length; i++){
|
double v;
|
||||||
v = value.getDouble(i);
|
for (int i = 0; i < xdata.length; i++){
|
||||||
if (Double.isNaN(v))
|
v = value.getDouble(i);
|
||||||
xdata[i] = this.missingValue;
|
if (Double.isNaN(v))
|
||||||
else
|
xdata[i] = this.missingValue;
|
||||||
xdata[i] = v;
|
else
|
||||||
}
|
xdata[i] = v;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get Y data
|
/**
|
||||||
* @return Y data
|
* Get Y data
|
||||||
*/
|
* @return Y data
|
||||||
public double[] getYdata(){
|
*/
|
||||||
return this.ydata;
|
public double[] getYdata(){
|
||||||
}
|
return this.ydata;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set Y data
|
/**
|
||||||
* @param value Y data
|
* Set Y data
|
||||||
*/
|
* @param value Y data
|
||||||
public void setYdata(double[] value){
|
*/
|
||||||
this.ydata = value;
|
public void setYdata(double[] value){
|
||||||
}
|
this.ydata = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set Y data
|
/**
|
||||||
* @param value Y data
|
* Set Y data
|
||||||
*/
|
* @param value Y data
|
||||||
public void setYdata(List<Number> value){
|
*/
|
||||||
this.ydata = new double[value.size()];
|
public void setYdata(List<Number> value){
|
||||||
double v;
|
this.ydata = new double[value.size()];
|
||||||
for (int i = 0; i < value.size(); i++){
|
double v;
|
||||||
v = value.get(i).doubleValue();
|
for (int i = 0; i < value.size(); i++){
|
||||||
if (Double.isNaN(v))
|
v = value.get(i).doubleValue();
|
||||||
ydata[i] = this.missingValue;
|
if (Double.isNaN(v))
|
||||||
else
|
ydata[i] = this.missingValue;
|
||||||
ydata[i] = v;
|
else
|
||||||
}
|
ydata[i] = v;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set Y data
|
/**
|
||||||
* @param value Y data
|
* Set Y data
|
||||||
*/
|
* @param value Y data
|
||||||
public void setYdata(Array value){
|
*/
|
||||||
this.ydata = new double[(int)value.getSize()];
|
public void setYdata(Array value){
|
||||||
double v;
|
this.ydata = new double[(int)value.getSize()];
|
||||||
for (int i = 0; i < ydata.length; i++){
|
double v;
|
||||||
v = value.getDouble(i);
|
for (int i = 0; i < ydata.length; i++){
|
||||||
if (Double.isNaN(v))
|
v = value.getDouble(i);
|
||||||
ydata[i] = this.missingValue;
|
if (Double.isNaN(v))
|
||||||
else
|
ydata[i] = this.missingValue;
|
||||||
ydata[i] = v;
|
else
|
||||||
}
|
ydata[i] = v;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get missing value
|
/**
|
||||||
* @return Missing value
|
* Get missing value
|
||||||
*/
|
* @return Missing value
|
||||||
public double getMissingValue(){
|
*/
|
||||||
return this.missingValue;
|
public double getMissingValue(){
|
||||||
}
|
return this.missingValue;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set missing value
|
/**
|
||||||
* @param value Missing value
|
* Set missing value
|
||||||
*/
|
* @param value Missing value
|
||||||
public void setMissingValue(double value){
|
*/
|
||||||
this.missingValue = value;
|
public void setMissingValue(double value){
|
||||||
}
|
this.missingValue = value;
|
||||||
// </editor-fold>
|
}
|
||||||
// <editor-fold desc="Methods">
|
// </editor-fold>
|
||||||
/**
|
// <editor-fold desc="Methods">
|
||||||
* Get data length
|
/**
|
||||||
* @return Data length
|
* Get data length
|
||||||
*/
|
* @return Data length
|
||||||
public int dataLength(){
|
*/
|
||||||
return this.xdata.length;
|
public int dataLength(){
|
||||||
}
|
return this.xdata.length;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get x value
|
/**
|
||||||
* @param idx Index
|
* Get x value
|
||||||
* @return X value
|
* @param idx Index
|
||||||
*/
|
* @return X value
|
||||||
public double getX(int idx){
|
*/
|
||||||
return this.xdata[idx];
|
public double getX(int idx){
|
||||||
}
|
return this.xdata[idx];
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get x - error value
|
/**
|
||||||
* @param idx Index
|
* Get x - error value
|
||||||
* @return X - error value
|
* @param idx Index
|
||||||
*/
|
* @return X - error value
|
||||||
public double getX_min(int idx){
|
*/
|
||||||
return this.xdata[idx];
|
public double getX_min(int idx){
|
||||||
}
|
return this.xdata[idx];
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get x + error value
|
/**
|
||||||
* @param idx Index
|
* Get x + error value
|
||||||
* @return X + error value
|
* @param idx Index
|
||||||
*/
|
* @return X + error value
|
||||||
public double getX_max(int idx){
|
*/
|
||||||
return this.xdata[idx];
|
public double getX_max(int idx){
|
||||||
}
|
return this.xdata[idx];
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get y value
|
/**
|
||||||
* @param idx Index
|
* Get y value
|
||||||
* @return Y value
|
* @param idx Index
|
||||||
*/
|
* @return Y value
|
||||||
public double getY(int idx){
|
*/
|
||||||
return this.ydata[idx];
|
public double getY(int idx){
|
||||||
}
|
return this.ydata[idx];
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get y - error value
|
/**
|
||||||
* @param idx Index
|
* Get y - error value
|
||||||
* @return Y - error value
|
* @param idx Index
|
||||||
*/
|
* @return Y - error value
|
||||||
public double getY_min(int idx){
|
*/
|
||||||
return this.ydata[idx];
|
public double getY_min(int idx){
|
||||||
}
|
return this.ydata[idx];
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get y + error value
|
/**
|
||||||
* @param idx Index
|
* Get y + error value
|
||||||
* @return Y + error value
|
* @param idx Index
|
||||||
*/
|
* @return Y + error value
|
||||||
public double getY_max(int idx){
|
*/
|
||||||
return this.ydata[idx];
|
public double getY_max(int idx){
|
||||||
}
|
return this.ydata[idx];
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get missing value index list
|
/**
|
||||||
* @return Missing value index list
|
* Get missing value index list
|
||||||
*/
|
* @return Missing value index list
|
||||||
public List<Integer> getMissingValueIndex(){
|
*/
|
||||||
List<Integer> mvidx = new ArrayList<>();
|
public List<Integer> getMissingValueIndex(){
|
||||||
for (int i = 0; i < xdata.length; i++){
|
List<Integer> mvidx = new ArrayList<>();
|
||||||
if (MIMath.doubleEquals(xdata[i], this.missingValue) || MIMath.doubleEquals(ydata[i], this.missingValue))
|
for (int i = 0; i < xdata.length; i++){
|
||||||
mvidx.add(i);
|
if (MIMath.doubleEquals(xdata[i], this.missingValue) || MIMath.doubleEquals(ydata[i], this.missingValue))
|
||||||
}
|
mvidx.add(i);
|
||||||
|
}
|
||||||
return mvidx;
|
|
||||||
}
|
return mvidx;
|
||||||
// </editor-fold>
|
}
|
||||||
}
|
// </editor-fold>
|
||||||
|
}
|
||||||
|
|||||||
@ -1,267 +1,267 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package org.meteoinfo.data.dataframe;
|
package org.meteoinfo.data.dataframe;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.meteoinfo.math.ArrayMath;
|
import org.meteoinfo.global.DataConvert;
|
||||||
import org.meteoinfo.global.DataConvert;
|
import org.meteoinfo.math.ArrayMath;
|
||||||
import org.meteoinfo.ndarray.Array;
|
import org.meteoinfo.ndarray.Array;
|
||||||
import org.meteoinfo.ndarray.DataType;
|
import org.meteoinfo.ndarray.DataType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Yaqiang Wang
|
* @author Yaqiang Wang
|
||||||
*/
|
*/
|
||||||
public class Column {
|
public class Column {
|
||||||
// <editor-fold desc="Variables">
|
// <editor-fold desc="Variables">
|
||||||
protected String name;
|
protected String name;
|
||||||
protected DataType dataType;
|
protected DataType dataType;
|
||||||
protected String format;
|
protected String format;
|
||||||
protected int formatLen;
|
protected int formatLen;
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
// <editor-fold desc="Constructor">
|
// <editor-fold desc="Constructor">
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public Column(){
|
public Column(){
|
||||||
this("Column", DataType.OBJECT);
|
this("Column", DataType.OBJECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param name Name
|
* @param name Name
|
||||||
*/
|
*/
|
||||||
public Column(String name){
|
public Column(String name){
|
||||||
this(name, DataType.OBJECT);
|
this(name, DataType.OBJECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param name Name
|
* @param name Name
|
||||||
* @param dataType Data type
|
* @param dataType Data type
|
||||||
*/
|
*/
|
||||||
public Column(String name, DataType dataType) {
|
public Column(String name, DataType dataType) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.dataType = dataType;
|
this.dataType = dataType;
|
||||||
this.updateFormat();
|
this.updateFormat();
|
||||||
}
|
}
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
// <editor-fold desc="Get Set Methods">
|
// <editor-fold desc="Get Set Methods">
|
||||||
/**
|
/**
|
||||||
* Get name
|
* Get name
|
||||||
* @return Name
|
* @return Name
|
||||||
*/
|
*/
|
||||||
public String getName(){
|
public String getName(){
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set name
|
* Set name
|
||||||
* @param value Name
|
* @param value Name
|
||||||
*/
|
*/
|
||||||
public void setName(String value){
|
public void setName(String value){
|
||||||
this.name = value;
|
this.name = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get data type
|
* Get data type
|
||||||
* @return Data type
|
* @return Data type
|
||||||
*/
|
*/
|
||||||
public DataType getDataType(){
|
public DataType getDataType(){
|
||||||
return this.dataType;
|
return this.dataType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set data type
|
* Set data type
|
||||||
* @param value Data type
|
* @param value Data type
|
||||||
*/
|
*/
|
||||||
public void setDataType(DataType value) {
|
public void setDataType(DataType value) {
|
||||||
this.dataType = value;
|
this.dataType = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get format
|
* Get format
|
||||||
* @return Format
|
* @return Format
|
||||||
*/
|
*/
|
||||||
public String getFormat(){
|
public String getFormat(){
|
||||||
return this.format;
|
return this.format;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Name format
|
* Get Name format
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getNameFormat() {
|
public String getNameFormat() {
|
||||||
return "%" + String.valueOf(this.formatLen) + "s";
|
return "%" + String.valueOf(this.formatLen) + "s";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set format
|
* Set format
|
||||||
* @param value Format
|
* @param value Format
|
||||||
*/
|
*/
|
||||||
public void setFormat(String value){
|
public void setFormat(String value){
|
||||||
this.format = value;
|
this.format = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get format length
|
* Get format length
|
||||||
* @return Format length
|
* @return Format length
|
||||||
*/
|
*/
|
||||||
public int getFormatLen(){
|
public int getFormatLen(){
|
||||||
return this.formatLen;
|
return this.formatLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set format length
|
* Set format length
|
||||||
* @param value Format length
|
* @param value Format length
|
||||||
*/
|
*/
|
||||||
public void setFormatLen(int value) {
|
public void setFormatLen(int value) {
|
||||||
this.formatLen = value;
|
this.formatLen = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
// <editor-fold desc="Methods">
|
// <editor-fold desc="Methods">
|
||||||
/**
|
/**
|
||||||
* Factory method
|
* Factory method
|
||||||
* @param name Name
|
* @param name Name
|
||||||
* @param dtype Data type
|
* @param dtype Data type
|
||||||
* @return Column
|
* @return Column
|
||||||
*/
|
*/
|
||||||
public static Column factory(String name, DataType dtype){
|
public static Column factory(String name, DataType dtype){
|
||||||
return new Column(name, dtype);
|
return new Column(name, dtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method
|
* Factory method
|
||||||
* @param name Name
|
* @param name Name
|
||||||
* @param array Data array
|
* @param array Data array
|
||||||
* @return Column
|
* @return Column
|
||||||
*/
|
*/
|
||||||
public static Column factory(String name, Array array){
|
public static Column factory(String name, Array array){
|
||||||
DataType dtype = array.getDataType();
|
DataType dtype = array.getDataType();
|
||||||
if (dtype == DataType.OBJECT && (array.getObject(0) instanceof DateTime)){
|
if (dtype == DataType.OBJECT && (array.getObject(0) instanceof DateTime)){
|
||||||
DateTimeColumn col = new DateTimeColumn(name);
|
DateTimeColumn col = new DateTimeColumn(name);
|
||||||
col.updateFormat(array);
|
col.updateFormat(array);
|
||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
return new Column(name, dtype);
|
return new Column(name, dtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update format
|
* Update format
|
||||||
*/
|
*/
|
||||||
public void updateFormat(){
|
public void updateFormat(){
|
||||||
this.format = null;
|
this.format = null;
|
||||||
switch (this.dataType){
|
switch (this.dataType){
|
||||||
case FLOAT:
|
case FLOAT:
|
||||||
case DOUBLE:
|
case DOUBLE:
|
||||||
this.format = "%f";
|
this.format = "%f";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this.formatLen = this.name.length();
|
this.formatLen = this.name.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update format
|
* Update format
|
||||||
* @param data Data array
|
* @param data Data array
|
||||||
*/
|
*/
|
||||||
public void updateFormat(Array data) {
|
public void updateFormat(Array data) {
|
||||||
this.formatLen = this.name.length();
|
this.formatLen = this.name.length();
|
||||||
switch(this.dataType) {
|
switch(this.dataType) {
|
||||||
case DOUBLE:
|
case DOUBLE:
|
||||||
case FLOAT:
|
case FLOAT:
|
||||||
double dmax = ArrayMath.max(data).doubleValue();
|
double dmax = ArrayMath.max(data).doubleValue();
|
||||||
DecimalFormat df = new DecimalFormat("0.0");
|
DecimalFormat df = new DecimalFormat("0.0");
|
||||||
df.setMaximumFractionDigits(6);
|
df.setMaximumFractionDigits(6);
|
||||||
int nf = 1, ci, nn;
|
int nf = 1, ci, nn;
|
||||||
String str;
|
String str;
|
||||||
for (int i = 0; i < data.getSize(); i++){
|
for (int i = 0; i < data.getSize(); i++){
|
||||||
str = df.format(data.getDouble(i));
|
str = df.format(data.getDouble(i));
|
||||||
ci = str.indexOf(".");
|
ci = str.indexOf(".");
|
||||||
nn = str.length() - ci - 1;
|
nn = str.length() - ci - 1;
|
||||||
if (nf < nn) {
|
if (nf < nn) {
|
||||||
nf = nn;
|
nf = nn;
|
||||||
if (nf == 6)
|
if (nf == 6)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String smax = df.format(dmax);
|
String smax = df.format(dmax);
|
||||||
ci = smax.indexOf(".");
|
ci = smax.indexOf(".");
|
||||||
int len = ci + nf + 2;
|
int len = ci + nf + 2;
|
||||||
formatLen = Math.max(formatLen, len);
|
formatLen = Math.max(formatLen, len);
|
||||||
this.format = "%" + String.valueOf(formatLen) + "." + String.valueOf(nf) + "f";
|
this.format = "%" + String.valueOf(formatLen) + "." + String.valueOf(nf) + "f";
|
||||||
break;
|
break;
|
||||||
case INT:
|
case INT:
|
||||||
int imax = (int)ArrayMath.max(data);
|
int imax = (int)ArrayMath.max(data);
|
||||||
smax = Integer.toString(imax);
|
smax = Integer.toString(imax);
|
||||||
formatLen = Math.max(formatLen, smax.length());
|
formatLen = Math.max(formatLen, smax.length());
|
||||||
this.format = "%" + String.valueOf(formatLen) + "d";
|
this.format = "%" + String.valueOf(formatLen) + "d";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
String v;
|
String v;
|
||||||
for (int i = 0; i < data.getSize(); i++){
|
for (int i = 0; i < data.getSize(); i++){
|
||||||
if (data.getObject(i) == null)
|
if (data.getObject(i) == null)
|
||||||
v = "null";
|
v = "null";
|
||||||
else
|
else
|
||||||
v = data.getObject(i).toString();
|
v = data.getObject(i).toString();
|
||||||
if (formatLen < v.length())
|
if (formatLen < v.length())
|
||||||
formatLen = v.length();
|
formatLen = v.length();
|
||||||
}
|
}
|
||||||
this.format = "%" + String.valueOf(formatLen) + "s";
|
this.format = "%" + String.valueOf(formatLen) + "s";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert input data to current data type
|
* Convert input data to current data type
|
||||||
*
|
*
|
||||||
* @param value Object value
|
* @param value Object value
|
||||||
* @return Result object
|
* @return Result object
|
||||||
*/
|
*/
|
||||||
public Object convertTo(Object value) {
|
public Object convertTo(Object value) {
|
||||||
return DataConvert.convertTo(value, this.dataType, this.format);
|
return DataConvert.convertTo(value, this.dataType, this.format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert input data to current data type
|
* Convert input data to current data type
|
||||||
* @param s Input string
|
* @param s Input string
|
||||||
* @return Result object
|
* @return Result object
|
||||||
*/
|
*/
|
||||||
public Object convertStringTo(String s) {
|
public Object convertStringTo(String s) {
|
||||||
return DataConvert.convertStringTo(s, dataType, format);
|
return DataConvert.convertStringTo(s, dataType, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(){
|
public String toString(){
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert an object (same datatype with this column) to string
|
* Convert an object (same datatype with this column) to string
|
||||||
* @param o
|
* @param o
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
public String toString(Object o){
|
public String toString(Object o){
|
||||||
if (format == null)
|
if (format == null)
|
||||||
return o.toString();
|
return o.toString();
|
||||||
else
|
else
|
||||||
return String.format(format, o);
|
return String.format(format, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return Column
|
* @return Column
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
Column col = new Column(this.name, this.dataType);
|
Column col = new Column(this.name, this.dataType);
|
||||||
col.setFormat(this.format);
|
col.setFormat(this.format);
|
||||||
col.setFormatLen(this.formatLen);
|
col.setFormatLen(this.formatLen);
|
||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,9 +28,9 @@ import java.util.Set;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.meteoinfo.global.util.JDateUtil;
|
import org.meteoinfo.common.util.GlobalUtil;
|
||||||
import org.meteoinfo.math.ArrayMath;
|
import org.meteoinfo.common.util.JDateUtil;
|
||||||
import org.meteoinfo.math.ArrayUtil;
|
import org.meteoinfo.common.util.TypeUtils;
|
||||||
import org.meteoinfo.data.dataframe.impl.Aggregation;
|
import org.meteoinfo.data.dataframe.impl.Aggregation;
|
||||||
import org.meteoinfo.data.dataframe.impl.Function;
|
import org.meteoinfo.data.dataframe.impl.Function;
|
||||||
import org.meteoinfo.data.dataframe.impl.Grouping;
|
import org.meteoinfo.data.dataframe.impl.Grouping;
|
||||||
@ -40,8 +40,8 @@ import org.meteoinfo.data.dataframe.impl.Sorting;
|
|||||||
import org.meteoinfo.data.dataframe.impl.Views;
|
import org.meteoinfo.data.dataframe.impl.Views;
|
||||||
import org.meteoinfo.data.dataframe.impl.WindowFunction;
|
import org.meteoinfo.data.dataframe.impl.WindowFunction;
|
||||||
import org.meteoinfo.global.DataConvert;
|
import org.meteoinfo.global.DataConvert;
|
||||||
import org.meteoinfo.global.util.GlobalUtil;
|
import org.meteoinfo.math.ArrayMath;
|
||||||
import org.meteoinfo.global.util.TypeUtils;
|
import org.meteoinfo.math.ArrayUtil;
|
||||||
import org.meteoinfo.ndarray.Array;
|
import org.meteoinfo.ndarray.Array;
|
||||||
import org.meteoinfo.ndarray.InvalidRangeException;
|
import org.meteoinfo.ndarray.InvalidRangeException;
|
||||||
import org.meteoinfo.ndarray.Range;
|
import org.meteoinfo.ndarray.Range;
|
||||||
|
|||||||
@ -13,11 +13,11 @@ import java.util.List;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.temporal.TemporalAmount;
|
import java.time.temporal.TemporalAmount;
|
||||||
|
|
||||||
import org.meteoinfo.math.ArrayMath;
|
import org.meteoinfo.common.util.JDateUtil;
|
||||||
import org.meteoinfo.global.DataConvert;
|
import org.meteoinfo.global.DataConvert;
|
||||||
import org.meteoinfo.global.util.JDateUtil;
|
|
||||||
import org.meteoinfo.ndarray.Array;
|
import org.meteoinfo.ndarray.Array;
|
||||||
import org.meteoinfo.ndarray.DataType;
|
import org.meteoinfo.ndarray.DataType;
|
||||||
|
import org.meteoinfo.math.ArrayMath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@ -10,8 +10,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.meteoinfo.common.MIMath;
|
||||||
import org.meteoinfo.math.ArrayMath;
|
import org.meteoinfo.math.ArrayMath;
|
||||||
import org.meteoinfo.global.MIMath;
|
|
||||||
import org.meteoinfo.ndarray.Array;
|
import org.meteoinfo.ndarray.Array;
|
||||||
import org.meteoinfo.ndarray.DataType;
|
import org.meteoinfo.ndarray.DataType;
|
||||||
|
|
||||||
|
|||||||
@ -15,14 +15,15 @@ import java.util.ArrayList;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
import org.meteoinfo.global.util.JDateUtil;
|
|
||||||
import org.meteoinfo.math.ArrayMath;
|
import org.meteoinfo.common.util.JDateUtil;
|
||||||
import org.meteoinfo.data.dataframe.impl.Grouping;
|
import org.meteoinfo.data.dataframe.impl.Grouping;
|
||||||
import org.meteoinfo.data.dataframe.impl.KeyFunction;
|
import org.meteoinfo.data.dataframe.impl.KeyFunction;
|
||||||
import org.meteoinfo.data.dataframe.impl.TimeFunction;
|
import org.meteoinfo.data.dataframe.impl.TimeFunction;
|
||||||
import org.meteoinfo.data.dataframe.impl.TimeFunctions;
|
import org.meteoinfo.data.dataframe.impl.TimeFunctions;
|
||||||
import org.meteoinfo.data.dataframe.impl.Views;
|
import org.meteoinfo.data.dataframe.impl.Views;
|
||||||
import org.meteoinfo.data.dataframe.impl.WindowFunction;
|
import org.meteoinfo.data.dataframe.impl.WindowFunction;
|
||||||
|
import org.meteoinfo.math.ArrayMath;
|
||||||
import org.meteoinfo.ndarray.Array;
|
import org.meteoinfo.ndarray.Array;
|
||||||
import org.meteoinfo.ndarray.DataType;
|
import org.meteoinfo.ndarray.DataType;
|
||||||
import org.meteoinfo.ndarray.InvalidRangeException;
|
import org.meteoinfo.ndarray.InvalidRangeException;
|
||||||
|
|||||||
@ -26,10 +26,11 @@ import java.util.LinkedHashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.meteoinfo.math.ArrayUtil;
|
|
||||||
import org.meteoinfo.data.dataframe.DataFrame;
|
import org.meteoinfo.data.dataframe.DataFrame;
|
||||||
import org.meteoinfo.data.dataframe.Series;
|
import org.meteoinfo.data.dataframe.Series;
|
||||||
import org.meteoinfo.data.dataframe.impl.Transforms.CumulativeFunction;
|
import org.meteoinfo.data.dataframe.impl.Transforms.CumulativeFunction;
|
||||||
|
import org.meteoinfo.math.ArrayUtil;
|
||||||
import org.meteoinfo.ndarray.Array;
|
import org.meteoinfo.ndarray.Array;
|
||||||
|
|
||||||
public class Grouping
|
public class Grouping
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.meteoinfo.data.dataframe.impl;
|
package org.meteoinfo.data.dataframe.impl;
|
||||||
|
|
||||||
import org.meteoinfo.global.util.JDateUtil;
|
import org.meteoinfo.common.util.JDateUtil;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.Period;
|
import java.time.Period;
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import org.meteoinfo.table.DataColumn;
|
|||||||
import org.meteoinfo.table.DataRow;
|
import org.meteoinfo.table.DataRow;
|
||||||
import org.meteoinfo.table.DataTable;
|
import org.meteoinfo.table.DataTable;
|
||||||
import org.meteoinfo.ndarray.DataType;
|
import org.meteoinfo.ndarray.DataType;
|
||||||
import org.meteoinfo.io.EndianDataOutputStream;
|
import org.meteoinfo.common.io.EndianDataOutputStream;
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
|
|||||||
@ -13,13 +13,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.meteoinfo.data.mapdata;
|
package org.meteoinfo.data.mapdata;
|
||||||
|
|
||||||
|
import org.meteoinfo.common.Extent;
|
||||||
|
import org.meteoinfo.common.PointD;
|
||||||
|
import org.meteoinfo.common.util.GlobalUtil;
|
||||||
import org.meteoinfo.data.GridData;
|
import org.meteoinfo.data.GridData;
|
||||||
import org.meteoinfo.data.mapdata.geotiff.GeoTiff;
|
import org.meteoinfo.data.mapdata.geotiff.GeoTiff;
|
||||||
import org.meteoinfo.data.meteodata.DrawMeteoData;
|
import org.meteoinfo.data.meteodata.DrawMeteoData;
|
||||||
import org.meteoinfo.global.Extent;
|
import org.meteoinfo.geoprocess.GeometryUtil;
|
||||||
import org.meteoinfo.global.util.GlobalUtil;
|
|
||||||
import org.meteoinfo.global.MIMath;
|
|
||||||
import org.meteoinfo.global.PointD;
|
|
||||||
import org.meteoinfo.ndarray.DataType;
|
import org.meteoinfo.ndarray.DataType;
|
||||||
import org.meteoinfo.layer.ImageLayer;
|
import org.meteoinfo.layer.ImageLayer;
|
||||||
import org.meteoinfo.layer.LayerDrawType;
|
import org.meteoinfo.layer.LayerDrawType;
|
||||||
@ -53,7 +53,7 @@ import org.meteoinfo.data.meteodata.ascii.ASCIIGridDataInfo;
|
|||||||
import org.meteoinfo.data.meteodata.ascii.SurferGridDataInfo;
|
import org.meteoinfo.data.meteodata.ascii.SurferGridDataInfo;
|
||||||
import org.meteoinfo.data.meteodata.bandraster.BILDataInfo;
|
import org.meteoinfo.data.meteodata.bandraster.BILDataInfo;
|
||||||
import org.meteoinfo.global.DataConvert;
|
import org.meteoinfo.global.DataConvert;
|
||||||
import org.meteoinfo.io.IOUtil;
|
import org.meteoinfo.common.io.IOUtil;
|
||||||
import org.meteoinfo.layer.RasterLayer;
|
import org.meteoinfo.layer.RasterLayer;
|
||||||
import org.meteoinfo.legend.LegendScheme;
|
import org.meteoinfo.legend.LegendScheme;
|
||||||
import org.meteoinfo.legend.LegendType;
|
import org.meteoinfo.legend.LegendType;
|
||||||
@ -293,7 +293,7 @@ public class MapDataManage {
|
|||||||
PolylineShape aPolyline = new PolylineShape();
|
PolylineShape aPolyline = new PolylineShape();
|
||||||
aPolyline.setValue(lineNum);
|
aPolyline.setValue(lineNum);
|
||||||
aPolyline.setPoints(pList);
|
aPolyline.setPoints(pList);
|
||||||
aPolyline.setExtent(MIMath.getPointsExtent(pList));
|
aPolyline.setExtent(GeometryUtil.getPointsExtent(pList));
|
||||||
aPolyline.setPartNum(1);
|
aPolyline.setPartNum(1);
|
||||||
aPolyline.parts = new int[1];
|
aPolyline.parts = new int[1];
|
||||||
aPolyline.parts[0] = 0;
|
aPolyline.parts[0] = 0;
|
||||||
@ -521,7 +521,7 @@ public class MapDataManage {
|
|||||||
}
|
}
|
||||||
PolylineShape aPLS = new PolylineShape();
|
PolylineShape aPLS = new PolylineShape();
|
||||||
aPLS.setValue(i);
|
aPLS.setValue(i);
|
||||||
aPLS.setExtent(MIMath.getPointsExtent(pList));
|
aPLS.setExtent(GeometryUtil.getPointsExtent(pList));
|
||||||
aPLS.setPoints(pList);
|
aPLS.setPoints(pList);
|
||||||
|
|
||||||
int sNum = aLayer.getShapeNum();
|
int sNum = aLayer.getShapeNum();
|
||||||
@ -554,7 +554,7 @@ public class MapDataManage {
|
|||||||
PolygonShape aPGS = new PolygonShape();
|
PolygonShape aPGS = new PolygonShape();
|
||||||
aPGS.lowValue = i;
|
aPGS.lowValue = i;
|
||||||
aPGS.highValue = i;
|
aPGS.highValue = i;
|
||||||
aPGS.setExtent(MIMath.getPointsExtent(pList));
|
aPGS.setExtent(GeometryUtil.getPointsExtent(pList));
|
||||||
aPGS.setPoints(pList);
|
aPGS.setPoints(pList);
|
||||||
|
|
||||||
int sNum = aLayer.getShapeNum();
|
int sNum = aLayer.getShapeNum();
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -28,12 +28,13 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.meteoinfo.math.ArrayMath;
|
|
||||||
import org.meteoinfo.data.GridArray;
|
import org.meteoinfo.data.GridArray;
|
||||||
import org.meteoinfo.data.mapdata.geotiff.compression.CompressionDecoder;
|
import org.meteoinfo.data.mapdata.geotiff.compression.CompressionDecoder;
|
||||||
import org.meteoinfo.data.mapdata.geotiff.compression.DeflateCompression;
|
import org.meteoinfo.data.mapdata.geotiff.compression.DeflateCompression;
|
||||||
import org.meteoinfo.data.mapdata.geotiff.compression.LZWCompression;
|
import org.meteoinfo.data.mapdata.geotiff.compression.LZWCompression;
|
||||||
import org.meteoinfo.global.DataConvert;
|
import org.meteoinfo.global.DataConvert;
|
||||||
|
import org.meteoinfo.math.ArrayMath;
|
||||||
import org.meteoinfo.ndarray.util.BigDecimalUtil;
|
import org.meteoinfo.ndarray.util.BigDecimalUtil;
|
||||||
import org.meteoinfo.projection.KnownCoordinateSystems;
|
import org.meteoinfo.projection.KnownCoordinateSystems;
|
||||||
import org.meteoinfo.projection.info.ProjectionInfo;
|
import org.meteoinfo.projection.info.ProjectionInfo;
|
||||||
|
|||||||
@ -1,452 +1,452 @@
|
|||||||
package org.meteoinfo.data.mapdata.webmap;
|
package org.meteoinfo.data.mapdata.webmap;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.ref.SoftReference;
|
import java.lang.ref.SoftReference;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.PriorityBlockingQueue;
|
import java.util.concurrent.PriorityBlockingQueue;
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import org.meteoinfo.global.util.GeoUtil;
|
import org.meteoinfo.common.util.GraphicsUtilities;
|
||||||
import org.meteoinfo.global.util.GraphicsUtilities;
|
import org.meteoinfo.global.util.GeoUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The
|
* The
|
||||||
* <code>AbstractTileFactory</code> provides a basic implementation for the
|
* <code>AbstractTileFactory</code> provides a basic implementation for the
|
||||||
* TileFactory.
|
* TileFactory.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractTileFactory extends TileFactory {
|
public abstract class AbstractTileFactory extends TileFactory {
|
||||||
|
|
||||||
private static final Logger LOG = Logger.getLogger(AbstractTileFactory.class.getName());
|
private static final Logger LOG = Logger.getLogger(AbstractTileFactory.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of DefaultTileFactory using the spcified
|
* Creates a new instance of DefaultTileFactory using the spcified
|
||||||
* TileFactoryInfo
|
* TileFactoryInfo
|
||||||
*
|
*
|
||||||
* @param info a TileFactoryInfo to configure this TileFactory
|
* @param info a TileFactoryInfo to configure this TileFactory
|
||||||
*/
|
*/
|
||||||
public AbstractTileFactory(TileFactoryInfo info) {
|
public AbstractTileFactory(TileFactoryInfo info) {
|
||||||
super(info);
|
super(info);
|
||||||
}
|
}
|
||||||
//private static final boolean doEagerLoading = true;
|
//private static final boolean doEagerLoading = true;
|
||||||
private int threadPoolSize = 4;
|
private int threadPoolSize = 4;
|
||||||
private ExecutorService service;
|
private ExecutorService service;
|
||||||
//TODO the tile map should be static ALWAYS, regardless of the number
|
//TODO the tile map should be static ALWAYS, regardless of the number
|
||||||
//of GoogleTileFactories because each tile is, really, a singleton.
|
//of GoogleTileFactories because each tile is, really, a singleton.
|
||||||
private final Map<String, Tile> tileMap = new HashMap<>();
|
private final Map<String, Tile> tileMap = new HashMap<>();
|
||||||
private TileCache cache = new TileCache();
|
private TileCache cache = new TileCache();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns
|
* Returns
|
||||||
*
|
*
|
||||||
* @param pixelCoordinate
|
* @param pixelCoordinate
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
//public TilePoint getTileCoordinate(Point2D pixelCoordinate) {
|
//public TilePoint getTileCoordinate(Point2D pixelCoordinate) {
|
||||||
// return GeoUtil.getTileCoordinate(pixelCoordinate, getInfo());
|
// return GeoUtil.getTileCoordinate(pixelCoordinate, getInfo());
|
||||||
//}
|
//}
|
||||||
/**
|
/**
|
||||||
* Returns the tile that is located at the given tilePoint for this zoom.
|
* Returns the tile that is located at the given tilePoint for this zoom.
|
||||||
* For example, if getMapSize() returns 10x20 for this zoom, and the
|
* For example, if getMapSize() returns 10x20 for this zoom, and the
|
||||||
* tilePoint is (3,5), then the appropriate tile will be located and
|
* tilePoint is (3,5), then the appropriate tile will be located and
|
||||||
* returned.
|
* returned.
|
||||||
*
|
*
|
||||||
* @param x X index
|
* @param x X index
|
||||||
* @param y Y index
|
* @param y Y index
|
||||||
* @param zoom Zoom value
|
* @param zoom Zoom value
|
||||||
* @return Tile
|
* @return Tile
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Tile getTile(int x, int y, int zoom) {
|
public Tile getTile(int x, int y, int zoom) {
|
||||||
return getTile(x, y, zoom, true);
|
return getTile(x, y, zoom, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Tile getTile(int tpx, int tpy, int zoom, boolean eagerLoad) {
|
private Tile getTile(int tpx, int tpy, int zoom, boolean eagerLoad) {
|
||||||
//wrap the tiles horizontally --> mod the X with the max width
|
//wrap the tiles horizontally --> mod the X with the max width
|
||||||
//and use that
|
//and use that
|
||||||
int tileX = tpx;//tilePoint.getX();
|
int tileX = tpx;//tilePoint.getX();
|
||||||
int numTilesWide = (int) getMapSize(zoom).getWidth();
|
int numTilesWide = (int) getMapSize(zoom).getWidth();
|
||||||
if (tileX < 0) {
|
if (tileX < 0) {
|
||||||
tileX = numTilesWide - (Math.abs(tileX) % numTilesWide);
|
tileX = numTilesWide - (Math.abs(tileX) % numTilesWide);
|
||||||
}
|
}
|
||||||
|
|
||||||
tileX = tileX % numTilesWide;
|
tileX = tileX % numTilesWide;
|
||||||
int tileY = tpy;
|
int tileY = tpy;
|
||||||
//TilePoint tilePoint = new TilePoint(tileX, tpy);
|
//TilePoint tilePoint = new TilePoint(tileX, tpy);
|
||||||
String url = getInfo().getTileUrl(tileX, tileY, zoom);//tilePoint);
|
String url = getInfo().getTileUrl(tileX, tileY, zoom);//tilePoint);
|
||||||
//System.out.println("loading: " + url);
|
//System.out.println("loading: " + url);
|
||||||
|
|
||||||
|
|
||||||
Tile.Priority pri = Tile.Priority.High;
|
Tile.Priority pri = Tile.Priority.High;
|
||||||
if (!eagerLoad) {
|
if (!eagerLoad) {
|
||||||
pri = Tile.Priority.Low;
|
pri = Tile.Priority.Low;
|
||||||
}
|
}
|
||||||
Tile tile = null;
|
Tile tile = null;
|
||||||
//System.out.println("testing for validity: " + tilePoint + " zoom = " + zoom);
|
//System.out.println("testing for validity: " + tilePoint + " zoom = " + zoom);
|
||||||
if (!tileMap.containsKey(url)) {
|
if (!tileMap.containsKey(url)) {
|
||||||
if (!GeoUtil.isValidTile(tileX, tileY, zoom, getInfo())) {
|
if (!GeoUtil.isValidTile(tileX, tileY, zoom, getInfo())) {
|
||||||
tile = new Tile(tileX, tileY, zoom);
|
tile = new Tile(tileX, tileY, zoom);
|
||||||
} else {
|
} else {
|
||||||
tile = new Tile(tileX, tileY, zoom, url, pri, this);
|
tile = new Tile(tileX, tileY, zoom, url, pri, this);
|
||||||
//load(tile);
|
//load(tile);
|
||||||
startLoading(tile);
|
startLoading(tile);
|
||||||
}
|
}
|
||||||
tileMap.put(url, tile);
|
tileMap.put(url, tile);
|
||||||
} else {
|
} else {
|
||||||
tile = tileMap.get(url);
|
tile = tileMap.get(url);
|
||||||
// if its in the map but is low and isn't loaded yet
|
// if its in the map but is low and isn't loaded yet
|
||||||
// but we are in high mode
|
// but we are in high mode
|
||||||
if (tile.getPriority() == Tile.Priority.Low && eagerLoad && !tile.isLoaded()) {
|
if (tile.getPriority() == Tile.Priority.Low && eagerLoad && !tile.isLoaded()) {
|
||||||
//System.out.println("in high mode and want a low");
|
//System.out.println("in high mode and want a low");
|
||||||
//tile.promote();
|
//tile.promote();
|
||||||
promote(tile);
|
promote(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (eagerLoad && doEagerLoading) {
|
if (eagerLoad && doEagerLoading) {
|
||||||
for (int i = 0; i<1; i++) {
|
for (int i = 0; i<1; i++) {
|
||||||
for (int j = 0; j<1; j++) {
|
for (int j = 0; j<1; j++) {
|
||||||
// preload the 4 tiles under the current one
|
// preload the 4 tiles under the current one
|
||||||
if(zoom > 0) {
|
if(zoom > 0) {
|
||||||
eagerlyLoad(tilePoint.getX()*2, tilePoint.getY()*2, zoom-1);
|
eagerlyLoad(tilePoint.getX()*2, tilePoint.getY()*2, zoom-1);
|
||||||
eagerlyLoad(tilePoint.getX()*2+1, tilePoint.getY()*2, zoom-1);
|
eagerlyLoad(tilePoint.getX()*2+1, tilePoint.getY()*2, zoom-1);
|
||||||
eagerlyLoad(tilePoint.getX()*2, tilePoint.getY()*2+1, zoom-1);
|
eagerlyLoad(tilePoint.getX()*2, tilePoint.getY()*2+1, zoom-1);
|
||||||
eagerlyLoad(tilePoint.getX()*2+1, tilePoint.getY()*2+1, zoom-1);
|
eagerlyLoad(tilePoint.getX()*2+1, tilePoint.getY()*2+1, zoom-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
return tile;
|
return tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
private void eagerlyLoad(int x, int y, int zoom) {
|
private void eagerlyLoad(int x, int y, int zoom) {
|
||||||
TilePoint t1 = new TilePoint(x,y);
|
TilePoint t1 = new TilePoint(x,y);
|
||||||
if(!isLoaded(t1,zoom)) {
|
if(!isLoaded(t1,zoom)) {
|
||||||
getTile(t1,zoom,false);
|
getTile(t1,zoom,false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
// private boolean isLoaded(int x, int y, int zoom) {
|
// private boolean isLoaded(int x, int y, int zoom) {
|
||||||
// String url = getInfo().getTileUrl(zoom,x,y);
|
// String url = getInfo().getTileUrl(zoom,x,y);
|
||||||
// return tileMap.containsKey(url);
|
// return tileMap.containsKey(url);
|
||||||
// }
|
// }
|
||||||
public TileCache getTileCache() {
|
public TileCache getTileCache() {
|
||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTileCache(TileCache cache) {
|
public void setTileCache(TileCache cache) {
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* ==== threaded tile loading stuff ===
|
* ==== threaded tile loading stuff ===
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Thread pool for loading the tiles
|
* Thread pool for loading the tiles
|
||||||
*/
|
*/
|
||||||
private static final BlockingQueue<Tile> tileQueue = new PriorityBlockingQueue<>(5,
|
private static final BlockingQueue<Tile> tileQueue = new PriorityBlockingQueue<>(5,
|
||||||
new Comparator<Tile>() {
|
new Comparator<Tile>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Tile o1, Tile o2) {
|
public int compare(Tile o1, Tile o2) {
|
||||||
if (o1.getPriority() == Tile.Priority.Low && o2.getPriority() == Tile.Priority.High) {
|
if (o1.getPriority() == Tile.Priority.Low && o2.getPriority() == Tile.Priority.High) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (o1.getPriority() == Tile.Priority.High && o2.getPriority() == Tile.Priority.Low) {
|
if (o1.getPriority() == Tile.Priority.High && o2.getPriority() == Tile.Priority.Low) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
return obj == this;
|
return obj == this;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclasses may override this method to provide their own executor
|
* Subclasses may override this method to provide their own executor
|
||||||
* services. This method will be called each time a tile needs to be loaded.
|
* services. This method will be called each time a tile needs to be loaded.
|
||||||
* Implementations should cache the ExecutorService when possible.
|
* Implementations should cache the ExecutorService when possible.
|
||||||
*
|
*
|
||||||
* @return ExecutorService to load tiles with
|
* @return ExecutorService to load tiles with
|
||||||
*/
|
*/
|
||||||
protected synchronized ExecutorService getService() {
|
protected synchronized ExecutorService getService() {
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
//System.out.println("creating an executor service with a threadpool of size " + threadPoolSize);
|
//System.out.println("creating an executor service with a threadpool of size " + threadPoolSize);
|
||||||
service = Executors.newFixedThreadPool(threadPoolSize, new ThreadFactory() {
|
service = Executors.newFixedThreadPool(threadPoolSize, new ThreadFactory() {
|
||||||
private int count = 0;
|
private int count = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable r) {
|
public Thread newThread(Runnable r) {
|
||||||
Thread t = new Thread(r, "tile-pool-" + count++);
|
Thread t = new Thread(r, "tile-pool-" + count++);
|
||||||
t.setPriority(Thread.MIN_PRIORITY);
|
t.setPriority(Thread.MIN_PRIORITY);
|
||||||
t.setDaemon(true);
|
t.setDaemon(true);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return service;
|
return service;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the number of threads to use for loading the tiles. This controls the
|
* Set the number of threads to use for loading the tiles. This controls the
|
||||||
* number of threads used by the ExecutorService returned from getService().
|
* number of threads used by the ExecutorService returned from getService().
|
||||||
* Note, this method should be called before loading the first tile. Calls
|
* Note, this method should be called before loading the first tile. Calls
|
||||||
* after the first tile are loaded will have no effect by default.
|
* after the first tile are loaded will have no effect by default.
|
||||||
*
|
*
|
||||||
* @param size
|
* @param size
|
||||||
*/
|
*/
|
||||||
public void setThreadPoolSize(int size) {
|
public void setThreadPoolSize(int size) {
|
||||||
if (size <= 0) {
|
if (size <= 0) {
|
||||||
throw new IllegalArgumentException("size invalid: " + size + ". The size of the threadpool must be greater than 0.");
|
throw new IllegalArgumentException("size invalid: " + size + ". The size of the threadpool must be greater than 0.");
|
||||||
}
|
}
|
||||||
threadPoolSize = size;
|
threadPoolSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected synchronized void startLoading(Tile tile) {
|
protected synchronized void startLoading(Tile tile) {
|
||||||
if (tile.isLoading()) {
|
if (tile.isLoading()) {
|
||||||
System.out.println("already loading. bailing");
|
System.out.println("already loading. bailing");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tile.setLoading(true);
|
tile.setLoading(true);
|
||||||
try {
|
try {
|
||||||
tileQueue.put(tile);
|
tileQueue.put(tile);
|
||||||
getService().submit(createTileRunner(tile));
|
getService().submit(createTileRunner(tile));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(Tile tile) {
|
public void load(Tile tile) {
|
||||||
/*
|
/*
|
||||||
* 3 strikes and you're out. Attempt to load the url. If it fails,
|
* 3 strikes and you're out. Attempt to load the url. If it fails,
|
||||||
* decrement the number of tries left and try again. Log failures.
|
* decrement the number of tries left and try again. Log failures.
|
||||||
* If I run out of try s just get out. This way, if there is some
|
* If I run out of try s just get out. This way, if there is some
|
||||||
* kind of serious failure, I can get out and let other tiles
|
* kind of serious failure, I can get out and let other tiles
|
||||||
* try to load.
|
* try to load.
|
||||||
*/
|
*/
|
||||||
//final Tile tile = tileQueue.remove();
|
//final Tile tile = tileQueue.remove();
|
||||||
|
|
||||||
int trys = 3;
|
int trys = 3;
|
||||||
while (!tile.isLoaded() && trys > 0) {
|
while (!tile.isLoaded() && trys > 0) {
|
||||||
try {
|
try {
|
||||||
BufferedImage img = null;
|
BufferedImage img = null;
|
||||||
URI uri = getURI(tile);
|
URI uri = getURI(tile);
|
||||||
img = cache.get(uri);
|
img = cache.get(uri);
|
||||||
if (img == null) {
|
if (img == null) {
|
||||||
byte[] bimg = cacheInputStream(uri.toURL());
|
byte[] bimg = cacheInputStream(uri.toURL());
|
||||||
img = GraphicsUtilities.loadCompatibleImage(new ByteArrayInputStream(bimg));//ImageIO.read(new URL(tile.url));
|
img = GraphicsUtilities.loadCompatibleImage(new ByteArrayInputStream(bimg));//ImageIO.read(new URL(tile.url));
|
||||||
cache.put(uri, bimg, img);
|
cache.put(uri, bimg, img);
|
||||||
img = cache.get(uri);
|
img = cache.get(uri);
|
||||||
}
|
}
|
||||||
if (img == null) {
|
if (img == null) {
|
||||||
System.out.println("error loading: " + uri);
|
System.out.println("error loading: " + uri);
|
||||||
LOG.log(Level.INFO, "Failed to load: " + uri);
|
LOG.log(Level.INFO, "Failed to load: " + uri);
|
||||||
trys--;
|
trys--;
|
||||||
} else {
|
} else {
|
||||||
final BufferedImage i = img;
|
final BufferedImage i = img;
|
||||||
tile.image = new SoftReference<>(i);
|
tile.image = new SoftReference<>(i);
|
||||||
tile.setLoaded(true);
|
tile.setLoaded(true);
|
||||||
}
|
}
|
||||||
} catch (OutOfMemoryError memErr) {
|
} catch (OutOfMemoryError memErr) {
|
||||||
cache.needMoreMemory();
|
cache.needMoreMemory();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
LOG.log(Level.SEVERE,
|
LOG.log(Level.SEVERE,
|
||||||
"Failed to load a tile at url: " + tile.getURL() + ", retrying", e);
|
"Failed to load a tile at url: " + tile.getURL() + ", retrying", e);
|
||||||
//temp
|
//temp
|
||||||
System.err.println("Failed to load a tile at url: " + tile.getURL());
|
System.err.println("Failed to load a tile at url: " + tile.getURL());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
///temp
|
///temp
|
||||||
Object oldError = tile.getError();
|
Object oldError = tile.getError();
|
||||||
tile.setError(e);
|
tile.setError(e);
|
||||||
tile.firePropertyChangeOnEDT("loadingError", oldError, e);
|
tile.firePropertyChangeOnEDT("loadingError", oldError, e);
|
||||||
if (trys == 0) {
|
if (trys == 0) {
|
||||||
tile.firePropertyChangeOnEDT("unrecoverableError", null, e);
|
tile.firePropertyChangeOnEDT("unrecoverableError", null, e);
|
||||||
} else {
|
} else {
|
||||||
trys--;
|
trys--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tile.setLoading(false);
|
tile.setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the full URI of a tile.
|
* Gets the full URI of a tile.
|
||||||
*
|
*
|
||||||
* @param tile
|
* @param tile
|
||||||
* @throws java.net.URISyntaxException
|
* @throws java.net.URISyntaxException
|
||||||
* @return URI
|
* @return URI
|
||||||
*/
|
*/
|
||||||
protected URI getURI(Tile tile) throws URISyntaxException {
|
protected URI getURI(Tile tile) throws URISyntaxException {
|
||||||
if (tile.getURL() == null) {
|
if (tile.getURL() == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new URI(tile.getURL());
|
return new URI(tile.getURL());
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] cacheInputStream(URL url) throws IOException {
|
private byte[] cacheInputStream(URL url) throws IOException {
|
||||||
InputStream ins = url.openStream();
|
InputStream ins = url.openStream();
|
||||||
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
||||||
byte[] buf = new byte[256];
|
byte[] buf = new byte[256];
|
||||||
while (true) {
|
while (true) {
|
||||||
int n = ins.read(buf);
|
int n = ins.read(buf);
|
||||||
if (n == -1) {
|
if (n == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bout.write(buf, 0, n);
|
bout.write(buf, 0, n);
|
||||||
}
|
}
|
||||||
return bout.toByteArray();
|
return bout.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclasses can override this if they need custom TileRunners for some
|
* Subclasses can override this if they need custom TileRunners for some
|
||||||
* reason
|
* reason
|
||||||
*
|
*
|
||||||
* @param tile Tile
|
* @param tile Tile
|
||||||
* @return Runnable
|
* @return Runnable
|
||||||
*/
|
*/
|
||||||
protected Runnable createTileRunner(Tile tile) {
|
protected Runnable createTileRunner(Tile tile) {
|
||||||
return new TileRunner();
|
return new TileRunner();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increase the priority of this tile so it will be loaded sooner.
|
* Increase the priority of this tile so it will be loaded sooner.
|
||||||
* @param tile Tile
|
* @param tile Tile
|
||||||
*/
|
*/
|
||||||
public synchronized void promote(Tile tile) {
|
public synchronized void promote(Tile tile) {
|
||||||
if (tileQueue.contains(tile)) {
|
if (tileQueue.contains(tile)) {
|
||||||
try {
|
try {
|
||||||
tileQueue.remove(tile);
|
tileQueue.remove(tile);
|
||||||
tile.setPriority(Tile.Priority.High);
|
tile.setPriority(Tile.Priority.High);
|
||||||
tileQueue.put(tile);
|
tileQueue.put(tile);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An inner class which actually loads the tiles. Used by the thread queue.
|
* An inner class which actually loads the tiles. Used by the thread queue.
|
||||||
* Subclasses can override this if necessary.
|
* Subclasses can override this if necessary.
|
||||||
*/
|
*/
|
||||||
private class TileRunner implements Runnable {
|
private class TileRunner implements Runnable {
|
||||||
//private Tile tile;
|
//private Tile tile;
|
||||||
//private BlockingQueue<Tile> tileQueue;
|
//private BlockingQueue<Tile> tileQueue;
|
||||||
|
|
||||||
//public TileRunner(BlockingQueue<Tile> tileQueue) {
|
//public TileRunner(BlockingQueue<Tile> tileQueue) {
|
||||||
//this.tileQueue = tileQueue;
|
//this.tileQueue = tileQueue;
|
||||||
//this.tile = tile;
|
//this.tile = tile;
|
||||||
//}
|
//}
|
||||||
/**
|
/**
|
||||||
* Gets the full URI of a tile.
|
* Gets the full URI of a tile.
|
||||||
*
|
*
|
||||||
* @param tile
|
* @param tile
|
||||||
* @throws java.net.URISyntaxException
|
* @throws java.net.URISyntaxException
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected URI getURI(Tile tile) throws URISyntaxException {
|
protected URI getURI(Tile tile) throws URISyntaxException {
|
||||||
if (tile.getURL() == null) {
|
if (tile.getURL() == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new URI(tile.getURL());
|
return new URI(tile.getURL());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* implementation of the Runnable interface.
|
* implementation of the Runnable interface.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
/*
|
/*
|
||||||
* 3 strikes and you're out. Attempt to load the url. If it fails,
|
* 3 strikes and you're out. Attempt to load the url. If it fails,
|
||||||
* decrement the number of tries left and try again. Log failures.
|
* decrement the number of tries left and try again. Log failures.
|
||||||
* If I run out of try s just get out. This way, if there is some
|
* If I run out of try s just get out. This way, if there is some
|
||||||
* kind of serious failure, I can get out and let other tiles
|
* kind of serious failure, I can get out and let other tiles
|
||||||
* try to load.
|
* try to load.
|
||||||
*/
|
*/
|
||||||
final Tile tile = tileQueue.remove();
|
final Tile tile = tileQueue.remove();
|
||||||
|
|
||||||
int trys = 3;
|
int trys = 3;
|
||||||
while (!tile.isLoaded() && trys > 0) {
|
while (!tile.isLoaded() && trys > 0) {
|
||||||
try {
|
try {
|
||||||
BufferedImage img = null;
|
BufferedImage img = null;
|
||||||
URI uri = getURI(tile);
|
URI uri = getURI(tile);
|
||||||
img = cache.get(uri);
|
img = cache.get(uri);
|
||||||
if (img == null) {
|
if (img == null) {
|
||||||
byte[] bimg = cacheInputStream(uri.toURL());
|
byte[] bimg = cacheInputStream(uri.toURL());
|
||||||
img = GraphicsUtilities.loadCompatibleImage(new ByteArrayInputStream(bimg));//ImageIO.read(new URL(tile.url));
|
img = GraphicsUtilities.loadCompatibleImage(new ByteArrayInputStream(bimg));//ImageIO.read(new URL(tile.url));
|
||||||
cache.put(uri, bimg, img);
|
cache.put(uri, bimg, img);
|
||||||
img = cache.get(uri);
|
img = cache.get(uri);
|
||||||
}
|
}
|
||||||
if (img == null) {
|
if (img == null) {
|
||||||
System.out.println("error loading: " + uri);
|
System.out.println("error loading: " + uri);
|
||||||
LOG.log(Level.INFO, "Failed to load: " + uri);
|
LOG.log(Level.INFO, "Failed to load: " + uri);
|
||||||
trys--;
|
trys--;
|
||||||
} else {
|
} else {
|
||||||
final BufferedImage i = img;
|
final BufferedImage i = img;
|
||||||
SwingUtilities.invokeAndWait(new Runnable() {
|
SwingUtilities.invokeAndWait(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
tile.image = new SoftReference<>(i);
|
tile.image = new SoftReference<>(i);
|
||||||
tile.setLoaded(true);
|
tile.setLoaded(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (OutOfMemoryError memErr) {
|
} catch (OutOfMemoryError memErr) {
|
||||||
cache.needMoreMemory();
|
cache.needMoreMemory();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
LOG.log(Level.SEVERE,
|
LOG.log(Level.SEVERE,
|
||||||
"Failed to load a tile at url: " + tile.getURL() + ", retrying", e);
|
"Failed to load a tile at url: " + tile.getURL() + ", retrying", e);
|
||||||
//temp
|
//temp
|
||||||
System.err.println("Failed to load a tile at url: " + tile.getURL());
|
System.err.println("Failed to load a tile at url: " + tile.getURL());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
///temp
|
///temp
|
||||||
Object oldError = tile.getError();
|
Object oldError = tile.getError();
|
||||||
tile.setError(e);
|
tile.setError(e);
|
||||||
tile.firePropertyChangeOnEDT("loadingError", oldError, e);
|
tile.firePropertyChangeOnEDT("loadingError", oldError, e);
|
||||||
if (trys == 0) {
|
if (trys == 0) {
|
||||||
tile.firePropertyChangeOnEDT("unrecoverableError", null, e);
|
tile.firePropertyChangeOnEDT("unrecoverableError", null, e);
|
||||||
} else {
|
} else {
|
||||||
trys--;
|
trys--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tile.setLoading(false);
|
tile.setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] cacheInputStream(URL url) throws IOException {
|
private byte[] cacheInputStream(URL url) throws IOException {
|
||||||
InputStream ins = url.openStream();
|
InputStream ins = url.openStream();
|
||||||
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
||||||
byte[] buf = new byte[256];
|
byte[] buf = new byte[256];
|
||||||
while (true) {
|
while (true) {
|
||||||
int n = ins.read(buf);
|
int n = ins.read(buf);
|
||||||
if (n == -1) {
|
if (n == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bout.write(buf, 0, n);
|
bout.write(buf, 0, n);
|
||||||
}
|
}
|
||||||
return bout.toByteArray();
|
return bout.toByteArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,331 +1,330 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* To change this template, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package org.meteoinfo.data.mathparser;
|
package org.meteoinfo.data.mathparser;
|
||||||
|
|
||||||
import java.beans.Expression;
|
import java.io.IOException;
|
||||||
import java.io.IOException;
|
import java.io.StringReader;
|
||||||
import java.io.StringReader;
|
import java.util.ArrayList;
|
||||||
import java.util.ArrayList;
|
import java.util.HashMap;
|
||||||
import java.util.Arrays;
|
import java.util.LinkedList;
|
||||||
import java.util.HashMap;
|
import java.util.List;
|
||||||
import java.util.LinkedList;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.Queue;
|
||||||
import java.util.Map;
|
import java.util.Stack;
|
||||||
import java.util.Queue;
|
|
||||||
import java.util.Stack;
|
import org.meteoinfo.common.MIMath;
|
||||||
import org.meteoinfo.data.meteodata.MeteoDataInfo;
|
import org.meteoinfo.data.meteodata.MeteoDataInfo;
|
||||||
import org.meteoinfo.global.MIMath;
|
|
||||||
|
/**
|
||||||
/**
|
*
|
||||||
*
|
* @author yaqiang
|
||||||
* @author yaqiang
|
*/
|
||||||
*/
|
public class MathParser {
|
||||||
public class MathParser {
|
// <editor-fold desc="Variables">
|
||||||
// <editor-fold desc="Variables">
|
|
||||||
|
private boolean _isGridData;
|
||||||
private boolean _isGridData;
|
private StringBuilder _buffer = new StringBuilder();
|
||||||
private StringBuilder _buffer = new StringBuilder();
|
private Stack<String> _symbolStack = new Stack<String>();
|
||||||
private Stack<String> _symbolStack = new Stack<String>();
|
private Queue<IExpression> _expressionQueue = new LinkedList<IExpression>();
|
||||||
private Queue<IExpression> _expressionQueue = new LinkedList<IExpression>();
|
private Map<String, IExpression> _expressionCache = new HashMap<String, IExpression>();
|
||||||
private Map<String, IExpression> _expressionCache = new HashMap<String, IExpression>();
|
private Stack<Object> _calculationStack = new Stack<Object>();
|
||||||
private Stack<Object> _calculationStack = new Stack<Object>();
|
private Stack<Object> _parameters = new Stack<Object>();
|
||||||
private Stack<Object> _parameters = new Stack<Object>();
|
private List<String> _variables = new ArrayList<String>();
|
||||||
private List<String> _variables = new ArrayList<String>();
|
private StringReader _expressionReader;
|
||||||
private StringReader _expressionReader;
|
private MeteoDataInfo _meteoDataInfo = null;
|
||||||
private MeteoDataInfo _meteoDataInfo = null;
|
// </editor-fold>
|
||||||
// </editor-fold>
|
// <editor-fold desc="Constructor">
|
||||||
// <editor-fold desc="Constructor">
|
|
||||||
|
/**
|
||||||
/**
|
* Constructor
|
||||||
* Constructor
|
*/
|
||||||
*/
|
public MathParser() {
|
||||||
public MathParser() {
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Constructor
|
||||||
* Constructor
|
*
|
||||||
*
|
* @param aDataInfo MeteoDataInfo
|
||||||
* @param aDataInfo MeteoDataInfo
|
*/
|
||||||
*/
|
public MathParser(MeteoDataInfo aDataInfo) {
|
||||||
public MathParser(MeteoDataInfo aDataInfo) {
|
_meteoDataInfo = aDataInfo;
|
||||||
_meteoDataInfo = aDataInfo;
|
_isGridData = aDataInfo.isGridData();
|
||||||
_isGridData = aDataInfo.isGridData();
|
_variables = aDataInfo.getDataInfo().getVariableNames();
|
||||||
_variables = aDataInfo.getDataInfo().getVariableNames();
|
}
|
||||||
}
|
// </editor-fold>
|
||||||
// </editor-fold>
|
// <editor-fold desc="Get Set Methods">
|
||||||
// <editor-fold desc="Get Set Methods">
|
// </editor-fold>
|
||||||
// </editor-fold>
|
// <editor-fold desc="Methods">
|
||||||
// <editor-fold desc="Methods">
|
|
||||||
|
/**
|
||||||
/**
|
* Evaluates the specified expression
|
||||||
* Evaluates the specified expression
|
*
|
||||||
*
|
* @param expression The expression to evaluate
|
||||||
* @param expression The expression to evaluate
|
* @return The evaluated result
|
||||||
* @return The evaluated result
|
*/
|
||||||
*/
|
public Object evaluate(String expression) throws ParseException, IOException {
|
||||||
public Object evaluate(String expression) throws ParseException, IOException {
|
if (expression == null || expression.isEmpty()) {
|
||||||
if (expression == null || expression.isEmpty()) {
|
throw new java.lang.IllegalArgumentException("expression");
|
||||||
throw new java.lang.IllegalArgumentException("expression");
|
}
|
||||||
}
|
|
||||||
|
_expressionReader = new StringReader(expression);
|
||||||
_expressionReader = new StringReader(expression);
|
_symbolStack.clear();
|
||||||
_symbolStack.clear();
|
_expressionQueue.clear();
|
||||||
_expressionQueue.clear();
|
|
||||||
|
parseExpressionToQueue();
|
||||||
parseExpressionToQueue();
|
|
||||||
|
Object result = calculateFromQueue();
|
||||||
Object result = calculateFromQueue();
|
|
||||||
|
//_variables[AnswerVariable] = result;
|
||||||
//_variables[AnswerVariable] = result;
|
return result;
|
||||||
return result;
|
}
|
||||||
}
|
|
||||||
|
private void parseExpressionToQueue() throws ParseException, IOException {
|
||||||
private void parseExpressionToQueue() throws ParseException, IOException {
|
int ic;
|
||||||
int ic;
|
char c;
|
||||||
char c;
|
while ((ic = _expressionReader.read()) != -1) {
|
||||||
while ((ic = _expressionReader.read()) != -1) {
|
c = (char) ic;
|
||||||
c = (char) ic;
|
if (Character.isWhitespace(c)) {
|
||||||
if (Character.isWhitespace(c)) {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
if (tryNumber(c)) {
|
||||||
if (tryNumber(c)) {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
if (tryString(c)) {
|
||||||
if (tryString(c)) {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
if (tryStartGroup(c)) {
|
||||||
if (tryStartGroup(c)) {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
if (tryOperator(c)) {
|
||||||
if (tryOperator(c)) {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
if (tryEndGroup(c)) {
|
||||||
if (tryEndGroup(c)) {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
//if (TryConvert(c))
|
||||||
//if (TryConvert(c))
|
// continue;
|
||||||
// continue;
|
throw new ParseException("Invalid character encountered" + c);
|
||||||
throw new ParseException("Invalid character encountered" + c);
|
}
|
||||||
}
|
|
||||||
|
processSymbolStack();
|
||||||
processSymbolStack();
|
}
|
||||||
}
|
|
||||||
|
private boolean tryNumber(char c) throws IOException, ParseException {
|
||||||
private boolean tryNumber(char c) throws IOException, ParseException {
|
boolean isNumber = NumberExpression.isNumber(c);
|
||||||
boolean isNumber = NumberExpression.isNumber(c);
|
boolean isNegative = false;
|
||||||
boolean isNegative = false;
|
if (NumberExpression.isNegativeSign(c)) {
|
||||||
if (NumberExpression.isNegativeSign(c)) {
|
if (_expressionQueue.size() == 0) {
|
||||||
if (_expressionQueue.size() == 0) {
|
isNegative = true;
|
||||||
isNegative = true;
|
} else if (_expressionQueue.size() > 0 && _symbolStack.size() > 0) {
|
||||||
} else if (_expressionQueue.size() > 0 && _symbolStack.size() > 0) {
|
if (((String) _symbolStack.peek()).equals("(")) {
|
||||||
if (((String) _symbolStack.peek()).equals("(")) {
|
isNegative = true;
|
||||||
isNegative = true;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (!isNumber && !isNegative) {
|
||||||
if (!isNumber && !isNegative) {
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
_buffer.setLength(0);
|
||||||
_buffer.setLength(0);
|
_buffer.append(c);
|
||||||
_buffer.append(c);
|
|
||||||
|
_expressionReader.mark(1);
|
||||||
_expressionReader.mark(1);
|
char p = (char) _expressionReader.read();
|
||||||
char p = (char) _expressionReader.read();
|
while (NumberExpression.isNumber(p)) {
|
||||||
while (NumberExpression.isNumber(p)) {
|
_buffer.append(p);
|
||||||
_buffer.append(p);
|
_expressionReader.mark(1);
|
||||||
_expressionReader.mark(1);
|
p = (char) _expressionReader.read();
|
||||||
p = (char) _expressionReader.read();
|
}
|
||||||
}
|
_expressionReader.reset();
|
||||||
_expressionReader.reset();
|
|
||||||
|
double value;
|
||||||
double value;
|
try {
|
||||||
try {
|
value = Double.parseDouble(_buffer.toString());
|
||||||
value = Double.parseDouble(_buffer.toString());
|
} catch (Exception e) {
|
||||||
} catch (Exception e) {
|
throw new ParseException("Invalid number format: " + _buffer);
|
||||||
throw new ParseException("Invalid number format: " + _buffer);
|
}
|
||||||
}
|
|
||||||
|
NumberExpression expression = new NumberExpression(value);
|
||||||
NumberExpression expression = new NumberExpression(value);
|
_expressionQueue.offer(expression);
|
||||||
_expressionQueue.offer(expression);
|
|
||||||
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
private boolean tryString(char c) throws IOException, ParseException {
|
||||||
private boolean tryString(char c) throws IOException, ParseException {
|
if (!Character.isLetter(c)) {
|
||||||
if (!Character.isLetter(c)) {
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
_buffer.setLength(0);
|
||||||
_buffer.setLength(0);
|
_buffer.append(c);
|
||||||
_buffer.append(c);
|
|
||||||
|
_expressionReader.mark(1);
|
||||||
_expressionReader.mark(1);
|
char p = (char) _expressionReader.read();
|
||||||
char p = (char) _expressionReader.read();
|
while (Character.isLetterOrDigit(p) || p == '_' || p == '@' || p == '.') {
|
||||||
while (Character.isLetterOrDigit(p) || p == '_' || p == '@' || p == '.') {
|
_buffer.append(p);
|
||||||
_buffer.append(p);
|
_expressionReader.mark(1);
|
||||||
_expressionReader.mark(1);
|
p = (char) _expressionReader.read();
|
||||||
p = (char) _expressionReader.read();
|
}
|
||||||
}
|
_expressionReader.reset();
|
||||||
_expressionReader.reset();
|
|
||||||
|
if (_variables.contains(_buffer.toString())) {
|
||||||
if (_variables.contains(_buffer.toString())) {
|
Object value = getVariableValue(_buffer.toString());
|
||||||
Object value = getVariableValue(_buffer.toString());
|
NumberExpression expression = new NumberExpression(value);
|
||||||
NumberExpression expression = new NumberExpression(value);
|
_expressionQueue.offer(expression);
|
||||||
_expressionQueue.offer(expression);
|
|
||||||
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
if (FunctionExpression.isFunction(_buffer.toString())) {
|
||||||
if (FunctionExpression.isFunction(_buffer.toString())) {
|
_symbolStack.push(_buffer.toString());
|
||||||
_symbolStack.push(_buffer.toString());
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
throw new ParseException("Invalid variable: " + _buffer);
|
||||||
throw new ParseException("Invalid variable: " + _buffer);
|
}
|
||||||
}
|
|
||||||
|
private boolean tryStartGroup(char c) {
|
||||||
private boolean tryStartGroup(char c) {
|
if (c != '(') {
|
||||||
if (c != '(') {
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
_symbolStack.push(String.valueOf(c));
|
||||||
_symbolStack.push(String.valueOf(c));
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
private boolean tryOperator(char c) throws ParseException {
|
||||||
private boolean tryOperator(char c) throws ParseException {
|
if (!OperatorExpression.isSymbol(c)) {
|
||||||
if (!OperatorExpression.isSymbol(c)) {
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
boolean repeat;
|
||||||
boolean repeat;
|
String s = String.valueOf(c);
|
||||||
String s = String.valueOf(c);
|
|
||||||
|
do {
|
||||||
do {
|
String p = _symbolStack.size() == 0 ? "" : _symbolStack.peek();
|
||||||
String p = _symbolStack.size() == 0 ? "" : _symbolStack.peek();
|
repeat = false;
|
||||||
repeat = false;
|
if (_symbolStack.size() == 0) {
|
||||||
if (_symbolStack.size() == 0) {
|
_symbolStack.push(s);
|
||||||
_symbolStack.push(s);
|
} else if (p.equals("(")) {
|
||||||
} else if (p.equals("(")) {
|
_symbolStack.push(s);
|
||||||
_symbolStack.push(s);
|
} else if (precedence(s) > precedence(p)) {
|
||||||
} else if (precedence(s) > precedence(p)) {
|
_symbolStack.push(s);
|
||||||
_symbolStack.push(s);
|
} else {
|
||||||
} else {
|
IExpression e = getExpressionFromSymbol(_symbolStack.pop());
|
||||||
IExpression e = getExpressionFromSymbol(_symbolStack.pop());
|
_expressionQueue.offer(e);
|
||||||
_expressionQueue.offer(e);
|
repeat = true;
|
||||||
repeat = true;
|
}
|
||||||
}
|
} while (repeat);
|
||||||
} while (repeat);
|
|
||||||
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
private boolean tryEndGroup(char c) throws ParseException {
|
||||||
private boolean tryEndGroup(char c) throws ParseException {
|
if (c != ')') {
|
||||||
if (c != ')') {
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
boolean ok = false;
|
||||||
boolean ok = false;
|
|
||||||
|
while (_symbolStack.size() > 0) {
|
||||||
while (_symbolStack.size() > 0) {
|
String p = _symbolStack.pop();
|
||||||
String p = _symbolStack.pop();
|
if (p.equals("(")) {
|
||||||
if (p.equals("(")) {
|
ok = true;
|
||||||
ok = true;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
IExpression e = getExpressionFromSymbol(p);
|
||||||
IExpression e = getExpressionFromSymbol(p);
|
_expressionQueue.offer(e);
|
||||||
_expressionQueue.offer(e);
|
}
|
||||||
}
|
|
||||||
|
if (!ok) {
|
||||||
if (!ok) {
|
throw new ParseException("Unbalance parenthese");
|
||||||
throw new ParseException("Unbalance parenthese");
|
}
|
||||||
}
|
|
||||||
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
private void processSymbolStack() throws ParseException {
|
||||||
private void processSymbolStack() throws ParseException {
|
while (_symbolStack.size() > 0) {
|
||||||
while (_symbolStack.size() > 0) {
|
String p = _symbolStack.pop();
|
||||||
String p = _symbolStack.pop();
|
if (p.length() == 1 && p.equals("(")) {
|
||||||
if (p.length() == 1 && p.equals("(")) {
|
throw new ParseException("Unbalance parenthese");
|
||||||
throw new ParseException("Unbalance parenthese");
|
}
|
||||||
}
|
|
||||||
|
IExpression e = getExpressionFromSymbol(p);
|
||||||
IExpression e = getExpressionFromSymbol(p);
|
_expressionQueue.offer(e);
|
||||||
_expressionQueue.offer(e);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private static int precedence(String c) {
|
||||||
private static int precedence(String c) {
|
String s = c.substring(0, 1);
|
||||||
String s = c.substring(0, 1);
|
if (c.length() == 1 && s.equals("*") || s.equals("/") || s.equals("%")) {
|
||||||
if (c.length() == 1 && s.equals("*") || s.equals("/") || s.equals("%")) {
|
return 2;
|
||||||
return 2;
|
}
|
||||||
}
|
|
||||||
|
return 1;
|
||||||
return 1;
|
}
|
||||||
}
|
|
||||||
|
private IExpression getExpressionFromSymbol(String p) throws ParseException {
|
||||||
private IExpression getExpressionFromSymbol(String p) throws ParseException {
|
IExpression e;
|
||||||
IExpression e;
|
|
||||||
|
if (_expressionCache.containsKey(p)) {
|
||||||
if (_expressionCache.containsKey(p)) {
|
e = _expressionCache.get(p);
|
||||||
e = _expressionCache.get(p);
|
} else if (OperatorExpression.isSymbol(p)) {
|
||||||
} else if (OperatorExpression.isSymbol(p)) {
|
e = new OperatorExpression(p);
|
||||||
e = new OperatorExpression(p);
|
_expressionCache.put(p, e);
|
||||||
_expressionCache.put(p, e);
|
} else if (FunctionExpression.isFunction(p)) {
|
||||||
} else if (FunctionExpression.isFunction(p)) {
|
e = new FunctionExpression(p, false);
|
||||||
e = new FunctionExpression(p, false);
|
_expressionCache.put(p, e);
|
||||||
_expressionCache.put(p, e);
|
} //else if (ConvertExpression.IsConvertExpression(p))
|
||||||
} //else if (ConvertExpression.IsConvertExpression(p))
|
//{
|
||||||
//{
|
// e = new ConvertExpression(p);
|
||||||
// e = new ConvertExpression(p);
|
// _expressionCache.Add(p, e);
|
||||||
// _expressionCache.Add(p, e);
|
//}
|
||||||
//}
|
else {
|
||||||
else {
|
throw new ParseException("Invalid symbol on stack" + p);
|
||||||
throw new ParseException("Invalid symbol on stack" + p);
|
}
|
||||||
}
|
|
||||||
|
return e;
|
||||||
return e;
|
}
|
||||||
}
|
|
||||||
|
private Object calculateFromQueue() throws ParseException {
|
||||||
private Object calculateFromQueue() throws ParseException {
|
Object result;
|
||||||
Object result;
|
_calculationStack.clear();
|
||||||
_calculationStack.clear();
|
|
||||||
|
for (IExpression expression : _expressionQueue) {
|
||||||
for (IExpression expression : _expressionQueue) {
|
if (_calculationStack.size() < expression.getArgumentCount()) {
|
||||||
if (_calculationStack.size() < expression.getArgumentCount()) {
|
throw new ParseException("Not enough numbers" + expression);
|
||||||
throw new ParseException("Not enough numbers" + expression);
|
}
|
||||||
}
|
|
||||||
|
_parameters.clear();
|
||||||
_parameters.clear();
|
for (int i = 0; i < expression.getArgumentCount(); i++) {
|
||||||
for (int i = 0; i < expression.getArgumentCount(); i++) {
|
_parameters.push(_calculationStack.pop());
|
||||||
_parameters.push(_calculationStack.pop());
|
}
|
||||||
}
|
|
||||||
|
Object[] parameters = _parameters.toArray();
|
||||||
Object[] parameters = _parameters.toArray();
|
MIMath.arrayReverse(parameters);
|
||||||
MIMath.arrayReverse(parameters);
|
_calculationStack.push(expression.evaluate(parameters));
|
||||||
_calculationStack.push(expression.evaluate(parameters));
|
}
|
||||||
}
|
|
||||||
|
result = _calculationStack.pop();
|
||||||
result = _calculationStack.pop();
|
return result;
|
||||||
return result;
|
}
|
||||||
}
|
|
||||||
|
private Object getVariableValue(String varName) {
|
||||||
private Object getVariableValue(String varName) {
|
if (_meteoDataInfo == null) {
|
||||||
if (_meteoDataInfo == null) {
|
return 100;
|
||||||
return 100;
|
} else {
|
||||||
} else {
|
if (_isGridData) {
|
||||||
if (_isGridData) {
|
return _meteoDataInfo.getGridData(varName);
|
||||||
return _meteoDataInfo.getGridData(varName);
|
} else {
|
||||||
} else {
|
return _meteoDataInfo.getStationData(varName);
|
||||||
return _meteoDataInfo.getStationData(varName);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// </editor-fold>
|
||||||
// </editor-fold>
|
}
|
||||||
}
|
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import java.time.Period;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.meteoinfo.global.util.JDateUtil;
|
import org.meteoinfo.common.util.JDateUtil;
|
||||||
import org.meteoinfo.ndarray.Array;
|
import org.meteoinfo.ndarray.Array;
|
||||||
import org.meteoinfo.ndarray.Dimension;
|
import org.meteoinfo.ndarray.Dimension;
|
||||||
import org.meteoinfo.projection.KnownCoordinateSystems;
|
import org.meteoinfo.projection.KnownCoordinateSystems;
|
||||||
|
|||||||
@ -14,6 +14,9 @@
|
|||||||
package org.meteoinfo.data.meteodata;
|
package org.meteoinfo.data.meteodata;
|
||||||
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import org.meteoinfo.common.Extent;
|
||||||
|
import org.meteoinfo.common.MIMath;
|
||||||
|
import org.meteoinfo.common.PointD;
|
||||||
import org.meteoinfo.data.DataMath;
|
import org.meteoinfo.data.DataMath;
|
||||||
import org.meteoinfo.data.GridData;
|
import org.meteoinfo.data.GridData;
|
||||||
import org.meteoinfo.data.StationData;
|
import org.meteoinfo.data.StationData;
|
||||||
@ -21,10 +24,10 @@ import org.meteoinfo.data.dataframe.DataFrame;
|
|||||||
import org.meteoinfo.data.mapdata.Field;
|
import org.meteoinfo.data.mapdata.Field;
|
||||||
import org.meteoinfo.drawing.ContourDraw;
|
import org.meteoinfo.drawing.ContourDraw;
|
||||||
import org.meteoinfo.drawing.Draw;
|
import org.meteoinfo.drawing.Draw;
|
||||||
|
import org.meteoinfo.geoprocess.GeometryUtil;
|
||||||
import org.meteoinfo.legend.MarkerType;
|
import org.meteoinfo.legend.MarkerType;
|
||||||
import org.meteoinfo.geoprocess.GeoComputation;
|
import org.meteoinfo.geoprocess.GeoComputation;
|
||||||
import org.meteoinfo.global.MIMath;
|
import org.meteoinfo.math.ArrayUtil;
|
||||||
import org.meteoinfo.global.PointD;
|
|
||||||
import org.meteoinfo.ndarray.DataType;
|
import org.meteoinfo.ndarray.DataType;
|
||||||
import org.meteoinfo.layer.LayerDrawType;
|
import org.meteoinfo.layer.LayerDrawType;
|
||||||
import org.meteoinfo.layer.VectorLayer;
|
import org.meteoinfo.layer.VectorLayer;
|
||||||
@ -45,10 +48,9 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.meteoinfo.math.ArrayUtil;
|
|
||||||
import org.meteoinfo.data.GridArray;
|
import org.meteoinfo.data.GridArray;
|
||||||
import org.meteoinfo.data.XYListDataset;
|
import org.meteoinfo.data.XYListDataset;
|
||||||
import org.meteoinfo.global.Extent;
|
|
||||||
import org.meteoinfo.layer.ImageLayer;
|
import org.meteoinfo.layer.ImageLayer;
|
||||||
import org.meteoinfo.layer.RasterLayer;
|
import org.meteoinfo.layer.RasterLayer;
|
||||||
import org.meteoinfo.layer.WorldFilePara;
|
import org.meteoinfo.layer.WorldFilePara;
|
||||||
@ -107,7 +109,7 @@ public class DrawMeteoData {
|
|||||||
}
|
}
|
||||||
aPolyline.setPoints(pList);
|
aPolyline.setPoints(pList);
|
||||||
aPolyline.setValue(i);
|
aPolyline.setValue(i);
|
||||||
aPolyline.setExtent(MIMath.getPointsExtent(pList));
|
aPolyline.setExtent(GeometryUtil.getPointsExtent(pList));
|
||||||
|
|
||||||
int shapeNum = layer.getShapeNum();
|
int shapeNum = layer.getShapeNum();
|
||||||
try {
|
try {
|
||||||
@ -157,7 +159,7 @@ public class DrawMeteoData {
|
|||||||
}
|
}
|
||||||
aPolyline.setPoints(pList);
|
aPolyline.setPoints(pList);
|
||||||
aPolyline.setValue(i);
|
aPolyline.setValue(i);
|
||||||
aPolyline.setExtent(MIMath.getPointsExtent(pList));
|
aPolyline.setExtent(GeometryUtil.getPointsExtent(pList));
|
||||||
|
|
||||||
int shapeNum = layer.getShapeNum();
|
int shapeNum = layer.getShapeNum();
|
||||||
try {
|
try {
|
||||||
@ -233,7 +235,7 @@ public class DrawMeteoData {
|
|||||||
PolylineShape aPolyline = new PolylineShape();
|
PolylineShape aPolyline = new PolylineShape();
|
||||||
aPolyline.setPoints(ps);
|
aPolyline.setPoints(ps);
|
||||||
aPolyline.setValue(i);
|
aPolyline.setValue(i);
|
||||||
aPolyline.setExtent(MIMath.getPointsExtent(ps));
|
aPolyline.setExtent(GeometryUtil.getPointsExtent(ps));
|
||||||
|
|
||||||
int shapeNum = layer.getShapeNum();
|
int shapeNum = layer.getShapeNum();
|
||||||
try {
|
try {
|
||||||
@ -368,7 +370,7 @@ public class DrawMeteoData {
|
|||||||
PolylineShape aPolyline = new PolylineShape();
|
PolylineShape aPolyline = new PolylineShape();
|
||||||
aPolyline.setPoints(ps);
|
aPolyline.setPoints(ps);
|
||||||
aPolyline.setValue(k);
|
aPolyline.setValue(k);
|
||||||
aPolyline.setExtent(MIMath.getPointsExtent(ps));
|
aPolyline.setExtent(GeometryUtil.getPointsExtent(ps));
|
||||||
|
|
||||||
int shapeNum = layer.getShapeNum();
|
int shapeNum = layer.getShapeNum();
|
||||||
try {
|
try {
|
||||||
@ -509,7 +511,7 @@ public class DrawMeteoData {
|
|||||||
PolylineZShape aPolyline = new PolylineZShape();
|
PolylineZShape aPolyline = new PolylineZShape();
|
||||||
aPolyline.setPoints(ps);
|
aPolyline.setPoints(ps);
|
||||||
aPolyline.setValue(0);
|
aPolyline.setValue(0);
|
||||||
aPolyline.setExtent(MIMath.getPointsExtent(ps));
|
aPolyline.setExtent(GeometryUtil.getPointsExtent(ps));
|
||||||
|
|
||||||
int shapeNum = layer.getShapeNum();
|
int shapeNum = layer.getShapeNum();
|
||||||
try {
|
try {
|
||||||
@ -621,7 +623,7 @@ public class DrawMeteoData {
|
|||||||
PolylineZShape aPolyline = new PolylineZShape();
|
PolylineZShape aPolyline = new PolylineZShape();
|
||||||
aPolyline.setPoints(ps);
|
aPolyline.setPoints(ps);
|
||||||
aPolyline.setValue(0);
|
aPolyline.setValue(0);
|
||||||
aPolyline.setExtent(MIMath.getPointsExtent(ps));
|
aPolyline.setExtent(GeometryUtil.getPointsExtent(ps));
|
||||||
|
|
||||||
int shapeNum = layer.getShapeNum();
|
int shapeNum = layer.getShapeNum();
|
||||||
try {
|
try {
|
||||||
@ -740,7 +742,7 @@ public class DrawMeteoData {
|
|||||||
}
|
}
|
||||||
aPolyline.setPoints(pList);
|
aPolyline.setPoints(pList);
|
||||||
aPolyline.setValue(aValue);
|
aPolyline.setValue(aValue);
|
||||||
aPolyline.setExtent(MIMath.getPointsExtent(pList));
|
aPolyline.setExtent(GeometryUtil.getPointsExtent(pList));
|
||||||
|
|
||||||
int shapeNum = aLayer.getShapeNum();
|
int shapeNum = aLayer.getShapeNum();
|
||||||
try {
|
try {
|
||||||
@ -826,7 +828,7 @@ public class DrawMeteoData {
|
|||||||
}
|
}
|
||||||
aPolyline.setPoints(pList);
|
aPolyline.setPoints(pList);
|
||||||
aPolyline.setValue(aValue);
|
aPolyline.setValue(aValue);
|
||||||
aPolyline.setExtent(MIMath.getPointsExtent(pList));
|
aPolyline.setExtent(GeometryUtil.getPointsExtent(pList));
|
||||||
int shapeNum = aLayer.getShapeNum();
|
int shapeNum = aLayer.getShapeNum();
|
||||||
try {
|
try {
|
||||||
if (aLayer.editInsertShape(aPolyline, shapeNum)) {
|
if (aLayer.editInsertShape(aPolyline, shapeNum)) {
|
||||||
@ -968,7 +970,7 @@ public class DrawMeteoData {
|
|||||||
}
|
}
|
||||||
PolygonShape aPolygonShape = new PolygonShape();
|
PolygonShape aPolygonShape = new PolygonShape();
|
||||||
aPolygonShape.setPoints(pList);
|
aPolygonShape.setPoints(pList);
|
||||||
aPolygonShape.setExtent(MIMath.getPointsExtent(pList));
|
aPolygonShape.setExtent(GeometryUtil.getPointsExtent(pList));
|
||||||
aPolygonShape.lowValue = aValue;
|
aPolygonShape.lowValue = aValue;
|
||||||
if (aPolygon.HasHoles()) {
|
if (aPolygon.HasHoles()) {
|
||||||
for (PolyLine holeLine : aPolygon.HoleLines) {
|
for (PolyLine holeLine : aPolygon.HoleLines) {
|
||||||
|
|||||||
@ -1,36 +1,36 @@
|
|||||||
/* Copyright 2012 Yaqiang Wang,
|
/* Copyright 2012 Yaqiang Wang,
|
||||||
* yaqiang.wang@gmail.com
|
* yaqiang.wang@gmail.com
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or modify it
|
* This library is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU Lesser General Public License as published by
|
* under the terms of the GNU Lesser General Public License as published by
|
||||||
* the Free Software Foundation; either version 2.1 of the License, or (at
|
* the Free Software Foundation; either version 2.1 of the License, or (at
|
||||||
* your option) any later version.
|
* your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful, but
|
* This library is distributed in the hope that it will be useful, but
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||||
* General Public License for more details.
|
* General Public License for more details.
|
||||||
*/
|
*/
|
||||||
package org.meteoinfo.data.meteodata;
|
package org.meteoinfo.data.meteodata;
|
||||||
|
|
||||||
import org.meteoinfo.global.Extent;
|
import org.meteoinfo.common.Extent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author yaqiang
|
* @author yaqiang
|
||||||
*/
|
*/
|
||||||
public class GridDataSetting {
|
public class GridDataSetting {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Data extent
|
/// Data extent
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
public Extent dataExtent = new Extent();
|
public Extent dataExtent = new Extent();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// X number
|
/// X number
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int xNum;
|
public int xNum;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Y number
|
/// Y number
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int yNum;
|
public int yNum;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,8 @@
|
|||||||
package org.meteoinfo.data.meteodata;
|
package org.meteoinfo.data.meteodata;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.meteoinfo.common.MIMath;
|
||||||
import org.meteoinfo.data.GridData;
|
import org.meteoinfo.data.GridData;
|
||||||
import org.meteoinfo.data.StationData;
|
import org.meteoinfo.data.StationData;
|
||||||
import org.meteoinfo.data.meteodata.arl.ARLDataInfo;
|
import org.meteoinfo.data.meteodata.arl.ARLDataInfo;
|
||||||
@ -30,14 +32,15 @@ import java.io.IOException;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.meteoinfo.math.ArrayMath;
|
||||||
import org.meteoinfo.projection.info.ProjectionInfo;
|
import org.meteoinfo.projection.info.ProjectionInfo;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.meteoinfo.math.ArrayMath;
|
|
||||||
import org.meteoinfo.data.meteodata.mm5.MM5DataInfo;
|
import org.meteoinfo.data.meteodata.mm5.MM5DataInfo;
|
||||||
import org.meteoinfo.data.meteodata.mm5.MM5IMDataInfo;
|
import org.meteoinfo.data.meteodata.mm5.MM5IMDataInfo;
|
||||||
import org.meteoinfo.global.MIMath;
|
|
||||||
import org.meteoinfo.data.mathparser.MathParser;
|
import org.meteoinfo.data.mathparser.MathParser;
|
||||||
import org.meteoinfo.data.mathparser.ParseException;
|
import org.meteoinfo.data.mathparser.ParseException;
|
||||||
import org.meteoinfo.data.meteodata.awx.AWXDataInfo;
|
import org.meteoinfo.data.meteodata.awx.AWXDataInfo;
|
||||||
|
|||||||
@ -1,100 +1,101 @@
|
|||||||
/* Copyright 2012 Yaqiang Wang,
|
/* Copyright 2012 Yaqiang Wang,
|
||||||
* yaqiang.wang@gmail.com
|
* yaqiang.wang@gmail.com
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or modify it
|
* This library is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU Lesser General Public License as published by
|
* under the terms of the GNU Lesser General Public License as published by
|
||||||
* the Free Software Foundation; either version 2.1 of the License, or (at
|
* the Free Software Foundation; either version 2.1 of the License, or (at
|
||||||
* your option) any later version.
|
* your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful, but
|
* This library is distributed in the hope that it will be useful, but
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||||
* General Public License for more details.
|
* General Public License for more details.
|
||||||
*/
|
*/
|
||||||
package org.meteoinfo.data.meteodata;
|
package org.meteoinfo.data.meteodata;
|
||||||
|
|
||||||
import org.meteoinfo.global.Extent;
|
import org.meteoinfo.common.Extent;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
* @author yaqiang
|
*
|
||||||
*/
|
* @author yaqiang
|
||||||
public class StationModelData {
|
*/
|
||||||
// <editor-fold desc="Variables">
|
public class StationModelData {
|
||||||
|
// <editor-fold desc="Variables">
|
||||||
private List<StationModel> _data = new ArrayList<>();
|
|
||||||
private Extent _dataExtent = new Extent();
|
private List<StationModel> _data = new ArrayList<>();
|
||||||
private double _missingValue = -9999.0;
|
private Extent _dataExtent = new Extent();
|
||||||
// </editor-fold>
|
private double _missingValue = -9999.0;
|
||||||
// <editor-fold desc="Constructor">
|
// </editor-fold>
|
||||||
// </editor-fold>
|
// <editor-fold desc="Constructor">
|
||||||
// <editor-fold desc="Get Set Methods">
|
// </editor-fold>
|
||||||
|
// <editor-fold desc="Get Set Methods">
|
||||||
/**
|
|
||||||
* Get data
|
/**
|
||||||
*
|
* Get data
|
||||||
* @return Data
|
*
|
||||||
*/
|
* @return Data
|
||||||
public List<StationModel> getData() {
|
*/
|
||||||
return _data;
|
public List<StationModel> getData() {
|
||||||
}
|
return _data;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set data
|
/**
|
||||||
*
|
* Set data
|
||||||
* @param value Data
|
*
|
||||||
*/
|
* @param value Data
|
||||||
public void setData(List<StationModel> value) {
|
*/
|
||||||
_data = value;
|
public void setData(List<StationModel> value) {
|
||||||
}
|
_data = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get data extent
|
/**
|
||||||
*
|
* Get data extent
|
||||||
* @return Data extent
|
*
|
||||||
*/
|
* @return Data extent
|
||||||
public Extent getDataExtent() {
|
*/
|
||||||
return _dataExtent;
|
public Extent getDataExtent() {
|
||||||
}
|
return _dataExtent;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set data extent
|
/**
|
||||||
*
|
* Set data extent
|
||||||
* @param value Data extent
|
*
|
||||||
*/
|
* @param value Data extent
|
||||||
public void setDataExtent(Extent value) {
|
*/
|
||||||
_dataExtent = value;
|
public void setDataExtent(Extent value) {
|
||||||
}
|
_dataExtent = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get missing data
|
/**
|
||||||
*
|
* Get missing data
|
||||||
* @return Missing data
|
*
|
||||||
*/
|
* @return Missing data
|
||||||
public double getMissingValue() {
|
*/
|
||||||
return _missingValue;
|
public double getMissingValue() {
|
||||||
}
|
return _missingValue;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set missing data
|
/**
|
||||||
*
|
* Set missing data
|
||||||
* @param value Missing data
|
*
|
||||||
*/
|
* @param value Missing data
|
||||||
public void setMissingValue(double value) {
|
*/
|
||||||
_missingValue = value;
|
public void setMissingValue(double value) {
|
||||||
}
|
_missingValue = value;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get data number
|
/**
|
||||||
*
|
* Get data number
|
||||||
* @return Data number
|
*
|
||||||
*/
|
* @return Data number
|
||||||
public int getDataNum() {
|
*/
|
||||||
return _data.size();
|
public int getDataNum() {
|
||||||
}
|
return _data.size();
|
||||||
// </editor-fold>
|
}
|
||||||
// <editor-fold desc="Methods">
|
// </editor-fold>
|
||||||
// </editor-fold>
|
// <editor-fold desc="Methods">
|
||||||
}
|
// </editor-fold>
|
||||||
|
}
|
||||||
|
|||||||
@ -13,13 +13,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.meteoinfo.data.meteodata;
|
package org.meteoinfo.data.meteodata;
|
||||||
|
|
||||||
|
import org.meteoinfo.common.util.JDateUtil;
|
||||||
import org.meteoinfo.ndarray.DimensionType;
|
import org.meteoinfo.ndarray.DimensionType;
|
||||||
import org.meteoinfo.ndarray.Dimension;
|
import org.meteoinfo.ndarray.Dimension;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.meteoinfo.global.util.JDateUtil;
|
|
||||||
import org.meteoinfo.ndarray.DataType;
|
import org.meteoinfo.ndarray.DataType;
|
||||||
import org.meteoinfo.ndarray.Range;
|
import org.meteoinfo.ndarray.Range;
|
||||||
import org.meteoinfo.ndarray.Section;
|
import org.meteoinfo.ndarray.Section;
|
||||||
|
|||||||
@ -13,17 +13,19 @@
|
|||||||
*/
|
*/
|
||||||
package org.meteoinfo.data.meteodata.arl;
|
package org.meteoinfo.data.meteodata.arl;
|
||||||
|
|
||||||
import org.meteoinfo.bak.ArrayMath;
|
import org.meteoinfo.common.MIMath;
|
||||||
|
import org.meteoinfo.common.util.GlobalUtil;
|
||||||
|
import org.meteoinfo.common.util.JDateUtil;
|
||||||
|
import org.meteoinfo.math.ArrayMath;
|
||||||
import org.meteoinfo.data.GridData;
|
import org.meteoinfo.data.GridData;
|
||||||
import org.meteoinfo.data.meteodata.DataInfo;
|
import org.meteoinfo.data.meteodata.DataInfo;
|
||||||
import org.meteoinfo.global.util.JDateUtil;
|
|
||||||
import org.meteoinfo.ndarray.Dimension;
|
import org.meteoinfo.ndarray.Dimension;
|
||||||
import org.meteoinfo.ndarray.DimensionType;
|
import org.meteoinfo.ndarray.DimensionType;
|
||||||
import org.meteoinfo.ndarray.util.BigDecimalUtil;
|
import org.meteoinfo.ndarray.util.BigDecimalUtil;
|
||||||
import org.meteoinfo.data.meteodata.IGridDataInfo;
|
import org.meteoinfo.data.meteodata.IGridDataInfo;
|
||||||
import org.meteoinfo.data.meteodata.Variable;
|
import org.meteoinfo.data.meteodata.Variable;
|
||||||
import org.meteoinfo.global.DataConvert;
|
import org.meteoinfo.global.DataConvert;
|
||||||
import org.meteoinfo.global.util.GlobalUtil;
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
@ -40,7 +42,6 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.meteoinfo.data.GridArray;
|
import org.meteoinfo.data.GridArray;
|
||||||
import org.meteoinfo.data.meteodata.MeteoDataType;
|
import org.meteoinfo.data.meteodata.MeteoDataType;
|
||||||
import org.meteoinfo.global.MIMath;
|
|
||||||
import org.locationtech.proj4j.proj.Projection;
|
import org.locationtech.proj4j.proj.Projection;
|
||||||
import org.meteoinfo.projection.KnownCoordinateSystems;
|
import org.meteoinfo.projection.KnownCoordinateSystems;
|
||||||
import org.meteoinfo.projection.info.ProjectionInfo;
|
import org.meteoinfo.projection.info.ProjectionInfo;
|
||||||
|
|||||||
@ -13,13 +13,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.meteoinfo.data.meteodata.ascii;
|
package org.meteoinfo.data.meteodata.ascii;
|
||||||
|
|
||||||
|
import org.meteoinfo.common.MIMath;
|
||||||
import org.meteoinfo.data.GridData;
|
import org.meteoinfo.data.GridData;
|
||||||
import org.meteoinfo.data.meteodata.DataInfo;
|
import org.meteoinfo.data.meteodata.DataInfo;
|
||||||
import org.meteoinfo.ndarray.Dimension;
|
import org.meteoinfo.ndarray.Dimension;
|
||||||
import org.meteoinfo.ndarray.DimensionType;
|
import org.meteoinfo.ndarray.DimensionType;
|
||||||
import org.meteoinfo.data.meteodata.IGridDataInfo;
|
import org.meteoinfo.data.meteodata.IGridDataInfo;
|
||||||
import org.meteoinfo.data.meteodata.Variable;
|
import org.meteoinfo.data.meteodata.Variable;
|
||||||
import org.meteoinfo.global.MIMath;
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
|||||||
@ -13,14 +13,16 @@
|
|||||||
*/
|
*/
|
||||||
package org.meteoinfo.data.meteodata.ascii;
|
package org.meteoinfo.data.meteodata.ascii;
|
||||||
|
|
||||||
|
import org.meteoinfo.common.Extent;
|
||||||
|
import org.meteoinfo.common.MIMath;
|
||||||
|
import org.meteoinfo.common.util.GlobalUtil;
|
||||||
import org.meteoinfo.data.StationData;
|
import org.meteoinfo.data.StationData;
|
||||||
import org.meteoinfo.data.meteodata.DataInfo;
|
import org.meteoinfo.data.meteodata.DataInfo;
|
||||||
import org.meteoinfo.data.meteodata.IStationDataInfo;
|
import org.meteoinfo.data.meteodata.IStationDataInfo;
|
||||||
import org.meteoinfo.data.meteodata.StationInfoData;
|
import org.meteoinfo.data.meteodata.StationInfoData;
|
||||||
import org.meteoinfo.data.meteodata.StationModelData;
|
import org.meteoinfo.data.meteodata.StationModelData;
|
||||||
import org.meteoinfo.data.meteodata.Variable;
|
import org.meteoinfo.data.meteodata.Variable;
|
||||||
import org.meteoinfo.global.Extent;
|
|
||||||
import org.meteoinfo.global.MIMath;
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@ -34,8 +36,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import org.meteoinfo.data.meteodata.MeteoDataType;
|
import org.meteoinfo.data.meteodata.MeteoDataType;
|
||||||
import org.meteoinfo.global.util.GlobalUtil;
|
import org.meteoinfo.common.io.FileCharsetDetector;
|
||||||
import org.meteoinfo.io.FileCharsetDetector;
|
|
||||||
import org.meteoinfo.ndarray.Array;
|
import org.meteoinfo.ndarray.Array;
|
||||||
import org.meteoinfo.data.meteodata.Attribute;
|
import org.meteoinfo.data.meteodata.Attribute;
|
||||||
|
|
||||||
|
|||||||
@ -15,6 +15,8 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.meteoinfo.common.Extent;
|
||||||
import org.meteoinfo.data.GridArray;
|
import org.meteoinfo.data.GridArray;
|
||||||
import org.meteoinfo.data.GridData;
|
import org.meteoinfo.data.GridData;
|
||||||
import org.meteoinfo.data.StationData;
|
import org.meteoinfo.data.StationData;
|
||||||
@ -28,7 +30,6 @@ import org.meteoinfo.data.meteodata.StationInfoData;
|
|||||||
import org.meteoinfo.data.meteodata.StationModelData;
|
import org.meteoinfo.data.meteodata.StationModelData;
|
||||||
import org.meteoinfo.data.meteodata.Variable;
|
import org.meteoinfo.data.meteodata.Variable;
|
||||||
import org.meteoinfo.global.DataConvert;
|
import org.meteoinfo.global.DataConvert;
|
||||||
import org.meteoinfo.global.Extent;
|
|
||||||
import org.meteoinfo.layer.WorldFilePara;
|
import org.meteoinfo.layer.WorldFilePara;
|
||||||
import org.meteoinfo.projection.KnownCoordinateSystems;
|
import org.meteoinfo.projection.KnownCoordinateSystems;
|
||||||
import org.meteoinfo.projection.info.ProjectionInfo;
|
import org.meteoinfo.projection.info.ProjectionInfo;
|
||||||
|
|||||||
@ -18,11 +18,12 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.meteoinfo.math.ArrayMath;
|
|
||||||
import org.meteoinfo.data.GridArray;
|
import org.meteoinfo.data.GridArray;
|
||||||
import org.meteoinfo.data.GridData;
|
import org.meteoinfo.data.GridData;
|
||||||
import org.meteoinfo.data.mapdata.geotiff.GeoTiff;
|
import org.meteoinfo.data.mapdata.geotiff.GeoTiff;
|
||||||
import org.meteoinfo.data.meteodata.DataInfo;
|
import org.meteoinfo.data.meteodata.DataInfo;
|
||||||
|
import org.meteoinfo.math.ArrayMath;
|
||||||
import org.meteoinfo.ndarray.Dimension;
|
import org.meteoinfo.ndarray.Dimension;
|
||||||
import org.meteoinfo.ndarray.DimensionType;
|
import org.meteoinfo.ndarray.DimensionType;
|
||||||
import org.meteoinfo.data.meteodata.IGridDataInfo;
|
import org.meteoinfo.data.meteodata.IGridDataInfo;
|
||||||
@ -149,7 +150,7 @@ public class GeoTiffDataInfo extends DataInfo implements IGridDataInfo {
|
|||||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||||
try {
|
try {
|
||||||
Array array = read(varName);
|
Array array = read(varName);
|
||||||
array = ArrayMath.section(array, origin, size, stride);
|
array = ArrayMath.section(array, origin, size, stride);
|
||||||
return array;
|
return array;
|
||||||
} catch (InvalidRangeException ex) {
|
} catch (InvalidRangeException ex) {
|
||||||
Logger.getLogger(GeoTiffDataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(GeoTiffDataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
|||||||
@ -13,6 +13,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.meteoinfo.data.meteodata.grads;
|
package org.meteoinfo.data.meteodata.grads;
|
||||||
|
|
||||||
|
import org.meteoinfo.common.Extent;
|
||||||
|
import org.meteoinfo.common.util.JDateUtil;
|
||||||
import org.meteoinfo.data.GridData;
|
import org.meteoinfo.data.GridData;
|
||||||
import org.meteoinfo.data.meteodata.DataInfo;
|
import org.meteoinfo.data.meteodata.DataInfo;
|
||||||
import org.meteoinfo.ndarray.Dimension;
|
import org.meteoinfo.ndarray.Dimension;
|
||||||
@ -20,7 +22,7 @@ import org.meteoinfo.ndarray.DimensionType;
|
|||||||
import org.meteoinfo.data.meteodata.IGridDataInfo;
|
import org.meteoinfo.data.meteodata.IGridDataInfo;
|
||||||
import org.meteoinfo.data.meteodata.Variable;
|
import org.meteoinfo.data.meteodata.Variable;
|
||||||
import org.meteoinfo.global.DataConvert;
|
import org.meteoinfo.global.DataConvert;
|
||||||
import org.meteoinfo.io.EndianDataOutputStream;
|
import org.meteoinfo.common.io.EndianDataOutputStream;
|
||||||
import org.meteoinfo.ndarray.util.BigDecimalUtil;
|
import org.meteoinfo.ndarray.util.BigDecimalUtil;
|
||||||
import org.meteoinfo.projection.KnownCoordinateSystems;
|
import org.meteoinfo.projection.KnownCoordinateSystems;
|
||||||
import org.meteoinfo.projection.info.ProjectionInfo;
|
import org.meteoinfo.projection.info.ProjectionInfo;
|
||||||
@ -51,7 +53,6 @@ import org.meteoinfo.data.meteodata.MeteoDataType;
|
|||||||
import org.meteoinfo.data.meteodata.StationInfoData;
|
import org.meteoinfo.data.meteodata.StationInfoData;
|
||||||
import org.meteoinfo.data.meteodata.StationModelData;
|
import org.meteoinfo.data.meteodata.StationModelData;
|
||||||
import org.meteoinfo.data.meteodata.arl.ARLDataInfo;
|
import org.meteoinfo.data.meteodata.arl.ARLDataInfo;
|
||||||
import org.meteoinfo.global.Extent;
|
|
||||||
import org.meteoinfo.ndarray.Array;
|
import org.meteoinfo.ndarray.Array;
|
||||||
import org.meteoinfo.ndarray.DataType;
|
import org.meteoinfo.ndarray.DataType;
|
||||||
import org.meteoinfo.ndarray.IndexIterator;
|
import org.meteoinfo.ndarray.IndexIterator;
|
||||||
@ -59,7 +60,6 @@ import org.meteoinfo.ndarray.InvalidRangeException;
|
|||||||
import org.meteoinfo.ndarray.Range;
|
import org.meteoinfo.ndarray.Range;
|
||||||
import org.meteoinfo.ndarray.Section;
|
import org.meteoinfo.ndarray.Section;
|
||||||
import org.meteoinfo.data.meteodata.Attribute;
|
import org.meteoinfo.data.meteodata.Attribute;
|
||||||
import org.meteoinfo.global.util.JDateUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@ -11,6 +11,8 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.meteoinfo.common.Bytes2Number;
|
||||||
import org.meteoinfo.data.DataMath;
|
import org.meteoinfo.data.DataMath;
|
||||||
import org.meteoinfo.data.GridArray;
|
import org.meteoinfo.data.GridArray;
|
||||||
import org.meteoinfo.data.GridData;
|
import org.meteoinfo.data.GridData;
|
||||||
@ -18,7 +20,6 @@ import org.meteoinfo.data.meteodata.DataInfo;
|
|||||||
import org.meteoinfo.data.meteodata.IGridDataInfo;
|
import org.meteoinfo.data.meteodata.IGridDataInfo;
|
||||||
import org.meteoinfo.data.meteodata.MeteoDataType;
|
import org.meteoinfo.data.meteodata.MeteoDataType;
|
||||||
import org.meteoinfo.data.meteodata.Variable;
|
import org.meteoinfo.data.meteodata.Variable;
|
||||||
import org.meteoinfo.global.Bytes2Number;
|
|
||||||
import org.meteoinfo.projection.info.ProjectionInfo;
|
import org.meteoinfo.projection.info.ProjectionInfo;
|
||||||
import org.meteoinfo.ndarray.Array;
|
import org.meteoinfo.ndarray.Array;
|
||||||
import org.meteoinfo.data.meteodata.Attribute;
|
import org.meteoinfo.data.meteodata.Attribute;
|
||||||
|
|||||||
@ -13,10 +13,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.meteoinfo.data.meteodata.hysplit;
|
package org.meteoinfo.data.meteodata.hysplit;
|
||||||
|
|
||||||
|
import org.meteoinfo.common.util.JDateUtil;
|
||||||
import org.meteoinfo.data.meteodata.ascii.ASCIIGridDataInfo;
|
import org.meteoinfo.data.meteodata.ascii.ASCIIGridDataInfo;
|
||||||
import org.meteoinfo.data.GridData;
|
import org.meteoinfo.data.GridData;
|
||||||
import org.meteoinfo.data.meteodata.DataInfo;
|
import org.meteoinfo.data.meteodata.DataInfo;
|
||||||
import org.meteoinfo.global.util.JDateUtil;
|
|
||||||
import org.meteoinfo.ndarray.Dimension;
|
import org.meteoinfo.ndarray.Dimension;
|
||||||
import org.meteoinfo.ndarray.DimensionType;
|
import org.meteoinfo.ndarray.DimensionType;
|
||||||
import org.meteoinfo.data.meteodata.IGridDataInfo;
|
import org.meteoinfo.data.meteodata.IGridDataInfo;
|
||||||
|
|||||||
@ -13,13 +13,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.meteoinfo.data.meteodata.hysplit;
|
package org.meteoinfo.data.meteodata.hysplit;
|
||||||
|
|
||||||
|
import org.meteoinfo.common.Extent;
|
||||||
|
import org.meteoinfo.common.util.JDateUtil;
|
||||||
import org.meteoinfo.data.StationData;
|
import org.meteoinfo.data.StationData;
|
||||||
import org.meteoinfo.data.dataframe.Column;
|
import org.meteoinfo.data.dataframe.Column;
|
||||||
import org.meteoinfo.data.dataframe.ColumnIndex;
|
import org.meteoinfo.data.dataframe.ColumnIndex;
|
||||||
import org.meteoinfo.data.dataframe.DataFrame;
|
import org.meteoinfo.data.dataframe.DataFrame;
|
||||||
import org.meteoinfo.data.dataframe.Index;
|
import org.meteoinfo.data.dataframe.Index;
|
||||||
import org.meteoinfo.data.meteodata.DataInfo;
|
import org.meteoinfo.data.meteodata.DataInfo;
|
||||||
import org.meteoinfo.global.util.JDateUtil;
|
|
||||||
import org.meteoinfo.ndarray.DataType;
|
import org.meteoinfo.ndarray.DataType;
|
||||||
import org.meteoinfo.ndarray.Dimension;
|
import org.meteoinfo.ndarray.Dimension;
|
||||||
import org.meteoinfo.ndarray.DimensionType;
|
import org.meteoinfo.ndarray.DimensionType;
|
||||||
@ -27,7 +28,6 @@ import org.meteoinfo.data.meteodata.IStationDataInfo;
|
|||||||
import org.meteoinfo.data.meteodata.StationInfoData;
|
import org.meteoinfo.data.meteodata.StationInfoData;
|
||||||
import org.meteoinfo.data.meteodata.StationModelData;
|
import org.meteoinfo.data.meteodata.StationModelData;
|
||||||
import org.meteoinfo.data.meteodata.Variable;
|
import org.meteoinfo.data.meteodata.Variable;
|
||||||
import org.meteoinfo.global.Extent;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user