From d25931c502aac5af56b98ab87d268ea198d5ee02 Mon Sep 17 00:00:00 2001 From: wyq Date: Wed, 10 Mar 2021 17:19:43 +0800 Subject: [PATCH] split modules... --- .idea/.name | 1 + .idea/compiler.xml | 8 +- .idea/encodings.xml | 12 +- .idea/misc.xml | 8 +- .idea/modules.xml | 4 +- MeteoInfoLib/MeteoInfoLib.iml | 2 + MeteoInfoLib/pom.xml | 10 + .../main/java/org/meteoinfo/chart/Chart.java | 902 --- .../org/meteoinfo/chart/ChartColorBar.java | 1038 --- .../org/meteoinfo/chart/ChartElement.java | 336 - .../java/org/meteoinfo/chart/ChartLegend.java | 1436 ---- .../org/meteoinfo/chart/ChartNorthArrow.java | 298 - .../java/org/meteoinfo/chart/ChartPanel.java | 1689 ----- .../org/meteoinfo/chart/ChartScaleBar.java | 457 -- .../java/org/meteoinfo/chart/ChartText.java | 741 --- .../java/org/meteoinfo/chart/ChartText3D.java | 127 - .../org/meteoinfo/chart/ChartWindArrow.java | 391 -- .../org/meteoinfo/chart/CoordinateType.java | 17 - .../java/org/meteoinfo/chart/IChartPanel.java | 34 - .../chart/IPointSelectedListener.java | 24 - .../org/meteoinfo/chart/LegendPosition.java | 99 - .../java/org/meteoinfo/chart/Location.java | 17 - .../main/java/org/meteoinfo/chart/Margin.java | 138 - .../java/org/meteoinfo/chart/MouseMode.java | 20 - .../meteoinfo/chart/PointSelectedEvent.java | 31 - .../java/org/meteoinfo/chart/axis/Axis.java | 1958 ------ .../meteoinfo/chart/axis/AxisProperty.java | 95 - .../org/meteoinfo/chart/axis/LogAxis.java | 83 - .../org/meteoinfo/chart/axis/LonLatAxis.java | 182 - .../meteoinfo/chart/axis/PositionType.java | 16 - .../meteoinfo/chart/axis/ProjLonLatAxis.java | 174 - .../org/meteoinfo/chart/axis/TimeAxis.java | 379 -- .../org/meteoinfo/chart/axis/TimeUnit.java | 19 - .../meteoinfo/chart/plot/AbstractPlot2D.java | 1418 ---- .../org/meteoinfo/chart/plot/AxesUnits.java | 15 - .../meteoinfo/chart/plot/ChartPlotMethod.java | 18 - .../meteoinfo/chart/plot/GraphicFactory.java | 5778 ----------------- .../org/meteoinfo/chart/plot/GridLine.java | 166 - .../org/meteoinfo/chart/plot/MapPlot.java | 1314 ---- .../org/meteoinfo/chart/plot/PiePlot.java | 161 - .../java/org/meteoinfo/chart/plot/Plot.java | 498 -- .../java/org/meteoinfo/chart/plot/Plot2D.java | 1245 ---- .../java/org/meteoinfo/chart/plot/Plot3D.java | 2375 ------- .../meteoinfo/chart/plot/PlotOrientation.java | 15 - .../org/meteoinfo/chart/plot/PlotSeries.java | 65 - .../org/meteoinfo/chart/plot/PlotType.java | 17 - .../org/meteoinfo/chart/plot/PolarPlot.java | 838 --- .../meteoinfo/chart/plot/SeriesLegend.java | 175 - .../org/meteoinfo/chart/plot/XY1DPlot.java | 865 --- .../chart/plot3d/GraphicCollection3D.java | 180 - .../meteoinfo/chart/plot3d/ImageShape3D.java | 58 - .../org/meteoinfo/chart/plot3d/Projector.java | 548 -- .../meteoinfo/data/mapdata/FrmAttriData.java | 415 -- .../meteoinfo/data/mapdata/MapDataManage.java | 747 --- .../org/meteoinfo/drawing/ContourDraw.java | 140 - .../org/meteoinfo/drawing/StringType.java | 16 - .../meteoinfo/geoprocess/GeoComputation.java | 2 +- .../meteoinfo/geoprocess/GeometryUtil.java | 2 +- .../geoprocess/analysis/AnalysisTypes.java | 14 - .../geoprocess/analysis/Clustering.java | 664 -- .../geoprocess/analysis/DistanceType.java | 14 - .../analysis/InterpolationMethods.java | 39 - .../analysis/InterpolationSetting.java | 231 - .../java/org/meteoinfo/layer/ChartSet.java | 457 -- .../org/meteoinfo/layer/FrmChartLabel.form | 146 - .../java/org/meteoinfo/layer/FrmLabelSet.form | 363 -- .../org/meteoinfo/layer/FrmLayerProperty.form | 727 --- .../java/org/meteoinfo/layer/ImageLayer.java | 890 --- .../java/org/meteoinfo/layer/LabelSet.java | 323 - .../org/meteoinfo/layer/LayerCollection.java | 59 - .../org/meteoinfo/layer/LayerDrawType.java | 38 - .../java/org/meteoinfo/layer/LayerTypes.java | 26 - .../java/org/meteoinfo/layer/MapLayer.java | 382 -- .../java/org/meteoinfo/layer/RasterLayer.java | 582 -- .../java/org/meteoinfo/layer/VectorLayer.java | 3144 --------- .../meteoinfo/layer/VectorLayerBeanInfo.java | 27 - .../org/meteoinfo/layer/VisibleScale.java | 119 - .../java/org/meteoinfo/layer/WebMapLayer.java | 919 --- .../org/meteoinfo/layer/WorldFilePara.java | 54 - .../java/org/meteoinfo/layout/FrmPageSet.form | 259 - .../org/meteoinfo/layout/LayoutChart.java | 78 - .../org/meteoinfo/layout/LayoutElement.java | 371 -- .../org/meteoinfo/layout/LayoutScaleBar.java | 730 --- .../java/org/meteoinfo/layout/MapLayout.java | 4445 ------------- .../meteoinfo/legend/FrmColorSymbolSet.form | 97 - .../meteoinfo/legend/FrmLabelSymbolSet.form | 181 - .../meteoinfo/legend/FrmLabelSymbolSet.java | 310 - .../org/meteoinfo/legend/FrmLegendBreaks.form | 303 - .../org/meteoinfo/legend/FrmLegendSet.form | 233 - .../meteoinfo/legend/FrmPointSymbolSet.form | 356 - .../meteoinfo/legend/FrmPolygonSymbolSet.form | 291 - .../legend/FrmPolylineSymbolSet.form | 362 -- .../legend/FrmPolylineSymbolSet.java | 602 -- .../java/org/meteoinfo/legend/LegendNode.java | 95 - .../meteoinfo/legend/LegendSchemeControl.java | 67 - .../java/org/meteoinfo/map/FrmIdentifer.form | 59 - .../java/org/meteoinfo/map/FrmIdentifer.java | 174 - .../org/meteoinfo/map/FrmIdentiferGrid.form | 72 - .../org/meteoinfo/map/FrmVerticeEdit.form | 117 - .../org/meteoinfo/map/MapViewBeanInfo.java | 34 - .../main/java/org/meteoinfo/map/MaskOut.java | 209 - .../java/org/meteoinfo/script/MapForm.java | 4 +- .../org/meteoinfo/script/MeteoInfoMap.java | 12 +- .../org/meteoinfo/script/MeteoInfoScript.java | 11 +- MeteoInfoLib/src/test/java/map/frmMap.java | 12 +- hs_err_pid31056.log | 10 +- meteoinfo-chart/meteoinfo-chart.iml | 36 +- meteoinfo-chart/pom.xml | 10 + .../main/java/org/meteoinfo/chart/Chart.java | 902 --- .../org/meteoinfo/chart/ChartColorBar.java | 1046 --- .../java/org/meteoinfo/chart/ChartLegend.java | 1441 ---- .../org/meteoinfo/chart/ChartNorthArrow.java | 297 - .../java/org/meteoinfo/chart/ChartPanel.java | 1689 ----- .../org/meteoinfo/chart/ChartScaleBar.java | 457 -- .../java/org/meteoinfo/chart/ChartText.java | 740 --- .../java/org/meteoinfo/chart/ChartText3D.java | 127 - .../org/meteoinfo/chart/ChartWindArrow.java | 391 -- .../org/meteoinfo/chart/CoordinateType.java | 17 - .../java/org/meteoinfo/chart/IChartPanel.java | 34 - .../chart/IPointSelectedListener.java | 24 - .../org/meteoinfo/chart/LegendPosition.java | 99 - .../java/org/meteoinfo/chart/Location.java | 17 - .../main/java/org/meteoinfo/chart/Margin.java | 138 - .../java/org/meteoinfo/chart/MouseMode.java | 20 - .../org/meteoinfo/chart/NorthArrowType.java | 30 - .../meteoinfo/chart/PointSelectedEvent.java | 31 - .../java/org/meteoinfo/chart/axis/Axis.java | 10 +- .../org/meteoinfo/chart/axis/LogAxis.java | 2 +- .../meteoinfo/chart/axis/ProjLonLatAxis.java | 4 +- .../org/meteoinfo/chart/drawing/Draw.java | 4587 ------------- .../org/meteoinfo/chart/form/ChartForm.form | 25 + .../org/meteoinfo/chart/form/ChartForm.java | 95 + .../meteoinfo/chart/graphic/ChartGraphic.java | 144 - .../org/meteoinfo/chart/graphic/Graphic.java | 713 -- .../chart/graphic/GraphicCollection.java | 692 -- .../meteoinfo/chart/graphic/ImageGraphic.java | 44 - .../chart/graphic/PolylineErrorShape.java | 195 - .../meteoinfo/chart/jogl/GLChartPanel.java | 21 +- .../java/org/meteoinfo/chart/jogl/GLForm.java | 85 +- .../chart/jogl/IsosurfaceGraphics.java | 7 +- .../org/meteoinfo/chart/jogl/JOGLUtil.java | 37 +- .../org/meteoinfo/chart/jogl/Lighting.java | 3 +- .../chart/jogl/ParticleGraphics.java | 0 .../org/meteoinfo/chart/jogl/Plot3DGL.java | 53 +- .../meteoinfo/chart/jogl/SurfaceGraphics.java | 0 .../meteoinfo/chart/jogl/TextureShape.java | 5 +- .../org/meteoinfo/chart/jogl/Transform.java | 0 .../org/meteoinfo/chart/jogl/Triangle.java | 0 .../chart/jogl/mc/BenchmarkHandler.java | 1598 ++--- .../meteoinfo/chart/jogl/mc/CallbackMC.java | 46 +- .../chart/jogl/mc/ExtractHandler.java | 1074 +-- .../org/meteoinfo/chart/jogl/mc/Main.java | 574 +- .../chart/jogl/mc/MarchingCubes.java | 2161 +++--- .../org/meteoinfo/chart/jogl/mc/TablesMC.java | 606 +- .../chart/jogl/mc/VolumeGenerator.java | 232 +- .../chart/jogl/tessellator/Primitive.java | 0 .../tessellator/PrimitiveTessellator.java | 1 - .../chart/jogl/tessellator/TessPolygon.java | 0 .../jogl/tessellator/TriangleTessellator.java | 1 - .../meteoinfo/chart/plot/AbstractPlot2D.java | 2 +- .../meteoinfo/chart/plot/CategoryPlot.java | 125 +- .../meteoinfo/chart/plot/GraphicFactory.java | 89 +- .../org/meteoinfo/chart/plot/GridLine.java | 2 +- .../org/meteoinfo/chart/plot/MapPlot.java | 22 +- .../org/meteoinfo/chart/plot/PiePlot.java | 14 +- .../java/org/meteoinfo/chart/plot/Plot.java | 15 +- .../java/org/meteoinfo/chart/plot/Plot2D.java | 31 +- .../java/org/meteoinfo/chart/plot/Plot3D.java | 49 +- .../org/meteoinfo/chart/plot/PolarPlot.java | 14 +- .../meteoinfo/chart/plot/SeriesLegend.java | 8 +- .../java/org/meteoinfo/chart/plot/XAlign.java | 16 - .../org/meteoinfo/chart/plot/XY1DPlot.java | 6 +- .../java/org/meteoinfo/chart/plot/YAlign.java | 16 - .../chart/plot3d/GraphicCollection3D.java | 2 +- .../org/meteoinfo/chart/plot3d/Projector.java | 4 +- .../chart}/shape/PolylineErrorShape.java | 2 +- .../org/meteoinfo/chart/util}/PlotUtil.java | 14 +- .../main/resources/images/AttributeTable.png | Bin .../src/main/resources/images/Edit_tool.png | Bin 0 -> 302 bytes .../src/main/resources/images/Label.png | Bin .../src/main/resources/images/Layers.png | Bin .../src/main/resources/images/MeteoInfo.png | Bin .../resources/images/Pan_Open_32x32x32.png | Bin .../src/main/resources/images/Properties.png | Bin 0 -> 714 bytes .../main/resources/images/TSB_Add.Image.png | Bin 0 -> 175 bytes .../main/resources/images/TSB_Area.Image.png | Bin 0 -> 165 bytes .../main/resources/images/TSB_Del.Image.png | Bin 0 -> 149 bytes .../resources/images/TSB_DelAll.Image.png | Bin 0 -> 310 bytes .../resources/images/TSB_Distance.Image.png | Bin 0 -> 258 bytes .../main/resources/images/TSB_Down.Image.png | Bin 0 -> 388 bytes .../resources/images/TSB_Feature.Image.png | Bin 0 -> 394 bytes .../resources/images/TSB_FullExent.Image.png | Bin .../resources/images/TSB_LabelSet.Image.png | Bin 0 -> 191 bytes .../resources/images/TSB_MakeBreaks.Image.png | Bin 0 -> 200 bytes .../main/resources/images/TSB_None.Image.png | Bin 0 -> 219 bytes .../main/resources/images/TSB_Open.Image.png | Bin .../main/resources/images/TSB_Pan.Image.png | Bin .../resources/images/TSB_Reverse.Image.png | Bin 0 -> 652 bytes .../main/resources/images/TSB_Save.Image.png | Bin 0 -> 373 bytes .../main/resources/images/TSB_Up.Image.png | Bin 0 -> 383 bytes .../resources/images/TSB_ZoomIn.Image.png | Bin .../resources/images/TSB_ZoomOut.Image.png | Bin .../images/TSB_ZoomToLayer.Image.png | Bin .../resources/images/VertexEdit_32x32x32.png | Bin 0 -> 175 bytes .../src/main/resources/images/ZoomToLayer.png | Bin .../resources/images/identifer_32x32x32.png | Bin .../src/main/resources/images/information.png | Bin .../main/resources/images/insert_vertice.png | Bin 0 -> 234 bytes .../src/main/resources/images/loading.png | Bin 0 -> 3318 bytes .../src/main/resources/images/rotate.png | Bin 0 -> 410 bytes .../src/main/resources/images/star.bmp | Bin 0 -> 17476 bytes .../resources/images/zoom_in_32x32x32.png | Bin .../resources/images/zoom_out_32x32x32.png | Bin meteoinfo-data/pom.xml | 8 + .../compression/DeflateCompression.java | 68 - .../data/meteodata/MeteoDataInfo.java | 6 +- .../meteodata/ascii/ASCIIGridDataInfo.java | 2 +- .../meteodata/bandraster/BILDataInfo.java | 2 +- .../meteodata/bandraster/GeoTiffDataInfo.java | 2 +- .../data/meteodata/grads/GrADSDataInfo.java | 2 +- .../data/meteodata/grads/VARDEFS.java | 1 + .../meteodata/grib2/GRIB2MessageIndex.java | 1 + .../hysplit/HYSPLITConcDataInfo.java | 4 +- .../hysplit/HYSPLITTrajDataInfo.java | 13 +- .../meteodata/micaps/MICAPS2DataInfo.java | 2 +- .../meteodata/micaps/MICAPS7DataInfo.java | 14 +- .../data/meteodata/micaps/MICAPSDataInfo.java | 1 + .../data/meteodata/netcdf/NCUtil.java | 1 + meteoinfo-geo/meteoinfo-geo.iml | 26 + meteoinfo-geo/pom.xml | 83 + .../geo/analysis/GeoComputation.java | 2 +- .../meteoinfo/geo/analysis/GeometryUtil.java | 956 +++ .../geo/analysis/InterpolationSetting.java | 2 +- .../geo/analysis/ResampleMethods.java | 14 - .../meteoinfo/geo/analysis/Statistics.java | 233 - .../org/meteoinfo/geo/data/GridArray.java | 984 --- .../java/org/meteoinfo/geo/data/GridData.java | 3571 ---------- .../meteoinfo/geo/data/GridDataSetting.java | 36 - .../org/meteoinfo/geo/data/StationData.java | 1554 ----- .../meteoinfo/geo/data/StationTableData.java | 199 - .../org/meteoinfo/geo/data/TableData.java | 1264 ---- .../geo/data/ascii/ASCIIGridDataInfo.java | 584 -- .../geo/data/ascii/LonLatStationDataInfo.java | 378 -- .../geo/data/ascii/SurferGridDataInfo.java | 355 - .../meteoinfo/geo/data/geotiff/FieldType.java | 80 - .../meteoinfo/geo/data/geotiff/GeoKey.java | 404 -- .../meteoinfo/geo/data/geotiff/GeoTiff.java | 1531 ----- .../meteoinfo/geo/data/geotiff/IFDEntry.java | 236 - .../org/meteoinfo/geo/data/geotiff/Tag.java | 124 - .../data/geotiff/compression/ByteReader.java | 394 -- .../compression/CompressionDecoder.java | 26 - .../compression/CompressionEncoder.java | 34 - .../compression/DeflateCompression.java | 68 - .../geotiff/compression/LZWCompression.java | 287 - .../geotiff/compression/TiffException.java | 55 - .../geo/data/mapdata/MapDataType.java | 21 - .../geo/data/mapdata/ShapeFileManage.java | 1033 --- .../meteoinfo/geo}/drawing/ContourDraw.java | 2 +- .../java/org/meteoinfo/geo}/drawing/Draw.java | 4 +- .../meteoinfo/geo}/drawing/StringType.java | 2 +- .../org/meteoinfo/geo/gui}/FontChooser.form | 0 .../org/meteoinfo/geo/gui}/FontChooser.java | 7 +- .../meteoinfo/geo/gui}/FrmMeasurement.form | 0 .../meteoinfo/geo/gui}/FrmMeasurement.java | 2 +- .../org/meteoinfo/geo/gui}/FrmProperty.form | 0 .../org/meteoinfo/geo/gui}/FrmProperty.java | 7 +- .../org/meteoinfo/geo}/gui/MainToolBar.java | 539 +- .../org/meteoinfo/geo/layer/ChartSet.java | 87 +- .../meteoinfo/geo}/layer/FrmChartLabel.java | 2 +- .../org/meteoinfo/geo}/layer/FrmLabelSet.java | 4 +- .../geo}/layer/FrmLayerProperty.java | 29 +- .../org/meteoinfo/geo/layer/ImageLayer.java | 2 - .../org/meteoinfo/geo/layer/LabelSet.java | 1 + .../meteoinfo/geo/layer/LayerCollection.java | 10 +- .../org/meteoinfo/geo/layer/MapLayer.java | 84 +- .../org/meteoinfo/geo/layer/RasterLayer.java | 8 +- .../org/meteoinfo/geo/layer/VectorLayer.java | 33 +- .../org/meteoinfo/geo/layer/WebMapLayer.java | 3 +- .../java/org/meteoinfo/geo}/layout/Edge.java | 62 +- .../meteoinfo/geo}/layout/ElementType.java | 58 +- .../org/meteoinfo/geo}/layout/FrmPageSet.java | 2 +- .../geo}/layout/LayerUpdateTypes.java | 76 +- .../meteoinfo/geo/layout/LayoutElement.java | 120 +- .../meteoinfo/geo}/layout/LayoutGraphic.java | 13 +- .../meteoinfo/geo}/layout/LayoutLegend.java | 13 +- .../org/meteoinfo/geo}/layout/LayoutMap.java | 7 +- .../geo}/layout/LayoutNorthArrow.java | 5 +- .../meteoinfo/geo/layout/LayoutScaleBar.java | 731 +++ .../meteoinfo/geo}/layout/LegendStyles.java | 68 +- .../org/meteoinfo/geo/layout/MapLayout.java | 4445 +++++++++++++ .../geo}/layout/MapLayoutBeanInfo.java | 58 +- .../geo}/layout/MapLayoutUndoRedo.java | 2 +- .../org/meteoinfo/geo}/layout/MouseMode.java | 284 +- .../meteoinfo/geo}/layout/NorthArrowType.java | 2 +- .../org/meteoinfo/geo}/layout/PaperSize.java | 194 +- .../meteoinfo/geo}/layout/ResizeAbility.java | 52 +- .../meteoinfo/geo}/layout/ScaleBarType.java | 2 +- .../meteoinfo/geo}/layout/ScaleBarUnits.java | 2 +- .../geo}/legend/FrmColorSymbolSet.java | 2 +- .../geo/legend/FrmLabelSymbolSet.java | 310 + .../geo}/legend/FrmLegendBreaks.java | 18 +- .../meteoinfo/geo}/legend/FrmLegendSet.java | 156 +- .../geo}/legend/FrmPointSymbolSet.java | 20 +- .../geo}/legend/FrmPolygonSymbolSet.java | 14 +- .../geo/legend/FrmPolylineSymbolSet.java | 602 ++ .../geo}/legend/GridLabelPosition.java | 54 +- .../org/meteoinfo/geo}/legend/GroupNode.java | 2 +- .../org/meteoinfo/geo}/legend/ItemNode.java | 2 +- .../org/meteoinfo/geo}/legend/LayerNode.java | 10 +- .../meteoinfo/geo}/legend/LayersLegend.java | 34 +- .../meteoinfo/geo}/legend/LegendManage.java | 8 +- .../org/meteoinfo/geo/legend/LegendNode.java | 95 + .../geo/legend/LegendSchemeControl.java | 67 + .../org/meteoinfo/geo}/legend/LegendView.java | 4 +- .../org/meteoinfo/geo}/legend/MapFrame.java | 18 +- .../org/meteoinfo/geo}/legend/NodeTypes.java | 50 +- .../meteoinfo/geo}/legend/SymbolControl.java | 4 +- .../java/org/meteoinfo/geo}/legend/Test.java | 68 +- .../meteoinfo/geo}/mapdata/FrmAddField.form | 0 .../meteoinfo/geo}/mapdata/FrmAddField.java | 2 +- .../meteoinfo/geo}/mapdata/FrmAttriData.form | 0 .../meteoinfo/geo/mapdata/FrmAttriData.java | 414 ++ .../geo/{data => }/mapdata/MapDataManage.java | 25 +- .../geo}/mapdata/ShapeFileManage.java | 69 +- .../geo/mapview}/FeatureUndoableEdit.java | 36 +- .../meteoinfo/geo/mapview/FrmIdentifer.java | 174 + .../geo/mapview}/FrmIdentiferGrid.java | 2 +- .../geo/mapview}/FrmVerticeEdit.java | 2 +- .../org/meteoinfo/geo/mapview/GridLabel.java | 190 - .../org/meteoinfo/geo/mapview}/MapView.java | 64 +- .../geo/mapview/MapViewBeanInfo.java | 34 + .../geo/mapview}/MapViewUndoRedo.java | 4 +- .../org/meteoinfo/geo/mapview/MaskOut.java | 209 + .../meteoinfo/geo/mapview}/MouseTools.java | 116 +- .../meteoinfo/geo/mapview}/ProjectionSet.java | 6 +- .../geo}/meteodata/DrawMeteoData.java | 87 +- .../geo}/meteodata/TrajDataInfo.java | 4 +- .../org/meteoinfo/geo}/plot/MainPlot.form | 6 +- .../org/meteoinfo/geo}/plot/MainPlot.java | 22 +- .../meteoinfo/geo}/plot/MapLayoutPlot.form | 2 +- .../meteoinfo/geo}/plot/MapLayoutPlot.java | 37 +- .../meteoinfo/geo}/plugin/IApplication.java | 172 +- .../org/meteoinfo/geo}/plugin/IPlugin.java | 180 +- .../org/meteoinfo/geo}/plugin/PluginBase.java | 154 +- .../projection/CoordinateSystemCategory.java | 22 - .../geo/projection/GeoGraphicSystem.java | 29 - .../projection/KnownCoordinateSystems.java | 22 - .../geo/projection/ProjRegistry.java | 458 -- .../geo/projection/ProjectionNames.java | 73 - .../geo/projection/ProjectionUtil.java | 1542 ----- .../meteoinfo/geo/projection/Reproject.java | 585 -- .../org/meteoinfo/geo/projection/World.java | 41 - .../meteoinfo/geo/projection/info/Albers.java | 94 - .../meteoinfo/geo/projection/info/Common.java | 53 - .../info/GeostationarySatellite.java | 130 - .../meteoinfo/geo/projection/info/Hammer.java | 87 - .../info/LambertAzimuthalEqualArea.java | 79 - .../info/LambertConformalConic.java | 99 - .../info/LambertEqualAreaConic.java | 95 - .../geo/projection/info/LongLat.java | 48 - .../geo/projection/info/Mercator.java | 89 - .../geo/projection/info/Molleweide.java | 146 - .../info/OrthographicAzimuthal.java | 126 - .../geo/projection/info/ProjectionInfo.java | 667 -- .../geo/projection/info/Robinson.java | 164 - .../geo/projection/info/Sinusoidal.java | 97 - .../info/StereographicAzimuthal.java | 108 - .../projection/info/TransverseMercator.java | 85 - .../geo/projection/info/Wagner3.java | 95 - .../org/meteoinfo/geo/util/GeoMathUtil.java | 4 +- .../meteoinfo/geo/util/GeoProjectionUtil.java | 14 +- .../org/meteoinfo/geo/util/LegendManage.java | 1854 ------ .../meteoinfo-lab.iml | 81 +- {MeteoInfoLab => meteoinfo-lab}/milconfig.xml | 4 +- {MeteoInfoLab => meteoinfo-lab}/nbactions.xml | 93 +- {MeteoInfoLab => meteoinfo-lab}/pom.xml | 11 +- .../pylib/milab$py.class | Bin .../pylib/milab.py | 0 .../pylib/milab_debug.py | 0 .../pylib/milab_s.py | 0 .../pylib/mipylib/__init__$py.class | Bin .../pylib/mipylib/__init__.py | 0 .../pylib/mipylib/dataframe/__init__$py.class | Bin .../pylib/mipylib/dataframe/__init__.py | 16 +- .../mipylib/dataframe/dataframe$py.class | Bin .../pylib/mipylib/dataframe/dataframe.py | 0 .../pylib/mipylib/dataframe/groupby$py.class | Bin .../pylib/mipylib/dataframe/groupby.py | 0 .../pylib/mipylib/dataframe/index$py.class | Bin .../pylib/mipylib/dataframe/index.py | 0 .../pylib/mipylib/dataframe/indexing$py.class | Bin .../pylib/mipylib/dataframe/indexing.py | 80 +- .../pylib/mipylib/dataframe/series$py.class | Bin .../pylib/mipylib/dataframe/series.py | 0 .../pylib/mipylib/dataset/__init__$py.class | Bin .../pylib/mipylib/dataset/__init__.py | 0 .../mipylib/dataset/dimdatafile$py.class | Bin .../pylib/mipylib/dataset/dimdatafile.py | 0 .../mipylib/dataset/dimvariable$py.class | Bin .../pylib/mipylib/dataset/dimvariable.py | 0 .../pylib/mipylib/dataset/midata$py.class | Bin .../pylib/mipylib/dataset/midata.py | 0 .../pylib/mipylib/dataset/miio$py.class | Bin .../pylib/mipylib/dataset/miio.py | 688 +- .../pylib/mipylib/dataset/ncutil$py.class | Bin .../pylib/mipylib/dataset/ncutil.py | 54 +- .../pylib/mipylib/geolib/__init__$py.class | Bin .../pylib/mipylib/geolib/__init__.py | 14 +- .../pylib/mipylib/geolib/geoutil$py.class | Bin .../pylib/mipylib/geolib/geoutil.py | 0 .../pylib/mipylib/geolib/migeo$py.class | Bin 33917 -> 33926 bytes .../pylib/mipylib/geolib/migeo.py | 4 +- .../pylib/mipylib/geolib/milayer$py.class | Bin 33518 -> 33525 bytes .../pylib/mipylib/geolib/milayer.py | 4 +- .../pylib/mipylib/geolib/topology$py.class | Bin .../pylib/mipylib/geolib/topology.py | 0 .../pylib/mipylib/imagelib/__init__$py.class | Bin .../pylib/mipylib/imagelib/__init__.py | 10 +- .../pylib/mipylib/imagelib/filters$py.class | Bin .../pylib/mipylib/imagelib/filters.py | 0 .../pylib/mipylib/imagelib/io$py.class | Bin .../pylib/mipylib/imagelib/io.py | 0 .../pylib/mipylib/meteolib/__init__$py.class | Bin .../pylib/mipylib/meteolib/__init__.py | 0 .../mipylib/meteolib/calc/__init__$py.class | Bin .../pylib/mipylib/meteolib/calc/__init__.py | 0 .../mipylib/meteolib/calc/kinematics$py.class | Bin .../pylib/mipylib/meteolib/calc/kinematics.py | 0 .../mipylib/meteolib/calc/thermo$py.class | Bin .../pylib/mipylib/meteolib/calc/thermo.py | 0 .../pylib/mipylib/meteolib/constants$py.class | Bin .../pylib/mipylib/meteolib/constants.py | 38 +- .../meteolib/interpolate/__init__$py.class | Bin .../mipylib/meteolib/interpolate/__init__.py | 0 .../interpolate/one_dimension$py.class | Bin .../meteolib/interpolate/one_dimension.py | 0 .../pylib/mipylib/meteolib/meteo$py.class | Bin .../pylib/mipylib/meteolib/meteo.py | 0 .../pylib/mipylib/meteolib/wrf$py.class | Bin .../pylib/mipylib/meteolib/wrf.py | 256 +- .../pylib/mipylib/migl$py.class | Bin .../pylib/mipylib/migl.py | 58 +- .../pylib/mipylib/miutil$py.class | Bin .../pylib/mipylib/miutil.py | 0 .../pylib/mipylib/numeric/__init__$py.class | Bin .../pylib/mipylib/numeric/__init__.py | 0 .../mipylib/numeric/core/__init__$py.class | Bin .../pylib/mipylib/numeric/core/__init__.py | 0 .../mipylib/numeric/core/_dtype$py.class | Bin .../pylib/mipylib/numeric/core/_dtype.py | 0 .../mipylib/numeric/core/dimarray$py.class | Bin 91892 -> 91901 bytes .../pylib/mipylib/numeric/core/dimarray.py | 2 +- .../pylib/mipylib/numeric/core/fromnumeric.py | 0 .../mipylib/numeric/core/mitable$py.class | Bin .../pylib/mipylib/numeric/core/mitable.py | 0 .../mipylib/numeric/core/multiarray$py.class | Bin .../pylib/mipylib/numeric/core/multiarray.py | 0 .../mipylib/numeric/core/numeric$py.class | Bin 144378 -> 144392 bytes .../pylib/mipylib/numeric/core/numeric.py | 4 +- .../mipylib/numeric/core/numerictypes.py | 0 .../mipylib/numeric/fitting/__init__$py.class | Bin .../pylib/mipylib/numeric/fitting/__init__.py | 0 .../mipylib/numeric/fitting/fitting$py.class | Bin .../pylib/mipylib/numeric/fitting/fitting.py | 0 .../numeric/interpolate/__init__$py.class | Bin .../mipylib/numeric/interpolate/__init__.py | 0 .../numeric/interpolate/interpolate$py.class | Bin .../numeric/interpolate/interpolate.py | 0 .../numeric/interpolate/ndgriddata$py.class | Bin .../mipylib/numeric/interpolate/ndgriddata.py | 0 .../mipylib/numeric/lib/__init__$py.class | Bin .../pylib/mipylib/numeric/lib/__init__.py | 0 .../pylib/mipylib/numeric/lib/_util$py.class | Bin .../pylib/mipylib/numeric/lib/_util.py | 0 .../pylib/mipylib/numeric/lib/index_tricks.py | 0 .../pylib/mipylib/numeric/lib/shape_base.py | 0 .../mipylib/numeric/linalg/__init__$py.class | Bin .../pylib/mipylib/numeric/linalg/__init__.py | 0 .../mipylib/numeric/linalg/linalg$py.class | Bin .../pylib/mipylib/numeric/linalg/linalg.py | 0 .../numeric/optimize/__init__$py.class | Bin .../mipylib/numeric/optimize/__init__.py | 0 .../numeric/optimize/_lsq/__init__$py.class | Bin .../mipylib/numeric/optimize/_lsq/__init__.py | 0 .../numeric/optimize/_lsq/common$py.class | Bin .../mipylib/numeric/optimize/_lsq/common.py | 0 .../optimize/_lsq/least_squares$py.class | Bin .../numeric/optimize/_lsq/least_squares.py | 0 .../mipylib/numeric/optimize/minpack$py.class | Bin .../pylib/mipylib/numeric/optimize/minpack.py | 0 .../mipylib/numeric/random/__init__$py.class | Bin .../pylib/mipylib/numeric/random/__init__.py | 0 .../pylib/mipylib/numeric/random/_random.py | 0 .../mipylib/numeric/random/mtrand$py.class | Bin .../pylib/mipylib/numeric/random/mtrand.py | 0 .../pylib/mipylib/numeric/signal/__init__.py | 0 .../mipylib/numeric/signal/signaltools.py | 0 .../mipylib/numeric/stats/__init__$py.class | Bin .../pylib/mipylib/numeric/stats/__init__.py | 12 +- .../stats/_distn_infrastructure$py.class | Bin .../numeric/stats/_distn_infrastructure.py | 0 .../numeric/stats/distributions$py.class | Bin .../mipylib/numeric/stats/distributions.py | 592 +- .../pylib/mipylib/numeric/stats/kde$py.class | Bin .../pylib/mipylib/numeric/stats/kde.py | 0 .../mipylib/numeric/stats/stats$py.class | Bin .../pylib/mipylib/numeric/stats/stats.py | 0 .../pylib/mipylib/plotlib/__init__$py.class | Bin .../pylib/mipylib/plotlib/__init__.py | 22 +- .../pylib/mipylib/plotlib/_axes$py.class | Bin 201416 -> 201424 bytes .../pylib/mipylib/plotlib/_axes.py | 4 +- .../pylib/mipylib/plotlib/_axes3d$py.class | Bin 84499 -> 84507 bytes .../pylib/mipylib/plotlib/_axes3d.py | 4 +- .../pylib/mipylib/plotlib/_axes3dgl$py.class | Bin 62177 -> 62185 bytes .../pylib/mipylib/plotlib/_axes3dgl.py | 4 +- .../pylib/mipylib/plotlib/_figure$py.class | Bin .../pylib/mipylib/plotlib/_figure.py | 0 .../pylib/mipylib/plotlib/_glfigure$py.class | Bin .../pylib/mipylib/plotlib/_glfigure.py | 0 .../pylib/mipylib/plotlib/_mapaxes$py.class | Bin 92105 -> 92124 bytes .../pylib/mipylib/plotlib/_mapaxes.py | 10 +- .../pylib/mipylib/plotlib/miplot$py.class | Bin 163604 -> 163612 bytes .../pylib/mipylib/plotlib/miplot.py | 6 +- .../pylib/mipylib/plotlib/plotutil$py.class | Bin 56537 -> 56541 bytes .../pylib/mipylib/plotlib/plotutil.py | 2 +- .../java/org/meteoinfo/lab}/MeteoInfoLab.java | 14 +- .../main/java/org/meteoinfo/lab}/Options.java | 2 +- .../java/org/meteoinfo/lab}/StackWindow.java | 138 +- .../lab}/application/AppCollection.java | 2 +- .../lab}/application/Application.java | 242 +- .../lab}/event/CurrentPathChangedEvent.java | 60 +- .../event/ICurrentPathChangedListener.java | 48 +- .../meteoinfo/lab}/gui/ConsoleDockable.java | 4 +- .../lab}/gui/CustomWindowFactory.java | 57 +- .../meteoinfo/lab}/gui/EditorDockable.java | 4 +- .../org/meteoinfo/lab}/gui/EncodingUtil.java | 106 +- .../meteoinfo/lab}/gui/FigureDockable.java | 18 +- .../org/meteoinfo/lab}/gui/FileDockable.java | 170 +- .../org/meteoinfo/lab}/gui/FileExplorer.java | 14 +- .../java/org/meteoinfo/lab}/gui/FrmAbout.form | 0 .../java/org/meteoinfo/lab}/gui/FrmAbout.java | 2 +- .../meteoinfo/lab}/gui/FrmAppsManager.form | 0 .../meteoinfo/lab}/gui/FrmAppsManager.java | 8 +- .../org/meteoinfo/lab}/gui/FrmCustom.java | 5 +- .../meteoinfo/lab}/gui/FrmFindReplace.form | 0 .../meteoinfo/lab}/gui/FrmFindReplace.java | 2 +- .../java/org/meteoinfo/lab}/gui/FrmMain.form | 0 .../java/org/meteoinfo/lab}/gui/FrmMain.java | 86 +- .../org/meteoinfo/lab}/gui/FrmSetting.form | 0 .../org/meteoinfo/lab}/gui/FrmSetting.java | 2 +- .../java/org/meteoinfo/lab}/gui/GuiUtil.java | 148 +- .../meteoinfo/lab}/gui/OutputDockable.java | 80 +- .../meteoinfo/lab}/gui/VariableDockable.java | 86 +- .../meteoinfo/lab}/gui/VariableExplorer.java | 114 +- .../org/meteoinfo/lab/util/JythonUtil.java | 55 + .../resources/codecomplete/abstract_co.gif | Bin .../codecomplete/class_default_obj.gif | Bin .../main/resources/codecomplete/class_obj.gif | Bin .../resources/codecomplete/constr_ovr.gif | Bin .../resources/codecomplete/deprecated.gif | Bin .../codecomplete/enum_default_obj.gif | Bin .../main/resources/codecomplete/enum_obj.gif | Bin .../codecomplete/enum_private_obj.gif | Bin .../codecomplete/enum_protected_obj.gif | Bin .../main/resources/codecomplete/error_obj.gif | Bin .../codecomplete/field_default_obj.gif | Bin .../codecomplete/field_private_obj.gif | Bin .../codecomplete/field_protected_obj.gif | Bin .../codecomplete/field_public_obj.gif | Bin .../main/resources/codecomplete/final_co.gif | Bin .../resources/codecomplete/html_tag_obj.gif | Bin .../main/resources/codecomplete/imp_obj.gif | Bin .../main/resources/codecomplete/impc_obj.gif | Bin .../main/resources/codecomplete/info_obj.gif | Bin .../codecomplete/innerclass_default_obj.gif | Bin .../codecomplete/innerclass_private_obj.gif | Bin .../codecomplete/innerclass_protected_obj.gif | Bin .../codecomplete/innerclass_public_obj.gif | Bin .../innerinterface_default_obj.gif | Bin .../innerinterface_private_obj.gif | Bin .../innerinterface_protected_obj.gif | Bin .../innerinterface_public_obj.gif | Bin .../codecomplete/int_default_obj.gif | Bin .../main/resources/codecomplete/int_obj.gif | Bin .../main/resources/codecomplete/jcu_obj.gif | Bin .../resources/codecomplete/jdoc_tag_obj.gif | Bin .../codecomplete/localvariable_obj.gif | Bin .../resources/codecomplete/methdef_obj.gif | Bin .../resources/codecomplete/methpri_obj.gif | Bin .../resources/codecomplete/methpro_obj.gif | Bin .../resources/codecomplete/methpub_obj.gif | Bin .../resources/codecomplete/package_obj.gif | Bin .../main/resources/codecomplete/static_co.gif | Bin .../main/resources/codecomplete/synch_co.gif | Bin .../resources/codecomplete/template_obj.gif | Bin .../resources/codecomplete/warning_obj.gif | Bin .../src/main/resources/images/Arrow.png | Bin .../src/main/resources/images/Color_Wheel.png | Bin .../main/resources/images/Disk_1_16x16x8.png | Bin .../resources/images/Folder_1_16x16x8.png | Bin .../src/main/resources/images/MeteoLab_16.png | Bin .../src/main/resources/images/MeteoLab_32.png | Bin .../resources/images/Pan_Open_32x32x32.png | Bin 0 -> 233 bytes .../images/TSB_DrawSetting.Image.png | Bin .../resources/images/TSB_FullExtent.Image.png | Bin .../resources/images/TSB_NewFile.Image.png | Bin .../main/resources/images/TSB_Pan.Image.png | Bin .../main/resources/images/TSB_Redo.Image.png | Bin .../resources/images/TSB_RunScript.Image.png | Bin .../main/resources/images/TSB_Undo.Image.png | Bin .../resources/images/TSB_ZoomIn.Image.png | Bin .../resources/images/TSB_ZoomOut.Image.png | Bin .../resources/images/TSMI_EditCut.Image.png | Bin .../src/main/resources/images/closefile.png | Bin .../src/main/resources/images/colors.png | Bin .../src/main/resources/images/find.png | Bin 0 -> 280 bytes .../src/main/resources/images/folder.png | Bin .../src/main/resources/images/help.png | Bin .../resources/images/identifer_32x32x32.png | Bin 0 -> 174 bytes .../src/main/resources/images/information.png | Bin .../main/resources/images/jython_small_c.png | Bin .../src/main/resources/images/logo.jpg | Bin .../resources/images/menuEditCopy.Image.png | Bin .../main/resources/images/miSetFont.Image.png | Bin .../images/pasteToolStripButton.Image.png | Bin .../resources/images/plugin_edit_green.png | Bin .../main/resources/images/plugin_green.png | Bin .../main/resources/images/plugin_unsel.png | Bin .../src/main/resources/images/previous.png | Bin .../src/main/resources/images/python_16px.png | Bin .../src/main/resources/images/rotate_16.png | Bin .../src/main/resources/images/save_16.png | Bin .../src/main/resources/images/setting.png | Bin .../src/main/resources/images/up_arrow.png | Bin .../src/main/resources/images/update.png | Bin .../resources/images/zoom_in_32x32x32.png | Bin 0 -> 238 bytes .../resources/images/zoom_out_32x32x32.png | Bin 0 -> 226 bytes .../org/meteoinfo/lab}/icons/back.svg | 0 .../org/meteoinfo/lab}/icons/color-wheel.svg | 0 .../org/meteoinfo/lab}/icons/colors.svg | 0 .../org/meteoinfo/lab}/icons/console.svg | 0 .../org/meteoinfo/lab}/icons/copy.svg | 0 .../org/meteoinfo/lab}/icons/editor.svg | 0 .../org/meteoinfo/lab}/icons/execute.svg | 0 .../org/meteoinfo/lab}/icons/figure.svg | 0 .../meteoinfo/lab}/icons/file-close-all.svg | 0 .../meteoinfo/lab}/icons/file-explorer.svg | 0 .../org/meteoinfo/lab}/icons/file-new.svg | 0 .../org/meteoinfo/lab}/icons/file-open.svg | 0 .../org/meteoinfo/lab}/icons/file-save-as.svg | 0 .../org/meteoinfo/lab}/icons/file-save.svg | 0 .../org/meteoinfo/lab}/icons/find.svg | 0 .../org/meteoinfo/lab}/icons/find_16.svg | 0 .../org/meteoinfo/lab}/icons/folder-up.svg | 0 .../org/meteoinfo/lab}/icons/folder.svg | 0 .../org/meteoinfo/lab}/icons/full-extent.svg | 0 .../org/meteoinfo/lab}/icons/gear.svg | 0 .../org/meteoinfo/lab}/icons/hand.svg | 0 .../org/meteoinfo/lab}/icons/help.svg | 0 .../org/meteoinfo/lab}/icons/help_16.svg | 0 .../org/meteoinfo/lab}/icons/incoming.svg | 0 .../org/meteoinfo/lab}/icons/information.svg | 0 .../org/meteoinfo/lab}/icons/jython.svg | 0 .../org/meteoinfo/lab}/icons/maximize.svg | 0 .../org/meteoinfo/lab}/icons/menu-cut.svg | 0 .../org/meteoinfo/lab}/icons/menu-paste.svg | 0 .../org/meteoinfo/lab}/icons/minimize.svg | 0 .../org/meteoinfo/lab}/icons/move.svg | 0 .../org/meteoinfo/lab}/icons/outgoing.svg | 0 .../org/meteoinfo/lab}/icons/pan_16.svg | 0 .../org/meteoinfo/lab}/icons/python.svg | 0 .../org/meteoinfo/lab}/icons/python_16.svg | 0 .../org/meteoinfo/lab}/icons/redo.svg | 0 .../org/meteoinfo/lab}/icons/refresh.svg | 0 .../org/meteoinfo/lab}/icons/restore.svg | 0 .../org/meteoinfo/lab}/icons/rotate_16.svg | 0 .../org/meteoinfo/lab}/icons/save-as.svg | 0 .../org/meteoinfo/lab}/icons/select.svg | 0 .../org/meteoinfo/lab}/icons/select_16.svg | 0 .../org/meteoinfo/lab}/icons/setting.svg | 0 .../org/meteoinfo/lab}/icons/terminal.svg | 0 .../org/meteoinfo/lab}/icons/toolbox.svg | 0 .../org/meteoinfo/lab}/icons/undo.svg | 0 .../org/meteoinfo/lab}/icons/variable.svg | 0 .../org/meteoinfo/lab}/icons/zoom-in.svg | 0 .../org/meteoinfo/lab}/icons/zoom-out.svg | 0 {MeteoInfoMap => meteoinfo-map}/config.xml | 4 +- {MeteoInfoMap => meteoinfo-map}/default.mip | 0 .../meteoinfo-map.iml | 65 +- {MeteoInfoMap => meteoinfo-map}/nbactions.xml | 93 +- {MeteoInfoMap => meteoinfo-map}/pom.xml | 6 +- .../java/org/meteoinfo/map}/MeteoInfoMap.java | 14 +- .../java/org/meteoinfo/map}/StackWindow.java | 140 +- .../meteoinfo/map}/config/EncodingUtil.java | 106 +- .../map}/config/GenericFileFilter.java | 234 +- .../meteoinfo/map}/config/MapFileFilter.java | 116 +- .../org/meteoinfo/map}/config/Options.java | 2 +- .../org/meteoinfo/map}/config/Plugin.java | 258 +- .../map}/config/PluginCollection.java | 394 +- .../meteoinfo/map}/config/ProjectFile.java | 380 +- .../map}/event/CurrentToolChangedEvent.java | 60 +- .../event/ICurrentToolChangedListener.java | 48 +- .../org/meteoinfo/map}/forms/FrmAbout.form | 0 .../org/meteoinfo/map}/forms/FrmAbout.java | 2 +- .../org/meteoinfo/map}/forms/FrmAddField.form | 0 .../org/meteoinfo/map}/forms/FrmAddField.java | 2 +- .../meteoinfo/map}/forms/FrmAddXYData.form | 0 .../meteoinfo/map}/forms/FrmAddXYData.java | 8 +- .../meteoinfo/map}/forms/FrmArrivalTimes.form | 0 .../meteoinfo/map}/forms/FrmArrivalTimes.java | 2 +- .../org/meteoinfo/map}/forms/FrmBuffer.form | 0 .../org/meteoinfo/map}/forms/FrmBuffer.java | 10 +- .../org/meteoinfo/map}/forms/FrmClipping.form | 0 .../org/meteoinfo/map}/forms/FrmClipping.java | 10 +- .../org/meteoinfo/map}/forms/FrmConsole.form | 0 .../org/meteoinfo/map}/forms/FrmConsole.java | 2 +- .../meteoinfo/map}/forms/FrmConvexhull.form | 0 .../meteoinfo/map}/forms/FrmConvexhull.java | 10 +- .../org/meteoinfo/map}/forms/FrmDataInfo.form | 0 .../org/meteoinfo/map}/forms/FrmDataInfo.java | 5 +- .../meteoinfo/map}/forms/FrmDifference.form | 0 .../meteoinfo/map}/forms/FrmDifference.java | 10 +- .../meteoinfo/map}/forms/FrmGifAnimator.form | 0 .../meteoinfo/map}/forms/FrmGifAnimator.java | 4 +- .../org/meteoinfo/map}/forms/FrmGridSet.form | 0 .../org/meteoinfo/map}/forms/FrmGridSet.java | 2 +- .../meteoinfo/map}/forms/FrmInterpolate.form | 0 .../meteoinfo/map}/forms/FrmInterpolate.java | 6 +- .../meteoinfo/map}/forms/FrmIntersection.form | 0 .../meteoinfo/map}/forms/FrmIntersection.java | 10 +- .../meteoinfo/map}/forms/FrmJoinNCFiles.form | 2 +- .../meteoinfo/map}/forms/FrmJoinNCFiles.java | 4 +- .../org/meteoinfo/map}/forms/FrmMain.java | 248 +- .../meteoinfo/map}/forms/FrmMeteoData.java | 48 +- .../org/meteoinfo/map}/forms/FrmOneDim.form | 48 +- .../org/meteoinfo/map}/forms/FrmOneDim.java | 29 +- .../org/meteoinfo/map}/forms/FrmOpenData.form | 0 .../org/meteoinfo/map}/forms/FrmOpenData.java | 2 +- .../org/meteoinfo/map}/forms/FrmOptions.form | 0 .../org/meteoinfo/map}/forms/FrmOptions.java | 4 +- .../map}/forms/FrmOutputMapData.form | 0 .../map}/forms/FrmOutputMapData.java | 10 +- .../map}/forms/FrmPluginManager.form | 0 .../map}/forms/FrmPluginManager.java | 6 +- .../meteoinfo/map}/forms/FrmProjection.form | 22 +- .../meteoinfo/map}/forms/FrmProjection.java | 2 +- .../meteoinfo/map}/forms/FrmSectionPlot.form | 10 +- .../meteoinfo/map}/forms/FrmSectionPlot.java | 75 +- .../map}/forms/FrmSelectByAttributes.form | 0 .../map}/forms/FrmSelectByAttributes.java | 8 +- .../map}/forms/FrmSelectByLocation.form | 0 .../map}/forms/FrmSelectByLocation.java | 12 +- .../map}/forms/FrmSymDifference.form | 0 .../map}/forms/FrmSymDifference.java | 10 +- .../meteoinfo/map}/forms/FrmTextEditor.form | 30 +- .../meteoinfo/map}/forms/FrmTextEditor.java | 30 +- .../org/meteoinfo/map}/forms/FrmUVSet.form | 0 .../org/meteoinfo/map}/forms/FrmUVSet.java | 2 +- .../org/meteoinfo/map}/forms/FrmViewData.form | 10 +- .../org/meteoinfo/map}/forms/FrmViewData.java | 10 +- .../meteoinfo/map}/forms/FrmZoomToExtent.form | 0 .../meteoinfo/map}/forms/FrmZoomToExtent.java | 4 +- .../map}/forms/ImageFileChooser.java | 198 +- .../map}/forms/ShapeFileChooser.java | 2 +- .../bundle/Bundle_FrmMain.properties | 0 .../bundle/Bundle_FrmMain_zh_CN.properties | 0 .../bundle/Bundle_FrmMeteoData.properties | 0 .../Bundle_FrmMeteoData_zh_CN.properties | 46 +- .../bundle/Bundle_FrmOneDim.properties | 0 .../bundle/Bundle_FrmOneDim_zh_CN.properties | 0 .../bundle/Bundle_FrmProjection.properties | 0 .../Bundle_FrmProjection_zh_CN.properties | 0 .../bundle/Bundle_FrmSectionPlot.properties | 0 .../Bundle_FrmSectionPlot_zh_CN.properties | 0 .../src/main/resources/images/Add_Layer.png | Bin .../src/main/resources/images/Animation-2.png | Bin .../src/main/resources/images/Arrow.png | Bin .../src/main/resources/images/Close_File.png | Bin .../main/resources/images/Disk_1_16x16x8.png | Bin .../resources/images/Folder_1_16x16x8.png | Bin .../src/main/resources/images/Layers.png | Bin 0 -> 131 bytes .../resources/images/MeteoInfo_1_16x16x8.png | Bin 0 -> 514 bytes .../main/resources/images/MeteoInfo_logo.png | Bin .../src/main/resources/images/Save_Image.png | Bin .../src/main/resources/images/Setting-1.png | Bin .../src/main/resources/images/Setting.png | Bin .../src/main/resources/images/Statictics.png | Bin .../images/TSB_ClearDrawing.Image.png | Bin .../main/resources/images/TSB_Draw.Image.png | Bin .../images/TSB_DrawSetting.Image.png | Bin .../images/TSB_EditVertices.Image.png | Bin .../resources/images/TSB_FullExent.Image.png | Bin 0 -> 666 bytes .../resources/images/TSB_LabelSet.Image.png | Bin 0 -> 191 bytes .../images/TSB_Measurement.Image.png | Bin .../resources/images/TSB_NewCircle.Image.png | Bin .../resources/images/TSB_NewCurve.Image.png | Bin .../images/TSB_NewCurvePolygon.Image.png | Bin .../resources/images/TSB_NewEllipse.Image.png | Bin .../resources/images/TSB_NewFile.Image.png | Bin .../images/TSB_NewFreehand.Image.png | Bin .../resources/images/TSB_NewLabel.Image.png | Bin .../resources/images/TSB_NewPoint.Image.png | Bin .../resources/images/TSB_NewPolygon.Image.png | Bin .../images/TSB_NewPolyline.Image.png | Bin .../images/TSB_NewRectangle.Image.png | Bin .../resources/images/TSB_NextTime.Image.png | Bin .../main/resources/images/TSB_Open.Image.png | Bin 0 -> 242 bytes .../resources/images/TSB_PageZoomIn.Image.png | Bin .../images/TSB_PageZoomOut.Image.png | Bin .../main/resources/images/TSB_Pan.Image.png | Bin 0 -> 389 bytes .../resources/images/TSB_PreTime.Image.png | Bin .../main/resources/images/TSB_Redo.Image.png | Bin .../images/TSB_RemoveDataLayes.Image.png | Bin .../resources/images/TSB_RunScript.Image.png | Bin .../images/TSB_SelectFeatures.Image.png | Bin .../resources/images/TSB_Setting.Image.png | Bin .../main/resources/images/TSB_Undo.Image.png | Bin .../resources/images/TSB_ViewData.Image.png | Bin .../resources/images/TSB_ZoomIn.Image.png | Bin 0 -> 408 bytes .../resources/images/TSB_ZoomOut.Image.png | Bin 0 -> 399 bytes .../images/TSB_ZoomToExtent.Image.png | Bin .../images/TSB_ZoomToLayer.Image.png | Bin 0 -> 280 bytes .../resources/images/TSMI_AttriData.Image.png | Bin 0 -> 594 bytes .../resources/images/TSMI_EditCut.Image.png | Bin .../images/TSMI_InsertLegend.Image.png | Bin .../src/main/resources/images/ZoomFullMap.png | Bin .../src/main/resources/images/animation-1.png | Bin .../src/main/resources/images/animation.png | Bin .../src/main/resources/images/chart-5.png | Bin .../src/main/resources/images/chart.png | Bin .../src/main/resources/images/closefile.png | Bin .../src/main/resources/images/console.png | Bin .../src/main/resources/images/edit_16.png | Bin .../src/main/resources/images/help.png | Bin .../src/main/resources/images/info.png | Bin .../src/main/resources/images/information.png | Bin 0 -> 736 bytes .../main/resources/images/jython_small_c.png | Bin .../main/resources/images/location_arrow.png | Bin .../src/main/resources/images/logo.jpg | Bin .../resources/images/menuEditCopy.Image.png | Bin .../src/main/resources/images/merge.png | Bin .../main/resources/images/miSetFont.Image.png | Bin .../main/resources/images/new_document_16.png | Bin .../main/resources/images/page_portrait.png | Bin .../images/pasteToolStripButton.Image.png | Bin .../resources/images/plugin_edit_green.png | Bin .../main/resources/images/plugin_green.png | Bin .../main/resources/images/plugin_unsel.png | Bin .../src/main/resources/images/point.png | Bin .../src/main/resources/images/reform_edit.png | Bin .../src/main/resources/images/ring.png | Bin .../src/main/resources/images/ring_add.png | Bin .../src/main/resources/images/ring_delete.png | Bin .../src/main/resources/images/save_16.png | Bin .../main/resources/images/select_circle.png | Bin .../main/resources/images/select_lasso.png | Bin .../main/resources/images/select_polygon.png | Bin .../resources/images/select_rectangle.png | Bin .../src/main/resources/images/snake.png | Bin .../src/main/resources/images/split.png | Bin .../src/main/resources/images/stop.png | Bin .../meteoinfo/map}/icons/add-layer-plus.svg | 0 .../org/meteoinfo/map}/icons/add-layer.svg | 0 .../org/meteoinfo/map}/icons/add-ring.svg | 0 .../meteoinfo/map}/icons/add-web-layer.svg | 0 .../meteoinfo/map}/icons/animator-file.svg | 0 .../org/meteoinfo/map}/icons/animator.svg | 0 .../org/meteoinfo/map}/icons/buffer.svg | 0 .../org/meteoinfo/map}/icons/cancel.svg | 0 .../meteoinfo/map}/icons/chart-line-bar.svg | 0 .../org/meteoinfo/map}/icons/chart-line.svg | 0 .../org/meteoinfo/map}/icons/chart-points.svg | 0 .../org/meteoinfo/map}/icons/clip.svg | 0 .../org/meteoinfo/map}/icons/close.svg | 0 .../org/meteoinfo/map}/icons/console.svg | 0 .../org/meteoinfo/map}/icons/convexhull.svg | 0 .../org/meteoinfo/map}/icons/copy.svg | 0 .../org/meteoinfo/map}/icons/delete-ring.svg | 0 .../org/meteoinfo/map}/icons/difference.svg | 0 .../org/meteoinfo/map}/icons/draw-layer.svg | 0 .../meteoinfo/map}/icons/edit-add-feature.svg | 0 .../org/meteoinfo/map}/icons/edit-status.svg | 0 .../org/meteoinfo/map}/icons/edit-tool.svg | 0 .../meteoinfo/map}/icons/edit-vertices.svg | 0 .../org/meteoinfo/map}/icons/editor.svg | 0 .../org/meteoinfo/map}/icons/execute.svg | 0 .../meteoinfo/map}/icons/figure-output.svg | 0 .../meteoinfo/map}/icons/file-close-all.svg | 0 .../org/meteoinfo/map}/icons/file-new.svg | 0 .../org/meteoinfo/map}/icons/fill-ring.svg | 0 .../org/meteoinfo/map}/icons/font.svg | 0 .../org/meteoinfo/map}/icons/full-extent.svg | 0 .../org/meteoinfo/map}/icons/gif.svg | 0 .../org/meteoinfo/map}/icons/hand.svg | 0 .../org/meteoinfo/map}/icons/help.svg | 0 .../org/meteoinfo/map}/icons/information.svg | 0 .../org/meteoinfo/map}/icons/intersection.svg | 0 .../org/meteoinfo/map}/icons/jython.svg | 0 .../meteoinfo/map}/icons/layout-setting.svg | 0 .../org/meteoinfo/map}/icons/left-arrow.svg | 0 .../meteoinfo/map}/icons/legend-setting.svg | 0 .../org/meteoinfo/map}/icons/legend.svg | 0 .../org/meteoinfo/map}/icons/lon-lat.svg | 0 .../org/meteoinfo/map}/icons/map-out.svg | 0 .../org/meteoinfo/map}/icons/map-setting.svg | 0 .../meteoinfo/map}/icons/measurement_1.svg | 0 .../org/meteoinfo/map}/icons/menu-cut.svg | 0 .../org/meteoinfo/map}/icons/menu-paste.svg | 0 .../meteoinfo/map}/icons/merge-feature.svg | 0 .../org/meteoinfo/map}/icons/meteo-data.svg | 0 .../org/meteoinfo/map}/icons/new-circle.svg | 0 .../org/meteoinfo/map}/icons/new-curve.svg | 0 .../org/meteoinfo/map}/icons/new-ellipse.svg | 0 .../org/meteoinfo/map}/icons/new-layer.svg | 0 .../meteoinfo/map}/icons/new-line-hand.svg | 0 .../org/meteoinfo/map}/icons/new-line.svg | 0 .../org/meteoinfo/map}/icons/new-point.svg | 0 .../map}/icons/new-polygon-curve.svg | 0 .../org/meteoinfo/map}/icons/new-polygon.svg | 0 .../meteoinfo/map}/icons/new-rectangle.svg | 0 .../org/meteoinfo/map}/icons/new-text.svg | 0 .../org/meteoinfo/map}/icons/north-arrow.svg | 0 .../org/meteoinfo/map}/icons/page-setting.svg | 0 .../org/meteoinfo/map}/icons/page-zoom-in.svg | 0 .../meteoinfo/map}/icons/page-zoom-out.svg | 0 .../meteoinfo/map}/icons/page-zoom-window.svg | 0 .../org/meteoinfo/map}/icons/pan.svg | 0 .../meteoinfo/map}/icons/plugin-loaded.svg | 0 .../meteoinfo/map}/icons/plugin-setting.svg | 0 .../org/meteoinfo/map}/icons/plugin.svg | 0 .../org/meteoinfo/map}/icons/redo.svg | 0 .../meteoinfo/map}/icons/reshape-feature.svg | 0 .../org/meteoinfo/map}/icons/right-arrow.svg | 0 .../org/meteoinfo/map}/icons/scale-bar.svg | 0 .../meteoinfo/map}/icons/section-chart.svg | 0 .../org/meteoinfo/map}/icons/select-attr.svg | 0 .../meteoinfo/map}/icons/select-circle.svg | 0 .../org/meteoinfo/map}/icons/select-lasso.svg | 0 .../meteoinfo/map}/icons/select-location.svg | 0 .../meteoinfo/map}/icons/select-polygon.svg | 0 .../meteoinfo/map}/icons/select-rectangle.svg | 0 .../org/meteoinfo/map}/icons/select.svg | 0 .../meteoinfo/map}/icons/split-feature.svg | 0 .../org/meteoinfo/map}/icons/statistics.svg | 0 .../org/meteoinfo/map}/icons/stop.svg | 0 .../map}/icons/system-difference.svg | 0 .../org/meteoinfo/map}/icons/text.svg | 0 .../org/meteoinfo/map}/icons/title.svg | 0 .../org/meteoinfo/map}/icons/tools.svg | 0 .../org/meteoinfo/map}/icons/undo.svg | 0 .../org/meteoinfo/map}/icons/wind-arrow.svg | 0 .../org/meteoinfo/map}/icons/zoom-extent.svg | 0 .../meteoinfo/map}/icons/zoom-extent_1.svg | 0 .../org/meteoinfo/map}/icons/zoom-in.svg | 0 .../org/meteoinfo/map}/icons/zoom-layer.svg | 0 .../org/meteoinfo/map}/icons/zoom-out.svg | 0 meteoinfo-projection/pom.xml | 8 + .../org/meteoinfo/ui/plugin/IApplication.java | 72 + .../java/org/meteoinfo/ui/plugin/IPlugin.java | 90 + .../org/meteoinfo/ui/plugin/PluginBase.java | 77 + .../java/org/meteoinfo/ui}/util/FontUtil.java | 22 +- .../main/resources/fonts/WeatherSymbol.ttf | Bin 0 -> 39364 bytes pom.xml | 4 +- 963 files changed, 17011 insertions(+), 89336 deletions(-) create mode 100644 .idea/.name delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/Chart.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartColorBar.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartElement.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartLegend.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartNorthArrow.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartPanel.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartScaleBar.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartText.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartText3D.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartWindArrow.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/CoordinateType.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/IChartPanel.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/IPointSelectedListener.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/LegendPosition.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/Location.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/Margin.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/MouseMode.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/PointSelectedEvent.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/Axis.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/AxisProperty.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/LogAxis.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/LonLatAxis.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/PositionType.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/ProjLonLatAxis.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/TimeAxis.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/TimeUnit.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/AbstractPlot2D.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/AxesUnits.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/ChartPlotMethod.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/GraphicFactory.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/GridLine.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/MapPlot.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/PiePlot.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/Plot.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/Plot2D.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/Plot3D.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/PlotOrientation.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/PlotSeries.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/PlotType.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/PolarPlot.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/SeriesLegend.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/XY1DPlot.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot3d/GraphicCollection3D.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot3d/ImageShape3D.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot3d/Projector.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/data/mapdata/FrmAttriData.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/data/mapdata/MapDataManage.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/drawing/ContourDraw.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/drawing/StringType.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/analysis/AnalysisTypes.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/analysis/Clustering.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/analysis/DistanceType.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/analysis/InterpolationMethods.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/analysis/InterpolationSetting.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/layer/ChartSet.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/layer/FrmChartLabel.form delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/layer/FrmLabelSet.form delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/layer/FrmLayerProperty.form delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/layer/ImageLayer.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/layer/LabelSet.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/layer/LayerCollection.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/layer/LayerDrawType.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/layer/LayerTypes.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/layer/MapLayer.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/layer/RasterLayer.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/layer/VectorLayer.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/layer/VectorLayerBeanInfo.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/layer/VisibleScale.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/layer/WebMapLayer.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/layer/WorldFilePara.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/layout/FrmPageSet.form delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutChart.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutElement.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutScaleBar.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/layout/MapLayout.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmColorSymbolSet.form delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLabelSymbolSet.form delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLabelSymbolSet.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLegendBreaks.form delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLegendSet.form delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPointSymbolSet.form delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPolygonSymbolSet.form delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPolylineSymbolSet.form delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPolylineSymbolSet.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/legend/LegendNode.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/legend/LegendSchemeControl.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmIdentifer.form delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmIdentifer.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmIdentiferGrid.form delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmVerticeEdit.form delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/map/MapViewBeanInfo.java delete mode 100644 MeteoInfoLib/src/main/java/org/meteoinfo/map/MaskOut.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/Chart.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartColorBar.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartLegend.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartNorthArrow.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartPanel.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartScaleBar.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartText.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartText3D.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartWindArrow.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/CoordinateType.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/IChartPanel.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/IPointSelectedListener.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/LegendPosition.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/Location.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/Margin.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/MouseMode.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/NorthArrowType.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/PointSelectedEvent.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/drawing/Draw.java create mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/form/ChartForm.form create mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/form/ChartForm.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/graphic/ChartGraphic.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/graphic/Graphic.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/graphic/GraphicCollection.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/graphic/ImageGraphic.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/graphic/PolylineErrorShape.java rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/GLChartPanel.java (99%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/GLForm.java (93%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/IsosurfaceGraphics.java (96%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/JOGLUtil.java (99%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/Lighting.java (99%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/ParticleGraphics.java (100%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/Plot3DGL.java (99%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/SurfaceGraphics.java (100%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/TextureShape.java (99%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/Transform.java (100%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/Triangle.java (100%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/mc/BenchmarkHandler.java (97%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/mc/CallbackMC.java (96%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/mc/ExtractHandler.java (97%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/mc/Main.java (97%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/mc/MarchingCubes.java (98%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/mc/TablesMC.java (98%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/mc/VolumeGenerator.java (97%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/tessellator/Primitive.java (100%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/tessellator/PrimitiveTessellator.java (99%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/tessellator/TessPolygon.java (100%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/jogl/tessellator/TriangleTessellator.java (99%) rename {MeteoInfoLib => meteoinfo-chart}/src/main/java/org/meteoinfo/chart/plot/CategoryPlot.java (94%) delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/XAlign.java delete mode 100644 meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/YAlign.java rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-chart/src/main/java/org/meteoinfo/chart}/shape/PolylineErrorShape.java (99%) rename {MeteoInfoLib/src/main/java/org/meteoinfo/plot => meteoinfo-chart/src/main/java/org/meteoinfo/chart/util}/PlotUtil.java (95%) rename MeteoInfoMap/src/main/resources/images/TSMI_AttriData.Image.png => meteoinfo-chart/src/main/resources/images/AttributeTable.png (100%) create mode 100644 meteoinfo-chart/src/main/resources/images/Edit_tool.png rename MeteoInfoMap/src/main/resources/images/TSB_LabelSet.Image.png => meteoinfo-chart/src/main/resources/images/Label.png (100%) rename {MeteoInfoMap => meteoinfo-chart}/src/main/resources/images/Layers.png (100%) rename MeteoInfoMap/src/main/resources/images/MeteoInfo_1_16x16x8.png => meteoinfo-chart/src/main/resources/images/MeteoInfo.png (100%) rename {MeteoInfoLab => meteoinfo-chart}/src/main/resources/images/Pan_Open_32x32x32.png (100%) create mode 100644 meteoinfo-chart/src/main/resources/images/Properties.png create mode 100644 meteoinfo-chart/src/main/resources/images/TSB_Add.Image.png create mode 100644 meteoinfo-chart/src/main/resources/images/TSB_Area.Image.png create mode 100644 meteoinfo-chart/src/main/resources/images/TSB_Del.Image.png create mode 100644 meteoinfo-chart/src/main/resources/images/TSB_DelAll.Image.png create mode 100644 meteoinfo-chart/src/main/resources/images/TSB_Distance.Image.png create mode 100644 meteoinfo-chart/src/main/resources/images/TSB_Down.Image.png create mode 100644 meteoinfo-chart/src/main/resources/images/TSB_Feature.Image.png rename {MeteoInfoMap => meteoinfo-chart}/src/main/resources/images/TSB_FullExent.Image.png (100%) create mode 100644 meteoinfo-chart/src/main/resources/images/TSB_LabelSet.Image.png create mode 100644 meteoinfo-chart/src/main/resources/images/TSB_MakeBreaks.Image.png create mode 100644 meteoinfo-chart/src/main/resources/images/TSB_None.Image.png rename {MeteoInfoMap => meteoinfo-chart}/src/main/resources/images/TSB_Open.Image.png (100%) rename {MeteoInfoLab => meteoinfo-chart}/src/main/resources/images/TSB_Pan.Image.png (100%) create mode 100644 meteoinfo-chart/src/main/resources/images/TSB_Reverse.Image.png create mode 100644 meteoinfo-chart/src/main/resources/images/TSB_Save.Image.png create mode 100644 meteoinfo-chart/src/main/resources/images/TSB_Up.Image.png rename {MeteoInfoLab => meteoinfo-chart}/src/main/resources/images/TSB_ZoomIn.Image.png (100%) rename {MeteoInfoLab => meteoinfo-chart}/src/main/resources/images/TSB_ZoomOut.Image.png (100%) rename {MeteoInfoMap => meteoinfo-chart}/src/main/resources/images/TSB_ZoomToLayer.Image.png (100%) create mode 100644 meteoinfo-chart/src/main/resources/images/VertexEdit_32x32x32.png rename MeteoInfoLab/src/main/resources/images/find.png => meteoinfo-chart/src/main/resources/images/ZoomToLayer.png (100%) rename {MeteoInfoLab => meteoinfo-chart}/src/main/resources/images/identifer_32x32x32.png (100%) rename {MeteoInfoLab => meteoinfo-chart}/src/main/resources/images/information.png (100%) create mode 100644 meteoinfo-chart/src/main/resources/images/insert_vertice.png create mode 100644 meteoinfo-chart/src/main/resources/images/loading.png create mode 100644 meteoinfo-chart/src/main/resources/images/rotate.png create mode 100644 meteoinfo-chart/src/main/resources/images/star.bmp rename {MeteoInfoLab => meteoinfo-chart}/src/main/resources/images/zoom_in_32x32x32.png (100%) rename {MeteoInfoLab => meteoinfo-chart}/src/main/resources/images/zoom_out_32x32x32.png (100%) delete mode 100644 meteoinfo-data/src/main/java/org/meteoinfo/data/mapdata/geotiff/compression/DeflateCompression.java create mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/analysis/GeometryUtil.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/analysis/ResampleMethods.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/analysis/Statistics.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/GridArray.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/GridData.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/GridDataSetting.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/StationData.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/StationTableData.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/TableData.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/ascii/ASCIIGridDataInfo.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/ascii/LonLatStationDataInfo.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/ascii/SurferGridDataInfo.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/FieldType.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/GeoKey.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/GeoTiff.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/IFDEntry.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/Tag.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/ByteReader.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/CompressionDecoder.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/CompressionEncoder.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/DeflateCompression.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/LZWCompression.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/TiffException.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/mapdata/MapDataType.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/mapdata/ShapeFileManage.java rename {meteoinfo-chart/src/main/java/org/meteoinfo/chart => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/drawing/ContourDraw.java (99%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/drawing/Draw.java (99%) rename {meteoinfo-chart/src/main/java/org/meteoinfo/chart => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/drawing/StringType.java (88%) rename {MeteoInfoLib/src/main/java/org/meteoinfo/global => meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui}/FontChooser.form (100%) rename {MeteoInfoLib/src/main/java/org/meteoinfo/global => meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui}/FontChooser.java (98%) rename {MeteoInfoLib/src/main/java/org/meteoinfo/global => meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui}/FrmMeasurement.form (100%) rename {MeteoInfoLib/src/main/java/org/meteoinfo/global => meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui}/FrmMeasurement.java (99%) rename {MeteoInfoLib/src/main/java/org/meteoinfo/global => meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui}/FrmProperty.form (100%) rename {MeteoInfoLib/src/main/java/org/meteoinfo/global => meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui}/FrmProperty.java (98%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/gui/MainToolBar.java (93%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/layer/FrmChartLabel.java (99%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/layer/FrmLabelSet.java (99%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/layer/FrmLayerProperty.java (98%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/layout/Edge.java (92%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/layout/ElementType.java (92%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/layout/FrmPageSet.java (99%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/layout/LayerUpdateTypes.java (93%) rename meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartElement.java => meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayoutElement.java (76%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/layout/LayoutGraphic.java (98%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/layout/LayoutLegend.java (99%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/layout/LayoutMap.java (99%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/layout/LayoutNorthArrow.java (98%) create mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayoutScaleBar.java rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/layout/LegendStyles.java (93%) create mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/MapLayout.java rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/layout/MapLayoutBeanInfo.java (56%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/layout/MapLayoutUndoRedo.java (99%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/layout/MouseMode.java (95%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/layout/NorthArrowType.java (96%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/layout/PaperSize.java (94%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/layout/ResizeAbility.java (92%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/layout/ScaleBarType.java (96%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/layout/ScaleBarUnits.java (97%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/legend/FrmColorSymbolSet.java (99%) create mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmLabelSymbolSet.java rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/legend/FrmLegendBreaks.java (96%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/legend/FrmLegendSet.java (76%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/legend/FrmPointSymbolSet.java (97%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/legend/FrmPolygonSymbolSet.java (98%) create mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmPolylineSymbolSet.java rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/legend/GridLabelPosition.java (92%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/legend/GroupNode.java (99%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/legend/ItemNode.java (99%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/legend/LayerNode.java (97%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/legend/LayersLegend.java (99%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/legend/LegendManage.java (99%) create mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/LegendNode.java create mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/LegendSchemeControl.java rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/legend/LegendView.java (99%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/legend/MapFrame.java (99%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/legend/NodeTypes.java (92%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/legend/SymbolControl.java (99%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/legend/Test.java (90%) rename {MeteoInfoLib/src/main/java/org/meteoinfo/data => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/mapdata/FrmAddField.form (100%) rename {MeteoInfoLib/src/main/java/org/meteoinfo/data => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/mapdata/FrmAddField.java (99%) rename {MeteoInfoLib/src/main/java/org/meteoinfo/data => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/mapdata/FrmAttriData.form (100%) create mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapdata/FrmAttriData.java rename meteoinfo-geo/src/main/java/org/meteoinfo/geo/{data => }/mapdata/MapDataManage.java (98%) rename {MeteoInfoLib/src/main/java/org/meteoinfo/data => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/mapdata/ShapeFileManage.java (95%) rename {MeteoInfoLib/src/main/java/org/meteoinfo/map => meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview}/FeatureUndoableEdit.java (89%) create mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/FrmIdentifer.java rename {MeteoInfoLib/src/main/java/org/meteoinfo/map => meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview}/FrmIdentiferGrid.java (99%) rename {MeteoInfoLib/src/main/java/org/meteoinfo/map => meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview}/FrmVerticeEdit.java (99%) delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/GridLabel.java rename {MeteoInfoLib/src/main/java/org/meteoinfo/map => meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview}/MapView.java (99%) create mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/MapViewBeanInfo.java rename {MeteoInfoLib/src/main/java/org/meteoinfo/map => meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview}/MapViewUndoRedo.java (99%) create mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/MaskOut.java rename {MeteoInfoLib/src/main/java/org/meteoinfo/map => meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview}/MouseTools.java (94%) rename {MeteoInfoLib/src/main/java/org/meteoinfo/map => meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview}/ProjectionSet.java (99%) rename {MeteoInfoLib/src/main/java/org/meteoinfo/data => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/meteodata/DrawMeteoData.java (98%) rename {MeteoInfoLib/src/main/java/org/meteoinfo/data => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/meteodata/TrajDataInfo.java (93%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/plot/MainPlot.form (96%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/plot/MainPlot.java (92%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/plot/MapLayoutPlot.form (96%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/plot/MapLayoutPlot.java (92%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/plugin/IApplication.java (90%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/plugin/IPlugin.java (94%) rename {MeteoInfoLib/src/main/java/org/meteoinfo => meteoinfo-geo/src/main/java/org/meteoinfo/geo}/plugin/PluginBase.java (92%) delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/CoordinateSystemCategory.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/GeoGraphicSystem.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/KnownCoordinateSystems.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/ProjRegistry.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/ProjectionNames.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/ProjectionUtil.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/Reproject.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/World.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Albers.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Common.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/GeostationarySatellite.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Hammer.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/LambertAzimuthalEqualArea.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/LambertConformalConic.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/LambertEqualAreaConic.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/LongLat.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Mercator.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Molleweide.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/OrthographicAzimuthal.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/ProjectionInfo.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Robinson.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Sinusoidal.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/StereographicAzimuthal.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/TransverseMercator.java delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Wagner3.java rename {MeteoInfoLib => meteoinfo-geo}/src/main/java/org/meteoinfo/geo/util/GeoMathUtil.java (99%) rename {MeteoInfoLib => meteoinfo-geo}/src/main/java/org/meteoinfo/geo/util/GeoProjectionUtil.java (98%) delete mode 100644 meteoinfo-geo/src/main/java/org/meteoinfo/geo/util/LegendManage.java rename MeteoInfoLab/MeteoInfoLab.iml => meteoinfo-lab/meteoinfo-lab.iml (93%) rename {MeteoInfoLab => meteoinfo-lab}/milconfig.xml (90%) rename {MeteoInfoLab => meteoinfo-lab}/nbactions.xml (84%) rename {MeteoInfoLab => meteoinfo-lab}/pom.xml (91%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/milab$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/milab.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/milab_debug.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/milab_s.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/__init__$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/__init__.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataframe/__init__$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataframe/__init__.py (96%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataframe/dataframe$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataframe/dataframe.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataframe/groupby$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataframe/groupby.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataframe/index$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataframe/index.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataframe/indexing$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataframe/indexing.py (96%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataframe/series$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataframe/series.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataset/__init__$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataset/__init__.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataset/dimdatafile$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataset/dimdatafile.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataset/dimvariable$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataset/dimvariable.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataset/midata$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataset/midata.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataset/miio$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataset/miio.py (97%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataset/ncutil$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/dataset/ncutil.py (96%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/geolib/__init__$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/geolib/__init__.py (95%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/geolib/geoutil$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/geolib/geoutil.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/geolib/migeo$py.class (97%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/geolib/migeo.py (99%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/geolib/milayer$py.class (98%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/geolib/milayer.py (99%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/geolib/topology$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/geolib/topology.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/imagelib/__init__$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/imagelib/__init__.py (95%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/imagelib/filters$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/imagelib/filters.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/imagelib/io$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/imagelib/io.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/meteolib/__init__$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/meteolib/__init__.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/meteolib/calc/__init__$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/meteolib/calc/__init__.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/meteolib/calc/kinematics$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/meteolib/calc/kinematics.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/meteolib/calc/thermo$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/meteolib/calc/thermo.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/meteolib/constants$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/meteolib/constants.py (98%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/meteolib/interpolate/__init__$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/meteolib/interpolate/__init__.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/meteolib/interpolate/one_dimension$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/meteolib/interpolate/one_dimension.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/meteolib/meteo$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/meteolib/meteo.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/meteolib/wrf$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/meteolib/wrf.py (97%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/migl$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/migl.py (96%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/miutil$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/miutil.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/__init__$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/__init__.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/core/__init__$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/core/__init__.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/core/_dtype$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/core/_dtype.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/core/dimarray$py.class (99%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/core/dimarray.py (99%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/core/fromnumeric.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/core/mitable$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/core/mitable.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/core/multiarray$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/core/multiarray.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/core/numeric$py.class (99%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/core/numeric.py (99%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/core/numerictypes.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/fitting/__init__$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/fitting/__init__.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/fitting/fitting$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/fitting/fitting.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/interpolate/__init__$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/interpolate/__init__.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/interpolate/interpolate$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/interpolate/interpolate.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/interpolate/ndgriddata$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/interpolate/ndgriddata.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/lib/__init__$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/lib/__init__.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/lib/_util$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/lib/_util.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/lib/index_tricks.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/lib/shape_base.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/linalg/__init__$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/linalg/__init__.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/linalg/linalg$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/linalg/linalg.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/optimize/__init__$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/optimize/__init__.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/optimize/_lsq/__init__$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/optimize/_lsq/__init__.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/optimize/_lsq/common$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/optimize/_lsq/common.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/optimize/_lsq/least_squares$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/optimize/_lsq/least_squares.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/optimize/minpack$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/optimize/minpack.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/random/__init__$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/random/__init__.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/random/_random.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/random/mtrand$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/random/mtrand.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/signal/__init__.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/signal/signaltools.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/stats/__init__$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/stats/__init__.py (96%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/stats/_distn_infrastructure$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/stats/_distn_infrastructure.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/stats/distributions$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/stats/distributions.py (96%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/stats/kde$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/stats/kde.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/stats/stats$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/numeric/stats/stats.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/plotlib/__init__$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/plotlib/__init__.py (96%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/plotlib/_axes$py.class (99%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/plotlib/_axes.py (99%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/plotlib/_axes3d$py.class (99%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/plotlib/_axes3d.py (99%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/plotlib/_axes3dgl$py.class (99%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/plotlib/_axes3dgl.py (99%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/plotlib/_figure$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/plotlib/_figure.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/plotlib/_glfigure$py.class (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/plotlib/_glfigure.py (100%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/plotlib/_mapaxes$py.class (99%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/plotlib/_mapaxes.py (99%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/plotlib/miplot$py.class (99%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/plotlib/miplot.py (99%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/plotlib/plotutil$py.class (99%) rename {MeteoInfoLab => meteoinfo-lab}/pylib/mipylib/plotlib/plotutil.py (99%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/MeteoInfoLab.java (97%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/Options.java (99%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/StackWindow.java (95%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/application/AppCollection.java (99%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/application/Application.java (91%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/event/CurrentPathChangedEvent.java (92%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/event/ICurrentPathChangedListener.java (92%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/ConsoleDockable.java (99%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/CustomWindowFactory.java (90%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/EditorDockable.java (99%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/EncodingUtil.java (94%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/FigureDockable.java (94%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/FileDockable.java (86%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/FileExplorer.java (96%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/FrmAbout.form (100%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/FrmAbout.java (99%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/FrmAppsManager.form (100%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/FrmAppsManager.java (98%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/FrmCustom.java (95%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/FrmFindReplace.form (100%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/FrmFindReplace.java (99%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/FrmMain.form (100%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/FrmMain.java (96%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/FrmSetting.form (100%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/FrmSetting.java (99%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/GuiUtil.java (95%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/OutputDockable.java (91%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/VariableDockable.java (85%) rename {MeteoInfoLab/src/main/java/org/meteoinfo/laboratory => meteoinfo-lab/src/main/java/org/meteoinfo/lab}/gui/VariableExplorer.java (93%) create mode 100644 meteoinfo-lab/src/main/java/org/meteoinfo/lab/util/JythonUtil.java rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/abstract_co.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/class_default_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/class_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/constr_ovr.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/deprecated.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/enum_default_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/enum_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/enum_private_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/enum_protected_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/error_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/field_default_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/field_private_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/field_protected_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/field_public_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/final_co.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/html_tag_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/imp_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/impc_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/info_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/innerclass_default_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/innerclass_private_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/innerclass_protected_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/innerclass_public_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/innerinterface_default_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/innerinterface_private_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/innerinterface_protected_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/innerinterface_public_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/int_default_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/int_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/jcu_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/jdoc_tag_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/localvariable_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/methdef_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/methpri_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/methpro_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/methpub_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/package_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/static_co.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/synch_co.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/template_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/codecomplete/warning_obj.gif (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/Arrow.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/Color_Wheel.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/Disk_1_16x16x8.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/Folder_1_16x16x8.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/MeteoLab_16.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/MeteoLab_32.png (100%) create mode 100644 meteoinfo-lab/src/main/resources/images/Pan_Open_32x32x32.png rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/TSB_DrawSetting.Image.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/TSB_FullExtent.Image.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/TSB_NewFile.Image.png (100%) rename {MeteoInfoMap => meteoinfo-lab}/src/main/resources/images/TSB_Pan.Image.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/TSB_Redo.Image.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/TSB_RunScript.Image.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/TSB_Undo.Image.png (100%) rename {MeteoInfoMap => meteoinfo-lab}/src/main/resources/images/TSB_ZoomIn.Image.png (100%) rename {MeteoInfoMap => meteoinfo-lab}/src/main/resources/images/TSB_ZoomOut.Image.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/TSMI_EditCut.Image.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/closefile.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/colors.png (100%) create mode 100644 meteoinfo-lab/src/main/resources/images/find.png rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/folder.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/help.png (100%) create mode 100644 meteoinfo-lab/src/main/resources/images/identifer_32x32x32.png rename {MeteoInfoMap => meteoinfo-lab}/src/main/resources/images/information.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/jython_small_c.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/logo.jpg (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/menuEditCopy.Image.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/miSetFont.Image.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/pasteToolStripButton.Image.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/plugin_edit_green.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/plugin_green.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/plugin_unsel.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/previous.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/python_16px.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/rotate_16.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/save_16.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/setting.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/up_arrow.png (100%) rename {MeteoInfoLab => meteoinfo-lab}/src/main/resources/images/update.png (100%) create mode 100644 meteoinfo-lab/src/main/resources/images/zoom_in_32x32x32.png create mode 100644 meteoinfo-lab/src/main/resources/images/zoom_out_32x32x32.png rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/back.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/color-wheel.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/colors.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/console.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/copy.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/editor.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/execute.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/figure.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/file-close-all.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/file-explorer.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/file-new.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/file-open.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/file-save-as.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/file-save.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/find.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/find_16.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/folder-up.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/folder.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/full-extent.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/gear.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/hand.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/help.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/help_16.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/incoming.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/information.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/jython.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/maximize.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/menu-cut.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/menu-paste.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/minimize.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/move.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/outgoing.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/pan_16.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/python.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/python_16.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/redo.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/refresh.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/restore.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/rotate_16.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/save-as.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/select.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/select_16.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/setting.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/terminal.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/toolbox.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/undo.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/variable.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/zoom-in.svg (100%) rename {MeteoInfoLab/src/main/resources/org/meteoinfo/laboratory => meteoinfo-lab/src/main/resources/org/meteoinfo/lab}/icons/zoom-out.svg (100%) rename {MeteoInfoMap => meteoinfo-map}/config.xml (79%) rename {MeteoInfoMap => meteoinfo-map}/default.mip (100%) rename MeteoInfoMap/MeteoInfoMap.iml => meteoinfo-map/meteoinfo-map.iml (97%) rename {MeteoInfoMap => meteoinfo-map}/nbactions.xml (81%) rename {MeteoInfoMap => meteoinfo-map}/pom.xml (95%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/MeteoInfoMap.java (97%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/StackWindow.java (95%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/config/EncodingUtil.java (94%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/config/GenericFileFilter.java (95%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/config/MapFileFilter.java (94%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/config/Options.java (99%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/config/Plugin.java (92%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/config/PluginCollection.java (97%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/config/ProjectFile.java (95%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/event/CurrentToolChangedEvent.java (92%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/event/ICurrentToolChangedListener.java (92%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmAbout.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmAbout.java (99%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmAddField.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmAddField.java (99%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmAddXYData.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmAddXYData.java (99%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmArrivalTimes.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmArrivalTimes.java (98%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmBuffer.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmBuffer.java (97%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmClipping.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmClipping.java (98%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmConsole.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmConsole.java (99%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmConvexhull.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmConvexhull.java (97%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmDataInfo.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmDataInfo.java (98%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmDifference.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmDifference.java (98%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmGifAnimator.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmGifAnimator.java (99%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmGridSet.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmGridSet.java (99%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmInterpolate.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmInterpolate.java (99%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmIntersection.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmIntersection.java (98%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmJoinNCFiles.form (99%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmJoinNCFiles.java (99%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmMain.java (97%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmMeteoData.java (99%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmOneDim.form (87%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmOneDim.java (98%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmOpenData.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmOpenData.java (99%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmOptions.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmOptions.java (99%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmOutputMapData.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmOutputMapData.java (99%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmPluginManager.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmPluginManager.java (98%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmProjection.form (85%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmProjection.java (99%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmSectionPlot.form (99%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmSectionPlot.java (98%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmSelectByAttributes.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmSelectByAttributes.java (99%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmSelectByLocation.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmSelectByLocation.java (98%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmSymDifference.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmSymDifference.java (98%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmTextEditor.form (93%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmTextEditor.java (97%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmUVSet.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmUVSet.java (99%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmViewData.form (94%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmViewData.java (98%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmZoomToExtent.form (100%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/FrmZoomToExtent.java (99%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/ImageFileChooser.java (94%) rename {MeteoInfoMap/src/main/java/org/meteoinfo/desktop => meteoinfo-map/src/main/java/org/meteoinfo/map}/forms/ShapeFileChooser.java (98%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/bundle/Bundle_FrmMain.properties (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/bundle/Bundle_FrmMain_zh_CN.properties (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/bundle/Bundle_FrmMeteoData.properties (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/bundle/Bundle_FrmMeteoData_zh_CN.properties (98%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/bundle/Bundle_FrmOneDim.properties (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/bundle/Bundle_FrmOneDim_zh_CN.properties (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/bundle/Bundle_FrmProjection.properties (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/bundle/Bundle_FrmProjection_zh_CN.properties (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/bundle/Bundle_FrmSectionPlot.properties (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/bundle/Bundle_FrmSectionPlot_zh_CN.properties (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/Add_Layer.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/Animation-2.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/Arrow.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/Close_File.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/Disk_1_16x16x8.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/Folder_1_16x16x8.png (100%) create mode 100644 meteoinfo-map/src/main/resources/images/Layers.png create mode 100644 meteoinfo-map/src/main/resources/images/MeteoInfo_1_16x16x8.png rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/MeteoInfo_logo.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/Save_Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/Setting-1.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/Setting.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/Statictics.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_ClearDrawing.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_Draw.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_DrawSetting.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_EditVertices.Image.png (100%) create mode 100644 meteoinfo-map/src/main/resources/images/TSB_FullExent.Image.png create mode 100644 meteoinfo-map/src/main/resources/images/TSB_LabelSet.Image.png rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_Measurement.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_NewCircle.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_NewCurve.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_NewCurvePolygon.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_NewEllipse.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_NewFile.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_NewFreehand.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_NewLabel.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_NewPoint.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_NewPolygon.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_NewPolyline.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_NewRectangle.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_NextTime.Image.png (100%) create mode 100644 meteoinfo-map/src/main/resources/images/TSB_Open.Image.png rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_PageZoomIn.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_PageZoomOut.Image.png (100%) create mode 100644 meteoinfo-map/src/main/resources/images/TSB_Pan.Image.png rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_PreTime.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_Redo.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_RemoveDataLayes.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_RunScript.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_SelectFeatures.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_Setting.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_Undo.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_ViewData.Image.png (100%) create mode 100644 meteoinfo-map/src/main/resources/images/TSB_ZoomIn.Image.png create mode 100644 meteoinfo-map/src/main/resources/images/TSB_ZoomOut.Image.png rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSB_ZoomToExtent.Image.png (100%) create mode 100644 meteoinfo-map/src/main/resources/images/TSB_ZoomToLayer.Image.png create mode 100644 meteoinfo-map/src/main/resources/images/TSMI_AttriData.Image.png rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSMI_EditCut.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/TSMI_InsertLegend.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/ZoomFullMap.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/animation-1.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/animation.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/chart-5.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/chart.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/closefile.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/console.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/edit_16.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/help.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/info.png (100%) create mode 100644 meteoinfo-map/src/main/resources/images/information.png rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/jython_small_c.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/location_arrow.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/logo.jpg (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/menuEditCopy.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/merge.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/miSetFont.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/new_document_16.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/page_portrait.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/pasteToolStripButton.Image.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/plugin_edit_green.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/plugin_green.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/plugin_unsel.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/point.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/reform_edit.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/ring.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/ring_add.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/ring_delete.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/save_16.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/select_circle.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/select_lasso.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/select_polygon.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/select_rectangle.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/snake.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/split.png (100%) rename {MeteoInfoMap => meteoinfo-map}/src/main/resources/images/stop.png (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/add-layer-plus.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/add-layer.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/add-ring.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/add-web-layer.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/animator-file.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/animator.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/buffer.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/cancel.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/chart-line-bar.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/chart-line.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/chart-points.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/clip.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/close.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/console.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/convexhull.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/copy.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/delete-ring.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/difference.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/draw-layer.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/edit-add-feature.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/edit-status.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/edit-tool.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/edit-vertices.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/editor.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/execute.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/figure-output.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/file-close-all.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/file-new.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/fill-ring.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/font.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/full-extent.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/gif.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/hand.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/help.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/information.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/intersection.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/jython.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/layout-setting.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/left-arrow.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/legend-setting.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/legend.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/lon-lat.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/map-out.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/map-setting.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/measurement_1.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/menu-cut.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/menu-paste.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/merge-feature.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/meteo-data.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/new-circle.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/new-curve.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/new-ellipse.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/new-layer.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/new-line-hand.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/new-line.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/new-point.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/new-polygon-curve.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/new-polygon.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/new-rectangle.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/new-text.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/north-arrow.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/page-setting.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/page-zoom-in.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/page-zoom-out.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/page-zoom-window.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/pan.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/plugin-loaded.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/plugin-setting.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/plugin.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/redo.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/reshape-feature.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/right-arrow.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/scale-bar.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/section-chart.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/select-attr.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/select-circle.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/select-lasso.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/select-location.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/select-polygon.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/select-rectangle.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/select.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/split-feature.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/statistics.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/stop.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/system-difference.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/text.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/title.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/tools.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/undo.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/wind-arrow.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/zoom-extent.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/zoom-extent_1.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/zoom-in.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/zoom-layer.svg (100%) rename {MeteoInfoMap/src/main/resources/org/meteoinfo/desktop => meteoinfo-map/src/main/resources/org/meteoinfo/map}/icons/zoom-out.svg (100%) create mode 100644 meteoinfo-ui/src/main/java/org/meteoinfo/ui/plugin/IApplication.java create mode 100644 meteoinfo-ui/src/main/java/org/meteoinfo/ui/plugin/IPlugin.java create mode 100644 meteoinfo-ui/src/main/java/org/meteoinfo/ui/plugin/PluginBase.java rename {meteoinfo-common/src/main/java/org/meteoinfo/common => meteoinfo-ui/src/main/java/org/meteoinfo/ui}/util/FontUtil.java (91%) create mode 100644 meteoinfo-ui/src/main/resources/fonts/WeatherSymbol.ttf diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 00000000..569c3f52 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +MeteoInfoMap \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 247fc3f6..91669d7a 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -8,8 +8,8 @@ + - @@ -18,9 +18,9 @@ + - @@ -34,15 +34,15 @@ + + - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml index f0b5b0f4..a5d679c2 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -2,15 +2,9 @@ - - - - - - @@ -27,6 +21,12 @@ + + + + + + diff --git a/.idea/misc.xml b/.idea/misc.xml index ab319e6a..728bc997 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -4,15 +4,11 @@ - - + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index 3b4d4bfb..31d41915 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,9 +3,7 @@ - - @@ -14,6 +12,8 @@ + + diff --git a/MeteoInfoLib/MeteoInfoLib.iml b/MeteoInfoLib/MeteoInfoLib.iml index 7d788611..363f687d 100644 --- a/MeteoInfoLib/MeteoInfoLib.iml +++ b/MeteoInfoLib/MeteoInfoLib.iml @@ -39,6 +39,8 @@ + + diff --git a/MeteoInfoLib/pom.xml b/MeteoInfoLib/pom.xml index f7dd09ef..17c3804e 100644 --- a/MeteoInfoLib/pom.xml +++ b/MeteoInfoLib/pom.xml @@ -92,6 +92,16 @@ meteoinfo-data ${project.version} + + ${project.groupId} + meteoinfo-geo + ${project.version} + + + ${project.groupId} + meteoinfo-chart + ${project.version} + edu.ucar netcdfAll diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/Chart.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/Chart.java deleted file mode 100644 index 1b99e49c..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/Chart.java +++ /dev/null @@ -1,902 +0,0 @@ -/* 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.chart; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.RenderingHints; -import java.awt.Stroke; -import java.awt.geom.AffineTransform; -import java.awt.geom.Rectangle2D; -import java.util.ArrayList; -import java.util.List; -import org.meteoinfo.chart.plot.MapPlot; -import org.meteoinfo.chart.plot.Plot; -import org.meteoinfo.common.PointF; -import org.meteoinfo.drawing.Draw; - -/** - * - * @author Yaqiang Wang - * yaqiang.wang@gmail.com - */ -public class Chart { - - // - private List plots; - private int currentPlot; - private int rowNum; - private int columnNum; - private ChartText title; - private ChartText subTitle; - private List texts; - private ChartLegend legend; - private Color background; - //private boolean drawBackground; - private boolean drawLegend; - private Rectangle2D plotArea; - private boolean antiAlias; - private boolean symbolAntialias; - private ChartPanel parent; - - // - // - /** - * Constructor - */ - public Chart() { - this.drawLegend = false; - this.background = Color.white; - //this.drawBackground = true; - this.antiAlias = false; - this.symbolAntialias = true; - this.rowNum = 1; - this.columnNum = 1; - this.plots = new ArrayList<>(); - this.currentPlot = -1; - this.texts = new ArrayList<>(); - } - - /** - * Constructor - * - * @param parent ChartPanel parent - */ - public Chart(ChartPanel parent) { - this(); - this.parent = parent; - } - - /** - * Constructor - * - * @param plot Plot - * @param parent ChartPanel - */ - public Chart(Plot plot, ChartPanel parent) { - this(parent); - this.plots.add(plot); - } - - /** - * Constructor - * - * @param plot Plot - */ - public Chart(Plot plot) { - this(plot, null); - } - - /** - * Constructor - * - * @param title Title - * @param plot Plot - * @param parent ChartPanel - */ - public Chart(String title, Plot plot, ChartPanel parent) { - this(plot, parent); - if (title == null) { - this.title = null; - } else { - this.title = new ChartText(title); - } - } - - /** - * Constructor - * - * @param title Title - * @param plot Plot - */ - public Chart(String title, Plot plot) { - this(title, plot, null); - } - - // - // - /** - * Set ChartPanel parent - * - * @param value ChartPanel - */ - public void setParent(ChartPanel value) { - this.parent = value; - for (Plot plot : this.plots) { - if (plot instanceof MapPlot) { - ((MapPlot) plot).setParent(value); - } - } - } - - /** - * Get plot - * - * @return Plot - */ - public List getPlots() { - return plots; - } - - /** - * Get current plot - * - * @return Current plot - */ - public Plot getCurrentPlot() { - if (this.plots.isEmpty()) { - return null; - } - - if (this.currentPlot < 0 || this.currentPlot >= this.plots.size()) { - this.currentPlot = this.plots.size() - 1; - } - return this.plots.get(this.currentPlot); - } - - /** - * Set current plot - * - * @param value Current plot - */ - public void setCurrentPlot(Plot value) { - if (this.plots.isEmpty()) { - this.addPlot(value); - //this.currentPlot = 0; - } else if (this.currentPlot == -1) { - this.plots.add(value); - } else { - if (this.currentPlot >= this.plots.size()) { - this.currentPlot = this.plots.size() - 1; - } - Plot plot = this.plots.get(this.currentPlot); - value.isSubPlot = plot.isSubPlot; - value.columnIndex = plot.columnIndex; - value.rowIndex = plot.rowIndex; - this.plots.set(this.currentPlot, value); - } - } - - /** - * Set current plot index - * - * @param value Current plot index - */ - public void setCurrentPlot(int value) { - this.currentPlot = value; - } - - /** - * Get the first plot - * - * @return Plot - */ - public Plot getPlot() { - if (this.plots.isEmpty()) { - return null; - } - - return this.plots.get(0); - } - - /** - * Get row number of sub plots - * - * @return Row number of sub plots - */ - public int getRowNum() { - return this.rowNum; - } - - /** - * Set row number of sub plots - * - * @param value Row number of sub plots - */ - public void setRowNum(int value) { - this.rowNum = value; - } - - /** - * Get column number of sub plots - * - * @return Column number of sub plots - */ - public int getColumnNum() { - return this.columnNum; - } - - /** - * Set column number of sub plots - * - * @param value Column number of sub plots - */ - public void setColumnNum(int value) { - this.columnNum = value; - } - - /** - * Get title - * - * @return Title - */ - public ChartText getTitle() { - return title; - } - - /** - * Set title - * - * @param value Title - */ - public void setTitle(ChartText value) { - title = value; - } - - /** - * Get sub title - * - * @return Sub title - */ - public ChartText getSubTitle() { - return subTitle; - } - - /** - * Set sub title - * - * @param value Sub title - */ - public void setSubTitle(ChartText value) { - subTitle = value; - } - - /** - * Get background - * - * @return Background - */ - public Color getBackground() { - return this.background; - } - - /** - * Set background - * - * @param value Background - */ - public void setBackground(Color value) { - this.background = value; - } - -// /** -// * Get if draw background -// * -// * @return Boolean -// */ -// public boolean isDrawBackground() { -// return this.drawBackground; -// } - -// /** -// * Set if draw background -// * -// * @param value Boolean -// */ -// public void setDrawBackground(boolean value) { -// this.drawBackground = value; -// } - - /** - * Get chart legend - * - * @return Chart legend - */ - public ChartLegend getLegend() { - return this.legend; - } - - /** - * Get if draw legend - * - * @return If draw legend - */ - public boolean isDrawLegend() { - return this.drawLegend; - } - - /** - * Set if draw legend - * - * @param value Boolean - */ - public void setDrawLegend(boolean value) { - this.drawLegend = value; - } - - /** - * Get plot area - * - * @return Plot area - */ - public Rectangle2D getPlotArea() { - return this.plotArea; - } - - /** - * Get if is anti-alias - * - * @return Boolean - */ - public boolean isAntiAlias() { - return this.antiAlias; - } - - /** - * Set if is anti-alias - * - * @param value Boolean - */ - public void setAntiAlias(boolean value) { - this.antiAlias = value; - } - - /** - * Get symbol antialias - * @return Boolean - */ - public boolean isSymbolAntialias() { - return this.symbolAntialias; - } - - /** - * Set symbol antialias - * @param value Boolean - */ - public void setSymbolAntialias(boolean value) { - this.symbolAntialias = value; - } - - // - // - /** - * Draw plot - * - * @param g Graphics2D - * @param area Drawing area - */ - public void draw(Graphics2D g, Rectangle2D area) { - g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); - if (antiAlias) { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - //g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); - g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); - g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); - g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); - //g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); - g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); - } else { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - //g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); - g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT); - g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF); - g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_DEFAULT); - //g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); - g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT); - } - - AffineTransform oldMatrix = g.getTransform(); - Rectangle oldRegion = g.getClipBounds(); - g.setClip(area); - g.translate(area.getX(), area.getY()); - - //Draw background - if (this.background != null) { - g.setColor(background); - g.fill(new Rectangle2D.Double(0, 0, area.getWidth(), area.getHeight())); - } - - //Draw title - float y = 5; - if (title != null) { - g.setColor(title.getColor()); - g.setFont(title.getFont()); - float x = (float) area.getWidth() / 2; - //y -= this.title.getHeight(g) - 5; - //FontMetrics metrics = g.getFontMetrics(title.getFont()); - //x -= metrics.stringWidth(title.getText()) / 2; - //y += metrics.getHeight(); - int i = 0; - for (String text : title.getTexts()) { - Dimension dim = Draw.getStringDimension(text, g); - if (i == 0) { - y += dim.getHeight(); - } - Draw.drawString(g, text, x - dim.width / 2, y); - g.setFont(title.getFont()); - y += dim.height + title.getLineSpace(); - i += 1; - } - y += 5; - } - - //Draw plot - plotArea = this.getPlotArea(g, area); - //plotArea = area; - if (plotArea.getWidth() < 20 || plotArea.getHeight() < 20) { - g.setTransform(oldMatrix); - g.setClip(oldRegion); - return; - } - - if (this.plots.size() > 0) { - //double zoom = this.getPositionAreaZoom(g, plotArea); - //Margin tightInset = this.getPlotsTightInset(g, plotArea); - Margin shrink = this.getPlotsShrink(g, plotArea); - for (int i = 0; i < this.plots.size(); i++) { - Plot plot = this.plots.get(i); - plot.setSymbolAntialias(this.symbolAntialias); - if (plot.isOuterPosActive()){ - if (plot.isSubPlot || plot.isSameShrink()) { - plot.setPlotShrink(shrink); - } else { - //plot.setPlotShrink(this.getPlotShrink(g, area, plot)); - plot.setPlotShrink(this.getPlotShrink(g, plotArea, plot)); - } - } - if (plot instanceof MapPlot) { - ((MapPlot) plot).setAntialias(this.antiAlias); - } - plot.draw(g, plotArea); - } - } - - //Draw text - drawText(g, area); - - //Draw legend - if (this.drawLegend) { - Dimension dim = this.legend.getLegendDimension(g, new Dimension((int) area.getWidth(), (int) area.getHeight())); - float x = 0; - switch (this.legend.getPosition()) { - case UPPER_CENTER_OUTSIDE: - x = (float) area.getWidth() / 2 - dim.width / 2; - y += 5; - break; - case LOWER_CENTER_OUTSIDE: - x = (float) area.getWidth() / 2 - dim.width / 2; - y += plotArea.getHeight() + 5; - break; - case LEFT_OUTSIDE: - x = 10; - y = (float) area.getHeight() / 2 - dim.height / 2; - break; - case RIGHT_OUTSIDE: - x = (float) plotArea.getWidth() + 10; - y = (float) area.getHeight() / 2 - dim.height / 2; - break; - } - this.legend.draw(g, new PointF(x, y)); - } - - g.setTransform(oldMatrix); - g.setClip(oldRegion); - } - - void drawText(Graphics2D g, Rectangle2D area) { - float x, y; - for (ChartText text : this.texts) { - x = (float) (area.getWidth() * text.getX()); - y = (float) (area.getHeight() * (1 - text.getY())); - Dimension dim = Draw.getStringDimension(text.getText(), g); - Rectangle.Double rect = new Rectangle.Double(x, y, dim.getWidth(), dim.getHeight()); - if (text.isFill()) { - g.setColor(text.getBackground()); - g.fill(rect); - } - if (text.isDrawNeatline()) { - g.setColor(text.getNeatlineColor()); - Stroke oldStroke = g.getStroke(); - g.setStroke(new BasicStroke(text.getNeatlineSize())); - g.draw(rect); - g.setStroke(oldStroke); - } - g.setFont(text.getFont()); - g.setColor(text.getColor()); - Draw.drawString(g, text.getText(), x, y); - } - } - - private Rectangle2D getPlotArea(Graphics2D g, Rectangle2D area) { - Rectangle2D pArea = new Rectangle2D.Double(); - int edge = 0; - int top = edge; - int left = edge; - int right = edge; - int bottom = edge; - if (this.title != null) { - top += this.title.getTrueDimension(g).height + 12; - } - pArea.setRect(left, top, area.getWidth() - left - right, area.getHeight() - top - bottom); - - return pArea; - } - - private Rectangle2D getPlotArea_bak(Graphics2D g, Rectangle2D area) { - Rectangle2D pArea = new Rectangle2D.Double(); - int edge = 2; - int top = edge; - int left = edge; - int right = edge; - int bottom = edge; - if (this.title != null) { - top += this.title.getTrueDimension(g).height + 10; - } - if (this.drawLegend) { - Dimension dim = this.legend.getLegendDimension(g, new Dimension((int) area.getWidth(), (int) area.getHeight())); - switch (this.legend.getPosition()) { - case UPPER_CENTER_OUTSIDE: - top += dim.height + 10; - break; - case LOWER_CENTER_OUTSIDE: - bottom += dim.height + 10; - break; - case LEFT_OUTSIDE: - left += dim.width + 10; - break; - case RIGHT_OUTSIDE: - right += dim.width + 10; - break; - } - } - pArea.setRect(left, top, area.getWidth() - left - right, area.getHeight() - top - bottom); - - return pArea; - } - - private Margin getPlotShrink(Graphics2D g, Rectangle2D area, Plot plot) { - Margin shrink; - if (plot.isSubPlot) { - double rowHeight = area.getHeight() / this.rowNum; - double colWidth = area.getWidth() / this.columnNum; - double x = area.getX() + plot.columnIndex * colWidth; - double y = area.getY() + plot.rowIndex * rowHeight; - Rectangle2D subPlotArea = new Rectangle2D.Double(x, y, colWidth, rowHeight); - plot.setOuterPositionArea(subPlotArea); - plot.updatePosition(area, subPlotArea); - Rectangle2D positionArea = plot.getPositionArea(area); - plot.setPositionArea(positionArea); - Margin tightInset = plot.getTightInset(g, positionArea); - plot.setTightInset(tightInset); - shrink = plot.getPlotShrink(); - } else { - plot.setOuterPositionArea(area); - Rectangle2D positionArea = plot.getPositionArea(area); - plot.setPositionArea(positionArea); - Margin tightInset = plot.getTightInset(g, positionArea); - plot.setTightInset(tightInset); - shrink = plot.getPlotShrink(); - //shrink = tightInset; - } - - return shrink; - } - - private Margin getPlotsShrink(Graphics2D g, Rectangle2D area) { - Margin pshrink = null, shrink; - for (int i = 0; i < this.plots.size(); i++) { - Plot plot = this.plots.get(i); - plot.setOuterPositionArea(plot.getOuterPositionArea(area)); - Rectangle2D positionArea = plot.getPositionArea(area); - plot.setPositionArea(positionArea); - Margin tightInset = plot.getTightInset(g, positionArea); - plot.setTightInset(tightInset); - shrink = plot.getPlotShrink(); - if (i == 0) { - pshrink = shrink; - } else if (pshrink != null) { - pshrink = pshrink.extend(shrink); - } - } - - return pshrink; - } - - private Margin getPlotsShrink_bak(Graphics2D g, Rectangle2D area) { - Margin pshrink = null, shrink; - for (int i = 0; i < this.plots.size(); i++) { - Plot plot = this.plots.get(i); - if (plot.isSubPlot) { - double rowHeight = area.getHeight() / this.rowNum; - double colWidth = area.getWidth() / this.columnNum; - double x = area.getX() + plot.columnIndex * colWidth; - double y = area.getY() + plot.rowIndex * rowHeight; - Rectangle2D subPlotArea = new Rectangle2D.Double(x, y, colWidth, rowHeight); - plot.setOuterPositionArea(subPlotArea); - plot.updatePosition(area, subPlotArea); - Rectangle2D positionArea = plot.getPositionArea(area); - plot.setPositionArea(positionArea); - Margin tightInset = plot.getTightInset(g, positionArea); - plot.setTightInset(tightInset); - shrink = plot.getPlotShrink(); - } else { - plot.setOuterPositionArea(area); - Rectangle2D positionArea = plot.getPositionArea(area); - plot.setPositionArea(positionArea); - Margin tightInset = plot.getTightInset(g, positionArea); - plot.setTightInset(tightInset); - shrink = plot.getPlotShrink(); - } - if (i == 0) { - pshrink = shrink; - } else if (pshrink != null) { - pshrink = pshrink.extend(shrink); - } - } - - return pshrink; - } - - private Margin getPlotsTightInset(Graphics2D g, Rectangle2D area) { - int i = 0; - Margin pti = null, tightInset; - for (Plot plot : this.plots) { - if (plot.isSubPlot) { - double rowHeight = area.getHeight() / this.rowNum; - double colWidth = area.getWidth() / this.columnNum; - double x = area.getX() + plot.columnIndex * colWidth; - double y = area.getY() + plot.rowIndex * rowHeight; - Rectangle2D subPlotArea = new Rectangle2D.Double(x, y, colWidth, rowHeight); - plot.setOuterPositionArea(subPlotArea); - plot.updatePosition(area, subPlotArea); - Rectangle2D positionArea = plot.getPositionArea(); - plot.setPositionArea(positionArea); - tightInset = plot.getTightInset(g, positionArea); - } else { - plot.setOuterPositionArea(area); - Rectangle2D positionArea = plot.getPositionArea(); - plot.setPositionArea(positionArea); - tightInset = plot.getTightInset(g, positionArea); - } - if (i == 0) { - pti = tightInset; - } else if (pti != null) { - pti = pti.extend(tightInset); - } - i += 1; - } - - return pti; - } - - private double getPositionAreaZoom(Graphics2D g, Rectangle2D area) { - double zoom = 1.0; - for (Plot plot : this.plots) { - if (plot.isSubPlot) { - double rowHeight = area.getHeight() / this.rowNum; - double colWidth = area.getWidth() / this.columnNum; - double x = area.getX() + plot.columnIndex * colWidth; - double y = area.getY() + plot.rowIndex * rowHeight; - Rectangle2D subPlotArea = new Rectangle2D.Double(x, y, colWidth, rowHeight); - plot.setOuterPositionArea(subPlotArea); - plot.updatePosition(area, subPlotArea); - Rectangle2D positionArea = plot.getPositionArea(); - plot.setPositionArea(positionArea); - Margin tightInset = plot.getTightInset(g, positionArea); - plot.setTightInset(tightInset); - double zoom1 = plot.updatePostionAreaZoom(); - if (zoom1 < zoom) { - zoom = zoom1; - } - } else { - plot.setOuterPositionArea(area); - Rectangle2D positionArea = plot.getPositionArea(); - plot.setPositionArea(positionArea); - Margin tightInset = plot.getTightInset(g, positionArea); - plot.setTightInset(tightInset); - double zoom1 = plot.updatePostionAreaZoom(); - if (zoom1 < zoom) { - zoom = zoom1; - } - } - } - - return zoom; - } - - private Rectangle2D getSubPlotArea(Graphics2D g, Plot plot, Rectangle2D area) { - if (plot.isSubPlot) { - double rowHeight = area.getHeight() / this.rowNum; - double colWidth = area.getWidth() / this.columnNum; - double x = area.getX() + plot.columnIndex * colWidth; - double y = area.getY() + plot.rowIndex * rowHeight; - Rectangle2D subPlotArea = new Rectangle2D.Double(x, y, colWidth, rowHeight); - plot.setOuterPositionArea(subPlotArea); - plot.updatePosition(area, subPlotArea); - Rectangle2D positionArea = plot.getPositionArea(); - plot.setPositionArea(positionArea); - Margin tightInset = plot.getTightInset(g, positionArea); - plot.setTightInset(tightInset); - double zoom = plot.updatePostionAreaZoom(); - plot.setPositionAreaZoom(zoom); - return subPlotArea; - } else { - plot.setOuterPositionArea(area); - Rectangle2D positionArea = plot.getPositionArea(); - plot.setPositionArea(positionArea); - Margin tightInset = plot.getTightInset(g, positionArea); - plot.setTightInset(tightInset); - double zoom = plot.updatePostionAreaZoom(); - plot.setPositionAreaZoom(zoom); - //return tightInset.getArea(positionArea); - return area; - } - } - - /** - * Get graph area - * - * @return Get graph area - */ - public Rectangle2D getGraphArea() { - Rectangle2D rect = this.plots.get(0).getPositionArea(); - double left = rect.getX() + this.plotArea.getX(); - double top = rect.getY() + this.plotArea.getY(); - return new Rectangle2D.Double(left, top, rect.getWidth(), rect.getHeight()); - } - - /** - * Find a plot by point - * - * @param x X - * @param y Y - * @return Plot - */ - public Plot findPlot(int x, int y) { - for (Plot plot : this.plots) { - Rectangle2D area = plot.getPositionArea(); - if (area.contains(x, y)) { - return plot; - } - } - - return null; - } - - /** - * Clear plots - */ - public void clearPlots() { - this.plots.clear(); - } - - /** - * Clear texts - */ - public void clearTexts() { - this.texts.clear(); - } - - /** - * Remove a plot - * - * @param plot The plot - */ - public void removePlot(Plot plot) { - this.plots.remove(plot); - } - - /** - * Add a plot - * - * @param plot Plot - */ - public void addPlot(Plot plot) { - if (plot instanceof MapPlot) { - ((MapPlot) plot).setParent(parent); - } - this.plots.add(plot); - } - - /** - * Set plot - * - * @param plot Plot - */ - public void setPlot(Plot plot) { - if (plot instanceof MapPlot) { - ((MapPlot) plot).setParent(parent); - } - this.plots.clear(); - this.plots.add(plot); - } - - /** - * Get plot by plot index - * - * @param plotIdx Plot index - begin with 1 - * @return Plot index - */ - public Plot getPlot(int plotIdx) { - for (Plot plot : this.plots) { - int pIdx = plot.rowIndex * this.columnNum + plot.columnIndex + 1; - if (pIdx == plotIdx) { - return plot; - } - } - - if (plotIdx > 0 && plotIdx <= this.plots.size()) - return this.plots.get(plotIdx - 1); - else - return null; - } - - /** - * Get plot index - * @param plot The plot - * @return Plot index - */ - public int getPlotIndex(Plot plot){ - return this.plots.indexOf(plot); - } - - /** - * Check if has web map layer - * - * @return Boolean - */ - public boolean hasWebMap() { - for (Plot plot : this.plots) { - if (plot instanceof MapPlot) { - MapPlot mp = (MapPlot) plot; - if (mp.hasWebMapLayer()) { - return true; - } - } - } - - return false; - } - - /** - * Add text - * - * @param text Text - */ - public void addText(ChartText text) { - this.texts.add(text); - } - // - -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartColorBar.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartColorBar.java deleted file mode 100644 index b949340c..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartColorBar.java +++ /dev/null @@ -1,1038 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.geom.AffineTransform; -import java.awt.geom.Line2D; -import java.awt.geom.Path2D; -import java.util.ArrayList; -import java.util.List; - -import org.meteoinfo.common.*; -import org.meteoinfo.drawing.Draw; -import org.meteoinfo.geometry.legend.*; -import org.meteoinfo.geometry.shape.ShapeTypes; - -/** - * - * @author Yaqiang Wang - */ -public class ChartColorBar extends ChartLegend { - - // - private List tickLocations; - private List tickLabels; - private boolean autoTick; - private boolean insideTick; - private float tickLength; - private boolean tickVisible; - private float tickWidth; - private Color tickColor; - private boolean drawMinLabel; - private boolean drawMaxLabel; - - // - // - /** - * Constructor - * - * @param ls LegendScheme - */ - public ChartColorBar(LegendScheme ls) { - super(ls); - - this.tickLocations = new ArrayList<>(); - this.tickLabels = new ArrayList<>(); - this.autoTick = true; - this.insideTick = true; - this.tickLength = 5; - this.tickVisible = true; - this.tickWidth = 1; - this.tickColor = Color.black; - this.drawMinLabel = false; - this.drawMaxLabel = false; - } - - // - // - /** - * Tick locations - * - * @return Tick locations - */ - public List getTickLocations() { - return this.tickLocations; - } - - /** - * Set tick locations - * - * @param value Tick locations - */ - public void setTickLocations(List value) { - this.tickLocations.clear(); - this.tickLabels.clear(); - for (Number v : value) { - this.tickLocations.add(v.doubleValue()); - this.tickLabels.add(new ChartText(DataConvert.removeTailingZeros(String.valueOf(v)))); - } - this.autoTick = false; - } - - /** - * Set tick locations - * - * @param value Tick locations - */ - public void setTickLocations(double[] value) { - this.tickLocations.clear(); - this.tickLabels.clear(); - for (double v : value) { - this.tickLocations.add(v); - this.tickLabels.add(new ChartText(DataConvert.removeTailingZeros(String.valueOf(v)))); - } - this.autoTick = false; - } - - /** - * Get tick labels - * - * @return Tick labels - */ - public List getTickLabels() { - return this.tickLabels; - } - - /** - * Get tick label text - * - * @return Tick label text - */ - public List getTickLabelText() { - List strs = new ArrayList<>(); - for (ChartText ct : this.tickLabels) { - strs.add(ct.toString()); - } - - return strs; - } - - /** - * Set tick label text - * - * @param value Tick label text - */ - public void setTickLabelText(List value) { - this.tickLabels = new ArrayList<>(); - for (String v : value) { - this.tickLabels.add(new ChartText(v)); - } - this.autoTick = false; - } - - /** - * Set tick labels. - * - * @param value Tick labels - */ - public void setTickLabels(List value) { - this.tickLabels = value; - } - - /** - * Set tick labels - * - * @param value Tick labels - */ - public void setTickLabels_Number(List value) { - this.tickLabels = new ArrayList<>(); - for (Number v : value) { - this.tickLabels.add(new ChartText(v.toString())); - } - this.autoTick = false; - } - - /** - * Get if is auto tick labels - * - * @return Boolean - */ - public boolean isAutoTick() { - return this.autoTick; - } - - /** - * Set if auto tick labels - * - * @param value Boolean - */ - public void setAutoTick(boolean value) { - this.autoTick = value; - } - - /** - * Get tick length - * - * @return Tick length - */ - public float getTickLength() { - return this.tickLength; - } - - /** - * Set tick length - * - * @param value Tick length - */ - public void setTickLength(int value) { - this.tickLength = value; - } - - /** - * Get if is inside tick - * - * @return Boolean - */ - public boolean isInsideTick() { - return this.insideTick; - } - - /** - * Set if is inside tick - * - * @param value Boolean - */ - public void setInsideTick(boolean value) { - this.insideTick = value; - } - - /** - * Get if is tick visible - * @return Boolean - */ - public boolean isTickVisible() { - return this.tickVisible; - } - - /** - * Set if is tick visible - * @param value Boolean - */ - public void setTickVisible(boolean value) { - this.tickVisible = value; - } - - /** - * Get tick line width - * @return Tick line width - */ - public float getTickWidth() { - return this.tickWidth; - } - - /** - * Set tick line width - * @param value Tick line width - */ - public void setTickWidth(float value) { - this.tickWidth = value; - } - - /** - * Get tick color - * @return Tick color - */ - public Color getTickColor() { - return this.tickColor; - } - - /** - * Set tick color - * @param value Tick color - */ - public void setTickColor(Color value) { - this.tickColor = value; - } - - /** - * Get if draw minimum value label - * - * @return Boolean - */ - public boolean isDrawMinLabel() { - return this.drawMinLabel; - } - - /** - * Set if draw minimum value label - * - * @param value Boolean - */ - public void setDrawMinLabel(boolean value) { - this.drawMinLabel = value; - } - - /** - * Get if draw maximum value label - * - * @return Boolean - */ - public boolean isDrawMaxLabel() { - return this.drawMaxLabel; - } - - /** - * Set if draw maximum value label - * - * @param value Boolean - */ - public void setDrawMaxLabel(boolean value) { - this.drawMaxLabel = value; - } - - // - // - /** - * Draw legend - * - * @param g Graphics2D - * @param point Start point - */ - @Override - public void draw(Graphics2D g, PointF point) { - - AffineTransform oldMatrix = g.getTransform(); - g.translate(point.X + this.xshift, point.Y + this.yshift); - - //Draw background color - if (this.drawBackground) { - g.setColor(this.background); - g.fill(new Rectangle.Float(0, 0, this.width, this.height)); - } - - //Draw legend - g.setStroke(new BasicStroke(1)); - switch (this.orientation) { - case HORIZONTAL: - this.drawHorizontalBarLegend(g, legendScheme); - break; - case VERTICAL: - this.drawVerticalBarLegend(g, legendScheme); - break; - } - - //Draw neatline - if (drawNeatLine) { - Rectangle.Float mapRect = new Rectangle.Float(0, 0, this.width, this.height); - g.setColor(neatLineColor); - g.setStroke(new BasicStroke(neatLineSize)); - g.draw(mapRect); - } - - g.setTransform(oldMatrix); - } - - private void drawTickLine(Graphics2D g, PointF sP, float tickLen, boolean vertical, float shift) { - if (vertical) { - if (this.insideTick) { - g.draw(new Line2D.Float(sP.X + shift, sP.Y, sP.X + shift, sP.Y - tickLen)); - } else { - g.draw(new Line2D.Float(sP.X + shift, sP.Y, sP.X + shift, sP.Y + tickLen)); - sP.Y += tickLen; - } - sP.Y += 5; - } else { - if (this.insideTick) { - g.draw(new Line2D.Float(sP.X - tickLen, sP.Y + shift, sP.X, sP.Y + shift)); - } else { - g.draw(new Line2D.Float(sP.X, sP.Y + shift, sP.X + tickLen, sP.Y + shift)); - sP.X += tickLen; - } - sP.X += 5; - } - } - - private void drawTickLine(Graphics2D g, PointD sP, float tickLen, boolean vertical, double shift) { - if (vertical) { - if (this.insideTick) { - g.draw(new Line2D.Double(sP.X + shift, sP.Y, sP.X + shift, sP.Y - tickLen)); - } else { - g.draw(new Line2D.Double(sP.X + shift, sP.Y, sP.X + shift, sP.Y + tickLen)); - sP.Y += tickLen; - } - sP.Y += 5; - } else { - if (this.insideTick) { - g.draw(new Line2D.Double(sP.X - tickLen, sP.Y + shift, sP.X, sP.Y + shift)); - } else { - g.draw(new Line2D.Double(sP.X, sP.Y + shift, sP.X + tickLen, sP.Y + shift)); - sP.X += tickLen; - } - sP.X += 5; - } - } - - private void drawHorizontalBarLegend(Graphics2D g, LegendScheme aLS) { - PointD aP = new PointD(0, 0); - PointD sP = new PointD(0, 0); - boolean DrawShape = true, DrawFill = true, DrawOutline = false; - Color FillColor = Color.red, OutlineColor = Color.black; - String caption; - - int bNum = aLS.getBreakNum(); - if (aLS.getLegendBreaks().get(bNum - 1).isNoData()) { - bNum -= 1; - } - - List labelIdxs = new ArrayList<>(); - List tLabels = new ArrayList<>(); - if (this.autoTick) { - int tickGap = this.getTickGap(g); - int sIdx = (bNum % tickGap) / 2; - int labNum = bNum - 1; - if (aLS.getLegendType() == LegendType.UniqueValue) { - labNum += 1; - } else if (this.drawMinLabel) { - sIdx = 0; - labNum = bNum; - } - while (sIdx < labNum) { - labelIdxs.add(sIdx); - sIdx += tickGap; - } - } else { - int tickIdx; - for (int i = 0; i < bNum; i++) { - ColorBreak cb = aLS.getLegendBreaks().get(i); - if (i == bNum - 1) { - if (cb.getStartValue().equals(cb.getEndValue())) - continue; - } - double v = Double.parseDouble(cb.getEndValue().toString()); - if (this.tickLocations.contains(v)) { - labelIdxs.add(i); - tickIdx = this.tickLocations.indexOf(v); - tLabels.add(this.tickLabels.get(tickIdx).getText()); - } - } - } - - this._hBarHeight = (double) this.legendWidth / this.aspect; - _vBarWidth = (double) this.legendWidth / bNum; - float y_shift = 0; - if (this.label != null){ - switch (this.labelLocation){ - case "top": - case "in": - y_shift = this.label.getDimension(g).height + 5; - break; - } - } - int idx; - aP.Y = y_shift; - for (int i = 0; i < bNum; i++) { - idx = i; - switch (aLS.getShapeType()) { - case Point: - PointBreak aPB = (PointBreak) aLS.getLegendBreaks().get(idx); - DrawShape = aPB.isDrawShape(); - DrawFill = aPB.isDrawFill(); - FillColor = aPB.getColor(); - break; - case Polyline: - PolylineBreak aPLB = (PolylineBreak) aLS.getLegendBreaks().get(idx); - DrawShape = aPLB.getDrawPolyline(); - FillColor = aPLB.getColor(); - break; - case Polygon: - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(idx); - DrawShape = aPGB.isDrawShape(); - DrawFill = aPGB.isDrawFill(); - FillColor = aPGB.getColor(); - break; - case Image: - ColorBreak aCB = aLS.getLegendBreaks().get(idx); - DrawShape = true; - DrawFill = true; - FillColor = aCB.getColor(); - break; - } - - if (DrawShape) { - if (this.extendRect) { - if (aLS.getShapeType() == ShapeTypes.Polygon) { - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(idx).clone(); - aPGB.setDrawOutline(false); - Draw.drawPolygonSymbol(aP.X, aP.Y, _vBarWidth, _hBarHeight, aPGB, g); - } else { - Draw.drawPolygonSymbol(aP.X, aP.Y, FillColor, OutlineColor, _vBarWidth, - _hBarHeight, DrawFill, DrawOutline, g); - } - } else { - double extendw = _vBarWidth; - if (this.autoExtendFrac) { - extendw = _hBarHeight; - } - if (i == 0) { - PointD[] Points = new PointD[4]; - Points[0] = new PointD(); - Points[0].X = _vBarWidth - extendw; - Points[0].Y = aP.Y + _hBarHeight * 0.5; - Points[1] = new PointD(); - Points[1].X = _vBarWidth; - Points[1].Y = aP.Y; - Points[2] = new PointD(); - Points[2].X = _vBarWidth; - Points[2].Y = aP.Y + _hBarHeight; - Points[3] = new PointD(); - Points[3].X = _vBarWidth - extendw; - Points[3].Y = aP.Y + _hBarHeight * 0.5; - if (aLS.getShapeType() == ShapeTypes.Polygon) { - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(idx).clone(); - aPGB.setDrawOutline(false); - Draw.drawPolygon(Points, aPGB, g); - } else { - Draw.drawPolygon(Points, FillColor, OutlineColor, DrawFill, DrawOutline, g); - } - } else if (i == bNum - 1) { - PointD[] Points = new PointD[4]; - Points[0] = new PointD(); - Points[0].X = i * _vBarWidth - 1.0f; - Points[0].Y = aP.Y + _hBarHeight; - Points[1] = new PointD(); - Points[1].X = i * _vBarWidth - 1.0f; - Points[1].Y = aP.Y; - Points[2] = new PointD(); - Points[2].X = i * _vBarWidth + extendw; - Points[2].Y = aP.Y + _hBarHeight * 0.5; - Points[3] = new PointD(); - Points[3].X = i * _vBarWidth - 1.0f; - Points[3].Y = aP.Y + _hBarHeight; - if (aLS.getShapeType() == ShapeTypes.Polygon) { - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(idx).clone(); - aPGB.setDrawOutline(false); - Draw.drawPolygon(Points, aPGB, g); - } else { - Draw.drawPolygon(Points, FillColor, OutlineColor, DrawFill, DrawOutline, g); - } - } else if (aLS.getShapeType() == ShapeTypes.Polygon) { - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(idx).clone(); - aPGB.setDrawOutline(false); - Draw.drawPolygonSymbol(aP.X, aP.Y, _vBarWidth, _hBarHeight, aPGB, g); - } else { - Draw.drawPolygonSymbol(aP.X, aP.Y, FillColor, OutlineColor, _vBarWidth, - _hBarHeight, DrawFill, DrawOutline, g); - } - } - } - aP.X += _vBarWidth; - } - //Draw neatline - g.setStroke(new BasicStroke(this.neatLineSize)); - g.setColor(this.neatLineColor); - if (this.extendRect) { - g.draw(new Rectangle.Double(0, y_shift, this._vBarWidth * bNum, this._hBarHeight)); - } else { - double extendw = _vBarWidth; - if (this.autoExtendFrac) { - extendw = _hBarHeight; - } - Path2D p = new Path2D.Double(); - p.moveTo(_vBarWidth - extendw, this._hBarHeight / 2 + y_shift); - p.lineTo(this._vBarWidth, y_shift); - p.lineTo(this._vBarWidth * (bNum - 1), y_shift); - p.lineTo(this._vBarWidth * (bNum - 1) + extendw, this._hBarHeight / 2 + y_shift); - p.lineTo(this._vBarWidth * (bNum - 1), this._hBarHeight + y_shift); - p.lineTo(this._vBarWidth, this._hBarHeight + y_shift); - p.closePath(); - g.draw(p); - } - //Draw tick and label - aP.X = -_vBarWidth / 2; - float tickLen = this.tickLength; - if (this.insideTick) { - if (this._hBarHeight < tickLen) { - tickLen = (int) this._hBarHeight; - } - } - g.setStroke(new BasicStroke(this.tickWidth)); - g.setFont(tickLabelFont); - g.setColor(this.tickColor); - idx = 0; - for (int i = 0; i < bNum; i++) { - aP.X += _vBarWidth; - aP.Y = _hBarHeight / 2 + y_shift; - if (labelIdxs.contains(i)) { - ColorBreak cb = aLS.getLegendBreaks().get(i); - if (this.autoTick) { - if (aLS.getLegendType() == LegendType.UniqueValue) { - caption = cb.getCaption(); - } else { - caption = DataConvert.removeTailingZeros(cb.getEndValue().toString()); - } - } else { - caption = tLabels.get(idx); - } - - if (aLS.getLegendType() == LegendType.UniqueValue) { - sP.X = aP.X; - sP.Y = aP.Y + _hBarHeight / 2 + 5; - g.setColor(this.tickLabelColor); - if (this.tickLabelAngle == 0) { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.CENTER, YAlign.TOP, this.tickLabelAngle, true); - } else if (this.tickLabelAngle < 45) { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.RIGHT, YAlign.TOP, this.tickLabelAngle, true); - } else { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.RIGHT, YAlign.CENTER, this.tickLabelAngle, true); - } - } else { - sP.X = aP.X + _vBarWidth / 2; - sP.Y = aP.Y + _hBarHeight / 2; - PointD ssP = (PointD)sP.clone(); - if (this.autoTick) { - if (i < bNum - 1) { - g.setColor(this.tickColor); - this.drawTickLine(g, sP, tickLen, true, 0); - g.setColor(this.tickLabelColor); - if (this.tickLabelAngle == 0) { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.CENTER, YAlign.TOP, this.tickLabelAngle, true); - } else if (this.tickLabelAngle < 45) { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.RIGHT, YAlign.TOP, this.tickLabelAngle, true); - } else { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.RIGHT, YAlign.CENTER, this.tickLabelAngle, true); - } - if (this.drawMinLabel && i == 0) { - g.setColor(this.tickColor); - this.drawTickLine(g, ssP, tickLen, true, -this._vBarWidth); - caption = DataConvert.removeTailingZeros(cb.getStartValue().toString()); - g.setColor(this.tickLabelColor); - //Draw.drawString(g, ssP.X - this._vBarWidth, ssP.Y, caption, XAlign.CENTER, YAlign.TOP, this.tickLabelAngle, true); - if (this.tickLabelAngle == 0) { - Draw.drawString(g, ssP.X - this._vBarWidth, ssP.Y, caption, XAlign.CENTER, YAlign.TOP, this.tickLabelAngle, true); - } else if (this.tickLabelAngle < 45) { - Draw.drawString(g, ssP.X - this._vBarWidth, ssP.Y, caption, XAlign.RIGHT, YAlign.TOP, this.tickLabelAngle, true); - } else { - Draw.drawString(g, ssP.X - this._vBarWidth, ssP.Y, caption, XAlign.RIGHT, YAlign.CENTER, this.tickLabelAngle, true); - } - } - } else if (this.drawMaxLabel) { - g.setColor(this.tickColor); - this.drawTickLine(g, sP, tickLen, true, 0); - g.setColor(this.tickLabelColor); - if (this.tickLabelAngle == 0) { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.CENTER, YAlign.TOP, this.tickLabelAngle, true); - } else if (this.tickLabelAngle < 45) { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.RIGHT, YAlign.TOP, this.tickLabelAngle, true); - } else { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.RIGHT, YAlign.CENTER, this.tickLabelAngle, true); - } - } - } else { - if (i == 0 && this.tickLocations.get(idx) == Double.parseDouble(cb.getStartValue().toString())) { - g.setColor(this.tickColor); - this.drawTickLine(g, sP, tickLen, true, -this._vBarWidth); - g.setColor(this.tickLabelColor); - //Draw.drawString(g, sP.X - this._vBarWidth, sP.Y, caption, XAlign.CENTER, YAlign.TOP, this.tickLabelAngle, true); - if (this.tickLabelAngle == 0) { - Draw.drawString(g, sP.X - this._vBarWidth, sP.Y, caption, XAlign.CENTER, YAlign.TOP, this.tickLabelAngle, true); - } else if (this.tickLabelAngle < 45) { - Draw.drawString(g, sP.X - this._vBarWidth, sP.Y, caption, XAlign.RIGHT, YAlign.TOP, this.tickLabelAngle, true); - } else { - Draw.drawString(g, sP.X - this._vBarWidth, sP.Y, caption, XAlign.RIGHT, YAlign.CENTER, this.tickLabelAngle, true); - } - } else { - g.setColor(this.tickColor); - this.drawTickLine(g, sP, tickLen, true, 0); - g.setColor(this.tickLabelColor); - if (this.tickLabelAngle == 0) { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.CENTER, YAlign.TOP, this.tickLabelAngle, true); - } else if (this.tickLabelAngle < 45) { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.RIGHT, YAlign.TOP, this.tickLabelAngle, true); - } else { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.RIGHT, YAlign.CENTER, this.tickLabelAngle, true); - } - } - } - } - idx += 1; - } - } - - //Draw label - double sx, sy; - if (this.label != null) { - g.setFont(this.label.getFont()); - g.setColor(this.label.getColor()); - switch (this.labelLocation) { - case "top": - case "in": - sx = this.legendWidth * 0.5; - sy = 2; - Draw.drawString(g, sx, sy, label.getText(), XAlign.CENTER, YAlign.TOP, label.isUseExternalFont()); - break; - case "right": - sx = this.legendWidth + 5; - sy = this._hBarHeight * 0.5; - Draw.drawString(g, sx, sy, label.getText(), XAlign.LEFT, YAlign.CENTER, label.isUseExternalFont()); - break; - case "left": - sx = -5; - sy = this._hBarHeight * 0.5; - Draw.drawString(g, sx, sy, label.getText(), XAlign.RIGHT, YAlign.CENTER, label.isUseExternalFont()); - break; - default: - sx = this.legendWidth * 0.5; - sy = this.height - 2; - Draw.drawString(g, sx, sy, label.getText(), XAlign.CENTER, YAlign.BOTTOM, label.isUseExternalFont()); - break; - } - } - } - - private void drawVerticalBarLegend(Graphics2D g, LegendScheme aLS) { - PointD aP = new PointD(0, 0); - PointD sP = new PointD(0, 0); - boolean DrawShape = true, DrawFill = true, DrawOutline = false; - Color FillColor = Color.red, OutlineColor = Color.black; - String caption; - - int bNum = aLS.getBreakNum(); - if (aLS.getLegendBreaks().get(bNum - 1).isNoData()) { - bNum -= 1; - } - - List labelIdxs = new ArrayList<>(); - List tLabels = new ArrayList<>(); - if (this.autoTick) { - int tickGap = this.getTickGap(g); - int sIdx = (bNum % tickGap) / 2; - int labNum = bNum - 1; - if (aLS.getLegendType() == LegendType.UniqueValue) { - labNum += 1; - } else if (this.drawMinLabel) { - sIdx = 0; - labNum = bNum; - } - while (sIdx < labNum) { - labelIdxs.add(sIdx); - sIdx += tickGap; - } - } else { - int tickIdx; - for (int i = 0; i < bNum; i++) { - ColorBreak cb = aLS.getLegendBreaks().get(i); - if (i == bNum - 1) { - if (cb.getStartValue().equals(cb.getEndValue())) - continue; - } - double v = Double.parseDouble(cb.getEndValue().toString()); - if (this.tickLocations.contains(v)) { - labelIdxs.add(i); - tickIdx = this.tickLocations.indexOf(v); - tLabels.add(this.tickLabels.get(tickIdx).getText()); - } - if (i == 0) { - v = Double.parseDouble(cb.getStartValue().toString()); - if (this.tickLocations.contains(v)) { - labelIdxs.add(i); - tickIdx = this.tickLocations.indexOf(v); - tLabels.add(this.tickLabels.get(tickIdx).getText()); - } - } - } - } - - this._vBarWidth = (double) this.legendHeight / this.aspect; - _hBarHeight = (double) this.legendHeight / bNum; - aP.Y = this.legendHeight; - float x_shift = 0; - if (this.label != null){ - switch (this.labelLocation){ - case "left": - case "in": - x_shift = this.label.getDimension(g).height + 5; - break; - } - } - int idx; - aP.X = x_shift; - for (int i = 0; i < bNum; i++) { - idx = i; - switch (aLS.getShapeType()) { - case Point: - PointBreak aPB = (PointBreak) aLS.getLegendBreaks().get(idx); - DrawShape = aPB.isDrawShape(); - DrawFill = aPB.isDrawFill(); - FillColor = aPB.getColor(); - break; - case Polyline: - PolylineBreak aPLB = (PolylineBreak) aLS.getLegendBreaks().get(idx); - DrawShape = aPLB.getDrawPolyline(); - FillColor = aPLB.getColor(); - break; - case Polygon: - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(idx); - DrawShape = aPGB.isDrawShape(); - DrawFill = aPGB.isDrawFill(); - FillColor = aPGB.getColor(); - break; - case Image: - ColorBreak aCB = aLS.getLegendBreaks().get(idx); - DrawShape = true; - DrawFill = true; - FillColor = aCB.getColor(); - break; - } - - aP.Y = aP.Y - _hBarHeight; - - if (DrawShape) { - if (this.extendRect) { - if (aLS.getShapeType() == ShapeTypes.Polygon) { - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(idx).clone(); - aPGB.setDrawOutline(false); - Draw.drawPolygonSymbol(aP.X, aP.Y, _vBarWidth, _hBarHeight, aPGB, g); - } else { - Draw.drawPolygonSymbol(aP.X, aP.Y, FillColor, OutlineColor, _vBarWidth, - _hBarHeight, DrawFill, DrawOutline, g); - } - } else if (i == 0) { - PointD[] Points = new PointD[4]; - Points[0] = new PointD(); - Points[0].X = aP.X + _vBarWidth * 0.5; - Points[0].Y = this.legendHeight; - Points[1] = new PointD(); - Points[1].X = aP.X; - Points[1].Y = aP.Y; - Points[2] = new PointD(); - Points[2].X = aP.X + _vBarWidth; - Points[2].Y = aP.Y; - Points[3] = new PointD(); - Points[3].X = aP.X + _vBarWidth * 0.5; - Points[3].Y = this.legendHeight; - if (aLS.getShapeType() == ShapeTypes.Polygon) { - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(idx).clone(); - aPGB.setDrawOutline(false); - Draw.drawPolygon(Points, aPGB, g); - } else { - Draw.drawPolygon(Points, FillColor, OutlineColor, DrawFill, DrawOutline, g); - } - } else if (i == bNum - 1) { - PointD[] Points = new PointD[4]; - Points[0] = new PointD(); - Points[0].X = aP.X; - Points[0].Y = _hBarHeight; - Points[1] = new PointD(); - Points[1].X = aP.X + _vBarWidth; - Points[1].Y = _hBarHeight; - Points[2] = new PointD(); - Points[2].X = aP.X + _vBarWidth * 0.5; - Points[2].Y = 0; - Points[3] = new PointD(); - Points[3].X = aP.X; - Points[3].Y = _hBarHeight; - if (aLS.getShapeType() == ShapeTypes.Polygon) { - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(idx).clone(); - aPGB.setDrawOutline(false); - Draw.drawPolygon(Points, aPGB, g); - } else { - Draw.drawPolygon(Points, FillColor, OutlineColor, DrawFill, DrawOutline, g); - } - } else if (aLS.getShapeType() == ShapeTypes.Polygon) { - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(idx).clone(); - aPGB.setDrawOutline(false); - Draw.drawPolygonSymbol(aP.X, aP.Y, _vBarWidth, _hBarHeight, aPGB, g); - } else { - Draw.drawPolygonSymbol(aP.X, aP.Y, FillColor, OutlineColor, _vBarWidth, - _hBarHeight, DrawFill, DrawOutline, g); - } - } - } - //Draw neatline - g.setStroke(new BasicStroke(this.neatLineSize)); - g.setColor(this.neatLineColor); - if (this.extendRect) { - g.draw(new Rectangle.Double(x_shift, 0, this._vBarWidth, this._hBarHeight * bNum)); - } else { - Path2D p = new Path2D.Double(); - p.moveTo(this._vBarWidth / 2 + x_shift, 0); - p.lineTo(x_shift, this._hBarHeight); - p.lineTo(x_shift, (this._hBarHeight * (bNum - 1))); - p.lineTo(this._vBarWidth / 2 + x_shift, this._hBarHeight * bNum); - p.lineTo(this._vBarWidth + x_shift, this._hBarHeight * (bNum - 1)); - p.lineTo(this._vBarWidth + x_shift, this._hBarHeight); - p.closePath(); - g.draw(p); - } - //Draw ticks - g.setStroke(new BasicStroke(this.tickWidth)); - aP.Y = this.legendHeight + _hBarHeight / 2; - float tickLen = this.tickLength; - if (this.insideTick) { - if (this._vBarWidth < tickLen) { - tickLen = (int) this._vBarWidth; - } - } - g.setFont(tickLabelFont); - idx = 0; - for (int i = 0; i < bNum; i++) { - aP.X = _vBarWidth / 2 + x_shift; - aP.Y = aP.Y - _hBarHeight; - if (labelIdxs.contains(i)) { - ColorBreak cb = aLS.getLegendBreaks().get(i); - if (this.autoTick) { - if (aLS.getLegendType() == LegendType.UniqueValue) { - caption = cb.getCaption(); - } else { - caption = DataConvert.removeTailingZeros(cb.getEndValue().toString()); - } - } else { - caption = tLabels.get(idx); - } - - if (aLS.getLegendType() == LegendType.UniqueValue) { - sP.X = aP.X + _vBarWidth / 2 + 5; - sP.Y = aP.Y; - g.setColor(this.tickLabelColor); - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.LEFT, YAlign.CENTER, this.tickLabelAngle, true); - } else { - sP.X = aP.X + _vBarWidth / 2; - sP.Y = aP.Y - _hBarHeight / 2; - PointD ssP = (PointD)sP.clone(); - if (this.autoTick) { - if (i < bNum - 1) { - g.setColor(this.tickColor); - this.drawTickLine(g, sP, tickLen, false, 0); - g.setColor(this.tickLabelColor); - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.LEFT, YAlign.CENTER, this.tickLabelAngle, true); - if (this.drawMinLabel && i == 0) { - g.setColor(this.tickColor); - this.drawTickLine(g, ssP, tickLen, false, this._hBarHeight); - caption = DataConvert.removeTailingZeros(cb.getStartValue().toString()); - g.setColor(this.tickLabelColor); - Draw.drawString(g, ssP.X, ssP.Y + this._hBarHeight, caption, XAlign.LEFT, YAlign.CENTER, this.tickLabelAngle, true); - } - } else if (this.drawMaxLabel) { - g.setColor(this.tickColor); - this.drawTickLine(g, sP, tickLen, false, 0); - g.setColor(this.tickLabelColor); - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.LEFT, YAlign.CENTER, this.tickLabelAngle, true); - } - } else { - if (i == 0 && this.tickLocations.get(idx) == Double.parseDouble(cb.getStartValue().toString())) { - g.setColor(this.tickColor); - this.drawTickLine(g, sP, tickLen, false, this._hBarHeight); - g.setColor(this.tickLabelColor); - Draw.drawString(g, sP.X, sP.Y + this._hBarHeight, caption, XAlign.LEFT, YAlign.CENTER, this.tickLabelAngle, true); - } else { - g.setColor(this.tickColor); - this.drawTickLine(g, sP, tickLen, false, 0); - g.setColor(this.tickLabelColor); - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.LEFT, YAlign.CENTER, this.tickLabelAngle, true); - } - } - } - idx += 1; - } - } - //Draw label - double sx, sy; - if (this.label != null) { - g.setFont(this.label.getFont()); - g.setColor(this.label.getColor()); - Dimension dim = Draw.getStringDimension(this.label.getText(), g); - switch (this.labelLocation) { - case "top": - sx = 0; - sy = -5; - Draw.drawString(g, sx, sy, label.getText(), XAlign.LEFT, YAlign.BOTTOM, label.isUseExternalFont()); - break; - case "bottom": - sx = 0; - sy = this.legendHeight + 5; - Draw.drawString(g, sx, sy, label.getText(), XAlign.LEFT, YAlign.TOP, label.isUseExternalFont()); - break; - case "left": - case "in": - sx = 0; - sy = this.legendHeight * 0.5; - Draw.drawString(g, sx, sy, label.getText(), XAlign.CENTER, YAlign.TOP, 90, label.isUseExternalFont()); - break; - default: - sx = this.width - dim.height; - sy = this.legendHeight * 0.5; - Draw.drawString(g, sx, sy, label.getText(), XAlign.CENTER, YAlign.TOP, 90, label.isUseExternalFont()); - break; - } - } - } - - /** - * Get legend dimension - * - * @param g Graphics2D - * @param limitDim Limit dimension - * @return Legend dimension - */ - @Override - public Dimension getLegendDimension(Graphics2D g, Dimension limitDim) { - if (legendScheme != null) { - switch (this.orientation) { - case VERTICAL: - this.width = (int) (this.getTickWidth(g) + limitDim.height * this.shrink / this.aspect + 5); - if (!this.insideTick){ - this.width += this.tickLength; - } - this.legendWidth = this.width; - this.legendHeight = this.height; - if (this.label != null) { - g.setFont(this.label.getFont()); - Dimension dim = Draw.getStringDimension(label.getText(), g); - switch (this.labelLocation) { - case "top": - case "bottom": - //this.height += dim.height + 10; - this.width = Math.max(this.width, dim.width); - break; - default: - this.width += dim.height + 5; - break; - } - } - break; - default: - g.setFont(this.tickLabelFont); - this.height = (int) (this.getTickHeight(g) + limitDim.width * this.shrink / this.aspect + 5); - if (!this.insideTick){ - this.height += this.tickLength; - } - this.legendWidth = this.width; - this.legendHeight = this.height; - if (this.label != null) { - g.setFont(this.label.getFont()); - Dimension dim = Draw.getStringDimension(label.getText(), g); - switch (this.labelLocation) { - case "right": - case "left": - //this.width += dim.width + 10; - break; - default: - this.height += dim.height + 5; - break; - } - } - } - } - - return new Dimension(this.width, this.height); - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartElement.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartElement.java deleted file mode 100644 index 145db3e7..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartElement.java +++ /dev/null @@ -1,336 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.chart; - -import org.meteoinfo.common.PointF; -import org.meteoinfo.ui.event.ILocationChangedListener; -import org.meteoinfo.ui.event.ISizeChangedListener; -import org.meteoinfo.ui.event.LocationChangedEvent; -import org.meteoinfo.ui.event.SizeChangedEvent; - -import java.awt.Color; -import java.awt.Rectangle; -import javax.swing.event.EventListenerList; -import org.meteoinfo.layout.ResizeAbility; - -/** - * - * @author yaqiang - */ -public abstract class ChartElement { - // - - public void addLocationChangedListener(ILocationChangedListener listener) { - this._listeners.add(ILocationChangedListener.class, listener); - } - - public void removeLocationChangedListener(ILocationChangedListener listener) { - this._listeners.remove(ILocationChangedListener.class, listener); - } - - public void fireLocationChangedEvent() { - fireLocationChangedEvent(new LocationChangedEvent(this)); - } - - private void fireLocationChangedEvent(LocationChangedEvent event) { - Object[] listeners = _listeners.getListenerList(); - for (int i = 0; i < listeners.length; i = i + 2) { - if (listeners[i] == ILocationChangedListener.class) { - ((ILocationChangedListener) listeners[i + 1]).locationChangedEvent(event); - } - } - } - - public void addSizeChangedListener(ISizeChangedListener listener) { - this._listeners.add(ISizeChangedListener.class, listener); - } - - public void removeSizeChangedListener(ISizeChangedListener listener) { - this._listeners.remove(ISizeChangedListener.class, listener); - } - - public void fireSizeChangedEvent() { - fireSizeChangedEvent(new SizeChangedEvent(this)); - } - - private void fireSizeChangedEvent(SizeChangedEvent event) { - Object[] listeners = _listeners.getListenerList(); - for (int i = 0; i < listeners.length; i = i + 2) { - if (listeners[i] == ISizeChangedListener.class) { - ((ISizeChangedListener) listeners[i + 1]).sizeChangedEvent(event); - } - } - } - // - // - private final EventListenerList _listeners = new EventListenerList(); - protected float x; - protected float y; - protected float width; - protected float height; - protected Color _foreColor; - protected Color _backColor; - private boolean _selected; - private ResizeAbility _resizeAbility; - private boolean _visible = true; - private boolean drawBackColor = false; - // - // - - public ChartElement() { - _foreColor = Color.black; - _backColor = Color.white; - _selected = false; - _resizeAbility = ResizeAbility.None; - } - // - // - - /** - * Get if visible - * - * @return Boolean - */ - public boolean isVisible() { - return _visible; - } - - /** - * Set if visible - * - * @param istrue Boolean - */ - public void setVisible(boolean istrue) { - _visible = istrue; - } - - /** - * Get x - * - * @return x - */ - public float getX() { - return x; - } - - /** - * Set left - * - * @param left - */ - public void setX(float left) { - x = left; - this.fireLocationChangedEvent(); - } - - /** - * Get y - * - * @return Y - */ - public float getY() { - return y; - } - - /** - * Set y - * - * @param top Y - */ - public void setY(float top) { - y = top; - this.fireLocationChangedEvent(); - } - - /** - * Get width - * - * @return Width - */ - public float getWidth() { - return width; - } - - /** - * Set width - * - * @param width Width - */ - public void setWidth(float width) { - this.width = width; - this.fireSizeChangedEvent(); - } - - /** - * Get height - * - * @return Height - */ - public float getHeight() { - return height; - } - - /** - * Set height - * - * @param height Height - */ - public void setHeight(float height) { - this.height = height; - this.fireSizeChangedEvent(); - } - - /** - * Get right - * - * @return Right - */ - public float getRight() { - return x + width; - } - - /** - * Get bottom - * - * @return Bottom - */ - public float getBottom() { - return y + height; - } - - /** - * Get bounds rectangle - * - * @return Bounds rectangle - */ - public Rectangle.Float getBounds() { - return new Rectangle.Float(x, y, width, height); - } - - /** - * Get foreground color - * - * @return Foreground color - */ - public Color getForeground() { - return _foreColor; - } - - /** - * Set foreground color - * - * @param color Foreground color - */ - public void setForeground(Color color) { - _foreColor = color; - } - - /** - * Get background color - * - * @return Background color - */ - public Color getBackground() { - return _backColor; - } - - /** - * Set background color - * - * @param color Background color - */ - public void setBackground(Color color) { - _backColor = color; - } - - /** - * Get if is selected - * - * @return Boolean - */ - public boolean isSelected() { - return _selected; - } - - /** - * Set if is selected - * - * @param istrue Boolean - */ - public void setSelected(boolean istrue) { - _selected = istrue; - } - - /** - * Get resize ability - * - * @return Resize ability - */ - public ResizeAbility getResizeAbility() { - return _resizeAbility; - } - - /** - * Set resize ability - * - * @param ra Resize ability - */ - public void setResizeAbility(ResizeAbility ra) { - _resizeAbility = ra; - } - - /** - * Get is draw backcolor - * @return Boolean - */ - public boolean isDrawBackColor(){ - return drawBackColor; - } - - /** - * Set is draw backcolor - * @param value Boolean - */ - public void setDrawBackColor(boolean value){ - drawBackColor = value; - } - // - // - - /** - * Move update method - */ - public abstract void moveUpdate(); - - /** - * Resize update method - */ - public abstract void resizeUpdate(); - - /** - * Page to screen - * - * @param pageX Page X - * @param pageY Page Y - * @param pageLocation Page location - * @param zoom Zoom - * @return Screen point - */ - public PointF pageToScreen(float pageX, float pageY, PointF pageLocation, float zoom) { - float x = pageX * zoom + pageLocation.X; - float y = pageY * zoom + pageLocation.Y; - return (new PointF(x, y)); - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartLegend.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartLegend.java deleted file mode 100644 index d2b638b3..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartLegend.java +++ /dev/null @@ -1,1436 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.chart; - -import org.meteoinfo.common.DataConvert; -import org.meteoinfo.common.PointF; -import org.meteoinfo.common.XAlign; -import org.meteoinfo.common.YAlign; -import org.meteoinfo.drawing.Draw; -import com.l2fprod.common.beans.BaseBeanInfo; -import com.l2fprod.common.beans.ExtendedPropertyDescriptor; -import com.l2fprod.common.beans.editor.ComboBoxPropertyEditor; -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.geom.AffineTransform; -import java.util.List; -import org.meteoinfo.chart.plot.PlotOrientation; -import org.meteoinfo.geometry.legend.*; - -/** - * - * @author Yaqiang Wang - */ -public class ChartLegend { - // - - //private final XY1DPlot plot; - protected LegendScheme legendScheme; - private LegendPosition position; - protected float shrink; - protected int aspect; - private boolean colorBar; - protected float x; - protected float y; - protected PlotOrientation orientation; - protected Color background; - protected boolean drawBackground; - protected int width; - protected int height; - protected int legendWidth; - protected int legendHeight; - protected ChartText label; - protected String labelLocation; - protected Font tickLabelFont; - protected Color tickLabelColor; - protected float tickLabelAngle; - protected boolean drawNeatLine; - protected Color neatLineColor; - protected float neatLineSize; - private float breakSpace; - private float topSpace; - private float leftSpace; - protected double _vBarWidth; - protected double _hBarHeight; - private int rowColNum = 1; - private boolean autoRowColNum = true; - private Dimension symbolDimension; - protected boolean extendRect; - protected boolean autoExtendFrac; - protected float xshift; - protected float yshift; - // - // - - /** - * Constructor - * - * @param ls LegendScheme - */ - public ChartLegend(LegendScheme ls) { - //this.plot = plot; - this.legendScheme = ls; - this.colorBar = false; - this.position = LegendPosition.LOWER_CENTER_OUTSIDE; - this.orientation = PlotOrientation.HORIZONTAL; - this.shrink = 1.0f; - this.aspect = 20; - this.background = Color.white; - this.drawBackground = false; - drawNeatLine = true; - neatLineColor = Color.black; - neatLineSize = 1; - breakSpace = 3; - topSpace = 5; - leftSpace = 5; - _vBarWidth = 10; - _hBarHeight = 10; - this.labelLocation = "out"; - tickLabelFont = new Font("Arial", Font.PLAIN, 14); - this.tickLabelColor = Color.black; - this.tickLabelAngle = 0; - this.symbolDimension = new Dimension(16, 10); - this.extendRect = true; - this.autoExtendFrac = false; - this.xshift = 0; - this.yshift = 0; - } - - // - // - // - // - /** - * Get legend scheme - * - * @return Legend scheme - */ - public LegendScheme getLegendScheme() { - return this.legendScheme; - } - - /** - * Set legend scheme - * - * @param value Legend scheme - */ - public void setLegendScheme(LegendScheme value) { - this.legendScheme = value; - } - - /** - * Get if is color bar - * - * @return Boolean - */ - public boolean isColorbar() { - return this.colorBar; - } - - /** - * Set if is color bar - * - * @param value Boolean - */ - public void setColorbar(boolean value) { - this.colorBar = value; - } - - /** - * Get legend position - * - * @return Legend position - */ - public LegendPosition getPosition() { - return this.position; - } - - /** - * Set legend position - * - * @param value Legend position - */ - public void setPosition(LegendPosition value) { - this.position = value; - } - - /** - * Get shrink - * - * @return Shrink - */ - public float getShrink() { - return this.shrink; - } - - /** - * Set shrink - * - * @param value Shrink - */ - public void setShrink(float value) { - this.shrink = value; - } - - /** - * Get aspect - * - * @return Aspect - */ - public int getAspect() { - return this.aspect; - } - - /** - * Set aspect - * - * @param value Aspect - */ - public void setAspect(int value) { - this.aspect = value; - } - - /** - * Get X - * - * @return X value - */ - public float getX() { - return this.x; - } - - /** - * Set X - * - * @param value X value - */ - public void setX(float value) { - x = value; - } - - /** - * Get Y - * - * @return Y value - */ - public float getY() { - return this.y; - } - - /** - * Set Y - * - * @param value Y value - */ - public void setY(float value) { - y = value; - } - - /** - * Get width - * - * @return Width - */ - public int getWidth() { - return this.width; - } - - /** - * Set width - * - * @param value Width - */ - public void setWidth(int value) { - this.width = value; - } - - /** - * Get height - * - * @return Height - */ - public int getHeight() { - return this.height; - } - - /** - * Set height - * - * @param value Height - */ - public void setHeight(int value) { - this.height = value; - } - - /** - * Get legend width - * - * @return Legend width - */ - public int getLegendWidth() { - return this.legendWidth; - } - - /** - * Set legend width - * - * @param value Legend width - */ - public void setLegendWidth(int value) { - this.legendWidth = value; - } - - /** - * Get legend height - * - * @return Legend height - */ - public int getLegendHeight() { - return this.legendHeight; - } - - /** - * Set legend height - * - * @param value Legend height - */ - public void setLegendHeight(int value) { - this.legendHeight = value; - } - - /** - * Get plot orientation - * - * @return Plot orientation - */ - public PlotOrientation getPlotOrientation() { - return this.orientation; - } - - /** - * Set plot orientation - * - * @param value Plot orientation - */ - public void setPlotOrientation(PlotOrientation value) { - this.orientation = value; - } - - /** - * Get background - * - * @return Background - */ - public Color getBackground() { - return this.background; - } - - /** - * Set background - * - * @param value Background - */ - public void setBackground(Color value) { - this.background = value; - } - - /** - * Get if draw background - * - * @return Boolean - */ - public boolean isDrawBackground() { - return this.drawBackground; - } - - /** - * Set if draw background - * - * @param value Boolean - */ - public void setDrawBackground(boolean value) { - this.drawBackground = value; - } - - /** - * Get if draw neat line - * - * @return If draw neat line - */ - public boolean isDrawNeatLine() { - return drawNeatLine; - } - - /** - * Set if draw neat line - * - * @param istrue If draw neat line - */ - public void setDrawNeatLine(boolean istrue) { - drawNeatLine = istrue; - } - - /** - * Get neat line color - * - * @return Neat line color - */ - public Color getNeatLineColor() { - return neatLineColor; - } - - /** - * Set neat line color - * - * @param color Neat line color - */ - public void setNeatLineColor(Color color) { - neatLineColor = color; - } - - /** - * Get neat line size - * - * @return Neat line size - */ - public float getNeatLineSize() { - return neatLineSize; - } - - /** - * Set neat line size - * - * @param size Neat line size - */ - public void setNeatLineSize(float size) { - neatLineSize = size; - } - - /** - * Get break space - * @return Break space - */ - public float getBreakSpace() { - return this.breakSpace; - } - - /** - * Set break space - * @param value Break space - */ - public void setBreakSpace(float value) { - this.breakSpace = value; - } - - /** - * Get label - * - * @return Label - */ - public ChartText getLabel() { - return this.label; - } - - /** - * Set label - * - * @param value Label - */ - public void setLabel(ChartText value) { - this.label = value; - } - - /** - * Get label font - * - * @return Label font - */ - public Font getLabelFont() { - return this.label.getFont(); - } - - /** - * Set label font - * - * @param value Label font - */ - public void setLabelFont(Font value) { - this.label.setFont(value); - } - - /** - * Get label color - * - * @return Label color - */ - public Color getLabelColor() { - return this.label.getColor(); - } - - /** - * Set label color - * - * @param value Label color - */ - public void setLabelColor(Color value) { - this.label.setColor(value); - } - - /** - * Get label location (in, out, top, bottom, left, right) - * - * @return Label location - */ - public String getLabelLocation() { - return this.labelLocation; - } - - /** - * Set label location - * - * @param value Label location - */ - public void setLabelLocation(String value) { - this.labelLocation = value; - } - - /** - * Get Tick label font - * - * @return The Tick label font - */ - public Font getTickLabelFont() { - return tickLabelFont; - } - - /** - * Set Tick label font - * - * @param font The Tick label font - */ - public void setTickLabelFont(Font font) { - tickLabelFont = font; - } - - /** - * Get tick label color - * - * @return Tick label color - */ - public Color getTickLabelColor() { - return this.tickLabelColor; - } - - /** - * Set tick label color - * - * @param value Tick label color - */ - public void setTickLabelColor(Color value) { - this.tickLabelColor = value; - } - - /** - * Get tick lable angle - * - * @return Tick label angle - */ - public float getTickLabelAngle() { - return this.tickLabelAngle; - } - - /** - * Set tick label angle - * - * @param value Tick label angle - */ - public void setTickLabelAngle(float value) { - this.tickLabelAngle = value; - } - - /** - * Get column number - * - * @return Column number - */ - public int getColumnNumber() { - return rowColNum; - } - - /** - * Set column number - * - * @param value Column number - */ - public void setColumnNumber(int value) { - rowColNum = value; - } - - /** - * Get if automatic set row/col number - * - * @return Boolean - */ - public boolean isAutoRowColNum() { - return this.autoRowColNum; - } - - /** - * Set if automatic set row/col number - * - * @param value Boolean - */ - public void setAutoRowColNum(boolean value) { - this.autoRowColNum = value; - } - - /** - * Get symbol dimension - * - * @return Symbol dimension - */ - public Dimension getSymbolDimension() { - return this.symbolDimension; - } - - /** - * Set symbol dimension - * - * @param value Symbol dimension - */ - public void setSymbolDimension(Dimension value) { - this.symbolDimension = value; - } - - /** - * Set symbol width - * - * @param value Width - */ - public void setSymbolWidth(int value) { - this.symbolDimension.width = value; - } - - /** - * Set symbol height - * - * @param value height - */ - public void setSymbolHeight(int value) { - this.symbolDimension.height = value; - } - - /** - * Set symbol scale - * - * @param value Symble scale - */ - public void setSymbolScale(float value) { - double w = this.symbolDimension.getWidth() * value; - double h = this.symbolDimension.getHeight() * value; - this.symbolDimension.setSize(w, h); - } - - /** - * Get if extend rectangle - or triangle - * - * @return Boolean - */ - public boolean isExtendRect() { - return this.extendRect; - } - - /** - * Set if extend rectangle - or triangle - * - * @param value Boolean - */ - public void setExtendRect(boolean value) { - this.extendRect = value; - } - - /** - * Get if auto set extend fraction - extend has save width and height Only - * valid for colorbar - * - * @return Boolean - */ - public boolean isAutoExtendFrac() { - return this.autoExtendFrac; - } - - /** - * Set if auto set extend fraction - extend has save width and height Only - * valid for colorbar - * - * @param value - */ - public void setAutoExtendFrac(boolean value) { - this.autoExtendFrac = value; - } - - /** - * Set tick labels - * - * @param value Tick labels - */ - public void setTickCaptions(List value) { - for (int i = 0; i < this.legendScheme.getBreakNum(); i++) { - if (i < value.size()) { - this.legendScheme.getLegendBreaks().get(i).setCaption(value.get(i)); - } else { - break; - } - } - } - - /** - * Get x shift - pixel unit - * - * @return X shift - */ - public float getXShift() { - return this.xshift; - } - - /** - * Set x shift - * - * @param value X shift - */ - public void setXShift(float value) { - this.xshift = value; - } - - /** - * Get y shift - pixel unit - * - * @return Y shift - */ - public float getYShift() { - return this.yshift; - } - - /** - * Set y shift - * - * @param value Y shift - */ - public void setYShift(float value) { - this.yshift = value; - } - - // - // - /** - * Draw legend - * - * @param g Graphics2D - * @param point Start point - */ - public void draw(Graphics2D g, PointF point) { - - AffineTransform oldMatrix = g.getTransform(); - g.translate(point.X + this.xshift, point.Y + this.yshift); - - //Draw background color - if (this.drawBackground) { - g.setColor(this.background); - g.fill(new Rectangle.Float(0, 0, this.width, this.height)); - } - - //Draw legend - g.setStroke(new BasicStroke(1)); - switch (this.orientation) { - case HORIZONTAL: - drawHorizontalLegend(g, legendScheme); - break; - case VERTICAL: - this.drawVerticalLegend(g, legendScheme); - break; - } - - //Draw neatline - if (drawNeatLine) { - Rectangle.Float mapRect = new Rectangle.Float(0, 0, this.width, this.height); - g.setColor(neatLineColor); - g.setStroke(new BasicStroke(neatLineSize)); - g.draw(mapRect); - } - - g.setTransform(oldMatrix); - } - - private void drawVerticalLegend(Graphics2D g, LegendScheme aLS) { - String caption; - float breakHeight = this.getBreakHeight(g); - float symbolHeight = this.symbolDimension.height; - float symbolWidth = this.symbolDimension.width; - float colWidth = symbolWidth + getMaxLabelWidth(g) + 10; - - //Set columns - int[] rowNums = new int[rowColNum]; - int ave = aLS.getVisibleBreakNum() / rowColNum; - if (ave * rowColNum < aLS.getBreakNum()) { - ave += 1; - } - int num = 0; - int i; - for (i = 1; i < rowColNum; i++) { - rowNums[i] = ave; - num += ave; - } - rowNums[0] = aLS.getVisibleBreakNum() - num; - - //Draw title - float y0 = 0; - if (this.label != null) { - float x0 = (float) (this.width / 2.); - y0 += this.breakSpace * 2; - this.label.draw(g, x0, y0); - y0 += this.label.getDimension(g).height + this.breakSpace * 2; - } - - //Draw legend - float x, y; - i = 0; - for (int col = 0; col < rowColNum; col++) { - x = symbolWidth / 2 + leftSpace + col * colWidth; - y = y0 + breakHeight / 2 + breakSpace * 2; - for (int row = 0; row < rowNums[col]; row++) { - if (!aLS.getLegendBreaks().get(i).isDrawShape()) { - continue; - } - - //y += breakHeight + breakSpace; - ColorBreak cb = aLS.getLegendBreaks().get(i); - if (!cb.isDrawShape()) { - continue; - } - caption = aLS.getLegendBreaks().get(i).getCaption(); - if (cb instanceof PointBreak) { - PointBreak aPB = (PointBreak) cb.clone(); - ((PointBreak) aPB).setSize(((PointBreak) cb).getSize() * (symbolHeight / 10.f)); - Draw.drawPoint(new PointF(x, y), aPB, g); - } else if (cb instanceof PolylineBreak) { - PolylineBreak aPLB = (PolylineBreak) cb; - Draw.drawPolylineSymbol_S(new PointF(x, y), symbolWidth, symbolHeight, aPLB, g); - } else if (cb instanceof PolygonBreak) { - Draw.drawPolygonSymbol(new PointF(x, y), symbolWidth, symbolHeight, (PolygonBreak) cb, g); - } else { - PolygonBreak pgb = new PolygonBreak(); - pgb.setColor(cb.getColor()); - pgb.setOutlineColor(Color.black); - Draw.drawPolygonSymbol(new PointF(x, y), symbolWidth, symbolHeight, pgb, g); - } - - PointF sP = new PointF(0, 0); - sP.X = x + symbolWidth / 2; - sP.Y = y; - g.setColor(this.tickLabelColor); - g.setFont(this.tickLabelFont); - Draw.drawString(g, sP.X + 5, sP.Y, caption, XAlign.LEFT, YAlign.CENTER, true); - y += breakHeight + breakSpace; - - i += 1; - } - } - } - - private void drawHorizontalLegend(Graphics2D g, LegendScheme aLS) { - String caption; - float breakHeight = this.getBreakHeight(g); - float symbolHeight = this.symbolDimension.height; - float symbolWidth = this.symbolDimension.width; - - //Set columns - int[] colNums = new int[rowColNum]; - int ave = aLS.getVisibleBreakNum() / rowColNum; - if (ave * rowColNum < aLS.getBreakNum()) { - ave += 1; - } - int num = 0; - int i; - for (i = 0; i < rowColNum - 1; i++) { - colNums[i] = ave; - num += ave; - } - colNums[rowColNum - 1] = aLS.getVisibleBreakNum() - num; - - //Draw legend - float x, y; - y = this.breakSpace + breakHeight / 2; - i = 0; - for (int row = 0; row < rowColNum; row++) { - x = this.symbolDimension.width / 2 + 5; - for (int col = 0; col < colNums[row]; col++) { - if (i >= aLS.getBreakNum()) { - break; - } - - ColorBreak cb = aLS.getLegendBreaks().get(i); - if (!cb.isDrawShape()) { - continue; - } - caption = aLS.getLegendBreaks().get(i).getCaption(); - if (cb instanceof PointBreak) { - PointBreak aPB = (PointBreak) cb; - Draw.drawPoint(new PointF(x, y), aPB, g); - } else if (cb instanceof PolylineBreak) { - PolylineBreak aPLB = (PolylineBreak) cb; - Draw.drawPolylineSymbol_S(new PointF(x, y), symbolWidth, symbolHeight, aPLB, g); - } else if (cb instanceof PolygonBreak) { - Draw.drawPolygonSymbol(new PointF(x, y), symbolWidth, symbolHeight, (PolygonBreak) cb, g); - } - - PointF sP = new PointF(0, 0); - sP.X = x + symbolWidth / 2; - sP.Y = y; - g.setColor(this.tickLabelColor); - g.setFont(this.tickLabelFont); - Draw.drawString(g, sP.X + 5, sP.Y, caption, XAlign.LEFT, YAlign.CENTER, true); - Dimension dim = Draw.getStringDimension(caption, g); - x += this.symbolDimension.width + dim.width + 15; - i += 1; - } - y += breakHeight + this.breakSpace * 2; - } - } - - private int getMaxLabelWidth(Graphics2D g) { - String caption; - Dimension aSF; - int bNum = legendScheme.getBreakNum(); - int labWidth = 0; - g.setFont(this.tickLabelFont); - for (int i = 0; i < bNum; i++) { - caption = legendScheme.getLegendBreaks().get(i).getCaption(); - boolean isValid = true; - if (isValid) { - aSF = Draw.getStringDimension(caption, this.tickLabelAngle, g); - int labwidth = aSF.width; - if (labWidth < labwidth) { - labWidth = labwidth; - } - } - } - - return labWidth; - } - - private int getBreakHeight(Graphics2D g) { - g.setFont(tickLabelFont); - Dimension dim = Draw.getStringDimension(this.legendScheme.getLegendBreak(0).getCaption(), g); - return Math.max(dim.height, this.symbolDimension.height); - } - - /** - * Get legend dimension - * - * @param g Graphics2D - * @param limitDim Limit dimension - * @return Legend dimension - */ - public Dimension getLegendDimension(Graphics2D g, Dimension limitDim) { - if (legendScheme != null) { - if (this.colorBar) { - switch (this.orientation) { - case VERTICAL: - this.width = (int) (this.getTickWidth(g) + limitDim.height * this.shrink / this.aspect + 5); - if (this.label != null) { - g.setFont(this.label.getFont()); - this.width += (int) Draw.getStringDimension(label.getText(), g).height + 5; - } - break; - default: - g.setFont(this.tickLabelFont); - this.height = (int) (Draw.getStringDimension("test", g).height + limitDim.width * this.shrink / this.aspect + 5); - if (this.label != null) { - g.setFont(this.label.getFont()); - Dimension dim = Draw.getStringDimension(label.getText(), g); - switch (this.labelLocation) { - case "top": - case "right": - this.width += dim.width + 10; - break; - default: - this.height += (int) Draw.getStringDimension(label.getText(), g).height + 5; - break; - } - } - } - } else { - int breakHeight = getBreakHeight(g); - int titleHeight = 0; - int titleWidth = 0; - if (this.label != null) { - Dimension dim = this.label.getDimension(g); - titleHeight = dim.height + (int) (this.breakSpace * 4); - titleWidth = dim.width; - } - switch (this.orientation) { - case VERTICAL: - //Get column number - if (this.autoRowColNum) { - int tHeight = (int) (legendScheme.getBreakNum() * (breakHeight + breakSpace) - + breakSpace * 2 + breakHeight / 2 + 5); - rowColNum = 1; - if (tHeight > limitDim.height * 10 / 8) { - rowColNum = tHeight / (limitDim.height * 10 / 8) + 1; - if (rowColNum == 1) { - rowColNum = 2; - } else { - int n = legendScheme.getBreakNum() / rowColNum; - int m = legendScheme.getBreakNum() % rowColNum; - if (m != 0) { - if (m <= n) { - rowColNum += 1; - } else { - rowColNum += 2; - } - } else if (rowColNum * (limitDim.width * 8 / 10) < tHeight) { - rowColNum += 1; - } - } - } - } - - //Get width - int colWidth = this.symbolDimension.width + getMaxLabelWidth(g) + 15; - this.width = colWidth * rowColNum; - - //Get height - int[] rowNums = new int[rowColNum]; - int ave = legendScheme.getBreakNum() / rowColNum; - if (ave * rowColNum < legendScheme.getBreakNum()) { - ave += 1; - } - int num = 0; - int i; - for (i = 0; i < rowColNum - 1; i++) { - rowNums[i] = ave; - num += ave; - } - rowNums[rowColNum - 1] = legendScheme.getBreakNum() - num; - -// this.height = (int) (rowNums[0] * (breakHeight + _breakSpace) -// + _breakSpace * 2 + breakHeight / 2 + 5); - this.height = (int) (rowNums[0] * (breakHeight + breakSpace) - + breakSpace * 3); - break; - case HORIZONTAL: - //Get row number - if (this.autoRowColNum) { - int breakWidth = this.symbolDimension.width + this.getMaxLabelWidth(g) + 15; - int tWidth = breakWidth * legendScheme.getBreakNum(); - rowColNum = 1; - if (tWidth > limitDim.width * 8 / 10) { - rowColNum = tWidth / (limitDim.width * 8 / 10); - if (rowColNum == 1) { - rowColNum = 2; - } else { - int n = legendScheme.getBreakNum() / rowColNum; - int m = legendScheme.getBreakNum() % rowColNum; - if (m != 0) { - if (m <= n) { - rowColNum += 1; - } else { - rowColNum += 2; - } - } else if (rowColNum * (limitDim.width * 8 / 10) < tWidth) { - rowColNum += 1; - } - } - } - } - - //Get height - this.height = (int) (breakHeight + this.breakSpace * 2) * this.rowColNum; - - //Get width - //FontMetrics metrics = g.getFontMetrics(tickFont); - ave = legendScheme.getBreakNum() / rowColNum; - if (ave * rowColNum < legendScheme.getBreakNum()) { - ave += 1; - } - num = 0; - int maxWidth = 0; - int tempWidth = 0; - for (i = 0; i < legendScheme.getBreakNum(); i++) { - if (num < ave) { - //tempWidth += this.symbolDimension.width + 15 - // + metrics.stringWidth(legendScheme.getLegendBreaks().get(i).getCaption()); - tempWidth += this.symbolDimension.width + 15 - + Draw.getStringDimension(legendScheme.getLegendBreaks().get(i).getCaption(), g).width; - num += 1; - } else { - if (maxWidth < tempWidth) { - maxWidth = tempWidth; - } - //tempWidth = metrics.stringWidth(legendScheme.getLegendBreaks().get(i).getCaption()) + 15; - tempWidth = Draw.getStringDimension(legendScheme.getLegendBreaks().get(i).getCaption(), g).width; - num = 1; - } - } - if (maxWidth < tempWidth) { - maxWidth = tempWidth; - } - if (maxWidth > limitDim.width) { - maxWidth = limitDim.width * 8 / 10; - } - this.width = maxWidth; - break; - } - this.height += titleHeight; - this.width = Math.max(this.width, titleWidth); - } - } - - return new Dimension(this.width, this.height); - } - - protected int getTickWidth(Graphics2D g) { - float rwidth = 0; - String caption = ""; - int bNum = this.legendScheme.getBreakNum(); - //FontMetrics metrics = g.getFontMetrics(this.tickFont); - g.setFont(this.tickLabelFont); - if (this.legendScheme.getLegendBreaks().get(bNum - 1).isNoData()) { - bNum -= 1; - } - for (int i = 0; i < bNum; i++) { - switch (this.legendScheme.getShapeType()) { - case Point: - PointBreak aPB = (PointBreak) legendScheme.getLegendBreaks().get(i); - if (legendScheme.getLegendType() == LegendType.GraduatedColor) { - caption = DataConvert.removeTailingZeros(aPB.getEndValue().toString()); - } else { - caption = aPB.getCaption(); - } - break; - case Polyline: - PolylineBreak aPLB = (PolylineBreak) legendScheme.getLegendBreaks().get(i); - if (legendScheme.getLegendType() == LegendType.GraduatedColor) { - caption = DataConvert.removeTailingZeros(aPLB.getEndValue().toString()); - } else { - caption = aPLB.getCaption(); - } - break; - case Polygon: - PolygonBreak aPGB = (PolygonBreak) legendScheme.getLegendBreaks().get(i); - if (legendScheme.getLegendType() == LegendType.GraduatedColor) { - caption = DataConvert.removeTailingZeros(aPGB.getEndValue().toString()); - } else { - caption = aPGB.getCaption(); - } - break; - case Image: - ColorBreak aCB = legendScheme.getLegendBreaks().get(i); - if (legendScheme.getLegendType() == LegendType.GraduatedColor) { - caption = DataConvert.removeTailingZeros(aCB.getEndValue().toString()); - } else { - caption = aCB.getCaption(); - } - break; - } - - boolean isValid = true; - switch (legendScheme.getLegendType()) { - case GraduatedColor: - if (i == bNum - 1) { - isValid = false; - } - break; - } - if (isValid) { - //float labwidth = metrics.stringWidth(caption); - float labwidth = (float) Draw.getStringDimension(caption, this.tickLabelAngle, g).getWidth(); - if (rwidth < labwidth) { - rwidth = labwidth; - } - } - } - - return (int) rwidth; - } - - protected int getTickHeight(Graphics2D g) { - float rheight = 0; - String caption = ""; - int bNum = this.legendScheme.getBreakNum(); - //FontMetrics metrics = g.getFontMetrics(this.tickFont); - g.setFont(this.tickLabelFont); - if (this.legendScheme.getLegendBreaks().get(bNum - 1).isNoData()) { - bNum -= 1; - } - for (int i = 0; i < bNum; i++) { - switch (this.legendScheme.getShapeType()) { - case Point: - PointBreak aPB = (PointBreak) legendScheme.getLegendBreaks().get(i); - if (legendScheme.getLegendType() == LegendType.GraduatedColor) { - caption = DataConvert.removeTailingZeros(aPB.getEndValue().toString()); - } else { - caption = aPB.getCaption(); - } - break; - case Polyline: - PolylineBreak aPLB = (PolylineBreak) legendScheme.getLegendBreaks().get(i); - if (legendScheme.getLegendType() == LegendType.GraduatedColor) { - caption = DataConvert.removeTailingZeros(aPLB.getEndValue().toString()); - } else { - caption = aPLB.getCaption(); - } - break; - case Polygon: - PolygonBreak aPGB = (PolygonBreak) legendScheme.getLegendBreaks().get(i); - if (legendScheme.getLegendType() == LegendType.GraduatedColor) { - caption = DataConvert.removeTailingZeros(aPGB.getEndValue().toString()); - } else { - caption = aPGB.getCaption(); - } - break; - case Image: - ColorBreak aCB = legendScheme.getLegendBreaks().get(i); - if (legendScheme.getLegendType() == LegendType.GraduatedColor) { - caption = DataConvert.removeTailingZeros(aCB.getEndValue().toString()); - } else { - caption = aCB.getCaption(); - } - break; - } - - boolean isValid = true; - switch (legendScheme.getLegendType()) { - case GraduatedColor: - if (i == bNum - 1) { - isValid = false; - } - break; - } - if (isValid) { - float labheight = (float) Draw.getStringDimension(caption, 90 - Math.abs(this.tickLabelAngle), g).getWidth(); - if (rheight < labheight) { - rheight = labheight; - } - } - } - - return (int) rheight; - } - - /** - * Update tick gap - * - * @param g Graphics2D - * @return Ticks gap - */ - protected int getTickGap(Graphics2D g) { - if (this.tickLabelAngle != 0) { - return 1; - } - - double len; - int n = this.legendScheme.getBreakNum(); - int nn; - if (this.orientation == PlotOrientation.HORIZONTAL) { - len = this.width; - int labLen = this.getTickWidth(g); - nn = (int) ((len * 0.8) / labLen); - } else { - len = this.height; - FontMetrics metrics = g.getFontMetrics(tickLabelFont); - nn = (int) (len / metrics.getHeight()); - } - if (nn == 0) { - nn = 1; - } - return n / nn + 1; - } - - // - // - public class LayoutLegendBean { - - LayoutLegendBean() { - } - - // - /** - * Get if draw neat line - * - * @return If draw neat line - */ - public boolean isDrawNeatLine() { - return drawNeatLine; - } - - /** - * Set if draw neat line - * - * @param istrue If draw neat line - */ - public void setDrawNeatLine(boolean istrue) { - drawNeatLine = istrue; - } - - /** - * Get neat line color - * - * @return Neat line color - */ - public Color getNeatLineColor() { - return neatLineColor; - } - - /** - * Set neat line color - * - * @param color Neat line color - */ - public void setNeatLineColor(Color color) { - neatLineColor = color; - } - - /** - * Get neat line size - * - * @return Neat line size - */ - public float getNeatLineSize() { - return neatLineSize; - } - - /** - * Set neat line size - * - * @param size Neat line size - */ - public void setNeatLineSize(float size) { - neatLineSize = size; - } - - /** - * Get tick label font - * - * @return The tick label font - */ - public Font getTickLabelFont() { - return tickLabelFont; - } - - /** - * Set tick label font - * - * @param font The tick label font - */ - public void setTickLabelFont(Font font) { - tickLabelFont = font; - } - - /** - * Get column number - * - * @return Column number - */ - public int getColumnNumber() { - return rowColNum; - } - - /** - * Set column number - * - * @param value Column number - */ - public void setColumnNumber(int value) { - rowColNum = value; - } - - /** - * Get is draw background - * - * @return Boolean - */ - public boolean isDrawBackground() { - return drawBackground; - } - - /** - * Set is draw background - * - * @param value Boolean - */ - public void setDrawBackground(boolean value) { - drawBackground = value; - } - - /** - * Get background color - * - * @return Background color - */ - public Color getBackground() { - return background; - } - - /** - * Set background color - * - * @param c Background color - */ - public void setBackground(Color c) { - background = c; - } - - // - } - - public static class LayoutLegendBeanBeanInfo extends BaseBeanInfo { - - public LayoutLegendBeanBeanInfo() { - super(LayoutLegendBean.class); - ExtendedPropertyDescriptor e = addProperty("plotOrientation"); - e.setCategory("General").setDisplayName("Plot orientation"); - e.setPropertyEditorClass(PlotOrientationEditor.class); - addProperty("tickFont").setCategory("General").setDisplayName("Tick Font"); - addProperty("drawBackground").setCategory("General").setDisplayName("Draw Background"); - addProperty("background").setCategory("General").setDisplayName("Background"); - addProperty("columnNumber").setCategory("General").setDisplayName("Column Number"); - addProperty("drawNeatLine").setCategory("Neat Line").setDisplayName("Draw Neat Line"); - addProperty("neatLineColor").setCategory("Neat Line").setDisplayName("Neat Line Color"); - addProperty("neatLineSize").setCategory("Neat Line").setDisplayName("Neat Line Size"); - } - } - - public static class PlotOrientationEditor extends ComboBoxPropertyEditor { - - public PlotOrientationEditor() { - super(); - PlotOrientation[] orientations = PlotOrientation.values(); - String[] types = new String[orientations.length]; - int i = 0; - for (PlotOrientation type : orientations) { - types[i] = type.toString(); - i += 1; - } - setAvailableValues(types); - } - } - - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartNorthArrow.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartNorthArrow.java deleted file mode 100644 index a6e9813f..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartNorthArrow.java +++ /dev/null @@ -1,298 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.chart; - -import org.meteoinfo.common.PointF; -import org.meteoinfo.drawing.Draw; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; -import org.meteoinfo.chart.plot.MapPlot; -import org.meteoinfo.layout.NorthArrowType; - -/** - * - * @author Yaqiang Wang - */ -public class ChartNorthArrow extends ChartElement { -// - - private MapPlot mapPlot; - private boolean _antiAlias; - private float lineWidth; - private boolean _drawNeatLine; - private Color _neatLineColor; - private float _neatLineSize; - private NorthArrowType _northArrowType; - private float _angle; - // - // - - /** - * Constructor - * - * @param mapPlot The map plot - */ - public ChartNorthArrow(MapPlot mapPlot) { - super(); - - this.setWidth(50); - this.setHeight(50); - - this.mapPlot = mapPlot; - this.lineWidth = 1; - _antiAlias = true; - _drawNeatLine = false; - _neatLineColor = Color.black; - _neatLineSize = 1; - _northArrowType = NorthArrowType.NORTHARROW_1; - _angle = 0; - } - // - // - - /** - * Get map plot - * - * @return The map plot - */ - public MapPlot getMapPlot() { - return this.mapPlot; - } - - /** - * Get line widht - * @return Line width - */ - public float getLineWidth() { - return this.lineWidth; - } - - /** - * Set line width - * @param value Line width - */ - public void setLineWidth(float value) { - this.lineWidth = value; - } - - /** - * Get if draw neat line - * - * @return If draw neat line - */ - public boolean isDrawNeatLine() { - return _drawNeatLine; - } - - /** - * Set if draw neat line - * - * @param istrue If draw neat line - */ - public void setDrawNeatLine(boolean istrue) { - _drawNeatLine = istrue; - } - - /** - * Get neat line color - * - * @return Neat line color - */ - public Color getNeatLineColor() { - return _neatLineColor; - } - - /** - * Set neat line color - * - * @param color Neat line color - */ - public void setNeatLineColor(Color color) { - _neatLineColor = color; - } - - /** - * Get neat line size - * - * @return Neat line size - */ - public float getNeatLineSize() { - return _neatLineSize; - } - - /** - * Set neat line size - * - * @param size Neat line size - */ - public void setNeatLineSize(float size) { - _neatLineSize = size; - } - - /** - * Get angle - * - * @return Angle - */ - public float getAngle() { - return _angle; - } - - /** - * Set angle - * - * @param angle The angle - */ - public void setAngle(float angle) { - _angle = angle; - } - - // - // - /** - * Draw text - * - * @param g Graphics2D - * @param x X - * @param y Y - */ - public void draw(Graphics2D g, float x, float y) { - AffineTransform oldMatrix = g.getTransform(); - g.translate(x, y); - if (_angle != 0) { - g.rotate(_angle); - } - if (_antiAlias) { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - } else { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - } - - //Draw background color - if (this.isDrawBackColor()){ - g.setColor(this.getBackground()); - g.fill(new Rectangle.Float(0, 0, this.getWidth(), this.getHeight())); - } - - drawNorthArrow(g); - - //Draw neatline - if (_drawNeatLine) { - Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1, - (this.getWidth() - _neatLineSize), (this.getHeight() - _neatLineSize)); - g.setColor(_neatLineColor); - g.setStroke(new BasicStroke(_neatLineSize)); - g.draw(mapRect); - } - - g.setTransform(oldMatrix); - } - - /** - * Paint graphics - * - * @param g Graphics - * @param pageLocation Page location - * @param zoom Zoom - */ - public void paintGraphics(Graphics2D g, PointF pageLocation, float zoom) { - AffineTransform oldMatrix = g.getTransform(); - PointF aP = pageToScreen(this.getX(), this.getY(), pageLocation, zoom); - g.translate(aP.X, aP.Y); - g.scale(zoom, zoom); - if (_angle != 0) { - g.rotate(_angle); - } - if (_antiAlias) { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - } else { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - } - - //Draw background color - if (this.isDrawBackColor()){ - g.setColor(this.getBackground()); - g.fill(new Rectangle.Float(0, 0, this.getWidth() * zoom, this.getHeight() * zoom)); - } - - drawNorthArrow(g); - - //Draw neatline - if (_drawNeatLine) { - Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1, - (this.getWidth() - _neatLineSize) * zoom, (this.getHeight() - _neatLineSize) * zoom); - g.setColor(_neatLineColor); - g.setStroke(new BasicStroke(_neatLineSize)); - g.draw(mapRect); - } - - g.setTransform(oldMatrix); - } - - private void drawNorthArrow(Graphics2D g) { - switch (_northArrowType) { - case NORTHARROW_1: - drawNorthArrow1(g); - break; - } - } - - private void drawNorthArrow1(Graphics2D g) { - g.setColor(this.getForeground()); - g.setStroke(new BasicStroke(this.lineWidth)); - - //Draw N symbol - PointF[] points = new PointF[4]; - float x = this.getWidth() / 2; - float y = this.getHeight() / 6; - float w = this.getWidth() / 6; - float h = this.getHeight() / 4; - points[0] = 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[3] = new PointF(x + w / 2, y - h / 2); - Draw.drawPolyline(points, g); - - //Draw arrow - w = this.getWidth() / 2; - h = this.getHeight() * 2 / 3; - points = new PointF[3]; - points[0] = new PointF(x - w / 2, this.getHeight()); - points[1] = new PointF(x, this.getHeight() - h / 2); - points[2] = new PointF(x, this.getHeight() - h); - Draw.fillPolygon(points, g, null); - Draw.drawPolyline(points, g); - - points = new PointF[4]; - points[0] = new PointF(x + w / 2, this.getHeight()); - points[1] = new PointF(x, this.getHeight() - h / 2); - points[2] = new PointF(x, this.getHeight() - h); - points[3] = points[0]; - Draw.drawPolyline(points, g); - } - - @Override - public void moveUpdate() { - } - - @Override - public void resizeUpdate() { - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartPanel.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartPanel.java deleted file mode 100644 index fc59e77f..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartPanel.java +++ /dev/null @@ -1,1689 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -import com.itextpdf.awt.PdfGraphics2D; -import com.itextpdf.text.Document; -import com.itextpdf.text.DocumentException; -import com.itextpdf.text.pdf.PdfContentByte; -import com.itextpdf.text.pdf.PdfTemplate; -import com.itextpdf.text.pdf.PdfWriter; - -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseMotionAdapter; -import java.awt.event.MouseWheelEvent; -import java.awt.event.MouseWheelListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.geom.AffineTransform; -import java.awt.geom.Rectangle2D; -import java.awt.image.AffineTransformOp; -import java.awt.image.BufferedImage; -import java.awt.print.PageFormat; -import java.awt.print.Printable; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.time.Duration; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.imageio.IIOImage; -import javax.imageio.ImageIO; -import javax.imageio.ImageTypeSpecifier; -import javax.imageio.ImageWriteParam; -import javax.imageio.ImageWriter; -import javax.imageio.metadata.IIOInvalidTreeException; -import javax.imageio.metadata.IIOMetadata; -import javax.imageio.plugins.jpeg.JPEGImageWriteParam; -import javax.imageio.stream.FileImageOutputStream; -import javax.imageio.stream.ImageOutputStream; -import javax.print.DocFlavor; -import javax.print.DocPrintJob; -import javax.print.PrintException; -import javax.print.PrintService; -import javax.print.SimpleDoc; -import javax.print.StreamPrintServiceFactory; -import javax.print.attribute.HashPrintRequestAttributeSet; -import javax.print.attribute.PrintRequestAttributeSet; -import javax.swing.JFileChooser; -import javax.swing.JFrame; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.SwingUtilities; -import javax.swing.Timer; -import javax.swing.event.EventListenerList; -import javax.swing.table.DefaultTableModel; -import org.freehep.graphics2d.VectorGraphics; -import org.freehep.graphicsio.emf.EMFGraphics2D; -import org.freehep.graphicsio.pdf.PDFGraphics2D; -import org.freehep.graphicsio.ps.PSGraphics2D; -import org.meteoinfo.chart.plot.MapPlot; -import org.meteoinfo.chart.plot.Plot; -import org.meteoinfo.chart.plot.XY1DPlot; -import org.meteoinfo.chart.plot.AbstractPlot2D; -import org.meteoinfo.chart.plot.Plot3D; -import org.meteoinfo.chart.plot.PlotType; -import org.meteoinfo.chart.plot3d.Projector; -import org.meteoinfo.common.Extent; -import org.meteoinfo.common.GenericFileFilter; -import org.meteoinfo.common.PointF; -import org.meteoinfo.ndarray.DataType; -import org.meteoinfo.image.ImageUtil; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layer.RasterLayer; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.map.FrmIdentifer; -import org.meteoinfo.map.FrmIdentiferGrid; -import org.meteoinfo.map.MapView; -import org.meteoinfo.table.Field; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * - * @author yaqiang - */ -public class ChartPanel extends JPanel implements IChartPanel{ - - // - private final EventListenerList listeners = new EventListenerList(); - private BufferedImage mapBitmap = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB); - private BufferedImage tempImage = null; - private boolean newPaint = false; - private boolean doubleBuffer = true; - private Chart chart; - private Plot currentPlot; - private Dimension chartSize; - private Point mouseDownPoint = new Point(0, 0); - private Point mouseLastPos = new Point(0, 0); - private boolean dragMode = false; - private JPopupMenu popupMenu; - private MouseMode mouseMode; - private List selectedPoints; - private int xShift = 0; - private int yShift = 0; - private double paintScale = 1.0; - private LocalDateTime lastMouseWheelTime; - private Timer mouseWheelDetctionTimer; - // - - // - /** - * Constructor - */ - public ChartPanel() { - super(); - //this.setBackground(Color.white); - this.setBackground(Color.lightGray); - this.setSize(200, 200); - this.addComponentListener(new ComponentAdapter() { - @Override - public void componentResized(ComponentEvent e) { - onComponentResized(e); - } - }); - this.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - onMouseClicked(e); - } - - @Override - public void mousePressed(MouseEvent e) { - onMousePressed(e); - } - - @Override - public void mouseReleased(MouseEvent e) { - onMouseReleased(e); - } - }); - this.addMouseMotionListener(new MouseMotionAdapter() { - @Override - public void mouseMoved(MouseEvent e) { - onMouseMoved(e); - } - - @Override - public void mouseDragged(MouseEvent e) { - onMouseDragged(e); - } - }); - this.addMouseWheelListener(new MouseWheelListener() { - @Override - public void mouseWheelMoved(MouseWheelEvent e) { - onMouseWheelMoved(e); - } - }); - - this.mouseWheelDetctionTimer = new Timer(100, new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - LocalDateTime now = LocalDateTime.now(); - if (Duration.between(lastMouseWheelTime, now).toMillis() > 200) { - xShift = 0; - yShift = 0; - paintScale = 1.0; - //paintGraphics(); - repaintNew(); - mouseWheelDetctionTimer.stop(); - } - } - }); - - popupMenu = new JPopupMenu(); - JMenuItem undoZoom = new JMenuItem("Undo zoom"); - undoZoom.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - onUndoZoomClick(); - } - }); - popupMenu.add(undoZoom); - popupMenu.addSeparator(); - - JMenuItem saveFigure = new JMenuItem("Save figure"); - saveFigure.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - onSaveFigureClick(e); - } - }); - popupMenu.add(saveFigure); - - this.chart = null; - this.mouseMode = MouseMode.DEFAULT; - //this.setMouseMode(mouseMode.ZOOM_IN); - } - - /** - * Constructor - * - * @param chart Chart - */ - public ChartPanel(Chart chart) { - this(); - this.chart = chart; - if (this.chart != null) { - this.chart.setParent(this); - } - } - - /** - * Constructor - * - * @param chart Chart - * @param width Chart width - * @param height Chart height - */ - public ChartPanel(Chart chart, int width, int height) { - this(chart); - this.chartSize = new Dimension(width, height); - this.setPreferredSize(chartSize); - } - - // - // - /** - * Get chart - * - * @return Chart - */ - public Chart getChart() { - return chart; - } - - /** - * Set chart - * - * @param value - */ - public void setChart(Chart value) { - chart = value; - if (this.chart != null) { - chart.setParent(this); - } - } - - /** - * Get if using off screen image double buffering. - * Using double buffering will be faster but lower view quality in - * high dpi screen computer. - * - * @return Boolean - */ - public boolean isDoubleBuffer() { - return this.doubleBuffer; - } - - /** - * Set using off screen image double buffering or not. - * @param value Boolean - */ - public void setDoubleBuffer(boolean value) { - this.doubleBuffer = value; - } - - /** - * Get popup menu - * - * @return Popup menu - */ - public JPopupMenu getPopupMenu() { - return this.popupMenu; - } - - /** - * Get mouse mode - * - * @return Mouse mode - */ - public MouseMode getMouseMode() { - return this.mouseMode; - } - - /** - * Set mouse mode - * - * @param value Mouse mode - */ - @Override - public void setMouseMode(MouseMode value) { - this.mouseMode = value; - Image image; - Toolkit toolkit = Toolkit.getDefaultToolkit(); - Cursor customCursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); - switch (this.mouseMode) { - case SELECT: - customCursor = Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR); - break; - case ZOOM_IN: - image = toolkit.getImage(this.getClass().getResource("/images/zoom_in_32x32x32.png")); - customCursor = toolkit.createCustomCursor(image, new Point(8, 8), "Zoom In"); - break; - case ZOOM_OUT: - image = toolkit.getImage(this.getClass().getResource("/images/zoom_out_32x32x32.png")); - customCursor = toolkit.createCustomCursor(image, new Point(8, 8), "Zoom In"); - break; - case PAN: - image = toolkit.getImage(this.getClass().getResource("/images/Pan_Open_32x32x32.png")); - customCursor = toolkit.createCustomCursor(image, new Point(8, 8), "Pan"); - break; - case IDENTIFER: - image = toolkit.getImage(this.getClass().getResource("/images/identifer_32x32x32.png")); - customCursor = toolkit.createCustomCursor(image, new Point(8, 8), "Identifer"); - break; - case ROTATE: - image = toolkit.getImage(this.getClass().getResource("/images/rotate.png")); - customCursor = toolkit.createCustomCursor(image, new Point(8, 8), "Identifer"); - break; - } - this.setCursor(customCursor); - } - - /** - * Get selected chart points - * - * @return Selected chart points - */ - public List getSelectedPoints() { - return this.selectedPoints; - } - // - - // - public void addPointSelectedListener(IPointSelectedListener listener) { - this.listeners.add(IPointSelectedListener.class, listener); - } - - public void removePointSelectedListener(IPointSelectedListener listener) { - this.listeners.remove(IPointSelectedListener.class, listener); - } - - public void firePointSelectedEvent() { - firePointSelectedEvent(new PointSelectedEvent(this)); - } - - private void firePointSelectedEvent(PointSelectedEvent event) { - Object[] listeners = this.listeners.getListenerList(); - for (int i = 0; i < listeners.length; i = i + 2) { - if (listeners[i] == IPointSelectedListener.class) { - ((IPointSelectedListener) listeners[i + 1]).pointSelectedEvent(event); - } - } - } - // - - // - /** - * Get figure width - * - * @return Figure width - */ - public int getFigureWidth() { - int width; - if (this.chartSize != null) { - width = this.chartSize.width; - } else { - width = this.getWidth(); - } - - return width; - } - - /** - * Get Figure height - * - * @return Figure height - */ - public int getFigureHeight() { - int height; - if (this.chartSize != null) { - height = this.chartSize.height; - } else { - height = this.getHeight(); - } - - return height; - } - - /** - * Select a plot by point - * - * @param x X - * @param y Y - * @return Selected plot - */ - public Plot selPlot(int x, int y) { - if (this.chart == null) { - return null; - } - - int n = this.chart.getPlots().size(); - for (int i = n - 1; i >= 0; i--) { - Plot plot = this.chart.getPlots().get(i); - Rectangle2D rect = plot.getGraphArea(); - if (rect.contains(x, y)) { - return plot; - } - } - return null; - } - - /** - * Paint component - * - * @param g Graphics - */ - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - - if (this.getWidth() < 5 || this.getHeight() < 5) { - return; - } - - //this.setBackground(Color.white); - Graphics2D g2 = (Graphics2D) g; - - if (this.newPaint) { - this.paintGraphics(g2); - } else { - AffineTransform mx = new AffineTransform(); - AffineTransformOp aop = new AffineTransformOp(mx, AffineTransformOp.TYPE_BICUBIC); - g2.drawImage(mapBitmap, aop, 0, 0); - } - - //Draw dynamic graphics - if (this.dragMode) { - switch (this.mouseMode) { - case ZOOM_IN: - case SELECT: - int aWidth = Math.abs(mouseLastPos.x - mouseDownPoint.x); - int aHeight = Math.abs(mouseLastPos.y - mouseDownPoint.y); - int aX = Math.min(mouseLastPos.x, mouseDownPoint.x); - int aY = Math.min(mouseLastPos.y, mouseDownPoint.y); - g2.setColor(this.getForeground()); - float dash1[] = {2.0f}; - g2.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f)); - g2.draw(new Rectangle(aX, aY, aWidth, aHeight)); - break; - } - } - - //Draw identifer shape - if (this.currentPlot != null) { - if (this.currentPlot instanceof MapPlot) { - MapPlot plot = (MapPlot) this.currentPlot; - if (plot.getMapView().isDrawIdentiferShape()) { - if (plot.getSelectedLayer() != null) { - if (plot.getSelectedLayer().getLayerType() == LayerTypes.VectorLayer) { - VectorLayer layer = (VectorLayer) plot.getSelectedLayer(); - Rectangle2D rect = plot.getGraphArea(); - Rectangle rr = new Rectangle((int) rect.getX(), (int) rect.getY(), - (int) rect.getWidth(), (int) rect.getHeight()); - plot.getMapView().drawIdShape(g2, layer.getShapes().get(layer.getIdentiferShape()), rr); - } - } - } - } - } - - g2.dispose(); - } - - /** - * New paint - */ - public void repaintNew() { - if (this.doubleBuffer) { - this.paintGraphics(); - } else { - this.newPaint = true; - this.repaint(); - this.updateViewImage(); - } - } - - private void repaintOld() { - if (this.doubleBuffer) { - this.repaint(); - } else { - this.newPaint = false; - this.repaint(); - } - } - - private void updateViewImage() { - if (this.getWidth() < 5 || this.getHeight() < 5) { - return; - } - - int width, height; - if (this.chartSize != null) { - height = this.chartSize.height; - width = this.chartSize.width; - } else { - width = this.getWidth(); - height = this.getHeight(); - } - - this.mapBitmap = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - Graphics2D g = this.mapBitmap.createGraphics(); - this.print(g); - g.dispose(); - } - - /** - * Paint graphics - */ - @Override - public void paintGraphics() { - if (this.getWidth() < 5 || this.getHeight() < 5) { - return; - } - - int width, height; - if (this.chartSize != null) { - height = this.chartSize.height; - width = this.chartSize.width; - } else { - width = this.getWidth(); - height = this.getHeight(); - } - - this.mapBitmap = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - - if (this.chart != null) { - Graphics2D g = this.mapBitmap.createGraphics(); - Rectangle2D chartArea; - if (this.chartSize == null) { - chartArea = new Rectangle2D.Double(0.0, 0.0, this.mapBitmap.getWidth(), this.mapBitmap.getHeight()); - } else { - chartArea = new Rectangle2D.Double(0.0, 0.0, this.chartSize.width, this.chartSize.height); - } - this.chart.draw(g, chartArea); - } - this.repaint(); - } - - public void paintGraphics(Graphics2D g) { - if (this.chart != null) { - Rectangle2D chartArea; - if (this.chartSize == null) { - chartArea = new Rectangle2D.Double(0.0, 0.0, this.getWidth(), this.getHeight()); - } else { - chartArea = new Rectangle2D.Double(0.0, 0.0, this.chartSize.width, this.chartSize.height); - } - this.chart.draw(g, chartArea); - } - } - - public void paintGraphics(Graphics2D g, int width, int height) { - if (this.chart != null) { - Rectangle2D chartArea; - chartArea = new Rectangle2D.Double(0.0, 0.0, width, height); - this.chart.draw(g, chartArea); - } - } - - void onComponentResized(ComponentEvent e) { - if (this.getWidth() > 0 && this.getHeight() > 0) { - if (this.chart != null) { - //this.paintGraphics(); - this.repaintNew(); - } - } - } - - void onMousePressed(MouseEvent e) { - mouseDownPoint.x = e.getX(); - mouseDownPoint.y = e.getY(); - mouseLastPos = (Point) mouseDownPoint.clone(); - switch (this.mouseMode) { - case PAN: - Plot plot = selPlot(e.getX(), e.getY()); - if (plot != null) { - Rectangle2D mapRect = plot.getGraphArea(); - tempImage = new BufferedImage((int) mapRect.getWidth() - 2, - (int) mapRect.getHeight() - 2, BufferedImage.TYPE_INT_ARGB); - Graphics2D tg = tempImage.createGraphics(); - tg.setColor(Color.white); - tg.fill(mapRect); - tg.drawImage(this.mapBitmap, -(int) mapRect.getX() - 1, -(int) mapRect.getY() - 1, this); - tg.dispose(); - } - break; - } - } - - void onMouseMoved(MouseEvent e) { - this.dragMode = false; -// switch (this.mouseMode) { -// case PAN: -// Plot plot = selPlot(e.getX(), e.getY()); -// if (plot != null) { -// Rectangle2D mapRect = plot.getGraphArea(); -// tempImage = new BufferedImage((int) mapRect.getWidth() - 2, -// (int) mapRect.getHeight() - 2, BufferedImage.TYPE_INT_ARGB); -// Graphics2D tg = tempImage.createGraphics(); -// tg.setColor(Color.white); -// tg.fill(mapRect); -// tg.drawImage(this.mapBitmap, -(int) mapRect.getX() - 1, -(int) mapRect.getY() - 1, this); -// tg.dispose(); -// } -// break; -// } - } - - void onMouseReleased(MouseEvent e) { - this.dragMode = false; - Plot plt = this.chart.findPlot(mouseDownPoint.x, mouseDownPoint.y); - if (!(plt instanceof AbstractPlot2D)) { - return; - } - - AbstractPlot2D xyplot = (AbstractPlot2D) plt; - this.currentPlot = xyplot; - switch (this.mouseMode) { - case ZOOM_IN: - if (Math.abs(mouseLastPos.x - mouseDownPoint.x) > 5) { - if (xyplot instanceof MapPlot) { - MapPlot plot = (MapPlot) xyplot; - Rectangle2D graphArea = xyplot.getGraphArea(); - double[] xy1 = plot.screenToProj(mouseDownPoint.x - graphArea.getX(), mouseDownPoint.y - graphArea.getY(), graphArea); - double[] xy2 = plot.screenToProj(mouseLastPos.x - graphArea.getX(), mouseLastPos.y - graphArea.getY(), graphArea); - Extent extent = new Extent(); - extent.minX = Math.min(xy1[0], xy2[0]); - extent.maxX = Math.max(xy1[0], xy2[0]); - extent.minY = Math.min(xy1[1], xy2[1]); - extent.maxY = Math.max(xy1[1], xy2[1]); - plot.setDrawExtent(extent); - //this.paintGraphics(); - this.repaintNew(); - } else { - Rectangle2D graphArea = xyplot.getGraphArea(); - double[] xy1 = xyplot.screenToProj(mouseDownPoint.x - graphArea.getX(), mouseDownPoint.y - graphArea.getY(), graphArea); - double[] xy2 = xyplot.screenToProj(mouseLastPos.x - graphArea.getX(), mouseLastPos.y - graphArea.getY(), graphArea); - Extent extent = new Extent(); - extent.minX = Math.min(xy1[0], xy2[0]); - extent.maxX = Math.max(xy1[0], xy2[0]); - extent.minY = Math.min(xy1[1], xy2[1]); - extent.maxY = Math.max(xy1[1], xy2[1]); - if (xyplot.getXAxis().isInverse()) { - Extent drawExtent = xyplot.getDrawExtent(); - double minx, maxx; - minx = drawExtent.getWidth() - (extent.maxX - drawExtent.minX) + drawExtent.minX; - maxx = drawExtent.getWidth() - (extent.minX - drawExtent.minX) + drawExtent.minX; - extent.minX = minx; - extent.maxX = maxx; - } - if (xyplot.getYAxis().isInverse()) { - Extent drawExtent = xyplot.getDrawExtent(); - double miny, maxy; - miny = drawExtent.getHeight() - (extent.maxY - drawExtent.minY) + drawExtent.minY; - maxy = drawExtent.getHeight() - (extent.minY - drawExtent.minY) + drawExtent.minY; - extent.minY = miny; - extent.maxY = maxy; - } - xyplot.setDrawExtent(extent); - //this.paintGraphics(); - this.repaintNew(); - } - } - break; - case ZOOM_OUT: - if (e.getButton() == MouseEvent.BUTTON1) { - double zoom = 1.5; - Extent extent = xyplot.getDrawExtent(); - double owidth = extent.getWidth(); - double oheight = extent.getHeight(); - double width = owidth * zoom; - double height = oheight * zoom; - double xshift = (owidth - width) * 0.5; - double yshift = (oheight - height) * 0.5; - extent.minX += xshift; - extent.maxX -= xshift; - extent.minY += yshift; - extent.maxY -= yshift; - xyplot.setDrawExtent(extent); - //this.paintGraphics(); - this.repaintNew(); - } - break; - case SELECT: - if (Math.abs(mouseLastPos.x - mouseDownPoint.x) > 5) { - if (xyplot instanceof XY1DPlot) { - XY1DPlot plot = (XY1DPlot) xyplot; - Rectangle2D graphArea = plot.getGraphArea(); - if (graphArea.contains(mouseDownPoint.x, mouseDownPoint.y) || graphArea.contains(mouseLastPos.x, mouseLastPos.y)) { - double[] xy1 = plot.screenToProj(mouseDownPoint.x - graphArea.getX(), mouseDownPoint.y - graphArea.getY(), graphArea); - double[] xy2 = plot.screenToProj(mouseLastPos.x - graphArea.getX(), mouseLastPos.y - graphArea.getY(), graphArea); - Extent extent = new Extent(); - extent.minX = Math.min(xy1[0], xy2[0]); - extent.maxX = Math.max(xy1[0], xy2[0]); - extent.minY = Math.min(xy1[1], xy2[1]); - extent.maxY = Math.max(xy1[1], xy2[1]); - this.selectedPoints = plot.getDataset().selectPoints(extent); - this.firePointSelectedEvent(); - //this.paintGraphics(); - this.repaintNew(); - } - } - } - break; - case PAN: - if (e.getButton() == MouseEvent.BUTTON1) { - int deltaX = e.getX() - mouseDownPoint.x; - int deltaY = e.getY() - mouseDownPoint.y; - double minX = -deltaX; - double minY = -deltaY; - double maxX = xyplot.getGraphArea().getWidth() - deltaX; - double maxY = xyplot.getGraphArea().getHeight() - deltaY; - xyplot.zoomToExtentScreen(minX, maxX, minY, maxY); - //this.paintGraphics(); - this.repaintNew(); - } - break; - } - } - - void onMouseDragged(MouseEvent e) { - this.dragMode = true; - int x = e.getX(); - int y = e.getY(); - switch (this.mouseMode) { - case ZOOM_IN: - case SELECT: - this.repaintOld(); - break; - case PAN: - Plot plot = selPlot(e.getX(), e.getY()); - if (plot != null) { - Graphics2D g = (Graphics2D) this.getGraphics(); - Rectangle2D mapRect = plot.getGraphArea(); - g.setClip(mapRect); - g.setColor(Color.white); - int aX = e.getX() - mouseDownPoint.x; - int aY = e.getY() - mouseDownPoint.y; - if (aX > 0) { - if (mapRect.getX() >= 0) { - g.fillRect((int) mapRect.getX(), (int) mapRect.getY(), aX, (int) mapRect.getHeight()); - } else { - g.fillRect(0, (int) mapRect.getY(), aX, (int) mapRect.getHeight()); - } - } else if (mapRect.getX() <= this.getWidth()) { - g.fillRect((int) (mapRect.getX() + mapRect.getWidth() + aX), (int) mapRect.getY(), Math.abs(aX), (int) mapRect.getHeight()); - } else { - g.fillRect(this.getWidth() + aX, (int) mapRect.getY(), Math.abs(aX), (int) mapRect.getHeight()); - } - if (aY > 0) { - if (mapRect.getY() >= 0) { - g.fillRect((int) mapRect.getX(), (int) mapRect.getY(), (int) mapRect.getWidth(), aY); - } else { - g.fillRect((int) mapRect.getX(), 0, (int) mapRect.getWidth(), aY); - } - } else if (mapRect.getY() + mapRect.getHeight() <= this.getX() + this.getHeight()) { - g.fillRect((int) mapRect.getX(), (int) mapRect.getY() + (int) mapRect.getHeight() + aY, (int) mapRect.getWidth(), Math.abs(aY)); - } else { - g.fillRect((int) mapRect.getX(), this.getY() + this.getHeight() + aY, (int) mapRect.getWidth(), Math.abs(aY)); - } - int startX = (int) mapRect.getX() + aX; - int startY = (int) mapRect.getY() + aY; - g.drawImage(tempImage, startX, startY, this); - g.setColor(this.getForeground()); - g.draw(mapRect); - } - break; - case ROTATE: - plot = selPlot(this.mouseDownPoint.x, this.mouseDownPoint.y); - if (plot != null && plot.getPlotType() == PlotType.XYZ) { - Plot3D plot3d = (Plot3D) plot; - Projector projector = plot3d.getProjector(); - float new_value = 0.0f; - // if (!thread.isAlive() || !data_available) { - if (e.isControlDown()) { - projector.set2D_xTranslation(projector.get2D_xTranslation() + (x - this.mouseLastPos.x)); - projector.set2D_yTranslation(projector.get2D_yTranslation() + (y - this.mouseLastPos.y)); - } else if (e.isShiftDown()) { - new_value = projector.getY2DScaling() + (y - this.mouseLastPos.y) * 0.5f; - if (new_value > 60.0f) { - new_value = 60.0f; - } - if (new_value < 2.0f) { - new_value = 2.0f; - } - projector.set2DScaling(new_value); - } else { - new_value = projector.getRotationAngle() + (x - this.mouseLastPos.x); - while (new_value > 360) { - new_value -= 360; - } - while (new_value < 0) { - new_value += 360; - } - projector.setRotationAngle(new_value); - new_value = projector.getElevationAngle() + (y - this.mouseLastPos.y); - if (new_value > 90) { - new_value = 90; - } else if (new_value < 0) { - new_value = 0; - } - projector.setElevationAngle(new_value); - } - this.repaintNew(); - //this.paintGraphics(); -// if (!model.isExpectDelay()) { -// repaint(); -// } else { -// if (!dragged) { -// is_data_available = data_available; -// dragged = true; -// } -// data_available = false; -// repaint(); -// } - } - break; - } - mouseLastPos.x = x; - mouseLastPos.y = y; - } - - void onMouseClicked(MouseEvent e) { - int clickTimes = e.getClickCount(); - if (clickTimes == 1) { - if (e.getButton() == MouseEvent.BUTTON1) { - switch (this.mouseMode) { - case IDENTIFER: - Plot plot = selPlot(e.getX(), e.getY()); - if (plot == null) { - return; - } - - if (!(plot instanceof MapPlot)) { - return; - } - - this.currentPlot = plot; - MapPlot mplot = (MapPlot) plot; - final MapView mapView = mplot.getMapView(); - MapLayer aMLayer = mplot.getSelectedLayer(); - if (aMLayer == null) { - return; - } - if (aMLayer.getLayerType() == LayerTypes.ImageLayer) { - return; - } - - Rectangle2D rect = mplot.getGraphArea(); - PointF aPoint = new PointF(e.getX() - (float) rect.getX(), e.getY() - (float) rect.getY()); - if (aMLayer.getLayerType() == LayerTypes.VectorLayer) { - VectorLayer aLayer = (VectorLayer) aMLayer; - List selectedShapes = mapView.selectShapes(aLayer, aPoint, true, false); - if (selectedShapes.size() > 0) { - if (mapView.frmIdentifer == null) { - mapView.frmIdentifer = new FrmIdentifer((JFrame) SwingUtilities.getWindowAncestor(this), false, mapView); - mapView.frmIdentifer.addWindowListener(new WindowAdapter() { - @Override - public void windowClosed(WindowEvent e) { - mapView.setDrawIdentiferShape(false); - ChartPanel.this.repaintOld(); - } - }); - } - String[] colNames = {"Field", "Value"}; - String fieldStr, valueStr; - int shapeIdx = selectedShapes.get(0); - aLayer.setIdentiferShape(shapeIdx); - mapView._drawIdentiferShape = true; - - Object[][] tData = new Object[aLayer.getFieldNumber() + 1][2]; - fieldStr = "Index"; - valueStr = String.valueOf(shapeIdx); - tData[0][0] = fieldStr; - tData[0][1] = valueStr; - Object value; - if (aLayer.getShapeNum() > 0) { - for (int i = 0; i < aLayer.getFieldNumber(); i++) { - Field field = aLayer.getField(i); - fieldStr = field.getColumnName(); - value = aLayer.getCellValue(i, shapeIdx); - if (value == null) { - valueStr = ""; - } else if (field.getDataType() == DataType.DATE) { - DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - valueStr = format.format((LocalDateTime) value); - } else { - valueStr = value.toString(); - } - tData[i + 1][0] = fieldStr; - tData[i + 1][1] = valueStr; - } - } - DefaultTableModel dtm = new javax.swing.table.DefaultTableModel(tData, colNames) { - @Override - public boolean isCellEditable(int row, int column) { - return false; - } - }; - mapView.frmIdentifer.getTable().setModel(dtm); - mapView.frmIdentifer.repaint(); - if (!mapView.frmIdentifer.isVisible()) { - //this._frmIdentifer.setLocation(e.getX(), e.getY()); - mapView.frmIdentifer.setLocationRelativeTo(this); - mapView.frmIdentifer.setVisible(true); - } - - mapView.setDrawIdentiferShape(true); - this.repaintOld(); - } - } else if (aMLayer.getLayerType() == LayerTypes.RasterLayer) { - RasterLayer aRLayer = (RasterLayer) aMLayer; - int[] ijIdx = mapView.selectGridCell(aRLayer, aPoint); - if (ijIdx != null) { - int iIdx = ijIdx[0]; - int jIdx = ijIdx[1]; - double aValue = aRLayer.getCellValue(iIdx, jIdx); - if (mapView._frmIdentiferGrid == null) { - mapView._frmIdentiferGrid = new FrmIdentiferGrid((JFrame) SwingUtilities.getWindowAncestor(this), false); - } - - mapView._frmIdentiferGrid.setIIndex(iIdx); - mapView._frmIdentiferGrid.setJIndex(jIdx); - mapView._frmIdentiferGrid.setCellValue(aValue); - if (!mapView._frmIdentiferGrid.isVisible()) { - //this._frmIdentiferGrid.setLocation(e.getX(), e.getY()); - mapView._frmIdentiferGrid.setLocationRelativeTo(this); - mapView._frmIdentiferGrid.setVisible(true); - } - } - } - break; - } - } else if (e.getButton() == MouseEvent.BUTTON3) { - popupMenu.show(this, e.getX(), e.getY()); - } - } - } - - void onMouseWheelMoved(MouseWheelEvent e) { - Plot plt = selPlot(e.getX(), e.getY()); - if (!(plt instanceof AbstractPlot2D)) { - return; - } - - double minX, maxX, minY, maxY, lonRan, latRan, zoomF; - double mouseLon, mouseLat; - Extent drawExtent = ((AbstractPlot2D) plt).getDrawExtent(); - lonRan = drawExtent.maxX - drawExtent.minX; - latRan = drawExtent.maxY - drawExtent.minY; - mouseLon = drawExtent.minX + lonRan / 2; - mouseLat = drawExtent.minY + latRan / 2; - - zoomF = 1 + e.getWheelRotation() / 10.0f; - - minX = mouseLon - (lonRan / 2 * zoomF); - maxX = mouseLon + (lonRan / 2 * zoomF); - minY = mouseLat - (latRan / 2 * zoomF); - maxY = mouseLat + (latRan / 2 * zoomF); - switch (this.mouseMode) { - case PAN: - if (plt instanceof MapPlot) { - MapPlot mplt = (MapPlot) plt; - Graphics2D g = (Graphics2D) this.getGraphics(); - Rectangle2D mapRect = mplt.getGraphArea(); - - this.lastMouseWheelTime = LocalDateTime.now(); - if (!this.mouseWheelDetctionTimer.isRunning()) { - this.mouseWheelDetctionTimer.start(); - tempImage = new BufferedImage((int) mapRect.getWidth() - 2, - (int) mapRect.getHeight() - 2, BufferedImage.TYPE_INT_ARGB); - Graphics2D tg = tempImage.createGraphics(); - tg.setColor(Color.white); - tg.fill(mapRect); - tg.drawImage(this.mapBitmap, -(int) mapRect.getX() - 1, -(int) mapRect.getY() - 1, this); - tg.dispose(); - } - - g.setClip(mapRect); - g.setColor(Color.white); - //g.clearRect((int)mapRect.getX(), (int)mapRect.getY(), (int)mapRect.getWidth(), (int)mapRect.getHeight()); - paintScale = paintScale / zoomF; - float nWidth = (float)mapRect.getWidth() * (float) paintScale; - float nHeight = (float)mapRect.getHeight() * (float) paintScale; - float nx = ((float)mapRect.getWidth() - nWidth) / 2; - float ny = ((float)mapRect.getHeight() - nHeight) / 2; - if (nx > 0) { - g.fillRect((int) mapRect.getX(), (int) mapRect.getY(), (int)nx, (int) mapRect.getHeight()); - g.fillRect((int) (mapRect.getMaxX() - nx), (int) mapRect.getY(), (int)nx, (int) mapRect.getHeight()); - } - if (ny > 0) { - g.fillRect((int) mapRect.getX(), (int) mapRect.getY(), (int) mapRect.getWidth(), (int)ny); - g.fillRect((int) mapRect.getX(), (int) (mapRect.getMaxY() - ny), (int) mapRect.getWidth(), (int)ny); - } - g.drawImage(tempImage, (int)(mapRect.getX() + nx), (int)(mapRect.getY() + ny), - (int)nWidth, (int)nHeight, null); - g.setColor(this.getForeground()); - g.draw(mapRect); - mplt.setDrawExtent(new Extent(minX, maxX, minY, maxY)); - } else { - ((AbstractPlot2D) plt).setDrawExtent(new Extent(minX, maxX, minY, maxY)); - //this.paintGraphics(); - this.repaintNew(); - } - break; - } - } - - /** - * Zoom back to full extent - */ - @Override - public void onUndoZoomClick() { - AbstractPlot2D xyplot; - if (this.currentPlot == null) { - xyplot = (AbstractPlot2D) this.chart.getPlots().get(0); - } else { - xyplot = (AbstractPlot2D) this.currentPlot; - } - xyplot.setDrawExtent((Extent) xyplot.getExtent().clone()); -// if (xyplot instanceof MapPlot) { -// MapPlot plot = (MapPlot) xyplot; -// plot.setDrawExtent(plot.getMapView().getLastAddedLayer().getExtent()); -// } else { -// xyplot.setAutoExtent(); -// } - //this.paintGraphics(); - this.repaintNew(); - } - - private void onSaveFigureClick(ActionEvent e) { - String path = System.getProperty("user.dir"); - File pathDir = new File(path); - JFileChooser aDlg = new JFileChooser(); - aDlg.setCurrentDirectory(pathDir); - String[] fileExts = new String[]{"png"}; - GenericFileFilter pngFileFilter = new GenericFileFilter(fileExts, "Png Image (*.png)"); - aDlg.addChoosableFileFilter(pngFileFilter); - fileExts = new String[]{"gif"}; - GenericFileFilter mapFileFilter = new GenericFileFilter(fileExts, "Gif Image (*.gif)"); - aDlg.addChoosableFileFilter(mapFileFilter); - fileExts = new String[]{"jpg"}; - mapFileFilter = new GenericFileFilter(fileExts, "Jpeg Image (*.jpg)"); - aDlg.addChoosableFileFilter(mapFileFilter); - fileExts = new String[]{"eps"}; - mapFileFilter = new GenericFileFilter(fileExts, "EPS file (*.eps)"); - aDlg.addChoosableFileFilter(mapFileFilter); - fileExts = new String[]{"pdf"}; - mapFileFilter = new GenericFileFilter(fileExts, "PDF file (*.pdf)"); - aDlg.addChoosableFileFilter(mapFileFilter); - fileExts = new String[]{"emf"}; - mapFileFilter = new GenericFileFilter(fileExts, "EMF file (*.emf)"); - aDlg.addChoosableFileFilter(mapFileFilter); - aDlg.setFileFilter(pngFileFilter); - aDlg.setAcceptAllFileFilterUsed(false); - if (JFileChooser.APPROVE_OPTION == aDlg.showSaveDialog(this)) { - File aFile = aDlg.getSelectedFile(); - System.setProperty("user.dir", aFile.getParent()); - String extent = ((GenericFileFilter) aDlg.getFileFilter()).getFileExtent(); - String fileName = aFile.getAbsolutePath(); - if (!fileName.substring(fileName.length() - extent.length()).equals(extent)) { - fileName = fileName + "." + extent; - } - if (new File(fileName).exists()) { - int overwrite = JOptionPane.showConfirmDialog(this, "File exists! Overwrite it?"); - if (overwrite == JOptionPane.YES_OPTION) { - this.saveImage(fileName); - } - } else { - this.saveImage(fileName); - } - } - } - - /** - * Save image to a picture file - * - * @param aFile File path - */ - @Override - public void saveImage(String aFile) { - try { - saveImage(aFile, null); - } catch (PrintException | IOException | InterruptedException ex) { - Logger.getLogger(ChartPanel.class.getName()).log(Level.SEVERE, null, ex); - } - } - - /** - * Save image to a picture file - * - * @param aFile File path - * @param sleep Sleep seconds for web map layer - * @throws java.io.FileNotFoundException - * @throws javax.print.PrintException - * @throws java.lang.InterruptedException - */ - public void saveImage(String aFile, Integer sleep) throws FileNotFoundException, PrintException, IOException, InterruptedException { - int w, h; - if (this.chartSize == null) { - w = this.getWidth(); - h = this.getHeight(); - } else { - w = this.chartSize.width; - h = this.chartSize.height; - } - this.saveImage(aFile, w, h, sleep); - } - - /** - * Save image to a picture file - * - * @param aFile File path - * @param width Width - * @param height Height - * @param sleep Sleep seconds for web map layer - * @throws java.io.FileNotFoundException - * @throws javax.print.PrintException - * @throws java.lang.InterruptedException - */ - public void saveImage(String aFile, int width, int height, Integer sleep) throws FileNotFoundException, PrintException, IOException, InterruptedException { - if (aFile.endsWith(".ps")) { - DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; - String mimeType = "application/postscript"; - StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, mimeType); - FileOutputStream out = new FileOutputStream(aFile); - if (factories.length > 0) { - PrintService service = factories[0].getPrintService(out); - SimpleDoc doc = new SimpleDoc(new Printable() { - @Override - public int print(Graphics g, PageFormat pf, int page) { - if (page >= 1) { - return Printable.NO_SUCH_PAGE; - } else { - double sf1 = pf.getImageableWidth() / (getWidth() + 1); - double sf2 = pf.getImageableHeight() / (getHeight() + 1); - double s = Math.min(sf1, sf2); - Graphics2D g2 = (Graphics2D) g; - g2.translate((pf.getWidth() - pf.getImageableWidth()) / 2, (pf.getHeight() - pf.getImageableHeight()) / 2); - g2.scale(s, s); - - paintGraphics(g2); - return Printable.PAGE_EXISTS; - } - } - }, flavor, null); - DocPrintJob job = service.createPrintJob(); - PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet(); - job.print(doc, attributes); - out.close(); - } - } else if (aFile.endsWith(".eps")) { - Properties p = new Properties(); - p.setProperty("PageSize", "A5"); - VectorGraphics g = new PSGraphics2D(new File(aFile), new Dimension(width, height)); - //g.setProperties(p); - g.startExport(); - //this.paintGraphics(g); - this.paintGraphics(g, width, height); - g.endExport(); - g.dispose(); - } else if (aFile.endsWith(".pdf")) { - try { - Document document = new Document(new com.itextpdf.text.Rectangle(width, height)); - PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(aFile)); - document.open(); - PdfContentByte cb = writer.getDirectContent(); - PdfTemplate pdfTemp = cb.createTemplate(width, height); - Graphics2D g2 = new PdfGraphics2D(pdfTemp, width, height, true); - this.paintGraphics(g2, width, height); - g2.dispose(); - cb.addTemplate(pdfTemp, 0, 0); - document.close(); - } catch (DocumentException | FileNotFoundException e) { - e.printStackTrace(); - } - } else if (aFile.endsWith(".emf")) { - VectorGraphics g = new EMFGraphics2D(new File(aFile), new Dimension(width, height)); - //g.setProperties(p); - g.startExport(); - //this.paintGraphics(g); - this.paintGraphics(g, width, height); - g.endExport(); - g.dispose(); - } else { - //String extension = aFile.substring(aFile.lastIndexOf('.') + 1); - //ImageIO.write(this.mapBitmap, extension, new File(aFile)); - - String extension = aFile.substring(aFile.lastIndexOf('.') + 1); - BufferedImage aImage; - if (extension.equalsIgnoreCase("bmp")) { - aImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - } else { - aImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - } - Graphics2D g = aImage.createGraphics(); - paintGraphics(g, width, height); - - if (sleep != null) { - Thread.sleep(sleep * 1000); - } - - if (extension.equalsIgnoreCase("jpg")) { - BufferedImage newImage = new BufferedImage(aImage.getWidth(), aImage.getHeight(), BufferedImage.TYPE_INT_RGB); - newImage.createGraphics().drawImage(aImage, 0, 0, Color.BLACK, null); - ImageIO.write(newImage, extension, new File(aFile)); - } else { - ImageIO.write(aImage, extension, new File(aFile)); - } - } - } - - /** - * Save image to a picture file - * - * @param aFile File path - * @param width Width - * @param height Height - * @param sleep Sleep seconds for web map layer - * @throws java.io.FileNotFoundException - * @throws javax.print.PrintException - * @throws java.lang.InterruptedException - */ - public void saveImage_bak(String aFile, int width, int height, Integer sleep) throws FileNotFoundException, PrintException, IOException, InterruptedException { - if (aFile.endsWith(".ps")) { - DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; - String mimeType = "application/postscript"; - StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, mimeType); - FileOutputStream out = new FileOutputStream(aFile); - if (factories.length > 0) { - PrintService service = factories[0].getPrintService(out); - SimpleDoc doc = new SimpleDoc(new Printable() { - @Override - public int print(Graphics g, PageFormat pf, int page) { - if (page >= 1) { - return Printable.NO_SUCH_PAGE; - } else { - double sf1 = pf.getImageableWidth() / (getWidth() + 1); - double sf2 = pf.getImageableHeight() / (getHeight() + 1); - double s = Math.min(sf1, sf2); - Graphics2D g2 = (Graphics2D) g; - g2.translate((pf.getWidth() - pf.getImageableWidth()) / 2, (pf.getHeight() - pf.getImageableHeight()) / 2); - g2.scale(s, s); - - paintGraphics(g2); - return Printable.PAGE_EXISTS; - } - } - }, flavor, null); - DocPrintJob job = service.createPrintJob(); - PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet(); - job.print(doc, attributes); - out.close(); - } - } else if (aFile.endsWith(".eps")) { -// EPSGraphics2D g = new EPSGraphics2D(0.0, 0.0, width, height); -// paintGraphics(g); -// FileOutputStream file = new FileOutputStream(aFile); -// try { -// file.write(g.getBytes()); -// } finally { -// file.close(); -// g.dispose(); -// } - - Properties p = new Properties(); - p.setProperty("PageSize", "A5"); - VectorGraphics g = new PSGraphics2D(new File(aFile), new Dimension(width, height)); - //g.setProperties(p); - g.startExport(); - //this.paintGraphics(g); - this.paintGraphics(g, width, height); - g.endExport(); - g.dispose(); - } else if (aFile.endsWith(".pdf")) { - VectorGraphics g = new PDFGraphics2D(new File(aFile), new Dimension(width, height)); - //g.setProperties(p); - g.startExport(); - this.paintGraphics(g, width, height); - g.endExport(); - g.dispose(); - } else if (aFile.endsWith(".emf")) { - VectorGraphics g = new EMFGraphics2D(new File(aFile), new Dimension(width, height)); - //g.setProperties(p); - g.startExport(); - //this.paintGraphics(g); - this.paintGraphics(g, width, height); - g.endExport(); - g.dispose(); - } else { - //String extension = aFile.substring(aFile.lastIndexOf('.') + 1); - //ImageIO.write(this.mapBitmap, extension, new File(aFile)); - - String extension = aFile.substring(aFile.lastIndexOf('.') + 1); - BufferedImage aImage; - if (extension.equalsIgnoreCase("bmp")) { - aImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - } else { - aImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - } - Graphics2D g = aImage.createGraphics(); - paintGraphics(g, width, height); - - if (sleep != null) { - Thread.sleep(sleep * 1000); - } - - if (extension.equalsIgnoreCase("jpg")) { - BufferedImage newImage = new BufferedImage(aImage.getWidth(), aImage.getHeight(), BufferedImage.TYPE_INT_RGB); - newImage.createGraphics().drawImage(aImage, 0, 0, Color.BLACK, null); - ImageIO.write(newImage, extension, new File(aFile)); - } else { - ImageIO.write(aImage, extension, new File(aFile)); - } - } - } - - /** - * Save image to Jpeg file - * - * @param fileName File name - * @param dpi DPI - * @throws java.io.IOException - */ - public void saveImage_Jpeg_old(String fileName, int dpi) throws IOException { - BufferedImage image = this.mapBitmap; - Iterator i = ImageIO.getImageWritersByFormatName("jpeg"); - //are there any jpeg encoders available? - - if (i.hasNext()) //there's at least one ImageWriter, just use the first one - { - ImageWriter imageWriter = (ImageWriter) i.next(); - //get the param - ImageWriteParam param = imageWriter.getDefaultWriteParam(); - ImageTypeSpecifier its = new ImageTypeSpecifier(image.getColorModel(), image.getSampleModel()); - - //get metadata - IIOMetadata iomd = imageWriter.getDefaultImageMetadata(its, - param); - - String formatName = "javax_imageio_jpeg_image_1.0";//this is the DOCTYPE of the metadata we need - - Node node = iomd.getAsTree(formatName); - //what are child nodes? - NodeList nl = node.getChildNodes(); - for (int j = 0; j < nl.getLength(); j++) { - Node n = nl.item(j); - System.out.println("node from IOMetadata is : " - + n.getNodeName()); - - if (n.getNodeName().equals("JPEGvariety")) { - NodeList childNodes = n.getChildNodes(); - - for (int k = 0; k < childNodes.getLength(); k++) { - System.out.println("node #" + k + " is " - + childNodes.item(k).getNodeName()); - if (childNodes.item(k).getNodeName().equals("app0JFIF")) { - NamedNodeMap nnm = childNodes.item(k).getAttributes(); - //get the resUnits, Xdensity, and Ydensity attribuutes - Node resUnitsNode = getAttributeByName(childNodes.item(k), "resUnits"); - Node XdensityNode = getAttributeByName(childNodes.item(k), "Xdensity"); - Node YdensityNode = getAttributeByName(childNodes.item(k), "Ydensity"); - - //reset values for nodes - resUnitsNode.setNodeValue("1"); //indicate DPI mode - XdensityNode.setNodeValue(String.valueOf(dpi)); - YdensityNode.setNodeValue(String.valueOf(dpi)); - - System.out.println("name=" - + resUnitsNode.getNodeName() + ", value=" + resUnitsNode.getNodeValue()); - System.out.println("name=" - + XdensityNode.getNodeName() + ", value=" + XdensityNode.getNodeValue()); - System.out.println("name=" - + YdensityNode.getNodeName() + ", value=" + YdensityNode.getNodeValue()); - - } //end if (childNodes.item(k).getNodeName().equals("app0JFIF")) - } //end if (n.getNodeName().equals("JPEGvariety") - break; //we don't care about the rest of the children - } //end if (n.getNodeName().equals("JPEGvariety")) - - } //end for (int j = 0; j < nl.getLength(); j++) - - try { - iomd.setFromTree(formatName, node); - } catch (IIOInvalidTreeException e) { - e.printStackTrace(); //To change body of catch statement use Options | File Templates. - } - //attach the metadata to an image - IIOImage iioimage = new IIOImage(image, null, iomd); - FileImageOutputStream stream = new FileImageOutputStream(new File(fileName)); - try { - imageWriter.setOutput(stream); - imageWriter.write(iioimage); - } catch (IOException e) { - e.printStackTrace(); - } finally { - stream.close(); - } - } //end if (i.hasNext()) //there's at least one ImageWriter, just use the first one - } - - /** - * @param node - * @param attributeName - name of child node to return - * @return Node - */ - private Node getAttributeByName(Node node, String attributeName) { - if (node == null) { - return null; - } - NamedNodeMap nnm = node.getAttributes(); - for (int i = 0; i < nnm.getLength(); i++) { - Node n = nnm.item(i); - if (n.getNodeName().equals(attributeName)) { - return n; - } - } - return null; // no such attribute was found - } - - public boolean saveImage_Jpeg(String file, int dpi) { - int w, h; - if (this.chartSize == null) { - w = this.getWidth(); - h = this.getHeight(); - } else { - w = this.chartSize.width; - h = this.chartSize.height; - } - return this.saveImage_Jpeg(file, w, h, dpi); - } - - public boolean saveImage_Jpeg(String file, int width, int height, int dpi) { - double scaleFactor = dpi / 72.0; - BufferedImage bufferedImage = new BufferedImage((int)(width * scaleFactor), (int)(height * scaleFactor), BufferedImage.TYPE_INT_RGB); - Graphics2D g = bufferedImage.createGraphics(); - AffineTransform at = g.getTransform(); - at.scale(scaleFactor, scaleFactor); - g.setTransform(at); - paintGraphics(g, width, height); - - try { - // Image writer - ImageWriter imageWriter = ImageIO.getImageWritersBySuffix("jpeg").next(); - ImageOutputStream ios = ImageIO.createImageOutputStream(new File(file)); - imageWriter.setOutput(ios); - - // Compression - JPEGImageWriteParam jpegParams = (JPEGImageWriteParam) imageWriter.getDefaultWriteParam(); - jpegParams.setCompressionMode(JPEGImageWriteParam.MODE_EXPLICIT); - jpegParams.setCompressionQuality(0.85f); - - // Metadata (dpi) - IIOMetadata data = imageWriter.getDefaultImageMetadata(new ImageTypeSpecifier(bufferedImage), jpegParams); - Element tree = (Element) data.getAsTree("javax_imageio_jpeg_image_1.0"); - Element jfif = (Element) tree.getElementsByTagName("app0JFIF").item(0); - jfif.setAttribute("Xdensity", Integer.toString(dpi)); - jfif.setAttribute("Ydensity", Integer.toString(dpi)); - jfif.setAttribute("resUnits", "1"); // density is dots per inch - data.setFromTree("javax_imageio_jpeg_image_1.0", tree); - - // Write and clean up - imageWriter.write(null, new IIOImage(bufferedImage, null, data), jpegParams); - ios.close(); - imageWriter.dispose(); - } catch (Exception e) { - return false; - } - g.dispose(); - - return true; - } - - /** - * Save image - * - * @param fileName File name - * @param dpi DPI - * @throws IOException - * @throws java.lang.InterruptedException - */ - public void saveImage(String fileName, int dpi) throws IOException, InterruptedException { - saveImage(fileName, dpi, null); - } - - /** - * Save image - * - * @param fileName File name - * @param dpi DPI - * @param sleep Sleep seconds for web map layer - * @throws IOException - * @throws java.lang.InterruptedException - */ - public void saveImage(String fileName, int dpi, Integer sleep) throws IOException, InterruptedException { - int width, height; - if (this.chartSize != null) { - height = this.chartSize.height; - width = this.chartSize.width; - } else { - width = this.getWidth(); - height = this.getHeight(); - } - - this.saveImage(fileName,dpi, width, height, sleep); - } - - /** - * Save image - * - * @param fileName File name - * @param dpi DPI - * @param width Width - * @param height Height - * @param sleep Sleep seconds for web map layer - * @throws IOException - * @throws java.lang.InterruptedException - */ - public void saveImage(String fileName, int dpi, int width, int height, Integer sleep) throws IOException, InterruptedException { - File output = new File(fileName); - output.delete(); - - String formatName = fileName.substring(fileName.lastIndexOf('.') + 1); - if (formatName.equals("jpg")) { - formatName = "jpeg"; - saveImage_Jpeg(fileName, width, height, dpi); - return; - } - - double scaleFactor = dpi / 72.0; - BufferedImage image = new BufferedImage((int)(width * scaleFactor), (int)(height * scaleFactor), BufferedImage.TYPE_INT_ARGB); - Graphics2D g = image.createGraphics(); - AffineTransform at = g.getTransform(); - at.scale(scaleFactor, scaleFactor); - g.setTransform(at); - paintGraphics(g, width, height); - for (Iterator iw = ImageIO.getImageWritersByFormatName(formatName); iw.hasNext();) { - ImageWriter writer = iw.next(); - ImageWriteParam writeParam = writer.getDefaultWriteParam(); - ImageTypeSpecifier typeSpecifier = ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_ARGB); - IIOMetadata metadata = writer.getDefaultImageMetadata(typeSpecifier, writeParam); - if (metadata == null) { - metadata = writer.getDefaultImageMetadata(typeSpecifier, null); - } - if (metadata.isReadOnly() || !metadata.isStandardMetadataFormatSupported()) { - continue; - } - - ImageUtil.setDPI(metadata, dpi); - - if (sleep != null) { - Thread.sleep(sleep * 1000); - } - final ImageOutputStream stream = ImageIO.createImageOutputStream(output); - try { - writer.setOutput(stream); - writer.write(metadata, new IIOImage(image, null, metadata), writeParam); - } finally { - stream.close(); - } - break; - } - g.dispose(); - } - - /** - * Get view image - * - * @return View image - */ - public BufferedImage getViewImage() { - return this.mapBitmap; - } - - /** - * Paint view image - * - * @return View image - */ - public BufferedImage paintViewImage() { - int w, h; - if (this.chartSize == null) { - w = this.getWidth(); - h = this.getHeight(); - } else { - w = this.chartSize.width; - h = this.chartSize.height; - } - return paintViewImage(w, h); - } - - /** - * Paint view image - * - * @param width Image width - * @param height Image height - * @return View image - */ - public BufferedImage paintViewImage(int width, int height) { - BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - Graphics2D g = image.createGraphics(); - paintGraphics(g); - - return image; - } - - /** - * Paint view image - * - * @param dpi Image resolution - * @return View image - */ - public BufferedImage paintViewImage(int dpi) { - int w, h; - if (this.chartSize == null) { - w = this.getWidth(); - h = this.getHeight(); - } else { - w = this.chartSize.width; - h = this.chartSize.height; - } - return paintViewImage(w, h, dpi); - } - - /** - * Paint view image - * - * @param width Image width - * @param height Image height - * @param dpi Image resolution - * @return View image - */ - public BufferedImage paintViewImage(int width, int height, int dpi) { - double scaleFactor = dpi / 72.0; - BufferedImage image = new BufferedImage((int)(width * scaleFactor), (int)(height * scaleFactor), - BufferedImage.TYPE_INT_ARGB); - Graphics2D g = image.createGraphics(); - AffineTransform at = g.getTransform(); - at.scale(scaleFactor, scaleFactor); - g.setTransform(at); - paintGraphics(g, width, height); - - return image; - } - - /** - * Check if has web map layer - * - * @return Boolean - */ - public boolean hasWebMap() { - if (this.chart != null) { - return this.chart.hasWebMap(); - } - - return false; - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartScaleBar.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartScaleBar.java deleted file mode 100644 index 4e813f5d..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartScaleBar.java +++ /dev/null @@ -1,457 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; -import java.awt.geom.Line2D; -import org.meteoinfo.chart.plot.MapPlot; -import org.meteoinfo.common.PointF; -import org.meteoinfo.layout.ScaleBarType; -import org.meteoinfo.layout.ScaleBarUnits; - -/** - * - * @author Yaqiang Wang - */ -public class ChartScaleBar extends ChartElement { - // - - private MapPlot mapPlot; - private boolean _antiAlias; - private float lineWidth; - private Font _font; - private ScaleBarType _scaleBarType; - private ScaleBarUnits _unit; - private String _unitText; - private int _numBreaks; - private boolean _drawNeatLine; - private Color _neatLineColor; - private float _neatLineSize; - private boolean _drawScaleText; - private float _yShiftScale = 2.0f; - // - // - - /** - * Constructor - * - * @param mapPlot The map plot - */ - public ChartScaleBar(MapPlot mapPlot) { - super(); - //this.setElementType(ElementType.LayoutScaleBar); - //this.setResizeAbility(ResizeAbility.ResizeAll); - - this.width = 200; - this.height = 50; - this.mapPlot = mapPlot; - _antiAlias = true; - _scaleBarType = ScaleBarType.SCALELINE_1; - lineWidth = 1; - _drawNeatLine = false; - _neatLineColor = Color.black; - _neatLineSize = 1; - _font = new Font("Arial", Font.PLAIN, 12); - _unit = ScaleBarUnits.KILOMETERS; - _unitText = "km"; - _numBreaks = 4; - _drawScaleText = false; - } - // - // - - /** - * Get map plot - * - * @return The map plot - */ - public MapPlot getMapPlot() { - return mapPlot; - } - - /** - * Get line widht - * @return Line width - */ - public float getLineWidth() { - return this.lineWidth; - } - - /** - * Set line width - * @param value Line width - */ - public void setLineWidth(float value) { - this.lineWidth = value; - } - - /** - * Get scale bar type - * - * @return Scale bar type - */ - public ScaleBarType getScaleBarType() { - return _scaleBarType; - } - - /** - * Set scale bar type - * - * @param type Scale bar type - */ - public void setScaleBarType(ScaleBarType type) { - _scaleBarType = type; - } - - /** - * Get if draw neat line - * - * @return If draw neat line - */ - public boolean isDrawNeatLine() { - return _drawNeatLine; - } - - /** - * Set if draw neat line - * - * @param istrue If draw neat line - */ - public void setDrawNeatLine(boolean istrue) { - _drawNeatLine = istrue; - } - - /** - * Get neat line color - * - * @return Neat line color - */ - public Color getNeatLineColor() { - return _neatLineColor; - } - - /** - * Set neat line color - * - * @param color Neat line color - */ - public void setNeatLineColor(Color color) { - _neatLineColor = color; - } - - /** - * Get neat line size - * - * @return Neat line size - */ - public float getNeatLineSize() { - return _neatLineSize; - } - - /** - * Set neat line size - * - * @param size Neat line size - */ - public void setNeatLineSize(float size) { - _neatLineSize = size; - } - - /** - * Get font - * - * @return The font - */ - public Font getFont() { - return _font; - } - - /** - * Set font - * - * @param font The font - */ - public void setFont(Font font) { - _font = font; - } - - /** - * Get break number - * - * @return The break number - */ - public int getBreakNumber() { - return _numBreaks; - } - - /** - * Set break number - * - * @param num Break number - */ - public void setBreakNumber(int num) { - _numBreaks = num; - } - - /** - * Get if draw scale text - * - * @return If draw scale text - */ - public boolean isDrawScaleText() { - return _drawScaleText; - } - - /** - * Set if draw scale text - * - * @param istrue If draw scale text - */ - public void setDrawScaleText(boolean istrue) { - _drawScaleText = istrue; - } - // - // - /** - * Draw text - * - * @param g Graphics2D - * @param x X - * @param y Y - */ - public void draw(Graphics2D g, float x, float y) { - AffineTransform oldMatrix = g.getTransform(); - g.translate(x, y); - if (_antiAlias) { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - } else { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - } - - //Draw background color - if (this.isDrawBackColor()){ - g.setColor(this.getBackground()); - g.fill(new Rectangle.Float(0, 0, this.getWidth(), this.getHeight())); - } - - drawScaleBar(g); - - //Draw neatline - if (_drawNeatLine) { - Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1, - (this.getWidth() - _neatLineSize), (this.getHeight() - _neatLineSize)); - g.setColor(_neatLineColor); - g.setStroke(new BasicStroke(_neatLineSize)); - g.draw(mapRect); - } - - g.setTransform(oldMatrix); - } - - /** - * Paint graphics - * - * @param g Graphics - * @param pageLocation Page location - * @param zoom Zoom - */ - public void paintGraphics(Graphics2D g, PointF pageLocation) { - AffineTransform oldMatrix = g.getTransform(); - PointF aP = pageToScreen(this.getX(), this.getY(), pageLocation, 1); - g.translate(aP.X, aP.Y); - if (_antiAlias) { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - } else { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - } - - //Draw background color - if (this.isDrawBackColor()){ - g.setColor(this.getBackground()); - g.fill(new Rectangle.Float(0, 0, this.getWidth(), this.getHeight())); - } - - drawScaleBar(g); - - //Draw neatline - if (_drawNeatLine) { - Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1, - (this.getWidth() - _neatLineSize), (this.getHeight() - _neatLineSize)); - g.setColor(_neatLineColor); - g.setStroke(new BasicStroke(_neatLineSize)); - g.draw(mapRect); - } - - g.setTransform(oldMatrix); - } - - private void drawScaleBar(Graphics2D g) { - //Calculates the width of one break in greographic units - FontMetrics metrics = g.getFontMetrics(this._font); - float unitLegnth = metrics.stringWidth(_unitText) * 2; - float widthNoUnit = (this.getWidth() - unitLegnth); - long geoBreakWidth = (long) (getGeoWidth(widthNoUnit / _numBreaks)); - - //If the geobreakWidth is less than 1 we return and don't draw anything - if (geoBreakWidth < 1) { - return; - } - - double n = Math.pow(10, String.valueOf(geoBreakWidth).length() - 1); - geoBreakWidth = (long) (Math.floor(geoBreakWidth / n) * n); - - long breakWidth = (long) (getWidth(geoBreakWidth)); - FontMetrics metrics1 = g.getFontMetrics(_font); - float fontHeight = metrics1.getHeight(); - float leftStart = metrics1.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F; - - //Draw scale text - double scale = geoBreakWidth * getConversionFactor(_unit) * 100 / (breakWidth / 96 * 2.539999918); - if (_drawScaleText) { - g.setFont(this._font); - g.setColor(this.getForeground()); - g.drawString("1 : " + String.format("{0:0,0}", scale), - leftStart - (metrics.stringWidth(String.valueOf(Math.abs(0))) / 2), fontHeight * 2.5F); - } - - //Draw scale bar - switch (_scaleBarType) { - case SCALELINE_1: - drawScaleLine1(g, breakWidth, geoBreakWidth); - break; - case SCALELINE_2: - drawScaleLine2(g, breakWidth, geoBreakWidth); - break; - case ALTERNATING_BAR: - drawAlternatingBar(g, breakWidth, geoBreakWidth); - break; - } - } - - private double getConversionFactor(ScaleBarUnits unit) { - switch (unit) { - case KILOMETERS: - return 1000; - default: - return 1; - } - } - - private double getGeoWidth(double width) { - double geoWidth = width / mapPlot.getMapFrame().getMapView().getXScale() / getConversionFactor(_unit); - if (mapPlot.getMapFrame().getMapView().getProjection().isLonLatMap()) { - geoWidth = geoWidth * getLonDistScale(); - } - - return geoWidth; - } - - private double getWidth(double geoWidth) { - double width = geoWidth * mapPlot.getMapFrame().getMapView().getXScale() * getConversionFactor(_unit); - if (mapPlot.getMapFrame().getMapView().getProjection().isLonLatMap()) { - width = width / getLonDistScale(); - } - - return width; - } - - private double getLonDistScale() { - //Get meters of one longitude degree - double pY = (mapPlot.getMapFrame().getMapView().getViewExtent().maxY + mapPlot.getMapFrame().getMapView().getViewExtent().minY) / 2; - double ProjX = 0, ProjY = pY, pProjX = 1, pProjY = pY; - double dx = Math.abs(ProjX - pProjX); - double dy = Math.abs(ProjY - pProjY); - double dist; - double y = (ProjY + pProjY) / 2; - double factor = Math.cos(y * Math.PI / 180); - dx *= factor; - dist = Math.sqrt(dx * dx + dy * dy); - dist = dist * 111319.5; - - return dist; - } - - private void drawScaleLine1(Graphics2D g, long breakWidth, long geoBreakWidth) { - FontMetrics metrics = g.getFontMetrics(_font); - float fontHeight = metrics.getHeight(); - float leftStart = metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F; - int yShift = 10; - - g.setColor(this.getForeground()); - g.setStroke(new BasicStroke(this.lineWidth)); - g.draw(new Line2D.Float(leftStart, fontHeight * 1.6f + yShift, leftStart + (breakWidth * _numBreaks), fontHeight * 1.6f + yShift)); - g.setFont(this._font); - for (int i = 0; i <= _numBreaks; i++) { - g.draw(new Line2D.Float(leftStart, fontHeight * 1.1f + yShift, leftStart, fontHeight * 1.6f + yShift)); - g.drawString(String.valueOf(Math.abs(geoBreakWidth * i)), - leftStart - (metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth * i))) / 2), yShift * _yShiftScale); - leftStart = leftStart + breakWidth; - } - g.drawString(_unitText, leftStart - breakWidth + (fontHeight / 2), fontHeight * 1.1f + yShift * _yShiftScale); - } - - private void drawScaleLine2(Graphics2D g, long breakWidth, long geoBreakWidth) { - FontMetrics metrics = g.getFontMetrics(_font); - float fontHeight = metrics.getHeight(); - float leftStart = metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F; - int yShift = 5; - - g.setColor(this.getForeground()); - g.setStroke(new BasicStroke(this.lineWidth)); - g.draw(new Line2D.Float(leftStart, fontHeight * 1.6f + yShift, leftStart + (breakWidth * _numBreaks), fontHeight * 1.6f + yShift)); - g.setFont(this._font); - for (int i = 0; i <= _numBreaks; i++) { - g.draw(new Line2D.Float(leftStart, fontHeight * 1.1f + yShift, leftStart, fontHeight + (fontHeight * 1.1f) + yShift)); - g.drawString(String.valueOf(Math.abs(geoBreakWidth * i)), - leftStart - (metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth * i))) / 2), yShift * _yShiftScale); - leftStart = leftStart + breakWidth; - } - g.drawString(_unitText, leftStart - breakWidth + (fontHeight / 2), fontHeight * 1.1f + yShift * _yShiftScale); - } - - private void drawAlternatingBar(Graphics2D g, long breakWidth, long geoBreakWidth) { - FontMetrics metrics = g.getFontMetrics(_font); - float fontHeight = metrics.getHeight(); - float leftStart = metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F; - int yShift = 5; - float rHeight = fontHeight / 2; - - boolean isFill = false; - g.setStroke(new BasicStroke(this.lineWidth)); - g.setColor(this.getForeground()); - g.setFont(this._font); - for (int i = 0; i <= _numBreaks; i++) { - if (i < _numBreaks) { - if (isFill) { - g.fill(new Rectangle.Float(leftStart, fontHeight * 1.1f + yShift, breakWidth, rHeight)); - } - g.draw(new Rectangle.Float(leftStart, fontHeight * 1.1f + yShift, breakWidth, rHeight)); - } - g.drawString(String.valueOf(Math.abs(geoBreakWidth * i)), - leftStart - (metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth * i))) / 2), yShift * _yShiftScale); - leftStart = leftStart + breakWidth; - isFill = !isFill; - } - g.setColor(this.getForeground()); - g.drawString(_unitText, leftStart - breakWidth + (fontHeight / 2), fontHeight * 1.1f + yShift * _yShiftScale); - } - - @Override - public void moveUpdate() { - } - - @Override - public void resizeUpdate() { - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartText.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartText.java deleted file mode 100644 index ac0fdcf3..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartText.java +++ /dev/null @@ -1,741 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.Stroke; -import java.awt.geom.AffineTransform; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.meteoinfo.common.Extent; -import org.meteoinfo.common.XAlign; -import org.meteoinfo.common.YAlign; -import org.meteoinfo.drawing.Draw; -import org.locationtech.jts.geom.Geometry; -import org.locationtech.jts.geom.GeometryFactory; -import org.meteoinfo.geometry.shape.Shape; -import org.meteoinfo.geometry.shape.ShapeTypes; - -/** - * - * @author yaqiang - */ -public class ChartText extends Shape { - - // - protected double x; - protected double y; - private Font font; - private List text; - private Color color; - private int lineSpace; - private CoordinateType coordinates; - private Color background; - private boolean drawBackground; - private boolean drawNeatline; - private Color neatLineColor; - private float neatLineSize; - private float gap; - protected float angle; - private XAlign xAlign; - private YAlign yAlign; - private boolean useExternalFont; - protected double xShift; - protected double yShift; - - // - // - /** - * Constructor - */ - public ChartText() { - font = new Font("Arial", Font.PLAIN, 14); - color = Color.black; - lineSpace = 5; - coordinates = CoordinateType.DATA; - this.background = Color.white; - this.drawBackground = false; - this.drawNeatline = false; - this.neatLineColor = Color.black; - this.neatLineSize = 1.0f; - this.gap = 3.0f; - this.angle = 0.0f; - this.xAlign = XAlign.LEFT; - this.yAlign = YAlign.BOTTOM; - this.useExternalFont = false; - this.xShift = 0; - this.yShift = 0; - } - - /** - * Constructor - * - * @param text Text - */ - public ChartText(String text) { - this(); - this.text = new ArrayList<>(); - String[] lines = text.split("\n"); - this.text.addAll(Arrays.asList(lines)); - } - - /** - * Constructor - * - * @param text Text - */ - public ChartText(List text) { - this(); - this.text = text; - } - - /** - * Constructor - * - * @param text Text - * @param font Font - */ - public ChartText(String text, Font font) { - this(); - this.text = new ArrayList<>(); - String[] lines = text.split("\n"); - this.text.addAll(Arrays.asList(lines)); - this.font = font; - } - - /** - * Constructor - * - * @param text Text - * @param font Font - */ - public ChartText(List text, Font font) { - this(); - this.text = text; - this.font = font; - } - // - // - - /** - * Get text - * - * @return Text - */ - public String getText() { - return text.get(0); - } - - /** - * Set text - * - * @param value Text - */ - public void setText(String value) { - text = new ArrayList<>(); - String[] lines = value.split("\n"); - this.text.addAll(Arrays.asList(lines)); - } - - /** - * Get texts - * - * @return Text list - */ - public List getTexts() { - return text; - } - - /** - * Set texts - * - * @param value Text list - */ - public void setTexts(List value) { - text = value; - } - - /** - * Get font - * - * @return Font - */ - public Font getFont() { - return font; - } - - /** - * Set font - * - * @param value Font - */ - public void setFont(Font value) { - font = value; - } - - /** - * Get title color - * - * @return Title color - */ - public Color getColor() { - return color; - } - - /** - * Set title color - * - * @param value Title color - */ - public void setColor(Color value) { - this.color = value; - } - - /** - * Get x - * - * @return X - */ - public double getX() { - return this.x; - } - - /** - * Set x - * - * @param value X - */ - public void setX(double value) { - this.x = value; - } - - /** - * Get y - * - * @return Y - */ - public double getY() { - return this.y; - } - - /** - * Set y - * - * @param value Y - */ - public void setY(double value) { - this.y = value; - } - - /** - * Get line space - * - * @return Line space - */ - public int getLineSpace() { - return this.lineSpace; - } - - /** - * Set line space - * - * @param value Line space - */ - public void setLineSpace(int value) { - this.lineSpace = value; - } - - /** - * Get coordinates - * - * @return Coordinates - */ - public CoordinateType getCoordinates() { - return this.coordinates; - } - - /** - * Set coordinates - * - * @param value Coordinates - */ - public void setCoordinates(CoordinateType value) { - this.coordinates = value; - } - - /** - * Set coordinates - * - * @param value Coordinates - */ - public void setCoordinates(String value) { - switch (value) { - case "axes": - this.coordinates = CoordinateType.AXES; - break; - case "figure": - this.coordinates = CoordinateType.FIGURE; - break; - case "data": - this.coordinates = CoordinateType.DATA; - break; - case "inches": - this.coordinates = CoordinateType.INCHES; - break; - } - } - - /** - * Get background color - * - * @return Background color - */ - public Color getBackground() { - return this.background; - } - - /** - * Set background color - * - * @param value Background color - */ - public void setBackground(Color value) { - this.background = value; - } - - /** - * Get if is fill background - * - * @return Boolean - */ - public boolean isFill() { - return this.drawBackground; - } - - /** - * Set fill background or not - * - * @param value Boolean - */ - public void setFill(boolean value) { - this.drawBackground = value; - } - - /** - * Get draw neatline or not - * - * @return Boolean - */ - public boolean isDrawNeatline() { - return this.drawNeatline; - } - - /** - * Set draw neatline or not - * - * @param value Boolean - */ - public void setDrawNeatline(boolean value) { - this.drawNeatline = value; - } - - /** - * Get neatline color - * - * @return Neatline color - */ - public Color getNeatlineColor() { - return this.neatLineColor; - } - - /** - * Set neatline color - * - * @param value Neatline color - */ - public void setNeatlineColor(Color value) { - this.neatLineColor = value; - } - - /** - * Get neatline size - * - * @return Neatline size - */ - public float getNeatlineSize() { - return this.neatLineSize; - } - - /** - * Set neatline size - * - * @param value Neatline size - */ - public void setNeatlineSize(float value) { - this.neatLineSize = value; - } - - /** - * Get gap - * - * @return Gap - */ - public float getGap() { - return this.gap; - } - - /** - * Set gap - * - * @param value Gap - */ - public void setGap(float value) { - this.gap = value; - } - - /** - * Get angle - * - * @return Angle - */ - public float getAngle() { - return this.angle; - } - - /** - * Set angle - * - * @param value Angle - */ - public void setAngle(float value) { - this.angle = value; - } - - /** - * Get x align - * - * @return X align - */ - public XAlign getXAlign() { - return this.xAlign; - } - - /** - * Set x align - * - * @param value X align - */ - public void setXAlign(XAlign value) { - this.xAlign = value; - } - - /** - * Set x align - * - * @param value X align string - */ - public void setXAlign(String value) { - this.xAlign = XAlign.valueOf(value.toUpperCase()); - } - - /** - * Get y align - * - * @return Y align - */ - public YAlign getYAlign() { - return this.yAlign; - } - - /** - * Set y align - * - * @param value Y align - */ - public void setYAlign(YAlign value) { - this.yAlign = value; - } - - /** - * Set y align - * - * @param value Y align string - */ - public void setYAlign(String value) { - this.yAlign = YAlign.valueOf(value.toUpperCase()); - } - - /** - * Get if use external font - only for LaTeX string - * - * @return Boolean - */ - public boolean isUseExternalFont() { - return this.useExternalFont; - } - - /** - * Set if use external font - only for LaTeX string - * - * @param value Boolean - */ - public void setUseExternalFont(boolean value) { - this.useExternalFont = value; - } - - /** - * Get x shift - * @return X shift - */ - public double getXShift() { - return this.xShift; - } - - /** - * Set x shift - * @param value X shift - */ - public void setXShift(double value) { - this.xShift = value; - } - - /** - * Get y shift - * @return Y shift - */ - public double getYShift() { - return this.yShift; - } - - /** - * Set y shift - * @param value Y shift - */ - public void setYShift(double value) { - this.yShift = value; - } - - // - // - /** - * Add text in new line - * - * @param value The text string - */ - public void addText(String value) { - this.text.add(value); - } - - @Override - public ShapeTypes getShapeType() { - return ShapeTypes.TEXT; - } - - /** - * Get text line number - * - * @return Text line number - */ - public int getLineNum() { - return this.text.size(); - } - - /** - * Get text dimension with angle - * - * @param g Graphics2D - * @return Dimension - */ - public Dimension getTrueDimension(Graphics2D g) { - Dimension dim = getDimension(g); - if (this.angle != 0) { - int width = dim.width; - int height = dim.height; - int temp; - if (angle == 90 || angle == -90) { - temp = width; - width = height; - height = temp; - } else { - width = (int) ((width * Math.cos(Math.toRadians(angle))) + (height * Math.sin(Math.toRadians(angle)))); - height = (int) ((width * Math.sin(Math.toRadians(angle))) + (height * Math.cos(Math.toRadians(angle)))); - } - return new Dimension(width, height); - } else { - return dim; - } - } - - /** - * Get text dimension - * - * @param g Graphics2D - * @return Dimension - */ - public Dimension getDimension(Graphics2D g) { - g.setFont(font); - int width = 0, height = 0; - for (String line : this.text) { - Dimension dim = Draw.getStringDimension(line, g); - if (width < dim.width) { - width = dim.width; - } - height += dim.height + this.lineSpace; - } - height -= this.lineSpace; - - return new Dimension(width, height); - } - - /** - * To geometry method - * - * @param factory GeometryFactory - * @return Geometry - */ - @Override - public Geometry toGeometry(GeometryFactory factory) { - return null; - } - - /** - * Set point - * - * @param x X - * @param y Y - */ - public void setPoint(double x, double y) { - this.x = x; - this.y = y; - Extent aExtent = new Extent(); - aExtent.minX = x; - aExtent.maxX = x; - aExtent.minY = y; - aExtent.maxY = y; - this.setExtent(aExtent); - } - - /** - * To string - * - * @return String - */ - @Override - public String toString() { - if (this.text.size() == 1) { - return this.text.get(0); - } else { - String r = ""; - for (int i = 0; i < this.text.size(); i++) { - if (i == 0) { - r = this.text.get(i); - } else { - r = r + "\n" + this.text.get(i); - } - } - return r; - } - } - - /** - * Draw text - * - * @param g Graphics2D - * @param x X - * @param y Y - */ - public void draw(Graphics2D g, float x, float y) { - Dimension dim = this.getDimension(g); - x += this.xShift; - y += this.yShift; - - AffineTransform tempTrans = g.getTransform(); - if (this.angle != 0) { - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform) tempTrans.clone(); - myTrans.translate(x, y); - //myTrans.translate(tempTrans.getTranslateX() + x, tempTrans.getTranslateY() + y); - myTrans.rotate(-angle * Math.PI / 180); - g.setTransform(myTrans); - x = 0; - y = 0; - } - - Rectangle.Double rect = new Rectangle.Double(x, y - dim.getHeight(), dim.getWidth(), dim.getHeight()); - rect.setRect(rect.x - gap, rect.y - gap, rect.width + gap * 2, - rect.height + gap * 2); - if (this.drawBackground) { - g.setColor(this.background); - g.fill(rect); - } - if (this.drawNeatline) { - g.setColor(this.neatLineColor); - Stroke oldStroke = g.getStroke(); - g.setStroke(new BasicStroke(neatLineSize)); - g.draw(rect); - g.setStroke(oldStroke); - } - - g.setColor(this.color); - g.setFont(font); - switch (this.yAlign) { - case BOTTOM: - y = y - dim.height; - break; - case CENTER: - y = y - dim.height * 0.5f; - break; - } - - for (String str : this.text) { - dim = Draw.getStringDimension(str, g); - Draw.drawString(g, x, y, str, xAlign, YAlign.TOP, useExternalFont); - y += dim.height; - y += this.lineSpace; - } - - if (this.angle != 0) { - g.setTransform(tempTrans); - } - } - - /** - * Clone - * - * @return Cloned object - */ - @Override - public Object clone() { - ChartText ct = new ChartText(); - ct.angle = this.angle; - ct.background = this.background; - ct.color = this.color; - ct.coordinates = this.coordinates; - ct.drawBackground = this.drawBackground; - ct.drawNeatline = this.drawNeatline; - ct.font = this.font; - ct.gap = this.gap; - ct.lineSpace = this.lineSpace; - ct.neatLineColor = this.neatLineColor; - ct.neatLineSize = this.neatLineSize; - ct.text = this.text; - ct.useExternalFont = this.useExternalFont; - ct.x = this.x; - ct.xAlign = this.xAlign; - ct.y = this.y; - ct.yAlign = this.yAlign; - - return ct; - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartText3D.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartText3D.java deleted file mode 100644 index 22d25881..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartText3D.java +++ /dev/null @@ -1,127 +0,0 @@ -/* 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.chart; - -import java.awt.Point; -import org.meteoinfo.chart.plot3d.Projector; -import org.meteoinfo.common.Extent3D; -import org.meteoinfo.data.DataMath; -import org.meteoinfo.geometry.shape.PointZ; - -/** - * - * @author Yaqiang Wang - * yaqiang.wang@gmail.com - */ -public class ChartText3D extends ChartText { - private double z; - private PointZ zdir = null; - - /** - * Get z coordinate value - * @return Z coordinate value - */ - public double getZ(){ - return this.z; - } - - /** - * Set z coordinate value - * @param value Z coordinate value - */ - public void setZ(double value){ - this.z = value; - } - - /** - * Get zdir point - * @return ZDir point - */ - public PointZ getZDir(){ - return zdir; - } - - /** - * Set zdir point - * @param value ZDir point - */ - public void setZDir(PointZ value){ - this.zdir = value; - } - - /** - * Set zdir point - * @param x X coordinate value - * @param y Y coordinate value - * @param z Z coordinate value - */ - public void setZDir(float x, float y, float z){ - if (x == 0 && y == 0 && z == 0) - this.zdir = null; - else - this.zdir = new PointZ(x, y, z); - } - - /** - * Set zdir point - * @param value ZDir point - */ - public void setZDir(String value){ - float x1 = 0, y1 = 0, z1 = 0; - switch(value.toLowerCase()){ - case "x": - x1 = 1; - break; - case "y": - y1 = 1; - break; - case "z": - z1 = 1; - break; - } - this.setZDir(x1, y1, z1); - } - - /** - * Set point - * - * @param x X - * @param y Y - * @param z Z - */ - public void setPoint(double x, double y, double z) { - this.x = x; - this.y = y; - this.z = z; - Extent3D aExtent = new Extent3D(); - aExtent.minX = x; - aExtent.maxX = x; - aExtent.minY = y; - aExtent.maxY = y; - aExtent.minZ = z; - aExtent.maxZ = z; - this.setExtent(aExtent); - } - - /** - * Update angle - * @param projector Projector - */ - public void updateAngle(Projector projector){ - if (this.zdir == null) - return; - - Point p0 = projector.project(0, 0, 0); - 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); - this.angle = (float)value[0]; - } -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartWindArrow.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartWindArrow.java deleted file mode 100644 index f2c2c818..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/ChartWindArrow.java +++ /dev/null @@ -1,391 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Graphics2D; -import java.awt.RenderingHints; -import java.awt.geom.Rectangle2D; - -import org.meteoinfo.common.DataConvert; -import org.meteoinfo.common.PointF; -import org.meteoinfo.drawing.Draw; -import org.meteoinfo.geometry.legend.ArrowBreak; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.geometry.graphic.GraphicCollection; -import org.meteoinfo.geometry.shape.WindArrow; - -/** - * - * @author Yaqiang Wang - */ -public class ChartWindArrow { - - // - private final WindArrow windArrow; - private ArrowBreak arrowBreak; - private Font font; - //private Color color; - private Color labelColor; - private float x; - private float y; - private String label; - private int labelSep; - private Object layer; - private Color background; - private boolean drawBackground; - private boolean drawNeatline; - private Color neatLineColor; - private float neatLineSize; - - // - // - /** - * Constructor - */ - public ChartWindArrow() { - this.windArrow = new WindArrow(); - this.windArrow.angle = 270; - this.windArrow.length = 20; - this.arrowBreak = new ArrowBreak(); - this.font = new Font("Arial", Font.PLAIN, 12); - //this.color = Color.black; - this.labelColor = Color.black; - this.labelSep = 5; - this.background = Color.white; - this.drawBackground = false; - this.drawNeatline = false; - this.neatLineColor = Color.black; - this.neatLineSize = 1.0f; - } - - // - // - /** - * Get wind arrow - * - * @return Wind arrow - */ - public WindArrow getWindArrow() { - return this.windArrow; - } - - /** - * Get arrow break - * @return Arrow break - */ - public ArrowBreak getArrowBreak() { - return this.arrowBreak; - } - - /** - * Set arrow break - * @param value Arrow break - */ - public void setArrowBreak(ArrowBreak value) { - this.arrowBreak = value; - } - - /** - * Get length - * - * @return Length - */ - public float getLength() { - return this.windArrow.length; - } - - /** - * Set length - * - * @param value Length - */ - public void setLength(float value) { - this.windArrow.length = value; - this.label = String.valueOf(value); - this.label = DataConvert.removeTailingZeros(this.label); - } - - /** - * Get angle - * - * @return Angle - */ - public double getAngle() { - return this.windArrow.angle; - } - - /** - * Set angle - * - * @param value Angle - */ - public void setAngle(double value) { - this.windArrow.angle = value; - } - - /** - * Get layer - * - * @return Layer - */ - public Object getLayer() { - return this.layer; - } - - /** - * Set layer - * - * @param value Layer - */ - public void setLayer(Object value) { - this.layer = value; - } - - /** - * Get font - * - * @return Font - */ - public Font getFont() { - return font; - } - - /** - * Set font - * - * @param value Font - */ - public void setFont(Font value) { - font = value; - } - - /** - * Get label color - * - * @return Label color - */ - public Color getLabelColor() { - return this.labelColor; - } - - /** - * Set label color - * - * @param value Label color - */ - public void setLabelColor(Color value) { - this.labelColor = value; - } - - /** - * Get the distance between arrow and label - * @return Distance between arrow and label - */ - public int getLabelSep(){ - return this.labelSep; - } - - /** - * Set the distance between arrow and label - * @param value Distance between arrow and label - */ - public void setLabelSep(int value) { - this.labelSep = value; - } - - /** - * Get x - * - * @return X - */ - public float getX() { - return this.x; - } - - /** - * Set x - * - * @param value X - */ - public void setX(float value) { - this.x = value; - } - - /** - * Get y - * - * @return Y - */ - public float getY() { - return this.y; - } - - /** - * Set y - * - * @param value Y - */ - public void setY(float value) { - this.y = value; - } - - /** - * Get label - * - * @return Label - */ - public String getLabel() { - return this.label; - } - - /** - * Set label - * - * @param value Label - */ - public void setLabel(String value) { - this.label = value; - } - - /** - * Get background color - * - * @return Background color - */ - public Color getBackground() { - return this.background; - } - - /** - * Set background color - * - * @param value Background color - */ - public void setBackground(Color value) { - this.background = value; - } - - /** - * Get if is fill background - * - * @return Boolean - */ - public boolean isFill() { - return this.drawBackground; - } - - /** - * Set fill background or not - * - * @param value Boolean - */ - public void setFill(boolean value) { - this.drawBackground = value; - } - - /** - * Get draw neatline or not - * - * @return Boolean - */ - public boolean isDrawNeatline() { - return this.drawNeatline; - } - - /** - * Set draw neatline or not - * - * @param value Boolean - */ - public void setDrawNeatline(boolean value) { - this.drawNeatline = value; - } - - /** - * Get neatline color - * - * @return Neatline color - */ - public Color getNeatlineColor() { - return this.neatLineColor; - } - - /** - * Set neatline color - * - * @param value Neatline color - */ - public void setNeatlineColor(Color value) { - this.neatLineColor = value; - } - - /** - * Get neatline size - * - * @return Neatline size - */ - public float getNeatlineSize() { - return this.neatLineSize; - } - - /** - * Set neatline size - * - * @param value Neatline size - */ - public void setNeatlineSize(float value) { - this.neatLineSize = value; - } - - // - // - /** - * Draw text - * - * @param g Graphics2D - * @param x X - * @param y Y - */ - public void draw(Graphics2D g, float x, float y) { - Object rendering = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING); - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - float zoom = 1.0f; - if (this.layer != null) { - if (this.layer instanceof VectorLayer) { - zoom = ((VectorLayer) this.layer).getDrawingZoom(); - } else if (this.layer instanceof GraphicCollection) { - zoom = ((GraphicCollection) this.layer).getArrowZoom(); - } - } - g.setFont(this.font); - //String drawStr = this.label wa.getLabel(); - Dimension dim = Draw.getStringDimension(this.label, g); - if (this.drawBackground || this.drawNeatline) { - Rectangle2D rect = Draw.getArrawBorder(new PointF(x, y), this.windArrow, g, zoom); - double gap = 5; - double width = Math.max(rect.getWidth(), dim.getWidth()); - rect.setRect(rect.getX() - gap, rect.getY() - gap - 2, width + gap * 2, - rect.getHeight() + dim.height + this.labelSep + gap + 2); - if (this.drawBackground) { - g.setColor(this.background); - g.fill(rect); - } - if (this.drawNeatline) { - 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); - g.setColor(this.labelColor); - Draw.drawString(g, this.label, x, y + dim.height + this.labelSep); - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, rendering); - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/CoordinateType.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/CoordinateType.java deleted file mode 100644 index 5b155c1c..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/CoordinateType.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -/** - * - * @author Yaqiang Wang - */ -public enum CoordinateType { - AXES, - FIGURE, - DATA, - INCHES -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/IChartPanel.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/IChartPanel.java deleted file mode 100644 index 94793140..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/IChartPanel.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -/** - * - * @author yaqiang - */ -public interface IChartPanel { - /** - * Save image - * @param fn Image file name - */ - public abstract void saveImage(String fn); - - /** - * Set mouse mode - * @param value Mouse mode - */ - public abstract void setMouseMode(MouseMode value); - - /** - * Zoom back to full extent - */ - public abstract void onUndoZoomClick(); - - /** - * Paint graphics - */ - public abstract void paintGraphics(); -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/IPointSelectedListener.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/IPointSelectedListener.java deleted file mode 100644 index 1513ca92..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/IPointSelectedListener.java +++ /dev/null @@ -1,24 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.chart; - -import java.util.EventListener; - -/** - * - * @author yaqiang - */ -public interface IPointSelectedListener extends EventListener { - public void pointSelectedEvent(PointSelectedEvent event); -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/LegendPosition.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/LegendPosition.java deleted file mode 100644 index 236945ed..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/LegendPosition.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -/** - * - * @author yaqiang - */ -public enum LegendPosition { - UPPER_RIGHT, - UPPER_LEFT, - UPPER_CENTER, - LOWER_LEFT, - LOWER_RIGHT, - LOWER_CENTER, - RIGHT, - CENTER_LEFT, - CENTER_RIGHT, - CENTER, - LEFT, - UPPER_RIGHT_OUTSIDE, - UPPER_LEFT_OUTSIDE, - UPPER_CENTER_OUTSIDE, - LOWER_LEFT_OUTSIDE, - LOWER_RIGHT_OUTSIDE, - LOWER_CENTER_OUTSIDE, - LEFT_OUTSIDE, - RIGHT_OUTSIDE, - CUSTOM; - - /** - * If the position is custom - * @return Boolean - */ - public boolean isCustom(){ - switch (this){ - case CUSTOM: - return true; - default: - return false; - } - } - - /** - * Get LegendPostion from string - * @param loc Location string - * @return LegenPosition - */ - public static LegendPosition fromString(String loc){ - LegendPosition lp = LegendPosition.UPPER_RIGHT; - loc = loc.toLowerCase(); - switch (loc){ - case "upper left": - lp = LegendPosition.UPPER_LEFT; - break; - case "upper right": - lp = LegendPosition.UPPER_RIGHT; - break; - case "upper center": - lp = LegendPosition.UPPER_CENTER; - break; - case "upper center outside": - lp = LegendPosition.UPPER_CENTER_OUTSIDE; - break; - case "lower left": - lp = LegendPosition.LOWER_LEFT; - break; - case "lower right": - lp = LegendPosition.LOWER_RIGHT; - break; - case "lower center": - lp = LegendPosition.LOWER_CENTER; - break; - case "lower center outside": - lp = LegendPosition.LOWER_CENTER_OUTSIDE; - break; - case "left": - lp = LegendPosition.LEFT; - break; - case "left outside": - lp = LegendPosition.LEFT_OUTSIDE; - break; - case "right": - lp = LegendPosition.RIGHT; - break; - case "right outside": - lp = LegendPosition.RIGHT_OUTSIDE; - break; - case "custom": - lp = LegendPosition.CUSTOM; - break; - } - - return lp; - } -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/Location.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/Location.java deleted file mode 100644 index f71e8a81..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/Location.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -/** - * - * @author yaqiang - */ -public enum Location { - LEFT, - RIGHT, - TOP, - BOTTOM -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/Margin.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/Margin.java deleted file mode 100644 index d057c8f7..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/Margin.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -import java.awt.geom.Rectangle2D; - -/** - * - * @author wyq - */ -public class Margin { - // - private double left; - private double right; - private double top; - private double bottom; - // - // - /** - * Constructor - */ - public Margin(){ - - } - - /** - * Constructor - * @param left Left - * @param right Right - * @param top Top - * @param bottom Bottom - */ - public Margin(double left, double right, double top, double bottom){ - this.left = left; - this.right = right; - this.top = top; - this.bottom = bottom; - } - // - // - /** - * Get left - * @return Left - */ - public double getLeft(){ - return this.left; - } - - /** - * Set left - * @param value Left - */ - public void setLeft(double value){ - this.left = value; - } - - /** - * Get right - * @return Right - */ - public double getRight(){ - return this.right; - } - - /** - * Set right - * @param value Right - */ - public void setRight(double value){ - this.right = value; - } - - /** - * Get top - * @return Top - */ - public double getTop(){ - return this.top; - } - - /** - * Set top - * @param value Top - */ - public void setTop(double value){ - this.top = value; - } - - /** - * Get bottom - * @return Bottom - */ - public double getBottom(){ - return this.bottom; - } - - /** - * Set bottom - * @param value Bottom - */ - public void setBottom(double value){ - this.bottom = value; - } - // - // - /** - * Get margin area - * @param inArea Inside area - * @return Margin area - */ - public Rectangle2D getArea(Rectangle2D inArea){ - double x = inArea.getX() - this.left; - double y = inArea.getY() - this.top; - double w = inArea.getWidth() + this.left + this.right; - double h = inArea.getHeight() + this.top + this.bottom; - - return new Rectangle2D.Double(x, y, w, h); - } - - /** - * Extent - * @param a Margin - * @return Extented margin - */ - public Margin extend(Margin a){ - Margin r = new Margin(); - r.setLeft(Math.max(this.left, a.left)); - r.setRight(Math.max(this.right, a.right)); - r.setTop(Math.max(this.top, a.top)); - r.setBottom(Math.max(this.bottom, a.bottom)); - - return r; - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/MouseMode.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/MouseMode.java deleted file mode 100644 index bba687d4..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/MouseMode.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -/** - * - * @author yaqiang - */ -public enum MouseMode { - DEFAULT, - ZOOM_IN, - ZOOM_OUT, - SELECT, - PAN, - IDENTIFER, - ROTATE -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/PointSelectedEvent.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/PointSelectedEvent.java deleted file mode 100644 index 26262fb6..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/PointSelectedEvent.java +++ /dev/null @@ -1,31 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.chart; - -import java.util.EventObject; - -/** - * Size changed event - * - * @author Yaqiang Wang - */ -public class PointSelectedEvent extends EventObject { - /** - * Constructor - * @param source Source object - */ - public PointSelectedEvent(Object source){ - super(source); - } -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/Axis.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/Axis.java deleted file mode 100644 index 3c65f6dc..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/Axis.java +++ /dev/null @@ -1,1958 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.axis; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics2D; -import java.awt.Stroke; -import java.awt.geom.Line2D; -import java.awt.geom.Rectangle2D; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.List; -import org.meteoinfo.chart.ChartText; -import org.meteoinfo.chart.Location; -import org.meteoinfo.chart.plot.AbstractPlot2D; -import org.meteoinfo.common.DataConvert; -import org.meteoinfo.common.MIMath; -import org.meteoinfo.common.XAlign; -import org.meteoinfo.common.YAlign; -import org.meteoinfo.common.util.JDateUtil; -import org.meteoinfo.drawing.Draw; -import org.meteoinfo.geometry.legend.LineStyles; -import org.meteoinfo.ndarray.util.BigDecimalUtil; - -/** - * - * @author yaqiang - */ -public class Axis implements Cloneable { - - // - protected boolean xAxis; - protected Location location; - protected ChartText label; - protected boolean visible; - protected boolean drawTickLine; - protected boolean drawTickLabel; - protected boolean drawLabel; - protected Color lineColor; - protected float lineWidth; - protected LineStyles lineStyle; - //private Stroke lineStroke; - protected Color tickColor; - protected Stroke tickStroke; - protected float tickLength; - protected boolean insideTick; - protected Font tickLabelFont; - protected Color tickLabelColor; - protected float tickLabelAngle; - protected int tickLabelGap; - protected double tickStartValue; - protected double tickDeltaValue; - protected double minValue; - protected double maxValue; - protected double[] tickValues; - //private boolean timeAxis; - //private String timeFormat; - //private TimeUnit timeUnit; - protected boolean inverse; - //private float shift; - protected List tickLocations; - //private List tickLabels; - protected List tickLabels; - protected boolean autoTick; - protected boolean minorTickVisible; - protected int minorTickNum; - protected int tickSpace; - protected PositionType positionType; - protected float position; - - // - // - /** - * Constructor - */ - public Axis() { - this.xAxis = true; - this.label = null; - this.visible = true; - this.drawTickLine = true; - this.drawTickLabel = true; - this.drawLabel = false; - this.lineColor = Color.black; - this.lineWidth = 1.0f; - this.lineStyle = LineStyles.SOLID; - //this.lineStroke = new BasicStroke(1.0f); - this.tickColor = Color.black; - this.tickStroke = new BasicStroke(1.0f); - this.tickLength = 5; - this.insideTick = true; - this.tickLabelFont = new Font("Arial", Font.PLAIN, 14); - this.tickLabelColor = Color.black; - this.tickLabelAngle = 0; - this.tickLabelGap = 1; - this.minValue = 0; - this.maxValue = 1; - this.updateTickValues(); - //this.timeAxis = false; - //this.timeFormat = "yyyy-MM-dd"; - //this.timeUnit = TimeUnit.DAY; - this.inverse = false; - //this.shift = 0; - this.tickLocations = new ArrayList<>(); - this.tickLabels = new ArrayList<>(); - this.autoTick = true; - this.minorTickVisible = false; - this.minorTickNum = 5; - this.tickSpace = 5; - this.positionType = PositionType.OUTERWARD; - this.position = 0; - } - - /** - * Constructor - * - * @param label Axis label - */ - public Axis(ChartText label) { - this(); - this.label = label; - } - - /** - * Constructor - * - * @param label Axis label - */ - public Axis(String label) { - this(); - this.label = new ChartText(label); - } - - /** - * Constructor - * - * @param label Axis label - * @param xAxis If is x axis - */ - public Axis(String label, boolean xAxis) { - this(label); - this.xAxis = xAxis; - if (this.xAxis) { - this.location = Location.BOTTOM; - } else { - this.location = Location.LEFT; - } - } - - /** - * Constructor - * - * @param label Axis label - * @param xAxis If is x axis - */ - public Axis(ChartText label, boolean xAxis) { - this(label); - this.xAxis = xAxis; - if (this.xAxis) { - this.location = Location.BOTTOM; - } else { - this.location = Location.LEFT; - } - } - - /** - * Constructor - * - * @param label Axis label - * @param xAxis If is x axis - * @param loc Location - */ - public Axis(String label, boolean xAxis, Location loc) { - this(label); - this.xAxis = xAxis; - this.location = loc; - } - - /** - * Constructor - * - * @param label Axis label - * @param xAxis If is x axis - * @param loc Location - * @param drawTickLabel If draw tick label - */ - public Axis(String label, boolean xAxis, Location loc, boolean drawTickLabel) { - this(label); - this.xAxis = xAxis; - this.location = loc; - this.drawTickLabel = drawTickLabel; - } - - /** - * Constructor - * - * @param axis Axis - */ - public Axis(Axis axis) { - this(axis.getLabel(), axis.isXAxis()); - this.autoTick = axis.isAutoTick(); - this.drawLabel = axis.isDrawLabel(); - this.drawTickLabel = axis.isDrawTickLabel(); - this.drawTickLine = axis.isDrawTickLine(); - this.insideTick = axis.isInsideTick(); - this.inverse = axis.isInverse(); - this.label.setColor(axis.getLabelColor()); - this.lineWidth = axis.getLineWidth(); - this.lineStyle = axis.getLineStyle(); - //this.setLineStroke(axis.getLineStroke()); - this.location = axis.getLocation(); - this.maxValue = axis.getMaxValue(); - this.minValue = axis.getMinValue(); - this.minorTickNum = axis.getMinorTickNum(); - this.minorTickVisible = axis.isMinorTickVisible(); - //this.shift = axis.getShift(); - this.tickColor = axis.getTickColor(); - this.tickDeltaValue = axis.getTickDeltaValue(); - this.tickLabelColor = axis.getTickLabelColor(); - this.tickLabelFont = axis.getTickLabelFont(); - this.tickLength = axis.getTickLength(); - this.visible = axis.isVisible(); - this.position = axis.getPosition(); - this.positionType = axis.getPositionType(); - } - - // - // - /** - * Get if is x axis - * - * @return Boolean - */ - public boolean isXAxis() { - return this.xAxis; - } - - /** - * Set if is x axis - * - * @param value Boolean - */ - public void setXAxis(boolean value) { - this.xAxis = value; - } - - /** - * Get location - * - * @return Location - */ - public Location getLocation() { - return this.location; - } - - /** - * Set location - * - * @param value Location - */ - public void setLocation(Location value) { - this.location = value; - } - - /** - * Get axis label - * - * @return Axis label - */ - public ChartText getLabel() { - return label; - } - - /** - * Set axis label - * - * @param value Axis label - */ - public void setLabel(ChartText value) { - label = value; - if (label != null && (this.location == Location.BOTTOM || this.location == Location.LEFT)) { - this.drawLabel = true; - } - } - - /** - * Set axis label - * - * @param value Axis label - */ - public void setLabel(String value) { - ChartText text = new ChartText(value); - if (this.xAxis) { - text.setXAlign(XAlign.CENTER); - text.setYAlign(YAlign.TOP); - } else { - text.setAngle(90); - text.setXAlign(XAlign.CENTER); - text.setYAlign(YAlign.BOTTOM); - } - setLabel(text); - } - - /** - * If is visible - * - * @return Boolean - */ - public boolean isVisible() { - return visible; - } - - /** - * Set if is visible - * - * @param value Boolean - */ - public void setVisible(boolean value) { - visible = value; - } - - /** - * Get if draw tick lines - * - * @return Boolean - */ - public boolean isDrawTickLine() { - return this.drawTickLine; - } - - /** - * Set if draw tick lines - * - * @param value Boolean - */ - public void setDrawTickLine(boolean value) { - this.drawTickLine = value; - } - - /** - * Get is draw tick label - * - * @return Boolean - */ - public boolean isDrawTickLabel() { - return this.drawTickLabel; - } - - /** - * Set if draw tick label - * - * @param value Boolean - */ - public void setDrawTickLabel(boolean value) { - this.drawTickLabel = value; - } - - /** - * Get if draw label - * - * @return Boolean - */ - public boolean isDrawLabel() { - return this.drawLabel; - } - - /** - * Set if draw label - * - * @param value Boolean - */ - public void setDrawLabel(boolean value) { - this.drawLabel = value; - } - - /** - * Get line color - * - * @return Line color - */ - public Color getLineColor() { - return lineColor; - } - - /** - * Set line color - * - * @param value Line color - */ - public void setLineColor(Color value) { - lineColor = value; - } - - /** - * Get line width - * - * @return Line width - */ - public float getLineWidth() { - return this.lineWidth; - } - - /** - * Set line width - * - * @param value Line width - */ - public void setLineWidth(float value) { - this.lineWidth = value; - } - - public LineStyles getLineStyle() { - return this.lineStyle; - } - - public void setLineStyle(LineStyles value) { - this.lineStyle = value; - } - - /** - * Get line stroke - * - * @return Line stroke - */ - public Stroke getLineStroke() { - return new BasicStroke(this.lineWidth, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, - 10.0f, Draw.getDashPattern(lineStyle), 0.0f); - } - -// /** -// * Set line stroke -// * -// * @param value Line stroke -// */ -// public void setLineStroke(Stroke value) { -// lineStroke = value; -// } - /** - * Get tick color - * - * @return Tick color - */ - public Color getTickColor() { - return tickColor; - } - - /** - * Set tick color - * - * @param value Tick color - */ - public void setTickColor(Color value) { - tickColor = value; - } - - /** - * Get tick stroke - * - * @return Tick stroke - */ - public Stroke getTickStroke() { - return tickStroke; - } - - /** - * Set tick stroke - * - * @param value Tick stroke - */ - public void setTickStroke(Stroke value) { - tickStroke = value; - } - - /** - * Get tick length - * - * @return Tick length - */ - public float getTickLength() { - return this.tickLength; - } - - /** - * Set tick length - * - * @param value Tick length - */ - public void setTickLength(float value) { - this.tickLength = value; - } - - /** - * Get if is inside tick - * - * @return Boolean - */ - public boolean isInsideTick() { - return this.insideTick; - } - - /** - * Set if is inside tick - * - * @param value Boolean - */ - public void setInsideTick(boolean value) { - this.insideTick = value; - } - - /** - * Get label font - * - * @return Label font - */ - public Font getLabelFont() { - return this.label.getFont(); - } - - /** - * Set lable font - * - * @param value Lable font - */ - public void setLabelFont(Font value) { - this.label.setFont(value); - } - - /** - * Get label color - * - * @return Label color - */ - public Color getLabelColor() { - return this.label.getColor(); - } - - /** - * Set label color - * - * @param value Label color - */ - public void setLabelColor(Color value) { - this.label.setColor(value); - } - - /** - * Get tick label font - * - * @return Tick label font - */ - public Font getTickLabelFont() { - return tickLabelFont; - } - - /** - * Set tick lable font - * - * @param value Tick lable font - */ - public void setTickLabelFont(Font value) { - tickLabelFont = value; - } - - /** - * Get tick label color - * - * @return Tick label color - */ - public Color getTickLabelColor() { - return tickLabelColor; - } - - /** - * Set tick label color - * - * @param value Tick label color - */ - public void setTickLabelColor(Color value) { - tickLabelColor = value; - } - - /** - * Get tick label angle - * - * @return Tick label angle - */ - public float getTickLabelAngle() { - return this.tickLabelAngle; - } - - /** - * Set tick label angle - * - * @param value Angle - */ - public void setTickLabelAngle(float value) { - this.tickLabelAngle = value; - } - - /** - * Get tick label gap - * - * @return Tick label gap - */ - public int getTickLabelGap() { - return this.tickLabelGap; - } - - /** - * Set tick label gap - * - * @param value Tick label gap - */ - public void setTickLabelGap(int value) { - this.tickLabelGap = value; - } - - /** - * Get tick start value - * - * @return Tick start value - */ - public double getTickStartValue() { - return this.tickStartValue; - } - - /** - * Set tick start value - * - * @param value Tick start value - */ - public void setTickStartValue(double value) { - this.tickStartValue = value; - } - - /** - * Get tick delta value - * - * @return Tick delta value - */ - public double getTickDeltaValue() { - return this.tickDeltaValue; - } - - /** - * Set tick delta value - * - * @param value Tick delta value - */ - public void setTickDeltaValue(double value) { - this.tickDeltaValue = value; - } - - /** - * Get minimum value - * - * @return Minimum value - */ - public double getMinValue() { - return this.minValue; - } - - /** - * Set minimum value - * - * @param value Minimum value - */ - public void setMinValue(double value) { - this.minValue = value; - } - - /** - * Get maximum value - * - * @return Maximum value - */ - public double getMaxValue() { - return this.maxValue; - } - - /** - * Set maximum value - * - * @param value Maximum value - */ - public void setMaxValue(double value) { - this.maxValue = value; - } - - /** - * Get tick values - * - * @return Tick values - */ - public double[] getTickValues() { - if (this.autoTick) { - return this.tickValues; - } else { - List values = new ArrayList<>(); - for (double v : this.tickLocations) { - if (v >= this.minValue && v <= this.maxValue) { - values.add(v); - } - } - double[] vs = new double[values.size()]; - for (int i = 0; i < values.size(); i++) { - vs[i] = values.get(i); - } - return vs; - } - } - - /** - * Set tick values - * - * @param value Tick values - */ - public void setTickValues(double[] value) { - this.tickValues = value; - if (value.length > 1) { - this.tickDeltaValue = BigDecimalUtil.sub(value[1], value[0]); - } else { - this.tickDeltaValue = 0; - } - } - - /** - * Set tick values - * - * @param value Tick value list - */ - public void setTickValues(List value) { - this.tickValues = new double[value.size()]; - for (int i = 0; i < value.size(); i++) { - this.tickValues[i] = value.get(i); - } - if (value.size() > 1) { - this.tickDeltaValue = BigDecimalUtil.sub(value.get(1), value.get(0)); - } else { - this.tickDeltaValue = 0; - } - } - -// /** -// * Get if is time axis -// * -// * @return Boolean -// */ -// public boolean isTimeAxis() { -// return this.timeAxis; -// } -// -// /** -// * Set if is time axis -// * -// * @param value Boolean -// */ -// public void setTimeAxis(boolean value) { -// this.timeAxis = value; -// } -// /** -// * Get time format -// * @return Time format -// */ -// public String getTimeFormat(){ -// return this.timeFormat; -// } -// -// /** -// * Set time format -// * @param value -// */ -// public void setTimeFormat(String value){ -// this.timeFormat = value; -// } -// -// /** -// * Get time unit -// * @return Time unit -// */ -// public TimeUnit getTimeUnit(){ -// return this.timeUnit; -// } -// -// /** -// * Set time unit -// * @param value Time unit -// */ -// public void setTimeUnit(TimeUnit value){ -// this.timeUnit = value; -// } - /** - * Get if is inverse - * - * @return Boolean - */ - public boolean isInverse() { - return this.inverse; - } - - /** - * Set if is inverse - * - * @param value Boolean - */ - public void setInverse(boolean value) { - this.inverse = value; - } - -// /** -// * Get shift -// * -// * @return Shift -// */ -// public float getShift() { -// return this.shift; -// } -// -// /** -// * Set shift -// * -// * @param value Shift -// */ -// public void setShift(float value) { -// this.shift = value; -// } - - /** - * Tick locations - * - * @return Tick locations - */ - public List getTickLocations() { - return this.tickLocations; - } - - /** - * Set tick locations - * - * @param value Tick locations - */ - public void setTickLocations(List value) { - this.tickLocations.clear(); - this.tickLabels.clear(); - for (Number v : value) { - this.tickLocations.add(v.doubleValue()); - this.tickLabels.add(new ChartText(String.valueOf(v))); - } - this.autoTick = false; - } - - /** - * Set tick locations - * - * @param value Tick locations - */ - public void setTickLocations(double[] value) { - this.tickLocations.clear(); - this.tickLabels.clear(); - String tick; - for (double v : value) { - this.tickLocations.add(v); - tick = String.valueOf(v); - tick = DataConvert.removeTailingZeros(tick); - this.tickLabels.add(new ChartText(tick)); - } - this.autoTick = false; - } - - /** - * Get tick labels - * - * @return Tick labels - */ - public List getTickLabels() { - return this.tickLabels; - } - - /** - * Get tick label text - * - * @return Tick label text - */ - public List getTickLabelText() { - List strs = new ArrayList<>(); - for (ChartText ct : this.tickLabels) { - strs.add(ct.toString()); - } - - return strs; - } - - /** - * Set tick label text - * - * @param value Tick label text - */ - public void setTickLabelText(List value) { - this.tickLabels = new ArrayList<>(); - for (String v : value) { - this.tickLabels.add(new ChartText(v)); - } - this.autoTick = false; - } - - /** - * Set tick labels. - * - * @param value Tick labels - */ - public void setTickLabels(List value) { - this.tickLabels = value; - } - - /** - * Set tick labels - * - * @param value Tick labels - */ - public void setTickLabels_Number(List value) { - this.tickLabels = new ArrayList<>(); - for (Number v : value) { - this.tickLabels.add(new ChartText(v.toString())); - } - this.autoTick = false; - } - - /** - * Get if is auto tick labels - * - * @return Boolean - */ - public boolean isAutoTick() { - return this.autoTick; - } - - /** - * Set if auto tick labels - * - * @param value Boolean - */ - public void setAutoTick(boolean value) { - this.autoTick = value; - } - - /** - * Get if minor tick visible or not - * - * @return Boolean - */ - public boolean isMinorTickVisible() { - return this.minorTickVisible; - } - - /** - * Set if minor tick visible or not - * - * @param value Boolean - */ - public void setMinorTickVisible(boolean value) { - this.minorTickVisible = value; - } - - /** - * Get minor tick number - * - * @return Minor tick number - */ - public int getMinorTickNum() { - return this.minorTickNum; - } - - /** - * Set minor tick number - * - * @param value Minor tick number - */ - public void setMinorTickNum(int value) { - this.minorTickNum = value; - } - - /** - * Get tick space - * @return Tick space - */ - public int getTickSpace(){ - return this.tickSpace; - } - - /** - * Set tick space - * @param value Tick space - */ - public void setTickSpace(int value){ - this.tickSpace = value; - } - - /** - * Get position type - * @return PositionType - */ - public PositionType getPositionType() { - return this.positionType; - } - - /** - * Set position type - * @param value PositionType - */ - public void setPositionType(PositionType value) { - this.positionType = value; - } - - /** - * Set position type - * @param value Position type string - */ - public void setPositionType(String value) { - this.positionType = PositionType.valueOf(value.toUpperCase()); - } - - /** - * Get position value - * @return Position value - */ - public float getPosition() { - return this.position; - } - - /** - * Set position value - * @param value Position value - */ - public void setPosition(float value) { - this.position = value; - } - // - // - - /** - * Set minimum and maximum values - * - * @param minValue Start value - * @param maxValue End value - */ - public void setMinMaxValue(double minValue, double maxValue) { - this.minValue = minValue; - this.maxValue = maxValue; - if (Double.isNaN(minValue) || Double.isNaN(maxValue)) { - return; - } - - updateTickValues(); -// if (this.timeAxis) { -// this.updateTimeLabels(); -// } else { -// tickValues = MIMath.getIntervalValues(minValue, maxValue); -// } - } - - /** - * Update tick values - */ - public void updateTickValues() { - List r = MIMath.getIntervalValues1(minValue, maxValue); - this.tickValues = (double[]) r.get(0); - this.tickDeltaValue = (Double) r.get(1); - } - -// /** -// * Update time labels -// */ -// public void updateTimeLabels() { -// Date sdate = DateUtil.fromOADate(minValue); -// Date edate = DateUtil.fromOADate(maxValue); -// Calendar scal = Calendar.getInstance(); -// Calendar ecal = Calendar.getInstance(); -// scal.setTime(sdate); -// ecal.setTime(edate); -// Calendar sscal = Calendar.getInstance(); -// sscal.setTime(sdate); -// -// List dates = new ArrayList<>(); -// scal.add(Calendar.YEAR, 5); -// if (scal.before(ecal)) { -// this.timeFormat = "yyyy"; -// this.timeUnit = TimeUnit.YEAR; -// scal.setTime(sdate); -// scal.set(Calendar.MONTH, 0); -// scal.set(Calendar.DAY_OF_MONTH, 1); -// scal.set(Calendar.HOUR_OF_DAY, 0); -// scal.set(Calendar.MINUTE, 0); -// scal.set(Calendar.SECOND, 0); -// if (!scal.before(sscal)) { -// dates.add(scal.getTime()); -// } -// while (!scal.after(ecal)) { -// scal.set(Calendar.YEAR, scal.get(Calendar.YEAR) + 1); -// dates.add(scal.getTime()); -// } -// } else { -// scal.setTime(sdate); -// scal.add(Calendar.MONTH, 5); -// if (scal.before(ecal)) { -// scal.setTime(sdate); -// this.timeFormat = "M"; -// this.timeUnit = TimeUnit.MONTH; -// scal.set(Calendar.DAY_OF_MONTH, 1); -// scal.set(Calendar.HOUR_OF_DAY, 0); -// scal.set(Calendar.MINUTE, 0); -// scal.set(Calendar.SECOND, 0); -// if (!scal.before(sscal)) { -// dates.add(scal.getTime()); -// } -// while (!scal.after(ecal)) { -// scal.add(Calendar.MONTH, 1); -// if (!scal.before(sscal)) { -// dates.add(scal.getTime()); -// } -// } -// } else { -// scal.setTime(sdate); -// scal.add(Calendar.DAY_OF_MONTH, 5); -// if (scal.before(ecal)) { -// scal.setTime(sdate); -// this.timeFormat = "d"; -// this.timeUnit = TimeUnit.DAY; -// scal.set(Calendar.HOUR_OF_DAY, 0); -// scal.set(Calendar.MINUTE, 0); -// scal.set(Calendar.SECOND, 0); -// if (!scal.before(sscal)) { -// dates.add(scal.getTime()); -// } -// while (!scal.after(ecal)) { -// scal.add(Calendar.DAY_OF_MONTH, 1); -// if (!scal.before(sscal)) { -// dates.add(scal.getTime()); -// } -// } -// } else { -// scal.setTime(sdate); -// scal.add(Calendar.HOUR_OF_DAY, 5); -// if (scal.before(ecal)) { -// scal.setTime(sdate); -// this.timeFormat = "H"; -// this.timeUnit = TimeUnit.HOUR; -// scal.set(Calendar.MINUTE, 0); -// scal.set(Calendar.SECOND, 0); -// if (!scal.before(sscal)) { -// dates.add(scal.getTime()); -// } -// while (!scal.after(ecal)) { -// scal.add(Calendar.HOUR_OF_DAY, 1); -// if (!scal.before(sscal)) { -// dates.add(scal.getTime()); -// } -// } -// } else { -// scal.setTime(sdate); -// scal.add(Calendar.MINUTE, 5); -// if (scal.before(ecal)) { -// scal.setTime(sdate); -// this.timeFormat = "HH:mm"; -// this.timeUnit = TimeUnit.MINITUE; -// scal.set(Calendar.SECOND, 0); -// if (!scal.before(sscal)) { -// dates.add(scal.getTime()); -// } -// while (!scal.after(ecal)) { -// scal.add(Calendar.MINUTE, 1); -// if (!scal.before(sscal)) { -// dates.add(scal.getTime()); -// } -// } -// } else { -// scal.setTime(sdate); -// this.timeFormat = "HH:mm:ss"; -// this.timeUnit = TimeUnit.SECOND; -// if (!scal.before(sscal)) { -// dates.add(scal.getTime()); -// } -// while (!scal.after(ecal)) { -// scal.add(Calendar.SECOND, 1); -// if (!scal.before(sscal)) { -// dates.add(scal.getTime()); -// } -// } -// } -// } -// } -// } -// } -// -// tickValues = new double[dates.size()]; -// for (int i = 0; i < dates.size(); i++) { -// tickValues[i] = DateUtil.toOADate(dates.get(i)); -// } -// } - /** - * Get tick labels - * - */ - public void updateTickLabels() { - List tls = new ArrayList<>(); - String lab; - if (this.autoTick) { - if (this.getTickValues() == null) { - return; - } - this.tickLocations = new ArrayList<>(); - for (double value : this.getTickValues()) { - this.tickLocations.add(value); - lab = String.valueOf(value); - lab = DataConvert.removeTailingZeros(lab); - tls.add(new ChartText(lab, this.tickLabelFont)); - } - } else { - ChartText ct; - for (int i = 0; i < this.tickLocations.size(); i++) { - if (i >= this.tickLabels.size()) { - break; - } - double v = this.tickLocations.get(i); - if (v >= this.minValue && v <= this.maxValue) { - ct = tickLabels.get(i); - ct.setFont(this.tickLabelFont); - tls.add(this.tickLabels.get(i)); - } - } - } - - this.tickLabels = tls; - } - - /** - * Get maximum label string length - * - * @param g Graphics2D - * @return Maximum lable string length - */ - public int getMaxLabelLength(Graphics2D g) { - this.updateTickLabels(); - int max = 0; - Dimension dim; - int width, height; - g.setFont(this.tickLabelFont); - for (int i = 0; i < this.tickLabels.size(); i++) { - ChartText lab = this.tickLabels.get(i); - dim = Draw.getStringDimension(lab.getText(), g); - width = dim.width; - if (this.tickLabelAngle != 0) { - width = (int) (dim.getWidth() * Math.cos(this.tickLabelAngle * Math.PI / 180)); - height = dim.height; - width = Math.max(width, height); - } - if (max < width) { - max = width; - } - } - - return max; - } - - /** - * Get label string with maximum length - * - * @return Maximum length lable string - */ - public String getMaxLenLable() { - this.updateTickLabels(); - if (this.tickLabels.isEmpty()) { - return "1"; - } - - ChartText rlab = this.tickLabels.get(0); - for (ChartText lab : this.tickLabels) { - if (lab.getText().length() > rlab.getText().length()) { - rlab = lab; - } - } - - return rlab.getText(); - } - - /** - * Get tick label text with maximum length - * - * @return Maximum length tick label text - */ - public ChartText getMaxLenText() { - this.updateTickLabels(); - if (this.tickLabels.isEmpty()) { - return new ChartText("1"); - } - - ChartText rlab = this.tickLabels.get(0); - for (ChartText lab : this.tickLabels) { - if (lab.getText().length() > rlab.getText().length()) { - rlab = lab; - } - } - - return rlab; - } - - /** - * Get maximum tick label dimension - * @param g Graphics2D - * @return Maximum tick label dimension - */ - public Dimension getMaxTickDim(Graphics2D g) { - this.updateTickLabels(); - Dimension dim = new Dimension(); - if (this.tickLabels.isEmpty()) { - return dim; - } - - Dimension dim1; - double width = dim.getWidth(), height = dim.getHeight(); - for (int i = 0; i < this.tickLabels.size(); i++) { - ChartText ct = this.tickLabels.get(i); - ct.setAngle(this.tickLabelAngle); - dim1 = ct.getTrueDimension(g); - if (width < dim1.getWidth()){ - width = dim1.getWidth(); - } - if (height < dim1.getHeight()) { - height = dim1.getHeight(); - } - } - - dim.setSize(width, height); - return dim; - } - - /** - * Get tick label text with maximum lines - * - * @return Maximum lines tick label text - */ - public ChartText getMaxLinesText() { - this.updateTickLabels(); - if (this.tickLabels.isEmpty()) { - return new ChartText("1"); - } - - ChartText rlab = this.tickLabels.get(0); - for (ChartText lab : this.tickLabels) { - if (lab.getTexts().size() > rlab.getTexts().size()) { - rlab = lab; - } - } - - return rlab; - } - - /** - * Get maximum tick label line number - * - * @return Maximum tick label line number - */ - public int getMaxTickLableLines() { - this.updateTickLabels(); - if (this.tickLabels.isEmpty()) { - return 1; - } - - int ln = this.tickLabels.get(0).getLineNum(); - for (ChartText lab : this.tickLabels) { - if (lab.getLineNum() > ln) { - ln = lab.getLineNum(); - } - } - - return ln; - } - - /** - * Update lable gap - * - * @param g Graphics2D - * @param rect The rectangle - */ - public void updateLabelGap(Graphics2D g, Rectangle2D rect) { - if (this.getTickValues() == null) { - return; - } - - double len; - int n = this.getTickValues().length; - int nn; - if (this.xAxis) { - len = rect.getWidth(); - int labLen = this.getMaxLabelLength(g); - nn = (int) ((len * 0.8) / labLen); - } else { - len = rect.getHeight(); - FontMetrics metrics = g.getFontMetrics(this.label.getFont()); - nn = (int) (len / metrics.getHeight()); - } - if (nn == 0) { - nn = 1; - } - this.tickLabelGap = n / nn + 1; - } - - /** - * Update lable gap - * - * @param g Graphics2D - * @param len Length - * @return Label gap - */ - public int getLabelGap(Graphics2D g, double len) { - if (this.getTickValues() == null) { - return 1; - } - - int n = this.getTickValues().length; - int nn; - FontMetrics metrics = g.getFontMetrics(this.label.getFont()); - nn = (int) (len / metrics.getHeight()); - if (nn == 0) { - nn = 1; - } - return n / nn + 1; - } - - /** - * Set color to all elements - * - * @param c Color - */ - public void setColor_All(Color c) { - this.lineColor = c; - this.tickColor = c; - this.tickLabelColor = c; - if (this.label != null) - this.label.setColor(c); - } - - /** - * Draw axis - * - * @param g Graphics2D - * @param area Area - * @param plot XYPlot - */ - public void draw(Graphics2D g, Rectangle2D area, AbstractPlot2D plot) { - if (plot.getDrawExtent() == null) { - return; - } - if (this.xAxis) { - this.drawXAxis(g, area, plot); - } else { - this.drawYAxis(g, area, plot); - } - } - - private void drawXAxis(Graphics2D g, Rectangle2D area, AbstractPlot2D plot) { - double[] xy; - double x, sy = 0; - double miny = area.getY(); - double minx = area.getX(); - double maxx = area.getX() + area.getWidth(); - double maxy = area.getY() + area.getHeight(); - float labx, laby = (float)maxy; - - //Draw x axis - //Draw axis line - g.setColor(this.lineColor); - g.setStroke(this.getLineStroke()); - switch (this.positionType) { - case OUTERWARD: - if (this.location == Location.BOTTOM) - sy = maxy + this.position; - else - sy = miny - this.position; - break; - case AXES: - sy = miny + this.position * area.getHeight(); - break; - case DATA: - xy = plot.projToScreen(plot.getDrawExtent().minX, this.position, area); - sy = miny + xy[1]; - break; - } - g.draw(new Line2D.Double(minx, sy, maxx, sy)); - - //Draw tick lines - float len = 0; - if (this.drawTickLine) { - g.setColor(this.tickColor); - g.setStroke(this.tickStroke); - g.setFont(this.tickLabelFont); - String drawStr; - len = this.tickLength; - this.updateTickLabels(); - int n = 0; - while (n < this.getTickValues().length) { - double value = this.getTickValues()[n]; - - if (value >= this.minValue && value <= this.maxValue) { - //Draw tick line - xy = plot.projToScreen(value, plot.getDrawExtent().minY, area); - x = xy[0]; - x += minx; - if (this.location == Location.BOTTOM) { - if (this.insideTick) { - g.draw(new Line2D.Double(x, sy, x, sy - len)); - } else { - g.draw(new Line2D.Double(x, sy, x, sy + len)); - } - } else { - if (this.insideTick) { - g.draw(new Line2D.Double(x, sy, x, sy + len)); - } else { - g.draw(new Line2D.Double(x, sy, x, sy - len)); - } - } - - //Draw tick label - if (this.drawTickLabel && n < this.tickLabels.size()) { - ChartText chartText = this.tickLabels.get(n); - g.setFont(tickLabelFont); - if (this.location == Location.BOTTOM) { - if (this.insideTick){ - laby = (float)sy; - } else { - laby = (float) (sy + len); - } - laby += this.tickSpace; - } else { - if (this.insideTick){ - laby = (float)sy; - } else { - laby = (float) (sy - len); - } - laby -= this.tickSpace; - } - Dimension dim = Draw.getStringDimension(chartText.getText(), this.tickLabelAngle, g); - labx = (float) x; - for (String dstr : chartText.getTexts()) { - if (this.location == Location.BOTTOM) { - //Draw.drawString(g, labx, laby, dstr, XAlign.CENTER, YAlign.TOP, this.tickLabelAngle, true); - if (this.tickLabelAngle == 0) { - Draw.drawString(g, labx, laby, dstr, XAlign.CENTER, YAlign.TOP, true); - } else if (this.tickLabelAngle < 45) { - Draw.drawString(g, labx, laby, dstr, XAlign.RIGHT, YAlign.TOP, this.tickLabelAngle, true); - } else { - Draw.drawString(g, labx, laby, dstr, XAlign.RIGHT, YAlign.CENTER, this.tickLabelAngle, true); - } - laby += dim.getHeight() + chartText.getLineSpace(); - } else { - //Draw.drawString(g, labx, laby, dstr, XAlign.CENTER, YAlign.BOTTOM, this.tickLabelAngle, true); - if (this.tickLabelAngle == 0) { - Draw.drawString(g, labx, laby, dstr, XAlign.CENTER, YAlign.BOTTOM, true); - } else if (this.tickLabelAngle < 45) { - Draw.drawString(g, labx, laby, dstr, XAlign.LEFT, YAlign.BOTTOM, this.tickLabelAngle, true); - } else { - Draw.drawString(g, labx, laby, dstr, XAlign.LEFT, YAlign.CENTER, this.tickLabelAngle, true); - } - laby -= dim.getHeight() + chartText.getLineSpace(); - } - } - } - } - n += this.getTickLabelGap(); - - //Draw minor tick lines - if (this.isMinorTickVisible()) { - float minorLen = len - 2; - double sp; - sp = this.tickDeltaValue * this.getTickLabelGap() / this.minorTickNum; - if (this instanceof LogAxis) { - if (n >= this.getTickValues().length) { - break; - } - sp = (this.getTickValues()[n] - this.getTickValues()[n - 1]) / this.minorTickNum; - } - List xx = new ArrayList<>(); - if (n == 1) { - if (value > this.minValue + sp) { - double value1 = value; - for (int i = 0; i < this.minorTickNum - 1; i++) { - value1 = value1 - sp; - if (value1 <= this.minValue) { - break; - } - xy = plot.projToScreen(value1, plot.getDrawExtent().minY, area); - x = xy[0]; -// if (this.inverse) { -// x = area.getWidth() - x; -// } - x += minx; - xx.add(x); - } - } - } - for (int i = 0; i < this.minorTickNum - 1; i++) { - value = value + sp; - if (value >= this.maxValue) { - break; - } else if (value <= this.minValue) { - continue; - } - xy = plot.projToScreen(value, plot.getDrawExtent().minY, area); - x = xy[0]; -// if (this.inverse) { -// x = area.getWidth() - x; -// } - x += minx; - xx.add(x); - } - for (int i = 0; i < xx.size(); i++) { - x = xx.get(i); - if (this.location == Location.BOTTOM) { - if (this.insideTick) { - g.draw(new Line2D.Double(x, sy, x, sy - minorLen)); - } else { - g.draw(new Line2D.Double(x, sy, x, sy + minorLen)); - } - } else { - if (this.insideTick) { - g.draw(new Line2D.Double(x, sy, x, sy + minorLen)); - } else { - g.draw(new Line2D.Double(x, sy, x, sy - minorLen)); - } - } - } - } - } - //Time label - left - if (this.drawTickLabel) { - DateTimeFormatter format; - if (this instanceof TimeAxis) { - TimeAxis tAxis = (TimeAxis) this; - if (tAxis.isVarFormat()) { - drawStr = null; - switch (tAxis.getTimeUnit()) { - case MONTH: - format = DateTimeFormatter.ofPattern("yyyy"); - LocalDateTime cdate = JDateUtil.fromOADate(this.getTickValues()[0]); - drawStr = format.format(cdate); - break; - case DAY: - format = DateTimeFormatter.ofPattern("yyyy-MM"); - cdate = JDateUtil.fromOADate(this.getTickValues()[0]); - drawStr = format.format(cdate); - break; - case HOUR: - case MINUTE: - case SECOND: - format = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - cdate = JDateUtil.fromOADate(this.getTickValues()[0]); - drawStr = format.format(cdate); - break; - } - if (drawStr != null) { - labx = (float) minx; - laby = laby + this.tickSpace; - Draw.drawString(g, labx, laby, drawStr, XAlign.LEFT, YAlign.TOP, true); - laby += Draw.getStringDimension(drawStr, g).height + this.tickSpace; - } - } - } - } - } - - //Draw label - if (this.isDrawLabel()) { - x = (maxx - minx) / 2 + minx; - g.setFont(this.getLabelFont()); - g.setColor(this.getLabelColor()); - labx = (float)x; - this.label.setXAlign(XAlign.CENTER); - if (this.getLocation() == Location.BOTTOM) { - //laby += this.tickSpace; - this.label.setYAlign(YAlign.TOP); - } else { - //laby -= this.tickSpace; - this.label.setYAlign(YAlign.BOTTOM); - } - this.label.draw(g, labx, laby); - } - } - - private void drawYAxis(Graphics2D g, Rectangle2D area, AbstractPlot2D plot) { - double[] xy; - double x, y, sx = 0; - double miny = area.getY(); - double minx = area.getX(); - double maxx = area.getX() + area.getWidth(); - double maxy = area.getY() + area.getHeight(); - float labx, laby; - - //Draw y axis - //Draw axis line - g.setColor(this.getLineColor()); - g.setStroke(this.getLineStroke()); - switch (this.positionType) { - case OUTERWARD: - if (this.location == Location.LEFT) - sx = minx - this.position; - else - sx = maxx + this.position; - break; - case AXES: - sx = minx + this.position * area.getWidth(); - break; - case DATA: - xy = plot.projToScreen(this.position, plot.getDrawExtent().minY, area); - sx = minx + xy[0]; - break; - } - g.draw(new Line2D.Double(sx, maxy, sx, miny)); - - //Draw tick lines - float len = 0; - if (this.drawTickLine) { - g.setColor(this.getTickColor()); - g.setStroke(this.getTickStroke()); - g.setFont(this.getTickLabelFont()); - this.updateLabelGap(g, area); - len = this.getTickLength(); - this.updateTickLabels(); - String drawStr; - Dimension dim; - int n = 0; - while (n < this.getTickValues().length) { - double value = this.getTickValues()[n]; - xy = plot.projToScreen(plot.getDrawExtent().minX, value, area); - y = xy[1]; - y += area.getY(); - if (this.location == Location.LEFT) { - if (this.isInsideTick()) { - g.draw(new Line2D.Double(sx, y, sx + len, y)); - } else { - g.draw(new Line2D.Double(sx, y, sx - len, y)); - } - } else if (this.isInsideTick()) { - g.draw(new Line2D.Double(sx, y, sx - len, y)); - } else { - g.draw(new Line2D.Double(sx, y, sx + len, y)); - } - //Draw tick label - if (this.drawTickLabel && n < this.tickLabels.size()) { - drawStr = this.tickLabels.get(n).getText(); - g.setFont(this.tickLabelFont); - if (this.location == Location.LEFT) { - labx = (float) (sx - this.tickSpace); - if (!this.isInsideTick()) { - labx -= len; - } - laby = (float)y; - Draw.drawString(g, labx, laby, drawStr, XAlign.RIGHT, YAlign.CENTER, this.tickLabelAngle, true); - } else { - labx = (float) (sx + this.tickSpace); - if (!this.isInsideTick()) { - labx += len; - } - laby = (float)y; - Draw.drawString(g, labx, laby, drawStr, XAlign.LEFT, YAlign.CENTER, this.tickLabelAngle, true); - } - } - n += this.getTickLabelGap(); - - //Draw minor tick lines - if (this.isMinorTickVisible()) { - float minorLen = len - 2; - double sp; - sp = this.tickDeltaValue * this.getTickLabelGap() / this.minorTickNum; - if (this instanceof LogAxis) { - if (n >= this.getTickValues().length) { - break; - } - sp = (this.getTickValues()[n] - this.getTickValues()[n - 1]) / this.minorTickNum; - } - List yy = new ArrayList<>(); - if (n == 1) { - if (value > this.minValue + sp) { - double value1 = value; - for (int i = 0; i < this.minorTickNum - 1; i++) { - value1 = value1 - sp; - if (value1 <= this.minValue) { - break; - } - xy = plot.projToScreen(plot.getDrawExtent().minX, value1, area); - y = xy[1]; - y += miny; - yy.add(y); - } - } - } - for (int i = 0; i < this.minorTickNum - 1; i++) { - value = value + sp; - if (value >= this.maxValue) { - break; - } else if (value <= this.minValue) { - continue; - } - xy = plot.projToScreen(plot.getDrawExtent().minX, value, area); - y = xy[1]; - y += miny; - yy.add(y); - } - for (int i = 0; i < yy.size(); i++) { - y = yy.get(i); - if (this.location == Location.LEFT) { - if (this.isInsideTick()) { - g.draw(new Line2D.Double(sx, y, sx + minorLen, y)); - } else { - g.draw(new Line2D.Double(sx, y, sx - minorLen, y)); - } - } else if (this.isInsideTick()) { - g.draw(new Line2D.Double(sx, y, sx - minorLen, y)); - } else { - g.draw(new Line2D.Double(sx, y, sx + minorLen, y)); - } - } - } - } - } - - //Draw label - XAlign x_align = XAlign.CENTER; - YAlign y_align = YAlign.BOTTOM; - if (this.isDrawLabel()) { - if (this.location == Location.LEFT) { - x = sx - this.tickSpace; - if (this.drawTickLine) { - if (!this.isInsideTick()) { - x -= len; - } - if (this.drawTickLabel) { - x = x - this.getMaxLabelLength(g) - this.tickSpace; - } - } - y = (maxy - miny) / 2 + miny; - if (this.label.getAngle() == 90) { - x_align = XAlign.CENTER; - y_align = YAlign.BOTTOM; - } else if (this.label.getAngle() == -90) { - x_align = XAlign.CENTER; - y_align = YAlign.TOP; - x -= this.label.getDimension(g).height; - } else if (this.label.getAngle() == 0) { - x_align = XAlign.RIGHT; - y_align = YAlign.CENTER; - } else if (Math.abs(this.label.getAngle()) == 180) { - x_align = XAlign.LEFT; - y_align = YAlign.TOP; - y -= this.label.getDimension(g).height; - } else if (this.label.getAngle() > 0 && this.label.getAngle() < 90) { - x_align = XAlign.RIGHT; - y_align = YAlign.TOP; - } - } else { - x = sx + this.tickSpace; - if (this.drawTickLine) { - if (!this.isInsideTick()) { - x += len; - } - if (this.drawTickLabel){ - x = x + this.getMaxLabelLength(g) + 5; - } - } - y = (maxy - miny) / 2 + miny; - y_align = YAlign.TOP; - } - this.label.setXAlign(x_align); - this.label.setYAlign(y_align); - this.label.draw(g, (float)x, (float)y); - } - } - - /** - * Get x axis height - * @param g Graphics2D - * @return Axis height - */ - public int getXAxisHeight(Graphics2D g) { - if (!this.isVisible()) { - return 0; - } - - int height = 0; - if (!this.insideTick){ - height += this.tickLength; - } - this.updateTickLabels(); - if (this.isDrawTickLabel() && this.tickLabels.size() > 0) { - Dimension dim = this.getMaxTickDim(g); -// ChartText text = this.getMaxLenText(); -// text.setAngle(this.tickLabelAngle); -// height += this.tickSpace + text.getTrueDimension(g).height; - height += this.tickSpace + dim.height; - Dimension dim1 = Draw.getStringDimension("Test", g); - if (this instanceof TimeAxis) { - height += dim1.height + this.tickSpace; - } - } - if (this.isDrawLabel()) { - g.setFont(this.getLabelFont()); - Dimension dim = Draw.getStringDimension(this.getLabel().getText(), g); - height += dim.height + this.tickSpace * 2; - } - - return height; - } - - /** - * Get y axis width - * @param g Graphics2D - * @return Axis width - */ - public int getYAxisWidth(Graphics2D g) { - if (!this.isVisible()) { - return 0; - } - - int width = 0; - if (this.isDrawTickLabel()) { - width += this.getMaxLabelLength(g) + this.tickSpace + this.tickSpace; - } - if (!this.isInsideTick()) { - width += this.getTickLength(); - } - if (this.isDrawLabel()) { - g.setFont(this.getLabelFont()); - Dimension dim = Draw.getStringDimension(this.getLabel().getText(), g); - width += dim.height + 10 - this.tickSpace; - } - - return width; - } - - @Override - public Object clone() throws CloneNotSupportedException { - Axis o = null; - try { - o = (Axis) super.clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - - return o; - } - - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/AxisProperty.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/AxisProperty.java deleted file mode 100644 index b39183c7..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/AxisProperty.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.axis; - -/** - * - * @author yaqiang - */ -public class AxisProperty { - // - private boolean visible; - private boolean drawTick; - private boolean drawLabel; - // - // - /** - * Constructor - */ - public AxisProperty(){ - this.visible = true; - this.drawTick = true; - this.drawLabel = true; - } - - /** - * Constructor - * @param visible Is visible - * @param drawTick Is draw tick - * @param drawLabel Is draw label - */ - public AxisProperty(boolean visible, boolean drawTick, boolean drawLabel){ - this.visible = visible; - this.drawTick = drawTick; - this.drawLabel = drawLabel; - } - // - // - /** - * If is visible - * - * @return Boolean - */ - public boolean isVisible() { - return visible; - } - - /** - * Set if is visible - * - * @param value Boolean - */ - public void setVisible(boolean value) { - visible = value; - } - - /** - * Get if draw tick lines - * @return Boolean - */ - public boolean isDrawTick(){ - return this.drawTick; - } - - /** - * Set if draw tick lines - * @param value Boolean - */ - public void setDrawTick(boolean value){ - this.drawTick = value; - } - - /** - * Get if draw label - * - * @return Boolean - */ - public boolean isDrawLabel() { - return this.drawLabel; - } - - /** - * Set if draw label - * - * @param value Boolean - */ - public void setDrawLabel(boolean value) { - this.drawLabel = value; - } - // - // - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/LogAxis.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/LogAxis.java deleted file mode 100644 index 1bcd167a..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/LogAxis.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.axis; - -import java.util.ArrayList; -import java.util.List; -import org.meteoinfo.chart.ChartText; -import org.meteoinfo.common.DataConvert; -import org.meteoinfo.common.MIMath; - -/** - * - * @author Yaqiang Wang - */ -public class LogAxis extends Axis { - // - // - // - /** - * Constructor - * @param axis Axis - */ - public LogAxis(Axis axis){ - super(axis); - } - // - // - // - // - /** - * Update tick values - */ - @Override - public void updateTickValues() { - double[] r = MIMath.getIntervalValues_Log(this.getMinValue(), this.getMaxValue()); - this.setTickValues((double[]) r); - this.setTickDeltaValue(1); - } - - @Override - public void updateTickLabels(){ - List tls = new ArrayList<>(); - String lab; - if (this.isAutoTick()) { - if (this.getTickValues() == null) { - return; - } - for (double value : this.getTickValues()) { - lab = String.valueOf(value); - lab = DataConvert.removeTailingZeros(lab); - tls.add(new ChartText(lab)); - } - - List values = new ArrayList<>(); - for (ChartText tl : tls){ - values.add(Double.parseDouble(tl.getText())); - } - tls.clear(); - int e; - for (Double v : values){ - e = (int) Math.floor(Math.log10(v)); - tls.add(new ChartText("$10^{" + String.valueOf(e) + "}$")); - } - } else { - for (int i = 0; i < this.getTickLocations().size(); i++) { - if (i >= this.getTickLabels().size()) { - break; - } - double v = this.getTickLocations().get(i); - if (v >= this.getMinValue() && v <= this.getMaxValue()) { - tls.add(this.getTickLabels().get(i)); - } - } - } - - this.setTickLabels(tls); - } - - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/LonLatAxis.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/LonLatAxis.java deleted file mode 100644 index f86fe715..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/LonLatAxis.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.axis; - -import java.util.ArrayList; -import java.util.List; -import org.meteoinfo.chart.ChartText; -import org.meteoinfo.common.DataConvert; - -/** - * - * @author wyq - */ -public class LonLatAxis extends Axis implements Cloneable { - - private boolean drawDegreeSymbol; - private boolean longitude; - private boolean degreeSpace; - - /** - * Constructor - * @param label Axis label - * @param isX Is x axis or not - * @param longitude Is longitude or not - */ - public LonLatAxis(String label, boolean isX, boolean longitude){ - super(label, isX); - - this.drawDegreeSymbol = true; - this.longitude = longitude; - this.degreeSpace = false; - } - - /** - * Constructor - * @param label Axis label - * @param isX Is x axis or not - */ - public LonLatAxis(String label, boolean isX){ - this(label, isX, isX); - } - - /** - * Constructor - * @param axis Axis - */ - public LonLatAxis(Axis axis) { - this(axis.getLabel().getText(), axis.isXAxis()); - this.autoTick = axis.autoTick; - this.drawLabel = axis.drawLabel; - this.drawTickLabel = axis.drawTickLabel; - this.drawTickLine = axis.drawTickLine; - this.insideTick = axis.insideTick; - this.inverse = axis.inverse; - this.setLabelColor(axis.getLabelColor()); - this.lineWidth = axis.lineWidth; - this.lineStyle = axis.lineStyle; - this.location = axis.location; - this.maxValue = axis.maxValue; - this.minValue = axis.minValue; - this.minorTickNum = axis.minorTickNum; - this.minorTickVisible = axis.minorTickVisible; - //this.setShift(axis.getShift()); - this.tickColor = axis.tickColor; - this.tickDeltaValue = axis.tickDeltaValue; - this.tickLabelColor = axis.tickLabelColor; - this.tickLabelFont = axis.tickLabelFont; - this.tickLength = axis.tickLength; - this.visible = axis.visible; - this.positionType = axis.positionType; - this.position = axis.position; - } - - /** - * Get if draw degree symbol - * @return Boolean - */ - public boolean isDrawDegreeSymbol(){ - return this.drawDegreeSymbol; - } - - /** - * Set if draw degree symbol - * @param value Boolean - */ - public void setDrawDegreeSymbol(boolean value){ - this.drawDegreeSymbol = value; - } - - /** - * Get is longitude or not - * @return Longitude or not - */ - public boolean isLongitude(){ - return this.longitude; - } - - /** - * Set is longitude or not - * @param value Longitude or not - */ - public void setLongitude(boolean value){ - this.longitude = value; - } - - /** - * Get if using space between degree and E/W/S/N - * @return Boolean - */ - public boolean isDegreeSpace() { - return this.degreeSpace; - } - - /** - * Set if using space between degree and E/W/S/N - * @param value Boolean - */ - public void setDegreeSpace(boolean value) { - this.degreeSpace = value; - } - - /** - * Get tick labels - * - */ - @Override - public void updateTickLabels() { - List tls = new ArrayList<>(); - String lab; - for (double v : this.getTickValues()) { - double value = v; - if (value > 180) { - value = value - 360; - } - lab = String.valueOf(value); - lab = DataConvert.removeTailingZeros(lab); - if (this.isLongitude()) { - if (value == -180) { - lab = "180"; - } else if (!(value == 0 || value == 180)) { - if (lab.substring(0, 1).equals("-")) { - lab = lab.substring(1) + "W"; - } else { - lab = lab + "E"; - } - } - } else { - if (!(value == 0)) { - if (lab.substring(0, 1).equals("-")) { - lab = lab.substring(1) + "S"; - } else { - lab = lab + "N"; - } - } - } - if (drawDegreeSymbol) { - if (lab.endsWith("E") || lab.endsWith("W") || lab.endsWith("N") || lab.endsWith("S")) { - if (degreeSpace) { - lab = lab.substring(0, lab.length() - 1) + String.valueOf((char) 186) + " " + - lab.substring(lab.length() - 1); - } else { - lab = lab.substring(0, lab.length() - 1) + String.valueOf((char) 186) + - lab.substring(lab.length() - 1); - } - } else { - lab = lab + String.valueOf((char) 186); - } - } - tls.add(new ChartText(lab)); - } - - this.setTickLabels(tls); - } - - @Override - public Object clone() throws CloneNotSupportedException { - return (LonLatAxis)super.clone(); - } -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/PositionType.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/PositionType.java deleted file mode 100644 index 713f7996..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/PositionType.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.axis; - -/** - * - * @author yaqiang - */ -public enum PositionType { - OUTERWARD, - AXES, - DATA -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/ProjLonLatAxis.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/ProjLonLatAxis.java deleted file mode 100644 index afce49b4..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/ProjLonLatAxis.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.axis; - -import java.util.ArrayList; -import java.util.List; -import org.meteoinfo.chart.ChartText; -import org.meteoinfo.common.DataConvert; -import org.meteoinfo.common.MIMath; -import org.meteoinfo.projection.KnownCoordinateSystems; -import org.meteoinfo.projection.ProjectionInfo; -import org.meteoinfo.projection.Reproject; - -/** - * - * @author Yaqiang Wang - */ -public class ProjLonLatAxis extends LonLatAxis{ - // - private ProjectionInfo proj; - private double x_y; - // - // - /** - * Constructor - * @param label Label - * @param isX Is x/longitude axis or not - * @param proj Projection - */ - public ProjLonLatAxis(String label, boolean isX, ProjectionInfo proj){ - super(label, isX, isX); - this.proj = proj; - } - - /** - * Constructor - * @param label Label - * @param isX Is x/longitude axis or not - * @param proj Projection - * @param xy X or Y value of the axis - using for projection - */ - public ProjLonLatAxis(String label, boolean isX, ProjectionInfo proj, double xy){ - super(label, isX); - this.proj = proj; - this.x_y = xy; - } - // - // - /** - * Get projection - * @return Projection - */ - public ProjectionInfo getProject(){ - return this.proj; - } - - /** - * Set projection - * @param value Projection - */ - public void setProject(ProjectionInfo value){ - this.proj = value; - } - - /** - * Get x_y value - * @return x_y value - */ - public double getX_Y(){ - return this.x_y; - } - - /** - * Set x_y value - * @param value x_y value - */ - public void setX_Y(double value){ - this.x_y = value; - //this.updateTickValues(); - } - // - // - /** - * Update tick values - */ - @Override - public void updateTickValues() { - if (this.proj == null) - return; - - double min = this.getMinValue(); - double max = this.getMaxValue(); - //Calculate min and max lon or lat - ProjectionInfo toproj = KnownCoordinateSystems.geographic.world.WGS1984; - double minv, maxv; - double[][] points = new double[2][]; - if (this.isXAxis()){ - points[0] = new double[]{min, this.x_y}; - points[1] = new double[]{max, this.x_y}; - Reproject.reprojectPoints(points, this.proj, toproj); - minv = points[0][0]; - maxv = points[1][0]; - } else { - points[0] = new double[]{this.x_y, min}; - points[1] = new double[]{this.x_y, max}; - Reproject.reprojectPoints(points, this.proj, toproj); - minv = points[0][1]; - maxv = points[1][1]; - } - //Get tick values - List r = MIMath.getIntervalValues1(minv, maxv); - double[] values = (double[])r.get(0); - double[] tickValues = new double[values.length]; - - this.setTickValues((double[]) r.get(0)); - this.setTickDeltaValue((Double) r.get(1)); - } - - /** - * Get tick labels - * - */ - @Override - public void updateTickLabels() { - List tls = new ArrayList<>(); - String lab; - for (double v : this.getTickValues()) { - double value = v; - if (value > 180) { - value = value - 360; - } - lab = String.valueOf(value); - lab = DataConvert.removeTailingZeros(lab); - if (this.isXAxis()) { - if (value == -180) { - lab = "180"; - } else if (!(value == 0 || value == 180)) { - if (lab.substring(0, 1).equals("-")) { - lab = lab.substring(1) + "W"; - } else { - lab = lab + "E"; - } - } - } else { - if (!(value == 0)) { - if (lab.substring(0, 1).equals("-")) { - lab = lab.substring(1) + "S"; - } else { - lab = lab + "N"; - } - } - } - if (this.isDrawDegreeSymbol()) { - 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); - } else { - lab = lab + String.valueOf((char) 186); - } - } - tls.add(new ChartText(lab)); - } - - this.setTickLabels(tls); - } - - @Override - public Object clone() throws CloneNotSupportedException { - return (ProjLonLatAxis)super.clone(); - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/TimeAxis.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/TimeAxis.java deleted file mode 100644 index 8694fa7c..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/TimeAxis.java +++ /dev/null @@ -1,379 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.axis; - -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.List; -import org.meteoinfo.chart.ChartText; -import org.meteoinfo.common.util.JDateUtil; - -/** - * - * @author wyq - */ -public class TimeAxis extends Axis implements Cloneable { - - private String timeFormat; - private TimeUnit timeUnit; - private boolean varFormat; - - /** - * Constructor - * - * @param label Axis label - * @param xAxis If is x axis - */ - public TimeAxis(String label, boolean xAxis) { - super(label, xAxis); - - this.timeFormat = "yyyy-MM-dd"; - this.timeUnit = TimeUnit.DAY; - this.varFormat = true; - } - - /** - * Constructor - * @param axis Axis - */ - public TimeAxis(Axis axis) { - this(axis.getLabel().getText(), axis.isXAxis()); - this.autoTick = axis.autoTick; - this.drawLabel = axis.drawLabel; - this.drawTickLabel = axis.drawTickLabel; - this.drawTickLine = axis.drawTickLine; - this.insideTick = axis.insideTick; - this.inverse = axis.inverse; - this.setLabelColor(axis.getLabelColor()); - this.lineWidth = axis.lineWidth; - this.lineStyle = axis.lineStyle; - this.location = axis.location; - this.maxValue = axis.maxValue; - this.minValue = axis.minValue; - this.minorTickNum = axis.minorTickNum; - this.minorTickVisible = axis.minorTickVisible; - //this.setShift(axis.getShift()); - this.tickColor = axis.tickColor; - this.tickDeltaValue = axis.tickDeltaValue; - this.tickLabelColor = axis.tickLabelColor; - this.tickLabelFont = axis.tickLabelFont; - this.tickLength = axis.tickLength; - this.visible = axis.visible; - this.positionType = axis.positionType; - this.position = axis.position; - } - - /** - * Get time format - * - * @return Time format - */ - public String getTimeFormat() { - return this.timeFormat; - } - - /** - * Set time format - * - * @param value - */ - public void setTimeFormat(String value) { - this.timeFormat = value; - if (value.contains("s")) { - this.timeUnit = TimeUnit.SECOND; - } else if (value.contains("m")) { - this.timeUnit = TimeUnit.MINUTE; - } else if (value.contains("H")) { - this.timeUnit = TimeUnit.HOUR; - } else if (value.contains("d")) { - this.timeUnit = TimeUnit.DAY; - } else if (value.contains("M")) { - this.timeUnit = TimeUnit.MONTH; - } else { - this.timeUnit = TimeUnit.YEAR; - } - this.varFormat = false; - } - - /** - * Get time unit - * - * @return Time unit - */ - public TimeUnit getTimeUnit() { - return this.timeUnit; - } - - /** - * Set time unit - * - * @param value Time unit - */ - public void setTimeUnit(TimeUnit value) { - this.timeUnit = value; - } - - /** - * If variable time format - * @return Boolean - */ - public boolean isVarFormat(){ - return this.varFormat; - } - - /** - * Set if variable format - * @param value Boolean - */ - public void setVarFormat(boolean value){ - this.varFormat = value; - } - - /** - * Get tick labels - * - */ - @Override - public void updateTickLabels() { - //this.updateTimeTickValues(); - List tls = new ArrayList<>(); - String lab; - DateTimeFormatter format = DateTimeFormatter.ofPattern(this.timeFormat); - LocalDateTime date; - double[] tvs = this.getTickValues(); - if (tvs != null){ - for (double value : this.getTickValues()) { - date = JDateUtil.fromOADate(value); - lab = format.format(date); - tls.add(new ChartText(lab)); - } - } - - this.setTickLabels(tls); - } - - /** - * Update time tick values - */ - @Override - public void updateTickValues() { - if (this.varFormat) - updateTimeTickValues_var(); - else { - if (this.timeUnit != null) - updateTimeTickValues(); - } - } - - /** - * Update time tick values - */ - private void updateTimeTickValues() { - LocalDateTime sdate = JDateUtil.fromOADate(this.getMinValue()); - LocalDateTime edate = JDateUtil.fromOADate(this.getMaxValue()); - LocalDateTime ssdate = LocalDateTime.of(sdate.getYear(), sdate.getMonthValue(), sdate.getDayOfMonth(), - sdate.getHour(), sdate.getMinute(), sdate.getSecond()); - - List dates = new ArrayList<>(); - switch (this.timeUnit) { - case YEAR: - sdate = LocalDateTime.of(sdate.getYear(), 1, 1, 0, 0, 0); - if (!sdate.isBefore(ssdate)) { - dates.add(sdate); - } - while (!sdate.isAfter(edate)) { - sdate = sdate.withYear(sdate.getYear() + 1); - dates.add(sdate); - } - break; - case MONTH: - sdate = LocalDateTime.of(sdate.getYear(), sdate.getMonthValue(), 1, 0, 0, 0); - if (!sdate.isBefore(ssdate)) { - dates.add(sdate); - } - while (!sdate.isAfter(edate)) { - sdate = sdate.plusMonths(1); - if (!sdate.isBefore(ssdate)) { - dates.add(sdate); - } - } - break; - case DAY: - sdate = LocalDateTime.of(sdate.getYear(), sdate.getMonthValue(), sdate.getDayOfMonth(), - 0, 0, 0); - if (!sdate.isBefore(ssdate)) { - dates.add(sdate); - } - while (!sdate.isAfter(edate)) { - sdate = sdate.plusDays(1); - if (sdate.isBefore(edate)) { - dates.add(sdate); - } - } - break; - case HOUR: - sdate = LocalDateTime.of(sdate.getYear(), sdate.getMonthValue(), sdate.getDayOfMonth(), - sdate.getHour(), 0, 0); - if (!sdate.isBefore(ssdate)) { - dates.add(sdate); - } - while (!sdate.isAfter(edate)) { - sdate = sdate.plusHours(1); - if (sdate.isBefore(edate)) { - dates.add(sdate); - } - } - break; - case MINUTE: - sdate = ssdate.withSecond(0); - if (!sdate.isBefore(ssdate)) { - dates.add(sdate); - } - while (!sdate.isAfter(edate)) { - sdate = sdate.plusMinutes(1); - if (sdate.isBefore(edate)) { - dates.add(sdate); - } - } - break; - case SECOND: - if (!sdate.isBefore(ssdate)) { - dates.add(sdate); - } - while (!sdate.isAfter(edate)) { - sdate = sdate.plusSeconds(1); - if (sdate.isBefore(edate)) { - dates.add(sdate); - } - } - break; - } - - double[] tvs = new double[dates.size()]; - for (int i = 0; i < dates.size(); i++) { - tvs[i] = JDateUtil.toOADate(dates.get(i)); - } - this.setTickValues(tvs); - } - - /** - * Update time tick values - */ - private void updateTimeTickValues_var() { - LocalDateTime sdate = JDateUtil.fromOADate(this.getMinValue()); - LocalDateTime edate = JDateUtil.fromOADate(this.getMaxValue()); - LocalDateTime ssdate = sdate; - - List dates = new ArrayList<>(); - sdate = ssdate.plusYears(5); - if (sdate.isBefore(edate)) { - this.timeFormat = "yyyy"; - this.timeUnit = TimeUnit.YEAR; - sdate = ssdate.withMonth(1); - sdate = ssdate.withDayOfMonth(1); - sdate = ssdate.withHour(0); - sdate = ssdate.withMinute(0); - sdate = ssdate.withSecond(0); - if (!sdate.isBefore(ssdate)) { - dates.add(sdate); - } - while (!sdate.isAfter(edate)) { - sdate = sdate.plusYears(1); - if (sdate.isBefore(edate)) - dates.add(sdate); - } - } else { - sdate = ssdate.plusMonths(5); - if (sdate.isBefore(edate)) { - this.timeFormat = "M"; - this.timeUnit = TimeUnit.MONTH; - sdate = ssdate.withDayOfMonth(1); - sdate = ssdate.withHour(0); - sdate = ssdate.withMinute(0); - sdate = ssdate.withSecond(0); - if (!sdate.isBefore(ssdate)) { - dates.add(sdate); - } - while (!sdate.isAfter(edate)) { - sdate = sdate.plusMonths(1); - if (sdate.isBefore(edate)) - dates.add(sdate); - } - } else { - sdate = ssdate.plusDays(5); - if (sdate.isBefore(edate)) { - this.timeFormat = "d"; - this.timeUnit = TimeUnit.DAY; - sdate = ssdate.withHour(0); - sdate = ssdate.withMinute(0); - sdate = ssdate.withSecond(0); - if (!sdate.isBefore(ssdate)) { - dates.add(sdate); - } - while (!sdate.isAfter(edate)) { - sdate = sdate.plusDays(1); - if (sdate.isBefore(edate)) - dates.add(sdate); - } - } else { - sdate = ssdate.plusHours(5); - if (sdate.isBefore(edate)) { - this.timeFormat = "H"; - this.timeUnit = TimeUnit.HOUR; - sdate = ssdate.withMinute(0); - sdate = ssdate.withSecond(0); - if (!sdate.isBefore(ssdate)) { - dates.add(sdate); - } - while (!sdate.isAfter(edate)) { - sdate = sdate.plusHours(1); - if (sdate.isBefore(edate)) - dates.add(sdate); - } - } else { - sdate = ssdate.plusMinutes(5); - if (sdate.isBefore(edate)) { - this.timeFormat = "HH:mm"; - this.timeUnit = TimeUnit.MINUTE; - sdate = ssdate.withSecond(0); - if (!sdate.isBefore(ssdate)) { - dates.add(sdate); - } - while (!sdate.isAfter(edate)) { - sdate = sdate.plusMinutes(1); - if (sdate.isBefore(edate)) - dates.add(sdate); - } - } else { - this.timeFormat = "HH:mm:ss"; - this.timeUnit = TimeUnit.SECOND; - if (!sdate.isBefore(ssdate)) { - dates.add(sdate); - } - while (!sdate.isAfter(edate)) { - sdate = sdate.plusSeconds(1); - if (sdate.isBefore(edate)) - dates.add(sdate); - } - } - } - } - } - } - - double[] tvs = new double[dates.size()]; - for (int i = 0; i < dates.size(); i++) { - tvs[i] = JDateUtil.toOADate(dates.get(i)); - } - this.setTickValues(tvs); - } - - @Override - public Object clone() throws CloneNotSupportedException { - return (TimeAxis) super.clone(); - } -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/TimeUnit.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/TimeUnit.java deleted file mode 100644 index f5fca947..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/axis/TimeUnit.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.axis; - -/** - * - * @author yaqiang - */ -public enum TimeUnit { - YEAR, - MONTH, - DAY, - HOUR, - MINUTE, - SECOND -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/AbstractPlot2D.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/AbstractPlot2D.java deleted file mode 100644 index 7fcd0727..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/AbstractPlot2D.java +++ /dev/null @@ -1,1418 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.plot; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; -import java.awt.geom.Line2D; -import java.awt.geom.Rectangle2D; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.meteoinfo.chart.ChartLegend; -import org.meteoinfo.chart.ChartText; -import org.meteoinfo.chart.ChartWindArrow; -import org.meteoinfo.chart.LegendPosition; -import org.meteoinfo.chart.Location; -import org.meteoinfo.chart.Margin; -import org.meteoinfo.chart.axis.Axis; -import org.meteoinfo.chart.axis.LogAxis; -import org.meteoinfo.common.Extent; -import org.meteoinfo.common.PointF; -import org.meteoinfo.drawing.Draw; - -/** - * - * @author wyq - */ -public abstract class AbstractPlot2D extends Plot { - - // - protected Color background; - //private boolean drawBackground; - private Color selectColor = Color.yellow; - private Extent extent; - private Extent drawExtent; - private final Map axis; - private Location xAxisLocation; - private Location yAxisLocation; - private PlotOrientation orientation; - private final GridLine gridLine; - private boolean drawTopAxis; - private boolean drawRightAxis; - private boolean drawNeatLine; - private ChartText title; - private ChartText leftTitle; - private ChartText rightTitle; - private List legends; - private List texts; - private ChartWindArrow windArrow; - private boolean autoAspect = true; - private double aspect = 1; - protected boolean clip = true; - - // - // - /** - * Constructor - */ - public AbstractPlot2D() { - super(); - this.background = null; - //this.drawBackground = false; - this.drawExtent = new Extent(0, 1, 0, 1); - //this.xAxis = new Axis("X", true); - //this.yAxis = new Axis("Y", false); - this.axis = new HashMap<>(); - this.axis.put(Location.BOTTOM, new Axis("X", true, Location.BOTTOM)); - this.axis.put(Location.LEFT, new Axis("Y", false, Location.LEFT)); - this.axis.put(Location.TOP, new Axis("X", true, Location.TOP, false)); - this.axis.put(Location.RIGHT, new Axis("Y", false, Location.RIGHT, false)); - this.xAxisLocation = Location.BOTTOM; - this.yAxisLocation = Location.RIGHT; - this.orientation = PlotOrientation.VERTICAL; - this.gridLine = new GridLine(); - this.drawTopAxis = true; - this.drawRightAxis = true; - this.drawNeatLine = false; - this.legends = new ArrayList<>(); - this.texts = new ArrayList<>(); - } - // - - // - /** - * Get title - * - * @return Title - */ - public ChartText getTitle() { - return this.title; - } - - /** - * Set title - * - * @param value Title - */ - public void setTitle(ChartText value) { - this.title = value; - } - - /** - * Set title - * - * @param text Title text - */ - public void setTitle(String text) { - if (this.title == null) { - this.title = new ChartText(text); - } else { - this.title.setText(text); - } - } - - /** - * Get selected color - * - * @return Selected color - */ - public Color getSelectedColor() { - return this.selectColor; - } - - /** - * Set selected color - * - * @param value Selected color - */ - public void setSelectedColor(Color value) { - this.selectColor = value; - } - - /** - * Get left sub title - * - * @return Left sub title - */ - public ChartText getLeftTitle() { - return leftTitle; - } - - /** - * Set left sub title - * - * @param value Left sub title - */ - public void setLeftTitle(ChartText value) { - leftTitle = value; - } - - /** - * Set left sub title - * - * @param text Title text - */ - public void setLeftTitle(String text) { - if (this.leftTitle == null) { - this.leftTitle = new ChartText(text); - } else { - this.leftTitle.setText(text); - } - } - - /** - * Get right sub title - * - * @return Right sub title - */ - public ChartText getRightTitle() { - return rightTitle; - } - - /** - * Set right sub title - * - * @param value Right sub title - */ - public void setRightTitle(ChartText value) { - rightTitle = value; - } - - /** - * Set right sub title - * - * @param text Title text - */ - public void setRightTitle(String text) { - if (this.rightTitle == null) { - this.rightTitle = new ChartText(text); - } else { - this.rightTitle.setText(text); - } - } - - /** - * Get legends - * - * @return Legends - */ - public List getLegends() { - return this.legends; - } - - /** - * Get chart legend - * - * @param idx Index - * @return Chart legend - */ - public ChartLegend getLegend(int idx) { - if (this.legends.isEmpty()) { - return null; - } else { - return this.legends.get(idx); - } - } - - /** - * Get chart legend - * - * @return Chart legend - */ - public ChartLegend getLegend() { - if (this.legends.isEmpty()) { - return null; - } else { - return this.legends.get(this.legends.size() - 1); - } - } - - /** - * Set chart legend - * - * @param value Legend - */ - public void setLegend(ChartLegend value) { - this.legends.clear(); - this.legends.add(value); - } - - /** - * Set legends - * - * @param value Legends - */ - public void setLegends(List value) { - this.legends = value; - } - -// /** -// * Get if draw legend -// * -// * @return If draw legend -// */ -// public boolean isDrawLegend() { -// return this.drawLegend; -// } -// - /** - * Set if draw legend - * - * @param value Boolean - */ - public void setDrawLegend(boolean value) { - //this.drawLegend = value; - //this.updateLegendScheme(); - } - - /** - * Get draw extent - * - * @return Draw extent - */ - public Extent getDrawExtent() { - return this.drawExtent; - } - - /** - * Set draw extent - * - * @param extent Extent - */ - public void setDrawExtent(Extent extent) { - this.drawExtent = extent; - this.getAxis(Location.BOTTOM).setMinMaxValue(extent.minX, extent.maxX); - this.getAxis(Location.TOP).setMinMaxValue(extent.minX, extent.maxX); - this.getAxis(Location.LEFT).setMinMaxValue(extent.minY, extent.maxY); - this.getAxis(Location.RIGHT).setMinMaxValue(extent.minY, extent.maxY); - } - - /** - * Set draw extent - * - * @param extent Extent - */ - public void setDrawExtent1(Extent extent) { - this.drawExtent = extent; - } - - /** - * Get extent - * - * @return Extent - */ - public Extent getExtent() { - return this.extent; - } - - /** - * Set extent - * - * @param extent Extent - */ - public void setExtent(Extent extent) { - this.extent = extent; - } - - /** - * Update draw extent - */ - public void updateDrawExtent() { - this.getAxis(Location.BOTTOM).setMinMaxValue(drawExtent.minX, drawExtent.maxX); - this.getAxis(Location.TOP).setMinMaxValue(drawExtent.minX, drawExtent.maxX); - this.getAxis(Location.LEFT).setMinMaxValue(drawExtent.minY, drawExtent.maxY); - this.getAxis(Location.RIGHT).setMinMaxValue(drawExtent.minY, drawExtent.maxY); - } - - /** - * Get background - * - * @return Background - */ - public Color getBackground() { - return this.background; - } - - /** - * Set background - * - * @param value Background - */ - public void setBackground(Color value) { - this.background = value; - } - -// /** -// * Get if draw background -// * -// * @return Boolean -// */ -// public boolean isDrawBackground() { -// return this.drawBackground; -// } - -// /** -// * Set if draw background -// * -// * @param value Boolean -// */ -// public void setDrawBackground(boolean value) { -// this.drawBackground = value; -// } - - @Override - public PlotType getPlotType() { - return PlotType.XY; - } - - /** - * Get bottom x axis - * - * @return Bottom x aixs - */ - public Axis getXAxis() { - return this.axis.get(Location.BOTTOM); - } - - /** - * Set x axis - * - * @param axis Axis - * @throws java.lang.CloneNotSupportedException - */ - public void setXAxis(Axis axis) throws CloneNotSupportedException { - axis.setLocation(Location.BOTTOM); - this.axis.put(Location.BOTTOM, axis); - Axis topAxis = (Axis) axis.clone(); - topAxis.setLocation(Location.TOP); - this.axis.put(Location.TOP, topAxis); - } - - /** - * Get left y axis - * - * @return Left y axis - */ - public Axis getYAxis() { - return this.axis.get(Location.LEFT); - } - - /** - * Set y axis - * - * @param axis Axis - * @throws java.lang.CloneNotSupportedException - */ - public void setYAxis(Axis axis) throws CloneNotSupportedException { - axis.setLocation(Location.LEFT); - this.axis.put(Location.LEFT, axis); - Axis rightAxis = (Axis) axis.clone(); - rightAxis.setLocation(Location.RIGHT); - this.axis.put(Location.RIGHT, rightAxis); - } - - /** - * Get axis - * - * @param loc Axis location - * @return Axis - */ - public Axis getAxis(Location loc) { - return this.axis.get(loc); - } - - /** - * Get x axis location - * - * @return X axis location - */ - public Location getXAxisLocation() { - return this.xAxisLocation; - } - - /** - * Set x axis location - * - * @param value X axis location - */ - public void setXAxisLocation(Location value) { - this.xAxisLocation = value; - } - - /** - * Get y axis location - * - * @return Y axis location - */ - public Location getYAxisLocation() { - return this.yAxisLocation; - } - - /** - * Set y axis location - * - * @param value Y axis location - */ - public void setYAxisLocation(Location value) { - this.yAxisLocation = value; - } - - /** - * Get plot orientation - * - * @return Plot orientation - */ - public PlotOrientation getPlotOrientation() { - return this.orientation; - } - - /** - * Set plot orientation - * - * @param value Plot orientation - */ - public void setPlotOrientation(PlotOrientation value) { - this.orientation = value; - } - - /** - * Get grid line - * - * @return Grid line - */ - public GridLine getGridLine() { - return this.gridLine; - } - - /** - * get if draw top axis - * - * @return Boolean - */ - public boolean isDrawTopAxis() { - return this.drawTopAxis; - } - - /** - * Set if draw top right axis - * - * @param value Boolean - */ - public void setDrawTopAxis(boolean value) { - this.drawTopAxis = value; - } - - /** - * get if draw right axis - * - * @return Boolean - */ - public boolean isDrawRightAxis() { - return this.drawRightAxis; - } - - /** - * Set if draw right axis - * - * @param value Boolean - */ - public void setDrawRightAxis(boolean value) { - this.drawRightAxis = value; - } - - /** - * Get if draw neat line - * - * @return Boolean - */ - public boolean isDrawNeatLine() { - return this.drawNeatLine; - } - - /** - * Set if draw neat line - * - * @param value Boolean - */ - public void setDrawNeatLine(boolean value) { - this.drawNeatLine = value; - } - - /** - * Get texts - * - * @return Texts - */ - public List getTexts() { - return this.texts; - } - - /** - * Set texts - * - * @param value texts - */ - public void setTexts(List value) { - this.texts = value; - } - - /** - * Get wind arrow - * - * @return Wind arrow - */ - public ChartWindArrow getWindArrow() { - return this.windArrow; - } - - /** - * Set wind arrow - * - * @param value Wind arrow - */ - public void setWindArrow(ChartWindArrow value) { - this.windArrow = value; - } - - /** - * Get x axis is log or not - * - * @return Boolean - */ - public boolean isLogX() { - Axis xAxis = this.getXAxis(); - return xAxis instanceof LogAxis; - } - - /** - * Get y axis is log or not - * - * @return Boolean - */ - public boolean isLogY() { - Axis yAxis = this.getYAxis(); - return yAxis instanceof LogAxis; - } - - /** - * Get is auto aspect or not - * - * @return Boolean - */ - public boolean isAutoAspect() { - return this.autoAspect; - } - - /** - * Set is auto aspect or not - * - * @param value Boolean - */ - public void setAutoAspect(boolean value) { - this.autoAspect = value; - } - - /** - * Get aspect - scaling from data to plot units for x and y - * - * @return Aspect - */ - public double getAspect() { - return this.aspect; - } - - /** - * Set aspect - * - * @param value Aspect - */ - public void setAspect(double value) { - this.aspect = value; - } - - /** - * Get if y axis is reverse or not - * - * @return Boolean - */ - public boolean isYReverse() { - return this.getYAxis().isInverse(); - } - - /** - * Get if x axis is reverse or not - * - * @return Boolean - */ - public boolean isXReverse() { - return this.getXAxis().isInverse(); - } - - /** - * Get is clip axes or not - * @return Boolean - */ - public boolean isClip() {return this.clip;} - - /** - * Set is clip axes or not - * @param value Boolean - */ - public void setClip(boolean value) {this.clip = value;} - - // - // - /** - * Add a legend - * - * @param legend The legend - */ - public void addLegend(ChartLegend legend) { - this.legends.add(legend); - } - - /** - * Remove a legend - * - * @param legend The legend - */ - public void removeLegend(ChartLegend legend) { - this.legends.remove(legend); - } - - /** - * Remove a legend by index - * - * @param idx The legend index - */ - public void removeLegend(int idx) { - this.legends.remove(idx); - } - - /** - * Set axis - * - * @param axis The axis - * @param loc Axis location - */ - public void setAxis(Axis axis, Location loc) { - this.axis.put(loc, axis); - } - - /** - * Set axis label font - * - * @param font Font - */ - public void setAxisLabelFont(Font font) { - for (Axis ax : this.axis.values()) { - ax.setTickLabelFont(font); - } - } - - /** - * Set all axis visible or not - * - * @param value Boolean - */ - public void setAxisOn(boolean value) { - for (Axis ax : this.axis.values()) { - ax.setVisible(value); - } - } - - /** - * Set axis tick line inside box or not - * - * @param isInside Inside box ot not - */ - public void setInsideTick(boolean isInside) { - this.getAxis(Location.LEFT).setInsideTick(isInside); - this.getAxis(Location.RIGHT).setInsideTick(isInside); - this.getAxis(Location.TOP).setInsideTick(isInside); - this.getAxis(Location.BOTTOM).setInsideTick(isInside); - } - - /** - * Get is inside tick line or not - * - * @return Is inside or not - */ - public boolean isInsideTick() { - return this.getAxis(Location.BOTTOM).isInsideTick(); - } - - /** - * Draw plot - * - * @param g Graphics2D - * @param area Drawing area - */ - @Override - public void draw(Graphics2D g, Rectangle2D area) { - // if the plot area is too small, just return... - boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW); - boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW); - if (b1 || b2) { - return; - } - - Rectangle2D graphArea; - graphArea = this.getPositionArea(); - this.setGraphArea(graphArea); - - //Draw title - this.drawTitle(g, graphArea); - - if (graphArea.getWidth() < 10 || graphArea.getHeight() < 10) { - return; - } - - //Draw background - if (this.background != null) { - g.setColor(this.getBackground()); - g.fill(graphArea); - } - - if (this.getGridLine().isTop()) { - //Draw graph - this.drawGraph(g, graphArea); - //Draw grid line - this.drawGridLine(g, graphArea); - } else { - //Draw grid line - this.drawGridLine(g, graphArea); - //Draw graph - this.drawGraph(g, graphArea); - } - - //Draw neat line - if (this.drawNeatLine) { - g.setStroke(new BasicStroke(1.0f)); - g.setColor(Color.black); - g.draw(graphArea); - } - - //Draw axis - this.drawAxis(g, graphArea); - - //Draw text - this.drawText(g, graphArea); - - //Draw legend - this.drawLegend(g, area, graphArea); - - //Draw wind arrow - quiverkey - if (this.getWindArrow() != null) { - ChartWindArrow wa = this.getWindArrow(); - float x = (float) (area.getWidth() * wa.getX()); - float y = (float) (area.getHeight() * (1 - wa.getY())); - wa.draw(g, x, y); - } - } - - /** - * Get tight inset area - * - * @param g Graphics2D - * @param positionArea Position area - * @return Tight inset area - */ - @Override - public Margin getTightInset(Graphics2D g, Rectangle2D positionArea) { - int left = 2, bottom = 2, right = 2, top = 10; - - top += this.getAxis(Location.TOP).getXAxisHeight(g); - if (this.title != null) { - top += this.title.getTrueDimension(g).height + 10; - } - if (this.leftTitle != null){ - top += this.leftTitle.getDimension(g).height + 5; - } else { - if (this.rightTitle != null){ - top += this.rightTitle.getDimension(g).height + 5; - } - } - - if (!this.legends.isEmpty()) { - ChartLegend legend = this.getLegend(); - Dimension dim = legend.getLegendDimension(g, new Dimension((int) positionArea.getWidth(), - (int) positionArea.getHeight())); - switch (legend.getPosition()) { - case UPPER_CENTER_OUTSIDE: - top += dim.height + 10; - break; - case LOWER_CENTER_OUTSIDE: - bottom += dim.height + 10; - break; - case LEFT_OUTSIDE: - left += dim.width + 10; - break; - case RIGHT_OUTSIDE: - right += dim.width + 10; - break; - } - } - - //Get x axis space - bottom += this.getXAxisHeight(g) + 5; - - //Get y axis space - left += this.getYAxisWidth(g) + 5; - - //Set right space - int radd = this.getAxis(Location.RIGHT).getYAxisWidth(g); - if (this.getXAxis().isVisible()) { - if (this.getXAxis().isDrawTickLabel()) { - radd = Math.max(radd,this.getXAxis().getMaxLabelLength(g) / 2); - } - } - right += radd; - - return new Margin(left, right, top, bottom); - } - - /** - * Get tight inset area - * - * @param g Graphics2D - * @param positionArea Position area - * @return Tight inset area - */ - public Rectangle2D getTightInsetArea(Graphics2D g, Rectangle2D positionArea) { - int left = 0, bottom = 0, right = 5, top = 5; - int space = 1; - - if (this.title != null) { - g.setFont(this.title.getFont()); - Dimension dim = Draw.getStringDimension(this.title.getText(), g); - top += dim.getHeight() + 10; - } - - if (!this.legends.isEmpty()) { - ChartLegend legend = this.getLegend(); - Dimension dim = legend.getLegendDimension(g, new Dimension((int) positionArea.getWidth(), - (int) positionArea.getHeight())); - switch (legend.getPosition()) { - case UPPER_CENTER_OUTSIDE: - top += dim.height + 10; - break; - case LOWER_CENTER_OUTSIDE: - bottom += dim.height + 10; - break; - case LEFT_OUTSIDE: - left += dim.width + 10; - break; - case RIGHT_OUTSIDE: - right += dim.width + 10; - break; - } - } - - //Get x axis space - bottom += this.getXAxisHeight(g); - - //Get y axis space - left += this.getYAxisWidth(g); - - //Set right space - if (this.getXAxis().isVisible()) { - if (this.getXAxis().isDrawTickLabel()) { - right += this.getXAxis().getMaxLabelLength(g) / 2; - } - } - - double x = positionArea.getX() - left; - double y = positionArea.getY() - top; - double w = positionArea.getWidth() + left + right; - double h = positionArea.getHeight() + top + bottom; - - return new Rectangle2D.Double(x, y, w, h); - } - - /** - * Get position area - * - * @return Position area - */ - @Override - public Rectangle2D getPositionArea() { - if (this.autoAspect) { - return super.getPositionArea(); - } else { - Rectangle2D plotArea = super.getPositionArea(); - double width = this.drawExtent.getWidth(); - double height = this.drawExtent.getHeight(); - if (width / height / aspect > plotArea.getWidth() / plotArea.getHeight()) { - double h = plotArea.getWidth() * height * aspect / width; - double delta = plotArea.getHeight() - h; - plotArea.setRect(plotArea.getX(), plotArea.getY() + delta / 2, plotArea.getWidth(), h); - } else { - double w = width * plotArea.getHeight() / height / aspect; - double delta = plotArea.getWidth() - w; - plotArea.setRect(plotArea.getX() + delta / 2, plotArea.getY(), w, plotArea.getHeight()); - } - - return plotArea; - } - } - - /** - * Get outer position area - * - * @param area Whole area - * @return Position area - */ - @Override - public Rectangle2D getOuterPositionArea(Rectangle2D area) { - Rectangle2D rect = this.getOuterPosition(); - double x = area.getWidth() * rect.getX() + area.getX(); - double y = area.getHeight() * (1 - rect.getHeight() - rect.getY()) + area.getY(); - double w = area.getWidth() * rect.getWidth(); - double h = area.getHeight() * rect.getHeight(); - return new Rectangle2D.Double(x, y, w, h); - } - - /** - * Get graphic area - * - * @param g Graphic2D - * @param area Whole area - * @return Graphic area - */ - public Rectangle2D getGraphArea(Graphics2D g, Rectangle2D area) { - int left = 5, bottom = 5, right = 5, top = 5; - int space = 5; - - if (this.title != null) { - top += this.title.getTrueDimension(g).height + 10; - } - - if (!this.legends.isEmpty()) { - ChartLegend legend = this.getLegend(); - Dimension dim = legend.getLegendDimension(g, new Dimension((int) area.getWidth(), (int) area.getHeight())); - switch (legend.getPosition()) { - case UPPER_CENTER_OUTSIDE: - top += dim.height + 10; - break; - case LOWER_CENTER_OUTSIDE: - bottom += dim.height + 10; - break; - case LEFT_OUTSIDE: - left += dim.width + 10; - break; - case RIGHT_OUTSIDE: - right += dim.width + 10; - break; - } - } - - //Get x axis space - bottom += this.getXAxisHeight(g); - - //Get y axis space - left += this.getYAxisWidth(g); - - //Set right space - if (this.getXAxis().isVisible()) { - if (this.getXAxis().isDrawTickLabel()) { - right += this.getXAxis().getMaxLabelLength(g) / 2; - } - } - - //Set area - Rectangle2D plotArea = new Rectangle2D.Double(left, top, - area.getWidth() - left - right, area.getHeight() - top - bottom); - return plotArea; - } - - int getXAxisHeight(Graphics2D g) { - return this.getXAxis().getXAxisHeight(g); - } - - int getYAxisWidth(Graphics2D g) { - return this.getYAxis().getYAxisWidth(g); - } - - int getTopAxisHeight(Graphics2D g) { - int height = this.getAxis(Location.TOP).getXAxisHeight(g); - return height; - } - - void drawTitle(Graphics2D g, Rectangle2D graphArea) { - float x; - float y = (float) graphArea.getY() - this.getTopAxisHeight(g); - int sh = 0; - if (leftTitle != null) { - x = (float) graphArea.getX(); - y -= 5; - leftTitle.draw(g, x, y); - y += 5; - sh = leftTitle.getDimension(g).height + 5; - } - if (rightTitle != null) { - x = (float) (graphArea.getX() + graphArea.getWidth()); - y -= 5; - rightTitle.draw(g, x, y); - y += 5; - sh = rightTitle.getDimension(g).height + 5; - } - if (title != null) { - y -= sh; - y -= 8; - x = (float) (graphArea.getX() + graphArea.getWidth() / 2); - title.draw(g, x, y); - } - } - - void drawGridLine(Graphics2D g, Rectangle2D area) { - if (!this.gridLine.isDrawXLine() && !this.gridLine.isDrawYLine()) { - return; - } - - double[] xy; - double x, y; - double miny = area.getY(); - double minx = area.getX(); - double maxx = area.getX() + area.getWidth(); - double maxy = area.getY() + area.getHeight(); - - float[] dashPattern = Draw.getDashPattern(this.gridLine.getStyle()); - g.setColor(this.gridLine.getColor()); - g.setStroke(new BasicStroke(this.gridLine.getSize(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, - 10.0f, dashPattern, 0.0f)); - - //Draw x grid lines - if (this.gridLine.isDrawXLine()) { - this.getXAxis().updateTickLabels(); - //this.getXAxis().updateLabelGap(g, area); - int n = 0; - while (n < this.getXAxis().getTickValues().length) { - double value = this.getXAxis().getTickValues()[n]; - if (value <= this.getXAxis().getMinValue() || value >= this.getXAxis().getMaxValue()) { - n += this.getXAxis().getTickLabelGap(); - continue; - } - xy = this.projToScreen(value, this.drawExtent.minY, area); - x = xy[0]; - if (x > 0 && x < area.getWidth()) { - if (this.getXAxis().isInverse()) { - x = area.getWidth() - x; - } - x += minx; - g.draw(new Line2D.Double(x, maxy, x, miny)); - } - n += this.getXAxis().getTickLabelGap(); - } - } - - //Draw y grid lines - if (this.gridLine.isDrawYLine()) { - this.getYAxis().updateTickLabels(); - //this.getYAxis().updateLabelGap(g, area); - int n = 0; - while (n < this.getYAxis().getTickValues().length) { - double value = this.getYAxis().getTickValues()[n]; - if (value <= this.getYAxis().getMinValue() || value >= this.getYAxis().getMaxValue()) { - n += this.getYAxis().getTickLabelGap(); - continue; - } - xy = this.projToScreen(this.drawExtent.minX, value, area); - y = xy[1]; - if (y > 0 && y < area.getHeight()) { - if (this.getYAxis().isInverse()) { - y = area.getHeight() - y; - } - y += miny; - g.draw(new Line2D.Double(minx, y, maxx, y)); - } - n += this.getYAxis().getTickLabelGap(); - } - } - } - - abstract void drawGraph(Graphics2D g, Rectangle2D area); - - void drawAxis(Graphics2D g, Rectangle2D area) { - for (Location loc : this.axis.keySet()) { - Axis ax = this.axis.get(loc); - if (ax.isVisible()) { - ax.updateLabelGap(g, area); - ax.draw(g, area, this); - } - } - } - - void drawText(Graphics2D g, Rectangle2D area) { -// Iterator iter = this.getTexts().iterator(); -// while (iter.hasNext()){ -// drawPlotText(iter.next(), g, area); -// } - for (int i = 0; i < this.getTexts().size(); i++){ - drawPlotText(this.getTexts().get(i), g, area); - } - } - - void drawPlotText(ChartText text, Graphics2D g, Rectangle2D area) { - float x, y; - switch (text.getCoordinates()) { - case AXES: - AffineTransform oldMatrix = g.getTransform(); - Rectangle oldRegion = g.getClipBounds(); - g.setClip(area); - g.translate(area.getX(), area.getY()); - x = (float) (area.getWidth() * text.getX()); - y = (float) (area.getHeight() * (1 - text.getY())); - this.drawText(text, g, x, y); - g.setTransform(oldMatrix); - g.setClip(oldRegion); - break; - case FIGURE: - x = (float) (area.getWidth() * text.getX()); - y = (float) (area.getHeight() * (1 - text.getY())); - this.drawText(text, g, x, y); - break; - case DATA: - oldMatrix = g.getTransform(); - oldRegion = g.getClipBounds(); - if (this.clip) - g.setClip(area); - g.translate(area.getX(), area.getY()); - double[] xy = this.projToScreen(text.getX(), text.getY(), area); - x = (float) xy[0]; - y = (float) xy[1]; - this.drawText(text, g, x, y); - g.setTransform(oldMatrix); - if (this.clip) - g.setClip(oldRegion); - break; - } - } - - void drawText(ChartText text, Graphics2D g, float x, float y) { - g.setFont(text.getFont()); - text.draw(g, x, y); - } - - void drawLegend(Graphics2D g, Rectangle2D area, Rectangle2D graphArea) { - if (!this.legends.isEmpty()) { - Object rendering = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING); - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - for (ChartLegend legend : this.legends) { - if (legend.isColorbar()) { - if (legend.getPlotOrientation() == PlotOrientation.VERTICAL) { - legend.setHeight((int) (graphArea.getHeight() * legend.getShrink())); - legend.setLegendHeight(legend.getHeight()); - } else { - legend.setWidth((int) (graphArea.getWidth() * legend.getShrink())); - legend.setLegendWidth(legend.getWidth()); - } - } - if (legend.getPosition() == LegendPosition.CUSTOM) { - legend.getLegendDimension(g, new Dimension((int) area.getWidth(), (int) area.getHeight())); - float x = (float) (area.getWidth() * legend.getX()); - float y = (float) (area.getHeight() * (1 - (this.getLegend().getHeight() / area.getHeight()) - - this.getLegend().getY())); - legend.draw(g, new PointF(x, y)); - } else { - this.drawLegendScheme(legend, g, graphArea); - } - } - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, rendering); - } - } - - void drawLegendScheme(ChartLegend legend, Graphics2D g, Rectangle2D area) { - g.setFont(legend.getTickLabelFont()); - Dimension dim = legend.getLegendDimension(g, new Dimension((int) area.getWidth(), (int) area.getHeight())); - float x = 0; - float y = 0; - switch (legend.getPosition()) { - case UPPER_CENTER_OUTSIDE: - x = (float) (area.getX() + area.getWidth() / 2 - dim.width / 2); - y = (float) (area.getY() - this.getAxis(Location.TOP).getXAxisHeight(g) - dim.height - 5); - break; - case LOWER_CENTER_OUTSIDE: - x = (float) (area.getX() + area.getWidth() / 2 - dim.width / 2); - y = (float) (area.getY() + area.getHeight() + this.getXAxisHeight(g) + 10); - break; - case LEFT_OUTSIDE: - x = 10; - y = (float) area.getHeight() / 2 - dim.height / 2; - break; - case RIGHT_OUTSIDE: - if (this.getAxis(Location.RIGHT).isDrawTickLabel() || this instanceof PolarPlot) { - x = (float) area.getX() + (float) area.getWidth() + (float) this.getTightInset().getRight(); - x = x - dim.width; - } else { - x = (float) area.getX() + (float) area.getWidth() + 10; - } - y = (float) area.getY() + (float) area.getHeight() / 2 - dim.height / 2; - break; - case UPPER_CENTER: - x = (float) (area.getX() + area.getWidth() / 2 - dim.width / 2); - y = (float) area.getY() + 10; - break; - case UPPER_RIGHT: - x = (float) (area.getX() + area.getWidth()) - dim.width - 10; - y = (float) area.getY() + 10; - break; - case LOWER_CENTER: - x = (float) (area.getX() + area.getWidth() / 2 - dim.width / 2); - y = (float) (area.getY() + area.getHeight()) - dim.height - 10; - break; - case LOWER_RIGHT: - x = (float) (area.getX() + area.getWidth()) - dim.width - 10; - y = (float) (area.getY() + area.getHeight()) - dim.height - 10; - break; - case UPPER_LEFT: - x = (float) area.getX() + 10; - y = (float) area.getY() + 10; - break; - case LOWER_LEFT: - x = (float) area.getX() + 10; - y = (float) (area.getY() + area.getHeight()) - dim.height - 10; - break; - } - legend.draw(g, new PointF(x, y)); - } - - /** - * Convert coordinate from map to screen - * - * @param projX Map X - * @param projY Map Y - * @param area Drawing area - * @return Screen X/Y array - */ - public double[] projToScreen(double projX, double projY, Rectangle2D area) { - double width = drawExtent.getWidth(); - double height = drawExtent.getHeight(); - if (this.isLogY()) { - height = Math.log10(drawExtent.maxY) - Math.log10(drawExtent.minY); - } - if (this.isLogX()) { - width = Math.log10(drawExtent.maxX) - Math.log10(drawExtent.minX); - } - double scaleX = area.getWidth() / width; - double scaleY = area.getHeight() / height; - double screenX = (projX - drawExtent.minX) * scaleX; - double screenY = (drawExtent.maxY - projY) * scaleY; - if (this.isLogY()) { - screenY = (Math.log10(drawExtent.maxY) - Math.log10(projY)) * scaleY; - } - if (this.isLogX()) { - screenX = (Math.log10(projX) - Math.log10(drawExtent.minX)) * scaleX; - } - if (this.isYReverse()) { - screenY = area.getHeight() - screenY; - } - if (this.isXReverse()) { - screenX = area.getWidth() - screenX; - } - - return new double[]{screenX, screenY}; - } - - /** - * Convert data length to screen length in x direction - * - * @param len data length - * @param area Drawing area - * @return Screen length - */ - public double projXLength(double len, Rectangle2D area) { - double scaleX = area.getWidth() / drawExtent.getWidth(); - return len * scaleX; - } - - /** - * Convert data length to screen length in y direction - * - * @param len data length - * @param area Drawing area - * @return Screen length - */ - public double projYLength(double len, Rectangle2D area) { - double scaleY = area.getHeight() / drawExtent.getHeight(); - return len * scaleY; - } - - /** - * Convert coordinate from screen to map - * - * @param screenX Screen X - * @param screenY Screen Y - * @param area Area - * @return Projected X/Y - */ - public double[] screenToProj(double screenX, double screenY, Rectangle2D area) { - double width = drawExtent.getWidth(); - double height = drawExtent.getHeight(); - if (this.isLogY()) { - height = Math.log10(drawExtent.maxY) - Math.log10(drawExtent.minY); - } - if (this.isLogX()) { - width = Math.log10(drawExtent.maxX) - Math.log10(drawExtent.minX); - } - if (this.isYReverse()) { - screenY = area.getHeight() - screenY; - } - if (this.isXReverse()) { - screenX = area.getWidth() - screenX; - } - double scaleX = area.getWidth() / width; - double scaleY = area.getHeight() / height; - double projX = screenX / scaleX + drawExtent.minX; - double projY = drawExtent.maxY - screenY / scaleY; - if (this.isLogY()) { - projY = Math.pow(10, Math.log10(drawExtent.maxY) - screenY / scaleY); - } - if (this.isLogX()) { - projX = Math.pow(10, screenX / scaleX + Math.log10(drawExtent.minX)); - } - - return new double[]{projX, projY}; - } - - abstract Extent getAutoExtent(); - - public abstract void setAutoExtent(); - - public abstract void updateLegendScheme(); - - /** - * Zoom to screen extent - * - * @param minX Minimum x - * @param maxX Maximum x - * @param minY Minimum y - * @param maxY Maximum y - */ - public void zoomToExtentScreen(double minX, double maxX, double minY, double maxY) { - double[] pMin = screenToProj(minX, maxY, this.getGraphArea()); - double[] pMax = screenToProj(maxX, minY, this.getGraphArea()); - this.setDrawExtent(new Extent(pMin[0], pMax[0], pMin[1], pMax[1])); - } - - /** - * Add text - * - * @param text Chart text - */ - public void addText(ChartText text) { - this.getTexts().add(text); - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/AxesUnits.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/AxesUnits.java deleted file mode 100644 index 6d54c7c7..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/AxesUnits.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.plot; - -/** - * - * @author Yaqiang Wang - */ -public enum AxesUnits { - NORMALIZED, - PIXELS; -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/ChartPlotMethod.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/ChartPlotMethod.java deleted file mode 100644 index 8326251f..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/ChartPlotMethod.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.plot; - -/** - * - * @author yaqiang - */ -public enum ChartPlotMethod { - LINE, - BAR, - POINT, - LINE_POINT, - FILL -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/GraphicFactory.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/GraphicFactory.java deleted file mode 100644 index 9b2624d4..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/GraphicFactory.java +++ /dev/null @@ -1,5778 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.plot; - -import java.awt.Color; -import java.awt.Font; -import java.awt.geom.AffineTransform; -import java.awt.image.BufferedImage; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; - -import org.apache.commons.lang3.ArrayUtils; -import org.meteoinfo.chart.ChartText; -import org.meteoinfo.chart.plot3d.GraphicCollection3D; -import org.meteoinfo.common.*; -import org.meteoinfo.data.GridArray; -import org.meteoinfo.data.GridData; -import org.meteoinfo.data.XYListDataset; -import org.meteoinfo.data.analysis.Statistics; -import org.meteoinfo.drawing.ContourDraw; -import org.meteoinfo.drawing.Draw; -import org.meteoinfo.geometry.graphic.Graphic; -import org.meteoinfo.geometry.graphic.GraphicCollection; -import org.meteoinfo.geometry.graphic.ImageGraphic; -import org.meteoinfo.geometry.legend.*; -import org.meteoinfo.geoprocess.GeometryUtil; -import org.meteoinfo.geoprocess.GeoComputation; -import org.meteoinfo.layer.ImageLayer; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.legend.LegendManage; -import org.meteoinfo.ndarray.math.ArrayMath; -import org.meteoinfo.ndarray.math.ArrayUtil; -import org.meteoinfo.math.meteo.MeteoMath; -import org.meteoinfo.ndarray.*; -import org.meteoinfo.ndarray.util.BigDecimalUtil; -import org.meteoinfo.geometry.shape.*; -import wcontour.Contour; -import wcontour.global.Point3D; -import wcontour.global.PolyLine; -import wcontour.global.PolyLine3D; - -/** - * - * @author Yaqiang Wang - */ -public class GraphicFactory { - - /** - * Create LineString graphic - * - * @param xdata X data array - * @param ydata Y data array - * @param cb Color break - * @return LineString graphic - */ - public static GraphicCollection createLineString(Array xdata, Array ydata, ColorBreak cb) { - GraphicCollection gc = new GraphicCollection(); - PolylineShape pls; - List points = new ArrayList<>(); - double x, y; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - while (xIter.hasNext()) { - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - if (Double.isNaN(y) || Double.isNaN(x)) { - if (points.isEmpty()) { - continue; - } - if (points.size() == 1) { - points.add((PointD) points.get(0).clone()); - } - pls = new PolylineShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - points = new ArrayList<>(); - } else { - points.add(new PointD(x, y)); - } - } - if (!points.isEmpty()) { - if (points.size() == 1) { - points.add((PointD) points.get(0).clone()); - } - pls = new PolylineShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - } - - return gc; - } - - /** - * Create LineString graphic - * - * @param xdata X data array - * @param ydata Y data array - * @param cb Color break - * @param iscurve Is curve line or not - * @return LineString graphic - */ - public static GraphicCollection createLineString(Array xdata, Array ydata, ColorBreak cb, boolean iscurve) { - GraphicCollection gc = new GraphicCollection(); - PolylineShape pls; - List points = new ArrayList<>(); - double x, y; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - if (xdata.getRank() == 1) { - while (xIter.hasNext()) { - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - if (Double.isNaN(y) || Double.isNaN(x)) { - if (points.isEmpty()) { - continue; - } - if (points.size() == 1) { - points.add((PointD) points.get(0).clone()); - } - if (iscurve) { - pls = new CurveLineShape(); - } else { - pls = new PolylineShape(); - } - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - points = new ArrayList<>(); - } else { - points.add(new PointD(x, y)); - } - } - if (!points.isEmpty()) { - if (points.size() == 1) { - points.add((PointD) points.get(0).clone()); - } - if (iscurve) { - pls = new CurveLineShape(); - } else { - pls = new PolylineShape(); - } - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - } - } else { //Two dimensions - int[] shape = xdata.getShape(); - int yn = shape[0]; - int xn = shape[1]; - for (int j = 0; j < yn; j++) { - points = new ArrayList<>(); - for (int i = 0; i < xn; i++) { - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - //x = xdata.getDouble(j * xn + i); - //y = ydata.getDouble(j * xn + i); - if (Double.isNaN(y) || Double.isNaN(x)) { - if (points.isEmpty()) { - continue; - } - if (points.size() == 1) { - points.add((PointD) points.get(0).clone()); - } - if (iscurve) { - pls = new CurveLineShape(); - } else { - pls = new PolylineShape(); - } - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - points = new ArrayList<>(); - } else { - points.add(new PointD(x, y)); - } - } - if (points.size() > 1) { - if (iscurve) { - pls = new CurveLineShape(); - } else { - pls = new PolylineShape(); - } - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - } - } - } - - return gc; - } - - /** - * Create LineString graphic - * - * @param xdata X data array - * @param ydata Y data array - * @param cbs Color break list - * @param iscurve Is curve line or not - * @return LineString graphic - */ - public static GraphicCollection createLineString(Array xdata, Array ydata, List cbs, boolean iscurve) { - GraphicCollection gc = new GraphicCollection(); - PolylineShape pls; - List points; - double x, y; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - ColorBreak cb; - if (xdata.getRank() == 1) { - points = new ArrayList<>(); - int i = 0; - while (xIter.hasNext()) { - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - if (Double.isNaN(y) || Double.isNaN(x)) { - if (points.isEmpty()) { - continue; - } - if (points.size() == 1) { - points.add((PointD) points.get(0).clone()); - } - if (iscurve) { - pls = new CurveLineShape(); - } else { - pls = new PolylineShape(); - } - pls.setPoints(points); - cb = cbs.get(i); - gc.add(new Graphic(pls, cb)); - points = new ArrayList<>(); - i += 1; - } else { - points.add(new PointD(x, y)); - } - } - if (points.size() > 1) { - if (iscurve) { - pls = new CurveLineShape(); - } else { - pls = new PolylineShape(); - } - pls.setPoints(points); - cb = cbs.get(i); - gc.add(new Graphic(pls, cb)); - } - } else { //Two dimensions - int[] shape = xdata.getShape(); - int yn = shape[0]; - int xn = shape[1]; - for (int j = 0; j < yn; j++) { - points = new ArrayList<>(); - cb = cbs.get(j); - for (int i = 0; i < xn; i++) { - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - //x = xdata.getDouble(j * xn + i); - //y = ydata.getDouble(j * xn + i); - if (Double.isNaN(y) || Double.isNaN(x)) { - if (points.isEmpty()) { - continue; - } - if (points.size() == 1) { - points.add((PointD) points.get(0).clone()); - } - if (iscurve) { - pls = new CurveLineShape(); - } else { - pls = new PolylineShape(); - } - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - points = new ArrayList<>(); - } else { - points.add(new PointD(x, y)); - } - } - if (points.size() > 1) { - if (iscurve) { - pls = new CurveLineShape(); - } else { - pls = new PolylineShape(); - } - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - } - } - } - gc.setSingleLegend(false); - - return gc; - } - - /** - * Create LineString graphic - * - * @param xdata X data array - * @param ydata Y data array - * @param zdata Z data array - * @param ls Legend scheme - * @param iscurve Is curve line or not - * @return LineString graphic - */ - public static GraphicCollection createLineString(Array xdata, Array ydata, Array zdata, LegendScheme ls, boolean iscurve) { - GraphicCollection gc = new GraphicCollection(); - PolylineShape pls; - List points; - ColorBreakCollection cbc; - double x, y, z; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - IndexIterator zIter = zdata.getIndexIterator(); - ColorBreak cb; - if (xdata.getRank() == 1) { - points = new ArrayList<>(); - cbc = new ColorBreakCollection(); - while (xIter.hasNext()){ - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - z = zIter.getDoubleNext(); - cb = ls.findLegendBreak(z); - if (Double.isNaN(y) || Double.isNaN(x)) { - if (points.isEmpty()) { - continue; - } - if (points.size() == 1) { - points.add((PointD) points.get(0).clone()); - } - if (iscurve) { - pls = new CurveLineShape(); - } else { - pls = new PolylineShape(); - } - pls.setPoints(points); - gc.add(new Graphic(pls, cbc)); - points = new ArrayList<>(); - cbc = new ColorBreakCollection(); - } else { - points.add(new PointD(x, y)); - cbc.add(cb); - } - } - if (points.size() > 1) { - if (iscurve) { - pls = new CurveLineShape(); - } else { - pls = new PolylineShape(); - } - pls.setPoints(points); - gc.add(new Graphic(pls, cbc)); - } - gc.setLegendScheme(ls); - } else { //Two dimensions - int[] shape = xdata.getShape(); - int yn = shape[0]; - int xn = shape[1]; - for (int j = 0; j < yn; j++) { - points = new ArrayList<>(); - cbc = new ColorBreakCollection(); - for (int i = 0; i < xn; i++) { - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - z = zIter.getDoubleNext(); - //x = xdata.getDouble(j * xn + i); - //y = ydata.getDouble(j * xn + i); - //z = zdata.getDouble(j * xn + i); - cb = ls.findLegendBreak(z); - if (Double.isNaN(y) || Double.isNaN(x)) { - if (points.isEmpty()) { - continue; - } - if (points.size() == 1) { - points.add((PointD) points.get(0).clone()); - } - if (iscurve) { - pls = new CurveLineShape(); - } else { - pls = new PolylineShape(); - } - pls.setPoints(points); - gc.add(new Graphic(pls, cbc)); - points = new ArrayList<>(); - cbc = new ColorBreakCollection(); - } else { - points.add(new PointD(x, y)); - cbc.add(cb); - } - } - if (points.size() > 1) { - if (iscurve) { - pls = new CurveLineShape(); - } else { - pls = new PolylineShape(); - } - pls.setPoints(points); - gc.add(new Graphic(pls, cbc)); - } - } - gc.setLegendScheme(ls); - gc.setSingleLegend(false); - } - - return gc; - } - - /** - * Create LineString graphic - * - * @param data Y data array - * @param cbs Color breaks - * @return LineString graphic - */ - public static GraphicCollection createLineString(XYListDataset data, List cbs) { - GraphicCollection gc = new GraphicCollection(); - PolylineShape pls; - List points; - double x, y; - for (int i = 0; i < data.getSeriesCount(); i++) { - points = new ArrayList<>(); - for (int j = 0; j < data.getItemCount(i); j++) { - x = data.getX(i, j); - y = data.getY(i, j); - points.add(new PointD(x, y)); - } - pls = new PolylineShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cbs.get(i))); - } - gc.setSingleLegend(false); - - return gc; - } - - /** - * Create 3D LineString graphic - * - * @param xdata X data array - * @param ydata Y data array - * @param zdata Z data array - * @param cb Color break - * @return LineString graphic - */ - public static GraphicCollection createLineString3D(Array xdata, Array ydata, Array zdata, ColorBreak cb) { - GraphicCollection3D gc = new GraphicCollection3D(); - PolylineZShape pls; - List points = new ArrayList<>(); - double x, y, z = 0; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - IndexIterator zIter = zdata.getIndexIterator(); - boolean fixZ = false; - if (zdata.getSize() == 1 && xdata.getSize() > 1) { - fixZ = true; - z = zdata.getDouble(0); - } - if (xdata.getRank() == 1) { - while (xIter.hasNext()) { - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - if (!fixZ) { - z = zIter.getDoubleNext(); - } - if (Double.isNaN(y) || Double.isNaN(x)) { - if (points.isEmpty()) { - continue; - } - if (points.size() == 1) { - points.add((PointZ) points.get(0).clone()); - } - pls = new PolylineZShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - points = new ArrayList<>(); - } else { - points.add(new PointZ(x, y, z)); - } - } - if (points.size() > 1) { - pls = new PolylineZShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - } - } else { //two dimensions - int[] shape = xdata.getShape(); - int yn = shape[0]; - int xn = shape[1]; - for (int j = 0; j < yn; j++) { - for (int i = 0; i < xn; i++) { - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - //x = xdata.getDouble(j * xn + i); - //y = ydata.getDouble(j * xn + i); - if (!fixZ) { - z = zIter.getDoubleNext(); - //z = zdata.getDouble(j * xn + i); - } - if (Double.isNaN(y) || Double.isNaN(x)) { - if (points.isEmpty()) { - continue; - } - if (points.size() == 1) { - points.add((PointZ) points.get(0).clone()); - } - pls = new PolylineZShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - points = new ArrayList<>(); - } else { - points.add(new PointZ(x, y, z)); - } - } - if (points.size() > 1) { - pls = new PolylineZShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - points = new ArrayList<>(); - } - } - } - - return gc; - } - - /** - * Create 3D LineString graphic - * - * @param xdata X data array - * @param ydata Y data array - * @param zdata Z data array - * @param cbs Color break list - * @return LineString graphic - */ - public static GraphicCollection createLineString3D(Array xdata, Array ydata, Array zdata, List cbs) { - GraphicCollection3D gc = new GraphicCollection3D(); - PolylineZShape pls; - List points = new ArrayList<>(); - double x, y, z = 0; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - IndexIterator zIter = zdata.getIndexIterator(); - boolean fixZ = false; - if (zdata.getSize() == 1 && xdata.getSize() > 1) { - fixZ = true; - z = zdata.getDouble(0); - } - ColorBreak cb; - if (xdata.getRank() == 1) { - int i = 0; - while (xIter.hasNext()) { - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - if (!fixZ) { - z = zIter.getDoubleNext(); - } - if (Double.isNaN(y) || Double.isNaN(x)) { - if (points.isEmpty()) { - continue; - } - if (points.size() == 1) { - points.add((PointZ) points.get(0).clone()); - } - pls = new PolylineZShape(); - pls.setPoints(points); - cb = cbs.get(i); - gc.add(new Graphic(pls, cb)); - points = new ArrayList<>(); - i += 1; - } else { - points.add(new PointZ(x, y, z)); - } - } - if (points.size() > 1) { - pls = new PolylineZShape(); - pls.setPoints(points); - cb = cbs.get(i); - gc.add(new Graphic(pls, cb)); - } - } else { //two dimensions - int[] shape = xdata.getShape(); - int yn = shape[0]; - int xn = shape[1]; - for (int j = 0; j < yn; j++) { - cb = cbs.get(j); - for (int i = 0; i < xn; i++) { - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - //x = xdata.getDouble(j * xn + i); - //y = ydata.getDouble(j * xn + i); - if (!fixZ) { - z = zIter.getDoubleNext(); - //z = zdata.getDouble(j * xn + i); - } - if (Double.isNaN(y) || Double.isNaN(x)) { - if (points.isEmpty()) { - continue; - } - if (points.size() == 1) { - points.add((PointZ) points.get(0).clone()); - } - pls = new PolylineZShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - points = new ArrayList<>(); - } else { - points.add(new PointZ(x, y, z)); - } - } - if (points.size() > 1) { - pls = new PolylineZShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - points = new ArrayList<>(); - } - } - } - - return gc; - } - - /** - * Create 3D LineString graphic - * - * @param xdata X data array - * @param ydata Y data array - * @param zdata Z data array - * @param mdata M data array - * @param ls Legend scheme - * @return LineString graphic - */ - public static GraphicCollection createLineString3D(Array xdata, Array ydata, Array zdata, Array mdata, - LegendScheme ls) { - GraphicCollection3D gc = new GraphicCollection3D(); - PolylineZShape pls; - List points = new ArrayList<>(); - double x, y, z = 0, m; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - IndexIterator zIter = zdata.getIndexIterator(); - IndexIterator mIter = mdata.getIndexIterator(); - boolean fixZ = false; - if (zdata.getSize() == 1 && xdata.getSize() > 1) { - fixZ = true; - z = zdata.getDouble(0); - } - ColorBreak cb; - ColorBreakCollection cbs; - if (xdata.getRank() == 1) { - cbs = new ColorBreakCollection(); - while (xIter.hasNext()){ - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - if (!fixZ) { - z = zIter.getDoubleNext(); - } - m = mIter.getDoubleNext(); - cb = ls.findLegendBreak(m); - if (Double.isNaN(y) || Double.isNaN(x)) { - if (points.isEmpty()) { - continue; - } - if (points.size() == 1) { - points.add((PointZ) points.get(0).clone()); - } - pls = new PolylineZShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cbs)); - points = new ArrayList<>(); - cbs = new ColorBreakCollection(); - } else { - points.add(new PointZ(x, y, z)); - cbs.add(cb); - } - } - if (points.size() > 1) { - pls = new PolylineZShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cbs)); - } - } else { //two dimensions - int[] shape = xdata.getShape(); - int yn = shape[0]; - int xn = shape[1]; - for (int j = 0; j < yn; j++) { - cbs = new ColorBreakCollection(); - for (int i = 0; i < xn; i++) { - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - //x = xdata.getDouble(j * xn + i); - //y = ydata.getDouble(j * xn + i); - if (!fixZ) { - z = zIter.getDoubleNext(); - //z = zdata.getDouble(j * xn + i); - } - m = mIter.getDoubleNext(); - //m = mdata.getDouble(j * xn + i); - cb = ls.findLegendBreak(m); - if (Double.isNaN(y) || Double.isNaN(x)) { - if (points.isEmpty()) { - continue; - } - if (points.size() == 1) { - points.add((PointZ) points.get(0).clone()); - } - pls = new PolylineZShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cbs)); - points = new ArrayList<>(); - cbs = new ColorBreakCollection(); - } else { - points.add(new PointZ(x, y, z)); - cbs.add(cb); - } - } - if (points.size() > 1) { - pls = new PolylineZShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cbs)); - points = new ArrayList<>(); - } - } - } - gc.setLegendScheme(ls); - - return gc; - } - - /** - * Create error LineString graphic - * - * @param xdata X data array - * @param ydata Y data array - * @param xErrorLeft X error array - left - * @param xErrorRight X error array - right - * @param yErrorBottom Y error array - bottom - * @param yErrorUp Y error array - up - * @param cb Color break - * @param ecb Error bar color break - * @param capSize The length of the error bar caps. - * @return LineString graphics - */ - public static GraphicCollection createErrorLineString(Array xdata, Array ydata, Array xErrorLeft, - Array xErrorRight, Array yErrorBottom, Array yErrorUp, PolylineBreak cb, PolylineBreak ecb, float capSize) { - GraphicCollection gc = new GraphicCollection(); - PolylineShape pls; - CapPolylineShape epls; - List points = new ArrayList<>(); - List eps; - double x, y, xerrL, xerrR, yerrB, yerrU; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - IndexIterator xelIter = xErrorLeft == null ? null : xErrorLeft.getIndexIterator(); - IndexIterator xerIter = xErrorRight == null ? null : xErrorRight.getIndexIterator(); - IndexIterator yebIter = yErrorBottom == null ? null : yErrorBottom.getIndexIterator(); - IndexIterator yeuIter = yErrorUp == null ? null : yErrorUp.getIndexIterator(); - //Loop - while (xIter.hasNext()) { - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - if (Double.isNaN(y) || Double.isNaN(x)) { - if (points.isEmpty()) { - continue; - } - if (points.size() == 1) { - points.add((PointD) points.get(0).clone()); - } - pls = new PolylineShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - points = new ArrayList<>(); - if (yebIter != null) { - yebIter.next(); - yeuIter.next(); - } - if (xelIter != null) { - xelIter.next(); - xerIter.next(); - } - } else { - points.add(new PointD(x, y)); - if (yebIter != null) { - yerrB = yebIter.getDoubleNext(); - yerrU = yeuIter.getDoubleNext(); - eps = new ArrayList<>(); - eps.add(new PointD(x, y + yerrU)); - eps.add(new PointD(x, y - yerrB)); - epls = new CapPolylineShape(); - epls.setCapLen(capSize); - epls.setPoints(eps); - gc.add(new Graphic(epls, ecb)); - } - if (xelIter != null) { - xerrL = xelIter.getDoubleNext(); - xerrR = xerIter.getDoubleNext(); - eps = new ArrayList<>(); - eps.add(new PointD(x - xerrL, y)); - eps.add(new PointD(x + xerrR, y)); - epls = new CapPolylineShape(); - epls.setCapLen(capSize); - epls.setCapAngle(90); - epls.setPoints(eps); - gc.add(new Graphic(epls, ecb)); - } - } - } - if (!points.isEmpty()) { - if (points.size() == 1) { - points.add((PointD) points.get(0).clone()); - } - pls = new PolylineShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - } - gc.setSingleLegend(false); - PolylineBreak lb = (PolylineBreak) ecb.clone(); - lb.setDrawSymbol(cb.getDrawSymbol()); - gc.setLegendBreak(lb); - - return gc; - } - - /** - * Create error LineString graphic - * - * @param xdata X data array - * @param ydata Y data array - * @param xErrorLeft X error array - left - * @param xErrorRight X error array - right - * @param yErrorBottom Y error array - bottom - * @param yErrorUp Y error array - up - * @param cb Color break - * @param ecb Error bar color break - * @param capSize The length of the error bar caps. - * @return LineString graphics - */ - public static GraphicCollection createErrorLineString_bak1(Array xdata, Array ydata, Array xErrorLeft, - Array xErrorRight, Array yErrorBottom, Array yErrorUp, ColorBreak cb, ColorBreak ecb, Double capSize) { - GraphicCollection gc = new GraphicCollection(); - PolylineShape pls, epls; - List points = new ArrayList<>(); - List eps; - double x, y, xerrL, xerrR, yerrB, yerrU; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - IndexIterator xelIter = xErrorLeft == null ? null : xErrorLeft.getIndexIterator(); - IndexIterator xerIter = xErrorRight == null ? null : xErrorRight.getIndexIterator(); - IndexIterator yebIter = yErrorBottom == null ? null : yErrorBottom.getIndexIterator(); - IndexIterator yeuIter = yErrorUp == null ? null : yErrorUp.getIndexIterator(); - double width; - if (capSize == null) { - width = (ArrayMath.getMaximum(xdata) - ArrayMath.getMinimum(xdata)) / xdata.getSize() * 0.1; - } else { - width = capSize * 0.5; - } - //Loop - while (xIter.hasNext()){ - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - if (Double.isNaN(y) || Double.isNaN(x)) { - if (points.isEmpty()) { - continue; - } - if (points.size() == 1) { - points.add((PointD) points.get(0).clone()); - } - pls = new PolylineShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - points = new ArrayList<>(); - if (yebIter != null) { - yebIter.next(); - yeuIter.next(); - } - if (xelIter != null) { - xelIter.next(); - xerIter.next(); - } - } else { - points.add(new PointD(x, y)); - if (yErrorBottom != null) { - yerrB = yebIter.getDoubleNext(); - yerrU = yeuIter.getDoubleNext(); - eps = new ArrayList<>(); - eps.add(new PointD(x, y + yerrU)); - eps.add(new PointD(x, y - yerrB)); - epls = new PolylineShape(); - epls.setPoints(eps); - gc.add(new Graphic(epls, ecb)); - eps = new ArrayList<>(); - eps.add(new PointD(x - width, y + yerrU)); - eps.add(new PointD(x + width, y + yerrU)); - epls = new PolylineShape(); - epls.setPoints(eps); - gc.add(new Graphic(epls, ecb)); - eps = new ArrayList<>(); - eps.add(new PointD(x - width, y - yerrB)); - eps.add(new PointD(x + width, y - yerrB)); - epls = new PolylineShape(); - epls.setPoints(eps); - gc.add(new Graphic(epls, ecb)); - } - if (xErrorLeft != null) { - xerrL = xelIter.getDoubleNext(); - xerrR = xerIter.getDoubleNext(); - eps = new ArrayList<>(); - eps.add(new PointD(x - xerrL, y)); - eps.add(new PointD(x + xerrR, y)); - epls = new PolylineShape(); - epls.setPoints(eps); - gc.add(new Graphic(epls, ecb)); - eps = new ArrayList<>(); - eps.add(new PointD(x - xerrL, y - width)); - eps.add(new PointD(x - xerrL, y + width)); - epls = new PolylineShape(); - epls.setPoints(eps); - gc.add(new Graphic(epls, ecb)); - eps = new ArrayList<>(); - eps.add(new PointD(x + xerrR, y - width)); - eps.add(new PointD(x + xerrR, y + width)); - epls = new PolylineShape(); - epls.setPoints(eps); - gc.add(new Graphic(epls, ecb)); - } - } - } - if (!points.isEmpty()) { - if (points.size() == 1) { - points.add((PointD) points.get(0).clone()); - } - pls = new PolylineShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - } - gc.setSingleLegend(false); - - return gc; - } - - /** - * Create step LineString graphic - * - * @param xdata X data array - * @param ydata Y data array - * @param cb Color break - * @param where Where - pre, post, mid - * @return LineString graphic - */ - public static GraphicCollection createStepLineString(Array xdata, Array ydata, ColorBreak cb, String where) { - GraphicCollection gc = new GraphicCollection(); - PolylineShape pls; - List points = new ArrayList<>(); - double x, x1, x2, y, y1, y2; - if (!xdata.getIndexPrivate().isFastIterator()) { - xdata = xdata.copy(); - } - if (!ydata.getIndexPrivate().isFastIterator()) { - ydata = ydata.copy(); - } - switch (where) { - case "mid": - for (int i = 0; i < xdata.getSize() - 1; i++) { - x1 = xdata.getDouble(i); - x2 = xdata.getDouble(i + 1); - y1 = ydata.getDouble(i); - y2 = ydata.getDouble(i + 1); - if (Double.isNaN(y1) || Double.isNaN(x1) || Double.isNaN(x2)) { - if (points.isEmpty()) { - continue; - } - if (points.size() > 1) { - pls = new PolylineShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - points = new ArrayList<>(); - } - } else { - x = x1 + (x2 - x1) * 0.5; - if (i == 0) { - points.add(new PointD(x1, y1)); - points.add(new PointD(x, y1)); - points.add(new PointD(x, y2)); - } else if (i == xdata.getSize() - 2) { - points.add(new PointD(x, y1)); - points.add(new PointD(x, y2)); - points.add(new PointD(x2, y2)); - } else { - points.add(new PointD(x, y1)); - points.add(new PointD(x, y2)); - } - } - } - if (points.size() > 1) { - pls = new PolylineShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - } - break; - case "post": - for (int i = 0; i < xdata.getSize() - 1; i++) { - x1 = xdata.getDouble(i); - x2 = xdata.getDouble(i + 1); - y = ydata.getDouble(i); - if (Double.isNaN(y) || Double.isNaN(x1) || Double.isNaN(x2)) { - if (points.isEmpty()) { - continue; - } - if (points.size() > 1) { - pls = new PolylineShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - points = new ArrayList<>(); - } - } else { - points.add(new PointD(x1, y)); - points.add(new PointD(x2, y)); - if (i == xdata.getSize() - 2) { - points.add(new PointD(x2, ydata.getDouble(i + 1))); - } - } - } - if (points.size() > 1) { - pls = new PolylineShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - } - break; - default: - for (int i = 0; i < xdata.getSize() - 1; i++) { - x1 = xdata.getDouble(i); - x2 = xdata.getDouble(i + 1); - y = ydata.getDouble(i + 1); - if (Double.isNaN(y) || Double.isNaN(x1) || Double.isNaN(x2)) { - if (points.isEmpty()) { - continue; - } - if (points.size() > 1) { - pls = new PolylineShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - points = new ArrayList<>(); - } - } else { - if (i == 0) { - points.add(new PointD(x1, ydata.getDouble(i))); - } - points.add(new PointD(x1, y)); - points.add(new PointD(x2, y)); - } - } - if (points.size() > 1) { - pls = new PolylineShape(); - pls.setPoints(points); - gc.add(new Graphic(pls, cb)); - } - break; - } - - return gc; - } - - /** - * Create graphics - * - * @param xdata X data array - * @param ydata Y data array - * @param cb Color break - * @return LineString graphic - */ - public static GraphicCollection createGraphics(Array xdata, Array ydata, ColorBreak cb) { - GraphicCollection graphics = new GraphicCollection(); - if (cb instanceof PolylineBreak) { - graphics.add(createLineString(xdata, ydata, cb)); - } else { - PointShape ps; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - while (xIter.hasNext()){ - ps = new PointShape(); - ps.setPoint(new PointD(xIter.getDoubleNext(), yIter.getDoubleNext())); - graphics.add(new Graphic(ps, cb)); - } - } - return graphics; - } - - /** - * Create a point graphic - * @param x X - * @param y Y - * @param pb Point legend break - * @return Point graphic - */ - public static Graphic createPoint(float x, float y, PointBreak pb) { - PointShape ps = new PointShape(); - ps.setPoint(new PointD(x, y)); - return new Graphic(ps, pb); - } - - /** - * Create graphics - * - * @param xdata X data array - * @param ydata Y data array - * @param pb Point legend break - * @return Point graphics - */ - public static GraphicCollection createPoints(Array xdata, Array ydata, PointBreak pb) { - GraphicCollection graphics = new GraphicCollection(); - PointShape ps; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - while (xIter.hasNext()) { - ps = new PointShape(); - ps.setPoint(new PointD(xIter.getDoubleNext(), yIter.getDoubleNext())); - graphics.add(new Graphic(ps, pb)); - } - return graphics; - } - - /** - * Create graphics - * - * @param xdata X data array - * @param ydata Y data array - * @param cbs Color breaks - * @return Point graphics - */ - public static GraphicCollection createPoints(Array xdata, Array ydata, List cbs) { - GraphicCollection graphics = new GraphicCollection(); - PointShape ps; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - if (cbs.size() == xdata.getSize()) { - int i = 0; - while (xIter.hasNext()){ - ps = new PointShape(); - ps.setPoint(new PointD(xIter.getDoubleNext(), yIter.getDoubleNext())); - graphics.add(new Graphic(ps, cbs.get(i))); - i++; - } - graphics.setSingleLegend(false); - LegendScheme ls = new LegendScheme(); - ls.setLegendBreaks(cbs); - ls.setLegendType(LegendType.UniqueValue); - ls.setShapeType(ShapeTypes.Point); - graphics.setLegendScheme(ls); - } else { - while (xIter.hasNext()){ - ps = new PointShape(); - ps.setPoint(new PointD(xIter.getDoubleNext(), yIter.getDoubleNext())); - graphics.add(new Graphic(ps, cbs.get(0))); - LegendScheme ls = new LegendScheme(); - ls.setLegendBreaks(cbs); - ls.setLegendType(LegendType.SingleSymbol); - ls.setShapeType(ShapeTypes.Point); - graphics.setLegendScheme(ls); - } - } - return graphics; - } - - /** - * Create graphics - * - * @param xdata X data array - * @param ydata Y data array - * @param zdata Z data array - * @param ls Legend scheme - * @return LineString graphic - */ - public static GraphicCollection createPoints(Array xdata, Array ydata, Array zdata, LegendScheme ls) { - GraphicCollection graphics = new GraphicCollection(); - PointShape ps; - double z; - ColorBreak cb; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - IndexIterator zIter = zdata.getIndexIterator(); - while (xIter.hasNext()) { - ps = new PointShape(); - ps.setPoint(new PointD(xIter.getDoubleNext(), yIter.getDoubleNext())); - z = zIter.getDoubleNext(); - cb = ls.findLegendBreak(z); - graphics.add(new Graphic(ps, cb)); - } - graphics.setSingleLegend(false); - graphics.setLegendScheme(ls); - return graphics; - } - - /** - * Create graphics - * - * @param xdata X data array - * @param ydata Y data array - * @param zdata Z data array - * @param cb Color break - * @return LineString graphic - */ - public static GraphicCollection createPoints3D(Array xdata, Array ydata, Array zdata, ColorBreak cb) { - List cbs = new ArrayList<>(); - cbs.add(cb); - return createPoints3D(xdata, ydata, zdata, cbs); - } - - /** - * Create graphics - * - * @param xdata X data array - * @param ydata Y data array - * @param zdata Z data array - * @param cbs Color breaks - * @return LineString graphic - */ - public static GraphicCollection createPoints3D(Array xdata, Array ydata, Array zdata, List cbs) { - GraphicCollection3D graphics = new GraphicCollection3D(); - PointShape ps; - boolean fixZ = false; - double z = 0; - if (zdata.getSize() == 1 && xdata.getSize() > 1) { - fixZ = true; - z = zdata.getDouble(0); - } - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - IndexIterator zIter = zdata.getIndexIterator(); - if (cbs.size() == xdata.getSize()) { - int i = 0; - while (xIter.hasNext()) { - ps = new PointZShape(); - if (fixZ) { - ps.setPoint(new PointZ(xIter.getDoubleNext(), yIter.getDoubleNext(), z)); - } else { - ps.setPoint(new PointZ(xIter.getDoubleNext(), yIter.getDoubleNext(), zIter.getDoubleNext())); - } - graphics.add(new Graphic(ps, cbs.get(i))); - i++; - } - graphics.setSingleLegend(false); - LegendScheme ls = new LegendScheme(); - ls.setLegendBreaks(cbs); - ls.setLegendType(LegendType.UniqueValue); - ls.setShapeType(ShapeTypes.Point); - graphics.setLegendScheme(ls); - } else { - while (xIter.hasNext()) { - ps = new PointZShape(); - if (fixZ) { - ps.setPoint(new PointZ(xIter.getDoubleNext(), yIter.getDoubleNext(), z)); - } else { - ps.setPoint(new PointZ(xIter.getDoubleNext(), yIter.getDoubleNext(), zIter.getDoubleNext())); - } - graphics.add(new Graphic(ps, cbs.get(0))); - LegendScheme ls = new LegendScheme(); - ls.setLegendBreaks(cbs); - ls.setLegendType(LegendType.SingleSymbol); - ls.setShapeType(ShapeTypes.Point); - graphics.setLegendScheme(ls); - } - } - return graphics; - } - - /** - * Create 3D point graphics - * - * @param xdata X data array - * @param ydata Y data array - * @param zdata Z data array - * @param cdata C data array - * @param ls Legend scheme - * @return 3D point graphics - */ - public static GraphicCollection createPoints3D(Array xdata, Array ydata, Array zdata, Array cdata, LegendScheme ls) { - GraphicCollection3D graphics = new GraphicCollection3D(); - PointShape ps; - double c; - ColorBreak cb; - boolean fixZ = false; - double z = 0; - if (zdata.getSize() == 1 && xdata.getSize() > 1) { - fixZ = true; - z = zdata.getDouble(0); - } - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - IndexIterator zIter = zdata.getIndexIterator(); - IndexIterator cIter = cdata.getIndexIterator(); - while (xIter.hasNext()) { - ps = new PointZShape(); - if (fixZ) { - ps.setPoint(new PointZ(xIter.getDoubleNext(), yIter.getDoubleNext(), z)); - } else { - ps.setPoint(new PointZ(xIter.getDoubleNext(), yIter.getDoubleNext(), zIter.getDoubleNext())); - } - c = cIter.getDoubleNext(); - cb = ls.findLegendBreak(c); - graphics.add(new Graphic(ps, cb)); - } - graphics.setSingleLegend(false); - graphics.setLegendScheme(ls); - return graphics; - } - - /** - * Create 3D stem graphics - * - * @param xdata X data array - * @param ydata Y data array - * @param zdata Z data array - * @param cbs Color breaks - * @param plb Stem line break - * @param bottom Stem bottom - * @param sameStemColor Same stem line and point color or not - * @return Graphics - */ - public static GraphicCollection[] createStems3D(Array xdata, Array ydata, Array zdata, List cbs, - PolylineBreak plb, double bottom, boolean sameStemColor) { - GraphicCollection3D graphics = new GraphicCollection3D(); - GraphicCollection3D stemlines = new GraphicCollection3D(); - PointShape ps; - boolean fixZ = false; - double x, y, z, z0 = 0; - if (zdata.getSize() == 1 && xdata.getSize() > 1) { - fixZ = true; - z0 = zdata.getDouble(0); - } - List pzs; - PolylineZShape pls; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - IndexIterator zIter = zdata.getIndexIterator(); - if (cbs.size() == xdata.getSize()) { - int i = 0; - while (xIter.hasNext()) { - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - if (Double.isNaN(x) || Double.isNaN(y)) { - continue; - } - ps = new PointZShape(); - pzs = new ArrayList<>(); - if (fixZ) { - ps.setPoint(new PointZ(x, y, z0)); - pzs.add(new PointZ(x, y, bottom)); - pzs.add(new PointZ(x, y, z0)); - } else { - z = zIter.getDoubleNext(); - if (Double.isNaN(z)) { - continue; - } - ps.setPoint(new PointZ(x, y, z)); - pzs.add(new PointZ(x, y, bottom)); - pzs.add(new PointZ(x, y, z)); - } - graphics.add(new Graphic(ps, cbs.get(i))); - pls = new PolylineZShape(); - pls.setPoints(pzs); - if (sameStemColor) { - PolylineBreak nplb = (PolylineBreak) plb.clone(); - nplb.setColor(cbs.get(i).getColor()); - stemlines.add(new Graphic(pls, nplb)); - } else { - stemlines.add(new Graphic(pls, plb)); - } - i++; - } - graphics.setSingleLegend(false); - LegendScheme ls = new LegendScheme(); - ls.setLegendBreaks(cbs); - ls.setLegendType(LegendType.UniqueValue); - ls.setShapeType(ShapeTypes.Point); - graphics.setLegendScheme(ls); - } else { - while (xIter.hasNext()) { - ps = new PointZShape(); - pzs = new ArrayList<>(); - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - if (fixZ) { - ps.setPoint(new PointZ(x, y, z0)); - pzs.add(new PointZ(x, y, bottom)); - pzs.add(new PointZ(x, y, z0)); - } else { - z = zIter.getDoubleNext(); - ps.setPoint(new PointZ(x, y, z)); - pzs.add(new PointZ(x, y, bottom)); - pzs.add(new PointZ(x, y, z)); - } - graphics.add(new Graphic(ps, cbs.get(0))); - pls = new PolylineZShape(); - pls.setPoints(pzs); - if (sameStemColor) { - PolylineBreak nplb = (PolylineBreak) plb.clone(); - nplb.setColor(cbs.get(0).getColor()); - stemlines.add(new Graphic(pls, nplb)); - } else { - stemlines.add(new Graphic(pls, plb)); - } - } - LegendScheme ls = new LegendScheme(); - ls.setLegendBreaks(cbs); - ls.setLegendType(LegendType.SingleSymbol); - ls.setShapeType(ShapeTypes.Point); - graphics.setLegendScheme(ls); - } - return new GraphicCollection[]{stemlines, graphics}; - } - - /** - * Create 3D stem graphics - * - * @param xdata X data array - * @param ydata Y data array - * @param zdata Z data array - * @param cdata C data array - * @param ls Legend scheme - * @param plb Stem line break - * @param bottom Stem bottom - * @param sameStemColor Same stem line and point color or not - * @return 3D point graphics - */ - public static GraphicCollection[] createStems3D(Array xdata, Array ydata, Array zdata, Array cdata, LegendScheme ls, - PolylineBreak plb, double bottom, boolean sameStemColor) { - GraphicCollection3D graphics = new GraphicCollection3D(); - GraphicCollection3D stemlines = new GraphicCollection3D(); - PointShape ps; - double c; - ColorBreak cb; - boolean fixZ = false; - double x, y, z, z0 = 0; - if (zdata.getSize() == 1 && xdata.getSize() > 1) { - fixZ = true; - z0 = zdata.getDouble(0); - } - List pzs; - PolylineZShape pls; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - IndexIterator zIter = zdata.getIndexIterator(); - IndexIterator cIter = cdata.getIndexIterator(); - while (xIter.hasNext()){ - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - if (Double.isNaN(x) || Double.isNaN(y)) { - continue; - } - ps = new PointZShape(); - pzs = new ArrayList<>(); - if (fixZ) { - ps.setPoint(new PointZ(x, y, z0)); - pzs.add(new PointZ(x, y, bottom)); - pzs.add(new PointZ(x, y, z0)); - } else { - z = zIter.getDoubleNext(); - if (Double.isNaN(z)) { - continue; - } - ps.setPoint(new PointZ(x, y, z)); - pzs.add(new PointZ(x, y, bottom)); - pzs.add(new PointZ(x, y, z)); - } - c = cIter.getDoubleNext(); - cb = ls.findLegendBreak(c); - graphics.add(new Graphic(ps, cb)); - pls = new PolylineZShape(); - pls.setPoints(pzs); - if (sameStemColor) { - PolylineBreak nplb = (PolylineBreak) plb.clone(); - nplb.setColor(cb.getColor()); - stemlines.add(new Graphic(pls, nplb)); - } else { - stemlines.add(new Graphic(pls, plb)); - } - } - graphics.setSingleLegend(false); - graphics.setLegendScheme(ls); - return new GraphicCollection[]{stemlines, graphics}; - } - - /** - * Add polygons - * - * @param xa X coordinate array - * @param ya Y coordinate array - * @param pgb PolygonBreak - * @return Graphics - */ - public static GraphicCollection createPolygons(Array xa, Array ya, PolygonBreak pgb) { - GraphicCollection graphics = new GraphicCollection(); - double x, y; - int n = (int) xa.getSize(); - PolygonShape pgs; - PointD p; - List points = new ArrayList<>(); - IndexIterator xIter = xa.getIndexIterator(); - IndexIterator yIter = ya.getIndexIterator(); - while (xIter.hasNext()){ - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - if (Double.isNaN(x)) { - if (points.size() > 2) { - pgs = new PolygonShape(); - pgs.setPoints(points); - Graphic aGraphic = new Graphic(pgs, pgb); - graphics.add(aGraphic); - } - points = new ArrayList<>(); - } else { - p = new PointD(x, y); - points.add(p); - } - } - if (points.size() > 2) { - pgs = new PolygonShape(); - pgs.setPoints(points); - Graphic aGraphic = new Graphic(pgs, pgb); - graphics.add(aGraphic); - } - return graphics; - } - - /** - * Add wireframe polylines - * - * @param xa X coordinate array - * @param ya Y coordinate array - * @param za Z coordinate array - * @param pb Polyline break - * @return Graphics - */ - public static GraphicCollection createWireframe(Array xa, Array ya, Array za, PolylineBreak pb) { - GraphicCollection3D graphics = new GraphicCollection3D(); - int[] shape = xa.getShape(); - int colNum = shape[1]; - int rowNum = shape[0]; - double z1, z2, z3, z4, z; - int idx1, idx2, idx3, idx4; - if (!xa.getIndexPrivate().isFastIterator()) - xa = xa.copy(); - if (!ya.getIndexPrivate().isFastIterator()) - ya = ya.copy(); - if (!za.getIndexPrivate().isFastIterator()) - za = za.copy(); - for (int i = 0; i < rowNum - 1; i++) { - for (int j = 0; j < colNum - 1; j++) { - idx1 = i * colNum + j; - idx2 = i * colNum + j + 1; - idx3 = (i + 1) * colNum + j; - idx4 = (i + 1) * colNum + j + 1; - z1 = za.getDouble(idx1); - z2 = za.getDouble(idx2); - z3 = za.getDouble(idx3); - z4 = za.getDouble(idx4); - z = (z1 + z2 + z3 + z4) / 4.0; - PolylineZShape ps = new PolylineZShape(); - List points = new ArrayList<>(); - points.add(new PointZ(xa.getDouble(idx1), ya.getDouble(idx1), z1)); - points.add(new PointZ(xa.getDouble(idx3), ya.getDouble(idx3), z3)); - points.add(new PointZ(xa.getDouble(idx4), ya.getDouble(idx4), z4)); - points.add(new PointZ(xa.getDouble(idx2), ya.getDouble(idx2), z2)); - points.add((PointZ) points.get(0).clone()); - ps.setPoints(points); - Graphic graphic = new Graphic(ps, pb); - graphics.add(graphic); - } - } - - return graphics; - } - - /** - * Add wireframe polylines - * - * @param xa X coordinate array - * @param ya Y coordinate array - * @param za Z coordinate array - * @param ls Legend scheme - * @return Graphics - */ - public static GraphicCollection createWireframe(Array xa, Array ya, Array za, LegendScheme ls) { - GraphicCollection3D graphics = new GraphicCollection3D(); - int[] shape = xa.getShape(); - int colNum = shape[1]; - int rowNum = shape[0]; - double z1, z2, z3, z4, z; - int idx1, idx2, idx3, idx4; - PolylineBreak pb; - PolylineZShape ps; - Graphic graphic; - List points; - if (!xa.getIndexPrivate().isFastIterator()) - xa = xa.copy(); - if (!ya.getIndexPrivate().isFastIterator()) - ya = ya.copy(); - if (!za.getIndexPrivate().isFastIterator()) - za = za.copy(); - for (int i = 0; i < rowNum - 1; i++) { - for (int j = 0; j < colNum - 1; j++) { - idx1 = i * colNum + j; - idx2 = i * colNum + j + 1; - idx3 = (i + 1) * colNum + j; - idx4 = (i + 1) * colNum + j + 1; - z1 = za.getDouble(idx1); - z2 = za.getDouble(idx2); - z3 = za.getDouble(idx3); - z4 = za.getDouble(idx4); - ps = new PolylineZShape(); - points = new ArrayList<>(); - points.add(new PointZ(xa.getDouble(idx1), ya.getDouble(idx1), z1)); - points.add(new PointZ(xa.getDouble(idx3), ya.getDouble(idx3), z3)); - ps.setPoints(points); - z = (z1 + z3) * 0.5; - ps.setValue(z); - pb = (PolylineBreak) ls.findLegendBreak(z); - graphic = new Graphic(ps, pb); - graphics.add(graphic); - ps = new PolylineZShape(); - points = new ArrayList<>(); - points.add(new PointZ(xa.getDouble(idx3), ya.getDouble(idx3), z3)); - points.add(new PointZ(xa.getDouble(idx4), ya.getDouble(idx4), z4)); - ps.setPoints(points); - z = (z3 + z4) * 0.5; - ps.setValue(z); - pb = (PolylineBreak) ls.findLegendBreak(z); - graphic = new Graphic(ps, pb); - graphics.add(graphic); - ps = new PolylineZShape(); - points = new ArrayList<>(); - points.add(new PointZ(xa.getDouble(idx4), ya.getDouble(idx4), z4)); - points.add(new PointZ(xa.getDouble(idx2), ya.getDouble(idx2), z2)); - ps.setPoints(points); - z = (z4 + z2) * 0.5; - ps.setValue(z); - pb = (PolylineBreak) ls.findLegendBreak(z); - graphic = new Graphic(ps, pb); - graphics.add(graphic); - ps = new PolylineZShape(); - points = new ArrayList<>(); - points.add(new PointZ(xa.getDouble(idx2), ya.getDouble(idx2), z2)); - points.add(new PointZ(xa.getDouble(idx1), ya.getDouble(idx1), z1)); - ps.setPoints(points); - z = (z1 + z2) * 0.5; - ps.setValue(z); - pb = (PolylineBreak) ls.findLegendBreak(z); - graphic = new Graphic(ps, pb); - graphics.add(graphic); - } - } - graphics.setSingleLegend(false); - graphics.setLegendScheme(ls); - - return graphics; - } - - /** - * Add mesh polygons - * - * @param xa X coordinate array - * @param ya Y coordinate array - * @param za Z coordinate array - * @param ls Legend scheme - * @return Graphics - */ - public static GraphicCollection createMeshPolygons(Array xa, Array ya, Array za, LegendScheme ls) { - GraphicCollection3D graphics = new GraphicCollection3D(); - int[] shape = xa.getShape(); - int colNum = shape[1]; - int rowNum = shape[0]; - double z1, z2, z3, z4, z; - int idx1, idx2, idx3, idx4; - PolygonBreak pb; - xa = xa.copyIfView(); - ya = ya.copyIfView(); - za = za.copyIfView(); - for (int i = 0; i < rowNum - 1; i++) { - for (int j = 0; j < colNum - 1; j++) { - idx1 = i * colNum + j; - idx2 = i * colNum + j + 1; - idx3 = (i + 1) * colNum + j; - idx4 = (i + 1) * colNum + j + 1; - z1 = za.getDouble(idx1); - z2 = za.getDouble(idx2); - z3 = za.getDouble(idx3); - z4 = za.getDouble(idx4); - z = (z1 + z2 + z3 + z4) / 4.0; - PolygonZShape ps = new PolygonZShape(); - List points = new ArrayList<>(); - points.add(new PointZ(xa.getDouble(idx1), ya.getDouble(idx1), z1)); - points.add(new PointZ(xa.getDouble(idx3), ya.getDouble(idx3), z3)); - points.add(new PointZ(xa.getDouble(idx4), ya.getDouble(idx4), z4)); - points.add(new PointZ(xa.getDouble(idx2), ya.getDouble(idx2), z2)); - points.add((PointZ) points.get(0).clone()); - ps.setPoints(points); - ps.lowValue = z; - ps.highValue = ps.lowValue; - pb = (PolygonBreak) ls.findLegendBreak(z); - //pb.setDrawOutline(true); - Graphic graphic = new Graphic(ps, pb); - graphics.add(graphic); - } - } - graphics.setAllQuads(true); - graphics.setSingleLegend(false); - graphics.setLegendScheme(ls); - return graphics; - } - - /** - * Create 3D graphics from a VectorLayer. - * - * @param layer The layer - * @param offset Offset of z axis. - * @param xshift X shift - to shift the grahpics in x direction, normally - * for map in 180 - 360 degree east - * @return Graphics - */ - public static GraphicCollection createGraphicsFromLayer(VectorLayer layer, double offset, double xshift) { - GraphicCollection3D graphics = new GraphicCollection3D(); - graphics.setFixZ(true); - graphics.setZValue(offset); - ShapeTypes shapeType = layer.getShapeType(); - LegendScheme ls = layer.getLegendScheme(); - PointZ pz; - ColorBreak cb; - switch (shapeType) { - case Point: - for (PointShape shape : (List) layer.getShapes()) { - PointZShape s = new PointZShape(); - PointD pd = shape.getPoint(); - pz = new PointZ(pd.X + xshift, pd.Y, offset); - s.setPoint(pz); - cb = ls.getLegendBreaks().get(shape.getLegendIndex()); - graphics.add(new Graphic(s, cb)); - } - break; - case Polyline: - for (PolylineShape shape : (List) layer.getShapes()) { - cb = ls.getLegendBreaks().get(shape.getLegendIndex()); - for (Polyline pl : (List) shape.getPolylines()) { - PolylineZShape s = new PolylineZShape(); - List plist = new ArrayList<>(); - for (PointD pd : pl.getPointList()) { - pz = new PointZ(pd.X + xshift, pd.Y, offset); - plist.add(pz); - } - s.setPoints(plist); - graphics.add(new Graphic(s, cb)); - } - } - break; - case Polygon: - for (PolygonShape shape : (List) layer.getShapes()) { - PolygonZShape s = new PolygonZShape(); - List plist = new ArrayList<>(); - for (PointD pd : shape.getPoints()) { - pz = new PointZ(pd.X + xshift, pd.Y, offset); - plist.add(pz); - } - s.setPartNum(shape.getPartNum()); - s.setParts(shape.getParts()); - s.setPoints(plist); - cb = ls.getLegendBreaks().get(shape.getLegendIndex()); - graphics.add(new Graphic(s, cb)); - } - break; - case PointZ: - case PolylineZ: - case PolygonZ: - graphics.setFixZ(false); - if (xshift == 0) { - for (Shape shape : layer.getShapes()) { - - cb = ls.getLegendBreaks().get(shape.getLegendIndex()); - graphics.add(new Graphic(shape, cb)); - } - } else { - switch (shapeType) { - case PointZ: - for (PointZShape shape : (List) layer.getShapes()) { - PointZShape s = new PointZShape(); - PointZ pd = (PointZ) shape.getPoint(); - pz = new PointZ(pd.X + xshift, pd.Y, pd.Z, pd.M); - s.setPoint(pz); - cb = ls.getLegendBreaks().get(shape.getLegendIndex()); - graphics.add(new Graphic(s, cb)); - } - break; - case PolylineZ: - for (PolylineZShape shape : (List) layer.getShapes()) { - cb = ls.getLegendBreaks().get(shape.getLegendIndex()); - for (PolylineZ pl : (List) shape.getPolylines()) { - PolylineZShape s = new PolylineZShape(); - List plist = new ArrayList<>(); - for (PointZ pd : (List) pl.getPointList()) { - pz = new PointZ(pd.X + xshift, pd.Y, pd.Z, pd.M); - plist.add(pz); - } - s.setPoints(plist); - graphics.add(new Graphic(s, cb)); - } - } - break; - case PolygonZ: - for (PolygonZShape shape : (List) layer.getShapes()) { - PolygonZShape s = new PolygonZShape(); - List plist = new ArrayList<>(); - for (PointZ pd : (List) shape.getPoints()) { - pz = new PointZ(pd.X + xshift, pd.Y, pd.Z, pd.M); - plist.add(pz); - } - s.setPartNum(shape.getPartNum()); - s.setParts(shape.getParts()); - s.setPoints(plist); - cb = ls.getLegendBreaks().get(shape.getLegendIndex()); - graphics.add(new Graphic(s, cb)); - } - break; - } - } - break; - } - graphics.setLegendScheme(ls); - - return graphics; - } - - /** - * Create rectangle graphic - * - * @param pos Rectangle position - * @param curvature Curvature - * @param pgb Polygon break - * @return - */ - public static Graphic createRectangle(List pos, List curvature, PolygonBreak pgb) { - RectangleShape rect = new RectangleShape(pos.get(0).doubleValue(), pos.get(1).doubleValue(), - pos.get(2).doubleValue(), pos.get(3).doubleValue()); - if (curvature != null) { - rect.setRoundX(curvature.get(0).doubleValue()); - rect.setRoundY(curvature.get(1).doubleValue()); - } - Graphic graphic = new Graphic(rect, pgb); - return graphic; - } - - /** - * Create bar graphics - * - * @param xdata X data array - * @param ydata Y data array - * @param autoWidth Is auto width or not - * @param widths Width - * @param drawError Is draw error or not - * @param error Error - * @param drawBottom Is draw bottom or not - * @param bottom Bottom - * @param bbs Bar breaks - * @return Bar graphics - */ - public static GraphicCollection createBars(Array xdata, Array ydata, boolean autoWidth, - Array widths, boolean drawError, Array error, boolean drawBottom, Array bottom, - List bbs) { - GraphicCollection graphics = new GraphicCollection(); - int n = (int) xdata.getSize(); - double x, y; - BarBreak bb = bbs.get(0); - PolylineBreak ebreak = new PolylineBreak(); - ebreak.setColor(bb.getErrorColor()); - ebreak.setWidth(bb.getErrorSize()); - double width = widths.getDouble(0); - if (autoWidth && xdata.getSize() > 1) { - width = (xdata.getDouble(1) - xdata.getDouble(0)) * width; - } - double bot = 0; - if (drawBottom) { - bot = bottom.getDouble(0); - } - double miny = 0; - //boolean baseLine = false; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - int i = 0; - while (xIter.hasNext()){ - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - // Add bar - if (drawBottom) { - if (bottom.getSize() > i) { - bot = bottom.getDouble(i); - } - miny = bot; - y += miny; - } -// if (y < miny) { -// baseLine = true; -// } - if (widths.getSize() > 1 && widths.getSize() > i) { - width = widths.getDouble(i); - } - List pList = new ArrayList<>(); - pList.add(new PointD(x, miny)); - pList.add(new PointD(x, y)); - pList.add(new PointD(x + width, y)); - pList.add(new PointD(x + width, miny)); - pList.add(new PointD(x, miny)); - PolygonShape pgs = new PolygonShape(); - pgs.setPoints(pList); - if (bbs.size() > i) { - bb = bbs.get(i); - } - graphics.add(new Graphic(pgs, bb)); - - if (drawError) { - //Add error line - double e = error.getDouble(i); - pList = new ArrayList<>(); - pList.add(new PointD(x + width * 0.5, y - e)); - pList.add(new PointD(x + width * 0.5, y + e)); - PolylineShape pls = new PolylineShape(); - pls.setPoints(pList); - graphics.add(new Graphic(pls, ebreak)); - //Add cap - pList = new ArrayList<>(); - pList.add(new PointD(x + width * 0.25, y - e)); - pList.add(new PointD(x + width * 0.75, y - e)); - pls = new PolylineShape(); - pls.setPoints(pList); - graphics.add(new Graphic(pls, ebreak)); - pList = new ArrayList<>(); - pList.add(new PointD(x + width * 0.25, y + e)); - pList.add(new PointD(x + width * 0.75, y + e)); - pls = new PolylineShape(); - pls.setPoints(pList); - graphics.add(new Graphic(pls, ebreak)); - } - i++; - } - -// if (baseLine) { -// List pList = new ArrayList<>(); -// double x1 = xdata.getDouble(0); -// double x2 = xdata.getDouble((int) xdata.getSize() - 1); -// x1 -= (x2 - x1); -// x2 += (x2 - x1); -// pList.add(new PointD(x1, miny)); -// pList.add(new PointD(x2, miny)); -// PolylineShape pls = new PolylineShape(); -// pls.setPoints(pList); -// ebreak = new PolylineBreak(); -// ebreak.setColor(Color.black); -// graphics.add(new Graphic(pls, ebreak)); -// } - graphics.setSingleLegend(false); - - return graphics; - } - - /** - * Create horizontal bar graphics - * - * @param ydata Y data array - * @param xdata X data array - * @param autoHeight Is auto height or not - * @param heights Heights - * @param drawError Is draw error or not - * @param error Error - * @param drawLeft Is draw left or not - * @param left Left - * @param bbs Bar breaks - * @return Bar graphics - */ - public static GraphicCollection createHBars(Array ydata, Array xdata, boolean autoHeight, - Array heights, boolean drawError, Array error, boolean drawLeft, Array left, - List bbs) { - GraphicCollection graphics = new GraphicCollection(); - int n = (int) ydata.getSize(); - double x, y; - BarBreak bb = bbs.get(0); - PolylineBreak ebreak = new PolylineBreak(); - ebreak.setColor(bb.getErrorColor()); - ebreak.setWidth(bb.getErrorSize()); - double height = heights.getDouble(0); - if (autoHeight && ydata.getSize() > 1) { - height = (ydata.getDouble(1) - ydata.getDouble(0)) * height; - } - double bot = 0; - if (drawLeft) { - bot = left.getDouble(0); - } - double minx = 0; - //boolean baseLine = false; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - int i = 0; - while (xIter.hasNext()){ - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - // Add bar - if (drawLeft) { - if (left.getSize() > i) { - bot = left.getDouble(i); - } - minx = bot; - x += minx; - } -// if (x < minx) { -// baseLine = true; -// } - if (heights.getSize() > 1 && heights.getSize() > i) { - height = heights.getDouble(i); - } - List pList = new ArrayList<>(); - pList.add(new PointD(minx, y)); - pList.add(new PointD(x, y)); - pList.add(new PointD(x, y + height)); - pList.add(new PointD(minx, y + height)); - pList.add(new PointD(minx, y)); - PolygonShape pgs = new PolygonShape(); - pgs.setPoints(pList); - if (bbs.size() > i) { - bb = bbs.get(i); - } - graphics.add(new Graphic(pgs, bb)); - - if (drawError) { - //Add error line - double e = error.getDouble(i); - pList = new ArrayList<>(); - pList.add(new PointD(x - e, y + height * 0.5)); - pList.add(new PointD(x + e, y + height * 0.5)); - PolylineShape pls = new PolylineShape(); - pls.setPoints(pList); - graphics.add(new Graphic(pls, ebreak)); - //Add cap - pList = new ArrayList<>(); - pList.add(new PointD(x - e, y + height * 0.25)); - pList.add(new PointD(x - e, y + height * 0.75)); - pls = new PolylineShape(); - pls.setPoints(pList); - graphics.add(new Graphic(pls, ebreak)); - pList = new ArrayList<>(); - pList.add(new PointD(x + e, y + height * 0.25)); - pList.add(new PointD(x + e, y + height * 0.75)); - pls = new PolylineShape(); - pls.setPoints(pList); - graphics.add(new Graphic(pls, ebreak)); - } - i++; - } - -// if (baseLine) { -// List pList = new ArrayList<>(); -// double y1 = ydata.getDouble(0); -// double y2 = ydata.getDouble((int) ydata.getSize() - 1); -// y1 -= (y2 - y1); -// y2 += (y2 - y1); -// pList.add(new PointD(minx, y1)); -// pList.add(new PointD(minx, y2)); -// PolylineShape pls = new PolylineShape(); -// pls.setPoints(pList); -// ebreak = new PolylineBreak(); -// ebreak.setColor(Color.black); -// graphics.add(new Graphic(pls, ebreak)); -// } - graphics.setSingleLegend(false); - - return graphics; - } - - /** - * Create bar graphics - * - * @param xdata X data array - * @param ydata Y data array - * @param autoWidth Is auto width or not - * @param widths Width - * @param drawError Is draw error or not - * @param error Error - * @param drawBottom Is draw bottom or not - * @param bottom Bottom - * @param bbs Bar breaks - * @return Bar graphics - */ - public static GraphicCollection createBars1(Array xdata, Array ydata, boolean autoWidth, - Array widths, boolean drawError, Array error, boolean drawBottom, Array bottom, - List bbs) { - GraphicCollection graphics = new GraphicCollection(); - int n = (int) xdata.getSize(); - double x, y; - BarBreak bb = bbs.get(0); - PolylineBreak ebreak = new PolylineBreak(); - ebreak.setColor(bb.getErrorColor()); - ebreak.setWidth(bb.getErrorSize()); - double width = widths.getDouble(0); - if (autoWidth && xdata.getSize() > 1) { - width = (xdata.getDouble(1) - xdata.getDouble(0)) * width; - } - double bot = 0; - if (drawBottom) { - bot = bottom.getDouble(0); - } - double miny = 0; - boolean baseLine = false; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - int i = 0; - while (xIter.hasNext()){ - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - // Add bar - if (drawBottom) { - if (bottom.getSize() > i) { - bot = bottom.getDouble(i); - } - miny = bot; - y += miny; - } - if (y < miny) { - baseLine = true; - } - if (widths.getSize() > 1 && widths.getSize() > i) { - width = widths.getDouble(i); - } - List pList = new ArrayList<>(); - pList.add(new PointD(x, miny)); - for (double x1 = x; x1 < x + width; x1 += width / 100) { - pList.add(new PointD(x1, y)); - } - pList.add(new PointD(x + width, y)); - for (double x1 = x + width; x1 > x; x1 -= width / 20) { - pList.add(new PointD(x1, miny)); - } - pList.add(new PointD(x, miny)); - PolygonShape pgs = new PolygonShape(); - pgs.setPoints(pList); - if (bbs.size() > i) { - bb = bbs.get(i); - } - graphics.add(new Graphic(pgs, bb)); - - if (drawError) { - //Add error line - double e = error.getDouble(i); - pList = new ArrayList<>(); - pList.add(new PointD(x + width * 0.5, y - e)); - pList.add(new PointD(x + width * 0.5, y + e)); - PolylineShape pls = new PolylineShape(); - pls.setPoints(pList); - graphics.add(new Graphic(pls, ebreak)); - //Add cap - pList = new ArrayList<>(); - pList.add(new PointD(x + width * 0.25, y - e)); - pList.add(new PointD(x + width * 0.75, y - e)); - pls = new PolylineShape(); - pls.setPoints(pList); - graphics.add(new Graphic(pls, ebreak)); - pList = new ArrayList<>(); - pList.add(new PointD(x + width * 0.25, y + e)); - pList.add(new PointD(x + width * 0.75, y + e)); - pls = new PolylineShape(); - pls.setPoints(pList); - graphics.add(new Graphic(pls, ebreak)); - } - i++; - } - - if (baseLine) { - List pList = new ArrayList<>(); - double x1 = xdata.getDouble(0); - double x2 = xdata.getDouble((int) xdata.getSize() - 1); - x1 -= (x2 - x1); - x2 += (x2 - x1); - pList.add(new PointD(x1, miny)); - pList.add(new PointD(x2, miny)); - PolylineShape pls = new PolylineShape(); - pls.setPoints(pList); - ebreak = new PolylineBreak(); - ebreak.setColor(Color.black); - graphics.add(new Graphic(pls, ebreak)); - } - graphics.setSingleLegend(false); - - return graphics; - } - - /** - * Create 3D bar graphics - * - * @param xdata X data array - * @param ydata Y data array - * @param zdata Z data array - * @param autoWidth Is auto width or not - * @param widths Width - * @param bottom Bottom - * @param bbs Bar breaks - * @return Bar graphics - */ - public static GraphicCollection createBars3D(Array xdata, Array ydata, Array zdata, boolean autoWidth, - Array widths, Array bottom, List bbs) { - GraphicCollection graphics = new GraphicCollection(); - int n = (int) xdata.getSize(); - double x, y, z; - BarBreak bb = bbs.get(0); - double width = widths.getDouble(0); - if (autoWidth && xdata.getSize() > 1) { - width = (xdata.getDouble(1) - xdata.getDouble(0)) * width; - } - double bot = 0; - double minz = 0; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - IndexIterator zIter = zdata.getIndexIterator(); - int i = 0; - double hw = width * 0.5; - while (xIter.hasNext()){ - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - z = zIter.getDoubleNext(); - if (!Double.isNaN(z)) { - // Add bar - if (widths.getSize() > 1 && widths.getSize() > i) { - width = widths.getDouble(i); - hw = width * 0.5; - } - List pList = new ArrayList<>(); - pList.add(new PointZ(x + hw, y + hw, minz)); - pList.add(new PointZ(x + hw, y - hw, minz)); - pList.add(new PointZ(x + hw, y + hw, z)); - pList.add(new PointZ(x + hw, y - hw, z)); - pList.add(new PointZ(x - hw, y + hw, minz)); - pList.add(new PointZ(x - hw, y - hw, minz)); - pList.add(new PointZ(x - hw, y + hw, z)); - pList.add(new PointZ(x - hw, y - hw, z)); - CubicShape cs = new CubicShape(); - cs.setPoints(pList); - if (bbs.size() > i) { - bb = bbs.get(i); - } - graphics.add(new Graphic(cs, bb)); - - i++; - } - } - - graphics.setSingleLegend(false); - - return graphics; - } - - /** - * Create 3D cylinder bar graphics - * - * @param xdata X data array - * @param ydata Y data array - * @param zdata Z data array - * @param autoWidth Is auto width or not - * @param widths Width - * @param bottom Bottom - * @param bbs Bar breaks - * @return Bar graphics - */ - public static GraphicCollection createCylinderBars3D(Array xdata, Array ydata, Array zdata, boolean autoWidth, - Array widths, Array bottom, List bbs) { - GraphicCollection graphics = new GraphicCollection(); - int n = (int) xdata.getSize(); - double x, y, z; - BarBreak bb = bbs.get(0); - double width = widths.getDouble(0); - if (autoWidth && xdata.getSize() > 1) { - width = (xdata.getDouble(1) - xdata.getDouble(0)) * width; - } - double bot = 0; - double minz = 0; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - IndexIterator zIter = zdata.getIndexIterator(); - int i = 0; - double hw = width * 0.5; - while (xIter.hasNext()){ - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - z = zIter.getDoubleNext(); - // Add bar - if (widths.getSize() > 1 && widths.getSize() > i) { - width = widths.getDouble(i); - hw = width * 0.5; - } - List pList = new ArrayList<>(); - pList.add(new PointZ(x, y, minz)); - pList.add(new PointZ(x, y, z)); - CylinderShape cs = new CylinderShape(pList, hw); - if (bbs.size() > i) { - bb = bbs.get(i); - } - graphics.add(new Graphic(cs, bb)); - - i++; - } - - graphics.setSingleLegend(false); - - return graphics; - } - - /** - * Create histogram bar graphics - * - * @param data The data array - * @param bins Bins number - * @param bbs Bar breaks - * @return Bar graphics - */ - public static GraphicCollection createHistBars(Array data, int bins, - List bbs) { - List r = ArrayUtil.histogram(data, bins); - Array xdata = r.get(1); - Array ydata = r.get(0); - return createHistBars(data, xdata, ydata, bbs); - } - - /** - * Create histogram bar graphics - * - * @param data The data array - * @param bins Bins array - * @param bbs Bar breaks - * @return Bar graphics - */ - public static GraphicCollection createHistBars(Array data, Array bins, - List bbs) { - List r = ArrayUtil.histogram(data, bins); - Array xdata = r.get(1); - Array ydata = r.get(0); - return createHistBars(data, xdata, ydata, bbs); - } - - /** - * Create histogram bar graphics - * - * @param data The data array - * @param xdata X bins data - * @param ydata Y bins data - * @param bbs Bar breaks - * @return Bar graphics - */ - public static GraphicCollection createHistBars(Array data, Array xdata, Array ydata, - List bbs) { - GraphicCollection graphics = new GraphicCollection(); - int n = (int) ydata.getSize(); - double x, y, width; - BarBreak bb = bbs.get(0); - if (!xdata.getIndexPrivate().isFastIterator()) - xdata = xdata.copy(); - if (!ydata.getIndexPrivate().isFastIterator()) - ydata = ydata.copy(); - for (int i = 0; i < n; i++) { - x = (xdata.getDouble(i + 1) + xdata.getDouble(i)) * 0.5; - width = xdata.getDouble(i + 1) - xdata.getDouble(i); - y = ydata.getDouble(i); - BarShape bs = new BarShape(); - bs.setPoint(new PointD(x, y)); - bs.setAutoWidth(false); - bs.setWidth(width); - bs.setDrawBottom(false); - if (bbs.size() > i) { - bb = bbs.get(i); - } - graphics.add(new Graphic(bs, bb)); - } - if (bbs.size() == 1) { - graphics.setSingleLegend(true); - } else { - graphics.setSingleLegend(false); - } - - return graphics; - } - - /** - * Create stem graphics - * - * @param xdata X data array - * @param ydata Y data array - * @param plb Polyline break - * @param pb Point break - * @param bplb Baseline break - * @param bottom Bottom - * @return Bar graphics - */ - public static GraphicCollection createStems(Array xdata, Array ydata, PolylineBreak plb, PointBreak pb, - PolylineBreak bplb, double bottom) { - GraphicCollection graphics = new GraphicCollection(); - int n = (int) xdata.getSize(); - double x, y; - double miny = bottom; - boolean baseLine = false; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - while (xIter.hasNext()) { - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - if (Double.isNaN(x) || Double.isNaN(y)) { - continue; - } - // Add stem - if (y < miny) { - baseLine = true; - } - List pList = new ArrayList<>(); - pList.add(new PointD(x, miny)); - pList.add(new PointD(x, y)); - PolylineShape pls = new PolylineShape(); - pls.setPoints(pList); - graphics.add(new Graphic(pls, plb)); - PointShape ps = new PointShape(); - ps.setPoint(new PointD(x, y)); - graphics.add(new Graphic(ps, pb)); - } - - if (baseLine) { - List pList = new ArrayList<>(); - Index xIdx = xdata.getIndex(); - xIdx.setCurrentCounter(0); - double x1 = xdata.getDouble(xIdx); - xIdx.setCurrentCounter((int)xdata.getSize() - 1); - double x2 = xdata.getDouble(xIdx); - pList.add(new PointD(x1, miny)); - pList.add(new PointD(x2, miny)); - PolylineShape pls = new PolylineShape(); - pls.setPoints(pList); - graphics.add(new Graphic(pls, bplb)); - } - graphics.setSingleLegend(false); - - return graphics; - } - - /** - * Create an image graphic - * - * @param image The image - * @return Image graphic - */ - public static Graphic createImage(BufferedImage image) { - ImageShape ishape = new ImageShape(); - ishape.setPoint(new PointD(0, 0)); - ishape.setImage(image); - ishape.setExtent(new Extent(0, image.getWidth(), 0, image.getHeight())); - return new Graphic(ishape, new ColorBreak()); - } - - /** - * Create image - * - * @param gdata data array - * @param extent Extent - * @return Image graphic - */ - public static Graphic createImage(Array gdata, List extent) { - int width, height; - width = gdata.getShape()[1]; - height = gdata.getShape()[0]; - Color undefColor = Color.white; - BufferedImage aImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - Color color; - Index index = gdata.getIndex(); - boolean isAlpha = gdata.getShape()[2] == 4; - if (gdata.getDataType() == DataType.FLOAT || gdata.getDataType() == DataType.DOUBLE) { - float r, g, b; - if (isAlpha) { - float a; - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - r = gdata.getFloat(index.set(i, j, 0)); - g = gdata.getFloat(index.set(i, j, 1)); - b = gdata.getFloat(index.set(i, j, 2)); - a = gdata.getFloat(index.set(i, j, 3)); - if (Double.isNaN(r) || Double.isNaN(g) || Double.isNaN(b) || Double.isNaN(a)) { - color = undefColor; - } else { - color = new Color(r, g, b, a); - } - aImage.setRGB(j, height - i - 1, color.getRGB()); - } - } - } else { - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - r = gdata.getFloat(index.set(i, j, 0)); - g = gdata.getFloat(index.set(i, j, 1)); - b = gdata.getFloat(index.set(i, j, 2)); - if (Double.isNaN(r) || Double.isNaN(g) || Double.isNaN(b)) { - color = undefColor; - } else { - color = new Color(r, g, b); - } - aImage.setRGB(j, height - i - 1, color.getRGB()); - } - } - } - } else { - int r, g, b; - if (isAlpha) { - int a; - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - r = gdata.getInt(index.set(i, j, 0)); - g = gdata.getInt(index.set(i, j, 1)); - b = gdata.getInt(index.set(i, j, 2)); - a = gdata.getInt(index.set(i, j, 3)); - if (Double.isNaN(r) || Double.isNaN(g) || Double.isNaN(b) || Double.isNaN(a)) { - color = undefColor; - } else { - color = new Color(r, g, b, a); - } - aImage.setRGB(j, height - i - 1, color.getRGB()); - } - } - } else { - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - r = gdata.getInt(index.set(i, j, 0)); - g = gdata.getInt(index.set(i, j, 1)); - b = gdata.getInt(index.set(i, j, 2)); - if (Double.isNaN(r) || Double.isNaN(g) || Double.isNaN(b)) { - color = undefColor; - } else { - color = new Color(r, g, b); - } - aImage.setRGB(j, height - i - 1, color.getRGB()); - } - } - } - } - - ImageShape ishape = new ImageShape(); - double minx, maxx, miny, maxy; - if (extent == null) { - minx = 0; - maxx = width; - miny = 0; - maxy = height; - } else { - minx = extent.get(0).doubleValue(); - maxx = extent.get(1).doubleValue(); - miny = extent.get(2).doubleValue(); - maxy = extent.get(3).doubleValue(); - } - ishape.setPoint(new PointD(minx, miny)); - ishape.setImage(aImage); - ishape.setExtent(new Extent(minx, maxx, miny, maxy)); - return new Graphic(ishape, new ColorBreak()); - } - - /** - * Create image by RGB data array - * - * @param data RGB data array list - * @param extent Exent - * @return Image graphic - */ - public static Graphic createImage(List data, List extent) { - int width, height; - width = data.get(0).getShape()[1]; - height = data.get(0).getShape()[0]; - Color undefColor = Color.white; - BufferedImage aImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - Color color; - boolean isAlpha = data.size() == 4; - Array rdata = data.get(0); - Array gdata = data.get(1); - Array bdata = data.get(2); - Index rindex = rdata.getIndex(); - Index gindex = gdata.getIndex(); - Index bindex = bdata.getIndex(); - if (rdata.getDataType() == DataType.FLOAT || rdata.getDataType() == DataType.DOUBLE) { - float r, g, b; - if (isAlpha) { - float a; - Array adata = data.get(3); - Index aindex = adata.getIndex(); - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - r = rdata.getFloat(rindex.set(i, j)); - g = gdata.getFloat(gindex.set(i, j)); - b = bdata.getFloat(bindex.set(i, j)); - a = adata.getFloat(aindex.set(i, j)); - if (Double.isNaN(r) || Double.isNaN(g) || Double.isNaN(b) || Double.isNaN(a)) { - color = undefColor; - } else { - color = new Color(r, g, b, a); - } - aImage.setRGB(j, height - i - 1, color.getRGB()); - } - } - } else { - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - r = rdata.getFloat(rindex.set(i, j)); - g = gdata.getFloat(gindex.set(i, j)); - b = bdata.getFloat(bindex.set(i, j)); - if (Double.isNaN(r) || Double.isNaN(g) || Double.isNaN(b)) { - color = undefColor; - } else { - color = new Color(r, g, b); - } - aImage.setRGB(j, height - i - 1, color.getRGB()); - } - } - } - } else { - int r, g, b; - if (isAlpha) { - int a; - Array adata = data.get(3); - Index aindex = adata.getIndex(); - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - r = rdata.getInt(rindex.set(i, j)); - g = gdata.getInt(gindex.set(i, j)); - b = bdata.getInt(bindex.set(i, j)); - a = adata.getInt(aindex.set(i, j)); - if (Double.isNaN(r) || Double.isNaN(g) || Double.isNaN(b) || Double.isNaN(a)) { - color = undefColor; - } else { - color = new Color(r, g, b, a); - } - aImage.setRGB(j, height - i - 1, color.getRGB()); - } - } - } else { - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - r = rdata.getInt(rindex.set(i, j)); - g = gdata.getInt(gindex.set(i, j)); - b = bdata.getInt(bindex.set(i, j)); - if (Double.isNaN(r) || Double.isNaN(g) || Double.isNaN(b)) { - color = undefColor; - } else { - color = new Color(r, g, b); - } - aImage.setRGB(j, height - i - 1, color.getRGB()); - } - } - } - } - - ImageShape ishape = new ImageShape(); - double minx, maxx, miny, maxy; - if (extent == null) { - minx = 0; - maxx = width; - miny = 0; - maxy = height; - } else { - minx = extent.get(0).doubleValue(); - maxx = extent.get(1).doubleValue(); - miny = extent.get(2).doubleValue(); - maxy = extent.get(3).doubleValue(); - } - ishape.setPoint(new PointD(minx, miny)); - ishape.setImage(aImage); - ishape.setExtent(new Extent(minx, maxx, miny, maxy)); - return new Graphic(ishape, new ColorBreak()); - } - - /** - * Create image by RGB data array - * - * @param x X data array - * @param y Y data array - * @param data RGB data array list - * @param offset Offset in z axis - * @param zdir Z direction - x, y or z - * @param interpolation Interpolation - * @return Graphics - */ - public static GraphicCollection createImage(Array x, Array y, List data, double offset, - String zdir, String interpolation) { - Graphic gg = createImage(data, null); - if (interpolation != null) { - ((ImageShape) gg.getShape()).setInterpolation(interpolation); - } - ImageShape shape = (ImageShape)gg.getShape(); - Extent extent = shape.getExtent(); - Extent3D ex3 = new Extent3D(); - List coords = new ArrayList<>(); - switch (zdir.toLowerCase()) { - case "x": - ex3 = new Extent3D(offset, offset, extent.minX, extent.maxX, extent.minY, extent.maxY); - coords.add(new PointZ(offset, extent.minX, extent.minY)); - coords.add(new PointZ(offset, extent.maxX, extent.minY)); - coords.add(new PointZ(offset, extent.maxX, extent.maxY)); - coords.add(new PointZ(offset, extent.minX, extent.maxY)); - break; - case "y": - ex3 = new Extent3D(extent.minX, extent.maxX, offset, offset, extent.minY, extent.maxY); - coords.add(new PointZ(extent.minX, offset, extent.minY)); - coords.add(new PointZ(extent.maxX, offset, extent.minY)); - coords.add(new PointZ(extent.maxX, offset, extent.maxY)); - coords.add(new PointZ(extent.minX, offset, extent.maxY)); - break; - case "z": - ex3 = new Extent3D(extent.minX, extent.maxX, extent.minY, extent.maxY, offset, offset); - coords.add(new PointZ(extent.minX, extent.minY, offset)); - coords.add(new PointZ(extent.maxX, extent.minY, offset)); - coords.add(new PointZ(extent.maxX, extent.maxY, offset)); - coords.add(new PointZ(extent.minX, extent.maxY, offset)); - break; - } - shape.setExtent(ex3); - shape.setCoords(coords); - GraphicCollection3D graphics = new GraphicCollection3D(); - graphics.setFixZ(true); - graphics.setZDir(zdir); - graphics.setZValue(offset); - graphics.add(gg); - return graphics; - } - - /** - * Create image - * - * @param gdata Grid data array - * @param ls Legend scheme - * @param extent Extent - * @return Image graphic - */ - public static Graphic createImage(Array gdata, LegendScheme ls, List extent) { - int width, height, breakNum; - width = gdata.getShape()[1]; - height = gdata.getShape()[0]; - breakNum = ls.getBreakNum(); - double[] breakValue = new double[breakNum]; - Color[] breakColor = new Color[breakNum]; - Color undefColor = Color.white; - for (int i = 0; i < breakNum; i++) { - breakValue[i] = Double.parseDouble(ls.getLegendBreaks().get(i).getEndValue().toString()); - breakColor[i] = ls.getLegendBreaks().get(i).getColor(); - if (ls.getLegendBreaks().get(i).isNoData()) { - undefColor = ls.getLegendBreaks().get(i).getColor(); - } - } - Color defaultColor = breakColor[breakNum - 1]; //Last color - BufferedImage aImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - double oneValue; - Color oneColor; - Index index = gdata.getIndex(); - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - index.set(i, j); - oneValue = gdata.getDouble(index); - if (Double.isNaN(oneValue)) { - oneColor = undefColor; - } else { - oneColor = defaultColor; - if (ls.getLegendType() == LegendType.GraduatedColor) { - for (int k = 0; k < breakNum - 1; k++) { - if (oneValue < breakValue[k]) { - oneColor = breakColor[k]; - break; - } - } - } else { - for (int k = 0; k < breakNum - 1; k++) { - if (oneValue == breakValue[k]) { - oneColor = breakColor[k]; - break; - } - } - } - } - aImage.setRGB(j, height - i - 1, oneColor.getRGB()); - } - } - - ImageShape ishape = new ImageShape(); - double minx, maxx, miny, maxy; - if (extent == null) { - minx = 0; - maxx = width; - miny = 0; - maxy = height; - } else { - minx = extent.get(0).doubleValue(); - maxx = extent.get(1).doubleValue(); - miny = extent.get(2).doubleValue(); - maxy = extent.get(3).doubleValue(); - } - ishape.setPoint(new PointD(minx, miny)); - ishape.setImage(aImage); - ishape.setExtent(new Extent(minx, maxx, miny, maxy)); - return new Graphic(ishape, new ColorBreak()); - } - - /** - * Create image - * - * @param gdata Grid data array - * @param ls Legend scheme - * @return Image graphic - */ - public static Graphic createImage(GridArray gdata, LegendScheme ls) { - int width, height, breakNum; - width = gdata.getXNum(); - height = gdata.getYNum(); - breakNum = ls.getBreakNum(); - double[] breakValue = new double[breakNum]; - Color[] breakColor = new Color[breakNum]; - Color undefColor = Color.white; - for (int i = 0; i < breakNum; i++) { - breakValue[i] = Double.parseDouble(ls.getLegendBreaks().get(i).getEndValue().toString()); - breakColor[i] = ls.getLegendBreaks().get(i).getColor(); - if (ls.getLegendBreaks().get(i).isNoData()) { - undefColor = ls.getLegendBreaks().get(i).getColor(); - } - } - Color defaultColor = breakColor[breakNum - 1]; //Last color - BufferedImage aImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - double oneValue; - Color oneColor; - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - oneValue = gdata.getDoubleValue(i, j); - if (Double.isNaN(oneValue) || MIMath.doubleEquals(oneValue, gdata.missingValue)) { - oneColor = undefColor; - } else { - oneColor = defaultColor; - if (ls.getLegendType() == LegendType.GraduatedColor) { - for (int k = 0; k < breakNum - 1; k++) { - if (oneValue < breakValue[k]) { - oneColor = breakColor[k]; - break; - } - } - } else { - for (int k = 0; k < breakNum - 1; k++) { - if (oneValue == breakValue[k]) { - oneColor = breakColor[k]; - break; - } - } - } - } - aImage.setRGB(j, height - i - 1, oneColor.getRGB()); - } - } - - ImageShape ishape = new ImageShape(); - double xdelta = BigDecimalUtil.mul(gdata.getXDelt(), 0.5); - double xmin = BigDecimalUtil.sub(gdata.xArray[0], xdelta); - double xmax = BigDecimalUtil.add(gdata.getXMax(), xdelta); - double ydelta = BigDecimalUtil.mul(gdata.getYDelt(), 0.5); - double ymin = BigDecimalUtil.sub(gdata.yArray[0], ydelta); - double ymax = BigDecimalUtil.add(gdata.getYMax(), ydelta); - ishape.setPoint(new PointD(xmin, ymin)); - ishape.setImage(aImage); - ishape.setExtent(new Extent(xmin, xmax, ymin, ymax)); - return new ImageGraphic(ishape, ls); - } - - /** - * Create image - * - * @param gdata Grid data array - * @param ls Legend scheme - * @param extent Extent - * @return Image graphic - */ - public static Graphic createImage(GridArray gdata, LegendScheme ls, List extent) { - int width, height, breakNum; - width = gdata.getXNum(); - height = gdata.getYNum(); - breakNum = ls.getBreakNum(); - double[] breakValue = new double[breakNum]; - Color[] breakColor = new Color[breakNum]; - Color undefColor = Color.white; - for (int i = 0; i < breakNum; i++) { - breakValue[i] = Double.parseDouble(ls.getLegendBreaks().get(i).getEndValue().toString()); - breakColor[i] = ls.getLegendBreaks().get(i).getColor(); - if (ls.getLegendBreaks().get(i).isNoData()) { - undefColor = ls.getLegendBreaks().get(i).getColor(); - } - } - Color defaultColor = breakColor[breakNum - 1]; //Last color - BufferedImage aImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - double oneValue; - Color oneColor; - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - oneValue = gdata.getDoubleValue(i, j); - if (Double.isNaN(oneValue) || MIMath.doubleEquals(oneValue, gdata.missingValue)) { - oneColor = undefColor; - } else { - oneColor = defaultColor; - if (ls.getLegendType() == LegendType.GraduatedColor) { - for (int k = 0; k < breakNum - 1; k++) { - if (oneValue < breakValue[k]) { - oneColor = breakColor[k]; - break; - } - } - } else { - for (int k = 0; k < breakNum - 1; k++) { - if (oneValue == breakValue[k]) { - oneColor = breakColor[k]; - break; - } - } - } - } - aImage.setRGB(j, height - i - 1, oneColor.getRGB()); - } - } - - ImageShape ishape = new ImageShape(); - double xmin, xmax, ymin, ymax; - if (extent == null) { - double xdelta = BigDecimalUtil.mul(gdata.getXDelt(), 0.5); - xmin = BigDecimalUtil.sub(gdata.xArray[0], xdelta); - xmax = BigDecimalUtil.add(gdata.getXMax(), xdelta); - double ydelta = BigDecimalUtil.mul(gdata.getYDelt(), 0.5); - ymin = BigDecimalUtil.sub(gdata.yArray[0], ydelta); - ymax = BigDecimalUtil.add(gdata.getYMax(), ydelta); - } else { - xmin = extent.get(0).doubleValue(); - xmax = extent.get(1).doubleValue(); - ymin = extent.get(2).doubleValue(); - ymax = extent.get(3).doubleValue(); - } - ishape.setPoint(new PointD(xmin, ymin)); - ishape.setImage(aImage); - ishape.setExtent(new Extent(xmin, xmax, ymin, ymax)); - return new ImageGraphic(ishape, ls); - } - - /** - * Create image - * - * @param gdata Grid data array - * @param ls Legend scheme - * @param offset Offset of z axis - * @param zdir Z direction - x, y or z - * @param sePoint Start and end points [xstart, ystart, xend, yend] - * @param interpolation Interpolation - * @return Graphics - */ - public static GraphicCollection createImage(GridArray gdata, LegendScheme ls, double offset, - String zdir, List sePoint, String interpolation) { - Graphic gg = createImage(gdata, ls); - if (interpolation != null) { - ((ImageShape) gg.getShape()).setInterpolation(interpolation); - } - ImageShape shape = (ImageShape) gg.getShape(); - Extent extent = shape.getExtent(); - Extent3D ex3 = new Extent3D(); - List coords = new ArrayList<>(); - switch (zdir.toLowerCase()) { - case "x": - ex3 = new Extent3D(offset, offset, extent.minX, extent.maxX, extent.minY, extent.maxY); - coords.add(new PointZ(offset, extent.minX, extent.minY)); - coords.add(new PointZ(offset, extent.maxX, extent.minY)); - coords.add(new PointZ(offset, extent.maxX, extent.maxY)); - coords.add(new PointZ(offset, extent.minX, extent.maxY)); - break; - case "y": - ex3 = new Extent3D(extent.minX, extent.maxX, offset, offset, extent.minY, extent.maxY); - coords.add(new PointZ(extent.minX, offset, extent.minY)); - coords.add(new PointZ(extent.maxX, offset, extent.minY)); - coords.add(new PointZ(extent.maxX, offset, extent.maxY)); - coords.add(new PointZ(extent.minX, offset, extent.maxY)); - break; - case "xy": - ex3 = new Extent3D(sePoint.get(0).doubleValue(), sePoint.get(2).doubleValue(), - sePoint.get(1).doubleValue(), sePoint.get(3).doubleValue(), extent.minY, extent.maxY); - coords.add(new PointZ(sePoint.get(0).doubleValue(), sePoint.get(1).doubleValue(), extent.minY)); - coords.add(new PointZ(sePoint.get(2).doubleValue(), sePoint.get(1).doubleValue(), extent.minY)); - coords.add(new PointZ(sePoint.get(2).doubleValue(), sePoint.get(3).doubleValue(), extent.maxY)); - coords.add(new PointZ(sePoint.get(0).doubleValue(), sePoint.get(3).doubleValue(), extent.maxY)); - break; - case "z": - ex3 = new Extent3D(extent.minX, extent.maxX, extent.minY, extent.maxY, offset, offset); - coords.add(new PointZ(extent.minX, extent.minY, offset)); - coords.add(new PointZ(extent.maxX, extent.minY, offset)); - coords.add(new PointZ(extent.maxX, extent.maxY, offset)); - coords.add(new PointZ(extent.minX, extent.maxY, offset)); - break; - } - shape.setExtent(ex3); - shape.setCoords(coords); - GraphicCollection3D graphics = new GraphicCollection3D(); - graphics.setFixZ(true); - graphics.setZDir(zdir); - graphics.setZValue(offset); - graphics.setSEPoint(sePoint); - graphics.add(gg); - graphics.setLegendScheme(ls); - graphics.setSingleLegend(false); - return graphics; - } - - /** - * Create image - * - * @param layer Image layer - * @param offset Offset of z axis - * @param xshift X shift - to shift the grahpics in x direction, normally - * for map in 180 - 360 degree east - * @param interpolation Interpolation - * @return Graphics - */ - public static GraphicCollection createImage(ImageLayer layer, double offset, double xshift, - String interpolation) { - GraphicCollection3D graphics = new GraphicCollection3D(); - graphics.setFixZ(true); - graphics.setZDir("z"); - graphics.setZValue(offset); - ImageShape ishape = new ImageShape(); - ishape.setImage(layer.getImage()); - Extent extent = layer.getExtent(); - Extent3D ex3 = new Extent3D(extent.minX + xshift, extent.maxX + xshift, extent.minY, extent.maxY, offset, offset); - List coords = new ArrayList<>(); - coords.add(new PointZ(extent.minX + xshift, extent.minY, offset)); - coords.add(new PointZ(extent.maxX + xshift, extent.minY, offset)); - coords.add(new PointZ(extent.maxX + xshift, extent.maxY, offset)); - coords.add(new PointZ(extent.minX + xshift, extent.maxY, offset)); - ishape.setExtent(ex3); - ishape.setCoords(coords); - Graphic gg = new Graphic(ishape, new ColorBreak()); - if (interpolation != null) { - ((ImageShape) gg.getShape()).setInterpolation(interpolation); - } - graphics.add(gg); - - return graphics; - } - - /** - * Create contour lines - * - * @param gridData Grid data - * @param ls Legend scheme - * @param isSmooth Is smooth or not - * @return Contour lines - */ - public static GraphicCollection createContourLines(GridData gridData, LegendScheme ls, boolean isSmooth) { - ls = ls.convertTo(ShapeTypes.Polyline); - Object[] ccs = LegendManage.getContoursAndColors(ls); - double[] cValues = (double[]) ccs[0]; - - int[][] S1 = new int[gridData.data.length][gridData.data[0].length]; - double[] x = gridData.xArray; - double[] y = gridData.yArray; - if (gridData.getXDelt() < 0) - ArrayUtils.reverse(x); - if (gridData.getYDelt() < 0) - ArrayUtils.reverse(y); - Object[] cbs = ContourDraw.tracingContourLines(gridData.data, - cValues, x, y, gridData.missingValue, S1); - List ContourLines = (List) cbs[0]; - - if (ContourLines.isEmpty()) { - return null; - } - - if (isSmooth) { - ContourLines = wcontour.Contour.smoothLines(ContourLines); - } - - wcontour.global.PolyLine aLine; - double v; - ColorBreak cbb = ls.findLegendBreak(0); - GraphicCollection graphics = new GraphicCollection(); - for (int i = 0; i < ContourLines.size(); i++) { - aLine = ContourLines.get(i); - v = aLine.Value; - - PolylineShape aPolyline = new PolylineShape(); - PointD aPoint; - List pList = new ArrayList<>(); - for (int j = 0; j < aLine.PointList.size(); j++) { - aPoint = new PointD(); - aPoint.X = aLine.PointList.get(j).X; - aPoint.Y = aLine.PointList.get(j).Y; - pList.add(aPoint); - } - aPolyline.setPoints(pList); - aPolyline.setValue(v); - aPolyline.setExtent(GeometryUtil.getPointsExtent(pList)); - - switch (ls.getLegendType()) { - case UniqueValue: - for (int j = 0; j < ls.getBreakNum(); j++) { - ColorBreak cb = ls.getLegendBreaks().get(j); - if (MIMath.doubleEquals(v, Double.parseDouble(cb.getStartValue().toString()))) { - cbb = cb; - break; - } - } - break; - case GraduatedColor: - int blNum = 0; - for (int j = 0; j < ls.getBreakNum(); j++) { - ColorBreak cb = ls.getLegendBreaks().get(j); - blNum += 1; - if (MIMath.doubleEquals(v, Double.parseDouble(cb.getStartValue().toString())) - || (v > Double.parseDouble(cb.getStartValue().toString()) - && v < Double.parseDouble(cb.getEndValue().toString())) - || (blNum == ls.getBreakNum() && v == Double.parseDouble(cb.getEndValue().toString()))) { - cbb = cb; - break; - } - } - break; - } - graphics.add(new Graphic(aPolyline, cbb)); - } - graphics.setSingleLegend(false); - graphics.setLegendScheme(ls); - - return graphics; - } - - /** - * Create contour lines - * - * @param gridData Grid data - * @param offset Offset in z direction - * @param zdir Z direction - x, y or z - * @param ls Legend scheme - * @param isSmooth Is smooth or not - * @return Contour lines - */ - public static GraphicCollection createContourLines(GridData gridData, double offset, - String zdir, LegendScheme ls, boolean isSmooth) { - ls = ls.convertTo(ShapeTypes.Polyline); - Object[] ccs = LegendManage.getContoursAndColors(ls); - double[] cValues = (double[]) ccs[0]; - - int[][] S1 = new int[gridData.data.length][gridData.data[0].length]; - double[] x = gridData.xArray; - double[] y = gridData.yArray; - if (gridData.getXDelt() < 0) - ArrayUtils.reverse(x); - if (gridData.getYDelt() < 0) - ArrayUtils.reverse(y); - Object[] cbs = ContourDraw.tracingContourLines(gridData.data, - cValues, x, y, gridData.missingValue, S1); - List ContourLines = (List) cbs[0]; - - if (ContourLines.isEmpty()) { - return null; - } - - if (isSmooth) { - ContourLines = wcontour.Contour.smoothLines(ContourLines); - } - - wcontour.global.PolyLine aLine; - double v; - ColorBreak cbb; - GraphicCollection3D graphics = new GraphicCollection3D(); - graphics.setFixZ(true); - graphics.setZValue(offset); - zdir = zdir.toLowerCase(); - graphics.setZDir(zdir); - for (int i = 0; i < ContourLines.size(); i++) { - aLine = ContourLines.get(i); - v = aLine.Value; - - PolylineZShape aPolyline = new PolylineZShape(); - PointZ aPoint; - List pList = new ArrayList<>(); - switch (zdir) { - case "x": - for (int j = 0; j < aLine.PointList.size(); j++) { - aPoint = new PointZ(); - aPoint.X = offset; - aPoint.Y = aLine.PointList.get(j).X; - aPoint.Z = aLine.PointList.get(j).Y; - pList.add(aPoint); - } - break; - case "y": - for (int j = 0; j < aLine.PointList.size(); j++) { - aPoint = new PointZ(); - aPoint.Y = offset; - aPoint.X = aLine.PointList.get(j).X; - aPoint.Z = aLine.PointList.get(j).Y; - pList.add(aPoint); - } - break; - case "z": - for (int j = 0; j < aLine.PointList.size(); j++) { - aPoint = new PointZ(); - aPoint.X = aLine.PointList.get(j).X; - aPoint.Y = aLine.PointList.get(j).Y; - aPoint.Z = offset; - pList.add(aPoint); - } - break; - } - aPolyline.setPoints(pList); - aPolyline.setValue(v); - aPolyline.setExtent(GeometryUtil.getPointsExtent(pList)); - cbb = ls.findLegendBreak(v); - graphics.add(new Graphic(aPolyline, cbb)); - } - graphics.setSingleLegend(false); - graphics.setLegendScheme(ls); - - return graphics; - } - - /** - * Create contour lines - * - * @param gridData Grid data - * @param offset Offset in z direction - * @param zdir Z direction - x, y or z - * @param ls Legend scheme - * @param isSmooth Is smooth or not - * @param sePoint Start and end points [xstart, ystart, xend, yend] - * @return Contour lines - */ - public static GraphicCollection createContourLines(GridData gridData, double offset, - String zdir, LegendScheme ls, boolean isSmooth, List sePoint) { - ls = ls.convertTo(ShapeTypes.Polyline); - Object[] ccs = LegendManage.getContoursAndColors(ls); - double[] cValues = (double[]) ccs[0]; - - int[][] S1 = new int[gridData.data.length][gridData.data[0].length]; - double[] xArray = gridData.xArray; - double[] yArray = gridData.yArray; - if (gridData.getXDelt() < 0) - ArrayUtils.reverse(xArray); - if (gridData.getYDelt() < 0) - ArrayUtils.reverse(yArray); - Object[] cbs = ContourDraw.tracingContourLines(gridData.data, - cValues, xArray, yArray, gridData.missingValue, S1); - List ContourLines = (List) cbs[0]; - - if (ContourLines.isEmpty()) { - return null; - } - - if (isSmooth) { - ContourLines = wcontour.Contour.smoothLines(ContourLines); - } - - wcontour.global.PolyLine aLine; - double v; - ColorBreak cbb; - GraphicCollection3D graphics = new GraphicCollection3D(); - graphics.setFixZ(true); - graphics.setZValue(offset); - graphics.setSEPoint(sePoint); - zdir = zdir.toLowerCase(); - graphics.setZDir(zdir); - double x, y, xs, xe, ys, ye; - xs = sePoint.get(0).doubleValue(); - ys = sePoint.get(1).doubleValue(); - xe = sePoint.get(2).doubleValue(); - ye = sePoint.get(3).doubleValue(); - for (int i = 0; i < ContourLines.size(); i++) { - aLine = ContourLines.get(i); - v = aLine.Value; - - PolylineZShape aPolyline = new PolylineZShape(); - PointZ aPoint; - List pList = new ArrayList<>(); - switch (zdir) { - case "x": - for (int j = 0; j < aLine.PointList.size(); j++) { - aPoint = new PointZ(); - aPoint.X = offset; - aPoint.Y = aLine.PointList.get(j).X; - aPoint.Z = aLine.PointList.get(j).Y; - pList.add(aPoint); - } - break; - case "y": - for (int j = 0; j < aLine.PointList.size(); j++) { - aPoint = new PointZ(); - aPoint.Y = offset; - aPoint.X = aLine.PointList.get(j).X; - aPoint.Z = aLine.PointList.get(j).Y; - pList.add(aPoint); - } - break; - case "xy": - for (int j = 0; j < aLine.PointList.size(); j++) { - x = aLine.PointList.get(j).X; - y = aLine.PointList.get(j).Y; - aPoint = new PointZ(); - aPoint.X = x; - aPoint.Y = ys + (ye - ys) * (x - xs) / (xe - xs); - aPoint.Z = y; - pList.add(aPoint); - } - break; - case "z": - for (int j = 0; j < aLine.PointList.size(); j++) { - aPoint = new PointZ(); - aPoint.X = aLine.PointList.get(j).X; - aPoint.Y = aLine.PointList.get(j).Y; - aPoint.Z = offset; - pList.add(aPoint); - } - break; - } - aPolyline.setPoints(pList); - aPolyline.setValue(v); - aPolyline.setExtent(GeometryUtil.getPointsExtent(pList)); - cbb = ls.findLegendBreak(v); - graphics.add(new Graphic(aPolyline, cbb)); - } - graphics.setSingleLegend(false); - graphics.setLegendScheme(ls); - - return graphics; - } - - /** - * Create contour polygons - * - * @param gridData Grid data - * @param ls Legend scheme - * @param isSmooth Is smooth or not - * @return Contour polygons - */ - public static GraphicCollection createContourPolygons(GridData gridData, LegendScheme ls, boolean isSmooth) { - ls = ls.convertTo(ShapeTypes.Polygon); - Object[] ccs = LegendManage.getContoursAndColors(ls); - double[] cValues = (double[]) ccs[0]; - - double minData; - double maxData; - double[] maxmin = new double[2]; - gridData.getMaxMinValue(maxmin); - maxData = maxmin[0]; - minData = maxmin[1]; - - int[][] S1 = new int[gridData.data.length][gridData.data[0].length]; - double[] xArray = gridData.xArray; - double[] yArray = gridData.yArray; - if (gridData.getXDelt() < 0) - ArrayUtils.reverse(xArray); - if (gridData.getYDelt() < 0) - ArrayUtils.reverse(yArray); - Object[] cbs = ContourDraw.tracingContourLines(gridData.data, - cValues, xArray, yArray, gridData.missingValue, S1); - List contourLines = (List) cbs[0]; - List borders = (List) cbs[1]; - - if (isSmooth) { - contourLines = wcontour.Contour.smoothLines(contourLines); - } - List contourPolygons = ContourDraw.tracingPolygons(gridData.data, contourLines, borders, cValues); - - double v; - ColorBreak cbb = ls.findLegendBreak(0); - GraphicCollection graphics = new GraphicCollection(); - for (int i = 0; i < contourPolygons.size(); i++) { - wcontour.global.Polygon poly = contourPolygons.get(i); - v = poly.LowValue; - PointD aPoint; - List pList = new ArrayList<>(); - for (wcontour.global.PointD pointList : poly.OutLine.PointList) { - aPoint = new PointD(); - aPoint.X = pointList.X; - aPoint.Y = pointList.Y; - pList.add(aPoint); - } - if (!GeoComputation.isClockwise(pList)) { - Collections.reverse(pList); - } - PolygonShape aPolygonShape = new PolygonShape(); - aPolygonShape.setPoints(pList); - aPolygonShape.setExtent(GeometryUtil.getPointsExtent(pList)); - aPolygonShape.lowValue = v; - if (poly.HasHoles()) { - for (PolyLine holeLine : poly.HoleLines) { - pList = new ArrayList<>(); - for (wcontour.global.PointD pointList : holeLine.PointList) { - aPoint = new PointD(); - aPoint.X = pointList.X; - aPoint.Y = pointList.Y; - pList.add(aPoint); - } - aPolygonShape.addHole(pList, 0); - } - } - int valueIdx = Arrays.binarySearch(cValues, v); - if (valueIdx < 0) { - valueIdx = -valueIdx; - } - //int valueIdx = findIndex(cValues, v); - if (valueIdx == cValues.length - 1) { - aPolygonShape.highValue = maxData; - } else { - aPolygonShape.highValue = cValues[valueIdx + 1]; - } -// if (!aPolygon.IsBorder) { -// if (!aPolygon.IsHighCenter) { -// aPolygonShape.highValue = aValue; -// if (valueIdx == 0) { -// aPolygonShape.lowValue = minData; -// } else { -// aPolygonShape.lowValue = cValues[valueIdx - 1]; -// } -// } -// } - if (!poly.IsHighCenter && poly.HighValue == poly.LowValue) { - aPolygonShape.highValue = v; - if (valueIdx == 0) { - aPolygonShape.lowValue = minData; - } else { - aPolygonShape.lowValue = cValues[valueIdx - 1]; - } - } - - v = aPolygonShape.lowValue; - switch (ls.getLegendType()) { - case UniqueValue: - for (int j = 0; j < ls.getBreakNum(); j++) { - ColorBreak cb = ls.getLegendBreaks().get(j); - if (MIMath.doubleEquals(v, Double.parseDouble(cb.getStartValue().toString()))) { - cbb = cb; - break; - } - } - break; - case GraduatedColor: - int blNum = 0; - for (int j = 0; j < ls.getBreakNum(); j++) { - ColorBreak cb = ls.getLegendBreaks().get(j); - blNum += 1; - if (MIMath.doubleEquals(v, Double.parseDouble(cb.getStartValue().toString())) - || (v > Double.parseDouble(cb.getStartValue().toString()) - && v < Double.parseDouble(cb.getEndValue().toString())) - || (blNum == ls.getBreakNum() && v == Double.parseDouble(cb.getEndValue().toString()))) { - cbb = cb; - break; - } - } - break; - } - graphics.add(new Graphic(aPolygonShape, cbb)); - } - graphics.setSingleLegend(false); - graphics.setLegendScheme(ls); - - return graphics; - } - - /** - * Create 3D contour polygons - * - * @param gridData Grid data - * @param offset Offset of z axis - * @param zdir Z direction - x, y or z - * @param ls Legend scheme - * @param isSmooth Is smooth or not - * @return Contour polygons - */ - public static GraphicCollection createContourPolygons(GridData gridData, double offset, - String zdir, LegendScheme ls, boolean isSmooth) { - ls = ls.convertTo(ShapeTypes.Polygon); - Object[] ccs = LegendManage.getContoursAndColors(ls); - double[] cValues = (double[]) ccs[0]; - - double minData; - double maxData; - double[] maxmin = new double[2]; - gridData.getMaxMinValue(maxmin); - maxData = maxmin[0]; - minData = maxmin[1]; - - int[][] S1 = new int[gridData.data.length][gridData.data[0].length]; - double[] xArray = gridData.xArray; - double[] yArray = gridData.yArray; - if (gridData.getXDelt() < 0) - ArrayUtils.reverse(xArray); - if (gridData.getYDelt() < 0) - ArrayUtils.reverse(yArray); - Object[] cbs = ContourDraw.tracingContourLines(gridData.data, - cValues, xArray, yArray, gridData.missingValue, S1); - List contourLines = (List) cbs[0]; - List borders = (List) cbs[1]; - - if (isSmooth) { - contourLines = wcontour.Contour.smoothLines(contourLines); - } - List contourPolygons = ContourDraw.tracingPolygons(gridData.data, contourLines, borders, cValues); - - double v; - ColorBreak cbb; - GraphicCollection3D graphics = new GraphicCollection3D(); - graphics.setFixZ(true); - graphics.setZValue(offset); - zdir = zdir.toLowerCase(); - graphics.setZDir(zdir); - for (int i = 0; i < contourPolygons.size(); i++) { - wcontour.global.Polygon poly = contourPolygons.get(i); - v = poly.LowValue; - PointZ aPoint; - List pList = new ArrayList<>(); - switch (zdir) { - case "x": - for (wcontour.global.PointD pointList : poly.OutLine.PointList) { - aPoint = new PointZ(); - aPoint.Y = pointList.X; - aPoint.Z = pointList.Y; - aPoint.X = offset; - pList.add(aPoint); - } - break; - case "y": - for (wcontour.global.PointD pointList : poly.OutLine.PointList) { - aPoint = new PointZ(); - aPoint.X = pointList.X; - aPoint.Z = pointList.Y; - aPoint.Y = offset; - pList.add(aPoint); - } - break; - case "z": - for (wcontour.global.PointD pointList : poly.OutLine.PointList) { - aPoint = new PointZ(); - aPoint.X = pointList.X; - aPoint.Y = pointList.Y; - aPoint.Z = offset; - pList.add(aPoint); - } - break; - } - - if (!GeoComputation.isClockwise(pList)) { - Collections.reverse(pList); - } - PolygonZShape aPolygonShape = new PolygonZShape(); - aPolygonShape.setPoints(pList); - aPolygonShape.setExtent(GeometryUtil.getPointsExtent(pList)); - aPolygonShape.lowValue = v; - if (poly.HasHoles()) { - switch (zdir) { - case "x": - for (PolyLine holeLine : poly.HoleLines) { - pList = new ArrayList<>(); - for (wcontour.global.PointD pointList : holeLine.PointList) { - aPoint = new PointZ(); - aPoint.Y = pointList.X; - aPoint.Z = pointList.Y; - aPoint.X = offset; - pList.add(aPoint); - } - aPolygonShape.addHole(pList, 0); - } - break; - case "y": - for (PolyLine holeLine : poly.HoleLines) { - pList = new ArrayList<>(); - for (wcontour.global.PointD pointList : holeLine.PointList) { - aPoint = new PointZ(); - aPoint.X = pointList.X; - aPoint.Z = pointList.Y; - aPoint.Y = offset; - pList.add(aPoint); - } - aPolygonShape.addHole(pList, 0); - } - break; - case "z": - for (PolyLine holeLine : poly.HoleLines) { - pList = new ArrayList<>(); - for (wcontour.global.PointD pointList : holeLine.PointList) { - aPoint = new PointZ(); - aPoint.X = pointList.X; - aPoint.Y = pointList.Y; - aPoint.Z = offset; - pList.add(aPoint); - } - aPolygonShape.addHole(pList, 0); - } - break; - } - } - int valueIdx = Arrays.binarySearch(cValues, v); - if (valueIdx < 0) { - valueIdx = -valueIdx; - } - //int valueIdx = findIndex(cValues, v); - if (valueIdx == cValues.length - 1) { - aPolygonShape.highValue = maxData; - } else { - aPolygonShape.highValue = cValues[valueIdx + 1]; - } - if (!poly.IsHighCenter && poly.HighValue == poly.LowValue) { - aPolygonShape.highValue = v; - if (valueIdx == 0) { - aPolygonShape.lowValue = minData; - } else { - aPolygonShape.lowValue = cValues[valueIdx - 1]; - } - } - - v = aPolygonShape.lowValue; - cbb = ls.findLegendBreak(v); - graphics.add(new Graphic(aPolygonShape, cbb)); - } - graphics.setSingleLegend(false); - graphics.setLegendScheme(ls); - - return graphics; - } - - /** - * Create 3D contour polygons - * - * @param gridData Grid data - * @param offset Offset of z axis - * @param zdir Z direction - x, y or z - * @param ls Legend scheme - * @param isSmooth Is smooth or not - * @param sePoint Start and end points [xstart, ystart, xend, yend] - * @return Contour polygons - */ - public static GraphicCollection createContourPolygons(GridData gridData, double offset, - String zdir, LegendScheme ls, boolean isSmooth, List sePoint) { - ls = ls.convertTo(ShapeTypes.Polygon); - Object[] ccs = LegendManage.getContoursAndColors(ls); - double[] cValues = (double[]) ccs[0]; - - double minData; - double maxData; - double[] maxmin = new double[2]; - gridData.getMaxMinValue(maxmin); - maxData = maxmin[0]; - minData = maxmin[1]; - - int[][] S1 = new int[gridData.data.length][gridData.data[0].length]; - double[] xArray = gridData.xArray; - double[] yArray = gridData.yArray; - if (gridData.getXDelt() < 0) - ArrayUtils.reverse(xArray); - if (gridData.getYDelt() < 0) - ArrayUtils.reverse(yArray); - Object[] cbs = ContourDraw.tracingContourLines(gridData.data, - cValues, xArray, yArray, gridData.missingValue, S1); - List contourLines = (List) cbs[0]; - List borders = (List) cbs[1]; - - if (isSmooth) { - contourLines = wcontour.Contour.smoothLines(contourLines); - } - List contourPolygons = ContourDraw.tracingPolygons(gridData.data, contourLines, borders, cValues); - - double v; - ColorBreak cbb; - GraphicCollection3D graphics = new GraphicCollection3D(); - graphics.setFixZ(true); - graphics.setZValue(offset); - graphics.setSEPoint(sePoint); - zdir = zdir.toLowerCase(); - graphics.setZDir(zdir); - double x, y, xs, xe, ys, ye; - xs = sePoint.get(0).doubleValue(); - ys = sePoint.get(1).doubleValue(); - xe = sePoint.get(2).doubleValue(); - ye = sePoint.get(3).doubleValue(); - for (int i = 0; i < contourPolygons.size(); i++) { - wcontour.global.Polygon poly = contourPolygons.get(i); - v = poly.LowValue; - PointZ aPoint; - List pList = new ArrayList<>(); - switch (zdir) { - case "x": - for (wcontour.global.PointD pointList : poly.OutLine.PointList) { - aPoint = new PointZ(); - aPoint.Y = pointList.X; - aPoint.Z = pointList.Y; - aPoint.X = offset; - pList.add(aPoint); - } - break; - case "y": - for (wcontour.global.PointD pointList : poly.OutLine.PointList) { - aPoint = new PointZ(); - aPoint.X = pointList.X; - aPoint.Z = pointList.Y; - aPoint.Y = offset; - pList.add(aPoint); - } - break; - case "xy": - for (wcontour.global.PointD pointList : poly.OutLine.PointList) { - x = pointList.X; - y = pointList.Y; - aPoint = new PointZ(); - aPoint.X = x; - aPoint.Y = ys + (ye - ys) * (x - xs) / (xe - xs); - aPoint.Z = y; - pList.add(aPoint); - } - break; - case "z": - for (wcontour.global.PointD pointList : poly.OutLine.PointList) { - aPoint = new PointZ(); - aPoint.X = pointList.X; - aPoint.Y = pointList.Y; - aPoint.Z = offset; - pList.add(aPoint); - } - break; - } - - if (!GeoComputation.isClockwise(pList)) { - Collections.reverse(pList); - } - PolygonZShape aPolygonShape = new PolygonZShape(); - aPolygonShape.setPoints(pList); - aPolygonShape.setExtent(GeometryUtil.getPointsExtent(pList)); - aPolygonShape.lowValue = v; - if (poly.HasHoles()) { - switch (zdir) { - case "x": - for (PolyLine holeLine : poly.HoleLines) { - pList = new ArrayList<>(); - for (wcontour.global.PointD pointList : holeLine.PointList) { - aPoint = new PointZ(); - aPoint.Y = pointList.X; - aPoint.Z = pointList.Y; - aPoint.X = offset; - pList.add(aPoint); - } - aPolygonShape.addHole(pList, 0); - } - break; - case "y": - for (PolyLine holeLine : poly.HoleLines) { - pList = new ArrayList<>(); - for (wcontour.global.PointD pointList : holeLine.PointList) { - aPoint = new PointZ(); - aPoint.X = pointList.X; - aPoint.Z = pointList.Y; - aPoint.Y = offset; - pList.add(aPoint); - } - aPolygonShape.addHole(pList, 0); - } - break; - case "z": - for (PolyLine holeLine : poly.HoleLines) { - pList = new ArrayList<>(); - for (wcontour.global.PointD pointList : holeLine.PointList) { - aPoint = new PointZ(); - aPoint.X = pointList.X; - aPoint.Y = pointList.Y; - aPoint.Z = offset; - pList.add(aPoint); - } - aPolygonShape.addHole(pList, 0); - } - break; - } - } - int valueIdx = Arrays.binarySearch(cValues, v); - if (valueIdx < 0) { - valueIdx = -valueIdx; - } - //int valueIdx = findIndex(cValues, v); - if (valueIdx == cValues.length - 1) { - aPolygonShape.highValue = maxData; - } else { - aPolygonShape.highValue = cValues[valueIdx + 1]; - } - if (!poly.IsHighCenter && poly.HighValue == poly.LowValue) { - aPolygonShape.highValue = v; - if (valueIdx == 0) { - aPolygonShape.lowValue = minData; - } else { - aPolygonShape.lowValue = cValues[valueIdx - 1]; - } - } - - v = aPolygonShape.lowValue; - cbb = ls.findLegendBreak(v); - graphics.add(new Graphic(aPolygonShape, cbb)); - } - graphics.setSingleLegend(false); - graphics.setLegendScheme(ls); - - return graphics; - } - - /** - * Create pseudocolor polygons - * - * @param x_s scatter X array - 2D - * @param y_s scatter Y array - 2D - * @param a scatter value array - 2D - * @param ls Legend scheme - * @return Mesh polygon layer - */ - public static GraphicCollection createPColorPolygons(Array x_s, Array y_s, Array a, LegendScheme ls) { - GraphicCollection gc = new GraphicCollection(); - - int[] shape = x_s.getShape(); - int colNum = shape[1]; - int rowNum = shape[0]; - double x1, x2, x3, x4, v; - PolygonBreak pb; - if (!x_s.getIndexPrivate().isFastIterator()) - x_s = x_s.copy(); - if (!y_s.getIndexPrivate().isFastIterator()) - y_s = y_s.copy(); - if (!a.getIndexPrivate().isFastIterator()) - a = a.copy(); - for (int i = 0; i < rowNum - 1; i++) { - for (int j = 0; j < colNum - 1; j++) { - x1 = x_s.getDouble(i * colNum + j); - x2 = x_s.getDouble(i * colNum + j + 1); - x3 = x_s.getDouble((i + 1) * colNum + j); - x4 = x_s.getDouble((i + 1) * colNum + j + 1); - PolygonShape ps = new PolygonShape(); - List points = new ArrayList<>(); - points.add(new PointD(x1, y_s.getDouble(i * colNum + j))); - points.add(new PointD(x3, y_s.getDouble((i + 1) * colNum + j))); - points.add(new PointD(x4, y_s.getDouble((i + 1) * colNum + j + 1))); - points.add(new PointD(x2, y_s.getDouble(i * colNum + j + 1))); - points.add((PointD) points.get(0).clone()); - ps.setPoints(points); - v = a.getDouble(i * colNum + j); - pb = (PolygonBreak) ls.findLegendBreak(v); - Graphic graphic = new Graphic(ps, pb); - gc.add(graphic); - } - } - - gc.setSingleLegend(false); - gc.setLegendScheme(ls); - - return gc; - } - - /** - * Create grid polygons - * - * @param x_s X array - 1D - * @param y_s Y array - 1D - * @param a scatter value array - 2D - * @param ls Legend scheme - * @return Grid polygons - */ - public static GraphicCollection createGridPolygons(Array x_s, Array y_s, Array a, LegendScheme ls) { - GraphicCollection gc = new GraphicCollection(); - - if (!x_s.getIndexPrivate().isFastIterator()) - x_s = x_s.copy(); - if (!y_s.getIndexPrivate().isFastIterator()) - y_s = y_s.copy(); - if (!a.getIndexPrivate().isFastIterator()) - a = a.copy(); - - int colNum = (int) x_s.getSize(); - int rowNum = (int) y_s.getSize(); - double x, x1 = 0, x2, y, y1 = 0, y2, xd, yd, v; - PolygonBreak pb; - for (int i = 0; i < rowNum; i++) { - if (i == 0) { - y1 = y_s.getDouble(i); - } - y = y_s.getDouble(i); - if (i < rowNum - 1) { - y2 = y_s.getDouble(i + 1); - yd = y2 - y; - } else { - y2 = y_s.getDouble(i - 1); - yd = y - y2; - } - if (i == 0) { - y1 = y1 - yd * 0.5; - } - y2 = y + yd * 0.5; - for (int j = 0; j < colNum; j++) { - if (j == 0) { - x1 = x_s.getDouble(j); - } - x = x_s.getDouble(j); - if (j < colNum - 1) { - x2 = x_s.getDouble(j + 1); - xd = x2 - x; - } else { - x2 = x_s.getDouble(j - 1); - xd = x - x2; - } - if (j == 0) { - x1 = x1 - xd * 0.5; - } - x2 = x + xd * 0.5; - PolygonShape ps = new PolygonShape(); - List points = new ArrayList<>(); - points.add(new PointD(x1, y1)); - points.add(new PointD(x1, y2)); - points.add(new PointD(x2, y2)); - points.add(new PointD(x2, y1)); - points.add((PointD) points.get(0).clone()); - ps.setPoints(points); - v = a.getDouble(i * colNum + j); - pb = (PolygonBreak) ls.findLegendBreak(v); - Graphic graphic = new Graphic(ps, pb); - gc.add(graphic); - x1 = x2; - } - y1 = y2; - } - - gc.setSingleLegend(false); - gc.setLegendScheme(ls); - - return gc; - } - - /** - * Create fill between polygons - * - * @param xdata X data array - * @param y1data Y1 data array - * @param y2data Y2 data array - * @param where Where data array - * @param pb Polygon break - * @return GraphicCollection - */ - public static GraphicCollection createFillBetweenPolygons(Array xdata, Array y1data, - Array y2data, Array where, PolygonBreak pb) { - GraphicCollection gc = new GraphicCollection(); - int len = (int) xdata.getSize(); - if (!xdata.getIndexPrivate().isFastIterator()) - xdata = xdata.copy(); - if (!y1data.getIndexPrivate().isFastIterator()) - y1data = y1data.copy(); - if (!y2data.getIndexPrivate().isFastIterator()) - y2data = y2data.copy(); - if (where == null) { - if (ArrayMath.containsNaN(y1data) || ArrayMath.containsNaN(y2data)) { - where = Array.factory(DataType.BOOLEAN, new int[]{len}); - double v1, v2; - for (int i = 0; i < len; i++) { - v1 = y1data.getDouble(i); - v2 = y2data.getDouble(i); - if (Double.isNaN(v1) || Double.isNaN(v2)) { - where.setBoolean(i, false); - } else { - where.setBoolean(i, true); - } - } - } - } - if (where == null) { - PolygonShape pgs = new PolygonShape(); - List points = new ArrayList<>(); - for (int i = 0; i < len; i++) { - points.add(new PointD(xdata.getDouble(i), y1data.getDouble(i))); - } - for (int i = len - 1; i >= 0; i--) { - points.add(new PointD(xdata.getDouble(i), y2data.getDouble(i))); - } - pgs.setPoints(points); - Graphic graphic = new Graphic(pgs, pb); - gc.add(graphic); - } else { - if (!where.getIndexPrivate().isFastIterator()) - where = where.copy(); - boolean ob = false; - List> idxs = new ArrayList<>(); - List idx = new ArrayList<>(); - for (int j = 0; j < len; j++) { - if (where.getInt(j) == 1) { - idx.add(j); - } else if (ob) { - idxs.add(idx); - idx = new ArrayList<>(); - } - ob = where.getInt(j) == 1; - } - if (!idx.isEmpty()) { - idxs.add(idx); - } - for (List index : idxs) { - int nn = index.size(); - if (nn >= 2) { - PolygonShape pgs = new PolygonShape(); - List points = new ArrayList<>(); - int ii; - for (int j = 0; j < nn; j++) { - ii = index.get(j); - points.add(new PointD(xdata.getDouble(ii), y1data.getDouble(ii))); - } - for (int j = 0; j < nn; j++) { - ii = index.get(nn - j - 1); - points.add(new PointD(xdata.getDouble(ii), y2data.getDouble(ii))); - } - pgs.setPoints(points); - Graphic graphic = new Graphic(pgs, pb); - gc.add(graphic); - } - } - } - - return gc; - } - - /** - * Create fill between polygons - X direction - * - * @param ydata Y data array - * @param x1data X1 data array - * @param x2data X2 data array - * @param where Where data array - * @param pb Polygon break - * @return GraphicCollection - */ - public static GraphicCollection createFillBetweenPolygonsX(Array ydata, Array x1data, - Array x2data, Array where, PolygonBreak pb) { - GraphicCollection gc = new GraphicCollection(); - int len = (int) ydata.getSize(); - if (!ydata.getIndexPrivate().isFastIterator()) - ydata = ydata.copy(); - if (!x1data.getIndexPrivate().isFastIterator()) - x1data = x1data.copy(); - if (!x2data.getIndexPrivate().isFastIterator()) - x2data = x2data.copy(); - if (where == null) { - if (ArrayMath.containsNaN(x1data) || ArrayMath.containsNaN(x2data)) { - where = Array.factory(DataType.BOOLEAN, new int[]{len}); - double v1, v2; - for (int i = 0; i < len; i++) { - v1 = x1data.getDouble(i); - v2 = x2data.getDouble(i); - if (Double.isNaN(v1) || Double.isNaN(v2)) { - where.setBoolean(i, false); - } else { - where.setBoolean(i, true); - } - } - } - } - if (where == null) { - PolygonShape pgs = new PolygonShape(); - List points = new ArrayList<>(); - for (int i = 0; i < len; i++) { - points.add(new PointD(x1data.getDouble(i), ydata.getDouble(i))); - } - for (int i = len - 1; i >= 0; i--) { - points.add(new PointD(x2data.getDouble(i), ydata.getDouble(i))); - } - pgs.setPoints(points); - Graphic graphic = new Graphic(pgs, pb); - gc.add(graphic); - } else { - if (!where.getIndexPrivate().isFastIterator()) - where = where.copy(); - boolean ob = false; - List> idxs = new ArrayList<>(); - List idx = new ArrayList<>(); - for (int j = 0; j < len; j++) { - if (where.getInt(j) == 1) { - idx.add(j); - } else if (ob) { - idxs.add(idx); - idx = new ArrayList<>(); - } - ob = where.getInt(j) == 1; - } - if (!idx.isEmpty()) { - idxs.add(idx); - } - for (List index : idxs) { - int nn = index.size(); - if (nn >= 2) { - PolygonShape pgs = new PolygonShape(); - List points = new ArrayList<>(); - int ii; - for (int j = 0; j < nn; j++) { - ii = index.get(j); - points.add(new PointD(x1data.getDouble(ii), ydata.getDouble(ii))); - } - for (int j = 0; j < nn; j++) { - ii = index.get(nn - j - 1); - points.add(new PointD(x2data.getDouble(ii), ydata.getDouble(ii))); - } - pgs.setPoints(points); - Graphic graphic = new Graphic(pgs, pb); - gc.add(graphic); - } - } - } - - return gc; - } - - /** - * Create fill between polygons - * - * @param xdata X data array - * @param y1data Y1 data array - * @param y2data Y2 data array - * @param where Where data array - * @param pb Polygon break - * @param offset Offset - * @param zdir Zdir - * @return GraphicCollection - */ - public static GraphicCollection createFillBetweenPolygons(Array xdata, Array y1data, - Array y2data, Array where, PolygonBreak pb, double offset, String zdir) { - GraphicCollection3D gc = new GraphicCollection3D(); - gc.setFixZ(true); - gc.setZValue(offset); - gc.setZDir(zdir); - int len = (int) xdata.getSize(); - if (!xdata.getIndexPrivate().isFastIterator()) - xdata = xdata.copy(); - if (!y1data.getIndexPrivate().isFastIterator()) - y1data = y1data.copy(); - if (!y2data.getIndexPrivate().isFastIterator()) - y2data = y2data.copy(); - if (where == null) { - if (ArrayMath.containsNaN(y1data) || ArrayMath.containsNaN(y2data)) { - where = Array.factory(DataType.BOOLEAN, new int[]{len}); - double v1, v2; - for (int i = 0; i < len; i++) { - v1 = y1data.getDouble(i); - v2 = y2data.getDouble(i); - if (Double.isNaN(v1) || Double.isNaN(v2)) { - where.setBoolean(i, false); - } else { - where.setBoolean(i, true); - } - } - } - } - if (where == null) { - PolygonZShape pgs = new PolygonZShape(); - List points = new ArrayList<>(); - switch (zdir) { - case "x": - for (int i = 0; i < len; i++) { - points.add(new PointZ(offset, xdata.getDouble(i), y1data.getDouble(i))); - } - for (int i = len - 1; i >= 0; i--) { - points.add(new PointZ(offset, xdata.getDouble(i), y2data.getDouble(i))); - } - break; - case "y": - for (int i = 0; i < len; i++) { - points.add(new PointZ(xdata.getDouble(i), offset, y1data.getDouble(i))); - } - for (int i = len - 1; i >= 0; i--) { - points.add(new PointZ(xdata.getDouble(i), offset, y2data.getDouble(i))); - } - break; - case "z": - for (int i = 0; i < len; i++) { - points.add(new PointZ(xdata.getDouble(i), y1data.getDouble(i), offset)); - } - for (int i = len - 1; i >= 0; i--) { - points.add(new PointZ(xdata.getDouble(i), y2data.getDouble(i), offset)); - } - break; - } - pgs.setPoints(points); - Graphic graphic = new Graphic(pgs, pb); - gc.add(graphic); - } else { - if (!where.getIndexPrivate().isFastIterator()) - where = where.copy(); - boolean ob = false; - List> idxs = new ArrayList<>(); - List idx = new ArrayList<>(); - for (int j = 0; j < len; j++) { - if (where.getInt(j) == 1) { - idx.add(j); - } else if (ob) { - idxs.add(idx); - idx = new ArrayList<>(); - } - ob = where.getInt(j) == 1; - } - if (!idx.isEmpty()) { - idxs.add(idx); - } - for (List index : idxs) { - int nn = index.size(); - if (nn >= 2) { - PolygonZShape pgs = new PolygonZShape(); - List points = new ArrayList<>(); - int ii; - switch (zdir) { - case "x": - for (int j = 0; j < nn; j++) { - ii = index.get(j); - points.add(new PointZ(offset, xdata.getDouble(ii), y1data.getDouble(ii))); - } - for (int j = 0; j < nn; j++) { - ii = index.get(nn - j - 1); - points.add(new PointZ(offset, xdata.getDouble(ii), y2data.getDouble(ii))); - } - break; - case "y": - for (int j = 0; j < nn; j++) { - ii = index.get(j); - points.add(new PointZ(xdata.getDouble(ii), offset, y1data.getDouble(ii))); - } - for (int j = 0; j < nn; j++) { - ii = index.get(nn - j - 1); - points.add(new PointZ(xdata.getDouble(ii), offset, y2data.getDouble(ii))); - } - break; - case "z": - for (int j = 0; j < nn; j++) { - ii = index.get(j); - points.add(new PointZ(xdata.getDouble(ii), y1data.getDouble(ii), offset)); - } - for (int j = 0; j < nn; j++) { - ii = index.get(nn - j - 1); - points.add(new PointZ(xdata.getDouble(ii), y2data.getDouble(ii), offset)); - } - break; - } - pgs.setPoints(points); - Graphic graphic = new Graphic(pgs, pb); - gc.add(graphic); - } - } - } - - return gc; - } - - /** - * Create fill between polygons - * - * @param xdata X data array - * @param ydata Y data array - * @param y1data Y1 data array - * @param y2data Y2 data array - * @param where Where data array - * @param pb Polygon break - * @param offset Offset - * @param zdir Zdir - * @return GraphicCollection - */ - public static GraphicCollection createFillBetweenPolygons(Array xdata, Array ydata, Array y1data, - Array y2data, Array where, PolygonBreak pb, double offset, String zdir) { - GraphicCollection3D gc = new GraphicCollection3D(); - gc.setFixZ(true); - gc.setZValue(offset); - gc.setZDir(zdir); - int len = (int) xdata.getSize(); - if (!xdata.getIndexPrivate().isFastIterator()) - xdata = xdata.copy(); - if (!y1data.getIndexPrivate().isFastIterator()) - y1data = y1data.copy(); - if (!y2data.getIndexPrivate().isFastIterator()) - y2data = y2data.copy(); - if (where == null) { - PolygonZShape pgs = new PolygonZShape(); - List points = new ArrayList<>(); - switch (zdir) { - case "x": - for (int i = 0; i < len; i++) { - points.add(new PointZ(offset, xdata.getDouble(i), y1data.getDouble(i))); - } - for (int i = len - 1; i >= 0; i--) { - points.add(new PointZ(offset, xdata.getDouble(i), y2data.getDouble(i))); - } - break; - case "y": - for (int i = 0; i < len; i++) { - points.add(new PointZ(xdata.getDouble(i), offset, y1data.getDouble(i))); - } - for (int i = len - 1; i >= 0; i--) { - points.add(new PointZ(xdata.getDouble(i), offset, y2data.getDouble(i))); - } - break; - case "xy": - if (!ydata.getIndexPrivate().isFastIterator()) - ydata = ydata.copy(); - for (int i = 0; i < len; i++) { - points.add(new PointZ(xdata.getDouble(i), ydata.getDouble(i), y1data.getDouble(i))); - } - for (int i = len - 1; i >= 0; i--) { - points.add(new PointZ(xdata.getDouble(i), ydata.getDouble(i), y2data.getDouble(i))); - } - break; - case "z": - for (int i = 0; i < len; i++) { - points.add(new PointZ(xdata.getDouble(i), y1data.getDouble(i), offset)); - } - for (int i = len - 1; i >= 0; i--) { - points.add(new PointZ(xdata.getDouble(i), y2data.getDouble(i), offset)); - } - break; - } - pgs.setPoints(points); - Graphic graphic = new Graphic(pgs, pb); - gc.add(graphic); - } else { - boolean ob = false; - List> idxs = new ArrayList<>(); - List idx = new ArrayList<>(); - for (int j = 0; j < len; j++) { - if (where.getInt(j) == 1) { - if (!ob) { - idx = new ArrayList<>(); - } - idx.add(j); - } else if (ob) { - idxs.add(idx); - } - ob = where.getInt(j) == 1; - } - for (List index : idxs) { - int nn = index.size(); - if (nn >= 2) { - PolygonZShape pgs = new PolygonZShape(); - List points = new ArrayList<>(); - int ii; - switch (zdir) { - case "x": - for (int j = 0; j < nn; j++) { - ii = index.get(j); - points.add(new PointZ(offset, xdata.getDouble(ii), y1data.getDouble(ii))); - } - for (int j = 0; j < nn; j++) { - ii = index.get(nn - j - 1); - points.add(new PointZ(offset, xdata.getDouble(ii), y2data.getDouble(ii))); - } - break; - case "y": - for (int j = 0; j < nn; j++) { - ii = index.get(j); - points.add(new PointZ(xdata.getDouble(ii), offset, y1data.getDouble(ii))); - } - for (int j = 0; j < nn; j++) { - ii = index.get(nn - j - 1); - points.add(new PointZ(xdata.getDouble(ii), offset, y2data.getDouble(ii))); - } - break; - case "xy": - if (!ydata.getIndexPrivate().isFastIterator()) - ydata = ydata.copy(); - for (int j = 0; j < nn; j++) { - ii = index.get(j); - points.add(new PointZ(xdata.getDouble(ii), ydata.getDouble(ii), y1data.getDouble(ii))); - } - for (int j = 0; j < nn; j++) { - ii = index.get(nn - j - 1); - points.add(new PointZ(xdata.getDouble(ii), ydata.getDouble(ii), y2data.getDouble(ii))); - } - break; - case "z": - for (int j = 0; j < nn; j++) { - ii = index.get(j); - points.add(new PointZ(xdata.getDouble(ii), y1data.getDouble(ii), offset)); - } - for (int j = 0; j < nn; j++) { - ii = index.get(nn - j - 1); - points.add(new PointZ(xdata.getDouble(ii), y2data.getDouble(ii), offset)); - } - break; - } - pgs.setPoints(points); - Graphic graphic = new Graphic(pgs, pb); - gc.add(graphic); - } - } - } - - return gc; - } - - /** - * Create wind barbs - * - * @param xdata X data array - * @param ydata Y data array - * @param udata U/WindDirection data array - * @param vdata V/WindSpeed data array - * @param cdata Colored data array - * @param ls Legend scheme - * @param isUV Is U/V or not - * @return GraphicCollection - */ - public static GraphicCollection createBarbs(Array xdata, Array ydata, Array udata, Array vdata, - Array cdata, LegendScheme ls, boolean isUV) { - GraphicCollection gc = new GraphicCollection(); - Array windDirData; - Array windSpeedData; - if (isUV) { - Array[] wwData = MeteoMath.uv2ds(udata, vdata); - windDirData = wwData[0]; - windSpeedData = wwData[1]; - } else { - windDirData = udata; - windSpeedData = vdata; - } - - ShapeTypes sts = ls.getShapeType(); - ls = ls.convertTo(ShapeTypes.Point); - if (sts != ShapeTypes.Point) { - for (int i = 0; i < ls.getBreakNum(); i++) { - ((PointBreak) ls.getLegendBreaks().get(i)).setSize(10); - } - } - - int i, j; - WindBarb aWB; - double windDir, windSpeed; - PointD aPoint; - ColorBreak cb; - double v; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - IndexIterator wdIter = windDirData.getIndexIterator(); - IndexIterator wsIter = windSpeedData.getIndexIterator(); - IndexIterator cIter = cdata == null ? null : cdata.getIndexIterator(); - while (xIter.hasNext()){ - windDir = wdIter.getDoubleNext(); - windSpeed = wsIter.getDoubleNext(); - if (!Double.isNaN(windDir) && !Double.isNaN(windSpeed)) { - aPoint = new PointD(); - aPoint.X = xIter.getDoubleNext(); - aPoint.Y = yIter.getDoubleNext(); - aWB = Draw.calWindBarb((float) windDir, (float) windSpeed, 0, 10, aPoint); - if (cdata == null) { - cb = ls.getLegendBreaks().get(0); - } else { - v = cIter.getDoubleNext(); - aWB.setValue(v); - cb = ls.findLegendBreak(v); - } - Graphic graphic = new Graphic(aWB, cb); - gc.add(graphic); - } else { - xIter.next(); - yIter.next(); - if (cIter != null) - cIter.next(); - } - } - - gc.setLegendScheme(ls); - if (cdata != null) { - gc.setSingleLegend(false); - } - - return gc; - } - - /** - * Create arrow polygon - * - * @param x X coordinate - * @param y Y coordinate - * @param dx The length of arrow along x direction - * @param dy The length of arrow along y direction - * @param ab The arrow polygon break - * @return Arrow polygon graphic - */ - public static Graphic createArrow(double x, double y, double dx, double dy, ArrowPolygonBreak ab) { - double[] r = MeteoMath.uv2ds(dx, dy); - double length = r[1]; - if (ab.isLengthIncludesHead()) { - length = length - ab.getHeadLength(); - } - - AffineTransform atf = new AffineTransform(); - atf.translate(x, y); - atf.rotate(dx, dy); - - float width = ab.getWidth(); - float headLength = ab.getHeadLength(); - float overhang = ab.getOverhang(); - float lenShift = headLength * overhang; - double[] srcPts = new double[8 * 2]; - srcPts[0] = 0; - srcPts[1] = -width * 0.5; - srcPts[2] = 0; - srcPts[3] = width * 0.5; - srcPts[4] = length + lenShift; - srcPts[5] = width * 0.5; - srcPts[6] = length; - srcPts[7] = ab.getHeadWidth() * 0.5; - srcPts[8] = length + ab.getHeadLength(); - srcPts[9] = 0; - srcPts[10] = length; - srcPts[11] = -ab.getHeadWidth() * 0.5; - srcPts[12] = length + lenShift; - srcPts[13] = -width * 0.5; - srcPts[14] = 0; - srcPts[15] = -width * 0.5; - atf.transform(srcPts, 0, srcPts, 0, 8); - List points = new ArrayList<>(); - for (int i = 0; i < srcPts.length; i += 2) { - points.add(new PointD(srcPts[i], srcPts[i + 1])); - } - PolygonShape pgs = new PolygonShape(); - pgs.setPoints(points); - - return new Graphic(pgs, ab); - } - - /** - * Create arrow line - * - * @param x X coordinate - * @param y Y coordinate - * @param dx The length of arrow along x direction - * @param dy The length of arrow along y direction - * @param ab The arrow line break - * @return Arrow line graphic - */ - public static Graphic createArrowLine(double x, double y, double dx, double dy, ArrowLineBreak ab) { - List points = new ArrayList<>(); - points.add(new PointD(x, y)); - points.add(new PointD(x + dx, y + dy)); - PolylineShape pls = new PolylineShape(); - pls.setPoints(points); - - return new Graphic(pls, ab); - } - - /** - * Create arrow line - * - * @param x X coordinates - * @param y Y coordinates - * @param ab The arrow line break - * @param iscurve Is curve or not - * @return Arrow line graphic - */ - public static Graphic createArrowLine(Array x, Array y, ArrowLineBreak ab, boolean iscurve) { - List points = new ArrayList<>(); - IndexIterator xIter = x.getIndexIterator(); - IndexIterator yIter = y.getIndexIterator(); - while (xIter.hasNext()){ - points.add(new PointD(xIter.getDoubleNext(), yIter.getDoubleNext())); - } - PolylineShape pls; - if (iscurve) { - pls = new CurveLineShape(); - } else { - pls = new PolylineShape(); - } - pls.setPoints(points); - - return new Graphic(pls, ab); - } - - /** - * Create wind arrows - * - * @param xdata X data array - * @param ydata Y data array - * @param udata U/WindDirection data array - * @param vdata V/WindSpeed data array - * @param cdata Colored data array - * @param ls Legend scheme - * @param isUV Is U/V or not - * @return GraphicCollection - */ - public static GraphicCollection createArrows(Array xdata, Array ydata, Array udata, Array vdata, - Array cdata, LegendScheme ls, boolean isUV) { - GraphicCollection gc = new GraphicCollection(); - Array windDirData; - Array windSpeedData; - if (isUV) { - Array[] wwData = MeteoMath.uv2ds(udata, vdata); - windDirData = wwData[0]; - windSpeedData = wwData[1]; - } else { - windDirData = udata; - windSpeedData = vdata; - } - - ShapeTypes sts = ls.getShapeType(); - ls = ls.convertTo(ShapeTypes.Point); - if (sts != ShapeTypes.Point) { - for (int i = 0; i < ls.getBreakNum(); i++) { - ((PointBreak) ls.getLegendBreaks().get(i)).setSize(10); - } - } - - int i; - WindArrow wa; - double windDir, windSpeed; - PointD aPoint; - ColorBreak cb; - double x, y, v = 0; - float size = 6; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - IndexIterator wdIter = windDirData.getIndexIterator(); - IndexIterator wsIter = windSpeedData.getIndexIterator(); - IndexIterator cIter = cdata == null ? null : cdata.getIndexIterator(); - while (xIter.hasNext()){ - windDir = wdIter.getDoubleNext(); - windSpeed = wsIter.getDoubleNext(); - x = xIter.getDoubleNext(); - y = yIter.getDoubleNext(); - if (cdata != null) - v = cIter.getDoubleNext(); - if (!Double.isNaN(windDir) && !Double.isNaN(windSpeed)) { - aPoint = new PointD(); - aPoint.X = x; - aPoint.Y = y; - wa = new WindArrow(); - wa.angle = windDir; - wa.length = (float) windSpeed; - wa.size = size; - wa.setPoint(aPoint); - if (cdata == null) { - cb = ls.getLegendBreaks().get(0); - } else { - wa.setValue(v); - cb = ls.findLegendBreak(v); - } - Graphic graphic = new Graphic(wa, cb); - gc.add(graphic); - } - } - - gc.setLegendScheme(ls); - if (cdata != null) { - gc.setSingleLegend(false); - } - - return gc; - } - - /** - * Create wind arrows - * - * @param xdata X data array - * @param ydata Y data array - * @param zdata Z data array - * @param udata U data array - * @param vdata V data array - * @param wdata W data array - * @param scale The length scale of each wind arrow - * @param headWidth The head width of the arrow - * @param headLength The head length of the arrow - * @param cdata Colored data array - * @param ls Legend scheme - * @return GraphicCollection - */ - public static GraphicCollection createArrows3D(Array xdata, Array ydata, Array zdata, Array udata, - Array vdata, Array wdata, float scale, float headWidth, float headLength, Array cdata, LegendScheme ls) { - GraphicCollection gc = new GraphicCollection(); - ShapeTypes sts = ls.getShapeType(); - ls = ls.convertTo(ShapeTypes.Point); - if (sts != ShapeTypes.Point) { - for (int i = 0; i < ls.getBreakNum(); i++) { - ((PointBreak) ls.getLegendBreaks().get(i)).setSize(10); - } - } - - int i; - WindArrow3D wa; - double u, v, w; - PointZ aPoint; - ColorBreak cb; - double value; - IndexIterator xIter = xdata.getIndexIterator(); - IndexIterator yIter = ydata.getIndexIterator(); - IndexIterator zIter = zdata.getIndexIterator(); - IndexIterator uIter = udata.getIndexIterator(); - IndexIterator vIter = vdata.getIndexIterator(); - IndexIterator wIter = wdata.getIndexIterator(); - IndexIterator cIter = cdata == null ? null : cdata.getIndexIterator(); - while (xIter.hasNext()){ - u = uIter.getDoubleNext(); - v = vIter.getDoubleNext(); - w = wIter.getDoubleNext(); - if (!Double.isNaN(u) && !Double.isNaN(v) && !Double.isNaN(w)) { - aPoint = new PointZ(); - aPoint.X = xIter.getDoubleNext(); - aPoint.Y = yIter.getDoubleNext(); - aPoint.Z = zIter.getDoubleNext(); - wa = new WindArrow3D(); - wa.u = u; - wa.v = v; - wa.w = w; - wa.scale = scale; - wa.setHeadWith(headWidth); - wa.setHeadLength(headLength); - wa.setPoint(aPoint); - if (cdata == null) { - cb = ls.getLegendBreaks().get(0); - } else { - value = cIter.getDoubleNext(); - wa.setValue(value); - cb = ls.findLegendBreak(value); - } - Graphic graphic = new Graphic(wa, cb); - gc.add(graphic); - } else { - xIter.next(); - yIter.next(); - zIter.next(); - if (cdata != null) - cIter.next(); - } - } - - gc.setLegendScheme(ls); - if (cdata != null) { - gc.setSingleLegend(false); - } - - return gc; - } - - /** - * Create 3D streamlines - * @param xdata X coordinate array - * @param ydata Y coordinate array - * @param zdata Z coordinate array - * @param udata U wind component array - * @param vdata V wind component array - * @param wdata W wind component array - * @param cdata Value array - * @param density Streamline density - * @param ls The legend scheme - * @return - */ - public static GraphicCollection3D createStreamlines3D(Array xdata, Array ydata, Array zdata, - Array udata, Array vdata, Array wdata, - Array cdata, int density, LegendScheme ls, - int minPoints) { - GraphicCollection3D graphics = new GraphicCollection3D(); - double[][][] u = (double[][][]) ArrayUtil.copyToNDJavaArray_Double(udata); - double[][][] v = (double[][][]) ArrayUtil.copyToNDJavaArray_Double(vdata); - double[][][] w = (double[][][]) ArrayUtil.copyToNDJavaArray_Double(wdata); - if (xdata.getRank() == 1) { - double[] x = (double[]) ArrayUtil.copyToNDJavaArray_Double(xdata); - double[] y = (double[]) ArrayUtil.copyToNDJavaArray_Double(ydata); - double[] z = (double[]) ArrayUtil.copyToNDJavaArray_Double(zdata); - - if (cdata == null) { - List streamLines = Contour.tracingStreamline3D(u, v, w, null, x, y, z, density); - ColorBreak cb = ls.getLegendBreak(0); - for (PolyLine3D line : streamLines) { - if (line.PointList.size() < minPoints) - continue; - - PolylineZShape shape = new PolylineZShape(); - List points = new ArrayList<>(); - for (Point3D point : line.PointList) { - points.add(new PointZ(point.X, point.Y, point.Z)); - } - shape.setPoints(points); - graphics.add(new Graphic(shape, cb)); - } - } else { - double[][][] m = (double[][][]) ArrayUtil.copyToNDJavaArray_Double(cdata); - List streamLines = Contour.tracingStreamline3D(u, v, w, m, x, y, z, density); - ColorBreak cb; - double mm; - for (PolyLine3D line : streamLines) { - if (line.PointList.size() < minPoints) - continue; - - PolylineZShape shape = new PolylineZShape(); - List points = new ArrayList<>(); - ColorBreakCollection cbs = new ColorBreakCollection(); - for (Point3D point : line.PointList) { - points.add(new PointZ(point.X, point.Y, point.Z)); - cb = ls.findLegendBreak(point.M); - cbs.add(cb); - } - shape.setPoints(points); - graphics.add(new Graphic(shape, cbs)); - } - } - } else { - double[][][] x = (double[][][]) ArrayUtil.copyToNDJavaArray_Double(xdata); - double[][][] y = (double[][][]) ArrayUtil.copyToNDJavaArray_Double(ydata); - double[][][] z = (double[][][]) ArrayUtil.copyToNDJavaArray_Double(zdata); - - if (cdata == null) { - List streamLines = Contour.tracingStreamline3D(u, v, w, null, x, y, z, density); - ColorBreak cb = ls.getLegendBreak(0); - for (PolyLine3D line : streamLines) { - if (line.PointList.size() < minPoints) - continue; - - PolylineZShape shape = new PolylineZShape(); - List points = new ArrayList<>(); - for (Point3D point : line.PointList) { - points.add(new PointZ(point.X, point.Y, point.Z)); - } - shape.setPoints(points); - graphics.add(new Graphic(shape, cb)); - } - } else { - double[][][] m = (double[][][]) ArrayUtil.copyToNDJavaArray_Double(cdata); - List streamLines = Contour.tracingStreamline3D(u, v, w, m, x, y, z, density); - ColorBreak cb; - double mm; - for (PolyLine3D line : streamLines) { - if (line.PointList.size() < minPoints) - continue; - - PolylineZShape shape = new PolylineZShape(); - List points = new ArrayList<>(); - ColorBreakCollection cbs = new ColorBreakCollection(); - for (Point3D point : line.PointList) { - points.add(new PointZ(point.X, point.Y, point.Z)); - cb = ls.findLegendBreak(point.M); - cbs.add(cb); - } - shape.setPoints(points); - graphics.add(new Graphic(shape, cbs)); - } - } - } - graphics.setLegendScheme(ls); - - return graphics; - } - - /** - * Create 3D streamlines - * @param xdata X coordinate array - * @param ydata Y coordinate array - * @param zdata Z coordinate array - * @param udata U wind component array - * @param vdata V wind component array - * @param wdata W wind component array - * @param cdata Value array - * @param density Streamline density - * @param ls The legend scheme - * @return - */ - public static GraphicCollection3D createStreamlines3D(Array xdata, Array ydata, Array zdata, - Array udata, Array vdata, Array wdata, - Array cdata, int density, LegendScheme ls, - int minPoints, Array startX, Array startY, - Array startZ) { - GraphicCollection3D graphics = new GraphicCollection3D(); - double[][][] u = (double[][][]) ArrayUtil.copyToNDJavaArray_Double(udata); - double[][][] v = (double[][][]) ArrayUtil.copyToNDJavaArray_Double(vdata); - double[][][] w = (double[][][]) ArrayUtil.copyToNDJavaArray_Double(wdata); - double[] sX = (double[]) ArrayUtil.copyToNDJavaArray_Double(startX); - double[] sY = (double[]) ArrayUtil.copyToNDJavaArray_Double(startY); - double[] sZ = (double[]) ArrayUtil.copyToNDJavaArray_Double(startZ); - if (xdata.getRank() == 1) { - double[] x = (double[]) ArrayUtil.copyToNDJavaArray_Double(xdata); - double[] y = (double[]) ArrayUtil.copyToNDJavaArray_Double(ydata); - double[] z = (double[]) ArrayUtil.copyToNDJavaArray_Double(zdata); - - if (cdata == null) { - List streamLines = Contour.tracingStreamline3D(u, v, w, null, x, y, z, density, - sX, sY, sZ); - ColorBreak cb = ls.getLegendBreak(0); - for (PolyLine3D line : streamLines) { - if (line.PointList.size() < minPoints) - continue; - - PolylineZShape shape = new PolylineZShape(); - List points = new ArrayList<>(); - for (Point3D point : line.PointList) { - points.add(new PointZ(point.X, point.Y, point.Z)); - } - shape.setPoints(points); - graphics.add(new Graphic(shape, cb)); - } - } else { - double[][][] m = (double[][][]) ArrayUtil.copyToNDJavaArray_Double(cdata); - List streamLines = Contour.tracingStreamline3D(u, v, w, m, x, y, z, density, - sX, sY, sZ); - ColorBreak cb; - double mm; - for (PolyLine3D line : streamLines) { - if (line.PointList.size() < minPoints) - continue; - - PolylineZShape shape = new PolylineZShape(); - List points = new ArrayList<>(); - ColorBreakCollection cbs = new ColorBreakCollection(); - for (Point3D point : line.PointList) { - points.add(new PointZ(point.X, point.Y, point.Z)); - cb = ls.findLegendBreak(point.M); - cbs.add(cb); - } - shape.setPoints(points); - graphics.add(new Graphic(shape, cbs)); - } - } - } else { - double[][][] x = (double[][][]) ArrayUtil.copyToNDJavaArray_Double(xdata); - double[][][] y = (double[][][]) ArrayUtil.copyToNDJavaArray_Double(ydata); - double[][][] z = (double[][][]) ArrayUtil.copyToNDJavaArray_Double(zdata); - - if (cdata == null) { - List streamLines = Contour.tracingStreamline3D(u, v, w, null, x, y, z, density, - sX, sY, sZ); - ColorBreak cb = ls.getLegendBreak(0); - for (PolyLine3D line : streamLines) { - if (line.PointList.size() < minPoints) - continue; - - PolylineZShape shape = new PolylineZShape(); - List points = new ArrayList<>(); - for (Point3D point : line.PointList) { - points.add(new PointZ(point.X, point.Y, point.Z)); - } - shape.setPoints(points); - graphics.add(new Graphic(shape, cb)); - } - } else { - double[][][] m = (double[][][]) ArrayUtil.copyToNDJavaArray_Double(cdata); - List streamLines = Contour.tracingStreamline3D(u, v, w, m, x, y, z, density, - sX, sY, sZ); - ColorBreak cb; - double mm; - for (PolyLine3D line : streamLines) { - if (line.PointList.size() < minPoints) - continue; - - PolylineZShape shape = new PolylineZShape(); - List points = new ArrayList<>(); - ColorBreakCollection cbs = new ColorBreakCollection(); - for (Point3D point : line.PointList) { - points.add(new PointZ(point.X, point.Y, point.Z)); - cb = ls.findLegendBreak(point.M); - cbs.add(cb); - } - shape.setPoints(points); - graphics.add(new Graphic(shape, cbs)); - } - } - } - graphics.setLegendScheme(ls); - - return graphics; - } - - /** - * Create stream line - * - * @param xdata X data array - * @param ydata Y data array - * @param udata U/WindDirection data array - * @param vdata V/WindSpeed data array - * @param density Streamline density - * @param slb Streamline break - * @param isUV Is U/V or not - * @return GraphicCollection - */ - public static GraphicCollection createStreamlines(Array xdata, Array ydata, Array udata, Array vdata, - int density, StreamlineBreak slb, boolean isUV) { - GraphicCollection gc = new GraphicCollection(); - if (!isUV) { - Array[] uvData = MeteoMath.ds2uv(udata, vdata); - udata = uvData[0]; - vdata = uvData[1]; - } - - double[][] u = (double[][])ArrayUtil.copyToNDJavaArray_Double(udata); - double[][] v = (double[][])ArrayUtil.copyToNDJavaArray_Double(vdata); - double[] x = (double[]) ArrayUtil.copyToNDJavaArray_Double(xdata); - double[] y = (double[]) ArrayUtil.copyToNDJavaArray_Double(ydata); - List streamlines = wcontour.Contour.tracingStreamline(u, v, - x, y, density); - wcontour.global.PolyLine line; - for (int i = 0; i < streamlines.size() - 1; i++) { - line = streamlines.get(i); - PolylineShape aPolyline = new PolylineShape(); - PointD aPoint; - List pList = new ArrayList<>(); - for (int j = 0; j < line.PointList.size(); j++) { - aPoint = new PointD(); - aPoint.X = (line.PointList.get(j)).X; - aPoint.Y = (line.PointList.get(j)).Y; - pList.add(aPoint); - } - aPolyline.setPoints(pList); - aPolyline.setValue(density); - gc.add(new Graphic(aPolyline, slb)); - } - - return gc; - } - - /** - * Trace streamlines - * @param xa X coordinate array - * @param ya Y coordinate array - * @param z Z value - * @param ua U component - * @param va V component - * @param data Data array - * @param density Streamline density - * @param zDir Z direction: "x", "y" or "z" - * @param ls Legend scheme - * @return Streamlines - */ - public static GraphicCollection3D streamLines(Array xa, Array ya, double z, Array ua, - Array va, Array data, int density, - String zDir, LegendScheme ls) { - GraphicCollection3D graphics = new GraphicCollection3D(); - double[][] u = (double[][]) ArrayUtil.copyToNDJavaArray_Double(ua); - double[][] v = (double[][]) ArrayUtil.copyToNDJavaArray_Double(va); - List streamlines; - if (xa.getRank() == 1) { - double[] x = (double[]) ArrayUtil.copyToNDJavaArray_Double(xa); - double[] y = (double[]) ArrayUtil.copyToNDJavaArray_Double(ya); - streamlines = wcontour.Contour.tracingStreamline(u, v, - x, y, density); - } else { - xa = xa.copyIfView(); - ya = ya.copyIfView(); - double[][] x = (double[][]) ArrayUtil.copyToNDJavaArray_Double(xa); - double[][] y = (double[][]) ArrayUtil.copyToNDJavaArray_Double(ya); - streamlines = wcontour.Contour.tracingStreamline(u, v, - x, y, density); - } - - int ny = u.length; - int nx = u[0].length; - ColorBreak cb = ls.getLegendBreak(0); - if (data == null) { - for (wcontour.global.PolyLine line : streamlines) { - PolylineZShape shape = new PolylineZShape(); - List points = new ArrayList<>(); - PointZ p; - if (zDir.equals("x")) { - for (int j = 0; j < line.PointList.size(); j++) { - p = new PointZ(); - p.Y = (line.PointList.get(j)).X; - p.Z = (line.PointList.get(j)).Y; - p.X = z; - points.add(p); - } - } else if (zDir.equals("y")) { - for (int j = 0; j < line.PointList.size(); j++) { - p = new PointZ(); - p.X = (line.PointList.get(j)).X; - p.Z = (line.PointList.get(j)).Y; - p.Y = z; - points.add(p); - } - } else { - for (int j = 0; j < line.PointList.size(); j++) { - p = new PointZ(); - p.X = (line.PointList.get(j)).X; - p.Y = (line.PointList.get(j)).Y; - p.Z = z; - points.add(p); - } - } - shape.setPoints(points); - graphics.add(new Graphic(shape, cb)); - } - } else { - for (wcontour.global.PolyLine line : streamlines) { - PolylineZShape shape = new PolylineZShape(); - List points = new ArrayList<>(); - PointZ p; - ColorBreakCollection cbs = new ColorBreakCollection(); - if (zDir.equals("x")) { - for (int j = 0; j < line.PointList.size(); j++) { - p = new PointZ(); - p.Y = (line.PointList.get(j)).X; - p.Z = (line.PointList.get(j)).Y; - p.X = z; - int[] idx = ArrayUtil.gridIndex(xa, ya, p.Y, p.Z); - if (idx != null) { - int yi = idx[0]; - int xi = idx[1]; - p.M = data.getDouble(yi * nx + xi); - } - cb = ls.findLegendBreak(p.M); - cbs.add(cb); - points.add(p); - } - } else if (zDir.equals("y")) { - for (int j = 0; j < line.PointList.size(); j++) { - p = new PointZ(); - p.X = (line.PointList.get(j)).X; - p.Z = (line.PointList.get(j)).Y; - p.Y = z; - int[] idx = ArrayUtil.gridIndex(xa, ya, p.X, p.Z); - if (idx != null) { - int yi = idx[0]; - int xi = idx[1]; - p.M = data.getDouble(yi * nx + xi); - } - cb = ls.findLegendBreak(p.M); - cbs.add(cb); - points.add(p); - } - } else { - for (int j = 0; j < line.PointList.size(); j++) { - p = new PointZ(); - p.X = (line.PointList.get(j)).X; - p.Y = (line.PointList.get(j)).Y; - p.Z = z; - int[] idx = ArrayUtil.gridIndex(xa, ya, p.X, p.Y); - if (idx != null) { - int yi = idx[0]; - int xi = idx[1]; - p.M = data.getDouble(yi * nx + xi); - } - cb = ls.findLegendBreak(p.M); - cbs.add(cb); - points.add(p); - } - } - shape.setPoints(points); - graphics.add(new Graphic(shape, cbs)); - } - } - graphics.setLegendScheme(ls); - - return graphics; - } - - /** - * Trace streamlines - * @param xa X coordinate array - * @param ya Y coordinate array - * @param za Z coordinate value - * @param ua U component - * @param va V component - * @param data Data array - * @param density Streamline density - * @param ls Legend scheme - * @return Streamlines - */ - public static GraphicCollection3D streamLines(Array xa, Array ya, Array za, Array ua, - Array va, Array data, int density, - LegendScheme ls) { - GraphicCollection3D graphics = new GraphicCollection3D(); - double[][] u = (double[][]) ArrayUtil.copyToNDJavaArray_Double(ua); - double[][] v = (double[][]) ArrayUtil.copyToNDJavaArray_Double(va); - List streamlines; - if (xa.getRank() == 1) { - double[] x = (double[]) ArrayUtil.copyToNDJavaArray_Double(xa); - double[] y = (double[]) ArrayUtil.copyToNDJavaArray_Double(ya); - streamlines = wcontour.Contour.tracingStreamline(u, v, - x, y, density); - } else { - xa = xa.copyIfView(); - ya = ya.copyIfView(); - double[][] x = (double[][]) ArrayUtil.copyToNDJavaArray_Double(xa); - double[][] y = (double[][]) ArrayUtil.copyToNDJavaArray_Double(ya); - streamlines = wcontour.Contour.tracingStreamline(u, v, - x, y, density); - } - - int ny = u.length; - int nx = u[0].length; - ColorBreak cb = ls.getLegendBreak(0); - if (data == null) { - for (wcontour.global.PolyLine line : streamlines) { - PolylineZShape shape = new PolylineZShape(); - List points = new ArrayList<>(); - PointZ p; - for (int j = 0; j < line.PointList.size(); j++) { - p = new PointZ(); - p.X = (line.PointList.get(j)).X; - p.Y = (line.PointList.get(j)).Y; - int[] idx = ArrayUtil.gridIndex(xa, ya, p.Y, p.Z); - if (idx != null) { - int yi = idx[0]; - int xi = idx[1]; - p.Z = za.getDouble(yi * nx + xi); - } - points.add(p); - } - shape.setPoints(points); - graphics.add(new Graphic(shape, cb)); - } - } else { - for (wcontour.global.PolyLine line : streamlines) { - PolylineZShape shape = new PolylineZShape(); - List points = new ArrayList<>(); - PointZ p; - ColorBreakCollection cbs = new ColorBreakCollection(); - for (int j = 0; j < line.PointList.size(); j++) { - p = new PointZ(); - p.X = (line.PointList.get(j)).X; - p.Y = (line.PointList.get(j)).Y; - int[] idx = ArrayUtil.gridIndex(xa, ya, p.X, p.Y); - if (idx != null) { - int yi = idx[0]; - int xi = idx[1]; - p.Z = za.getDouble(yi * nx + xi); - p.M = data.getDouble(yi * nx + xi); - } - cb = ls.findLegendBreak(p.M); - cbs.add(cb); - points.add(p); - } - shape.setPoints(points); - graphics.add(new Graphic(shape, cbs)); - } - } - graphics.setLegendScheme(ls); - - return graphics; - } - - /** - * Create streamline slices in 3D axes - * @param xa X coordinate array - * @param ya Y coordinate array - * @param za Z coordinate array - * @param ua U component array - * @param va V component array - * @param wa W component array - * @param data Data array - * @param xSlice X slices - * @param ySlice Y slices - * @param zSlice Z slices - * @param density Streamline density - * @param ls Legend scheme - * @return Streamline slices graphics - * @throws InvalidRangeException - */ - public static List streamSlice(Array xa, Array ya, Array za, Array ua, - Array va, Array wa, Array data, List xSlice, - List ySlice, List zSlice, - int density, LegendScheme ls) throws InvalidRangeException { - List sgs = new ArrayList<>(); - double x, y, z; - - //X slice - for (int i = 0; i < xSlice.size(); i++) { - x = xSlice.get(i).doubleValue(); - Array aa = xa; - if (xa.getRank() == 3) { - int[] shape = xa.getShape(); - aa = xa.section(new int[]{0,0,0}, new int[]{1,1,shape[2]}); - } - Array xua = ArrayUtil.slice(va, 2, aa, x); - Array xva = ArrayUtil.slice(wa, 2, aa, x); - Array r = data == null ? null : ArrayUtil.slice(data, 2, aa, x); - Array yya = ya.getRank() == 1 ? ya : ArrayUtil.slice(ya, 2, aa, x); - Array zza = za.getRank() == 1 ? za : ArrayUtil.slice(za, 2, aa, x); - GraphicCollection3D graphics = streamLines(yya, zza, x, xua, xva, r, density, "x", ls); - sgs.add(graphics); - } - - //Y slice - for (int i = 0; i < ySlice.size(); i++) { - y = ySlice.get(i).doubleValue(); - Array aa = ya; - if (ya.getRank() == 3) { - int[] shape = ya.getShape(); - aa = ya.section(new int[]{0,0,0}, new int[]{1,shape[1],1}); - } - Array xua = ArrayUtil.slice(ua, 1, aa, y); - Array xva = ArrayUtil.slice(wa, 1, aa, y); - Array r = data == null ? null : ArrayUtil.slice(data, 1, aa, y); - Array xxa = xa.getRank() == 1 ? xa : ArrayUtil.slice(xa, 1, aa, y); - Array zza = za.getRank() == 1 ? za : ArrayUtil.slice(za, 1, aa, y); - GraphicCollection3D graphics = streamLines(xxa, zza, y, xua, xva, r, density, "y", ls); - sgs.add(graphics); - } - - //Z slice - for (int i = 0; i < zSlice.size(); i++) { - z = zSlice.get(i).doubleValue(); - Array aa = za; - if (za.getRank() == 3) { - int[] shape = za.getShape(); - aa = za.section(new int[]{0,0,0}, new int[]{shape[0],1,1}); - } - Array xua = ArrayUtil.slice(ua, 0, aa, z); - Array xva = ArrayUtil.slice(va, 0, aa, z); - Array r = data == null ? null : ArrayUtil.slice(data, 0, aa, z); - Array xxa = xa.getRank() == 1 ? xa : ArrayUtil.slice(xa, 0, aa, z); - Array yya = ya.getRank() == 1 ? ya : ArrayUtil.slice(ya, 0, aa, z); - GraphicCollection3D graphics = streamLines(xxa, yya, z, xua, xva, r, density, "z", ls); - sgs.add(graphics); - } - - return sgs; - } - - /** - * Create streamline slices in 3D axes - * @param xa X coordinate array - * @param ya Y coordinate array - * @param za Z coordinate array - * @param ua U component array - * @param va V component array - * @param wa W component array - * @param data Data array - * @param xSlice X slices - * @param ySlice Y slices - * @param zSlice Z slices - * @param density Streamline density - * @param ls Legend scheme - * @return Streamline slices graphics - * @throws InvalidRangeException - */ - public static List streamSlice(Array xa, Array ya, Array za, Array ua, - Array va, Array wa, Array data, List zSliceIndex, - int density, LegendScheme ls) throws InvalidRangeException { - List sgs = new ArrayList<>(); - int zIdx; - - //Z slice - for (int i = 0; i < zSliceIndex.size(); i++) { - zIdx = zSliceIndex.get(i); - Array aa = za; - Array xua = ArrayUtil.slice(ua, 0, zIdx); - Array xva = ArrayUtil.slice(va, 0, zIdx); - Array r = data == null ? null : ArrayUtil.slice(data, 0, zIdx); - Array xxa = xa.getRank() == 1 ? xa : ArrayUtil.slice(xa, 0, zIdx); - Array yya = ya.getRank() == 1 ? ya : ArrayUtil.slice(ya, 0, zIdx); - GraphicCollection3D graphics; - if (za.getRank() == 1) { - double z = za.getDouble(zIdx); - graphics = streamLines(xxa, yya, z, xua, xva, r, density, "z", ls); - } else { - Array zza = ArrayUtil.slice(za, 0, zIdx); - zza = zza.copyIfView(); - graphics = streamLines(xxa, yya, zza, xua, xva, r, density, ls); - } - sgs.add(graphics); - } - - return sgs; - } - -// /** -// * Create annotate -// * @param text The text -// * @param x X coordinate -// * @param y Y coordinate -// * @param xText X coordinate of the text -// * @param yText Y coordinate of the text -// * @param ab Arrow line break -// * @return Arrow line break and text -// */ -// public static GraphicCollection createAnnotate(ChartText text, float x, float y, -// float xText, float yText, ArrowLineBreak ab) { -// GraphicCollection gc = new GraphicCollection(); -// Graphic gg = createArrowLine(x, y, xText - x, xText - y, ab); -// gc.add(gg) -// } - /** - * Create pie arc polygons - * - * @param xdata X data array - * @param colors Colors - * @param labels Labels - * @param startAngle Start angle - * @param explode Explode - * @param labelFont Label font - * @param labelColor Label color - * @param labelDis Label distance - * @param autopct pct format - * @param pctDis pct distance - * @param radius Pie radius - * @param wedgeprops Wedge properties - * @return GraphicCollection - */ - public static GraphicCollection[] createPieArcs(Array xdata, List colors, - List labels, float startAngle, List explode, Font labelFont, - Color labelColor, float labelDis, String autopct, float pctDis, float radius, - HashMap wedgeprops) { - GraphicCollection gc = new GraphicCollection(); - GraphicCollection lgc = new GraphicCollection(); - GraphicCollection pgc = new GraphicCollection(); - double sum = ArrayMath.sum(xdata).doubleValue(); - double v; - float sweepAngle, angle; - float ex; - double dx, dy, ldx, ldy; - String label, pct = null; - LegendScheme ls = new LegendScheme(ShapeTypes.Polygon); - Boolean drawEdge = wedgeprops.get("drawedge") == null ? null : (Boolean) wedgeprops.get("drawedge"); - Color edgeColor = wedgeprops.get("edgecolor") == null ? null : (Color) wedgeprops.get("edgecolor"); - Float lineWidth = wedgeprops.get("linewidth") == null ? null : Float.parseFloat(String.valueOf(wedgeprops.get("linewidth"))); - Float wedgeWidth = wedgeprops.get("width") == null ? null : Float.parseFloat(String.valueOf(wedgeprops.get("width"))); - IndexIterator xIter = xdata.getIndexIterator(); - int i = 0; - while (xIter.hasNext()){ - v = xIter.getDoubleNext(); - if (Double.isNaN(v)) { - continue; - } - - if (sum > 1) { - v = v / sum; - } - sweepAngle = (float) (360.0 * v); - ArcShape aShape = new ArcShape(); - aShape.setStartAngle(startAngle); - aShape.setSweepAngle(sweepAngle); - angle = startAngle + sweepAngle / 2; - if (explode == null) { - dx = 0; - dy = 0; - } else { - ex = explode.get(i).floatValue(); - aShape.setExplode(ex); - dx = radius * ex * Math.cos(angle * Math.PI / 180); - dy = radius * ex * Math.sin(angle * Math.PI / 180); - } - List points = new ArrayList<>(); - points.add(new PointD(-radius + dx, -radius + dy)); - points.add(new PointD(-radius + dx, radius + dy)); - points.add(new PointD(radius + dx, radius + dy)); - points.add(new PointD(radius + dx, -radius + dy)); - points.add(new PointD(dx, dy)); - aShape.setPoints(points); - if (wedgeWidth != null) { - aShape.setWedgeWidth(wedgeWidth); - } - PolygonBreak pgb = new PolygonBreak(); - pgb.setColor(colors.get(i)); - if (drawEdge != null) { - pgb.setDrawOutline(drawEdge); - } - if (edgeColor != null) { - pgb.setOutlineColor(edgeColor); - } - if (lineWidth != null) { - pgb.setOutlineSize(lineWidth); - } - if (labels == null) { - if (autopct == null) { - label = ""; - } else { - label = String.format(autopct, v * 100); - } - } else { - label = labels.get(i); - if (autopct != null) { - pct = String.format(autopct, v * 100); - } - } - pgb.setCaption(label); - Graphic graphic = new Graphic(aShape, pgb); - gc.add(graphic); - ls.addLegendBreak(pgb); - - //Label text - if (!label.isEmpty()) { - ChartText ps = new ChartText(); - ldx = dx + radius * labelDis * Math.cos(angle * Math.PI / 180); - ldy = dy + radius * labelDis * Math.sin(angle * Math.PI / 180); - ps.setPoint(ldx, ldy); - ps.setText(label); - ps.setFont(labelFont); - ps.setColor(labelColor); - if (angle > 90 && angle < 270) { - ps.setXAlign(XAlign.RIGHT); - } - if (angle > 180 && angle < 360) { - ps.setYAlign(YAlign.TOP); - } - if (angle == 0 || angle == 180) { - ps.setYAlign(YAlign.CENTER); - } else if (angle == 90 || angle == 270) { - ps.setXAlign(XAlign.CENTER); - } - lgc.add(new Graphic(ps, new ColorBreak())); - } - - //pct text - if (pct != null) { - ChartText ps = new ChartText(); - ldx = dx + radius * pctDis * Math.cos(angle * Math.PI / 180); - ldy = dy + radius * pctDis * Math.sin(angle * Math.PI / 180); - ps.setPoint(ldx, ldy); - ps.setText(pct); - ps.setFont(labelFont); - ps.setColor(labelColor); - ps.setXAlign(XAlign.CENTER); - ps.setYAlign(YAlign.CENTER); - pgc.add(new Graphic(ps, new ColorBreak())); - } - - startAngle += sweepAngle; - i++; - } - gc.setSingleLegend(false); - gc.setLegendScheme(ls); - gc.getLabelSet().setLabelFont(labelFont); - gc.getLabelSet().setLabelColor(labelColor); - dx = radius * 0.1; - if (labels != null || autopct != null) { - Extent ext = gc.getExtent().extend(dx, dx); - gc.setExtent(ext); - } - - if (pct == null) { - if (lgc.isEmpty()) { - return new GraphicCollection[]{gc}; - } else { - return new GraphicCollection[]{gc, lgc}; - } - } else { - if (lgc.isEmpty()) { - return new GraphicCollection[]{gc, pgc}; - } else { - return new GraphicCollection[]{gc, lgc, pgc}; - } - } - } - - /** - * Create box graphics - * - * @param xdata X data array list - * @param positions Box position list - * @param widths Box width list - * @param showcaps Show caps or not - * @param showfliers Show fliers or not - * @param showmeans Show means or not - * @param showmedians Show medians or not - * @param boxBreak Box polygon break - * @param medianBreak Meandian line break - * @param whiskerBreak Whisker line break - * @param capBreak Whisker cap line break - * @param meanBreak Mean point break - * @param flierBreak Flier point break - * @return GraphicCollection - */ - public static GraphicCollection createBox(List xdata, List positions, List widths, - boolean showcaps, boolean showfliers, boolean showmeans, boolean showmedians, PolygonBreak boxBreak, - ColorBreak medianBreak, PolylineBreak whiskerBreak, PolylineBreak capBreak, - ColorBreak meanBreak, PointBreak flierBreak) { - GraphicCollection gc = new GraphicCollection(); - int n = xdata.size(); - if (positions == null) { - positions = new ArrayList<>(); - for (int i = 0; i < n; i++) { - positions.add(i + 1); - } - } - if (widths == null) { - widths = new ArrayList<>(); - for (int i = 0; i < n; i++) { - widths.add(0.5); - } - } - double v, width; - if (boxBreak == null) { - boxBreak = new PolygonBreak(); - boxBreak.setDrawFill(false); - boxBreak.setOutlineColor(Color.blue); - } - if (medianBreak == null) { - medianBreak = new PolylineBreak(); - medianBreak.setColor(Color.red); - } - if (whiskerBreak == null) { - whiskerBreak = new PolylineBreak(); - whiskerBreak.setColor(Color.black); - whiskerBreak.setStyle(LineStyles.DASH); - } - if (capBreak == null) { - capBreak = new PolylineBreak(); - capBreak.setColor(Color.black); - } - if (flierBreak == null) { - flierBreak = new PointBreak(); - flierBreak.setStyle(PointStyle.Plus); - } - if (meanBreak == null) { - meanBreak = new PointBreak(); - ((PointBreak) meanBreak).setStyle(PointStyle.Square); - ((PointBreak) meanBreak).setColor(Color.red); - ((PointBreak) meanBreak).setOutlineColor(Color.black); - } - - for (int i = 0; i < n; i++) { - Array a = xdata.get(i); - if (Double.isNaN(ArrayMath.min(a).doubleValue())) { - continue; - } - - v = positions.get(i).doubleValue(); - width = widths.get(i).doubleValue(); - //Add box polygon - double q1 = Statistics.quantile(a, 1); - double q3 = Statistics.quantile(a, 3); - double median = Statistics.quantile(a, 2); - double mind = ArrayMath.getMinimum(a); - double maxd = ArrayMath.getMaximum(a); - double mino = q1 - (q3 - q1) * 1.5; - double maxo = q3 + (q3 - q1) * 1.5; - List pList = new ArrayList<>(); - pList.add(new PointD(v - width * 0.5, q1)); - pList.add(new PointD(v - width * 0.5, q3)); - pList.add(new PointD(v + width * 0.5, q3)); - pList.add(new PointD(v + width * 0.5, q1)); - pList.add(new PointD(v - width * 0.5, q1)); - PolygonShape pgs = new PolygonShape(); - pgs.setPoints(pList); - gc.add(new Graphic(pgs, boxBreak)); - - //Add meadian line - if (showmedians) { - if (medianBreak.getBreakType() == BreakTypes.PolylineBreak) { - pList = new ArrayList<>(); - pList.add(new PointD(v - width * 0.5, median)); - pList.add(new PointD(v + width * 0.5, median)); - PolylineShape pls = new PolylineShape(); - pls.setPoints(pList); - gc.add(new Graphic(pls, medianBreak)); - } else { - PointShape ps = new PointShape(); - ps.setPoint(new PointD(v, median)); - gc.add(new Graphic(ps, medianBreak)); - } - } - - //Add low whisker line - double min = Math.max(mino, mind); - pList = new ArrayList<>(); - pList.add(new PointD(v, q1)); - pList.add(new PointD(v, min)); - PolylineShape pls = new PolylineShape(); - pls.setPoints(pList); - gc.add(new Graphic(pls, whiskerBreak)); - //Add cap - if (showcaps) { - pList = new ArrayList<>(); - pList.add(new PointD(v - width * 0.25, min)); - pList.add(new PointD(v + width * 0.25, min)); - pls = new PolylineShape(); - pls.setPoints(pList); - gc.add(new Graphic(pls, capBreak)); - } - //Add low fliers - if (showfliers) { - if (mino > mind) { - for (int j = 0; j < a.getSize(); j++) { - if (a.getDouble(j) < mino) { - PointShape ps = new PointShape(); - ps.setPoint(new PointD(v, a.getDouble(j))); - gc.add(new Graphic(ps, flierBreak)); - } - } - } - } - - //Add high whisker line - double max = Math.min(maxo, maxd); - pList = new ArrayList<>(); - pList.add(new PointD(v, q3)); - pList.add(new PointD(v, max)); - pls = new PolylineShape(); - pls.setPoints(pList); - gc.add(new Graphic(pls, whiskerBreak)); - //Add cap - if (showcaps) { - pList = new ArrayList<>(); - pList.add(new PointD(v - width * 0.25, max)); - pList.add(new PointD(v + width * 0.25, max)); - pls = new PolylineShape(); - pls.setPoints(pList); - gc.add(new Graphic(pls, capBreak)); - } - //Add high fliers - if (showfliers) { - if (maxo < maxd) { - for (int j = 0; j < a.getSize(); j++) { - if (a.getDouble(j) > maxo) { - PointShape ps = new PointShape(); - ps.setPoint(new PointD(v, a.getDouble(j))); - gc.add(new Graphic(ps, flierBreak)); - } - } - } - } - - //Add mean line - if (showmeans) { - double mean = ArrayMath.mean(a); - if (meanBreak.getBreakType() == BreakTypes.PointBreak) { - PointShape ps = new PointShape(); - ps.setPoint(new PointD(v, mean)); - gc.add(new Graphic(ps, meanBreak)); - } else { - pList = new ArrayList<>(); - pList.add(new PointD(v - width * 0.5, mean)); - pList.add(new PointD(v + width * 0.5, mean)); - pls = new PolylineShape(); - pls.setPoints(pList); - gc.add(new Graphic(pls, meanBreak)); - } - } - } - gc.setSingleLegend(false); - - return gc; - } - - /** - * Convert graphics from polar to cartesian coordinate - * - * @param graphics Graphics - */ - public static void polarToCartesian(GraphicCollection graphics) { - for (int m = 0; m < graphics.getNumGraphics(); m++) { - Graphic graphic = graphics.get(m); - for (int i = 0; i < graphic.getNumGraphics(); i++) { - Graphic gg = graphic.getGraphicN(i); - Shape shape = gg.getShape(); - List points = new ArrayList<>(); - for (PointD p : shape.getPoints()) { - double[] xy = MIMath.polarToCartesian(p.X, p.Y); - points.add(new PointD(xy[0], xy[1])); - } - shape.setPoints(points); - } - } - graphics.updateExtent(); - } - - /** - * Convert graphics from polar to cartesian coordinate - * - * @param graphics Graphics - */ - public static void polarToCartesian(GraphicCollection graphics, double bottom) { - for (int m = 0; m < graphics.getNumGraphics(); m++) { - Graphic graphic = graphics.get(m); - for (int i = 0; i < graphic.getNumGraphics(); i++) { - Graphic gg = graphic.getGraphicN(i); - Shape shape = gg.getShape(); - List points = new ArrayList<>(); - for (PointD p : shape.getPoints()) { - double[] xy = MIMath.polarToCartesian(p.X, p.Y + bottom); - points.add(new PointD(xy[0], xy[1])); - } - shape.setPoints(points); - } - } - graphics.updateExtent(); - } - - private static int findIndex(double[] values, double v) { - int idx = -1; - for (int i = 0; i < values.length; i++) { - if (i == values.length - 1) { - if (v == values[i]) { - idx = i; - break; - } - } else { - if (v == values[i] || v < values[i + 1]) { - idx = i; - break; - } - } - } - - return idx; - } - -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/GridLine.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/GridLine.java deleted file mode 100644 index 12f6188a..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/GridLine.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.plot; - -import org.meteoinfo.geometry.legend.LineStyles; - -import java.awt.Color; - -/** - * - * @author yaqiang - */ -public class GridLine { - // - private Color color; - private float size; - private LineStyles style; - private boolean drawXLine; - private boolean drawYLine; - private boolean drawZLine; - private boolean top; - // - // - /** - * Constructor - */ - public GridLine(){ - this.color = Color.LIGHT_GRAY; - this.size = 1.0f; - this.style = LineStyles.DASH; - this.drawXLine = false; - this.drawYLine = false; - this.drawZLine = false; - this.top = false; - } - - /** - * Constructor - * @param visible - */ - public GridLine(boolean visible) { - this(); - this.drawXLine = visible; - this.drawYLine = visible; - this.drawZLine = visible; - } - // - // - /** - * Get color - * @return Color - */ - public Color getColor(){ - return this.color; - } - - /** - * Set color - * @param value Color - */ - public void setColor(Color value){ - this.color = value; - } - - /** - * Get size - * @return Size - */ - public float getSize(){ - return this.size; - } - - /** - * Set size - * @param value Size - */ - public void setSize(float value) { - this.size = value; - } - - /** - * Get style - * @return Style - */ - public LineStyles getStyle(){ - return this.style; - } - - /** - * Set style - * @param value Style - */ - public void setStyle(LineStyles value){ - this.style = value; - } - - /** - * Get if draw x grid lines - * @return Boolean - */ - public boolean isDrawXLine(){ - return this.drawXLine; - } - - /** - * Set if draw x grid lines - * @param value Boolean - */ - public void setDrawXLine(boolean value){ - this.drawXLine = value; - } - - /** - * Get if draw y grid lines - * @return Boolean - */ - public boolean isDrawYLine(){ - return this.drawYLine; - } - - /** - * Set if draw y grid lines - * @param value Boolean - */ - public void setDrawYLine(boolean value){ - this.drawYLine = value; - } - - /** - * Get if draw z grid lines - * @return Boolean - */ - public boolean isDrawZLine(){ - return this.drawZLine; - } - - /** - * Set if draw z grid lines - * @param value Boolean - */ - public void setDrawZLine(boolean value){ - this.drawZLine = value; - } - - /** - * Return if the grid draw on the top of the graph - * @return Boolean - */ - public boolean isTop(){ - return this.top; - } - - /** - * Set if the grid draw on the top of the graph - * @param value Boolean - */ - public void setTop(boolean value){ - this.top = value; - } - // - // - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/MapPlot.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/MapPlot.java deleted file mode 100644 index 4239cdc7..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/MapPlot.java +++ /dev/null @@ -1,1314 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.plot; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics2D; -import java.awt.geom.Line2D; -import java.awt.geom.Rectangle2D; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import org.meteoinfo.chart.ChartNorthArrow; -import org.meteoinfo.chart.ChartPanel; -import org.meteoinfo.chart.ChartScaleBar; -import org.meteoinfo.chart.ChartText; -import org.meteoinfo.chart.Location; -import org.meteoinfo.chart.axis.LonLatAxis; -import org.meteoinfo.common.*; -import org.meteoinfo.data.Dataset; -import org.meteoinfo.data.mapdata.webmap.IWebMapPanel; -import org.meteoinfo.data.mapdata.webmap.TileLoadListener; -import org.meteoinfo.drawing.Draw; -import org.meteoinfo.geometry.graphic.Graphic; -import org.meteoinfo.geometry.graphic.GraphicCollection; -import org.meteoinfo.geometry.legend.*; -import org.meteoinfo.layer.LayerCollection; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.legend.MapFrame; -import org.meteoinfo.map.MapView; -import org.meteoinfo.projection.KnownCoordinateSystems; -import org.meteoinfo.projection.ProjectionInfo; -import org.meteoinfo.projection.ProjectionUtil; -import org.meteoinfo.projection.Reproject; -import org.meteoinfo.geometry.shape.*; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -/** - * - * @author wyq - */ -public class MapPlot extends AbstractPlot2D implements IWebMapPanel { - - // - private MapFrame mapFrame; - private MapView mapView; - private boolean antialias; - private MapLayer selectedLayer; - private final TileLoadListener tileLoadListener = new TileLoadListener(this); - private ChartPanel parent; - private float[] lonLim; - private float[] latLim; - private Graphic boundary; - private ChartScaleBar scaleBar; - private ChartNorthArrow northArrow; - private boolean degreeSpace = false; - - // - // - /** - * Constructor - */ - public MapPlot() { - super(); - this.antialias = false; - this.setAutoAspect(false); - try { - this.setXAxis(new LonLatAxis("Longitude", true)); - this.setYAxis(new LonLatAxis("Latitude", false)); - } catch (CloneNotSupportedException ex) { - Logger.getLogger(MapPlot.class.getName()).log(Level.SEVERE, null, ex); - } - this.getAxis(Location.TOP).setDrawTickLabel(false); - this.getAxis(Location.RIGHT).setDrawTickLabel(false); - this.setDrawNeatLine(true); - this.getGridLine().setTop(true); - } - - /** - * Constructor - * - * @param mapView MapView - */ - public MapPlot(MapView mapView) { - this(); - this.setMapView(mapView, true); - this.mapFrame = new MapFrame(); - this.mapFrame.setMapView(mapView); - } - - /** - * Constructor - * - * @param mapFrame MapFrame - */ - public MapPlot(MapFrame mapFrame) { - this(); - this.mapFrame = mapFrame; - this.setMapView(mapFrame.getMapView(), true); - } - - // - // - /** - * ChartPanel parent - * - * @param value ChartPanel - */ - public void setParent(ChartPanel value) { - this.parent = value; - } - - @Override - public Dataset getDataset() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public void setDataset(Dataset dataset) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - /** - * Get map view - * - * @return Map view - */ - public MapView getMapView() { - return this.mapView; - } - - /** - * Set map view - * - * @param value Map view - * @param isGeoMap If is geo map - */ - public void setMapView(MapView value, boolean isGeoMap) { - this.mapView = value; - this.mapView.setGeoMap(isGeoMap); - this.mapView.setMultiGlobalDraw(isGeoMap); - Extent extent = this.getAutoExtent(); - this.setDrawExtent(extent); - PolygonShape bvs = this.mapView.getProjection().getProjInfo().getBoundary(); - if (bvs != null) { - this.setBoundary(bvs); - } - } - - @Override - public PlotType getPlotType() { - return PlotType.XY2D; - } - - /** - * Get if is antialias - * - * @return Boolean - */ - public boolean isAntialias() { - return this.antialias; - } - - /** - * Set if is antialias - * - * @param value Boolean - */ - public void setAntialias(boolean value) { - this.antialias = value; - } - - /** - * Get background color - * - * @return Background color - */ - @Override - public Color getBackground() { - return this.mapView.getBackground(); - } - - /** - * Set background color - * - * @param value Background color - */ - @Override - public void setBackground(Color value) { - this.mapView.setBackground(value); - } - - /** - * Get map frame - * - * @return Map frame - */ - public MapFrame getMapFrame() { - return this.mapFrame; - } - - /** - * Set map frame - * - * @param value Map frame - */ - public void setMapFrame(MapFrame value) { - this.mapFrame = value; - this.setMapView(mapFrame.getMapView(), true); - } - - /** - * Get projection info - * - * @return Projection info - */ - public ProjectionInfo getProjInfo() { - return this.getMapView().getProjection().getProjInfo(); - } - - /** - * Set projection info - * @param proj Projection info - */ - public void setProjInfo(ProjectionInfo proj) { - this.getMapView().getProjection().setProjInfo(proj); - if (proj.getBoundary() != null) { - this.setBoundary(proj.getBoundary()); - } - } - - /** - * Is lon/lat map or not - * - * @return Boolean - */ - public boolean isLonLatMap() { - return this.getMapView().getProjection().isLonLatMap(); - } - - /** - * Get selected layer - * - * @return Selected layer - */ - public MapLayer getSelectedLayer() { - if (this.selectedLayer != null) { - return this.selectedLayer; - } else if (this.mapView.getLastAddedLayer() != null) { - return this.mapView.getLastAddedLayer(); - } else { - return null; - } - } - - /** - * Set selected layer - * - * @param value Selected layer - */ - public void setSelectedLayer(MapLayer value) { - this.selectedLayer = value; - } - - /** - * Get longitude limitations - * - * @return Longitude limitations - */ - public float[] getLonLim() { - return this.lonLim; - } - - /** - * Set longitude limitations - * - * @param value Longitude limitations - */ - public void setLonLim(float[] value) { - this.lonLim = value; - } - - /** - * Set longitude limitations - * - * @param lon1 Minimum longitude - * @param lon2 Maximum longitude - */ - public void setLonLim(float lon1, float lon2) { - this.lonLim = new float[]{lon1, lon2}; - } - - /** - * Get latitude limitations - * - * @return latitude limitations - */ - public float[] getLatLim() { - return this.latLim; - } - - /** - * Set latitude limitations - * - * @param value latitude limitations - */ - public void setLatLim(float[] value) { - this.latLim = value; - } - - /** - * Set latitude limitations - * - * @param lat1 Minimum latitude - * @param lat2 Maximum latitude - */ - public void setLatLim(float lat1, float lat2) { - this.latLim = new float[]{lat1, lat2}; - } - - /** - * Get map boundary - * - * @return Map boundary - */ - public Graphic getBoundary() { - return this.boundary; - } - - /** - * Set map boundary - * - * @param value Map boundary - */ - public void setBoundary(Graphic value) { - this.boundary = value; - } - - /** - * Set map boundary - * - * @param value Map boundary - */ - public void setBoundary(PolygonShape value) { - PolygonBreak pb = new PolygonBreak(); - pb.setOutlineSize(1.5f); - pb.setDrawFill(false); - this.boundary = new Graphic(value, pb); - } - - /** - * Set boundary property - * @param pb Boundary property - */ - public void setBoundaryProp(PolygonBreak pb) { - if (this.boundary != null) { - this.boundary = new Graphic(this.boundary.getShape(), pb); - } - } - - /** - * Get scale bar - * @return Scale bar - */ - public ChartScaleBar getScaleBar() { - return this.scaleBar; - } - - /** - * Set scale bar - * @param value Scale bar - */ - public void setScaleBar(ChartScaleBar value) { - this.scaleBar = value; - } - - /** - * Get north arrow - * @return North arrow - */ - public ChartNorthArrow getNorthArrow() { - return this.northArrow; - } - - /** - * Set north arrow - * @param value North arrow - */ - public void setNorthArrow(ChartNorthArrow value) { - this.northArrow = value; - } - - /** - * Get if using space between degree and E/W/S/N - * @return Boolean - */ - public boolean isDegreeSpace() { - return this.degreeSpace; - } - - /** - * Set if using space between degree and E/W/S/N - * @param value Boolean - */ - public void setDegreeSpace(boolean value) { - this.degreeSpace = value; - } - // - // - /** - * Check if has web map layer - * - * @return Boolean - */ - public boolean hasWebMapLayer() { - return this.mapView.hasWebMapLayer(); - } - - /** - * Get web map zoom - * - * @return Web map zoom - */ - @Override - public int getWebMapZoom() { - return this.mapView.getWebMapZoom(); - } - - @Override - public void reDraw() { - if (this.parent != null) { - this.parent.paintGraphics(); - } - } - - /** - * Draw plot - * - * @param g Graphics2D - * @param area Drawing area - */ - @Override - public void draw(Graphics2D g, Rectangle2D area) { - super.draw(g, area); - if (this.scaleBar != null) { - float x = (float) (area.getWidth() * this.scaleBar.getX()); - float y = (float) (area.getHeight() * (1 - this.scaleBar.getY())); - this.scaleBar.draw(g, x, y); - } - - if (this.northArrow != null) { - float x = (float) (area.getWidth() * this.northArrow.getX()); - float y = (float) (area.getHeight() * (1 - this.northArrow.getY())); - this.northArrow.draw(g, x, y); - } - } - - @Override - void drawGraph(Graphics2D g, Rectangle2D area) { - this.mapView.setAntiAlias(this.antialias); - this.mapView.setViewExtent((Extent) this.getDrawExtent().clone()); - if (this.boundary != null) { - PolygonBreak pb = (PolygonBreak)this.boundary.getLegend().clone(); - if (pb.isDrawFill()) { - pb.setDrawOutline(false); - this.mapView.drawGraphic(g, new Graphic(this.boundary.getShape(), pb), area.getBounds()); - //pb.setDrawOutline(true); - } - } - this.mapView.paintGraphics(g, area, this.tileLoadListener); - if (this.boundary != null) { - PolygonBreak pb = (PolygonBreak)this.boundary.getLegend().clone(); - pb.setDrawFill(false); - this.mapView.drawGraphic(g, new Graphic(this.boundary.getShape(), pb), area.getBounds()); - //pb.setDrawFill(true); - } - } - - /** - * Get auto extent - * - * @return Auto extent - */ - @Override - public Extent getAutoExtent() { - return this.mapView.getLayersWholeExtent(); - } - - @Override - public void setAutoExtent() { - - } - - @Override - public void updateLegendScheme() { - - } - - /** - * Add a graphic - * - * @param graphic The graphic - */ - public void addGraphic(Graphic graphic) { - this.getMapView().addGraphic(graphic); - } - - /** - * Add graphics - * @param graphics The graphics - */ - public void addGraphics(GraphicCollection graphics) { - for (int i = 0; i < graphics.getNumGraphics(); i++) { - this.getMapView().addGraphic(graphics.getGraphicN(i)); - } - } - - /** - * Add a graphic - * - * @param graphic The graphic - * @param proj The graphic projection - * @return Added graphic - */ - public Graphic addGraphic(Graphic graphic, ProjectionInfo proj) { - ProjectionInfo toProj = this.getMapView().getProjection().getProjInfo(); - if (proj.equals(toProj)) { - this.getMapView().addGraphic(graphic); - return graphic; - } else { - Graphic nGraphic = ProjectionUtil.projectGraphic(graphic, proj, toProj); - this.getMapView().addGraphic(nGraphic); - return nGraphic; - } - } - - /** - * Add graphics - * - * @param graphics The graphics - * @param proj The graphic projection - * @return Added graphics - */ - public GraphicCollection addGraphics(GraphicCollection graphics, ProjectionInfo proj) { - - ProjectionInfo toProj = this.getMapView().getProjection().getProjInfo(); - if (proj.equals(toProj)) { - for (int i = 0; i < graphics.getNumGraphics(); i++) - this.getMapView().addGraphic(graphics.getGraphicN(i)); - return graphics; - } else { - GraphicCollection nGraphics = new GraphicCollection(); - for (int i = 0; i < graphics.getNumGraphics(); i++) { - Graphic nGraphic = ProjectionUtil.projectGraphic(graphics.getGraphicN(i), proj, toProj); - nGraphics.add(nGraphic); - this.getMapView().addGraphic(nGraphic); - } - return nGraphics; - } - } - - /** - * Add a layer - * - * @param layer The layer - */ - public void addLayer(MapLayer layer) { - this.mapView.addLayer(layer); - this.setDrawExtent(layer.getExtent()); - } - - /** - * Add a layer - * - * @param idx Index - * @param layer Layer - */ - public void addLayer(int idx, MapLayer layer) { - this.mapView.addLayer(idx, layer); - this.setDrawExtent(layer.getExtent()); - } - - /** - * Remove last added layer - */ - public void removeLastLayer() { - this.mapView.removeLayer(this.mapView.getLastAddedLayer()); - } - - /** - * Set all axis visible or not - * - * @param value Boolean - */ - @Override - public void setAxisOn(boolean value) { - super.setAxisOn(value); - this.mapFrame.setDrawGridTickLine(value); - this.mapFrame.setDrawGridLabel(value); - } - - /** - * Get full extent - * - * @return Full extent - */ - public Extent getFullExtent() { - Extent ext = this.mapView.getExtent(); - if (this.boundary != null) { - ext = ext.union(this.boundary.getExtent().extend(0.01)); - } - - return ext; - } - - /** - * Set longitude/latitude extent - * - * @param extent Extent - */ - public void setLonLatExtent(Extent extent) { - if (this.getMapView().getProjection().isLonLatMap()) { - super.setDrawExtent(extent); - } else { - this.getMapView().zoomToExtentLonLatEx(extent); - super.setDrawExtent1(this.getMapView().getViewExtent()); - this.setAxisExtent(extent); - } - } - - /** - * Set axis extent - * - * @param extent Extent - */ - public void setAxisExtent(Extent extent) { - this.getAxis(Location.BOTTOM).setMinMaxValue(extent.minX, extent.maxX); - this.getAxis(Location.TOP).setMinMaxValue(extent.minX, extent.maxX); - this.getAxis(Location.LEFT).setMinMaxValue(extent.minY, extent.maxY); - this.getAxis(Location.RIGHT).setMinMaxValue(extent.minY, extent.maxY); - } - - @Override - public void addText(ChartText text) { - addText(text, true); - } - - public void addText(ChartText text, boolean isLonLat) { - if (isLonLat) { - if (this.getMapView().getProjection().isLonLatMap()) { - super.addText(text); - } else { - PointShape ps = new PointShape(); - PointD lonlatp = new PointD(text.getX(), text.getY()); - PointD xyp = Reproject.reprojectPoint(lonlatp, KnownCoordinateSystems.geographic.world.WGS1984, - this.getMapView().getProjection().getProjInfo()); - ps.setPoint(xyp); - LabelBreak lb = new LabelBreak(); - lb.setText(text.getText()); - lb.setFont(text.getFont()); - lb.setColor(text.getColor()); - Graphic aGraphic = new Graphic(ps, lb); - this.getMapView().addGraphic(aGraphic); - } - } else { - super.addText(text); - } - } - - /** - * Add point graphic - * - * @param lat Latitude - * @param lon Lontitude - * @param pb Point break - */ - public void addPoint(double lat, double lon, PointBreak pb) { - PointShape ps = new PointShape(); - PointD lonlatp = new PointD(lon, lat); - if (this.getMapView().getProjection().isLonLatMap()) { - ps.setPoint(lonlatp); - } else { - PointD xyp = Reproject.reprojectPoint(lonlatp, KnownCoordinateSystems.geographic.world.WGS1984, - this.getMapView().getProjection().getProjInfo()); - ps.setPoint(xyp); - } - Graphic aGraphic = new Graphic(ps, pb); - this.getMapView().addGraphic(aGraphic); - } - - /** - * Add point graphic - * - * @param lat Latitude - * @param lon Lontitude - * @param pb Point break - * @return Graphic - */ - public Graphic addPoint(List lat, List lon, PointBreak pb) { - double x, y; - PointShape ps; - PointD lonlatp, xyp; - for (int i = 0; i < lat.size(); i++) { - ps = new PointShape(); - x = lon.get(i).doubleValue(); - y = lat.get(i).doubleValue(); - lonlatp = new PointD(x, y); - if (this.getMapView().getProjection().isLonLatMap()) { - ps.setPoint(lonlatp); - } else { - xyp = Reproject.reprojectPoint(lonlatp, KnownCoordinateSystems.geographic.world.WGS1984, - this.getMapView().getProjection().getProjInfo()); - ps.setPoint(xyp); - } - Graphic aGraphic = new Graphic(ps, pb); - this.getMapView().addGraphic(aGraphic); - return aGraphic; - } - return null; - } - - /** - * Add polyline - * - * @param lat Latitude - * @param lon Longitude - * @param plb PolylineBreak - * @return Graphic - */ - public Graphic addPolyline(List lat, List lon, PolylineBreak plb) { - double x, y; - PolylineShape pls; - PointD lonlatp; - List points = new ArrayList<>(); - for (int i = 0; i < lat.size(); i++) { - x = lon.get(i).doubleValue(); - y = lat.get(i).doubleValue(); - if (Double.isNaN(x)) { - if (points.size() >= 2) { - pls = new PolylineShape(); - pls.setPoints(points); - Graphic aGraphic = new Graphic(pls, plb); - this.getMapView().addGraphic(aGraphic); - } - points = new ArrayList<>(); - } else { - lonlatp = new PointD(x, y); - if (!this.getMapView().getProjection().isLonLatMap()) { - lonlatp = Reproject.reprojectPoint(lonlatp, KnownCoordinateSystems.geographic.world.WGS1984, - this.getMapView().getProjection().getProjInfo()); - } - points.add(lonlatp); - } - } - if (points.size() >= 2) { - pls = new PolylineShape(); - pls.setPoints(points); - Graphic aGraphic = new Graphic(pls, plb); - this.getMapView().addGraphic(aGraphic); - return aGraphic; - } - return null; - } - - /** - * Add polyline - * - * @param lat Latitude - * @param lon Longitude - * @param plb PolylineBreak - * @param iscurve Is curve line or not - * @return Graphic - */ - public Graphic addPolyline(List lat, List lon, PolylineBreak plb, boolean iscurve) { - double x, y; - PolylineShape pls; - PointD lonlatp; - List points = new ArrayList<>(); - for (int i = 0; i < lat.size(); i++) { - x = lon.get(i).doubleValue(); - y = lat.get(i).doubleValue(); - if (Double.isNaN(x)) { - if (points.size() >= 2) { - if (iscurve) { - pls = new CurveLineShape(); - } else { - pls = new PolylineShape(); - } - pls.setPoints(points); - Graphic aGraphic = new Graphic(pls, plb); - this.getMapView().addGraphic(aGraphic); - } - points = new ArrayList<>(); - } else { - lonlatp = new PointD(x, y); - if (!this.getMapView().getProjection().isLonLatMap()) { - lonlatp = Reproject.reprojectPoint(lonlatp, KnownCoordinateSystems.geographic.world.WGS1984, - this.getMapView().getProjection().getProjInfo()); - } - points.add(lonlatp); - } - } - if (points.size() >= 2) { - if (iscurve) { - pls = new CurveLineShape(); - } else { - pls = new PolylineShape(); - } - pls.setPoints(points); - Graphic aGraphic = new Graphic(pls, plb); - this.getMapView().addGraphic(aGraphic); - return aGraphic; - } - return null; - } - - /** - * Add polygon - * - * @param lat Latitude - * @param lon Longitude - * @param pgb PolygonBreak - * @return Graphic - */ - public Graphic addPolygon(List lat, List lon, PolygonBreak pgb) { - double x, y; - PolygonShape pgs; - PointD lonlatp; - List points = new ArrayList<>(); - for (int i = 0; i < lat.size(); i++) { - x = lon.get(i).doubleValue(); - y = lat.get(i).doubleValue(); - if (Double.isNaN(x)) { - if (points.size() > 2) { - pgs = new PolygonShape(); - pgs.setPoints(points); - Graphic aGraphic = new Graphic(pgs, pgb); - this.getMapView().addGraphic(aGraphic); - } - points = new ArrayList<>(); - } else { - lonlatp = new PointD(x, y); - if (!this.getMapView().getProjection().isLonLatMap()) { - lonlatp = Reproject.reprojectPoint(lonlatp, KnownCoordinateSystems.geographic.world.WGS1984, - this.getMapView().getProjection().getProjInfo()); - } - points.add(lonlatp); - } - } - if (points.size() > 2) { - pgs = new PolygonShape(); - pgs.setPoints(points); - Graphic aGraphic = new Graphic(pgs, pgb); - this.getMapView().addGraphic(aGraphic); - return aGraphic; - } - return null; - } - - /** - * Add a circle - * - * @param x Center x - * @param y Center y - * @param radius - * @param pgb PolygonBreak - * @return Graphic - */ - public Graphic addCircle(float x, float y, float radius, PolygonBreak pgb) { - CircleShape aPGS = ShapeUtil.createCircleShape(x, y, radius); - Graphic graphic = new Graphic(aPGS, pgb); - this.mapView.addGraphic(graphic); - - return graphic; - } - -// /** -// * Add a layer -// * @param idx Index -// * @param layer Layer -// */ -// public void addLayer(int idx, MapLayer layer){ -// this.mapFrame.addLayer(idx, layer); -// } -// -// /** -// * Add a layer -// * @param layer Layer -// */ -// public void addLayer(MapLayer layer){ -// this.mapFrame.addLayer(layer); -// } -// -// /** -// * Set extent -// * -// * @param extent Extent -// */ -// public void setExtent(Extent extent) { -// this.mapFrame.getMapView().setViewExtent(extent); -// } - /** - * Get position area - * - * @param area Whole area - * @return Graphic area - */ - @Override - public Rectangle2D getPositionArea(Rectangle2D area) { - Rectangle2D plotArea = super.getPositionArea(area); - if (!this.isAutoAspect()) { - MapView mv = this.mapFrame.getMapView(); - mv.setViewExtent((Extent) this.getDrawExtent().clone()); - Extent extent = mv.getViewExtent(); - double width = extent.getWidth(); - double height = extent.getHeight(); - double scaleFactor = mv.getXYScaleFactor(); - if (width / height / scaleFactor > plotArea.getWidth() / plotArea.getHeight()) { - double h = plotArea.getWidth() * height * scaleFactor / width; - double delta = plotArea.getHeight() - h; - plotArea.setRect(plotArea.getX(), plotArea.getY() + delta / 2, plotArea.getWidth(), h); - } else { - double w = width * plotArea.getHeight() / height / scaleFactor; - double delta = plotArea.getWidth() - w; - plotArea.setRect(plotArea.getX() + delta / 2, plotArea.getY(), w, plotArea.getHeight()); - } - } - return plotArea; - } - -// @Override -// public void drawGraph(Graphics2D g, Rectangle2D area) { -// MapView mapView = this.mapFrame.getMapView(); -// mapView.setViewExtent(this.getDrawExtent()); -// Extent extent = mapView.getViewExtent(); -// double width = extent.getWidth(); -// double height = extent.getHeight(); -// double scaleFactor = mapView.getXYScaleFactor(); -// if (width / height / scaleFactor > area.getWidth() / area.getHeight()){ -// double h = area.getWidth() * height * scaleFactor / width; -// double delta = area.getHeight() - h; -// area.setRect(area.getX(), area.getY() + delta / 2, area.getWidth(), h); -// } else { -// double w = width * area.getHeight() / height / scaleFactor; -// double delta = area.getWidth() - w; -// area.setRect(area.getX() + delta / 2, area.getY(), w, area.getHeight()); -// } -// mapView.paintGraphics(g, area); -// } -// /** -// * Set draw extent -// * -// * @param extent Extent -// */ -// @Override -// public void setDrawExtent(Extent extent) { -// if (this.isLonLatMap()){ -// super.updateDrawExtent(); -// } else { -// ((ProjLonLatAxis)this.getAxis(Location.BOTTOM)).setX_Y(extent.minY); -// ((ProjLonLatAxis)this.getAxis(Location.TOP)).setX_Y(extent.maxY); -// ((ProjLonLatAxis)this.getAxis(Location.LEFT)).setX_Y(extent.minX); -// ((ProjLonLatAxis)this.getAxis(Location.RIGHT)).setX_Y(extent.maxX); -// super.setDrawExtent(extent); -// } -// } -// -// /** -// * Update draw extent -// */ -// @Override -// public void updateDrawExtent(){ -// if (this.isLonLatMap()){ -// super.updateDrawExtent(); -// } else { -// Extent extent = this.getDrawExtent(); -// ((ProjLonLatAxis)this.getAxis(Location.BOTTOM)).setX_Y(extent.minY); -// ((ProjLonLatAxis)this.getAxis(Location.TOP)).setX_Y(extent.maxY); -// ((ProjLonLatAxis)this.getAxis(Location.LEFT)).setX_Y(extent.minX); -// ((ProjLonLatAxis)this.getAxis(Location.RIGHT)).setX_Y(extent.maxX); -// super.updateDrawExtent(); -// } -// } - @Override - void drawAxis(Graphics2D g, Rectangle2D area) { - if (this.mapFrame.getMapView().getProjection().isLonLatMap()) { - super.drawAxis(g, area); - return; - } - - //Draw lon/lat grid labels - if (this.mapFrame.isDrawGridLabel()) { - final float shift = 5.0F; - List extentList = new ArrayList<>(); - Extent maxExtent = new Extent(); - Extent aExtent; - Dimension aSF; - g.setColor(this.mapFrame.getGridLineColor()); - g.setStroke(new BasicStroke(this.mapFrame.getGridLineSize())); - String drawStr; - PointF sP = new PointF(0, 0); - PointF eP = new PointF(0, 0); - Font font = this.getXAxis().getTickLabelFont(); - //Font font = new Font(this.mapFrame.getGridFont().getFontName(), this.mapFrame.getGridFont().getStyle(), (int) (this.mapFrame.getGridFont().getSize())); - g.setFont(font); - float labX, labY; - int len = mapFrame.getTickLineLength(); - int space = len + this.mapFrame.getGridLabelShift(); - if (mapFrame.isInsideTickLine()) { - space = mapFrame.getGridLabelShift(); - } - - Object[] objs; - float xShift, yShift; - XAlign xAlign; - YAlign yAlign; - for (int i = 0; i < mapFrame.getMapView().getGridLabels().size(); i++) { - GridLabel aGL = mapFrame.getMapView().getGridLabels().get(i); - switch (mapFrame.getGridLabelPosition()) { - case LEFT_BOTTOM: - switch (aGL.getLabDirection()) { - case East: - case North: - continue; - } - break; - case LEFT_UP: - switch (aGL.getLabDirection()) { - case East: - case South: - continue; - } - break; - case RIGHT_BOTTOM: - switch (aGL.getLabDirection()) { - case Weast: - case North: - continue; - } - break; - case RIGHT_UP: - switch (aGL.getLabDirection()) { - case Weast: - case South: - continue; - } - break; - } - - labX = (float) aGL.getLabPoint().X; - labY = (float) aGL.getLabPoint().Y; - labX = labX + (float) area.getX(); - labY = labY + (float) area.getY(); - sP.X = labX; - sP.Y = labY; - - drawStr = aGL.getLabString(); - //if (this.drawDegreeSymbol) { - if (drawStr.endsWith("E") || drawStr.endsWith("W") || drawStr.endsWith("N") || drawStr.endsWith("S")) { - if (this.degreeSpace) { - drawStr = drawStr.substring(0, drawStr.length() - 1) + String.valueOf((char) 186) + - " " + drawStr.substring(drawStr.length() - 1); - } else { - drawStr = drawStr.substring(0, drawStr.length() - 1) + String.valueOf((char) 186) + - drawStr.substring(drawStr.length() - 1); - } - } else { - drawStr = drawStr + String.valueOf((char) 186); - } - //} - aSF = Draw.getStringDimension(drawStr, g); - boolean ifDraw = true; - aExtent = new Extent(); - aExtent.minX = labX; - aExtent.maxX = labX + aSF.width; - aExtent.minY = labY - aSF.height; - aExtent.maxY = labY; - - //Judge extent - if (extentList.isEmpty()) { - maxExtent = (Extent) aExtent.clone(); - extentList.add((Extent) aExtent.clone()); - } else if (!MIMath.isExtentCross(aExtent, maxExtent)) { - extentList.add((Extent) aExtent.clone()); - maxExtent = MIMath.getLagerExtent(maxExtent, aExtent); - } else { - for (int j = 0; j < extentList.size(); j++) { - if (MIMath.isExtentCross(aExtent, extentList.get(j))) { - ifDraw = false; - break; - } - } - if (ifDraw) { - extentList.add(aExtent); - maxExtent = MIMath.getLagerExtent(maxExtent, aExtent); - } - } - if (ifDraw) { - if (aGL.isBorder()) { - switch (aGL.getLabDirection()) { - case South: - labX = labX - aSF.width / 2; - labY = labY + aSF.height * 3 / 4 + space; - eP.X = sP.X; - if (mapFrame.isInsideTickLine()) { - eP.Y = sP.Y - len; - } else { - eP.Y = sP.Y + len; - } - break; - case Weast: - labX = labX - aSF.width - space; - labY = labY + aSF.height / 3; - eP.Y = sP.Y; - if (mapFrame.isInsideTickLine()) { - eP.X = sP.X + len; - } else { - eP.X = sP.X - len; - } - break; - case North: - labX = labX - aSF.width / 2; - //labY = labY - aSF.height / 3 - space; - labY = labY - space; - eP.X = sP.X; - if (mapFrame.isInsideTickLine()) { - eP.Y = sP.Y + len; - } else { - eP.Y = sP.Y - len; - } - break; - case East: - labX = labX + space; - labY = labY + aSF.height / 3; - eP.Y = sP.Y; - if (mapFrame.isInsideTickLine()) { - eP.X = sP.X - len; - } else { - eP.X = sP.X + len; - } - break; - } - g.setColor(mapFrame.getGridLineColor()); - g.draw(new Line2D.Float(sP.X, sP.Y, eP.X, eP.Y)); - g.setColor(this.getXAxis().getTickLabelColor()); - g.drawString(drawStr, labX, labY); - } else { - g.setColor(this.getXAxis().getTickLabelColor()); - objs = this.getProjInfo().checkGridLabel(aGL, shift); - xShift = (float)objs[0]; - yShift = (float)objs[1]; - xAlign = (XAlign)objs[2]; - yAlign = (YAlign)objs[3]; - Draw.drawString(g, labX+xShift, labY+yShift, drawStr, xAlign, yAlign, false); - } - } - } - } - } - - @Override - int getXAxisHeight(Graphics2D g) { - if (this.isLonLatMap()) { - return super.getXAxisHeight(g); - } - - int space = 4; - if (this.mapFrame.isDrawGridLabel()) { - int height = space; - height += mapFrame.getTickLineLength() + mapFrame.getGridLabelShift(); - FontMetrics m = g.getFontMetrics(mapFrame.getGridFont()); - height += m.getHeight(); - return height; - } - - return 0; - } - - @Override - int getYAxisWidth(Graphics2D g) { - if (this.isLonLatMap()) { - return super.getYAxisWidth(g); - } - - int space = 4; - if (this.mapFrame.isDrawGridLabel()) { - int width = space; - width += mapFrame.getTickLineLength() + mapFrame.getGridLabelShift(); - FontMetrics m = g.getFontMetrics(mapFrame.getGridFont()); - List labels = mapFrame.getMapView().getGridLabels(); - int labWidth = 0, w; - for (int i = 0; i < labels.size(); i++) { - w = m.stringWidth(labels.get(i).getLabString()); - if (w > labWidth) { - labWidth = w; - } - } - width += labWidth; - return width; - } - - return 0; - } - - /** - * Get layer number - * - * @return Layer number - */ - public int getLayerNum() { - return this.mapView.getLayerNum(); - } - - /** - * Get layers - * - * @return Layers - */ - public LayerCollection getLayers() { - return this.mapView.getLayers(); - } - - /** - * Get layer by index - * - * @param i The layer index - * @return The layer - */ - public MapLayer getLayer(int i) { - return this.mapView.getLayers().get(i); - } - - /** - * Get layer by name - * - * @param name The layer name - * @return The layer - */ - public MapLayer getLayer(String name) { - return this.mapView.getLayer(name); - } - - /** - * Get legend scheme - * - * @return Legend scheme - */ - public LegendScheme getLegendScheme() { - MapLayer layer = this.mapView.getLastAddedLayer(); - return layer == null ? null : layer.getLegendScheme(); - } - - /** - * Load MeteoInfo project file - * - * @param fn MeteoInfo project file name - * @param mfidx Map frame index - * @throws org.xml.sax.SAXException - * @throws java.io.IOException - * @throws javax.xml.parsers.ParserConfigurationException - */ - public void loadMIProjectFile(String fn, int mfidx) throws SAXException, IOException, ParserConfigurationException { - File file = new File(fn); - String userDir = System.getProperty("user.dir"); - System.setProperty("user.dir", file.getParent()); - String pPath = file.getParent(); - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); - Document doc = db.parse(new File(fn)); - - Element root = doc.getDocumentElement(); - - Element mapFrames = (Element) root.getElementsByTagName("MapFrames").item(0); - if (mapFrames == null) { - this.mapFrame.importProjectXML(pPath, root); - } else { - NodeList mfNodes = mapFrames.getElementsByTagName("MapFrame"); - Node mfNode = mfNodes.item(mfidx); - this.mapFrame.importProjectXML(pPath, (Element) mfNode); - } - this.setDrawExtent(this.mapView.getViewExtent()); - this.setExtent(this.mapView.getViewExtent()); - System.setProperty("user.dir", userDir); - } - - /** - * Load MeteoInfo project file - * - * @param fn MeteoInfo project file name - * @throws org.xml.sax.SAXException - * @throws java.io.IOException - * @throws javax.xml.parsers.ParserConfigurationException - */ - public void loadMIProjectFile(String fn) throws SAXException, IOException, ParserConfigurationException { - this.loadMIProjectFile(fn, 0); - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/PiePlot.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/PiePlot.java deleted file mode 100644 index 13fbd7bb..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/PiePlot.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.plot; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Graphics2D; -import java.awt.geom.AffineTransform; -import java.awt.geom.Rectangle2D; - -import org.meteoinfo.common.PointF; -import org.meteoinfo.drawing.Draw; -import org.meteoinfo.geometry.legend.ColorBreak; -import org.meteoinfo.geometry.legend.PolygonBreak; -import org.meteoinfo.geometry.shape.ArcShape; -import org.meteoinfo.geometry.graphic.Graphic; -import org.meteoinfo.geometry.graphic.GraphicCollection; -import org.meteoinfo.geometry.shape.Shape; - -/** - * - * @author Yaqiang Wang - */ -public class PiePlot extends Plot2D { - - // - // - // - /** - * Constructor - */ - public PiePlot(){ - super(); - this.setAutoAspect(false); - } - // - // - // - // - @Override - void drawGraph(Graphics2D g, Rectangle2D area) { - AffineTransform oldMatrix = g.getTransform(); - //Rectangle oldRegion = g.getClipBounds(); - //g.setClip(area); - g.translate(area.getX(), area.getY()); - - //Draw background - if (this.background != null) { - 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); - ColorBreak cb = graphic.getLegend(); - float dist = 5; - float ex = this.getExplode(); - Font labelFont = ((GraphicCollection)graphic).getLabelSet().getLabelFont(); - Color labelColor = ((GraphicCollection)graphic).getLabelSet().getLabelColor(); - for (int i = 0; i < graphic.getNumGraphics(); i++) { - Graphic gg = graphic.getGraphicN(i); - if (!graphic.isSingleLegend()) { - cb = gg.getLegend(); - } - Shape shape = gg.getShape(); - this.drawArc(g, (ArcShape) shape, (PolygonBreak) cb, area, dist, ex, labelFont, - labelColor); - } - } - - g.setTransform(oldMatrix); - //g.setClip(oldRegion); - } - - private float getExplode() { - Graphic graphic = this.getGraphics().get(0); - float ex = 0; - for (int i = 0; i < graphic.getNumGraphics(); i++) { - Graphic gg = graphic.getGraphicN(i); - ArcShape shape = (ArcShape) gg.getShape(); - if (shape.getExplode() > 0) { - ex = 10; - break; - } - } - return ex; - } - - private void drawArc(Graphics2D g, ArcShape aShape, PolygonBreak aPGB, - Rectangle2D area, float dist, float ex, Font labelFont, Color labelColor) { - float startAngle = aShape.getStartAngle(); - float sweepAngle = aShape.getSweepAngle(); - float angle = startAngle + sweepAngle / 2; - float space = 20; - Rectangle2D rect = new Rectangle2D.Double(area.getX() + ex + space, area.getY() + ex + space, area.getWidth() - ex - space, - area.getHeight() - ex - space); - double dx = 0, dy = 0; - if (aShape.getExplode() > 0) { - dx = ex * Math.cos((360 - angle) * Math.PI / 180); - 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()); - Draw.drawPie(new PointF(sx, sy), (float) rect.getWidth(), (float) rect.getHeight(), - startAngle, sweepAngle, aPGB, g); - - //Draw label - //Rectangle clip = g.getClipBounds(); - //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)); - String label = aPGB.getCaption(); - if (angle > 360) { - angle = angle - 360; - } - float r = (float) (rect.getWidth() * 0.5) + dist; - PointF lPoint = Draw.getPieLabelPoint(sPoint, r, angle); - x = lPoint.X; - y = lPoint.Y; - Dimension dim = Draw.getStringDimension(label, g); - h = dim.height; - w = dim.width; - if ((angle >= 0 && angle < 45)) { - //x = x + dis; - y = y - h; - } else if (angle >= 45 && angle < 90) { - //y = y - dis; - } else if (angle >= 90 && angle < 135) { - x = x - w; - //y = y - dis; - } else if (angle >= 135 && angle < 225) { - x = x - w - 3; - y = y + h / 2; - } else if (angle >= 225 && angle < 270) { - x = x - w / 2; - y = y + h; - } else if (angle >= 270 && angle < 315) { - //x = x + dis; - y = y + h; - } else { - //x = x + dis; - y = y + h / 2; - } - g.setFont(labelFont); - g.setColor(labelColor); - //g.drawOval((int)(x - 3), (int)(y - 3), 6, 6); - g.drawString(label, x, y); - - //if (clip != null) { - // g.setClip(clip); - //} - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/Plot.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/Plot.java deleted file mode 100644 index abb7e6b3..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/Plot.java +++ /dev/null @@ -1,498 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.plot; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.Paint; -import java.awt.Shape; -import java.awt.Stroke; -import java.awt.geom.Ellipse2D; -import java.awt.geom.Rectangle2D; -import java.util.List; -import org.meteoinfo.chart.Margin; -import org.meteoinfo.data.Dataset; - -/** - * - * @author yaqiang - */ -public abstract class Plot { - - /** The default outline stroke. */ - public static final Stroke DEFAULT_OUTLINE_STROKE = new BasicStroke(0.5f, - BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); - - /** The default outline color. */ - public static final Paint DEFAULT_OUTLINE_PAINT = Color.gray; - - /** The default foreground alpha transparency. */ - public static final float DEFAULT_FOREGROUND_ALPHA = 1.0f; - - /** The default background alpha transparency. */ - public static final float DEFAULT_BACKGROUND_ALPHA = 1.0f; - - /** The default background color. */ - public static final Paint DEFAULT_BACKGROUND_PAINT = Color.white; - - /** The minimum width at which the plot should be drawn. */ - public static final int MINIMUM_WIDTH_TO_DRAW = 10; - - /** The minimum height at which the plot should be drawn. */ - public static final int MINIMUM_HEIGHT_TO_DRAW = 10; - - /** A default box shape for legend items. */ - public static final Shape DEFAULT_LEGEND_ITEM_BOX - = new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0); - - /** A default circle shape for legend items. */ - public static final Shape DEFAULT_LEGEND_ITEM_CIRCLE - = new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0); - - protected Rectangle2D position = new Rectangle2D.Double(0.13, 0.11, 0.775, 0.815); - protected Rectangle2D outerPosition = new Rectangle2D.Double(0, 0, 1, 1); - private Rectangle2D outerPositionArea; - private Margin tightInset = new Margin(); - - /** If is sub plot. */ - public boolean isSubPlot = false; - - /** Column index as a sub plot. */ - public int columnIndex = 0; - - /** Row index as a sub plot. */ - public int rowIndex = 0; - - private boolean outerPosActive = true; - private boolean sameShrink = false; - - //units - normalized or pixels - protected AxesUnits units = AxesUnits.NORMALIZED; - - protected boolean symbolAntialias = true; - - /** - * Get units - * @return Units - */ - public AxesUnits getUnits(){ - return this.units; - } - - /** - * Set units - * @param value Units - */ - public void setUnits(AxesUnits value){ - this.units = value; - } - - /** - * Set units - * @param value Units - */ - public void setUnits(String value){ - this.units = AxesUnits.valueOf(value.toUpperCase()); - } - - /** - * Get if Outer position active - * @return Boolean - */ - public boolean isOuterPosActive(){ - return this.outerPosActive; - } - - /** - * Set outer position active or not - * @param value Boolean - */ - public void setOuterPosActive(boolean value){ - this.outerPosActive = value; - } - - /** - * Get if same shrink - * @return Boolean - */ - public boolean isSameShrink(){ - return this.sameShrink; - } - - /** - * Set if same shrink - * @param value Boolean - */ - public void setSameShrink(boolean value){ - this.sameShrink = value; - } - - /** - * Get position - * @return Position - */ - public Rectangle2D getPosition(){ - return this.position; - } - - /** - * Set position - * @param value Position - */ - public void setPosition(Rectangle2D value){ - this.position = value; - } - - /** - * Set position - * @param xmin Minimum x - * @param ymin Minimum y - * @param width Width - * @param height Height - */ - public void setPosition(double xmin, double ymin, double width, double height){ - this.position = new Rectangle2D.Double(xmin, ymin, width, height); - } - - /** - * Set position - * @param pos Position list - */ - public void setPosition(List pos){ - this.position = new Rectangle2D.Double(pos.get(0).doubleValue(), pos.get(1).doubleValue(), - pos.get(2).doubleValue(), pos.get(3).doubleValue()); - } - - /** - * Update position - * @param figureArea Figure area - * @param outerArea Outer position area - */ - public void updatePosition(Rectangle2D figureArea, Rectangle2D outerArea){ - double x = outerArea.getX() / figureArea.getWidth(); - double y = 1.0 - ((outerArea.getY() - figureArea.getY()) + outerArea.getHeight()) / figureArea.getHeight(); - double w = outerArea.getWidth() / figureArea.getWidth(); - double h = outerArea.getHeight() / figureArea.getHeight(); - this.setPosition(x, y, w, h); - } - - /** - * Update position - * @param figureArea Figure areaa - */ - public void updatePosition(Rectangle2D figureArea){ - double x = this.positionArea.getX() / figureArea.getWidth(); - double y = 1.0 - (this.positionArea.getY() + this.positionArea.getHeight()) / figureArea.getHeight(); - double w = this.positionArea.getWidth() / figureArea.getWidth(); - double h = this.positionArea.getHeight() / figureArea.getHeight(); - this.setPosition(x, y, w, h); - } - - /** - * Get tight inset - * @return Tight inset - */ - public Margin getTightInset(){ - return this.tightInset; - } - - /** - * Set tight inset - * @param value Tight inset - */ - public void setTightInset(Margin value){ - this.tightInset = value; - } - - /** - * Get outer position - * @return Outer position - */ - public Rectangle2D getOuterPosition(){ - return this.outerPosition; - } - - /** - * Set outer postion - * @param value Outer position - */ - public void setOuterPosition(Rectangle2D value){ - this.outerPosition = value; - } - - /** - * Set outer position - * @param xmin Minimum x - * @param ymin Minimum y - * @param width Width - * @param height Height - */ - public void setOuterPosition(double xmin, double ymin, double width, double height){ - this.outerPosition = new Rectangle2D.Double(xmin, ymin, width, height); - } - - /** - * Set outer position - * @param pos Outer position list - */ - public void setOuterPosition(List pos){ - this.position = new Rectangle2D.Double(pos.get(0).doubleValue(), pos.get(1).doubleValue(), - pos.get(2).doubleValue(), pos.get(3).doubleValue()); - } - - /** - * Get outer position area - * @return Outer positoin area - */ - public Rectangle2D getOuterPositionArea(){ - return this.outerPositionArea; - } - - /** - * Get outer position area - * @param area Whole area - * @return Outer position area - */ - public abstract Rectangle2D getOuterPositionArea(Rectangle2D area); - - /** - * Set outer position area - * @param value Outer position area - */ - public void setOuterPositionArea(Rectangle2D value){ - this.outerPositionArea = value; - } - - /** - * Get dataset - * @return Dataset - */ - public abstract Dataset getDataset(); - - /** - * Set dataset - * @param dataset Dataset - */ - public abstract void setDataset(Dataset dataset); - - /** - * Get plot type - * @return Plot type - */ - public abstract PlotType getPlotType(); - - /** - * Get symbol antialias - * @return Boolean - */ - public boolean isSymbolAntialias() { - return this.symbolAntialias; - } - - /** - * Set symbol antialias - * @param value Boolean - */ - public void setSymbolAntialias(boolean value) { - this.symbolAntialias = value; - } - - /** - * Draw graphics - * @param g2 Graphics2D - * @param area Graphics area - */ - public abstract void draw(Graphics2D g2, Rectangle2D area); - - protected Rectangle2D positionArea = new Rectangle2D.Double(); - - /** - * Get position area - * @return position area - */ - public Rectangle2D getPositionArea() { - return this.positionArea; - } - - /** - * Get position area - * @param zoom Zoom - * @return Position area - */ - public Rectangle2D getPositionArea(double zoom) { - double w = this.positionArea.getWidth() * zoom; - double h = this.positionArea.getHeight() * zoom; - double xshift = (this.positionArea.getWidth() - w) / 2.0; - double yshift = (this.positionArea.getHeight() - h) / 2.0; - double x = this.positionArea.getX() + xshift; - double y = this.positionArea.getY() + yshift; - - return new Rectangle2D.Double(x, y, w, h); - } - - /** - * Set position area - * @param value Position area - */ - public void setPositionArea(Rectangle2D value){ - this.positionArea = value; - } - - private Rectangle2D graphArea = new Rectangle2D.Double(); - - /** - * Get graph area - * @return Graph area - */ - public Rectangle2D getGraphArea(){ - return graphArea; - } - - /** - * Set graph area - * @param value Graph area - */ - public void setGraphArea(Rectangle2D value){ - graphArea = value; - } - - /** - * Get position area - * @param area Figure area - * @return Position area - */ - public Rectangle2D getPositionArea(Rectangle2D area) { - if (this.units == AxesUnits.NORMALIZED) { - double x = area.getWidth() * this.getPosition().getX() + area.getX(); - double y = area.getHeight() * (1 - this.getPosition().getHeight() - this.getPosition().getY()) + area.getY(); - double w = area.getWidth() * this.getPosition().getWidth(); - double h = area.getHeight() * this.getPosition().getHeight(); - return new Rectangle2D.Double(x, y, w, h); - } else { - double x = this.position.getX() + area.getX(); - double y = area.getHeight() - this.position.getY() - this.position.getHeight(); - double w = this.position.getWidth(); - double h = this.position.getHeight(); - return new Rectangle2D.Double(x, y, w, h); - } - } - - /** - * Get tight inset - * @param g Graphics2D - * @param positionArea Position area - * @return Tight inset margin - */ - public abstract Margin getTightInset(Graphics2D g, Rectangle2D positionArea); - - private double positionAreaZoom = 1.0; - - /** - * Get position area zoom - * @return Position area zoom - */ - public double getPositionAreaZoom(){ - return this.positionAreaZoom; - } - - /** - * Set position area zoom - * @param value Position area zoom - */ - public void setPositionAreaZoom(double value){ - this.positionAreaZoom = value; - } - - /** - * Get plot shrink - * @return Plot shrink - */ - public Margin getPlotShrink(){ - Margin shrink = new Margin(); - if (this.tightInset.getLeft() + this.outerPositionArea.getX() > this.positionArea.getX()){ - shrink.setLeft(this.tightInset.getLeft() + this.outerPositionArea.getX() - this.positionArea.getX()); - } - if (this.tightInset.getRight()+ this.positionArea.getX() + this.positionArea.getWidth() > - this.outerPositionArea.getX() + this.outerPositionArea.getWidth()){ - shrink.setRight(this.tightInset.getRight()+ this.positionArea.getX() + this.positionArea.getWidth() - - (this.outerPositionArea.getX() + this.outerPositionArea.getWidth())); - } - if (this.tightInset.getTop()+ this.outerPositionArea.getY()> this.positionArea.getY()){ - shrink.setTop(this.tightInset.getTop()+ this.outerPositionArea.getY()- this.positionArea.getY()); - } - if (this.tightInset.getBottom()+ this.positionArea.getY()+ this.positionArea.getHeight()> - this.outerPositionArea.getY() + this.outerPositionArea.getHeight()){ - shrink.setBottom(this.tightInset.getBottom()+ this.positionArea.getY()+ this.positionArea.getHeight() - - (this.outerPositionArea.getY() + this.outerPositionArea.getHeight())); - } - - return shrink; - } - - /** - * Set plot shrink - * @param shrink Shrink - */ - public void setPlotShrink(Margin shrink){ - if (this.positionArea == null) - return; - - double x = this.positionArea.getX() + shrink.getLeft(); - double y = this.positionArea.getY() + shrink.getTop(); - double w = this.positionArea.getWidth() - (shrink.getLeft() + shrink.getRight()); - double h = this.positionArea.getHeight() - (shrink.getTop() + shrink.getBottom()); - - this.positionArea = new Rectangle2D.Double(x, y, w, h); - } - - /** - * Update position area zoom - * @return Position area zoom - */ - public double updatePostionAreaZoom(){ - Rectangle2D tightInsetArea = this.tightInset.getArea(this.positionArea); - double left = tightInsetArea.getX() - this.outerPositionArea.getX(); - double right = this.outerPositionArea.getX() + this.outerPositionArea.getWidth() - - (tightInsetArea.getX() + tightInsetArea.getWidth()); - double top = tightInsetArea.getY() - this.outerPositionArea.getY(); - double bottom = this.outerPositionArea.getY() + this.outerPositionArea.getHeight() - - (tightInsetArea.getY() + tightInsetArea.getHeight()); - double minh = Math.min(left, right); - double minv = Math.min(top, bottom); - double min = Math.min(minh, minv); - double zoom = 1.0; - double factor = 2; - //if (this.isSubPlot) - // factor = 1.5; - if (min < 0){ - double zoomh = 1.0; - if (minh < 0) - zoomh = (this.positionArea.getWidth() - Math.abs(minh) * factor) / this.positionArea.getWidth(); - double zoomv = 1.0; - if (minv < 0) - zoomv = (this.positionArea.getHeight() - Math.abs(minv) * factor) / this.positionArea.getHeight(); - zoom = Math.min(zoomh, zoomv); - if (zoom < 0){ - zoom = 0.2; - } - } - - return zoom; - } - - /** - * Update position area - */ - public void updatePositionArea(){ - double w = this.outerPositionArea.getWidth() - this.tightInset.getLeft() - this.tightInset.getRight(); - double h = this.outerPositionArea.getHeight() - this.tightInset.getTop() - this.tightInset.getBottom(); - double x = this.outerPositionArea.getX() + this.tightInset.getLeft(); - double y = this.outerPositionArea.getY() + this.tightInset.getTop(); - - this.positionArea = new Rectangle2D.Double(x, y, w, h); - } -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/Plot2D.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/Plot2D.java deleted file mode 100644 index 1024ebf4..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/Plot2D.java +++ /dev/null @@ -1,1245 +0,0 @@ -/* Copyright 2016 - Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.chart.plot; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.RenderingHints; -import java.awt.TexturePaint; -import java.awt.geom.AffineTransform; -import java.awt.geom.GeneralPath; -import java.awt.geom.Line2D; -import java.awt.geom.Rectangle2D; -import java.awt.geom.RectangularShape; -import java.awt.geom.RoundRectangle2D; -import java.awt.image.BufferedImage; -import java.util.ArrayList; -import java.util.List; -import org.meteoinfo.chart.ChartLegend; -import org.meteoinfo.chart.ChartText; -import org.meteoinfo.chart.axis.LogAxis; -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.drawing.Draw; -import static org.meteoinfo.drawing.Draw.getHatchImage; - -import org.meteoinfo.geometry.graphic.Graphic; -import org.meteoinfo.geometry.graphic.GraphicCollection; -import org.meteoinfo.geometry.graphic.ImageGraphic; -import org.meteoinfo.geometry.legend.*; -import org.meteoinfo.geoprocess.GeometryUtil; -import org.meteoinfo.geometry.shape.*; -import org.meteoinfo.shape.PolylineErrorShape; - -/** - * - * @author Yaqiang Wang - */ -public class Plot2D extends AbstractPlot2D { - - // - private GraphicCollection graphics; - private float barsWidth = 0.8f; - - // - // - public Plot2D() { - super(); - this.graphics = new GraphicCollection(); - } - - // - // - /** - * Get graphics - * - * @return Graphics - */ - public GraphicCollection getGraphics() { - return this.graphics; - } - - /** - * Get the number of graphics - * @return The number of graphics - */ - public int getGraphicNumber() { - return this.graphics.size(); - } - - /** - * Set graphics - * - * @param value Graphics - */ - public void setGraphics(GraphicCollection value) { - this.graphics = value; - } - - /** - * Get bars width (0 - 1), only used for automatic bar width. - * @return Bars width - */ - public float getBarsWidth(){ - return this.barsWidth; - } - - /** - * Set bars width (0 - 1), only used for automatic bar width. - * @param value Bars width - */ - public void setBarsWidth(float value){ - this.barsWidth = value; - } - - // - // - /** - * Add a graphic - * - * @param g Grahic - */ - public void addGraphic(Graphic g) { - this.graphics.add(g); - } - - /** - * Add a graphic by index - * - * @param idx Index - * @param g Graphic - */ - public void addGraphic(int idx, Graphic g) { - this.graphics.add(idx, g); - } - - /** - * Remove a graphic - * - * @param g Graphic - */ - public void removeGraphic(Graphic g) { - this.graphics.remove(g); - } - - /** - * Remove a graphic by index - * - * @param idx Index - */ - public void removeGraphic(int idx) { - this.graphics.remove(idx); - } - - /** - * Remove last graphic - */ - public void removeLastGraphic() { - this.graphics.remove(this.graphics.size() - 1); - } - - /** - * Add graphic list - * - * @param gs Graphic list - */ - public void addGraphics(List gs) { - this.graphics.addAll(gs); - } - - @Override - void drawGraph(Graphics2D g, Rectangle2D area) { - if (isPiePlot()){ - plotPie(g, area); - } else - plotGraphics(g, area); - } - - private boolean isPiePlot(){ - boolean isPie = false; - int n = 0; - for (int m = 0; m < this.graphics.getNumGraphics(); m++) { - Graphic graphic = this.graphics.get(m).getGraphicN(0); - ShapeTypes st = graphic.getShape().getShapeType(); - switch (st){ - case ARC: - isPie = true; - n += 1; - break; - } - } - //return isPie && n == 1; - return isPie; - } - - void plotPie(Graphics2D g, Rectangle2D area){ - AffineTransform oldMatrix = g.getTransform(); - g.translate(area.getX(), area.getY()); - - //Draw background - if (this.background != null) { - g.setColor(this.getBackground()); - g.fill(new Rectangle2D.Double(0, 0, area.getWidth(), area.getHeight())); - } - - for (int m = 0; m < this.graphics.getNumGraphics(); m++) { - Graphic graphic = this.graphics.get(m); - ColorBreak cb = graphic.getLegend(); - for (int i = 0; i < graphic.getNumGraphics(); i++) { - Graphic gg = graphic.getGraphicN(i); - if (!graphic.isSingleLegend()) { - cb = gg.getLegend(); - } - Shape shape = gg.getShape(); - switch (shape.getShapeType()) { - case Point: - case PointM: - case PointZ: - this.drawPoint(g, (PointShape) shape, (PointBreak) cb, area); - break; - case TEXT: - this.drawText((ChartText)shape, g, area); - break; - case Polyline: - case PolylineZ: - if (cb instanceof PointBreak) { - this.drawPolyline(g, (PolylineShape) shape, (PointBreak) cb, area); - } else { - this.drawPolyline(g, (PolylineShape) shape, (PolylineBreak) cb, area); - } - break; - case Polygon: - case PolygonZ: - for (Polygon poly : ((PolygonShape) shape).getPolygons()) { - drawPolygon(g, poly, (PolygonBreak) cb, false, area); - } - break; - case Rectangle: - this.drawRectangle(g, (RectangleShape) shape, (PolygonBreak) cb, false, area); - break; - case ARC: - this.drawArc(g, (ArcShape) shape, (PolygonBreak) cb, area); - break; - case WindBarb: - this.drawWindBarb(g, (WindBarb) shape, (PointBreak) cb, area); - break; - case WindArraw: - this.drawWindArrow(g, (WindArrow) shape, (ArrowBreak) cb, area); - break; - case Image: - this.drawImage(g, gg, area); - break; - } - } - if (graphic instanceof GraphicCollection) { - GraphicCollection gc = (GraphicCollection) graphic; - if (gc.getLabelSet().isDrawLabels()) { - this.drawLabels(g, gc, area); - } - } - } - - g.setTransform(oldMatrix); - } - - void plotGraphics(Graphics2D g, Rectangle2D area) { - AffineTransform oldMatrix = g.getTransform(); - java.awt.Shape oldRegion = g.getClip(); - if (this.clip) { - g.setClip(area); - } - g.translate(area.getX(), area.getY()); - - int barIdx = 0; - for (int m = 0; m < this.graphics.getNumGraphics(); m++) { - Graphic graphic = this.graphics.get(m); - ColorBreak cb = graphic.getLegend(); - ShapeTypes shapeType = graphic.getGraphicN(0).getShape().getShapeType(); - switch(shapeType){ - case Bar: - this.drawBars(g, (GraphicCollection) graphic, barIdx, area); - barIdx += 1; - break; - } - for (int i = 0; i < graphic.getNumGraphics(); i++) { - Graphic gg = graphic.getGraphicN(i); - if (!graphic.isSingleLegend()) { - cb = gg.getLegend(); - } - Shape shape = gg.getShape(); - switch (shape.getShapeType()) { - case Point: - case PointM: - case PointZ: - this.drawPoint(g, (PointShape) shape, (PointBreak) cb, area); - break; - case TEXT: - this.drawText((ChartText)shape, g, area); - break; - case Polyline: - case PolylineZ: - if (shape instanceof CapPolylineShape){ - this.drawCapPolyline(g, (CapPolylineShape) shape, (PolylineBreak) cb, area); - } else { - switch (cb.getBreakType()){ - case PointBreak: - this.drawPolyline(g, (PolylineShape) shape, (PointBreak) cb, area); - break; - case PolylineBreak: - this.drawPolyline(g, (PolylineShape) shape, (PolylineBreak) cb, area); - break; - case ColorBreakCollection: - this.drawPolyline(g, (PolylineShape) shape, (ColorBreakCollection) cb, area); - break; - } - } - break; - case CurveLine: - this.drawCurveline(g, (CurveLineShape) shape, (PolylineBreak) cb, area); - break; - case PolylineError: - if (cb instanceof PointBreak) { - this.drawPolylineError(g, (PolylineErrorShape) shape, (PointBreak) cb, area); - } else { - this.drawPolylineError(g, (PolylineErrorShape) shape, (PolylineBreak) cb, area); - } - break; - case Polygon: - case PolygonZ: - for (Polygon poly : ((PolygonShape) shape).getPolygons()) { - drawPolygon(g, poly, (PolygonBreak) cb, false, area); - } - break; - case Rectangle: - this.drawRectangle(g, (RectangleShape) shape, (PolygonBreak) cb, false, area); - break; - case ARC: - this.drawArc(g, (ArcShape) shape, (PolygonBreak) cb, area); - break; - case WindBarb: - this.drawWindBarb(g, (WindBarb) shape, (PointBreak) cb, area); - break; - case WindArraw: - this.drawWindArrow(g, (WindArrow) shape, (ArrowBreak) cb, area); - break; - case Image: - this.drawImage(g, gg, area); - break; - } - } - if (graphic instanceof GraphicCollection) { - GraphicCollection gc = (GraphicCollection) graphic; - if (gc.getLabelSet().isDrawLabels()) { - this.drawLabels(g, gc, area); - } - } - } - - g.setTransform(oldMatrix); - if (this.clip) { - g.setClip(oldRegion); - } - } - - private void drawPoint(Graphics2D g, PointShape aPS, PointBreak aPB, Rectangle2D area) { - PointD p = aPS.getPoint(); - double[] sXY = projToScreen(p.X, p.Y, area); - PointF pf = new PointF((float) sXY[0], (float) sXY[1]); - RenderingHints rend = g.getRenderingHints(); - boolean rc = false; - if (this.symbolAntialias && rend.get(RenderingHints.KEY_ANTIALIASING) != RenderingHints.VALUE_ANTIALIAS_ON) { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - rc = true; - } - Draw.drawPoint(pf, aPB, g); - if (rc){ - g.setRenderingHints(rend); - } - } - - void drawText(ChartText text, Graphics2D g, Rectangle2D area) { - float x, y; - switch (text.getCoordinates()) { - case AXES: - x = (float) (area.getWidth() * text.getX()); - y = (float) (area.getHeight() * (1 - text.getY())); - this.drawText(g, text, x, y); - break; - case FIGURE: - x = (float) (area.getWidth() * text.getX()); - y = (float) (area.getHeight() * (1 - text.getY())); - this.drawText(g, text, x, y); - break; - case DATA: - double[] xy = this.projToScreen(text.getX(), text.getY(), area); - x = (float) xy[0]; - y = (float) xy[1]; - this.drawText(g, text, x, y); - break; - } - } - - private void drawText(Graphics2D g, ChartText text, float x, float y) { - g.setFont(text.getFont()); - g.setColor(text.getColor()); - switch (text.getYAlign()) { - case TOP: - y += g.getFontMetrics(g.getFont()).getAscent(); - break; - case CENTER: - y += g.getFontMetrics(g.getFont()).getAscent() / 2; - break; - } - String s = text.getText(); - switch (text.getXAlign()) { - case RIGHT: - x = x - g.getFontMetrics(g.getFont()).stringWidth(s); - break; - case CENTER: - x = x - g.getFontMetrics(g.getFont()).stringWidth(s) * 0.5f; - break; - } - Draw.drawString(g, s, x, y, text.isUseExternalFont()); - } - - private void drawWindBarb(Graphics2D g, WindBarb aPS, PointBreak aPB, Rectangle2D area) { - PointD p = aPS.getPoint(); - double[] sXY = projToScreen(p.X, p.Y, area); - PointF pf = new PointF((float) sXY[0], (float) sXY[1]); - Draw.drawWindBarb(pf, aPS, aPB, g); - } - - private void drawWindArrow(Graphics2D g, WindArrow aPS, ArrowBreak aPB, Rectangle2D area) { - PointD p = aPS.getPoint(); - double[] sXY = projToScreen(p.X, p.Y, area); - PointF pf = new PointF((float) sXY[0], (float) sXY[1]); - float zoom = aPB.getSize() / 10; - Draw.drawArraw(pf, aPS, aPB, g, zoom); - } - - private void drawPolyline(Graphics2D g, PolylineShape aPLS, PointBreak aPB, Rectangle2D area) { - for (Polyline aline : aPLS.getPolylines()) { - double[] sXY; - PointF p; - for (int i = 0; i < aline.getPointList().size(); i++) { - PointD wPoint = aline.getPointList().get(i); - sXY = projToScreen(wPoint.X, wPoint.Y, area); - p = new PointF((float) sXY[0], (float) sXY[1]); - Draw.drawPoint(p, aPB, g); - } - } - } - - private void drawPolyline(Graphics2D g, PolylineShape aPLS, PolylineBreak aPLB, Rectangle2D area) { - for (Polyline aline : aPLS.getPolylines()) { - double[] sXY; - PointF[] points = new PointF[aline.getPointList().size()]; - for (int i = 0; i < aline.getPointList().size(); i++) { - PointD wPoint = aline.getPointList().get(i); - sXY = projToScreen(wPoint.X, wPoint.Y, area); - points[i] = new PointF((float) sXY[0], (float) sXY[1]); - } - Draw.drawPolyline(points, aPLB, g); - } - } - - private void drawPolyline(Graphics2D g, PolylineShape aPLS, ColorBreakCollection cpc, Rectangle2D area) { - for (Polyline aline : aPLS.getPolylines()) { - double[] sXY; - PointF[] points = new PointF[aline.getPointList().size()]; - for (int i = 0; i < aline.getPointList().size(); i++) { - PointD wPoint = aline.getPointList().get(i); - sXY = projToScreen(wPoint.X, wPoint.Y, area); - points[i] = new PointF((float) sXY[0], (float) sXY[1]); - } - Draw.drawPolyline(points, cpc, g); - } - } - - private void drawCapPolyline(Graphics2D g, CapPolylineShape aPLS, PolylineBreak aPLB, Rectangle2D area) { - for (Polyline aline : aPLS.getPolylines()) { - double[] sXY; - PointF[] points = new PointF[aline.getPointList().size()]; - for (int i = 0; i < aline.getPointList().size(); i++) { - PointD wPoint = aline.getPointList().get(i); - sXY = projToScreen(wPoint.X, wPoint.Y, area); - points[i] = new PointF((float) sXY[0], (float) sXY[1]); - } - Draw.drawPolyline(points, aPLB, g); - float capLen = aPLS.getCapLen(); - int idx = points.length - 1; - if (aPLS.getCapAngle() == 0){ - PointF[] ps = new PointF[2]; - ps[0] = new PointF(points[0].X - capLen / 2, points[0].Y); - ps[1] = new PointF(points[0].X + capLen / 2, points[0].Y); - Draw.drawPolyline(ps, aPLB, g); - ps = new PointF[2]; - ps[0] = new PointF(points[idx].X - capLen / 2, points[idx].Y); - ps[1] = new PointF(points[idx].X + capLen / 2, points[idx].Y); - Draw.drawPolyline(ps, aPLB, g); - } else { - PointF[] ps = new PointF[2]; - ps[0] = new PointF(points[0].X, points[0].Y - capLen / 2); - ps[1] = new PointF(points[0].X, points[0].Y + capLen / 2); - Draw.drawPolyline(ps, aPLB, g); - ps = new PointF[2]; - ps[0] = new PointF(points[idx].X, points[idx].Y - capLen / 2); - ps[1] = new PointF(points[idx].X, points[idx].Y + capLen / 2); - Draw.drawPolyline(ps, aPLB, g); - } - } - } - - private void drawCurveline(Graphics2D g, CurveLineShape aPLS, PolylineBreak aPLB, Rectangle2D area) { - for (Polyline aline : aPLS.getPolylines()) { - double[] sXY; - PointF[] points = new PointF[aline.getPointList().size()]; - for (int i = 0; i < aline.getPointList().size(); i++) { - PointD wPoint = aline.getPointList().get(i); - sXY = projToScreen(wPoint.X, wPoint.Y, area); - points[i] = new PointF((float) sXY[0], (float) sXY[1]); - } - Draw.drawCurveLine(points, aPLB, g); - } - } - - private void drawPolylineError(Graphics2D g, PolylineErrorShape aPLS, PointBreak aPB, Rectangle2D area) { - for (Polyline aline : aPLS.getPolylines()) { - double[] sXY; - PointF p; - double error; - double elen = 6; - g.setColor(aPB.getColor()); - for (int i = 0; i < aline.getPointList().size(); i++) { - PointD wPoint = aline.getPointList().get(i); - sXY = projToScreen(wPoint.X, wPoint.Y, area); - p = new PointF((float) sXY[0], (float) sXY[1]); - if (aPLS.getYerror() != null) { - error = aPLS.getYerror(i); - error = this.projYLength(error, area); - g.draw(new Line2D.Double(p.X, p.Y - error, p.X, p.Y + error)); - g.draw(new Line2D.Double(p.X - (elen * 0.5), p.Y - error, p.X + (elen * 0.5), p.Y - error)); - g.draw(new Line2D.Double(p.X - (elen * 0.5), p.Y + error, p.X + (elen * 0.5), p.Y + error)); - } - if (aPLS.getXerror() != null) { - error = aPLS.getXerror(i); - error = this.projXLength(error, area); - g.draw(new Line2D.Double(p.X - error, p.Y, p.X + error, p.Y)); - g.draw(new Line2D.Double(p.X - error, p.Y - (elen * 0.5), p.X - error, p.Y + (elen * 0.5))); - g.draw(new Line2D.Double(p.X + error, p.Y - (elen * 0.5), p.X + error, p.Y + (elen * 0.5))); - } - Draw.drawPoint(p, aPB, g); - } - } - } - - private void drawPolylineError(Graphics2D g, PolylineErrorShape aPLS, PolylineBreak aPLB, Rectangle2D area) { - for (Polyline aline : aPLS.getPolylines()) { - double[] sXY; - PointF[] points = new PointF[aline.getPointList().size()]; - PointF p; - double error; - double elen = 6; - g.setColor(aPLB.getColor()); - for (int i = 0; i < aline.getPointList().size(); i++) { - PointD wPoint = aline.getPointList().get(i); - sXY = projToScreen(wPoint.X, wPoint.Y, area); - p = new PointF((float) sXY[0], (float) sXY[1]); - points[i] = p; - if (aPLS.getYerror() != null) { - error = aPLS.getYerror(i); - error = this.projYLength(error, area); - g.draw(new Line2D.Double(p.X, p.Y - error, p.X, p.Y + error)); - g.draw(new Line2D.Double(p.X - (elen * 0.5), p.Y - error, p.X + (elen * 0.5), p.Y - error)); - g.draw(new Line2D.Double(p.X - (elen * 0.5), p.Y + error, p.X + (elen * 0.5), p.Y + error)); - } - if (aPLS.getXerror() != null) { - error = aPLS.getXerror(i); - error = this.projXLength(error, area); - g.draw(new Line2D.Double(p.X - error, p.Y, p.X + error, p.Y)); - g.draw(new Line2D.Double(p.X - error, p.Y - (elen * 0.5), p.X - error, p.Y + (elen * 0.5))); - g.draw(new Line2D.Double(p.X + error, p.Y - (elen * 0.5), p.X + error, p.Y + (elen * 0.5))); - } - } - Draw.drawPolyline(points, aPLB, g); - } - } - - private void drawLabels(Graphics2D g, GraphicCollection graphics, Rectangle2D area) { - Extent lExtent = graphics.getExtent(); - Extent drawExtent = this.getDrawExtent(); - if (!MIMath.isExtentCross(lExtent, drawExtent)) { - return; - } - - Font drawFont; - List extentList = new ArrayList<>(); - Extent maxExtent = new Extent(); - Extent aExtent; - int i, j; - List LabelPoints = graphics.getLabelPoints(); - String LabelStr; - PointF aPoint = new PointF(); - - for (i = 0; i < LabelPoints.size(); i++) { - Graphic aLP = LabelPoints.get(i); - PointShape aPS = (PointShape) aLP.getShape(); - LabelBreak aLB = (LabelBreak) aLP.getLegend(); - aPS.setVisible(true); - LabelStr = aLB.getText(); - aPoint.X = (float) aPS.getPoint().X; - aPoint.Y = (float) aPS.getPoint().Y; - drawFont = aLB.getFont(); - if (aPoint.X < drawExtent.minX || aPoint.X > drawExtent.maxX - || aPoint.Y < drawExtent.minY || aPoint.Y > drawExtent.maxY) { - continue; - } - double[] xy = projToScreen(aPoint.X, aPoint.Y, area); - aPoint.X = (float) xy[0]; - aPoint.Y = (float) xy[1]; - FontMetrics metrics = g.getFontMetrics(drawFont); - Dimension labSize = new Dimension(metrics.stringWidth(LabelStr), metrics.getHeight()); - switch (aLB.getAlignType()) { - case Center: - aPoint.X = (float) xy[0] - labSize.width / 2; - break; - case Left: - aPoint.X = (float) xy[0] - labSize.width; - break; - } - aPoint.Y += labSize.height / 2; - aPoint.Y -= aLB.getYShift(); - aPoint.X += aLB.getXShift(); - - AffineTransform tempTrans = g.getTransform(); - if (aLB.getAngle() != 0) { - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform)tempTrans.clone(); - myTrans.translate(aPoint.X, aPoint.Y); - myTrans.rotate(aLB.getAngle() * Math.PI / 180); - g.setTransform(myTrans); - aPoint.X = 0; - aPoint.Y = 0; - } - - boolean ifDraw = true; - Rectangle rect = this.getGraphicRectangle(g, aLP, area); - aExtent = new Extent(); - aExtent.minX = rect.x; - aExtent.maxX = rect.x + rect.width; - aExtent.minY = rect.y; - aExtent.maxY = rect.y + rect.height; - if (graphics.getLabelSet().isAvoidCollision()) { - //Judge extent - if (extentList.isEmpty()) { - maxExtent = (Extent) aExtent.clone(); - extentList.add(aExtent); - } else if (!MIMath.isExtentCross(aExtent, maxExtent)) { - extentList.add(aExtent); - maxExtent = MIMath.getLagerExtent(maxExtent, aExtent); - } else { - for (j = 0; j < extentList.size(); j++) { - if (MIMath.isExtentCross(aExtent, extentList.get(j))) { - ifDraw = false; - break; - } - } - if (ifDraw) { - extentList.add(aExtent); - maxExtent = MIMath.getLagerExtent(maxExtent, aExtent); - } else { - aPS.setVisible(false); - } - } - } - - if (ifDraw) { - if (graphics.getLabelSet().isDrawShadow()) { - g.setColor(graphics.getLabelSet().getShadowColor()); - g.fill(new Rectangle.Float((float) aExtent.minX, (float) aExtent.minY, labSize.width, labSize.height)); - } - g.setFont(drawFont); - //g.setColor(aLayer.getLabelSet().getLabelColor()); - g.setColor(aLP.getLegend().getColor()); - g.drawString(LabelStr, aPoint.X, aPoint.Y); - - //Draw selected rectangle - if (aPS.isSelected()) { - float[] dashPattern = new float[]{2.0F, 1.0F}; - g.setColor(Color.cyan); - g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 10.0f, dashPattern, 0.0f)); - g.draw(new Rectangle.Float((float) aExtent.minX, (float) aExtent.minY, labSize.width, labSize.height)); - } - } - - if (aLB.getAngle() != 0) { - g.setTransform(tempTrans); - } - } - } - - /** - * Get graphic rectangle - * - * @param g The graphics - * @param aGraphic The graphic - * @param area Area - * @return Rectangle - */ - public Rectangle getGraphicRectangle(Graphics2D g, Graphic aGraphic, Rectangle2D area) { - Rectangle rect = new Rectangle(); - double[] sXY; - float aX, aY; - switch (aGraphic.getShape().getShapeType()) { - case Point: - case PointM: - PointShape aPS = (PointShape) aGraphic.getShape(); - sXY = projToScreen(aPS.getPoint().X, aPS.getPoint().Y, area); - aX = (float) sXY[0]; - aY = (float) sXY[1]; - switch (aGraphic.getLegend().getBreakType()) { - case PointBreak: - PointBreak aPB = (PointBreak) aGraphic.getLegend(); - int buffer = (int) aPB.getSize() + 2; - rect.x = (int) aX - buffer / 2; - rect.y = (int) aY - buffer / 2; - rect.width = buffer; - rect.height = buffer; - break; - case LabelBreak: - LabelBreak aLB = (LabelBreak) aGraphic.getLegend(); - g.setFont(aLB.getFont()); - //FontMetrics metrics = g.getFontMetrics(aLB.getFont()); - //Dimension labSize = new Dimension(metrics.stringWidth(aLB.getText()), metrics.getHeight()); - Dimension labSize = Draw.getStringDimension(aLB.getText(), g); - switch (aLB.getAlignType()) { - case Center: - aX = aX - labSize.width / 2; - break; - case Left: - aX = aX - labSize.width; - break; - } - aY -= aLB.getYShift(); - aY -= labSize.height / 3; - rect.x = (int) aX; - rect.y = (int) aY; - rect.width = (int) labSize.width; - rect.height = (int) labSize.height; - break; - } - break; - case Polyline: - case Polygon: - case Rectangle: - case CurveLine: - case Ellipse: - case Circle: - case CurvePolygon: - List newPList = (List) aGraphic.getShape().getPoints(); - List points = new ArrayList<>(); - for (PointD wPoint : newPList) { - sXY = projToScreen(wPoint.X, wPoint.Y, area); - aX = (float) sXY[0]; - aY = (float) sXY[1]; - points.add(new PointD(aX, aY)); - } - Extent aExtent = GeometryUtil.getPointsExtent(points); - rect.x = (int) aExtent.minX; - rect.y = (int) aExtent.minY; - rect.width = (int) (aExtent.maxX - aExtent.minX); - rect.height = (int) (aExtent.maxY - aExtent.minY); - break; - } - - return rect; - } - - private List drawPolygon(Graphics2D g, Polygon aPG, PolygonBreak aPGB, - boolean isSelected, Rectangle2D area) { - int len = aPG.getOutLine().size(); - GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, len); - PointD wPoint; - double[] sXY; - List rPoints = new ArrayList<>(); - for (int i = 0; i < aPG.getOutLine().size(); i++) { - wPoint = aPG.getOutLine().get(i); - sXY = projToScreen(wPoint.X, wPoint.Y, area); - if (i == 0) { - path.moveTo(sXY[0], sXY[1]); - } else { - path.lineTo(sXY[0], sXY[1]); - } - rPoints.add(new PointF((float) sXY[0], (float) sXY[1])); - } - - List newPList; - if (aPG.hasHole()) { - for (int h = 0; h < aPG.getHoleLines().size(); h++) { - newPList = (List)aPG.getHoleLines().get(h); - for (int j = 0; j < newPList.size(); j++) { - wPoint = newPList.get(j); - sXY = projToScreen(wPoint.X, wPoint.Y, area); - if (j == 0) { - path.moveTo(sXY[0], sXY[1]); - } else { - path.lineTo(sXY[0], sXY[1]); - } - } - } - } - path.closePath(); - - if (aPGB.isDrawFill()) { - //int alpha = (int)((1 - (double)transparencyPerc / 100.0) * 255); - //Color aColor = Color.FromArgb(alpha, aPGB.Color); - Color aColor = aPGB.getColor(); - if (isSelected) { - aColor = this.getSelectedColor(); - } - if (aPGB.isUsingHatchStyle()) { - int size = aPGB.getStyleSize(); - BufferedImage bi = getHatchImage(aPGB.getStyle(), size, aPGB.getColor(), aPGB.getBackColor()); - Rectangle2D rect = new Rectangle2D.Double(0, 0, size, size); - g.setPaint(new TexturePaint(bi, rect)); - g.fill(path); - } else { - g.setColor(aColor); - g.fill(path); - } - } else if (isSelected) { - g.setColor(this.getSelectedColor()); - g.fill(path); - } - - if (aPGB.isDrawOutline()) { - BasicStroke pen = new BasicStroke(aPGB.getOutlineSize()); - g.setStroke(pen); - g.setColor(aPGB.getOutlineColor()); - g.draw(path); - } - - return rPoints; - } - - private void drawRectangle(Graphics2D g, RectangleShape rs, PolygonBreak aPGB, - boolean isSelected, Rectangle2D area) { - Extent extent = rs.getExtent(); - double[] sXY; - sXY = projToScreen(extent.minX, extent.minY + extent.getHeight(), area); - double x = sXY[0]; - double y = sXY[1]; - double width = this.projXLength(extent.getWidth(), area); - double height = this.projYLength(extent.getHeight(), area); - RectangularShape rshape; - if (rs.isRound()) - rshape = new RoundRectangle2D.Double(x, y, width, height, width * rs.getRoundX(), height * rs.getRoundY()); - else - rshape = new Rectangle2D.Double(x, y, width, height); - - if (aPGB.isDrawFill()) { - Color aColor = aPGB.getColor(); - if (isSelected) { - aColor = this.getSelectedColor(); - } - if (aPGB.isUsingHatchStyle()) { - int size = aPGB.getStyleSize(); - BufferedImage bi = getHatchImage(aPGB.getStyle(), size, aPGB.getColor(), aPGB.getBackColor()); - Rectangle2D rect = new Rectangle2D.Double(0, 0, size, size); - g.setPaint(new TexturePaint(bi, rect)); - g.fill(rshape); - } else { - g.setColor(aColor); - g.fill(rshape); - } - } else if (isSelected) { - g.setColor(this.getSelectedColor()); - g.fill(rshape); - } - - if (aPGB.isDrawOutline()) { - BasicStroke pen = new BasicStroke(aPGB.getOutlineSize()); - g.setStroke(pen); - g.setColor(aPGB.getOutlineColor()); - g.draw(rshape); - } - } - - private void drawArc(Graphics2D g, ArcShape aShape, PolygonBreak aPGB, - Rectangle2D area, float dist, float ex, Font labelFont, Color labelColor) { - float startAngle = aShape.getStartAngle(); - float sweepAngle = aShape.getSweepAngle(); - float angle = startAngle + sweepAngle / 2; - float space = 20; - Rectangle2D rect = new Rectangle2D.Double(area.getX() + ex + space, area.getY() + ex + space, area.getWidth() - ex - space, - area.getHeight() - ex - space); - double dx = 0, dy = 0; - if (aShape.getExplode() > 0) { - dx = ex * Math.cos((360 - angle) * Math.PI / 180); - 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()); - Draw.drawPie(new PointF(sx, sy), (float) rect.getWidth(), (float) rect.getHeight(), - startAngle, sweepAngle, aPGB, g); - - float x, y, w, h; - PointF sPoint = new PointF((float) (rect.getWidth() * 0.5 + sx), (float) (rect.getHeight() * 0.5 + sy)); - String label = aPGB.getCaption(); - if (angle > 360) { - angle = angle - 360; - } - float r = (float) (rect.getWidth() * 0.5) + dist; - PointF lPoint = Draw.getPieLabelPoint(sPoint, r, angle); - x = lPoint.X; - y = lPoint.Y; - Dimension dim = Draw.getStringDimension(label, g); - h = dim.height; - w = dim.width; - if ((angle >= 0 && angle < 45)) { - //x = x + dis; - y = y - h; - } else if (angle >= 45 && angle < 90) { - //y = y - dis; - } else if (angle >= 90 && angle < 135) { - x = x - w; - //y = y - dis; - } else if (angle >= 135 && angle < 225) { - x = x - w - 3; - y = y + h / 2; - } else if (angle >= 225 && angle < 270) { - x = x - w / 2; - y = y + h; - } else if (angle >= 270 && angle < 315) { - //x = x + dis; - y = y + h; - } else { - //x = x + dis; - y = y + h / 2; - } - g.setFont(labelFont); - g.setColor(labelColor); - //g.drawOval((int)(x - 3), (int)(y - 3), 6, 6); - g.drawString(label, x, y); - } - - private void drawArc(Graphics2D g, ArcShape aShape, PolygonBreak aPGB, - Rectangle2D area) { - float startAngle = aShape.getStartAngle(); - float sweepAngle = aShape.getSweepAngle(); - Extent extent = aShape.getExtent(); - double[] sXY; - sXY = projToScreen(extent.minX, extent.minY + extent.getHeight(), area); - double x = sXY[0]; - double y = sXY[1]; - double width = this.projXLength(extent.getWidth(), area); - double height = this.projYLength(extent.getHeight(), area); - Float wedgeWidth = aShape.getWedgeWidth(); - if (wedgeWidth == null) { - Draw.drawPie(new PointF((float)x, (float)y), - (float) width, (float) height, startAngle, sweepAngle, aPGB, g); - } else { - wedgeWidth = (float)this.projXLength(wedgeWidth, area); - Draw.drawPie(new PointF((float)x, (float)y), - (float) width, (float) height, startAngle, sweepAngle, aPGB, wedgeWidth, g); - } - } - - private void drawBar(Graphics2D g, BarShape bar, BarBreak bb, float width, Rectangle2D area) { - double[] xy; - xy = this.projToScreen(0, 0, area); - float y0 = (float) xy[1]; - width = (float) this.projXLength(width, area); - xy = projToScreen(bar.getPoint().X, bar.getPoint().Y, area); - double x = xy[0]; - double y = xy[1]; - float height; - height = Math.abs((float) (y - y0)); - float yb = y0; - if (y >= y0) { - yb += height; - } - Draw.drawBar(new PointF((float) x, yb), width, height, bb, g, false, 5); - } - - private int getBarSeriesNum() { - int n = 0; - for (Graphic g : this.graphics.getGraphics()) { - if (g.getGraphicN(0).getShape().getShapeType() == ShapeTypes.Bar) { - n += 1; - } - } - return n; - } - - private void drawBars(Graphics2D g, GraphicCollection bars, int barIdx, Rectangle2D area) { - double[] xy; - xy = this.projToScreen(0, 0, area); - float y0 = (float) xy[1]; - int len = bars.getNumGraphics(); - PointF[] points = new PointF[len]; - for (int i = 0; i < len; i++) { - BarShape bs = (BarShape) bars.getGraphicN(i).getShape(); - xy = this.projToScreen(bs.getPoint().X, bs.getPoint().Y, area); - points[i] = new PointF((float) xy[0], (float) xy[1]); - } - float width; - int barSeriesN = this.getBarSeriesNum(); - BarShape bs1 = (BarShape) bars.getGraphicN(0).getShape(); - if (bs1.isAutoWidth()) { - if (len > 1) { - width = (float) ((points[1].X - points[0].X) * this.barsWidth) / barSeriesN; - } else { - width = (float) (area.getWidth() / 10) / barSeriesN; - } - float height; - BarBreak bb; - for (int i = 0; i < len; i++) { - BarShape bs = (BarShape) bars.getGraphicN(i).getShape(); - bb = (BarBreak) bars.getGraphicN(i).getLegend(); - height = Math.abs((float) (points[i].Y - y0)); - float yBottom = y0; - if (bs.isDrawBottom()) { - xy = this.projToScreen(bs.getPoint().X, bs.getBottom(), area); - yBottom = (float) xy[1]; - } - float yb = yBottom; - if (points[i].Y >= y0) { - yb += height; - } - Draw.drawBar(new PointF(points[i].X - width * barSeriesN / 2 - + barIdx * width, yb), width, height, bb, g, false, 5); - if (bs.isDrawError()) { - PointF p = (PointF) points[i].clone(); - p.Y -= y0 - yBottom; - double elen = 6; - double error = bs.getError(); - error = this.projYLength(error, area); - double x = p.X - width * barSeriesN / 2 - + barIdx * width + width / 2; - g.setColor(bb.getErrorColor()); - g.draw(new Line2D.Double(x, p.Y - error, x, p.Y + error)); - g.draw(new Line2D.Double(x - (elen * 0.5), p.Y - error, x + (elen * 0.5), p.Y - error)); - g.draw(new Line2D.Double(x - (elen * 0.5), p.Y + error, x + (elen * 0.5), p.Y + error)); - } - } - } else { - width = (float) this.projXLength(bs1.getWidth(), area); - float height; - BarBreak bb; - for (int i = 0; i < len; i++) { - BarShape bs = (BarShape) bars.getGraphicN(i).getShape(); - bb = (BarBreak) bars.getGraphicN(i).getLegend(); - height = Math.abs((float) (points[i].Y - y0)); - float yBottom = y0; - if (bs.isDrawBottom()) { - xy = this.projToScreen(bs.getPoint().X, bs.getBottom(), area); - yBottom = (float) xy[1]; - } - float yb = yBottom; - if (points[i].Y >= y0) { - yb += height; - } - Draw.drawBar(new PointF(points[i].X, yb), width, height, bb, g, false, 5); - if (bs.isDrawError()) { - PointF p = (PointF) points[i].clone(); - p.Y -= y0 - yBottom; - double elen = 6; - double error = bs.getError(); - error = this.projYLength(error, area); - double x = p.X + width / 2; - g.setColor(bb.getErrorColor()); - g.draw(new Line2D.Double(x, p.Y - error, x, p.Y + error)); - g.draw(new Line2D.Double(x - (elen * 0.5), p.Y - error, x + (elen * 0.5), p.Y - error)); - g.draw(new Line2D.Double(x - (elen * 0.5), p.Y + error, x + (elen * 0.5), p.Y + error)); - } - } - } - - //Draw baseline - boolean drawBaseline = true; - if (drawBaseline) { - g.setColor(Color.black); - g.draw(new Line2D.Double(0, y0, area.getWidth(), y0)); - } - } - - private double getBarXInterval(int idx) { - Graphic gg = this.graphics.get(idx); - if (gg.getNumGraphics() == 1) { - if (gg.getGraphicN(0).getShape().getPoints().get(0).X == 0) { - return 1; - } else { - return gg.getGraphicN(0).getShape().getPoints().get(0).X / 10; - } - } else { - return gg.getGraphicN(1).getShape().getPoints().get(0).X - - gg.getGraphicN(0).getShape().getPoints().get(0).X; - } - } - - private int getBarIndex() { - int idx = -1; - for (int i = 0; i < this.graphics.size(); i++) { - if (this.graphics.get(i).getGraphicN(0).getShape().getShapeType() == ShapeTypes.Bar) { - idx = i; - break; - } - } - return idx; - } - - private int getImageIndex() { - int idx = -1; - for (int i = 0; i < this.graphics.size(); i++) { - if (this.graphics.get(i).getGraphicN(0).getShape().getShapeType() == ShapeTypes.Image) { - idx = i; - break; - } - } - return idx; - } - - private void drawImage(Graphics2D g, Graphic igraphic, Rectangle2D area) { - ImageShape ishape = (ImageShape) igraphic.getShape(); - BufferedImage image = ishape.getImage(); - //double sx = ishape.getPoint().X, sy = ishape.getPoint().Y + image.getHeight(); - Extent extent = ishape.getExtent(); - double sx = extent.minX, sy = extent.maxY; - double[] xy1 = this.projToScreen(sx, sy, area); - double ex = extent.maxX, ey = extent.minY; - //double[] xy2 = this.projToScreen(sx + image.getWidth(), ishape.getPoint().Y, area); - double[] xy2 = this.projToScreen(ex, ey, area); - int x = (int) xy1[0]; - int y = (int) xy1[1]; - int width = (int) (xy2[0] - xy1[0]); - int height = (int) (xy2[1] - xy1[1]); - g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, ishape.getInterpolation()); - g.drawImage(image, x, y, width, height, null); - } - - @Override - Extent getAutoExtent() { - Extent extent = (Extent)this.graphics.getExtent().clone(); - if (extent.minX == extent.maxX) { - extent.minX = extent.minX - Math.abs(extent.minX); - extent.maxX = extent.maxX + Math.abs(extent.minX); - } - if (extent.minY == extent.maxY) { - extent.minY = extent.minY - Math.abs(extent.minY); - extent.maxY = extent.maxY + Math.abs(extent.maxY); - } - - int imageIdx = this.getImageIndex(); - if (imageIdx >= 0){ - return extent; - } - - int barIdx = this.getBarIndex(); - if (barIdx >= 0) { - double dx = getBarXInterval(barIdx); - extent.minX -= dx; - extent.maxX += dx; - } - double[] xValues; - if (this.getXAxis() instanceof TimeAxis) { - xValues = (double[]) MIMath.getIntervalValues(extent.minX, extent.maxX, false).get(0); - xValues[0] = extent.minX; - xValues[xValues.length - 1] = extent.maxX; - } else if (this.getXAxis() instanceof LogAxis) { - xValues = (double[]) MIMath.getIntervalValues_Log(extent.minX, extent.maxX); - } else { - xValues = (double[]) MIMath.getIntervalValues(extent.minX, extent.maxX, true).get(0); - } - double[] yValues; - if (this.getYAxis() instanceof LogAxis) { - yValues = (double[]) MIMath.getIntervalValues_Log(extent.minY, extent.maxY); - } else { - yValues = (double[]) MIMath.getIntervalValues(extent.minY, extent.maxY, true).get(0); - } - if (this.getPlotOrientation() == PlotOrientation.VERTICAL) { - return new Extent(xValues[0], xValues[xValues.length - 1], yValues[0], yValues[yValues.length - 1]); - } else { - return new Extent(yValues[0], yValues[yValues.length - 1], xValues[0], xValues[xValues.length - 1]); - } - } - - /** - * Set auto extent - */ - @Override - public void setAutoExtent() { - Extent extent = this.getAutoExtent(); - this.setDrawExtent(extent); - this.setExtent((Extent) extent.clone()); - } - - @Override - public void updateLegendScheme() { - if (this.getLegend() == null) { - this.setLegend(new ChartLegend(this.getLegendScheme())); - } else { - this.getLegend().setLegendScheme(this.getLegendScheme()); - } - } - - @Override - public Dataset getDataset() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public void setDataset(Dataset dataset) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - /** - * Get legend scheme - * - * @return Legend scheme - */ - public LegendScheme getLegendScheme() { - LegendScheme ls = null; - int n = this.graphics.getNumGraphics(); - for (int i = n - 1; i >= 0; i--) { - Graphic g = this.graphics.getGraphicN(i); - if (g instanceof ImageGraphic) { - ls = ((ImageGraphic)g).getLegendScheme(); - } else if (g instanceof GraphicCollection) { - ls = ((GraphicCollection)g).getLegendScheme(); - } - } - - if (ls == null) { - ShapeTypes stype = ShapeTypes.Polyline; - ls = new LegendScheme(stype); - for (Graphic g : this.graphics.getGraphics()) { - ls.getLegendBreaks().add(g.getLegend()); - } - } - return ls; - } - // - -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/Plot3D.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/Plot3D.java deleted file mode 100644 index c3d3dc9c..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/Plot3D.java +++ /dev/null @@ -1,2375 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.plot; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics2D; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.RenderingHints; -import java.awt.TexturePaint; -import java.awt.geom.AffineTransform; -import java.awt.geom.GeneralPath; -import java.awt.geom.Rectangle2D; -import java.awt.image.BufferedImage; -import java.util.ArrayList; -import java.util.List; -import org.meteoinfo.chart.ChartLegend; -import org.meteoinfo.chart.ChartText; -import org.meteoinfo.chart.ChartText3D; -import org.meteoinfo.chart.LegendPosition; -import org.meteoinfo.chart.Margin; -import org.meteoinfo.chart.axis.Axis; -import org.meteoinfo.chart.axis.LogAxis; -import org.meteoinfo.chart.plot3d.GraphicCollection3D; -import org.meteoinfo.chart.plot3d.Projector; -import org.meteoinfo.common.*; -import org.meteoinfo.data.DataMath; -import org.meteoinfo.data.Dataset; -import org.meteoinfo.drawing.Draw; -import org.meteoinfo.geometry.graphic.Graphic; -import org.meteoinfo.geometry.graphic.GraphicCollection; -import org.meteoinfo.geometry.legend.*; -import org.meteoinfo.math.sort.QuickSort; -import org.meteoinfo.geometry.shape.*; - -/** - * - * @author Yaqiang Wang - */ -public class Plot3D extends Plot { - - // - private final GraphicCollection3D graphics; - private Extent3D extent; - private ChartText title; - private List legends; - private Axis xAxis; - private Axis yAxis; - private Axis zAxis; - private GridLine gridLine; - - private final Projector projector; // the projector, controls the point of view - private int prevwidth, prevheight; // canvas size - private Rectangle graphBounds; //Graphic area bounds - - private boolean isBoxed, isMesh, isScaleBox, isDisplayXY, isDisplayZ, - drawBoundingBox, drawBase; - private boolean hideOnDrag; - private float xmin, xmax, ymin; - private float ymax, zmin, zmax; - - private Color boxColor = Color.getHSBColor(0f, 0f, 0.95f); - //private Color lineboxColor = Color.getHSBColor(0f, 0f, 0.8f); - - // Projection parameters - private int factor_x, factor_y; // conversion factors - private int t_x, t_y, t_z; // determines ticks density - //private final int poly_x[] = new int[9]; - //private final int poly_y[] = new int[9]; - private Point projection; - float xfactor; - float yfactor; - float zfactor; - - // - // - /** - * Constructor - */ - public Plot3D() { - this.legends = new ArrayList<>(); - this.xAxis = new Axis(); - this.xAxis.setLabel("X"); - this.xAxis.setTickLength(8); - this.yAxis = new Axis(); - this.yAxis.setLabel("Y"); - this.yAxis.setTickLength(8); - this.zAxis = new Axis(); - this.zAxis.setLabel("Z"); - this.zAxis.setTickLength(8); - projector = new Projector(); - projector.setDistance(10000); - projector.set2DScaling(15); - projector.setRotationAngle(225); - projector.setElevationAngle(30); - this.graphics = new GraphicCollection3D(); - this.hideOnDrag = false; - this.isBoxed = true; - this.gridLine = new GridLine(); - //this.displayGrids = true; - this.isDisplayXY = true; - this.isDisplayZ = true; - this.drawBoundingBox = false; - this.drawBase = true; - } - - // - // - /** - * Get graphics - * @return The graphics - */ - public GraphicCollection3D getGraphics() { - return this.graphics; - } - - /** - * Get the number of graphics - * @return The number of graphics - */ - public int getGraphicNumber() { - return this.graphics.size(); - } - - /** - * Get projector - * - * @return The Projector - */ - public Projector getProjector() { - return this.projector; - } - - /** - * Get title - * - * @return Title - */ - public ChartText getTitle() { - return this.title; - } - - /** - * Set title - * - * @param value Title - */ - public void setTitle(ChartText value) { - this.title = value; - } - - /** - * Set title - * - * @param text Title text - */ - public void setTitle(String text) { - if (this.title == null) { - this.title = new ChartText(text); - } else { - this.title.setText(text); - } - } - - /** - * Get legends - * - * @return Legends - */ - public List getLegends() { - return this.legends; - } - - /** - * Get chart legend - * - * @param idx Index - * @return Chart legend - */ - public ChartLegend getLegend(int idx) { - if (this.legends.isEmpty()) { - return null; - } else { - return this.legends.get(idx); - } - } - - /** - * Get chart legend - * - * @return Chart legend - */ - public ChartLegend getLegend() { - if (this.legends.isEmpty()) { - return null; - } else { - return this.legends.get(this.legends.size() - 1); - } - } - - /** - * Set chart legend - * - * @param value Legend - */ - public void setLegend(ChartLegend value) { - this.legends.clear(); - this.legends.add(value); - } - - /** - * Set legends - * - * @param value Legends - */ - public void setLegends(List value) { - this.legends = value; - } - - /** - * Get x axis - * - * @return X axis - */ - public Axis getXAxis() { - return this.xAxis; - } - - /** - * Set x axis - * @param value X axis - */ - public void setXAxis(Axis value) { - this.xAxis = value; - } - - /** - * Get y axis - * - * @return Y axis - */ - public Axis getYAxis() { - return this.yAxis; - } - - /** - * Set y axis - * @param value Y axis - */ - public void setYAxis(Axis value) { this.yAxis = value; } - - /** - * Get z axis - * @return Z axis - */ - public Axis getZAxis() { - return this.zAxis; - } - - /** - * Set z axis - * @param value Z axis - */ - public void setZAxis(Axis value) { - this.zAxis = value; - } - - /** - * Get x minimum - * @return X minimum - */ - public float getXMin(){ - return this.xmin; - } - - /** - * Set minimum x - * - * @param value Minimum x - */ - public void setXMin(float value) { - this.xmin = value; - updateExtent(); - this.xAxis.setMinMaxValue(xmin, xmax); - } - - /** - * Get x maximum - * @return X maximum - */ - public float getXMax() { - return this.xmax; - } - - /** - * Set maximum x - * - * @param value Maximum x - */ - public void setXMax(float value) { - this.xmax = value; - updateExtent(); - this.xAxis.setMinMaxValue(xmin, xmax); - } - - /** - * Set x minimum and maximum values - * - * @param min Minimum value - * @param max Maximum value - */ - public void setXMinMax(float min, float max) { - this.xmin = min; - this.xmax = max; - updateExtent(); - this.xAxis.setMinMaxValue(min, max); - } - - /** - * Get y minimum - * @return Y minimum - */ - public float getYMin(){ - return this.ymin; - } - - /** - * Set minimum y - * - * @param value Minimum y - */ - public void setYMin(float value) { - this.ymin = value; - updateExtent(); - this.yAxis.setMinMaxValue(ymin, ymax); - } - - /** - * Get y maximum - * @return Y maximum - */ - public float getYMax() { - return this.ymax; - } - - /** - * Set Maximum y - * - * @param value Maximum y - */ - public void setYMax(float value) { - this.ymax = value; - updateExtent(); - this.yAxis.setMinMaxValue(ymin, ymax); - } - - /** - * Set y minimum and maximum values - * - * @param min Minimum value - * @param max Maximum value - */ - public void setYMinMax(float min, float max) { - this.ymin = min; - this.ymax = max; - updateExtent(); - this.yAxis.setMinMaxValue(min, max); - } - - /** - * Get z minimum - * @return Z minimum - */ - public float getZMin(){ - return this.zmin; - } - - /** - * Set minimum z - * - * @param value Minimum z - */ - public void setZMin(float value) { - this.zmin = value; - updateExtent(); - this.zAxis.setMinMaxValue(zmin, zmax); - } - - /** - * Get z maximum - * @return Z maximum - */ - public float getZMax() { - return this.zmax; - } - - /** - * Set maximum z - * - * @param value Maximum z - */ - public void setZMax(float value) { - this.zmax = value; - updateExtent(); - this.zAxis.setMinMaxValue(zmin, zmax); - } - - /** - * Set z minimum and maximum values - * - * @param min Minimum value - * @param max Maximum value - */ - public void setZMinMax(float min, float max) { - this.zmin = min; - this.zmax = max; - updateExtent(); - this.zAxis.setMinMaxValue(min, max); - } - - /** - * Get grid line - * - * @return Grid line - */ - public GridLine getGridLine() { - return this.gridLine; - } - - /** - * Set display X/Y axis or not - * - * @param value Boolean - */ - public void setDisplayXY(boolean value) { - this.isDisplayXY = value; - } - - /** - * Set display Z axis or not - * - * @param value Boolean - */ - public void setDisplayZ(boolean value) { - this.isDisplayZ = value; - } - -// /** -// * Get display grids or not -// * @return Boolean -// */ -// public boolean isDisplayGrids() { -// return this.displayGrids; -// } -// -// /** -// * Set display grids or not -// * -// * @param value Boolean -// */ -// public void setDisplayGrids(boolean value) { -// this.displayGrids = value; -// } - - /** - * Set display box or not - * - * @param value Boolean - */ - public void setBoxed(boolean value) { - this.isBoxed = value; - } - - /** - * Set display mesh line or not - * - * @param value Boolean - */ - public void setMesh(boolean value) { - this.isMesh = value; - } - - /** - * Get if draw bounding box or not - * - * @return Boolean - */ - public boolean isDrawBoundingBox() { - return this.drawBoundingBox; - } - - /** - * Set if draw bounding box or not - * - * @param value Boolean - */ - public void setDrawBoundingBox(boolean value) { - this.drawBoundingBox = value; - } - - /** - * Get if draw base area - * @return Draw base area or not - */ - public boolean isDrawBase() { - return this.drawBase; - } - - /** - * Set if draw base area - * @param value Draw base area or not - */ - public void setDrawBase(boolean value) { - this.drawBase = value; - } - - /** - * Get extent - * - * @return Extent - */ - public Extent3D getExtent() { - return this.extent; - } - - /** - * Set extent - * - * @param value Extent - */ - public void setExtent(Extent3D value) { - this.extent = value; - xmin = (float) extent.minX; - xmax = (float) extent.maxX; - ymin = (float) extent.minY; - ymax = (float) extent.maxY; - zmin = (float) extent.minZ; - zmax = (float) extent.maxZ; - xAxis.setMinMaxValue(xmin, xmax); - yAxis.setMinMaxValue(ymin, ymax); - zAxis.setMinMaxValue(zmin, zmax); - if (zAxis instanceof LogAxis) - this.projector.setZRange((float)Math.log10(zmin), (float)Math.log10(zmax)); - else - this.projector.setZRange(zmin, zmax); - } - - // - // - private void updateExtent() { - this.extent = new Extent3D(xmin, xmax, ymin, ymax, zmin, zmax); - } - - /** - * Set axis tick font - * - * @param font Font - */ - public void setAxisTickFont(Font font) { - this.xAxis.setTickLabelFont(font); - this.yAxis.setTickLabelFont(font); - this.zAxis.setTickLabelFont(font); - } - - /** - * Add a graphic - * - * @param g Grahic - */ - public void addGraphic(Graphic g) { - this.graphics.add(g); - Extent ex = this.graphics.getExtent(); - if (!ex.is3D()){ - ex = ex.to3D(); - } - this.setExtent((Extent3D)ex); - } - - /** - * Remove a graphic by index - * - * @param idx Index - */ - public void removeGraphic(int idx) { - this.graphics.remove(idx); - } - - /** - * Remove last graphic - */ - public void removeLastGraphic() { - this.graphics.remove(this.graphics.size() - 1); - } - - /** - * Set auto extent - */ - public void setAutoExtent() { - } - - /** - * Destroys the internal image. It will force SurfaceCanvas to - * regenerate all images when the paint method is called. - */ - public void destroyImage() { - repaint(); - } - - private void repaint() { - - } - - /** - * Add a legend - * - * @param legend The legend - */ - public void addLegend(ChartLegend legend) { - this.legends.add(legend); - } - - /** - * Remove a legend - * - * @param legend The legend - */ - public void removeLegend(ChartLegend legend) { - this.legends.remove(legend); - } - - /** - * Remove a legend by index - * - * @param idx The legend index - */ - public void removeLegend(int idx) { - this.legends.remove(idx); - } - - /** - * Get outer position area - * - * @param area Whole area - * @return Position area - */ - @Override - public Rectangle2D getOuterPositionArea(Rectangle2D area) { - Rectangle2D rect = this.getOuterPosition(); - double x = area.getWidth() * rect.getX() + area.getX(); - double y = area.getHeight() * (1 - rect.getHeight() - rect.getY()) + area.getY(); - double w = area.getWidth() * rect.getWidth(); - double h = area.getHeight() * rect.getHeight(); - return new Rectangle2D.Double(x, y, w, h); - } - - @Override - public Dataset getDataset() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public void setDataset(Dataset dataset) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public PlotType getPlotType() { - return PlotType.XYZ; - } - - @Override - public void draw(Graphics2D g2, Rectangle2D area) { - this.setGraphArea(this.getPositionArea()); - - //Draw title - float y = this.drawTitle(g2, this.getGraphArea()); - - //Set projection area - Rectangle parea = this.getPositionArea(area).getBounds(); - if ((parea.width != prevwidth) || (parea.height != prevheight)) { - prevwidth = parea.width; - prevheight = parea.height; - } - projector.setProjectionArea(parea); - - if (this.xAxis instanceof LogAxis) - xfactor = 20f / ((float)Math.log10(xmax) - (float)Math.log10(this.xmin)); - else - xfactor = 20f / (this.xmax - this.xmin); // 20 aint magic: surface vertex requires a value in [-10 ; 10] - if (this.yAxis instanceof LogAxis) - yfactor = 20f / ((float)Math.log10(this.ymax) - (float)Math.log10(this.ymin)); - else - yfactor = 20f / (this.ymax - this.ymin); - if (this.zAxis instanceof LogAxis) - zfactor = 20f / ((float)Math.log10(this.zmax) - (float)Math.log10(this.zmin)); - else - zfactor = 20f / (this.zmax - this.zmin); - - //Get graph bounds - this.graphBounds = this.projector.getBounds(); - - //Draw box - drawBoxGridsTicksLabels(g2); - - //Draw graph border polygon - java.awt.Polygon border = getBorder(); - //g2.setColor(Color.red); - //g2.draw(border); - - //Set graph border polygon clip - Rectangle oldClip = g2.getClipBounds(); - g2.setClip(border); - - //Draw 3D graphics - drawAllGraphics(g2); - - //Cancel the graph border polygon clip - g2.setClip(oldClip); - - //Draw bounding box - if (this.drawBoundingBox) { - drawBoundingBox(g2); - } - - //Draw legend - this.drawLegend(g2, area, this.graphBounds, y); - } - - float drawTitle(Graphics2D g, Rectangle2D graphArea) { - float y = (float) graphArea.getY(); - if (title != null) { - float x = (float) (graphArea.getX() + graphArea.getWidth() / 2); - y -= 8; - title.draw(g, x, y); - g.setFont(new Font("Arial", Font.PLAIN, 14)); - } - return y; - } - - private void drawAllGraphics(Graphics2D g2) { - for (int m = 0; m < this.graphics.getNumGraphics(); m++) { - Graphic graphic = this.graphics.get(m); - if (graphic instanceof GraphicCollection3D && ((GraphicCollection3D) graphic).isFixZ()) { - this.drawGraphics_FixZ(g2, graphic); - } else { - this.drawGrahpics(g2, graphic); - } - } - } - - private void drawGrahic(Graphics2D g, Graphic graphic) { - Shape shape = graphic.getGraphicN(0).getShape(); - switch (shape.getShapeType()) { - case Point: - case PointZ: - this.drawPoint(g, graphic); - break; - case TEXT: - this.drawText((ChartText3D) shape, g); - break; - case Polyline: - case PolylineZ: - this.drawLineString(g, graphic); - break; - case Polygon: - case PolygonZ: - this.drawPolygonShape(g, graphic); - break; - case WindArraw: - this.drawWindArrow(g, graphic); - break; - case Image: - - break; - } - } - - private void drawGraphics_FixZ(Graphics2D g, Graphic graphic) { - //Set clip polygon - float zValue = (float) ((GraphicCollection3D) graphic).getZValue(); - String zdir = ((GraphicCollection3D) graphic).getZDir(); - java.awt.Polygon polygon = new java.awt.Polygon(); - Point p; - List points = new ArrayList<>(); - switch (zdir) { - case "x": - /*zValue = (zValue - this.xmin) * xfactor - 10; - p = projector.project(zValue, -10, -10);*/ - p = this.project(zValue, this.ymin, this.zmin); - points.add(p); - //p = projector.project(zValue, -10, 10); - p = this.project(zValue, this.ymin, this.zmax); - points.add(p); - //p = projector.project(zValue, 10, 10); - p = this.project(zValue, this.ymax, this.zmax); - points.add(p); - //p = projector.project(zValue, 10, -10); - p = this.project(zValue, this.ymax, this.zmin); - points.add(p); - break; - case "y": - //zValue = (zValue - this.ymin) * yfactor - 10; - //p = projector.project(-10, zValue, -10); - p = this.project(this.xmin, zValue, this.zmin); - points.add(p); - //p = projector.project(-10, zValue, 10); - p = this.project(this.xmin, zValue, this.zmax); - points.add(p); - //p = projector.project(10, zValue, 10); - p = this.project(this.xmax, zValue, this.zmax); - points.add(p); - //p = projector.project(10, zValue, -10); - p = this.project(this.xmax, zValue, this.zmin); - points.add(p); - break; - case "xy": - List sePoint = ((GraphicCollection3D) graphic).getSEPoint(); - if (sePoint != null && sePoint.size() > 3){ - float sx = sePoint.get(0).floatValue(); - float sy = sePoint.get(1).floatValue(); - float ex = sePoint.get(2).floatValue(); - float ey = sePoint.get(3).floatValue(); - /*sx = (sx - this.xmin) * xfactor - 10; - ex = (ex - this.xmin) * xfactor - 10; - sy = (sy - this.ymin) * yfactor - 10; - ey = (ey - this.ymin) * yfactor - 10; - p = projector.project(sx, sy, -10);*/ - p = this.project(sx, sy, this.zmin); - points.add(p); - //p = projector.project(sx, sy, 10); - p = this.project(sx, sy, this.zmax); - points.add(p); - //p = projector.project(ex, ey, 10); - p = this.project(ex, ey, this.zmax); - points.add(p); - //p = projector.project(ex, ey, -10); - p = this.project(ex, ey, this.zmin); - points.add(p); - } - break; - case "z": - //zValue = (zValue - this.zmin) * zfactor - 10; - //p = projector.project(-10, -10, zValue); - p = this.project(this.xmin, this.ymin, zValue); - points.add(p); - //p = projector.project(-10, 10, zValue); - p = this.project(this.xmin, this.ymax, zValue); - points.add(p); - //p = projector.project(10, 10, zValue); - p = this.project(this.xmax, this.ymax, zValue); - points.add(p); - //p = projector.project(10, -10, zValue); - p = this.project(this.xmax, this.ymin, zValue); - points.add(p); - break; - } - java.awt.Shape oldRegion = g.getClip(); - if (points.size() > 3){ - for (Point pp : points) { - polygon.addPoint(pp.x, pp.y); - } - g.setClip(polygon); - } - - //Draw graphics - for (int i = 0; i < graphic.getNumGraphics(); i++) { - Graphic gg = graphic.getGraphicN(i); - if (gg.getShape().getShapeType() == ShapeTypes.Image) { - //g.setClip(oldRegion); - this.drawImage(g, gg, zdir, (float) ((GraphicCollection3D) graphic).getZValue()); - } else { - this.drawGrahic(g, gg); - } - } - - //Set clip to orgin - if (points.size() > 3){ - g.setClip(oldRegion); - } - } - - private void drawGrahpics(Graphics2D g, Graphic graphic) { - if (graphic.getNumGraphics() == 1) { - Graphic gg = graphic.getGraphicN(0); - this.drawGrahic(g, gg); - } else { - int n = graphic.getNumGraphics(); - double[] dds = new double[n]; - int[] order = new int[n]; - PointZ p; - double d; - float angle = projector.getRotationAngle(); - boolean xdir = true; - if (angle < 45 || angle > 135 && angle < 225 || angle > 315) { - xdir = false; - } - - if (xdir) { - for (int i = 0; i < n; i++) { - Graphic gg = graphic.getGraphicN(i); - Shape shape = gg.getShape(); - p = (PointZ) shape.getPoints().get(0); - d = p.X * projector.getSinRotationAngle(); - dds[i] = d; - order[i] = i; - } - } else { - for (int i = 0; i < graphic.getNumGraphics(); i++) { - Graphic gg = graphic.getGraphicN(i); - Shape shape = gg.getShape(); - p = (PointZ) shape.getPoints().get(0); - d = p.Y * projector.getCosRotationAngle(); - dds[i] = d; - order[i] = i; - } - } - - QuickSort.sort(dds, order); - - for (int i : order) { - Graphic gg = graphic.getGraphicN(i); - this.drawGrahic(g, gg); - } - } - } - - private void drawGrahpics_bak(Graphics2D g, Graphic graphic) { - if (graphic.getNumGraphics() == 1) { - Graphic gg = graphic.getGraphicN(0); - this.drawGrahic(g, gg); - } else { - List dds = new ArrayList<>(); - List order = new ArrayList<>(); - PointZ p; - double d; - boolean isIn; - float angle = projector.getRotationAngle(); - boolean xdir = true; - if (angle < 45 || angle > 135 && angle < 225 || angle > 315) { - xdir = false; - } - if (xdir) { - for (int i = 0; i < graphic.getNumGraphics(); i++) { - Graphic gg = graphic.getGraphicN(i); - Shape shape = gg.getShape(); - p = (PointZ) shape.getPoints().get(0); - d = p.X * projector.getSinRotationAngle(); - isIn = false; - for (int j = 0; j < dds.size(); j++) { - if (d < dds.get(j)) { - dds.add(j, d); - order.add(j, i); - isIn = true; - break; - } - } - if (!isIn) { - dds.add(d); - order.add(i); - } - } - } else { - for (int i = 0; i < graphic.getNumGraphics(); i++) { - Graphic gg = graphic.getGraphicN(i); - Shape shape = gg.getShape(); - p = (PointZ) shape.getPoints().get(0); - d = p.Y * projector.getCosRotationAngle(); - isIn = false; - for (int j = 0; j < dds.size(); j++) { - if (d < dds.get(j)) { - dds.add(j, d); - order.add(j, i); - isIn = true; - break; - } - } - if (!isIn) { - dds.add(d); - order.add(i); - } - } - } - - for (int i : order) { - Graphic gg = graphic.getGraphicN(i); - this.drawGrahic(g, gg); - } - } - } - - private void drawPoints(Graphics2D g, Graphic graphic) { - if (graphic.getNumGraphics() == 1) { - Graphic gg = graphic.getGraphicN(0); - drawPoint(g, gg); - } else { - List dds = new ArrayList<>(); - List order = new ArrayList<>(); - PointZ p; - double d; - boolean isIn; - float angle = projector.getRotationAngle(); - boolean xdir = true; - if (angle < 45 || angle > 135 && angle < 225 || angle > 315) { - xdir = false; - } - if (xdir) { - for (int i = 0; i < graphic.getNumGraphics(); i++) { - Graphic gg = graphic.getGraphicN(i); - PointZShape shape = (PointZShape) gg.getShape(); - p = (PointZ) shape.getPoint(); - d = p.X * projector.getSinRotationAngle(); - isIn = false; - for (int j = 0; j < dds.size(); j++) { - if (d < dds.get(j)) { - dds.add(j, d); - order.add(j, i); - isIn = true; - break; - } - } - if (!isIn) { - dds.add(d); - order.add(i); - } - } - } else { - for (int i = 0; i < graphic.getNumGraphics(); i++) { - Graphic gg = graphic.getGraphicN(i); - PointZShape shape = (PointZShape) gg.getShape(); - p = (PointZ) shape.getPoint(); - d = p.Y * projector.getCosRotationAngle(); - isIn = false; - for (int j = 0; j < dds.size(); j++) { - if (d < dds.get(j)) { - dds.add(j, d); - order.add(j, i); - isIn = true; - break; - } - } - if (!isIn) { - dds.add(d); - order.add(i); - } - } - } - - for (int i : order) { - Graphic gg = graphic.getGraphicN(i); - drawPoint(g, gg); - } - } - } - - /** - * Project 3D point - * - * @param x X - * @param y Y - * @param z Z - * @return Projected 2D point - */ - public Point project(float x, float y, float z) { - float px, py, pz; - if (this.xAxis instanceof LogAxis) - px = (float)(Math.log10(x) - Math.log10(xmin)) * xfactor - 10; - else - px = (x - xmin) * xfactor - 10; - if (this.yAxis instanceof LogAxis) - py = (float)(Math.log10(y) - Math.log10(ymin)) * yfactor - 10; - else - py = (y - ymin) * yfactor - 10; - if (this.zAxis instanceof LogAxis) - pz = (float)(Math.log10(z) - Math.log10(zmin)) * zfactor - 10; - else - pz = (z - zmin) * zfactor - 10; - return this.projector.project(px, py, pz); - } - - /** - * Project 3D point - * - * @param x X - * @param y Y - * @param z Z - * @return Projected 2D point - */ - public Point project_bak(float x, float y, float z) { - return this.projector.project((x - xmin) * xfactor - 10, - (y - ymin) * yfactor - 10, (z - zmin) * zfactor - 10); - } - - void drawText(ChartText3D text, Graphics2D g) { - float x, y; - Point p = this.project((float) text.getX(), (float) text.getY(), (float) text.getZ()); - x = p.x; - y = p.y; - this.drawText(g, text, x, y); - } - - private void drawText(Graphics2D g, ChartText3D text, float x, float y) { - AffineTransform tempTrans = g.getTransform(); - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform)tempTrans.clone(); - myTrans.translate(x, y); - if (text.getZDir() != null) { - text.updateAngle(projector); - float angle = text.getAngle() + 90; - myTrans.rotate(-angle * Math.PI / 180); - } - g.setTransform(myTrans); - g.setFont(text.getFont()); - g.setColor(text.getColor()); - x = 0; - y = 0; - switch (text.getYAlign()) { - case TOP: - y += g.getFontMetrics(g.getFont()).getAscent(); - break; - case CENTER: - y += g.getFontMetrics(g.getFont()).getAscent() / 2; - break; - } - String s = text.getText(); - Dimension labSize = Draw.getStringDimension(s, g); - switch (text.getXAlign()) { - case RIGHT: - x = x - labSize.width; - break; - case CENTER: - x = x - labSize.width / 2; - break; - } - Draw.drawString(g, s, x, y); - g.setTransform(tempTrans); - } - - private void drawPoint(Graphics2D g, Graphic graphic) { - if (extent.intersects(graphic.getExtent())) { - PointZShape shape = (PointZShape) graphic.getShape(); - PointBreak pb = (PointBreak) graphic.getLegend(); - PointZ p = (PointZ) shape.getPoint(); - /*PointZ pp = new PointZ((p.X - xmin) * xfactor - 10, (p.Y - ymin) * yfactor - 10, - (p.Z - this.zmin) * zfactor - 10); - projection = projector.project((float) pp.X, (float) pp.Y, (float) pp.Z);*/ - projection = this.project((float)p.X, (float)p.Y, (float)p.Z); - PointF pf = new PointF(projection.x, projection.y); - Draw.drawPoint(pf, pb, g); - } - } - - private void drawLineStrings(Graphics2D g, Graphic graphic) { - if (graphic.getNumGraphics() == 1) { - Graphic gg = graphic.getGraphicN(0); - drawLineString(g, gg); - } else { - List dds = new ArrayList<>(); - List order = new ArrayList<>(); - PointZ p; - double d; - boolean isIn; - float angle = projector.getRotationAngle(); - boolean xdir = true; - if (angle < 45 || angle > 135 && angle < 225 || angle > 315) { - xdir = false; - } - if (xdir) { - for (int i = 0; i < graphic.getNumGraphics(); i++) { - Graphic gg = graphic.getGraphicN(i); - Shape shape = gg.getShape(); - p = (PointZ) shape.getPoints().get(0); - d = p.X * projector.getSinRotationAngle(); - isIn = false; - for (int j = 0; j < dds.size(); j++) { - if (d < dds.get(j)) { - dds.add(j, d); - order.add(j, i); - isIn = true; - break; - } - } - if (!isIn) { - dds.add(d); - order.add(i); - } - } - } else { - for (int i = 0; i < graphic.getNumGraphics(); i++) { - Graphic gg = graphic.getGraphicN(i); - Shape shape = gg.getShape(); - p = (PointZ) shape.getPoints().get(0); - d = p.Y * projector.getCosRotationAngle(); - isIn = false; - for (int j = 0; j < dds.size(); j++) { - if (d < dds.get(j)) { - dds.add(j, d); - order.add(j, i); - isIn = true; - break; - } - } - if (!isIn) { - dds.add(d); - order.add(i); - } - } - } - - for (int i : order) { - Graphic gg = graphic.getGraphicN(i); - drawLineString(g, gg); - } - } - } - - private void drawLineString(Graphics2D g, Graphic graphic) { - if (extent.intersects(graphic.getExtent())) { - PolylineZShape shape = (PolylineZShape) graphic.getShape(); - ColorBreak pb = graphic.getLegend(); - for (Polyline line : shape.getPolylines()){ - List ps = (List)line.getPointList(); - PointF[] points = new PointF[ps.size()]; - PointZ p, pp; - for (int i = 0; i < ps.size(); i++) { - p = ps.get(i); - projection = this.project((float)p.X, (float)p.Y, (float)p.Z); - points[i] = new PointF(projection.x, projection.y); - } - if (pb.getBreakType() == BreakTypes.ColorBreakCollection) - Draw.drawPolyline(points, (ColorBreakCollection)pb, g); - else - Draw.drawPolyline(points, (PolylineBreak)pb, g); - } - } - } - - private void drawPolygons(Graphics2D g, Graphic graphic) { - List dds = new ArrayList<>(); - List order = new ArrayList<>(); - PointZ p; - double d; - boolean isIn; - float angle = projector.getRotationAngle(); - boolean xdir = true; - if (angle < 45 || angle > 135 && angle < 225 || angle > 315) { - xdir = false; - } - if (xdir) { - for (int i = 0; i < graphic.getNumGraphics(); i++) { - Graphic gg = graphic.getGraphicN(i); - Shape shape = gg.getShape(); - p = (PointZ) shape.getPoints().get(0); - d = p.X * projector.getSinRotationAngle(); - isIn = false; - for (int j = 0; j < dds.size(); j++) { - if (d < dds.get(j)) { - dds.add(j, d); - order.add(j, i); - isIn = true; - break; - } - } - if (!isIn) { - dds.add(d); - order.add(i); - } - } - } else { - for (int i = 0; i < graphic.getNumGraphics(); i++) { - Graphic gg = graphic.getGraphicN(i); - Shape shape = gg.getShape(); - p = (PointZ) shape.getPoints().get(0); - d = p.Y * projector.getCosRotationAngle(); - isIn = false; - for (int j = 0; j < dds.size(); j++) { - if (d < dds.get(j)) { - dds.add(j, d); - order.add(j, i); - isIn = true; - break; - } - } - if (!isIn) { - dds.add(d); - order.add(i); - } - } - } - - for (int i : order) { - Graphic gg = graphic.getGraphicN(i); - this.drawPolygonShape(g, gg); - } - } - - private void drawPolygonShape(Graphics2D g, Graphic graphic) { - if (extent.intersects(graphic.getExtent())) { - PolygonZShape shape = (PolygonZShape) graphic.getShape(); - PolygonBreak pb = (PolygonBreak) graphic.getLegend(); - for (PolygonZ poly : (List) shape.getPolygons()) { - drawPolygon(g, poly, pb); - } - } - } - - private List drawPolygon(Graphics2D g, PolygonZ aPG, PolygonBreak aPGB) { - int len = aPG.getOutLine().size(); - GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, len); - PointZ p, pp; - List rPoints = new ArrayList<>(); - for (int i = 0; i < aPG.getOutLine().size(); i++) { - p = ((List) aPG.getOutLine()).get(i); -// pp = new PointZ((p.X - xmin) * xfactor - 10, (p.Y - ymin) * yfactor - 10, -// (p.Z - this.zmin) * zfactor - 10); -// projection = projector.project((float) pp.X, (float) pp.Y, (float) pp.Z); - projection = this.project((float)p.X, (float)p.Y, (float)p.Z); - if (i == 0) { - path.moveTo(projection.x, projection.y); - } else { - path.lineTo(projection.x, projection.y); - } - rPoints.add(new PointF(projection.x, projection.y)); - } - - List newPList; - if (aPG.hasHole()) { - for (int h = 0; h < aPG.getHoleLines().size(); h++) { - newPList = (List) aPG.getHoleLines().get(h); - for (int j = 0; j < newPList.size(); j++) { - p = newPList.get(j); -// pp = new PointZ((p.X - xmin) * xfactor - 10, (p.Y - ymin) * yfactor - 10, -// (p.Z - this.zmin) * zfactor - 10); -// projection = projector.project((float) pp.X, (float) pp.Y, (float) pp.Z); - projection = this.project((float)p.X, (float)p.Y, (float)p.Z); - if (j == 0) { - path.moveTo(projection.x, projection.y); - } else { - path.lineTo(projection.x, projection.y); - } - } - } - } - path.closePath(); - - if (aPGB.isDrawFill()) { - Color aColor = aPGB.getColor(); - if (aPGB.isUsingHatchStyle()) { - int size = aPGB.getStyleSize(); - BufferedImage bi = Draw.getHatchImage(aPGB.getStyle(), size, aPGB.getColor(), aPGB.getBackColor()); - Rectangle2D rect = new Rectangle2D.Double(0, 0, size, size); - g.setPaint(new TexturePaint(bi, rect)); - g.fill(path); - } else { - g.setColor(aColor); - g.fill(path); - } - } - - if (aPGB.isDrawOutline()) { - BasicStroke pen = new BasicStroke(aPGB.getOutlineSize()); - g.setStroke(pen); - g.setColor(aPGB.getOutlineColor()); - g.draw(path); - } - - return rPoints; - } - - private void drawImage(Graphics2D g, Graphic igraphic, String zdir, float zValue) { - ImageShape ishape = (ImageShape) igraphic.getShape(); - BufferedImage image = ishape.getImage(); - Extent3D ext = (Extent3D) ishape.getExtent(); - Point p1, p2, p3, p4; - AffineTransform transform = new AffineTransform(); - transform.setToIdentity(); - float minx, miny, maxx, maxy, minz, maxz; - double angle, xscale, yscale, xtran, ytran; - switch (zdir) { - case "x": - /*zValue = (zValue - this.xmin) * xfactor - 10; - miny = ((float) ext.minY - ymin) * yfactor - 10; - maxy = ((float) ext.maxY - ymin) * yfactor - 10; - minz = ((float) ext.minZ - zmin) * zfactor - 10; - maxz = ((float) ext.maxZ - zmin) * zfactor - 10; - p1 = this.projector.project(zValue, miny, maxz); - p2 = this.projector.project(zValue, maxy, maxz); - p3 = this.projector.project(zValue, maxy, minz); - p4 = this.projector.project(zValue, miny, minz);*/ - p1 = this.project(zValue, (float)ext.minY, (float)ext.maxZ); - p2 = this.project(zValue, (float)ext.maxY, (float)ext.maxZ); - p3 = this.project(zValue, (float)ext.maxY, (float)ext.minZ); - p4 = this.project(zValue, (float)ext.minY, (float)ext.minZ); - xscale = (double) Math.abs(p2.x - p1.x) / image.getWidth(); - yscale = (double) Math.abs(p1.y - p4.y) / image.getHeight(); - xtran = p1.x; - ytran = p1.y; - if (p2.x > p1.x) { - angle = MIMath.cartesianToPolar(p2.x - p1.x, p1.y - p2.y)[0]; - } else { - angle = MIMath.cartesianToPolar(p1.x - p2.x, p2.y - p1.y)[0]; - xscale = -xscale; - } - angle = -angle; - transform.setTransform(Math.cos(angle), Math.sin(angle), 0, 1, xtran, ytran); - transform.scale(xscale / Math.cos(angle), yscale); - break; - case "y": - /*zValue = (zValue - this.ymin) * yfactor - 10; - minx = ((float) ext.minX - xmin) * xfactor - 10; - maxx = ((float) ext.maxX - xmin) * xfactor - 10; - minz = ((float) ext.minZ - zmin) * zfactor - 10; - maxz = ((float) ext.maxZ - zmin) * zfactor - 10; - p1 = this.projector.project(minx, zValue, maxz); - p2 = this.projector.project(maxx, zValue, maxz); - p3 = this.projector.project(maxx, zValue, minz); - p4 = this.projector.project(minx, zValue, minz);*/ - p1 = this.project((float)ext.minX, zValue, (float)ext.maxZ); - p2 = this.project((float)ext.maxX, zValue, (float)ext.maxZ); - p3 = this.project((float)ext.maxX, zValue, (float)ext.minZ); - p4 = this.project((float)ext.minX, zValue, (float)ext.minZ); - xscale = (double) Math.abs(p2.x - p1.x) / image.getWidth(); - yscale = (double) Math.abs(p1.y - p4.y) / image.getHeight(); - xtran = p1.x; - ytran = p1.y; - if (p2.x > p1.x) { - angle = MIMath.cartesianToPolar(p2.x - p1.x, p1.y - p2.y)[0]; - } else { - angle = MIMath.cartesianToPolar(p1.x - p2.x, p2.y - p1.y)[0]; - xscale = -xscale; - } - angle = -angle; - transform.setTransform(Math.cos(angle), Math.sin(angle), 0, 1, xtran, ytran); - transform.scale(xscale / Math.cos(angle), yscale); - break; - case "xy": - /*miny = ((float) ext.minY - ymin) * yfactor - 10; - maxy = ((float) ext.maxY - ymin) * yfactor - 10; - minx = ((float) ext.minX - xmin) * xfactor - 10; - maxx = ((float) ext.maxX - xmin) * xfactor - 10; - minz = ((float) ext.minZ - zmin) * zfactor - 10; - maxz = ((float) ext.maxZ - zmin) * zfactor - 10; - p1 = this.projector.project(minx, miny, maxz); - p2 = this.projector.project(maxx, maxy, maxz); - p3 = this.projector.project(maxx, maxy, minz); - p4 = this.projector.project(minx, miny, minz);*/ - p1 = this.project((float)ext.minX, (float)ext.minY, (float)ext.maxZ); - p2 = this.project((float)ext.maxX, (float)ext.maxY, (float)ext.maxZ); - p3 = this.project((float)ext.maxX, (float)ext.maxY, (float)ext.minZ); - p4 = this.project((float)ext.minX, (float)ext.minY, (float)ext.minZ); - xscale = (double) Math.abs(p2.x - p1.x) / image.getWidth(); - yscale = (double) Math.abs(p1.y - p4.y) / image.getHeight(); - xtran = p1.x; - ytran = p1.y; - if (p2.x > p1.x) { - angle = MIMath.cartesianToPolar(p2.x - p1.x, p1.y - p2.y)[0]; - } else { - angle = MIMath.cartesianToPolar(p1.x - p2.x, p2.y - p1.y)[0]; - xscale = -xscale; - } - angle = -angle; - transform.setTransform(Math.cos(angle), Math.sin(angle), 0, 1, xtran, ytran); - transform.scale(xscale / Math.cos(angle), yscale); - break; - case "z": - /*zValue = (zValue - this.zmin) * zfactor - 10; - minx = ((float) ext.minX - xmin) * xfactor - 10; - maxx = ((float) ext.maxX - xmin) * xfactor - 10; - miny = ((float) ext.minY - ymin) * yfactor - 10; - maxy = ((float) ext.maxY - ymin) * yfactor - 10; - p1 = this.projector.project(minx, maxy, zValue); - p2 = this.projector.project(maxx, maxy, zValue); - p3 = this.projector.project(maxx, miny, zValue); - p4 = this.projector.project(minx, miny, zValue);*/ - p1 = this.project((float)ext.minX, (float)ext.maxY, zValue); - p2 = this.project((float)ext.maxX, (float)ext.maxY, zValue); - p3 = this.project((float)ext.maxX, (float)ext.minY, zValue); - p4 = this.project((float)ext.minX, (float)ext.minY, zValue); - xscale = (double) Math.abs(p2.x - p1.x) / image.getWidth(); - yscale = (double) Math.abs(p1.y - p4.y) / image.getHeight(); - xtran = p1.x; - ytran = p1.y; - angle = MIMath.cartesianToPolar(p2.x - p1.x, p1.y - p2.y)[0]; - double angle_y = MIMath.cartesianToPolar(p4.x - p1.x, p4.y - p1.y)[0]; - if (p2.x < p1.x) { - xscale = -xscale; - yscale = -yscale; - } - angle = -angle; - angle_y = Math.PI * 0.5 - angle_y; - angle_y = -angle_y; - transform.setTransform(Math.cos(angle), Math.sin(angle), -Math.sin(angle_y), Math.cos(angle_y), xtran, ytran); - transform.scale(xscale / Math.cos(angle), yscale / Math.cos(angle_y)); - break; - } - g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, ishape.getInterpolation()); - g.drawImage(image, transform, null); - } - - private void drawWindArrow(Graphics2D g, Graphic graphic) { - if (extent.intersects(graphic.getExtent())) { - WindArrow3D shape = (WindArrow3D) graphic.getShape(); - PointBreak pb = (PointBreak) graphic.getLegend(); - PointZ p = (PointZ) shape.getPoint(); - /*PointZ pp = new PointZ((p.X - xmin) * xfactor - 10, (p.Y - ymin) * yfactor - 10, - (p.Z - this.zmin) * zfactor - 10); - projection = projector.project((float) pp.X, (float) pp.Y, (float) pp.Z);*/ - projection = this.project((float)p.X, (float)p.Y, (float)p.Z); - PointF pf = new PointF(projection.x, projection.y); - p = (PointZ)shape.getEndPoint(); - /*pp = new PointZ((p.X - xmin) * xfactor - 10, (p.Y - ymin) * yfactor - 10, - (p.Z - this.zmin) * zfactor - 10); - projection = projector.project((float) pp.X, (float) pp.Y, (float) pp.Z);*/ - projection = this.project((float)p.X, (float)p.Y, (float)p.Z); - PointF epf = new PointF(projection.x, projection.y); - PointF[] points = new PointF[]{pf, epf}; - Draw.drawArrow(points, pb, 4, g); - } - } - - /** - * Draws the base plane. The base plane is the x-y plane. - * - * @param g the graphics context to draw. - * @param x used to retrieve x coordinates of drawn plane from this method. - * @param y used to retrieve y coordinates of drawn plane from this method. - */ - private void drawBase(Graphics2D g, int[] x, int[] y) { - Point p = projector.project(-10, -10, -10); - x[0] = p.x; - y[0] = p.y; - p = projector.project(-10, 10, -10); - x[1] = p.x; - y[1] = p.y; - p = projector.project(10, 10, -10); - x[2] = p.x; - y[2] = p.y; - p = projector.project(10, -10, -10); - x[3] = p.x; - y[3] = p.y; - x[4] = x[0]; - y[4] = y[0]; - - g.setColor(this.boxColor); - g.fillPolygon(x, y, 4); - - g.setColor(this.gridLine.getColor()); - g.setStroke(new BasicStroke(this.gridLine.getSize())); - g.drawPolygon(x, y, 5); - } - - /** - * Draws string at the specified coordinates with the specified alignment. - * - * @param g graphics context to draw - * @param x the x coordinate - * @param y the y coordinate - * @param s the string to draw - * @param x_align the alignment in x direction - * @param y_align the alignment in y direction - */ - private void outString(Graphics2D g, int x, int y, String s, XAlign x_align, YAlign y_align) { - switch (y_align) { - case TOP: - y += g.getFontMetrics(g.getFont()).getAscent(); - break; - case CENTER: - y += g.getFontMetrics(g.getFont()).getAscent() / 2; - break; - } - switch (x_align) { - case LEFT: - g.drawString(s, x, y); - break; - case RIGHT: - g.drawString(s, x - g.getFontMetrics(g.getFont()).stringWidth(s), y); - break; - case CENTER: - g.drawString(s, x - g.getFontMetrics(g.getFont()).stringWidth(s) / 2, y); - break; - } - } - - private void outString(Graphics2D g, int x, int y, String s, XAlign x_align, YAlign y_align, float angle) { - AffineTransform tempTrans = g.getTransform(); - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform)tempTrans.clone(); - myTrans.translate(x, y); - myTrans.rotate(-angle * Math.PI / 180); - g.setTransform(myTrans); - x = 0; y = 0; - switch (y_align) { - case TOP: - y += g.getFontMetrics(g.getFont()).getAscent(); - break; - case CENTER: - y += g.getFontMetrics(g.getFont()).getAscent() / 2; - break; - } - Dimension labSize = Draw.getStringDimension(s, g); - switch (x_align) { - case RIGHT: - x = x - labSize.width; - break; - case CENTER: - x = x - labSize.width / 2; - break; - } - Draw.drawString(g, s, x, y); - g.setTransform(tempTrans); - } - - private void outString_bak(Graphics2D g, int x, int y, String s, XAlign x_align, YAlign y_align, float angle) { - switch (y_align) { - case TOP: - y += g.getFontMetrics(g.getFont()).getAscent(); - break; - case CENTER: - y += g.getFontMetrics(g.getFont()).getAscent() / 2; - break; - } - Dimension labSize = Draw.getStringDimension(s, g); - switch (x_align) { - case RIGHT: - x = x - labSize.width; - break; - case CENTER: - x = x - labSize.width / 2; - break; - } - - AffineTransform tempTrans = g.getTransform(); - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform)tempTrans.clone(); - myTrans.translate(x, y); - myTrans.rotate(-angle * Math.PI / 180); - g.setTransform(myTrans); - x = 0; y = 0; -// if (angle == 90) { -// x = -(int) (labSize.getWidth() - 10); -// y = (int) (labSize.getHeight() / 3); -// } else { -// x = -(int) (labSize.getWidth() - 5); -// y = 0; -// } - Draw.drawString(g, s, x, y); - g.setTransform(tempTrans); - } - - /** - * Sets the axes scaling factor. Computes the proper axis lengths based on - * the ratio of variable ranges. The axis lengths will also affect the size - * of bounding box. - */ - private void setAxesScale() { - float scale_x, scale_y, scale_z, divisor; - int longest; - - if (!isScaleBox) { - projector.setScaling(1); - t_x = t_y = t_z = 4; - return; - } - - scale_x = xmax - xmin; - scale_y = ymax - ymin; - scale_z = zmax - zmin; - - if (scale_x < scale_y) { - if (scale_y < scale_z) { - longest = 3; - divisor = scale_z; - } else { - longest = 2; - divisor = scale_y; - } - } else if (scale_x < scale_z) { - longest = 3; - divisor = scale_z; - } else { - longest = 1; - divisor = scale_x; - } - scale_x /= divisor; - scale_y /= divisor; - scale_z /= divisor; - - if ((scale_x < 0.2f) || (scale_y < 0.2f) && (scale_z < 0.2f)) { - switch (longest) { - case 1: - if (scale_y < scale_z) { - scale_y /= scale_z; - scale_z = 1.0f; - } else { - scale_z /= scale_y; - scale_y = 1.0f; - } - break; - case 2: - if (scale_x < scale_z) { - scale_x /= scale_z; - scale_z = 1.0f; - } else { - scale_z /= scale_x; - scale_x = 1.0f; - } - break; - case 3: - if (scale_y < scale_x) { - scale_y /= scale_x; - scale_x = 1.0f; - } else { - scale_x /= scale_y; - scale_y = 1.0f; - } - break; - } - } - if (scale_x < 0.2f) { - scale_x = 1.0f; - } - projector.setXScaling(scale_x); - if (scale_y < 0.2f) { - scale_y = 1.0f; - } - projector.setYScaling(scale_y); - if (scale_z < 0.2f) { - scale_z = 1.0f; - } - projector.setZScaling(scale_z); - - if (scale_x < 0.5f) { - t_x = 8; - } else { - t_x = 4; - } - if (scale_y < 0.5f) { - t_y = 8; - } else { - t_y = 4; - } - if (scale_z < 0.5f) { - t_z = 8; - } else { - t_z = 4; - } - } - - /** - * Draws float at the specified coordinates with the specified alignment. - * - * @param g graphics context to draw - * @param x the x coordinate - * @param y the y coordinate - * @param f the float to draw - * @param x_align the alignment in x direction - * @param y_align the alignment in y direction - */ - private void outFloat(Graphics2D g, int x, int y, float f, XAlign x_align, YAlign y_align) { - // String s = Float.toString(f); - String s = format(f); - outString(g, x, y, s, x_align, y_align); - } - - private String format(float f) { - return String.format("%.3G", f); - } - - private void drawAxes(Graphics2D g) { - int x[], y[], i; - x = new int[5]; - y = new int[5]; - drawBase(g, x, y); - projection = projector.project(0, 0, -10); - x[0] = projection.x; - y[0] = projection.y; - projection = projector.project(10.5f, 0, -10); - g.drawLine(x[0], y[0], projection.x, projection.y); - if (projection.x < x[0]) { - outString(g, (int) (1.05 * (projection.x - x[0])) + x[0], (int) (1.05 * (projection.y - y[0])) + y[0], "x", XAlign.RIGHT, YAlign.TOP); - } else { - outString(g, (int) (1.05 * (projection.x - x[0])) + x[0], (int) (1.05 * (projection.y - y[0])) + y[0], "x", XAlign.LEFT, YAlign.TOP); - } - projection = projector.project(0, 11.5f, -10); - g.drawLine(x[0], y[0], projection.x, projection.y); - if (projection.x < x[0]) { - outString(g, (int) (1.05 * (projection.x - x[0])) + x[0], (int) (1.05 * (projection.y - y[0])) + y[0], "y", XAlign.RIGHT, YAlign.TOP); - } else { - outString(g, (int) (1.05 * (projection.x - x[0])) + x[0], (int) (1.05 * (projection.y - y[0])) + y[0], "y", XAlign.LEFT, YAlign.TOP); - } - projection = projector.project(0, 0, 10.5f); - g.drawLine(x[0], y[0], projection.x, projection.y); - outString(g, (int) (1.05 * (projection.x - x[0])) + x[0], (int) (1.05 * (projection.y - y[0])) + y[0], "z", XAlign.CENTER, YAlign.CENTER); - } - - private int getLabelGap(Graphics2D g, List labels, double len) { - int n = labels.size(); - int nn; - FontMetrics metrics = g.getFontMetrics(); - nn = (int) (len / metrics.getHeight()); - if (nn == 0) { - nn = 1; - } - return n / nn + 1; - } - - private java.awt.Polygon getBorder() { - Point p; - java.awt.Polygon polygon = new java.awt.Polygon(); - float elevation = this.projector.getElevationAngle(); - float rotation = this.projector.getRotationAngle(); - if (elevation == 0 && ((rotation > 90 && rotation < 180) || (rotation > 270 && rotation < 360))) { - Rectangle rect = this.projector.getBounds(); - polygon.addPoint(rect.x, rect.y); - polygon.addPoint(rect.x, rect.y + rect.height); - polygon.addPoint(rect.x + rect.width, rect.y + rect.height); - polygon.addPoint(rect.x + rect.width, rect.y); - } else { - p = projector.project(factor_x * 10, -factor_y * 10, -10); - polygon.addPoint(p.x, p.y); - p = projector.project(factor_x * 10, -factor_y * 10, 10); - polygon.addPoint(p.x, p.y); - p = projector.project(-factor_x * 10, -factor_y * 10, 10); - polygon.addPoint(p.x, p.y); - p = projector.project(-factor_x * 10, factor_y * 10, 10); - polygon.addPoint(p.x, p.y); - p = projector.project(-factor_x * 10, factor_y * 10, -10); - polygon.addPoint(p.x, p.y); - p = projector.project(factor_x * 10, factor_y * 10, -10); - polygon.addPoint(p.x, p.y); - } - - return polygon; - } - - /** - * Draws bounding box, axis grids, axis ticks, axis labels, base plane. - * - * @param g the graphics context to draw - */ - private void drawBoxGridsTicksLabels(Graphics2D g) { - Point tickpos; - boolean x_left, y_left; - int x[], y[], i; - - x = new int[5]; - y = new int[5]; - if (projector == null) { - return; - } - - factor_x = factor_y = 1; - projection = projector.project(0, 0, -10); - x[0] = projection.x; - projection = projector.project(10.5f, 0, -10); - y_left = projection.x > x[0]; - i = projection.y; - projection = projector.project(-10.5f, 0, -10); - if (projection.y > i) { - factor_x = -1; - y_left = projection.x > x[0]; - } - projection = projector.project(0, 10.5f, -10); - x_left = projection.x > x[0]; - i = projection.y; - projection = projector.project(0, -10.5f, -10); - if (projection.y > i) { - factor_y = -1; - x_left = projection.x > x[0]; - } - setAxesScale(); - - //Draw base area - if (this.drawBase) - drawBase(g, x, y); - - //Draw box - if (isBoxed) { - projection = projector.project(-factor_x * 10, -factor_y * 10, -10); - x[0] = projection.x; - y[0] = projection.y; - projection = projector.project(-factor_x * 10, -factor_y * 10, 10); - x[1] = projection.x; - y[1] = projection.y; - projection = projector.project(factor_x * 10, -factor_y * 10, 10); - x[2] = projection.x; - y[2] = projection.y; - projection = projector.project(factor_x * 10, -factor_y * 10, -10); - x[3] = projection.x; - y[3] = projection.y; - x[4] = x[0]; - y[4] = y[0]; - - g.setColor(this.boxColor); - g.fillPolygon(x, y, 4); - - g.setColor(this.gridLine.getColor()); - g.setStroke(new BasicStroke(this.gridLine.getSize())); - g.drawPolygon(x, y, 5); - - projection = projector.project(-factor_x * 10, factor_y * 10, 10); - x[2] = projection.x; - y[2] = projection.y; - projection = projector.project(-factor_x * 10, factor_y * 10, -10); - x[3] = projection.x; - y[3] = projection.y; - x[4] = x[0]; - y[4] = y[0]; - - g.setColor(this.boxColor); - g.fillPolygon(x, y, 4); - - g.setColor(this.gridLine.getColor()); - g.setStroke(new BasicStroke(this.gridLine.getSize())); - g.drawPolygon(x, y, 5); - } /*else if (isDisplayZ) { - projection = projector.project(factor_x * 10, -factor_y * 10, -10); - x[0] = projection.x; - y[0] = projection.y; - projection = projector.project(factor_x * 10, -factor_y * 10, 10); - g.drawLine(x[0], y[0], projection.x, projection.y); - - projection = projector.project(-factor_x * 10, factor_y * 10, -10); - x[0] = projection.x; - y[0] = projection.y; - projection = projector.project(-factor_x * 10, factor_y * 10, 10); - g.drawLine(x[0], y[0], projection.x, projection.y); - }*/ - - //Draw axis - float v, vi; - String s; - double[] value; - float angle, xangle, yangle, xlen, ylen; - int skip; - if (this.isDisplayXY) { - //Draw x/y axis lines - //x axis line - projection = projector.project(-10, factor_y * 10, -10); - x[0] = projection.x; - y[0] = projection.y; - projection = projector.project(10, factor_y * 10, -10); - g.setColor(this.xAxis.getLineColor()); - g.drawLine(x[0], y[0], projection.x, projection.y); - if (projection.x > x[0]) { - value = DataMath.getDSFromUV(projection.x - x[0], projection.y - y[0]); - } else { - value = DataMath.getDSFromUV(x[0] - projection.x, y[0] - projection.y); - } - xangle = (float) value[0]; - xlen = (float) value[1]; - - //yaxis line - projection = projector.project(factor_x * 10, -10, -10); - x[0] = projection.x; - y[0] = projection.y; - projection = projector.project(factor_x * 10, 10, -10); - g.setColor(this.yAxis.getLineColor()); - g.drawLine(x[0], y[0], projection.x, projection.y); - if (projection.x > x[0]) { - value = DataMath.getDSFromUV(projection.x - x[0], projection.y - y[0]); - } else { - value = DataMath.getDSFromUV(x[0] - projection.x, y[0] - projection.y); - } - yangle = (float) value[0]; - ylen = (float) value[1]; - - //Draw x ticks - if (x_left) { - angle = yangle; - } else { - angle = yangle + 180; - if (angle > 360) { - angle -= 360; - } - } - g.setFont(this.xAxis.getTickLabelFont()); - this.xAxis.updateTickLabels(); - List tlabs = this.xAxis.getTickLabels(); - skip = getLabelGap(g, tlabs, Math.abs(xlen)); - int strWidth = 0, w; - for (i = 0; i < this.xAxis.getTickValues().length; i += skip) { - v = (float) this.xAxis.getTickValues()[i]; - if (i == tlabs.size()) { - break; - } - s = tlabs.get(i).getText(); - if (v < xmin || v > xmax) { - continue; - } - //vi = (v - xmin) * xfactor - 10; - //tickpos = projector.project(vi, factor_y * 10, -10); - tickpos = this.project(v, factor_y > 0 ? this.ymax : this.ymin, this.zmin); - if (this.gridLine.isDrawXLine() && (v != xmin && v != xmax)) { - //projection = projector.project(vi, -factor_y * 10, -10); - projection = this.project(v, factor_y < 0 ? this.ymax : this.ymin, this.zmin); - g.setColor(this.gridLine.getColor()); - g.setStroke(new BasicStroke(this.gridLine.getSize())); - g.drawLine(projection.x, projection.y, tickpos.x, tickpos.y); - if (this.isDisplayZ && this.isBoxed) { - x[0] = projection.x; - y[0] = projection.y; - //projection = projector.project(vi, -factor_y * 10, 10); - projection = this.project(v, factor_y < 0 ? this.ymax : this.ymin, this.zmax); - g.drawLine(x[0], y[0], projection.x, projection.y); - } - } - //projection = projector.project(vi, factor_y * 10.5f, -10); - value = DataMath.getEndPoint(tickpos.x, tickpos.y, angle, this.xAxis.getTickLength()); - g.setColor(this.xAxis.getLineColor()); - //g.drawLine(projection.x, projection.y, tickpos.x, tickpos.y); - g.drawLine(tickpos.x, tickpos.y, (int) value[0], (int) value[1]); - value = DataMath.getEndPoint(tickpos.x, tickpos.y, angle, this.xAxis.getTickLength() + 5); - tickpos = new Point((int) value[0], (int) value[1]); - if (x_left) { - //outString(g, tickpos.x, tickpos.y, s, XAlign.LEFT, YAlign.TOP); - Draw.drawString(g, tickpos.x, tickpos.y, s, XAlign.LEFT, YAlign.TOP, true); - } else { - //outString(g, tickpos.x, tickpos.y, s, XAlign.RIGHT, YAlign.TOP); - Draw.drawString(g, tickpos.x, tickpos.y, s, XAlign.RIGHT, YAlign.TOP, true); - } - //w = g.getFontMetrics().stringWidth(s); - w = Draw.getStringDimension(s, g).width; - if (strWidth < w) { - strWidth = w; - } - } - String label = this.xAxis.getLabel().getText(); - if (label != null) { - g.setFont(this.xAxis.getLabelFont()); - g.setColor(this.xAxis.getLabelColor()); - tickpos = projector.project(0, factor_y * 10.f, -10); - Dimension dim = Draw.getStringDimension(label, g); - strWidth = (int) Math.abs((strWidth * Math.sin(Math.toRadians(angle)))); - value = DataMath.getEndPoint(tickpos.x, tickpos.y, angle, this.xAxis.getTickLength() + strWidth + dim.height + 5); - tickpos.x = (int) value[0]; - tickpos.y = (int) value[1]; - if (this.projector.getElevationAngle() < 10) { - tickpos.y += g.getFontMetrics().getHeight(); - } - if (x_left) { - //outString(g, tickpos.x, tickpos.y, label, XAlign.CENTER, YAlign.TOP, xangle + 90); - Draw.drawString(g, tickpos.x, tickpos.y, label, XAlign.CENTER, YAlign.TOP, xangle + 90, true); - } else { - //outString(g, tickpos.x, tickpos.y, label, XAlign.CENTER, YAlign.TOP, xangle + 90); - Draw.drawString(g, tickpos.x, tickpos.y, label, XAlign.CENTER, YAlign.TOP, xangle + 90, true); - } - } - - //Draw y ticks - if (y_left) { - angle = xangle; - } else { - angle = xangle + 180; - if (angle > 360) { - angle -= 360; - } - } - g.setFont(this.yAxis.getTickLabelFont()); - this.yAxis.updateTickLabels(); - tlabs = this.yAxis.getTickLabels(); - skip = getLabelGap(g, tlabs, Math.abs(ylen)); - strWidth = 0; - for (i = 0; i < this.yAxis.getTickValues().length; i += skip) { - if (i >= tlabs.size()) - break; - - v = (float) this.yAxis.getTickValues()[i]; - s = tlabs.get(i).getText(); - if (v < ymin || v > ymax) { - continue; - } - //vi = (v - ymin) * yfactor - 10; - //tickpos = projector.project(factor_x * 10, vi, -10); - tickpos = this.project(factor_x > 0 ? this.xmax : this.xmin, v, this.zmin); - if (this.gridLine.isDrawYLine() && (v != ymin && v != ymax)) { - //projection = projector.project(-factor_x * 10, vi, -10); - projection = this.project(factor_x < 0 ? this.xmax : this.xmin, v, this.zmin); - g.setColor(this.gridLine.getColor()); - g.setStroke(new BasicStroke(this.gridLine.getSize())); - g.drawLine(projection.x, projection.y, tickpos.x, tickpos.y); - if (this.isDisplayZ && this.isBoxed) { - x[0] = projection.x; - y[0] = projection.y; - //projection = projector.project(-factor_x * 10, vi, 10); - projection = this.project(factor_x < 0 ? this.xmax : this.xmin, v, this.zmax); - g.drawLine(x[0], y[0], projection.x, projection.y); - } - } - value = DataMath.getEndPoint(tickpos.x, tickpos.y, angle, this.xAxis.getTickLength()); - g.setColor(this.yAxis.getLineColor()); - g.drawLine(tickpos.x, tickpos.y, (int) value[0], (int) value[1]); - value = DataMath.getEndPoint(tickpos.x, tickpos.y, angle, this.xAxis.getTickLength() + 5); - tickpos = new Point((int) value[0], (int) value[1]); - if (y_left) { - //outString(g, tickpos.x, tickpos.y, s, XAlign.LEFT, YAlign.TOP); - Draw.drawString(g, tickpos.x, tickpos.y, s, XAlign.LEFT, YAlign.TOP, true); - } else { - //outString(g, tickpos.x, tickpos.y, s, XAlign.RIGHT, YAlign.TOP); - Draw.drawString(g, tickpos.x, tickpos.y, s, XAlign.RIGHT, YAlign.TOP, true); - } - //w = g.getFontMetrics().stringWidth(s); - w = Draw.getStringDimension(s, g).width; - if (strWidth < w) { - strWidth = w; - } - } - label = this.yAxis.getLabel().getText(); - if (label != null) { - g.setFont(this.yAxis.getLabelFont()); - g.setColor(this.yAxis.getLabelColor()); - tickpos = projector.project(factor_x * 10.f, 0, -10); - Dimension dim = Draw.getStringDimension(label, g); - strWidth = (int) Math.abs((strWidth * Math.sin(Math.toRadians(angle)))); - value = DataMath.getEndPoint(tickpos.x, tickpos.y, angle, this.yAxis.getTickLength() + strWidth + dim.height + 5); - tickpos.x = (int) value[0]; - tickpos.y = (int) value[1]; - if (this.projector.getElevationAngle() < 10) { - tickpos.y += g.getFontMetrics().getHeight(); - } - if (y_left) { - //outString(g, tickpos.x, tickpos.y, label, XAlign.CENTER, YAlign.TOP, yangle + 90); - Draw.drawString(g, tickpos.x, tickpos.y, label, XAlign.CENTER, YAlign.TOP, yangle + 90, true); - } else { - //outString(g, tickpos.x, tickpos.y, label, XAlign.CENTER, YAlign.TOP, yangle + 90); - Draw.drawString(g, tickpos.x, tickpos.y, label, XAlign.CENTER, YAlign.TOP, yangle + 90, true); - } - } - } - - //Draw z axis - if (this.isDisplayZ) { - float lf = 1; - if (y_left) { - lf = -1; - } - projection = projector.project(factor_x * 10 * lf, -factor_y * 10 * lf, -10); - x[0] = projection.x; - y[0] = projection.y; - projection = projector.project(factor_x * 10 * lf, -factor_y * 10 * lf, 10); - g.setFont(this.zAxis.getTickLabelFont()); - g.setColor(this.zAxis.getLineColor()); - g.drawLine(x[0], y[0], projection.x, projection.y); - this.zAxis.updateTickLabels(); - List tlabs = this.zAxis.getTickLabels(); - int len = Math.abs(y[0] - projection.y); - skip = getLabelGap(g, tlabs, len); - int strWidth = 0, w; - for (i = 0; i < this.zAxis.getTickValues().length; i += skip) { - v = (float) this.zAxis.getTickValues()[i]; - s = tlabs.get(i).getText(); - if (v < zmin || v > zmax) { - continue; - } - //vi = (v - zmin) * zfactor - 10; - //tickpos = projector.project(factor_x * 10 * lf, -factor_y * 10 * lf, vi); - tickpos = this.project(factor_x * lf > 0 ? this.xmax : this.xmin, - factor_y * lf < 0 ? this.ymax : this.ymin, v); - if (this.gridLine.isDrawZLine() && this.isBoxed && (v != zmin && v != zmax)) { - //projection = projector.project(-factor_x * 10, -factor_y * 10, vi); - projection = this.project(factor_x < 0 ? this.xmax : this.xmin, - factor_y < 0 ? this.ymax : this.ymin, v); - g.setColor(this.gridLine.getColor()); - g.setStroke(new BasicStroke(this.gridLine.getSize())); - g.drawLine(projection.x, projection.y, tickpos.x, tickpos.y); - x[0] = projection.x; - y[0] = projection.y; - //projection = projector.project(-factor_x * 10 * lf, factor_y * 10 * lf, vi); - projection = this.project(factor_x * lf < 0 ? this.xmax : this.xmin, - factor_y * lf > 0 ? this.ymax : this.ymin, v); - g.drawLine(x[0], y[0], projection.x, projection.y); - } - //projection = projector.project(factor_x * 10.2f * lf, -factor_y * 10.2f * lf, vi); - g.setColor(this.zAxis.getLineColor()); - //g.drawLine(projection.x, projection.y, tickpos.x, tickpos.y); - g.drawLine(tickpos.x, tickpos.y, tickpos.x - (int)this.zAxis.getTickLength(), tickpos.y); - //tickpos = projector.project(factor_x * 10.5f * lf, -factor_y * 10.5f * lf, vi); - //outString(g, tickpos.x - this.zAxis.getTickLength() - 5, tickpos.y, s, XAlign.RIGHT, YAlign.CENTER); - Draw.drawString(g, tickpos.x - this.zAxis.getTickLength() - 5, tickpos.y, s, XAlign.RIGHT, YAlign.CENTER, true); - w = g.getFontMetrics().stringWidth(s); - if (strWidth < w) { - strWidth = w; - } - } - String label = this.zAxis.getLabel().getText(); - if (label != null) { - tickpos = projector.project(factor_x * 10 * lf, -factor_y * 10 * lf, 0); - tickpos.x = tickpos.x - (int)this.xAxis.getTickLength() - 15 - strWidth; - g.setFont(this.zAxis.getLabelFont()); - g.setColor(this.zAxis.getLabelColor()); - //Draw.drawLabelPoint_270(tickpos.x, tickpos.y, this.zAxis.getLabelFont(), label, - // this.zAxis.getLabelColor(), g, null, this.zAxis.getLabel().isUseExternalFont()); - Draw.drawString(g, tickpos.x, tickpos.y, label, XAlign.CENTER, YAlign.BOTTOM, 90, - this.zAxis.getLabel().isUseExternalFont()); - } - } - } - - /** - * Draws the bounding box of surface. - */ - private void drawBoundingBox(Graphics2D g2) { - Point startingpoint; - - startingpoint = projector.project(factor_x * 10, factor_y * 10, 10); - g2.setColor(this.gridLine.getColor()); - g2.setStroke(new BasicStroke(this.gridLine.getSize())); - projection = projector.project(-factor_x * 10, factor_y * 10, 10); - g2.drawLine(startingpoint.x, startingpoint.y, projection.x, projection.y); - projection = projector.project(factor_x * 10, -factor_y * 10, 10); - g2.drawLine(startingpoint.x, startingpoint.y, projection.x, projection.y); - projection = projector.project(factor_x * 10, factor_y * 10, -10); - g2.drawLine(startingpoint.x, startingpoint.y, projection.x, projection.y); - } - - /** - * Get tight inset area - * - * @param g Graphics2D - * @param positionArea Position area - * @return Tight inset area - */ - @Override - public Margin getTightInset(Graphics2D g, Rectangle2D positionArea) { - int left = 2, bottom = 2, right = 2, top = 5; - int space = 2; - - if (this.title != null) { - top += this.title.getTrueDimension(g).height + 10; - } - - if (!this.legends.isEmpty()) { - ChartLegend legend = this.getLegend(); - Dimension dim = legend.getLegendDimension(g, new Dimension((int) positionArea.getWidth(), - (int) positionArea.getHeight())); - switch (legend.getPosition()) { - case UPPER_CENTER_OUTSIDE: - top += dim.height + 10; - break; - case LOWER_CENTER_OUTSIDE: - bottom += dim.height + legend.getYShift() + 10; - break; - case LEFT_OUTSIDE: - left += dim.width + 10; - break; - case RIGHT_OUTSIDE: - right += dim.width + legend.getXShift() + 10; - break; - } - } - - //Get x axis space - //bottom += this.getXAxisHeight(g, space); - //Get y axis space - //left += this.getYAxisWidth(g, space); - //Set right space -// if (this.getXAxis().isVisible()) { -// if (this.getXAxis().isDrawTickLabel()) { -// right += this.getXAxis().getMaxLabelLength(g) / 2; -// } -// } - return new Margin(left, right, top, bottom); - } - - void drawLegend(Graphics2D g, Rectangle2D area, Rectangle2D graphArea, float y) { - if (!this.legends.isEmpty()) { - Object rendering = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING); - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - for (ChartLegend legend : this.legends) { - if (legend.isColorbar()) { - if (legend.getPlotOrientation() == PlotOrientation.VERTICAL) { - legend.setHeight((int) (graphArea.getHeight() * legend.getShrink())); - } else { - legend.setWidth((int) (graphArea.getWidth() * legend.getShrink())); - } - } - if (legend.getPosition() == LegendPosition.CUSTOM) { - legend.getLegendDimension(g, new Dimension((int) area.getWidth(), (int) area.getHeight())); - float x = (float) (area.getWidth() * legend.getX()); - y = (float) (area.getHeight() * (1 - (this.getLegend().getHeight() / area.getHeight()) - - this.getLegend().getY())); - legend.draw(g, new PointF(x, y)); - } else { - this.drawLegendScheme(legend, g, graphArea, y); - } - } - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, rendering); - } - } - - void drawLegendScheme(ChartLegend legend, Graphics2D g, Rectangle2D area, float y) { - g.setStroke(new BasicStroke(1)); - g.setFont(legend.getTickLabelFont()); - Dimension dim = legend.getLegendDimension(g, new Dimension((int) area.getWidth(), (int) area.getHeight())); - float x = 0; - //Rectangle2D graphArea = this.getPositionArea(); - switch (legend.getPosition()) { - case UPPER_CENTER_OUTSIDE: - x = (float) (area.getX() + area.getWidth() / 2 - dim.width / 2); - y += 5; - break; - case LOWER_CENTER_OUTSIDE: - x = (float) (area.getX() + area.getWidth() / 2 - dim.width / 2); - y = (float) (area.getY() + area.getHeight() + 10); - break; - case LEFT_OUTSIDE: - x = 10; - y = (float) area.getHeight() / 2 - dim.height / 2; - break; - case RIGHT_OUTSIDE: - x = (float) area.getX() + (float) area.getWidth() + 10 + 40; - y = (float) area.getY() + (float) area.getHeight() / 2 - dim.height / 2; - break; - case UPPER_CENTER: - x = (float) (area.getX() + area.getWidth() / 2 - dim.width / 2); - y = (float) area.getY() + 10; - break; - case UPPER_RIGHT: - x = (float) (area.getX() + area.getWidth()) - dim.width - 10; - y = (float) area.getY() + 10; - break; - case LOWER_CENTER: - x = (float) (area.getX() + area.getWidth() / 2 - dim.width / 2); - y = (float) (area.getY() + area.getHeight()) - dim.height - 10; - break; - case LOWER_RIGHT: - x = (float) (area.getX() + area.getWidth()) - dim.width - 10; - y = (float) (area.getY() + area.getHeight()) - dim.height - 10; - break; - case UPPER_LEFT: - x = (float) area.getX() + 10; - y = (float) area.getY() + 10; - break; - case LOWER_LEFT: - x = (float) area.getX() + 10; - y = (float) (area.getY() + area.getHeight()) - dim.height - 10; - break; - } - legend.draw(g, new PointF(x, y)); - } - - /** - * Get legend scheme - * - * @return Legend scheme - */ - public LegendScheme getLegendScheme() { - LegendScheme ls = null; - int n = this.graphics.getNumGraphics(); - for (int i = n - 1; i >= 0; i--) { - Graphic g = this.graphics.getGraphicN(i); - if (g instanceof GraphicCollection) { - ls = ((GraphicCollection)g).getLegendScheme(); - break; - } - } - - if (ls == null) { - ShapeTypes stype = ShapeTypes.Polyline; - ls = new LegendScheme(stype); - for (Graphic g : this.graphics.getGraphics()) { - ls.getLegendBreaks().add(g.getLegend()); - } - } - return ls; - } - - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/PlotOrientation.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/PlotOrientation.java deleted file mode 100644 index 8dfd68a4..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/PlotOrientation.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.plot; - -/** - * - * @author wyq - */ -public enum PlotOrientation { - VERTICAL, - HORIZONTAL -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/PlotSeries.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/PlotSeries.java deleted file mode 100644 index 26aad6c7..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/PlotSeries.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.plot; - -import org.meteoinfo.data.XYSeriesData; - -/** - * - * @author Yaqiang Wang - */ -public class PlotSeries { - // - private XYSeriesData data; - private SeriesLegend legend; - // - // - /** - * Construtor - * @param data Series data - * @param legend Series legend - */ - public PlotSeries(XYSeriesData data, SeriesLegend legend){ - this.data = data; - this.legend = legend; - } - // - // - /** - * Get series data - * @return Series data - */ - public XYSeriesData getData(){ - return this.data; - } - - /** - * Set series data - * @param value Series data - */ - public void setData(XYSeriesData value){ - this.data = value; - } - - /** - * Get series legend - * @return Series legend - */ - public SeriesLegend getLegend(){ - return this.legend; - } - - /** - * Set series legend - * @param value Series legend - */ - public void setLegend(SeriesLegend value){ - this.legend = value; - } - // - // - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/PlotType.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/PlotType.java deleted file mode 100644 index 63ce41a0..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/PlotType.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.plot; - -/** - * - * @author yaqiang - */ -public enum PlotType { - XY, - CATEGORY, - XY2D, - XYZ -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/PolarPlot.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/PolarPlot.java deleted file mode 100644 index db616afb..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/PolarPlot.java +++ /dev/null @@ -1,838 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.plot; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Graphics2D; -import java.awt.geom.Ellipse2D; -import java.awt.geom.Line2D; -import java.awt.geom.Rectangle2D; -import java.util.ArrayList; -import java.util.List; -import org.meteoinfo.chart.Margin; -import org.meteoinfo.common.*; -import org.meteoinfo.drawing.Draw; -import static org.meteoinfo.drawing.Draw.getDashPattern; - -import org.meteoinfo.geometry.legend.LineStyles; -import org.meteoinfo.geometry.graphic.Graphic; -import org.meteoinfo.geometry.graphic.GraphicCollection; -import org.meteoinfo.ndarray.util.BigDecimalUtil; - -/** - * - * @author Yaqiang Wang - */ -public class PolarPlot extends Plot2D { - - // - private double radius; - private double bottom = 0; - private Font xTickFont = new Font("Arial", Font.PLAIN, 12); - private Font yTickFont = new Font("Aria", Font.PLAIN, 12); - private Color xTickColor = Color.black; - private Color yTickColor = Color.black; - private List xTickLocations; - private List xTickLabels; - private boolean yTickAuto = true; - private List yTickLocations; - private List yTickLabels; - private float yTickLabelPos = 22.5f; - private String yTickFormat = ""; - - // - // - /** - * Constructor - */ - public PolarPlot() { - super(); - this.setAutoAspect(false); - GridLine gl = this.getGridLine(); - gl.setDrawXLine(true); - gl.setDrawYLine(true); - this.xTickLocations = new ArrayList<>(); - this.xTickLabels = new ArrayList<>(); - double angle = 0; - while (angle < 360) { - this.xTickLocations.add(angle); - String label = DataConvert.removeTailingZeros(String.valueOf(angle)) + String.valueOf((char) 186); - this.xTickLabels.add(label); - angle += 45; - } - } - // - // - /** - * Get max radius - * @return Max radius - */ - public double getRadius() { - return this.radius; - } - - /** - * Set max radius - * @param value Max radius - */ - public void setRadius(double value){ - this.radius = value + this.bottom; - super.setDrawExtent(new Extent(-this.radius, this.radius, -this.radius, this.radius)); - } - - /** - * Get radius bottom - calm wind in center circle - * @return Radius bottom - */ - public double getBottom() { - return this.bottom; - } - - /** - * Set radius bottom - * @param value Radius bottom - */ - public void setBottom(double value) { - this.bottom = value; - } - - /** - * Get x tick font - * @return X tick font - */ - public Font getXTickFont(){ - return this.xTickFont; - } - - /** - * Set x tick font - * @param value X tick font - */ - public void setXTickFont(Font value){ - this.xTickFont = value; - } - - /** - * Get y tick font - * @return Y tick font - */ - public Font getYTickFont(){ - return this.yTickFont; - } - - /** - * Set y tick font - * @param value Y tick font - */ - public void setYTickFont(Font value){ - this.yTickFont = value; - } - - /** - * Get x tick label color - * @return X tick label color - */ - public Color getXTickColor() {return this.xTickColor;} - - /** - * Set x tick label color - * @param value X tick label color - */ - public void setXTickColor(Color value) {this.xTickColor = value;} - - /** - * Get y tick label color - * @return Y tick label color - */ - public Color getYTickColor() {return this.yTickColor;} - - /** - * Set y tick label color - * @param value Y tick label color - */ - public void setYTickColor(Color value) {this.yTickColor = value;} - - /** - * Get x tick locations - * @return X tick locations - */ - public List getXTickLocations(){ - return this.xTickLocations; - } - - /** - * Set x tick locations - * @param value X tick locations - */ - public void setXTickLocations(List value){ - this.xTickLocations = new ArrayList<>(); - for (Number v : value) - this.xTickLocations.add(v.doubleValue()); - if (this.xTickLabels.size() != value.size()) { - this.xTickLabels = new ArrayList<>(); - String label; - for (Number v : value) { - label = DataConvert.removeTailingZeros(String.valueOf(v.floatValue())) + String.valueOf((char) 186); - this.xTickLabels.add(label); - } - } - } - - /** - * Get x tick labels - * @return X tick labels - */ - public List getXTickLabels(){ - return this.xTickLabels; - } - - /** - * Set x tick labels - * @param value X tick labels - */ - public void setXTickLabels(List value){ - this.xTickLabels = value; - } - - /** - * Get y tick locations - * @return Y tick locations - */ - public List getYTickLocations(){ - return this.yTickLocations; - } - - /** - * Set y tick locations - * @param value Y tick locations - */ - public void setYTickLocations(List value){ - this.yTickLocations = new ArrayList<>(); - for (Number v : value) - this.yTickLocations.add(v.doubleValue()); - this.yTickAuto = false; - } - - /** - * Get y tick labels - * @return Y tick labels - */ - public List getYTickLabels(){ - return this.yTickLabels; - } - - /** - * Set y tick labels - * @param value Y tick labels - */ - public void setYTickLabels(List value){ - this.yTickLabels = value; - this.yTickAuto = false; - } - - /** - * Get y tick label position - * @return Y tick label position - */ - public float getYTickLabelPos(){ - return this.yTickLabelPos; - } - - /** - * Set y tick label position - * @param value Y tick label position - */ - public void setYTickLabelPos(float value){ - this.yTickLabelPos = value; - } - - /** - * Get y tick format - * @return Y tick format - */ - public String getYTickFormat(){ - return this.yTickFormat; - } - - /** - * Set y tick format - * @param value Y tick format - */ - public void setYTickFormat(String value){ - this.yTickFormat = value; - } - // - // - /** - * Add a graphic - * - * @param g Graphic - */ - @Override - public void addGraphic(Graphic g) { - GraphicFactory.polarToCartesian((GraphicCollection) g, this.bottom); - super.addGraphic(g); - } - - /** - * Add a graphic by index - * - * @param idx Index - * @param g Graphic - */ - @Override - public void addGraphic(int idx, Graphic g) { - GraphicFactory.polarToCartesian((GraphicCollection) g, this.bottom); - super.addGraphic(idx, g); - } - - @Override - Extent getAutoExtent() { - Extent extent = this.getGraphics().getExtent(); - if (extent.minX == extent.maxX) { - extent.minX = extent.minX - Math.abs(extent.minX); - extent.maxX = extent.maxX + Math.abs(extent.minX); - } - if (extent.minY == extent.maxY) { - extent.minY = extent.minY - Math.abs(extent.minY); - extent.maxY = extent.maxY + Math.abs(extent.maxY); - } - - return extent; - } - - /** - * Set draw extent - * - * @param extent Extent - */ - @Override - public void setDrawExtent(Extent extent) { - double max = Math.abs(extent.minX); - max = Math.max(max, Math.abs(extent.maxX)); - max = Math.max(max, Math.abs(extent.minY)); - max = Math.max(max, Math.abs(extent.maxY)); - double[] values = (double[]) MIMath.getIntervalValues(0, max, true).get(0); - this.radius = values[values.length - 1] + this.bottom; - super.setDrawExtent(new Extent(-this.radius, this.radius, -this.radius, this.radius)); - } - - /** - * Get tight inset area - * - * @param g Graphics2D - * @param positionArea Position area - * @return Tight inset area - */ - @Override - public Margin getTightInset(Graphics2D g, Rectangle2D positionArea) { - int left = 2, bottom = 2, right = 2, top = 5; - - if (this.getTitle() != null) { - top += this.getTitle().getTrueDimension(g).height + 15; - } - - if (!this.getLegends().isEmpty()) { - Dimension dim = this.getLegend().getLegendDimension(g, new Dimension((int) positionArea.getWidth(), - (int) positionArea.getHeight())); - switch (this.getLegend().getPosition()) { - case UPPER_CENTER_OUTSIDE: - top += dim.height + 10; - break; - case LOWER_CENTER_OUTSIDE: - bottom += dim.height + 10; - break; - case LEFT_OUTSIDE: - left += dim.width + 10; - break; - case RIGHT_OUTSIDE: - right += dim.width + 10; - break; - } - } - - int space = 5; - if (this.xTickLabels != null && this.xTickLabels.size() > 0) { - g.setFont(xTickFont); - Dimension dim = Draw.getStringDimension(this.xTickLabels.get(0), g); - bottom += dim.height; - top += dim.height; - left += dim.width + space; - right += dim.width + space; - } - - return new Margin(left, right, top, bottom); - } - - /** - * Get graphic area - * - * @param g Graphic2D - * @param area Whole area - * @return Graphic area - */ - @Override - public Rectangle2D getGraphArea(Graphics2D g, Rectangle2D area) { - int left = 5, bottom = 5, right = 5, top = 5; - int space = 10; - - if (this.getTitle() != null) { - top += this.getTitle().getTrueDimension(g).height + 10; - } - - if (!this.getLegends().isEmpty()) { - Dimension dim = this.getLegend().getLegendDimension(g, new Dimension((int) area.getWidth(), (int) area.getHeight())); - switch (this.getLegend().getPosition()) { - case UPPER_CENTER_OUTSIDE: - top += dim.height + 10; - break; - case LOWER_CENTER_OUTSIDE: - bottom += dim.height + 10; - break; - case LEFT_OUTSIDE: - left += dim.width + 10; - break; - case RIGHT_OUTSIDE: - right += dim.width + 10; - break; - } - } - - //Get x axis space - bottom += space; - left += space; - top += space; - right += space; - - //Set area - Rectangle2D plotArea = new Rectangle2D.Double(left, top, - area.getWidth() - left - right, area.getHeight() - top - bottom); - return plotArea; - } - - /** - * Draw plot - * - * @param g Graphics2D - * @param area Drawing area - */ - @Override - public void draw(Graphics2D g, Rectangle2D area) { - // if the plot area is too small, just return... - boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW); - boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW); - if (b1 || b2) { - return; - } - - Rectangle2D graphArea; - graphArea = this.getPositionArea(); - this.setGraphArea(graphArea); - - //Draw title - this.drawTitle(g, graphArea); - - if (graphArea.getWidth() < 10 || graphArea.getHeight() < 10) { - return; - } - - //Draw background - if (this.background != null) { - g.setColor(this.getBackground()); - //g.fill(graphArea); - Ellipse2D ellipse=new Ellipse2D.Double(); - ellipse.setFrame(graphArea); - g.fill(ellipse); - } - - if (this.getGridLine().isTop()){ - //Draw graph - this.drawGraph(g, graphArea); - //Draw grid line - this.drawGridLine(g, graphArea); - } else { - //Draw grid line - this.drawGridLine(g, graphArea); - //Draw graph - this.drawGraph(g, graphArea); - } - this.drawGridLabel(g, graphArea); - - //Draw border circle - this.drawBorder(g, graphArea); - - //Draw neat line - if (this.isDrawNeatLine()) { - g.setStroke(new BasicStroke(1.0f)); - g.setColor(Color.black); - g.draw(graphArea); - } - - //Draw text - this.drawText(g, graphArea); - - //Draw legend - this.drawLegend(g, area, graphArea); - - } - - @Override - int getTopAxisHeight(Graphics2D g) { - g.setFont(xTickFont); - int height = Draw.getStringDimension("tick", g).height + 5; - return height; - } - - @Override - void drawGraph(Graphics2D g, Rectangle2D area) { - super.drawGraph(g, area); - } - - @Override - void drawGridLine(Graphics2D g, Rectangle2D area) { - GridLine gridLine = this.getGridLine(); - if (!gridLine.isDrawXLine() && !gridLine.isDrawYLine()) { - return; - } - - double[] xy; - double x, y; - double miny = area.getY(); - double minx = area.getX(); - - if (gridLine.getStyle() == LineStyles.SOLID) { - g.setStroke(new BasicStroke(gridLine.getSize())); - } else { - float[] dashPattern = getDashPattern(gridLine.getStyle()); - g.setStroke(new BasicStroke(gridLine.getSize(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, - 10.0f, dashPattern, 0.0f)); - } - - xy = this.projToScreen(0, 0, area); - double x0 = xy[0] + minx; - double y0 = xy[1] + miny; - //Draw straight grid lines - if (gridLine.isDrawXLine()) { - g.setFont(this.xTickFont); - float shift = 5; - for (int i = 0; i < this.xTickLocations.size(); i++) { - double angle = this.xTickLocations.get(i); - if (bottom != 0) { - xy = MIMath.polarToCartesian(Math.toRadians(angle), bottom); - xy = this.projToScreen(xy[0], xy[1], area); - x0 = xy[0] + minx; - y0 = xy[1] + miny; - } - xy = MIMath.polarToCartesian(Math.toRadians(angle), this.radius); - xy = this.projToScreen(xy[0], xy[1], area); - x = xy[0] + minx; - y = xy[1] + miny; - g.setColor(gridLine.getColor()); - g.draw(new Line2D.Double(x0, y0, x, y)); -// //Draw x tick label -// String label = this.xTickLabels.get(i); -// Dimension dim = Draw.getStringDimension(label, g); -// float w = dim.width; -// float h = dim.height; -// if (angle == 0 || angle == 180){ -// y = y + h * 0.5; -// if (angle == 0) -// x += shift; -// else { -// x -= w; -// x -= shift; -// } -// } else if (angle == 90 || angle == 270) { -// x = x - w * 0.5; -// if (angle == 90) -// y -= shift; -// else { -// y += h; -// y += shift; -// } -// } else if (angle > 0 && angle <= 45) { -// x += shift; -// } else if (angle > 45 && angle < 90) { -// y -= shift; -// } else if (angle > 90 && angle < 180) { -// x -= w; -// x -= shift; -// } else if (angle > 180 && angle <= 225) { -// x -= w; -// x -= shift; -// y += h; -// } else if (angle > 225 && angle < 270) { -// x -= w; -// x -= shift; -// y += h; -// } else if (angle > 270) { -// x += shift; -// y += h; -// } -// g.setColor(Color.black); -// g.drawString(label, (float) x, (float) y); - } - } - - //Draw y grid lines - if (gridLine.isDrawYLine()) { - g.setFont(this.yTickFont); - if (this.yTickAuto) - this.yTickLocations = this.getTickValues(); - - for (int i = 0; i < this.yTickLocations.size(); i++) { - double v = this.yTickLocations.get(i); - if (v > 0 && v < this.radius) { - g.setColor(gridLine.getColor()); - this.drawCircle(g, area, v + bottom); - } -// if (v > 0){ -// g.setColor(Color.black); -// xy = MIMath.polarToCartesian(Math.toRadians(this.yTickLabelPos), v); -// xy = this.projToScreen(xy[0], xy[1], area); -// x = xy[0]; -// y = xy[1]; -// x += minx; -// y += miny; -// String label; -// if (this.yTickLabels != null) -// label = this.yTickLabels.get(i); -// else { -// if (this.yTickFormat.equals("%")) -// label = DataConvert.removeTailingZeros(String.valueOf(BigDecimalUtil.mul(v, 100))) + "%"; -// else -// label = DataConvert.removeTailingZeros(String.valueOf(v)); -// } -// g.drawString(label, (float)x, (float)y); -// } - } - } - } - - void drawGridLabel_bak(Graphics2D g, Rectangle2D area) { - GridLine gridLine = this.getGridLine(); - if (!gridLine.isDrawXLine() && !gridLine.isDrawYLine()) { - return; - } - - double[] xy; - double x, y; - double miny = area.getY(); - double minx = area.getX(); - - //Draw straight grid lines - if (gridLine.isDrawXLine()) { - g.setFont(this.xTickFont); - float shift = 5; - for (int i = 0; i < this.xTickLocations.size(); i++) { - double angle = this.xTickLocations.get(i); - xy = MIMath.polarToCartesian(Math.toRadians(angle), this.radius); - xy = this.projToScreen(xy[0], xy[1], area); - x = xy[0]; - y = xy[1]; - x += minx; - y += miny; - //Draw x tick label - String label = this.xTickLabels.get(i); - Dimension dim = Draw.getStringDimension(label, g); - float w = dim.width; - float h = dim.height; - if (angle == 0 || angle == 180){ - y = y + h * 0.5; - if (angle == 0) - x += shift; - else { - x -= w; - x -= shift; - } - } else if (angle == 90 || angle == 270) { - x = x - w * 0.5; - if (angle == 90) - y -= shift; - else { - y += h; - y += shift; - } - } else if (angle > 0 && angle <= 45) { - x += shift; - } else if (angle > 45 && angle < 90) { - y -= shift; - } else if (angle > 90 && angle < 180) { - x -= w; - x -= shift; - } else if (angle > 180 && angle <= 225) { - x -= w; - x -= shift; - y += h; - } else if (angle > 225 && angle < 270) { - x -= w; - x -= shift; - y += h; - } else if (angle > 270) { - x += shift; - y += h; - } - g.setColor(Color.black); - g.drawString(label, (float) x, (float) y); - } - } - - //Draw y grid lines - if (gridLine.isDrawYLine()) { - g.setFont(this.yTickFont); - if (this.yTickAuto) - this.yTickLocations = this.getTickValues(); - - for (int i = 0; i < this.yTickLocations.size(); i++) { - double v = this.yTickLocations.get(i); - if (v > 0){ - g.setColor(Color.black); - xy = MIMath.polarToCartesian(Math.toRadians(this.yTickLabelPos), v); - xy = this.projToScreen(xy[0], xy[1], area); - x = xy[0]; - y = xy[1]; - x += minx; - y += miny; - String label; - if (this.yTickLabels != null) - label = this.yTickLabels.get(i); - else { - if (this.yTickFormat.equals("%")) - label = DataConvert.removeTailingZeros(String.valueOf(BigDecimalUtil.mul(v, 100))) + "%"; - else - label = DataConvert.removeTailingZeros(String.valueOf(v)); - } - g.drawString(label, (float)x, (float)y); - } - } - } - } - - void drawGridLabel(Graphics2D g, Rectangle2D area) { - GridLine gridLine = this.getGridLine(); - if (!gridLine.isDrawXLine() && !gridLine.isDrawYLine()) { - return; - } - - double[] xy; - double x, y; - double miny = area.getY(); - double minx = area.getX(); - - //Draw x grid line labels - if (gridLine.isDrawXLine()) { - g.setFont(this.xTickFont); - g.setColor(this.xTickColor); - float shift = 5; - for (int i = 0; i < this.xTickLocations.size(); i++) { - double angle = this.xTickLocations.get(i); - xy = MIMath.polarToCartesian(Math.toRadians(angle), this.radius); - xy = this.projToScreen(xy[0], xy[1], area); - x = xy[0]; - y = xy[1]; - x += minx; - y += miny; - //Draw x tick label - String label = this.xTickLabels.get(i); - Dimension dim = Draw.getStringDimension(label, g); - float w = dim.width; - float h = dim.height; - if (angle == 0 || angle == 180){ - if (angle == 0) { - x += shift; - Draw.drawString(g, (float)x, (float)y, label, XAlign.LEFT, YAlign.CENTER, false); - } - else { - x -= shift; - Draw.drawString(g, (float)x, (float)y, label, XAlign.RIGHT, YAlign.CENTER, false); - } - } else if (angle == 90 || angle == 270) { - if (angle == 90) { - y -= shift; - Draw.drawString(g, (float)x, (float)y, label, XAlign.CENTER, YAlign.BOTTOM, false); - } else { - y += shift; - Draw.drawString(g, (float)x, (float)y, label, XAlign.CENTER, YAlign.TOP, false); - } - } else if (angle > 0 && angle < 90) { - x += shift; - Draw.drawString(g, (float)x, (float)y, label, XAlign.LEFT, YAlign.BOTTOM, false); - } else if (angle > 90 && angle < 180) { - x -= shift; - Draw.drawString(g, (float)x, (float)y, label, XAlign.RIGHT, YAlign.BOTTOM, false); - } else if (angle > 180 && angle < 270) { - x -= shift; - Draw.drawString(g, (float)x, (float)y, label, XAlign.RIGHT, YAlign.TOP, false); - } else if (angle > 270) { - x += shift; - Draw.drawString(g, (float)x, (float)y, label, XAlign.LEFT, YAlign.TOP, false); - } - } - } - - //Draw y grid lines - if (gridLine.isDrawYLine()) { - g.setFont(this.yTickFont); - g.setColor(this.yTickColor); - if (this.yTickAuto) - this.yTickLocations = this.getTickValues(); - - for (int i = 0; i < this.yTickLocations.size(); i++) { - double v = this.yTickLocations.get(i); - if (v > 0 && v < this.radius){ - xy = MIMath.polarToCartesian(Math.toRadians(this.yTickLabelPos), v + bottom); - xy = this.projToScreen(xy[0], xy[1], area); - x = xy[0]; - y = xy[1]; - x += minx; - y += miny; - String label; - if (this.yTickLabels != null) - label = this.yTickLabels.get(i); - else { - if (this.yTickFormat.equals("%")) - label = DataConvert.removeTailingZeros(String.valueOf(BigDecimalUtil.mul(v, 100))) + "%"; - else - label = DataConvert.removeTailingZeros(String.valueOf(v)); - } - g.drawString(label, (float)x, (float)y); - } - } - } - } - - List getTickValues() { - //List r = MIMath.getIntervalValues1(0, this.radius); - double[] v = MIMath.getIntervalValues(0, radius, 4); - List vl = new ArrayList<>(); - for (double vv : v){ - vl.add(vv); - } - return vl; - } - - void drawBorder(Graphics2D g, Rectangle2D area) { - g.setColor(Color.black); - g.setStroke(new BasicStroke(1.f)); - //this.drawCircle(g, area, radius); - Ellipse2D ellipse=new Ellipse2D.Double(); - ellipse.setFrame(area); - g.draw(ellipse); - } - - void drawCircle(Graphics2D g, Rectangle2D area, double r) { - double[] xy = this.projToScreen(0, 0, area); - double x = xy[0] + area.getX(); - double y = xy[1] + area.getY(); - r = this.projXLength(r, area); - g.draw(new Ellipse2D.Double(x - r, y - r, 2 * r, 2 * r)); - } - - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/SeriesLegend.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/SeriesLegend.java deleted file mode 100644 index 88f3691a..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/SeriesLegend.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.plot; - -import org.meteoinfo.geometry.legend.ColorBreak; -import org.meteoinfo.geometry.legend.PointBreak; -import org.meteoinfo.geometry.legend.PolygonBreak; -import org.meteoinfo.geometry.legend.PolylineBreak; - -import java.awt.Color; -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author wyq - */ -public class SeriesLegend { - // - private ChartPlotMethod plotMethod; - private List legendBreaks; - private Color errorColor; - // - // - /** - * Constructor - */ - public SeriesLegend(){ - this.plotMethod = ChartPlotMethod.LINE; - this.legendBreaks = new ArrayList<>(); - this.errorColor = Color.black; - } - - /** - * Constructor - * @param cb ColorBreak - */ - public SeriesLegend(ColorBreak cb){ - this(); - this.legendBreaks.add(cb); - } - - /** - * Constructor - * @param n Break number - */ - public SeriesLegend(int n){ - this(); - for (int i = 0; i < n; i++) - this.legendBreaks.add(new PolylineBreak()); - } - // - // - /** - * Get plot method - * @return Plot method - */ - public ChartPlotMethod getPlotMethod(){ - return this.plotMethod; - } - - /** - * Set plot method - * @param value Plot method - */ - public void setPlotMethod(ChartPlotMethod value){ - this.plotMethod = value; - } - - /** - * Get if the legend is PointBreak - * @return Boolean - */ - public boolean isPoint(){ - return this.legendBreaks.get(0) instanceof PointBreak; - } - - /** - * Get if the legend is PolylineBreak - * @return Boolean - */ - public boolean isLine(){ - return this.legendBreaks.get(0) instanceof PolylineBreak; - } - - /** - * Get if the legend is PolygonBreak - * @return Boolean - */ - public boolean isPolygon(){ - return this.legendBreaks.get(0) instanceof PolygonBreak; - } - - /** - * Get if if mutiple legend breaks - * @return Boolean - */ - public boolean isMutiple(){ - return this.legendBreaks.size() > 1; - } - - /** - * Get a legend break - * @return Legend break - */ - public ColorBreak getLegendBreak(){ - return this.legendBreaks.get(0); - } - - /** - * Set legend break - * @param cb Legend break - */ - public void setLegendBreak(ColorBreak cb){ - this.legendBreaks.clear(); - this.legendBreaks.add(cb); - } - - /** - * Get a legend break - * @param idx Index - * @return Legend break - */ - public ColorBreak getLegendBreak(int idx){ - if (idx >= this.legendBreaks.size()) - idx = 0; - return this.legendBreaks.get(idx); - } - - /** - * Set legend break - * @param idx Index - * @param cb Legend break - */ - public void setLegendBreak(int idx, ColorBreak cb){ - this.legendBreaks.set(idx, cb); - } - - /** - * Get error color - * @return Error color - */ - public Color getErrorColor(){ - return this.errorColor; - } - - /** - * Set error color - * @param value Error color - */ - public void setErrorColor(Color value){ - this.errorColor = value; - } - // - // - /** - * Add a legend break - * @param cb Legend break - */ - public void addLegendBreak(ColorBreak cb){ - this.legendBreaks.add(cb); - } - - /** - * Get legend break number - * @return Legend break number - */ - public int getBreakNum(){ - return this.legendBreaks.size(); - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/XY1DPlot.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/XY1DPlot.java deleted file mode 100644 index 16e89cae..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/XY1DPlot.java +++ /dev/null @@ -1,865 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.plot; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.geom.AffineTransform; -import java.awt.geom.Line2D; -import java.awt.geom.Rectangle2D; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.meteoinfo.chart.ChartLegend; -import org.meteoinfo.chart.Location; -import org.meteoinfo.chart.axis.TimeAxis; -import org.meteoinfo.common.Extent; -import org.meteoinfo.common.MIMath; -import org.meteoinfo.common.PointF; -import org.meteoinfo.data.*; -import org.meteoinfo.drawing.Draw; -import org.meteoinfo.common.colors.ColorUtil; -import org.meteoinfo.geometry.legend.*; -import org.meteoinfo.geometry.shape.ShapeTypes; - -/** - * - * @author yaqiang - */ -public class XY1DPlot extends AbstractPlot2D { - - // - private XYListDataset dataset; - private ChartPlotMethod chartPlotMethod; - private List seriesLegends; - private boolean useBreak2D; - private float barWidth; - private boolean autoBarWidth; - - // - // - /** - * Constructor - */ - public XY1DPlot() { - super(); - - this.dataset = new XYListDataset(); - this.chartPlotMethod = ChartPlotMethod.LINE; - this.useBreak2D = false; - this.seriesLegends = new ArrayList<>(); - this.barWidth = 0.8f; - this.autoBarWidth = true; - } - - /** - * Constructor - * - * @param dateset Dataset - */ - public XY1DPlot(XYDataset dateset) { - this(); - this.setDataset(dateset); - } - - /** - * Constructor - * - * @param orientation Plot orientation - * @param dateset Dataset - */ - public XY1DPlot(PlotOrientation orientation, XYDataset dateset) { - this(); - this.setPlotOrientation(orientation); - this.setDataset(dateset); - } - - /** - * Constructor - * - * @param isTime If x axis is time - * @param dateset Dataset - */ - public XY1DPlot(boolean isTime, XYDataset dateset) { - this(); - if (isTime) { - try { - this.setXAxis(new TimeAxis("X", true)); - } catch (CloneNotSupportedException ex) { - Logger.getLogger(XY1DPlot.class.getName()).log(Level.SEVERE, null, ex); - } - this.getAxis(Location.TOP).setDrawTickLabel(false); - } - //this.getXAxis().setTimeAxis(isTime); - this.setDataset(dateset); - } - - /** - * Constructor - * - * @param isTime If x axis is time - * @param cpMethod Plot method - * @param dateset Dataset - */ - public XY1DPlot(boolean isTime, ChartPlotMethod cpMethod, XYDataset dateset) { - this(); - if (isTime) { - try { - this.setXAxis(new TimeAxis("X", true)); - } catch (CloneNotSupportedException ex) { - Logger.getLogger(XY1DPlot.class.getName()).log(Level.SEVERE, null, ex); - } - this.getAxis(Location.TOP).setDrawTickLabel(false); - } - //this.getXAxis().setTimeAxis(isTime); - this.setChartPlotMethod(cpMethod); - this.setDataset(dateset); - } - - /** - * Constructor - * - * @param isTime If x axis is time - * @param orientation Plot orientation - * @param dateset Dataset - */ - public XY1DPlot(boolean isTime, PlotOrientation orientation, XYDataset dateset) { - this(); - if (isTime) { - try { - this.setXAxis(new TimeAxis("X", true)); - } catch (CloneNotSupportedException ex) { - Logger.getLogger(XY1DPlot.class.getName()).log(Level.SEVERE, null, ex); - } - this.getAxis(Location.TOP).setDrawTickLabel(false); - } - //this.getXAxis().setTimeAxis(isTime); - this.setPlotOrientation(orientation); - this.setDataset(dateset); - } - - // - // - @Override - public XYDataset getDataset() { - return dataset; - } - - @Override - public void setDataset(Dataset value) { - dataset = (XYListDataset) value; - Extent extent = this.getAutoExtent(); - this.setDrawExtent(extent); - this.setExtent(extent); - this.updateSeriesLegend(); - } - - private void updateSeriesLegend() { - //this.seriesLegends.clear(); - int si = this.seriesLegends.size(); - if (si > dataset.getSeriesCount()) { - si = 0; - } - for (int i = si; i < dataset.getSeriesCount(); i++) { - Color color = ColorUtil.getCommonColor(i); - switch (this.chartPlotMethod) { - case LINE: - case LINE_POINT: - PolylineBreak plb = new PolylineBreak(); - if (this.chartPlotMethod == ChartPlotMethod.LINE) { - plb.setDrawSymbol(false); - } else { - plb.setDrawSymbol(true); - plb.setSymbolColor(color); - plb.setSymbolFillColor(color); - } - plb.setColor(color); - plb.setCaption(dataset.getSeriesKey(i)); - seriesLegends.add(new SeriesLegend(plb)); - break; - case POINT: - PointBreak pb = new PointBreak(); - pb.setColor(color); - pb.setCaption(dataset.getSeriesKey(i)); - seriesLegends.add(new SeriesLegend(pb)); - break; - case BAR: - PolygonBreak pgb = new PolygonBreak(); - pgb.setColor(color); - pgb.setCaption(dataset.getSeriesKey(i)); - seriesLegends.add(new SeriesLegend(pgb)); - break; - } - } - } - - /** - * Get chart plot method - * - * @return Chart plot method - */ - public ChartPlotMethod getChartPlotMethod() { - return this.chartPlotMethod; - } - - /** - * Set chart plot method - * - * @param value Chart plot method - */ - public void setChartPlotMethod(ChartPlotMethod value) { - this.chartPlotMethod = value; - if (this.dataset != null) { - this.updateSeriesLegend(); - } - } - - @Override - public PlotType getPlotType() { - return PlotType.XY; - } - - /** - * Get Series legend breaks - * - * @return Series legend breaks - */ - public List getLegendBreaks() { - return this.seriesLegends; - } - -// /** -// * Get point breaks -// * -// * @return Point breaks -// */ -// public PointBreak[] getPointBreaks() { -// return this.pointBreaks; -// } - /** - * If use item 2D point breaks - * - * @return Boolean - */ - public boolean isUseBreak2D() { - return this.useBreak2D; - } - - /** - * Set if use item 2D point breaks - * - * @param value Boolean - */ - public void setUseBeak2D(boolean value) { - this.useBreak2D = value; - } - - /** - * Get bar width ratio - * - * @return Bar width ratio - */ - public float getBarWidth() { - return this.barWidth; - } - - /** - * Set bar width ratio - * - * @param value Bar width ratio - */ - public void setBarWidth(float value) { - this.barWidth = value; - } - - /** - * Get if automatically decide bar width - * - * @return Boolean - */ - public boolean isAutoBarWidth() { - return this.autoBarWidth; - } - - /** - * Set if automatically decide bar height - * - * @param value Boolean - */ - public void setAutoBarWidth(boolean value) { - this.autoBarWidth = value; - } - - // - // - /** - * Add a series data - * - * @param seriesKey Series key - * @param xvs X value array - * @param yvs Y value array - */ - public void addSeries(String seriesKey, double[] xvs, double[] yvs) { - ((XYListDataset) this.dataset).addSeries(seriesKey, xvs, yvs); - PolylineBreak plb = new PolylineBreak(); - plb.setColor(ColorUtil.getCommonColor(this.dataset.getSeriesCount())); - plb.setCaption(seriesKey); - seriesLegends.add(new SeriesLegend(plb)); - - Extent extent = this.getAutoExtent(); - this.setDrawExtent(extent); - } - - /** - * Remove last series - */ - public void removeLastSeries() { - XYListDataset ds = (XYListDataset) this.dataset; - ds.removeSeries(dataset.getSeriesCount() - 1); - this.seriesLegends.remove(this.seriesLegends.size() - 1); - - Extent extent = this.getAutoExtent(); - this.setDrawExtent(extent); - } - - private PointF[] getScreenPoints(double[] xdata, double[] ydata, List mvIdx, Rectangle2D area) { - int len = xdata.length; - PointF[] points = new PointF[len]; - double[] xy; - if (this.getPlotOrientation() == PlotOrientation.VERTICAL) { - for (int j = 0; j < len; j++) { - xy = this.projToScreen(xdata[j], ydata[j], area); - points[j] = new PointF((float) xy[0], (float) xy[1]); - } - } else { - for (int j = 0; j < len; j++) { - xy = this.projToScreen(xdata[j], ydata[j], area); - points[j] = new PointF((float) xy[0], (float) xy[1]); - } - } -// if (this.getYAxis().isInverse()) { -// PointF[] npoints = new PointF[len]; -// PointF p; -// float y; -// for (int j = 0; j < len; j++) { -// p = points[len - j - 1]; -// y = (float) area.getHeight() - p.Y; -// npoints[j] = new PointF(p.X, y); -// } -// points = npoints; -// if (!mvIdx.isEmpty()) { -// for (int j = 0; j < mvIdx.size(); j++) { -// mvIdx.set(j, len - mvIdx.get(j) - 1); -// } -// } -// } -// if (this.getXAxis().isInverse()) { -// PointF[] npoints = new PointF[len]; -// PointF p; -// float x; -// for (int j = 0; j < len; j++) { -// p = points[len - j - 1]; -// x = (float) area.getWidth() - p.X; -// npoints[j] = new PointF(x, p.Y); -// } -// points = npoints; -// if (!mvIdx.isEmpty()) { -// for (int j = 0; j < mvIdx.size(); j++) { -// mvIdx.set(j, len - mvIdx.get(j) - 1); -// } -// } -// } - - return points; - } - - @Override - void drawGraph(Graphics2D g, Rectangle2D area) { - AffineTransform oldMatrix = g.getTransform(); - Rectangle oldRegion = g.getClipBounds(); - g.setClip(area); - g.translate(area.getX(), area.getY()); - - //Draw background - if (this.background != null) { - g.setColor(this.getBackground()); - g.fill(new Rectangle2D.Double(0, 0, area.getWidth(), area.getHeight())); - } - - double[] xy; - xy = this.projToScreen(0, 0, area); - float y0 = (float) xy[1]; - boolean drawBaseline = false; - for (int i = 0; i < this.dataset.getSeriesCount(); i++) { - XYSeriesData sdata = this.dataset.getSeriesData(i); - int len = sdata.dataLength(); - List mvIdx = sdata.getMissingValueIndex(); - PointF[] points = getScreenPoints(sdata.getXdata(), sdata.getYdata(), mvIdx, area); - SeriesLegend slegend = this.seriesLegends.get(i); - if (slegend.isLine()) { - if (mvIdx.isEmpty()) { - Draw.drawPolyline(points, (PolylineBreak) slegend.getLegendBreak(), g); - } else { - Draw.drawPolyline(points, (PolylineBreak) slegend.getLegendBreak(), g, mvIdx); - } - } else if (slegend.isPoint()) { - if (slegend.isMutiple()) { - for (int j = 0; j < len; j++) { - if (!mvIdx.contains(j)) { - Draw.drawPoint(points[j], (PointBreak) slegend.getLegendBreak(j), g); - } - } - } else { - for (int j = 0; j < len; j++) { - if (!mvIdx.contains(j)) { - Draw.drawPoint(points[j], (PointBreak) slegend.getLegendBreak(), g); - } - } - } - } else if (slegend.isPolygon()) { - switch (slegend.getPlotMethod()) { - case BAR: - if (sdata instanceof XYErrorSeriesData) { - drawBaseline = true; - XYErrorSeriesData esdata = (XYErrorSeriesData) sdata; - double[] bottom = esdata.getBottom(); - float[] yBottoms = null; - if (bottom != null) { - yBottoms = new float[bottom.length]; - for (int j = 0; j < bottom.length; j++) { - xy = this.projToScreen(esdata.getBottom(j), esdata.getBottom(j), area); - yBottoms[j] = (float) xy[1]; - } - } - float width = this.barWidth; - if (this.autoBarWidth) { - if (points.length > 1) { - width = (float) ((points[1].X - points[0].X) * 0.5) / this.dataset.getSeriesCount(); - } else { - width = (float) (area.getWidth() / 10) / this.dataset.getSeriesCount(); - } - float height; - PolygonBreak pgb; - for (int j = 0; j < len; j++) { - if (!mvIdx.contains(j)) { - pgb = (PolygonBreak) slegend.getLegendBreak(j); - height = Math.abs((float) (points[j].Y - y0)); - float yBottom = y0; - if (yBottoms != null) { - if (j < yBottoms.length) { - yBottom = yBottoms[j]; - } else { - yBottom = yBottoms[0]; - } - } - float yb = yBottom; - if (points[j].Y >= y0) { - yb += height; - } - Draw.drawBar(new PointF(points[j].X - width * this.dataset.getSeriesCount() / 2 - + i * width, yb), width, height, pgb, g, false, 5); - if (esdata.getYerror() != null) { - PointF p = (PointF) points[j].clone(); - p.Y -= y0 - yBottom; - double elen = 6; - double error = esdata.getYerror(j); - error = this.projYLength(error, area); - double x = p.X - width * this.dataset.getSeriesCount() / 2 - + i * width + width / 2; - g.setColor(slegend.getErrorColor()); - g.draw(new Line2D.Double(x, p.Y - error, x, p.Y + error)); - g.draw(new Line2D.Double(x - (elen * 0.5), p.Y - error, x + (elen * 0.5), p.Y - error)); - g.draw(new Line2D.Double(x - (elen * 0.5), p.Y + error, x + (elen * 0.5), p.Y + error)); - } - } - } - } else { - width = (float) this.projXLength(width, area); - float height; - PolygonBreak pgb; - for (int j = 0; j < len; j++) { - if (!mvIdx.contains(j)) { - pgb = (PolygonBreak) slegend.getLegendBreak(j); - height = Math.abs((float) (points[j].Y - y0)); - float yBottom = y0; - if (yBottoms != null) { - if (j < yBottoms.length) { - yBottom = yBottoms[j]; - } else { - yBottom = yBottoms[0]; - } - } - float yb = yBottom; - if (points[j].Y >= y0) { - yb += height; - } - Draw.drawBar(new PointF(points[j].X, yb), width, height, pgb, g, false, 5); - if (esdata.getYerror() != null) { - PointF p = (PointF) points[j].clone(); - p.Y -= y0 - yBottom; - double elen = 6; - double error = esdata.getYerror(j); - error = this.projYLength(error, area); - double x = p.X + width / 2; - g.setColor(slegend.getErrorColor()); - g.draw(new Line2D.Double(x, p.Y - error, x, p.Y + error)); - g.draw(new Line2D.Double(x - (elen * 0.5), p.Y - error, x + (elen * 0.5), p.Y - error)); - g.draw(new Line2D.Double(x - (elen * 0.5), p.Y + error, x + (elen * 0.5), p.Y + error)); - } - } - } - } - } else { - drawBaseline = true; - float width = this.barWidth; - if (this.autoBarWidth) { - if (points.length > 1) { - width = (float) ((points[1].X - points[0].X) * 0.5) / this.dataset.getSeriesCount(); - } else { - width = (float) (area.getWidth() / 10) / this.dataset.getSeriesCount(); - } - float height; - PolygonBreak pgb; - for (int j = 0; j < len; j++) { - if (!mvIdx.contains(j)) { - pgb = (PolygonBreak) slegend.getLegendBreak(j); - height = Math.abs((float) (points[j].Y - y0)); - float yb = y0; - if (points[j].Y >= y0) { - yb += height; - } - Draw.drawBar(new PointF(points[j].X - width * this.dataset.getSeriesCount() / 2 - + i * width, yb), width, height, pgb, g, false, 5); - } - } - } else { - width = (float) this.projXLength(width, area); - float height; - PolygonBreak pgb; - for (int j = 0; j < len; j++) { - if (!mvIdx.contains(j)) { - pgb = (PolygonBreak) slegend.getLegendBreak(j); - height = Math.abs((float) (points[j].Y - y0)); - float yb = y0; - if (points[j].Y >= y0) { - yb += height; - } - Draw.drawBar(new PointF(points[j].X, yb), width, height, pgb, g, false, 5); - } - } - } - } - break; - case FILL: - XYYSeriesData xyydata = (XYYSeriesData) sdata; - PointF[] y2Points = this.getScreenPoints(xyydata.getXdata(), xyydata.getY2data(), mvIdx, area); - if (xyydata.getWhere() == null) { - PointF[] npoints = new PointF[len * 2]; - for (int j = 0; j < len; j++) { - npoints[j] = points[len - j - 1]; - npoints[j + len] = y2Points[j]; - } - Draw.drawPolygon(npoints, (PolygonBreak) slegend.getLegendBreak(), g); - } else { - boolean ob = false; - List> idxs = new ArrayList<>(); - List idx = new ArrayList<>(); - for (int j = 0; j < len; j++) { - if (xyydata.getWhere().get(j)) { - if (!ob) { - idx = new ArrayList<>(); - } - idx.add(j); - } else if (ob) { - idxs.add(idx); - } - ob = xyydata.getWhere().get(j); - } - for (List index : idxs) { - int nn = index.size(); - if (nn >= 2) { - PointF[] npoints = new PointF[nn * 2]; - int ii, ii2; - for (int j = 0; j < nn; j++) { - ii = index.get(j); - ii2 = index.get(nn - j - 1); - npoints[j] = points[ii]; - npoints[j + index.size()] = y2Points[ii2]; - } - Draw.drawPolygon(npoints, (PolygonBreak) slegend.getLegendBreak(), g); - } - } - } - break; - } - } - - //Draw baseline - if (drawBaseline) { - g.setColor(Color.black); - g.draw(new Line2D.Double(0, y0, area.getWidth(), y0)); - } - - //Draw error bar - if (sdata instanceof XYErrorSeriesData) { - XYErrorSeriesData esdata = (XYErrorSeriesData) sdata; - g.setColor(slegend.getLegendBreak().getColor()); - PointF p; - double error; - double elen = 6; - if (esdata.getYerror() != null) { - if (slegend.getPlotMethod() == ChartPlotMethod.BAR) { - - } else { - for (int j = 0; j < len; j++) { - if (!mvIdx.contains(j)) { - p = points[j]; - error = esdata.getYerror(j); - error = this.projYLength(error, area); - g.draw(new Line2D.Double(p.X, p.Y - error, p.X, p.Y + error)); - g.draw(new Line2D.Double(p.X - (elen * 0.5), p.Y - error, p.X + (elen * 0.5), p.Y - error)); - g.draw(new Line2D.Double(p.X - (elen * 0.5), p.Y + error, p.X + (elen * 0.5), p.Y + error)); - } - } - } - } - if (esdata.getXerror() != null) { - for (int j = 0; j < len; j++) { - if (!mvIdx.contains(j)) { - p = points[j]; - error = esdata.getXerror(j); - error = this.projXLength(error, area); - g.draw(new Line2D.Double(p.X - error, p.Y, p.X + error, p.Y)); - g.draw(new Line2D.Double(p.X - error, p.Y - (elen * 0.5), p.X - error, p.Y + (elen * 0.5))); - g.draw(new Line2D.Double(p.X + error, p.Y - (elen * 0.5), p.X + error, p.Y + (elen * 0.5))); - } - } - } - } - } - - //Draw texts -// for (ChartText text : this.getTexts()) { -// xy = this.projToScreen(text.getX(), text.getY(), area); -// float x = (float) xy[0]; -// float y = (float) xy[1]; -// g.setFont(text.getFont()); -// g.setColor(text.getColor()); -// //Dimension dim = Draw.getStringDimension(text.getText(), g); -// //y -= dim.height * 2 / 3; -// Draw.drawString(g, text.getText(), x, y); -// } - g.setTransform(oldMatrix); - g.setClip(oldRegion); - } - - /** - * Get a item point break - * - * @param seriesIdx Series index - * @param itemIdx Item index - * @return Item point break; - */ - public PointBreak getItemPointBreak(int seriesIdx, int itemIdx) { - return (PointBreak) this.seriesLegends.get(seriesIdx).getLegendBreak(itemIdx); - } - - /** - * Set item point break - * - * @param seriesIdx Series index - * @param itemIdx Item index - * @param pb Item point break - */ - public void setItemPointBreak(int seriesIdx, int itemIdx, PointBreak pb) { - this.seriesLegends.get(seriesIdx).setLegendBreak(itemIdx, pb); - } - - /** - * Get legend break - * - * @param seriesIdx Series index - * @return Legend break - */ - public ColorBreak getLegendBreak(int seriesIdx) { - return this.seriesLegends.get(seriesIdx).getLegendBreak(); - } - - /** - * Set legend break - * - * @param seriesIdx Series index - * @param cb Legend break - */ - public void setLegendBreak(int seriesIdx, ColorBreak cb) { - this.seriesLegends.get(seriesIdx).setLegendBreak(cb); - } - - /** - * Set series legend - * - * @param seriesIdx Series index - * @param sLegend SeriesLegend - */ - public void setLegendBreak(int seriesIdx, SeriesLegend sLegend) { - this.seriesLegends.set(seriesIdx, sLegend); - } - -// /** -// * Get point break -// * -// * @param seriesIdx Series index -// * @return Point break -// */ -// public PointBreak getPointBreak(int seriesIdx) { -// return this.pointBreaks[seriesIdx]; -// } -// -// /** -// * Set point break -// * -// * @param seriesIdx Series index -// * @param pb Point break -// */ -// public void setPointBreak(int seriesIdx, PointBreak pb) { -// this.pointBreaks[seriesIdx] = pb; -// } -// -// /** -// * Get polygon break -// * -// * @param seriesIdx Series index -// * @return Polygon break -// */ -// public PolygonBreak getPolygonBreak(int seriesIdx) { -// return this.polygonBreaks[seriesIdx]; -// } -// -// /** -// * Set polygon break -// * -// * @param seriesIdx Series index -// * @param pgb Polygon break -// */ -// public void setPolygonBreak(int seriesIdx, PolygonBreak pgb) { -// this.polygonBreaks[seriesIdx] = pgb; -// } - private double getBarXInterval(int idx) { - double[] xvalues = this.dataset.getXValues(idx); - if (xvalues.length == 1) { - if (xvalues[0] == 0) { - return 1; - } else { - return xvalues[0] / 10; - } - } else { - return xvalues[1] - xvalues[0]; - } - } - - private int getBarIndex() { - int idx = -1; - for (int i = 0; i < this.seriesLegends.size(); i++) { - if (this.seriesLegends.get(i).getPlotMethod() == ChartPlotMethod.BAR) { - idx = i; - break; - } - } - return idx; - } - - /** - * Get auto extent - * - * @return Auto extent - */ - @Override - public Extent getAutoExtent() { - Extent extent = dataset.getDataExtent(); - if (extent.minX == extent.maxX){ - extent.minX = extent.minX - Math.abs(extent.minX); - extent.maxX = extent.maxX + Math.abs(extent.minX); - } - if (extent.minY == extent.maxY){ - extent.minY = extent.minY - Math.abs(extent.minY); - extent.maxY = extent.maxY + Math.abs(extent.maxY); - } - - int barIdx = this.getBarIndex(); - if (barIdx >= 0) { - double dx = getBarXInterval(barIdx); - extent.minX -= dx; - extent.maxX += dx; - } - double[] xValues; - if (this.getXAxis() instanceof TimeAxis) { - //if (this.getXAxis().isTimeAxis()) { - xValues = (double[]) MIMath.getIntervalValues(extent.minX, extent.maxX, false).get(0); - xValues[0] = extent.minX; - xValues[xValues.length - 1] = extent.maxX; - } else { - xValues = (double[]) MIMath.getIntervalValues(extent.minX, extent.maxX, true).get(0); - } - double[] yValues = (double[]) MIMath.getIntervalValues(extent.minY, extent.maxY, true).get(0); - if (this.getPlotOrientation() == PlotOrientation.VERTICAL) { - return new Extent(xValues[0], xValues[xValues.length - 1], yValues[0], yValues[yValues.length - 1]); - } else { - return new Extent(yValues[0], yValues[yValues.length - 1], xValues[0], xValues[xValues.length - 1]); - } - } - - /** - * Set auto extent - */ - @Override - public void setAutoExtent() { - Extent extent = this.getAutoExtent(); - this.setDrawExtent(extent); - } - - /** - * Get legend scheme - * - * @return Legend scheme - */ - public LegendScheme getLegendScheme() { -// LegendScheme ls = null; -// switch (this.chartPlotMethod) { -// case LINE: -// case LINE_POINT: -// ls = new LegendScheme(ShapeTypes.Polyline); -// ls.getLegendBreaks().addAll(Arrays.asList(this.lineBreaks)); -// break; -// case POINT: -// ls = new LegendScheme(ShapeTypes.Point); -// ls.getLegendBreaks().addAll(Arrays.asList(this.pointBreaks)); -// break; -// case BAR: -// ls = new LegendScheme(ShapeTypes.Polygon); -// ls.getLegendBreaks().addAll(Arrays.asList(this.polygonBreaks)); -// break; -// } - ShapeTypes stype = ShapeTypes.Polyline; - LegendScheme ls = new LegendScheme(stype); - for (SeriesLegend slegend : this.seriesLegends) { - ls.getLegendBreaks().add(slegend.getLegendBreak()); - } - return ls; - } - - @Override - public void updateLegendScheme() { - if (this.getLegend() == null) { - this.setLegend(new ChartLegend(this.getLegendScheme())); - } else { - this.getLegend().setLegendScheme(this.getLegendScheme()); - } - } - - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot3d/GraphicCollection3D.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot3d/GraphicCollection3D.java deleted file mode 100644 index e8aba60b..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot3d/GraphicCollection3D.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.plot3d; - -import java.util.List; -import org.meteoinfo.geometry.graphic.GraphicCollection; - -/** - * - * @author Yaqiang Wang - */ -public class GraphicCollection3D extends GraphicCollection{ - - private boolean fixZ; - private double zValue; - private String zdir; - private List sePoint; - protected boolean allQuads; - protected boolean allTriangle; - protected boolean allConvexPolygon; - protected boolean usingLight; - - /** - * Constructor - */ - public GraphicCollection3D(){ - super(); - fixZ = false; - zdir = "z"; - sePoint = null; - allQuads = false; - allTriangle = false; - allConvexPolygon = false; - usingLight = true; - } - - /** - * Get if is 3D - * @return Boolean - */ - @Override - public boolean is3D(){ - return true; - } - - /** - * Get if is fixed z graphics - * @return Boolean - */ - public boolean isFixZ(){ - return this.fixZ; - } - - /** - * Set if is fixed z graphics - * @param value Boolean - */ - public void setFixZ(boolean value){ - this.fixZ = value; - } - - /** - * Get fixed z value - * @return Fixed z value - */ - public double getZValue(){ - return this.zValue; - } - - /** - * Set fixed z value - * @param value Fixed z value - */ - public void setZValue(double value){ - this.zValue = value; - } - - /** - * Get z direction - x, y or z - * @return Z direction - */ - public String getZDir(){ - return this.zdir; - } - - /** - * Set z direction - x, y or z - * @param value Z direction - */ - public void setZDir(String value){ - this.zdir = value; - } - - /** - * Get start and end points [xstart, ystart, xend, yend] - * @return Start and end points - */ - public List getSEPoint(){ - return this.sePoint; - } - - /** - * Set start and end points - * @param value Start and end points - */ - public void setSEPoint(List value){ - this.sePoint = value; - } - - /** - * Get is all quads or not - * @return All quads or not - */ - public boolean isAllQuads() { - return this.allQuads; - } - - /** - * Set is all quads or not - * @param value All quads or not - */ - public void setAllQuads(boolean value) { - this.allQuads = value; - } - - /** - * Get is all triangle or not - * @return All triangle or not - */ - public boolean isAllTriangle() { - return this.allTriangle; - } - - /** - * Set is all triangle or not - * @param value All triangle or not - */ - public void setAllTriangle(boolean value) { - this.allTriangle = value; - } - - /** - * Get is all convex polygon or not - * @return All convex polygon or not - */ - public boolean isAllConvexPolygon() { - if (this.allConvexPolygon) { - return true; - } else { - return this.allQuads || this.allTriangle; - } - } - - /** - * Set is all convex polygon or not - * @param value All convex polygon or not - */ - public void setAllConvexPolygon(boolean value) { - this.allConvexPolygon = value; - } - - /** - * Get using light or not - * @return Boolean - */ - public boolean isUsingLight() { - return this.usingLight; - } - - /** - * Set using light or not - * @param value Boolean - */ - public void setUsingLight(boolean value) { - this.usingLight = value; - } -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot3d/ImageShape3D.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot3d/ImageShape3D.java deleted file mode 100644 index 57f9e4d1..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot3d/ImageShape3D.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.plot3d; - -import org.meteoinfo.geometry.shape.ImageShape; - -/** - * - * @author Yaqiang Wang - */ -public class ImageShape3D extends ImageShape { - private double zValue; - private String zdir; - - /** - * Constructor - */ - public ImageShape3D(){ - super(); - this.zValue = 0; - this.zdir = "z"; - } - - /** - * Get fixed z value - * @return Fixed z value - */ - public double getZValue(){ - return this.zValue; - } - - /** - * Set fixed z value - * @param value Fixed z value - */ - public void setZValue(double value){ - this.zValue = value; - } - - /** - * Get z direction - x, y or z - * @return Z direction - */ - public String getZDir(){ - return this.zdir; - } - - /** - * Set z direction - x, y or z - * @param value Z direction - */ - public void setZDir(String value){ - this.zdir = value; - } -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot3d/Projector.java b/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot3d/Projector.java deleted file mode 100644 index 0debf382..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot3d/Projector.java +++ /dev/null @@ -1,548 +0,0 @@ -/*----------------------------------------------------------------------------------------* - * Projector.java version 1.7 Nov 8 1996 * - * Projector.java version 1.71 May 14 1997 * - * * - * Copyright (c) Yanto Suryono * - * * - * This program is free software; you can redistribute it and/or modify it * - * under the terms of the GNU Lesser General Public License as published by the * - * Free Software Foundation; either version 2 of the License, or (at your option) * - * any later version. * - * * - * This program is distributed in the hope that it will be useful, but * - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for * - * more details. * - * * - * You should have received a copy of the GNU Lesser General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * * - *----------------------------------------------------------------------------------------*/ -package org.meteoinfo.chart.plot3d; - -import org.meteoinfo.data.DataMath; - -import java.awt.Point; -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.List; - -/** - * The class Projector projects points in 3D space to 2D space. - * - * @author Yanto Suryono - */ -public final class Projector { - - private float scale_x, scale_y, scale_z; // 3D scaling factor - private float distance; // distance to object - private float _2D_scale_x, _2D_scale_y; // 2D scaling factor - private float rotation, elevation; // rotation and elevation angle - private float sin_rotation, cos_rotation; // sin and cos of rotation angle - private float sin_elevation, cos_elevation; // sin and cos of elevation angle - private int _2D_trans_x, _2D_trans_y; // 2D translation - private int x1, x2, y1, y2; // projection area - private int center_x, center_y; // center of projection area - - private int trans_x, trans_y; - private float factor_x, factor_y; - private float sx_cos, sy_cos, sz_cos; - private float sx_sin, sy_sin, sz_sin; - - private final float DEGTORAD = (float) Math.PI / 180; - - //was static in SurfaceVertex ! now Dynamic in Projector - float zmin, zmax; - float zfactor; - - /** - * The constructor of Projector. - */ - public Projector() { - setScaling(1); - setRotationAngle(0); - setElevationAngle(0); - setDistance(10); - set2DScaling(1); - set2DTranslation(0, 0); - } - - /** - * Sets the projection area. - * - * @param r the projection area - */ - public void setProjectionArea(Rectangle r) { - x1 = r.x; - x2 = x1 + r.width; - y1 = r.y; - y2 = y1 + r.height; - center_x = (x1 + x2) / 2; - center_y = (y1 + y2) / 2; - - trans_x = center_x + _2D_trans_x; - trans_y = center_y + _2D_trans_y; - - this.update2DScaling(); - } - - /** - * Sets the rotation angle. - * - * @param angle the rotation angle in degrees - */ - public void setRotationAngle(float angle) { - rotation = angle; - sin_rotation = (float) Math.sin(angle * DEGTORAD); - cos_rotation = (float) Math.cos(angle * DEGTORAD); - - sx_cos = -scale_x * cos_rotation; - sx_sin = -scale_x * sin_rotation; - sy_cos = -scale_y * cos_rotation; - sy_sin = scale_y * sin_rotation; - } - - /** - * Gets current rotation angle. - * - * @return the rotation angle in degrees. - */ - public float getRotationAngle() { - return rotation; - } - - /** - * Gets the sine of rotation angle. - * - * @return the sine of rotation angle - */ - public float getSinRotationAngle() { - return sin_rotation; - } - - /** - * Gets the cosine of rotation angle. - * - * @return the cosine of rotation angle - */ - public float getCosRotationAngle() { - return cos_rotation; - } - - /** - * Sets the elevation angle. - * - * @param angle the elevation angle in degrees - */ - public void setElevationAngle(float angle) { - elevation = angle; - sin_elevation = (float) Math.sin(angle * DEGTORAD); - cos_elevation = (float) Math.cos(angle * DEGTORAD); - sz_cos = scale_z * cos_elevation; - sz_sin = scale_z * sin_elevation; - } - - /** - * Gets current elevation angle. - * - * @return the elevation angle in degrees. - */ - public float getElevationAngle() { - return elevation; - } - - /** - * Gets the sine of elevation angle. - * - * @return the sine of elevation angle - */ - public float getSinElevationAngle() { - return sin_elevation; - } - - /** - * Gets the cosine of elevation angle. - * - * @return the cosine of elevation angle - */ - public float getCosElevationAngle() { - return cos_elevation; - } - - /** - * Sets the projector distance. - * - * @param new_distance the new distance - */ - public void setDistance(float new_distance) { - distance = new_distance; - factor_x = distance * _2D_scale_x; - } - - /** - * Gets the projector distance. - * - * @return the projector distance - */ - public float getDistance() { - return distance; - } - - /** - * Sets the scaling factor in x direction. - * - * @param scaling the scaling factor - */ - public void setXScaling(float scaling) { - scale_x = scaling; - sx_cos = -scale_x * cos_rotation; - sx_sin = -scale_x * sin_rotation; - } - - /** - * Gets the scaling factor in x direction. - * - * @return the scaling factor - */ - public float getXScaling() { - return scale_x; - } - - /** - * Sets the scaling factor in y direction. - * - * @param scaling the scaling factor - */ - public void setYScaling(float scaling) { - scale_y = scaling; - sy_cos = -scale_y * cos_rotation; - sy_sin = scale_y * sin_rotation; - } - - /** - * Gets the scaling factor in y direction. - * - * @return the scaling factor - */ - public float getYScaling() { - return scale_y; - } - - /** - * Sets the scaling factor in z direction. - * - * @param scaling the scaling factor - */ - public void setZScaling(float scaling) { - scale_z = scaling; - sz_cos = scale_z * cos_elevation; - sz_sin = scale_z * sin_elevation; - } - - /** - * Gets the scaling factor in z direction. - * - * @return the scaling factor - */ - public float getZScaling() { - return scale_z; - } - - /** - * Sets the scaling factor in all direction. - * - * @param x the scaling factor in x direction - * @param y the scaling factor in y direction - * @param z the scaling factor in z direction - */ - public void setScaling(float x, float y, float z) { - scale_x = x; - scale_y = y; - scale_z = z; - - sx_cos = -scale_x * cos_rotation; - sx_sin = -scale_x * sin_rotation; - sy_cos = -scale_y * cos_rotation; - sy_sin = scale_y * sin_rotation; - sz_cos = scale_z * cos_elevation; - sz_sin = scale_z * sin_elevation; - } - - /** - * Sets the same scaling factor for all direction. - * - * @param scaling the scaling factor - */ - public void setScaling(float scaling) { - scale_x = scale_y = scale_z = scaling; - - sx_cos = -scale_x * cos_rotation; - sx_sin = -scale_x * sin_rotation; - sy_cos = -scale_y * cos_rotation; - sy_sin = scale_y * sin_rotation; - sz_cos = scale_z * cos_elevation; - sz_sin = scale_z * sin_elevation; - } - - /** - * Sets the 2D scaling factor. - * - * @param scaling the scaling factor - */ - public void set2DScaling(float scaling) { - _2D_scale_x = scaling; - _2D_scale_y = scaling; - factor_x = distance * _2D_scale_x; - factor_y = distance * _2D_scale_y; - } - - /** - * Sets the x 2D scaling factor. - * - * @param scaling the x scaling factor - */ - public void setX2DScaling(float scaling) { - _2D_scale_x = scaling; - factor_x = distance * _2D_scale_x; - } - - /** - * Sets the 2D scaling factor. - * - * @param scaling the scaling factor - */ - public void setY2DScaling(float scaling) { - _2D_scale_y = scaling; - factor_y = distance * _2D_scale_y; - } - - /** - * Gets the x 2D scaling factor. - * - * @return the x scaling factor - */ - public float getX2DScaling() { - return _2D_scale_x; - } - - /** - * Gets the x 2D scaling factor. - * - * @return the x scaling factor - */ - public float getY2DScaling() { - return _2D_scale_y; - } - - /** - * Sets the 2D translation. - * - * @param x the x translation - * @param y the y translation - */ - public void set2DTranslation(int x, int y) { - _2D_trans_x = x; - _2D_trans_y = y; - - trans_x = center_x + _2D_trans_x; - trans_y = center_y + _2D_trans_y; - } - - /** - * Sets the 2D x translation. - * - * @param x the x translation - */ - public void set2D_xTranslation(int x) { - _2D_trans_x = x; - trans_x = center_x + _2D_trans_x; - } - - /** - * Gets the 2D x translation. - * - * @return the x translation - */ - public int get2D_xTranslation() { - return _2D_trans_x; - } - - /** - * Sets the 2D y translation. - * - * @param y the y translation - */ - public void set2D_yTranslation(int y) { - _2D_trans_y = y; - trans_y = center_y + _2D_trans_y; - } - - /** - * Gets the 2D y translation. - * - * @return the y translation - */ - public int get2D_yTranslation() { - return _2D_trans_y; - } - - /** - * Projects 3D points. - * - * @param x the x coordinate - * @param y the y coordinate - * @param z the z coordinate - * @return Projected point - */ - public final Point project(float x, float y, float z) { - float temp; - - // rotates - temp = x; - x = x * sx_cos + y * sy_sin; - y = temp * sx_sin + y * sy_cos; - - // elevates and projects - //float temp_x = factor_x / (x * sin_elevation - z * sz_sin + distance); - float temp_x = factor_x / (y * cos_elevation - z * sz_sin + distance); - float temp_y = factor_y / (y * cos_elevation - z * sz_sin + distance); - return new Point((int) (Math.round(x * temp_x) + trans_x), - (int) (Math.round((y * sin_elevation + z * sz_cos) * -temp_y) + trans_y)); - } - - /** - * Project angle and length from two points - * @param x1 Point 1 x - * @param y1 Point 1 y - * @param z1 Point 1 z - * @param x2 Point 2 x - * @param y2 Point 2 y - * @param z2 Point 2 z - * @return Angle and length - */ - public double[] projectAL(float x1, float y1, float z1, float x2, float y2, float z2){ - Point p1 = project(x1, y1, z1); - Point p2 = project(x2, y2, z2); - float u = p2.x - p1.x; - float v = p2.y - p1.y; - return DataMath.getDSFromUV(u, v); - } - - /** - * Projects 3D points without scaling. - * - * @param x the x coordinate - * @param y the y coordinate - * @param z the z coordinate - * @return Projected point - */ - public final Point project_noScale(float x, float y, float z) { - float temp; - - // rotates - temp = x; - x = x * sx_cos + y * sy_sin; - y = temp * sx_sin + y * sy_cos; - - // elevates and projects - return new Point((int) (Math.round(x) + trans_x), - (int) (Math.round((y * sin_elevation + z * sz_cos)) + trans_y)); - } - - public void setZRange(float zmin, float zmax) { - this.zmin = zmin; - this.zmax = zmax; - this.zfactor = 20 / (zmax - zmin); - } - - /** - * Get bounds - * @return Bounds rectangle - */ - public Rectangle getBounds(){ - List ps = new ArrayList<>(); - ps.add(this.project(10, 10, 10)); - ps.add(this.project(-10, 10, 10)); - ps.add(this.project(10, -10, 10)); - ps.add(this.project(-10, -10, 10)); - ps.add(this.project(10, 10, -10)); - ps.add(this.project(-10, -10, -10)); - ps.add(this.project(-10, 10, -10)); - ps.add(this.project(10, -10, -10)); - int i = 0; - int minx =0, miny = 0, maxx = 0, maxy = 0; - for (Point p : ps){ - if (i == 0){ - minx = p.x; - maxx = p.x; - miny = p.y; - maxy = p.y; - } else { - if (minx > p.x) - minx = p.x; - else if (maxx < p.x) - maxx = p.x; - if (miny > p.y) - miny = p.y; - else if (maxy < p.y) - maxy = p.y; - } - i += 1; - } - - return new Rectangle(minx, miny, maxx - minx, maxy - miny); - } - - /** - * Get bounds without scale - * @return Bounds rectangle - */ - public Rectangle getBounds_noScale(){ - List ps = new ArrayList<>(); - ps.add(this.project_noScale(10, 10, 10)); - ps.add(this.project_noScale(-10, 10, 10)); - ps.add(this.project_noScale(10, -10, 10)); - ps.add(this.project_noScale(-10, -10, 10)); - ps.add(this.project_noScale(10, 10, -10)); - ps.add(this.project_noScale(-10, -10, -10)); - ps.add(this.project_noScale(-10, 10, -10)); - ps.add(this.project_noScale(10, -10, -10)); - int i = 0; - int minx =0, miny = 0, maxx = 0, maxy = 0; - for (Point p : ps){ - if (i == 0){ - minx = p.x; - maxx = p.x; - miny = p.y; - maxy = p.y; - } else { - if (minx > p.x) - minx = p.x; - else if (maxx < p.x) - maxx = p.x; - if (miny > p.y) - miny = p.y; - else if (maxy < p.y) - maxy = p.y; - } - i += 1; - } - - return new Rectangle(minx, miny, maxx - minx, maxy - miny); - } - - /** - * Update 2D scaling - */ - public void update2DScaling(){ - Rectangle rect = this.getBounds(); - float s1 = (float)((x2 - x1) / rect.getWidth()); - float s2 = (float)((y2 - y1) / rect.getHeight()); - s1 = s1 * this._2D_scale_x; - s2 = s2 * this._2D_scale_y; - this.setX2DScaling(s1); - this.setY2DScaling(s2); - } - -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/data/mapdata/FrmAttriData.java b/MeteoInfoLib/src/main/java/org/meteoinfo/data/mapdata/FrmAttriData.java deleted file mode 100644 index 077dec8e..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/data/mapdata/FrmAttriData.java +++ /dev/null @@ -1,415 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.data.mapdata; - -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.File; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.JFrame; -import javax.swing.JOptionPane; -import javax.swing.table.JTableHeader; - -import com.formdev.flatlaf.extras.FlatSVGUtils; -import org.meteoinfo.table.*; -import org.meteoinfo.ndarray.DataType; -import org.meteoinfo.layer.VectorLayer; - -/** - * - * @author Yaqiang Wang - */ -public class FrmAttriData extends javax.swing.JFrame { - - private VectorLayer _layer; - private DataTable _dataTable; - private boolean _isEditing = false; - - /** - * Creates new form FrmAttriData - */ - public FrmAttriData() { - initComponents(); - - this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - this.setIconImages(FlatSVGUtils.createWindowIconImages("/org/meteoinfo/icons/table.svg")); - - //this.jTable1.setColumnSelectionAllowed(true); - //this.jTable1.setRowSelectionAllowed(false); - final JTableHeader header = this.jTable1.getTableHeader(); - header.addMouseListener(new MouseAdapter() { - @Override - public void mouseReleased(MouseEvent e) { - - if (!e.isShiftDown()) { - jTable1.clearSelection(); - } - - //Get column index of the mouse point - int pick = header.columnAtPoint(e.getPoint()); - - //set select model - //jTable1.addColumnSelectionInterval(pick, pick); - jTable1.setColumnSelectionAllowed(true); - jTable1.setRowSelectionAllowed(false); - jTable1.setColumnSelectionInterval(pick, pick); - - if (_isEditing) { - jMenuItem_RemoveField.setEnabled(true); - jMenuItem_RenameField.setEnabled(true); - } - } - }); - this.jTable1.setDefaultEditor(Object.class, new MyCellEditor()); - this.jTable1.addMouseListener(new MouseAdapter() { - @Override - public void mouseReleased(MouseEvent e) { - jTable1.clearSelection(); - int pick = jTable1.rowAtPoint(e.getPoint()); - jTable1.setColumnSelectionAllowed(false); - jTable1.setRowSelectionAllowed(true); - jTable1.setRowSelectionInterval(pick, pick); - - if (jMenuItem_RemoveField.isEnabled()) { - jMenuItem_RemoveField.setEnabled(false); - } - if (jMenuItem_RenameField.isEnabled()) { - jMenuItem_RenameField.setEnabled(false); - } - } - }); - - this.jMenuItem_AddField.setEnabled(false); - this.jMenuItem_RemoveField.setEnabled(false); - this.jMenuItem_RenameField.setEnabled(false); - this.jMenuItem_StopEdit.setEnabled(false); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - jScrollPane1 = new javax.swing.JScrollPane(); - jTable1 = new javax.swing.JTable(); - jMenuBar1 = new javax.swing.JMenuBar(); - jMenu_Edit = new javax.swing.JMenu(); - jMenuItem_StartEdit = new javax.swing.JMenuItem(); - jMenuItem_StopEdit = new javax.swing.JMenuItem(); - jSeparator1 = new javax.swing.JPopupMenu.Separator(); - jMenuItem_AddField = new javax.swing.JMenuItem(); - jMenuItem_RemoveField = new javax.swing.JMenuItem(); - jMenuItem_RenameField = new javax.swing.JMenuItem(); - - setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - - jTable1.setModel(new javax.swing.table.DefaultTableModel( - new Object [][] { - {null, null, null, null}, - {null, null, null, null}, - {null, null, null, null}, - {null, null, null, null} - }, - new String [] { - "Title 1", "Title 2", "Title 3", "Title 4" - } - )); - jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); - jScrollPane1.setViewportView(jTable1); - - jMenu_Edit.setText("Edit"); - - jMenuItem_StartEdit.setText("Start Edit"); - jMenuItem_StartEdit.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuItem_StartEditActionPerformed(evt); - } - }); - jMenu_Edit.add(jMenuItem_StartEdit); - - jMenuItem_StopEdit.setText("Stop Edit"); - jMenuItem_StopEdit.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuItem_StopEditActionPerformed(evt); - } - }); - jMenu_Edit.add(jMenuItem_StopEdit); - jMenu_Edit.add(jSeparator1); - - jMenuItem_AddField.setText("Add Field"); - jMenuItem_AddField.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuItem_AddFieldActionPerformed(evt); - } - }); - jMenu_Edit.add(jMenuItem_AddField); - - jMenuItem_RemoveField.setText("Remove Field"); - jMenuItem_RemoveField.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuItem_RemoveFieldActionPerformed(evt); - } - }); - jMenu_Edit.add(jMenuItem_RemoveField); - - jMenuItem_RenameField.setText("Rename Field"); - jMenuItem_RenameField.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuItem_RenameFieldActionPerformed(evt); - } - }); - jMenu_Edit.add(jMenuItem_RenameField); - - jMenuBar1.add(jMenu_Edit); - - setJMenuBar(jMenuBar1); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 580, Short.MAX_VALUE) - .addGap(0, 0, 0)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE) - .addGap(0, 0, 0)) - ); - - pack(); - }// //GEN-END:initComponents - - private void jMenuItem_StartEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_StartEditActionPerformed - // TODO add your handling code here: - this.jMenuItem_StartEdit.setEnabled(false); - this.jMenuItem_AddField.setEnabled(true); - this.jMenuItem_StopEdit.setEnabled(true); - if (this.jTable1.getSelectedColumnCount() > 0) { - this.jMenuItem_RemoveField.setEnabled(true); - this.jMenuItem_RenameField.setEnabled(true); - } - this._isEditing = true; - - DataTableModel dataTableModel = new DataTableModel(_dataTable) { - @Override - public boolean isCellEditable(int row, int column) { - return true; - } - }; - this.jTable1.setModel(dataTableModel); - }//GEN-LAST:event_jMenuItem_StartEditActionPerformed - - private void jMenuItem_StopEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_StopEditActionPerformed - // TODO add your handling code here: - this.jMenuItem_StartEdit.setEnabled(true); - this.jMenuItem_AddField.setEnabled(false); - this.jMenuItem_RemoveField.setEnabled(false); - this.jMenuItem_RenameField.setEnabled(false); - this.jMenuItem_StopEdit.setEnabled(false); - this._isEditing = false; - - int result = JOptionPane.showConfirmDialog(null, "If save the edition?", "Confirm", JOptionPane.YES_NO_OPTION); - if (result == JOptionPane.YES_OPTION) { - this.saveDataTable(); - } else { - _dataTable = _layer.getAttributeTable().getTable().cloneTable_Field(); - } - - DataTableModel dataTableModel = new DataTableModel(_dataTable) { - @Override - public boolean isCellEditable(int row, int column) { - return false; - } - }; - this.jTable1.setModel(dataTableModel); - }//GEN-LAST:event_jMenuItem_StopEditActionPerformed - - private void jMenuItem_AddFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_AddFieldActionPerformed - // TODO add your handling code here: - FrmAddField frmField = new FrmAddField(null, true); - frmField.setLocationRelativeTo(this); - frmField.setVisible(true); - if (frmField.isOK()) { - String fieldName = frmField.getFieldName(); - if (fieldName.isEmpty()) { - JOptionPane.showMessageDialog(null, "Field name is empty!"); - return; - } - List fieldNames = _layer.getFieldNames(); - if (fieldNames.contains(fieldName)) { - JOptionPane.showMessageDialog(null, "Field name has exist in the data table!"); - return; - } - DataType dataType = frmField.getDataType(); - try { - _dataTable.addColumn(new Field(fieldName, dataType)); - //this.jTable1.revalidate(); - DataTableModel dataTableModel = new DataTableModel(_dataTable) { - @Override - public boolean isCellEditable(int row, int column) { - return true; - } - }; - this.jTable1.setModel(dataTableModel); - } catch (Exception ex) { - Logger.getLogger(FrmAttriData.class.getName()).log(Level.SEVERE, null, ex); - } - } - }//GEN-LAST:event_jMenuItem_AddFieldActionPerformed - - private void jMenuItem_RemoveFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_RemoveFieldActionPerformed - // TODO add your handling code here: - if (this.jTable1.getSelectedColumnCount() == 0) { - JOptionPane.showMessageDialog(null, "Please select one field firstly!"); - return; - } - - int fieldIdx = this.jTable1.getSelectedColumn(); - String fieldName = this.jTable1.getColumnName(fieldIdx); - int result = JOptionPane.showConfirmDialog(null, "If remove the field: " + fieldName + "?", "Confirm", - JOptionPane.YES_NO_OPTION); - if (result == JOptionPane.YES_OPTION) { - _dataTable.removeColumn(_dataTable.getColumns().get(fieldName)); - DataTableModel dataTableModel = new DataTableModel(_dataTable) { - @Override - public boolean isCellEditable(int row, int column) { - return true; - } - }; - this.jTable1.setModel(dataTableModel); - } - }//GEN-LAST:event_jMenuItem_RemoveFieldActionPerformed - - private void jMenuItem_RenameFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_RenameFieldActionPerformed - // TODO add your handling code here: - if (this.jTable1.getSelectedColumnCount() == 0) { - JOptionPane.showMessageDialog(null, "Please select one field firstly!"); - return; - } - - int fieldIdx = this.jTable1.getSelectedColumn(); - String fieldName = this.jTable1.getColumnName(fieldIdx); - String result = JOptionPane.showInputDialog(this, "Please input new field name:", fieldName); - if (result != null) { - if (result.isEmpty()){ - JOptionPane.showMessageDialog(null, "The field name is empty!"); - return; - } - List fieldNames = _dataTable.getColumnNames(); - if (fieldNames.contains(result)){ - JOptionPane.showMessageDialog(null, "The field name is exist!"); - return; - } - _dataTable.renameColumn(_dataTable.getColumns().get(fieldName), result); - DataTableModel dataTableModel = new DataTableModel(_dataTable) { - @Override - public boolean isCellEditable(int row, int column) { - return true; - } - }; - this.jTable1.setModel(dataTableModel); - } - }//GEN-LAST:event_jMenuItem_RenameFieldActionPerformed - - /** - * Set vector layer - * - * @param aLayer The vector layer - */ - public void setLayer(VectorLayer aLayer) { - _layer = aLayer; - _dataTable = _layer.getAttributeTable().getTable().cloneTable_Field(); - this.setTitle("Attribute Data - " + _layer.getLayerName()); - DataTableModel dataTableModel = new DataTableModel(_dataTable); - this.jTable1.setModel(dataTableModel); - this.jScrollPane1.setRowHeaderView(new RowHeaderTable(this.jTable1, 40)); - } - - private void saveDataTable() { -// for (int i = 0; i < _layer.getFieldNumber(); i++){ -// for (int j = 0; j < _layer.getShapeNum(); j++){ -// _layer.editCellValue(i, j, this.jTable1.getModel().getValueAt(j, i)); -// } -// } - - _layer.getAttributeTable().setTable(_dataTable.cloneTable_Field()); - if (new File(_layer.getFileName()).exists()) - _layer.getAttributeTable().save(); - else - _layer.saveFile(); - } - - /** - * @param args the command line arguments - */ - public static void main(String args[]) { - /* Set the Nimbus look and feel */ - // - /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. - * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html - */ - try { - for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { - if ("Nimbus".equals(info.getName())) { - javax.swing.UIManager.setLookAndFeel(info.getClassName()); - break; - } - } - } catch (ClassNotFoundException ex) { - java.util.logging.Logger.getLogger(FrmAttriData.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(FrmAttriData.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(FrmAttriData.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (javax.swing.UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(FrmAttriData.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } - // - - /* Create and display the dialog */ - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - FrmAttriData dialog = new FrmAttriData(); - dialog.addWindowListener(new java.awt.event.WindowAdapter() { - @Override - public void windowClosing(java.awt.event.WindowEvent e) { - System.exit(0); - } - }); - dialog.setVisible(true); - } - }); - } - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JMenuBar jMenuBar1; - private javax.swing.JMenuItem jMenuItem_AddField; - private javax.swing.JMenuItem jMenuItem_RemoveField; - private javax.swing.JMenuItem jMenuItem_RenameField; - private javax.swing.JMenuItem jMenuItem_StartEdit; - private javax.swing.JMenuItem jMenuItem_StopEdit; - private javax.swing.JMenu jMenu_Edit; - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JPopupMenu.Separator jSeparator1; - private javax.swing.JTable jTable1; - // End of variables declaration//GEN-END:variables -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/data/mapdata/MapDataManage.java b/MeteoInfoLib/src/main/java/org/meteoinfo/data/mapdata/MapDataManage.java deleted file mode 100644 index 81eee517..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/data/mapdata/MapDataManage.java +++ /dev/null @@ -1,747 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.data.mapdata; - -import org.meteoinfo.common.DataConvert; -import org.meteoinfo.common.Extent; -import org.meteoinfo.common.PointD; -import org.meteoinfo.common.util.GlobalUtil; -import org.meteoinfo.data.GridArray; -import org.meteoinfo.data.GridData; -import org.meteoinfo.data.mapdata.geotiff.GeoTiff; -import org.meteoinfo.data.meteodata.DrawMeteoData; -import org.meteoinfo.geometry.legend.LegendScheme; -import org.meteoinfo.geometry.legend.LegendType; -import org.meteoinfo.geoprocess.GeometryUtil; -import org.meteoinfo.ndarray.DataType; -import org.meteoinfo.layer.ImageLayer; -import org.meteoinfo.layer.LayerDrawType; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.layer.WorldFilePara; -import org.meteoinfo.legend.LegendManage; -import org.meteoinfo.geometry.shape.PolylineShape; -import org.meteoinfo.geometry.shape.ShapeTypes; -import java.awt.Color; -import java.awt.image.BufferedImage; -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.DataInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.imageio.ImageIO; -import javax.swing.JOptionPane; - -import org.meteoinfo.data.meteodata.ascii.ASCIIGridDataInfo; -import org.meteoinfo.data.meteodata.ascii.SurferGridDataInfo; -import org.meteoinfo.data.meteodata.bandraster.BILDataInfo; -import org.meteoinfo.common.io.IOUtil; -import org.meteoinfo.layer.RasterLayer; -import org.meteoinfo.projection.KnownCoordinateSystems; -import org.meteoinfo.projection.ProjectionInfo; -import org.meteoinfo.geometry.shape.PointShape; -import org.meteoinfo.geometry.shape.PolygonShape; -import org.meteoinfo.geometry.shape.Shape; -import org.meteoinfo.ndarray.Array; -import org.meteoinfo.table.Field; - -/** - * - * @author yaqiang - */ -public class MapDataManage { - - /** - * Can open or not as a map layer - * - * @param fileName File name - * @return MapDataType - * @throws java.io.FileNotFoundException - */ - public static MapDataType canOpen(String fileName) throws FileNotFoundException, IOException { - MapDataType mdt = null; - if (new File(fileName).isFile()) { - String ext = GlobalUtil.getFileExtension(fileName); - switch (ext.toLowerCase()) { - case "shp": - mdt = MapDataType.SHAPE; - break; - case "wmp": - mdt = MapDataType.WMP; - break; - case "bmp": - case "gif": - case "jpg": - case "png": - mdt = MapDataType.IMAGE; - break; - case "tif": - mdt = MapDataType.GEO_TIFF; - break; - case "bil": - case "bip": - case "bsq": - mdt = MapDataType.BIL; - break; - default: - RandomAccessFile br = new RandomAccessFile(fileName, "r"); - byte[] bytes = new byte[100]; - br.read(bytes); - String line = new String(bytes).trim().toUpperCase(); - br.close(); - if (line.contains("NCOLS")) { - mdt = MapDataType.ESRI_ASCII_GRID; - } else if (line.contains("DSAA")) { - mdt = MapDataType.SURFER_ASCII_GRID; - } else { - mdt = MapDataType.GRADS; - } - break; - } - } - - return mdt; - } - - /** - * Load a layer from a file - * - * @param aFile The file path - * @return The layer - * @throws java.io.IOException - * @throws java.io.FileNotFoundException - */ - public static MapLayer loadLayer(String aFile) throws IOException, FileNotFoundException, Exception { - MapDataType mdt = canOpen(aFile); - if (mdt == null) { - return null; - } - - MapLayer aLayer = null; - switch (mdt) { - case SHAPE: - aLayer = readMapFile_ShapeFile(aFile); - break; - case WMP: - aLayer = readMapFile_WMP(aFile); - break; - case IMAGE: - aLayer = readImageFile(aFile); - break; - case GEO_TIFF: - aLayer = readGeoTiffFile(aFile); - break; - case BIL: - aLayer = readBILFile(aFile); - break; - case ESRI_ASCII_GRID: - aLayer = readESRI_ASCII_GRID(aFile); - break; - case SURFER_ASCII_GRID: - aLayer = readSurfer_ASCII_GRID(aFile); - break; - case GRADS: - aLayer = readMapFile_GrADS(aFile); - break; - } - - if (aLayer != null) { - switch (mdt) { - case BIL: - case ESRI_ASCII_GRID: - case SURFER_ASCII_GRID: - String projFn = aFile.substring(0, aFile.length() - 4) + ".prj"; - File pFile = new File(projFn); - if (pFile.isFile()) { - ProjectionInfo projInfo = ShapeFileManage.loadProjFile(pFile); - aLayer.setProjInfo(projInfo); - } - break; - } - } - - return aLayer; - } - - /** - * Load a layer from a file with a certain projection - * - * @param aFile The file name - * @param projInfo The projection - * @return The layer - * @throws IOException - * @throws FileNotFoundException - * @throws Exception - */ - public static MapLayer loadLayer(String aFile, ProjectionInfo projInfo) throws IOException, FileNotFoundException, Exception { - MapLayer layer = loadLayer(aFile); - layer.setProjInfo(projInfo); - - return layer; - } - - /** - * Read shape file as map - * - * @param fn File name - * @return Vector layer - * @throws java.io.IOException - * @throws java.io.FileNotFoundException - */ - public static VectorLayer readMapFile_ShapeFile(String fn) throws IOException, FileNotFoundException, Exception { - String encoding = IOUtil.encodingDetectShp(fn); - if (encoding.equals("ISO8859_1")) { - encoding = "UTF-8"; - } - - return readMapFile_ShapeFile(fn, encoding); - } - - /** - * Read shape file as map - * - * @param aFile File name - * @param encoding Encoding - * @return Vector layer - * @throws java.io.IOException - * @throws java.io.FileNotFoundException - */ - public static VectorLayer readMapFile_ShapeFile(String aFile, String encoding) throws IOException, FileNotFoundException, Exception { - VectorLayer aLayer = ShapeFileManage.loadShapeFile(aFile, encoding); - - return aLayer; - } - - /** - * Read GrADS map file - * - * @param aFile The file path - * @return The layer - * @throws java.io.FileNotFoundException - */ - public static VectorLayer readMapFile_GrADS(String aFile) throws FileNotFoundException, IOException, Exception { - DataInputStream br = new DataInputStream(new BufferedInputStream(new FileInputStream(new File(aFile)))); - int i, lineNum; - byte b; - short N, lType; - double lon, lat; - byte[] bytes; - - PointD aPoint; - List pList = new ArrayList<>(); - - VectorLayer aLayer = new VectorLayer(ShapeTypes.Polyline); - String columnName = "Value"; - Field aDC = new Field(columnName, DataType.INT); - aLayer.editAddField(aDC); - - lineNum = 0; - do { - b = br.readByte(); // 1-data, 2-skip - if ("2".equals(Byte.toString(b))) { - br.skipBytes(18); - continue; - } - b = br.readByte(); // Line type: country, river ... - lType = (short) DataConvert.byte2Int(b); - b = br.readByte(); // Point number - N = (short) DataConvert.byte2Int(b); - for (i = 0; i < N; i++) { - bytes = new byte[3]; - br.read(bytes); //Longitude - int val = 0; - for (int bb = 0; bb < 3; bb++) { - val <<= 8; - val |= (int) bytes[bb] & 0xFF; - } - lon = val / 10000.0; - - bytes = new byte[3]; - br.read(bytes); //Latitude - val = 0; - for (int bb = 0; bb < 3; bb++) { - val <<= 8; - val |= (int) bytes[bb] & 0xFF; - } - lat = val / 10000.0 - 90.0; - - aPoint = new PointD(); - aPoint.X = lon; - aPoint.Y = lat; - pList.add(aPoint); - } - if (pList.size() > 1) { - PolylineShape aPolyline = new PolylineShape(); - aPolyline.setValue(lineNum); - aPolyline.setPoints(pList); - aPolyline.setExtent(GeometryUtil.getPointsExtent(pList)); - aPolyline.setPartNum(1); - aPolyline.parts = new int[1]; - aPolyline.parts[0] = 0; - - int shapeNum = aLayer.getShapeNum(); - if (aLayer.editInsertShape(aPolyline, shapeNum)) { - aLayer.editCellValue(columnName, shapeNum, lineNum); - } - - lineNum++; - } - pList = new ArrayList<>(); - - } while (br.available() > 0); - - br.close(); - - aLayer.setLayerName(new File(aFile).getName()); - aLayer.setFileName(aFile); - aLayer.setLayerDrawType(LayerDrawType.Map); - aLayer.setLegendScheme(LegendManage.createSingleSymbolLegendScheme(ShapeTypes.Polyline, Color.darkGray, 1.0F)); - aLayer.setVisible(true); - - return aLayer; - } - - /** - * Read image file - * - * @param aFile File path - * @return Image layer - * @throws java.io.IOException - */ - public static ImageLayer readImageFile(String aFile) throws IOException { - String oEx = aFile.substring(aFile.lastIndexOf(".")); - String last = oEx.substring(oEx.length() - 1); - String sEx = oEx.substring(0, oEx.length() - 2) + last; - sEx = sEx + "w"; - String wFile = aFile.replace(oEx, sEx); - BufferedImage aImage = ImageIO.read(new File(aFile)); - ImageLayer aImageLayer = new ImageLayer(); - aImageLayer.setFileName(aFile); - aImageLayer.setWorldFileName(wFile); - aImageLayer.setImage(aImage); - aImageLayer.setLayerName(new File(aFile).getName()); - aImageLayer.setVisible(true); - if (new File(wFile).exists()) { - aImageLayer.readImageWorldFile(wFile); - } else { - WorldFilePara aWFP = new WorldFilePara(); - aWFP.xUL = 0; - aWFP.yUL = 90; - aWFP.xScale = 0.05; - aWFP.yScale = -0.05; - aWFP.xRotate = 0; - aWFP.yRotate = 0; - aImageLayer.setWorldFilePara(aWFP); - aImageLayer.writeImageWorldFile(wFile, aImageLayer.getWorldFilePara()); - } - - double XBR, YBR; - XBR = aImageLayer.getImage().getWidth() * aImageLayer.getWorldFilePara().xScale + aImageLayer.getWorldFilePara().xUL; - YBR = aImageLayer.getImage().getHeight() * aImageLayer.getWorldFilePara().yScale + aImageLayer.getWorldFilePara().yUL; - Extent aExtent = new Extent(); - aExtent.minX = aImageLayer.getWorldFilePara().xUL; - aExtent.minY = YBR; - aExtent.maxX = XBR; - aExtent.maxY = aImageLayer.getWorldFilePara().yUL; - aImageLayer.setExtent(aExtent); - aImageLayer.setLayerDrawType(LayerDrawType.Image); - aImageLayer.setMaskout(true); - - return aImageLayer; - } - - /** - * Create a raster layer from geotiff file - * - * @param fileName File path - * @return Raster layer - */ - public static RasterLayer readGeoTiffFile(String fileName) { - try { - GeoTiff geoTiff = new GeoTiff(fileName); - geoTiff.read(); - GridArray gData = geoTiff.getGridArray(); -// LegendScheme aLS = LegendManage.createLegendSchemeFromGridData(gData, LegendType.GraduatedColor, -// ShapeTypes.Image); - RasterLayer aLayer = DrawMeteoData.createRasterLayer(gData, new File(fileName).getName()); - aLayer.setProjInfo(gData.projInfo); - aLayer.setFileName(fileName); - - return aLayer; - } catch (IOException ex) { - Logger.getLogger(MapDataManage.class.getName()).log(Level.SEVERE, null, ex); - return null; - } - } - - /** - * Read BIL file and create a raster layer - * - * @param fileName BIL file name - * @return Raster layer - */ - public static RasterLayer readBILFile(String fileName) { - BILDataInfo dataInfo = new BILDataInfo(); - dataInfo.readDataInfo(fileName); - //GridData gData = dataInfo.getGridData_LonLat(0, 0, 0); - Array a = dataInfo.read(dataInfo.getVariableNames().get(0)); - GridArray data = new GridArray(); - data.setData(a); - data.xArray = dataInfo.getXDimension().getValues(); - data.yArray = dataInfo.getYDimension().getValues(); - data.missingValue = dataInfo.getMissingValue(); - LegendScheme aLS = LegendManage.createLegendSchemeFromGridData(data, LegendType.GraduatedColor, - ShapeTypes.Image); - RasterLayer aLayer = DrawMeteoData.createRasterLayer(data, new File(fileName).getName(), aLS); - aLayer.setFileName(fileName); - - return aLayer; - } - - /** - * Read ESRI ASCII grid file and create a raster layer - * - * @param fileName File name - * @return Raster layer - */ - public static RasterLayer readESRI_ASCII_GRID(String fileName) { - ASCIIGridDataInfo dataInfo = new ASCIIGridDataInfo(); - dataInfo.readDataInfo(fileName); - GridArray gData = dataInfo.getGridArray("var"); - RasterLayer aLayer = DrawMeteoData.createRasterLayer(gData, new File(fileName).getName()); - aLayer.setProjInfo(KnownCoordinateSystems.geographic.world.WGS1984); - aLayer.setFileName(fileName); - - return aLayer; - } - - /** - * Read surfer ASCII grid file and create a raster layer - * - * @param fileName File name - * @return Raster layer - */ - public static RasterLayer readSurfer_ASCII_GRID(String fileName) { - SurferGridDataInfo dataInfo = new SurferGridDataInfo(); - dataInfo.readDataInfo(fileName); - GridData gData = dataInfo.getGridData_LonLat(0, "var", 0); - LegendScheme aLS = LegendManage.createLegendSchemeFromGridData(gData, LegendType.GraduatedColor, - ShapeTypes.Image); - RasterLayer aLayer = DrawMeteoData.createRasterLayer(gData, new File(fileName).getName(), aLS); - aLayer.setFileName(fileName); - - return aLayer; - } - - /** - * Read WMP file - * - * @param fileName The file name - * @return Created vector layer - * @throws java.io.IOException - */ - public static VectorLayer readMapFile_WMP(String fileName) throws IOException, Exception { - BufferedReader sr = null; - try { - File file = new File(fileName); - sr = new BufferedReader(new FileReader(file)); - String aLine; - String shapeType; - String[] dataArray; - int shapeNum; - int i, j, pNum; - List pList = new ArrayList<>(); - PointD aPoint; - boolean IsTrue; - String columnName = "Value"; - VectorLayer aLayer = new VectorLayer(ShapeTypes.Point); - //Read shape type - shapeType = sr.readLine().trim().toLowerCase(); - //Read shape number - shapeNum = Integer.parseInt(sr.readLine()); - switch (shapeType) { - case "point": - aLayer = new VectorLayer(ShapeTypes.Point); - aLayer.editAddField(columnName, DataType.INT); - for (i = 0; i < shapeNum; i++) { - aLine = sr.readLine(); - dataArray = aLine.split(","); - aPoint = new PointD(); - aPoint.X = Double.parseDouble(dataArray[0]); - aPoint.Y = Double.parseDouble(dataArray[1]); - pList.add(aPoint); - PointShape aPS = new PointShape(); - aPS.setValue(i); - aPS.setPoint(aPoint); - - int sNum = aLayer.getShapeNum(); - if (aLayer.editInsertShape(aPS, sNum)) { - aLayer.editCellValue(columnName, sNum, i); - } - } - aLayer.setLayerName(file.getName()); - aLayer.setFileName(fileName); - aLayer.setLayerDrawType(LayerDrawType.Map); - aLayer.setLegendScheme(LegendManage.createSingleSymbolLegendScheme(ShapeTypes.Point, Color.black, 5)); - aLayer.setVisible(true); - IsTrue = true; - break; - case "polyline": - aLayer = new VectorLayer(ShapeTypes.Polyline); - aLayer.editAddField(columnName, DataType.INT); - for (i = 0; i < shapeNum; i++) { - pNum = Integer.parseInt(sr.readLine()); - pList = new ArrayList<>(); - for (j = 0; j < pNum; j++) { - aLine = sr.readLine(); - dataArray = aLine.split(","); - aPoint = new PointD(); - aPoint.X = Double.parseDouble(dataArray[0]); - aPoint.Y = Double.parseDouble(dataArray[1]); - pList.add(aPoint); - } - PolylineShape aPLS = new PolylineShape(); - aPLS.setValue(i); - aPLS.setExtent(GeometryUtil.getPointsExtent(pList)); - aPLS.setPoints(pList); - - int sNum = aLayer.getShapeNum(); - if (aLayer.editInsertShape(aPLS, sNum)) { - aLayer.editCellValue(columnName, sNum, i); - } - } - aLayer.setLayerName(file.getName()); - aLayer.setFileName(fileName); - aLayer.setLayerDrawType(LayerDrawType.Map); - aLayer.setLegendScheme(LegendManage.createSingleSymbolLegendScheme(ShapeTypes.Polyline, Color.darkGray, 1.0F)); - aLayer.setVisible(true); - IsTrue = true; - break; - case "polygon": - aLayer = new VectorLayer(ShapeTypes.Polygon); - aLayer.editAddField(columnName, DataType.INT); - //ArrayList polygons = new ArrayList(); - for (i = 0; i < shapeNum; i++) { - pNum = Integer.parseInt(sr.readLine()); - pList = new ArrayList<>(); - for (j = 0; j < pNum; j++) { - aLine = sr.readLine(); - dataArray = aLine.split(","); - aPoint = new PointD(); - aPoint.X = Double.parseDouble(dataArray[0]); - aPoint.Y = Double.parseDouble(dataArray[1]); - pList.add(aPoint); - } - PolygonShape aPGS = new PolygonShape(); - aPGS.lowValue = i; - aPGS.highValue = i; - aPGS.setExtent(GeometryUtil.getPointsExtent(pList)); - aPGS.setPoints(pList); - - int sNum = aLayer.getShapeNum(); - if (aLayer.editInsertShape(aPGS, sNum)) { - aLayer.editCellValue(columnName, sNum, i); - } - } - aLayer.setLayerName(file.getName()); - aLayer.setFileName(fileName); - aLayer.setLayerDrawType(LayerDrawType.Map); - aLayer.setLegendScheme(LegendManage.createSingleSymbolLegendScheme(ShapeTypes.Polygon, new Color(255, 251, 195), 1.0F)); - aLayer.setVisible(true); - IsTrue = true; - break; - default: - JOptionPane.showMessageDialog(null, "Shape type is invalid!" + System.getProperty("line.separator") - + shapeType); - IsTrue = false; - break; - } - sr.close(); - if (IsTrue) { - return aLayer; - } else { - return null; - } - } catch (FileNotFoundException ex) { - Logger.getLogger(MapDataManage.class.getName()).log(Level.SEVERE, null, ex); - return null; - } finally { - try { - if (sr != null) { - sr.close(); - } - } catch (IOException ex) { - Logger.getLogger(MapDataManage.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - - /** - * Write WMP file - * - * @param fileName The file name - * @param shapes Shapes - */ - public static void writeMapFile_WMP(String fileName, List shapes) { - BufferedWriter sw = null; - try { - File file = new File(fileName); - sw = new BufferedWriter(new FileWriter(file)); - int shpNum = shapes.size(); - int i; - switch (shapes.get(0).getShapeType()) { - case Point: - sw.write("Point"); - sw.newLine(); - sw.write(String.valueOf(shpNum)); - sw.newLine(); - PointShape aPS; - for (i = 0; i < shpNum; i++) { - aPS = (PointShape) shapes.get(i); - if (aPS.isSelected()) { - sw.write(String.valueOf(aPS.getPoint().X) + "," + String.valueOf(aPS.getPoint().Y)); - sw.newLine(); - } - } - break; - case Polyline: - case PolylineZ: - sw.write("Polyline"); - sw.newLine(); - int shapeNum = 0; - PolylineShape aPLS; - for (i = 0; i < shpNum; i++) { - aPLS = (PolylineShape) shapes.get(i); - shapeNum += aPLS.getPartNum(); - } - sw.write(String.valueOf(shapeNum)); - sw.newLine(); - - shapeNum = 0; - for (i = 0; i < shpNum; i++) { - aPLS = (PolylineShape) shapes.get(i); - PointD[] Pointps; - for (int p = 0; p < aPLS.getPartNum(); p++) { - if (p == aPLS.getPartNum() - 1) { - Pointps = new PointD[aPLS.getPointNum() - aPLS.parts[p]]; - for (int pp = aPLS.parts[p]; pp < aPLS.getPointNum(); pp++) { - Pointps[pp - aPLS.parts[p]] = (PointD) aPLS.getPoints().get(pp); - } - } else { - Pointps = new PointD[aPLS.parts[p + 1] - aPLS.parts[p]]; - for (int pp = aPLS.parts[p]; pp < aPLS.parts[p + 1]; pp++) { - Pointps[pp - aPLS.parts[p]] = (PointD) aPLS.getPoints().get(pp); - } - } - sw.write(String.valueOf(Pointps.length)); - sw.newLine(); - for (PointD aPoint : Pointps) { - sw.write(String.valueOf(aPoint.X) + "," + String.valueOf(aPoint.Y)); - sw.newLine(); - } - shapeNum += 1; - } - } - break; - case Polygon: - sw.write("Polygon"); - sw.newLine(); - shapeNum = 0; - PolygonShape aPGS; - for (i = 0; i < shpNum; i++) { - aPGS = (PolygonShape) shapes.get(i); - shapeNum += aPGS.getPartNum(); - } - sw.write(String.valueOf(shapeNum)); - sw.newLine(); - - shapeNum = 0; - for (i = 0; i < shpNum; i++) { - aPGS = (PolygonShape) shapes.get(i); - - PointD[] Pointps; - for (int p = 0; p < aPGS.getPartNum(); p++) { - if (p == aPGS.getPartNum() - 1) { - Pointps = new PointD[aPGS.getPointNum() - aPGS.parts[p]]; - for (int pp = aPGS.parts[p]; pp < aPGS.getPointNum(); pp++) { - Pointps[pp - aPGS.parts[p]] = (PointD) aPGS.getPoints().get(pp); - } - } else { - Pointps = new PointD[aPGS.parts[p + 1] - aPGS.parts[p]]; - for (int pp = aPGS.parts[p]; pp < aPGS.parts[p + 1]; pp++) { - Pointps[pp - aPGS.parts[p]] = (PointD) aPGS.getPoints().get(pp); - } - } - sw.write(String.valueOf(Pointps.length)); - sw.newLine(); - for (PointD aPoint : Pointps) { - sw.write(String.valueOf(aPoint.X) + "," + String.valueOf(aPoint.Y)); - sw.newLine(); - } - shapeNum += 1; - } - } - break; - } - sw.close(); - } catch (IOException ex) { - Logger.getLogger(MapDataManage.class.getName()).log(Level.SEVERE, null, ex); - } finally { - try { - if (sw != null) { - sw.close(); - } - } catch (IOException ex) { - Logger.getLogger(MapDataManage.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - - /** - * Write projection file - * - * @param projFilePath Projection file path - * @param projInfo Projection info - */ - public static void writeProjFile(String projFilePath, ProjectionInfo projInfo) { - BufferedWriter sw = null; - try { - String esriString = projInfo.toEsriString(); - sw = new BufferedWriter(new FileWriter(new File(projFilePath))); - sw.write(esriString); - sw.flush(); - sw.close(); - } catch (IOException ex) { - Logger.getLogger(ShapeFileManage.class.getName()).log(Level.SEVERE, null, ex); - } finally { - try { - if (sw != null) { - sw.close(); - } - } catch (IOException ex) { - Logger.getLogger(ShapeFileManage.class.getName()).log(Level.SEVERE, null, ex); - } - } - } -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/drawing/ContourDraw.java b/MeteoInfoLib/src/main/java/org/meteoinfo/drawing/ContourDraw.java deleted file mode 100644 index dae1da75..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/drawing/ContourDraw.java +++ /dev/null @@ -1,140 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.drawing; - -import org.meteoinfo.common.MIMath; - -import java.util.List; - -/** - * Template - * - * @author Yaqiang Wang - */ -public class ContourDraw { - // - // - // - // - // - // - // - - /** - * Tracing contour borders - * - * @param gridData Grid data - * @param X X array - * @param Y Y array - * @param S1 Flat array - * @param undef Undefine value - * @return Borders - */ - public static List tracingBorders(double[][] gridData, double[] X, double[] Y, int[][] S1, - double undef) { - return wcontour.Contour.tracingBorders(gridData, X, Y, S1, undef); - } - -// /** -// * Tracing contour lines with undefined data -// * -// * @param gridData Grid data -// * @param cValues Values -// * @param X X array -// * @param Y Y array -// * @param noData Undefine data -// * @param borders Contour line borders -// * @param S1 Flag array -// * @return Traced contour lines -// */ -// public static List tracingContourLines(double[][] gridData, double[] cValues, double[] X, -// double[] Y, double noData, List borders, int[][] S1) { -// int nc = cValues.length; -// return wContour.Contour.tracingContourLines(gridData, X, Y, nc, cValues, noData, borders, S1); -// } - - /** - * Tracing contour lines with undefined data - * - * @param gridData Grid data - * @param cValues Values - * @param X X array - * @param Y Y array - * @param noData Undefine data - * @param S1 Flag array - * @return Traced contour lines and borders - */ - public static Object[] tracingContourLines(double[][] gridData, double[] cValues, double[] X, - double[] Y, double noData, int[][] S1) { - int nc = cValues.length; - List borders = wcontour.Contour.tracingBorders(gridData, X, Y, S1, noData); - List contourLines = wcontour.Contour.tracingContourLines(gridData, X, Y, nc, cValues, noData, borders, S1); - return new Object[]{contourLines, borders}; - } - - /** - * Tracing shaded polygons with undefined data - * - * @param gridData Grid data - * @param contourLines Contour lines - * @param borders Border lines - * @param cValues Values - * @return Polygon list - */ - public static List tracingPolygons(double[][] gridData, - List contourLines, List borders, double[] cValues) { - return wcontour.Contour.tracingPolygons(gridData, contourLines, borders, cValues); - } - - /** - * Get max/min values from a station data - * - * @param S Discrete data - * @param noData Missing value - * @param minmax Min/Max data array - * @return If has missing value - */ - public static boolean getMinMaxValueFDiscreteData(double[][] S, double noData, double[] minmax) { - int i, validNum; - boolean isNodata = false; - double min = 0.0, max = 0.0; - - validNum = 0; - for (i = 0; i < S.length; i++) { - if (!MIMath.doubleEquals(S[i][2], noData)) { - validNum++; - if (validNum == 1) { - min = S[i][2]; - max = min; - } else { - if (S[i][2] < min) { - min = S[i][2]; - } - if (S[i][2] > max) { - max = S[i][2]; - } - } - } else { - isNodata = true; - } - - } - - minmax[0] = min; - minmax[1] = max; - - return isNodata; - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/drawing/StringType.java b/MeteoInfoLib/src/main/java/org/meteoinfo/drawing/StringType.java deleted file mode 100644 index f4275edb..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/drawing/StringType.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.drawing; - -/** - * - * @author Yaqiang Wang - */ -public enum StringType { - NORMAL, - LATEX, - MIXING -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/GeoComputation.java b/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/GeoComputation.java index 5a9e8d5f..6d78a014 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/GeoComputation.java +++ b/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/GeoComputation.java @@ -33,7 +33,7 @@ import java.util.logging.Logger; import org.meteoinfo.table.DataColumn; import org.meteoinfo.table.DataRow; import org.meteoinfo.table.DataTable; -import org.meteoinfo.layer.VectorLayer; +import org.meteoinfo.geo.layer.VectorLayer; import org.meteoinfo.table.Field; /** diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/GeometryUtil.java b/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/GeometryUtil.java index a238960d..15a4c264 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/GeometryUtil.java +++ b/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/GeometryUtil.java @@ -13,7 +13,7 @@ import org.locationtech.jts.geom.GeometryFactory; import org.meteoinfo.common.Extent; import org.meteoinfo.common.Extent3D; import org.meteoinfo.common.PointD; -import org.meteoinfo.layer.VectorLayer; +import org.meteoinfo.geo.layer.VectorLayer; import org.meteoinfo.ndarray.math.ArrayMath; import org.meteoinfo.ndarray.*; import org.meteoinfo.geometry.shape.*; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/analysis/AnalysisTypes.java b/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/analysis/AnalysisTypes.java deleted file mode 100644 index 0ad07cc1..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/analysis/AnalysisTypes.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.geoprocess.analysis; - -/** - * - * @author yaqiang - */ -public enum AnalysisTypes { - Resample, - Aggregate -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/analysis/Clustering.java b/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/analysis/Clustering.java deleted file mode 100644 index 96ec8772..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/analysis/Clustering.java +++ /dev/null @@ -1,664 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.geoprocess.analysis; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.List; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.geometry.shape.PointZ; -import org.meteoinfo.geometry.shape.PolylineZShape; - -/** - * - * @author wyq - */ -public class Clustering { - - /** - * Clustering calculation - * - * @param inFile Input file - * @param outFile Output file - * @param N Row number - * @param M Column number - * @param LN Level number - * @param disType Distant define type: Euclidean or Angle - * @throws java.io.FileNotFoundException - */ - public static void calculate(String inFile, String outFile, int N, int M, int LN, DistanceType disType) throws FileNotFoundException, IOException { - double[][] DATA = new double[N][M]; - - //---- Open input File - String aLine; - String[] aDataArray; - int i; - int j; - int row; - int col; - List flags = new ArrayList<>(); //Date time and height - - BufferedReader sr = new BufferedReader(new FileReader(new File(inFile))); - row = 0; - while ((aLine = sr.readLine()) != null) { - if (aLine.isEmpty()) { - continue; - } - - aDataArray = aLine.split(","); - - //Ignor the data line with not normal point number - if ((aDataArray.length - 2) / 3 != M / 2) { - continue; - } - - flags.add(aDataArray[0] + "," + aDataArray[1]); - - col = 0; - for (i = 0; i <= M / 2 - 1; i++) { - for (j = 0; j <= 2; j++) { - if (j != 2) { - DATA[row][col] = Double.parseDouble(aDataArray[i * 3 + j + 2]); - col += 1; - } - } - } - row += 1; - } - sr.close(); - - //Clustering calculation - int[][] ICLASS = calculation(DATA, LN, disType); - - //Write clustering result to output file - BufferedWriter sw = new BufferedWriter(new FileWriter(new File(outFile))); - aLine = "Time,Height"; - for (i = 2; i <= LN; i++) { - aLine = aLine + "," + String.valueOf(i) + "CL"; - } - sw.write(aLine); - sw.newLine(); - for (i = 0; i <= N - 1; i++) { - aLine = flags.get(i); - for (j = 0; j <= LN - 2; j++) { - aLine = aLine + "," + String.valueOf(ICLASS[i][j]); - } - sw.write(aLine); - sw.newLine(); - } - sw.close(); - } - - /** - * Clustering calculation - * - * @param trajLayers Trajectory layers - * @param outFile Output file - * @param N Row number - trajectory number - * @param M Column number - 2 times of point number - * @param LN Level number - * @param interval Point interval - * @param disType Distant define type: Euclidean or Angle - * @throws java.io.IOException - */ - public static void calculate(List trajLayers, String outFile, int N, int M, int LN, int interval, DistanceType disType) throws IOException { - double[][] DATA = new double[N][M]; - - //---- Get data array - String aLine; - int i; - int j; - int row; - int col; - List flags = new ArrayList<>(); //Date time and height - LocalDateTime aDate; - - row = 0; - DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyyMMddHH"); - for (VectorLayer layer : trajLayers) { - PointZ aPoint; - int sNum = layer.getShapeNum(); - for (i = 0; i < sNum; i++) { - aDate = (LocalDateTime) layer.getCellValue("Date", i); - int hour = Integer.parseInt(layer.getCellValue("Hour", i).toString()); - aDate = aDate.withHour(hour); - aLine = format.format(aDate); - String height = layer.getCellValue("Height", i).toString(); - flags.add(aLine + "," + height); - PolylineZShape aPLZ = (PolylineZShape) layer.getShapes().get(i); - col = 0; - for (j = 0; j < aPLZ.getPointNum(); j++) { - if (j % interval == 0) { - aPoint = (PointZ) aPLZ.getPoints().get(j); - DATA[row][col] = aPoint.Y; - col += 1; - DATA[row][col] = aPoint.X; - col += 1; - } - } - row += 1; - } - } - - //Clustering calculation - int[][] ICLASS = calculation(DATA, LN, disType); - - //Write clustering result to output file - BufferedWriter sw = new BufferedWriter(new FileWriter(new File(outFile))); - aLine = "Time,Height"; - for (i = 2; i <= LN; i++) { - aLine = aLine + "," + String.valueOf(i) + "CL"; - } - sw.write(aLine); - sw.newLine(); - for (i = 0; i <= N - 1; i++) { - aLine = flags.get(i); - for (j = 0; j <= LN - 2; j++) { - aLine = aLine + "," + String.valueOf(ICLASS[i][j]); - } - sw.write(aLine); - sw.newLine(); - } - sw.close(); - } - - /** - * Clustering calculation - * - * @param DATA Input data array - * @param outFile Output file - * @param LN Level number - * @param disType Distant define type: Euclidean or Angle - * @throws java.io.IOException - */ - public static void calculation(double[][] DATA, String outFile, int LN, DistanceType disType) throws IOException { - int N = DATA.length; - int M = DATA[0].length; - double[] CRIT = new double[N]; - double[] MEMBR = new double[N]; - double[] CRITVAL = new double[LN]; - int[] IA = new int[N]; - int[] IB = new int[N]; - int[][] ICLASS = new int[N][LN]; - int[] HVALS = new int[LN]; - int[] IORDER = new int[LN]; - int[] HEIGHT = new int[LN]; - int[] NN = new int[N]; - double[] DISNN = new double[N]; - double[] D = new double[N * (N - 1) / 2]; - boolean[] FLAG = new boolean[N]; - - //---- IN ABOVE, 18=N, 16=M, 9=LEV, 153=N(N-1)/2 - - - //---- Call HC - int LEN = (N * (N - 1)) / 2; - int IOPT = 1; - HC(N, M, IOPT, DATA, IA, IB, CRIT, MEMBR, NN, DISNN, FLAG, D, disType); - - //---- Call HCASS - HCASS(N, IA, IB, CRIT, LN, ICLASS, HVALS, IORDER, CRITVAL, HEIGHT); - - //---- Write output file - BufferedWriter sw = new BufferedWriter(new FileWriter(new File(outFile))); - int i, j; - String aLine = "NO"; - for (i = 2; i <= LN; i++) { - aLine = aLine + "," + String.valueOf(i) + "CL"; - } - sw.write(aLine); - sw.newLine(); - for (i = 0; i <= N - 1; i++) { - aLine = String.valueOf(i + 1); - for (j = 0; j <= LN - 2; j++) { - aLine = aLine + "," + String.valueOf(ICLASS[i][j]); - } - sw.write(aLine); - sw.newLine(); - } - sw.close(); - - //---- Call HCDEN - //Call HCDEN(LEV, IORDER, HEIGHT, CRITVAL) - - } - - /** - * Clustering calculation - * - * @param DATA Input data array - * @param LN Level number - * @param disType Distant define type: Euclidean or Angle - * @return Clustering result array - */ - public static int[][] calculation(double[][] DATA, int LN, DistanceType disType) { - //double[,] DATA = new double[N, M]; - int N = DATA.length; - int M = DATA[0].length; - double[] CRIT = new double[N]; - double[] MEMBR = new double[N]; - double[] CRITVAL = new double[LN]; - int[] IA = new int[N]; - int[] IB = new int[N]; - int[][] ICLASS = new int[N][LN]; - int[] HVALS = new int[LN]; - int[] IORDER = new int[LN]; - int[] HEIGHT = new int[LN]; - int[] NN = new int[N]; - double[] DISNN = new double[N]; - double[] D = new double[N * (N - 1) / 2]; - boolean[] FLAG = new boolean[N]; - - //---- IN ABOVE, 18=N, 16=M, 9=LEV, 153=N(N-1)/2 - - - //---- Call HC - //int LEN = (N * (N - 1)) / 2; - int IOPT = 1; - HC(N, M, IOPT, DATA, IA, IB, CRIT, MEMBR, NN, DISNN, FLAG, D, disType); - - //---- Call HCASS - HCASS(N, IA, IB, CRIT, LN, ICLASS, HVALS, IORDER, CRITVAL, HEIGHT); - - //---- Call HCDEN - //Call HCDEN(LEV, IORDER, HEIGHT, CRITVAL) - - return ICLASS; - } - - //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // C - // HIERARCHICAL CLUSTERING using (user-specified) criterion. C - // C - // Parameters: C - // C - // DATA(N,M) input data matrix, C - // DISS(LEN) dissimilarities in lower half diagonal C - // storage; LEN = N.N-1/2, C - // IOPT clustering criterion to be used, C - // IA, IB, CRIT history of agglomerations; dimensions C - // N, first N-1 locations only used, C - // MEMBR, NN, DISNN vectors of length N, used to store C - // cluster cardinalities, current nearest C - // neighbour, and the dissimilarity assoc. C - // with the latter. C - // FLAG boolean indicator of agglomerable obj./ C - // clusters. C - // C - // F. Murtagh, ESA/ESO/STECF, Garching, February 1986. C - // C - //------------------------------------------------------------C - private static void HC(int N, int M, int IOPT, double[][] DATA, int[] IA, int[] IB, double[] CRIT, double[] MEMBR, - int[] NN, double[] DISNN, boolean[] FLAG, double[] DISS, DistanceType DISTYPE) { - double INF = 1.0 * (Math.pow(10, 20)); - int i; - int j; - int k; - - //---- Initializations - for (i = 0; i <= N - 1; i++) { - MEMBR[i] = 1.0; - FLAG[i] = true; - } - int NCL = N; - - //---- Construct dissimilarity matrix - int IND; - - if (DISTYPE == DistanceType.ANGLE) { - double X0; - double Y0; - double ANGLE; - double A; - double B; - double C; - X0 = DATA[0][0]; - Y0 = DATA[0][1]; - for (i = 0; i <= N - 2; i++) { - for (j = i + 1; j <= N - 1; j++) { - IND = IOFFSET(N, i + 1, j + 1); - DISS[IND] = 0.0; - for (k = 1; k <= M / 2 - 1; k++) { - A = Math.pow((DATA[i][2 * k] - X0), 2) + Math.pow((DATA[i][2 * k + 1] - Y0), 2); - B = Math.pow((DATA[j][2 * k] - X0), 2) + Math.pow((DATA[j][2 * k + 1] - Y0), 2); - C = Math.pow((DATA[j][2 * k] - DATA[i][2 * k]), 2) + Math.pow((DATA[j][2 * k + 1] - DATA[i][2 * k + 1]), 2); - if (A == 0 | B == 0) { - ANGLE = 0; - } else { - ANGLE = 0.5 * (A + B - C) / Math.sqrt(A * B); - } - if ((Math.abs(ANGLE) > 1.0)) { - ANGLE = 1.0; - } - DISS[IND] = DISS[IND] + Math.acos(ANGLE); - } - DISS[IND] = DISS[IND] / (M / 2); - if (IOPT == 1) { - DISS[IND] = DISS[IND] / 2.0; - } - // (Above is done for the case of the min. var. method - // where merging criteria are defined in terms of variances - // rather than distances.) - } - } - } else { - for (i = 0; i <= N - 2; i++) { - for (j = i + 1; j <= N - 1; j++) { - IND = IOFFSET(N, i + 1, j + 1); - DISS[IND] = 0.0; - for (k = 0; k <= M / 2 - 1; k++) { - DISS[IND] = DISS[IND] + Math.pow((DATA[i][2 * k] - DATA[j][2 * k]), 2) + Math.pow((DATA[i][2 * k + 1] - DATA[j][2 * k + 1]), 2); - } - DISS[IND] = Math.sqrt(DISS[IND]); - if (IOPT == 1) { - DISS[IND] = DISS[IND] / 2; - } - //---- (Above is done for the case of the min. var. method - //---- where merging criteria are defined in terms of variances - //---- rather than distances.) - } - } - - //For i = 0 To N - 2 - //For j = i + 1 To N - 1 - //IND = IOFFSET(N, i + 1, j + 1) - //DISS(IND) = 0.0 - //For k = 0 To M - 1 - //DISS(IND) = DISS(IND) + (DATA(i, k) - DATA(j, k)) ^ 2 - //Next - //If IOPT = 1 Then - //DISS(IND) = DISS(IND) / 2 - //End If - //---- (Above is done for the case of the min. var. method - //---- where merging criteria are defined in terms of variances - //---- rather than distances.) - //Next - //Next - } - - //---- Carry out an agglomeration - first create list of NNs - double DMIN; - int JM = 0; - for (i = 0; i <= N - 2; i++) { - DMIN = INF; - for (j = i + 1; j <= N - 1; j++) { - IND = IOFFSET(N, i + 1, j + 1); - if (DISS[IND] >= DMIN) { - continue; - } - DMIN = DISS[IND]; - JM = j; - } - NN[i] = JM; - DISNN[i] = DMIN; - } - - //---- Loop - do { - //---- Next, determine least diss. using list of NNs - int IM = 0; - DMIN = INF; - for (i = 0; i <= N - 2; i++) { - if (!FLAG[i]) { - continue; - } - if (DISNN[i] >= DMIN) { - continue; - } - DMIN = DISNN[i]; - IM = i; - JM = NN[i]; - } - NCL = NCL - 1; - - //---- This allows an agglomeration to be carried out. - int I2; - int J2; - - I2 = Math.min(IM, JM); - J2 = Math.max(IM, JM); - IA[N - NCL - 1] = I2 + 1; - IB[N - NCL - 1] = J2 + 1; - CRIT[N - NCL - 1] = DMIN; - - //---- Update dissimilarities from new cluster. - double X; - double XX; - int IND1; - int IND2; - int IND3; - int JJ = 0; - FLAG[J2] = false; - DMIN = INF; - for (k = 0; k <= N - 1; k++) { - if (!FLAG[k]) { - continue; - } - if (k == I2) { - continue; - } - X = MEMBR[I2] + MEMBR[J2] + MEMBR[k]; - if (I2 < k) { - IND1 = IOFFSET(N, I2 + 1, k + 1); - } else { - IND1 = IOFFSET(N, k + 1, I2 + 1); - } - if (J2 < k) { - IND2 = IOFFSET(N, J2 + 1, k + 1); - } else { - IND2 = IOFFSET(N, k + 1, J2 + 1); - } - IND3 = IOFFSET(N, I2 + 1, J2 + 1); - XX = DISS[IND3]; - - //---- Ward's minimum variance method - IOPT=1. - if (IOPT == 1) { - DISS[IND1] = (MEMBR[I2] + MEMBR[k]) * DISS[IND1] + (MEMBR[J2] + MEMBR[k]) * DISS[IND2] - MEMBR[k] * XX; - DISS[IND1] = DISS[IND1] / X; - } - - //---- Single link method - IOPT=2. - if (IOPT == 2) { - DISS[IND1] = Math.min(DISS[IND1], DISS[IND2]); - } - - //---- Complete link method - IOPT=3. - if (IOPT == 3) { - DISS[IND1] = Math.max(DISS[IND1], DISS[IND2]); - } - - //---- Average link (or group average) method - IOPT=4. - if (IOPT == 4) { - DISS[IND1] = (MEMBR[I2] * DISS[IND1] + MEMBR[J2] * DISS[IND2]) / (MEMBR[I2] + MEMBR[J2]); - } - - //---- Mcquitty's method - IOPT=5. - if (IOPT == 5) { - DISS[IND1] = 0.5 * DISS[IND1] + 0.5 * DISS[IND2]; - } - - //---- MEDIAN (GOWER'S) METHOD - IOPT=6. - if (IOPT == 6) { - DISS[IND1] = 0.5 * DISS[IND1] + 0.5 * DISS[IND2] - 0.25 * XX; - } - - // CENTROID METHOD - IOPT=7. - if (IOPT == 7) { - DISS[IND1] = (MEMBR[I2] * DISS[IND1] + MEMBR[J2] * DISS[IND2] - MEMBR[I2] * MEMBR[J2] * XX / (MEMBR[I2] + MEMBR[J2])) / (MEMBR[I2] + MEMBR[J2]); - } - - if (I2 > k) { - continue; - } - if (DISS[IND1] >= DMIN) { - continue; - } - DMIN = DISS[IND1]; - JJ = k; - } - MEMBR[I2] = MEMBR[I2] + MEMBR[J2]; - DISNN[I2] = DMIN; - NN[I2] = JJ; - - //---- Update list of NNs insofar as this is required. - for (i = 0; i <= N - 2; i++) { - if (!FLAG[i]) { - continue; - } - if (NN[i] == I2 | NN[i] == J2) { - //---- Redetermine NN of I - DMIN = INF; - for (j = i + 1; j <= N - 1; j++) { - IND = IOFFSET(N, i + 1, j + 1); - if (!FLAG[j]) { - continue; - } - if (i == j) { - continue; - } - if (DISS[IND] >= DMIN) { - continue; - } - DMIN = DISS[IND]; - JJ = j; - } - NN[i] = JJ; - DISNN[i] = DMIN; - } - } - } while (!(NCL == 1)); - - } - - private static int IOFFSET(int N, int I, int J) { - // Map row I and column J of upper half diagonal symmetric matrix - // onto vector. - return J + (I - 1) * N - (I * (I + 1)) / 2 - 1; - } - - //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++C - // C - // Given a HIERARCHIC CLUSTERING, described as a sequence of C - // agglomerations, derive the assignments into clusters for the C - // top LEV-1 levels of the hierarchy. C - // Prepare also the required data for representing the C - // dendrogram of this top part of the hierarchy. C - // C - // Parameters: C - // C - // IA, IB, CRIT: vectors of dimension N defining the agglomer- C - // ations. C - // LEV: number of clusters in largest partition. C - // HVALS: vector of dim. LEV, used internally only. C - // ICLASS: array of cluster assignments; dim. N by LEV. C - // IORDER, CRITVAL, HEIGHT: vectors describing the dendrogram, C - // all of dim. LEV. C - // C - // F. Murtagh, ESA/ESO/STECF, Garching, February 1986. C - // C - //---------------------------------------------------------------C - private static void HCASS(int N, int[] IA, int[] IB, double[] CRIT, int LEV, int[][] ICLASS, int[] HVALS, int[] IORDER, - double[] CRITVAL, int[] HEIGHT) { - // Pick out the clusters which the N objects belong to, - // at levels N-2, N-3, ... N-LEV+1 of the hierarchy. - // The clusters are identified by the lowest seq. no. of - // their members. - // There are 2, 3, ... LEV clusters, respectively, for the - // above levels of the hierarchy. - - HVALS[0] = 1; - HVALS[1] = IB[N - 2]; - int LOC = 2; - int i; - int j; - boolean ifGo; - for (i = N - 3; i >= N - LEV; i += -1) { - ifGo = true; - for (j = 0; j <= LOC - 1; j++) { - if (IA[i] == HVALS[j]) { - ifGo = false; - } - } - if (ifGo) { - HVALS[LOC] = IA[i]; - LOC += 1; - } - ifGo = true; - for (j = 0; j <= LOC - 1; j++) { - if (IB[i] == HVALS[j]) { - ifGo = false; - } - } - if (ifGo) { - HVALS[LOC] = IB[i]; - LOC += 1; - } - } - - int LEVEL; - int ICL; - int ILEV; - int NCL; - for (LEVEL = N - LEV; LEVEL <= N - 2; LEVEL++) { - for (i = 0; i <= N - 1; i++) { - ICL = i + 1; - for (ILEV = 0; ILEV <= LEVEL - 1; ILEV++) { - if (IB[ILEV] == ICL) { - ICL = IA[ILEV]; - } - } - NCL = N - LEVEL - 1; - ICLASS[i][NCL - 1] = ICL; - } - } - - int k; - for (i = 0; i <= N - 1; i++) { - for (j = 0; j <= LEV - 2; j++) { - for (k = 1; k <= LEV - 1; k++) { - if (ICLASS[i][j] != HVALS[k]) { - continue; - } - ICLASS[i][j] = k + 1; - break; - } - } - } - - } - - //+++++++++++++++++++++++++++++++++++++++++++++++++C - // C - // Construct a DENDROGRAM of the top 8 levels of C - // a HIERARCHIC CLUSTERING. C - // C - // Parameters: C - // C - // IORDER, HEIGHT, CRITVAL: vectors of length LEV C - // defining the dendrogram. C - // These are: the ordering of objects C - // along the bottom of the dendrogram C - // (IORDER); the height of the vertical C - // above each object, in ordinal values C - // (HEIGHT); and in real values (CRITVAL).C - // C - // NOTE: these vectors MUST have been set up with C - // LEV = 9 in the prior call to routine C - // HCASS. - // C - // F. Murtagh, ESA/ESO/STECF, Garching, Feb. 1986.C - // C - //-------------------------------------------------C - private static void HCDEN(int LEV, int[] IORDER, int[] HEIGHT, double[] CRITVAL) { - } -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/analysis/DistanceType.java b/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/analysis/DistanceType.java deleted file mode 100644 index b27cd241..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/analysis/DistanceType.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.geoprocess.analysis; - -/** - * - * @author yaqiang - */ -public enum DistanceType { - EUCLIDEAN, - ANGLE -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/analysis/InterpolationMethods.java b/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/analysis/InterpolationMethods.java deleted file mode 100644 index dcd62af1..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/analysis/InterpolationMethods.java +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geoprocess.analysis; - -/** - * - * @author yaqiang - */ -public enum InterpolationMethods { - /// - /// IDW radius - /// - - IDW_Radius, - /// - /// IDV neighbors - /// - IDW_Neighbors, - /// - /// Cressman analysis - /// - Cressman, - /// - /// Assign point to grid - /// - AssignPointToGrid, - -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/analysis/InterpolationSetting.java b/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/analysis/InterpolationSetting.java deleted file mode 100644 index 4b39fb0f..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/geoprocess/analysis/InterpolationSetting.java +++ /dev/null @@ -1,231 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geoprocess.analysis; - -import org.meteoinfo.data.GridDataSetting; - -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author yaqiang - */ -public class InterpolationSetting { - // - - private GridDataSetting _gridDataPara = new GridDataSetting(); - private InterpolationMethods _gridInterMethod; - private int _minPointNum; - private double _radius; - private double _missingValue = -9999.0; - private List _radList; //For cressman analysis - // - // - - /** - * Constructor - */ - public InterpolationSetting() { - _gridDataPara.xNum = 50; - _gridDataPara.yNum = 50; - _gridInterMethod = InterpolationMethods.IDW_Radius; - _minPointNum = 1; - _radius = 1; - _radList = new ArrayList<>(); - double[] values = new double[]{10, 7, 4, 2, 1}; - for (double v : values) { - _radList.add(v); - } - } - - /** - * Constructor - * - * @param minX Minimum x - * @param maxX Maximum x - * @param minY Minimum y - * @param maxY Maximum y - * @param xNum X number - * @param yNum Y number - * @param aInterMethod Interpolation method - * @param radius Radius - * @param minNum Minimum number - */ - public InterpolationSetting(double minX, double maxX, double minY, double maxY, int xNum, int yNum, - String aInterMethod, float radius, int minNum) { - GridDataSetting aGDP = new GridDataSetting(); - aGDP.dataExtent.minX = minX; - aGDP.dataExtent.maxX = maxX; - aGDP.dataExtent.minY = minY; - aGDP.dataExtent.maxY = maxY; - aGDP.xNum = xNum; - aGDP.yNum = yNum; - _gridDataPara = aGDP; - - _gridInterMethod = InterpolationMethods.valueOf(aInterMethod); - _radius = radius; - _minPointNum = minNum; - - _radList = new ArrayList<>(); - double[] values = new double[]{10, 7, 4, 2, 1}; - for (double v : values) { - _radList.add(v); - } - } - - /** - * Constructor - * - * @param minX Minimum x - * @param maxX Maximum x - * @param minY Minimum y - * @param maxY Maximum y - * @param xNum X number - * @param yNum Y number - * @param aInterMethod Interpolation method - * @param radList Radius list - Cressman - */ - public InterpolationSetting(double minX, double maxX, double minY, double maxY, int xNum, int yNum, - String aInterMethod, List radList) { - GridDataSetting aGDP = new GridDataSetting(); - aGDP.dataExtent.minX = minX; - aGDP.dataExtent.maxX = maxX; - aGDP.dataExtent.minY = minY; - aGDP.dataExtent.maxY = maxY; - aGDP.xNum = xNum; - aGDP.yNum = yNum; - _gridDataPara = aGDP; - - _gridInterMethod = InterpolationMethods.valueOf(aInterMethod); - _radList = radList; - _minPointNum = 1; - } - // - // - - /** - * Get grid data setting - * - * @return Grid data setting - */ - public GridDataSetting getGridDataSetting() { - return _gridDataPara; - } - - /** - * Set grid data setting - * - * @param value Grid data setting - */ - public void setGridDataSetting(GridDataSetting value) { - _gridDataPara = value; - } - - /** - * Get interpolation method - * - * @return Interpolation method - */ - public InterpolationMethods getInterpolationMethod() { - return _gridInterMethod; - } - - /** - * Set interpolation method - * - * @param value Interpolation method - */ - public void setInterpolationMethod(InterpolationMethods value) { - _gridInterMethod = value; - } - - /** - * Get minimum point number - * - * @return Minimum point number - */ - public int getMinPointNum() { - return _minPointNum; - } - - /** - * Set minimum point number - * - * @param value Minimum point number - */ - public void setMinPointNum(int value) { - _minPointNum = value; - } - - /** - * Get search radius - * - * @return Radius - */ - public double getRadius() { - return _radius; - } - - /** - * Set search radius - * - * @param value Radius - */ - public void setRadius(double value) { - _radius = value; - } - - /** - * Get missing value - * - * @return Missing value - */ - public double getMissingValue() { - return _missingValue; - } - - /** - * Set missing value - * - * @param value Missing value - */ - public void setMissingValue(double value) { - _missingValue = value; - } - - /** - * Get radius list - * - * @return Radius list - */ - public List getRadiusList() { - return _radList; - } - - /** - * Set radius list - * - * @param value Radius list - */ - public void setRadiusList(List value) { - _radList = value; - } - // - // - - - - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/ChartSet.java b/MeteoInfoLib/src/main/java/org/meteoinfo/layer/ChartSet.java deleted file mode 100644 index 57527ffc..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/ChartSet.java +++ /dev/null @@ -1,457 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layer; - -import java.awt.Color; -import java.awt.Font; - -import org.meteoinfo.geometry.legend.AlignType; -import org.meteoinfo.geometry.legend.ChartTypes; -import org.meteoinfo.geometry.legend.LegendScheme; -import org.meteoinfo.geometry.shape.ShapeTypes; -import java.util.ArrayList; -import java.util.List; - -/** - * Template - * - * @author Yaqiang Wang - */ -public class ChartSet { - // - - private ChartTypes _chartType; - private boolean _drawCharts; - private List _fieldNames; - private int _xShift; - private int _yShift; - private LegendScheme _legendScheme; - private int _maxSize; - private int _minSize; - private float _maxValue; - private float _minValue; - private int _barWidth; - private boolean _avoidCollision; - private AlignType _alignType; - private boolean _view3D; - private int _thickness; - private boolean drawLabel; - private Font labelFont; - private Color labelColor; - private int decimalDigits; - // - // - - /** - * Constructor - */ - public ChartSet() { - _chartType = ChartTypes.BarChart; - _drawCharts = false; - _fieldNames = new ArrayList<>(); - _xShift = 0; - _yShift = 0; - _legendScheme = new LegendScheme(ShapeTypes.Polygon); - _maxSize = 50; - _minSize = 0; - _barWidth = 8; - _avoidCollision = true; - _alignType = AlignType.Center; - _view3D = false; - _thickness = 5; - drawLabel = false; - labelFont = new Font("Arial", Font.PLAIN, 12); - labelColor = Color.black; - this.decimalDigits = 0; - } - // - // - - /** - * Get chart type - * - * @return Chart type - */ - public ChartTypes getChartType() { - return _chartType; - } - - /** - * Set chart type - * - * @param type Chart type - */ - public void setChartType(ChartTypes type) { - _chartType = type; - } - - /** - * Set chart type - * @param tstr Chart type string - */ - public void setChartType(String tstr) { - switch(tstr.toLowerCase()) { - case "bar": - this._chartType = ChartTypes.BarChart; - break; - case "pie": - this._chartType = ChartTypes.PieChart; - break; - } - } - - /** - * Set if draw charts - * - * @return If draw charts - */ - public boolean isDrawCharts() { - return _drawCharts; - } - - /** - * Set if draw charts - * - * @param istrue If draw charts - */ - public void setDrawCharts(boolean istrue) { - _drawCharts = istrue; - } - - /** - * Get field names - * - * @return The file names - */ - public List getFieldNames() { - return _fieldNames; - } - - /** - * Set field names - * - * @param names Field names - */ - public void setFieldNames(List names) { - _fieldNames = names; - } - - /** - * Get x shift - * - * @return X shift - */ - public int getXShift() { - return _xShift; - } - - /** - * Set x shift - * - * @param shift X shift - */ - public void setXShift(int shift) { - _xShift = shift; - } - - /** - * Get y shift - * - * @return Y shift - */ - public int getYShift() { - return _yShift; - } - - /** - * Set y shift - * - * @param shift Y shift - */ - public void setYShift(int shift) { - _yShift = shift; - } - - /** - * Get legend scheme - * - * @return The legend scheme - */ - public LegendScheme getLegendScheme() { - return _legendScheme; - } - - /** - * Set legend scheme - * - * @param ls The legend scheme - */ - public void setLegendScheme(LegendScheme ls) { - _legendScheme = ls; - } - - /** - * Get maximum size - * - * @return Maximum size - */ - public int getMaxSize() { - return _maxSize; - } - - /** - * Set maximum size - * - * @param size Maximum size - */ - public void setMaxSize(int size) { - _maxSize = size; - } - - /** - * Get minimum size - * - * @return Minimum size - */ - public int getMinSize() { - return _minSize; - } - - /** - * Set minimum size - * - * @param size Minimum size - */ - public void setMinSize(int size) { - _minSize = size; - } - - /** - * Get maximum value - * - * @return Maximum value - */ - public float getMaxValue() { - return _maxValue; - } - - public void setMaxValue(float value) { - _maxValue = value; - } - - /** - * Get minimum value - * - * @return Minimum value - */ - public float getMinValue() { - return _minValue; - } - - /** - * Set minimum value - * - * @param value Minimum value - */ - public void setMinValue(float value) { - _minValue = value; - } - - /** - * Get bar width - * - * @return Bar width - */ - public int getBarWidth() { - return _barWidth; - } - - /** - * Set bar width - * - * @param width Bar width - */ - public void setBarWidth(int width) { - _barWidth = width; - } - - /** - * Get if avoid collision - * - * @return If avoid collisioin - */ - public boolean isAvoidCollision() { - return _avoidCollision; - } - - /** - * Set if avoid collision - * - * @param istrue If avoid collision - */ - public void setAvoidCollision(boolean istrue) { - _avoidCollision = istrue; - } - - /** - * Get align type - * - * @return Align type - */ - public AlignType getAlignType() { - return _alignType; - } - - /** - * Set align type - * - * @param type Align type - */ - public void setAlignType(AlignType type) { - _alignType = type; - } - - /** - * Set align type - * @param tstr Align type string - */ - public void setAlignType(String tstr) { - switch(tstr.toLowerCase()) { - case "center": - this._alignType = AlignType.Center; - break; - case "left": - this._alignType = AlignType.Left; - break; - case "right": - this._alignType = AlignType.Right; - break; - case "none": - this._alignType = AlignType.None; - break; - } - } - - /** - * Get if view 3D - * - * @return If view 3D - */ - public boolean isView3D() { - return _view3D; - } - - /** - * Set if view 3D - * - * @param istrue If view 3D - */ - public void setView3D(boolean istrue) { - _view3D = istrue; - } - - /** - * Get 3D thickness - * - * @return 3D thickness - */ - public int getThickness() { - return _thickness; - } - - /** - * Set 3D thickness - * - * @param value 3D thickness - */ - public void setThickness(int value) { - _thickness = value; - } - - /** - * Get if draw label - * @return Boolean - */ - public boolean isDrawLabel(){ - return this.drawLabel; - } - - /** - * Set if draw label - * @param value Boolean - */ - public void setDrawLabel(boolean value){ - this.drawLabel = value; - } - - /** - * Get label font - * @return Label font - */ - public Font getLabelFont(){ - return this.labelFont; - } - - /** - * Set label font - * @param value Label font - */ - public void setLabelFont(Font value){ - this.labelFont = value; - } - - /** - * Get label color - * @return Label color - */ - public Color getLabelColor(){ - return this.labelColor; - } - - /** - * Set label color - * @param value Label color - */ - public void setLabelColor(Color value){ - this.labelColor = value; - } - - /** - * Get decimal digits - * @return Decimal digits - */ - public int getDecimalDigits(){ - return this.decimalDigits; - } - - /** - * Set decimal digits - * @param value Decimal digits - */ - public void setDecimalDigits(int value){ - this.decimalDigits = value; - } - // - // - /** - * Update - avoid the disagree of field names and legend scheme - */ - public void update(){ - if (this._fieldNames.size() != this._legendScheme.getBreakNum()){ - this._fieldNames = new ArrayList<>(); - _legendScheme = new LegendScheme(ShapeTypes.Polygon); - } - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/FrmChartLabel.form b/MeteoInfoLib/src/main/java/org/meteoinfo/layer/FrmChartLabel.form deleted file mode 100644 index 58c8d9f2..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/FrmChartLabel.form +++ /dev/null @@ -1,146 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/FrmLabelSet.form b/MeteoInfoLib/src/main/java/org/meteoinfo/layer/FrmLabelSet.form deleted file mode 100644 index b0291a86..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/FrmLabelSet.form +++ /dev/null @@ -1,363 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/FrmLayerProperty.form b/MeteoInfoLib/src/main/java/org/meteoinfo/layer/FrmLayerProperty.form deleted file mode 100644 index 9dcc1e0d..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/FrmLayerProperty.form +++ /dev/null @@ -1,727 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/ImageLayer.java b/MeteoInfoLib/src/main/java/org/meteoinfo/layer/ImageLayer.java deleted file mode 100644 index ae0b39c9..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/ImageLayer.java +++ /dev/null @@ -1,890 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layer; - -import com.l2fprod.common.beans.BaseBeanInfo; -import com.l2fprod.common.beans.ExtendedPropertyDescriptor; -import com.l2fprod.common.beans.editor.ComboBoxPropertyEditor; -import org.meteoinfo.common.Extent; -import org.meteoinfo.common.util.GlobalUtil; -import org.meteoinfo.geometry.shape.ShapeTypes; -import java.awt.Color; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.image.BufferedImage; -import java.awt.image.Raster; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * - * @author Yaqiang Wang - */ -public class ImageLayer extends MapLayer { - // - - private BufferedImage _image; - private WorldFilePara _worldFilePara = new WorldFilePara(); - private String _worldFileName; - private boolean _isSetTransColor; - private Color _transparencyColor; - protected Object interp; - // - // - - /** - * Constructor - */ - public ImageLayer() { - super(); - this.setLayerType(LayerTypes.ImageLayer); - this.setShapeType(ShapeTypes.Image); - _isSetTransColor = false; - _transparencyColor = Color.black; - this.interp = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR; - } - // - // - - /** - * Get image - * - * @return The image - */ - public BufferedImage getImage() { - return _image; - } - - /** - * Set image - * - * @param image The image - */ - public void setImage(BufferedImage image) { - _image = image; - _transparencyColor = new Color(image.getRGB(1, 1)); - } - - /** - * Get world file name of the layer - * - * @return World file name - */ - public String getWorldFileName() { - return _worldFileName; - } - - /** - * Set world file name - * - * @param name World file name - */ - public void setWorldFileName(String name) { - _worldFileName = name; - } - - /** - * Get world file parameters - * - * @return World file parameters - */ - public WorldFilePara getWorldFilePara() { - return _worldFilePara; - } - - /** - * Set world file parameters - * - * @param value World file parameters - */ - public void setWorldFilePara(WorldFilePara value) { - _worldFilePara = value; - } - - /** - * Get if set transparency color - * - * @return Boolean - */ - public boolean isUseTransColor() { - return _isSetTransColor; - } - - /** - * Set if using transparency color - * - * @param istrue Boolean - */ - public void setUseTransColor(boolean istrue) { - _isSetTransColor = istrue; - if (istrue) { - Image image = GlobalUtil.makeColorTransparent(_image, _transparencyColor); - _image = GlobalUtil.imageToBufferedImage(image); - } - } - - /** - * Get transparency color - * - * @return Transparency color - */ - public Color getTransparencyColor() { - return _transparencyColor; - } - - /** - * Set transparency color - * - * @param color The color - */ - public void setTransparencyColor(Color color) { - _transparencyColor = color; - if (_isSetTransColor) { - Image image = GlobalUtil.makeColorTransparent(_image, _transparencyColor); - _image = GlobalUtil.imageToBufferedImage(image); - } - } - - /** - * Get X upper-left - * - * @return Upper-left x value - */ - public double getXUL() { - return _worldFilePara.xUL; - } - - /** - * Set upper-left x - * - * @param value The value - * @throws java.io.IOException - */ - public void setXUL(double value) throws IOException { - _worldFilePara.xUL = value; - Extent aExtent = (Extent) this.getExtent().clone(); - aExtent.minX = _worldFilePara.xUL; - aExtent.maxX = _worldFilePara.xUL + this.getExtent().getWidth(); - this.setExtent(aExtent); - if (new File(_worldFileName).exists()) { - writeImageWorldFile(_worldFileName, _worldFilePara); - } - } - - /** - * Get y upper-left - * - * @return Upper-left y - */ - public double getYUL() { - return _worldFilePara.yUL; - } - - /** - * Set upper-left y - * - * @param value The value - * @throws java.io.IOException - */ - public void setYUL(double value) throws IOException { - _worldFilePara.yUL = value; - Extent aExtent = (Extent) this.getExtent().clone(); - aExtent.maxY = _worldFilePara.yUL; - aExtent.minY = _worldFilePara.yUL - this.getExtent().getHeight(); - this.setExtent(aExtent); - if (new File(_worldFileName).exists()) { - writeImageWorldFile(_worldFileName, _worldFilePara); - } - } - - /** - * Get x scale - * - * @return The x scale - */ - public double getXScale() { - return _worldFilePara.xScale; - } - - /** - * Set x scale - * - * @param value The value - * @throws java.io.IOException - */ - public void setXScale(double value) throws IOException { - _worldFilePara.xScale = value; - Extent aExtent = (Extent) this.getExtent(); - double width = _image.getWidth() * _worldFilePara.xScale; - aExtent.maxX = _worldFilePara.xUL + width; - this.setExtent(aExtent); - if (new File(_worldFileName).exists()) { - writeImageWorldFile(_worldFileName, _worldFilePara); - } - } - - /** - * Get y scale - * - * @return The y scale - */ - public double getYScale() { - return _worldFilePara.yScale; - } - - /** - * Set y scale - * - * @param value The y scale value - * @throws IOException - */ - public void setYScale(double value) throws IOException { - _worldFilePara.yScale = value; - Extent aExtent = (Extent) this.getExtent(); - double height = _image.getHeight() * _worldFilePara.yScale; - aExtent.minY = _worldFilePara.yUL + height; - this.setExtent(aExtent); - if (new File(_worldFileName).exists()) { - writeImageWorldFile(_worldFileName, _worldFilePara); - } - } - - /** - * Get x rotate(shear) - * - * @return X rotate - */ - public double getXRotate() { - return _worldFilePara.xRotate; - } - - /** - * Set x rotate(shear) - * - * @param value Value - * @throws IOException - */ - public void setXRotate(double value) throws IOException { - _worldFilePara.xRotate = value; - if (new File(_worldFileName).exists()) { - writeImageWorldFile(_worldFileName, _worldFilePara); - } - } - - /** - * Get y rotate(shear) - * - * @return X rotate - */ - public double getYRotate() { - return _worldFilePara.yRotate; - } - - /** - * Set y rotate(shear) - * - * @param value Value - * @throws IOException - */ - public void setYRotate(double value) throws IOException { - _worldFilePara.yRotate = value; - if (new File(_worldFileName).exists()) { - writeImageWorldFile(_worldFileName, _worldFilePara); - } - } - - /** - * Get interpolation - * - * @return Interpolation - */ - public Object getInterpolation() { - return this.interp; - } - - /** - * Get interpolation string - * - * @return Interpolation string - */ - public String getInterpolationStr() { - if (interp == RenderingHints.VALUE_INTERPOLATION_BILINEAR) { - return "bilinear"; - } else if (interp == RenderingHints.VALUE_INTERPOLATION_BICUBIC) { - return "bicubic"; - } else { - return "nearest"; - } - } - - /** - * Set interpolation object - * - * @param value Interpolation object - */ - public void setInterpolation(Object value) { - this.interp = value; - } - - /** - * Set interpolation string - * - * @param value Interpolation string - */ - public void setInterpolation(String value) { - switch (value) { - case "nearest": - this.interp = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR; - break; - case "bilinear": - this.interp = RenderingHints.VALUE_INTERPOLATION_BILINEAR; - break; - case "bicubic": - this.interp = RenderingHints.VALUE_INTERPOLATION_BICUBIC; - break; - } - } - // - // - - /** - * Read image world file - * - * @param aIFile Image world file path - * @throws java.io.FileNotFoundException - */ - public void readImageWorldFile(String aIFile) throws FileNotFoundException, IOException { - BufferedReader sr = new BufferedReader(new FileReader(new File(aIFile))); - - _worldFilePara.xScale = Double.parseDouble(sr.readLine()); - _worldFilePara.yRotate = Double.parseDouble(sr.readLine()); - _worldFilePara.xRotate = Double.parseDouble(sr.readLine()); - _worldFilePara.yScale = Double.parseDouble(sr.readLine()); - _worldFilePara.xUL = Double.parseDouble(sr.readLine()); - _worldFilePara.yUL = Double.parseDouble(sr.readLine()); - sr.close(); - } - - /** - * Write image world file - * - * @param aFile File path - * @param aWFP WorldFilePara - * @throws java.io.IOException - */ - public void writeImageWorldFile(String aFile, WorldFilePara aWFP) throws IOException { - BufferedWriter sw = new BufferedWriter(new FileWriter(new File(aFile))); - sw.write(String.valueOf(aWFP.xScale)); - sw.newLine(); - sw.write(String.valueOf(aWFP.yRotate)); - sw.newLine(); - sw.write(String.valueOf(aWFP.xRotate)); - sw.newLine(); - sw.write(String.valueOf(aWFP.yScale)); - sw.newLine(); - sw.write(String.valueOf(aWFP.xUL)); - sw.newLine(); - sw.write(String.valueOf(aWFP.yUL)); - sw.close(); - } - - /** - * Get colors from palette file - * - * @param pFile Palette file path - * @return Colors - */ - public List getColorsFromPaletteFile(String pFile) { - BufferedReader sr; - try { - sr = new BufferedReader(new InputStreamReader(new FileInputStream(pFile))); - sr.readLine(); - String aLine = sr.readLine(); - String[] dataArray; - List colors = new ArrayList<>(); - while (aLine != null) { - if (aLine.isEmpty()) { - aLine = sr.readLine(); - continue; - } - - aLine = aLine.trim(); - dataArray = aLine.split("\\s+"); - colors.add(new Color(Integer.parseInt(dataArray[3]), Integer.parseInt(dataArray[2]), - Integer.parseInt(dataArray[1]))); - - aLine = sr.readLine(); - } - sr.close(); - - return colors; - } catch (FileNotFoundException ex) { - Logger.getLogger(ImageLayer.class.getName()).log(Level.SEVERE, null, ex); - return null; - } catch (IOException ex) { - Logger.getLogger(ImageLayer.class.getName()).log(Level.SEVERE, null, ex); - return null; - } - } - - /** - * Set palette - * - * @param colors Colors - */ - public void setPalette(List colors) { - Raster imageData = _image.getData(); - - for (int i = 0; i < _image.getWidth(); i++) { - for (int j = 0; j < _image.getHeight(); j++) { - _image.setRGB(i, _image.getHeight() - j - 1, colors.get(imageData.getSample(i, j, 0)).getRGB()); - } - } - } - - /** - * Set color palette to a image from a palette file - * - * @param aFile File path - */ - public void setPalette(String aFile) { - List colors = getColorsFromPaletteFile(aFile); - - setPalette(colors); - } - // - - // - public class ImageLayerBean { - - ImageLayerBean() { - } - - // - /** - * Get layer type - * - * @return Layer type - */ - public LayerTypes getLayerType() { - return ImageLayer.this.getLayerType(); - } - - /** - * Set layer type - * - * @param lt Layer type - */ - public void setLayerType(LayerTypes lt) { - ImageLayer.this.setLayerType(lt); - } - - /** - * Get layer draw type - * - * @return Layer draw type - */ - public LayerDrawType getLayerDrawType() { - return ImageLayer.this.getLayerDrawType(); - } - - /** - * Set layer draw type - * - * @param ldt Layer draw type - */ - public void setLayerDrawType(LayerDrawType ldt) { - ImageLayer.this.setLayerDrawType(ldt); - } - - /** - * Get file name - * - * @return File name - */ - public String getFileName() { - return ImageLayer.this.getFileName(); - } - - /** - * Set file name - * - * @param fn File name - */ - public void setFileName(String fn) { - ImageLayer.this.setFileName(fn); - } - - /** - * Get layer handle - * - * @return Layer handle - */ - public int getHandle() { - return ImageLayer.this.getHandle(); - } - - /** - * Get layer name - * - * @return Layer name - */ - public String getLayerName() { - return ImageLayer.this.getLayerName(); - } - - /** - * Set layer name - * - * @param name Layer name - */ - public void setLayerName(String name) { - ImageLayer.this.setLayerName(name); - } - - /** - * Get if is maskout - * - * @return If is maskout - */ - public boolean isMaskout() { - return ImageLayer.this.isMaskout(); - } - - /** - * Set if maskout - * - * @param value If maskout - */ - public void setMaskout(boolean value) { - ImageLayer.this.setMaskout(value); - } - - /** - * Get if is visible - * - * @return If is visible - */ - public boolean isVisible() { - return ImageLayer.this.isVisible(); - } - - /** - * Set if is visible - * - * @param value If is visible - */ - public void setVisible(boolean value) { - ImageLayer.this.setVisible(value); - } - - /** - * Get world file name of the layer - * - * @return World file name - */ - public String getWorldFileName() { - return _worldFileName; - } - - /** - * Get if set transparency color - * - * @return Boolean - */ - public boolean isUseTransColor() { - return _isSetTransColor; - } - - /** - * Set if using transparency color - * - * @param istrue Boolean - */ - public void setUseTransColor(boolean istrue) { - _isSetTransColor = istrue; - if (istrue) { - Image image = GlobalUtil.makeColorTransparent(_image, _transparencyColor); - _image = GlobalUtil.imageToBufferedImage(image); - } - } - - /** - * Get transparency color - * - * @return Transparency color - */ - public Color getTransparencyColor() { - return _transparencyColor; - } - - /** - * Set transparency color - * - * @param color The color - */ - public void setTransparencyColor(Color color) { - _transparencyColor = color; - if (_isSetTransColor) { - Image image = GlobalUtil.makeColorTransparent(_image, _transparencyColor); - _image = GlobalUtil.imageToBufferedImage(image); - } - } - - /** - * Get transparency percent - * - * @return Transparency percent - */ - public int getTransparency() { - return ImageLayer.this.getTransparency(); - } - - /** - * Set transparency percent - * - * @param value Transparency percent - */ - public void setTransparency(int value) { - ImageLayer.this.setTransparency(value); - } - - /** - * Get X upper-left - * - * @return Upper-left x value - */ - public double getXUL() { - return _worldFilePara.xUL; - } - - /** - * Set upper-left x - * - * @param value The value - * @throws java.io.IOException - */ - public void setXUL(double value) throws IOException { - _worldFilePara.xUL = value; - Extent aExtent = (Extent) ImageLayer.this.getExtent().clone(); - aExtent.minX = _worldFilePara.xUL; - aExtent.maxX = _worldFilePara.xUL + ImageLayer.this.getExtent().getWidth(); - ImageLayer.this.setExtent(aExtent); - if (new File(_worldFileName).exists()) { - writeImageWorldFile(_worldFileName, _worldFilePara); - } - } - - /** - * Get y upper-left - * - * @return Upper-left y - */ - public double getYUL() { - return _worldFilePara.yUL; - } - - /** - * Set upper-left y - * - * @param value The value - * @throws java.io.IOException - */ - public void setYUL(double value) throws IOException { - _worldFilePara.yUL = value; - Extent aExtent = (Extent) ImageLayer.this.getExtent().clone(); - aExtent.maxY = _worldFilePara.yUL; - aExtent.minY = _worldFilePara.yUL - ImageLayer.this.getExtent().getHeight(); - ImageLayer.this.setExtent(aExtent); - if (new File(_worldFileName).exists()) { - writeImageWorldFile(_worldFileName, _worldFilePara); - } - } - - /** - * Get x scale - * - * @return The x scale - */ - public double getXScale() { - return _worldFilePara.xScale; - } - - /** - * Set x scale - * - * @param value The value - * @throws java.io.IOException - */ - public void setXScale(double value) throws IOException { - _worldFilePara.xScale = value; - Extent aExtent = (Extent) ImageLayer.this.getExtent(); - double width = _image.getWidth() * _worldFilePara.xScale; - aExtent.maxX = _worldFilePara.xUL + width; - ImageLayer.this.setExtent(aExtent); - if (new File(_worldFileName).exists()) { - writeImageWorldFile(_worldFileName, _worldFilePara); - } - } - - /** - * Get y scale - * - * @return The y scale - */ - public double getYScale() { - return _worldFilePara.yScale; - } - - public void setYScale(double value) throws IOException { - _worldFilePara.yScale = value; - Extent aExtent = (Extent) ImageLayer.this.getExtent(); - double height = _image.getHeight() * _worldFilePara.yScale; - aExtent.minY = _worldFilePara.yUL + height; - ImageLayer.this.setExtent(aExtent); - if (new File(_worldFileName).exists()) { - writeImageWorldFile(_worldFileName, _worldFilePara); - } - } - - /** - * Get x rotate(shear) - * - * @return X rotate - */ - public double getXRotate() { - return _worldFilePara.xRotate; - } - - /** - * Set x rotate(shear) - * - * @param value Value - * @throws IOException - */ - public void setXRotate(double value) throws IOException { - _worldFilePara.xRotate = value; - if (new File(_worldFileName).exists()) { - writeImageWorldFile(_worldFileName, _worldFilePara); - } - } - - /** - * Get y rotate(shear) - * - * @return X rotate - */ - public double getYRotate() { - return _worldFilePara.yRotate; - } - - /** - * Set y rotate(shear) - * - * @param value Value - * @throws IOException - */ - public void setYRotate(double value) throws IOException { - _worldFilePara.yRotate = value; - if (new File(_worldFileName).exists()) { - writeImageWorldFile(_worldFileName, _worldFilePara); - } - } - - /** - * Get interpolation - * - * @return Interpolation - */ - public String getInterpolation() { - if (interp == RenderingHints.VALUE_INTERPOLATION_BILINEAR) { - return "bilinear"; - } else if (interp == RenderingHints.VALUE_INTERPOLATION_BICUBIC) { - return "bicubic"; - } else { - return "nearest"; - } - } - - /** - * Set interpolation - * - * @param value Interpolation - */ - public void setInterpolation(String value) { - switch (value) { - case "nearest": - interp = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR; - break; - case "bilinear": - interp = RenderingHints.VALUE_INTERPOLATION_BILINEAR; - break; - case "bicubic": - interp = RenderingHints.VALUE_INTERPOLATION_BICUBIC; - break; - } - } - // - } - - public static class ImageLayerBeanBeanInfo extends BaseBeanInfo { - - public ImageLayerBeanBeanInfo() { - super(ImageLayerBean.class); - addProperty("fileName").setCategory("Read only").setReadOnly().setDisplayName("File name"); - addProperty("layerType").setCategory("Read only").setReadOnly().setDisplayName("Layer type"); - addProperty("layerDrawType").setCategory("Read only").setReadOnly().setDisplayName("Layer draw type"); - addProperty("handle").setCategory("Read only").setReadOnly().setDisplayName("Handle"); - addProperty("layerName").setCategory("Editable").setDisplayName("Layer name"); - addProperty("visible").setCategory("Editable").setDisplayName("Visible"); - addProperty("maskout").setCategory("Editable").setDisplayName("Is maskout"); - addProperty("transparency").setCategory("Editable").setDisplayName("Transparency Percent"); - addProperty("useTransColor").setCategory("Editable").setDisplayName("If use transparency color"); - addProperty("transparencyColor").setCategory("Editable").setDisplayName("Transparency color"); - addProperty("xScale").setCategory("Editable").setDisplayName("X scale"); - addProperty("yScale").setCategory("Editable").setDisplayName("Y scale"); - addProperty("xUL").setCategory("Editable").setDisplayName("X upper left"); - addProperty("yUL").setCategory("Editable").setDisplayName("Y upper left"); - addProperty("xRotate").setCategory("Editable").setDisplayName("X rotate"); - addProperty("yRotate").setCategory("Editable").setDisplayName("Y rotate"); - ExtendedPropertyDescriptor e = addProperty("interpolation"); - e.setCategory("Editable").setPropertyEditorClass(InterpolationEditor.class); - e.setDisplayName("Interpolation"); - } - } - - public static class InterpolationEditor extends ComboBoxPropertyEditor { - - public InterpolationEditor() { - super(); - String[] names = new String[3]; - names[0] = "nearest"; - names[1] = "bilinear"; - names[2] = "bicubic"; - setAvailableValues(names); - } - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/LabelSet.java b/MeteoInfoLib/src/main/java/org/meteoinfo/layer/LabelSet.java deleted file mode 100644 index e3e0be4e..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/LabelSet.java +++ /dev/null @@ -1,323 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layer; - -import org.meteoinfo.common.util.GlobalUtil; -import org.meteoinfo.geometry.legend.AlignType; - -import java.awt.Color; -import java.awt.Font; - - /** - * Template - * - * @author Yaqiang Wang - */ -public class LabelSet { - // - - private boolean _drawLabels; - private String _fieldName; - private Font _labelFont; - private Color _labelColor; - private boolean _drawShadow; - private Color _shadowColor; - private AlignType _labelAlignType; - private int _xOffset; - private int _yOffset; - private boolean _avoidCollision; - private boolean _colorByLegend; - private boolean _dynamicContourLabel; - private boolean _autoDecimal; - private int _decimalDigits; - // - // - - public LabelSet() { - _drawLabels = false; - _fieldName = null; - _labelFont = new Font(GlobalUtil.getDefaultFontName(), Font.PLAIN, 12); - _labelColor = Color.black; - _drawShadow = false; - _shadowColor = Color.white; - _labelAlignType = AlignType.Center; - _xOffset = 0; - _yOffset = 0; - _avoidCollision = true; - _colorByLegend = false; - _dynamicContourLabel = false; - _autoDecimal = true; - _decimalDigits = 2; - } - // - // - - /** - * Get if draw labels - * - * @return If draw labels - */ - public boolean isDrawLabels() { - return _drawLabels; - } - - /** - * Set if draw labels - * - * @param istrue If draw labels - */ - public void setDrawLabels(boolean istrue) { - _drawLabels = istrue; - } - - /** - * Get label field name - * - * @return Label field name - */ - public String getFieldName() { - return _fieldName; - } - - /** - * Set label field name - * - * @param name Label field name - */ - public void setFieldName(String name) { - _fieldName = name; - } - - /** - * Get label font - * - * @return Font - */ - public Font getLabelFont() { - return _labelFont; - } - - /** - * Set label font - * - * @param font Label font - */ - public void setLabelFont(Font font) { - _labelFont = font; - } - - /** - * Get label color - * - * @return Label color - */ - public Color getLabelColor() { - return _labelColor; - } - - /** - * Set label color - * - * @param color Label color - */ - public void setLabelColor(Color color) { - _labelColor = color; - } - - /** - * Get if show shadow - * - * @return If show shadow - */ - public boolean isDrawShadow() { - return _drawShadow; - } - - /** - * Set if show shadow - * - * @param istrue If show shadow - */ - public void setDrawShadow(boolean istrue) { - _drawShadow = istrue; - } - - /** - * Get shadow color - * - * @return Shadow color - */ - public Color getShadowColor() { - return _shadowColor; - } - - /** - * Set shadow color - * - * @param color Shadow color - */ - public void setShadowColor(Color color) { - _shadowColor = color; - } - - /** - * Get label align type - * - * @return Align type - */ - public AlignType getLabelAlignType() { - return _labelAlignType; - } - - /** - * Set label align type - * - * @param type Align type - */ - public void setLabelAlignType(AlignType type) { - _labelAlignType = type; - } - - /** - * Get x offset - * - * @return X offset - */ - public int getXOffset() { - return _xOffset; - } - - /** - * Set x offset - * - * @param value X offset - */ - public void setXOffset(int value) { - _xOffset = value; - } - - /** - * Get y offset - * - * @return Y offset - */ - public int getYOffset() { - return _yOffset; - } - - /** - * Set y offset - * - * @param value Y offset - */ - public void setYOffset(int value) { - _yOffset = value; - } - - /** - * Get if avoid collision - * - * @return If avoid collision - */ - public boolean isAvoidCollision() { - return _avoidCollision; - } - - /** - * Set if avoid collision - * - * @param istrue If avoid collision - */ - public void setAvoidCollision(boolean istrue) { - _avoidCollision = istrue; - } - - /** - * Get if set color by legend - * - * @return Boolean - */ - public boolean isColorByLegend() { - return _colorByLegend; - } - - /** - * Set if set color by legend - * - * @param istrue Boolean - */ - public void setColorByLegend(boolean istrue) { - _colorByLegend = istrue; - } - - /** - * Get if using dynamic contour label - * - * @return Boolean - */ - public boolean isDynamicContourLabel() { - return _dynamicContourLabel; - } - - /** - * Set if using dynamic contour label - * - * @param istrue Boolean - */ - public void setDynamicContourLabel(boolean istrue) { - _dynamicContourLabel = istrue; - } - - /// - /// Get or set if automatic set decimal digits - /// - /** - * Get if automatic set decimal digits - * - * @return Boolean - */ - public boolean isAutoDecimal() { - return _autoDecimal; - } - - /** - * Set if automatic set decimal digits - * - * @param istrue Boolean - */ - public void setAutoDecimal(boolean istrue) { - _autoDecimal = istrue; - } - - /** - * Get decimal digits - * - * @return Decimal digits - */ - public int getDecimalDigits() { - return _decimalDigits; - } - - /** - * Set decimal digits - * - * @param value Decimal digits - */ - public void setDecimalDigits(int value) { - _decimalDigits = value; - } - // - // - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/LayerCollection.java b/MeteoInfoLib/src/main/java/org/meteoinfo/layer/LayerCollection.java deleted file mode 100644 index fcbf4d14..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/LayerCollection.java +++ /dev/null @@ -1,59 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layer; - -import java.util.ArrayList; - -/** - * - * @author Yaqiang Wang - */ -public class LayerCollection extends ArrayList { - // - - private int _selectedLayer; - // - // - - /** - * Constructor - */ - public LayerCollection() { - _selectedLayer = -1; - } - // - // - - /** - * Get selected layer - * - * @return Selected layer handle - */ - public int getSelectedLayer() { - return _selectedLayer; - } - - /** - * Set selected layer handle - * - * @param handle Layer handle - */ - public void setSelectedLayer(int handle) { - _selectedLayer = handle; - } - - // - // - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/LayerDrawType.java b/MeteoInfoLib/src/main/java/org/meteoinfo/layer/LayerDrawType.java deleted file mode 100644 index de6f94cb..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/LayerDrawType.java +++ /dev/null @@ -1,38 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layer; - -/** - * Layer draw type enum - * - * @author Yaqiang Wang - */ -public enum LayerDrawType { - - Map, - Shaded, - Contour, - GridFill, - GridPoint, - Vector, - StationPoint, - Barb, - WeatherSymbol, - StationModel, - Image, - Raster, - TrajLine, - TrajPoint, - Streamline -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/LayerTypes.java b/MeteoInfoLib/src/main/java/org/meteoinfo/layer/LayerTypes.java deleted file mode 100644 index daa426bb..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/LayerTypes.java +++ /dev/null @@ -1,26 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layer; - -/** - * Layer type enum - * - * @author Yaqiang Wang - */ -public enum LayerTypes { - VectorLayer, - ImageLayer, - RasterLayer, - WebMapLayer -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/MapLayer.java b/MeteoInfoLib/src/main/java/org/meteoinfo/layer/MapLayer.java deleted file mode 100644 index 66ce5c08..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/MapLayer.java +++ /dev/null @@ -1,382 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layer; - -import org.meteoinfo.common.Extent; -import org.meteoinfo.geometry.legend.LegendScheme; -import org.meteoinfo.projection.KnownCoordinateSystems; -import org.meteoinfo.projection.ProjectionInfo; -import org.meteoinfo.geometry.shape.ShapeTypes; - -/** - * Map layer class - * - * @author Yaqiang Wang - */ -public class MapLayer implements Cloneable { - // - - private LayerTypes _layerType; - private ShapeTypes _shapeType; - private int _handle; - private String _layerName; - private String _fileName; - protected ProjectionInfo _projInfo; - private Extent _extent; - private boolean _visible; - private LayerDrawType _layerDrawType; - private boolean _isMaskout; - private LegendScheme _legendScheme; - private boolean _expanded; - private int _transparencyPerc; - private String _tag; - private VisibleScale _visibleScale; - // - // - - /** - * Constructor - */ - public MapLayer() { - _layerName = "layer"; - _fileName = ""; - _projInfo = KnownCoordinateSystems.geographic.world.WGS1984; - _handle = -1; - _extent = new Extent(); - _visible = true; - _isMaskout = false; - _expanded = false; - _transparencyPerc = 0; - _layerDrawType = LayerDrawType.Map; - _tag = ""; - _visibleScale = new VisibleScale(); - } - // - // - - /** - * Get layer type - * - * @return Layer type - */ - public LayerTypes getLayerType() { - return _layerType; - } - - /** - * Set layer type - * - * @param lt Layer type - */ - public void setLayerType(LayerTypes lt) { - _layerType = lt; - } - - /** - * Get shape type - * - * @return Shape type - */ - public ShapeTypes getShapeType() { - return _shapeType; - } - - /** - * Set shape type - * - * @param st Shape type - */ - public void setShapeType(ShapeTypes st) { - _shapeType = st; - } - - /** - * Get layer draw type - * - * @return Layer draw type - */ - public LayerDrawType getLayerDrawType() { - return _layerDrawType; - } - - /** - * Set layer draw type - * - * @param ldt Layer draw type - */ - public void setLayerDrawType(LayerDrawType ldt) { - _layerDrawType = ldt; - } - - /** - * Get file name - * - * @return File name - */ - public String getFileName() { - return _fileName; - } - - /** - * Set file name - * - * @param fn File name - */ - public void setFileName(String fn) { - _fileName = fn; - } - - /** - * Get layer handle - * - * @return Layer handle - */ - public int getHandle() { - return _handle; - } - - /** - * Set layer handle - * - * @param handle Layer handle - */ - public void setHandle(int handle) { - _handle = handle; - } - - /** - * Get layer name - * - * @return Layer name - */ - public String getLayerName() { - return _layerName; - } - - /** - * Set layer name - * - * @param lName Layer name - */ - public void setLayerName(String lName) { - _layerName = lName; - } - - /** - * Get extent - * - * @return Extent - */ - public Extent getExtent() { - return _extent; - } - - /** - * Set extent - * - * @param extent Extent - */ - public void setExtent(Extent extent) { - _extent = extent; - } - - /** - * Get if layer is visible - * - * @return Boolean - */ - public boolean isVisible() { - return _visible; - } - - /** - * Set if layer is visible - * - * @param isTrue Boolean - */ - public void setVisible(boolean isTrue) { - _visible = isTrue; - } - - /** - * Get legend scheme - * - * @return Legend scheme - */ - public LegendScheme getLegendScheme() { - return _legendScheme; - } - - /** - * Get if is maskout - * @return Boolean - */ - public boolean isMaskout(){ - return this._isMaskout; - } - - /** - * Set if is maskout - * @param istrue Boolean - */ - public void setMaskout(boolean istrue){ - this._isMaskout = istrue; - } - - /** - * Set legend scheme - * - * @param ls - */ - public void setLegendScheme(LegendScheme ls) { - _legendScheme = ls; - } - - /** - * Get transparency percent - * - * @return Transparency percent - */ - public int getTransparency() { - return this._transparencyPerc; - } - - /** - * Set transparency percent - * - * @param trans Transparency percent - */ - public void setTransparency(int trans) { - this._transparencyPerc = trans; - } - - /** - * Get if is expanded - * - * @return Boolean - */ - public boolean isExpanded() { - return this._expanded; - } - - /** - * Set if expand - * - * @param istrue Boolean - */ - public void setExpanded(boolean istrue) { - this._expanded = istrue; - } - - /** - * Get projection info - * @return Projection info - */ - public ProjectionInfo getProjInfo(){ - return _projInfo; - } - - /** - * Set projection info - * @param projInfo Projection info - */ - public void setProjInfo(ProjectionInfo projInfo){ - _projInfo = projInfo; - } - - /** - * Get tag - * @return Tag - */ - public String getTag(){ - return _tag; - } - - /** - * Set tag - * @param value Tag value - */ - public void setTag(String value){ - _tag = value; - } - - /** - * Get visible scale - * @return Visible scale - */ - public VisibleScale getVisibleScale(){ - return _visibleScale; - } - - /** - * Set visible scale - * @param value Visible scale - */ - public void setVisibleScale(VisibleScale value){ - _visibleScale = value; - } - // - // - /** - * If the layer has legend schem or not - * @return Boolean - */ - public boolean hasLegendScheme(){ - return this._legendScheme != null; - } - - @Override - public Object clone() throws CloneNotSupportedException { - MapLayer aLayer = (MapLayer)super.clone(); - if (_legendScheme != null) - aLayer._legendScheme = (LegendScheme)this._legendScheme.clone(); - - return aLayer; - } - - /** - * To string - * @return String - */ - @Override - public String toString(){ - return this.getLayerName(); - } - - /** - * To string - * @return String - */ - public String getLayerInfo(){ - String str = "Layer name: " + this.getLayerName(); - str += System.getProperty("line.separator") + "Layer file: " + this.getFileName(); - str += System.getProperty("line.separator") + "Layer type: " + this.getLayerType(); - str += System.getProperty("line.separator") + "Shape type: " + this.getShapeType(); - - return str; - } - - /** - * Save layer to a file - */ - public void saveFile(){} - - /** - * Save layer to a file - * @param fileName File name - */ - public void saveFile(String fileName){} - // - -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/RasterLayer.java b/MeteoInfoLib/src/main/java/org/meteoinfo/layer/RasterLayer.java deleted file mode 100644 index a8b186e2..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/RasterLayer.java +++ /dev/null @@ -1,582 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layer; - -import com.l2fprod.common.beans.BaseBeanInfo; -import com.l2fprod.common.beans.ExtendedPropertyDescriptor; -import org.meteoinfo.common.Extent; -import org.meteoinfo.common.GenericFileFilter; -import org.meteoinfo.common.MIMath; -import org.meteoinfo.common.util.GlobalUtil; -import org.meteoinfo.data.GridArray; -import org.meteoinfo.geometry.legend.LegendScheme; -import org.meteoinfo.geometry.shape.ShapeTypes; -import java.awt.Color; -import java.awt.RenderingHints; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; - -import org.meteoinfo.data.mapdata.MapDataManage; -import org.meteoinfo.projection.ProjectionInfo; -import org.meteoinfo.ndarray.Index; - -/** - * - * @author yaqiang - */ -public class RasterLayer extends ImageLayer { - // - - //private LegendScheme _legendScheme; - private GridArray _gridData; - private GridArray _originGridData = null; - private boolean _isProjected = false; - private List _colors; - //private InterpolationMode _interpMode = InterpolationMode.NearestNeighbor; - // - // - - /** - * Constructor - */ - public RasterLayer() { - this.setLayerType(LayerTypes.RasterLayer); - this.setShapeType(ShapeTypes.Image); - } - // - // - - /** - * Set legend scheme - * - * @param ls Legend scheme - */ - @Override - public void setLegendScheme(LegendScheme ls) { - super.setLegendScheme(ls); - if (ls == null) { - updateImage(ls); - } else if (ls.getBreakNum() < 200) { - updateImage(ls); - } else { - setPaletteByLegend(); - } - } - - /** - * Get grid data - * - * @return Grid data - */ - public GridArray getGridData() { - return _gridData; - } - - /** - * Set grid data - * - * @param gdata Grid data - */ - public void setGridData(GridArray gdata) { - _gridData = gdata; - updateGridData(); - } - - /** - * Get if is projected - * - * @return Boolean - */ - public boolean isProjected() { - return _isProjected; - } - - /** - * Set if is projected - * - * @param istrue Boolean - */ - public void setProjected(boolean istrue) { - _isProjected = istrue; - } - -// public InterpolationMode InterpMode -// { -// get { return _interpMode; } -// set -// { -// _interpMode = value; -// if (_interpMode == InterpolationMode.Invalid) -// _interpMode = InterpolationMode.NearestNeighbor; -// } -// } - // - // - /** - * Get cell value by a point - * - * @param iIdx I index - * @param jIdx J index - * @return Cell value - */ - public double getCellValue(int iIdx, int jIdx) { - return _gridData.getDoubleValue(iIdx, jIdx); - } - - /** - * Update image by legend scheme - * - * @param als The legend scheme - */ - public void updateImage(LegendScheme als) { - BufferedImage image; - if (_gridData.getData().getRank() <= 2) { - image = getImageFromGridData(_gridData, als); - } else { - image = getRGBImage(_gridData); - super.setLegendScheme(null); - } - this.setImage(image); - } - - /** - * Update image by legend scheme - */ - public void updateImage() { - BufferedImage image = getImageFromGridData(_gridData, this.getLegendScheme()); - this.setImage(image); - } - - private BufferedImage getRGBImage(GridArray gdata) { - int width, height, r, g, b; - width = gdata.getXNum(); - height = gdata.getYNum(); - BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - Index index = gdata.getData().getIndex(); - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - r = gdata.getData().getInt(index); - index.incr(); - g = gdata.getData().getInt(index); - index.incr(); - b = gdata.getData().getInt(index); - index.incr(); - image.setRGB(j, height - i - 1, new Color(r, g, b).getRGB()); - } - } - - return image; - } - - private BufferedImage getImageFromGridData(GridArray gdata, LegendScheme als) { - int width, height, breakNum; - width = gdata.getXNum(); - height = gdata.getYNum(); - breakNum = als.getBreakNum(); - double[] breakValue = new double[breakNum]; - Color[] breakColor = new Color[breakNum]; - Color undefColor = new Color(255, 255, 255, 0); - Color defaultColor = als.getLegendBreaks().get(breakNum - 1).getColor(); - Color color; - for (int i = 0; i < breakNum; i++) { - breakValue[i] = Double.parseDouble(als.getLegendBreaks().get(i).getEndValue().toString()); - color = als.getLegendBreaks().get(i).getColor(); - breakColor[i] = color; - if (als.getLegendBreaks().get(i).isNoData()) { - undefColor = color; - } else { - defaultColor = color; - } - } - BufferedImage aImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - double oneValue; - Color oneColor; - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - //oneValue = gdata.data[i][j]; - oneValue = gdata.getDoubleValue(i, j); - if (Double.isNaN(oneValue) || MIMath.doubleEquals(oneValue, gdata.missingValue)) { - oneColor = undefColor; - } else { - oneColor = als.findLegendBreak(oneValue).getColor(); - } - aImage.setRGB(j, height - i - 1, oneColor.getRGB()); - } - } - - return aImage; - } - - private BufferedImage getImageFromGridData(GridArray gdata, List colors) { - int width, height; - width = gdata.getXNum(); - height = gdata.getYNum(); - BufferedImage aImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - int oneValue; - Color oneColor; - int n = colors.size(); - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - oneValue = gdata.getValue(i, j).intValue(); - oneColor = colors.get(oneValue); - aImage.setRGB(j, height - i - 1, oneColor.getRGB()); - } - } - - return aImage; - } - - /** - * Set color palette to a image from a palette file - * - * @param aFile File path - */ - @Override - public void setPalette(String aFile) { - List colors = this.getColorsFromPaletteFile(aFile); - BufferedImage image = this.getImageFromGridData(_gridData, colors); - this.setImage(image); - - LegendScheme ls = new LegendScheme(ShapeTypes.Image); - ls.importFromPaletteFile_Unique(aFile); - this.setLegendScheme(ls); - } - - /** - * Set color palette by legend scheme - */ - public void setPaletteByLegend() { - _colors = this.getLegendScheme().getColors(); - BufferedImage image = this.getImageFromGridData(_gridData, _colors); - this.setImage(image); - } - - /** - * Update grid data - */ - public void updateGridData() { - WorldFilePara aWFP = new WorldFilePara(); - - //aWFP.xUL = _gridData.xArray[0]; - //aWFP.yUL = _gridData.yArray[_gridData.getYNum() - 1]; - aWFP.xUL = _gridData.xArray[0] - _gridData.getXDelt() / 2; - aWFP.yUL = _gridData.yArray[_gridData.getYNum() - 1] + _gridData.getYDelt() / 2; - aWFP.xScale = _gridData.getXDelt(); - aWFP.yScale = -_gridData.getYDelt(); - - aWFP.xRotate = 0; - aWFP.yRotate = 0; - - this.setWorldFilePara(aWFP); - - updateExtent(); - } - - private void updateExtent() { - double XBR, YBR; - XBR = _gridData.getXNum() * this.getWorldFilePara().xScale + this.getWorldFilePara().xUL; - YBR = _gridData.getYNum() * this.getWorldFilePara().yScale + this.getWorldFilePara().yUL; - Extent aExtent = new Extent(); - aExtent.minX = this.getWorldFilePara().xUL; - aExtent.minY = YBR; - aExtent.maxX = XBR; - aExtent.maxY = this.getWorldFilePara().yUL; - this.setExtent(aExtent); - } - - /** - * Update origin data - */ - public void updateOriginData() { - _originGridData = (GridArray) _gridData.clone(); - _isProjected = true; - } - - /** - * Get origin data - */ - public void getOriginData() { - _gridData = (GridArray) _originGridData.clone(); - } - - /** - * Save layer as a shape file - */ - @Override - public void saveFile() { - File aFile = new File(this.getFileName()); - if (aFile.exists()) { - saveFile(aFile.getAbsolutePath()); - } else { - JFileChooser aDlg = new JFileChooser(); - String curDir = System.getProperty("user.dir"); - aDlg.setCurrentDirectory(new File(curDir)); - String[] fileExts = {"bil"}; - GenericFileFilter pFileFilter = new GenericFileFilter(fileExts, "BIL File (*.bil)"); - aDlg.addChoosableFileFilter(pFileFilter); - aDlg.setFileFilter(pFileFilter); - fileExts = new String[]{"grd"}; - pFileFilter = new GenericFileFilter(fileExts, "Surfer ASCII Grid File (*.grd)"); - aDlg.addChoosableFileFilter(pFileFilter); - fileExts = new String[]{"asc"}; - pFileFilter = new GenericFileFilter(fileExts, "ESRI ASCII Grid File (*.asc)"); - aDlg.addChoosableFileFilter(pFileFilter); - aDlg.setAcceptAllFileFilterUsed(false); - if (JFileChooser.APPROVE_OPTION == aDlg.showSaveDialog(null)) { - aFile = aDlg.getSelectedFile(); - System.setProperty("user.dir", aFile.getParent()); - String extent = ((GenericFileFilter) aDlg.getFileFilter()).getFileExtent(); - String fileName = aFile.getAbsolutePath(); - if (!fileName.substring(fileName.length() - extent.length()).equals(extent)) { - fileName = fileName + "." + extent; - } - saveFile(fileName); - } - } - } - - /** - * Save layer as a file - * - * @param fileName File name - */ - @Override - public void saveFile(String fileName) { - this.saveFile(fileName, this.getProjInfo()); - } - - /** - * Save layer as a file - * - * @param fileName File name - * @param projInfo Projection information - */ - public void saveFile(String fileName, ProjectionInfo projInfo) { - File aFile = new File(fileName); - if (aFile.exists()) { - int n = JOptionPane.showConfirmDialog(null, "Overwirte the existing file?", "Overwrite confirm", JOptionPane.YES_NO_OPTION); - if (n == JOptionPane.NO_OPTION) { - return; - } - } - try { - this.setFileName(fileName); - String ext = GlobalUtil.getFileExtension(fileName); - switch (ext) { - case "bil": - this._gridData.saveAsBILFile(fileName); - break; - case "grd": - this._gridData.saveAsSurferASCIIFile(fileName); - break; - case "asc": - this._gridData.saveAsESRIASCIIFile(fileName); - break; - default: - return; - } - if (!this.getProjInfo().isLonLat()) { - String projFn = fileName.substring(0, fileName.length() - 3) + "prj"; - MapDataManage.writeProjFile(projFn, projInfo); - } - } catch (IOException ex) { - Logger.getLogger(RasterLayer.class.getName()).log(Level.SEVERE, null, ex); - } - } - - // - // - public class RasterLayerBean { - - RasterLayerBean() { - } - - // - /** - * Get layer type - * - * @return Layer type - */ - public LayerTypes getLayerType() { - return RasterLayer.this.getLayerType(); - } - - /** - * Set layer type - * - * @param lt Layer type - */ - public void setLayerType(LayerTypes lt) { - RasterLayer.this.setLayerType(lt); - } - - /** - * Get layer draw type - * - * @return Layer draw type - */ - public LayerDrawType getLayerDrawType() { - return RasterLayer.this.getLayerDrawType(); - } - - /** - * Set layer draw type - * - * @param ldt Layer draw type - */ - public void setLayerDrawType(LayerDrawType ldt) { - RasterLayer.this.setLayerDrawType(ldt); - } - - /** - * Get file name - * - * @return File name - */ - public String getFileName() { - return RasterLayer.this.getFileName(); - } - - /** - * Set file name - * - * @param fn File name - */ - public void setFileName(String fn) { - RasterLayer.this.setFileName(fn); - } - - /** - * Get layer handle - * - * @return Layer handle - */ - public int getHandle() { - return RasterLayer.this.getHandle(); - } - - /** - * Get layer name - * - * @return Layer name - */ - public String getLayerName() { - return RasterLayer.this.getLayerName(); - } - - /** - * Set layer name - * - * @param name Layer name - */ - public void setLayerName(String name) { - RasterLayer.this.setLayerName(name); - } - - /** - * Get if is maskout - * - * @return If is maskout - */ - public boolean isMaskout() { - return RasterLayer.this.isMaskout(); - } - - /** - * Set if maskout - * - * @param value If maskout - */ - public void setMaskout(boolean value) { - RasterLayer.this.setMaskout(value); - } - - /** - * Get if is visible - * - * @return If is visible - */ - public boolean isVisible() { - return RasterLayer.this.isVisible(); - } - - /** - * Set if is visible - * - * @param value If is visible - */ - public void setVisible(boolean value) { - RasterLayer.this.setVisible(value); - } - - /** - * Get interpolation - * - * @return Interpolation - */ - public String getInterpolation() { - if (interp == RenderingHints.VALUE_INTERPOLATION_BILINEAR) { - return "bilinear"; - } else if (interp == RenderingHints.VALUE_INTERPOLATION_BICUBIC) { - return "bicubic"; - } else { - return "nearest"; - } - } - - /** - * Set interpolation - * - * @param value Interpolation - */ - public void setInterpolation(String value) { - switch (value) { - case "nearest": - interp = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR; - break; - case "bilinear": - interp = RenderingHints.VALUE_INTERPOLATION_BILINEAR; - break; - case "bicubic": - interp = RenderingHints.VALUE_INTERPOLATION_BICUBIC; - break; - } - } - // - } - - public static class RasterLayerBeanBeanInfo extends BaseBeanInfo { - - public RasterLayerBeanBeanInfo() { - super(RasterLayer.RasterLayerBean.class); - addProperty("fileName").setCategory("Read only").setReadOnly().setDisplayName("File name"); - addProperty("layerType").setCategory("Read only").setReadOnly().setDisplayName("Layer type"); - addProperty("layerDrawType").setCategory("Read only").setReadOnly().setDisplayName("Layer draw type"); - addProperty("handle").setCategory("Read only").setReadOnly().setDisplayName("Handle"); - addProperty("layerName").setCategory("Editable").setDisplayName("Layer name"); - addProperty("visible").setCategory("Editable").setDisplayName("Visible"); - addProperty("maskout").setCategory("Editable").setDisplayName("Is maskout"); - ExtendedPropertyDescriptor e = addProperty("interpolation"); - e.setCategory("Editable").setPropertyEditorClass(InterpolationEditor.class); - e.setDisplayName("Interpolation"); - } - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/VectorLayer.java b/MeteoInfoLib/src/main/java/org/meteoinfo/layer/VectorLayer.java deleted file mode 100644 index 071c160a..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/VectorLayer.java +++ /dev/null @@ -1,3144 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layer; - -import org.meteoinfo.common.*; -import org.meteoinfo.data.mapdata.ShapeFileManage; -import org.meteoinfo.geometry.legend.*; -import org.meteoinfo.geoprocess.GeoComputation; -import org.meteoinfo.common.colors.ColorUtil; -import org.meteoinfo.projection.ProjectionInfo; -import org.meteoinfo.table.*; -import org.meteoinfo.ndarray.DataType; -import org.meteoinfo.geometry.graphic.Graphic; -import org.meteoinfo.geometry.shape.PointShape; -import org.meteoinfo.geometry.shape.PolygonShape; -import org.meteoinfo.geometry.shape.PolylineShape; -import org.meteoinfo.geometry.shape.Shape; -import org.meteoinfo.geometry.shape.ShapeTypes; -import java.awt.Color; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.undo.UndoManager; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Result; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.sax.SAXTransformerFactory; -import javax.xml.transform.sax.TransformerHandler; -import javax.xml.transform.stream.StreamResult; - -import org.locationtech.jts.geom.Coordinate; -import org.locationtech.jts.geom.Geometry; -import org.locationtech.jts.geom.GeometryFactory; -import org.locationtech.jts.operation.union.CascadedPolygonUnion; -import org.meteoinfo.legend.LegendManage; -import org.meteoinfo.geometry.graphic.ChartGraphic; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.AttributesImpl; -import org.meteoinfo.geometry.shape.PointZShape; -import org.meteoinfo.geometry.shape.Polygon; -import org.meteoinfo.geometry.shape.Polyline; -import org.meteoinfo.geometry.shape.PolylineZShape; - -/** - * Vector layer class - * - * @author yaqiang - */ -public class VectorLayer extends MapLayer { - - enum SelectType { - NEW, - ADD_TO_CURRENT, - REMOVE_FROM_CURRENT, - SELECT_FROM_CURRENT - } - - // - //private final boolean _isEditing; - private boolean _avoidCollision; - private List _shapeList; - private AttributeTable _attributeTable; - private LabelSet _labelSet; - private List _labelPoints; - private ChartSet _chartSet; - private List _chartPoints; - //private int _numFields; - private int _identiferShape; - private float _drawingZoom = 1.0f; - private List _originShapes = null; - private AttributeTable _originAttributeTable = null; - private List _originLabelPoints = null; - private List _originChartPoints = null; - private ProjectionInfo originProjInfo = null; - private boolean _projected = false; - private boolean editing = false; - private Shape editingShape; - private final UndoManager undoManager = new UndoManager(); - // - - // - /** - * Constructor - * - * @param shapeType Shape type - */ - public VectorLayer(ShapeTypes shapeType) { - super(); - this.setLayerType(LayerTypes.VectorLayer); - this.setShapeType(shapeType); - _avoidCollision = false; - _attributeTable = new AttributeTable(); - _labelSet = new LabelSet(); - _labelPoints = new ArrayList<>(); - _chartSet = new ChartSet(); - _chartPoints = new ArrayList<>(); - _shapeList = new ArrayList<>(); - LegendScheme ls = LegendManage.createSingleSymbolLegendScheme(shapeType); - super.setLegendScheme(ls); - //_isEditing = false; - } - // - - // - /** - * Get UndoManager - * - * @return UndoManager - */ - public UndoManager getUndoManager() { - return undoManager; - } - - /** - * Get if avoid collision - * - * @return Boolean - */ - public boolean getAvoidCollision() { - return this._avoidCollision; - } - - /** - * Set if avoid collision - * - * @param istrue Boolean - */ - public void setAvoidCollision(boolean istrue) { - this._avoidCollision = istrue; - } - - /** - * Get shape number - * - * @return Shape number - */ - public int getShapeNum() { - return _shapeList.size(); - } - - /** - * Get shape list - * - * @return Shape list - */ - public List getShapes() { - return _shapeList; - } - - /** - * Set shape list - * - * @param shapes Shape list - */ - public void setShapes(List shapes) { - _shapeList = (List) shapes; - } - - /** - * Get attribute table - * - * @return The attribute table - */ - public AttributeTable getAttributeTable() { - return _attributeTable; - } - - /** - * Set attribute table - * - * @param table The attribute table - */ - public void setAttributeTable(AttributeTable table) { - _attributeTable = table; - } - -// /** -// * Get field number -// * -// * @return Field number -// */ -// public int getFieldNum() { -// return this._numFields; -// } -// /** -// * Set field number -// * -// * @param fNum Field number -// */ -// public void setFieldNum(int fNum) { -// this._numFields = fNum; -// } - /** - * Get identifer shape index - * - * @return The identifer shape index - */ - public int getIdentiferShape() { - return this._identiferShape; - } - - /** - * Set identifer shape index - * - * @param idx Identifer shape index - */ - public void setIdentiferShape(int idx) { - this._identiferShape = idx; - } - - @Override - public void setTransparency(int trans) { - super.setTransparency(trans); - switch (this.getShapeType()) { - case Polygon: - case PolygonM: - case PolygonZ: - for (int i = 0; i < this.getLegendScheme().getBreakNum(); i++) { - PolygonBreak aPGB = (PolygonBreak) this.getLegendScheme().getLegendBreaks().get(i); - int alpha = (int) ((1 - (double) trans / 100.0) * 255); - Color aColor = aPGB.getColor(); - aPGB.setColor(new Color(aColor.getRed(), aColor.getGreen(), aColor.getBlue(), alpha)); - } - break; - } - } - - /** - * Get label set - * - * @return Label set - */ - public LabelSet getLabelSet() { - return _labelSet; - } - - /** - * Set label set - * - * @param ls Label set - */ - public void setLabelSet(LabelSet ls) { - _labelSet = ls; - } - - /** - * Get label points - * - * @return The lable points - */ - public List getLabelPoints() { - return this._labelPoints; - } - - /** - * Set label points - * - * @param lps The lable points - */ - public void setLabelPoints(List lps) { - this._labelPoints = lps; - } - - /** - * Get chart set - * - * @return Chart set - */ - public ChartSet getChartSet() { - return _chartSet; - } - - /** - * Set chart set - * - * @param cs Chart set - */ - public void setChartSet(ChartSet cs) { - _chartSet = cs; - } - - /** - * Get chart points - * - * @return The chart points - */ - public List getChartPoints() { - return this._chartPoints; - } - - /** - * Set chart pints - * - * @param cps The chart points - */ - public void setChartPoints(List cps) { - this._chartPoints = cps; - } - - /** - * Get drawing zoom - * - * @return Drawing zoom - */ - public float getDrawingZoom() { - return this._drawingZoom; - } - - /** - * Set drawing zoom - * - * @param zoom Drawing zoom - */ - public void setDrawingZoom(float zoom) { - _drawingZoom = zoom; - } - - /** - * Get origin ProjectionInfo - * @return ProjectionInfo - */ - public ProjectionInfo getOriginProjInfo() { - return this.originProjInfo == null ? this._projInfo : this.originProjInfo; - } - - /** - * Get if is projected - * - * @return Boolean - */ - public boolean isProjected() { - return _projected; - } - - /** - * Set if is projected - * - * @param istrue Boolean - */ - public void setProjected(boolean istrue) { - _projected = istrue; - } - - /** - * Override set legend scheme - * - * @param value Legend scheme - */ - @Override - public void setLegendScheme(LegendScheme value) { - super.setLegendScheme(value); - List fieldNames = this._attributeTable.getTable().getColumnNames(); - switch (value.getLegendType()) { - case UniqueValue: - if (!fieldNames.contains(value.getFieldName())) { - LegendScheme ls = this.getLegendScheme(); - ls.setFieldName(fieldNames.get(0)); - for (int i = 0; i < this.getShapeNum(); i++) { - ColorBreak cb = ls.getLegendBreaks().get(i); - cb.setStartValue(this.getCellValue(fieldNames.get(0), i)); - cb.setEndValue(cb.getStartValue()); - } - } - break; - case GraduatedColor: - if (!fieldNames.contains(value.getFieldName()) && !value.isGeometry()) { - String fName = ""; - if (fieldNames.size() > 0) { - fName = fieldNames.get(0); - } - LegendScheme ls = this.createLegendScheme(LegendType.SingleSymbol, fName); - super.setLegendScheme(ls); - } - break; - } - updateLegendIndexes(); - } - - /** - * Get if is editing - * - * @return Boolean - */ - public boolean isEditing() { - return editing; - } - - /** - * Set if is editing - * - * @param value Boolean - */ - public void setEditing(boolean value) { - editing = value; - } - - /** - * Get editing shape - * - * @return Editing shape - */ - public Shape getEditingShape() { - return editingShape; - } - - /** - * Set editing shape - * - * @param value The shape - */ - public void setEditingShape(Shape value) { - editingShape = value; - for (Shape shape : _shapeList) { - shape.setEditing(false); - } - editingShape.setEditing(true); - } - - // - // - // - /** - * Update charts properties - */ - public void updateChartsProp() { - for (Graphic chartG : _chartPoints) { - ChartBreak aCP = (ChartBreak) chartG.getLegend(); - aCP.setLegendScheme(_chartSet.getLegendScheme()); - aCP.setMinSize(_chartSet.getMinSize()); - aCP.setMaxSize(_chartSet.getMaxSize()); - aCP.setMinValue(_chartSet.getMinValue()); - aCP.setMaxValue(_chartSet.getMaxValue()); - aCP.setBarWidth(_chartSet.getBarWidth()); - aCP.setAlignType(_chartSet.getAlignType()); - aCP.setView3D(_chartSet.isView3D()); - aCP.setThickness(_chartSet.getThickness()); - aCP.setDrawLabel(_chartSet.isDrawLabel()); - aCP.setLabelColor(_chartSet.getLabelColor()); - aCP.setLabelFont(_chartSet.getLabelFont()); - } - } - - /** - * Add charts - */ - public void addCharts() { - List shapeList = new ArrayList<>(this._shapeList); - int shapeIdx = -1; - PointD aPoint = new PointD(); - - List selShapeIdx = getSelectedShapeIndexes(); - boolean isShapeSel = true; - if (selShapeIdx.isEmpty()) { - isShapeSel = false; - } - for (Shape aShape : shapeList) { - shapeIdx += 1; - if (isShapeSel) { - if (!aShape.isSelected()) { - continue; - } - } - - PointShape aPS = new PointShape(); - switch (this.getShapeType()) { - case Point: - case PointM: - case PointZ: - aPS.setPoint((PointD) ((PointShape) aShape).getPoint().clone()); - break; - case Polyline: - case PolylineM: - case PolylineZ: - int pIdx = ((PolylineShape) aShape).getPoints().size() / 2; - aPS.setPoint((PointD) ((PolylineShape) aShape).getPoints().get(pIdx - 1).clone()); - break; - case Polygon: - case PolygonM: - case PolygonZ: - Extent aExtent = aShape.getExtent(); - aPoint.X = (aExtent.minX + aExtent.maxX) / 2; - aPoint.Y = (aExtent.minY + aExtent.maxY) / 2; - aPS.setPoint(aPoint); - break; - } - - ChartBreak aCP = new ChartBreak(_chartSet.getChartType()); - for (String fn : _chartSet.getFieldNames()) { - aCP.getChartData().add(Float.parseFloat(getCellValue(fn, shapeIdx).toString())); - } - aCP.setXShift(_chartSet.getXShift()); - aCP.setYShift(_chartSet.getYShift()); - aCP.setLegendScheme(_chartSet.getLegendScheme()); - aCP.setMinSize(_chartSet.getMinSize()); - aCP.setMaxSize(_chartSet.getMaxSize()); - aCP.setMinValue(_chartSet.getMinValue()); - aCP.setMaxValue(_chartSet.getMaxValue()); - aCP.setBarWidth(_chartSet.getBarWidth()); - aCP.setAlignType(_chartSet.getAlignType()); - aCP.setView3D(_chartSet.isView3D()); - aCP.setThickness(_chartSet.getThickness()); - aCP.setShapeIndex(shapeIdx); - aCP.setDrawLabel(_chartSet.isDrawLabel()); - aCP.setLabelColor(_chartSet.getLabelColor()); - aCP.setLabelFont(_chartSet.getLabelFont()); - aCP.setDecimalDigits(_chartSet.getDecimalDigits()); - - ChartGraphic aGraphic = new ChartGraphic(aPS, aCP); - addChart(aGraphic); - } - _chartSet.setDrawCharts(true); - } - - /** - * Update chart set with minimum and maximum values - */ - public void updateChartSet() { - List minList = new ArrayList<>(); - List maxList = new ArrayList<>(); - List sumList = new ArrayList<>(); - double[] minMax; - List fieldNames = this._chartSet.getFieldNames(); - for (int i = 0; i < this.getShapeNum(); i++) { - List vList = new ArrayList<>(); - double sum = 0; - double v; - for (int j = 0; j < fieldNames.size(); j++) { - v = Double.parseDouble(this.getCellValue(fieldNames.get(j), i).toString()); - vList.add(v); - sum += v; - } - //values.add(vList); - minMax = MIMath.getMinMaxValue(vList, -9999.0); - minList.add(minMax[0]); - maxList.add(minMax[1]); - sumList.add(sum); - } - - switch (_chartSet.getChartType()) { - case BarChart: - minMax = MIMath.getMinMaxValue(minList, -9999.0); - _chartSet.setMinValue((float) minMax[0]); - minMax = MIMath.getMinMaxValue(maxList, -9999.0); - _chartSet.setMaxValue((float) minMax[1]); - break; - case PieChart: - minMax = MIMath.getMinMaxValue(sumList, -9999.0); - _chartSet.setMinValue((float) minMax[0]); - _chartSet.setMaxValue((float) minMax[1]); - break; - } - } - - /** - * Update charts - */ - public void updateCharts() { - int shapeIdx; - for (ChartGraphic cg : this._chartPoints) { - ChartBreak aCP = (ChartBreak) cg.getLegend(); - shapeIdx = aCP.getShapeIndex(); - aCP.getChartData().clear(); - for (String fn : _chartSet.getFieldNames()) { - aCP.getChartData().add(Float.parseFloat(getCellValue(fn, shapeIdx).toString())); - } - aCP.setXShift(_chartSet.getXShift()); - aCP.setYShift(_chartSet.getYShift()); - aCP.setLegendScheme(_chartSet.getLegendScheme()); - aCP.setMinSize(_chartSet.getMinSize()); - aCP.setMaxSize(_chartSet.getMaxSize()); - aCP.setMinValue(_chartSet.getMinValue()); - aCP.setMaxValue(_chartSet.getMaxValue()); - aCP.setBarWidth(_chartSet.getBarWidth()); - aCP.setAlignType(_chartSet.getAlignType()); - aCP.setView3D(_chartSet.isView3D()); - aCP.setThickness(_chartSet.getThickness()); - aCP.setDrawLabel(_chartSet.isDrawLabel()); - aCP.setLabelColor(_chartSet.getLabelColor()); - aCP.setLabelFont(_chartSet.getLabelFont()); - aCP.setDecimalDigits(_chartSet.getDecimalDigits()); - } - _chartSet.setDrawCharts(true); - } - - /** - * Add a chart point - * - * @param aCP Chart point - */ - public void addChart(ChartGraphic aCP) { - _chartPoints.add(aCP); - } - - /** - * Remove all charts - */ - public void removeCharts() { - _chartPoints.clear(); - _chartSet.setDrawCharts(false); - } - - // - // - /** - * Get a shape by index - * - * @param idx Shape index - * @return Shape - */ - public Shape getShape(int idx) { - return this._shapeList.get(idx); - } - - /** - * Add a shape - * - * @param aShape Shape - */ - public void addShape(Shape aShape) { - _shapeList.add(aShape); - updateLayerExtent(aShape); - } - - /** - * Find a shape contains anthor shape - * - * @param other Another shape - * @return Result shape - */ - public Shape findShape_contains(Shape other) { - for (Shape s : this._shapeList) { - if (s.contains(other)) { - return s; - } - } - - return null; - } - - /** - * Find a shape crosses anthor shape - * - * @param other Another shape - * @return Result shape - */ - public Shape findShape_crosses(Shape other) { - for (Shape s : this._shapeList) { - if (s.crosses(other)) { - return s; - } - } - - return null; - } - - /** - * Find a shape for reformation by a polyline shape - * - * @param other The polyline shape - * @return Result shape - */ - public Shape findReformShape(PolylineShape other) { - if (this.getShapeType().isLine()) { - return this.findShape_crosses(other); - } else if (this.getShapeType().isPolygon()) { - PointShape a = new PointShape(); - a.setPoint(other.getPoints().get(0)); - PolygonShape r = (PolygonShape) this.findShape_contains(a); - if (r == null) { - return null; - } else { - PointShape b = new PointShape(); - b.setPoint(other.getPoints().get(other.getPointNum() - 1)); - if (r.contains(b)) { - return r; - } else { - return null; - } - } - } - return null; - } - - /** - * Select shapes - * - * @param extent The extent - * @return Selected shapes - */ - public List selectShapes(Extent extent) { - return this.selectShapes(extent, false); - } - - /** - * Select shapes - * - * @param aExtent The extent - * @param isSingleSel If just select one shape - * @return Selected shapes - */ - public List selectShapes(Extent aExtent, boolean isSingleSel) { - return this.selectShapes(aExtent, _shapeList, isSingleSel); - } - - /** - * Select shapes - * - * @param aExtent The extent - * @param shapes The shape list to be selected - * @param isSingleSel If just select one shape - * @return Selected shapes - */ - public List selectShapes(Extent aExtent, List shapes, boolean isSingleSel) { - List selectedShapes = new ArrayList<>(); - int i, j; - PointD sp = aExtent.getCenterPoint(); - - switch (this.getShapeType()) { - case Point: - case PointM: - case PointZ: - case WindArraw: - case WindBarb: - case WeatherSymbol: - case StationModel: - for (i = 0; i < shapes.size(); i++) { - PointShape aPS = (PointShape) shapes.get(i); - if (MIMath.pointInExtent(aPS.getPoint(), aExtent)) { - selectedShapes.add(_shapeList.indexOf(aPS)); - if (isSingleSel) { - break; - } - } - } - break; - case Polyline: - case PolylineM: - case PolylineZ: - Object sel; - List dislist = new ArrayList<>(); - for (i = 0; i < shapes.size(); i++) { - PolylineShape aPLS = (PolylineShape) shapes.get(i); - if (MIMath.isExtentCross(aExtent, aPLS.getExtent())) { - sel = GeoComputation.selectPolylineShape(sp, aPLS, aExtent.getWidth() / 2); - if (sel != null) { - if (dislist.size() > 0) { - for (j = 0; j < dislist.size(); j++) { - if ((Double) sel < dislist.get(j)) { - selectedShapes.add(j, _shapeList.indexOf(aPLS)); - dislist.add(j, (Double) sel); - break; - } - } - } else { - selectedShapes.add(_shapeList.indexOf(aPLS)); - dislist.add((Double) sel); - } - if (isSingleSel) { - break; - } - } - } - } - break; - case Polygon: - case PolygonM: - case PolygonZ: - for (i = shapes.size() - 1; i >= 0; i--) { - PolygonShape aPGS = (PolygonShape) shapes.get(i); - if (isSingleSel) { - if (GeoComputation.pointInPolygon(aPGS, sp)) { - selectedShapes.add(_shapeList.indexOf(aPGS)); - break; - } - } else if (GeoComputation.pointInPolygon(aPGS, sp)) { - selectedShapes.add(_shapeList.indexOf(aPGS)); - } else if (MIMath.isExtentCross(aExtent, aPGS.getExtent())) { - for (j = 0; j < aPGS.getPolygons().get(0).getOutLine().size(); j++) { - if (MIMath.pointInExtent(aPGS.getPolygons().get(0).getOutLine().get(j), aExtent)) { - selectedShapes.add(_shapeList.indexOf(aPGS)); - break; - } - } - } - } - break; - } - - return selectedShapes; - } - - /** - * Select shapes by a polygon shape - * - * @param polygonShape The polygon shape - * @return Selected shape indexes - */ - public List selectShapes(PolygonShape polygonShape) { - List selIdxs = new ArrayList<>(); - for (int i = 0; i < _shapeList.size(); i++) { - boolean isIn = false; - List points = (List) _shapeList.get(i).getPoints(); - for (PointD aPoint : points) { - if (GeoComputation.pointInPolygon(polygonShape, aPoint)) { - isIn = true; - break; - } - } - - if (isIn) { - _shapeList.get(i).setSelected(true); - selIdxs.add(i); - } - } - - return selIdxs; - } - - /** - * Select shapes by SQL expression - * - * @param expression The SQL expression - */ - public void sqlSelect(String expression) { - this.sqlSelect(expression, SelectType.NEW); - } - - /** - * Select shapes by SQL expression - * - * @param expression The SQL expression - * @param selType Selection type - */ - public void sqlSelect(String expression, String selType) { - SelectType st = SelectType.valueOf(selType.toUpperCase()); - this.sqlSelect(expression, st); - } - - /** - * Select shapes by SQL expression - * - * @param expression The SQL expression - * @param selType Selection type - */ - public void sqlSelect(String expression, SelectType selType) { - List rows = this._attributeTable.getTable().select(expression); - List rowIdxs = new ArrayList<>(); - for (DataRow row : rows) { - rowIdxs.add(row.getRowIndex()); - } - - int i; - switch (selType) { - case NEW: //Create a new selection - for (i = 0; i < this.getShapeNum(); i++) { - if (rowIdxs.contains(i)) { - this._shapeList.get(i).setSelected(true); - } else { - this._shapeList.get(i).setSelected(false); - } - } - break; - case ADD_TO_CURRENT: //Add to current selection - for (i = 0; i < this.getShapeNum(); i++) { - if (rowIdxs.contains(i)) { - this._shapeList.get(i).setSelected(true); - } - } - break; - case REMOVE_FROM_CURRENT: //Remove from current selection - for (i = 0; i < this.getShapeNum(); i++) { - if (rowIdxs.contains(i)) { - this._shapeList.get(i).setSelected(false); - } - } - break; - case SELECT_FROM_CURRENT: //Select from current selection - for (i = 0; i < this.getShapeNum(); i++) { - if (this._shapeList.get(i).isSelected()) { - if (!rowIdxs.contains(i)) { - this._shapeList.get(i).setSelected(false); - } - } - } - break; - } - } - - /** - * Select a shape by point - * - * @param p The point - * @return Selected shape - */ - public Shape selectShape(PointD p) { - Coordinate c = new Coordinate(p.X, p.Y); - Geometry point = new GeometryFactory().createPoint(c); - for (Shape shape : _shapeList) { - if (point.within(shape.toGeometry())) { - return shape; - } - } - return null; - } - - /** - * Get polygon hole index by point - * - * @param p The point - * @return PolygonShape and polygon hole index - */ - public Object[] selectPolygonHole(PointD p) { - for (Shape shape : _shapeList) { - int i = 0; - for (Polygon poly : ((PolygonShape) shape).getPolygons()) { - if (poly.hasHole()) { - if (GeoComputation.pointInPolygon(poly.getOutLine(), p)) { - int j = 0; - for (List hole : poly.getHoleLines()) { - if (GeoComputation.pointInPolygon(hole, p)) { - return new Object[]{shape, i, j}; - } - j += 1; - } - } - } - i += 1; - } - } - return null; - } - - /** - * Get seleted data rows - * - * @return Selected data rows - */ - public List getSelectedDataRows() { - List rows = this.getDataRows(); - List selRows = new ArrayList<>(); - int i = 0; - for (Shape shape : _shapeList) { - if (shape.isSelected()) { - selRows.add(rows.get(i)); - } - i++; - } - - return selRows; - } - - /** - * Get selected shapes - * - * @return Selected shapes - */ - public List getSelectedShapes() { - List selShapes = new ArrayList<>(); - for (Shape shape : _shapeList) { - if (shape.isSelected()) { - selShapes.add(shape); - } - } - - return selShapes; - } - - /** - * Get selected shape index list - * - * @return Index list - */ - public List getSelectedShapeIndexes() { - List selIndexes = new ArrayList<>(); - for (int i = 0; i < this.getShapeNum(); i++) { - if (_shapeList.get(i).isSelected()) { - selIndexes.add(i); - } - } - - return selIndexes; - } - - /** - * Get visible shapes - * - * @return The visible shapes - */ - public List getVisibleShapes() { - List visShapes = new ArrayList<>(); - for (Shape shape : _shapeList) { - if (shape.isVisible()) { - visShapes.add(shape); - } - } - - return visShapes; - } - - /** - * Clear selected shapes - */ - public void clearSelectedShapes() { - for (Shape aShape : _shapeList) { - if (aShape.isSelected()) { - aShape.setSelected(false); - } - } - } - - /** - * Get if has selected shape - * - * @return Boolean - */ - public boolean hasSelectedShapes() { - for (Shape shape : _shapeList) { - if (shape.isSelected()) { - return true; - } - } - - return false; - } - - /** - * Clear editing shape - */ - public void clearEditingShape() { - if (editingShape != null) { - editingShape.setEditing(false); - } - } - - // - // - /** - * Get field number - * - * @return Field number - */ - public int getFieldNumber() { - return _attributeTable.getTable().getColumns().size(); - } - - /** - * Get field name by index - * - * @param FieldIndex Field index - * @return Field name - */ - public String getFieldName(int FieldIndex) { - return _attributeTable.getTable().getColumns().get(FieldIndex).getColumnName(); - } - - /** - * Get field name list - * - * @return The field name list - */ - public List getFieldNames() { - List FNList = new ArrayList<>(); - for (int i = 0; i < this.getFieldNumber(); i++) { - FNList.add(getFieldName(i)); - } - return FNList; - } - - /** - * Get fields - * - * @return Fields - */ - public List getFields() { - DataColumnCollection cols = _attributeTable.getTable().getColumns(); - List fields = new ArrayList<>(); - for (DataColumn col : cols) { - fields.add((Field) col); - } - - return fields; - } - - /** - * Get field by index - * - * @param idx The field index - * @return The field - */ - public Field getField(int idx) { - return (Field) _attributeTable.getTable().getColumns().get(idx); - } - - /** - * Get field by field name - * - * @param fieldName Field name - * @return The field - */ - public Field getField(String fieldName) { - return (Field) _attributeTable.getTable().getColumns().get(fieldName); - } - - /** - * Get field index by name - * - * @param fieldName The field name - * @return Field index - */ - public int getFieldIdxByName(String fieldName) { - int fieldIdx = -1; - for (int i = 0; i < this.getFieldNumber(); i++) { - if (_attributeTable.getTable().getColumns().get(i).getColumnName().equals(fieldName)) { - fieldIdx = i; - break; - } - } - - return fieldIdx; - } - - /** - * Get cell value - * - * @param fieldIndex Field index - * @param shapeIndex Shape index - * @return Cell value - */ - public Object getCellValue(int fieldIndex, int shapeIndex) { - return _attributeTable.getTable().getValue(shapeIndex, fieldIndex); - } - - /** - * Get cell value - * - * @param fieldName Field name - * @param shapeIndex Shape index - * @return Cell value - */ - public Object getCellValue(String fieldName, int shapeIndex) { - return _attributeTable.getTable().getValue(shapeIndex, fieldName); - } - - /** - * Get all data rows - * - * @return All data rows - */ - public List getDataRows() { - return this._attributeTable.getTable().getRows(); - } - - /** - * Edit: Add a field - * - * @param aField The field - */ - public void editAddField(Field aField) { - for (int i = 0; i < this.getFieldNumber(); i++) { - if (aField.getColumnName().equals(_attributeTable.getTable().getColumns().get(i).getColumnName())) { - aField.setColumnName(aField.getColumnName() + "_1"); - } - } - _attributeTable.getTable().getColumns().add(aField); - } - - /** - * Edit: Add a field - * - * @param fieldName Field name - * @param fieldType Field data type - */ - public void editAddField(String fieldName, DataType fieldType) { - Field aField = new Field(fieldName, fieldType); - editAddField(aField); - } - - /** - * Edit: Remove a field - * - * @param fieldName Field name - */ - public void editRemoveField(String fieldName) { - this._attributeTable.getTable().removeColumn(this.getField(fieldName)); - } - - /** - * Edit: Rename a field - * - * @param fieldName Origin field name - * @param newFieldName New field name - */ - public void editRenameField(String fieldName, String newFieldName) { - this._attributeTable.getTable().renameColumn(this.getField(fieldName), newFieldName); - } - - private void insertRecord(int position) throws Exception { - DataRow aDR = _attributeTable.getTable().newRow(); - _attributeTable.getTable().getRows().add(position, aDR); - } - - private void insertRecord(int position, DataRow record) throws Exception { - _attributeTable.getTable().getRows().add(position, record); - } - - /** - * Edit: Edit cell value - * - * @param fieldName Field name - * @param shapeIndex Shape index - * @param value The data value - */ - public void editCellValue(String fieldName, int shapeIndex, Object value) { - _attributeTable.getTable().getRows().get(shapeIndex).setValue(fieldName, value); - } - - /** - * Edit: Edit cell value - * - * @param fieldIndex Field index - * @param shapeIndex Shape index - * @param value Data value - */ - public void editCellValue(int fieldIndex, int shapeIndex, Object value) { - _attributeTable.getTable().getRows().get(shapeIndex).setValue(fieldIndex, value); - } - - /** - * Get minimum data value of a field - * - * @param fieldName Field name - * @return Minimum data - */ - public double getMinValue(String fieldName) { - if (((Field) _attributeTable.getTable().getColumns().get(fieldName)).isNumeric()) { - double min = 0; - int dNum = 0; - for (int i = 0; i < this.getShapeNum(); i++) { - double aValue = Double.parseDouble(getCellValue(fieldName, i).toString()); - if (Math.abs(aValue / this.getLegendScheme().getUndefValue() - 1) < 0.01) { - continue; - } - - if (dNum == 0) { - min = aValue; - } else if (min > aValue) { - min = aValue; - } - dNum += 1; - } - return min; - } else { - return 0; - } - } - - /** - * Join data table - * - * @param dataTable The input data table - * @param colName The column name for join - */ - public void joinTable(DataTable dataTable, String colName) { - this.joinTable(dataTable, colName, false); - } - - /** - * Join data table - * - * @param dataTable The input data table - * @param colName The column name for join - * @param isUpdate - */ - public void joinTable(DataTable dataTable, String colName, boolean isUpdate) { - DataTable thisTable = this._attributeTable.getTable(); - thisTable.join(dataTable, colName, isUpdate); - this._attributeTable.updateDataTable(); - } - - /** - * Join data table - * - * @param dataTable The input data table - * @param colName_this The column name of this data table for join - * @param colName_in The column name of the input data table for join - * @param isUpdate If update the existing values with same column name - */ - public void joinTable(DataTable dataTable, String colName_this, String colName_in, boolean isUpdate) { - DataTable thisTable = this._attributeTable.getTable(); - thisTable.join(dataTable, colName_this, colName_in, isUpdate); - this._attributeTable.updateDataTable(); - } - - /** - * Remove joined data columns - */ - public void removeJoins() { - DataTable thisTable = this._attributeTable.getTable(); - for (DataColumn col : thisTable.getColumns()) { - if (col.isJoined()) { - thisTable.removeColumn(col); - } - } - } - // - - // - /** - * Edit: Insert shape - * - * @param aShape The shape - * @param position The position index - * @return If success - * @throws java.lang.Exception - */ - public boolean editInsertShape(Shape aShape, int position) throws Exception { - if (position < 0) { - position = 0; - } else if (position > _shapeList.size()) { - position = _shapeList.size(); - } - - _shapeList.add(position, aShape); - insertRecord(position); - updateLayerExtent(aShape); - - return true; - } - - /** - * Edit: Insert shape - * - * @param aShape The shape - * @param position The position index - * @param record - * @return If success - * @throws java.lang.Exception - */ - public boolean editInsertShape(Shape aShape, int position, DataRow record) throws Exception { - if (position < 0) { - position = 0; - } else if (position > _shapeList.size()) { - position = _shapeList.size(); - } - - _shapeList.add(position, aShape); - insertRecord(position, record); - updateLayerExtent(aShape); - - return true; - } - - /** - * Edit: Add a shape - * - * @param aShape The shape - * @return If success - * @throws Exception - */ - public boolean editAddShape(Shape aShape) throws Exception { - int pos = _shapeList.size(); - return this.editInsertShape(aShape, pos); - } - - /** - * Edit: Add a shape - * - * @param aShape The shape - * @param fvalues Field values - * @throws Exception - */ - public void editAddShape(Shape aShape, List fvalues) throws Exception { - int pos = _shapeList.size(); - this.editInsertShape(aShape, pos); - for (int i = 0; i < this.getFieldNumber(); i++) { - this.editCellValue(i, pos, fvalues.get(i)); - } - } - - /** - * Edit: Remove a shape - * - * @param shape The shape - */ - public void editRemoveShape(Shape shape) { - int idx = this._shapeList.indexOf(shape); - if (idx >= 0) { - this._shapeList.remove(shape); - this._attributeTable.getTable().removeRow(idx); - } - } - - private void updateLayerExtent(Shape aShape) { - if (this.getShapeNum() == 1) { - this.setExtent((Extent) aShape.getExtent().clone()); - } else { - this.setExtent(MIMath.getLagerExtent(this.getExtent(), aShape.getExtent())); - } - } - - private void updateLayerExtent() { - if (this.getShapeNum() == 1) { - this.setExtent((Extent) _shapeList.get(0).getExtent().clone()); - } else { - this.setExtent((Extent) _shapeList.get(0).getExtent().clone()); - for (int i = 1; i < this.getShapeNum(); i++) { - this.setExtent(MIMath.getLagerExtent(this.getExtent(), _shapeList.get(i).getExtent())); - } - - } - } - - /** - * Save layer as a shape file - */ - @Override - public void saveFile() { - File aFile = new File(this.getFileName()); - if (aFile.exists()) { - saveFile(aFile.getAbsolutePath()); - } else { - JFileChooser aDlg = new JFileChooser(); - String curDir = System.getProperty("user.dir"); - aDlg.setCurrentDirectory(new File(curDir)); - String[] fileExts = {"shp"}; - GenericFileFilter pFileFilter = new GenericFileFilter(fileExts, "Shape File (*.shp)"); - aDlg.setFileFilter(pFileFilter); - aDlg.setAcceptAllFileFilterUsed(false); - if (JFileChooser.APPROVE_OPTION == aDlg.showSaveDialog(null)) { - aFile = aDlg.getSelectedFile(); - System.setProperty("user.dir", aFile.getParent()); - String extent = ((GenericFileFilter) aDlg.getFileFilter()).getFileExtent(); - String fileName = aFile.getAbsolutePath(); - if (!fileName.substring(fileName.length() - extent.length()).equals(extent)) { - fileName = fileName + "." + extent; - } - saveFile(fileName); - } - } - } - - /** - * Save layer as a shape file - * - * @param shpfilepath Shape file path - */ - @Override - public void saveFile(String shpfilepath) { - this.setFileName(shpfilepath); - try { - ShapeFileManage.saveShapeFile(shpfilepath, this); - } catch (IOException ex) { - Logger.getLogger(VectorLayer.class.getName()).log(Level.SEVERE, null, ex); - } - } - - /** - * Save layer as a shape file - * - * @param shpfilepath Shape file path - * @param encoding Encoding - */ - public void saveFile(String shpfilepath, String encoding) { - this.setFileName(shpfilepath); - try { - ShapeFileManage.saveShapeFile(shpfilepath, this, encoding); - } catch (IOException ex) { - Logger.getLogger(VectorLayer.class.getName()).log(Level.SEVERE, null, ex); - } - } - - /** - * Buffer the shapes - * - * @param distance Distance - * @param onlySel If only buffer selected shapes - * @param isMerge If merge or not - * @return Bufferred layer - */ - public VectorLayer buffer(double distance, boolean onlySel, boolean isMerge) { - List shapes = new ArrayList<>(); - if (onlySel) { - for (Shape aShape : this._shapeList) { - if (aShape.isSelected()) { - shapes.add(aShape); - } - } - } else { - shapes = (List) this._shapeList; - } - - VectorLayer newLayer = new VectorLayer(ShapeTypes.Polygon); - newLayer.setProjInfo(this.getProjInfo()); - - if (isMerge) { - List bgeos = new ArrayList<>(); - for (Shape shape : shapes) { - bgeos.add(shape.toGeometry().buffer(distance)); - } - Geometry mbgeo = CascadedPolygonUnion.union(bgeos); - Shape bShape = new PolygonShape(mbgeo); - try { - newLayer.editAddShape(bShape); - } catch (Exception ex) { - Logger.getLogger(VectorLayer.class.getName()).log(Level.SEVERE, null, ex); - } - } else { - for (Shape aShape : shapes) { - Shape bShape = aShape.buffer(distance); - try { - newLayer.editAddShape(bShape); - } catch (Exception ex) { - Logger.getLogger(VectorLayer.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - - return newLayer; - } - - /** - * Get convex hull of the shapes - * - * @param onlySel If only buffer selected shapes - * @param isMerge If merge or not - * @return Result layer - */ - public VectorLayer convexhull(boolean onlySel, boolean isMerge) { - List shapes = new ArrayList<>(); - if (onlySel) { - for (Shape aShape : this._shapeList) { - if (aShape.isSelected()) { - shapes.add(aShape); - } - } - } else { - shapes = (List) this._shapeList; - } - - VectorLayer newLayer = new VectorLayer(ShapeTypes.Polygon); - newLayer.setProjInfo(this.getProjInfo()); - - if (shapes.size() == 1) { - Shape rshape = shapes.get(0).convexHull(); - try { - newLayer.editAddShape(rshape); - } catch (Exception ex) { - Logger.getLogger(VectorLayer.class.getName()).log(Level.SEVERE, null, ex); - } - } else if (isMerge) { - Geometry[] geos = new Geometry[shapes.size()]; - for (int i = 0; i < geos.length; i++) { - geos[i] = shapes.get(i).toGeometry(); - } - GeometryFactory factory = new GeometryFactory(); - Geometry gs = factory.createGeometryCollection(geos); - Geometry ch = gs.convexHull(); - Shape rshape = new PolygonShape(ch); - try { - newLayer.editAddShape(rshape); - } catch (Exception ex) { - Logger.getLogger(VectorLayer.class.getName()).log(Level.SEVERE, null, ex); - } - } else { - for (Shape shape : shapes) { - Shape rshape = shape.convexHull(); - try { - newLayer.editAddShape(rshape); - } catch (Exception ex) { - Logger.getLogger(VectorLayer.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - - return newLayer; - } - - /** - * Clip the layer by a clipping layer - * - * @param clipLayer Clipping layer - * @return Clipped result layer - */ - public VectorLayer clip(VectorLayer clipLayer) { - return this.clip(clipLayer, false); - } - - /** - * Clip the layer by a clipping layer - * - * @param clipLayer Clipping layer - * @param onlySel If only using selected shapes in clipping layer - * @return Clipped result layer - */ - public VectorLayer clip(VectorLayer clipLayer, boolean onlySel) { - List shapes = new ArrayList<>(); - if (onlySel) { - for (Shape aShape : clipLayer.getShapes()) { - if (aShape.isSelected()) { - shapes.add((PolygonShape) aShape); - } - } - } else { - shapes = (List) clipLayer.getShapes(); - } - - return this.clip(shapes); - } - - /** - * Clip the layer by clipping polygons - * - * @param clipPolys Clipping polygons - * @return Clipped result layer - */ - public VectorLayer clip(List clipPolys) { - VectorLayer newLayer = (VectorLayer) this.cloneValue(); - DataTable aTable = new DataTable(); - for (DataColumn aDC : this.getAttributeTable().getTable().getColumns()) { - Field bDC = new Field(aDC.getColumnName(), aDC.getDataType()); - aTable.getColumns().add(bDC); - } - - newLayer.setShapes(new ArrayList()); - for (PolygonShape aPGS : clipPolys) { - for (int i = 0; i < this.getShapeNum(); i++) { - Shape bShape = this.getShapes().get(i); - DataRow aDR = this.getAttributeTable().getTable().getRows().get(i); - Shape clipShape = bShape.intersection(aPGS); - if (clipShape != null) { - newLayer.addShape(clipShape); - try { - aTable.addRow((DataRow) aDR.clone()); - } catch (Exception ex) { - Logger.getLogger(VectorLayer.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - } - - newLayer.getAttributeTable().setTable(aTable); - newLayer.setLegendScheme((LegendScheme) this.getLegendScheme().clone()); - //newLayer.setTransparency(this.getTransparency()); - - return newLayer; - } - - /** - * Clip the layer by clipping polygons - * - * @param clipPolys Clipping polygons - * @return Clipped result layer - */ - public VectorLayer clip_bak(List clipPolys) { - VectorLayer newLayer = (VectorLayer) this.cloneValue(); - DataTable aTable = new DataTable(); - for (DataColumn aDC : this.getAttributeTable().getTable().getColumns()) { - Field bDC = new Field(aDC.getColumnName(), aDC.getDataType()); - aTable.getColumns().add(bDC); - } - - newLayer.setShapes(new ArrayList()); - for (PolygonShape aPGS : clipPolys) { - for (int i = 0; i < this.getShapeNum(); i++) { - Shape bShape = this.getShapes().get(i); - DataRow aDR = this.getAttributeTable().getTable().getRows().get(i); - for (Polygon aPolygon : aPGS.getPolygons()) { - Shape clipShape = GeoComputation.clipShape(bShape, aPolygon.getOutLine()); - if (clipShape != null) { - newLayer.addShape(clipShape); - try { - aTable.addRow((DataRow) aDR.clone()); - } catch (Exception ex) { - Logger.getLogger(VectorLayer.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - } - } - - newLayer.getAttributeTable().setTable(aTable); - newLayer.setLegendScheme((LegendScheme) this.getLegendScheme().clone()); - newLayer.setTransparency(this.getTransparency()); - - return newLayer; - } - - /** - * Intersection the layer by another layer - * - * @param ilayer Intersection layer - * @param onlySel Only selected shapes in this layer - * @param onlySelOther Only selected shapes in - * @return Result layer - */ - public VectorLayer intersection(VectorLayer ilayer, boolean onlySel, boolean onlySelOther) { - List ishapes = new ArrayList<>(); - if (onlySelOther) { - for (Shape shape : ilayer.getSelectedShapes()) { - ishapes.add((PolygonShape) shape); - } - } else { - for (Shape shape : ilayer.getShapes()) { - ishapes.add((PolygonShape) shape); - } - } - - return intersection(ishapes, onlySel); - } - - /** - * Intersection the layer by polygons - * - * @param clipPolys Intersection polygons - * @param onlySel Only selected shapes - * @return Result layer - */ - public VectorLayer intersection(List clipPolys, boolean onlySel) { - VectorLayer newLayer = (VectorLayer) this.cloneValue(); - DataTable aTable = new DataTable(); - for (DataColumn aDC : this.getAttributeTable().getTable().getColumns()) { - Field bDC = new Field(aDC.getColumnName(), aDC.getDataType()); - aTable.getColumns().add(bDC); - } - - newLayer.setShapes(new ArrayList()); - for (int i = 0; i < this.getShapeNum(); i++) { - Shape bShape = this.getShapes().get(i); - if (onlySel) { - if (bShape.isSelected()) { - DataRow aDR = this.getAttributeTable().getTable().getRows().get(i); - for (PolygonShape aPGS : clipPolys) { - Shape clipShape = bShape.intersection(aPGS); - if (clipShape != null) { - newLayer.addShape(clipShape); - try { - aTable.addRow((DataRow) aDR.clone()); - } catch (Exception ex) { - Logger.getLogger(VectorLayer.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - } - } else { - DataRow aDR = this.getAttributeTable().getTable().getRows().get(i); - for (PolygonShape aPGS : clipPolys) { - Shape clipShape = bShape.intersection(aPGS); - if (clipShape != null) { - newLayer.addShape(clipShape); - try { - aTable.addRow((DataRow) aDR.clone()); - } catch (Exception ex) { - Logger.getLogger(VectorLayer.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - } - } - - newLayer.getAttributeTable().setTable(aTable); - newLayer.setLegendScheme((LegendScheme) this.getLegendScheme().clone()); - newLayer.setTransparency(this.getTransparency()); - - return newLayer; - } - - /** - * Difference the layer by polygons - * - * @param clipPolys Difference polygons - * @param onlySel Only selected shapes - * @return Result layer - */ - public VectorLayer difference(List clipPolys, boolean onlySel) { - VectorLayer newLayer = (VectorLayer) this.cloneValue(); - DataTable aTable = new DataTable(); - for (DataColumn aDC : this.getAttributeTable().getTable().getColumns()) { - Field bDC = new Field(aDC.getColumnName(), aDC.getDataType()); - aTable.getColumns().add(bDC); - } - List shapes; - if (onlySel) { - shapes = (List) this.getSelectedShapes(); - } else { - shapes = this._shapeList; - } - List dataRows; - if (onlySel) { - dataRows = this.getSelectedDataRows(); - } else { - dataRows = this.getDataRows(); - } - - newLayer.setShapes(new ArrayList()); - boolean isNull; - for (int i = 0; i < shapes.size(); i++) { - Shape bShape = shapes.get(i); - DataRow dataRow = dataRows.get(i); - Shape clipShape = bShape.difference(clipPolys.get(0)); - isNull = clipShape == null; - if (!isNull) { - if (clipPolys.size() > 1) { - for (int j = 1; j < clipPolys.size(); j++) { - clipShape = clipShape.difference(clipPolys.get(j)); - if (clipShape == null) { - isNull = true; - break; - } - } - if (!isNull){ - newLayer.addShape(clipShape); - try { - aTable.addRow((DataRow) dataRow.clone()); - } catch (Exception ex) { - Logger.getLogger(VectorLayer.class.getName()).log(Level.SEVERE, null, ex); - } - } - } else { - newLayer.addShape(clipShape); - try { - aTable.addRow((DataRow) dataRow.clone()); - } catch (Exception ex) { - Logger.getLogger(VectorLayer.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - } - - newLayer.getAttributeTable().setTable(aTable); - newLayer.setLegendScheme((LegendScheme) this.getLegendScheme().clone()); - newLayer.setTransparency(this.getTransparency()); - - return newLayer; - } - - /** - * Symmetrical difference the layer by polygons - * - * @param clipPolys Symmetrical difference polygons - * @param onlySel Only selected shapes - * @return Result layer - */ - public VectorLayer symDifference(List clipPolys, boolean onlySel) { - VectorLayer newLayer = (VectorLayer) this.cloneValue(); - DataTable aTable = new DataTable(); - for (DataColumn aDC : this.getAttributeTable().getTable().getColumns()) { - Field bDC = new Field(aDC.getColumnName(), aDC.getDataType()); - aTable.getColumns().add(bDC); - } - List shapes; - if (onlySel) { - shapes = (List) this.getSelectedShapes(); - } else { - shapes = this._shapeList; - } - List dataRows; - if (onlySel) { - dataRows = this.getSelectedDataRows(); - } else { - dataRows = this.getDataRows(); - } - - newLayer.setShapes(new ArrayList()); - boolean isNull; - for (int i = 0; i < shapes.size(); i++) { - Shape bShape = shapes.get(i); - DataRow dataRow = dataRows.get(i); - Shape clipShape = bShape.difference(clipPolys.get(0)); - isNull = clipShape == null; - if (!isNull) { - if (clipPolys.size() > 1) { - for (int j = 1; j < clipPolys.size(); j++) { - clipShape = clipShape.difference(clipPolys.get(j)); - if (clipShape == null) { - isNull = true; - break; - } - } - if (!isNull){ - newLayer.addShape(clipShape); - try { - aTable.addRow((DataRow) dataRow.clone()); - } catch (Exception ex) { - Logger.getLogger(VectorLayer.class.getName()).log(Level.SEVERE, null, ex); - } - } - } else { - newLayer.addShape(clipShape); - try { - aTable.addRow((DataRow) dataRow.clone()); - } catch (Exception ex) { - Logger.getLogger(VectorLayer.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - } - - newLayer.getAttributeTable().setTable(aTable); - for (int i = 0; i < clipPolys.size(); i++) { - Shape bShape = clipPolys.get(i); - Shape clipShape = bShape.difference(shapes.get(0)); - isNull = clipShape == null; - if (!isNull) { - if (shapes.size() > 1) { - for (int j = 1; j < shapes.size(); j++) { - clipShape = clipShape.difference(shapes.get(j)); - if (clipShape == null) { - isNull = true; - break; - } - } - if (!isNull){ - try { - newLayer.editAddShape(clipShape); - } catch (Exception ex) { - Logger.getLogger(VectorLayer.class.getName()).log(Level.SEVERE, null, ex); - } - } - } else { - try { - newLayer.editAddShape(clipShape); - } catch (Exception ex) { - Logger.getLogger(VectorLayer.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - } - - newLayer.setLegendScheme((LegendScheme) this.getLegendScheme().clone()); - newLayer.setTransparency(this.getTransparency()); - - return newLayer; - } - // - - // - /** - * Add label point - * - * @param aLP Label point - */ - public void addLabel(Graphic aLP) { - _labelPoints.add(aLP); - } - - /** - * Get a label by text - * - * @param text Text - * @return Label - */ - public Graphic getLabel(String text) { - for (Graphic lb : _labelPoints) { - if (((LabelBreak) lb.getLegend()).getText().equals(text)) { - return lb; - } - } - return null; - } - - /** - * Move label - * - * @param text Label text - * @param x X - * @param y Y - */ - public void moveLabel(String text, float x, float y) { - Graphic lb = this.getLabel(text); - if (lb != null) { - this.moveLabel(lb, x, y); - } - } - - /** - * Move label - * - * @param lb Label - * @param x X - * @param y Y - */ - public void moveLabel(Graphic lb, float x, float y) { - LabelBreak lbb = (LabelBreak) lb.getLegend(); - lbb.setXShift(lbb.getXShift() + x); - lbb.setYShift(lbb.getYShift() + y); - } - - /** - * Remove all labels - */ - public void removeLabels() { - _labelPoints.clear(); - _labelSet.setDrawLabels(false); - } - - /** - * Add labels - */ - public void addLabels() { - addLabelsByColor(); - - _labelSet.setDrawLabels(true); - } - - /** - * Add labels - */ - private void addLabelsByColor() { - int shapeIdx = -1; - PointD aPoint; - - String dFormat = "%1$.1f"; - boolean isData = false; - if (((Field) _attributeTable.getTable().getColumns().get(_labelSet.getFieldName())).isNumeric()) { - if (_labelSet.isAutoDecimal()) { - double min = getMinValue(_labelSet.getFieldName()); - _labelSet.setDecimalDigits(MIMath.getDecimalNum(min)); - } - - dFormat = "%1$." + String.valueOf(_labelSet.getDecimalDigits()) + "f"; - isData = true; - } - - List selShapeIdx = getSelectedShapeIndexes(); - boolean isShapeSel = true; - if (selShapeIdx.isEmpty()) { - isShapeSel = false; - } - for (Shape aShape : _shapeList) { - shapeIdx += 1; - if (isShapeSel) { - if (!aShape.isSelected()) { - continue; - } - } - - ColorBreak aCB = null; - if (this.getLegendScheme().getLegendType() == LegendType.SingleSymbol) { - aCB = this.getLegendScheme().getLegendBreaks().get(0); - } else if (this.getLegendScheme().getFieldName() != null) { - String vStr = getCellValue(this.getLegendScheme().getFieldName(), shapeIdx).toString().trim(); - aCB = getColorBreak(vStr); - } - if (aCB == null) { - continue; - } - if (!aCB.isDrawShape()) { - continue; - } - - PointShape aPS = new PointShape(); - switch (this.getShapeType()) { - case Point: - case PointM: - case PointZ: - aPS.setPoint((PointD) ((PointShape) aShape).getPoint().clone()); - break; - case Polyline: - case PolylineM: - case PolylineZ: - int pIdx = ((PolylineShape) aShape).getPoints().size() / 2; - aPS.setPoint((PointD) ((PolylineShape) aShape).getPoints().get(pIdx - 1).clone()); - break; - case Polygon: - case PolygonM: - case PolygonZ: - Extent aExtent = aShape.getExtent(); - aPoint = new PointD(); - aPoint.X = ((aExtent.minX + aExtent.maxX) / 2); - aPoint.Y = ((aExtent.minY + aExtent.maxY) / 2); - aPS.setPoint(aPoint); - break; - } - - LabelBreak aLP = new LabelBreak(); - if (isData) { - if (this._labelSet.isAutoDecimal()) { - aLP.setText(DataConvert.removeTailingZeros(getCellValue(_labelSet.getFieldName(), shapeIdx).toString())); - } else { - aLP.setText(String.format(dFormat, Double.parseDouble(getCellValue(_labelSet.getFieldName(), shapeIdx).toString()))); - } - } else { - aLP.setText(getCellValue(_labelSet.getFieldName(), shapeIdx).toString()); - } - - if (_labelSet.isColorByLegend()) { - aLP.setColor(aCB.getColor()); - } else { - aLP.setColor(_labelSet.getLabelColor()); - } - aLP.setFont(_labelSet.getLabelFont()); - aLP.setAlignType(_labelSet.getLabelAlignType()); - aLP.setYShift(_labelSet.getYOffset()); - aLP.setXShift(_labelSet.getXOffset()); - Graphic aGraphic = new Graphic(aPS, aLP); - addLabel(aGraphic); - } - } - - private ColorBreak getColorBreak(String vStr) { - ColorBreak aCB = null; - switch (this.getLegendScheme().getLegendType()) { - case SingleSymbol: - aCB = this.getLegendScheme().getLegendBreaks().get(0); - break; - case UniqueValue: - for (int j = 0; j < this.getLegendScheme().getLegendBreaks().size(); j++) { - if (vStr.equals(this.getLegendScheme().getLegendBreaks().get(j).getStartValue().toString())) { - aCB = this.getLegendScheme().getLegendBreaks().get(j); - break; - } - } - break; - case GraduatedColor: - double value; - if ("".equals(vStr) || vStr == null) { - value = 0; - } else { - value = Double.parseDouble(vStr); - } - int blNum = 0; - for (int j = 0; j < this.getLegendScheme().getLegendBreaks().size(); j++) { - ColorBreak aPB = this.getLegendScheme().getLegendBreaks().get(j); - blNum += 1; - if (value == Double.parseDouble(aPB.getStartValue().toString()) || (value > Double.parseDouble(aPB.getStartValue().toString()) - && value < Double.parseDouble(aPB.getEndValue().toString())) - || (blNum == this.getLegendScheme().getLegendBreaks().size() - && value == Double.parseDouble(aPB.getEndValue().toString()))) { - aCB = aPB; - break; - } - } - break; - } - - return aCB; - } - - /** - * Add labels of contour layer dynamicly - * - * @param sExtent View extent of MapView - */ - public void addLabelsContourDynamic(Extent sExtent) { - String dFormat; - if (_labelSet.isAutoDecimal()) { - double min = getMinValue(_labelSet.getFieldName()); - _labelSet.setDecimalDigits(MIMath.getDecimalNum(min)); - } - - dFormat = "%1$." + String.valueOf(_labelSet.getDecimalDigits()) + "f"; - int shapeIdx = 0; - String text; - for (Shape aShape : _shapeList) { - PolylineShape aPLS = (PolylineShape) aShape; - Extent IExtent = aPLS.getExtent(); - if (IExtent.maxX - IExtent.minX > (sExtent.maxX - sExtent.minX) / 10 - || IExtent.maxY - IExtent.minY > (sExtent.maxY - sExtent.minY) / 10) { - LabelBreak aLP = new LabelBreak(); - int pIdx = aPLS.getPoints().size() / 2; - //PointF aPoint = new PointF(0, 0); - PointShape aPS = new PointShape(); - aPS.setPoint(aPLS.getPoints().get(pIdx - 1)); - if (this._labelSet.isAutoDecimal()) { - text = DataConvert.removeTailingZeros(getCellValue(_labelSet.getFieldName(), shapeIdx).toString()); - } else { - text = String.format(dFormat, Double.parseDouble(getCellValue(_labelSet.getFieldName(), shapeIdx).toString())); - } - aLP.setText(text); - aLP.setFont(_labelSet.getLabelFont()); - aLP.setAlignType(_labelSet.getLabelAlignType()); - aLP.setYShift(_labelSet.getYOffset()); - - String vStr; - PolylineBreak aPLB; - switch (this.getLegendScheme().getLegendType()) { - case SingleSymbol: - aPLB = (PolylineBreak) this.getLegendScheme().getLegendBreaks().get(0); - aLP.setColor(aPLB.getColor()); - break; - case UniqueValue: - vStr = getCellValue(_labelSet.getFieldName(), shapeIdx).toString(); - for (int j = 0; j < this.getLegendScheme().getLegendBreaks().size(); j++) { - aPLB = (PolylineBreak) this.getLegendScheme().getLegendBreaks().get(j); - if (vStr.equals(aPLB.getStartValue().toString())) { - aLP.setColor(aPLB.getColor()); - } - } - break; - case GraduatedColor: - vStr = getCellValue(_labelSet.getFieldName(), shapeIdx).toString(); - double value = Double.parseDouble(vStr); - int blNum = 0; - for (int j = 0; j < this.getLegendScheme().getLegendBreaks().size(); j++) { - aPLB = (PolylineBreak) this.getLegendScheme().getLegendBreaks().get(j); - blNum += 1; - if (value == Double.parseDouble(aPLB.getStartValue().toString()) - || (value > Double.parseDouble(aPLB.getStartValue().toString()) - && value < Double.parseDouble(aPLB.getEndValue().toString())) - || (blNum == this.getLegendScheme().getLegendBreaks().size() - && value == Double.parseDouble(aPLB.getEndValue().toString()))) { - aLP.setColor(aPLB.getColor()); - } - } - break; - } - - Graphic aGraphic = new Graphic(aPS, aLP); - addLabel(aGraphic); - } - shapeIdx += 1; - } - - _labelSet.setDrawLabels(true); - } - // - - // - /** - * Update data to origion set - */ - public void updateOriginData() { - _originAttributeTable = (AttributeTable) _attributeTable.clone(); - _originShapes = new ArrayList<>(); - for (Shape aShape : _shapeList) { - _originShapes.add((Shape) aShape.clone()); - } - - _originLabelPoints = new ArrayList<>(_labelPoints); - _originChartPoints = new ArrayList<>(_chartPoints); - this.originProjInfo = (ProjectionInfo) this._projInfo.clone(); - _projected = true; - } - - /** - * Get origin data - */ - public void getOriginData() { - _attributeTable = (AttributeTable) _originAttributeTable.clone(); - _shapeList = new ArrayList<>(); - for (Shape aShape : _originShapes) { - _shapeList.add((Shape) aShape.clone()); - } - - _labelPoints = _originLabelPoints; - _chartPoints = _originChartPoints; - this._projInfo = (ProjectionInfo) this.originProjInfo.clone(); - updateExtent(); - } - - // - // - /** - * Save as KML (Google Earth data format) file - * - * @param fileName KML file name - */ - public void saveAsKMLFile(String fileName) { - if (this.getShapeType().isPoint()) { - saveAsKMLFile_Point(fileName); - } else if (this.getShapeType().isLine()) { - saveAsKMLFile_Polyline(fileName); - } else if (this.getShapeType().isPolygon()) { - saveAsKMLFile_Polygon(fileName); - } - } - - /** - * Save as KML (Google Earth data format) file - Polygon - * - * @param fileName KML file name - */ - private void saveAsKMLFile_Polygon(String fileName) { - try { - // Create XML text file - SAXTransformerFactory fac = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); - TransformerHandler handler = fac.newTransformerHandler(); - Transformer transformer = handler.getTransformer(); - transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); - transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); - OutputStream outStream = new FileOutputStream(fileName); - Result resultxml = new StreamResult(outStream); - handler.setResult(resultxml); - AttributesImpl atts = new AttributesImpl(); - - //Write KML - handler.startDocument(); - atts.addAttribute("", "", "xmlns", String.class.getName(), "http://www.opengis.net/kml/2.2"); - handler.startElement("", "", "kml", atts); - atts.clear(); - handler.startElement("", "", "Document", atts); - handler.startElement("", "", "Name", atts); - handler.characters(fileName.toCharArray(), 0, fileName.length()); - handler.endElement("", "", "Name"); //Name - - //Write styles - int styleNum = 0; - String str; - for (ColorBreak cb : this.getLegendScheme().getLegendBreaks()) { - //StyleMap - atts.addAttribute("", "", "id", "", "pg" + String.valueOf(styleNum)); - handler.startElement("", "", "StyleMap", atts); - atts.clear(); - handler.startElement("", "", "Pair", atts); - handler.startElement("", "", "key", atts); - str = "normal"; - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "key"); //key - handler.startElement("", "", "styleUrl", atts); - str = "#pgn" + String.valueOf(styleNum); - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "styleUrl"); //styleUrl - handler.endElement("", "", "Pair"); //Pair - - handler.startElement("", "", "Pair", atts); - handler.startElement("", "", "key", atts); - str = "highlight"; - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "key"); //key - handler.startElement("", "", "styleUrl", atts); - str = "#pgn"; - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "styleUrl"); //styleUrl - handler.endElement("", "", "Pair"); //Pair - handler.endElement("", "", "StyleMap"); //StyleMap - - //Normal style - PolygonBreak pgb = (PolygonBreak) cb; - atts.addAttribute("", "", "id", "", "pgn" + String.valueOf(styleNum)); - handler.startElement("", "", "Style", atts); - atts.clear(); - handler.startElement("", "", "LineStyle", atts); - handler.startElement("", "", "color", atts); - str = ColorUtil.toKMLColor(pgb.getOutlineColor()); - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "color"); //color - handler.startElement("", "", "width", atts); - str = String.valueOf((int) pgb.getOutlineSize()); - if (!pgb.isDrawOutline()) { - str = "0"; - } - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "width"); - handler.endElement("", "", "LineStyle"); //LineStyle - handler.startElement("", "", "PolyStyle", atts); - handler.startElement("", "", "color", atts); - str = ColorUtil.toKMLColor(pgb.getColor()); - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "color"); //color - handler.startElement("", "", "fill", atts); - str = "1"; - if (!pgb.isDrawFill()) { - str = "0"; - } - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "fill"); //fill - handler.endElement("", "", "PolyStyle"); //PolyStyle - handler.endElement("", "", "Style"); //Style - - styleNum += 1; - } - - // Highlight style - shared by all elements - atts.addAttribute("", "", "id", "", "pgh"); - handler.startElement("", "", "Style", atts); - atts.clear(); - handler.startElement("", "", "LineStyle", atts); - handler.startElement("", "", "color", atts); - str = "00000000"; - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "color"); //color - handler.endElement("", "", "LineStyle"); //LineStyle - handler.startElement("", "", "PolyStyle", atts); - handler.startElement("", "", "color", atts); - str = "a0ff00ff"; - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "color"); //color - handler.startElement("", "", "fill", atts); - str = "1"; - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "fill"); //fill - handler.endElement("", "", "PolyStyle"); //PolyStyle - handler.endElement("", "", "Style"); //Style - - //Write shape coordinates - handler.startElement("", "", "Folder", atts); - handler.startElement("", "", "name", atts); - str = fileName; - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "name"); //name - handler.startElement("", "", "description", atts); - str = "Generated using MeteoInfo"; - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "description"); //description - - boolean hasSelShape = this.hasSelectedShapes(); - for (Shape shp : _shapeList) { - PolygonShape pgs = (PolygonShape) shp; - if (hasSelShape) { - if (!pgs.isSelected()) { - continue; - } - } - double currentLevel = pgs.lowValue; - int levelNum = pgs.getLegendIndex(); - - for (Polygon polygon : pgs.getPolygons()) { - handler.startElement("", "", "Placemark", atts); - handler.startElement("", "", "name", atts); - str = "Level " + String.valueOf(currentLevel); - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "name"); //name - handler.startElement("", "", "description", atts); - str = "Level " + String.valueOf(currentLevel); - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "description"); //description - handler.startElement("", "", "styleUrl", atts); - str = "#pg" + String.valueOf(levelNum); - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "styleUrl"); - handler.startElement("", "", "Polygon", atts); - handler.startElement("", "", "outerBoundaryIs", atts); - handler.startElement("", "", "LinearRing", atts); - handler.startElement("", "", "coordinates", atts); - for (PointD point : polygon.getOutLine()) { - str = String.valueOf(point.X) + "," + String.valueOf(point.Y) + " "; - handler.characters(str.toCharArray(), 0, str.length()); - } - handler.endElement("", "", "coordinates"); //coordinates - handler.endElement("", "", "LinearRing"); //LinearRing - handler.endElement("", "", "outerBoundaryIs"); //outerBoundaryIs - - // If Fill=true then add innerBoundaryIs for the contour 'holes' - if (((PolygonBreak) this.getLegendScheme().getLegendBreaks().get(levelNum)).isDrawFill()) { - if (polygon.hasHole()) { - for (List hole : polygon.getHoleLines()) { - handler.startElement("", "", "innerBoundaryIs", atts); - handler.startElement("", "", "LinearRing", atts); - handler.startElement("", "", "coordinates", atts); - for (PointD point : hole) { - str = String.valueOf(point.X) + "," + String.valueOf(point.Y) + " "; - handler.characters(str.toCharArray(), 0, str.length()); - } - handler.endElement("", "", "coordinates"); //coordinates - handler.endElement("", "", "LinearRing"); //LinearRing - handler.endElement("", "", "innerBoundaryIs"); //innerBoundaryIs - } - } - } - - handler.endElement("", "", "Polygon"); //Polygon - handler.endElement("", "", "Placemark"); //Placemark - } - } - - handler.endElement("", "", "Folder"); //Folder - handler.endElement("", "", "Document"); //Document - handler.endElement("", "", "kml"); //kml - - //End the document - handler.endDocument(); - - //Close - outStream.close(); - - } catch (TransformerConfigurationException e) { - } catch (FileNotFoundException e) { - } catch (SAXException e) { - } catch (IOException e) { - } - - } - - /** - * Save as KML (Google Earth data format) file - Polyline - * - * @param fileName KML file name - */ - private void saveAsKMLFile_Polyline(String fileName) { - try { - // Create XML text file - SAXTransformerFactory fac = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); - TransformerHandler handler = fac.newTransformerHandler(); - Transformer transformer = handler.getTransformer(); - transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); - transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); - OutputStream outStream = new FileOutputStream(fileName); - Result resultxml = new StreamResult(outStream); - handler.setResult(resultxml); - AttributesImpl atts = new AttributesImpl(); - - //Write KML - handler.startDocument(); - atts.addAttribute("", "", "xmlns", String.class.getName(), "http://www.opengis.net/kml/2.2"); - handler.startElement("", "", "kml", atts); - atts.clear(); - handler.startElement("", "", "Document", atts); - handler.startElement("", "", "Name", atts); - handler.characters(fileName.toCharArray(), 0, fileName.length()); - handler.endElement("", "", "Name"); //Name - - //Write styles - int styleNum = 0; - String str; - for (ColorBreak cb : this.getLegendScheme().getLegendBreaks()) { - //StyleMap - atts.addAttribute("", "", "id", "", "pg" + String.valueOf(styleNum)); - handler.startElement("", "", "StyleMap", atts); - atts.clear(); - handler.startElement("", "", "Pair", atts); - handler.startElement("", "", "key", atts); - str = "normal"; - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "key"); //key - handler.startElement("", "", "styleUrl", atts); - str = "#pgn" + String.valueOf(styleNum); - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "styleUrl"); //styleUrl - handler.endElement("", "", "Pair"); //Pair - - handler.startElement("", "", "Pair", atts); - handler.startElement("", "", "key", atts); - str = "highlight"; - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "key"); //key - handler.startElement("", "", "styleUrl", atts); - str = "#pgn"; - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "styleUrl"); //styleUrl - handler.endElement("", "", "Pair"); //Pair - handler.endElement("", "", "StyleMap"); //StyleMap - - //Normal style - PolylineBreak pgb = (PolylineBreak) cb; - atts.addAttribute("", "", "id", "", "pgn" + String.valueOf(styleNum)); - handler.startElement("", "", "Style", atts); - atts.clear(); - handler.startElement("", "", "LineStyle", atts); - handler.startElement("", "", "color", atts); - str = ColorUtil.toKMLColor(pgb.getColor()); - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "color"); //color - handler.endElement("", "", "LineStyle"); //LineStyle - handler.endElement("", "", "Style"); //Style - - styleNum += 1; - } - - // Highlight style - shared by all elements - atts.addAttribute("", "", "id", "", "pgh"); - handler.startElement("", "", "Style", atts); - atts.clear(); - handler.startElement("", "", "LineStyle", atts); - handler.startElement("", "", "color", atts); - str = "00000000"; - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "color"); //color - handler.endElement("", "", "LineStyle"); //LineStyle - handler.endElement("", "", "Style"); //Style - - //Write shape coordinates - handler.startElement("", "", "Folder", atts); - handler.startElement("", "", "name", atts); - str = fileName; - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "name"); //name - handler.startElement("", "", "description", atts); - str = "Generated using MeteoInfo"; - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "description"); //description - - boolean hasSelShape = this.hasSelectedShapes(); - for (Shape shp : _shapeList) { - PolylineShape pgs = (PolylineShape) shp; - if (hasSelShape) { - if (!pgs.isSelected()) { - continue; - } - } - double currentLevel = pgs.getValue(); - int levelNum = pgs.getLegendIndex(); - int i = 0; - for (Polyline line : pgs.getPolylines()) { - handler.startElement("", "", "Placemark", atts); - handler.startElement("", "", "name", atts); - str = "Level " + String.valueOf(currentLevel); - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "name"); //name - handler.startElement("", "", "description", atts); - str = "Level " + String.valueOf(currentLevel); - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "description"); //description - handler.startElement("", "", "styleUrl", atts); - str = "#pg" + String.valueOf(levelNum); - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "styleUrl"); //styleUrl - handler.startElement("", "", "LineString", atts); - handler.startElement("", "", "coordinates", atts); - for (PointD point : line.getPointList()) { - str = String.valueOf(point.X) + "," + String.valueOf(point.Y); - if (this.getShapeType() == ShapeTypes.PolylineZ) { - str = str + "," + String.valueOf(((PolylineZShape) shp).getZArray()[i]); - } - str = str + " "; - handler.characters(str.toCharArray(), 0, str.length()); - i += 1; - } - handler.endElement("", "", "coordinates"); //coordinates - handler.endElement("", "", "LineString"); //LineString - handler.endElement("", "", "Placemark"); //Placemark - } - } - - handler.endElement("", "", "Folder"); //Folder - handler.endElement("", "", "Document"); //Document - handler.endElement("", "", "kml"); //kml - - //End the document - handler.endDocument(); - - //Close - outStream.close(); - - } catch (TransformerConfigurationException e) { - } catch (FileNotFoundException e) { - } catch (SAXException e) { - } catch (IOException e) { - } - } - - /** - * Save as KML (Google Earth data format) file - Point - * - * @param fileName KML file name - */ - private void saveAsKMLFile_Point(String fileName) { - try { - // Create XML text file - SAXTransformerFactory fac = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); - TransformerHandler handler = fac.newTransformerHandler(); - Transformer transformer = handler.getTransformer(); - transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); - transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); - OutputStream outStream = new FileOutputStream(fileName); - Result resultxml = new StreamResult(outStream); - handler.setResult(resultxml); - AttributesImpl atts = new AttributesImpl(); - - //Write KML - handler.startDocument(); - atts.addAttribute("", "", "xmlns", String.class.getName(), "http://www.opengis.net/kml/2.2"); - handler.startElement("", "", "kml", atts); - atts.clear(); - handler.startElement("", "", "Document", atts); - handler.startElement("", "", "Name", atts); - handler.characters(fileName.toCharArray(), 0, fileName.length()); - handler.endElement("", "", "Name"); //Name - - //Write styles - int styleNum = 0; - String str; - for (ColorBreak cb : this.getLegendScheme().getLegendBreaks()) { - //StyleMap - atts.addAttribute("", "", "id", "", "pg" + String.valueOf(styleNum)); - handler.startElement("", "", "StyleMap", atts); - atts.clear(); - handler.startElement("", "", "Pair", atts); - handler.startElement("", "", "key", atts); - str = "normal"; - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "key"); //key - handler.startElement("", "", "styleUrl", atts); - str = "#pgn" + String.valueOf(styleNum); - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "styleUrl"); //styleUrl - handler.endElement("", "", "Pair"); //Pair - - handler.startElement("", "", "Pair", atts); - handler.startElement("", "", "key", atts); - str = "highlight"; - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "key"); //key - handler.startElement("", "", "styleUrl", atts); - str = "#pgn"; - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "styleUrl"); //styleUrl - handler.endElement("", "", "Pair"); //Pair - handler.endElement("", "", "StyleMap"); //StyleMap - - //Normal style - PointBreak pgb = (PointBreak) cb; - atts.addAttribute("", "", "id", "", "pgn" + String.valueOf(styleNum)); - handler.startElement("", "", "Style", atts); - atts.clear(); - handler.startElement("", "", "BalloonStyle", atts); - handler.startElement("", "", "bgColor", atts); - str = ColorUtil.toKMLColor(pgb.getColor()); - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "bgColor"); //color - handler.endElement("", "", "BalloonStyle"); //BalloonStyle - handler.endElement("", "", "Style"); //Style - - styleNum += 1; - } - - // Highlight style - shared by all elements - atts.addAttribute("", "", "id", "", "pgh"); - handler.startElement("", "", "Style", atts); - atts.clear(); - handler.startElement("", "", "BalloonStyle", atts); - handler.startElement("", "", "color", atts); - str = "00000000"; - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "color"); //color - handler.endElement("", "", "BalloonStyle"); //BalloonStyle - handler.endElement("", "", "Style"); //Style - - //Write shape coordinates - handler.startElement("", "", "Folder", atts); - handler.startElement("", "", "name", atts); - str = fileName; - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "name"); //name - handler.startElement("", "", "description", atts); - str = "Generated using MeteoInfo"; - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "description"); //description - - boolean hasSelShape = this.hasSelectedShapes(); - int shapIdx = 0; - for (Shape shp : _shapeList) { - PointShape pgs = (PointShape) shp; - if (hasSelShape) { - if (!pgs.isSelected()) { - shapIdx += 1; - continue; - } - } - double currentLevel = pgs.getValue(); - int levelNum = pgs.getLegendIndex(); - - handler.startElement("", "", "Placemark", atts); - if (this.getLabelSet().isDrawLabels()) { - handler.startElement("", "", "name", atts); - str = this.getCellValue(this.getLabelSet().getFieldName(), shapIdx).toString(); - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "name"); //name - } - handler.startElement("", "", "description", atts); - str = "Level " + String.valueOf(currentLevel); - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "description"); //description - handler.startElement("", "", "styleUrl", atts); - str = "#pg" + String.valueOf(levelNum); - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "styleUrl"); //sytleUrl - handler.startElement("", "", "Point", atts); - handler.startElement("", "", "coordinates", atts); - str = String.valueOf(pgs.getPoint().X) + "," + String.valueOf(pgs.getPoint().Y); - if (this.getShapeType() == ShapeTypes.PointZ) { - str = str + "," + String.valueOf(((PointZShape) shp).getZ()); - } - handler.characters(str.toCharArray(), 0, str.length()); - handler.endElement("", "", "coordinates"); //coordinates - handler.endElement("", "", "Point"); //Point - handler.endElement("", "", "Placemark"); //Placemark - } - - handler.endElement("", "", "Folder"); //Folder - handler.endElement("", "", "Document"); //Document - handler.endElement("", "", "kml"); //kml - - //End the document - handler.endDocument(); - - //Close - outStream.close(); - - } catch (TransformerConfigurationException e) { - } catch (FileNotFoundException e) { - } catch (SAXException e) { - } catch (IOException e) { - } - } - // - - // - /** - * Update extent - */ - public void updateExtent() { - for (int i = 0; i < _shapeList.size(); i++) { - if (i == 0) { - this.setExtent((Extent) _shapeList.get(i).getExtent().clone()); - } else { - this.setExtent(MIMath.getLagerExtent(this.getExtent(), _shapeList.get(i).getExtent())); - } - } - } - - /** - * Update legend scheme - * - * @param aLT Legend type - * @param fieldName Field name - */ - public void updateLegendScheme(LegendType aLT, String fieldName) { - this.setLegendScheme(createLegendScheme(aLT, fieldName)); - } - - /** - * Update legend scheme - update legend indexes of the shapes - */ - public void updateLegendIndexes() { - LegendScheme ls = this.getLegendScheme(); - switch (ls.getLegendType()) { - case UniqueValue: - int shapeIdx = 0; - if (this.getField(ls.getFieldName()).isNumeric()) { - for (Shape aShape : this.getShapes()) { - String vStr = this.getCellValue(ls.getFieldName(), shapeIdx).toString(); - aShape.setLegendIndex(-1); - for (int i = 0; i < ls.getBreakNum(); i++) { - if (MIMath.doubleEquals(Double.parseDouble(ls.getLegendBreaks().get(i).getStartValue().toString()), - Double.parseDouble(vStr))) { - aShape.setLegendIndex(i); - break; - } - } - shapeIdx += 1; - } - } else { - for (Shape aShape : this.getShapes()) { - String vStr = this.getCellValue(ls.getFieldName(), shapeIdx).toString(); - aShape.setLegendIndex(-1); - for (int i = 0; i < ls.getBreakNum(); i++) { - if (vStr.equals(ls.getLegendBreaks().get(i).getStartValue().toString())) { - aShape.setLegendIndex(i); - break; - } - } - shapeIdx += 1; - } - } - break; - case GraduatedColor: - if (!ls.isGeometry()) { - shapeIdx = 0; - int idx = -1; - for (Shape aShape : this.getShapes()) { - String vStr = this.getCellValue(ls.getFieldName(), shapeIdx).toString(); - double v = Double.parseDouble(vStr); - if (Double.isNaN(v)) - idx = -1; - else if (v <= ls.getMinValue()) - idx = 0; - else if (v >= ls.getMaxValue()) - idx = ls.getBreakNum() - 1; - else { - int blNum = 0; - for (int i = 0; i < ls.getBreakNum(); i++) { - ColorBreak cb = ls.getLegendBreaks().get(i); - blNum += 1; - if (MIMath.doubleEquals(v, Double.parseDouble(cb.getStartValue().toString())) - || (v > Double.parseDouble(cb.getStartValue().toString()) - && v < Double.parseDouble(cb.getEndValue().toString())) - || (blNum == ls.getBreakNum() && v == Double.parseDouble(cb.getEndValue().toString()))) { - idx = i; - break; - } - } - } - aShape.setLegendIndex(idx); - shapeIdx += 1; - } - } - break; - default: - for (Shape aShape : this.getShapes()) { - aShape.setLegendIndex(0); - } - break; - } - } - - /** - * Create legend scheme - * - * @param aLT Legend type - * @param fieldName Field name - * @return Legend scheme - */ - public LegendScheme createLegendScheme(LegendType aLT, String fieldName) { - double min, max; - ShapeTypes aST = this.getShapeType(); - LegendScheme aLS = new LegendScheme(this.getShapeType()); - - min = aLS.getMinValue(); - max = aLS.getMaxValue(); - switch (aLT) { - case SingleSymbol: - Color aColor = Color.black; - float size = 1.0F; - switch (aST) { - case Point: - case PointM: - case PointZ: - aColor = Color.black; - size = 5; - break; - case Polyline: - case PolylineM: - case PolylineZ: - aColor = Color.black; - break; - case Polygon: - case PolygonM: - case PolygonZ: - case Image: - aColor = new Color(255, 251, 195); - break; - } - - aLS = LegendManage.createSingleSymbolLegendScheme(aST, aColor, size); - break; - case UniqueValue: - Color[] colors; - List valueList = new ArrayList<>(); - boolean isDateField = false; - DataType colType = this.getAttributeTable().getTable().getColumns().get(fieldName).getDataType(); - if (colType == DataType.DATE) { - isDateField = true; - } - - List captions = new ArrayList<>(); - DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy/M/d"); - - for (int i = 0; i < this.getAttributeTable().getTable().getRows().size(); i++) { - Object value = this.getAttributeTable().getTable().getRows().get(i).getValue(fieldName); - if (!valueList.contains(value.toString())) { - valueList.add(value.toString()); - if (isDateField) { - captions.add(format.format((LocalDateTime) value)); - } - } - } - -// if (valueList.size() == 1) { -// JOptionPane.showMessageDialog(null, "The values of all shapes are same!"); -// break; -// } - if (valueList.size() <= 13) { - colors = LegendManage.createRainBowColors(valueList.size()); - } else { - colors = LegendManage.createRandomColors(valueList.size()); - } - Color[] newcolors = new Color[colors.length + 1]; - newcolors[0] = Color.white; - for (int i = 1; i < newcolors.length; i++) { - newcolors[i] = colors[i - 1]; - } - - if (isDateField) { - aLS = LegendManage.createUniqValueLegendScheme(valueList, captions, newcolors, aST, min, - max, aLS.getHasNoData(), aLS.getUndefValue()); - } else { - aLS = LegendManage.createUniqValueLegendScheme(valueList, newcolors, - aST, min, max, aLS.getHasNoData(), aLS.getUndefValue()); - } - - aLS.setFieldName(fieldName); - break; - case GraduatedColor: - double[] S = new double[this.getAttributeTable().getTable().getRows().size()]; - for (int i = 0; i < S.length; i++) { - S[i] = Double.parseDouble(this.getAttributeTable().getTable().getRows().get(i).getValue(fieldName).toString()); - } - double[] minmax = MIMath.getMinMaxValue(S, aLS.getUndefValue()); - min = minmax[0]; - max = minmax[1]; - - if (min == max) { - JOptionPane.showMessageDialog(null, "The values of all shapes are same!"); - break; - } - - double[] CValues; - CValues = LegendManage.createContourValues(min, max); - colors = LegendManage.createRainBowColors(CValues.length + 1); - - aLS = LegendManage.createGraduatedLegendScheme(CValues, colors, - aST, min, max, aLS.getHasNoData(), aLS.getUndefValue()); - aLS.setFieldName(fieldName); - break; - } - - return aLS; - } - - /** - * Clone VectorLayer object - * - * @return VectorLayer object - */ - @Override - public Object clone() { - VectorLayer aLayer = new VectorLayer(this.getShapeType()); - aLayer.setExtent((Extent) this.getExtent().clone()); - aLayer.setFileName(this.getFileName()); - aLayer.setHandle(this.getHandle()); - aLayer.setLayerName(this.getLayerName()); - if (_projected) { - for (Shape shape : _originShapes) { - aLayer.addShape((Shape) shape.clone()); - } - aLayer.setAttributeTable((AttributeTable) _originAttributeTable.clone()); - } else { - for (Shape shape : _shapeList) { - aLayer.addShape((Shape) shape.clone()); - } - aLayer.setAttributeTable((AttributeTable) _attributeTable.clone()); - } - aLayer.setLegendScheme((LegendScheme) this.getLegendScheme().clone()); - aLayer.setTransparency(this.getTransparency()); - aLayer.setLayerDrawType(this.getLayerDrawType()); - aLayer.setVisible(this.isVisible()); - aLayer.setLabelSet(_labelSet); - aLayer.setExpanded(this.isExpanded()); - aLayer.setAvoidCollision(this._avoidCollision); - aLayer.setMaskout(this.isMaskout()); - aLayer.setTag(this.getTag()); - - return aLayer; - } - - /** - * Clone VectorLayer object - without attribute table - * - * @return Object - */ - public Object cloneShapes() { - VectorLayer aLayer = new VectorLayer(this.getShapeType()); - aLayer.setExtent((Extent) this.getExtent().clone()); - //aLayer.setFileName(this.getFileName()); - //aLayer.setHandle(this.getHandle()); - aLayer.setLayerName(this.getLayerName()); - aLayer.setProjInfo(this.getProjInfo()); - aLayer.setLegendScheme((LegendScheme) this.getLegendScheme().clone()); - if (_projected) { - for (Shape shape : _originShapes) { - aLayer.addShape((Shape) shape.clone()); - } - } else { - for (Shape shape : _shapeList) { - aLayer.addShape((Shape) shape.clone()); - } - } - aLayer.setTransparency(this.getTransparency()); - aLayer.setLayerDrawType(this.getLayerDrawType()); - aLayer.setVisible(this.isVisible()); - aLayer.setLabelSet(_labelSet); - aLayer.setExpanded(this.isExpanded()); - aLayer.setAvoidCollision(this._avoidCollision); - aLayer.setMaskout(this.isMaskout()); - //aLayer.setTag(this.getTag()); - - return aLayer; - } - - /** - * Clone VectorLayer object - only parameters - * - * @return Object - */ - public Object cloneValue() { - VectorLayer aLayer = new VectorLayer(this.getShapeType()); - //aLayer.setExtent((Extent) this.getExtent().clone()); - //aLayer.setFileName(this.getFileName()); - //aLayer.setHandle(this.getHandle()); - aLayer.setLayerName(this.getLayerName()); - aLayer.setProjInfo(this.getProjInfo()); - //aLayer.setLegendScheme((LegendScheme) this.getLegendScheme().clone()); - //aLayer.setTransparency(this.getTransparency()); - aLayer.setLayerDrawType(this.getLayerDrawType()); - aLayer.setVisible(this.isVisible()); - aLayer.setLabelSet(_labelSet); - aLayer.setExpanded(this.isExpanded()); - aLayer.setAvoidCollision(this._avoidCollision); - aLayer.setMaskout(this.isMaskout()); - //aLayer.setTag(this.getTag()); - - return aLayer; - } - - /** - * To string - * - * @return String - */ - @Override - public String getLayerInfo() { - String str = "Layer name: " + this.getLayerName(); - str += System.getProperty("line.separator") + "Layer file: " + this.getFileName(); - str += System.getProperty("line.separator") + "Layer type: " + this.getLayerType(); - str += System.getProperty("line.separator") + "Shape type: " + this.getShapeType(); - str += System.getProperty("line.separator") + "Shape count: " + String.valueOf(this.getShapeNum()); - str += System.getProperty("line.separator") + "Fields:"; - for (Field field : this.getFields()) { - str += System.getProperty("line.separator") + "\t" + field.getColumnName() + ": " + field.getDataTypeName(); - } - - return str; - } - // - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/VectorLayerBeanInfo.java b/MeteoInfoLib/src/main/java/org/meteoinfo/layer/VectorLayerBeanInfo.java deleted file mode 100644 index 5b1f6856..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/VectorLayerBeanInfo.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.layer; - -import com.l2fprod.common.beans.BaseBeanInfo; - -/** - * - * @author Yaqiang - */ -public class VectorLayerBeanInfo extends BaseBeanInfo { - public VectorLayerBeanInfo(){ - super(VectorLayer.class); - addProperty("fileName").setCategory("Read only").setReadOnly().setDisplayName("File name"); - addProperty("layerType").setCategory("Read only").setReadOnly().setDisplayName("Layer type"); - addProperty("layerDrawType").setCategory("Read only").setReadOnly().setDisplayName("Layer draw type"); - addProperty("shapeType").setCategory("Read only").setReadOnly().setDisplayName("Shape type"); - addProperty("handle").setCategory("Read only").setReadOnly().setDisplayName("Handle"); - addProperty("layerName").setCategory("Editable").setDisplayName("Layer name"); - addProperty("visible").setCategory("Editable").setDisplayName("Visible"); - addProperty("maskout").setCategory("Editable").setDisplayName("Is maskout"); - //addProperty("transparency").setCategory("Editable").setDisplayName("Transparency Percent"); - addProperty("avoidCollision").setCategory("Editable").setDisplayName("Avoid collision"); - } -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/VisibleScale.java b/MeteoInfoLib/src/main/java/org/meteoinfo/layer/VisibleScale.java deleted file mode 100644 index f54374c3..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/VisibleScale.java +++ /dev/null @@ -1,119 +0,0 @@ - /* Copyright 2012 - Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layer; - -/** - * - * @author Yaqiang Wang - */ -public class VisibleScale { - // - - private boolean _enableMinVisScale = false; - private boolean _enableMaxVisScale = false; - private double _minVisScale; - private double _maxVisScale; - // - // - // - // - - /** - * Get if is enable minimum visible scale - * - * @return Boolean - */ - public boolean isEnableMinVisScale() { - return _enableMinVisScale; - } - - /** - * Set if is enable minimum visible scale - * - * @param value Boolean - */ - public void setEnableMinVisScale(boolean value) { - _enableMinVisScale = value; - } - - /** - * Get if is enable maximum visible scale - * - * @return Boolean - */ - public boolean isEnableMaxVisScale() { - return _enableMaxVisScale; - } - - /** - * Set if is enable maximum visible scale - * - * @param value Boolean - */ - public void setEnableMaxVisScale(boolean value) { - _enableMaxVisScale = value; - } - - /** - * Get minimum visible scale value - * - * @return Minimum visible scale value - */ - public double getMinVisScale() { - return _minVisScale; - } - - /** - * Set minimum visible scale value - * - * @param value Minimum visible scale value - */ - public void setMinVisScale(double value) { - _minVisScale = value; - } - - /** - * Get maximum visible scale value - * - * @return maximum visible scale value - */ - public double getMaxVisScale() { - return _maxVisScale; - } - - /** - * Set maximum visible scale value - * - * @param value maximum visible scale value - */ - public void setMaxVisScale(double value) { - _maxVisScale = value; - } - // - // - - /** - * Get if is visible scale enabled - * - * @return Is visible scale enabled - */ - public boolean isVisibleScaleEnabled() { - if (this._enableMaxVisScale || this._enableMinVisScale) { - return true; - } else { - return false; - } - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/WebMapLayer.java b/MeteoInfoLib/src/main/java/org/meteoinfo/layer/WebMapLayer.java deleted file mode 100644 index 29c4593d..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/WebMapLayer.java +++ /dev/null @@ -1,919 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.layer; - -//import com.sun.java.swing.Painter; -import com.l2fprod.common.beans.BaseBeanInfo; -import com.l2fprod.common.beans.ExtendedPropertyDescriptor; -import com.l2fprod.common.beans.editor.ComboBoxPropertyEditor; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.Rectangle; -import java.awt.geom.Point2D; -import java.awt.image.BufferedImage; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import javax.imageio.ImageIO; - -import org.meteoinfo.common.Extent; -import org.meteoinfo.common.PointD; -import org.meteoinfo.data.mapdata.webmap.*; -import org.meteoinfo.data.mapdata.webmap.empty.EmptyTileFactory; -import org.meteoinfo.data.mapdata.webmap.GeoUtil; -import org.meteoinfo.projection.KnownCoordinateSystems; -import org.meteoinfo.projection.Reproject; -import org.meteoinfo.geometry.shape.ShapeTypes; - -/** - * - * @author wyq - */ -public class WebMapLayer extends MapLayer { - // - - private final boolean isNegativeYAllowed = true; //maybe rename to isNorthBounded and isSouthBounded? - /** - * The zoom level. Generally a value between 1 and 15 (TODO Is this true for - * all the mapping worlds? What does this mean if some mapping system - * doesn't support the zoom level? - */ - private int zoom = 11; - /** - * The position, in map coordinates of the center point. This is - * defined as the distance from the top and left edges of the map in pixels. - * Dragging the map component will change the center position. Zooming - * in/out will cause the center to be recalculated so as to remain in the - * center of the new "map". - */ - private Point2D center = new Point2D.Double(0, 0); - /** - * Indicates whether or not to draw the borders between tiles. Defaults to - * false. - * - * TODO Generally not very nice looking, very much a product of testing - * Consider whether this should really be a property or not. - */ - private boolean drawTileBorders = false; - /** - * Factory used by this component to grab the tiles necessary for painting - * the map. - */ - private TileFactory factory; - /** - * The position in latitude/longitude of the "address" being mapped. This is - * a special coordinate that, when moved, will cause the map to be moved as - * well. It is separate from "center" in that "center" tracks the current - * center (in pixels) of the viewport whereas this will not change when - * panning or zooming. Whenever the addressLocation is changed, however, the - * map will be repositioned. - */ - private GeoPosition addressLocation; - /** - * Specifies whether panning is enabled. Panning is being able to click and - * drag the map around to cause it to move - */ - private boolean panEnabled = true; - /** - * Specifies whether zooming is enabled (the mouse wheel, for example, - * zooms) - */ - private boolean zoomEnabled = true; - /** - * Indicates whether the component should recenter the map when the "middle" - * mouse button is pressed - */ - private boolean recenterOnClickEnabled = true; - /** - * The overlay to delegate to for painting the "foreground" of the map - * component. This would include painting waypoints, day/night, etc. Also - * receives mouse events. - */ - //private Painter overlay; - private boolean designTime; - private double webMapScale = 0.; - private Image loadingImage; - private boolean restrictOutsidePanning = false; - private boolean horizontalWrapped = true; - private WebMapProvider defaultProvider = WebMapProvider.OpenStreetMap; - private Graphics2D graphics; - private int width; - private int height; - private List scales = new ArrayList<>(); - // - // - // a property change listener which forces repaints when tiles finish loading - //private TileLoadListener tileLoadListener = new TileLoadListener(); - -// private final class TileLoadListener implements PropertyChangeListener { -// -// @Override -// public void propertyChange(PropertyChangeEvent evt) { -// if ("loaded".equals(evt.getPropertyName()) -// && Boolean.TRUE.equals(evt.getNewValue())) { -// Tile t = (Tile) evt.getSource(); -// if (t.getZoom() == getZoom()) { -// repaint(); -// /* this optimization doesn't save much and it doesn't work if you -// * wrap around the world -// Rectangle viewportBounds = getViewportBounds(); -// TilePoint tilePoint = t.getLocation(); -// Point point = new Point(tilePoint.getX() * getTileFactory().getTileSize(), tilePoint.getY() * getTileFactory().getTileSize()); -// Rectangle tileRect = new Rectangle(point, new Dimension(getTileFactory().getTileSize(), getTileFactory().getTileSize())); -// if (viewportBounds.intersects(tileRect)) { -// //convert tileRect from world space to viewport space -// repaint(new Rectangle( -// tileRect.x - viewportBounds.x, -// tileRect.y - viewportBounds.y, -// tileRect.width, -// tileRect.height -// )); -// }*/ -// } -// } -// } -// } - // - // - - /** - * Constructor - */ - public WebMapLayer() { - super(); - this.setLayerType(LayerTypes.WebMapLayer); - this.setShapeType(ShapeTypes.Image); - this.setLayerDrawType(LayerDrawType.Image); - this.setLayerName("OpenStreetMap"); - this.setExtent(new Extent(-2.0037508342789244E7, 2.0037508342789244E7, -1.8375854901481014E7, 1.8375854901481014E7)); - factory = new EmptyTileFactory(); - - // make a dummy loading image - try { - URL url = this.getClass().getResource("/images/loading.png"); - this.setLoadingImage(ImageIO.read(url)); - } catch (Throwable ex) { - System.out.println("could not load 'loading.png'"); - BufferedImage img = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB); - Graphics2D g2 = img.createGraphics(); - g2.setColor(Color.black); - g2.fillRect(0, 0, 16, 16); - g2.dispose(); - this.setLoadingImage(img); - } - } - // - // - - /** - * Gets the current zoom level - * - * @return the current zoom level - */ - public int getZoom() { - return this.zoom; - } - - /** - * Set the current zoom level - * - * @param zoom the new zoom level - */ - public void setZoom(int zoom) { - if (zoom == this.zoom) { - return; - } - - TileFactoryInfo info = getTileFactory().getInfo(); - // don't repaint if we are out of the valid zoom levels - if (info != null - && (zoom < info.getMinimumZoomLevel() - || zoom > info.getMaximumZoomLevel())) { - return; - } - - //if(zoom >= 0 && zoom <= 15 && zoom != this.zoom) { - int oldzoom = this.zoom; - Point2D oldCenter = getCenter(); - Dimension oldMapSize = getTileFactory().getMapSize(oldzoom); - this.zoom = zoom; - //this.firePropertyChange("zoom", oldzoom, zoom); - - Dimension mapSize = getTileFactory().getMapSize(zoom); - - setCenter(new Point2D.Double( - oldCenter.getX() * (mapSize.getWidth() / oldMapSize.getWidth()), - oldCenter.getY() * (mapSize.getHeight() / oldMapSize.getHeight()))); - - //repaint(); - } - - /** - * Gets the current pixel center of the map. This point is in the global - * bitmap coordinate system, not as lat/longs. - * - * @return the current center of the map as a pixel value - */ - public Point2D getCenter() { - return center; - } - - public boolean isRestrictOutsidePanning() { - return restrictOutsidePanning; - } - - public void setRestrictOutsidePanning(boolean restrictOutsidePanning) { - this.restrictOutsidePanning = restrictOutsidePanning; - } - - /** - * Sets the new center of the map in pixel coordinates. - * - * @param center the new center of the map in pixel coordinates - */ - public void setCenter(Point2D center) { - this.center = center; -// if(isRestrictOutsidePanning()) { -// Insets insets = getInsets(); -// int viewportHeight = getHeight() - insets.top - insets.bottom; -// int viewportWidth = getWidth() - insets.left - insets.right; -// -// // don't let the user pan over the top edge -// Rectangle newVP = calculateViewportBounds(center); -// if(newVP.getY() < 0) { -// double centerY = viewportHeight/2; -// center = new Point2D.Double(center.getX(),centerY); -// } -// -// // don't let the user pan over the left edge -// if(!isHorizontalWrapped() && newVP.getX() <0) { -// double centerX = viewportWidth/2; -// center = new Point2D.Double(centerX, center.getY()); -// } -// -// // don't let the user pan over the bottom edge -// Dimension mapSize = getTileFactory().getMapSize(getZoom()); -// int mapHeight = (int)mapSize.getHeight()*getTileFactory().getTileSize(getZoom()); -// if(newVP.getY() + newVP.getHeight() > mapHeight) { -// double centerY = mapHeight - viewportHeight/2; -// center = new Point2D.Double(center.getX(),centerY); -// } -// -// //don't let the user pan over the right edge -// int mapWidth = (int)mapSize.getWidth()*getTileFactory().getTileSize(getZoom()); -// if(!isHorizontalWrapped() && (newVP.getX() + newVP.getWidth() > mapWidth)) { -// double centerX = mapWidth - viewportWidth/2; -// center = new Point2D.Double(centerX, center.getY()); -// } -// -// // if map is to small then just center it vert -// if(mapHeight < newVP.getHeight()) { -// double centerY = mapHeight/2;//viewportHeight/2;// - mapHeight/2; -// center = new Point2D.Double(center.getX(),centerY); -// } -// -// // if map is too small then just center it horiz -// if(!isHorizontalWrapped() && mapWidth < newVP.getWidth()) { -// double centerX = mapWidth/2; -// center = new Point2D.Double(centerX, center.getY()); -// } -// } -// -// //joshy: this is an evil hack to force a property change event -// //i don't know why it doesn't work normally -// old = new Point(5,6); -// -// GeoPosition oldGP = this.getCenterPosition(); - } - - /** - * A property indicating the center position of the map - * - * @param geoPosition the new property value - */ - public void setCenterPosition(GeoPosition geoPosition) { - GeoPosition oldVal = getCenterPosition(); - setCenter(getTileFactory().geoToPixel(geoPosition, zoom)); - //repaint(); - GeoPosition newVal = getCenterPosition(); - //firePropertyChange("centerPosition", oldVal, newVal); - } - - /** - * A property indicating the center position of the map - * - * @return the current center position - */ - public GeoPosition getCenterPosition() { - return getTileFactory().pixelToGeo(getCenter(), zoom); - } - - /** - * Get the current factory - * - * @return the current property value - */ - public TileFactory getTileFactory() { - return factory; - } - - /** - * Set the current tile factory - * - * @param factory the new property value - */ - public void setTileFactory(TileFactory factory) { - this.factory = factory; - this.setZoom(factory.getInfo().getDefaultZoomLevel()); - this.setCenterPosition(new GeoPosition(0, 0)); - } - - /** - * Get web map scale - * @return Web map scale - */ - public double getWebMapScale() { - return this.webMapScale; - } - - /** - * Set web map scale - * @param value Web map scale - */ - public void setWebMapScale(double value) { - this.webMapScale = value; - } - - /** - * A property for an image which will be display when an image is still - * loading. - * - * @return the current property value - */ - public Image getLoadingImage() { - return loadingImage; - } - - /** - * A property for an image which will be display when an image is still - * loading. - * - * @param loadingImage the new property value - */ - public void setLoadingImage(Image loadingImage) { - this.loadingImage = loadingImage; - } - - /** - * Indicates if the tile borders should be drawn. Mainly used for debugging. - * - * @return the value of this property - */ - public boolean isDrawTileBorders() { - return drawTileBorders; - } - - /** - * Set if the tile borders should be drawn. Mainly used for debugging. - * - * @param drawTileBorders new value of this drawTileBorders - */ - public void setDrawTileBorders(boolean drawTileBorders) { - //boolean old = isDrawTileBorders(); - this.drawTileBorders = drawTileBorders; - //firePropertyChange("drawTileBorders", old, isDrawTileBorders()); - //repaint(); - } - - /** - * Set web map provider - * @param prov The web map provider - */ - public void setWebMapProvider(WebMapProvider prov) { - TileFactoryInfo info = null; - switch (prov) { -// case SwingLabsBlueMarble: -// setTileFactory(new CylindricalProjectionTileFactory()); -// setZoom(3); -// return; - case OpenStreetMap: - info = new OpenStreetMapInfo(); - break; - case OpenStreetMapQuestSatellite: - info = new OpenStreetMapQuestSatelliteInfo(); - break; - case BingMap: - info = new BingMapInfo(); - break; - case BingSatelliteMap: - info = new BingSatelliteMapInfo(); - break; - case BingHybridMap: - info = new BingHybridMapInfo(); - break; -// case OviMap: -// info = new OviMapInfo(); -// break; -// case OviSatelliteMap: -// info = new OviSatelliteMapInfo(); -// break; -// case OviTerrainMap: -// info = new OviTerrainMapInfo(); -// break; -// case OviHybridMap: -// info = new OviHybridMapInfo(); -// break; - case YahooMap: - info = new YahooMapInfo(); - break; - case YahooSatelliteMap: - info = new YahooSatelliteMapInfo(); - break; - case YahooHybridMap: - info = new YahooHybridMapInfo(); - break; - case GoogleMap: - info = new GoogleMapInfo(); - break; - case GoogleSatelliteMap: - info = new GoogleSatelliteMapInfo(); - break; - case GoogleTerrainMap: - info = new GoogleTerrainMapInfo(); - break; - case GoogleHybridMap: - info = new GoogleHybridMapInfo(); - break; - case GoogleHybridTerrainMap: - info = new GoogleHybridTerrainMapInfo(); - break; -// case BaiduMap: -// info = new BaiduMapInfo(); -// break; -// case BaiduSatelliteMap: -// info = new BaiduSatelliteMapInfo(); -// break; - case AMap: - info = new AMapInfo(); - break; - case ASatelliteMap: - info = new ASatelliteMapInfo(); - break; - case AHybridMap: - info = new AHybridMapInfo(); - break; - case TencentMap: - info = new TencentMapInfo(); - break; - case CMA_CVA_MAP: - info = new CMACvaMapInfo(); - break; - case CMA_VEC_MAP: - info = new CMAVecMapInfo(); - break; - case CMA_IMG_MAP: - info = new CMAImgMapInfo(); - break; -// case ArcGISImage: -// info = new ArcGISImageInfo(); -// break; - } - - if (info != null) { - this.defaultProvider = prov; - this.setLayerName("WebMap_" + info.getName()); - TileFactory tf = new DefaultTileFactory(info); - setTileFactory(tf); - //setZoom(11); - setAddressLocation(new GeoPosition(51.5, 0)); - } - } - - /** - * Get web map provider - * @return Web map provider - */ - public WebMapProvider getWebMapProvider() { - return this.defaultProvider; - } - - public GeoPosition getAddressLocation() { - return this.addressLocation; - } - - public void setAddressLocation(GeoPosition pos, int zoom) { - this.addressLocation = pos; - setCenter(getTileFactory().geoToPixel(pos, zoom)); - } - - public void setAddressLocation(GeoPosition pos) { - this.addressLocation = pos; - setCenter(getTileFactory().geoToPixel(addressLocation, getZoom())); - } - // - // - - /** - * Repaint - */ - public void repaint() { - Rectangle rect = this.calculateViewportBounds(graphics, width, height); - this.drawMapTiles(graphics, zoom, rect); - } - - /** - * Draw the map tiles - * - * @param g Graphics2D - * @param zoom Zoom level to draw at - * @param width The width - * @param height The height - */ - public void drawMapTiles(final Graphics2D g, final int zoom, int width, int height) { - this.graphics = g; - this.zoom = zoom; - this.width = width; - this.height = height; - Rectangle rect = this.calculateViewportBounds(g, width, height); - this.drawMapTiles(g, zoom, rect); - } - - /** - * Draw the map tiles. This method is for implementation use only. - * - * @param g Graphics - * @param zoom zoom level to draw at - * @param viewportBounds View bounds - */ - public void drawMapTiles(final Graphics2D g, final int zoom, final Rectangle viewportBounds) { - int size = getTileFactory().getTileSize(zoom); - Dimension mapSize = getTileFactory().getMapSize(zoom); - - //calculate the "visible" viewport area in tiles - int numWide = viewportBounds.width / size + 2; - int numHigh = viewportBounds.height / size + 2; - - //TilePoint topLeftTile = getTileFactory().getTileCoordinate( - // new Point2D.Double(viewportBounds.x, viewportBounds.y)); - TileFactoryInfo info = getTileFactory().getInfo(); - int tpx = (int) Math.floor(viewportBounds.getX() / info.getTileSize(0)); - int tpy = (int) Math.floor(viewportBounds.getY() / info.getTileSize(0)); - //TilePoint topLeftTile = new TilePoint(tpx, tpy); - - //p("top tile = " + topLeftTile); - //fetch the tiles from the factory and store them in the tiles cache - //attach the tileLoadListener - for (int x = 0; x <= numWide; x++) { - for (int y = 0; y <= numHigh; y++) { - int itpx = x + tpx;//topLeftTile.getX(); - int itpy = y + tpy;//topLeftTile.getY(); - //TilePoint point = new TilePoint(x + topLeftTile.getX(), y + topLeftTile.getY()); - //only proceed if the specified tile point lies within the area being painted - //if (g.getClipBounds().intersects(new Rectangle(itpx * size - viewportBounds.x, - //itpy * size - viewportBounds.y, size, size))) { - Tile tile = getTileFactory().getTile(itpx, itpy, zoom); - //tile.addUniquePropertyChangeListener("loaded", tileLoadListener); //this is a filthy hack - int ox = ((itpx * getTileFactory().getTileSize(zoom)) - viewportBounds.x); - int oy = ((itpy * getTileFactory().getTileSize(zoom)) - viewportBounds.y); - - //if the tile is off the map to the north/south, then just don't paint anything - if (isTileOnMap(itpx, itpy, mapSize)) { -// if (isOpaque()) { -// g.setColor(getBackground()); -// g.fillRect(ox,oy,size,size); -// } - } else if (tile.isLoaded()) { - g.drawImage(tile.getImage(), ox, oy, null); - } -// else { -// int imageX = (getTileFactory().getTileSize(zoom) - getLoadingImage().getWidth(null)) / 2; -// int imageY = (getTileFactory().getTileSize(zoom) - getLoadingImage().getHeight(null)) / 2; -// g.setColor(Color.GRAY); -// g.fillRect(ox, oy, size, size); -// g.drawImage(getLoadingImage(), ox + imageX, oy + imageY, null); -// } - if (isDrawTileBorders()) { - - g.setColor(Color.black); - g.drawRect(ox, oy, size, size); - g.drawRect(ox + size / 2 - 5, oy + size / 2 - 5, 10, 10); - g.setColor(Color.white); - g.drawRect(ox + 1, oy + 1, size, size); - - String text = itpx + ", " + itpy + ", " + getZoom(); - g.setColor(Color.BLACK); - g.drawString(text, ox + 10, oy + 30); - g.drawString(text, ox + 10 + 2, oy + 30 + 2); - g.setColor(Color.WHITE); - g.drawString(text, ox + 10 + 1, oy + 30 + 1); - } - //} - } - } - } - - /** - * Draw layer - * @param g The Graphics2D - * @param width Canvas width - * @param height Canvas height - * @param tll TileLoadListener - */ - public void drawWebMapLayer(Graphics2D g, int width, int height, TileLoadListener tll) { - //layer.setZoom(zoom); - //layer.drawMapTiles(g, zoom, width, height); - Rectangle viewportBounds = this.calculateViewportBounds(g, width, height); - int size = this.getTileFactory().getTileSize(zoom); - Dimension mapSize = this.getTileFactory().getMapSize(zoom); - - //calculate the "visible" viewport area in tiles - int numWide = viewportBounds.width / size + 2; - int numHigh = viewportBounds.height / size + 2; - - //TilePoint topLeftTile = getTileFactory().getTileCoordinate( - // new Point2D.Double(viewportBounds.x, viewportBounds.y)); - TileFactoryInfo info = this.getTileFactory().getInfo(); - int tpx = (int) Math.floor(viewportBounds.getX() / info.getTileSize(0)); - int tpy = (int) Math.floor(viewportBounds.getY() / info.getTileSize(0)); - //TilePoint topLeftTile = new TilePoint(tpx, tpy); - - //p("top tile = " + topLeftTile); - //fetch the tiles from the factory and store them in the tiles cache - //attach the TileLoadListener - //String language = layer.getTileFactory().getInfo().getLanguage(); - for (int x = 0; x <= numWide; x++) { - for (int y = 0; y <= numHigh; y++) { - int itpx = x + tpx;//topLeftTile.getX(); - int itpy = y + tpy;//topLeftTile.getY(); - //TilePoint point = new TilePoint(x + topLeftTile.getX(), y + topLeftTile.getY()); - //only proceed if the specified tile point lies within the area being painted - //if (g.getClipBounds().intersects(new Rectangle(itpx * size - viewportBounds.x, - //itpy * size - viewportBounds.y, size, size))) { - Tile tile = this.getTileFactory().getTile(itpx, itpy, zoom); - tile.addUniquePropertyChangeListener("loaded", tll); //this is a filthy hack - int ox = ((itpx * this.getTileFactory().getTileSize(zoom)) - viewportBounds.x); - int oy = ((itpy * this.getTileFactory().getTileSize(zoom)) - viewportBounds.y); - - //if the tile is off the map to the north/south, then just don't paint anything - if (this.isTileOnMap(itpx, itpy, mapSize)) { -// if (isOpaque()) { -// g.setColor(getBackground()); -// g.fillRect(ox,oy,size,size); -// } - } else if (tile.isLoaded()) { - g.drawImage(tile.getImage(), ox, oy, null); - } else { - int imageX = (this.getTileFactory().getTileSize(zoom) - this.getLoadingImage().getWidth(null)) / 2; - int imageY = (this.getTileFactory().getTileSize(zoom) - this.getLoadingImage().getHeight(null)) / 2; - g.setColor(Color.GRAY); - g.fillRect(ox, oy, size, size); - g.drawImage(this.getLoadingImage(), ox + imageX, oy + imageY, null); - } - if (this.isDrawTileBorders()) { - - g.setColor(Color.black); - g.drawRect(ox, oy, size, size); - g.drawRect(ox + size / 2 - 5, oy + size / 2 - 5, 10, 10); - g.setColor(Color.white); - g.drawRect(ox + 1, oy + 1, size, size); - - String text = itpx + ", " + itpy + ", " + this.getZoom(); - g.setColor(Color.BLACK); - g.drawString(text, ox + 10, oy + 30); - g.drawString(text, ox + 10 + 2, oy + 30 + 2); - g.setColor(Color.WHITE); - g.drawString(text, ox + 10 + 1, oy + 30 + 1); - } - //} - } - } - } - - private double getWebMapScale(int zoom, int width, int height) { - Point2D center = this.getCenter(); - double minx = center.getX() - width / 2; - double miny = center.getY() - height / 2; - double maxx = center.getX() + width / 2; - double maxy = center.getY() + height / 2; - GeoPosition pos1 = GeoUtil.getPosition(new Point2D.Double(minx, miny), zoom, this.getTileFactory().getInfo()); - GeoPosition pos2 = GeoUtil.getPosition(new Point2D.Double(maxx, maxy), zoom, this.getTileFactory().getInfo()); - PointD p1 = Reproject.reprojectPoint(new PointD(pos1.getLongitude(), pos1.getLatitude()), - KnownCoordinateSystems.geographic.world.WGS1984, this.getProjInfo()); - PointD p2 = Reproject.reprojectPoint(new PointD(pos2.getLongitude(), pos2.getLatitude()), - KnownCoordinateSystems.geographic.world.WGS1984, this.getProjInfo()); - if (pos2.getLongitude() - pos1.getLongitude() < 360.0) { - double xlen = p2.X - p1.X; -// if (pos2.getLongitude() - pos1.getLongitude() > 360) -// xlen += 2.0037497210840166E7 * 2; - return (double) width / xlen; - } else { - double ylen = Math.abs(p2.Y - p1.Y); - return (double) height / ylen; - } - } - - public boolean isTileOnMap(int x, int y, Dimension mapSize) { - return !isNegativeYAllowed && y < 0 || y >= mapSize.getHeight(); - } - - /** - * Calculate view port bounds - * - * @param g Graphic2D - * @param width The width - * @param height The height - * @return View port bounds rectangle - */ - public Rectangle calculateViewportBounds(Graphics2D g, int width, int height) { - //calculate the "visible" viewport area in pixels - //double sx = g.getTransform().getTranslateX(); - //double sy = g.getTransform().getTranslateY(); - double viewportX = (center.getX() - width / 2); - double viewportY = (center.getY() - height / 2); - return new Rectangle((int) viewportX, (int) viewportY, width, height); - } - - /** - * To string - * @return String - */ - @Override - public String getLayerInfo(){ - String str = "Layer name: " + this.getLayerName(); - str += System.getProperty("line.separator") + "Layer file: " + this.getFileName(); - str += System.getProperty("line.separator") + "Layer type: " + this.getLayerType(); - str += System.getProperty("line.separator") + "Data provider: " + this.defaultProvider; - - return str; - } - // - // - public class WebMapLayerBean { - public WebMapLayerBean(){ - - } - - // - /** - * Get layer type - * - * @return Layer type - */ - public LayerTypes getLayerType() { - return WebMapLayer.this.getLayerType(); - } - - /** - * Get layer draw type - * - * @return Layer draw type - */ - public LayerDrawType getLayerDrawType() { - return WebMapLayer.this.getLayerDrawType(); - } - - /** - * Get layer handle - * - * @return Layer handle - */ - public int getHandle() { - return WebMapLayer.this.getHandle(); - } - - /** - * Get layer name - * - * @return Layer name - */ - public String getLayerName() { - return WebMapLayer.this.getLayerName(); - } - - /** - * Set layer name - * - * @param name Layer name - */ - public void setLayerName(String name) { - WebMapLayer.this.setLayerName(name); - } - - /** - * Get web map provider - * @return The web map provider - */ - public String getWebMapProvider(){ - return WebMapLayer.this.defaultProvider.toString(); - } - - /** - * Set web map provider - * @param provider The web map provider - */ - public void setWebMapProvider(String provider){ - WebMapLayer.this.setWebMapProvider(WebMapProvider.valueOf(provider)); - } - - /** - * Get if is maskout - * - * @return If is maskout - */ - public boolean isMaskout() { - return WebMapLayer.this.isMaskout(); - } - - /** - * Set if maskout - * - * @param value If maskout - */ - public void setMaskout(boolean value) { - WebMapLayer.this.setMaskout(value); - } - - /** - * Get if is visible - * - * @return If is visible - */ - public boolean isVisible() { - return WebMapLayer.this.isVisible(); - } - - /** - * Set if is visible - * - * @param value If is visible - */ - public void setVisible(boolean value) { - WebMapLayer.this.setVisible(value); - } - - /** - * Get language - * @return The language - */ - public String getLanguage(){ - return WebMapLayer.this.getTileFactory().getInfo().getLanguage(); - } - - /** - * Set language - * @param value The language - */ - public void setLanguage(String value) { - WebMapLayer.this.getTileFactory().getInfo().setLanguage(value); - } - - // - } - - public static class WebMapLayerBeanBeanInfo extends BaseBeanInfo { - - public WebMapLayerBeanBeanInfo() { - super(WebMapLayer.WebMapLayerBean.class); - addProperty("layerType").setCategory("Read only").setReadOnly().setDisplayName("Layer type"); - addProperty("layerDrawType").setCategory("Read only").setReadOnly().setDisplayName("Layer draw type"); - addProperty("handle").setCategory("Read only").setReadOnly().setDisplayName("Handle"); - ExtendedPropertyDescriptor e = addProperty("webMapProvider"); - e.setCategory("Editable").setDisplayName("Web Map Provider"); - e.setPropertyEditorClass(WebMapProviderEditor.class); - e = addProperty("language"); - e.setCategory("Editable").setDisplayName("Language"); - e.setPropertyEditorClass(LanguageEditor.class); - addProperty("visible").setCategory("Editable").setDisplayName("Visible"); - addProperty("maskout").setCategory("Editable").setDisplayName("Is maskout"); - } - } - - public static class WebMapProviderEditor extends ComboBoxPropertyEditor { - - public WebMapProviderEditor() { - super(); - WebMapProvider[] providers = WebMapProvider.values(); - String[] types = new String[providers.length]; - int i = 0; - for (WebMapProvider prov : providers) { - types[i] = prov.toString(); - i += 1; - } - setAvailableValues(types); - } - } - - public static class LanguageEditor extends ComboBoxPropertyEditor { - - public LanguageEditor() { - super(); - String[] langs = new String[]{"en-us", "zh-cn"}; - setAvailableValues(langs); - } - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/WorldFilePara.java b/MeteoInfoLib/src/main/java/org/meteoinfo/layer/WorldFilePara.java deleted file mode 100644 index 8303ad0c..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/WorldFilePara.java +++ /dev/null @@ -1,54 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layer; - -/** - * World file parameters - * - * @author Yaqiang Wang - */ -public class WorldFilePara { - // - /// - /// x of up-left - /// - public double xUL; - /// - /// y of up-left - /// - public double yUL; - /// - /// x scale - /// - public double xScale; - /// - /// y scale - /// - public double yScale; - /// - /// x rotate - /// - public double xRotate; - /// - /// y rotate - /// - public double yRotate; - // - // - // - // - // - // - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/FrmPageSet.form b/MeteoInfoLib/src/main/java/org/meteoinfo/layout/FrmPageSet.form deleted file mode 100644 index 642fdea3..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/FrmPageSet.form +++ /dev/null @@ -1,259 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutChart.java b/MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutChart.java deleted file mode 100644 index 3eb65f45..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutChart.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.layout; - -import java.awt.Graphics2D; -import java.awt.geom.Rectangle2D; -import org.meteoinfo.chart.Chart; -import org.meteoinfo.common.PointF; - -/** - * - * @author yaqiang - */ -public class LayoutChart extends LayoutElement { - - // - private Chart chart; - // - // - - /** - * Constructor - */ - public LayoutChart() { - super(); - this.setElementType(ElementType.LayoutChart); - this.setResizeAbility(ResizeAbility.ResizeAll); - this.setWidth(200); - this.setHeight(150); - } - // - // - - /** - * Get chart - * - * @return The chart - */ - public Chart getChart() { - return chart; - } - - /** - * Set chart - * - * @param value The chart - */ - public void setChart(Chart value) { - chart = value; - } - // - // - - @Override - public void paint(Graphics2D g) { - } - - @Override - public void paintOnLayout(Graphics2D g, PointF pageLocation, float zoom) { - if (chart == null) - return; - - PointF aP = pageToScreen(this.getLeft(), this.getTop(), pageLocation, zoom); - Rectangle2D area = new Rectangle2D.Double(aP.X, aP.Y, this.getWidth() * zoom, this.getHeight() * zoom); - chart.draw(g, area); - } - - @Override - public void moveUpdate() { - } - - @Override - public void resizeUpdate() { - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutElement.java b/MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutElement.java deleted file mode 100644 index 3a5778b2..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutElement.java +++ /dev/null @@ -1,371 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layout; - -import org.meteoinfo.common.PointF; -import org.meteoinfo.ui.event.ILocationChangedListener; -import org.meteoinfo.ui.event.ISizeChangedListener; -import org.meteoinfo.ui.event.LocationChangedEvent; -import org.meteoinfo.ui.event.SizeChangedEvent; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import javax.swing.event.EventListenerList; - -/** - * - * @author yaqiang - */ -public abstract class LayoutElement { - // - - public void addLocationChangedListener(ILocationChangedListener listener) { - this._listeners.add(ILocationChangedListener.class, listener); - } - - public void removeLocationChangedListener(ILocationChangedListener listener) { - this._listeners.remove(ILocationChangedListener.class, listener); - } - - public void fireLocationChangedEvent() { - fireLocationChangedEvent(new LocationChangedEvent(this)); - } - - private void fireLocationChangedEvent(LocationChangedEvent event) { - Object[] listeners = _listeners.getListenerList(); - for (int i = 0; i < listeners.length; i = i + 2) { - if (listeners[i] == ILocationChangedListener.class) { - ((ILocationChangedListener) listeners[i + 1]).locationChangedEvent(event); - } - } - } - - public void addSizeChangedListener(ISizeChangedListener listener) { - this._listeners.add(ISizeChangedListener.class, listener); - } - - public void removeSizeChangedListener(ISizeChangedListener listener) { - this._listeners.remove(ISizeChangedListener.class, listener); - } - - public void fireSizeChangedEvent() { - fireSizeChangedEvent(new SizeChangedEvent(this)); - } - - private void fireSizeChangedEvent(SizeChangedEvent event) { - Object[] listeners = _listeners.getListenerList(); - for (int i = 0; i < listeners.length; i = i + 2) { - if (listeners[i] == ISizeChangedListener.class) { - ((ISizeChangedListener) listeners[i + 1]).sizeChangedEvent(event); - } - } - } - // - // - private final EventListenerList _listeners = new EventListenerList(); - private int _left; - private int _top; - private int _width; - private int _height; - private ElementType _elementType; - private Color _foreColor; - private Color _backColor; - private boolean _selected; - private ResizeAbility _resizeAbility; - private boolean _visible = true; - private boolean drawBackColor = false; - // - // - - public LayoutElement() { - _foreColor = Color.black; - _backColor = Color.white; - _selected = false; - _resizeAbility = ResizeAbility.None; - } - // - // - - /** - * Get if visible - * - * @return Boolean - */ - public boolean isVisible() { - return _visible; - } - - /** - * Set if visible - * - * @param istrue Boolean - */ - public void setVisible(boolean istrue) { - _visible = istrue; - } - - /** - * Get left - * - * @return Left - */ - public int getLeft() { - return _left; - } - - /** - * Set left - * - * @param left - */ - public void setLeft(int left) { - _left = left; - this.fireLocationChangedEvent(); - } - - /** - * Get top - * - * @return Top - */ - public int getTop() { - return _top; - } - - /** - * Set top - * - * @param top Top - */ - public void setTop(int top) { - _top = top; - this.fireLocationChangedEvent(); - } - - /** - * Get width - * - * @return Width - */ - public int getWidth() { - return _width; - } - - /** - * Set width - * - * @param width Width - */ - public void setWidth(int width) { - _width = width; - this.fireSizeChangedEvent(); - } - - /** - * Get height - * - * @return Height - */ - public int getHeight() { - return _height; - } - - /** - * Set height - * - * @param height Height - */ - public void setHeight(int height) { - _height = height; - this.fireSizeChangedEvent(); - } - - /** - * Get right - * - * @return Right - */ - public int getRight() { - return _left + _width; - } - - /** - * Get bottom - * - * @return Bottom - */ - public int getBottom() { - return _top + _height; - } - - /** - * Get bounds rectangle - * - * @return Bounds rectangle - */ - public Rectangle getBounds() { - return new Rectangle(_left, _top, _width, _height); - } - - /** - * Get element type - * - * @return The element type - */ - public ElementType getElementType() { - return _elementType; - } - - /** - * Set element type - * - * @param type Element type - */ - public void setElementType(ElementType type) { - _elementType = type; - } - - /** - * Get foreground color - * - * @return Foreground color - */ - public Color getForeColor() { - return _foreColor; - } - - /** - * Set foreground color - * - * @param color Foreground color - */ - public void setForeColor(Color color) { - _foreColor = color; - } - - /** - * Get background color - * - * @return Background color - */ - public Color getBackColor() { - return _backColor; - } - - /** - * Set background color - * - * @param color Background color - */ - public void setBackColor(Color color) { - _backColor = color; - } - - /** - * Get if is selected - * - * @return Boolean - */ - public boolean isSelected() { - return _selected; - } - - /** - * Set if is selected - * - * @param istrue Boolean - */ - public void setSelected(boolean istrue) { - _selected = istrue; - } - - /** - * Get resize ability - * - * @return Resize ability - */ - public ResizeAbility getResizeAbility() { - return _resizeAbility; - } - - /** - * Set resize ability - * - * @param ra Resize ability - */ - public void setResizeAbility(ResizeAbility ra) { - _resizeAbility = ra; - } - - /** - * Get is draw backcolor - * @return Boolean - */ - public boolean isDrawBackColor(){ - return drawBackColor; - } - - /** - * Set is draw backcolor - * @param value Boolean - */ - public void setDrawBackColor(boolean value){ - drawBackColor = value; - } - // - // - - /** - * Paint method - * - * @param g Graphics2D - */ - public abstract void paint(Graphics2D g); - - /** - * Paint on layout method - * - * @param g Grahpics2D - * @param pageLocation Page location - * @param zoom Zoom - */ - public abstract void paintOnLayout(Graphics2D g, PointF pageLocation, float zoom); - - /** - * Move update method - */ - public abstract void moveUpdate(); - - /** - * Resize update method - */ - public abstract void resizeUpdate(); - - /** - * Page to screen - * - * @param pageX Page X - * @param pageY Page Y - * @param pageLocation Page location - * @param zoom Zoom - * @return Screen point - */ - public PointF pageToScreen(float pageX, float pageY, PointF pageLocation, float zoom) { - float x = pageX * zoom + pageLocation.X; - float y = pageY * zoom + pageLocation.Y; - return (new PointF(x, y)); - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutScaleBar.java b/MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutScaleBar.java deleted file mode 100644 index fc64637e..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutScaleBar.java +++ /dev/null @@ -1,730 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layout; - -import com.l2fprod.common.beans.BaseBeanInfo; -import com.l2fprod.common.beans.ExtendedPropertyDescriptor; -import com.l2fprod.common.beans.editor.ComboBoxPropertyEditor; -import org.meteoinfo.common.PointF; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; -import java.awt.geom.Line2D; - -/** - * - * @author Yaqiang Wang - */ -public class LayoutScaleBar extends LayoutElement { -// - - private LayoutMap _layoutMap; - private boolean _antiAlias; - private Font _font; - private ScaleBarType _scaleBarType; - private ScaleBarUnits _unit; - private String _unitText; - private int _numBreaks; - private boolean _drawNeatLine; - private Color _neatLineColor; - private float _neatLineSize; - private boolean _drawScaleText; - private float _yShiftScale = 2.0f; - // - // - - /** - * Constructor - * - * @param layoutMap The layout map - */ - public LayoutScaleBar(LayoutMap layoutMap) { - super(); - this.setElementType(ElementType.LayoutScaleBar); - this.setResizeAbility(ResizeAbility.ResizeAll); - - this.setWidth(200); - this.setHeight(50); - _layoutMap = layoutMap; - _antiAlias = true; - _scaleBarType = ScaleBarType.SCALELINE_1; - _drawNeatLine = false; - _neatLineColor = Color.black; - _neatLineSize = 1; - _font = new Font("Arial", Font.PLAIN, 12); - _unit = ScaleBarUnits.KILOMETERS; - _unitText = "km"; - _numBreaks = 4; - _drawScaleText = false; - } - // - // - - /** - * Get layout map - * - * @return The layout map - */ - public LayoutMap getLayoutMap() { - return _layoutMap; - } - - /** - * Get scale bar type - * - * @return Scale bar type - */ - public ScaleBarType getScaleBarType() { - return _scaleBarType; - } - - /** - * Set scale bar type - * - * @param type Scale bar type - */ - public void setScaleBarType(ScaleBarType type) { - _scaleBarType = type; - } - - /** - * Get if draw neat line - * - * @return If draw neat line - */ - public boolean isDrawNeatLine() { - return _drawNeatLine; - } - - /** - * Set if draw neat line - * - * @param istrue If draw neat line - */ - public void setDrawNeatLine(boolean istrue) { - _drawNeatLine = istrue; - } - - /** - * Get neat line color - * - * @return Neat line color - */ - public Color getNeatLineColor() { - return _neatLineColor; - } - - /** - * Set neat line color - * - * @param color Neat line color - */ - public void setNeatLineColor(Color color) { - _neatLineColor = color; - } - - /** - * Get neat line size - * - * @return Neat line size - */ - public float getNeatLineSize() { - return _neatLineSize; - } - - /** - * Set neat line size - * - * @param size Neat line size - */ - public void setNeatLineSize(float size) { - _neatLineSize = size; - } - - /** - * Get font - * - * @return The font - */ - public Font getFont() { - return _font; - } - - /** - * Set font - * - * @param font The font - */ - public void setFont(Font font) { - _font = font; - } - - /** - * Get break number - * - * @return The break number - */ - public int getBreakNumber() { - return _numBreaks; - } - - /** - * Set break number - * - * @param num Break number - */ - public void setBreakNumber(int num) { - _numBreaks = num; - } - - /** - * Get if draw scale text - * - * @return If draw scale text - */ - public boolean isDrawScaleText() { - return _drawScaleText; - } - - /** - * Set if draw scale text - * - * @param istrue If draw scale text - */ - public void setDrawScaleText(boolean istrue) { - _drawScaleText = istrue; - } - // - // - - @Override - public void paint(Graphics2D g) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void paintOnLayout(Graphics2D g, PointF pageLocation, float zoom) { - if (this.isVisible()) { - paintGraphics(g, pageLocation, zoom); - } - } - - /** - * Paint graphics - * - * @param g Graphics - * @param pageLocation Page location - * @param zoom Zoom - */ - public void paintGraphics(Graphics2D g, PointF pageLocation, float zoom) { - AffineTransform oldMatrix = g.getTransform(); - PointF aP = pageToScreen(this.getLeft(), this.getTop(), pageLocation, zoom); - g.translate(aP.X, aP.Y); - g.scale(zoom, zoom); - if (_antiAlias) { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - } else { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - } - - //Draw background color - if (this.isDrawBackColor()){ - g.setColor(this.getBackColor()); - g.fill(new Rectangle.Float(0, 0, this.getWidth() * zoom, this.getHeight() * zoom)); - } - - drawScaleBar(g, zoom); - - //Draw neatline - if (_drawNeatLine) { - Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1, - (this.getWidth() - _neatLineSize) * zoom, (this.getHeight() - _neatLineSize) * zoom); - g.setColor(_neatLineColor); - g.setStroke(new BasicStroke(_neatLineSize)); - g.draw(mapRect); - } - - g.setTransform(oldMatrix); - } - - private void drawScaleBar(Graphics2D g, float zoom) { - Font aFont = new Font(_font.getFontName(), _font.getStyle(), (int) (_font.getSize() * zoom)); - //Calculates the width of one break in greographic units - FontMetrics metrics = g.getFontMetrics(aFont); - float unitLegnth = metrics.stringWidth(_unitText) * 2; - float widthNoUnit = (this.getWidth() * zoom - unitLegnth); - long geoBreakWidth = (long) (getGeoWidth(widthNoUnit / _numBreaks)); - - //If the geobreakWidth is less than 1 we return and don't draw anything - if (geoBreakWidth < 1) { - return; - } - - double n = Math.pow(10, String.valueOf(geoBreakWidth).length() - 1); - geoBreakWidth = (long) (Math.floor(geoBreakWidth / n) * n); - - long breakWidth = (long) (getWidth(geoBreakWidth)); - FontMetrics metrics1 = g.getFontMetrics(_font); - float fontHeight = metrics1.getHeight() * zoom; - float leftStart = metrics1.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F; - - //Draw scale text - double scale = geoBreakWidth * getConversionFactor(_unit) * 100 / (breakWidth / 96 * 2.539999918) * zoom; - if (_drawScaleText) { - g.setFont(aFont); - g.setColor(this.getForeColor()); - g.drawString("1 : " + String.format("{0:0,0}", scale), - leftStart - (metrics.stringWidth(String.valueOf(Math.abs(0))) / 2), fontHeight * 2.5F); - } - - //Draw scale bar - switch (_scaleBarType) { - case SCALELINE_1: - drawScaleLine1(g, zoom, aFont, breakWidth, geoBreakWidth); - break; - case SCALELINE_2: - drawScaleLine2(g, zoom, aFont, breakWidth, geoBreakWidth); - break; - case ALTERNATING_BAR: - drawAlternatingBar(g, zoom, aFont, breakWidth, geoBreakWidth); - break; - } - } - - private double getConversionFactor(ScaleBarUnits unit) { - switch (unit) { - case KILOMETERS: - return 1000; - default: - return 1; - } - } - - private double getGeoWidth(double width) { - double geoWidth = width / _layoutMap.getMapFrame().getMapView().getXScale() / getConversionFactor(_unit); - if (_layoutMap.getMapFrame().getMapView().getProjection().isLonLatMap()) { - geoWidth = geoWidth * getLonDistScale(); - } - - return geoWidth; - } - - private double getWidth(double geoWidth) { - double width = geoWidth * _layoutMap.getMapFrame().getMapView().getXScale() * getConversionFactor(_unit); - if (_layoutMap.getMapFrame().getMapView().getProjection().isLonLatMap()) { - width = width / getLonDistScale(); - } - - return width; - } - - private double getLonDistScale() { - //Get meters of one longitude degree - double pY = (_layoutMap.getMapFrame().getMapView().getViewExtent().maxY + _layoutMap.getMapFrame().getMapView().getViewExtent().minY) / 2; - double ProjX = 0, ProjY = pY, pProjX = 1, pProjY = pY; - double dx = Math.abs(ProjX - pProjX); - double dy = Math.abs(ProjY - pProjY); - double dist; - double y = (ProjY + pProjY) / 2; - double factor = Math.cos(y * Math.PI / 180); - dx *= factor; - dist = Math.sqrt(dx * dx + dy * dy); - dist = dist * 111319.5; - - return dist; - } - - private void drawScaleLine1(Graphics2D g, float zoom, Font aFont, long breakWidth, long geoBreakWidth) { - FontMetrics metrics = g.getFontMetrics(_font); - float fontHeight = metrics.getHeight() * zoom; - float leftStart = metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F; - int yShift = 10; - - g.setColor(this.getForeColor()); - g.setStroke(new BasicStroke(zoom)); - g.draw(new Line2D.Float(leftStart, fontHeight * 1.6f + yShift, leftStart + (breakWidth * _numBreaks), fontHeight * 1.6f + yShift)); - FontMetrics metrics1 = g.getFontMetrics(aFont); - g.setFont(aFont); - for (int i = 0; i <= _numBreaks; i++) { - g.draw(new Line2D.Float(leftStart, fontHeight * 1.1f + yShift, leftStart, fontHeight * 1.6f + yShift)); - g.drawString(String.valueOf(Math.abs(geoBreakWidth * i)), - leftStart - (metrics1.stringWidth(String.valueOf(Math.abs(geoBreakWidth * i))) / 2), yShift * _yShiftScale); - leftStart = leftStart + breakWidth; - } - g.drawString(_unitText, leftStart - breakWidth + (fontHeight / 2), fontHeight * 1.1f + yShift * _yShiftScale); - } - - private void drawScaleLine2(Graphics2D g, float zoom, Font aFont, long breakWidth, long geoBreakWidth) { - FontMetrics metrics = g.getFontMetrics(_font); - float fontHeight = metrics.getHeight() * zoom; - float leftStart = metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F; - int yShift = 5; - - g.setColor(this.getForeColor()); - g.draw(new Line2D.Float(leftStart, fontHeight * 1.6f + yShift, leftStart + (breakWidth * _numBreaks), fontHeight * 1.6f + yShift)); - FontMetrics metrics1 = g.getFontMetrics(aFont); - g.setFont(aFont); - for (int i = 0; i <= _numBreaks; i++) { - g.draw(new Line2D.Float(leftStart, fontHeight * 1.1f + yShift, leftStart, fontHeight + (fontHeight * 1.1f) + yShift)); - g.drawString(String.valueOf(Math.abs(geoBreakWidth * i)), - leftStart - (metrics1.stringWidth(String.valueOf(Math.abs(geoBreakWidth * i))) / 2), yShift * _yShiftScale); - leftStart = leftStart + breakWidth; - } - g.drawString(_unitText, leftStart - breakWidth + (fontHeight / 2), fontHeight * 1.1f + yShift * _yShiftScale); - } - - private void drawAlternatingBar(Graphics2D g, float zoom, Font aFont, long breakWidth, long geoBreakWidth) { - FontMetrics metrics = g.getFontMetrics(_font); - float fontHeight = metrics.getHeight() * zoom; - float leftStart = metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F; - int yShift = 5; - float rHeight = fontHeight / 2; - FontMetrics metrics1 = g.getFontMetrics(aFont); - - boolean isFill = false; - for (int i = 0; i <= _numBreaks; i++) { - if (i < _numBreaks) { - if (isFill) { - g.setColor(this.getForeColor()); - g.fill(new Rectangle.Float(leftStart, fontHeight * 1.1f + yShift, breakWidth, rHeight)); - } else { - g.setColor(this.getForeColor()); - g.draw(new Rectangle.Float(leftStart, fontHeight * 1.1f + yShift, breakWidth, rHeight)); - } - } - - g.setColor(this.getForeColor()); - g.setFont(aFont); - g.drawString(String.valueOf(Math.abs(geoBreakWidth * i)), - leftStart - (metrics1.stringWidth(String.valueOf(Math.abs(geoBreakWidth * i))) / 2), yShift * _yShiftScale); - leftStart = leftStart + breakWidth; - isFill = !isFill; - } - g.setColor(this.getForeColor()); - g.setFont(aFont); - g.drawString(_unitText, leftStart - breakWidth + (fontHeight / 2), fontHeight * 1.1f + yShift * _yShiftScale); - } - - @Override - public void moveUpdate() { - } - - @Override - public void resizeUpdate() { - } - // - // - - public class LayoutScaleBarBean { - - LayoutScaleBarBean() { - } - // - - /** - * Get scale bar type - * - * @return Scale bar type - */ - public String getScaleBarType() { - return _scaleBarType.toString(); - } - - /** - * Set scale bar type - * - * @param type Scale bar type - */ - public void setScaleBarType(String type) { - _scaleBarType = ScaleBarType.valueOf(type); - } - - /** - * Get if draw neat line - * - * @return If draw neat line - */ - public boolean isDrawNeatLine() { - return _drawNeatLine; - } - - /** - * Set if draw neat line - * - * @param istrue If draw neat line - */ - public void setDrawNeatLine(boolean istrue) { - _drawNeatLine = istrue; - } - - /** - * Get neat line color - * - * @return Neat line color - */ - public Color getNeatLineColor() { - return _neatLineColor; - } - - /** - * Set neat line color - * - * @param color Neat line color - */ - public void setNeatLineColor(Color color) { - _neatLineColor = color; - } - - /** - * Get neat line size - * - * @return Neat line size - */ - public float getNeatLineSize() { - return _neatLineSize; - } - - /** - * Set neat line size - * - * @param size Neat line size - */ - public void setNeatLineSize(float size) { - _neatLineSize = size; - } - - /** - * Get font - * - * @return The font - */ - public Font getFont() { - return _font; - } - - /** - * Set font - * - * @param font The font - */ - public void setFont(Font font) { - _font = font; - } - - /** - * Get break number - * - * @return The break number - */ - public int getBreakNumber() { - return _numBreaks; - } - - /** - * Set break number - * - * @param num Break number - */ - public void setBreakNumber(int num) { - _numBreaks = num; - } - - /** - * Get if draw scale text - * - * @return If draw scale text - */ - public boolean isDrawScaleText() { - return _drawScaleText; - } - - /** - * Set if draw scale text - * - * @param istrue If draw scale text - */ - public void setDrawScaleText(boolean istrue) { - _drawScaleText = istrue; - } - - /** - * Get is draw backcolor - * @return Boolean - */ - public boolean isDrawBackColor(){ - return LayoutScaleBar.this.isDrawBackColor(); - } - - /** - * Set is draw backcolor - * @param value Boolean - */ - public void setDrawBackColor(boolean value){ - LayoutScaleBar.this.setDrawBackColor(value); - } - - /** - * Get background color - * - * @return Background color - */ - public Color getBackColor() { - return LayoutScaleBar.this.getBackColor(); - } - - /** - * Set background color - * - * @param c Background color - */ - public void setBackColor(Color c) { - LayoutScaleBar.this.setBackColor(c); - } - - /** - * Get foreground color - * - * @return Foreground color - */ - public Color getForeColor() { - return LayoutScaleBar.this.getForeColor(); - } - - /** - * Set foreground color - * - * @param c Foreground color - */ - public void setForeColor(Color c) { - LayoutScaleBar.this.setForeColor(c); - } - - /** - * Get left - * - * @return Left - */ - public int getLeft() { - return LayoutScaleBar.this.getLeft(); - } - - /** - * Set left - * - * @param left Left - */ - public void setLeft(int left) { - LayoutScaleBar.this.setLeft(left); - } - - /** - * Get top - * - * @return Top - */ - public int getTop() { - return LayoutScaleBar.this.getTop(); - } - - /** - * Set top - * - * @param top Top - */ - public void setTop(int top) { - LayoutScaleBar.this.setTop(top); - } - - /** - * Get width - * - * @return Width - */ - public int getWidth() { - return LayoutScaleBar.this.getWidth(); - } - - /** - * Set width - * - * @param width Width - */ - public void setWidth(int width) { - LayoutScaleBar.this.setWidth(width); - } - - /** - * Get height - * - * @return Height - */ - public int getHeight() { - return LayoutScaleBar.this.getHeight(); - } - - /** - * Set height - * - * @param height Height - */ - public void setHeight(int height) { - LayoutScaleBar.this.setHeight(height); - } - // - } - - public static class LayoutScaleBarBeanBeanInfo extends BaseBeanInfo { - - public LayoutScaleBarBeanBeanInfo() { - super(LayoutScaleBarBean.class); - ExtendedPropertyDescriptor e = addProperty("scaleBarType"); - e.setCategory("General").setDisplayName("Scale Bar Type"); - e.setPropertyEditorClass(ScaleBarTypeEditor.class); - addProperty("drawBackColor").setCategory("General").setDisplayName("Draw Background"); - addProperty("backColor").setCategory("General").setDisplayName("Background"); - addProperty("foreColor").setCategory("General").setDisplayName("Foreground"); - addProperty("font").setCategory("General").setDisplayName("Font"); - addProperty("drawScaleText").setCategory("General").setDisplayName("Draw Scale Text"); - addProperty("drawNeatLine").setCategory("Neat Line").setDisplayName("Draw Neat Line"); - addProperty("neatLineColor").setCategory("Neat Line").setDisplayName("Neat Line Color"); - addProperty("neatLineSize").setCategory("Neat Line").setDisplayName("Neat Line Size"); - addProperty("left").setCategory("Location").setDisplayName("Left"); - addProperty("top").setCategory("Location").setDisplayName("Top"); - addProperty("width").setCategory("Location").setDisplayName("Width"); - addProperty("height").setCategory("Location").setDisplayName("Height"); - } - } - - public static class ScaleBarTypeEditor extends ComboBoxPropertyEditor { - - public ScaleBarTypeEditor() { - super(); - ScaleBarType[] lutypes = ScaleBarType.values(); - String[] types = new String[lutypes.length]; - int i = 0; - for (ScaleBarType type : lutypes) { - types[i] = type.toString(); - i += 1; - } - setAvailableValues(types); - } - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/MapLayout.java b/MeteoInfoLib/src/main/java/org/meteoinfo/layout/MapLayout.java deleted file mode 100644 index 392c2bc6..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/MapLayout.java +++ /dev/null @@ -1,4445 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layout; - -import com.itextpdf.awt.PdfGraphics2D; -import com.itextpdf.text.DocumentException; -import com.itextpdf.text.pdf.PdfContentByte; -import com.itextpdf.text.pdf.PdfTemplate; -import com.itextpdf.text.pdf.PdfWriter; -import org.meteoinfo.common.MIMath; -import org.meteoinfo.common.PointD; -import org.meteoinfo.common.PointF; -import org.meteoinfo.common.util.GlobalUtil; -import org.meteoinfo.drawing.Draw; -import org.meteoinfo.geometry.legend.*; -import org.meteoinfo.geoprocess.GeoComputation; -import org.meteoinfo.common.colors.ColorUtil; -import org.meteoinfo.ui.event.ActiveMapFrameChangedEvent; -import org.meteoinfo.ui.event.ElementSelectedEvent; -import org.meteoinfo.ui.event.IActiveMapFrameChangedListener; -import org.meteoinfo.ui.event.IElementSelectedListener; -import org.meteoinfo.ui.event.IMapFramesUpdatedListener; -import org.meteoinfo.ui.event.IMapViewUpdatedListener; -import org.meteoinfo.ui.event.IZoomChangedListener; -import org.meteoinfo.ui.event.MapFramesUpdatedEvent; -import org.meteoinfo.ui.event.MapViewUpdatedEvent; -import org.meteoinfo.ui.event.ZoomChangedEvent; -import org.meteoinfo.global.FrmMeasurement; -import org.meteoinfo.global.FrmMeasurement.MeasureTypes; -import org.meteoinfo.global.FrmProperty; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.legend.FrmLabelSymbolSet; -import org.meteoinfo.legend.FrmPointSymbolSet; -import org.meteoinfo.legend.FrmPolygonSymbolSet; -import org.meteoinfo.legend.FrmPolylineSymbolSet; -import org.meteoinfo.legend.GridLabelPosition; -import org.meteoinfo.legend.MapFrame; -import org.meteoinfo.map.FrmIdentifer; -import org.meteoinfo.geometry.shape.CircleShape; -import org.meteoinfo.geometry.shape.CurveLineShape; -import org.meteoinfo.geometry.shape.CurvePolygonShape; -import org.meteoinfo.geometry.shape.EllipseShape; -import org.meteoinfo.geometry.graphic.Graphic; -import org.meteoinfo.geometry.shape.PointShape; -import org.meteoinfo.geometry.shape.PolygonShape; -import org.meteoinfo.geometry.shape.PolylineShape; -import org.meteoinfo.geometry.shape.RectangleShape; -import org.meteoinfo.geometry.shape.ShapeTypes; -import org.meteoinfo.geometry.shape.WindArrow; - -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.AdjustmentEvent; -import java.awt.event.AdjustmentListener; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseMotionAdapter; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.geom.AffineTransform; -import java.awt.image.AffineTransformOp; -import java.awt.image.BufferedImage; -import java.awt.print.PageFormat; -import java.awt.print.Printable; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.imageio.IIOImage; -import javax.imageio.ImageIO; -import javax.imageio.ImageTypeSpecifier; -import javax.imageio.ImageWriteParam; -import javax.imageio.ImageWriter; -import javax.imageio.metadata.IIOMetadata; -import javax.imageio.plugins.jpeg.JPEGImageWriteParam; -import javax.imageio.stream.ImageOutputStream; -import javax.print.DocFlavor; -import javax.print.DocPrintJob; -import javax.print.PrintException; -import javax.print.PrintService; -import javax.print.SimpleDoc; -import javax.print.StreamPrintServiceFactory; -import javax.print.attribute.HashPrintRequestAttributeSet; -import javax.print.attribute.PrintRequestAttributeSet; -import javax.swing.JFrame; -import javax.swing.JMenu; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JScrollBar; -import javax.swing.JSeparator; -import javax.swing.SwingUtilities; -import javax.swing.event.EventListenerList; -import javax.swing.table.DefaultTableModel; -import javax.swing.undo.UndoableEdit; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import org.freehep.graphics2d.VectorGraphics; -import org.freehep.graphicsio.emf.EMFGraphics2D; -import org.freehep.graphicsio.ps.PSGraphics2D; -import org.meteoinfo.data.mapdata.webmap.IWebMapPanel; -import org.meteoinfo.data.mapdata.webmap.TileLoadListener; -import org.meteoinfo.ui.event.IUndoEditListener; -import org.meteoinfo.ui.event.UndoEditEvent; -import org.meteoinfo.image.ImageUtil; -import org.meteoinfo.layer.RasterLayer; -import org.meteoinfo.layer.WebMapLayer; -import org.meteoinfo.map.FrmIdentiferGrid; -import org.meteoinfo.map.MapView; -import org.meteoinfo.geometry.shape.Shape; -import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -/** - * - * @author yaqiang - */ -public class MapLayout extends JPanel implements IWebMapPanel { - - // - private final EventListenerList _listeners = new EventListenerList(); - private final TileLoadListener tileLoadListener = new TileLoadListener(this); - private FrmIdentifer frmIdentifier = null; - private FrmIdentiferGrid frmIdentifierGrid = null; - private FrmMeasurement _frmMeasure = null; - private JScrollBar _vScrollBar; - private JScrollBar _hScrollBar; - private boolean _lockViewUpdate = false; - private List _mapFrames = new ArrayList<>(); - private final List _layoutElements = new ArrayList<>(); - private LayoutMap _currentLayoutMap; - private BufferedImage _layoutBitmap = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB); - private BufferedImage _tempImage = null; - private boolean newPaint = false; - private boolean doubleBuffer = true; - private boolean _antiAlias = false; - private FrmLabelSymbolSet _frmLabelSymbolSet = null; - private FrmPointSymbolSet _frmPointSymbolSet = null; - private FrmPolylineSymbolSet _frmPolylineSymbolSet = null; - private FrmPolygonSymbolSet _frmPolygonSymbolSet = null; - private Rectangle _pageBounds; - private Color _pageForeColor = Color.black; - private Color _pageBackColor = Color.white; - private PaperSize _paperSize = new PaperSize(); - private final List _paperSizeList = new ArrayList<>(); - private boolean _isLandscape; - private float _zoom = 1.0f; - private PointF _pageLocation = new PointF(0, 0); - private PointBreak _defPointBreak = new PointBreak(); - private LabelBreak _defLabelBreak = new LabelBreak(); - private PolylineBreak _defPolylineBreak = new PolylineBreak(); - private PolygonBreak _defPolygonBreak = new PolygonBreak(); - private final int _xShift = 0; - private final int _yShift = 0; - private MouseMode _mouseMode = MouseMode.Default; - private List _selectedElements = new ArrayList<>(); - private Rectangle _selectedRectangle = new Rectangle(); - private final Point _mouseDownPos = new Point(0, 0); - private Point _mouseLastPos = new Point(0, 0); - private final Point _mouseDownPoint = new Point(0, 0); - private Edge _resizeSelectedEdge = Edge.None; - private boolean _startNewGraphic = true; - private List _graphicPoints = new ArrayList<>(); - private final List _editingVertices = new ArrayList<>(); - private int _editingVerticeIndex; - private boolean _dragMode = false; - // - - // - public MapLayout() { - super(); - this.setLayout(new BorderLayout()); - initComponents(); - - this.addComponentListener(new ComponentAdapter() { - @Override - public void componentResized(ComponentEvent e) { - onComponentResized(e); - } - }); - this.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - try { - onMouseClicked(e); - } catch (CloneNotSupportedException ex) { - Logger.getLogger(MapLayout.class.getName()).log(Level.SEVERE, null, ex); - } - } - - @Override - public void mousePressed(MouseEvent e) { - onMousePressed(e); - } - - @Override - public void mouseReleased(MouseEvent e) { - try { - onMouseReleased(e); - } catch (CloneNotSupportedException ex) { - Logger.getLogger(MapLayout.class.getName()).log(Level.SEVERE, null, ex); - } - } - }); - this.addMouseMotionListener(new MouseMotionAdapter() { - @Override - public void mouseMoved(MouseEvent e) { - onMouseMoved(e); - } - - @Override - public void mouseDragged(MouseEvent e) { - onMouseDragged(e); - } - }); -// this.addMouseWheelListener(new MouseWheelListener() { -// @Override -// public void mouseWheelMoved(MouseWheelEvent e) { -// onMouseWheelMoved(e); -// } -// }); - this.addKeyListener(new KeyListener() { - @Override - public void keyTyped(KeyEvent e) { - } - - @Override - public void keyPressed(KeyEvent e) { - onKeyPressed(e); - } - - @Override - public void keyReleased(KeyEvent e) { - } - }); - - this.setBackground(Color.lightGray); - this.setForeground(Color.black); - //Set page - PaperSize aPS = new PaperSize("A4", 827, 1169); - _paperSizeList.add(aPS); - aPS = new PaperSize("Letter", 850, 1100); - _paperSizeList.add(aPS); - aPS = new PaperSize("A5", 583, 827); - _paperSizeList.add(aPS); - aPS = new PaperSize("Custom", 500, 750); - _paperSizeList.add(aPS); - _isLandscape = true; - - //Set default size - _pageBounds = new Rectangle(); - _pageBounds.x = 0; - _pageBounds.y = 0; - _pageBounds.width = 730; - _pageBounds.height = 480; - _zoom = 1.0F; - this.setPaperSize(aPS); - - //Add a default map frame - MapFrame aMF = new MapFrame(); - aMF.setActive(true); - aMF.setLayoutBounds(new Rectangle(40, 36, 606, 420)); - _mapFrames.add(aMF); - LayoutMap layoutMap = new LayoutMap(aMF, this.tileLoadListener); - this.addElement(layoutMap); - - _defPointBreak.setSize(10); - _defLabelBreak.setText("Text"); - _defLabelBreak.setFont(new Font(GlobalUtil.getDefaultFontName(), Font.PLAIN, 12)); - _defPolylineBreak.setColor(Color.red); - _defPolylineBreak.setWidth(2); - _defPolygonBreak.setColor(new Color(104, 255, 104, 125)); - } - - private void initComponents() { - _vScrollBar = new JScrollBar(JScrollBar.VERTICAL); - _vScrollBar.addAdjustmentListener(new AdjustmentListener() { - @Override - public void adjustmentValueChanged(AdjustmentEvent e) { - onScrollValueChanged(e); - } - }); - this.add(_vScrollBar, BorderLayout.EAST); - - _hScrollBar = new JScrollBar(JScrollBar.HORIZONTAL); - _hScrollBar.addAdjustmentListener(new AdjustmentListener() { - @Override - public void adjustmentValueChanged(AdjustmentEvent e) { - onScrollValueChanged(e); - } - }); - this.add(_hScrollBar, BorderLayout.SOUTH); - - this._vScrollBar.setLocation(this.getWidth() - this._vScrollBar.getWidth(), 0); - if (this._hScrollBar.isVisible()) { - this._vScrollBar.setSize(21, this.getHeight() - 21); - } else { - this._vScrollBar.setSize(21, this.getHeight()); - } - - this._hScrollBar.setLocation(0, this.getHeight() - this._hScrollBar.getHeight()); - if (this._vScrollBar.isVisible()) { - this._hScrollBar.setSize(this.getWidth() - 21, 21); - } else { - this._hScrollBar.setSize(this.getWidth(), 21); - } - } - // - - // - public void addMapFramesUpdatedListener(IMapFramesUpdatedListener listener) { - this._listeners.add(IMapFramesUpdatedListener.class, listener); - } - - public void removeMapFramesUpdatedListener(IMapFramesUpdatedListener listener) { - this._listeners.remove(IMapFramesUpdatedListener.class, listener); - } - - public void fireMapFramesUpdatedEvent() { - fireMapFramesUpdatedEvent(new MapFramesUpdatedEvent(this)); - } - - private void fireMapFramesUpdatedEvent(MapFramesUpdatedEvent event) { - Object[] listeners = _listeners.getListenerList(); - for (int i = 0; i < listeners.length; i = i + 2) { - if (listeners[i] == IMapFramesUpdatedListener.class) { - ((IMapFramesUpdatedListener) listeners[i + 1]).mapFramesUpdatedEvent(event); - } - } - } - - public void addActiveMapFrameChangedListener(IActiveMapFrameChangedListener listener) { - this._listeners.add(IActiveMapFrameChangedListener.class, listener); - } - - public void removeActiveMapFrameChangedListener(IActiveMapFrameChangedListener listener) { - this._listeners.remove(IActiveMapFrameChangedListener.class, listener); - } - - public void fireActiveMapFrameChangedEvent() { - fireActiveMapFrameChangedEvent(new ActiveMapFrameChangedEvent(this)); - } - - private void fireActiveMapFrameChangedEvent(ActiveMapFrameChangedEvent event) { - Object[] listeners = _listeners.getListenerList(); - for (int i = 0; i < listeners.length; i = i + 2) { - if (listeners[i] == IActiveMapFrameChangedListener.class) { - ((IActiveMapFrameChangedListener) listeners[i + 1]).activeMapFrameChangedEvent(event); - } - } - } - - public void addElementSelectedListener(IElementSelectedListener listener) { - this._listeners.add(IElementSelectedListener.class, listener); - } - - public void removeElementSelectedListener(IElementSelectedListener listener) { - this._listeners.remove(IElementSelectedListener.class, listener); - } - - public void fireElementSelectedEvent() { - fireElementSelectedEvent(new ElementSelectedEvent(this)); - } - - private void fireElementSelectedEvent(ElementSelectedEvent event) { - Object[] listeners = _listeners.getListenerList(); - for (int i = 0; i < listeners.length; i = i + 2) { - if (listeners[i] == IElementSelectedListener.class) { - ((IElementSelectedListener) listeners[i + 1]).elementSelectedEvent(event); - } - } - } - - public void addZoomChangedListener(IZoomChangedListener listener) { - this._listeners.add(IZoomChangedListener.class, listener); - } - - public void removeZoomChangedListener(IZoomChangedListener listener) { - this._listeners.remove(IZoomChangedListener.class, listener); - } - - public void fireZoomChangedEvent() { - fireZoomChangedEvent(new ZoomChangedEvent(this)); - } - - private void fireZoomChangedEvent(ZoomChangedEvent event) { - Object[] listeners = _listeners.getListenerList(); - for (int i = 0; i < listeners.length; i = i + 2) { - if (listeners[i] == IZoomChangedListener.class) { - ((IZoomChangedListener) listeners[i + 1]).zoomChangedEvent(event); - } - } - } - - public void addUndoEditListener(IUndoEditListener listener) { - this._listeners.add(IUndoEditListener.class, listener); - } - - public void removeUndoEditListener(IUndoEditListener listener) { - this._listeners.remove(IUndoEditListener.class, listener); - } - - public void fireUndoEditEvent(UndoableEdit undoEdit) { - fireUndoEditEvent(new UndoEditEvent(this), undoEdit); - } - - private void fireUndoEditEvent(UndoEditEvent event, UndoableEdit undoEdit) { - Object[] listeners = _listeners.getListenerList(); - for (int i = 0; i < listeners.length; i = i + 2) { - if (listeners[i] == IUndoEditListener.class) { - ((IUndoEditListener) listeners[i + 1]).undoEditEvent(event, undoEdit); - } - } - } - - public void onScrollValueChanged(AdjustmentEvent e) { - if (e.getSource() == _vScrollBar) { - //_vScrollBar.setValue(e.getValue()); - //this._yShift = - this._vScrollBar.getValue(); - int y = -e.getValue(); - if (y == 1) { - y = 0; - } - this._pageLocation.Y = y; - } - if (e.getSource() == _hScrollBar) { - //_hScrollBar.setValue(e.getValue()); - //this._xShift = - this._hScrollBar.getValue(); - int x = -e.getValue(); - if (x == 1) { - x = 0; - } - this._pageLocation.X = x; - } - //this.paintGraphics(); - this.repaintNew(); - //this.repaint(); - } - - void onComponentResized(ComponentEvent e) { - if (this.getWidth() > 0 && this.getHeight() > 0) { - this._vScrollBar.setLocation(this.getWidth() - this._vScrollBar.getWidth(), 0); - if (this._hScrollBar.isVisible()) { - this._vScrollBar.setSize(this._vScrollBar.getWidth(), this.getHeight() - this._vScrollBar.getWidth()); - } else { - this._vScrollBar.setSize(this._vScrollBar.getWidth(), this.getHeight()); - } - - this._hScrollBar.setLocation(0, this.getHeight() - this._hScrollBar.getHeight()); - if (this._vScrollBar.isVisible()) { - this._hScrollBar.setSize(this.getWidth() - this._hScrollBar.getHeight(), this._hScrollBar.getHeight()); - } else { - this._hScrollBar.setSize(this.getWidth(), this._hScrollBar.getHeight()); - } - - //this.paintGraphics(); - this.repaintNew(); - } - } - - void onMousePressed(MouseEvent e) { - if (e.getButton() == MouseEvent.BUTTON1) { - //int left = e.getX(); - //int top = e.getY(); - Point pageP = screenToPage(e.getX(), e.getY()); - Graphics2D g = (Graphics2D) this.getGraphics(); - LayoutMap aLM = getLayoutMap(pageP); - if (aLM != null) { - _currentLayoutMap = aLM; - } - - switch (_mouseMode) { - case Map_Pan: - Rectangle mapRect = pageToScreen(_currentLayoutMap.getBounds()); - _tempImage = new BufferedImage(mapRect.width - 2, - mapRect.height - 2, BufferedImage.TYPE_INT_ARGB); - Graphics2D tg = _tempImage.createGraphics(); - tg.setColor(_currentLayoutMap.getMapFrame().getMapView().getBackground()); - tg.fill(mapRect); - tg.drawImage(_layoutBitmap, -mapRect.x - 1, -mapRect.y - 1, this); - tg.dispose(); - break; - case Select: - List tempGraphics = selectElements(pageP, _selectedElements, 3); - if (tempGraphics.size() > 0) { - _selectedRectangle = (Rectangle) _selectedElements.get(0).getBounds().clone(); - _selectedRectangle = pageToScreen(_selectedRectangle); - if (_resizeSelectedEdge == Edge.None) { - _mouseMode = MouseMode.MoveSelection; - } else { - _mouseMode = MouseMode.ResizeSelected; - } - } else { - _mouseMode = MouseMode.CreateSelection; - } - - break; - case New_Point: - PointShape aPS = new PointShape(); - aPS.setPoint(new PointD(pageP.x, pageP.y)); - Graphic aGraphic = new Graphic(aPS, (PointBreak) _defPointBreak.clone()); - LayoutGraphic aLayoutGraphic = new LayoutGraphic(aGraphic, this); - addElement(aLayoutGraphic); - //this.paintGraphics(); - this.repaintNew(); - UndoableEdit edit = (new MapLayoutUndoRedo()).new AddElementEdit(this, aLayoutGraphic); - this.fireUndoEditEvent(edit); - break; - case New_Label: - aPS = new PointShape(); - aPS.setPoint(new PointD(pageP.x, pageP.y)); - aGraphic = new Graphic(aPS, (LabelBreak) _defLabelBreak.clone()); - aLayoutGraphic = new LayoutGraphic(aGraphic, this); - addElement(aLayoutGraphic); - //this.paintGraphics(); - this.repaintNew(); - edit = (new MapLayoutUndoRedo()).new AddElementEdit(this, aLayoutGraphic); - this.fireUndoEditEvent(edit); - break; - case New_Polyline: - case New_Polygon: - case New_Curve: - case New_CurvePolygon: - case New_Freehand: - case Map_SelectFeatures_Polygon: - case Map_SelectFeatures_Lasso: - if (_startNewGraphic) { - _graphicPoints = new ArrayList<>(); - _startNewGraphic = false; - } - _graphicPoints.add(new PointF(e.getX(), e.getY())); - break; - case EditVertices: - if (_selectedElements.size() > 0) { - _editingVerticeIndex = selectEditVertices(pageP, ((LayoutGraphic) _selectedElements.get(0)).getGraphic().getShape(), - _editingVertices); - if (_editingVerticeIndex >= 0) { - _mouseMode = MouseMode.InEditingVertices; - } - } - break; - case Map_Measurement: - if (_frmMeasure == null) { - break; - } - if (_frmMeasure.isVisible()) { - switch (_frmMeasure.getMeasureType()) { - case Length: - case Area: - if (_startNewGraphic) { - _graphicPoints = new ArrayList<>(); - _startNewGraphic = false; - } - _frmMeasure.setPreviousValue(_frmMeasure.getTotalValue()); - _graphicPoints.add(new PointF(e.getX(), e.getY())); - break; - case Feature: - MapLayer aMLayer = _currentLayoutMap.getMapFrame().getMapView().getSelectedLayer(); - if (aMLayer != null) { - if (aMLayer.getLayerType() == LayerTypes.VectorLayer) { - VectorLayer aLayer = (VectorLayer) aMLayer; - if (aLayer.getShapeType() != ShapeTypes.Point) { - PointF mapP = pageToScreen(_currentLayoutMap.getLeft(), _currentLayoutMap.getTop()); - PointF aPoint = new PointF(e.getX() - mapP.X, e.getY() - mapP.Y); - List selectedShapes = _currentLayoutMap.getMapFrame().getMapView().selectShapes(aLayer, aPoint); - if (selectedShapes.size() > 0) { - int shapeIdx = selectedShapes.get(0); - org.meteoinfo.geometry.shape.Shape aShape = aLayer.getShapes().get(shapeIdx); - aLayer.setIdentiferShape(shapeIdx); - _currentLayoutMap.getMapFrame().getMapView().setDrawIdentiferShape(true); - //this.repaint(); - this.repaintOld(); - //_currentLayoutMap.getMapFrame().getMapView().drawIdShape((Graphics2D) this.getGraphics(), aLayer.getShapes().get(shapeIdx), rect); - double value = 0.0; - switch (aShape.getShapeType()) { - case Polyline: - case PolylineZ: - _frmMeasure.setArea(false); - if (_currentLayoutMap.getMapFrame().getMapView().getProjection().isLonLatMap()) { - value = GeoComputation.getDistance(((PolylineShape) aShape).getPoints(), true); - } else { - value = ((PolylineShape) aShape).getLength(); - value *= _currentLayoutMap.getMapFrame().getMapView().getProjection().getProjInfo().getCoordinateReferenceSystem().getProjection().getFromMetres(); - } - break; - case Polygon: - case PolygonM: - case PolygonZ: - _frmMeasure.setArea(true); - if (_currentLayoutMap.getMapFrame().getMapView().getProjection().isLonLatMap()) { - value = ((PolygonShape) aShape).getSphericalArea(); - } else { - value = ((PolygonShape) aShape).getArea(); - } - value *= _currentLayoutMap.getMapFrame().getMapView().getProjection().getProjInfo().getCoordinateReferenceSystem().getProjection().getFromMetres() - * _currentLayoutMap.getMapFrame().getMapView().getProjection().getProjInfo().getCoordinateReferenceSystem().getProjection().getFromMetres(); - break; - } - _frmMeasure.setCurrentValue(value); - } - } - } - } - break; - } - } - break; - } - } else if (e.getButton() == MouseEvent.BUTTON3) { - switch (_mouseMode) { - case Map_Measurement: - if (_frmMeasure.isVisible()) { - switch (_frmMeasure.getMeasureType()) { - case Length: - case Area: - _startNewGraphic = true; - _frmMeasure.setTotalValue(0); - break; - } - } - break; - } - } - - _mouseDownPoint.x = e.getX(); - _mouseDownPoint.y = e.getY(); - _mouseLastPos = new Point(_mouseDownPoint.x, _mouseDownPoint.y); - } - - void onMouseDragged(MouseEvent e) { - _dragMode = true; - int deltaX = e.getX() - _mouseLastPos.x; - int deltaY = e.getY() - _mouseLastPos.y; - _mouseLastPos.x = e.getX(); - _mouseLastPos.y = e.getY(); - - Point pageP = screenToPage(e.getX(), e.getY()); - - Graphics2D g = (Graphics2D) this.getGraphics(); - //Pen aPen = new Pen(Color.Red); - //aPen.DashStyle = DashStyle.Dash; - //Rectangle rect = new Rectangle(); - _vScrollBar.setCursor(Cursor.getDefaultCursor()); - _hScrollBar.setCursor(Cursor.getDefaultCursor()); - //this.setCursor(Cursor.getDefaultCursor()); - - switch (_mouseMode) { - case Map_ZoomIn: - if (isInLayoutMaps(pageP)) { - this.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(Toolkit.getDefaultToolkit(). - getImage(this.getClass().getResource("/images/zoom_in_32x32x32.png")), new Point(8, 8), "Zoom In")); - - //this.repaint(); - this.repaintOld(); - } - break; - case Map_Pan: - if (isInLayoutMaps(pageP)) { - this.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(Toolkit.getDefaultToolkit(). - getImage(this.getClass().getResource("/images/Pan_Open_32x32x32.png")), new Point(8, 8), "Pan")); - - Rectangle mapRect = pageToScreen(_currentLayoutMap.getBounds()); - g.setClip(mapRect); - Color aColor = _currentLayoutMap.getMapFrame().getBackColor(); - if (aColor.getAlpha() == 255) { - aColor = Color.white; - } - g.setColor(aColor); - int aX = e.getX() - _mouseDownPoint.x; - int aY = e.getY() - _mouseDownPoint.y; - aX = (int) (aX / _zoom); - aY = (int) (aY / _zoom); - if (aX > 0) { - if (mapRect.x >= 0) { - g.fillRect(mapRect.x, mapRect.y, aX, mapRect.height); - } else { - g.fillRect(0, mapRect.y, aX, mapRect.height); - } - } else { - if (mapRect.x <= this.getWidth()) { - g.fillRect(mapRect.x + mapRect.width + aX, mapRect.y, Math.abs(aX), mapRect.height); - } else { - g.fillRect(this.getWidth() + aX, mapRect.y, Math.abs(aX), mapRect.height); - } - } - if (aY > 0) { - if (mapRect.y >= 0) { - g.fillRect(mapRect.x, mapRect.y, mapRect.width, aY); - } else { - g.fillRect(mapRect.x, 0, mapRect.width, aY); - } - } else { - if (mapRect.y + mapRect.height <= this.getX() + this.getHeight()) { - g.fillRect(mapRect.x, mapRect.y + mapRect.height + aY, mapRect.width, Math.abs(aY)); - } else { - g.fillRect(mapRect.x, this.getY() + this.getHeight() + aY, mapRect.width, Math.abs(aY)); - } - } - int startX = mapRect.x + aX; - int startY = mapRect.y + aY; - AffineTransformOp aop = new AffineTransformOp(new AffineTransform(), AffineTransformOp.TYPE_BILINEAR); - g.drawImage(_tempImage, aop, startX, startY); - //g.drawImage(_tempImage, startX, startY, this); - g.setColor(this.getForeground()); - g.draw(mapRect); - } - break; - case Map_SelectFeatures_Rectangle: - //this.repaint(); - this.repaintOld(); - break; - case MoveSelection: - this.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); - //this.repaint(); - this.repaintOld(); - break; - case ResizeSelected: - LayoutElement oElement = _selectedElements.get(0); - switch (oElement.getResizeAbility()) { - case SameWidthHeight: - switch (_resizeSelectedEdge) { - case TopLeft: - _selectedRectangle.x += deltaX; - _selectedRectangle.y += deltaX; - _selectedRectangle.width -= deltaX; - _selectedRectangle.height -= deltaX; - break; - case BottomRight: - _selectedRectangle.width += deltaX; - _selectedRectangle.height += deltaX; - break; - case TopRight: - _selectedRectangle.y += deltaY; - _selectedRectangle.width -= deltaY; - _selectedRectangle.height -= deltaY; - break; - case BottomLeft: - _selectedRectangle.x += deltaX; - _selectedRectangle.width -= deltaX; - _selectedRectangle.height -= deltaX; - break; - } - break; - case ResizeAll: - switch (_resizeSelectedEdge) { - case TopLeft: - _selectedRectangle.x += deltaX; - _selectedRectangle.y += deltaY; - _selectedRectangle.width -= deltaX; - _selectedRectangle.height -= deltaY; - break; - case BottomRight: - _selectedRectangle.width += deltaX; - _selectedRectangle.height += deltaY; - break; - case Top: - _selectedRectangle.y += deltaY; - _selectedRectangle.height -= deltaY; - break; - case Bottom: - _selectedRectangle.height += deltaY; - break; - case TopRight: - _selectedRectangle.y += deltaY; - _selectedRectangle.width += deltaX; - _selectedRectangle.height -= deltaY; - break; - case BottomLeft: - _selectedRectangle.x += deltaX; - _selectedRectangle.width -= deltaX; - _selectedRectangle.height += deltaY; - break; - case Left: - _selectedRectangle.x += deltaX; - _selectedRectangle.width -= deltaX; - break; - case Right: - _selectedRectangle.width += deltaX; - break; - } - break; - } - //this.repaint(); - this.repaintOld(); - break; - case New_Rectangle: - case New_Ellipse: - case New_Freehand: - case New_Circle: - case Map_SelectFeatures_Polygon: - case Map_SelectFeatures_Lasso: - case Map_SelectFeatures_Circle: - //this.repaint(); - this.repaintOld(); - break; - case InEditingVertices: - //this.repaint(); - this.repaintOld(); - break; - } - } - - void onMouseMoved(MouseEvent e) { - //int deltaX = e.getX() - _mouseLastPos.x; - //int deltaY = e.getY() - _mouseLastPos.y; - _mouseLastPos.x = e.getX(); - _mouseLastPos.y = e.getY(); - - Point pageP = screenToPage(e.getX(), e.getY()); - - Graphics2D g = (Graphics2D) this.getGraphics(); - //Pen aPen = new Pen(Color.Red); - //aPen.DashStyle = DashStyle.Dash; - //Rectangle rect = new Rectangle(); - _vScrollBar.setCursor(Cursor.getDefaultCursor()); - _hScrollBar.setCursor(Cursor.getDefaultCursor()); - //this.setCursor(Cursor.getDefaultCursor()); - - switch (_mouseMode) { - case Map_ZoomIn: - if (isInLayoutMaps(pageP)) { - this.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(Toolkit.getDefaultToolkit(). - getImage(this.getClass().getResource("/images/zoom_in_32x32x32.png")), new Point(8, 8), "Zoom In")); - } - break; - case Map_ZoomOut: - if (isInLayoutMaps(pageP)) { - this.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(Toolkit.getDefaultToolkit(). - getImage(this.getClass().getResource("/images/zoom_out_32x32x32.png")), new Point(8, 8), "Zoom Out")); - } - break; - case Map_Pan: - if (isInLayoutMaps(pageP)) { - this.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(Toolkit.getDefaultToolkit(). - getImage(this.getClass().getResource("/images/Pan_Open_32x32x32.png")), new Point(8, 8), "Pan")); - } - break; - case Map_Identifer: - if (isInLayoutMaps(pageP)) { - this.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(Toolkit.getDefaultToolkit(). - getImage(this.getClass().getResource("/images/identifer_32x32x32.png")), new Point(8, 8), "Identifer")); - } - break; - case Map_SelectFeatures_Rectangle: - //case Map_SelectFeatures_Polygon: - //case Map_SelectFeatures_Lasso: - //case Map_SelectFeatures_Circle: - if (isInLayoutMaps(pageP)) { - this.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); - } - break; - case Select: - if (_selectedElements.size() > 0) { - List tempElements = selectElements(pageP, _selectedElements, 3); - if (tempElements.size() > 0) { - //Change mouse cursor - Rectangle aRect = (Rectangle) _selectedElements.get(0).getBounds().clone(); - _resizeSelectedEdge = intersectElementEdge(aRect, new PointF(pageP.x, pageP.y), 3F); - switch (_selectedElements.get(0).getResizeAbility()) { - case SameWidthHeight: - switch (_resizeSelectedEdge) { - case TopLeft: - case BottomRight: - this.setCursor(Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR)); - break; - case TopRight: - case BottomLeft: - this.setCursor(Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR)); - break; - default: - this.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); - break; - } - break; - case ResizeAll: - switch (_resizeSelectedEdge) { - case TopLeft: - case BottomRight: - this.setCursor(Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR)); - break; - case Top: - case Bottom: - this.setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR)); - break; - case TopRight: - case BottomLeft: - this.setCursor(Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR)); - break; - case Left: - case Right: - this.setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); - break; - case None: - this.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); - break; - } - break; - default: - this.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); - break; - } - } else { - this.setCursor(Cursor.getDefaultCursor()); - } - } else { - this.setCursor(Cursor.getDefaultCursor()); - } - - break; - case MoveSelection: - break; - case ResizeSelected: - break; - case New_Polyline: - case New_Polygon: - case New_Curve: - case New_CurvePolygon: - case Map_SelectFeatures_Polygon: - if (!_startNewGraphic) { - //this.repaint(); - this.repaintOld(); - } - break; - case EditVertices: - if (_selectedElements.size() > 0) { - _editingVerticeIndex = selectEditVertices(pageP, ((LayoutGraphic) _selectedElements.get(0)).getGraphic().getShape(), - _editingVertices); - Toolkit toolkit = Toolkit.getDefaultToolkit(); - if (_editingVerticeIndex >= 0) { - this.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(Toolkit.getDefaultToolkit(). - getImage(this.getClass().getResource("/images/VertexEdit_32x32x32.png")), new Point(8, 8), "Vertices edit")); - } else { - Image image = toolkit.getImage(this.getClass().getResource("/images/Edit_tool.png")); - this.setCursor(toolkit.createCustomCursor(image, new Point(2, 2), "Edit Tool")); - } - } - break; - case Map_Measurement: - if (isInLayoutMaps(pageP)) { - this.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); - } - - if (_frmMeasure == null) { - break; - } - if (_frmMeasure.isVisible()) { - switch (_frmMeasure.getMeasureType()) { - case Length: - case Area: - if (!_startNewGraphic) { - //Draw graphic - //g.SmoothingMode = SmoothingMode.AntiAlias; - //this.repaint(); - this.repaintOld(); - PointF[] fpoints = (PointF[]) _graphicPoints.toArray(new PointF[_graphicPoints.size()]); - PointF[] points = new PointF[fpoints.length + 1]; - System.arraycopy(fpoints, 0, points, 0, fpoints.length); - points[_graphicPoints.size()] = new PointF(e.getX(), e.getY()); - - //Calculate - PointF mapP = pageToScreen(_currentLayoutMap.getLeft(), _currentLayoutMap.getTop()); - PointF aPoint = new PointF(e.getX() - mapP.X, e.getY() - mapP.Y); - float[] pXY = _currentLayoutMap.getMapFrame().getMapView().screenToProj(aPoint.X, aPoint.Y); - if (_frmMeasure.getMeasureType() == MeasureTypes.Length) { - aPoint = new PointF(_mouseDownPoint.x - mapP.X, _mouseDownPoint.y - mapP.Y); - float[] pPXY = _currentLayoutMap.getMapFrame().getMapView().screenToProj(aPoint.X, aPoint.Y); - double dx = Math.abs(pXY[0] - pPXY[0]); - double dy = Math.abs(pXY[1] - pPXY[1]); - double dist; - if (_currentLayoutMap.getMapFrame().getMapView().getProjection().isLonLatMap()) { - double y = (pXY[1] + pPXY[1]) / 2; - double factor = Math.cos(y * Math.PI / 180); - dx *= factor; - dist = Math.sqrt(dx * dx + dy * dy); - dist = dist * 111319.5; - } else { - dist = Math.sqrt(dx * dx + dy * dy); - dist *= _currentLayoutMap.getMapFrame().getMapView().getProjection().getProjInfo().getCoordinateReferenceSystem().getProjection().getFromMetres(); - } - - _frmMeasure.setCurrentValue(dist); - } else { - List mPoints = new ArrayList<>(); - for (int i = 0; i < points.length; i++) { - aPoint = new PointF(points[i].X - mapP.X, points[i].Y - mapP.Y); - pXY = _currentLayoutMap.getMapFrame().getMapView().screenToProj(aPoint.X, aPoint.Y); - mPoints.add(new PointD(pXY[0], pXY[1])); - } - double area = GeoComputation.getArea(mPoints); - if (_currentLayoutMap.getMapFrame().getMapView().getProjection().isLonLatMap()) { - area = area * 111319.5 * 111319.5; - } else { - area *= _currentLayoutMap.getMapFrame().getMapView().getProjection().getProjInfo().getCoordinateReferenceSystem().getProjection().getFromMetres() - * _currentLayoutMap.getMapFrame().getMapView().getProjection().getProjInfo().getCoordinateReferenceSystem().getProjection().getFromMetres(); - } - _frmMeasure.setCurrentValue(area); - } - } - break; - } - } - break; - } - } - - void onMouseReleased(MouseEvent e) throws CloneNotSupportedException { - _dragMode = false; - double MinX, MaxX, MinY, MaxY, ZoomF; - Point pageP = screenToPage(e.getX(), e.getY()); - switch (_mouseMode) { - case Map_ZoomIn: - MinX = Math.min(e.getX(), _mouseDownPoint.x); - MinY = Math.min(e.getY(), _mouseDownPoint.y); - MaxX = Math.max(e.getX(), _mouseDownPoint.x); - MaxY = Math.max(e.getY(), _mouseDownPoint.y); - if (MaxX - MinX < 5) { - if (e.getButton() == MouseEvent.BUTTON1) { - ZoomF = 0.75; - } else { - ZoomF = 1.5; - } - MinX = pageP.x - (_currentLayoutMap.getWidth() / 2 * ZoomF); - MaxX = pageP.x + (_currentLayoutMap.getWidth() / 2 * ZoomF); - MinY = pageP.y - (_currentLayoutMap.getHeight() / 2 * ZoomF); - MaxY = pageP.y + (_currentLayoutMap.getHeight() / 2 * ZoomF); - } else { - PointF minP = screenToPage((float) MinX, (float) MinY); - PointF maxP = screenToPage((float) MaxX, (float) MaxY); - MinX = minP.X; - MinY = minP.Y; - MaxX = maxP.X; - MaxY = maxP.Y; - } - - MinX -= _currentLayoutMap.getLeft(); - MinY -= _currentLayoutMap.getTop(); - MaxX -= _currentLayoutMap.getLeft(); - MaxY -= _currentLayoutMap.getTop(); - if (MaxX - MinX > 0.001) { - _currentLayoutMap.getMapFrame().getMapView().zoomToExtentScreen(MinX, MaxX, MinY, MaxY, _zoom); - } - break; - case Map_ZoomOut: - if (e.getButton() == MouseEvent.BUTTON1) { - ZoomF = 1.5; - } else { - ZoomF = 0.75; - } - MinX = pageP.x - (_currentLayoutMap.getWidth() / 2 * ZoomF); - MaxX = pageP.x + (_currentLayoutMap.getWidth() / 2 * ZoomF); - MinY = pageP.y - (_currentLayoutMap.getHeight() / 2 * ZoomF); - MaxY = pageP.y + (_currentLayoutMap.getHeight() / 2 * ZoomF); - - MinX -= _currentLayoutMap.getLeft(); - MinY -= _currentLayoutMap.getTop(); - MaxX -= _currentLayoutMap.getLeft(); - MaxY -= _currentLayoutMap.getTop(); - if (MaxX - MinX > 0.001) { - _currentLayoutMap.getMapFrame().getMapView().zoomToExtentScreen(MinX, MaxX, MinY, MaxY, _zoom); - } - break; - case Map_Pan: - if (e.getButton() == MouseEvent.BUTTON1) { - int deltaX = e.getX() - _mouseDownPoint.x; - int deltaY = e.getY() - _mouseDownPoint.y; - deltaX = (int) (deltaX / _zoom); - deltaY = (int) (deltaY / _zoom); - MinX = -deltaX; - MinY = -deltaY; - MaxX = _currentLayoutMap.getWidth() - deltaX; - MaxY = _currentLayoutMap.getHeight() - deltaY; - _currentLayoutMap.getMapFrame().getMapView().zoomToExtentScreen(MinX, MaxX, MinY, MaxY, _zoom); - } - break; - } - - if (e.getButton() == MouseEvent.BUTTON1) { - switch (_mouseMode) { - case Map_SelectFeatures_Rectangle: - if (_currentLayoutMap.getMapFrame().getMapView().getSelectedLayerHandle() < 0) { - return; - } - MapLayer aMLayer = _currentLayoutMap.getMapFrame().getMapView().getSelectedLayer(); - if (aMLayer == null) { - return; - } - if (aMLayer.getLayerType() != LayerTypes.VectorLayer) { - return; - } - - VectorLayer aLayer = (VectorLayer) aMLayer; - PointF mapP = pageToScreen(_currentLayoutMap.getLeft(), _currentLayoutMap.getTop()); - Point aPoint = new Point(e.getX() - (int) mapP.X, e.getY() - (int) mapP.Y); - Point bPoint = new Point(_mouseDownPoint.x - (int) mapP.X, _mouseDownPoint.y - (int) mapP.Y); - int minx = Math.min(bPoint.x, aPoint.x); - int miny = Math.min(bPoint.y, aPoint.y); - int width = Math.abs(aPoint.x - bPoint.x); - int height = Math.abs(aPoint.y - bPoint.y); - Rectangle.Float rect = new Rectangle.Float(minx, miny, width, height); - List selectedShapes = _currentLayoutMap.getMapFrame().getMapView().selectShapes(aLayer, rect); - if (!(e.isControlDown() || e.isShiftDown())) { - aLayer.clearSelectedShapes(); - } - if (selectedShapes.size() > 0) { - for (int shapeIdx : selectedShapes) { - Shape shape = aLayer.getShapes().get(shapeIdx); - shape.setSelected(!shape.isSelected()); - } - _currentLayoutMap.getMapFrame().getMapView().fireShapeSelectedEvent(); - } - //this.paintGraphics(); - this.repaintNew(); - break; - case CreateSelection: - //Remove selected graphics - for (LayoutElement aElement : _selectedElements) { - aElement.setSelected(false); - } - _selectedElements.clear(); - - //Select elements - if (Math.abs(e.getX() - _mouseDownPoint.x) > 2 || Math.abs(e.getY() - _mouseDownPoint.y) > 2) { - //this.paintGraphics(); - this.repaintNew(); - return; - } - - //Point mousePoint = new Point(_mouseDownPoint.X, _mouseDownPoint.Y); - _selectedElements = selectElements(pageP, _layoutElements, 0); - if (_selectedElements.size() > 0) { - for (int i = 0; i < _selectedElements.size() - 1; i++) { - _selectedElements.remove(_selectedElements.size() - 1); - } - _selectedElements.get(0).setSelected(true); - if (_selectedElements.get(0).getElementType() == ElementType.LayoutMap) { - setActiveMapFrame(((LayoutMap) _selectedElements.get(0)).getMapFrame()); - } - } - this.fireElementSelectedEvent(); - - _mouseMode = MouseMode.Select; - //this.paintGraphics(); - this.repaintNew(); - break; - case MoveSelection: - //Select elements - if (Math.abs(e.getX() - _mouseDownPoint.x) < 2 && Math.abs(e.getY() - _mouseDownPoint.y) < 2) { - LayoutElement aElement = _selectedElements.get(0); - _selectedElements = selectElements(pageP, _layoutElements, 0); - if (_selectedElements.size() > 1) { - aElement.setSelected(false); - int idx = _selectedElements.indexOf(aElement); - if (idx == 0) { - idx = _selectedElements.size() - 1; - } else { - idx -= 1; - } - if (idx < 0) { - idx = 0; - } - aElement = _selectedElements.get(idx); - _selectedElements.clear(); - _selectedElements.add(aElement); - _selectedElements.get(0).setSelected(true); - if (_selectedElements.get(0).getElementType() == ElementType.LayoutMap) { - setActiveMapFrame(((LayoutMap) _selectedElements.get(0)).getMapFrame()); - } - } - this.fireElementSelectedEvent(); - } else { - int deltaX = (int) ((e.getX() - _mouseDownPoint.x) / _zoom); - int deltaY = (int) ((e.getY() - _mouseDownPoint.y) / _zoom); - for (LayoutElement aElement : _selectedElements) { - aElement.setLeft(aElement.getLeft() + deltaX); - aElement.setTop(aElement.getTop() + deltaY); - aElement.moveUpdate(); - } - UndoableEdit edit = (new MapLayoutUndoRedo()).new MoveElementsEdit(this, _selectedElements, deltaX, deltaY); - this.fireUndoEditEvent(edit); - } - - _mouseMode = MouseMode.Select; - //this.paintGraphics(); - this.repaintNew(); - break; - case ResizeSelected: - _mouseMode = MouseMode.Select; - LayoutElement oElement = _selectedElements.get(0); - if (_selectedRectangle.width < 3) { - _selectedRectangle.width = 3; - } - if (_selectedRectangle.height < 3) { - _selectedRectangle.height = 3; - } - - UndoableEdit edit = (new MapLayoutUndoRedo()).new ResizeElementEdit(this, oElement, _selectedRectangle); - this.fireUndoEditEvent(edit); - PointF minP = screenToPage((float) _selectedRectangle.x, (float) _selectedRectangle.y); - PointF maxP = screenToPage((float) _selectedRectangle.x + _selectedRectangle.width, _selectedRectangle.y + _selectedRectangle.height); - oElement.setLeft((int) minP.X); - oElement.setTop((int) minP.Y); - oElement.setWidth((int) (maxP.X - minP.X)); - oElement.setHeight((int) (maxP.Y - minP.Y)); - oElement.resizeUpdate(); - //this.paintGraphics(); - this.repaintNew(); - break; - case New_Rectangle: - case New_Ellipse: - if (e.getButton() == MouseEvent.BUTTON1) { - if (e.getX() - _mouseDownPoint.x < 2 || e.getY() - _mouseDownPoint.y < 2) { - return; - } - - _startNewGraphic = true; - _graphicPoints = new ArrayList<>(); - _graphicPoints.add(new PointF(_mouseDownPoint.x, _mouseDownPoint.y)); - _graphicPoints.add(new PointF(_mouseDownPoint.x, e.getY())); - _graphicPoints.add(new PointF(e.getX(), e.getY())); - _graphicPoints.add(new PointF(e.getX(), _mouseDownPoint.y)); - List points = new ArrayList<>(); - for (PointF cPoint : _graphicPoints) { - PointF dPoint = screenToPage(cPoint.X, cPoint.Y); - points.add(new PointD(dPoint.X, dPoint.Y)); - } - - Graphic aGraphic = null; - switch (_mouseMode) { - case New_Rectangle: - RectangleShape aPGS = new RectangleShape(); - points.add((PointD) points.get(0).clone()); - aPGS.setPoints(points); - aGraphic = new Graphic(aPGS, (PolygonBreak) _defPolygonBreak.clone()); - break; - case New_Ellipse: - EllipseShape aES = new EllipseShape(); - aES.setPoints(points); - aGraphic = new Graphic(aES, (PolygonBreak) _defPolygonBreak.clone()); - break; - } - - if (aGraphic != null) { - LayoutGraphic lg = new LayoutGraphic(aGraphic, this); - addElement(lg); - //this.paintGraphics(); - this.repaintNew(); - edit = (new MapLayoutUndoRedo()).new AddElementEdit(this, lg); - this.fireUndoEditEvent(edit); - } else { - //this.repaint(); - this.repaintOld(); - } - } - break; - case New_Freehand: - if (e.getButton() == MouseEvent.BUTTON1) { - _startNewGraphic = true; - if (_graphicPoints.size() < 2) { - break; - } - - List points = new ArrayList<>(); - for (PointF cPoint : _graphicPoints) { - PointF dPoint = screenToPage(cPoint.X, cPoint.Y); - points.add(new PointD(dPoint.X, dPoint.Y)); - } - - PolylineShape aPLS = new PolylineShape(); - aPLS.setPoints(points); - Graphic aGraphic = new Graphic(aPLS, (PolylineBreak) _defPolylineBreak.clone()); - LayoutGraphic lg = new LayoutGraphic(aGraphic, this); - addElement(lg); - //this.paintGraphics(); - this.repaintNew(); - edit = (new MapLayoutUndoRedo()).new AddElementEdit(this, lg); - this.fireUndoEditEvent(edit); - } - break; - case New_Circle: - if (e.getButton() == MouseEvent.BUTTON1) { - if (e.getX() - _mouseDownPoint.x < 2 || e.getY() - _mouseDownPoint.y < 2) { - return; - } - - float radius = (float) Math.sqrt(Math.pow(e.getX() - _mouseDownPoint.x, 2) - + Math.pow(e.getY() - _mouseDownPoint.y, 2)); - _startNewGraphic = true; - _graphicPoints = new ArrayList<>(); - _graphicPoints.add(new PointF(_mouseDownPoint.x - radius, _mouseDownPoint.y)); - _graphicPoints.add(new PointF(_mouseDownPoint.x, _mouseDownPoint.y - radius)); - _graphicPoints.add(new PointF(_mouseDownPoint.x + radius, _mouseDownPoint.y)); - _graphicPoints.add(new PointF(_mouseDownPoint.x, _mouseDownPoint.y + radius)); - List points = new ArrayList<>(); - for (PointF cPoint : _graphicPoints) { - PointF dPoint = screenToPage(cPoint.X, cPoint.Y); - points.add(new PointD(dPoint.X, dPoint.Y)); - } - - CircleShape aPGS = new CircleShape(); - aPGS.setPoints(points); - Graphic aGraphic = new Graphic(aPGS, (PolygonBreak) _defPolygonBreak.clone()); - LayoutGraphic lg = new LayoutGraphic(aGraphic, this); - addElement(lg); - //this.paintGraphics(); - this.repaintNew(); - edit = (new MapLayoutUndoRedo()).new AddElementEdit(this, lg); - this.fireUndoEditEvent(edit); - } - break; - case InEditingVertices: - LayoutGraphic lg = (LayoutGraphic) _selectedElements.get(0); - edit = (new MapLayoutUndoRedo()).new MoveGraphicVerticeEdit(this, lg, _editingVerticeIndex, - pageP.x, pageP.y); - this.fireUndoEditEvent(edit); - lg.verticeEditUpdate(_editingVerticeIndex, pageP.x, pageP.y); - _mouseMode = MouseMode.EditVertices; - //this.paintGraphics(); - this.repaintNew(); - break; - } - } - } - - void onMouseClicked(MouseEvent e) throws CloneNotSupportedException { - int clickTimes = e.getClickCount(); - if (clickTimes == 1) { - Point pageP = screenToPage(e.getX(), e.getY()); - if (e.getButton() == MouseEvent.BUTTON1) { - switch (_mouseMode) { - case Map_Identifer: - MapLayer aMLayer = _currentLayoutMap.getMapFrame().getMapView().getSelectedLayer(); - if (aMLayer == null) { - return; - } - if (aMLayer.getLayerType() == LayerTypes.ImageLayer) { - return; - } - - PointF mapP = pageToScreen(_currentLayoutMap.getLeft(), _currentLayoutMap.getTop()); - PointF aPoint = new PointF(e.getX() - mapP.X, e.getY() - mapP.Y); - if (aMLayer.getLayerType() == LayerTypes.VectorLayer) { - VectorLayer aLayer = (VectorLayer) aMLayer; - List selectedShapes = _currentLayoutMap.getMapFrame().getMapView().selectShapes(aLayer, aPoint); - if (selectedShapes.size() > 0) { - if (frmIdentifier == null) { - frmIdentifier = new FrmIdentifer((JFrame) SwingUtilities.getWindowAncestor(this), false, _currentLayoutMap.getMapFrame().getMapView()); - frmIdentifier.addWindowListener(new WindowAdapter() { - @Override - public void windowClosed(WindowEvent e) { - _currentLayoutMap.getMapFrame().getMapView().setDrawIdentiferShape(false); - //repaint(); - repaintOld(); - } - }); - } - frmIdentifier.setMapView(_currentLayoutMap.getMapFrame().getMapView()); - - String[] colNames = {"Field", "Value"}; - String fieldStr, valueStr; - int shapeIdx = selectedShapes.get(0); - aLayer.setIdentiferShape(shapeIdx); - _currentLayoutMap.getMapFrame().getMapView().setDrawIdentiferShape(true); - - Object[][] tData = new Object[aLayer.getFieldNumber() + 1][2]; - fieldStr = "Index"; - valueStr = String.valueOf(shapeIdx); - tData[0][0] = fieldStr; - tData[0][1] = valueStr; - if (aLayer.getShapeNum() > 0) { - for (int i = 0; i < aLayer.getFieldNumber(); i++) { - fieldStr = aLayer.getFieldName(i); - valueStr = aLayer.getCellValue(i, shapeIdx).toString(); - tData[i + 1][0] = fieldStr; - tData[i + 1][1] = valueStr; - } - } - DefaultTableModel dtm = new javax.swing.table.DefaultTableModel(tData, colNames) { - @Override - public boolean isCellEditable(int row, int column) { - return false; - } - }; - this.frmIdentifier.getTable().setModel(dtm); - this.frmIdentifier.repaint(); - if (!this.frmIdentifier.isVisible()) { - this.frmIdentifier.setLocation(e.getX(), e.getY()); - this.frmIdentifier.setVisible(true); - } - - //this.repaint(); - this.repaintOld(); - //Rectangle rect = getElementViewExtent(_currentLayoutMap); - //_currentLayoutMap.getMapFrame().getMapView().drawIdShape(this.createGraphics(), aLayer.getShapes().get(shapeIdx), rect); - } - } else if (aMLayer.getLayerType() == LayerTypes.RasterLayer) { - RasterLayer aRLayer = (RasterLayer) aMLayer; - int[] ijIdx = _currentLayoutMap.getMapFrame().getMapView().selectGridCell(aRLayer, aPoint); - if (ijIdx != null) { - int iIdx = ijIdx[0]; - int jIdx = ijIdx[1]; - double aValue = aRLayer.getCellValue(iIdx, jIdx); - if (frmIdentifierGrid == null) { - frmIdentifierGrid = new FrmIdentiferGrid((JFrame) SwingUtilities.getWindowAncestor(this), false); - } - - frmIdentifierGrid.setIIndex(iIdx); - frmIdentifierGrid.setJIndex(jIdx); - frmIdentifierGrid.setCellValue(aValue); - if (!this.frmIdentifierGrid.isVisible()) { - //this._frmIdentiferGrid.setLocation(e.getX(), e.getY()); - this.frmIdentifierGrid.setLocationRelativeTo(this); - this.frmIdentifierGrid.setVisible(true); - } - } - } - break; -// case Map_SelectFeatures_Rectangle: -// aMLayer = _currentLayoutMap.getMapFrame().getMapView().getSelectedLayer(); -// if (aMLayer == null) { -// return; -// } -// -// if (aMLayer.getLayerType() != LayerTypes.VectorLayer) { -// return; -// } -// -// VectorLayer aLayer = (VectorLayer) aMLayer; -// if (!e.isControlDown() && !e.isShiftDown()) { -// aLayer.clearSelectedShapes(); -// //_currentLayoutMap.getMapFrame().getMapView().paintLayers(); -// } -// -// mapP = pageToScreen(_currentLayoutMap.getLeft(), _currentLayoutMap.getTop()); -// aPoint = new PointF(e.getX() - mapP.X, e.getY() - mapP.Y); -// List selectedShapes = _currentLayoutMap.getMapFrame().getMapView().selectShapes(aLayer, aPoint); -// this._layoutBitmap = GlobalUtil.deepCopy(this._tempImage); -// if (selectedShapes.size() > 0) { -// int shapeIdx = selectedShapes.get(0); -// Shape selShape = aLayer.getShapes().get(shapeIdx); -// Rectangle rect = getElementViewExtent(_currentLayoutMap); -// if (!e.isControlDown() && !e.isShiftDown()) { -// selShape.setSelected(true); -// _currentLayoutMap.getMapFrame().getMapView().drawIdShape((Graphics2D) this._layoutBitmap.getGraphics(), selShape, rect); -// } else { -// selShape.setSelected(!selShape.isSelected()); -// for (int sIdx : aLayer.getSelectedShapeIndexes()) { -// _currentLayoutMap.getMapFrame().getMapView().drawIdShape((Graphics2D) this._layoutBitmap.getGraphics(), aLayer.getShapes().get(sIdx), rect); -// } -// } -// this.repaint(); -// } else { -// if (!e.isControlDown() && !e.isShiftDown()) { -// this.repaint(); -// } -// } -// break; - } - } else if (e.getButton() == MouseEvent.BUTTON3 && _mouseMode == MouseMode.Select) { - if (_selectedElements.isEmpty()) { - return; - } - - JPopupMenu jPopupMenu_Element = new JPopupMenu(); - JMenu jMenu_Order = new JMenu("Order"); - jPopupMenu_Element.add(jMenu_Order); - - JMenuItem jMenuItem_BTF = new JMenuItem("Bring to Front"); - jMenuItem_BTF.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - onBringToFrontClick(e); - } - }); - jMenu_Order.add(jMenuItem_BTF); - - JMenuItem jMenuItem_STB = new JMenuItem("Send to Back"); - jMenuItem_STB.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - onSendToBackClick(e); - } - }); - jMenu_Order.add(jMenuItem_STB); - - JMenuItem jMenuItem_BF = new JMenuItem("Bring Forward"); - jMenuItem_BF.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - onBringForwardClick(e); - } - }); - jMenu_Order.add(jMenuItem_BF); - - JMenuItem jMenuItem_SB = new JMenuItem("Send Backward"); - jMenuItem_SB.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - onSendBackwardClick(e); - } - }); - jMenu_Order.add(jMenuItem_SB); - - jPopupMenu_Element.add(new JSeparator()); - - JMenuItem jMenuItem_Remove = new JMenuItem("Remove"); - jMenuItem_Remove.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - onRemoveElementClick(e); - } - }); - jPopupMenu_Element.add(jMenuItem_Remove); - - switch (_mouseMode) { - case Select: - case MoveSelection: - case ResizeSelected: - if (_selectedElements.size() > 0) { - LayoutElement aElement = _selectedElements.get(0); - if (MIMath.pointInRectangle(pageP, aElement.getBounds())) { - if (aElement.getElementType() == ElementType.LayoutGraphic) { - Graphic aGraphic = ((LayoutGraphic) aElement).getGraphic(); - if (aGraphic.getLegend().getBreakType() == BreakTypes.PolylineBreak || aGraphic.getLegend().getBreakType() == BreakTypes.PolygonBreak) { - JMenuItem jMenuItem_Reverse = new JMenuItem("Reverse"); - jMenuItem_Reverse.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - onReverseGraphicClick(e); - } - }); - jPopupMenu_Element.add(jMenuItem_Reverse); - - if (aGraphic.getShape().getShapeType() == ShapeTypes.Polyline || aGraphic.getShape().getShapeType() == ShapeTypes.Polygon) { - jPopupMenu_Element.add(new JSeparator()); - JMenuItem jMenuItem_Smooth = new JMenuItem("Smooth Graphic"); - jMenuItem_Smooth.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - onGraphicSmoothClick(e); - } - }); - jPopupMenu_Element.add(jMenuItem_Smooth); - } - - if (aGraphic.getShape().getShapeType() == ShapeTypes.Ellipse) { - JMenuItem jMenuItem_Angle = new JMenuItem("Set Angle"); - jMenuItem_Angle.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - onGraphicAngleClick(e); - } - }); - jPopupMenu_Element.add(jMenuItem_Angle); - } - } - } - } - } - break; - } - - jPopupMenu_Element.show(this, e.getX(), e.getY()); - } - } else if (clickTimes == 2) { - Point pageP = screenToPage(e.getX(), e.getY()); - switch (_mouseMode) { - case Select: - case MoveSelection: - case ResizeSelected: - if (_selectedElements.isEmpty()) { - return; - } - - LayoutElement aElement = _selectedElements.get(0); - _selectedElements = selectElements(pageP, _layoutElements, 0); - if (_selectedElements.size() > 1) { - aElement.setSelected(false); - int idx = _selectedElements.indexOf(aElement); - idx += 2; - if (idx > _selectedElements.size() - 1) { - idx = idx - _selectedElements.size(); - } - aElement = _selectedElements.get(idx); - _selectedElements.clear(); - _selectedElements.add(aElement); - _selectedElements.get(0).setSelected(true); - } - //this.paintGraphics(); - this.repaintNew(); - - if (aElement.getElementType() == ElementType.LayoutGraphic) { - Graphic aGraphic = ((LayoutGraphic) aElement).getGraphic(); - showSymbolSetForm(aGraphic); - } else { - FrmProperty aFrmProperty = new FrmProperty((JFrame) SwingUtilities.getWindowAncestor(this), true, false); - Object object = aElement; - switch (aElement.getElementType()) { - case LayoutLegend: - object = ((LayoutLegend) aElement).new LayoutLegendBean(); - break; - case LayoutMap: - object = ((LayoutMap) aElement).new LayoutMapBean(); - break; - case LayoutNorthArraw: - object = ((LayoutNorthArrow) aElement).new LayoutNorthArrowBean(); - break; - case LayoutScaleBar: - object = ((LayoutScaleBar) aElement).new LayoutScaleBarBean(); - break; - } - aFrmProperty.setObject(object); - aFrmProperty.setParent(this); - aFrmProperty.setLocationRelativeTo(this); - aFrmProperty.setVisible(true); - } - setMouseMode(MouseMode.Select); - this.fireElementSelectedEvent(); - break; - case New_Polyline: - case New_Polygon: - case New_Curve: - case New_CurvePolygon: - case New_Freehand: - case Map_SelectFeatures_Polygon: - if (!_startNewGraphic) { - _startNewGraphic = true; - _graphicPoints.remove(_graphicPoints.size() - 1); - - if (_mouseMode == MouseMode.Map_SelectFeatures_Polygon) { - PointF mapP = pageToScreen(_currentLayoutMap.getLeft(), _currentLayoutMap.getTop()); - List points = new ArrayList<>(); - MapView currentMapView = _currentLayoutMap.getMapFrame().getMapView(); - for (PointF aPoint : _graphicPoints) { - float[] pXY = currentMapView.screenToProj(aPoint.X - mapP.X, aPoint.Y - mapP.Y); - points.add(new PointD(pXY[0], pXY[1])); - } - - MapLayer aMLayer = _currentLayoutMap.getMapFrame().getMapView().getSelectedLayer(); - if (aMLayer == null) { - return; - } - if (aMLayer.getLayerType() != LayerTypes.VectorLayer) { - return; - } - - PolygonShape aPGS = new PolygonShape(); - points.add((PointD) points.get(0).clone()); - aPGS.setPoints(points); - VectorLayer aLayer = (VectorLayer) aMLayer; - if (!e.isControlDown() && !e.isShiftDown()) { - aLayer.clearSelectedShapes(); - } - aLayer.selectShapes(aPGS); - _currentLayoutMap.getMapFrame().getMapView().fireShapeSelectedEvent(); - } else { - List points = new ArrayList<>(); - for (PointF aPoint : _graphicPoints) { - PointF bPoint = screenToPage(aPoint.X, aPoint.Y); - points.add(new PointD(bPoint.X, bPoint.Y)); - } - - Graphic aGraphic = null; - switch (_mouseMode) { - case New_Polyline: - case New_Freehand: - PolylineShape aPLS = new PolylineShape(); - aPLS.setPoints(points); - aGraphic = new Graphic(aPLS, (PolylineBreak) _defPolylineBreak.clone()); - break; - case New_Polygon: - if (points.size() > 2) { - PolygonShape aPGS = new PolygonShape(); - points.add((PointD) points.get(0).clone()); - aPGS.setPoints(points); - aGraphic = new Graphic(aPGS, (PolygonBreak) _defPolygonBreak.clone()); - } - break; - case New_Curve: - CurveLineShape aCLS = new CurveLineShape(); - aCLS.setPoints(points); - aGraphic = new Graphic(aCLS, (PolylineBreak) _defPolylineBreak.clone()); - break; - case New_CurvePolygon: - if (points.size() > 2) { - CurvePolygonShape aCPS = new CurvePolygonShape(); - points.add((PointD) points.get(0).clone()); - aCPS.setPoints(points); - aGraphic = new Graphic(aCPS, (PolygonBreak) _defPolygonBreak.clone()); - } - break; - } - - if (aGraphic != null) { - LayoutGraphic lg = new LayoutGraphic(aGraphic, this); - addElement(lg); - //this.paintGraphics(); - this.repaintNew(); - UndoableEdit edit = (new MapLayoutUndoRedo()).new AddElementEdit(this, lg); - this.fireUndoEditEvent(edit); - } else { - this.repaint(); - } - } - } - break; - } - } - } - - private void onRemoveElementClick(ActionEvent e) { - this.onRemoveElementClick(); - } - - private void onBringToFrontClick(ActionEvent e) { - LayoutElement aLE = _selectedElements.get(0); - int idx = _layoutElements.indexOf(aLE); - if (idx < _layoutElements.size() - 1) { - _layoutElements.remove(aLE); - _layoutElements.add(aLE); - //this.paintGraphics(); - this.repaintNew(); - } - } - - private void onSendToBackClick(ActionEvent e) { - LayoutElement aLE = _selectedElements.get(0); - int idx = _layoutElements.indexOf(aLE); - if (idx > 0) { - _layoutElements.remove(aLE); - _layoutElements.add(0, aLE); - //this.paintGraphics(); - this.repaintNew(); - } - } - - private void onBringForwardClick(ActionEvent e) { - LayoutElement aLE = _selectedElements.get(0); - int idx = _layoutElements.indexOf(aLE); - if (idx < _layoutElements.size() - 1) { - _layoutElements.remove(aLE); - _layoutElements.add(idx + 1, aLE); - //this.paintGraphics(); - this.repaintNew(); - } - } - - private void onSendBackwardClick(ActionEvent e) { - LayoutElement aLE = _selectedElements.get(0); - int idx = _layoutElements.indexOf(aLE); - if (idx > 0) { - _layoutElements.remove(aLE); - _layoutElements.add(idx - 1, aLE); - //this.paintGraphics(); - this.repaintNew(); - } - } - - private void onReverseGraphicClick(ActionEvent e) { - LayoutElement aElement = _selectedElements.get(0); - Graphic aGraphic = ((LayoutGraphic) aElement).getGraphic(); - List points = (List) aGraphic.getShape().getPoints(); - Collections.reverse(points); - aGraphic.getShape().setPoints(points); - - //this.paintGraphics(); - this.repaintNew(); - } - - private void onGraphicSmoothClick(ActionEvent e) { - LayoutElement aElement = _selectedElements.get(0); - Graphic aGraphic = ((LayoutGraphic) aElement).getGraphic(); - List pointList = new ArrayList<>(); - List newPoints = new ArrayList<>(); - - for (PointD aP : aGraphic.getShape().getPoints()) { - pointList.add(new wcontour.global.PointD(aP.X, aP.Y)); - } - - if (aGraphic.getShape().getShapeType() == ShapeTypes.Polygon) { - pointList.add(pointList.get(0)); - } - - pointList = wcontour.Contour.smoothPoints(pointList); - for (wcontour.global.PointD aP : pointList) { - newPoints.add(new PointD(aP.X, aP.Y)); - } - aGraphic.getShape().setPoints(newPoints); - ((LayoutGraphic) aElement).updateControlSize(); - //this.paintGraphics(); - this.repaintNew(); - } - - private void onGraphicAngleClick(ActionEvent e) { - LayoutElement aElement = _selectedElements.get(0); - Graphic aGraphic = ((LayoutGraphic) aElement).getGraphic(); - EllipseShape es = (EllipseShape)aGraphic.getShape(); - String angleStr = JOptionPane.showInputDialog(this, "Ellipse angle:", es.getAngle()); - if (angleStr != null){ - es.setAngle(Float.parseFloat(angleStr)); - //this.paintGraphics(); - this.repaintNew(); - } - } - - private void showSymbolSetForm(ColorBreak aCB) { - switch (aCB.getBreakType()) { - case PointBreak: - PointBreak aPB = (PointBreak) aCB; - - if (_frmPointSymbolSet == null) { - _frmPointSymbolSet = new FrmPointSymbolSet((JFrame) SwingUtilities.getWindowAncestor(this), false, this); - _frmPointSymbolSet.setLocationRelativeTo(this); - _frmPointSymbolSet.setVisible(true); - } - _frmPointSymbolSet.setPointBreak(aPB); - _frmPointSymbolSet.setVisible(true); - break; - case LabelBreak: - LabelBreak aLB = (LabelBreak) aCB; - - if (_frmLabelSymbolSet == null) { - _frmLabelSymbolSet = new FrmLabelSymbolSet((JFrame) SwingUtilities.getWindowAncestor(this), false, this); - _frmLabelSymbolSet.setLocationRelativeTo(this); - _frmLabelSymbolSet.setVisible(true); - } - _frmLabelSymbolSet.setLabelBreak(aLB); - _frmLabelSymbolSet.setVisible(true); - break; - case PolylineBreak: - PolylineBreak aPLB = (PolylineBreak) aCB; - - if (_frmPolylineSymbolSet == null) { - _frmPolylineSymbolSet = new FrmPolylineSymbolSet((JFrame) SwingUtilities.getWindowAncestor(this), false, this); - _frmPolylineSymbolSet.setLocationRelativeTo(this); - _frmPolylineSymbolSet.setVisible(true); - } - _frmPolylineSymbolSet.setPolylineBreak(aPLB); - _frmPolylineSymbolSet.setVisible(true); - break; - case PolygonBreak: - PolygonBreak aPGB = (PolygonBreak) aCB; - - if (_frmPolygonSymbolSet == null) { - _frmPolygonSymbolSet = new FrmPolygonSymbolSet((JFrame) SwingUtilities.getWindowAncestor(this), false, this); - _frmPolygonSymbolSet.setLocationRelativeTo(this); - _frmPolygonSymbolSet.setVisible(true); - } - _frmPolygonSymbolSet.setPolygonBreak(aPGB); - _frmPolygonSymbolSet.setVisible(true); - break; - } - } - - private void showSymbolSetForm(Graphic graphic) { - Shape shape = graphic.getShape(); - ColorBreak aCB = graphic.getLegend(); - switch (aCB.getBreakType()) { - case PointBreak: - PointBreak aPB = (PointBreak) aCB; - - if (_frmPointSymbolSet == null) { - _frmPointSymbolSet = new FrmPointSymbolSet((JFrame) SwingUtilities.getWindowAncestor(this), false, this); - _frmPointSymbolSet.setLocationRelativeTo(this); - _frmPointSymbolSet.setVisible(true); - } - _frmPointSymbolSet.setPointBreak(aPB); - _frmPointSymbolSet.setVisible(true); - break; - case LabelBreak: - LabelBreak aLB = (LabelBreak) aCB; - - if (_frmLabelSymbolSet == null) { - _frmLabelSymbolSet = new FrmLabelSymbolSet((JFrame) SwingUtilities.getWindowAncestor(this), false, this); - _frmLabelSymbolSet.setLocationRelativeTo(this); - _frmLabelSymbolSet.setVisible(true); - } - _frmLabelSymbolSet.setLabelBreak(aLB); - _frmLabelSymbolSet.setVisible(true); - break; - case PolylineBreak: - PolylineBreak aPLB = (PolylineBreak) aCB; - - if (_frmPolylineSymbolSet == null) { - _frmPolylineSymbolSet = new FrmPolylineSymbolSet((JFrame) SwingUtilities.getWindowAncestor(this), false, this); - _frmPolylineSymbolSet.setLocationRelativeTo(this); - _frmPolylineSymbolSet.setVisible(true); - } - _frmPolylineSymbolSet.setPolylineBreak(aPLB); - _frmPolylineSymbolSet.setVisible(true); - break; - case PolygonBreak: - PolygonBreak aPGB = (PolygonBreak) aCB; - - if (_frmPolygonSymbolSet == null) { - _frmPolygonSymbolSet = new FrmPolygonSymbolSet((JFrame) SwingUtilities.getWindowAncestor(this), false, this); - _frmPolygonSymbolSet.setLocationRelativeTo(this); - _frmPolygonSymbolSet.setVisible(true); - } - _frmPolygonSymbolSet.setPolygonBreak(aPGB); - _frmPolygonSymbolSet.setVisible(true); - break; - case VectorBreak: - WindArrow wa = (WindArrow) shape; - //VectorBreak vb = (VectorBreak) aCB; - Object[] lens = {5, 10, 15, 20, 25, 30}; - Object lenObj = JOptionPane.showInputDialog((JFrame) SwingUtilities.getWindowAncestor(this), - "Select wind speed:", "Selection", JOptionPane.PLAIN_MESSAGE, null, lens, (int) wa.length); - if (lenObj != null) { - wa.length = Integer.parseInt(lenObj.toString()); - //this.paintGraphics(); - this.repaintNew(); - } - break; - } - } - - void onKeyPressed(KeyEvent e) { - if (_mouseMode == MouseMode.Select) { - switch (e.getKeyCode()) { - case KeyEvent.VK_DELETE: - onRemoveElementClick(); - break; - case KeyEvent.VK_LEFT: - case KeyEvent.VK_RIGHT: - case KeyEvent.VK_UP: - case KeyEvent.VK_DOWN: - int x = 0; - int y = 0; - int d = 5; - if (e.isControlDown()) { - d = 1; - } - switch (e.getKeyCode()) { - case KeyEvent.VK_LEFT: - x = -d; - break; - case KeyEvent.VK_RIGHT: - x = d; - break; - case KeyEvent.VK_UP: - y = -d; - break; - case KeyEvent.VK_DOWN: - y = d; - break; - } - for (int i = 0; i < _layoutElements.size(); i++) { - LayoutElement aElement = _layoutElements.get(i); - if (aElement.isSelected()) { - if (x != 0) { - aElement.setLeft(aElement.getLeft() + x); - } - if (y != 0) { - aElement.setTop(aElement.getTop() + y); - } - aElement.moveUpdate(); - } - } - //this.paintGraphics(); - this.repaintNew(); - break; - } - } - } - - private void onRemoveElementClick() { - UndoableEdit edit = (new MapLayoutUndoRedo()).new RemoveElementsEdit(this, _selectedElements); - this.fireUndoEditEvent(edit); - for (LayoutElement element : _selectedElements) { - removeElement(element); - } - - _selectedElements.clear(); - _startNewGraphic = true; - //paintGraphics(); - this.repaintNew(); - } - - // - // - /** - * Get if using off screen image double buffering. - * Using double buffering will be faster but lower view quality in - * high dpi screen computer. - * - * @return Boolean - */ - public boolean isDoubleBuffer() { - return this.doubleBuffer; - } - - /** - * Set using off screen image double buffering or not. - * @param value Boolean - */ - public void setDoubleBuffer(boolean value) { - this.doubleBuffer = value; - } - - /** - * Get if lock view update - * - * @return If lock view update - */ - public boolean isLockViewUpdate() { - return _lockViewUpdate; - } - - /** - * Set if lock view update - * - * @param istrue If lock view update - */ - public void setLockViewUpdate(boolean istrue) { - _lockViewUpdate = istrue; - } - - /** - * Get map frames - * - * @return Map frames - */ - public List getMapFrames() { - return _mapFrames; - } - - /** - * Set map frames - * - * @param mfs Map frames - */ - public void setMapFrames(List mfs) { - _mapFrames = mfs; - _mapFrames = new ArrayList<>(); - for (MapFrame mf : mfs) { - boolean isInsert = false; - for (int i = 0; i < _mapFrames.size(); i++) { - MapFrame amf = _mapFrames.get(i); - if (mf.getOrder() < amf.getOrder()) { - _mapFrames.add(i, mf); - isInsert = true; - break; - } - } - - if (!isInsert) { - _mapFrames.add(mf); - } - } - } - - /** - * Get active map frame - * - * @return Active map frame - */ - public MapFrame getActiveMapFrame() { - for (MapFrame mf : _mapFrames) { - if (mf.isActive()) { - return mf; - } - } - - return null; - } - - /** - * Get active layout map - * - * @return Active layout map - */ - public LayoutMap getActiveLayoutMap() { - LayoutMap aLM = null; - for (LayoutMap lm : this.getLayoutMaps()) { - if (lm.getMapFrame().isActive()) { - aLM = lm; - break; - } - } - return aLM; - } - - /** - * Get if is landscape - * - * @return Boolean - */ - public boolean isLandscape() { - return _isLandscape; - } - - /** - * Set if is landscape - * - * @param istrue - */ - public void setLandscape(boolean istrue) { - _isLandscape = istrue; - Rectangle.Float aRect = paperToScreen(new Rectangle.Float(0, 0, this.getPaperWidth(), this.getPaperHeight())); - _pageBounds.width = (int) aRect.width; - _pageBounds.height = (int) aRect.height; - } - - /** - * Get mouse mode - * - * @return The mouse mode - */ - public MouseMode getMouseMode() { - return _mouseMode; - } - - /** - * Set mouse mode - * - * @param mm The mouse mode - */ - public void setMouseMode(MouseMode mm) { - _mouseMode = mm; - switch (_mouseMode) { - case New_Label: - case New_Point: - case New_Polyline: - case New_Polygon: - case New_Rectangle: - case New_Circle: - case New_Curve: - case New_CurvePolygon: - case New_Ellipse: - case New_Freehand: - this.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); - break; - case Map_Measurement: - this.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); - break; - case Map_SelectFeatures_Rectangle: - case Map_SelectFeatures_Polygon: - case Map_SelectFeatures_Lasso: - case Map_SelectFeatures_Circle: - this.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); - this._tempImage = GlobalUtil.deepCopy(this._layoutBitmap); - break; - } - } - - /** - * Get if antialias - * - * @return Boolean - */ - public boolean isAntiAlias() { - return _antiAlias; - } - - /** - * Set if antialias - * - * @param istrue Boolean - */ - public void setAntiAlias(boolean istrue) { - _antiAlias = istrue; - } - - /** - * Get page foreground color - * - * @return Page foreground color - */ - public Color getPageForeColor() { - return this._pageForeColor; - } - - /** - * Set page foreground color - * - * @param c Page foreground color - */ - public void setPageForeColor(Color c) { - _pageForeColor = c; - } - - /** - * Get page background color - * - * @return Page background color - */ - public Color getPageBackColor() { - return _pageBackColor; - } - - /** - * Set page background color - * - * @param c Page background color - */ - public void setPageBackColor(Color c) { - _pageBackColor = c; - - if (c == Color.black) { - _pageForeColor = Color.white; - } else if (c == Color.white) { - _pageForeColor = Color.black; - } - } - - /** - * Get paper size - * - * @return Paper size - */ - public PaperSize getPaperSize() { - return _paperSize; - } - - /** - * Set paper size - * - * @param ps Paper size - */ - public void setPaperSize(PaperSize ps) { - _paperSize = ps; - Rectangle.Float aRect = paperToScreen(new Rectangle.Float(0, 0, getPaperWidth(), getPaperHeight())); - _pageBounds.width = (int) aRect.width; - _pageBounds.height = (int) aRect.height; - } - - /** - * Set paper size - * - * @param width Width - * @param height Height - */ - public void setPaperSize(int width, int height) { - PaperSize ps = new PaperSize("Custom", width, height); - setPaperSize(ps); - } - - /** - * Get the width of the paper in 1/100 of an inch - */ - private int getPaperWidth() { - if (_isLandscape) { - return _paperSize.getHeight(); - } - return _paperSize.getWidth(); - } - - /** - * Gets the heigh of the paper in 1/100 of an inch - */ - private int getPaperHeight() { - if (_isLandscape) { - return _paperSize.getWidth(); - } - return _paperSize.getHeight(); - } - - /** - * Get layout map elements - * - * @return The layout map elements - */ - public List getLayoutMaps() { - List layoutMaps = new ArrayList<>(); - for (LayoutElement aLE : _layoutElements) { - if (aLE.getElementType() == ElementType.LayoutMap) { - layoutMaps.add((LayoutMap) aLE); - } - } - return layoutMaps; - } - - /** - * Get selected elements - * - * @return Selected elements - */ - public List getSelectedElements() { - return _selectedElements; - } - - /// - /// Get or set page bounds - /// - /** - * Get page bounds - * - * @return Page bounds - */ - public Rectangle getPageBounds() { - return _pageBounds; - } - - /** - * Set page bounds - * - * @param pb Page bounds - */ - public void setPageBounds(Rectangle pb) { - _pageBounds = pb; - } - - /** - * Get page location - * - * @return Page location - */ - public PointF getPageLocation() { - return _pageLocation; - } - - /** - * Set page location - * - * @param p Page location - */ - public void setPageLocation(PointF p) { - _pageLocation = p; - } - - /** - * Get zoom - * - * @return Zoom - */ - public float getZoom() { - return _zoom; - } - - /** - * Set zoom - * - * @param zoom Zoom - */ - public void setZoom(float zoom) { - _zoom = zoom; - this.fireZoomChangedEvent(); - } - - /** - * Get default point break - * - * @return Default point break - */ - public PointBreak getDefPointBreak() { - return _defPointBreak; - } - - /** - * Set default point break - * - * @param pb Default point break - */ - public void setDefPointBreak(PointBreak pb) { - _defPointBreak = pb; - } - - /** - * Get default label break - * - * @return Default label break - */ - public LabelBreak getDefLabelBreak() { - return _defLabelBreak; - } - - /** - * Set default label break - * - * @param lb Default label break - */ - public void setDefLabelBreak(LabelBreak lb) { - _defLabelBreak = lb; - } - - /** - * Get default polyline break - * - * @return Default polyline break - */ - public PolylineBreak getDefPolylineBreak() { - return _defPolylineBreak; - } - - /** - * Set default polyline break - * - * @param pb Default polyline break - */ - public void setDefPolylineBreak(PolylineBreak pb) { - _defPolylineBreak = pb; - } - - /** - * Get default polygon break - * - * @return Default polygon break - */ - public PolygonBreak getDefPolygonBreak() { - return _defPolygonBreak; - } - - /** - * Set default polygon break - * - * @param pb Default polygon break - */ - public void setDefPolygonBreak(PolygonBreak pb) { - _defPolygonBreak = pb; - } - - /** - * Get measurement form - * - * @return Measurement form - */ - public FrmMeasurement getMeasurementForm() { - return _frmMeasure; - } - - /** - * set measurement form - * - * @param form Measurement form - */ - public void setMeasurementForm(FrmMeasurement form) { - _frmMeasure = form; - } - - /** - * Get view image - * - * @return View image - */ - public BufferedImage getViewImage() { - BufferedImage aImage = new BufferedImage(_pageBounds.width, _pageBounds.height, BufferedImage.TYPE_INT_ARGB); - Graphics2D g = aImage.createGraphics(); - paintGraphics(g); - return aImage; - } - - // - // - // - @Override - public int getWebMapZoom(){ - WebMapLayer layer = this.getActiveMapFrame().getMapView().getWebMapLayer(); - if (layer != null){ - return layer.getZoom(); - } - return 0; - } - - @Override - public void reDraw(){ - //this.paintGraphics(); - this.repaintNew(); - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - - Graphics2D g2 = (Graphics2D) g; - g2.setColor(this.getBackground()); - g2.clearRect(0, 0, this.getWidth(), this.getHeight()); - g2.fillRect(0, 0, this.getWidth(), this.getHeight()); - - if (this.newPaint) { - this.paintGraphicsAll(g2); - } else { - //g2.drawImage(this._layoutBitmap, _xShift, _yShift, this.getBackground(), this); - AffineTransform mx = new AffineTransform(); - mx.translate((float) _xShift, (float) _yShift); - AffineTransformOp aop = new AffineTransformOp(mx, AffineTransformOp.TYPE_BILINEAR); - g2.drawImage(this._layoutBitmap, aop, 0, 0); - } - - if (this._dragMode) { - Rectangle rect = new Rectangle(); - float dash1[] = {2.0f}; - switch (this._mouseMode) { - case Map_ZoomIn: - rect.width = Math.abs(_mouseLastPos.x - _mouseDownPoint.x); - rect.height = Math.abs(_mouseLastPos.y - _mouseDownPoint.y); - rect.x = Math.min(_mouseLastPos.x, _mouseDownPoint.x); - rect.y = Math.min(_mouseLastPos.y, _mouseDownPoint.y); - //g2.setColor(this.getForeground()); - g2.setColor(Color.black); - g2.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f)); - g2.draw(rect); - break; - case MoveSelection: - rect.x = _selectedRectangle.x + _mouseLastPos.x - _mouseDownPoint.x; - rect.y = _selectedRectangle.y + _mouseLastPos.y - _mouseDownPoint.y; - rect.width = _selectedRectangle.width; - rect.height = _selectedRectangle.height; - g2.setColor(Color.red); - g2.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f)); - g2.draw(rect); - break; - case ResizeSelected: - g2.setColor(Color.red); - g2.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f)); - g2.draw(_selectedRectangle); - break; - case CreateSelection: - case New_Rectangle: - case New_Ellipse: - case Map_SelectFeatures_Rectangle: - int sx = Math.min(_mouseDownPoint.x, _mouseLastPos.x); - int sy = Math.min(_mouseDownPoint.y, _mouseLastPos.y); - g2.setColor(this.getForeground()); - g2.draw(new Rectangle(sx, sy, Math.abs(_mouseLastPos.x - _mouseDownPoint.x), - Math.abs(_mouseLastPos.y - _mouseDownPoint.y))); - break; - case New_Freehand: - case Map_SelectFeatures_Lasso: - List points = new ArrayList<>(_graphicPoints); - points.add(new PointF(_mouseLastPos.x, _mouseLastPos.y)); - g2.setColor(this.getForeground()); - _graphicPoints.add(new PointF(_mouseLastPos.x, _mouseLastPos.y)); - Draw.drawPolyline(points, g2); - break; - case New_Circle: - case Map_SelectFeatures_Circle: - int radius = (int) Math.sqrt(Math.pow(_mouseLastPos.x - _mouseDownPoint.x, 2) - + Math.pow(_mouseLastPos.y - _mouseDownPoint.y, 2)); - g2.setColor(this.getForeground()); - g2.drawLine(_mouseDownPoint.x, _mouseDownPoint.y, _mouseLastPos.x, _mouseLastPos.y); - g2.drawOval(_mouseDownPoint.x - radius, _mouseDownPoint.y - radius, - radius * 2, radius * 2); - break; - case InEditingVertices: - PointF p1 = pageToScreen((float) _editingVertices.get(1).X, (float) _editingVertices.get(1).Y); - PointF p2 = pageToScreen((float) _editingVertices.get(2).X, (float) _editingVertices.get(2).Y); - g2.setColor(Color.black); - g2.drawLine((int) p1.X, (int) p1.Y, _mouseLastPos.x, _mouseLastPos.y); - if (_editingVertices.size() == 3) { - g2.drawLine((int) p2.X, (int) p2.Y, _mouseLastPos.x, _mouseLastPos.y); - } - - Rectangle nRect = new Rectangle(_mouseLastPos.x - 3, _mouseLastPos.y - 3, 6, 6); - g2.setColor(Color.cyan); - g2.fill(nRect); - g2.setColor(Color.black); - g2.draw(nRect); - break; - } - } - - switch (this._mouseMode) { - case New_Polyline: - case New_Polygon: - case New_Curve: - case New_CurvePolygon: - case Map_SelectFeatures_Polygon: - if (!_startNewGraphic) { - List points = new ArrayList<>(_graphicPoints); - points.add(new PointF(_mouseLastPos.x, _mouseLastPos.y)); - g2.setColor(this.getForeground()); - switch (_mouseMode) { - case New_Polyline: - Draw.drawPolyline(points, g2); - break; - case New_Polygon: - points.add(points.get(0)); - Draw.drawPolyline(points, g2); - break; - case New_Curve: - Draw.drawCurveLine(points, g2); - break; - case New_CurvePolygon: - points.add(points.get(0)); - Draw.drawCurveLine(points, g2); - break; - } - } - break; - case Map_Measurement: - if (!_startNewGraphic) { - //Draw graphic - //g.SmoothingMode = SmoothingMode.AntiAlias; - PointF[] fpoints = (PointF[]) _graphicPoints.toArray(new PointF[_graphicPoints.size()]); - PointF[] points = new PointF[fpoints.length + 1]; - System.arraycopy(fpoints, 0, points, 0, fpoints.length); - points[_graphicPoints.size()] = new PointF(_mouseLastPos.x, _mouseLastPos.y); - - if (_frmMeasure.getMeasureType() == MeasureTypes.Length) { - g2.setColor(Color.red); - g2.setStroke(new BasicStroke(2)); - Draw.drawPolyline(points, g2); - } else { - PointF[] ppoints = new PointF[points.length + 1]; - System.arraycopy(points, 0, ppoints, 0, points.length); - ppoints[ppoints.length - 1] = _graphicPoints.get(0); - Color aColor = new Color(Color.blue.getRed(), Color.blue.getGreen(), Color.blue.getBlue(), 100); - g2.setColor(aColor); - PolygonBreak aPB = new PolygonBreak(); - aPB.setColor(aColor); - Draw.drawPolygon(ppoints, aPB, g2); - g2.setColor(Color.red); - Draw.drawPolyline(ppoints, g2); - } - } - break; - } - - if (this._currentLayoutMap != null) { - if (this._currentLayoutMap.getMapFrame().getMapView().isDrawIdentiferShape()) { - int selLayerHandle = this._currentLayoutMap.getMapFrame().getMapView().getSelectedLayerHandle(); - if (selLayerHandle >= 0) { - MapLayer aLayer = this._currentLayoutMap.getMapFrame().getMapView().getLayerByHandle(selLayerHandle); - if (aLayer.getLayerType() == LayerTypes.VectorLayer) { - VectorLayer vLayer = (VectorLayer) aLayer; - Rectangle rect = getElementViewExtent(_currentLayoutMap); - this._currentLayoutMap.getMapFrame().getMapView().drawIdShape(g2, vLayer.getShapes().get(vLayer.getIdentiferShape()), rect); - } - } - } - } - } - - /** - * New paint - */ - public void repaintNew() { - if (this.doubleBuffer) { - this.newPaint = false; - this.paintGraphics(); - } else { - this.newPaint = true; - this.repaint(); - this.updateViewImage(); - } - } - - private void repaintOld() { - if (this.doubleBuffer) { - this.repaint(); - } else { - this.newPaint = false; - this.repaint(); - } - } - - private void updateViewImage() { - if (this.getWidth() < 5 || this.getHeight() < 5) { - return; - } - - int width = this.getWidth(); - int height = this.getHeight(); - - this._layoutBitmap = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - Graphics2D g = this._layoutBitmap.createGraphics(); - this.print(g); - g.dispose(); - } - - public void paintGraphicsAll(Graphics2D g) { - if (this._lockViewUpdate) { - return; - } - - if (this.getWidth() < 10 || this.getHeight() < 10) { - return; - } - - if ((this._pageBounds.width < 2) || (this._pageBounds.height < 2)) { - return; - } - - g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); - - //Judge if show scroll bar - int pageHeight = (int) (_pageBounds.height * _zoom); - int pageWidth = (int) (_pageBounds.width * _zoom); - if (pageHeight > this.getHeight()) { - int sHeight = pageHeight - this.getHeight() + 40; - _vScrollBar.setMinimum(0); - _vScrollBar.setMaximum(pageHeight); - _vScrollBar.setVisibleAmount(pageHeight - sHeight); - _vScrollBar.setUnitIncrement(pageHeight / 10); - _vScrollBar.setBlockIncrement(pageHeight / 5); - if (_vScrollBar.getWidth() == 0) { - _vScrollBar.setSize(21, this._vScrollBar.getHeight()); - } - - if (_vScrollBar.isVisible() == false) { - _vScrollBar.setValue(0); - _vScrollBar.setVisible(true); - } - } else { - _pageBounds.y = 0; - this._pageLocation.Y = 0; - _vScrollBar.setVisible(false); - } - - if (pageWidth > this.getWidth()) { - int sWidth = pageWidth - this.getWidth() + 40; - _hScrollBar.setMinimum(0); - _hScrollBar.setMaximum(pageWidth); - _hScrollBar.setVisibleAmount(pageWidth - sWidth); - _hScrollBar.setUnitIncrement(pageWidth / 10); - _hScrollBar.setBlockIncrement(pageWidth / 5); - if (this._hScrollBar.getHeight() == 0) { - this._hScrollBar.setSize(this._hScrollBar.getWidth(), 21); - } - - if (_hScrollBar.isVisible() == false) { - _hScrollBar.setValue(0); - _hScrollBar.setVisible(true); - } - } else { - _pageBounds.x = 0; - this._pageLocation.X = 0; - _hScrollBar.setVisible(false); - } - - //Draw bound rectangle - Rectangle.Float aRect = pageToScreen(_pageBounds.x, _pageBounds.y, _pageBounds.width, _pageBounds.height); - g.setColor(_pageBackColor); - g.fill(aRect); - - //Draw layout elements - paintGraphicsOnLayout(g); - } - - public void paintGraphics() { - if (this._lockViewUpdate) { - return; - } - - if (this.getWidth() < 10 || this.getHeight() < 10) { - return; - } - - if ((this._pageBounds.width < 2) || (this._pageBounds.height < 2)) { - return; - } - - _layoutBitmap = new BufferedImage(this.getWidth(), - this.getHeight(), BufferedImage.TYPE_INT_ARGB); - Graphics2D g = _layoutBitmap.createGraphics(); - g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); - - //Judge if show scroll bar - int pageHeight = (int) (_pageBounds.height * _zoom); - int pageWidth = (int) (_pageBounds.width * _zoom); - if (pageHeight > this.getHeight()) { - int sHeight = pageHeight - this.getHeight() + 40; - _vScrollBar.setMinimum(0); - _vScrollBar.setMaximum(pageHeight); - _vScrollBar.setVisibleAmount(pageHeight - sHeight); - _vScrollBar.setUnitIncrement(pageHeight / 10); - _vScrollBar.setBlockIncrement(pageHeight / 5); - if (_vScrollBar.getWidth() == 0) { - _vScrollBar.setSize(21, this._vScrollBar.getHeight()); - } - - if (_vScrollBar.isVisible() == false) { - _vScrollBar.setValue(0); - _vScrollBar.setVisible(true); - } - } else { - _pageBounds.y = 0; - this._pageLocation.Y = 0; - _vScrollBar.setVisible(false); - } - - if (pageWidth > this.getWidth()) { - int sWidth = pageWidth - this.getWidth() + 40; - _hScrollBar.setMinimum(0); - _hScrollBar.setMaximum(pageWidth); - _hScrollBar.setVisibleAmount(pageWidth - sWidth); - _hScrollBar.setUnitIncrement(pageWidth / 10); - _hScrollBar.setBlockIncrement(pageWidth / 5); - if (this._hScrollBar.getHeight() == 0) { - this._hScrollBar.setSize(this._hScrollBar.getWidth(), 21); - } - - if (_hScrollBar.isVisible() == false) { - _hScrollBar.setValue(0); - _hScrollBar.setVisible(true); - } - } else { - _pageBounds.x = 0; - this._pageLocation.X = 0; - _hScrollBar.setVisible(false); - } - - //Draw bound rectangle - Rectangle.Float aRect = pageToScreen(_pageBounds.x, _pageBounds.y, _pageBounds.width, _pageBounds.height); - g.setColor(_pageBackColor); - g.fill(aRect); - - //Draw layout elements - paintGraphicsOnLayout(g); - - g.dispose(); - this.repaint(); - } - - /** - * Paint graphics on layout - * - * @param g Graphics2D - */ - public void paintGraphicsOnLayout(Graphics2D g) { - //g.SmoothingMode = _smoothingMode; - //g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; - - for (LayoutElement aElement : _layoutElements) { - if (!aElement.isVisible()) { - continue; - } - - aElement.paintOnLayout(g, _pageLocation, _zoom); - } - - //Draws the selection rectangle around each selected item - for (LayoutElement aElement : _layoutElements) { - if (!aElement.isVisible()) { - continue; - } - - if (aElement.isSelected()) { - if (_mouseMode == MouseMode.EditVertices) { - LayoutGraphic aLG = (LayoutGraphic) aElement; - List points = (List) aLG.getGraphic().getShape().getPoints(); - drawSelectedVertices(g, points); - } else { - float[] dashPattern = new float[]{2.0F, 1.0F}; - Rectangle aRect = pageToScreen(aElement.getBounds()); - g.setColor(Color.cyan); - g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 10.0f, dashPattern, 0.0f)); - g.draw(aRect); - - switch (aElement.getResizeAbility()) { - case SameWidthHeight: - drawSelectedConers(g, aElement); - break; - case ResizeAll: - drawSelectedConers(g, aElement); - drawSelectedEdgeCenters(g, aElement); - break; - } - } - } - } - } - - /** - * Paint graphics - * - * @param g Graphics2D - */ - public void paintGraphics(Graphics2D g) { - g.setColor(this._pageBackColor); - g.fillRect(0, 0, _pageBounds.width, _pageBounds.height); - - for (LayoutElement aElement : _layoutElements) { - if (!aElement.isVisible()) { - continue; - } - - //aElement.Paint(g); - aElement.paintOnLayout(g, new PointF(0, 0), 1); - } - } - - private void drawSelectedConers(Graphics2D g, LayoutElement aElement) { - Rectangle elementRect = pageToScreen(aElement.getBounds()); - int size = 6; - Rectangle rect = new Rectangle(elementRect.x - size / 2, elementRect.y - size / 2, size, size); - g.setColor(Color.cyan); - g.fill(rect); - g.setColor(Color.black); - g.draw(rect); - rect.y = elementRect.y + elementRect.height - size / 2; - g.setColor(Color.cyan); - g.fill(rect); - g.setColor(Color.black); - g.draw(rect); - rect.x = elementRect.x + elementRect.width - size / 2; - g.setColor(Color.cyan); - g.fill(rect); - g.setColor(Color.black); - g.draw(rect); - rect.y = elementRect.y - size / 2; - g.setColor(Color.cyan); - g.fill(rect); - g.setColor(Color.black); - g.draw(rect); - } - - private void drawSelectedEdgeCenters(Graphics2D g, LayoutElement aElement) { - Rectangle elementRect = pageToScreen(aElement.getBounds()); - int size = 6; - Rectangle rect = new Rectangle(elementRect.x + elementRect.width / 2 - size / 2, elementRect.y - size / 2, size, size); - g.setColor(Color.cyan); - g.fill(rect); - g.setColor(Color.black); - g.draw(rect); - rect.y = elementRect.y + elementRect.height - size / 2; - g.setColor(Color.cyan); - g.fill(rect); - g.setColor(Color.black); - g.draw(rect); - rect.x = elementRect.x - size / 2; - rect.y = elementRect.y + elementRect.height / 2 - size / 2; - g.setColor(Color.cyan); - g.fill(rect); - g.setColor(Color.black); - g.draw(rect); - rect.x = elementRect.x + elementRect.width - size / 2; - g.setColor(Color.cyan); - g.fill(rect); - g.setColor(Color.black); - g.draw(rect); - } - - private void drawSelectedVertices(Graphics2D g, List points) { - int size = 6; - Rectangle rect = new Rectangle(0, 0, size, size); - - for (PointD aPoint : points) { - PointF aP = pageToScreen((float) aPoint.X, (float) aPoint.Y); - rect.x = (int) aP.X - size / 2; - rect.y = (int) aP.Y - size / 2; - g.setColor(Color.cyan); - g.fill(rect); - g.setColor(Color.black); - g.draw(rect); - } - } - - /** - * Export to a picture file - * - * @param aFile File path - * @throws java.io.FileNotFoundException - * @throws javax.print.PrintException - */ - public void exportToPicture(String aFile) throws FileNotFoundException, PrintException, IOException { - if (aFile.endsWith(".ps")) { - DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; - String mimeType = "application/postscript"; - StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, mimeType); - FileOutputStream out = new FileOutputStream(aFile); - if (factories.length > 0) { - PrintService service = factories[0].getPrintService(out); - SimpleDoc doc = new SimpleDoc(new Printable() { - @Override - public int print(Graphics g, PageFormat pf, int page) { - if (page >= 1) { - return Printable.NO_SUCH_PAGE; - } else { - double sf1 = pf.getImageableWidth() / (_pageBounds.width + 1); - double sf2 = pf.getImageableHeight() / (_pageBounds.height + 1); - double s = Math.min(sf1, sf2); - Graphics2D g2 = (Graphics2D) g; - g2.translate((pf.getWidth() - pf.getImageableWidth()) / 2, (pf.getHeight() - pf.getImageableHeight()) / 2); - g2.scale(s, s); - - paintGraphics(g2); - return Printable.PAGE_EXISTS; - } - } - }, flavor, null); - DocPrintJob job = service.createPrintJob(); - PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet(); - job.print(doc, attributes); - out.close(); - } - } else if (aFile.endsWith(".eps")) { - int width = this.getPaperWidth(); - int height = this.getPaperHeight(); -// EPSGraphics2D g = new EPSGraphics2D(0.0, 0.0, width, height); -// paintGraphics(g); -// FileOutputStream file = new FileOutputStream(aFile); -// try { -// file.write(g.getBytes()); -// } finally { -// file.close(); -// g.dispose(); -// } - - Properties p = new Properties(); - p.setProperty("PageSize", "A5"); - VectorGraphics g = new PSGraphics2D(new File(aFile), new Dimension(width, height)); - //g.setProperties(p); - g.startExport(); - this.paintGraphics(g); - g.endExport(); - g.dispose(); - } else if (aFile.endsWith(".pdf")) { - int width = this.getPaperWidth(); - int height = this.getPaperHeight(); - try { - com.itextpdf.text.Document document = new com.itextpdf.text.Document(new com.itextpdf.text.Rectangle(width, height)); - PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(aFile)); - document.open(); - PdfContentByte cb = writer.getDirectContent(); - PdfTemplate pdfTemp = cb.createTemplate(width, height); - Graphics2D g2 = new PdfGraphics2D(pdfTemp, width, height, true); - this.paintGraphics(g2); - g2.dispose(); - cb.addTemplate(pdfTemp, 0, 0); - document.close(); - } catch (DocumentException | FileNotFoundException e) { - e.printStackTrace(); - } - } else if (aFile.endsWith(".emf")) { - int width = this.getPaperWidth(); - int height = this.getPaperHeight(); - VectorGraphics g = new EMFGraphics2D(new File(aFile), new Dimension(width, height)); - //g.setProperties(p); - g.startExport(); - this.paintGraphics(g); - g.endExport(); - g.dispose(); - } else { - String extension = aFile.substring(aFile.lastIndexOf('.') + 1); - BufferedImage aImage; - if (extension.equalsIgnoreCase("bmp")) - aImage = new BufferedImage(_pageBounds.width, _pageBounds.height, BufferedImage.TYPE_INT_RGB); - else - aImage = new BufferedImage(_pageBounds.width, _pageBounds.height, BufferedImage.TYPE_INT_ARGB); - Graphics2D g = aImage.createGraphics(); - paintGraphics(g); - if (extension.equalsIgnoreCase("jpg")) { - BufferedImage newImage = new BufferedImage(aImage.getWidth(), aImage.getHeight(), BufferedImage.TYPE_INT_RGB); - newImage.createGraphics().drawImage(aImage, 0, 0, Color.BLACK, null); - ImageIO.write(newImage, extension, new File(aFile)); - } else { - ImageIO.write(aImage, extension, new File(aFile)); - } - } - } - - /** - * Export to a picture file - * - * @param fileName File path - * @param dpi DPI - * @throws java.io.FileNotFoundException - * @throws javax.print.PrintException - */ - public void exportToPicture(String fileName, Integer dpi) throws FileNotFoundException, PrintException, IOException { - if (dpi == null) { - exportToPicture(fileName); - } else { - File output = new File(fileName); - output.delete(); - - int width = _pageBounds.width; - int height = _pageBounds.height; - String formatName = fileName.substring(fileName.lastIndexOf('.') + 1); - if (formatName.equals("jpg")) { - formatName = "jpeg"; - saveImage_Jpeg(fileName, width, height, dpi); - return; - } - - double scaleFactor = dpi / 72.0; - BufferedImage image = new BufferedImage((int)(width * scaleFactor), (int)(height * scaleFactor), BufferedImage.TYPE_INT_ARGB); - Graphics2D g = image.createGraphics(); - AffineTransform at = g.getTransform(); - at.scale(scaleFactor, scaleFactor); - g.setTransform(at); - paintGraphics(g); - for (Iterator iw = ImageIO.getImageWritersByFormatName(formatName); iw.hasNext();) { - ImageWriter writer = iw.next(); - ImageWriteParam writeParam = writer.getDefaultWriteParam(); - ImageTypeSpecifier typeSpecifier = ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_ARGB); - IIOMetadata metadata = writer.getDefaultImageMetadata(typeSpecifier, writeParam); - if (metadata.isReadOnly() || !metadata.isStandardMetadataFormatSupported()) { - continue; - } - - ImageUtil.setDPI(metadata, dpi); - - final ImageOutputStream stream = ImageIO.createImageOutputStream(output); - try { - writer.setOutput(stream); - writer.write(metadata, new IIOImage(image, null, metadata), writeParam); - } finally { - stream.close(); - } - break; - } - g.dispose(); - } - } - - private boolean saveImage_Jpeg(String file, int width, int height, int dpi) { - double scaleFactor = dpi / 72.0; - BufferedImage bufferedImage = new BufferedImage((int)(width * scaleFactor), (int)(height * scaleFactor), BufferedImage.TYPE_INT_RGB); - Graphics2D g = bufferedImage.createGraphics(); - AffineTransform at = g.getTransform(); - at.scale(scaleFactor, scaleFactor); - g.setTransform(at); - paintGraphics(g); - - try { - // Image writer - ImageWriter imageWriter = ImageIO.getImageWritersBySuffix("jpeg").next(); - ImageOutputStream ios = ImageIO.createImageOutputStream(new File(file)); - imageWriter.setOutput(ios); - - // Compression - JPEGImageWriteParam jpegParams = (JPEGImageWriteParam) imageWriter.getDefaultWriteParam(); - jpegParams.setCompressionMode(JPEGImageWriteParam.MODE_EXPLICIT); - jpegParams.setCompressionQuality(0.85f); - - // Metadata (dpi) - IIOMetadata data = imageWriter.getDefaultImageMetadata(new ImageTypeSpecifier(bufferedImage), jpegParams); - Element tree = (Element) data.getAsTree("javax_imageio_jpeg_image_1.0"); - Element jfif = (Element) tree.getElementsByTagName("app0JFIF").item(0); - jfif.setAttribute("Xdensity", Integer.toString(dpi)); - jfif.setAttribute("Ydensity", Integer.toString(dpi)); - jfif.setAttribute("resUnits", "1"); // density is dots per inch - data.setFromTree("javax_imageio_jpeg_image_1.0", tree); - - // Write and clean up - imageWriter.write(null, new IIOImage(bufferedImage, null, data), jpegParams); - ios.close(); - imageWriter.dispose(); - } catch (Exception e) { - return false; - } - g.dispose(); - - return true; - } - - // - // - - /** - * Convert screen coordinate to page coordinate - * - * @param screenX Screen x - * @param screenY Screen y - * @return Page position - */ - public Point screenToPage(int screenX, int screenY) { - float x = (screenX - _pageLocation.X) / _zoom; - float y = (screenY - _pageLocation.Y) / _zoom; - return (new Point((int) x, (int) y)); - } - - /** - * Convert screen coordinate to page coordinate - * - * @param screenX Screen x - * @param screenY Screen y - * @return Page position - */ - public PointF screenToPage(float screenX, float screenY) { - float x = (screenX - _pageLocation.X) / _zoom; - float y = (screenY - _pageLocation.Y) / _zoom; - return (new PointF(x, y)); - } - - private PointF pageToScreen(float pageX, float pageY) { - float x = pageX * _zoom + _pageLocation.X; - float y = pageY * _zoom + _pageLocation.Y; - return (new PointF(x, y)); - } - - private Rectangle.Float pageToScreen(float pageX, float pageY, float pageW, float pageH) { - PointF screenTL = pageToScreen(pageX, pageY); - PointF screenBR = pageToScreen(pageX + pageW, pageY + pageH); - return new Rectangle.Float(screenTL.X, screenTL.Y, screenBR.X - screenTL.X, screenBR.Y - screenTL.Y); - } - - private Rectangle pageToScreen(Rectangle rect) { - PointF screenTL = pageToScreen(rect.x, rect.y); - PointF screenBR = pageToScreen(rect.x + rect.width, rect.y + rect.height); - return new Rectangle((int) screenTL.X, (int) screenTL.Y, (int) (screenBR.X - screenTL.X), (int) (screenBR.Y - screenTL.Y)); - } - - private Rectangle.Float paperToScreen(Rectangle.Float paper) { - return paperToScreen(paper.x, paper.y, paper.width, paper.height); - } - - /** - * Converts a rectangle in paper coordiants in 1/100 of an inch to screen - * coordinants - * - * @param paperX Paper x - * @param paperY Paper Y - * @param paperW Paper width - * @param paperH Paper height - * @return Screen rectangle - */ - private Rectangle.Float paperToScreen(float paperX, float paperY, float paperW, float paperH) { - PointF screenTL = paperToScreen(paperX, paperY); - PointF screenBR = paperToScreen(paperX + paperW, paperY + paperH); - return new Rectangle.Float(screenTL.X, screenTL.Y, screenBR.X - screenTL.X, screenBR.Y - screenTL.Y); - } - - /** - * Converts between a point in paper coordinants in 1/100th of an inch to - * screen coordinants - * - * @param paperX Paper x - * @param paperY Paper y - * @return Screen point - */ - private PointF paperToScreen(float paperX, float paperY) { - float screenX = (paperX / 100F * 96F * _zoom) + _pageLocation.X; - float screenY = (paperY / 100F * 96F * _zoom) + _pageLocation.Y; - return (new PointF(screenX, screenY)); - } - // - // - - /** - * Update the order of the map frames - */ - public void updateMapFrameOrder() { - List lms = getLayoutMaps(); - for (int i = 0; i < lms.size(); i++) { - lms.get(i).getMapFrame().setOrder(i); - } - } - - /** - * Update map frames - * - * @param mapFrames The map frames - */ - public void updateMapFrames(List mapFrames) { - for (MapFrame mf : mapFrames) { - boolean isNew = true; - for (MapFrame aMF : _mapFrames) { - if (mf == aMF) { - isNew = false; - break; - } - } - if (isNew) { - LayoutMap aLM = new LayoutMap(mf, this.tileLoadListener); - addElement(aLM); - } - } - - for (int i = 0; i < _mapFrames.size(); i++) { - MapFrame mf = _mapFrames.get(i); - boolean isNew = true; - for (MapFrame aMF : mapFrames) { - if (mf == aMF) { - isNew = false; - break; - } - } - if (isNew) { - LayoutMap aLM = getLayoutMap(mf); - if (aLM != null) { - removeElement(aLM); - i -= 1; - } - } - } - - this.setMapFrames(mapFrames); - } - - /** - * Add a layout element - * - * @param aElement The layout element - */ - public void addElement(LayoutElement aElement) { - _layoutElements.add(aElement); - if (aElement.getElementType() == ElementType.LayoutMap) { - final LayoutMap aLM = (LayoutMap) aElement; - aLM.addMapViewUpdatedListener(new IMapViewUpdatedListener() { - @Override - public void mapViewUpdatedEvent(MapViewUpdatedEvent event) { - //if (aLM.getMapFrame().isFireMapViewUpdate()) { - //paintGraphics(); - repaintNew(); - //} - } - }); - if (aLM.getMapFrame().isActive()) { - _currentLayoutMap = aLM; - } - } - } - - /** - * Remove a layout element - * - * @param aElement The layout element - */ - public void removeElement(LayoutElement aElement) { - switch (aElement.getElementType()) { - case LayoutMap: - if (this.getLayoutMaps().size() == 1) { - JOptionPane.showMessageDialog(this, "There is at least one layout map!"); - return; - } - - LayoutMap aLM = (LayoutMap) aElement; - for (int i = 0; i < _layoutElements.size(); i++) { - LayoutElement aLE = _layoutElements.get(i); - switch (aLE.getElementType()) { - case LayoutLegend: - if (((LayoutLegend) aLE).getLayoutMap() == aLM) { - _layoutElements.remove(aLE); - i -= 1; - } - break; - case LayoutScaleBar: - if (((LayoutScaleBar) aLE).getLayoutMap() == aLM) { - _layoutElements.remove(aLE); - i -= 1; - } - break; - case LayoutNorthArraw: - if (((LayoutNorthArrow) aLE).getLayoutMap() == aLM) { - _layoutElements.remove(aLE); - i -= 1; - } - break; - } - } - _mapFrames.remove(aLM.getMapFrame()); - _layoutElements.remove(aElement); - if (_mapFrames.size() > 0) { - setActiveMapFrame(_mapFrames.get(0)); - } - this.fireMapFramesUpdatedEvent(); - break; - default: - _layoutElements.remove(aElement); - break; - } -// if (this._selectedElements.contains(aElement)){ -// this._selectedElements.remove(aElement); -// } - } - - /** - * Add a text label element - * - * @param text The text - * @param x Center x - * @param y Center y - * @return Text layout graphic - */ - public LayoutGraphic addText(String text, int x, int y) { - return addText(text, x, y, _defLabelBreak.getFont().getFontName(), _defLabelBreak.getFont().getSize()); - } - - /** - * Add a text label element - * - * @param text The text - * @param x Center x - * @param y Center y - * @param fontSize Font size - * @return Text layout graphic - */ - public LayoutGraphic addText(String text, int x, int y, float fontSize) { - return addText(text, x, y, _defLabelBreak.getFont().getName(), fontSize); - } - - /** - * Add a text label element - * - * @param text The text - * @param x Center x - * @param y Center y - * @param fontName Font name - * @param fontSize Font size - * @return Text layout graphic - */ - public LayoutGraphic addText(String text, int x, int y, String fontName, float fontSize) { - PointShape aPS = new PointShape(); - aPS.setPoint(new PointD(x, y)); - LabelBreak aLB = (LabelBreak) _defLabelBreak.clone(); - aLB.setText(text); - aLB.setFont(new Font(fontName, Font.PLAIN, (int) fontSize)); - Graphic aGraphic = new Graphic(aPS, aLB); - LayoutGraphic aLayoutGraphic = new LayoutGraphic(aGraphic, this); - addElement(aLayoutGraphic); - - return aLayoutGraphic; - } - - public LayoutGraphic addWindArrow(int left, int top) { - WindArrow aWindArraw = new WindArrow(); - //aWindArraw.setPoint(new PointD(left, top)); - aWindArraw.angle = 270; - aWindArraw.length = 20; - VectorBreak aVB = new VectorBreak(); - aVB.setColor(Color.black); - LayoutGraphic wag = new LayoutGraphic(new Graphic(aWindArraw, aVB), this, - this.getActiveLayoutMap()); - wag.setLeft(left); - wag.setTop(top); - addElement(wag); - - return wag; - } - - /** - * Add a layout legend - * - * @param left Left - * @param top Top - * @return Layout legend - */ - public LayoutLegend addLegend(int left, int top) { - LayoutMap aLM = getActiveLayoutMap(); - LayoutLegend aLL = new LayoutLegend(this, aLM); - aLL.setLeft(left); - aLL.setTop(top); - if (aLM.getMapFrame().getMapView().getLayerNum() > 0) { - for (MapLayer aLayer : aLM.getMapFrame().getMapView().getLayers()) { - if (aLayer.getLayerType() != LayerTypes.ImageLayer) { - aLL.setLegendLayer(aLayer); - } - } - } - - addElement(aLL); - - return aLL; - } - - /** - * Add a layout scale bar - * - * @param left Left - * @param top Top - * @return Layout scale bar - */ - public LayoutScaleBar addScaleBar(int left, int top) { - LayoutMap aLM = getActiveLayoutMap(); - LayoutScaleBar aLSB = new LayoutScaleBar(aLM); - aLSB.setLeft(left); - aLSB.setTop(top); - addElement(aLSB); - - return aLSB; - } - - /** - * Add a layout north arrow - * - * @param left Left - * @param top Top - * @return Layout north arrow - */ - public LayoutNorthArrow addNorthArrow(int left, int top) { - LayoutMap aLM = getActiveLayoutMap(); - LayoutNorthArrow aLNA = new LayoutNorthArrow(aLM); - aLNA.setLeft(left); - aLNA.setTop(top); - addElement(aLNA); - - return aLNA; - } - - /** - * Add a layout chart - * - * @param left Left - * @param top Top - * @return Layout chart - */ - public LayoutChart addChart(int left, int top) { - LayoutChart chart = new LayoutChart(); - chart.setLeft(left); - chart.setTop(top); - addElement(chart); - - return chart; - } - - /** - * Get layout graphic list - * - * @return Layout graphic list - */ - public List getLayoutGraphics() { - List graphics = new ArrayList<>(); - for (LayoutElement aLE : _layoutElements) { - if (aLE.getElementType() == ElementType.LayoutGraphic) { - graphics.add((LayoutGraphic) aLE); - } - } - - return graphics; - } - - /** - * Get text graphic list - * - * @return Text graphic list - */ - public List getTexts() { - List texts = new ArrayList<>(); - List graphics = getLayoutGraphics(); - for (LayoutGraphic aLG : graphics) { - if (aLG.getGraphic().getLegend().getBreakType() == BreakTypes.LabelBreak) { - texts.add(aLG); - } - } - - return texts; - } - - /** - * Get a text graphic by text string - * - * @param text Text string - * @return Text graphic - */ - public LayoutGraphic getText(String text) { - List texts = getTexts(); - for (LayoutGraphic aLG : texts) { - if (((LabelBreak) aLG.getGraphic().getLegend()).getText().equals(text)) { - return aLG; - } - } - - return null; - } - - /** - * Get layout legend list - * - * @return Layout legend list - */ - public List getLegends() { - List legends = new ArrayList<>(); - for (LayoutElement aLE : _layoutElements) { - if (aLE.getElementType() == ElementType.LayoutLegend) { - legends.add((LayoutLegend) aLE); - } - } - - return legends; - } - - /** - * Set a map frame as active - * - * @param mapFrame The map frame - */ - public void setActiveMapFrame(MapFrame mapFrame) { - for (MapFrame mf : _mapFrames) { - mf.setActive(false); - } - - mapFrame.setActive(true); - this.fireActiveMapFrameChangedEvent(); - } - - private LayoutMap getLayoutMap(MapFrame mapFrame) { - LayoutMap aLM = null; - for (LayoutMap lm : this.getLayoutMaps()) { - if (lm.getMapFrame() == mapFrame) { - aLM = lm; - break; - } - } - - return aLM; - } - - private LayoutMap getLayoutMap(Point aPoint) { - for (int i = getLayoutMaps().size() - 1; i >= 0; i--) { - LayoutMap aLM = getLayoutMaps().get(i); - if (MIMath.pointInRectangle(aPoint, aLM.getBounds())) { - return aLM; - } - } - - return null; - } - - private int getLayoutMapIndex(LayoutMap aLM) { - return getLayoutMaps().indexOf(aLM); - } - - /** - * If has legend element - * - * @return Boolean - */ - public boolean hasLegendElement() { - for (LayoutElement aLE : _layoutElements) { - if (aLE.getElementType() == ElementType.LayoutLegend) { - return true; - } - } - return false; - } - - private List selectElements(Point aPoint, List baseElements, int limit) { - List selectedElements = new ArrayList<>(); - for (int i = baseElements.size() - 1; i >= 0; i--) { - LayoutElement element = baseElements.get(i); - if (element.isVisible()) { - Rectangle rect = (Rectangle) element.getBounds().clone(); - if (rect.width < 5) { - rect.width = 5; - rect.x -= 2.5; - } - if (rect.height < 5) { - rect.height = 5; - rect.y -= 2.5; - } - rect.width += limit; - rect.height += limit; - if (MIMath.pointInRectangle(aPoint, rect)) { - selectedElements.add(element); - } - } - } - - return selectedElements; - } - - private Rectangle getElementViewExtent(LayoutElement aLE) { - PointF aP = aLE.pageToScreen(aLE.getLeft(), aLE.getTop(), _pageLocation, _zoom); - Rectangle rect = new Rectangle((int) aP.X, (int) aP.Y, (int) (aLE.getWidth() * _zoom), (int) (aLE.getHeight() * _zoom)); - - return rect; - } - - private int selectEditVertices(Point aPoint, org.meteoinfo.geometry.shape.Shape aShape, List vertices) { - List points = (List) aShape.getPoints(); - int buffer = 4; - Rectangle rect = new Rectangle(aPoint.x - buffer / 2, aPoint.y - buffer / 2, buffer, buffer); - vertices.clear(); - PointD aPD; - int vIdx = -1; - for (int i = 0; i < points.size(); i++) { - if (MIMath.pointInRectangle(points.get(i), rect)) { - vIdx = i; - vertices.add(points.get(i)); - switch (aShape.getShapeType()) { - case Polyline: - case CurveLine: - if (i == 0) { - vertices.add(points.get(i + 1)); - } else if (i == points.size() - 1) { - vertices.add(points.get(i - 1)); - } else { - vertices.add(points.get(i - 1)); - vertices.add(points.get(i + 1)); - } - break; - default: - if (i == 0) { - vertices.add(points.get(i + 1)); - aPD = points.get(points.size() - 1); - if (aPD.X == points.get(i).X && aPD.Y == points.get(i).Y) { - vertices.add(points.get(points.size() - 2)); - } else { - vertices.add(aPD); - } - } else if (i == points.size() - 1) { - vertices.add(points.get(i - 1)); - aPD = points.get(0); - if (aPD.X == points.get(i).X && aPD.Y == points.get(i).Y) { - vertices.add(points.get(1)); - } else { - vertices.add(points.get(0)); - } - } else { - vertices.add(points.get(i - 1)); - vertices.add(points.get(i + 1)); - } - break; - } - break; -// if (aShape.getShapeType() == ShapeTypes.Polyline) { -// if (i == 0) { -// vertices.add(points.get(i + 1)); -// } else if (i == points.size() - 1) { -// vertices.add(points.get(i - 1)); -// } else { -// vertices.add(points.get(i - 1)); -// vertices.add(points.get(i + 1)); -// } -// } else { -// if (i == 0) { -// vertices.add(points.get(i + 1)); -// aPD = points.get(points.size() - 1); -// if (aPD.X == points.get(i).X && aPD.Y == points.get(i).Y) { -// vertices.add(points.get(points.size() - 2)); -// } else { -// vertices.add(aPD); -// } -// } else if (i == points.size() - 1) { -// vertices.add(points.get(i - 1)); -// aPD = points.get(0); -// if (aPD.X == points.get(i).X && aPD.Y == points.get(i).Y) { -// vertices.add(points.get(1)); -// } else { -// vertices.add(points.get(0)); -// } -// } else { -// vertices.add(points.get(i - 1)); -// vertices.add(points.get(i + 1)); -// } -// } - } - } - - return vIdx; - } - - private boolean isInLayoutMaps(Point aPoint) { - for (LayoutMap aLM : getLayoutMaps()) { - if (MIMath.pointInRectangle(aPoint, aLM.getBounds())) { - return true; - } - } - - return false; - } - - private static Edge intersectElementEdge(Rectangle screen, PointF pt, float limit) { - Rectangle.Float ptRect = new Rectangle.Float(pt.X - limit, pt.Y - limit, 2F * limit, 2F * limit); - if ((pt.X >= screen.x - limit && pt.X <= screen.x + limit) && (pt.Y >= screen.y - limit && pt.Y <= screen.y + limit)) { - return Edge.TopLeft; - } - if ((pt.X >= screen.x + screen.width - limit && pt.X <= screen.x + screen.width + limit) && (pt.Y >= screen.y - limit && pt.Y <= screen.y + limit)) { - return Edge.TopRight; - } - if ((pt.X >= screen.x + screen.width - limit && pt.X <= screen.x + screen.width + limit) && (pt.Y >= screen.y + screen.height - limit && pt.Y <= screen.y + screen.height + limit)) { - return Edge.BottomRight; - } - if ((pt.X >= screen.x - limit && pt.X <= screen.x + limit) && (pt.Y >= screen.y + screen.height - limit && pt.Y <= screen.y + screen.height + limit)) { - return Edge.BottomLeft; - } - if (ptRect.intersects(new Rectangle.Float(screen.x, screen.y, screen.width, 1F))) { - return Edge.Top; - } - if (ptRect.intersects(new Rectangle.Float(screen.x, screen.y, 1F, screen.height))) { - return Edge.Left; - } - if (ptRect.intersects(new Rectangle.Float(screen.x, screen.y + screen.height, screen.width, 1F))) { - return Edge.Bottom; - } - if (ptRect.intersects(new Rectangle.Float(screen.x + screen.width, screen.y, 1F, screen.height))) { - return Edge.Right; - } - return Edge.None; - } - // - - // - private void updatePageSet() { - Rectangle.Float aRect = paperToScreen(new Rectangle.Float(0, 0, this.getPaperWidth(), this.getPaperHeight())); - _pageBounds.width = (int) aRect.width; - _pageBounds.height = (int) aRect.height; - } - - /** - * Show measurment form - */ - public void showMeasurementForm() { - if (_frmMeasure == null) { - _frmMeasure = new FrmMeasurement((JFrame) SwingUtilities.getWindowAncestor(this), false); - _frmMeasure.addWindowListener(new WindowAdapter() { - @Override - public void windowClosed(WindowEvent e) { - _currentLayoutMap.getMapFrame().getMapView().setDrawIdentiferShape(false); - //repaint(); - repaintOld(); - } - }); - _frmMeasure.setLocationRelativeTo(this); - _frmMeasure.setVisible(true); - } else if (!_frmMeasure.isVisible()) { - _frmMeasure.setVisible(true); - } - } - - // - // - /** - * Export project XML content - * - * @param m_Doc XML document - * @param parent Parent XML element - */ - public void exportProjectXML(Document m_Doc, Element parent) { - exportLayout(m_Doc, parent); - } - - private void exportLayout(Document m_Doc, Element parent) { - Element layout = m_Doc.createElement("Layout"); - - //Add attribute - Attr BackColor = m_Doc.createAttribute("BackColor"); - Attr ForeColor = m_Doc.createAttribute("ForeColor"); - Attr SmoothingMode = m_Doc.createAttribute("SmoothingMode"); - Attr PaperSizeName = m_Doc.createAttribute("PaperSizeName"); - Attr PaperSizeWidth = m_Doc.createAttribute("PaperSizeWidth"); - Attr PaperSizeHeight = m_Doc.createAttribute("PaperSizeHeight"); - Attr Landscape = m_Doc.createAttribute("Landscape"); - - BackColor.setValue(ColorUtil.toHexEncoding(_pageBackColor)); - ForeColor.setValue(ColorUtil.toHexEncoding(_pageForeColor)); - SmoothingMode.setValue(String.valueOf(_antiAlias)); - PaperSizeName.setValue(_paperSize.getName()); - PaperSizeWidth.setValue(String.valueOf(_paperSize.getWidth())); - PaperSizeHeight.setValue(String.valueOf(_paperSize.getHeight())); - Landscape.setValue(String.valueOf(_isLandscape)); - - layout.setAttributeNode(BackColor); - layout.setAttributeNode(ForeColor); - layout.setAttributeNode(SmoothingMode); - layout.setAttributeNode(PaperSizeName); - layout.setAttributeNode(PaperSizeWidth); - layout.setAttributeNode(PaperSizeHeight); - layout.setAttributeNode(Landscape); - - parent.appendChild(layout); - - //Add layout elements - addLayoutElements(m_Doc, layout); - } - - private void addLayoutElements(Document doc, Element parent) { - Element layoutElements = doc.createElement("LayoutElements"); - for (LayoutElement aElement : _layoutElements) { - switch (aElement.getElementType()) { - case LayoutMap: - addLayoutMapElement(doc, layoutElements, (LayoutMap) aElement); - break; - case LayoutIllustration: - //AddIllustrationElement(ref doc, layoutElements, (LayoutIllustrationMap)aElement); - break; - case LayoutLegend: - addLayoutLegendElement(doc, layoutElements, (LayoutLegend) aElement); - break; - case LayoutGraphic: - addLayoutGraphicElement(doc, layoutElements, (LayoutGraphic) aElement); - break; - case LayoutScaleBar: - addLayoutScaleBarElement(doc, layoutElements, (LayoutScaleBar) aElement); - break; - case LayoutNorthArraw: - addLayoutNorthArrowElement(doc, layoutElements, (LayoutNorthArrow) aElement); - break; - } - } - parent.appendChild(layoutElements); - } - - private void addLayoutMapElement(Document m_Doc, Element parent, LayoutMap aMap) { - Element layoutMap = m_Doc.createElement("LayoutMap"); - Attr elementType = m_Doc.createAttribute("ElementType"); - Attr left = m_Doc.createAttribute("Left"); - Attr top = m_Doc.createAttribute("Top"); - Attr width = m_Doc.createAttribute("Width"); - Attr height = m_Doc.createAttribute("Height"); - Attr DrawMapNeatLine = m_Doc.createAttribute("DrawNeatLine"); - Attr MapNeatLineColor = m_Doc.createAttribute("NeatLineColor"); - Attr MapNeatLineSize = m_Doc.createAttribute("NeatLineSize"); - Attr GridLineColor = m_Doc.createAttribute("GridLineColor"); - Attr GridLineSize = m_Doc.createAttribute("GridLineSize"); - Attr GridLineStyle = m_Doc.createAttribute("GridLineStyle"); - Attr DrawGridLine = m_Doc.createAttribute("DrawGridLine"); - Attr DrawGridLabel = m_Doc.createAttribute("DrawGridLabel"); - Attr GridFontName = m_Doc.createAttribute("GridFontName"); - Attr GridFontSize = m_Doc.createAttribute("GridFontSize"); - Attr GridXDelt = m_Doc.createAttribute("GridXDelt"); - Attr GridYDelt = m_Doc.createAttribute("GridYDelt"); - Attr GridXOrigin = m_Doc.createAttribute("GridXOrigin"); - Attr GridYOrigin = m_Doc.createAttribute("GridYOrigin"); - Attr gridLabelPosition = m_Doc.createAttribute("GridLabelPosition"); - Attr drawDegreeSymbol = m_Doc.createAttribute("DrawDegreeSymbol"); - Attr drawBackColor = m_Doc.createAttribute("DrawBackColor"); - - elementType.setValue(aMap.getElementType().toString()); - left.setValue(String.valueOf(aMap.getLeft())); - top.setValue(String.valueOf(aMap.getTop())); - width.setValue(String.valueOf(aMap.getWidth())); - height.setValue(String.valueOf(aMap.getHeight())); - DrawMapNeatLine.setValue(String.valueOf(aMap.isDrawNeatLine())); - MapNeatLineColor.setValue(ColorUtil.toHexEncoding(aMap.getNeatLineColor())); - MapNeatLineSize.setValue(String.valueOf(aMap.getNeatLineSize())); - GridLineColor.setValue(ColorUtil.toHexEncoding(aMap.getGridLineColor())); - GridLineSize.setValue(String.valueOf(aMap.getGridLineSize())); - GridLineStyle.setValue(aMap.getGridLineStyle().toString()); - DrawGridLine.setValue(String.valueOf(aMap.isDrawGridLine())); - DrawGridLabel.setValue(String.valueOf(aMap.isDrawGridLabel())); - GridFontName.setValue(aMap.getGridFont().getFontName()); - GridFontSize.setValue(String.valueOf(aMap.getGridFont().getSize())); - GridXDelt.setValue(String.valueOf(aMap.getGridXDelt())); - GridYDelt.setValue(String.valueOf(aMap.getGridYDelt())); - GridXOrigin.setValue(String.valueOf(aMap.getGridXOrigin())); - GridYOrigin.setValue(String.valueOf(aMap.getGridYOrigin())); - gridLabelPosition.setValue(aMap.getGridLabelPosition().toString()); - drawDegreeSymbol.setValue(String.valueOf(aMap.isDrawDegreeSymbol())); - drawBackColor.setValue(String.valueOf(aMap.isDrawBackColor())); - - layoutMap.setAttributeNode(elementType); - layoutMap.setAttributeNode(left); - layoutMap.setAttributeNode(top); - layoutMap.setAttributeNode(width); - layoutMap.setAttributeNode(height); - layoutMap.setAttributeNode(DrawMapNeatLine); - layoutMap.setAttributeNode(MapNeatLineColor); - layoutMap.setAttributeNode(MapNeatLineSize); - layoutMap.setAttributeNode(GridLineColor); - layoutMap.setAttributeNode(GridLineSize); - layoutMap.setAttributeNode(GridLineStyle); - layoutMap.setAttributeNode(DrawGridLine); - layoutMap.setAttributeNode(DrawGridLabel); - layoutMap.setAttributeNode(GridFontName); - layoutMap.setAttributeNode(GridFontSize); - layoutMap.setAttributeNode(GridXDelt); - layoutMap.setAttributeNode(GridYDelt); - layoutMap.setAttributeNode(GridXOrigin); - layoutMap.setAttributeNode(GridYOrigin); - layoutMap.setAttributeNode(gridLabelPosition); - layoutMap.setAttributeNode(drawDegreeSymbol); - layoutMap.setAttributeNode(drawBackColor); - - parent.appendChild(layoutMap); - } - - private void addLayoutLegendElement(Document doc, Element parent, LayoutLegend aLegend) { - Element Legend = doc.createElement("LayoutLegend"); - Attr elementType = doc.createAttribute("ElementType"); - Attr layoutMapIndex = doc.createAttribute("LayoutMapIndex"); - Attr legendLayer = doc.createAttribute("LegendLayer"); - Attr LegendStyle = doc.createAttribute("LegendStyle"); - Attr layerUpdateType = doc.createAttribute("LayerUpdateType"); - Attr BackColor = doc.createAttribute("BackColor"); - Attr DrawNeatLine = doc.createAttribute("DrawNeatLine"); - Attr NeatLineColor = doc.createAttribute("NeatLineColor"); - Attr NeatLineSize = doc.createAttribute("NeatLineSize"); - Attr drawChartBreaks = doc.createAttribute("DrawChartBreaks"); - Attr Left = doc.createAttribute("Left"); - Attr Top = doc.createAttribute("Top"); - Attr Width = doc.createAttribute("Width"); - Attr Height = doc.createAttribute("Height"); - Attr FontName = doc.createAttribute("FontName"); - Attr FontSize = doc.createAttribute("FontSize"); - Attr colNum = doc.createAttribute("ColumnNumber"); - Attr drawBackColor = doc.createAttribute("DrawBackColor"); - Attr forceDrawOutline = doc.createAttribute("ForceDrawOutline"); - - elementType.setValue(aLegend.getElementType().toString()); - layoutMapIndex.setValue(String.valueOf(getLayoutMapIndex(aLegend.getLayoutMap()))); - legendLayer.setValue(aLegend.getLayerName()); - LegendStyle.setValue(aLegend.getLegendStyle().toString()); - layerUpdateType.setValue(aLegend.getLayerUpdateType().toString()); - BackColor.setValue(ColorUtil.toHexEncoding(aLegend.getBackColor())); - DrawNeatLine.setValue(String.valueOf(aLegend.isDrawNeatLine())); - NeatLineColor.setValue(ColorUtil.toHexEncoding(aLegend.getNeatLineColor())); - NeatLineSize.setValue(String.valueOf(aLegend.getNeatLineSize())); - drawChartBreaks.setValue(String.valueOf(aLegend.isDrawChartBreaks())); - Left.setValue(String.valueOf(aLegend.getLeft())); - Top.setValue(String.valueOf(aLegend.getTop())); - Width.setValue(String.valueOf(aLegend.getWidth())); - Height.setValue(String.valueOf(aLegend.getHeight())); - FontName.setValue(aLegend.getFont().getFontName()); - FontSize.setValue(String.valueOf(aLegend.getFont().getSize())); - colNum.setValue(String.valueOf(aLegend.getColumnNumber())); - drawBackColor.setValue(String.valueOf(aLegend.isDrawBackColor())); - forceDrawOutline.setValue(String.valueOf(aLegend.isForceDrawOutline())); - - Legend.setAttributeNode(elementType); - Legend.setAttributeNode(layoutMapIndex); - Legend.setAttributeNode(legendLayer); - Legend.setAttributeNode(LegendStyle); - Legend.setAttributeNode(layerUpdateType); - Legend.setAttributeNode(BackColor); - Legend.setAttributeNode(DrawNeatLine); - Legend.setAttributeNode(NeatLineColor); - Legend.setAttributeNode(NeatLineSize); - Legend.setAttributeNode(drawChartBreaks); - Legend.setAttributeNode(Left); - Legend.setAttributeNode(Top); - Legend.setAttributeNode(Width); - Legend.setAttributeNode(Height); - Legend.setAttributeNode(FontName); - Legend.setAttributeNode(FontSize); - Legend.setAttributeNode(colNum); - Legend.setAttributeNode(drawBackColor); - Legend.setAttributeNode(forceDrawOutline); - - parent.appendChild(Legend); - } - - private void addLayoutScaleBarElement(Document doc, Element parent, LayoutScaleBar aScaleBar) { - Element scaleBar = doc.createElement("LayoutScaleBar"); - Attr elementType = doc.createAttribute("ElementType"); - Attr layoutMapIndex = doc.createAttribute("LayoutMapIndex"); - Attr scaleBarType = doc.createAttribute("ScaleBarType"); - Attr BackColor = doc.createAttribute("BackColor"); - Attr foreColor = doc.createAttribute("ForeColor"); - Attr DrawNeatLine = doc.createAttribute("DrawNeatLine"); - Attr NeatLineColor = doc.createAttribute("NeatLineColor"); - Attr NeatLineSize = doc.createAttribute("NeatLineSize"); - Attr Left = doc.createAttribute("Left"); - Attr Top = doc.createAttribute("Top"); - Attr Width = doc.createAttribute("Width"); - Attr Height = doc.createAttribute("Height"); - Attr FontName = doc.createAttribute("FontName"); - Attr FontSize = doc.createAttribute("FontSize"); - Attr drawScaleText = doc.createAttribute("DrawScaleText"); - Attr drawBackColor = doc.createAttribute("DrawBackColor"); - - elementType.setValue(aScaleBar.getElementType().toString()); - layoutMapIndex.setValue(String.valueOf(getLayoutMapIndex(aScaleBar.getLayoutMap()))); - scaleBarType.setValue(aScaleBar.getScaleBarType().toString()); - BackColor.setValue(ColorUtil.toHexEncoding(aScaleBar.getBackColor())); - foreColor.setValue(ColorUtil.toHexEncoding(aScaleBar.getForeColor())); - DrawNeatLine.setValue(String.valueOf(aScaleBar.isDrawNeatLine())); - NeatLineColor.setValue(ColorUtil.toHexEncoding(aScaleBar.getNeatLineColor())); - NeatLineSize.setValue(String.valueOf(aScaleBar.getNeatLineSize())); - Left.setValue(String.valueOf(aScaleBar.getLeft())); - Top.setValue(String.valueOf(aScaleBar.getTop())); - Width.setValue(String.valueOf(aScaleBar.getWidth())); - Height.setValue(String.valueOf(aScaleBar.getHeight())); - FontName.setValue(aScaleBar.getFont().getFontName()); - FontSize.setValue(String.valueOf(aScaleBar.getFont().getSize())); - drawScaleText.setValue(String.valueOf(aScaleBar.isDrawScaleText())); - drawBackColor.setValue(String.valueOf(aScaleBar.isDrawBackColor())); - - scaleBar.setAttributeNode(elementType); - scaleBar.setAttributeNode(layoutMapIndex); - scaleBar.setAttributeNode(scaleBarType); - scaleBar.setAttributeNode(BackColor); - scaleBar.setAttributeNode(foreColor); - scaleBar.setAttributeNode(DrawNeatLine); - scaleBar.setAttributeNode(NeatLineColor); - scaleBar.setAttributeNode(NeatLineSize); - scaleBar.setAttributeNode(Left); - scaleBar.setAttributeNode(Top); - scaleBar.setAttributeNode(Width); - scaleBar.setAttributeNode(Height); - scaleBar.setAttributeNode(FontName); - scaleBar.setAttributeNode(FontSize); - scaleBar.setAttributeNode(drawScaleText); - scaleBar.setAttributeNode(drawBackColor); - - parent.appendChild(scaleBar); - } - - private void addLayoutNorthArrowElement(Document doc, Element parent, LayoutNorthArrow aNorthArrow) { - Element northArrow = doc.createElement("LayoutNorthArrow"); - Attr elementType = doc.createAttribute("ElementType"); - Attr layoutMapIndex = doc.createAttribute("LayoutMapIndex"); - Attr BackColor = doc.createAttribute("BackColor"); - Attr foreColor = doc.createAttribute("ForeColor"); - Attr DrawNeatLine = doc.createAttribute("DrawNeatLine"); - Attr NeatLineColor = doc.createAttribute("NeatLineColor"); - Attr NeatLineSize = doc.createAttribute("NeatLineSize"); - Attr Left = doc.createAttribute("Left"); - Attr Top = doc.createAttribute("Top"); - Attr Width = doc.createAttribute("Width"); - Attr Height = doc.createAttribute("Height"); - Attr angle = doc.createAttribute("Angle"); - Attr drawBackColor = doc.createAttribute("DrawBackColor"); - - elementType.setValue(aNorthArrow.getElementType().toString()); - layoutMapIndex.setValue(String.valueOf(getLayoutMapIndex(aNorthArrow.getLayoutMap()))); - BackColor.setValue(ColorUtil.toHexEncoding(aNorthArrow.getBackColor())); - foreColor.setValue(ColorUtil.toHexEncoding(aNorthArrow.getForeColor())); - DrawNeatLine.setValue(String.valueOf(aNorthArrow.isDrawNeatLine())); - NeatLineColor.setValue(ColorUtil.toHexEncoding(aNorthArrow.getNeatLineColor())); - NeatLineSize.setValue(String.valueOf(aNorthArrow.getNeatLineSize())); - Left.setValue(String.valueOf(aNorthArrow.getLeft())); - Top.setValue(String.valueOf(aNorthArrow.getTop())); - Width.setValue(String.valueOf(aNorthArrow.getWidth())); - Height.setValue(String.valueOf(aNorthArrow.getHeight())); - angle.setValue(String.valueOf(aNorthArrow.getAngle())); - drawBackColor.setValue(String.valueOf(aNorthArrow.isDrawBackColor())); - - northArrow.setAttributeNode(elementType); - northArrow.setAttributeNode(layoutMapIndex); - northArrow.setAttributeNode(BackColor); - northArrow.setAttributeNode(foreColor); - northArrow.setAttributeNode(DrawNeatLine); - northArrow.setAttributeNode(NeatLineColor); - northArrow.setAttributeNode(NeatLineSize); - northArrow.setAttributeNode(Left); - northArrow.setAttributeNode(Top); - northArrow.setAttributeNode(Width); - northArrow.setAttributeNode(Height); - northArrow.setAttributeNode(angle); - northArrow.setAttributeNode(drawBackColor); - - parent.appendChild(northArrow); - } - - private void addLayoutGraphicElement(Document doc, Element parent, LayoutGraphic aLayoutGraphic) { - Element layoutGraphic = doc.createElement("LayoutGraphic"); - Attr elementType = doc.createAttribute("ElementType"); - Attr isTitle = doc.createAttribute("IsTitle"); - Attr left = doc.createAttribute("Left"); - Attr top = doc.createAttribute("Top"); - Attr width = doc.createAttribute("Width"); - Attr height = doc.createAttribute("Height"); - - elementType.setValue(aLayoutGraphic.getElementType().toString()); - isTitle.setValue(String.valueOf(aLayoutGraphic.isTitle())); - left.setValue(String.valueOf(aLayoutGraphic.getLeft())); - top.setValue(String.valueOf(aLayoutGraphic.getTop())); - width.setValue(String.valueOf(aLayoutGraphic.getWidth())); - height.setValue(String.valueOf(aLayoutGraphic.getHeight())); - - layoutGraphic.setAttributeNode(elementType); - layoutGraphic.setAttributeNode(isTitle); - layoutGraphic.setAttributeNode(left); - layoutGraphic.setAttributeNode(top); - layoutGraphic.setAttributeNode(width); - layoutGraphic.setAttributeNode(height); - - //Add graphic - Graphic aGraphic = aLayoutGraphic.getGraphic(); - aGraphic.exportToXML(doc, layoutGraphic); - - //Append in parent - parent.appendChild(layoutGraphic); - } - - /** - * Load project file - * - * @param aFile The project file - * @throws javax.xml.parsers.ParserConfigurationException - * @throws org.xml.sax.SAXException - * @throws java.io.IOException - */ - public void loadProjectFile(String aFile) throws ParserConfigurationException, SAXException, IOException { - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); - Document doc = db.parse(aFile); - - Element root = doc.getDocumentElement(); - - Properties property = System.getProperties(); - String path = System.getProperty("user.dir"); - property.setProperty("user.dir", new File(aFile).getAbsolutePath()); - String pPath = new File(aFile).getParent(); - - //Load map frames content - List mfs = new ArrayList<>(); - Element mapFrames = (Element) root.getElementsByTagName("MapFrames").item(0); - if (mapFrames == null) { - MapFrame mf = new MapFrame(); - mf.importProjectXML(pPath, root); - mf.setActive(true); - mfs.add(mf); - } else { - NodeList mfNodes = mapFrames.getElementsByTagName("MapFrame"); - for (int i = 0; i < mfNodes.getLength(); i++) { - Node mapFrame = mfNodes.item(i); - MapFrame mf = new MapFrame(); - mf.importProjectXML(pPath, (Element) mapFrame); - mfs.add(mf); - } - } - - this.setMapFrames(mfs); - //Load MapLayout content - this.importProjectXML(root); - - property.setProperty("user.dir", path); - } - - /** - * Import project XML element - * - * @param parent Parent element - */ - public void importProjectXML(Element parent) { - loadLayout(parent); - } - - private void loadLayout(Element parent) { - Node layout = parent.getElementsByTagName("Layout").item(0); - try { - _pageBackColor = ColorUtil.parseToColor(layout.getAttributes().getNamedItem("BackColor").getNodeValue()); - _pageForeColor = ColorUtil.parseToColor(layout.getAttributes().getNamedItem("ForeColor").getNodeValue()); - this.setAntiAlias(Boolean.parseBoolean(layout.getAttributes().getNamedItem("SmoothingMode").getNodeValue())); - _paperSize.setName(layout.getAttributes().getNamedItem("PaperSizeName").getNodeValue()); - _paperSize.setWidth(Integer.parseInt(layout.getAttributes().getNamedItem("PaperSizeWidth").getNodeValue())); - _paperSize.setHeight(Integer.parseInt(layout.getAttributes().getNamedItem("PaperSizeHeight").getNodeValue())); - _isLandscape = Boolean.parseBoolean(layout.getAttributes().getNamedItem("Landscape").getNodeValue()); - - updatePageSet(); - - loadLayoutElements((Element) layout); - } catch (Exception e) { - } - } - - private void loadLayoutElements(Element parent) { - _layoutElements.clear(); - _selectedElements.clear(); - - Node layoutElements = parent.getElementsByTagName("LayoutElements").item(0); - //Load layout maps - NodeList layoutNodes = ((Element) layoutElements).getElementsByTagName("LayoutMap"); - for (int i = 0; i < layoutNodes.getLength(); i++) { - Node elementNode = layoutNodes.item(i); - MapFrame aMF; - if (_mapFrames.size() > i) { - aMF = _mapFrames.get(i); - } else { - aMF = new MapFrame(); - } - - LayoutMap aLM = new LayoutMap(aMF, this.tileLoadListener); - loadLayoutMapElement(elementNode, aLM); - addElement(aLM); - } - - //Load other elements - for (int i = 0; i < layoutElements.getChildNodes().getLength(); i++) { - Node elementNode = layoutElements.getChildNodes().item(i); - if (elementNode.getNodeType() != Node.ELEMENT_NODE) { - continue; - } - ElementType aType = ElementType.valueOf(elementNode.getAttributes().getNamedItem("ElementType").getNodeValue()); - switch (aType) { - case LayoutIllustration: - break; - case LayoutLegend: - LayoutLegend aLL = loadLayoutLegendElement(elementNode); - addElement(aLL); - break; - case LayoutGraphic: - LayoutGraphic aLG = loadLayoutGraphicElement(elementNode); - if (aLG.getGraphic().getShape().getShapeType() == ShapeTypes.WindArraw) { - ((WindArrow) aLG.getGraphic().getShape()).angle = 270; - } - addElement(aLG); - break; - case LayoutScaleBar: - LayoutScaleBar aLSB = loadLayoutScaleBarElement(elementNode); - if (aLSB != null) { - addElement(aLSB); - } - break; - case LayoutNorthArraw: - LayoutNorthArrow aLNA = loadLayoutNorthArrowElement(elementNode); - if (aLNA != null) { - addElement(aLNA); - } - break; - } - } - } - - private void loadLayoutMapElement(Node layoutMap, LayoutMap aLM) { - try { - aLM.setLeft(Integer.parseInt(layoutMap.getAttributes().getNamedItem("Left").getNodeValue())); - aLM.setTop(Integer.parseInt(layoutMap.getAttributes().getNamedItem("Top").getNodeValue())); - aLM.setWidth(Integer.parseInt(layoutMap.getAttributes().getNamedItem("Width").getNodeValue())); - aLM.setHeight(Integer.parseInt(layoutMap.getAttributes().getNamedItem("Height").getNodeValue())); - aLM.setDrawNeatLine(Boolean.parseBoolean(layoutMap.getAttributes().getNamedItem("DrawNeatLine").getNodeValue())); - aLM.setNeatLineColor(ColorUtil.parseToColor(layoutMap.getAttributes().getNamedItem("NeatLineColor").getNodeValue())); - aLM.setNeatLineSize(Float.parseFloat(layoutMap.getAttributes().getNamedItem("NeatLineSize").getNodeValue())); - aLM.setGridLineColor(ColorUtil.parseToColor(layoutMap.getAttributes().getNamedItem("GridLineColor").getNodeValue())); - aLM.setGridLineSize(Float.parseFloat(layoutMap.getAttributes().getNamedItem("GridLineSize").getNodeValue())); - aLM.setGridLineStyle(LineStyles.valueOf(layoutMap.getAttributes().getNamedItem("GridLineStyle").getNodeValue())); - aLM.setDrawGridLine(Boolean.parseBoolean(layoutMap.getAttributes().getNamedItem("DrawGridLine").getNodeValue())); - aLM.setDrawGridLabel(Boolean.parseBoolean(layoutMap.getAttributes().getNamedItem("DrawGridLabel").getNodeValue())); - String fontName = layoutMap.getAttributes().getNamedItem("GridFontName").getNodeValue(); - float fontSize = Float.parseFloat(layoutMap.getAttributes().getNamedItem("GridFontSize").getNodeValue()); - aLM.setGridFont(new Font(fontName, Font.PLAIN, (int) fontSize)); - aLM.setGridXDelt(Double.parseDouble(layoutMap.getAttributes().getNamedItem("GridXDelt").getNodeValue())); - aLM.setGridYDelt(Double.parseDouble(layoutMap.getAttributes().getNamedItem("GridYDelt").getNodeValue())); - aLM.setGridXOrigin(Float.parseFloat(layoutMap.getAttributes().getNamedItem("GridXOrigin").getNodeValue())); - aLM.setGridYOrigin(Float.parseFloat(layoutMap.getAttributes().getNamedItem("GridYOrigin").getNodeValue())); - aLM.setGridLabelPosition(GridLabelPosition.valueOf(layoutMap.getAttributes().getNamedItem("GridLabelPosition").getNodeValue())); - aLM.setDrawDegreeSymbol(Boolean.parseBoolean(layoutMap.getAttributes().getNamedItem("DrawDegreeSymbol").getNodeValue())); - aLM.setDrawBackColor(Boolean.parseBoolean(layoutMap.getAttributes().getNamedItem("DrawBackColor").getNodeValue())); - } catch (Exception e) { - } - } - - private LayoutLegend loadLayoutLegendElement(Node layoutLegend) { - LayoutLegend aLL = null; - try { - int layoutMapIdx = Integer.parseInt(layoutLegend.getAttributes().getNamedItem("LayoutMapIndex").getNodeValue()); - String legendLayerName = layoutLegend.getAttributes().getNamedItem("LegendLayer").getNodeValue(); - LayoutMap aLM = this.getLayoutMaps().get(layoutMapIdx); - MapLayer legendLayer = aLM.getMapFrame().getMapView().getLayer(legendLayerName); - aLL = new LayoutLegend(this, aLM); - aLL.setLegendLayer(legendLayer); - } catch (Exception e) { - aLL = new LayoutLegend(this, this.getLayoutMaps().get(0)); - aLL.setLegendLayer(aLL.getLayoutMap().getMapFrame().getMapView().getLayers().get(0)); - } - - try { - aLL.setLegendStyle(LegendStyles.valueOf(layoutLegend.getAttributes().getNamedItem("LegendStyle").getNodeValue())); - aLL.setBackColor(ColorUtil.parseToColor(layoutLegend.getAttributes().getNamedItem("BackColor").getNodeValue())); - aLL.setDrawNeatLine(Boolean.parseBoolean(layoutLegend.getAttributes().getNamedItem("DrawNeatLine").getNodeValue())); - aLL.setNeatLineColor(ColorUtil.parseToColor(layoutLegend.getAttributes().getNamedItem("NeatLineColor").getNodeValue())); - aLL.setNeatLineSize(Float.parseFloat(layoutLegend.getAttributes().getNamedItem("NeatLineSize").getNodeValue())); - aLL.setLeft(Integer.parseInt(layoutLegend.getAttributes().getNamedItem("Left").getNodeValue())); - aLL.setTop(Integer.parseInt(layoutLegend.getAttributes().getNamedItem("Top").getNodeValue())); - aLL.setWidth(Integer.parseInt(layoutLegend.getAttributes().getNamedItem("Width").getNodeValue())); - aLL.setHeight(Integer.parseInt(layoutLegend.getAttributes().getNamedItem("Height").getNodeValue())); - String fontName = layoutLegend.getAttributes().getNamedItem("FontName").getNodeValue(); - float fontSize = Float.parseFloat(layoutLegend.getAttributes().getNamedItem("FontSize").getNodeValue()); - aLL.setFont(new Font(fontName, Font.PLAIN, (int) fontSize)); - aLL.setLayerUpdateType(LayerUpdateTypes.valueOf(layoutLegend.getAttributes().getNamedItem("LayerUpdateType").getNodeValue())); - aLL.setColumnNumber(Integer.parseInt(layoutLegend.getAttributes().getNamedItem("ColumnNumber").getNodeValue())); - aLL.setDrawBackColor(Boolean.parseBoolean(layoutLegend.getAttributes().getNamedItem("DrawBackColor").getNodeValue())); - aLL.setDrawChartBreaks(Boolean.parseBoolean(layoutLegend.getAttributes().getNamedItem("DrawChartBreaks").getNodeValue())); - aLL.setForceDrawOutline(Boolean.parseBoolean(layoutLegend.getAttributes().getNamedItem("ForceDrawOutline").getNodeValue())); - } catch (Exception e) { - } - - return aLL; - } - - private LayoutScaleBar loadLayoutScaleBarElement(Node layoutScaleBar) { - LayoutScaleBar aLSB = null; - try { - int layoutMapIdx = Integer.parseInt(layoutScaleBar.getAttributes().getNamedItem("LayoutMapIndex").getNodeValue()); - LayoutMap aLM = this.getLayoutMaps().get(layoutMapIdx); - aLSB = new LayoutScaleBar(aLM); - } catch (Exception e) { - aLSB = new LayoutScaleBar(this.getLayoutMaps().get(0)); - } - - try { - aLSB.setScaleBarType(ScaleBarType.valueOf(layoutScaleBar.getAttributes().getNamedItem("ScaleBarType").getNodeValue())); - aLSB.setBackColor(ColorUtil.parseToColor(layoutScaleBar.getAttributes().getNamedItem("BackColor").getNodeValue())); - aLSB.setForeColor(ColorUtil.parseToColor(layoutScaleBar.getAttributes().getNamedItem("ForeColor").getNodeValue())); - aLSB.setDrawNeatLine(Boolean.parseBoolean(layoutScaleBar.getAttributes().getNamedItem("DrawNeatLine").getNodeValue())); - aLSB.setNeatLineColor(ColorUtil.parseToColor(layoutScaleBar.getAttributes().getNamedItem("NeatLineColor").getNodeValue())); - aLSB.setNeatLineSize(Float.parseFloat(layoutScaleBar.getAttributes().getNamedItem("NeatLineSize").getNodeValue())); - aLSB.setLeft(Integer.parseInt(layoutScaleBar.getAttributes().getNamedItem("Left").getNodeValue())); - aLSB.setTop(Integer.parseInt(layoutScaleBar.getAttributes().getNamedItem("Top").getNodeValue())); - aLSB.setWidth(Integer.parseInt(layoutScaleBar.getAttributes().getNamedItem("Width").getNodeValue())); - aLSB.setHeight(Integer.parseInt(layoutScaleBar.getAttributes().getNamedItem("Height").getNodeValue())); - String fontName = layoutScaleBar.getAttributes().getNamedItem("FontName").getNodeValue(); - float fontSize = Float.parseFloat(layoutScaleBar.getAttributes().getNamedItem("FontSize").getNodeValue()); - aLSB.setFont(new Font(fontName, Font.PLAIN, (int) fontSize)); - aLSB.setDrawScaleText(Boolean.parseBoolean(layoutScaleBar.getAttributes().getNamedItem("DrawScaleText").getNodeValue())); - aLSB.setDrawBackColor(Boolean.parseBoolean(layoutScaleBar.getAttributes().getNamedItem("DrawBackColor").getNodeValue())); - } catch (Exception e) { - } - - return aLSB; - } - - private LayoutNorthArrow loadLayoutNorthArrowElement(Node layoutNorthArrow) { - LayoutNorthArrow aLNA = null; - try { - int layoutMapIdx = Integer.parseInt(layoutNorthArrow.getAttributes().getNamedItem("LayoutMapIndex").getNodeValue()); - LayoutMap aLM = this.getLayoutMaps().get(layoutMapIdx); - aLNA = new LayoutNorthArrow(aLM); - } catch (Exception e) { - aLNA = new LayoutNorthArrow(this.getLayoutMaps().get(0)); - } - - try { - aLNA.setBackColor(ColorUtil.parseToColor(layoutNorthArrow.getAttributes().getNamedItem("BackColor").getNodeValue())); - aLNA.setForeColor(ColorUtil.parseToColor(layoutNorthArrow.getAttributes().getNamedItem("ForeColor").getNodeValue())); - aLNA.setDrawNeatLine(Boolean.parseBoolean(layoutNorthArrow.getAttributes().getNamedItem("DrawNeatLine").getNodeValue())); - aLNA.setNeatLineColor(ColorUtil.parseToColor(layoutNorthArrow.getAttributes().getNamedItem("NeatLineColor").getNodeValue())); - aLNA.setNeatLineSize(Float.parseFloat(layoutNorthArrow.getAttributes().getNamedItem("NeatLineSize").getNodeValue())); - aLNA.setLeft(Integer.parseInt(layoutNorthArrow.getAttributes().getNamedItem("Left").getNodeValue())); - aLNA.setTop(Integer.parseInt(layoutNorthArrow.getAttributes().getNamedItem("Top").getNodeValue())); - aLNA.setWidth(Integer.parseInt(layoutNorthArrow.getAttributes().getNamedItem("Width").getNodeValue())); - aLNA.setHeight(Integer.parseInt(layoutNorthArrow.getAttributes().getNamedItem("Height").getNodeValue())); - aLNA.setAngle(Float.parseFloat(layoutNorthArrow.getAttributes().getNamedItem("Angle").getNodeValue())); - aLNA.setDrawBackColor(Boolean.parseBoolean(layoutNorthArrow.getAttributes().getNamedItem("DrawBackColor").getNodeValue())); - } catch (Exception e) { - } - - return aLNA; - } - - private LayoutGraphic loadLayoutGraphicElement(Node layoutGraphic) { - Graphic aGraphic = new Graphic(); - Node graphicNode = ((Element) layoutGraphic).getElementsByTagName("Graphic").item(0); - aGraphic.importFromXML((Element) graphicNode); - - LayoutGraphic aLG; - if (aGraphic.getShape().getShapeType() == ShapeTypes.WindArraw) { - aLG = new LayoutGraphic(aGraphic, this, this.getActiveLayoutMap()); - } else { - aLG = new LayoutGraphic(aGraphic, this); - } - - aLG.setIsTitle(Boolean.parseBoolean(layoutGraphic.getAttributes().getNamedItem("IsTitle").getNodeValue())); - - return aLG; - } - // - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmColorSymbolSet.form b/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmColorSymbolSet.form deleted file mode 100644 index 41176a29..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmColorSymbolSet.form +++ /dev/null @@ -1,97 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLabelSymbolSet.form b/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLabelSymbolSet.form deleted file mode 100644 index 6bc20e96..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLabelSymbolSet.form +++ /dev/null @@ -1,181 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLabelSymbolSet.java b/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLabelSymbolSet.java deleted file mode 100644 index 51b289e2..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLabelSymbolSet.java +++ /dev/null @@ -1,310 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.legend; - -import org.meteoinfo.geometry.legend.LabelBreak; -import org.meteoinfo.layout.MapLayout; -import org.meteoinfo.map.MapView; -import com.l2fprod.common.swing.JFontChooser; -import java.awt.Color; -import java.awt.Font; -import javax.swing.JColorChooser; - -/** - * - * @author Yaqiang Wang - */ -public class FrmLabelSymbolSet extends javax.swing.JDialog { - - private Object _parent = null; - private LabelBreak _labelBreak = null; - private boolean _isLoading = false; - - /** - * Creates new form FrmLabelSymbolSet - * @param parent - * @param modal - */ - public FrmLabelSymbolSet(java.awt.Frame parent, boolean modal) { - super(parent, modal); - initComponents(); - } - - /** - * Creates new form FrmLabelSymbolSet - * @param parent - * @param modal - * @param tparent - */ - public FrmLabelSymbolSet(java.awt.Frame parent, boolean modal, Object tparent) { - super(parent, modal); - initComponents(); - - _parent = tparent; - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - jScrollPane1 = new javax.swing.JScrollPane(); - jTextArea_Text = new javax.swing.JTextArea(); - jPanel1 = new javax.swing.JPanel(); - jButton_Font = new javax.swing.JButton(); - jLabel1 = new javax.swing.JLabel(); - jSpinner_Angle = new javax.swing.JSpinner(); - jLabel_Color = new javax.swing.JLabel(); - jButton_OK = new javax.swing.JButton(); - jButton_Apply = new javax.swing.JButton(); - - setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - - jTextArea_Text.setColumns(20); - jTextArea_Text.setRows(5); - jTextArea_Text.setWrapStyleWord(true); - jScrollPane1.setViewportView(jTextArea_Text); - - jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder()); - - jButton_Font.setText("Font"); - jButton_Font.setPreferredSize(new java.awt.Dimension(81, 30)); - jButton_Font.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton_FontActionPerformed(evt); - } - }); - - jLabel1.setText("Angle:"); - - jSpinner_Angle.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.0f), Float.valueOf(-360.0f), Float.valueOf(360.0f), Float.valueOf(1.0f))); - jSpinner_Angle.addChangeListener(new javax.swing.event.ChangeListener() { - public void stateChanged(javax.swing.event.ChangeEvent evt) { - jSpinner_AngleStateChanged(evt); - } - }); - - jLabel_Color.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel_Color.setText("Color"); - jLabel_Color.setBorder(javax.swing.BorderFactory.createEtchedBorder()); - jLabel_Color.setOpaque(true); - jLabel_Color.setPreferredSize(new java.awt.Dimension(34, 22)); - jLabel_Color.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent evt) { - jLabel_ColorMouseClicked(evt); - } - }); - - javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); - jPanel1.setLayout(jPanel1Layout); - jPanel1Layout.setHorizontalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addContainerGap() - .addComponent(jButton_Font, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE) - .addComponent(jLabel_Color, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jLabel1) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jSpinner_Angle, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - ); - jPanel1Layout.setVerticalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jButton_Font, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel_Color, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel1) - .addComponent(jSpinner_Angle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap()) - ); - - jButton_OK.setText("OK"); - jButton_OK.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton_OKActionPerformed(evt); - } - }); - - jButton_Apply.setText("Apply"); - jButton_Apply.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton_ApplyActionPerformed(evt); - } - }); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane1) - .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addContainerGap()) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jButton_OK, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(58, 58, 58) - .addComponent(jButton_Apply, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(49, 49, 49)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jButton_OK) - .addComponent(jButton_Apply)) - .addContainerGap(17, Short.MAX_VALUE)) - ); - - pack(); - }// //GEN-END:initComponents - - private void jButton_OKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_OKActionPerformed - // TODO add your handling code here: - _labelBreak.setText(this.jTextArea_Text.getText()); - if (_parent.getClass() == MapView.class) { - ((MapView) _parent).setDefLabelBreak(_labelBreak); - ((MapView) _parent).paintLayers(); - } else if (_parent.getClass() == MapLayout.class) { - ((MapLayout) _parent).setDefLabelBreak(_labelBreak); - ((MapLayout) _parent).paintGraphics(); - } - - this.dispose(); - }//GEN-LAST:event_jButton_OKActionPerformed - - private void jButton_ApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_ApplyActionPerformed - // TODO add your handling code here: - _labelBreak.setText(this.jTextArea_Text.getText()); - if (_parent.getClass() == MapView.class) { - ((MapView) _parent).paintLayers(); - } else if (_parent.getClass() == MapLayout.class) { - ((MapLayout) _parent).paintGraphics(); - } - }//GEN-LAST:event_jButton_ApplyActionPerformed - - private void jLabel_ColorMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel_ColorMouseClicked - // TODO add your handling code here: - Color aColor = JColorChooser.showDialog(this, null, this.jLabel_Color.getBackground()); - this.jLabel_Color.setBackground(aColor); - this.jTextArea_Text.setForeground(aColor); - _labelBreak.setColor(aColor); - }//GEN-LAST:event_jLabel_ColorMouseClicked - - private void jButton_FontActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_FontActionPerformed - // TODO add your handling code here: - //FontChooser fontChooser = new FontChooser(this, true, _labelBreak.getFont()); - //fontChooser.setVisible(true); - Font aFont = JFontChooser.showDialog(this, null, _labelBreak.getFont()); - if (aFont != null) { - this.jTextArea_Text.setFont(aFont); - _labelBreak.setFont(aFont); - } - }//GEN-LAST:event_jButton_FontActionPerformed - - private void jSpinner_AngleStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner_AngleStateChanged - // TODO add your handling code here: - if (_isLoading) { - return; - } - - float angle = Float.parseFloat(this.jSpinner_Angle.getValue().toString()); - _labelBreak.setAngle(angle); - }//GEN-LAST:event_jSpinner_AngleStateChanged - - /** - * Set label break - * - * @param lb The label break - */ - public void setLabelBreak(LabelBreak lb) { - _labelBreak = lb; - - _isLoading = true; - this.jTextArea_Text.setText(_labelBreak.getText()); - this.jTextArea_Text.setForeground(_labelBreak.getColor()); - this.jTextArea_Text.setFont(_labelBreak.getFont()); - this.jLabel_Color.setBackground(_labelBreak.getColor()); - this.jSpinner_Angle.setValue(_labelBreak.getAngle()); - _isLoading = false; - } - - /** - * @param args the command line arguments - */ - public static void main(String args[]) { - /* Set the Nimbus look and feel */ - // - /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. - * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html - */ - try { - for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { - if ("Nimbus".equals(info.getName())) { - javax.swing.UIManager.setLookAndFeel(info.getClassName()); - break; - } - } - } catch (ClassNotFoundException ex) { - java.util.logging.Logger.getLogger(FrmLabelSymbolSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(FrmLabelSymbolSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(FrmLabelSymbolSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (javax.swing.UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(FrmLabelSymbolSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } - // - - /* Create and display the dialog */ - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - FrmLabelSymbolSet dialog = new FrmLabelSymbolSet(new javax.swing.JFrame(), true); - dialog.addWindowListener(new java.awt.event.WindowAdapter() { - @Override - public void windowClosing(java.awt.event.WindowEvent e) { - System.exit(0); - } - }); - dialog.setVisible(true); - } - }); - } - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton jButton_Apply; - private javax.swing.JButton jButton_Font; - private javax.swing.JButton jButton_OK; - private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel_Color; - private javax.swing.JPanel jPanel1; - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JSpinner jSpinner_Angle; - private javax.swing.JTextArea jTextArea_Text; - // End of variables declaration//GEN-END:variables -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLegendBreaks.form b/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLegendBreaks.form deleted file mode 100644 index f3ddf23f..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLegendBreaks.form +++ /dev/null @@ -1,303 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLegendSet.form b/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLegendSet.form deleted file mode 100644 index 1917ecbb..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLegendSet.form +++ /dev/null @@ -1,233 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPointSymbolSet.form b/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPointSymbolSet.form deleted file mode 100644 index e555d098..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPointSymbolSet.form +++ /dev/null @@ -1,356 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPolygonSymbolSet.form b/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPolygonSymbolSet.form deleted file mode 100644 index d02b186b..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPolygonSymbolSet.form +++ /dev/null @@ -1,291 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPolylineSymbolSet.form b/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPolylineSymbolSet.form deleted file mode 100644 index 1f6dea22..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPolylineSymbolSet.form +++ /dev/null @@ -1,362 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPolylineSymbolSet.java b/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPolylineSymbolSet.java deleted file mode 100644 index f2df10b4..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPolylineSymbolSet.java +++ /dev/null @@ -1,602 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.legend; - -import org.meteoinfo.geometry.legend.LineStyles; -import org.meteoinfo.geometry.legend.PointStyle; -import org.meteoinfo.geometry.legend.PolylineBreak; -import org.meteoinfo.ui.event.ISelectedCellChangedListener; -import org.meteoinfo.ui.event.SelectedCellChangedEvent; -import org.meteoinfo.layout.MapLayout; -import org.meteoinfo.map.MapView; -import java.awt.Color; -import java.awt.Dimension; -import java.util.Arrays; -import javax.swing.JColorChooser; - -/** - * - * @author Yaqiang Wang - */ -public class FrmPolylineSymbolSet extends javax.swing.JDialog { - - private Object _parent = null; - private PolylineBreak _polylineBreak = null; - private boolean isLoading = false; - - /** - * Creates new form FrmPolylineSymbolSet - * @param parent - * @param modal - */ - public FrmPolylineSymbolSet(java.awt.Frame parent, boolean modal) { - super(parent, modal); - initComponents(); - - this.setTitle("Polyline Symbol Set"); - } - - /** - * Creates new form FrmPolylineSymbolSet - * @param parent - * @param modal - * @param tparent - */ - public FrmPolylineSymbolSet(java.awt.Dialog parent, boolean modal, Object tparent) { - super(parent, modal); - initComponents(); - - this.setTitle("Polyline Symbol Set"); - if (tparent.getClass() == LegendView.class){ - this.jButton_Apply.setVisible(false); - this.jButton_OK.setVisible(false); - this.setPreferredSize(new Dimension(this.getWidth(), this.getHeight() - 40)); - } - - this.symbolControl1.addSelectedCellChangedListener(new ISelectedCellChangedListener() { - @Override - public void selectedCellChangedEvent(SelectedCellChangedEvent event) { - onSelectedCellChanged(event); - } - }); - - this._parent = tparent; - } - - /** - * Creates new form FrmPolylineSymbolSet - * @param parent - * @param modal - * @param tparent - */ - public FrmPolylineSymbolSet(java.awt.Frame parent, boolean modal, Object tparent) { - super(parent, modal); - initComponents(); - - this.setTitle("Polyline Symbol Set"); - if (tparent.getClass() == LegendView.class){ - this.jButton_Apply.setVisible(false); - this.jButton_OK.setVisible(false); - this.setPreferredSize(new Dimension(this.getWidth(), this.getHeight() - 40)); - } - - this.symbolControl1.addSelectedCellChangedListener(new ISelectedCellChangedListener() { - @Override - public void selectedCellChangedEvent(SelectedCellChangedEvent event) { - onSelectedCellChanged(event); - } - }); - - this._parent = tparent; - } - - private void onSelectedCellChanged(SelectedCellChangedEvent event) { - if (isLoading) { - return; - } - - _polylineBreak.setStyle(LineStyles.values()[symbolControl1.getSelectedCell()]); - if (_parent.getClass() == LegendView.class) { - ((LegendView) _parent).setLegendBreak_PolylineStyle(_polylineBreak.getStyle()); - } - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - symbolControl1 = new org.meteoinfo.legend.SymbolControl(); - jLabel1 = new javax.swing.JLabel(); - jSpinner_Size = new javax.swing.JSpinner(); - jLabel2 = new javax.swing.JLabel(); - jLabel_Color = new javax.swing.JLabel(); - jCheckBox_DrawShape = new javax.swing.JCheckBox(); - jCheckBox_DrawPointSymbol = new javax.swing.JCheckBox(); - jPanel1 = new javax.swing.JPanel(); - jLabel3 = new javax.swing.JLabel(); - jSpinner_SymbolSize = new javax.swing.JSpinner(); - jLabel4 = new javax.swing.JLabel(); - jLabel_SymbolColor = new javax.swing.JLabel(); - jLabel5 = new javax.swing.JLabel(); - jSpinner_SymbolInterval = new javax.swing.JSpinner(); - jComboBox_SymbolStyle = new javax.swing.JComboBox(); - jCheckBox_DrawFill = new javax.swing.JCheckBox(); - jLabel6 = new javax.swing.JLabel(); - jLabel_FillColor = new javax.swing.JLabel(); - jButton_Apply = new javax.swing.JButton(); - jButton_OK = new javax.swing.JButton(); - - setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - setResizable(false); - - symbolControl1.setCellSize(new java.awt.Dimension(50, 40)); - symbolControl1.setPreferredSize(new java.awt.Dimension(200, 50)); - symbolControl1.setShapeType(org.meteoinfo.geometry.shape.ShapeTypes.Polyline); - - jLabel1.setText("Size:"); - - jSpinner_Size.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(1.0f), Float.valueOf(1.0f), Float.valueOf(100.0f), Float.valueOf(0.5f))); - jSpinner_Size.addChangeListener(new javax.swing.event.ChangeListener() { - public void stateChanged(javax.swing.event.ChangeEvent evt) { - jSpinner_SizeStateChanged(evt); - } - }); - - jLabel2.setText("Color:"); - - jLabel_Color.setBorder(javax.swing.BorderFactory.createEtchedBorder()); - jLabel_Color.setOpaque(true); - jLabel_Color.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent evt) { - jLabel_ColorMouseClicked(evt); - } - }); - - jCheckBox_DrawShape.setText("Draw Shape"); - jCheckBox_DrawShape.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jCheckBox_DrawShapeActionPerformed(evt); - } - }); - - jCheckBox_DrawPointSymbol.setText("Draw Point Symbol"); - jCheckBox_DrawPointSymbol.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jCheckBox_DrawPointSymbolActionPerformed(evt); - } - }); - - jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Point Symbol")); - jPanel1.setToolTipText("Outline"); - jPanel1.setName("Outline"); // NOI18N - - jLabel3.setText("Size:"); - - jSpinner_SymbolSize.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(1.0f), Float.valueOf(1.0f), Float.valueOf(100.0f), Float.valueOf(0.5f))); - jSpinner_SymbolSize.addChangeListener(new javax.swing.event.ChangeListener() { - public void stateChanged(javax.swing.event.ChangeEvent evt) { - jSpinner_SymbolSizeStateChanged(evt); - } - }); - - jLabel4.setText("Outline Color:"); - - jLabel_SymbolColor.setBorder(javax.swing.BorderFactory.createEtchedBorder()); - jLabel_SymbolColor.setOpaque(true); - jLabel_SymbolColor.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent evt) { - jLabel_SymbolColorMouseClicked(evt); - } - }); - - jLabel5.setText("Interval:"); - - jSpinner_SymbolInterval.setModel(new javax.swing.SpinnerNumberModel(1, 1, 100, 1)); - jSpinner_SymbolInterval.addChangeListener(new javax.swing.event.ChangeListener() { - public void stateChanged(javax.swing.event.ChangeEvent evt) { - jSpinner_SymbolIntervalStateChanged(evt); - } - }); - - jComboBox_SymbolStyle.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); - jComboBox_SymbolStyle.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jComboBox_SymbolStyleActionPerformed(evt); - } - }); - - jCheckBox_DrawFill.setText("Draw Fill"); - jCheckBox_DrawFill.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jCheckBox_DrawFillActionPerformed(evt); - } - }); - - jLabel6.setText("Fill Color:"); - - jLabel_FillColor.setBorder(javax.swing.BorderFactory.createEtchedBorder()); - jLabel_FillColor.setOpaque(true); - jLabel_FillColor.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent evt) { - jLabel_FillColorMouseClicked(evt); - } - }); - - javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); - jPanel1.setLayout(jPanel1Layout); - jPanel1Layout.setHorizontalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jComboBox_SymbolStyle, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() - .addGap(0, 5, Short.MAX_VALUE) - .addComponent(jLabel3) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jSpinner_SymbolSize, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)))) - .addGroup(jPanel1Layout.createSequentialGroup() - .addGap(0, 0, Short.MAX_VALUE) - .addComponent(jCheckBox_DrawFill))) - .addGap(18, 18, 18) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() - .addComponent(jLabel5) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jSpinner_SymbolInterval, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() - .addComponent(jLabel4) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel_SymbolColor, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() - .addComponent(jLabel6) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel_FillColor, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addContainerGap()) - ); - jPanel1Layout.setVerticalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jLabel_SymbolColor, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel3) - .addComponent(jSpinner_SymbolSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel4))) - .addGap(18, 18, 18) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jCheckBox_DrawFill) - .addComponent(jLabel6)) - .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(jLabel_FillColor, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(2, 2, 2))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel5) - .addComponent(jSpinner_SymbolInterval, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jComboBox_SymbolStyle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap()) - ); - - jButton_Apply.setText("Apply"); - jButton_Apply.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton_ApplyActionPerformed(evt); - } - }); - - jButton_OK.setText("OK"); - jButton_OK.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton_OKActionPerformed(evt); - } - }); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(symbolControl1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addGap(31, 31, 31) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel1) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jSpinner_Size, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(jCheckBox_DrawShape)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel2) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel_Color, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(jCheckBox_DrawPointSymbol)))) - .addContainerGap()) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addGap(0, 0, Short.MAX_VALUE) - .addComponent(jButton_OK, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(58, 58, 58) - .addComponent(jButton_Apply, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(52, 52, 52)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(symbolControl1, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel1) - .addComponent(jSpinner_Size, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jCheckBox_DrawShape)) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel2) - .addComponent(jLabel_Color, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jCheckBox_DrawPointSymbol))) - .addGap(18, 18, 18) - .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jButton_Apply) - .addComponent(jButton_OK, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addContainerGap()) - ); - - pack(); - }// //GEN-END:initComponents - - private void jSpinner_SizeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner_SizeStateChanged - // TODO add your handling code here: - float size = Float.parseFloat(this.jSpinner_Size.getValue().toString()); - _polylineBreak.setWidth(size); - if (_parent.getClass() == LegendView.class) { - ((LegendView) _parent).setLegendBreak_Size(size); - } - }//GEN-LAST:event_jSpinner_SizeStateChanged - - private void jLabel_ColorMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel_ColorMouseClicked - // TODO add your handling code here: - Color aColor = JColorChooser.showDialog(rootPane, null, this.jLabel_Color.getBackground()); - this.jLabel_Color.setBackground(aColor); - _polylineBreak.setColor(aColor); - if (_parent.getClass() == LegendView.class) { - ((LegendView) _parent).setLegendBreak_Color(aColor); - } - }//GEN-LAST:event_jLabel_ColorMouseClicked - - private void jCheckBox_DrawShapeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox_DrawShapeActionPerformed - // TODO add your handling code here: - _polylineBreak.setDrawShape(this.jCheckBox_DrawShape.isSelected()); - if (_parent.getClass() == LegendView.class) { - ((LegendView) _parent).setLegendBreak_DrawShape(this.jCheckBox_DrawShape.isSelected()); - } - }//GEN-LAST:event_jCheckBox_DrawShapeActionPerformed - - private void jCheckBox_DrawPointSymbolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox_DrawPointSymbolActionPerformed - // TODO add your handling code here: - _polylineBreak.setDrawSymbol(this.jCheckBox_DrawPointSymbol.isSelected()); - if (_parent.getClass() == LegendView.class) { - ((LegendView) _parent).setLegendBreak_DrawSymbol(this.jCheckBox_DrawPointSymbol.isSelected()); - } - }//GEN-LAST:event_jCheckBox_DrawPointSymbolActionPerformed - - private void jSpinner_SymbolSizeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner_SymbolSizeStateChanged - // TODO add your handling code here: - float size = Float.parseFloat(this.jSpinner_SymbolSize.getValue().toString()); - _polylineBreak.setSymbolSize(size); - if (_parent.getClass() == LegendView.class) { - ((LegendView) _parent).setLegendBreak_SymbolSize(size); - } - }//GEN-LAST:event_jSpinner_SymbolSizeStateChanged - - private void jLabel_SymbolColorMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel_SymbolColorMouseClicked - // TODO add your handling code here: - Color aColor = JColorChooser.showDialog(rootPane, null, this.jLabel_SymbolColor.getBackground()); - this.jLabel_SymbolColor.setBackground(aColor); - _polylineBreak.setSymbolColor(aColor); - if (_parent.getClass() == LegendView.class) { - ((LegendView) _parent).setLegendBreak_SymbolColor(aColor); - } - }//GEN-LAST:event_jLabel_SymbolColorMouseClicked - - private void jSpinner_SymbolIntervalStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner_SymbolIntervalStateChanged - // TODO add your handling code here: - int interval = Integer.parseInt(this.jSpinner_SymbolInterval.getValue().toString()); - _polylineBreak.setSymbolInterval(interval); - if (_parent.getClass() == LegendView.class) { - ((LegendView) _parent).setLegendBreak_SymbolInterval(interval); - } - }//GEN-LAST:event_jSpinner_SymbolIntervalStateChanged - - private void jComboBox_SymbolStyleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox_SymbolStyleActionPerformed - // TODO add your handling code here: - if (isLoading){ - return; - } - - _polylineBreak.setSymbolStyle(PointStyle.valueOf(this.jComboBox_SymbolStyle.getSelectedItem().toString())); - if (_parent.getClass() == LegendView.class) { - ((LegendView)_parent).setLegendBreak_SymbolStyle(_polylineBreak.getSymbolStyle()); - } - }//GEN-LAST:event_jComboBox_SymbolStyleActionPerformed - - private void jButton_ApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_ApplyActionPerformed - // TODO add your handling code here: - if (_parent.getClass() == MapView.class) { - ((MapView) _parent).paintLayers(); - } else if (_parent.getClass() == MapLayout.class) { - ((MapLayout) _parent).paintGraphics(); - } - }//GEN-LAST:event_jButton_ApplyActionPerformed - - private void jButton_OKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_OKActionPerformed - // TODO add your handling code here: - if (_parent.getClass() == MapView.class) { - ((MapView) _parent).setDefPolylineBreak(_polylineBreak); - ((MapView) _parent).paintLayers(); - } else if (_parent.getClass() == MapLayout.class) { - ((MapLayout) _parent).setDefPolylineBreak(_polylineBreak); - ((MapLayout) _parent).paintGraphics(); - } - - this.dispose(); - }//GEN-LAST:event_jButton_OKActionPerformed - - private void jCheckBox_DrawFillActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox_DrawFillActionPerformed - // TODO add your handling code here: - _polylineBreak.setFillSymbol(this.jCheckBox_DrawFill.isSelected()); - if (_parent.getClass() == LegendView.class) { - //((LegendView) _parent).setLegendBreak_DrawFill(this.jCheckBox_DrawFill.isSelected()); - ((LegendView) _parent).repaint(); - } - }//GEN-LAST:event_jCheckBox_DrawFillActionPerformed - - private void jLabel_FillColorMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel_FillColorMouseClicked - // TODO add your handling code here: - Color c = JColorChooser.showDialog(rootPane, null, this.jLabel_FillColor.getBackground()); - if (c == null) - return; - - Color aColor = new Color(c.getRed(), c.getGreen(), c.getBlue()); - this.jLabel_FillColor.setBackground(aColor); - _polylineBreak.setSymbolFillColor(aColor); - if (_parent.getClass() == LegendView.class) { - //((LegendView) _parent).setLegendBreak_Color(aColor); - ((LegendView) _parent).repaint(); - } - }//GEN-LAST:event_jLabel_FillColorMouseClicked - - /** - * Set polyline break - * - * @param plb The polyline break - */ - public void setPolylineBreak(PolylineBreak plb) { - _polylineBreak = plb; - updateProperties(); - } - - private void updateProperties() { - isLoading = true; - - this.jLabel_Color.setBackground(_polylineBreak.getColor()); - this.jSpinner_Size.setValue(_polylineBreak.getWidth()); - this.jCheckBox_DrawShape.setSelected(_polylineBreak.isDrawShape()); - this.jCheckBox_DrawPointSymbol.setSelected(_polylineBreak.getDrawSymbol()); - this.jSpinner_SymbolSize.setValue(_polylineBreak.getSymbolSize()); - this.jLabel_SymbolColor.setBackground(_polylineBreak.getSymbolColor()); - this.jSpinner_SymbolInterval.setValue(_polylineBreak.getSymbolInterval()); - this.jComboBox_SymbolStyle.removeAllItems(); - for (PointStyle sName : PointStyle.values()) { - this.jComboBox_SymbolStyle.addItem(sName); - } - this.jComboBox_SymbolStyle.setSelectedItem(_polylineBreak.getSymbolStyle()); - this.jCheckBox_DrawFill.setSelected(_polylineBreak.isFillSymbol()); - this.jLabel_FillColor.setBackground(_polylineBreak.getSymbolFillColor()); - - //symbolControl1.setSymbolNumber(LineStyles.values().length); - if (_parent.getClass() == LegendView.class) { - symbolControl1.setSymbolNumber(5); - } else { - symbolControl1.setSymbolNumber(LineStyles.values().length); - } - - symbolControl1.setSelectedCell(Arrays.asList(LineStyles.values()).indexOf(_polylineBreak.getStyle())); - - isLoading = false; - } - - /** - * @param args the command line arguments - */ - public static void main(String args[]) { - /* Set the Nimbus look and feel */ - // - /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. - * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html - */ - try { - for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { - if ("Nimbus".equals(info.getName())) { - javax.swing.UIManager.setLookAndFeel(info.getClassName()); - break; - } - } - } catch (ClassNotFoundException ex) { - java.util.logging.Logger.getLogger(FrmPolylineSymbolSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(FrmPolylineSymbolSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(FrmPolylineSymbolSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (javax.swing.UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(FrmPolylineSymbolSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } - // - - /* Create and display the dialog */ - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - FrmPolylineSymbolSet dialog = new FrmPolylineSymbolSet(new javax.swing.JFrame(), true); - dialog.addWindowListener(new java.awt.event.WindowAdapter() { - @Override - public void windowClosing(java.awt.event.WindowEvent e) { - System.exit(0); - } - }); - dialog.setVisible(true); - } - }); - } - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton jButton_Apply; - private javax.swing.JButton jButton_OK; - private javax.swing.JCheckBox jCheckBox_DrawFill; - private javax.swing.JCheckBox jCheckBox_DrawPointSymbol; - private javax.swing.JCheckBox jCheckBox_DrawShape; - private javax.swing.JComboBox jComboBox_SymbolStyle; - private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel2; - private javax.swing.JLabel jLabel3; - private javax.swing.JLabel jLabel4; - private javax.swing.JLabel jLabel5; - private javax.swing.JLabel jLabel6; - private javax.swing.JLabel jLabel_Color; - private javax.swing.JLabel jLabel_FillColor; - private javax.swing.JLabel jLabel_SymbolColor; - private javax.swing.JPanel jPanel1; - private javax.swing.JSpinner jSpinner_Size; - private javax.swing.JSpinner jSpinner_SymbolInterval; - private javax.swing.JSpinner jSpinner_SymbolSize; - private org.meteoinfo.legend.SymbolControl symbolControl1; - // End of variables declaration//GEN-END:variables -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/LegendNode.java b/MeteoInfoLib/src/main/java/org/meteoinfo/legend/LegendNode.java deleted file mode 100644 index 793e4c3c..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/LegendNode.java +++ /dev/null @@ -1,95 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.legend; - -import org.meteoinfo.geometry.legend.ColorBreak; -import org.meteoinfo.geometry.shape.ShapeTypes; - -/** - * - * @author yaqiang - */ -public class LegendNode extends ItemNode { - // - - private ShapeTypes _shapeType; - private ColorBreak _legendBreak; - // - // - // - // - - /** - * Get shape type - * - * @return The shape type - */ - public ShapeTypes getShapeType() { - return _shapeType; - } - - /** - * Set shape type - * - * @param type The shape type - */ - public void setShapeType(ShapeTypes type) { - _shapeType = type; - } - - /** - * Get legend break - * - * @return The legend break - */ - public ColorBreak getLegendBreak() { - return _legendBreak; - } - - /** - * Set legend break - * - * @param aCB The legend break - */ - public void setLegendBreak(ColorBreak aCB) { - _legendBreak = aCB; - } - // - // - - /** - * Clone - * - * @return LegendNode object - */ - @Override - public Object clone() { - LegendNode aLN = new LegendNode(); - aLN.setShapeType(_shapeType); - aLN.setLegendBreak(_legendBreak); - - return aLN; - } - - @Override - public int getDrawHeight() { - return this.getHeight(); - } - - @Override - public int getExpandedHeight() { - return this.getHeight(); - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/LegendSchemeControl.java b/MeteoInfoLib/src/main/java/org/meteoinfo/legend/LegendSchemeControl.java deleted file mode 100644 index 24a1ad84..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/LegendSchemeControl.java +++ /dev/null @@ -1,67 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.legend; - -import org.meteoinfo.geometry.legend.LegendScheme; -import org.meteoinfo.global.FrmProperty; -import org.meteoinfo.layer.MapLayer; -import javax.swing.JPanel; - -/** - * - * @author Yaqiang Wang - */ -public class LegendSchemeControl extends JPanel { - // - - public FrmProperty m_FrmSS = null; - private MapLayer _mapLayer; - //Form m_FrmMeteoData = new Form(); - LegendScheme _legendScheme = null; - LayersLegend m_LayersTV = new LayersLegend(); - boolean m_IfFrmMeteoData = false; - boolean _ifCreateLegendScheme = false; - // - // - - /** - * Constructor - */ - public LegendSchemeControl() { - initComponents(); - } - - /** - * Constructor - * - * @param ifFrmMeteoData If is from meteo data - * @param mapLayer The map layer - * @param aLayersTV The layersLegend - */ - public LegendSchemeControl(boolean ifFrmMeteoData, MapLayer mapLayer, LayersLegend aLayersTV) { - initComponents(); - - m_IfFrmMeteoData = ifFrmMeteoData; - _mapLayer = mapLayer; - m_LayersTV = aLayersTV; - } - - private void initComponents() { - } - // - // - // - // - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmIdentifer.form b/MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmIdentifer.form deleted file mode 100644 index 3bec417b..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmIdentifer.form +++ /dev/null @@ -1,59 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
-
-
-
-
diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmIdentifer.java b/MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmIdentifer.java deleted file mode 100644 index a4a52132..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmIdentifer.java +++ /dev/null @@ -1,174 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.map; - -import javax.swing.JTable; - -/** - * - * @author Yaqiang Wang - */ -public class FrmIdentifer extends javax.swing.JDialog { - - private MapView _mapView; - - /** - * Creates new form FrmIdentifer - */ - public FrmIdentifer(java.awt.Frame parent, boolean modal, MapView mapView) { - super(parent, modal); - _mapView = mapView; - initComponents(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - jScrollPane1 = new javax.swing.JScrollPane(); - jTable1 = new javax.swing.JTable(); - - setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - addWindowListener(new java.awt.event.WindowAdapter() { - public void windowClosed(java.awt.event.WindowEvent evt) { - formWindowClosed(evt); - } - }); - - jTable1.setModel(new javax.swing.table.DefaultTableModel( - new Object [][] { - {null, null}, - {null, null}, - {null, null}, - {null, null} - }, - new String [] { - "Field", "Value" - } - ) { - Class[] types = new Class [] { - java.lang.String.class, java.lang.String.class - }; - - public Class getColumnClass(int columnIndex) { - return types [columnIndex]; - } - }); - jScrollPane1.setViewportView(jTable1); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 220, Short.MAX_VALUE) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 226, Short.MAX_VALUE) - ); - - pack(); - }// //GEN-END:initComponents - - private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed - // TODO add your handling code here: -// if (_mapView != null){ -// _mapView.setDrawIdentiferShape(false); -// _mapView.repaint(); -// } - }//GEN-LAST:event_formWindowClosed - - /** - * Set map view - * @return Map view - */ - public MapView getMapView(){ - return _mapView; - } - - /** - * Set map view - * @param mapView Map view - */ - public void setMapView(MapView mapView){ - _mapView = mapView; - } - - /** - * Get JTable - * @return JTable - */ - public JTable getTable(){ - return this.jTable1; - } - - /** - * Set JTable - * @param table JTable - */ - public void setTable(JTable table){ - this.jTable1 = table; - } - - /** - * @param args the command line arguments - */ - public static void main(String args[]) { - /* Set the Nimbus look and feel */ - // - /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. - * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html - */ - try { - for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { - if ("Nimbus".equals(info.getName())) { - javax.swing.UIManager.setLookAndFeel(info.getClassName()); - break; - } - } - } catch (ClassNotFoundException ex) { - java.util.logging.Logger.getLogger(FrmIdentifer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(FrmIdentifer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(FrmIdentifer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (javax.swing.UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(FrmIdentifer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } - // - - /* Create and display the dialog */ - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - FrmIdentifer dialog = new FrmIdentifer(new javax.swing.JFrame(), true, new MapView()); - dialog.addWindowListener(new java.awt.event.WindowAdapter() { - @Override - public void windowClosing(java.awt.event.WindowEvent e) { - System.exit(0); - } - }); - dialog.setVisible(true); - } - }); - } - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JTable jTable1; - // End of variables declaration//GEN-END:variables -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmIdentiferGrid.form b/MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmIdentiferGrid.form deleted file mode 100644 index 965b4420..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmIdentiferGrid.form +++ /dev/null @@ -1,72 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmVerticeEdit.form b/MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmVerticeEdit.form deleted file mode 100644 index 916b4f9f..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmVerticeEdit.form +++ /dev/null @@ -1,117 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/map/MapViewBeanInfo.java b/MeteoInfoLib/src/main/java/org/meteoinfo/map/MapViewBeanInfo.java deleted file mode 100644 index 341b85af..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/map/MapViewBeanInfo.java +++ /dev/null @@ -1,34 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.map; - -import com.l2fprod.common.beans.BaseBeanInfo; - -/** - * - * @author Yaqiang - */ -public class MapViewBeanInfo extends BaseBeanInfo { - public MapViewBeanInfo(){ - super(MapView.class); - addProperty("antiAlias").setCategory("General").setDisplayName("AntiAlias"); - addProperty("background").setCategory("General").setDisplayName("Background"); - addProperty("foreground").setCategory("General").setDisplayName("Foreground"); - addProperty("xYScaleFactor").setCategory("General").setDisplayName("XYScaleFactor"); - addProperty("selectColor").setCategory("General").setDisplayName("Select Color"); - addProperty("multiGlobalDraw").setCategory("General").setDisplayName("MultiGlobalDraw"); - addProperty("pointAntiAlias").setCategory("General").setDisplayName("Point AntiAlias"); - addProperty("highSpeedWheelZoom").setCategory("General").setDisplayName("HighSpeedWheelZoom"); - } -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/map/MaskOut.java b/MeteoInfoLib/src/main/java/org/meteoinfo/map/MaskOut.java deleted file mode 100644 index 3d0228ba..00000000 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/map/MaskOut.java +++ /dev/null @@ -1,209 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.map; - -import com.l2fprod.common.beans.BaseBeanInfo; -import com.l2fprod.common.beans.ExtendedPropertyDescriptor; -import com.l2fprod.common.beans.editor.ComboBoxPropertyEditor; -import java.util.ArrayList; -import java.util.List; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.geometry.shape.ShapeTypes; - -/** - * - * @author yaqiang - */ -public class MaskOut { - // - - private static MapView _mapView; - private boolean _setMaskLayer; - private String _maskLayer; - private List _layerList; - // - // - - /** - * Constructor - * - * @param aMapView - */ - public MaskOut(MapView aMapView) { - _mapView = aMapView; - _setMaskLayer = false; - _maskLayer = ""; - } - // - // - - /** - * Set map view - * @param mapView Map view - */ - public void setMapView(MapView mapView){ - _mapView = mapView; - } - - /** - * Get polygon map layers - * - * @return The polygon layer names - */ - public List getPolygonMapLayers() { - return _layerList; - } - - /** - * Set polygon map layers - * - * @param layers The polygon layer names - */ - public void setPolygonMapLayers(List layers) { - _layerList = layers; - } - - /** - * Get if is mask out - * - * @return Boolean - */ - public boolean isMask() { - return _setMaskLayer; - } - - /** - * Set if is mask out - * - * @param istrue Boolean - */ - public void setMask(boolean istrue) { - _setMaskLayer = istrue; - _mapView.paintLayers(); - } - - /** - * Get mask layer name - * - * @return The mask layer name - */ - public String getMaskLayer() { - return _maskLayer; - } - - /** - * Set mask layer name - * - * @param lname The layer name - */ - public void setMaskLayer(String lname) { - _maskLayer = lname; - _mapView.paintLayers(); - } - // - // - - /** - * Get layer names - * - * @return Layer names - */ - public static List getLayerNames() { - List layerNames = new ArrayList<>(); - for (MapLayer aLayer : _mapView.getLayers()) { - if (aLayer.getLayerType() == LayerTypes.VectorLayer) { - if (aLayer.getShapeType() == ShapeTypes.Polygon) { - layerNames.add(aLayer.getLayerName()); - } - } - } - - return layerNames; - } - // - - // - public class MaskOutBean { - - public MaskOutBean() { - } - - // - /** - * Get if is mask out - * - * @return Boolean - */ - public boolean isMask() { - return _setMaskLayer; - } - - /** - * Set if is mask out - * - * @param istrue Boolean - */ - public void setMask(boolean istrue) { - _setMaskLayer = istrue; - _mapView.paintLayers(); - } - - /** - * Get mask layer name - * - * @return The mask layer name - */ - public String getMaskLayer() { - return _maskLayer; - } - - /** - * Set mask layer name - * - * @param lname The layer name - */ - public void setMaskLayer(String lname) { - _maskLayer = lname; - _mapView.paintLayers(); - } - // - } - - public static class MaskOutBeanBeanInfo extends BaseBeanInfo { - - public MaskOutBeanBeanInfo() { - super(MaskOut.MaskOutBean.class); - ExtendedPropertyDescriptor e = addProperty("maskLayer"); - e.setCategory("General").setPropertyEditorClass(MaskOut.LayerNameEditor.class); - e.setDisplayName("Layer Name"); - e.setShortDescription("The name of the layers can be used as maskout"); - e = addProperty("mask"); - e.setCategory("General").setDisplayName("Is Maskout"); - } - } - - public static class LayerNameEditor extends ComboBoxPropertyEditor { - - public LayerNameEditor() { - super(); - String[] names = (String[]) getLayerNames().toArray(new String[0]); - setAvailableValues(names); -// Icon[] icons = new Icon[4]; -// Arrays.fill(icons, UIManager.getIcon("Tree.openIcon")); -// setAvailableIcons(icons); - } - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/script/MapForm.java b/MeteoInfoLib/src/main/java/org/meteoinfo/script/MapForm.java index 87d2ac0c..9246949a 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/script/MapForm.java +++ b/MeteoInfoLib/src/main/java/org/meteoinfo/script/MapForm.java @@ -8,8 +8,8 @@ package org.meteoinfo.script; import java.awt.BorderLayout; import java.awt.image.BufferedImage; import javax.imageio.ImageIO; -import org.meteoinfo.layout.MapLayout; -import org.meteoinfo.layout.MouseMode; +import org.meteoinfo.geo.layout.MapLayout; +import org.meteoinfo.geo.layout.MouseMode; /** * diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/script/MeteoInfoMap.java b/MeteoInfoLib/src/main/java/org/meteoinfo/script/MeteoInfoMap.java index 82c15490..56ae1047 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/script/MeteoInfoMap.java +++ b/MeteoInfoLib/src/main/java/org/meteoinfo/script/MeteoInfoMap.java @@ -11,14 +11,14 @@ import java.util.logging.Logger; import javax.swing.WindowConstants; import org.meteoinfo.data.GridData; -import org.meteoinfo.data.mapdata.MapDataManage; -import org.meteoinfo.data.meteodata.DrawMeteoData; +import org.meteoinfo.geo.mapdata.MapDataManage; +import org.meteoinfo.geo.meteodata.DrawMeteoData; import org.meteoinfo.data.meteodata.DrawType2D; import org.meteoinfo.geometry.legend.PolygonBreak; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layout.MapLayout; -import org.meteoinfo.legend.MapFrame; -import org.meteoinfo.map.MapView; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.layout.MapLayout; +import org.meteoinfo.geo.legend.MapFrame; +import org.meteoinfo.geo.mapview.MapView; /** * diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/script/MeteoInfoScript.java b/MeteoInfoLib/src/main/java/org/meteoinfo/script/MeteoInfoScript.java index 3ee9a397..38641d1d 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/script/MeteoInfoScript.java +++ b/MeteoInfoLib/src/main/java/org/meteoinfo/script/MeteoInfoScript.java @@ -17,15 +17,16 @@ import org.meteoinfo.chart.ChartText; import org.meteoinfo.chart.plot.XY1DPlot; import org.meteoinfo.common.Extent; import org.meteoinfo.data.GridData; -import org.meteoinfo.data.mapdata.MapDataManage; +import org.meteoinfo.geo.mapdata.MapDataManage; import org.meteoinfo.data.meteodata.*; +import org.meteoinfo.geo.meteodata.DrawMeteoData; import org.meteoinfo.geometry.legend.LineStyles; import org.meteoinfo.geometry.legend.PointStyle; import org.meteoinfo.geometry.legend.PolygonBreak; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layout.MapLayout; -import org.meteoinfo.legend.MapFrame; -import org.meteoinfo.map.MapView; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.layout.MapLayout; +import org.meteoinfo.geo.legend.MapFrame; +import org.meteoinfo.geo.mapview.MapView; /** * diff --git a/MeteoInfoLib/src/test/java/map/frmMap.java b/MeteoInfoLib/src/test/java/map/frmMap.java index 7ea8471f..6b129ad8 100644 --- a/MeteoInfoLib/src/test/java/map/frmMap.java +++ b/MeteoInfoLib/src/test/java/map/frmMap.java @@ -1,12 +1,12 @@ package map; import org.meteoinfo.common.GenericFileFilter; -import org.meteoinfo.data.mapdata.MapDataManage; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layout.MapLayout; -import org.meteoinfo.legend.LayersLegend; -import org.meteoinfo.map.MapView; -import org.meteoinfo.map.MouseTools; +import org.meteoinfo.geo.mapdata.MapDataManage; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.layout.MapLayout; +import org.meteoinfo.geo.legend.LayersLegend; +import org.meteoinfo.geo.mapview.MapView; +import org.meteoinfo.geo.mapview.MouseTools; import javax.swing.*; import java.awt.*; diff --git a/hs_err_pid31056.log b/hs_err_pid31056.log index b7cef7dd..383b5155 100644 --- a/hs_err_pid31056.log +++ b/hs_err_pid31056.log @@ -18,7 +18,7 @@ --------------- S U M M A R Y ------------ -Command Line: -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:53660,suspend=y,server=n -javaagent:C:\Users\dell\AppData\Local\JetBrains\IdeaIC2020.1\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 org.meteoinfo.laboratory.MeteoInfoLab +Command Line: -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:53660,suspend=y,server=n -javaagent:C:\Users\dell\AppData\Local\JetBrains\IdeaIC2020.1\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 org.meteoinfo.lab.MeteoInfoLab Host: Intel(R) Xeon(R) Silver 4210 CPU @ 2.20GHz, 40 cores, 63G, Windows 10 , 64 bit Build 18362 (10.0.18362.329) Time: Sat Apr 18 10:19:59 2020 ?D1��������?����?? elapsed time: 51 seconds (0d 0h 0m 51s) @@ -64,9 +64,9 @@ j org.python.core.PyCode.call(Lorg/python/core/ThreadState;Lorg/python/core/PyF j org.python.core.Py.runCode(Lorg/python/core/PyCode;Lorg/python/core/PyObject;Lorg/python/core/PyObject;)Lorg/python/core/PyObject;+156 j org.python.core.__builtin__.execfile_flags(Ljava/lang/String;Lorg/python/core/PyObject;Lorg/python/core/PyObject;Lorg/python/core/CompilerFlags;)V+86 j org.python.util.PythonInterpreter.execfile(Ljava/lang/String;)V+16 -j org.meteoinfo.laboratory.gui.PythonInteractiveInterpreter.execfile(Ljava/lang/String;)V+10 -j org.meteoinfo.laboratory.gui.ConsoleDockable$3.doInBackground()Ljava/lang/String;+102 -j org.meteoinfo.laboratory.gui.ConsoleDockable$3.doInBackground()Ljava/lang/Object;+1 +j org.meteoinfo.lab.gui.PythonInteractiveInterpreter.execfile(Ljava/lang/String;)V+10 +j org.meteoinfo.lab.gui.ConsoleDockable$3.doInBackground()Ljava/lang/String;+102 +j org.meteoinfo.lab.gui.ConsoleDockable$3.doInBackground()Ljava/lang/Object;+1 j javax.swing.SwingWorker$1.call()Ljava/lang/Object;+14 java.desktop@11.0.5 j java.util.concurrent.FutureTask.run$$$capture()V+39 java.base@11.0.5 j java.util.concurrent.FutureTask.run()V+5 java.base@11.0.5 @@ -843,7 +843,7 @@ symbol engine: initialized successfully - sym options: 0x614 - pdb path: .;C:\Pr VM Arguments: jvm_args: -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:53660,suspend=y,server=n -javaagent:C:\Users\dell\AppData\Local\JetBrains\IdeaIC2020.1\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -java_command: org.meteoinfo.laboratory.MeteoInfoLab +java_command: org.meteoinfo.lab.MeteoInfoLab java_class_path (initial): D:\MyProgram\java\MeteoInfoDev\MeteoInfo\MeteoInfoLab\target\classes;D:\MyProgram\java\MeteoInfoDev\MeteoInfo\MeteoInfoLib\target\classes;C:\Users\dell\.m2\repository\edu\ucar\netcdfAll\5.1.0\netcdfAll-5.1.0.jar;C:\Users\dell\.m2\repository\com\l2fprod\l2fprod-common-all\0.1\l2fprod-common-all-0.1.jar;C:\Users\dell\.m2\repository\org\freehep\freehep-graphics2d\2.4\freehep-graphics2d-2.4.jar;C:\Users\dell\.m2\repository\org\freehep\freehep-graphicsbase\2.4\freehep-graphicsbase-2.4.jar;C:\Users\dell\.m2\repository\org\freehep\freehep-io\2.2.2\freehep-io-2.2.2.jar;C:\Users\dell\.m2\repository\junit\junit\4.10\junit-4.10.jar;C:\Users\dell\.m2\repository\org\hamcrest\hamcrest-core\1.1\hamcrest-core-1.1.jar;C:\Users\dell\.m2\repository\org\freehep\freehep-graphicsio-ps\2.4\freehep-graphicsio-ps-2.4.jar;C:\Users\dell\.m2\repository\org\freehep\freehep-graphicsio\2.4\freehep-graphicsio-2.4.jar;C:\Users\dell\.m2\repository\org\freehep\freehep-graphicsio-tests\2.4\freehep-graphicsio-tests-2.4.jar;C:\Users\dell\.m2\repository\org\scilab\forge\jlatexmath\1.0.7\jlatexmath-1.0.7.jar;C:\Users\dell\.m2\repository\org\scilab\forge\jlatexmath-font-greek\1.0.7\jlatexmath-font-greek-1.0.7.jar;C:\Users\dell\.m2\repository\org\scilab\forge\jlatexmath-font-cyrillic\1.0.7\jlatexmath-font-cyrillic-1.0.7.jar;C:\Users\dell\.m2\repository\org\python\jython-standalone\2.7.2\jython-standalone-2.7.2.jar;C:\Users\dell\.m2\repository\org\freehep\freehep-graphicsio-emf\2.4\freehep-graphicsio-emf-2.4.jar;C:\Users\dell\.m2\repository\org\freehep\freehep-graphicsio-pdf\2.4\freehep-graphicsio-pdf-2.4.jar;C:\Users\dell\.m2\repository\org\apache\commons\commons-imaging\1.0-alpha1\commons-imaging-1.0-alpha1.jar;C:\Users\dell\.m2\repository\com\toedter\jcalendar\1.4\jcalendar-1.4.jar;C:\Users\dell\.m2\repository\org\ejml\ejml-experimental\0.32\ejml-experimental-0.32.jar;C:\Users\dell\.m2\repository\org\ejml\ejml-core\0.32\ejml-core-0.32.jar;C:\Users\dell\.m2\repository\org\ejml\ Launcher Type: SUN_STANDARD diff --git a/meteoinfo-chart/meteoinfo-chart.iml b/meteoinfo-chart/meteoinfo-chart.iml index c16c9a62..6576bbf2 100644 --- a/meteoinfo-chart/meteoinfo-chart.iml +++ b/meteoinfo-chart/meteoinfo-chart.iml @@ -36,13 +36,17 @@ + + + + + + + - - - @@ -63,5 +67,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/meteoinfo-chart/pom.xml b/meteoinfo-chart/pom.xml index 10268258..4ed930d7 100644 --- a/meteoinfo-chart/pom.xml +++ b/meteoinfo-chart/pom.xml @@ -92,6 +92,16 @@ freehep-graphicsio-ps 2.4 + + org.jogamp.gluegen + gluegen-rt-main + 2.3.2 + + + org.jogamp.jogl + jogl-all-main + 2.3.2 + \ No newline at end of file diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/Chart.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/Chart.java deleted file mode 100644 index 66b3c7f8..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/Chart.java +++ /dev/null @@ -1,902 +0,0 @@ -/* 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.chart; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.RenderingHints; -import java.awt.Stroke; -import java.awt.geom.AffineTransform; -import java.awt.geom.Rectangle2D; -import java.util.ArrayList; -import java.util.List; -import org.meteoinfo.chart.plot.MapPlot; -import org.meteoinfo.chart.plot.Plot; -import org.meteoinfo.common.PointF; -import org.meteoinfo.chart.drawing.Draw; - -/** - * - * @author Yaqiang Wang - * yaqiang.wang@gmail.com - */ -public class Chart { - - // - private List plots; - private int currentPlot; - private int rowNum; - private int columnNum; - private ChartText title; - private ChartText subTitle; - private List texts; - private ChartLegend legend; - private Color background; - //private boolean drawBackground; - private boolean drawLegend; - private Rectangle2D plotArea; - private boolean antiAlias; - private boolean symbolAntialias; - private ChartPanel parent; - - // - // - /** - * Constructor - */ - public Chart() { - this.drawLegend = false; - this.background = Color.white; - //this.drawBackground = true; - this.antiAlias = false; - this.symbolAntialias = true; - this.rowNum = 1; - this.columnNum = 1; - this.plots = new ArrayList<>(); - this.currentPlot = -1; - this.texts = new ArrayList<>(); - } - - /** - * Constructor - * - * @param parent ChartPanel parent - */ - public Chart(ChartPanel parent) { - this(); - this.parent = parent; - } - - /** - * Constructor - * - * @param plot Plot - * @param parent ChartPanel - */ - public Chart(Plot plot, ChartPanel parent) { - this(parent); - this.plots.add(plot); - } - - /** - * Constructor - * - * @param plot Plot - */ - public Chart(Plot plot) { - this(plot, null); - } - - /** - * Constructor - * - * @param title Title - * @param plot Plot - * @param parent ChartPanel - */ - public Chart(String title, Plot plot, ChartPanel parent) { - this(plot, parent); - if (title == null) { - this.title = null; - } else { - this.title = new ChartText(title); - } - } - - /** - * Constructor - * - * @param title Title - * @param plot Plot - */ - public Chart(String title, Plot plot) { - this(title, plot, null); - } - - // - // - /** - * Set ChartPanel parent - * - * @param value ChartPanel - */ - public void setParent(ChartPanel value) { - this.parent = value; - for (Plot plot : this.plots) { - if (plot instanceof MapPlot) { - ((MapPlot) plot).setParent(value); - } - } - } - - /** - * Get plot - * - * @return Plot - */ - public List getPlots() { - return plots; - } - - /** - * Get current plot - * - * @return Current plot - */ - public Plot getCurrentPlot() { - if (this.plots.isEmpty()) { - return null; - } - - if (this.currentPlot < 0 || this.currentPlot >= this.plots.size()) { - this.currentPlot = this.plots.size() - 1; - } - return this.plots.get(this.currentPlot); - } - - /** - * Set current plot - * - * @param value Current plot - */ - public void setCurrentPlot(Plot value) { - if (this.plots.isEmpty()) { - this.addPlot(value); - //this.currentPlot = 0; - } else if (this.currentPlot == -1) { - this.plots.add(value); - } else { - if (this.currentPlot >= this.plots.size()) { - this.currentPlot = this.plots.size() - 1; - } - Plot plot = this.plots.get(this.currentPlot); - value.isSubPlot = plot.isSubPlot; - value.columnIndex = plot.columnIndex; - value.rowIndex = plot.rowIndex; - this.plots.set(this.currentPlot, value); - } - } - - /** - * Set current plot index - * - * @param value Current plot index - */ - public void setCurrentPlot(int value) { - this.currentPlot = value; - } - - /** - * Get the first plot - * - * @return Plot - */ - public Plot getPlot() { - if (this.plots.isEmpty()) { - return null; - } - - return this.plots.get(0); - } - - /** - * Get row number of sub plots - * - * @return Row number of sub plots - */ - public int getRowNum() { - return this.rowNum; - } - - /** - * Set row number of sub plots - * - * @param value Row number of sub plots - */ - public void setRowNum(int value) { - this.rowNum = value; - } - - /** - * Get column number of sub plots - * - * @return Column number of sub plots - */ - public int getColumnNum() { - return this.columnNum; - } - - /** - * Set column number of sub plots - * - * @param value Column number of sub plots - */ - public void setColumnNum(int value) { - this.columnNum = value; - } - - /** - * Get title - * - * @return Title - */ - public ChartText getTitle() { - return title; - } - - /** - * Set title - * - * @param value Title - */ - public void setTitle(ChartText value) { - title = value; - } - - /** - * Get sub title - * - * @return Sub title - */ - public ChartText getSubTitle() { - return subTitle; - } - - /** - * Set sub title - * - * @param value Sub title - */ - public void setSubTitle(ChartText value) { - subTitle = value; - } - - /** - * Get background - * - * @return Background - */ - public Color getBackground() { - return this.background; - } - - /** - * Set background - * - * @param value Background - */ - public void setBackground(Color value) { - this.background = value; - } - -// /** -// * Get if draw background -// * -// * @return Boolean -// */ -// public boolean isDrawBackground() { -// return this.drawBackground; -// } - -// /** -// * Set if draw background -// * -// * @param value Boolean -// */ -// public void setDrawBackground(boolean value) { -// this.drawBackground = value; -// } - - /** - * Get chart legend - * - * @return Chart legend - */ - public ChartLegend getLegend() { - return this.legend; - } - - /** - * Get if draw legend - * - * @return If draw legend - */ - public boolean isDrawLegend() { - return this.drawLegend; - } - - /** - * Set if draw legend - * - * @param value Boolean - */ - public void setDrawLegend(boolean value) { - this.drawLegend = value; - } - - /** - * Get plot area - * - * @return Plot area - */ - public Rectangle2D getPlotArea() { - return this.plotArea; - } - - /** - * Get if is anti-alias - * - * @return Boolean - */ - public boolean isAntiAlias() { - return this.antiAlias; - } - - /** - * Set if is anti-alias - * - * @param value Boolean - */ - public void setAntiAlias(boolean value) { - this.antiAlias = value; - } - - /** - * Get symbol antialias - * @return Boolean - */ - public boolean isSymbolAntialias() { - return this.symbolAntialias; - } - - /** - * Set symbol antialias - * @param value Boolean - */ - public void setSymbolAntialias(boolean value) { - this.symbolAntialias = value; - } - - // - // - /** - * Draw plot - * - * @param g Graphics2D - * @param area Drawing area - */ - public void draw(Graphics2D g, Rectangle2D area) { - g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); - if (antiAlias) { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - //g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); - g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); - g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); - g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); - //g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); - g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); - } else { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - //g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); - g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT); - g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF); - g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_DEFAULT); - //g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); - g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT); - } - - AffineTransform oldMatrix = g.getTransform(); - Rectangle oldRegion = g.getClipBounds(); - g.setClip(area); - g.translate(area.getX(), area.getY()); - - //Draw background - if (this.background != null) { - g.setColor(background); - g.fill(new Rectangle2D.Double(0, 0, area.getWidth(), area.getHeight())); - } - - //Draw title - float y = 5; - if (title != null) { - g.setColor(title.getColor()); - g.setFont(title.getFont()); - float x = (float) area.getWidth() / 2; - //y -= this.title.getHeight(g) - 5; - //FontMetrics metrics = g.getFontMetrics(title.getFont()); - //x -= metrics.stringWidth(title.getText()) / 2; - //y += metrics.getHeight(); - int i = 0; - for (String text : title.getTexts()) { - Dimension dim = Draw.getStringDimension(text, g); - if (i == 0) { - y += dim.getHeight(); - } - Draw.drawString(g, text, x - dim.width / 2, y); - g.setFont(title.getFont()); - y += dim.height + title.getLineSpace(); - i += 1; - } - y += 5; - } - - //Draw plot - plotArea = this.getPlotArea(g, area); - //plotArea = area; - if (plotArea.getWidth() < 20 || plotArea.getHeight() < 20) { - g.setTransform(oldMatrix); - g.setClip(oldRegion); - return; - } - - if (this.plots.size() > 0) { - //double zoom = this.getPositionAreaZoom(g, plotArea); - //Margin tightInset = this.getPlotsTightInset(g, plotArea); - Margin shrink = this.getPlotsShrink(g, plotArea); - for (int i = 0; i < this.plots.size(); i++) { - Plot plot = this.plots.get(i); - plot.setSymbolAntialias(this.symbolAntialias); - if (plot.isOuterPosActive()){ - if (plot.isSubPlot || plot.isSameShrink()) { - plot.setPlotShrink(shrink); - } else { - //plot.setPlotShrink(this.getPlotShrink(g, area, plot)); - plot.setPlotShrink(this.getPlotShrink(g, plotArea, plot)); - } - } - if (plot instanceof MapPlot) { - ((MapPlot) plot).setAntialias(this.antiAlias); - } - plot.draw(g, plotArea); - } - } - - //Draw text - drawText(g, area); - - //Draw legend - if (this.drawLegend) { - Dimension dim = this.legend.getLegendDimension(g, new Dimension((int) area.getWidth(), (int) area.getHeight())); - float x = 0; - switch (this.legend.getPosition()) { - case UPPER_CENTER_OUTSIDE: - x = (float) area.getWidth() / 2 - dim.width / 2; - y += 5; - break; - case LOWER_CENTER_OUTSIDE: - x = (float) area.getWidth() / 2 - dim.width / 2; - y += plotArea.getHeight() + 5; - break; - case LEFT_OUTSIDE: - x = 10; - y = (float) area.getHeight() / 2 - dim.height / 2; - break; - case RIGHT_OUTSIDE: - x = (float) plotArea.getWidth() + 10; - y = (float) area.getHeight() / 2 - dim.height / 2; - break; - } - this.legend.draw(g, new PointF(x, y)); - } - - g.setTransform(oldMatrix); - g.setClip(oldRegion); - } - - void drawText(Graphics2D g, Rectangle2D area) { - float x, y; - for (ChartText text : this.texts) { - x = (float) (area.getWidth() * text.getX()); - y = (float) (area.getHeight() * (1 - text.getY())); - Dimension dim = Draw.getStringDimension(text.getText(), g); - Rectangle.Double rect = new Rectangle.Double(x, y, dim.getWidth(), dim.getHeight()); - if (text.isFill()) { - g.setColor(text.getBackground()); - g.fill(rect); - } - if (text.isDrawNeatline()) { - g.setColor(text.getNeatlineColor()); - Stroke oldStroke = g.getStroke(); - g.setStroke(new BasicStroke(text.getNeatlineSize())); - g.draw(rect); - g.setStroke(oldStroke); - } - g.setFont(text.getFont()); - g.setColor(text.getColor()); - Draw.drawString(g, text.getText(), x, y); - } - } - - private Rectangle2D getPlotArea(Graphics2D g, Rectangle2D area) { - Rectangle2D pArea = new Rectangle2D.Double(); - int edge = 0; - int top = edge; - int left = edge; - int right = edge; - int bottom = edge; - if (this.title != null) { - top += this.title.getTrueDimension(g).height + 12; - } - pArea.setRect(left, top, area.getWidth() - left - right, area.getHeight() - top - bottom); - - return pArea; - } - - private Rectangle2D getPlotArea_bak(Graphics2D g, Rectangle2D area) { - Rectangle2D pArea = new Rectangle2D.Double(); - int edge = 2; - int top = edge; - int left = edge; - int right = edge; - int bottom = edge; - if (this.title != null) { - top += this.title.getTrueDimension(g).height + 10; - } - if (this.drawLegend) { - Dimension dim = this.legend.getLegendDimension(g, new Dimension((int) area.getWidth(), (int) area.getHeight())); - switch (this.legend.getPosition()) { - case UPPER_CENTER_OUTSIDE: - top += dim.height + 10; - break; - case LOWER_CENTER_OUTSIDE: - bottom += dim.height + 10; - break; - case LEFT_OUTSIDE: - left += dim.width + 10; - break; - case RIGHT_OUTSIDE: - right += dim.width + 10; - break; - } - } - pArea.setRect(left, top, area.getWidth() - left - right, area.getHeight() - top - bottom); - - return pArea; - } - - private Margin getPlotShrink(Graphics2D g, Rectangle2D area, Plot plot) { - Margin shrink; - if (plot.isSubPlot) { - double rowHeight = area.getHeight() / this.rowNum; - double colWidth = area.getWidth() / this.columnNum; - double x = area.getX() + plot.columnIndex * colWidth; - double y = area.getY() + plot.rowIndex * rowHeight; - Rectangle2D subPlotArea = new Rectangle2D.Double(x, y, colWidth, rowHeight); - plot.setOuterPositionArea(subPlotArea); - plot.updatePosition(area, subPlotArea); - Rectangle2D positionArea = plot.getPositionArea(area); - plot.setPositionArea(positionArea); - Margin tightInset = plot.getTightInset(g, positionArea); - plot.setTightInset(tightInset); - shrink = plot.getPlotShrink(); - } else { - plot.setOuterPositionArea(area); - Rectangle2D positionArea = plot.getPositionArea(area); - plot.setPositionArea(positionArea); - Margin tightInset = plot.getTightInset(g, positionArea); - plot.setTightInset(tightInset); - shrink = plot.getPlotShrink(); - //shrink = tightInset; - } - - return shrink; - } - - private Margin getPlotsShrink(Graphics2D g, Rectangle2D area) { - Margin pshrink = null, shrink; - for (int i = 0; i < this.plots.size(); i++) { - Plot plot = this.plots.get(i); - plot.setOuterPositionArea(plot.getOuterPositionArea(area)); - Rectangle2D positionArea = plot.getPositionArea(area); - plot.setPositionArea(positionArea); - Margin tightInset = plot.getTightInset(g, positionArea); - plot.setTightInset(tightInset); - shrink = plot.getPlotShrink(); - if (i == 0) { - pshrink = shrink; - } else if (pshrink != null) { - pshrink = pshrink.extend(shrink); - } - } - - return pshrink; - } - - private Margin getPlotsShrink_bak(Graphics2D g, Rectangle2D area) { - Margin pshrink = null, shrink; - for (int i = 0; i < this.plots.size(); i++) { - Plot plot = this.plots.get(i); - if (plot.isSubPlot) { - double rowHeight = area.getHeight() / this.rowNum; - double colWidth = area.getWidth() / this.columnNum; - double x = area.getX() + plot.columnIndex * colWidth; - double y = area.getY() + plot.rowIndex * rowHeight; - Rectangle2D subPlotArea = new Rectangle2D.Double(x, y, colWidth, rowHeight); - plot.setOuterPositionArea(subPlotArea); - plot.updatePosition(area, subPlotArea); - Rectangle2D positionArea = plot.getPositionArea(area); - plot.setPositionArea(positionArea); - Margin tightInset = plot.getTightInset(g, positionArea); - plot.setTightInset(tightInset); - shrink = plot.getPlotShrink(); - } else { - plot.setOuterPositionArea(area); - Rectangle2D positionArea = plot.getPositionArea(area); - plot.setPositionArea(positionArea); - Margin tightInset = plot.getTightInset(g, positionArea); - plot.setTightInset(tightInset); - shrink = plot.getPlotShrink(); - } - if (i == 0) { - pshrink = shrink; - } else if (pshrink != null) { - pshrink = pshrink.extend(shrink); - } - } - - return pshrink; - } - - private Margin getPlotsTightInset(Graphics2D g, Rectangle2D area) { - int i = 0; - Margin pti = null, tightInset; - for (Plot plot : this.plots) { - if (plot.isSubPlot) { - double rowHeight = area.getHeight() / this.rowNum; - double colWidth = area.getWidth() / this.columnNum; - double x = area.getX() + plot.columnIndex * colWidth; - double y = area.getY() + plot.rowIndex * rowHeight; - Rectangle2D subPlotArea = new Rectangle2D.Double(x, y, colWidth, rowHeight); - plot.setOuterPositionArea(subPlotArea); - plot.updatePosition(area, subPlotArea); - Rectangle2D positionArea = plot.getPositionArea(); - plot.setPositionArea(positionArea); - tightInset = plot.getTightInset(g, positionArea); - } else { - plot.setOuterPositionArea(area); - Rectangle2D positionArea = plot.getPositionArea(); - plot.setPositionArea(positionArea); - tightInset = plot.getTightInset(g, positionArea); - } - if (i == 0) { - pti = tightInset; - } else if (pti != null) { - pti = pti.extend(tightInset); - } - i += 1; - } - - return pti; - } - - private double getPositionAreaZoom(Graphics2D g, Rectangle2D area) { - double zoom = 1.0; - for (Plot plot : this.plots) { - if (plot.isSubPlot) { - double rowHeight = area.getHeight() / this.rowNum; - double colWidth = area.getWidth() / this.columnNum; - double x = area.getX() + plot.columnIndex * colWidth; - double y = area.getY() + plot.rowIndex * rowHeight; - Rectangle2D subPlotArea = new Rectangle2D.Double(x, y, colWidth, rowHeight); - plot.setOuterPositionArea(subPlotArea); - plot.updatePosition(area, subPlotArea); - Rectangle2D positionArea = plot.getPositionArea(); - plot.setPositionArea(positionArea); - Margin tightInset = plot.getTightInset(g, positionArea); - plot.setTightInset(tightInset); - double zoom1 = plot.updatePostionAreaZoom(); - if (zoom1 < zoom) { - zoom = zoom1; - } - } else { - plot.setOuterPositionArea(area); - Rectangle2D positionArea = plot.getPositionArea(); - plot.setPositionArea(positionArea); - Margin tightInset = plot.getTightInset(g, positionArea); - plot.setTightInset(tightInset); - double zoom1 = plot.updatePostionAreaZoom(); - if (zoom1 < zoom) { - zoom = zoom1; - } - } - } - - return zoom; - } - - private Rectangle2D getSubPlotArea(Graphics2D g, Plot plot, Rectangle2D area) { - if (plot.isSubPlot) { - double rowHeight = area.getHeight() / this.rowNum; - double colWidth = area.getWidth() / this.columnNum; - double x = area.getX() + plot.columnIndex * colWidth; - double y = area.getY() + plot.rowIndex * rowHeight; - Rectangle2D subPlotArea = new Rectangle2D.Double(x, y, colWidth, rowHeight); - plot.setOuterPositionArea(subPlotArea); - plot.updatePosition(area, subPlotArea); - Rectangle2D positionArea = plot.getPositionArea(); - plot.setPositionArea(positionArea); - Margin tightInset = plot.getTightInset(g, positionArea); - plot.setTightInset(tightInset); - double zoom = plot.updatePostionAreaZoom(); - plot.setPositionAreaZoom(zoom); - return subPlotArea; - } else { - plot.setOuterPositionArea(area); - Rectangle2D positionArea = plot.getPositionArea(); - plot.setPositionArea(positionArea); - Margin tightInset = plot.getTightInset(g, positionArea); - plot.setTightInset(tightInset); - double zoom = plot.updatePostionAreaZoom(); - plot.setPositionAreaZoom(zoom); - //return tightInset.getArea(positionArea); - return area; - } - } - - /** - * Get graph area - * - * @return Get graph area - */ - public Rectangle2D getGraphArea() { - Rectangle2D rect = this.plots.get(0).getPositionArea(); - double left = rect.getX() + this.plotArea.getX(); - double top = rect.getY() + this.plotArea.getY(); - return new Rectangle2D.Double(left, top, rect.getWidth(), rect.getHeight()); - } - - /** - * Find a plot by point - * - * @param x X - * @param y Y - * @return Plot - */ - public Plot findPlot(int x, int y) { - for (Plot plot : this.plots) { - Rectangle2D area = plot.getPositionArea(); - if (area.contains(x, y)) { - return plot; - } - } - - return null; - } - - /** - * Clear plots - */ - public void clearPlots() { - this.plots.clear(); - } - - /** - * Clear texts - */ - public void clearTexts() { - this.texts.clear(); - } - - /** - * Remove a plot - * - * @param plot The plot - */ - public void removePlot(Plot plot) { - this.plots.remove(plot); - } - - /** - * Add a plot - * - * @param plot Plot - */ - public void addPlot(Plot plot) { - if (plot instanceof MapPlot) { - ((MapPlot) plot).setParent(parent); - } - this.plots.add(plot); - } - - /** - * Set plot - * - * @param plot Plot - */ - public void setPlot(Plot plot) { - if (plot instanceof MapPlot) { - ((MapPlot) plot).setParent(parent); - } - this.plots.clear(); - this.plots.add(plot); - } - - /** - * Get plot by plot index - * - * @param plotIdx Plot index - begin with 1 - * @return Plot index - */ - public Plot getPlot(int plotIdx) { - for (Plot plot : this.plots) { - int pIdx = plot.rowIndex * this.columnNum + plot.columnIndex + 1; - if (pIdx == plotIdx) { - return plot; - } - } - - if (plotIdx > 0 && plotIdx <= this.plots.size()) - return this.plots.get(plotIdx - 1); - else - return null; - } - - /** - * Get plot index - * @param plot The plot - * @return Plot index - */ - public int getPlotIndex(Plot plot){ - return this.plots.indexOf(plot); - } - - /** - * Check if has web map layer - * - * @return Boolean - */ - public boolean hasWebMap() { - for (Plot plot : this.plots) { - if (plot instanceof MapPlot) { - MapPlot mp = (MapPlot) plot; - if (mp.hasWebMapLayer()) { - return true; - } - } - } - - return false; - } - - /** - * Add text - * - * @param text Text - */ - public void addText(ChartText text) { - this.texts.add(text); - } - // - -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartColorBar.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartColorBar.java deleted file mode 100644 index 3e715c75..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartColorBar.java +++ /dev/null @@ -1,1046 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.geom.AffineTransform; -import java.awt.geom.Line2D; -import java.awt.geom.Path2D; -import java.util.ArrayList; -import java.util.List; -import org.meteoinfo.chart.plot.XAlign; -import org.meteoinfo.chart.plot.YAlign; -import org.meteoinfo.common.PointD; -import org.meteoinfo.common.PointF; -import org.meteoinfo.chart.drawing.Draw; -import org.meteoinfo.common.DataConvert; -import org.meteoinfo.chart.legend.ColorBreak; -import org.meteoinfo.chart.legend.LegendScheme; -import org.meteoinfo.chart.legend.LegendType; -import org.meteoinfo.chart.legend.PointBreak; -import org.meteoinfo.chart.legend.PolygonBreak; -import org.meteoinfo.chart.legend.PolylineBreak; -import org.meteoinfo.geometry.shape.ShapeTypes; - -/** - * - * @author Yaqiang Wang - */ -public class ChartColorBar extends ChartLegend { - - // - private List tickLocations; - private List tickLabels; - private boolean autoTick; - private boolean insideTick; - private float tickLength; - private boolean tickVisible; - private float tickWidth; - private Color tickColor; - private boolean drawMinLabel; - private boolean drawMaxLabel; - - // - // - /** - * Constructor - * - * @param ls LegendScheme - */ - public ChartColorBar(LegendScheme ls) { - super(ls); - - this.tickLocations = new ArrayList<>(); - this.tickLabels = new ArrayList<>(); - this.autoTick = true; - this.insideTick = true; - this.tickLength = 5; - this.tickVisible = true; - this.tickWidth = 1; - this.tickColor = Color.black; - this.drawMinLabel = false; - this.drawMaxLabel = false; - } - - // - // - /** - * Tick locations - * - * @return Tick locations - */ - public List getTickLocations() { - return this.tickLocations; - } - - /** - * Set tick locations - * - * @param value Tick locations - */ - public void setTickLocations(List value) { - this.tickLocations.clear(); - this.tickLabels.clear(); - for (Number v : value) { - this.tickLocations.add(v.doubleValue()); - this.tickLabels.add(new ChartText(DataConvert.removeTailingZeros(String.valueOf(v)))); - } - this.autoTick = false; - } - - /** - * Set tick locations - * - * @param value Tick locations - */ - public void setTickLocations(double[] value) { - this.tickLocations.clear(); - this.tickLabels.clear(); - for (double v : value) { - this.tickLocations.add(v); - this.tickLabels.add(new ChartText(DataConvert.removeTailingZeros(String.valueOf(v)))); - } - this.autoTick = false; - } - - /** - * Get tick labels - * - * @return Tick labels - */ - public List getTickLabels() { - return this.tickLabels; - } - - /** - * Get tick label text - * - * @return Tick label text - */ - public List getTickLabelText() { - List strs = new ArrayList<>(); - for (ChartText ct : this.tickLabels) { - strs.add(ct.toString()); - } - - return strs; - } - - /** - * Set tick label text - * - * @param value Tick label text - */ - public void setTickLabelText(List value) { - this.tickLabels = new ArrayList<>(); - for (String v : value) { - this.tickLabels.add(new ChartText(v)); - } - this.autoTick = false; - } - - /** - * Set tick labels. - * - * @param value Tick labels - */ - public void setTickLabels(List value) { - this.tickLabels = value; - } - - /** - * Set tick labels - * - * @param value Tick labels - */ - public void setTickLabels_Number(List value) { - this.tickLabels = new ArrayList<>(); - for (Number v : value) { - this.tickLabels.add(new ChartText(v.toString())); - } - this.autoTick = false; - } - - /** - * Get if is auto tick labels - * - * @return Boolean - */ - public boolean isAutoTick() { - return this.autoTick; - } - - /** - * Set if auto tick labels - * - * @param value Boolean - */ - public void setAutoTick(boolean value) { - this.autoTick = value; - } - - /** - * Get tick length - * - * @return Tick length - */ - public float getTickLength() { - return this.tickLength; - } - - /** - * Set tick length - * - * @param value Tick length - */ - public void setTickLength(int value) { - this.tickLength = value; - } - - /** - * Get if is inside tick - * - * @return Boolean - */ - public boolean isInsideTick() { - return this.insideTick; - } - - /** - * Set if is inside tick - * - * @param value Boolean - */ - public void setInsideTick(boolean value) { - this.insideTick = value; - } - - /** - * Get if is tick visible - * @return Boolean - */ - public boolean isTickVisible() { - return this.tickVisible; - } - - /** - * Set if is tick visible - * @param value Boolean - */ - public void setTickVisible(boolean value) { - this.tickVisible = value; - } - - /** - * Get tick line width - * @return Tick line width - */ - public float getTickWidth() { - return this.tickWidth; - } - - /** - * Set tick line width - * @param value Tick line width - */ - public void setTickWidth(float value) { - this.tickWidth = value; - } - - /** - * Get tick color - * @return Tick color - */ - public Color getTickColor() { - return this.tickColor; - } - - /** - * Set tick color - * @param value Tick color - */ - public void setTickColor(Color value) { - this.tickColor = value; - } - - /** - * Get if draw minimum value label - * - * @return Boolean - */ - public boolean isDrawMinLabel() { - return this.drawMinLabel; - } - - /** - * Set if draw minimum value label - * - * @param value Boolean - */ - public void setDrawMinLabel(boolean value) { - this.drawMinLabel = value; - } - - /** - * Get if draw maximum value label - * - * @return Boolean - */ - public boolean isDrawMaxLabel() { - return this.drawMaxLabel; - } - - /** - * Set if draw maximum value label - * - * @param value Boolean - */ - public void setDrawMaxLabel(boolean value) { - this.drawMaxLabel = value; - } - - // - // - /** - * Draw legend - * - * @param g Graphics2D - * @param point Start point - */ - @Override - public void draw(Graphics2D g, PointF point) { - - AffineTransform oldMatrix = g.getTransform(); - g.translate(point.X + this.xshift, point.Y + this.yshift); - - //Draw background color - if (this.drawBackground) { - g.setColor(this.background); - g.fill(new Rectangle.Float(0, 0, this.width, this.height)); - } - - //Draw legend - g.setStroke(new BasicStroke(1)); - switch (this.orientation) { - case HORIZONTAL: - this.drawHorizontalBarLegend(g, legendScheme); - break; - case VERTICAL: - this.drawVerticalBarLegend(g, legendScheme); - break; - } - - //Draw neatline - if (drawNeatLine) { - Rectangle.Float mapRect = new Rectangle.Float(0, 0, this.width, this.height); - g.setColor(neatLineColor); - g.setStroke(new BasicStroke(neatLineSize)); - g.draw(mapRect); - } - - g.setTransform(oldMatrix); - } - - private void drawTickLine(Graphics2D g, PointF sP, float tickLen, boolean vertical, float shift) { - if (vertical) { - if (this.insideTick) { - g.draw(new Line2D.Float(sP.X + shift, sP.Y, sP.X + shift, sP.Y - tickLen)); - } else { - g.draw(new Line2D.Float(sP.X + shift, sP.Y, sP.X + shift, sP.Y + tickLen)); - sP.Y += tickLen; - } - sP.Y += 5; - } else { - if (this.insideTick) { - g.draw(new Line2D.Float(sP.X - tickLen, sP.Y + shift, sP.X, sP.Y + shift)); - } else { - g.draw(new Line2D.Float(sP.X, sP.Y + shift, sP.X + tickLen, sP.Y + shift)); - sP.X += tickLen; - } - sP.X += 5; - } - } - - private void drawTickLine(Graphics2D g, PointD sP, float tickLen, boolean vertical, double shift) { - if (vertical) { - if (this.insideTick) { - g.draw(new Line2D.Double(sP.X + shift, sP.Y, sP.X + shift, sP.Y - tickLen)); - } else { - g.draw(new Line2D.Double(sP.X + shift, sP.Y, sP.X + shift, sP.Y + tickLen)); - sP.Y += tickLen; - } - sP.Y += 5; - } else { - if (this.insideTick) { - g.draw(new Line2D.Double(sP.X - tickLen, sP.Y + shift, sP.X, sP.Y + shift)); - } else { - g.draw(new Line2D.Double(sP.X, sP.Y + shift, sP.X + tickLen, sP.Y + shift)); - sP.X += tickLen; - } - sP.X += 5; - } - } - - private void drawHorizontalBarLegend(Graphics2D g, LegendScheme aLS) { - PointD aP = new PointD(0, 0); - PointD sP = new PointD(0, 0); - boolean DrawShape = true, DrawFill = true, DrawOutline = false; - Color FillColor = Color.red, OutlineColor = Color.black; - String caption; - - int bNum = aLS.getBreakNum(); - if (aLS.getLegendBreaks().get(bNum - 1).isNoData()) { - bNum -= 1; - } - - List labelIdxs = new ArrayList<>(); - List tLabels = new ArrayList<>(); - if (this.autoTick) { - int tickGap = this.getTickGap(g); - int sIdx = (bNum % tickGap) / 2; - int labNum = bNum - 1; - if (aLS.getLegendType() == LegendType.UniqueValue) { - labNum += 1; - } else if (this.drawMinLabel) { - sIdx = 0; - labNum = bNum; - } - while (sIdx < labNum) { - labelIdxs.add(sIdx); - sIdx += tickGap; - } - } else { - int tickIdx; - for (int i = 0; i < bNum; i++) { - ColorBreak cb = aLS.getLegendBreaks().get(i); - if (i == bNum - 1) { - if (cb.getStartValue().equals(cb.getEndValue())) - continue; - } - double v = Double.parseDouble(cb.getEndValue().toString()); - if (this.tickLocations.contains(v)) { - labelIdxs.add(i); - tickIdx = this.tickLocations.indexOf(v); - tLabels.add(this.tickLabels.get(tickIdx).getText()); - } - } - } - - this._hBarHeight = (double) this.legendWidth / this.aspect; - _vBarWidth = (double) this.legendWidth / bNum; - float y_shift = 0; - if (this.label != null){ - switch (this.labelLocation){ - case "top": - case "in": - y_shift = this.label.getDimension(g).height + 5; - break; - } - } - int idx; - aP.Y = y_shift; - for (int i = 0; i < bNum; i++) { - idx = i; - switch (aLS.getShapeType()) { - case Point: - PointBreak aPB = (PointBreak) aLS.getLegendBreaks().get(idx); - DrawShape = aPB.isDrawShape(); - DrawFill = aPB.isDrawFill(); - FillColor = aPB.getColor(); - break; - case Polyline: - PolylineBreak aPLB = (PolylineBreak) aLS.getLegendBreaks().get(idx); - DrawShape = aPLB.getDrawPolyline(); - FillColor = aPLB.getColor(); - break; - case Polygon: - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(idx); - DrawShape = aPGB.isDrawShape(); - DrawFill = aPGB.isDrawFill(); - FillColor = aPGB.getColor(); - break; - case Image: - ColorBreak aCB = aLS.getLegendBreaks().get(idx); - DrawShape = true; - DrawFill = true; - FillColor = aCB.getColor(); - break; - } - - if (DrawShape) { - if (this.extendRect) { - if (aLS.getShapeType() == ShapeTypes.Polygon) { - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(idx).clone(); - aPGB.setDrawOutline(false); - Draw.drawPolygonSymbol(aP.X, aP.Y, _vBarWidth, _hBarHeight, aPGB, g); - } else { - Draw.drawPolygonSymbol(aP.X, aP.Y, FillColor, OutlineColor, _vBarWidth, - _hBarHeight, DrawFill, DrawOutline, g); - } - } else { - double extendw = _vBarWidth; - if (this.autoExtendFrac) { - extendw = _hBarHeight; - } - if (i == 0) { - PointD[] Points = new PointD[4]; - Points[0] = new PointD(); - Points[0].X = _vBarWidth - extendw; - Points[0].Y = aP.Y + _hBarHeight * 0.5; - Points[1] = new PointD(); - Points[1].X = _vBarWidth; - Points[1].Y = aP.Y; - Points[2] = new PointD(); - Points[2].X = _vBarWidth; - Points[2].Y = aP.Y + _hBarHeight; - Points[3] = new PointD(); - Points[3].X = _vBarWidth - extendw; - Points[3].Y = aP.Y + _hBarHeight * 0.5; - if (aLS.getShapeType() == ShapeTypes.Polygon) { - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(idx).clone(); - aPGB.setDrawOutline(false); - Draw.drawPolygon(Points, aPGB, g); - } else { - Draw.drawPolygon(Points, FillColor, OutlineColor, DrawFill, DrawOutline, g); - } - } else if (i == bNum - 1) { - PointD[] Points = new PointD[4]; - Points[0] = new PointD(); - Points[0].X = i * _vBarWidth - 1.0f; - Points[0].Y = aP.Y + _hBarHeight; - Points[1] = new PointD(); - Points[1].X = i * _vBarWidth - 1.0f; - Points[1].Y = aP.Y; - Points[2] = new PointD(); - Points[2].X = i * _vBarWidth + extendw; - Points[2].Y = aP.Y + _hBarHeight * 0.5; - Points[3] = new PointD(); - Points[3].X = i * _vBarWidth - 1.0f; - Points[3].Y = aP.Y + _hBarHeight; - if (aLS.getShapeType() == ShapeTypes.Polygon) { - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(idx).clone(); - aPGB.setDrawOutline(false); - Draw.drawPolygon(Points, aPGB, g); - } else { - Draw.drawPolygon(Points, FillColor, OutlineColor, DrawFill, DrawOutline, g); - } - } else if (aLS.getShapeType() == ShapeTypes.Polygon) { - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(idx).clone(); - aPGB.setDrawOutline(false); - Draw.drawPolygonSymbol(aP.X, aP.Y, _vBarWidth, _hBarHeight, aPGB, g); - } else { - Draw.drawPolygonSymbol(aP.X, aP.Y, FillColor, OutlineColor, _vBarWidth, - _hBarHeight, DrawFill, DrawOutline, g); - } - } - } - aP.X += _vBarWidth; - } - //Draw neatline - g.setStroke(new BasicStroke(this.neatLineSize)); - g.setColor(this.neatLineColor); - if (this.extendRect) { - g.draw(new Rectangle.Double(0, y_shift, this._vBarWidth * bNum, this._hBarHeight)); - } else { - double extendw = _vBarWidth; - if (this.autoExtendFrac) { - extendw = _hBarHeight; - } - Path2D p = new Path2D.Double(); - p.moveTo(_vBarWidth - extendw, this._hBarHeight / 2 + y_shift); - p.lineTo(this._vBarWidth, y_shift); - p.lineTo(this._vBarWidth * (bNum - 1), y_shift); - p.lineTo(this._vBarWidth * (bNum - 1) + extendw, this._hBarHeight / 2 + y_shift); - p.lineTo(this._vBarWidth * (bNum - 1), this._hBarHeight + y_shift); - p.lineTo(this._vBarWidth, this._hBarHeight + y_shift); - p.closePath(); - g.draw(p); - } - //Draw tick and label - aP.X = -_vBarWidth / 2; - float tickLen = this.tickLength; - if (this.insideTick) { - if (this._hBarHeight < tickLen) { - tickLen = (int) this._hBarHeight; - } - } - g.setStroke(new BasicStroke(this.tickWidth)); - g.setFont(tickLabelFont); - g.setColor(this.tickColor); - idx = 0; - for (int i = 0; i < bNum; i++) { - aP.X += _vBarWidth; - aP.Y = _hBarHeight / 2 + y_shift; - if (labelIdxs.contains(i)) { - ColorBreak cb = aLS.getLegendBreaks().get(i); - if (this.autoTick) { - if (aLS.getLegendType() == LegendType.UniqueValue) { - caption = cb.getCaption(); - } else { - caption = DataConvert.removeTailingZeros(cb.getEndValue().toString()); - } - } else { - caption = tLabels.get(idx); - } - - if (aLS.getLegendType() == LegendType.UniqueValue) { - sP.X = aP.X; - sP.Y = aP.Y + _hBarHeight / 2 + 5; - g.setColor(this.tickLabelColor); - if (this.tickLabelAngle == 0) { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.CENTER, YAlign.TOP, this.tickLabelAngle, true); - } else if (this.tickLabelAngle < 45) { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.RIGHT, YAlign.TOP, this.tickLabelAngle, true); - } else { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.RIGHT, YAlign.CENTER, this.tickLabelAngle, true); - } - } else { - sP.X = aP.X + _vBarWidth / 2; - sP.Y = aP.Y + _hBarHeight / 2; - PointD ssP = (PointD)sP.clone(); - if (this.autoTick) { - if (i < bNum - 1) { - g.setColor(this.tickColor); - this.drawTickLine(g, sP, tickLen, true, 0); - g.setColor(this.tickLabelColor); - if (this.tickLabelAngle == 0) { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.CENTER, YAlign.TOP, this.tickLabelAngle, true); - } else if (this.tickLabelAngle < 45) { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.RIGHT, YAlign.TOP, this.tickLabelAngle, true); - } else { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.RIGHT, YAlign.CENTER, this.tickLabelAngle, true); - } - if (this.drawMinLabel && i == 0) { - g.setColor(this.tickColor); - this.drawTickLine(g, ssP, tickLen, true, -this._vBarWidth); - caption = DataConvert.removeTailingZeros(cb.getStartValue().toString()); - g.setColor(this.tickLabelColor); - //Draw.drawString(g, ssP.X - this._vBarWidth, ssP.Y, caption, XAlign.CENTER, YAlign.TOP, this.tickLabelAngle, true); - if (this.tickLabelAngle == 0) { - Draw.drawString(g, ssP.X - this._vBarWidth, ssP.Y, caption, XAlign.CENTER, YAlign.TOP, this.tickLabelAngle, true); - } else if (this.tickLabelAngle < 45) { - Draw.drawString(g, ssP.X - this._vBarWidth, ssP.Y, caption, XAlign.RIGHT, YAlign.TOP, this.tickLabelAngle, true); - } else { - Draw.drawString(g, ssP.X - this._vBarWidth, ssP.Y, caption, XAlign.RIGHT, YAlign.CENTER, this.tickLabelAngle, true); - } - } - } else if (this.drawMaxLabel) { - g.setColor(this.tickColor); - this.drawTickLine(g, sP, tickLen, true, 0); - g.setColor(this.tickLabelColor); - if (this.tickLabelAngle == 0) { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.CENTER, YAlign.TOP, this.tickLabelAngle, true); - } else if (this.tickLabelAngle < 45) { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.RIGHT, YAlign.TOP, this.tickLabelAngle, true); - } else { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.RIGHT, YAlign.CENTER, this.tickLabelAngle, true); - } - } - } else { - if (i == 0 && this.tickLocations.get(idx) == Double.parseDouble(cb.getStartValue().toString())) { - g.setColor(this.tickColor); - this.drawTickLine(g, sP, tickLen, true, -this._vBarWidth); - g.setColor(this.tickLabelColor); - //Draw.drawString(g, sP.X - this._vBarWidth, sP.Y, caption, XAlign.CENTER, YAlign.TOP, this.tickLabelAngle, true); - if (this.tickLabelAngle == 0) { - Draw.drawString(g, sP.X - this._vBarWidth, sP.Y, caption, XAlign.CENTER, YAlign.TOP, this.tickLabelAngle, true); - } else if (this.tickLabelAngle < 45) { - Draw.drawString(g, sP.X - this._vBarWidth, sP.Y, caption, XAlign.RIGHT, YAlign.TOP, this.tickLabelAngle, true); - } else { - Draw.drawString(g, sP.X - this._vBarWidth, sP.Y, caption, XAlign.RIGHT, YAlign.CENTER, this.tickLabelAngle, true); - } - } else { - g.setColor(this.tickColor); - this.drawTickLine(g, sP, tickLen, true, 0); - g.setColor(this.tickLabelColor); - if (this.tickLabelAngle == 0) { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.CENTER, YAlign.TOP, this.tickLabelAngle, true); - } else if (this.tickLabelAngle < 45) { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.RIGHT, YAlign.TOP, this.tickLabelAngle, true); - } else { - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.RIGHT, YAlign.CENTER, this.tickLabelAngle, true); - } - } - } - } - idx += 1; - } - } - - //Draw label - double sx, sy; - if (this.label != null) { - g.setFont(this.label.getFont()); - g.setColor(this.label.getColor()); - switch (this.labelLocation) { - case "top": - case "in": - sx = this.legendWidth * 0.5; - sy = 2; - Draw.drawString(g, sx, sy, label.getText(), XAlign.CENTER, YAlign.TOP, label.isUseExternalFont()); - break; - case "right": - sx = this.legendWidth + 5; - sy = this._hBarHeight * 0.5; - Draw.drawString(g, sx, sy, label.getText(), XAlign.LEFT, YAlign.CENTER, label.isUseExternalFont()); - break; - case "left": - sx = -5; - sy = this._hBarHeight * 0.5; - Draw.drawString(g, sx, sy, label.getText(), XAlign.RIGHT, YAlign.CENTER, label.isUseExternalFont()); - break; - default: - sx = this.legendWidth * 0.5; - sy = this.height - 2; - Draw.drawString(g, sx, sy, label.getText(), XAlign.CENTER, YAlign.BOTTOM, label.isUseExternalFont()); - break; - } - } - } - - private void drawVerticalBarLegend(Graphics2D g, LegendScheme aLS) { - PointD aP = new PointD(0, 0); - PointD sP = new PointD(0, 0); - boolean DrawShape = true, DrawFill = true, DrawOutline = false; - Color FillColor = Color.red, OutlineColor = Color.black; - String caption; - - int bNum = aLS.getBreakNum(); - if (aLS.getLegendBreaks().get(bNum - 1).isNoData()) { - bNum -= 1; - } - - List labelIdxs = new ArrayList<>(); - List tLabels = new ArrayList<>(); - if (this.autoTick) { - int tickGap = this.getTickGap(g); - int sIdx = (bNum % tickGap) / 2; - int labNum = bNum - 1; - if (aLS.getLegendType() == LegendType.UniqueValue) { - labNum += 1; - } else if (this.drawMinLabel) { - sIdx = 0; - labNum = bNum; - } - while (sIdx < labNum) { - labelIdxs.add(sIdx); - sIdx += tickGap; - } - } else { - int tickIdx; - for (int i = 0; i < bNum; i++) { - ColorBreak cb = aLS.getLegendBreaks().get(i); - if (i == bNum - 1) { - if (cb.getStartValue().equals(cb.getEndValue())) - continue; - } - double v = Double.parseDouble(cb.getEndValue().toString()); - if (this.tickLocations.contains(v)) { - labelIdxs.add(i); - tickIdx = this.tickLocations.indexOf(v); - tLabels.add(this.tickLabels.get(tickIdx).getText()); - } - if (i == 0) { - v = Double.parseDouble(cb.getStartValue().toString()); - if (this.tickLocations.contains(v)) { - labelIdxs.add(i); - tickIdx = this.tickLocations.indexOf(v); - tLabels.add(this.tickLabels.get(tickIdx).getText()); - } - } - } - } - - this._vBarWidth = (double) this.legendHeight / this.aspect; - _hBarHeight = (double) this.legendHeight / bNum; - aP.Y = this.legendHeight; - float x_shift = 0; - if (this.label != null){ - switch (this.labelLocation){ - case "left": - case "in": - x_shift = this.label.getDimension(g).height + 5; - break; - } - } - int idx; - aP.X = x_shift; - for (int i = 0; i < bNum; i++) { - idx = i; - switch (aLS.getShapeType()) { - case Point: - PointBreak aPB = (PointBreak) aLS.getLegendBreaks().get(idx); - DrawShape = aPB.isDrawShape(); - DrawFill = aPB.isDrawFill(); - FillColor = aPB.getColor(); - break; - case Polyline: - PolylineBreak aPLB = (PolylineBreak) aLS.getLegendBreaks().get(idx); - DrawShape = aPLB.getDrawPolyline(); - FillColor = aPLB.getColor(); - break; - case Polygon: - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(idx); - DrawShape = aPGB.isDrawShape(); - DrawFill = aPGB.isDrawFill(); - FillColor = aPGB.getColor(); - break; - case Image: - ColorBreak aCB = aLS.getLegendBreaks().get(idx); - DrawShape = true; - DrawFill = true; - FillColor = aCB.getColor(); - break; - } - - aP.Y = aP.Y - _hBarHeight; - - if (DrawShape) { - if (this.extendRect) { - if (aLS.getShapeType() == ShapeTypes.Polygon) { - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(idx).clone(); - aPGB.setDrawOutline(false); - Draw.drawPolygonSymbol(aP.X, aP.Y, _vBarWidth, _hBarHeight, aPGB, g); - } else { - Draw.drawPolygonSymbol(aP.X, aP.Y, FillColor, OutlineColor, _vBarWidth, - _hBarHeight, DrawFill, DrawOutline, g); - } - } else if (i == 0) { - PointD[] Points = new PointD[4]; - Points[0] = new PointD(); - Points[0].X = aP.X + _vBarWidth * 0.5; - Points[0].Y = this.legendHeight; - Points[1] = new PointD(); - Points[1].X = aP.X; - Points[1].Y = aP.Y; - Points[2] = new PointD(); - Points[2].X = aP.X + _vBarWidth; - Points[2].Y = aP.Y; - Points[3] = new PointD(); - Points[3].X = aP.X + _vBarWidth * 0.5; - Points[3].Y = this.legendHeight; - if (aLS.getShapeType() == ShapeTypes.Polygon) { - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(idx).clone(); - aPGB.setDrawOutline(false); - Draw.drawPolygon(Points, aPGB, g); - } else { - Draw.drawPolygon(Points, FillColor, OutlineColor, DrawFill, DrawOutline, g); - } - } else if (i == bNum - 1) { - PointD[] Points = new PointD[4]; - Points[0] = new PointD(); - Points[0].X = aP.X; - Points[0].Y = _hBarHeight; - Points[1] = new PointD(); - Points[1].X = aP.X + _vBarWidth; - Points[1].Y = _hBarHeight; - Points[2] = new PointD(); - Points[2].X = aP.X + _vBarWidth * 0.5; - Points[2].Y = 0; - Points[3] = new PointD(); - Points[3].X = aP.X; - Points[3].Y = _hBarHeight; - if (aLS.getShapeType() == ShapeTypes.Polygon) { - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(idx).clone(); - aPGB.setDrawOutline(false); - Draw.drawPolygon(Points, aPGB, g); - } else { - Draw.drawPolygon(Points, FillColor, OutlineColor, DrawFill, DrawOutline, g); - } - } else if (aLS.getShapeType() == ShapeTypes.Polygon) { - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(idx).clone(); - aPGB.setDrawOutline(false); - Draw.drawPolygonSymbol(aP.X, aP.Y, _vBarWidth, _hBarHeight, aPGB, g); - } else { - Draw.drawPolygonSymbol(aP.X, aP.Y, FillColor, OutlineColor, _vBarWidth, - _hBarHeight, DrawFill, DrawOutline, g); - } - } - } - //Draw neatline - g.setStroke(new BasicStroke(this.neatLineSize)); - g.setColor(this.neatLineColor); - if (this.extendRect) { - g.draw(new Rectangle.Double(x_shift, 0, this._vBarWidth, this._hBarHeight * bNum)); - } else { - Path2D p = new Path2D.Double(); - p.moveTo(this._vBarWidth / 2 + x_shift, 0); - p.lineTo(x_shift, this._hBarHeight); - p.lineTo(x_shift, (this._hBarHeight * (bNum - 1))); - p.lineTo(this._vBarWidth / 2 + x_shift, this._hBarHeight * bNum); - p.lineTo(this._vBarWidth + x_shift, this._hBarHeight * (bNum - 1)); - p.lineTo(this._vBarWidth + x_shift, this._hBarHeight); - p.closePath(); - g.draw(p); - } - //Draw ticks - g.setStroke(new BasicStroke(this.tickWidth)); - aP.Y = this.legendHeight + _hBarHeight / 2; - float tickLen = this.tickLength; - if (this.insideTick) { - if (this._vBarWidth < tickLen) { - tickLen = (int) this._vBarWidth; - } - } - g.setFont(tickLabelFont); - idx = 0; - for (int i = 0; i < bNum; i++) { - aP.X = _vBarWidth / 2 + x_shift; - aP.Y = aP.Y - _hBarHeight; - if (labelIdxs.contains(i)) { - ColorBreak cb = aLS.getLegendBreaks().get(i); - if (this.autoTick) { - if (aLS.getLegendType() == LegendType.UniqueValue) { - caption = cb.getCaption(); - } else { - caption = DataConvert.removeTailingZeros(cb.getEndValue().toString()); - } - } else { - caption = tLabels.get(idx); - } - - if (aLS.getLegendType() == LegendType.UniqueValue) { - sP.X = aP.X + _vBarWidth / 2 + 5; - sP.Y = aP.Y; - g.setColor(this.tickLabelColor); - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.LEFT, YAlign.CENTER, this.tickLabelAngle, true); - } else { - sP.X = aP.X + _vBarWidth / 2; - sP.Y = aP.Y - _hBarHeight / 2; - PointD ssP = (PointD)sP.clone(); - if (this.autoTick) { - if (i < bNum - 1) { - g.setColor(this.tickColor); - this.drawTickLine(g, sP, tickLen, false, 0); - g.setColor(this.tickLabelColor); - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.LEFT, YAlign.CENTER, this.tickLabelAngle, true); - if (this.drawMinLabel && i == 0) { - g.setColor(this.tickColor); - this.drawTickLine(g, ssP, tickLen, false, this._hBarHeight); - caption = DataConvert.removeTailingZeros(cb.getStartValue().toString()); - g.setColor(this.tickLabelColor); - Draw.drawString(g, ssP.X, ssP.Y + this._hBarHeight, caption, XAlign.LEFT, YAlign.CENTER, this.tickLabelAngle, true); - } - } else if (this.drawMaxLabel) { - g.setColor(this.tickColor); - this.drawTickLine(g, sP, tickLen, false, 0); - g.setColor(this.tickLabelColor); - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.LEFT, YAlign.CENTER, this.tickLabelAngle, true); - } - } else { - if (i == 0 && this.tickLocations.get(idx) == Double.parseDouble(cb.getStartValue().toString())) { - g.setColor(this.tickColor); - this.drawTickLine(g, sP, tickLen, false, this._hBarHeight); - g.setColor(this.tickLabelColor); - Draw.drawString(g, sP.X, sP.Y + this._hBarHeight, caption, XAlign.LEFT, YAlign.CENTER, this.tickLabelAngle, true); - } else { - g.setColor(this.tickColor); - this.drawTickLine(g, sP, tickLen, false, 0); - g.setColor(this.tickLabelColor); - Draw.drawString(g, sP.X, sP.Y, caption, XAlign.LEFT, YAlign.CENTER, this.tickLabelAngle, true); - } - } - } - idx += 1; - } - } - //Draw label - double sx, sy; - if (this.label != null) { - g.setFont(this.label.getFont()); - g.setColor(this.label.getColor()); - Dimension dim = Draw.getStringDimension(this.label.getText(), g); - switch (this.labelLocation) { - case "top": - sx = 0; - sy = -5; - Draw.drawString(g, sx, sy, label.getText(), XAlign.LEFT, YAlign.BOTTOM, label.isUseExternalFont()); - break; - case "bottom": - sx = 0; - sy = this.legendHeight + 5; - Draw.drawString(g, sx, sy, label.getText(), XAlign.LEFT, YAlign.TOP, label.isUseExternalFont()); - break; - case "left": - case "in": - sx = 0; - sy = this.legendHeight * 0.5; - Draw.drawString(g, sx, sy, label.getText(), XAlign.CENTER, YAlign.TOP, 90, label.isUseExternalFont()); - break; - default: - sx = this.width - dim.height; - sy = this.legendHeight * 0.5; - Draw.drawString(g, sx, sy, label.getText(), XAlign.CENTER, YAlign.TOP, 90, label.isUseExternalFont()); - break; - } - } - } - - /** - * Get legend dimension - * - * @param g Graphics2D - * @param limitDim Limit dimension - * @return Legend dimension - */ - @Override - public Dimension getLegendDimension(Graphics2D g, Dimension limitDim) { - if (legendScheme != null) { - switch (this.orientation) { - case VERTICAL: - this.width = (int) (this.getTickWidth(g) + limitDim.height * this.shrink / this.aspect + 5); - if (!this.insideTick){ - this.width += this.tickLength; - } - this.legendWidth = this.width; - this.legendHeight = this.height; - if (this.label != null) { - g.setFont(this.label.getFont()); - Dimension dim = Draw.getStringDimension(label.getText(), g); - switch (this.labelLocation) { - case "top": - case "bottom": - //this.height += dim.height + 10; - this.width = Math.max(this.width, dim.width); - break; - default: - this.width += dim.height + 5; - break; - } - } - break; - default: - g.setFont(this.tickLabelFont); - this.height = (int) (this.getTickHeight(g) + limitDim.width * this.shrink / this.aspect + 5); - if (!this.insideTick){ - this.height += this.tickLength; - } - this.legendWidth = this.width; - this.legendHeight = this.height; - if (this.label != null) { - g.setFont(this.label.getFont()); - Dimension dim = Draw.getStringDimension(label.getText(), g); - switch (this.labelLocation) { - case "right": - case "left": - //this.width += dim.width + 10; - break; - default: - this.height += dim.height + 5; - break; - } - } - } - } - - return new Dimension(this.width, this.height); - } - // -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartLegend.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartLegend.java deleted file mode 100644 index ef6b1889..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartLegend.java +++ /dev/null @@ -1,1441 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.chart; - -import org.meteoinfo.common.PointF; -import org.meteoinfo.chart.drawing.Draw; -import org.meteoinfo.chart.legend.ColorBreak; -import org.meteoinfo.chart.legend.LegendScheme; -import org.meteoinfo.chart.legend.PointBreak; -import org.meteoinfo.chart.legend.PolygonBreak; -import org.meteoinfo.chart.legend.PolylineBreak; -import com.l2fprod.common.beans.BaseBeanInfo; -import com.l2fprod.common.beans.ExtendedPropertyDescriptor; -import com.l2fprod.common.beans.editor.ComboBoxPropertyEditor; -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.geom.AffineTransform; -import java.util.List; -import org.meteoinfo.chart.plot.PlotOrientation; -import org.meteoinfo.chart.plot.XAlign; -import org.meteoinfo.chart.plot.YAlign; -import org.meteoinfo.common.DataConvert; -import org.meteoinfo.chart.legend.LegendType; - -/** - * - * @author Yaqiang Wang - */ -public class ChartLegend { - // - - //private final XY1DPlot plot; - protected LegendScheme legendScheme; - private LegendPosition position; - protected float shrink; - protected int aspect; - private boolean colorBar; - protected float x; - protected float y; - protected PlotOrientation orientation; - protected Color background; - protected boolean drawBackground; - protected int width; - protected int height; - protected int legendWidth; - protected int legendHeight; - protected ChartText label; - protected String labelLocation; - protected Font tickLabelFont; - protected Color tickLabelColor; - protected float tickLabelAngle; - protected boolean drawNeatLine; - protected Color neatLineColor; - protected float neatLineSize; - private float breakSpace; - private float topSpace; - private float leftSpace; - protected double _vBarWidth; - protected double _hBarHeight; - private int rowColNum = 1; - private boolean autoRowColNum = true; - private Dimension symbolDimension; - protected boolean extendRect; - protected boolean autoExtendFrac; - protected float xshift; - protected float yshift; - // - // - - /** - * Constructor - * - * @param ls LegendScheme - */ - public ChartLegend(LegendScheme ls) { - //this.plot = plot; - this.legendScheme = ls; - this.colorBar = false; - this.position = LegendPosition.LOWER_CENTER_OUTSIDE; - this.orientation = PlotOrientation.HORIZONTAL; - this.shrink = 1.0f; - this.aspect = 20; - this.background = Color.white; - this.drawBackground = false; - drawNeatLine = true; - neatLineColor = Color.black; - neatLineSize = 1; - breakSpace = 3; - topSpace = 5; - leftSpace = 5; - _vBarWidth = 10; - _hBarHeight = 10; - this.labelLocation = "out"; - tickLabelFont = new Font("Arial", Font.PLAIN, 14); - this.tickLabelColor = Color.black; - this.tickLabelAngle = 0; - this.symbolDimension = new Dimension(16, 10); - this.extendRect = true; - this.autoExtendFrac = false; - this.xshift = 0; - this.yshift = 0; - } - - // - // - // - // - /** - * Get legend scheme - * - * @return Legend scheme - */ - public LegendScheme getLegendScheme() { - return this.legendScheme; - } - - /** - * Set legend scheme - * - * @param value Legend scheme - */ - public void setLegendScheme(LegendScheme value) { - this.legendScheme = value; - } - - /** - * Get if is color bar - * - * @return Boolean - */ - public boolean isColorbar() { - return this.colorBar; - } - - /** - * Set if is color bar - * - * @param value Boolean - */ - public void setColorbar(boolean value) { - this.colorBar = value; - } - - /** - * Get legend position - * - * @return Legend position - */ - public LegendPosition getPosition() { - return this.position; - } - - /** - * Set legend position - * - * @param value Legend position - */ - public void setPosition(LegendPosition value) { - this.position = value; - } - - /** - * Get shrink - * - * @return Shrink - */ - public float getShrink() { - return this.shrink; - } - - /** - * Set shrink - * - * @param value Shrink - */ - public void setShrink(float value) { - this.shrink = value; - } - - /** - * Get aspect - * - * @return Aspect - */ - public int getAspect() { - return this.aspect; - } - - /** - * Set aspect - * - * @param value Aspect - */ - public void setAspect(int value) { - this.aspect = value; - } - - /** - * Get X - * - * @return X value - */ - public float getX() { - return this.x; - } - - /** - * Set X - * - * @param value X value - */ - public void setX(float value) { - x = value; - } - - /** - * Get Y - * - * @return Y value - */ - public float getY() { - return this.y; - } - - /** - * Set Y - * - * @param value Y value - */ - public void setY(float value) { - y = value; - } - - /** - * Get width - * - * @return Width - */ - public int getWidth() { - return this.width; - } - - /** - * Set width - * - * @param value Width - */ - public void setWidth(int value) { - this.width = value; - } - - /** - * Get height - * - * @return Height - */ - public int getHeight() { - return this.height; - } - - /** - * Set height - * - * @param value Height - */ - public void setHeight(int value) { - this.height = value; - } - - /** - * Get legend width - * - * @return Legend width - */ - public int getLegendWidth() { - return this.legendWidth; - } - - /** - * Set legend width - * - * @param value Legend width - */ - public void setLegendWidth(int value) { - this.legendWidth = value; - } - - /** - * Get legend height - * - * @return Legend height - */ - public int getLegendHeight() { - return this.legendHeight; - } - - /** - * Set legend height - * - * @param value Legend height - */ - public void setLegendHeight(int value) { - this.legendHeight = value; - } - - /** - * Get plot orientation - * - * @return Plot orientation - */ - public PlotOrientation getPlotOrientation() { - return this.orientation; - } - - /** - * Set plot orientation - * - * @param value Plot orientation - */ - public void setPlotOrientation(PlotOrientation value) { - this.orientation = value; - } - - /** - * Get background - * - * @return Background - */ - public Color getBackground() { - return this.background; - } - - /** - * Set background - * - * @param value Background - */ - public void setBackground(Color value) { - this.background = value; - } - - /** - * Get if draw background - * - * @return Boolean - */ - public boolean isDrawBackground() { - return this.drawBackground; - } - - /** - * Set if draw background - * - * @param value Boolean - */ - public void setDrawBackground(boolean value) { - this.drawBackground = value; - } - - /** - * Get if draw neat line - * - * @return If draw neat line - */ - public boolean isDrawNeatLine() { - return drawNeatLine; - } - - /** - * Set if draw neat line - * - * @param istrue If draw neat line - */ - public void setDrawNeatLine(boolean istrue) { - drawNeatLine = istrue; - } - - /** - * Get neat line color - * - * @return Neat line color - */ - public Color getNeatLineColor() { - return neatLineColor; - } - - /** - * Set neat line color - * - * @param color Neat line color - */ - public void setNeatLineColor(Color color) { - neatLineColor = color; - } - - /** - * Get neat line size - * - * @return Neat line size - */ - public float getNeatLineSize() { - return neatLineSize; - } - - /** - * Set neat line size - * - * @param size Neat line size - */ - public void setNeatLineSize(float size) { - neatLineSize = size; - } - - /** - * Get break space - * @return Break space - */ - public float getBreakSpace() { - return this.breakSpace; - } - - /** - * Set break space - * @param value Break space - */ - public void setBreakSpace(float value) { - this.breakSpace = value; - } - - /** - * Get label - * - * @return Label - */ - public ChartText getLabel() { - return this.label; - } - - /** - * Set label - * - * @param value Label - */ - public void setLabel(ChartText value) { - this.label = value; - } - - /** - * Get label font - * - * @return Label font - */ - public Font getLabelFont() { - return this.label.getFont(); - } - - /** - * Set label font - * - * @param value Label font - */ - public void setLabelFont(Font value) { - this.label.setFont(value); - } - - /** - * Get label color - * - * @return Label color - */ - public Color getLabelColor() { - return this.label.getColor(); - } - - /** - * Set label color - * - * @param value Label color - */ - public void setLabelColor(Color value) { - this.label.setColor(value); - } - - /** - * Get label location (in, out, top, bottom, left, right) - * - * @return Label location - */ - public String getLabelLocation() { - return this.labelLocation; - } - - /** - * Set label location - * - * @param value Label location - */ - public void setLabelLocation(String value) { - this.labelLocation = value; - } - - /** - * Get Tick label font - * - * @return The Tick label font - */ - public Font getTickLabelFont() { - return tickLabelFont; - } - - /** - * Set Tick label font - * - * @param font The Tick label font - */ - public void setTickLabelFont(Font font) { - tickLabelFont = font; - } - - /** - * Get tick label color - * - * @return Tick label color - */ - public Color getTickLabelColor() { - return this.tickLabelColor; - } - - /** - * Set tick label color - * - * @param value Tick label color - */ - public void setTickLabelColor(Color value) { - this.tickLabelColor = value; - } - - /** - * Get tick lable angle - * - * @return Tick label angle - */ - public float getTickLabelAngle() { - return this.tickLabelAngle; - } - - /** - * Set tick label angle - * - * @param value Tick label angle - */ - public void setTickLabelAngle(float value) { - this.tickLabelAngle = value; - } - - /** - * Get column number - * - * @return Column number - */ - public int getColumnNumber() { - return rowColNum; - } - - /** - * Set column number - * - * @param value Column number - */ - public void setColumnNumber(int value) { - rowColNum = value; - } - - /** - * Get if automatic set row/col number - * - * @return Boolean - */ - public boolean isAutoRowColNum() { - return this.autoRowColNum; - } - - /** - * Set if automatic set row/col number - * - * @param value Boolean - */ - public void setAutoRowColNum(boolean value) { - this.autoRowColNum = value; - } - - /** - * Get symbol dimension - * - * @return Symbol dimension - */ - public Dimension getSymbolDimension() { - return this.symbolDimension; - } - - /** - * Set symbol dimension - * - * @param value Symbol dimension - */ - public void setSymbolDimension(Dimension value) { - this.symbolDimension = value; - } - - /** - * Set symbol width - * - * @param value Width - */ - public void setSymbolWidth(int value) { - this.symbolDimension.width = value; - } - - /** - * Set symbol height - * - * @param value height - */ - public void setSymbolHeight(int value) { - this.symbolDimension.height = value; - } - - /** - * Set symbol scale - * - * @param value Symble scale - */ - public void setSymbolScale(float value) { - double w = this.symbolDimension.getWidth() * value; - double h = this.symbolDimension.getHeight() * value; - this.symbolDimension.setSize(w, h); - } - - /** - * Get if extend rectangle - or triangle - * - * @return Boolean - */ - public boolean isExtendRect() { - return this.extendRect; - } - - /** - * Set if extend rectangle - or triangle - * - * @param value Boolean - */ - public void setExtendRect(boolean value) { - this.extendRect = value; - } - - /** - * Get if auto set extend fraction - extend has save width and height Only - * valid for colorbar - * - * @return Boolean - */ - public boolean isAutoExtendFrac() { - return this.autoExtendFrac; - } - - /** - * Set if auto set extend fraction - extend has save width and height Only - * valid for colorbar - * - * @param value - */ - public void setAutoExtendFrac(boolean value) { - this.autoExtendFrac = value; - } - - /** - * Set tick labels - * - * @param value Tick labels - */ - public void setTickCaptions(List value) { - for (int i = 0; i < this.legendScheme.getBreakNum(); i++) { - if (i < value.size()) { - this.legendScheme.getLegendBreaks().get(i).setCaption(value.get(i)); - } else { - break; - } - } - } - - /** - * Get x shift - pixel unit - * - * @return X shift - */ - public float getXShift() { - return this.xshift; - } - - /** - * Set x shift - * - * @param value X shift - */ - public void setXShift(float value) { - this.xshift = value; - } - - /** - * Get y shift - pixel unit - * - * @return Y shift - */ - public float getYShift() { - return this.yshift; - } - - /** - * Set y shift - * - * @param value Y shift - */ - public void setYShift(float value) { - this.yshift = value; - } - - // - // - /** - * Draw legend - * - * @param g Graphics2D - * @param point Start point - */ - public void draw(Graphics2D g, PointF point) { - - AffineTransform oldMatrix = g.getTransform(); - g.translate(point.X + this.xshift, point.Y + this.yshift); - - //Draw background color - if (this.drawBackground) { - g.setColor(this.background); - g.fill(new Rectangle.Float(0, 0, this.width, this.height)); - } - - //Draw legend - g.setStroke(new BasicStroke(1)); - switch (this.orientation) { - case HORIZONTAL: - drawHorizontalLegend(g, legendScheme); - break; - case VERTICAL: - this.drawVerticalLegend(g, legendScheme); - break; - } - - //Draw neatline - if (drawNeatLine) { - Rectangle.Float mapRect = new Rectangle.Float(0, 0, this.width, this.height); - g.setColor(neatLineColor); - g.setStroke(new BasicStroke(neatLineSize)); - g.draw(mapRect); - } - - g.setTransform(oldMatrix); - } - - private void drawVerticalLegend(Graphics2D g, LegendScheme aLS) { - String caption; - float breakHeight = this.getBreakHeight(g); - float symbolHeight = this.symbolDimension.height; - float symbolWidth = this.symbolDimension.width; - float colWidth = symbolWidth + getMaxLabelWidth(g) + 10; - - //Set columns - int[] rowNums = new int[rowColNum]; - int ave = aLS.getVisibleBreakNum() / rowColNum; - if (ave * rowColNum < aLS.getBreakNum()) { - ave += 1; - } - int num = 0; - int i; - for (i = 1; i < rowColNum; i++) { - rowNums[i] = ave; - num += ave; - } - rowNums[0] = aLS.getVisibleBreakNum() - num; - - //Draw title - float y0 = 0; - if (this.label != null) { - float x0 = (float) (this.width / 2.); - y0 += this.breakSpace * 2; - this.label.draw(g, x0, y0); - y0 += this.label.getDimension(g).height + this.breakSpace * 2; - } - - //Draw legend - float x, y; - i = 0; - for (int col = 0; col < rowColNum; col++) { - x = symbolWidth / 2 + leftSpace + col * colWidth; - y = y0 + breakHeight / 2 + breakSpace * 2; - for (int row = 0; row < rowNums[col]; row++) { - if (!aLS.getLegendBreaks().get(i).isDrawShape()) { - continue; - } - - //y += breakHeight + breakSpace; - ColorBreak cb = aLS.getLegendBreaks().get(i); - if (!cb.isDrawShape()) { - continue; - } - caption = aLS.getLegendBreaks().get(i).getCaption(); - if (cb instanceof PointBreak) { - PointBreak aPB = (PointBreak) cb.clone(); - ((PointBreak) aPB).setSize(((PointBreak) cb).getSize() * (symbolHeight / 10.f)); - Draw.drawPoint(new PointF(x, y), aPB, g); - } else if (cb instanceof PolylineBreak) { - PolylineBreak aPLB = (PolylineBreak) cb; - Draw.drawPolylineSymbol_S(new PointF(x, y), symbolWidth, symbolHeight, aPLB, g); - } else if (cb instanceof PolygonBreak) { - Draw.drawPolygonSymbol(new PointF(x, y), symbolWidth, symbolHeight, (PolygonBreak) cb, g); - } else { - PolygonBreak pgb = new PolygonBreak(); - pgb.setColor(cb.getColor()); - pgb.setOutlineColor(Color.black); - Draw.drawPolygonSymbol(new PointF(x, y), symbolWidth, symbolHeight, pgb, g); - } - - PointF sP = new PointF(0, 0); - sP.X = x + symbolWidth / 2; - sP.Y = y; - g.setColor(this.tickLabelColor); - g.setFont(this.tickLabelFont); - Draw.drawString(g, sP.X + 5, sP.Y, caption, XAlign.LEFT, YAlign.CENTER, true); - y += breakHeight + breakSpace; - - i += 1; - } - } - } - - private void drawHorizontalLegend(Graphics2D g, LegendScheme aLS) { - String caption; - float breakHeight = this.getBreakHeight(g); - float symbolHeight = this.symbolDimension.height; - float symbolWidth = this.symbolDimension.width; - - //Set columns - int[] colNums = new int[rowColNum]; - int ave = aLS.getVisibleBreakNum() / rowColNum; - if (ave * rowColNum < aLS.getBreakNum()) { - ave += 1; - } - int num = 0; - int i; - for (i = 0; i < rowColNum - 1; i++) { - colNums[i] = ave; - num += ave; - } - colNums[rowColNum - 1] = aLS.getVisibleBreakNum() - num; - - //Draw legend - float x, y; - y = this.breakSpace + breakHeight / 2; - i = 0; - for (int row = 0; row < rowColNum; row++) { - x = this.symbolDimension.width / 2 + 5; - for (int col = 0; col < colNums[row]; col++) { - if (i >= aLS.getBreakNum()) { - break; - } - - ColorBreak cb = aLS.getLegendBreaks().get(i); - if (!cb.isDrawShape()) { - continue; - } - caption = aLS.getLegendBreaks().get(i).getCaption(); - if (cb instanceof PointBreak) { - PointBreak aPB = (PointBreak) cb; - Draw.drawPoint(new PointF(x, y), aPB, g); - } else if (cb instanceof PolylineBreak) { - PolylineBreak aPLB = (PolylineBreak) cb; - Draw.drawPolylineSymbol_S(new PointF(x, y), symbolWidth, symbolHeight, aPLB, g); - } else if (cb instanceof PolygonBreak) { - Draw.drawPolygonSymbol(new PointF(x, y), symbolWidth, symbolHeight, (PolygonBreak) cb, g); - } - - PointF sP = new PointF(0, 0); - sP.X = x + symbolWidth / 2; - sP.Y = y; - g.setColor(this.tickLabelColor); - g.setFont(this.tickLabelFont); - Draw.drawString(g, sP.X + 5, sP.Y, caption, XAlign.LEFT, YAlign.CENTER, true); - Dimension dim = Draw.getStringDimension(caption, g); - x += this.symbolDimension.width + dim.width + 15; - i += 1; - } - y += breakHeight + this.breakSpace * 2; - } - } - - private int getMaxLabelWidth(Graphics2D g) { - String caption; - Dimension aSF; - int bNum = legendScheme.getBreakNum(); - int labWidth = 0; - g.setFont(this.tickLabelFont); - for (int i = 0; i < bNum; i++) { - caption = legendScheme.getLegendBreaks().get(i).getCaption(); - boolean isValid = true; - if (isValid) { - aSF = Draw.getStringDimension(caption, this.tickLabelAngle, g); - int labwidth = aSF.width; - if (labWidth < labwidth) { - labWidth = labwidth; - } - } - } - - return labWidth; - } - - private int getBreakHeight(Graphics2D g) { - g.setFont(tickLabelFont); - Dimension dim = Draw.getStringDimension(this.legendScheme.getLegendBreak(0).getCaption(), g); - return Math.max(dim.height, this.symbolDimension.height); - } - - /** - * Get legend dimension - * - * @param g Graphics2D - * @param limitDim Limit dimension - * @return Legend dimension - */ - public Dimension getLegendDimension(Graphics2D g, Dimension limitDim) { - if (legendScheme != null) { - if (this.colorBar) { - switch (this.orientation) { - case VERTICAL: - this.width = (int) (this.getTickWidth(g) + limitDim.height * this.shrink / this.aspect + 5); - if (this.label != null) { - g.setFont(this.label.getFont()); - this.width += (int) Draw.getStringDimension(label.getText(), g).height + 5; - } - break; - default: - g.setFont(this.tickLabelFont); - this.height = (int) (Draw.getStringDimension("test", g).height + limitDim.width * this.shrink / this.aspect + 5); - if (this.label != null) { - g.setFont(this.label.getFont()); - Dimension dim = Draw.getStringDimension(label.getText(), g); - switch (this.labelLocation) { - case "top": - case "right": - this.width += dim.width + 10; - break; - default: - this.height += (int) Draw.getStringDimension(label.getText(), g).height + 5; - break; - } - } - } - } else { - int breakHeight = getBreakHeight(g); - int titleHeight = 0; - int titleWidth = 0; - if (this.label != null) { - Dimension dim = this.label.getDimension(g); - titleHeight = dim.height + (int) (this.breakSpace * 4); - titleWidth = dim.width; - } - switch (this.orientation) { - case VERTICAL: - //Get column number - if (this.autoRowColNum) { - int tHeight = (int) (legendScheme.getBreakNum() * (breakHeight + breakSpace) - + breakSpace * 2 + breakHeight / 2 + 5); - rowColNum = 1; - if (tHeight > limitDim.height * 10 / 8) { - rowColNum = tHeight / (limitDim.height * 10 / 8) + 1; - if (rowColNum == 1) { - rowColNum = 2; - } else { - int n = legendScheme.getBreakNum() / rowColNum; - int m = legendScheme.getBreakNum() % rowColNum; - if (m != 0) { - if (m <= n) { - rowColNum += 1; - } else { - rowColNum += 2; - } - } else if (rowColNum * (limitDim.width * 8 / 10) < tHeight) { - rowColNum += 1; - } - } - } - } - - //Get width - int colWidth = this.symbolDimension.width + getMaxLabelWidth(g) + 15; - this.width = colWidth * rowColNum; - - //Get height - int[] rowNums = new int[rowColNum]; - int ave = legendScheme.getBreakNum() / rowColNum; - if (ave * rowColNum < legendScheme.getBreakNum()) { - ave += 1; - } - int num = 0; - int i; - for (i = 0; i < rowColNum - 1; i++) { - rowNums[i] = ave; - num += ave; - } - rowNums[rowColNum - 1] = legendScheme.getBreakNum() - num; - -// this.height = (int) (rowNums[0] * (breakHeight + _breakSpace) -// + _breakSpace * 2 + breakHeight / 2 + 5); - this.height = (int) (rowNums[0] * (breakHeight + breakSpace) - + breakSpace * 3); - break; - case HORIZONTAL: - //Get row number - if (this.autoRowColNum) { - int breakWidth = this.symbolDimension.width + this.getMaxLabelWidth(g) + 15; - int tWidth = breakWidth * legendScheme.getBreakNum(); - rowColNum = 1; - if (tWidth > limitDim.width * 8 / 10) { - rowColNum = tWidth / (limitDim.width * 8 / 10); - if (rowColNum == 1) { - rowColNum = 2; - } else { - int n = legendScheme.getBreakNum() / rowColNum; - int m = legendScheme.getBreakNum() % rowColNum; - if (m != 0) { - if (m <= n) { - rowColNum += 1; - } else { - rowColNum += 2; - } - } else if (rowColNum * (limitDim.width * 8 / 10) < tWidth) { - rowColNum += 1; - } - } - } - } - - //Get height - this.height = (int) (breakHeight + this.breakSpace * 2) * this.rowColNum; - - //Get width - //FontMetrics metrics = g.getFontMetrics(tickFont); - ave = legendScheme.getBreakNum() / rowColNum; - if (ave * rowColNum < legendScheme.getBreakNum()) { - ave += 1; - } - num = 0; - int maxWidth = 0; - int tempWidth = 0; - for (i = 0; i < legendScheme.getBreakNum(); i++) { - if (num < ave) { - //tempWidth += this.symbolDimension.width + 15 - // + metrics.stringWidth(legendScheme.getLegendBreaks().get(i).getCaption()); - tempWidth += this.symbolDimension.width + 15 - + Draw.getStringDimension(legendScheme.getLegendBreaks().get(i).getCaption(), g).width; - num += 1; - } else { - if (maxWidth < tempWidth) { - maxWidth = tempWidth; - } - //tempWidth = metrics.stringWidth(legendScheme.getLegendBreaks().get(i).getCaption()) + 15; - tempWidth = Draw.getStringDimension(legendScheme.getLegendBreaks().get(i).getCaption(), g).width; - num = 1; - } - } - if (maxWidth < tempWidth) { - maxWidth = tempWidth; - } - if (maxWidth > limitDim.width) { - maxWidth = limitDim.width * 8 / 10; - } - this.width = maxWidth; - break; - } - this.height += titleHeight; - this.width = Math.max(this.width, titleWidth); - } - } - - return new Dimension(this.width, this.height); - } - - protected int getTickWidth(Graphics2D g) { - float rwidth = 0; - String caption = ""; - int bNum = this.legendScheme.getBreakNum(); - //FontMetrics metrics = g.getFontMetrics(this.tickFont); - g.setFont(this.tickLabelFont); - if (this.legendScheme.getLegendBreaks().get(bNum - 1).isNoData()) { - bNum -= 1; - } - for (int i = 0; i < bNum; i++) { - switch (this.legendScheme.getShapeType()) { - case Point: - PointBreak aPB = (PointBreak) legendScheme.getLegendBreaks().get(i); - if (legendScheme.getLegendType() == LegendType.GraduatedColor) { - caption = DataConvert.removeTailingZeros(aPB.getEndValue().toString()); - } else { - caption = aPB.getCaption(); - } - break; - case Polyline: - PolylineBreak aPLB = (PolylineBreak) legendScheme.getLegendBreaks().get(i); - if (legendScheme.getLegendType() == LegendType.GraduatedColor) { - caption = DataConvert.removeTailingZeros(aPLB.getEndValue().toString()); - } else { - caption = aPLB.getCaption(); - } - break; - case Polygon: - PolygonBreak aPGB = (PolygonBreak) legendScheme.getLegendBreaks().get(i); - if (legendScheme.getLegendType() == LegendType.GraduatedColor) { - caption = DataConvert.removeTailingZeros(aPGB.getEndValue().toString()); - } else { - caption = aPGB.getCaption(); - } - break; - case Image: - ColorBreak aCB = legendScheme.getLegendBreaks().get(i); - if (legendScheme.getLegendType() == LegendType.GraduatedColor) { - caption = DataConvert.removeTailingZeros(aCB.getEndValue().toString()); - } else { - caption = aCB.getCaption(); - } - break; - } - - boolean isValid = true; - switch (legendScheme.getLegendType()) { - case GraduatedColor: - if (i == bNum - 1) { - isValid = false; - } - break; - } - if (isValid) { - //float labwidth = metrics.stringWidth(caption); - float labwidth = (float) Draw.getStringDimension(caption, this.tickLabelAngle, g).getWidth(); - if (rwidth < labwidth) { - rwidth = labwidth; - } - } - } - - return (int) rwidth; - } - - protected int getTickHeight(Graphics2D g) { - float rheight = 0; - String caption = ""; - int bNum = this.legendScheme.getBreakNum(); - //FontMetrics metrics = g.getFontMetrics(this.tickFont); - g.setFont(this.tickLabelFont); - if (this.legendScheme.getLegendBreaks().get(bNum - 1).isNoData()) { - bNum -= 1; - } - for (int i = 0; i < bNum; i++) { - switch (this.legendScheme.getShapeType()) { - case Point: - PointBreak aPB = (PointBreak) legendScheme.getLegendBreaks().get(i); - if (legendScheme.getLegendType() == LegendType.GraduatedColor) { - caption = DataConvert.removeTailingZeros(aPB.getEndValue().toString()); - } else { - caption = aPB.getCaption(); - } - break; - case Polyline: - PolylineBreak aPLB = (PolylineBreak) legendScheme.getLegendBreaks().get(i); - if (legendScheme.getLegendType() == LegendType.GraduatedColor) { - caption = DataConvert.removeTailingZeros(aPLB.getEndValue().toString()); - } else { - caption = aPLB.getCaption(); - } - break; - case Polygon: - PolygonBreak aPGB = (PolygonBreak) legendScheme.getLegendBreaks().get(i); - if (legendScheme.getLegendType() == LegendType.GraduatedColor) { - caption = DataConvert.removeTailingZeros(aPGB.getEndValue().toString()); - } else { - caption = aPGB.getCaption(); - } - break; - case Image: - ColorBreak aCB = legendScheme.getLegendBreaks().get(i); - if (legendScheme.getLegendType() == LegendType.GraduatedColor) { - caption = DataConvert.removeTailingZeros(aCB.getEndValue().toString()); - } else { - caption = aCB.getCaption(); - } - break; - } - - boolean isValid = true; - switch (legendScheme.getLegendType()) { - case GraduatedColor: - if (i == bNum - 1) { - isValid = false; - } - break; - } - if (isValid) { - float labheight = (float) Draw.getStringDimension(caption, 90 - Math.abs(this.tickLabelAngle), g).getWidth(); - if (rheight < labheight) { - rheight = labheight; - } - } - } - - return (int) rheight; - } - - /** - * Update tick gap - * - * @param g Graphics2D - * @return Ticks gap - */ - protected int getTickGap(Graphics2D g) { - if (this.tickLabelAngle != 0) { - return 1; - } - - double len; - int n = this.legendScheme.getBreakNum(); - int nn; - if (this.orientation == PlotOrientation.HORIZONTAL) { - len = this.width; - int labLen = this.getTickWidth(g); - nn = (int) ((len * 0.8) / labLen); - } else { - len = this.height; - FontMetrics metrics = g.getFontMetrics(tickLabelFont); - nn = (int) (len / metrics.getHeight()); - } - if (nn == 0) { - nn = 1; - } - return n / nn + 1; - } - - // - // - public class LayoutLegendBean { - - LayoutLegendBean() { - } - - // - /** - * Get if draw neat line - * - * @return If draw neat line - */ - public boolean isDrawNeatLine() { - return drawNeatLine; - } - - /** - * Set if draw neat line - * - * @param istrue If draw neat line - */ - public void setDrawNeatLine(boolean istrue) { - drawNeatLine = istrue; - } - - /** - * Get neat line color - * - * @return Neat line color - */ - public Color getNeatLineColor() { - return neatLineColor; - } - - /** - * Set neat line color - * - * @param color Neat line color - */ - public void setNeatLineColor(Color color) { - neatLineColor = color; - } - - /** - * Get neat line size - * - * @return Neat line size - */ - public float getNeatLineSize() { - return neatLineSize; - } - - /** - * Set neat line size - * - * @param size Neat line size - */ - public void setNeatLineSize(float size) { - neatLineSize = size; - } - - /** - * Get tick label font - * - * @return The tick label font - */ - public Font getTickLabelFont() { - return tickLabelFont; - } - - /** - * Set tick label font - * - * @param font The tick label font - */ - public void setTickLabelFont(Font font) { - tickLabelFont = font; - } - - /** - * Get column number - * - * @return Column number - */ - public int getColumnNumber() { - return rowColNum; - } - - /** - * Set column number - * - * @param value Column number - */ - public void setColumnNumber(int value) { - rowColNum = value; - } - - /** - * Get is draw background - * - * @return Boolean - */ - public boolean isDrawBackground() { - return drawBackground; - } - - /** - * Set is draw background - * - * @param value Boolean - */ - public void setDrawBackground(boolean value) { - drawBackground = value; - } - - /** - * Get background color - * - * @return Background color - */ - public Color getBackground() { - return background; - } - - /** - * Set background color - * - * @param c Background color - */ - public void setBackground(Color c) { - background = c; - } - - // - } - - public static class LayoutLegendBeanBeanInfo extends BaseBeanInfo { - - public LayoutLegendBeanBeanInfo() { - super(LayoutLegendBean.class); - ExtendedPropertyDescriptor e = addProperty("plotOrientation"); - e.setCategory("General").setDisplayName("Plot orientation"); - e.setPropertyEditorClass(PlotOrientationEditor.class); - addProperty("tickFont").setCategory("General").setDisplayName("Tick Font"); - addProperty("drawBackground").setCategory("General").setDisplayName("Draw Background"); - addProperty("background").setCategory("General").setDisplayName("Background"); - addProperty("columnNumber").setCategory("General").setDisplayName("Column Number"); - addProperty("drawNeatLine").setCategory("Neat Line").setDisplayName("Draw Neat Line"); - addProperty("neatLineColor").setCategory("Neat Line").setDisplayName("Neat Line Color"); - addProperty("neatLineSize").setCategory("Neat Line").setDisplayName("Neat Line Size"); - } - } - - public static class PlotOrientationEditor extends ComboBoxPropertyEditor { - - public PlotOrientationEditor() { - super(); - PlotOrientation[] orientations = PlotOrientation.values(); - String[] types = new String[orientations.length]; - int i = 0; - for (PlotOrientation type : orientations) { - types[i] = type.toString(); - i += 1; - } - setAvailableValues(types); - } - } - - // -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartNorthArrow.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartNorthArrow.java deleted file mode 100644 index 13dcd4e5..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartNorthArrow.java +++ /dev/null @@ -1,297 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.chart; - -import org.meteoinfo.common.PointF; -import org.meteoinfo.chart.drawing.Draw; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; -import org.meteoinfo.chart.plot.MapPlot; - -/** - * - * @author Yaqiang Wang - */ -public class ChartNorthArrow extends ChartElement { -// - - private MapPlot mapPlot; - private boolean _antiAlias; - private float lineWidth; - private boolean _drawNeatLine; - private Color _neatLineColor; - private float _neatLineSize; - private NorthArrowType _northArrowType; - private float _angle; - // - // - - /** - * Constructor - * - * @param mapPlot The map plot - */ - public ChartNorthArrow(MapPlot mapPlot) { - super(); - - this.setWidth(50); - this.setHeight(50); - - this.mapPlot = mapPlot; - this.lineWidth = 1; - _antiAlias = true; - _drawNeatLine = false; - _neatLineColor = Color.black; - _neatLineSize = 1; - _northArrowType = NorthArrowType.NORTHARROW_1; - _angle = 0; - } - // - // - - /** - * Get map plot - * - * @return The map plot - */ - public MapPlot getMapPlot() { - return this.mapPlot; - } - - /** - * Get line widht - * @return Line width - */ - public float getLineWidth() { - return this.lineWidth; - } - - /** - * Set line width - * @param value Line width - */ - public void setLineWidth(float value) { - this.lineWidth = value; - } - - /** - * Get if draw neat line - * - * @return If draw neat line - */ - public boolean isDrawNeatLine() { - return _drawNeatLine; - } - - /** - * Set if draw neat line - * - * @param istrue If draw neat line - */ - public void setDrawNeatLine(boolean istrue) { - _drawNeatLine = istrue; - } - - /** - * Get neat line color - * - * @return Neat line color - */ - public Color getNeatLineColor() { - return _neatLineColor; - } - - /** - * Set neat line color - * - * @param color Neat line color - */ - public void setNeatLineColor(Color color) { - _neatLineColor = color; - } - - /** - * Get neat line size - * - * @return Neat line size - */ - public float getNeatLineSize() { - return _neatLineSize; - } - - /** - * Set neat line size - * - * @param size Neat line size - */ - public void setNeatLineSize(float size) { - _neatLineSize = size; - } - - /** - * Get angle - * - * @return Angle - */ - public float getAngle() { - return _angle; - } - - /** - * Set angle - * - * @param angle The angle - */ - public void setAngle(float angle) { - _angle = angle; - } - - // - // - /** - * Draw text - * - * @param g Graphics2D - * @param x X - * @param y Y - */ - public void draw(Graphics2D g, float x, float y) { - AffineTransform oldMatrix = g.getTransform(); - g.translate(x, y); - if (_angle != 0) { - g.rotate(_angle); - } - if (_antiAlias) { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - } else { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - } - - //Draw background color - if (this.isDrawBackColor()){ - g.setColor(this.getBackground()); - g.fill(new Rectangle.Float(0, 0, this.getWidth(), this.getHeight())); - } - - drawNorthArrow(g); - - //Draw neatline - if (_drawNeatLine) { - Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1, - (this.getWidth() - _neatLineSize), (this.getHeight() - _neatLineSize)); - g.setColor(_neatLineColor); - g.setStroke(new BasicStroke(_neatLineSize)); - g.draw(mapRect); - } - - g.setTransform(oldMatrix); - } - - /** - * Paint graphics - * - * @param g Graphics - * @param pageLocation Page location - * @param zoom Zoom - */ - public void paintGraphics(Graphics2D g, PointF pageLocation, float zoom) { - AffineTransform oldMatrix = g.getTransform(); - PointF aP = pageToScreen(this.getX(), this.getY(), pageLocation, zoom); - g.translate(aP.X, aP.Y); - g.scale(zoom, zoom); - if (_angle != 0) { - g.rotate(_angle); - } - if (_antiAlias) { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - } else { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - } - - //Draw background color - if (this.isDrawBackColor()){ - g.setColor(this.getBackground()); - g.fill(new Rectangle.Float(0, 0, this.getWidth() * zoom, this.getHeight() * zoom)); - } - - drawNorthArrow(g); - - //Draw neatline - if (_drawNeatLine) { - Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1, - (this.getWidth() - _neatLineSize) * zoom, (this.getHeight() - _neatLineSize) * zoom); - g.setColor(_neatLineColor); - g.setStroke(new BasicStroke(_neatLineSize)); - g.draw(mapRect); - } - - g.setTransform(oldMatrix); - } - - private void drawNorthArrow(Graphics2D g) { - switch (_northArrowType) { - case NORTHARROW_1: - drawNorthArrow1(g); - break; - } - } - - private void drawNorthArrow1(Graphics2D g) { - g.setColor(this.getForeground()); - g.setStroke(new BasicStroke(this.lineWidth)); - - //Draw N symbol - PointF[] points = new PointF[4]; - float x = this.getWidth() / 2; - float y = this.getHeight() / 6; - float w = this.getWidth() / 6; - float h = this.getHeight() / 4; - points[0] = 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[3] = new PointF(x + w / 2, y - h / 2); - Draw.drawPolyline(points, g); - - //Draw arrow - w = this.getWidth() / 2; - h = this.getHeight() * 2 / 3; - points = new PointF[3]; - points[0] = new PointF(x - w / 2, this.getHeight()); - points[1] = new PointF(x, this.getHeight() - h / 2); - points[2] = new PointF(x, this.getHeight() - h); - Draw.fillPolygon(points, g, null); - Draw.drawPolyline(points, g); - - points = new PointF[4]; - points[0] = new PointF(x + w / 2, this.getHeight()); - points[1] = new PointF(x, this.getHeight() - h / 2); - points[2] = new PointF(x, this.getHeight() - h); - points[3] = points[0]; - Draw.drawPolyline(points, g); - } - - @Override - public void moveUpdate() { - } - - @Override - public void resizeUpdate() { - } - // -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartPanel.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartPanel.java deleted file mode 100644 index 260674b3..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartPanel.java +++ /dev/null @@ -1,1689 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -import com.itextpdf.awt.PdfGraphics2D; -import com.itextpdf.text.Document; -import com.itextpdf.text.DocumentException; -import com.itextpdf.text.pdf.PdfContentByte; -import com.itextpdf.text.pdf.PdfTemplate; -import com.itextpdf.text.pdf.PdfWriter; - -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseMotionAdapter; -import java.awt.event.MouseWheelEvent; -import java.awt.event.MouseWheelListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.geom.AffineTransform; -import java.awt.geom.Rectangle2D; -import java.awt.image.AffineTransformOp; -import java.awt.image.BufferedImage; -import java.awt.print.PageFormat; -import java.awt.print.Printable; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.time.Duration; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.imageio.IIOImage; -import javax.imageio.ImageIO; -import javax.imageio.ImageTypeSpecifier; -import javax.imageio.ImageWriteParam; -import javax.imageio.ImageWriter; -import javax.imageio.metadata.IIOInvalidTreeException; -import javax.imageio.metadata.IIOMetadata; -import javax.imageio.plugins.jpeg.JPEGImageWriteParam; -import javax.imageio.stream.FileImageOutputStream; -import javax.imageio.stream.ImageOutputStream; -import javax.print.DocFlavor; -import javax.print.DocPrintJob; -import javax.print.PrintException; -import javax.print.PrintService; -import javax.print.SimpleDoc; -import javax.print.StreamPrintServiceFactory; -import javax.print.attribute.HashPrintRequestAttributeSet; -import javax.print.attribute.PrintRequestAttributeSet; -import javax.swing.JFileChooser; -import javax.swing.JFrame; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.SwingUtilities; -import javax.swing.Timer; -import javax.swing.event.EventListenerList; -import javax.swing.table.DefaultTableModel; -import org.freehep.graphics2d.VectorGraphics; -import org.freehep.graphicsio.emf.EMFGraphics2D; -import org.freehep.graphicsio.pdf.PDFGraphics2D; -import org.freehep.graphicsio.ps.PSGraphics2D; -import org.meteoinfo.chart.plot.MapPlot; -import org.meteoinfo.chart.plot.Plot; -import org.meteoinfo.chart.plot.XY1DPlot; -import org.meteoinfo.chart.plot.AbstractPlot2D; -import org.meteoinfo.chart.plot.Plot3D; -import org.meteoinfo.chart.plot.PlotType; -import org.meteoinfo.chart.plot3d.Projector; -import org.meteoinfo.common.Extent; -import org.meteoinfo.common.GenericFileFilter; -import org.meteoinfo.common.PointF; -import org.meteoinfo.ndarray.DataType; -import org.meteoinfo.table.Field; -import org.meteoinfo.image.ImageUtil; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layer.RasterLayer; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.map.FrmIdentifer; -import org.meteoinfo.map.FrmIdentiferGrid; -import org.meteoinfo.map.MapView; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * - * @author yaqiang - */ -public class ChartPanel extends JPanel implements IChartPanel{ - - // - private final EventListenerList listeners = new EventListenerList(); - private BufferedImage mapBitmap = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB); - private BufferedImage tempImage = null; - private boolean newPaint = false; - private boolean doubleBuffer = true; - private Chart chart; - private Plot currentPlot; - private Dimension chartSize; - private Point mouseDownPoint = new Point(0, 0); - private Point mouseLastPos = new Point(0, 0); - private boolean dragMode = false; - private JPopupMenu popupMenu; - private MouseMode mouseMode; - private List selectedPoints; - private int xShift = 0; - private int yShift = 0; - private double paintScale = 1.0; - private LocalDateTime lastMouseWheelTime; - private Timer mouseWheelDetctionTimer; - // - - // - /** - * Constructor - */ - public ChartPanel() { - super(); - //this.setBackground(Color.white); - this.setBackground(Color.lightGray); - this.setSize(200, 200); - this.addComponentListener(new ComponentAdapter() { - @Override - public void componentResized(ComponentEvent e) { - onComponentResized(e); - } - }); - this.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - onMouseClicked(e); - } - - @Override - public void mousePressed(MouseEvent e) { - onMousePressed(e); - } - - @Override - public void mouseReleased(MouseEvent e) { - onMouseReleased(e); - } - }); - this.addMouseMotionListener(new MouseMotionAdapter() { - @Override - public void mouseMoved(MouseEvent e) { - onMouseMoved(e); - } - - @Override - public void mouseDragged(MouseEvent e) { - onMouseDragged(e); - } - }); - this.addMouseWheelListener(new MouseWheelListener() { - @Override - public void mouseWheelMoved(MouseWheelEvent e) { - onMouseWheelMoved(e); - } - }); - - this.mouseWheelDetctionTimer = new Timer(100, new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - LocalDateTime now = LocalDateTime.now(); - if (Duration.between(lastMouseWheelTime, now).toMillis() > 200) { - xShift = 0; - yShift = 0; - paintScale = 1.0; - //paintGraphics(); - repaintNew(); - mouseWheelDetctionTimer.stop(); - } - } - }); - - popupMenu = new JPopupMenu(); - JMenuItem undoZoom = new JMenuItem("Undo zoom"); - undoZoom.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - onUndoZoomClick(); - } - }); - popupMenu.add(undoZoom); - popupMenu.addSeparator(); - - JMenuItem saveFigure = new JMenuItem("Save figure"); - saveFigure.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - onSaveFigureClick(e); - } - }); - popupMenu.add(saveFigure); - - this.chart = null; - this.mouseMode = MouseMode.DEFAULT; - //this.setMouseMode(mouseMode.ZOOM_IN); - } - - /** - * Constructor - * - * @param chart Chart - */ - public ChartPanel(Chart chart) { - this(); - this.chart = chart; - if (this.chart != null) { - this.chart.setParent(this); - } - } - - /** - * Constructor - * - * @param chart Chart - * @param width Chart width - * @param height Chart height - */ - public ChartPanel(Chart chart, int width, int height) { - this(chart); - this.chartSize = new Dimension(width, height); - this.setPreferredSize(chartSize); - } - - // - // - /** - * Get chart - * - * @return Chart - */ - public Chart getChart() { - return chart; - } - - /** - * Set chart - * - * @param value - */ - public void setChart(Chart value) { - chart = value; - if (this.chart != null) { - chart.setParent(this); - } - } - - /** - * Get if using off screen image double buffering. - * Using double buffering will be faster but lower view quality in - * high dpi screen computer. - * - * @return Boolean - */ - public boolean isDoubleBuffer() { - return this.doubleBuffer; - } - - /** - * Set using off screen image double buffering or not. - * @param value Boolean - */ - public void setDoubleBuffer(boolean value) { - this.doubleBuffer = value; - } - - /** - * Get popup menu - * - * @return Popup menu - */ - public JPopupMenu getPopupMenu() { - return this.popupMenu; - } - - /** - * Get mouse mode - * - * @return Mouse mode - */ - public MouseMode getMouseMode() { - return this.mouseMode; - } - - /** - * Set mouse mode - * - * @param value Mouse mode - */ - @Override - public void setMouseMode(MouseMode value) { - this.mouseMode = value; - Image image; - Toolkit toolkit = Toolkit.getDefaultToolkit(); - Cursor customCursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); - switch (this.mouseMode) { - case SELECT: - customCursor = Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR); - break; - case ZOOM_IN: - image = toolkit.getImage(this.getClass().getResource("/images/zoom_in_32x32x32.png")); - customCursor = toolkit.createCustomCursor(image, new Point(8, 8), "Zoom In"); - break; - case ZOOM_OUT: - image = toolkit.getImage(this.getClass().getResource("/images/zoom_out_32x32x32.png")); - customCursor = toolkit.createCustomCursor(image, new Point(8, 8), "Zoom In"); - break; - case PAN: - image = toolkit.getImage(this.getClass().getResource("/images/Pan_Open_32x32x32.png")); - customCursor = toolkit.createCustomCursor(image, new Point(8, 8), "Pan"); - break; - case IDENTIFER: - image = toolkit.getImage(this.getClass().getResource("/images/identifer_32x32x32.png")); - customCursor = toolkit.createCustomCursor(image, new Point(8, 8), "Identifer"); - break; - case ROTATE: - image = toolkit.getImage(this.getClass().getResource("/images/rotate.png")); - customCursor = toolkit.createCustomCursor(image, new Point(8, 8), "Identifer"); - break; - } - this.setCursor(customCursor); - } - - /** - * Get selected chart points - * - * @return Selected chart points - */ - public List getSelectedPoints() { - return this.selectedPoints; - } - // - - // - public void addPointSelectedListener(IPointSelectedListener listener) { - this.listeners.add(IPointSelectedListener.class, listener); - } - - public void removePointSelectedListener(IPointSelectedListener listener) { - this.listeners.remove(IPointSelectedListener.class, listener); - } - - public void firePointSelectedEvent() { - firePointSelectedEvent(new PointSelectedEvent(this)); - } - - private void firePointSelectedEvent(PointSelectedEvent event) { - Object[] listeners = this.listeners.getListenerList(); - for (int i = 0; i < listeners.length; i = i + 2) { - if (listeners[i] == IPointSelectedListener.class) { - ((IPointSelectedListener) listeners[i + 1]).pointSelectedEvent(event); - } - } - } - // - - // - /** - * Get figure width - * - * @return Figure width - */ - public int getFigureWidth() { - int width; - if (this.chartSize != null) { - width = this.chartSize.width; - } else { - width = this.getWidth(); - } - - return width; - } - - /** - * Get Figure height - * - * @return Figure height - */ - public int getFigureHeight() { - int height; - if (this.chartSize != null) { - height = this.chartSize.height; - } else { - height = this.getHeight(); - } - - return height; - } - - /** - * Select a plot by point - * - * @param x X - * @param y Y - * @return Selected plot - */ - public Plot selPlot(int x, int y) { - if (this.chart == null) { - return null; - } - - int n = this.chart.getPlots().size(); - for (int i = n - 1; i >= 0; i--) { - Plot plot = this.chart.getPlots().get(i); - Rectangle2D rect = plot.getGraphArea(); - if (rect.contains(x, y)) { - return plot; - } - } - return null; - } - - /** - * Paint component - * - * @param g Graphics - */ - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - - if (this.getWidth() < 5 || this.getHeight() < 5) { - return; - } - - //this.setBackground(Color.white); - Graphics2D g2 = (Graphics2D) g; - - if (this.newPaint) { - this.paintGraphics(g2); - } else { - AffineTransform mx = new AffineTransform(); - AffineTransformOp aop = new AffineTransformOp(mx, AffineTransformOp.TYPE_BICUBIC); - g2.drawImage(mapBitmap, aop, 0, 0); - } - - //Draw dynamic graphics - if (this.dragMode) { - switch (this.mouseMode) { - case ZOOM_IN: - case SELECT: - int aWidth = Math.abs(mouseLastPos.x - mouseDownPoint.x); - int aHeight = Math.abs(mouseLastPos.y - mouseDownPoint.y); - int aX = Math.min(mouseLastPos.x, mouseDownPoint.x); - int aY = Math.min(mouseLastPos.y, mouseDownPoint.y); - g2.setColor(this.getForeground()); - float dash1[] = {2.0f}; - g2.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f)); - g2.draw(new Rectangle(aX, aY, aWidth, aHeight)); - break; - } - } - - //Draw identifer shape - if (this.currentPlot != null) { - if (this.currentPlot instanceof MapPlot) { - MapPlot plot = (MapPlot) this.currentPlot; - if (plot.getMapView().isDrawIdentiferShape()) { - if (plot.getSelectedLayer() != null) { - if (plot.getSelectedLayer().getLayerType() == LayerTypes.VectorLayer) { - VectorLayer layer = (VectorLayer) plot.getSelectedLayer(); - Rectangle2D rect = plot.getGraphArea(); - Rectangle rr = new Rectangle((int) rect.getX(), (int) rect.getY(), - (int) rect.getWidth(), (int) rect.getHeight()); - plot.getMapView().drawIdShape(g2, layer.getShapes().get(layer.getIdentiferShape()), rr); - } - } - } - } - } - - g2.dispose(); - } - - /** - * New paint - */ - public void repaintNew() { - if (this.doubleBuffer) { - this.paintGraphics(); - } else { - this.newPaint = true; - this.repaint(); - this.updateViewImage(); - } - } - - private void repaintOld() { - if (this.doubleBuffer) { - this.repaint(); - } else { - this.newPaint = false; - this.repaint(); - } - } - - private void updateViewImage() { - if (this.getWidth() < 5 || this.getHeight() < 5) { - return; - } - - int width, height; - if (this.chartSize != null) { - height = this.chartSize.height; - width = this.chartSize.width; - } else { - width = this.getWidth(); - height = this.getHeight(); - } - - this.mapBitmap = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - Graphics2D g = this.mapBitmap.createGraphics(); - this.print(g); - g.dispose(); - } - - /** - * Paint graphics - */ - @Override - public void paintGraphics() { - if (this.getWidth() < 5 || this.getHeight() < 5) { - return; - } - - int width, height; - if (this.chartSize != null) { - height = this.chartSize.height; - width = this.chartSize.width; - } else { - width = this.getWidth(); - height = this.getHeight(); - } - - this.mapBitmap = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - - if (this.chart != null) { - Graphics2D g = this.mapBitmap.createGraphics(); - Rectangle2D chartArea; - if (this.chartSize == null) { - chartArea = new Rectangle2D.Double(0.0, 0.0, this.mapBitmap.getWidth(), this.mapBitmap.getHeight()); - } else { - chartArea = new Rectangle2D.Double(0.0, 0.0, this.chartSize.width, this.chartSize.height); - } - this.chart.draw(g, chartArea); - } - this.repaint(); - } - - public void paintGraphics(Graphics2D g) { - if (this.chart != null) { - Rectangle2D chartArea; - if (this.chartSize == null) { - chartArea = new Rectangle2D.Double(0.0, 0.0, this.getWidth(), this.getHeight()); - } else { - chartArea = new Rectangle2D.Double(0.0, 0.0, this.chartSize.width, this.chartSize.height); - } - this.chart.draw(g, chartArea); - } - } - - public void paintGraphics(Graphics2D g, int width, int height) { - if (this.chart != null) { - Rectangle2D chartArea; - chartArea = new Rectangle2D.Double(0.0, 0.0, width, height); - this.chart.draw(g, chartArea); - } - } - - void onComponentResized(ComponentEvent e) { - if (this.getWidth() > 0 && this.getHeight() > 0) { - if (this.chart != null) { - //this.paintGraphics(); - this.repaintNew(); - } - } - } - - void onMousePressed(MouseEvent e) { - mouseDownPoint.x = e.getX(); - mouseDownPoint.y = e.getY(); - mouseLastPos = (Point) mouseDownPoint.clone(); - switch (this.mouseMode) { - case PAN: - Plot plot = selPlot(e.getX(), e.getY()); - if (plot != null) { - Rectangle2D mapRect = plot.getGraphArea(); - tempImage = new BufferedImage((int) mapRect.getWidth() - 2, - (int) mapRect.getHeight() - 2, BufferedImage.TYPE_INT_ARGB); - Graphics2D tg = tempImage.createGraphics(); - tg.setColor(Color.white); - tg.fill(mapRect); - tg.drawImage(this.mapBitmap, -(int) mapRect.getX() - 1, -(int) mapRect.getY() - 1, this); - tg.dispose(); - } - break; - } - } - - void onMouseMoved(MouseEvent e) { - this.dragMode = false; -// switch (this.mouseMode) { -// case PAN: -// Plot plot = selPlot(e.getX(), e.getY()); -// if (plot != null) { -// Rectangle2D mapRect = plot.getGraphArea(); -// tempImage = new BufferedImage((int) mapRect.getWidth() - 2, -// (int) mapRect.getHeight() - 2, BufferedImage.TYPE_INT_ARGB); -// Graphics2D tg = tempImage.createGraphics(); -// tg.setColor(Color.white); -// tg.fill(mapRect); -// tg.drawImage(this.mapBitmap, -(int) mapRect.getX() - 1, -(int) mapRect.getY() - 1, this); -// tg.dispose(); -// } -// break; -// } - } - - void onMouseReleased(MouseEvent e) { - this.dragMode = false; - Plot plt = this.chart.findPlot(mouseDownPoint.x, mouseDownPoint.y); - if (!(plt instanceof AbstractPlot2D)) { - return; - } - - AbstractPlot2D xyplot = (AbstractPlot2D) plt; - this.currentPlot = xyplot; - switch (this.mouseMode) { - case ZOOM_IN: - if (Math.abs(mouseLastPos.x - mouseDownPoint.x) > 5) { - if (xyplot instanceof MapPlot) { - MapPlot plot = (MapPlot) xyplot; - Rectangle2D graphArea = xyplot.getGraphArea(); - double[] xy1 = plot.screenToProj(mouseDownPoint.x - graphArea.getX(), mouseDownPoint.y - graphArea.getY(), graphArea); - double[] xy2 = plot.screenToProj(mouseLastPos.x - graphArea.getX(), mouseLastPos.y - graphArea.getY(), graphArea); - Extent extent = new Extent(); - extent.minX = Math.min(xy1[0], xy2[0]); - extent.maxX = Math.max(xy1[0], xy2[0]); - extent.minY = Math.min(xy1[1], xy2[1]); - extent.maxY = Math.max(xy1[1], xy2[1]); - plot.setDrawExtent(extent); - //this.paintGraphics(); - this.repaintNew(); - } else { - Rectangle2D graphArea = xyplot.getGraphArea(); - double[] xy1 = xyplot.screenToProj(mouseDownPoint.x - graphArea.getX(), mouseDownPoint.y - graphArea.getY(), graphArea); - double[] xy2 = xyplot.screenToProj(mouseLastPos.x - graphArea.getX(), mouseLastPos.y - graphArea.getY(), graphArea); - Extent extent = new Extent(); - extent.minX = Math.min(xy1[0], xy2[0]); - extent.maxX = Math.max(xy1[0], xy2[0]); - extent.minY = Math.min(xy1[1], xy2[1]); - extent.maxY = Math.max(xy1[1], xy2[1]); - if (xyplot.getXAxis().isInverse()) { - Extent drawExtent = xyplot.getDrawExtent(); - double minx, maxx; - minx = drawExtent.getWidth() - (extent.maxX - drawExtent.minX) + drawExtent.minX; - maxx = drawExtent.getWidth() - (extent.minX - drawExtent.minX) + drawExtent.minX; - extent.minX = minx; - extent.maxX = maxx; - } - if (xyplot.getYAxis().isInverse()) { - Extent drawExtent = xyplot.getDrawExtent(); - double miny, maxy; - miny = drawExtent.getHeight() - (extent.maxY - drawExtent.minY) + drawExtent.minY; - maxy = drawExtent.getHeight() - (extent.minY - drawExtent.minY) + drawExtent.minY; - extent.minY = miny; - extent.maxY = maxy; - } - xyplot.setDrawExtent(extent); - //this.paintGraphics(); - this.repaintNew(); - } - } - break; - case ZOOM_OUT: - if (e.getButton() == MouseEvent.BUTTON1) { - double zoom = 1.5; - Extent extent = xyplot.getDrawExtent(); - double owidth = extent.getWidth(); - double oheight = extent.getHeight(); - double width = owidth * zoom; - double height = oheight * zoom; - double xshift = (owidth - width) * 0.5; - double yshift = (oheight - height) * 0.5; - extent.minX += xshift; - extent.maxX -= xshift; - extent.minY += yshift; - extent.maxY -= yshift; - xyplot.setDrawExtent(extent); - //this.paintGraphics(); - this.repaintNew(); - } - break; - case SELECT: - if (Math.abs(mouseLastPos.x - mouseDownPoint.x) > 5) { - if (xyplot instanceof XY1DPlot) { - XY1DPlot plot = (XY1DPlot) xyplot; - Rectangle2D graphArea = plot.getGraphArea(); - if (graphArea.contains(mouseDownPoint.x, mouseDownPoint.y) || graphArea.contains(mouseLastPos.x, mouseLastPos.y)) { - double[] xy1 = plot.screenToProj(mouseDownPoint.x - graphArea.getX(), mouseDownPoint.y - graphArea.getY(), graphArea); - double[] xy2 = plot.screenToProj(mouseLastPos.x - graphArea.getX(), mouseLastPos.y - graphArea.getY(), graphArea); - Extent extent = new Extent(); - extent.minX = Math.min(xy1[0], xy2[0]); - extent.maxX = Math.max(xy1[0], xy2[0]); - extent.minY = Math.min(xy1[1], xy2[1]); - extent.maxY = Math.max(xy1[1], xy2[1]); - this.selectedPoints = plot.getDataset().selectPoints(extent); - this.firePointSelectedEvent(); - //this.paintGraphics(); - this.repaintNew(); - } - } - } - break; - case PAN: - if (e.getButton() == MouseEvent.BUTTON1) { - int deltaX = e.getX() - mouseDownPoint.x; - int deltaY = e.getY() - mouseDownPoint.y; - double minX = -deltaX; - double minY = -deltaY; - double maxX = xyplot.getGraphArea().getWidth() - deltaX; - double maxY = xyplot.getGraphArea().getHeight() - deltaY; - xyplot.zoomToExtentScreen(minX, maxX, minY, maxY); - //this.paintGraphics(); - this.repaintNew(); - } - break; - } - } - - void onMouseDragged(MouseEvent e) { - this.dragMode = true; - int x = e.getX(); - int y = e.getY(); - switch (this.mouseMode) { - case ZOOM_IN: - case SELECT: - this.repaintOld(); - break; - case PAN: - Plot plot = selPlot(e.getX(), e.getY()); - if (plot != null) { - Graphics2D g = (Graphics2D) this.getGraphics(); - Rectangle2D mapRect = plot.getGraphArea(); - g.setClip(mapRect); - g.setColor(Color.white); - int aX = e.getX() - mouseDownPoint.x; - int aY = e.getY() - mouseDownPoint.y; - if (aX > 0) { - if (mapRect.getX() >= 0) { - g.fillRect((int) mapRect.getX(), (int) mapRect.getY(), aX, (int) mapRect.getHeight()); - } else { - g.fillRect(0, (int) mapRect.getY(), aX, (int) mapRect.getHeight()); - } - } else if (mapRect.getX() <= this.getWidth()) { - g.fillRect((int) (mapRect.getX() + mapRect.getWidth() + aX), (int) mapRect.getY(), Math.abs(aX), (int) mapRect.getHeight()); - } else { - g.fillRect(this.getWidth() + aX, (int) mapRect.getY(), Math.abs(aX), (int) mapRect.getHeight()); - } - if (aY > 0) { - if (mapRect.getY() >= 0) { - g.fillRect((int) mapRect.getX(), (int) mapRect.getY(), (int) mapRect.getWidth(), aY); - } else { - g.fillRect((int) mapRect.getX(), 0, (int) mapRect.getWidth(), aY); - } - } else if (mapRect.getY() + mapRect.getHeight() <= this.getX() + this.getHeight()) { - g.fillRect((int) mapRect.getX(), (int) mapRect.getY() + (int) mapRect.getHeight() + aY, (int) mapRect.getWidth(), Math.abs(aY)); - } else { - g.fillRect((int) mapRect.getX(), this.getY() + this.getHeight() + aY, (int) mapRect.getWidth(), Math.abs(aY)); - } - int startX = (int) mapRect.getX() + aX; - int startY = (int) mapRect.getY() + aY; - g.drawImage(tempImage, startX, startY, this); - g.setColor(this.getForeground()); - g.draw(mapRect); - } - break; - case ROTATE: - plot = selPlot(this.mouseDownPoint.x, this.mouseDownPoint.y); - if (plot != null && plot.getPlotType() == PlotType.XYZ) { - Plot3D plot3d = (Plot3D) plot; - Projector projector = plot3d.getProjector(); - float new_value = 0.0f; - // if (!thread.isAlive() || !data_available) { - if (e.isControlDown()) { - projector.set2D_xTranslation(projector.get2D_xTranslation() + (x - this.mouseLastPos.x)); - projector.set2D_yTranslation(projector.get2D_yTranslation() + (y - this.mouseLastPos.y)); - } else if (e.isShiftDown()) { - new_value = projector.getY2DScaling() + (y - this.mouseLastPos.y) * 0.5f; - if (new_value > 60.0f) { - new_value = 60.0f; - } - if (new_value < 2.0f) { - new_value = 2.0f; - } - projector.set2DScaling(new_value); - } else { - new_value = projector.getRotationAngle() + (x - this.mouseLastPos.x); - while (new_value > 360) { - new_value -= 360; - } - while (new_value < 0) { - new_value += 360; - } - projector.setRotationAngle(new_value); - new_value = projector.getElevationAngle() + (y - this.mouseLastPos.y); - if (new_value > 90) { - new_value = 90; - } else if (new_value < 0) { - new_value = 0; - } - projector.setElevationAngle(new_value); - } - this.repaintNew(); - //this.paintGraphics(); -// if (!model.isExpectDelay()) { -// repaint(); -// } else { -// if (!dragged) { -// is_data_available = data_available; -// dragged = true; -// } -// data_available = false; -// repaint(); -// } - } - break; - } - mouseLastPos.x = x; - mouseLastPos.y = y; - } - - void onMouseClicked(MouseEvent e) { - int clickTimes = e.getClickCount(); - if (clickTimes == 1) { - if (e.getButton() == MouseEvent.BUTTON1) { - switch (this.mouseMode) { - case IDENTIFER: - Plot plot = selPlot(e.getX(), e.getY()); - if (plot == null) { - return; - } - - if (!(plot instanceof MapPlot)) { - return; - } - - this.currentPlot = plot; - MapPlot mplot = (MapPlot) plot; - final MapView mapView = mplot.getMapView(); - MapLayer aMLayer = mplot.getSelectedLayer(); - if (aMLayer == null) { - return; - } - if (aMLayer.getLayerType() == LayerTypes.ImageLayer) { - return; - } - - Rectangle2D rect = mplot.getGraphArea(); - PointF aPoint = new PointF(e.getX() - (float) rect.getX(), e.getY() - (float) rect.getY()); - if (aMLayer.getLayerType() == LayerTypes.VectorLayer) { - VectorLayer aLayer = (VectorLayer) aMLayer; - List selectedShapes = mapView.selectShapes(aLayer, aPoint, true, false); - if (selectedShapes.size() > 0) { - if (mapView.frmIdentifer == null) { - mapView.frmIdentifer = new FrmIdentifer((JFrame) SwingUtilities.getWindowAncestor(this), false, mapView); - mapView.frmIdentifer.addWindowListener(new WindowAdapter() { - @Override - public void windowClosed(WindowEvent e) { - mapView.setDrawIdentiferShape(false); - ChartPanel.this.repaintOld(); - } - }); - } - String[] colNames = {"Field", "Value"}; - String fieldStr, valueStr; - int shapeIdx = selectedShapes.get(0); - aLayer.setIdentiferShape(shapeIdx); - mapView._drawIdentiferShape = true; - - Object[][] tData = new Object[aLayer.getFieldNumber() + 1][2]; - fieldStr = "Index"; - valueStr = String.valueOf(shapeIdx); - tData[0][0] = fieldStr; - tData[0][1] = valueStr; - Object value; - if (aLayer.getShapeNum() > 0) { - for (int i = 0; i < aLayer.getFieldNumber(); i++) { - Field field = aLayer.getField(i); - fieldStr = field.getColumnName(); - value = aLayer.getCellValue(i, shapeIdx); - if (value == null) { - valueStr = ""; - } else if (field.getDataType() == DataType.DATE) { - DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - valueStr = format.format((LocalDateTime) value); - } else { - valueStr = value.toString(); - } - tData[i + 1][0] = fieldStr; - tData[i + 1][1] = valueStr; - } - } - DefaultTableModel dtm = new DefaultTableModel(tData, colNames) { - @Override - public boolean isCellEditable(int row, int column) { - return false; - } - }; - mapView.frmIdentifer.getTable().setModel(dtm); - mapView.frmIdentifer.repaint(); - if (!mapView.frmIdentifer.isVisible()) { - //this._frmIdentifer.setLocation(e.getX(), e.getY()); - mapView.frmIdentifer.setLocationRelativeTo(this); - mapView.frmIdentifer.setVisible(true); - } - - mapView.setDrawIdentiferShape(true); - this.repaintOld(); - } - } else if (aMLayer.getLayerType() == LayerTypes.RasterLayer) { - RasterLayer aRLayer = (RasterLayer) aMLayer; - int[] ijIdx = mapView.selectGridCell(aRLayer, aPoint); - if (ijIdx != null) { - int iIdx = ijIdx[0]; - int jIdx = ijIdx[1]; - double aValue = aRLayer.getCellValue(iIdx, jIdx); - if (mapView._frmIdentiferGrid == null) { - mapView._frmIdentiferGrid = new FrmIdentiferGrid((JFrame) SwingUtilities.getWindowAncestor(this), false); - } - - mapView._frmIdentiferGrid.setIIndex(iIdx); - mapView._frmIdentiferGrid.setJIndex(jIdx); - mapView._frmIdentiferGrid.setCellValue(aValue); - if (!mapView._frmIdentiferGrid.isVisible()) { - //this._frmIdentiferGrid.setLocation(e.getX(), e.getY()); - mapView._frmIdentiferGrid.setLocationRelativeTo(this); - mapView._frmIdentiferGrid.setVisible(true); - } - } - } - break; - } - } else if (e.getButton() == MouseEvent.BUTTON3) { - popupMenu.show(this, e.getX(), e.getY()); - } - } - } - - void onMouseWheelMoved(MouseWheelEvent e) { - Plot plt = selPlot(e.getX(), e.getY()); - if (!(plt instanceof AbstractPlot2D)) { - return; - } - - double minX, maxX, minY, maxY, lonRan, latRan, zoomF; - double mouseLon, mouseLat; - Extent drawExtent = ((AbstractPlot2D) plt).getDrawExtent(); - lonRan = drawExtent.maxX - drawExtent.minX; - latRan = drawExtent.maxY - drawExtent.minY; - mouseLon = drawExtent.minX + lonRan / 2; - mouseLat = drawExtent.minY + latRan / 2; - - zoomF = 1 + e.getWheelRotation() / 10.0f; - - minX = mouseLon - (lonRan / 2 * zoomF); - maxX = mouseLon + (lonRan / 2 * zoomF); - minY = mouseLat - (latRan / 2 * zoomF); - maxY = mouseLat + (latRan / 2 * zoomF); - switch (this.mouseMode) { - case PAN: - if (plt instanceof MapPlot) { - MapPlot mplt = (MapPlot) plt; - Graphics2D g = (Graphics2D) this.getGraphics(); - Rectangle2D mapRect = mplt.getGraphArea(); - - this.lastMouseWheelTime = LocalDateTime.now(); - if (!this.mouseWheelDetctionTimer.isRunning()) { - this.mouseWheelDetctionTimer.start(); - tempImage = new BufferedImage((int) mapRect.getWidth() - 2, - (int) mapRect.getHeight() - 2, BufferedImage.TYPE_INT_ARGB); - Graphics2D tg = tempImage.createGraphics(); - tg.setColor(Color.white); - tg.fill(mapRect); - tg.drawImage(this.mapBitmap, -(int) mapRect.getX() - 1, -(int) mapRect.getY() - 1, this); - tg.dispose(); - } - - g.setClip(mapRect); - g.setColor(Color.white); - //g.clearRect((int)mapRect.getX(), (int)mapRect.getY(), (int)mapRect.getWidth(), (int)mapRect.getHeight()); - paintScale = paintScale / zoomF; - float nWidth = (float)mapRect.getWidth() * (float) paintScale; - float nHeight = (float)mapRect.getHeight() * (float) paintScale; - float nx = ((float)mapRect.getWidth() - nWidth) / 2; - float ny = ((float)mapRect.getHeight() - nHeight) / 2; - if (nx > 0) { - g.fillRect((int) mapRect.getX(), (int) mapRect.getY(), (int)nx, (int) mapRect.getHeight()); - g.fillRect((int) (mapRect.getMaxX() - nx), (int) mapRect.getY(), (int)nx, (int) mapRect.getHeight()); - } - if (ny > 0) { - g.fillRect((int) mapRect.getX(), (int) mapRect.getY(), (int) mapRect.getWidth(), (int)ny); - g.fillRect((int) mapRect.getX(), (int) (mapRect.getMaxY() - ny), (int) mapRect.getWidth(), (int)ny); - } - g.drawImage(tempImage, (int)(mapRect.getX() + nx), (int)(mapRect.getY() + ny), - (int)nWidth, (int)nHeight, null); - g.setColor(this.getForeground()); - g.draw(mapRect); - mplt.setDrawExtent(new Extent(minX, maxX, minY, maxY)); - } else { - ((AbstractPlot2D) plt).setDrawExtent(new Extent(minX, maxX, minY, maxY)); - //this.paintGraphics(); - this.repaintNew(); - } - break; - } - } - - /** - * Zoom back to full extent - */ - @Override - public void onUndoZoomClick() { - AbstractPlot2D xyplot; - if (this.currentPlot == null) { - xyplot = (AbstractPlot2D) this.chart.getPlots().get(0); - } else { - xyplot = (AbstractPlot2D) this.currentPlot; - } - xyplot.setDrawExtent((Extent) xyplot.getExtent().clone()); -// if (xyplot instanceof MapPlot) { -// MapPlot plot = (MapPlot) xyplot; -// plot.setDrawExtent(plot.getMapView().getLastAddedLayer().getExtent()); -// } else { -// xyplot.setAutoExtent(); -// } - //this.paintGraphics(); - this.repaintNew(); - } - - private void onSaveFigureClick(ActionEvent e) { - String path = System.getProperty("user.dir"); - File pathDir = new File(path); - JFileChooser aDlg = new JFileChooser(); - aDlg.setCurrentDirectory(pathDir); - String[] fileExts = new String[]{"png"}; - GenericFileFilter pngFileFilter = new GenericFileFilter(fileExts, "Png Image (*.png)"); - aDlg.addChoosableFileFilter(pngFileFilter); - fileExts = new String[]{"gif"}; - GenericFileFilter mapFileFilter = new GenericFileFilter(fileExts, "Gif Image (*.gif)"); - aDlg.addChoosableFileFilter(mapFileFilter); - fileExts = new String[]{"jpg"}; - mapFileFilter = new GenericFileFilter(fileExts, "Jpeg Image (*.jpg)"); - aDlg.addChoosableFileFilter(mapFileFilter); - fileExts = new String[]{"eps"}; - mapFileFilter = new GenericFileFilter(fileExts, "EPS file (*.eps)"); - aDlg.addChoosableFileFilter(mapFileFilter); - fileExts = new String[]{"pdf"}; - mapFileFilter = new GenericFileFilter(fileExts, "PDF file (*.pdf)"); - aDlg.addChoosableFileFilter(mapFileFilter); - fileExts = new String[]{"emf"}; - mapFileFilter = new GenericFileFilter(fileExts, "EMF file (*.emf)"); - aDlg.addChoosableFileFilter(mapFileFilter); - aDlg.setFileFilter(pngFileFilter); - aDlg.setAcceptAllFileFilterUsed(false); - if (JFileChooser.APPROVE_OPTION == aDlg.showSaveDialog(this)) { - File aFile = aDlg.getSelectedFile(); - System.setProperty("user.dir", aFile.getParent()); - String extent = ((GenericFileFilter) aDlg.getFileFilter()).getFileExtent(); - String fileName = aFile.getAbsolutePath(); - if (!fileName.substring(fileName.length() - extent.length()).equals(extent)) { - fileName = fileName + "." + extent; - } - if (new File(fileName).exists()) { - int overwrite = JOptionPane.showConfirmDialog(this, "File exists! Overwrite it?"); - if (overwrite == JOptionPane.YES_OPTION) { - this.saveImage(fileName); - } - } else { - this.saveImage(fileName); - } - } - } - - /** - * Save image to a picture file - * - * @param aFile File path - */ - @Override - public void saveImage(String aFile) { - try { - saveImage(aFile, null); - } catch (PrintException | IOException | InterruptedException ex) { - Logger.getLogger(ChartPanel.class.getName()).log(Level.SEVERE, null, ex); - } - } - - /** - * Save image to a picture file - * - * @param aFile File path - * @param sleep Sleep seconds for web map layer - * @throws FileNotFoundException - * @throws PrintException - * @throws InterruptedException - */ - public void saveImage(String aFile, Integer sleep) throws FileNotFoundException, PrintException, IOException, InterruptedException { - int w, h; - if (this.chartSize == null) { - w = this.getWidth(); - h = this.getHeight(); - } else { - w = this.chartSize.width; - h = this.chartSize.height; - } - this.saveImage(aFile, w, h, sleep); - } - - /** - * Save image to a picture file - * - * @param aFile File path - * @param width Width - * @param height Height - * @param sleep Sleep seconds for web map layer - * @throws FileNotFoundException - * @throws PrintException - * @throws InterruptedException - */ - public void saveImage(String aFile, int width, int height, Integer sleep) throws FileNotFoundException, PrintException, IOException, InterruptedException { - if (aFile.endsWith(".ps")) { - DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; - String mimeType = "application/postscript"; - StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, mimeType); - FileOutputStream out = new FileOutputStream(aFile); - if (factories.length > 0) { - PrintService service = factories[0].getPrintService(out); - SimpleDoc doc = new SimpleDoc(new Printable() { - @Override - public int print(Graphics g, PageFormat pf, int page) { - if (page >= 1) { - return Printable.NO_SUCH_PAGE; - } else { - double sf1 = pf.getImageableWidth() / (getWidth() + 1); - double sf2 = pf.getImageableHeight() / (getHeight() + 1); - double s = Math.min(sf1, sf2); - Graphics2D g2 = (Graphics2D) g; - g2.translate((pf.getWidth() - pf.getImageableWidth()) / 2, (pf.getHeight() - pf.getImageableHeight()) / 2); - g2.scale(s, s); - - paintGraphics(g2); - return Printable.PAGE_EXISTS; - } - } - }, flavor, null); - DocPrintJob job = service.createPrintJob(); - PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet(); - job.print(doc, attributes); - out.close(); - } - } else if (aFile.endsWith(".eps")) { - Properties p = new Properties(); - p.setProperty("PageSize", "A5"); - VectorGraphics g = new PSGraphics2D(new File(aFile), new Dimension(width, height)); - //g.setProperties(p); - g.startExport(); - //this.paintGraphics(g); - this.paintGraphics(g, width, height); - g.endExport(); - g.dispose(); - } else if (aFile.endsWith(".pdf")) { - try { - Document document = new Document(new com.itextpdf.text.Rectangle(width, height)); - PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(aFile)); - document.open(); - PdfContentByte cb = writer.getDirectContent(); - PdfTemplate pdfTemp = cb.createTemplate(width, height); - Graphics2D g2 = new PdfGraphics2D(pdfTemp, width, height, true); - this.paintGraphics(g2, width, height); - g2.dispose(); - cb.addTemplate(pdfTemp, 0, 0); - document.close(); - } catch (DocumentException | FileNotFoundException e) { - e.printStackTrace(); - } - } else if (aFile.endsWith(".emf")) { - VectorGraphics g = new EMFGraphics2D(new File(aFile), new Dimension(width, height)); - //g.setProperties(p); - g.startExport(); - //this.paintGraphics(g); - this.paintGraphics(g, width, height); - g.endExport(); - g.dispose(); - } else { - //String extension = aFile.substring(aFile.lastIndexOf('.') + 1); - //ImageIO.write(this.mapBitmap, extension, new File(aFile)); - - String extension = aFile.substring(aFile.lastIndexOf('.') + 1); - BufferedImage aImage; - if (extension.equalsIgnoreCase("bmp")) { - aImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - } else { - aImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - } - Graphics2D g = aImage.createGraphics(); - paintGraphics(g, width, height); - - if (sleep != null) { - Thread.sleep(sleep * 1000); - } - - if (extension.equalsIgnoreCase("jpg")) { - BufferedImage newImage = new BufferedImage(aImage.getWidth(), aImage.getHeight(), BufferedImage.TYPE_INT_RGB); - newImage.createGraphics().drawImage(aImage, 0, 0, Color.BLACK, null); - ImageIO.write(newImage, extension, new File(aFile)); - } else { - ImageIO.write(aImage, extension, new File(aFile)); - } - } - } - - /** - * Save image to a picture file - * - * @param aFile File path - * @param width Width - * @param height Height - * @param sleep Sleep seconds for web map layer - * @throws FileNotFoundException - * @throws PrintException - * @throws InterruptedException - */ - public void saveImage_bak(String aFile, int width, int height, Integer sleep) throws FileNotFoundException, PrintException, IOException, InterruptedException { - if (aFile.endsWith(".ps")) { - DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; - String mimeType = "application/postscript"; - StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, mimeType); - FileOutputStream out = new FileOutputStream(aFile); - if (factories.length > 0) { - PrintService service = factories[0].getPrintService(out); - SimpleDoc doc = new SimpleDoc(new Printable() { - @Override - public int print(Graphics g, PageFormat pf, int page) { - if (page >= 1) { - return Printable.NO_SUCH_PAGE; - } else { - double sf1 = pf.getImageableWidth() / (getWidth() + 1); - double sf2 = pf.getImageableHeight() / (getHeight() + 1); - double s = Math.min(sf1, sf2); - Graphics2D g2 = (Graphics2D) g; - g2.translate((pf.getWidth() - pf.getImageableWidth()) / 2, (pf.getHeight() - pf.getImageableHeight()) / 2); - g2.scale(s, s); - - paintGraphics(g2); - return Printable.PAGE_EXISTS; - } - } - }, flavor, null); - DocPrintJob job = service.createPrintJob(); - PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet(); - job.print(doc, attributes); - out.close(); - } - } else if (aFile.endsWith(".eps")) { -// EPSGraphics2D g = new EPSGraphics2D(0.0, 0.0, width, height); -// paintGraphics(g); -// FileOutputStream file = new FileOutputStream(aFile); -// try { -// file.write(g.getBytes()); -// } finally { -// file.close(); -// g.dispose(); -// } - - Properties p = new Properties(); - p.setProperty("PageSize", "A5"); - VectorGraphics g = new PSGraphics2D(new File(aFile), new Dimension(width, height)); - //g.setProperties(p); - g.startExport(); - //this.paintGraphics(g); - this.paintGraphics(g, width, height); - g.endExport(); - g.dispose(); - } else if (aFile.endsWith(".pdf")) { - VectorGraphics g = new PDFGraphics2D(new File(aFile), new Dimension(width, height)); - //g.setProperties(p); - g.startExport(); - this.paintGraphics(g, width, height); - g.endExport(); - g.dispose(); - } else if (aFile.endsWith(".emf")) { - VectorGraphics g = new EMFGraphics2D(new File(aFile), new Dimension(width, height)); - //g.setProperties(p); - g.startExport(); - //this.paintGraphics(g); - this.paintGraphics(g, width, height); - g.endExport(); - g.dispose(); - } else { - //String extension = aFile.substring(aFile.lastIndexOf('.') + 1); - //ImageIO.write(this.mapBitmap, extension, new File(aFile)); - - String extension = aFile.substring(aFile.lastIndexOf('.') + 1); - BufferedImage aImage; - if (extension.equalsIgnoreCase("bmp")) { - aImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - } else { - aImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - } - Graphics2D g = aImage.createGraphics(); - paintGraphics(g, width, height); - - if (sleep != null) { - Thread.sleep(sleep * 1000); - } - - if (extension.equalsIgnoreCase("jpg")) { - BufferedImage newImage = new BufferedImage(aImage.getWidth(), aImage.getHeight(), BufferedImage.TYPE_INT_RGB); - newImage.createGraphics().drawImage(aImage, 0, 0, Color.BLACK, null); - ImageIO.write(newImage, extension, new File(aFile)); - } else { - ImageIO.write(aImage, extension, new File(aFile)); - } - } - } - - /** - * Save image to Jpeg file - * - * @param fileName File name - * @param dpi DPI - * @throws IOException - */ - public void saveImage_Jpeg_old(String fileName, int dpi) throws IOException { - BufferedImage image = this.mapBitmap; - Iterator i = ImageIO.getImageWritersByFormatName("jpeg"); - //are there any jpeg encoders available? - - if (i.hasNext()) //there's at least one ImageWriter, just use the first one - { - ImageWriter imageWriter = (ImageWriter) i.next(); - //get the param - ImageWriteParam param = imageWriter.getDefaultWriteParam(); - ImageTypeSpecifier its = new ImageTypeSpecifier(image.getColorModel(), image.getSampleModel()); - - //get metadata - IIOMetadata iomd = imageWriter.getDefaultImageMetadata(its, - param); - - String formatName = "javax_imageio_jpeg_image_1.0";//this is the DOCTYPE of the metadata we need - - Node node = iomd.getAsTree(formatName); - //what are child nodes? - NodeList nl = node.getChildNodes(); - for (int j = 0; j < nl.getLength(); j++) { - Node n = nl.item(j); - System.out.println("node from IOMetadata is : " - + n.getNodeName()); - - if (n.getNodeName().equals("JPEGvariety")) { - NodeList childNodes = n.getChildNodes(); - - for (int k = 0; k < childNodes.getLength(); k++) { - System.out.println("node #" + k + " is " - + childNodes.item(k).getNodeName()); - if (childNodes.item(k).getNodeName().equals("app0JFIF")) { - NamedNodeMap nnm = childNodes.item(k).getAttributes(); - //get the resUnits, Xdensity, and Ydensity attribuutes - Node resUnitsNode = getAttributeByName(childNodes.item(k), "resUnits"); - Node XdensityNode = getAttributeByName(childNodes.item(k), "Xdensity"); - Node YdensityNode = getAttributeByName(childNodes.item(k), "Ydensity"); - - //reset values for nodes - resUnitsNode.setNodeValue("1"); //indicate DPI mode - XdensityNode.setNodeValue(String.valueOf(dpi)); - YdensityNode.setNodeValue(String.valueOf(dpi)); - - System.out.println("name=" - + resUnitsNode.getNodeName() + ", value=" + resUnitsNode.getNodeValue()); - System.out.println("name=" - + XdensityNode.getNodeName() + ", value=" + XdensityNode.getNodeValue()); - System.out.println("name=" - + YdensityNode.getNodeName() + ", value=" + YdensityNode.getNodeValue()); - - } //end if (childNodes.item(k).getNodeName().equals("app0JFIF")) - } //end if (n.getNodeName().equals("JPEGvariety") - break; //we don't care about the rest of the children - } //end if (n.getNodeName().equals("JPEGvariety")) - - } //end for (int j = 0; j < nl.getLength(); j++) - - try { - iomd.setFromTree(formatName, node); - } catch (IIOInvalidTreeException e) { - e.printStackTrace(); //To change body of catch statement use Options | File Templates. - } - //attach the metadata to an image - IIOImage iioimage = new IIOImage(image, null, iomd); - FileImageOutputStream stream = new FileImageOutputStream(new File(fileName)); - try { - imageWriter.setOutput(stream); - imageWriter.write(iioimage); - } catch (IOException e) { - e.printStackTrace(); - } finally { - stream.close(); - } - } //end if (i.hasNext()) //there's at least one ImageWriter, just use the first one - } - - /** - * @param node - * @param attributeName - name of child node to return - * @return Node - */ - private Node getAttributeByName(Node node, String attributeName) { - if (node == null) { - return null; - } - NamedNodeMap nnm = node.getAttributes(); - for (int i = 0; i < nnm.getLength(); i++) { - Node n = nnm.item(i); - if (n.getNodeName().equals(attributeName)) { - return n; - } - } - return null; // no such attribute was found - } - - public boolean saveImage_Jpeg(String file, int dpi) { - int w, h; - if (this.chartSize == null) { - w = this.getWidth(); - h = this.getHeight(); - } else { - w = this.chartSize.width; - h = this.chartSize.height; - } - return this.saveImage_Jpeg(file, w, h, dpi); - } - - public boolean saveImage_Jpeg(String file, int width, int height, int dpi) { - double scaleFactor = dpi / 72.0; - BufferedImage bufferedImage = new BufferedImage((int)(width * scaleFactor), (int)(height * scaleFactor), BufferedImage.TYPE_INT_RGB); - Graphics2D g = bufferedImage.createGraphics(); - AffineTransform at = g.getTransform(); - at.scale(scaleFactor, scaleFactor); - g.setTransform(at); - paintGraphics(g, width, height); - - try { - // Image writer - ImageWriter imageWriter = ImageIO.getImageWritersBySuffix("jpeg").next(); - ImageOutputStream ios = ImageIO.createImageOutputStream(new File(file)); - imageWriter.setOutput(ios); - - // Compression - JPEGImageWriteParam jpegParams = (JPEGImageWriteParam) imageWriter.getDefaultWriteParam(); - jpegParams.setCompressionMode(JPEGImageWriteParam.MODE_EXPLICIT); - jpegParams.setCompressionQuality(0.85f); - - // Metadata (dpi) - IIOMetadata data = imageWriter.getDefaultImageMetadata(new ImageTypeSpecifier(bufferedImage), jpegParams); - Element tree = (Element) data.getAsTree("javax_imageio_jpeg_image_1.0"); - Element jfif = (Element) tree.getElementsByTagName("app0JFIF").item(0); - jfif.setAttribute("Xdensity", Integer.toString(dpi)); - jfif.setAttribute("Ydensity", Integer.toString(dpi)); - jfif.setAttribute("resUnits", "1"); // density is dots per inch - data.setFromTree("javax_imageio_jpeg_image_1.0", tree); - - // Write and clean up - imageWriter.write(null, new IIOImage(bufferedImage, null, data), jpegParams); - ios.close(); - imageWriter.dispose(); - } catch (Exception e) { - return false; - } - g.dispose(); - - return true; - } - - /** - * Save image - * - * @param fileName File name - * @param dpi DPI - * @throws IOException - * @throws InterruptedException - */ - public void saveImage(String fileName, int dpi) throws IOException, InterruptedException { - saveImage(fileName, dpi, null); - } - - /** - * Save image - * - * @param fileName File name - * @param dpi DPI - * @param sleep Sleep seconds for web map layer - * @throws IOException - * @throws InterruptedException - */ - public void saveImage(String fileName, int dpi, Integer sleep) throws IOException, InterruptedException { - int width, height; - if (this.chartSize != null) { - height = this.chartSize.height; - width = this.chartSize.width; - } else { - width = this.getWidth(); - height = this.getHeight(); - } - - this.saveImage(fileName,dpi, width, height, sleep); - } - - /** - * Save image - * - * @param fileName File name - * @param dpi DPI - * @param width Width - * @param height Height - * @param sleep Sleep seconds for web map layer - * @throws IOException - * @throws InterruptedException - */ - public void saveImage(String fileName, int dpi, int width, int height, Integer sleep) throws IOException, InterruptedException { - File output = new File(fileName); - output.delete(); - - String formatName = fileName.substring(fileName.lastIndexOf('.') + 1); - if (formatName.equals("jpg")) { - formatName = "jpeg"; - saveImage_Jpeg(fileName, width, height, dpi); - return; - } - - double scaleFactor = dpi / 72.0; - BufferedImage image = new BufferedImage((int)(width * scaleFactor), (int)(height * scaleFactor), BufferedImage.TYPE_INT_ARGB); - Graphics2D g = image.createGraphics(); - AffineTransform at = g.getTransform(); - at.scale(scaleFactor, scaleFactor); - g.setTransform(at); - paintGraphics(g, width, height); - for (Iterator iw = ImageIO.getImageWritersByFormatName(formatName); iw.hasNext();) { - ImageWriter writer = iw.next(); - ImageWriteParam writeParam = writer.getDefaultWriteParam(); - ImageTypeSpecifier typeSpecifier = ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_ARGB); - IIOMetadata metadata = writer.getDefaultImageMetadata(typeSpecifier, writeParam); - if (metadata == null) { - metadata = writer.getDefaultImageMetadata(typeSpecifier, null); - } - if (metadata.isReadOnly() || !metadata.isStandardMetadataFormatSupported()) { - continue; - } - - ImageUtil.setDPI(metadata, dpi); - - if (sleep != null) { - Thread.sleep(sleep * 1000); - } - final ImageOutputStream stream = ImageIO.createImageOutputStream(output); - try { - writer.setOutput(stream); - writer.write(metadata, new IIOImage(image, null, metadata), writeParam); - } finally { - stream.close(); - } - break; - } - g.dispose(); - } - - /** - * Get view image - * - * @return View image - */ - public BufferedImage getViewImage() { - return this.mapBitmap; - } - - /** - * Paint view image - * - * @return View image - */ - public BufferedImage paintViewImage() { - int w, h; - if (this.chartSize == null) { - w = this.getWidth(); - h = this.getHeight(); - } else { - w = this.chartSize.width; - h = this.chartSize.height; - } - return paintViewImage(w, h); - } - - /** - * Paint view image - * - * @param width Image width - * @param height Image height - * @return View image - */ - public BufferedImage paintViewImage(int width, int height) { - BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - Graphics2D g = image.createGraphics(); - paintGraphics(g); - - return image; - } - - /** - * Paint view image - * - * @param dpi Image resolution - * @return View image - */ - public BufferedImage paintViewImage(int dpi) { - int w, h; - if (this.chartSize == null) { - w = this.getWidth(); - h = this.getHeight(); - } else { - w = this.chartSize.width; - h = this.chartSize.height; - } - return paintViewImage(w, h, dpi); - } - - /** - * Paint view image - * - * @param width Image width - * @param height Image height - * @param dpi Image resolution - * @return View image - */ - public BufferedImage paintViewImage(int width, int height, int dpi) { - double scaleFactor = dpi / 72.0; - BufferedImage image = new BufferedImage((int)(width * scaleFactor), (int)(height * scaleFactor), - BufferedImage.TYPE_INT_ARGB); - Graphics2D g = image.createGraphics(); - AffineTransform at = g.getTransform(); - at.scale(scaleFactor, scaleFactor); - g.setTransform(at); - paintGraphics(g, width, height); - - return image; - } - - /** - * Check if has web map layer - * - * @return Boolean - */ - public boolean hasWebMap() { - if (this.chart != null) { - return this.chart.hasWebMap(); - } - - return false; - } - // -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartScaleBar.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartScaleBar.java deleted file mode 100644 index 4e813f5d..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartScaleBar.java +++ /dev/null @@ -1,457 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; -import java.awt.geom.Line2D; -import org.meteoinfo.chart.plot.MapPlot; -import org.meteoinfo.common.PointF; -import org.meteoinfo.layout.ScaleBarType; -import org.meteoinfo.layout.ScaleBarUnits; - -/** - * - * @author Yaqiang Wang - */ -public class ChartScaleBar extends ChartElement { - // - - private MapPlot mapPlot; - private boolean _antiAlias; - private float lineWidth; - private Font _font; - private ScaleBarType _scaleBarType; - private ScaleBarUnits _unit; - private String _unitText; - private int _numBreaks; - private boolean _drawNeatLine; - private Color _neatLineColor; - private float _neatLineSize; - private boolean _drawScaleText; - private float _yShiftScale = 2.0f; - // - // - - /** - * Constructor - * - * @param mapPlot The map plot - */ - public ChartScaleBar(MapPlot mapPlot) { - super(); - //this.setElementType(ElementType.LayoutScaleBar); - //this.setResizeAbility(ResizeAbility.ResizeAll); - - this.width = 200; - this.height = 50; - this.mapPlot = mapPlot; - _antiAlias = true; - _scaleBarType = ScaleBarType.SCALELINE_1; - lineWidth = 1; - _drawNeatLine = false; - _neatLineColor = Color.black; - _neatLineSize = 1; - _font = new Font("Arial", Font.PLAIN, 12); - _unit = ScaleBarUnits.KILOMETERS; - _unitText = "km"; - _numBreaks = 4; - _drawScaleText = false; - } - // - // - - /** - * Get map plot - * - * @return The map plot - */ - public MapPlot getMapPlot() { - return mapPlot; - } - - /** - * Get line widht - * @return Line width - */ - public float getLineWidth() { - return this.lineWidth; - } - - /** - * Set line width - * @param value Line width - */ - public void setLineWidth(float value) { - this.lineWidth = value; - } - - /** - * Get scale bar type - * - * @return Scale bar type - */ - public ScaleBarType getScaleBarType() { - return _scaleBarType; - } - - /** - * Set scale bar type - * - * @param type Scale bar type - */ - public void setScaleBarType(ScaleBarType type) { - _scaleBarType = type; - } - - /** - * Get if draw neat line - * - * @return If draw neat line - */ - public boolean isDrawNeatLine() { - return _drawNeatLine; - } - - /** - * Set if draw neat line - * - * @param istrue If draw neat line - */ - public void setDrawNeatLine(boolean istrue) { - _drawNeatLine = istrue; - } - - /** - * Get neat line color - * - * @return Neat line color - */ - public Color getNeatLineColor() { - return _neatLineColor; - } - - /** - * Set neat line color - * - * @param color Neat line color - */ - public void setNeatLineColor(Color color) { - _neatLineColor = color; - } - - /** - * Get neat line size - * - * @return Neat line size - */ - public float getNeatLineSize() { - return _neatLineSize; - } - - /** - * Set neat line size - * - * @param size Neat line size - */ - public void setNeatLineSize(float size) { - _neatLineSize = size; - } - - /** - * Get font - * - * @return The font - */ - public Font getFont() { - return _font; - } - - /** - * Set font - * - * @param font The font - */ - public void setFont(Font font) { - _font = font; - } - - /** - * Get break number - * - * @return The break number - */ - public int getBreakNumber() { - return _numBreaks; - } - - /** - * Set break number - * - * @param num Break number - */ - public void setBreakNumber(int num) { - _numBreaks = num; - } - - /** - * Get if draw scale text - * - * @return If draw scale text - */ - public boolean isDrawScaleText() { - return _drawScaleText; - } - - /** - * Set if draw scale text - * - * @param istrue If draw scale text - */ - public void setDrawScaleText(boolean istrue) { - _drawScaleText = istrue; - } - // - // - /** - * Draw text - * - * @param g Graphics2D - * @param x X - * @param y Y - */ - public void draw(Graphics2D g, float x, float y) { - AffineTransform oldMatrix = g.getTransform(); - g.translate(x, y); - if (_antiAlias) { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - } else { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - } - - //Draw background color - if (this.isDrawBackColor()){ - g.setColor(this.getBackground()); - g.fill(new Rectangle.Float(0, 0, this.getWidth(), this.getHeight())); - } - - drawScaleBar(g); - - //Draw neatline - if (_drawNeatLine) { - Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1, - (this.getWidth() - _neatLineSize), (this.getHeight() - _neatLineSize)); - g.setColor(_neatLineColor); - g.setStroke(new BasicStroke(_neatLineSize)); - g.draw(mapRect); - } - - g.setTransform(oldMatrix); - } - - /** - * Paint graphics - * - * @param g Graphics - * @param pageLocation Page location - * @param zoom Zoom - */ - public void paintGraphics(Graphics2D g, PointF pageLocation) { - AffineTransform oldMatrix = g.getTransform(); - PointF aP = pageToScreen(this.getX(), this.getY(), pageLocation, 1); - g.translate(aP.X, aP.Y); - if (_antiAlias) { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - } else { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - } - - //Draw background color - if (this.isDrawBackColor()){ - g.setColor(this.getBackground()); - g.fill(new Rectangle.Float(0, 0, this.getWidth(), this.getHeight())); - } - - drawScaleBar(g); - - //Draw neatline - if (_drawNeatLine) { - Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1, - (this.getWidth() - _neatLineSize), (this.getHeight() - _neatLineSize)); - g.setColor(_neatLineColor); - g.setStroke(new BasicStroke(_neatLineSize)); - g.draw(mapRect); - } - - g.setTransform(oldMatrix); - } - - private void drawScaleBar(Graphics2D g) { - //Calculates the width of one break in greographic units - FontMetrics metrics = g.getFontMetrics(this._font); - float unitLegnth = metrics.stringWidth(_unitText) * 2; - float widthNoUnit = (this.getWidth() - unitLegnth); - long geoBreakWidth = (long) (getGeoWidth(widthNoUnit / _numBreaks)); - - //If the geobreakWidth is less than 1 we return and don't draw anything - if (geoBreakWidth < 1) { - return; - } - - double n = Math.pow(10, String.valueOf(geoBreakWidth).length() - 1); - geoBreakWidth = (long) (Math.floor(geoBreakWidth / n) * n); - - long breakWidth = (long) (getWidth(geoBreakWidth)); - FontMetrics metrics1 = g.getFontMetrics(_font); - float fontHeight = metrics1.getHeight(); - float leftStart = metrics1.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F; - - //Draw scale text - double scale = geoBreakWidth * getConversionFactor(_unit) * 100 / (breakWidth / 96 * 2.539999918); - if (_drawScaleText) { - g.setFont(this._font); - g.setColor(this.getForeground()); - g.drawString("1 : " + String.format("{0:0,0}", scale), - leftStart - (metrics.stringWidth(String.valueOf(Math.abs(0))) / 2), fontHeight * 2.5F); - } - - //Draw scale bar - switch (_scaleBarType) { - case SCALELINE_1: - drawScaleLine1(g, breakWidth, geoBreakWidth); - break; - case SCALELINE_2: - drawScaleLine2(g, breakWidth, geoBreakWidth); - break; - case ALTERNATING_BAR: - drawAlternatingBar(g, breakWidth, geoBreakWidth); - break; - } - } - - private double getConversionFactor(ScaleBarUnits unit) { - switch (unit) { - case KILOMETERS: - return 1000; - default: - return 1; - } - } - - private double getGeoWidth(double width) { - double geoWidth = width / mapPlot.getMapFrame().getMapView().getXScale() / getConversionFactor(_unit); - if (mapPlot.getMapFrame().getMapView().getProjection().isLonLatMap()) { - geoWidth = geoWidth * getLonDistScale(); - } - - return geoWidth; - } - - private double getWidth(double geoWidth) { - double width = geoWidth * mapPlot.getMapFrame().getMapView().getXScale() * getConversionFactor(_unit); - if (mapPlot.getMapFrame().getMapView().getProjection().isLonLatMap()) { - width = width / getLonDistScale(); - } - - return width; - } - - private double getLonDistScale() { - //Get meters of one longitude degree - double pY = (mapPlot.getMapFrame().getMapView().getViewExtent().maxY + mapPlot.getMapFrame().getMapView().getViewExtent().minY) / 2; - double ProjX = 0, ProjY = pY, pProjX = 1, pProjY = pY; - double dx = Math.abs(ProjX - pProjX); - double dy = Math.abs(ProjY - pProjY); - double dist; - double y = (ProjY + pProjY) / 2; - double factor = Math.cos(y * Math.PI / 180); - dx *= factor; - dist = Math.sqrt(dx * dx + dy * dy); - dist = dist * 111319.5; - - return dist; - } - - private void drawScaleLine1(Graphics2D g, long breakWidth, long geoBreakWidth) { - FontMetrics metrics = g.getFontMetrics(_font); - float fontHeight = metrics.getHeight(); - float leftStart = metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F; - int yShift = 10; - - g.setColor(this.getForeground()); - g.setStroke(new BasicStroke(this.lineWidth)); - g.draw(new Line2D.Float(leftStart, fontHeight * 1.6f + yShift, leftStart + (breakWidth * _numBreaks), fontHeight * 1.6f + yShift)); - g.setFont(this._font); - for (int i = 0; i <= _numBreaks; i++) { - g.draw(new Line2D.Float(leftStart, fontHeight * 1.1f + yShift, leftStart, fontHeight * 1.6f + yShift)); - g.drawString(String.valueOf(Math.abs(geoBreakWidth * i)), - leftStart - (metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth * i))) / 2), yShift * _yShiftScale); - leftStart = leftStart + breakWidth; - } - g.drawString(_unitText, leftStart - breakWidth + (fontHeight / 2), fontHeight * 1.1f + yShift * _yShiftScale); - } - - private void drawScaleLine2(Graphics2D g, long breakWidth, long geoBreakWidth) { - FontMetrics metrics = g.getFontMetrics(_font); - float fontHeight = metrics.getHeight(); - float leftStart = metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F; - int yShift = 5; - - g.setColor(this.getForeground()); - g.setStroke(new BasicStroke(this.lineWidth)); - g.draw(new Line2D.Float(leftStart, fontHeight * 1.6f + yShift, leftStart + (breakWidth * _numBreaks), fontHeight * 1.6f + yShift)); - g.setFont(this._font); - for (int i = 0; i <= _numBreaks; i++) { - g.draw(new Line2D.Float(leftStart, fontHeight * 1.1f + yShift, leftStart, fontHeight + (fontHeight * 1.1f) + yShift)); - g.drawString(String.valueOf(Math.abs(geoBreakWidth * i)), - leftStart - (metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth * i))) / 2), yShift * _yShiftScale); - leftStart = leftStart + breakWidth; - } - g.drawString(_unitText, leftStart - breakWidth + (fontHeight / 2), fontHeight * 1.1f + yShift * _yShiftScale); - } - - private void drawAlternatingBar(Graphics2D g, long breakWidth, long geoBreakWidth) { - FontMetrics metrics = g.getFontMetrics(_font); - float fontHeight = metrics.getHeight(); - float leftStart = metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F; - int yShift = 5; - float rHeight = fontHeight / 2; - - boolean isFill = false; - g.setStroke(new BasicStroke(this.lineWidth)); - g.setColor(this.getForeground()); - g.setFont(this._font); - for (int i = 0; i <= _numBreaks; i++) { - if (i < _numBreaks) { - if (isFill) { - g.fill(new Rectangle.Float(leftStart, fontHeight * 1.1f + yShift, breakWidth, rHeight)); - } - g.draw(new Rectangle.Float(leftStart, fontHeight * 1.1f + yShift, breakWidth, rHeight)); - } - g.drawString(String.valueOf(Math.abs(geoBreakWidth * i)), - leftStart - (metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth * i))) / 2), yShift * _yShiftScale); - leftStart = leftStart + breakWidth; - isFill = !isFill; - } - g.setColor(this.getForeground()); - g.drawString(_unitText, leftStart - breakWidth + (fontHeight / 2), fontHeight * 1.1f + yShift * _yShiftScale); - } - - @Override - public void moveUpdate() { - } - - @Override - public void resizeUpdate() { - } - // -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartText.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartText.java deleted file mode 100644 index 03151a78..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartText.java +++ /dev/null @@ -1,740 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.Stroke; -import java.awt.geom.AffineTransform; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import org.meteoinfo.chart.plot.XAlign; -import org.meteoinfo.chart.plot.YAlign; -import org.meteoinfo.common.Extent; -import org.meteoinfo.chart.drawing.Draw; -import org.locationtech.jts.geom.Geometry; -import org.locationtech.jts.geom.GeometryFactory; -import org.meteoinfo.geometry.shape.Shape; -import org.meteoinfo.geometry.shape.ShapeTypes; - -/** - * - * @author yaqiang - */ -public class ChartText extends Shape { - - // - protected double x; - protected double y; - private Font font; - private List text; - private Color color; - private int lineSpace; - private CoordinateType coordinates; - private Color background; - private boolean drawBackground; - private boolean drawNeatline; - private Color neatLineColor; - private float neatLineSize; - private float gap; - protected float angle; - private XAlign xAlign; - private YAlign yAlign; - private boolean useExternalFont; - protected double xShift; - protected double yShift; - - // - // - /** - * Constructor - */ - public ChartText() { - font = new Font("Arial", Font.PLAIN, 14); - color = Color.black; - lineSpace = 5; - coordinates = CoordinateType.DATA; - this.background = Color.white; - this.drawBackground = false; - this.drawNeatline = false; - this.neatLineColor = Color.black; - this.neatLineSize = 1.0f; - this.gap = 3.0f; - this.angle = 0.0f; - this.xAlign = XAlign.LEFT; - this.yAlign = YAlign.BOTTOM; - this.useExternalFont = false; - this.xShift = 0; - this.yShift = 0; - } - - /** - * Constructor - * - * @param text Text - */ - public ChartText(String text) { - this(); - this.text = new ArrayList<>(); - String[] lines = text.split("\n"); - this.text.addAll(Arrays.asList(lines)); - } - - /** - * Constructor - * - * @param text Text - */ - public ChartText(List text) { - this(); - this.text = text; - } - - /** - * Constructor - * - * @param text Text - * @param font Font - */ - public ChartText(String text, Font font) { - this(); - this.text = new ArrayList<>(); - String[] lines = text.split("\n"); - this.text.addAll(Arrays.asList(lines)); - this.font = font; - } - - /** - * Constructor - * - * @param text Text - * @param font Font - */ - public ChartText(List text, Font font) { - this(); - this.text = text; - this.font = font; - } - // - // - - /** - * Get text - * - * @return Text - */ - public String getText() { - return text.get(0); - } - - /** - * Set text - * - * @param value Text - */ - public void setText(String value) { - text = new ArrayList<>(); - String[] lines = value.split("\n"); - this.text.addAll(Arrays.asList(lines)); - } - - /** - * Get texts - * - * @return Text list - */ - public List getTexts() { - return text; - } - - /** - * Set texts - * - * @param value Text list - */ - public void setTexts(List value) { - text = value; - } - - /** - * Get font - * - * @return Font - */ - public Font getFont() { - return font; - } - - /** - * Set font - * - * @param value Font - */ - public void setFont(Font value) { - font = value; - } - - /** - * Get title color - * - * @return Title color - */ - public Color getColor() { - return color; - } - - /** - * Set title color - * - * @param value Title color - */ - public void setColor(Color value) { - this.color = value; - } - - /** - * Get x - * - * @return X - */ - public double getX() { - return this.x; - } - - /** - * Set x - * - * @param value X - */ - public void setX(double value) { - this.x = value; - } - - /** - * Get y - * - * @return Y - */ - public double getY() { - return this.y; - } - - /** - * Set y - * - * @param value Y - */ - public void setY(double value) { - this.y = value; - } - - /** - * Get line space - * - * @return Line space - */ - public int getLineSpace() { - return this.lineSpace; - } - - /** - * Set line space - * - * @param value Line space - */ - public void setLineSpace(int value) { - this.lineSpace = value; - } - - /** - * Get coordinates - * - * @return Coordinates - */ - public CoordinateType getCoordinates() { - return this.coordinates; - } - - /** - * Set coordinates - * - * @param value Coordinates - */ - public void setCoordinates(CoordinateType value) { - this.coordinates = value; - } - - /** - * Set coordinates - * - * @param value Coordinates - */ - public void setCoordinates(String value) { - switch (value) { - case "axes": - this.coordinates = CoordinateType.AXES; - break; - case "figure": - this.coordinates = CoordinateType.FIGURE; - break; - case "data": - this.coordinates = CoordinateType.DATA; - break; - case "inches": - this.coordinates = CoordinateType.INCHES; - break; - } - } - - /** - * Get background color - * - * @return Background color - */ - public Color getBackground() { - return this.background; - } - - /** - * Set background color - * - * @param value Background color - */ - public void setBackground(Color value) { - this.background = value; - } - - /** - * Get if is fill background - * - * @return Boolean - */ - public boolean isFill() { - return this.drawBackground; - } - - /** - * Set fill background or not - * - * @param value Boolean - */ - public void setFill(boolean value) { - this.drawBackground = value; - } - - /** - * Get draw neatline or not - * - * @return Boolean - */ - public boolean isDrawNeatline() { - return this.drawNeatline; - } - - /** - * Set draw neatline or not - * - * @param value Boolean - */ - public void setDrawNeatline(boolean value) { - this.drawNeatline = value; - } - - /** - * Get neatline color - * - * @return Neatline color - */ - public Color getNeatlineColor() { - return this.neatLineColor; - } - - /** - * Set neatline color - * - * @param value Neatline color - */ - public void setNeatlineColor(Color value) { - this.neatLineColor = value; - } - - /** - * Get neatline size - * - * @return Neatline size - */ - public float getNeatlineSize() { - return this.neatLineSize; - } - - /** - * Set neatline size - * - * @param value Neatline size - */ - public void setNeatlineSize(float value) { - this.neatLineSize = value; - } - - /** - * Get gap - * - * @return Gap - */ - public float getGap() { - return this.gap; - } - - /** - * Set gap - * - * @param value Gap - */ - public void setGap(float value) { - this.gap = value; - } - - /** - * Get angle - * - * @return Angle - */ - public float getAngle() { - return this.angle; - } - - /** - * Set angle - * - * @param value Angle - */ - public void setAngle(float value) { - this.angle = value; - } - - /** - * Get x align - * - * @return X align - */ - public XAlign getXAlign() { - return this.xAlign; - } - - /** - * Set x align - * - * @param value X align - */ - public void setXAlign(XAlign value) { - this.xAlign = value; - } - - /** - * Set x align - * - * @param value X align string - */ - public void setXAlign(String value) { - this.xAlign = XAlign.valueOf(value.toUpperCase()); - } - - /** - * Get y align - * - * @return Y align - */ - public YAlign getYAlign() { - return this.yAlign; - } - - /** - * Set y align - * - * @param value Y align - */ - public void setYAlign(YAlign value) { - this.yAlign = value; - } - - /** - * Set y align - * - * @param value Y align string - */ - public void setYAlign(String value) { - this.yAlign = YAlign.valueOf(value.toUpperCase()); - } - - /** - * Get if use external font - only for LaTeX string - * - * @return Boolean - */ - public boolean isUseExternalFont() { - return this.useExternalFont; - } - - /** - * Set if use external font - only for LaTeX string - * - * @param value Boolean - */ - public void setUseExternalFont(boolean value) { - this.useExternalFont = value; - } - - /** - * Get x shift - * @return X shift - */ - public double getXShift() { - return this.xShift; - } - - /** - * Set x shift - * @param value X shift - */ - public void setXShift(double value) { - this.xShift = value; - } - - /** - * Get y shift - * @return Y shift - */ - public double getYShift() { - return this.yShift; - } - - /** - * Set y shift - * @param value Y shift - */ - public void setYShift(double value) { - this.yShift = value; - } - - // - // - /** - * Add text in new line - * - * @param value The text string - */ - public void addText(String value) { - this.text.add(value); - } - - @Override - public ShapeTypes getShapeType() { - return ShapeTypes.TEXT; - } - - /** - * Get text line number - * - * @return Text line number - */ - public int getLineNum() { - return this.text.size(); - } - - /** - * Get text dimension with angle - * - * @param g Graphics2D - * @return Dimension - */ - public Dimension getTrueDimension(Graphics2D g) { - Dimension dim = getDimension(g); - if (this.angle != 0) { - int width = dim.width; - int height = dim.height; - int temp; - if (angle == 90 || angle == -90) { - temp = width; - width = height; - height = temp; - } else { - width = (int) ((width * Math.cos(Math.toRadians(angle))) + (height * Math.sin(Math.toRadians(angle)))); - height = (int) ((width * Math.sin(Math.toRadians(angle))) + (height * Math.cos(Math.toRadians(angle)))); - } - return new Dimension(width, height); - } else { - return dim; - } - } - - /** - * Get text dimension - * - * @param g Graphics2D - * @return Dimension - */ - public Dimension getDimension(Graphics2D g) { - g.setFont(font); - int width = 0, height = 0; - for (String line : this.text) { - Dimension dim = Draw.getStringDimension(line, g); - if (width < dim.width) { - width = dim.width; - } - height += dim.height + this.lineSpace; - } - height -= this.lineSpace; - - return new Dimension(width, height); - } - - /** - * To geometry method - * - * @param factory GeometryFactory - * @return Geometry - */ - @Override - public Geometry toGeometry(GeometryFactory factory) { - return null; - } - - /** - * Set point - * - * @param x X - * @param y Y - */ - public void setPoint(double x, double y) { - this.x = x; - this.y = y; - Extent aExtent = new Extent(); - aExtent.minX = x; - aExtent.maxX = x; - aExtent.minY = y; - aExtent.maxY = y; - this.setExtent(aExtent); - } - - /** - * To string - * - * @return String - */ - @Override - public String toString() { - if (this.text.size() == 1) { - return this.text.get(0); - } else { - String r = ""; - for (int i = 0; i < this.text.size(); i++) { - if (i == 0) { - r = this.text.get(i); - } else { - r = r + "\n" + this.text.get(i); - } - } - return r; - } - } - - /** - * Draw text - * - * @param g Graphics2D - * @param x X - * @param y Y - */ - public void draw(Graphics2D g, float x, float y) { - Dimension dim = this.getDimension(g); - x += this.xShift; - y += this.yShift; - - AffineTransform tempTrans = g.getTransform(); - if (this.angle != 0) { - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform) tempTrans.clone(); - myTrans.translate(x, y); - //myTrans.translate(tempTrans.getTranslateX() + x, tempTrans.getTranslateY() + y); - myTrans.rotate(-angle * Math.PI / 180); - g.setTransform(myTrans); - x = 0; - y = 0; - } - - Rectangle.Double rect = new Rectangle.Double(x, y - dim.getHeight(), dim.getWidth(), dim.getHeight()); - rect.setRect(rect.x - gap, rect.y - gap, rect.width + gap * 2, - rect.height + gap * 2); - if (this.drawBackground) { - g.setColor(this.background); - g.fill(rect); - } - if (this.drawNeatline) { - g.setColor(this.neatLineColor); - Stroke oldStroke = g.getStroke(); - g.setStroke(new BasicStroke(neatLineSize)); - g.draw(rect); - g.setStroke(oldStroke); - } - - g.setColor(this.color); - g.setFont(font); - switch (this.yAlign) { - case BOTTOM: - y = y - dim.height; - break; - case CENTER: - y = y - dim.height * 0.5f; - break; - } - - for (String str : this.text) { - dim = Draw.getStringDimension(str, g); - Draw.drawString(g, x, y, str, xAlign, YAlign.TOP, useExternalFont); - y += dim.height; - y += this.lineSpace; - } - - if (this.angle != 0) { - g.setTransform(tempTrans); - } - } - - /** - * Clone - * - * @return Cloned object - */ - @Override - public Object clone() { - ChartText ct = new ChartText(); - ct.angle = this.angle; - ct.background = this.background; - ct.color = this.color; - ct.coordinates = this.coordinates; - ct.drawBackground = this.drawBackground; - ct.drawNeatline = this.drawNeatline; - ct.font = this.font; - ct.gap = this.gap; - ct.lineSpace = this.lineSpace; - ct.neatLineColor = this.neatLineColor; - ct.neatLineSize = this.neatLineSize; - ct.text = this.text; - ct.useExternalFont = this.useExternalFont; - ct.x = this.x; - ct.xAlign = this.xAlign; - ct.y = this.y; - ct.yAlign = this.yAlign; - - return ct; - } - // -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartText3D.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartText3D.java deleted file mode 100644 index 9f1bdd42..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartText3D.java +++ /dev/null @@ -1,127 +0,0 @@ -/* 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.chart; - -import java.awt.Point; -import org.meteoinfo.chart.plot3d.Projector; -import org.meteoinfo.common.Extent3D; -import org.meteoinfo.data.DataMath; -import org.meteoinfo.shape.PointZ; - -/** - * - * @author Yaqiang Wang - * yaqiang.wang@gmail.com - */ -public class ChartText3D extends ChartText { - private double z; - private PointZ zdir = null; - - /** - * Get z coordinate value - * @return Z coordinate value - */ - public double getZ(){ - return this.z; - } - - /** - * Set z coordinate value - * @param value Z coordinate value - */ - public void setZ(double value){ - this.z = value; - } - - /** - * Get zdir point - * @return ZDir point - */ - public PointZ getZDir(){ - return zdir; - } - - /** - * Set zdir point - * @param value ZDir point - */ - public void setZDir(PointZ value){ - this.zdir = value; - } - - /** - * Set zdir point - * @param x X coordinate value - * @param y Y coordinate value - * @param z Z coordinate value - */ - public void setZDir(float x, float y, float z){ - if (x == 0 && y == 0 && z == 0) - this.zdir = null; - else - this.zdir = new PointZ(x, y, z); - } - - /** - * Set zdir point - * @param value ZDir point - */ - public void setZDir(String value){ - float x1 = 0, y1 = 0, z1 = 0; - switch(value.toLowerCase()){ - case "x": - x1 = 1; - break; - case "y": - y1 = 1; - break; - case "z": - z1 = 1; - break; - } - this.setZDir(x1, y1, z1); - } - - /** - * Set point - * - * @param x X - * @param y Y - * @param z Z - */ - public void setPoint(double x, double y, double z) { - this.x = x; - this.y = y; - this.z = z; - Extent3D aExtent = new Extent3D(); - aExtent.minX = x; - aExtent.maxX = x; - aExtent.minY = y; - aExtent.maxY = y; - aExtent.minZ = z; - aExtent.maxZ = z; - this.setExtent(aExtent); - } - - /** - * Update angle - * @param projector Projector - */ - public void updateAngle(Projector projector){ - if (this.zdir == null) - return; - - Point p0 = projector.project(0, 0, 0); - 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); - this.angle = (float)value[0]; - } -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartWindArrow.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartWindArrow.java deleted file mode 100644 index bb279fcc..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartWindArrow.java +++ /dev/null @@ -1,391 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Graphics2D; -import java.awt.RenderingHints; -import java.awt.geom.Rectangle2D; - -import org.meteoinfo.common.PointF; -import org.meteoinfo.drawing.Draw; -import org.meteoinfo.global.DataConvert; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.legend.ArrowBreak; -import org.meteoinfo.shape.GraphicCollection; -import org.meteoinfo.shape.WindArrow; - -/** - * - * @author Yaqiang Wang - */ -public class ChartWindArrow { - - // - private final WindArrow windArrow; - private ArrowBreak arrowBreak; - private Font font; - //private Color color; - private Color labelColor; - private float x; - private float y; - private String label; - private int labelSep; - private Object layer; - private Color background; - private boolean drawBackground; - private boolean drawNeatline; - private Color neatLineColor; - private float neatLineSize; - - // - // - /** - * Constructor - */ - public ChartWindArrow() { - this.windArrow = new WindArrow(); - this.windArrow.angle = 270; - this.windArrow.length = 20; - this.arrowBreak = new ArrowBreak(); - this.font = new Font("Arial", Font.PLAIN, 12); - //this.color = Color.black; - this.labelColor = Color.black; - this.labelSep = 5; - this.background = Color.white; - this.drawBackground = false; - this.drawNeatline = false; - this.neatLineColor = Color.black; - this.neatLineSize = 1.0f; - } - - // - // - /** - * Get wind arrow - * - * @return Wind arrow - */ - public WindArrow getWindArrow() { - return this.windArrow; - } - - /** - * Get arrow break - * @return Arrow break - */ - public ArrowBreak getArrowBreak() { - return this.arrowBreak; - } - - /** - * Set arrow break - * @param value Arrow break - */ - public void setArrowBreak(ArrowBreak value) { - this.arrowBreak = value; - } - - /** - * Get length - * - * @return Length - */ - public float getLength() { - return this.windArrow.length; - } - - /** - * Set length - * - * @param value Length - */ - public void setLength(float value) { - this.windArrow.length = value; - this.label = String.valueOf(value); - this.label = DataConvert.removeTailingZeros(this.label); - } - - /** - * Get angle - * - * @return Angle - */ - public double getAngle() { - return this.windArrow.angle; - } - - /** - * Set angle - * - * @param value Angle - */ - public void setAngle(double value) { - this.windArrow.angle = value; - } - - /** - * Get layer - * - * @return Layer - */ - public Object getLayer() { - return this.layer; - } - - /** - * Set layer - * - * @param value Layer - */ - public void setLayer(Object value) { - this.layer = value; - } - - /** - * Get font - * - * @return Font - */ - public Font getFont() { - return font; - } - - /** - * Set font - * - * @param value Font - */ - public void setFont(Font value) { - font = value; - } - - /** - * Get label color - * - * @return Label color - */ - public Color getLabelColor() { - return this.labelColor; - } - - /** - * Set label color - * - * @param value Label color - */ - public void setLabelColor(Color value) { - this.labelColor = value; - } - - /** - * Get the distance between arrow and label - * @return Distance between arrow and label - */ - public int getLabelSep(){ - return this.labelSep; - } - - /** - * Set the distance between arrow and label - * @param value Distance between arrow and label - */ - public void setLabelSep(int value) { - this.labelSep = value; - } - - /** - * Get x - * - * @return X - */ - public float getX() { - return this.x; - } - - /** - * Set x - * - * @param value X - */ - public void setX(float value) { - this.x = value; - } - - /** - * Get y - * - * @return Y - */ - public float getY() { - return this.y; - } - - /** - * Set y - * - * @param value Y - */ - public void setY(float value) { - this.y = value; - } - - /** - * Get label - * - * @return Label - */ - public String getLabel() { - return this.label; - } - - /** - * Set label - * - * @param value Label - */ - public void setLabel(String value) { - this.label = value; - } - - /** - * Get background color - * - * @return Background color - */ - public Color getBackground() { - return this.background; - } - - /** - * Set background color - * - * @param value Background color - */ - public void setBackground(Color value) { - this.background = value; - } - - /** - * Get if is fill background - * - * @return Boolean - */ - public boolean isFill() { - return this.drawBackground; - } - - /** - * Set fill background or not - * - * @param value Boolean - */ - public void setFill(boolean value) { - this.drawBackground = value; - } - - /** - * Get draw neatline or not - * - * @return Boolean - */ - public boolean isDrawNeatline() { - return this.drawNeatline; - } - - /** - * Set draw neatline or not - * - * @param value Boolean - */ - public void setDrawNeatline(boolean value) { - this.drawNeatline = value; - } - - /** - * Get neatline color - * - * @return Neatline color - */ - public Color getNeatlineColor() { - return this.neatLineColor; - } - - /** - * Set neatline color - * - * @param value Neatline color - */ - public void setNeatlineColor(Color value) { - this.neatLineColor = value; - } - - /** - * Get neatline size - * - * @return Neatline size - */ - public float getNeatlineSize() { - return this.neatLineSize; - } - - /** - * Set neatline size - * - * @param value Neatline size - */ - public void setNeatlineSize(float value) { - this.neatLineSize = value; - } - - // - // - /** - * Draw text - * - * @param g Graphics2D - * @param x X - * @param y Y - */ - public void draw(Graphics2D g, float x, float y) { - Object rendering = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING); - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - float zoom = 1.0f; - if (this.layer != null) { - if (this.layer instanceof VectorLayer) { - zoom = ((VectorLayer) this.layer).getDrawingZoom(); - } else if (this.layer instanceof GraphicCollection) { - zoom = ((GraphicCollection) this.layer).getArrowZoom(); - } - } - g.setFont(this.font); - //String drawStr = this.label wa.getLabel(); - Dimension dim = Draw.getStringDimension(this.label, g); - if (this.drawBackground || this.drawNeatline) { - Rectangle2D rect = Draw.getArrawBorder(new PointF(x, y), this.windArrow, g, zoom); - double gap = 5; - double width = Math.max(rect.getWidth(), dim.getWidth()); - rect.setRect(rect.getX() - gap, rect.getY() - gap - 2, width + gap * 2, - rect.getHeight() + dim.height + this.labelSep + gap + 2); - if (this.drawBackground) { - g.setColor(this.background); - g.fill(rect); - } - if (this.drawNeatline) { - 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); - g.setColor(this.labelColor); - Draw.drawString(g, this.label, x, y + dim.height + this.labelSep); - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, rendering); - } - // -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/CoordinateType.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/CoordinateType.java deleted file mode 100644 index 99ee5c46..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/CoordinateType.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -/** - * - * @author Yaqiang Wang - */ -public enum CoordinateType { - AXES, - FIGURE, - DATA, - INCHES -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/IChartPanel.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/IChartPanel.java deleted file mode 100644 index 5e786ab0..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/IChartPanel.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -/** - * - * @author yaqiang - */ -public interface IChartPanel { - /** - * Save image - * @param fn Image file name - */ - public abstract void saveImage(String fn); - - /** - * Set mouse mode - * @param value Mouse mode - */ - public abstract void setMouseMode(MouseMode value); - - /** - * Zoom back to full extent - */ - public abstract void onUndoZoomClick(); - - /** - * Paint graphics - */ - public abstract void paintGraphics(); -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/IPointSelectedListener.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/IPointSelectedListener.java deleted file mode 100644 index b4bd5c4a..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/IPointSelectedListener.java +++ /dev/null @@ -1,24 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.chart; - -import java.util.EventListener; - - /** - * - * @author yaqiang - */ - public interface IPointSelectedListener extends EventListener { - public void pointSelectedEvent(PointSelectedEvent event); - } diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/LegendPosition.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/LegendPosition.java deleted file mode 100644 index 8257f958..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/LegendPosition.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -/** - * - * @author yaqiang - */ -public enum LegendPosition { - UPPER_RIGHT, - UPPER_LEFT, - UPPER_CENTER, - LOWER_LEFT, - LOWER_RIGHT, - LOWER_CENTER, - RIGHT, - CENTER_LEFT, - CENTER_RIGHT, - CENTER, - LEFT, - UPPER_RIGHT_OUTSIDE, - UPPER_LEFT_OUTSIDE, - UPPER_CENTER_OUTSIDE, - LOWER_LEFT_OUTSIDE, - LOWER_RIGHT_OUTSIDE, - LOWER_CENTER_OUTSIDE, - LEFT_OUTSIDE, - RIGHT_OUTSIDE, - CUSTOM; - - /** - * If the position is custom - * @return Boolean - */ - public boolean isCustom(){ - switch (this){ - case CUSTOM: - return true; - default: - return false; - } - } - - /** - * Get LegendPostion from string - * @param loc Location string - * @return LegenPosition - */ - public static LegendPosition fromString(String loc){ - LegendPosition lp = LegendPosition.UPPER_RIGHT; - loc = loc.toLowerCase(); - switch (loc){ - case "upper left": - lp = LegendPosition.UPPER_LEFT; - break; - case "upper right": - lp = LegendPosition.UPPER_RIGHT; - break; - case "upper center": - lp = LegendPosition.UPPER_CENTER; - break; - case "upper center outside": - lp = LegendPosition.UPPER_CENTER_OUTSIDE; - break; - case "lower left": - lp = LegendPosition.LOWER_LEFT; - break; - case "lower right": - lp = LegendPosition.LOWER_RIGHT; - break; - case "lower center": - lp = LegendPosition.LOWER_CENTER; - break; - case "lower center outside": - lp = LegendPosition.LOWER_CENTER_OUTSIDE; - break; - case "left": - lp = LegendPosition.LEFT; - break; - case "left outside": - lp = LegendPosition.LEFT_OUTSIDE; - break; - case "right": - lp = LegendPosition.RIGHT; - break; - case "right outside": - lp = LegendPosition.RIGHT_OUTSIDE; - break; - case "custom": - lp = LegendPosition.CUSTOM; - break; - } - - return lp; - } -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/Location.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/Location.java deleted file mode 100644 index 5187ee5f..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/Location.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -/** - * - * @author yaqiang - */ -public enum Location { - LEFT, - RIGHT, - TOP, - BOTTOM -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/Margin.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/Margin.java deleted file mode 100644 index ab51f796..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/Margin.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -import java.awt.geom.Rectangle2D; - -/** - * - * @author wyq - */ -public class Margin { - // - private double left; - private double right; - private double top; - private double bottom; - // - // - /** - * Constructor - */ - public Margin(){ - - } - - /** - * Constructor - * @param left Left - * @param right Right - * @param top Top - * @param bottom Bottom - */ - public Margin(double left, double right, double top, double bottom){ - this.left = left; - this.right = right; - this.top = top; - this.bottom = bottom; - } - // - // - /** - * Get left - * @return Left - */ - public double getLeft(){ - return this.left; - } - - /** - * Set left - * @param value Left - */ - public void setLeft(double value){ - this.left = value; - } - - /** - * Get right - * @return Right - */ - public double getRight(){ - return this.right; - } - - /** - * Set right - * @param value Right - */ - public void setRight(double value){ - this.right = value; - } - - /** - * Get top - * @return Top - */ - public double getTop(){ - return this.top; - } - - /** - * Set top - * @param value Top - */ - public void setTop(double value){ - this.top = value; - } - - /** - * Get bottom - * @return Bottom - */ - public double getBottom(){ - return this.bottom; - } - - /** - * Set bottom - * @param value Bottom - */ - public void setBottom(double value){ - this.bottom = value; - } - // - // - /** - * Get margin area - * @param inArea Inside area - * @return Margin area - */ - public Rectangle2D getArea(Rectangle2D inArea){ - double x = inArea.getX() - this.left; - double y = inArea.getY() - this.top; - double w = inArea.getWidth() + this.left + this.right; - double h = inArea.getHeight() + this.top + this.bottom; - - return new Rectangle2D.Double(x, y, w, h); - } - - /** - * Extent - * @param a Margin - * @return Extented margin - */ - public Margin extend(Margin a){ - Margin r = new Margin(); - r.setLeft(Math.max(this.left, a.left)); - r.setRight(Math.max(this.right, a.right)); - r.setTop(Math.max(this.top, a.top)); - r.setBottom(Math.max(this.bottom, a.bottom)); - - return r; - } - // -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/MouseMode.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/MouseMode.java deleted file mode 100644 index baf59dbd..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/MouseMode.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart; - -/** - * - * @author yaqiang - */ -public enum MouseMode { - DEFAULT, - ZOOM_IN, - ZOOM_OUT, - SELECT, - PAN, - IDENTIFER, - ROTATE -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/NorthArrowType.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/NorthArrowType.java deleted file mode 100644 index 7eaf5236..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/NorthArrowType.java +++ /dev/null @@ -1,30 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.chart; - -/** - * North arrow types - * - * @author Yaqiang Wang - */ -public enum NorthArrowType { - /// - /// North arrow 1 - /// - NORTHARROW_1, - /// - /// North arrow 2 - /// - NORTHARROW_2, -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/PointSelectedEvent.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/PointSelectedEvent.java deleted file mode 100644 index 38628745..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/PointSelectedEvent.java +++ /dev/null @@ -1,31 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.chart; - -import java.util.EventObject; - - /** - * Size changed event - * - * @author Yaqiang Wang - */ - public class PointSelectedEvent extends EventObject { - /** - * Constructor - * @param source Source object - */ - public PointSelectedEvent(Object source){ - super(source); - } - } diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/axis/Axis.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/axis/Axis.java index 62f1fc0e..bd90c3bb 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/axis/Axis.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/axis/Axis.java @@ -8,13 +8,13 @@ package org.meteoinfo.chart.axis; import org.meteoinfo.chart.ChartText; import org.meteoinfo.chart.Location; import org.meteoinfo.chart.plot.AbstractPlot2D; -import org.meteoinfo.chart.plot.XAlign; -import org.meteoinfo.chart.plot.YAlign; +import org.meteoinfo.common.DataConvert; import org.meteoinfo.common.MIMath; +import org.meteoinfo.common.XAlign; +import org.meteoinfo.common.YAlign; import org.meteoinfo.common.util.JDateUtil; -import org.meteoinfo.drawing.Draw; -import org.meteoinfo.global.DataConvert; -import org.meteoinfo.legend.LineStyles; +import org.meteoinfo.geo.drawing.Draw; +import org.meteoinfo.geometry.legend.LineStyles; import org.meteoinfo.ndarray.util.BigDecimalUtil; import java.awt.*; diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/axis/LogAxis.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/axis/LogAxis.java index de9d11a4..8ce84053 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/axis/LogAxis.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/axis/LogAxis.java @@ -6,8 +6,8 @@ package org.meteoinfo.chart.axis; import org.meteoinfo.chart.ChartText; +import org.meteoinfo.common.DataConvert; import org.meteoinfo.common.MIMath; -import org.meteoinfo.global.DataConvert; import java.util.ArrayList; import java.util.List; diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/axis/ProjLonLatAxis.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/axis/ProjLonLatAxis.java index d1638eb5..e74f6160 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/axis/ProjLonLatAxis.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/axis/ProjLonLatAxis.java @@ -6,11 +6,11 @@ package org.meteoinfo.chart.axis; import org.meteoinfo.chart.ChartText; +import org.meteoinfo.common.DataConvert; import org.meteoinfo.common.MIMath; -import org.meteoinfo.global.DataConvert; import org.meteoinfo.projection.KnownCoordinateSystems; +import org.meteoinfo.projection.ProjectionInfo; import org.meteoinfo.projection.Reproject; -import org.meteoinfo.projection.info.ProjectionInfo; import java.util.ArrayList; import java.util.List; diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/drawing/Draw.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/drawing/Draw.java deleted file mode 100644 index c41f25b6..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/drawing/Draw.java +++ /dev/null @@ -1,4587 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.chart.drawing; - -import org.meteoinfo.common.Extent; -import org.meteoinfo.common.MIMath; -import org.meteoinfo.common.PointD; -import org.meteoinfo.common.PointF; -import org.meteoinfo.chart.legend.MarkerType; -import org.meteoinfo.chart.legend.PointStyle; -import org.meteoinfo.geometry.geoprocess.Spline; -import org.meteoinfo.common.colors.ColorUtil; -import org.meteoinfo.chart.legend.BreakTypes; -import org.meteoinfo.chart.legend.ChartBreak; -import org.meteoinfo.chart.legend.LabelBreak; -import org.meteoinfo.chart.legend.LineStyles; -import org.meteoinfo.chart.legend.PointBreak; -import org.meteoinfo.chart.legend.PolygonBreak; -import org.meteoinfo.chart.legend.PolylineBreak; -import org.meteoinfo.chart.graphic.Graphic; -import org.meteoinfo.geometry.shape.Polyline; -import org.meteoinfo.geometry.shape.WindArrow; -import org.meteoinfo.geometry.shape.WindBarb; -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.Insets; -import java.awt.Rectangle; -import java.awt.RenderingHints; -import java.awt.TexturePaint; -import java.awt.geom.AffineTransform; -import java.awt.geom.Arc2D; -import java.awt.geom.Area; -import java.awt.geom.Ellipse2D; -import java.awt.geom.GeneralPath; -import java.awt.geom.Line2D; -import java.awt.geom.Rectangle2D; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.imageio.ImageIO; -import org.meteoinfo.chart.plot.XAlign; -import org.meteoinfo.chart.plot.YAlign; -import org.meteoinfo.chart.legend.ArrowBreak; -import org.meteoinfo.chart.legend.ArrowLineBreak; -import org.meteoinfo.chart.legend.ColorBreakCollection; -import org.meteoinfo.chart.legend.HatchStyle; -import org.meteoinfo.chart.legend.StreamlineBreak; -import org.meteoinfo.geometry.shape.EllipseShape; -import org.meteoinfo.geometry.shape.Polygon; -import org.meteoinfo.geometry.shape.PolygonShape; -import org.meteoinfo.geometry.shape.StationModelShape; -import org.scilab.forge.jlatexmath.TeXConstants; -import org.scilab.forge.jlatexmath.TeXFormula; -import org.scilab.forge.jlatexmath.TeXIcon; - -/** - * Draw class with some drawing methods - * - * @author Yaqiang Wang - */ -public class Draw { - - // -// /** -// * Determine if the string is a LaTeX string -// * -// * @param str String -// * @return Boolean -// */ -// public static boolean isLaTeX(String str) { -// if (str.length() < 2) { -// return false; -// } -// -// String str1 = str.substring(0, 1); -// String str2 = str.substring(str.length() - 1); -// return str1.equals("$") && str2.equals("$"); -// } - /** - * Get string type [NORMAL | LATEX | MIXING]. - * - * @param str The string - * @return String type - */ - public static StringType getStringType(String str) { - if (str.length() < 2 || !str.contains("$")) { - return StringType.NORMAL; - } - - if (str.contains("$")) { - int n = str.length() - str.replace("$", "").length(); - int n1 = str.length() - str.replace("\\$", "").length(); - int n2 = n - n1; - if (n2 < 2) { - return StringType.NORMAL; - } else if (n2 == 2) { - if (str.startsWith("$") && str.endsWith("$") && !str.endsWith("\\$")) { - return StringType.LATEX; - } else { - return StringType.MIXING; - } - } else { - return StringType.MIXING; - } - } else { - return StringType.NORMAL; - } - } - - /** - * Split mixing string by $ - * - * @param str The mixing string - * @return String list - */ - public static List splitMixingString(String str) { - List strs = new ArrayList<>(); - StringBuilder sb = new StringBuilder(); - for (char c : str.toCharArray()) { - if (c == '$') { - if (sb.length() == 0) { - sb.append(c); - } else { - if (sb.substring(sb.length() - 1).equals("\\")) { - sb.append(c); - } else { - if (sb.substring(0, 1).equals("$")) { - sb.append(c); - strs.add(sb.toString()); - sb = new StringBuilder(); - } else { - strs.add(sb.toString()); - sb = new StringBuilder(); - sb.append(c); - } - } - } - } else { - sb.append(c); - } - } - if (sb.length() > 0) { - strs.add(sb.toString()); - } - - return strs; - } - - /** - * Get string dimension - * - * @param str String - * @param g Graphics2D - * @param isLaTeX Is LaTeX or not - * @return String dimension - */ - public static Dimension getStringDimension(String str, Graphics2D g, boolean isLaTeX) { - if (isLaTeX) { - float size = g.getFont().getSize2D(); - // create a formula - TeXFormula formula = new TeXFormula(str); - - // render the formla to an icon of the same size as the formula. - TeXIcon icon = formula.createTeXIcon(TeXConstants.STYLE_TEXT, size); - - // insert a border - //icon.setInsets(new Insets(5, 5, 5, 5)); - //return new Dimension(icon.getIconWidth(), icon.getIconHeight()); - int width = (int) icon.getTrueIconWidth() + 10; - int height = (int) icon.getTrueIconHeight(); - //int height = icon.getIconHeight(); - return new Dimension(width, height); - } else { - FontMetrics metrics = g.getFontMetrics(); - //int height = (int) (metrics.getAscent() * 5.f / 6.f); - int height = metrics.getAscent(); - //return new Dimension(metrics.stringWidth(str), metrics.getHeight()); - return new Dimension(metrics.stringWidth(str), height); - } - } - - /** - * Get string dimension - * - * @param str String - * @param angle Angle - * @param g Graphics2D - * @param isLaTeX Is LaTeX or not - * @return String dimension - */ - public static Dimension getStringDimension(String str, float angle, Graphics2D g, boolean isLaTeX) { - float width, height; - if (isLaTeX) { - float size = g.getFont().getSize2D(); - // create a formula - TeXFormula formula = new TeXFormula(str); - - // render the formla to an icon of the same size as the formula. - TeXIcon icon = formula.createTeXIcon(TeXConstants.STYLE_TEXT, size); - - // insert a border - //icon.setInsets(new Insets(5, 5, 5, 5)); - //return new Dimension(icon.getIconWidth(), icon.getIconHeight()); - width = (int) icon.getTrueIconWidth() + 10; - height = (int) icon.getTrueIconHeight(); - //height = icon.getIconHeight(); - } else { - FontMetrics metrics = g.getFontMetrics(); - width = metrics.stringWidth(str); - height = metrics.getAscent(); - } - float temp; - if (angle == 90 || angle == -90) { - temp = width; - width = height; - height = temp; - } else { - width = (float) (width * Math.cos(Math.toRadians(angle))) + (float) (height * Math.sin(Math.toRadians(angle))); - height = (float) (width * Math.sin(Math.toRadians(angle))) + (float) (height * Math.cos(Math.toRadians(angle))); - } - return new Dimension((int) width, (int) height); - } - - /** - * Get string dimension - * - * @param str String - * @param g Graphics2D - * @return String dimension - */ - public static Dimension getStringDimension(String str, Graphics2D g) { - AffineTransform at = g.getTransform(); - if (at.getShearX() != 0 || at.getShearY() != 0) { - g.setTransform(new AffineTransform()); - } - Dimension dim; - switch (getStringType(str)) { - case LATEX: - dim = getStringDimension(str, g, true); - break; - case MIXING: - List strs = splitMixingString(str); - dim = new Dimension(0, 0); - for (String s : strs) { - Dimension dim1 = getStringDimension(s, g, s.startsWith("$") && s.endsWith("$")); - dim.setSize(dim.getWidth() + dim1.getWidth(), Math.max(dim.getHeight(), dim1.getHeight())); - } - break; - default: - dim = getStringDimension(str, g, false); - break; - } - if (at.getShearX() != 0 || at.getShearY() != 0) { - g.setTransform(at); - } - return dim; - } - - /** - * Get string dimension - * - * @param str String - * @param angle Angle - * @param g Graphics2D - * @return String dimension - */ - public static Dimension getStringDimension(String str, float angle, Graphics2D g) { - if (angle == 0) { - return getStringDimension(str, g); - } else { - switch (getStringType(str)) { - case LATEX: - return getStringDimension(str, angle, g, true); - case MIXING: - List strs = splitMixingString(str); - Dimension dim = new Dimension(0, 0); - for (String s : strs) { - Dimension dim1 = getStringDimension(s, angle, g, s.startsWith("$") && s.endsWith("$")); - dim.setSize(dim.getWidth() + dim1.getWidth(), Math.max(dim.getHeight(), dim1.getHeight())); - } - return dim; - default: - return getStringDimension(str, angle, g, false); - } - } - } - - /** - * Draw string - * - * @param g Graphics2D - * @param str String - * @param x X - * @param y Y - */ - public static void drawString(Graphics2D g, String str, float x, float y) { - drawString(g, str, x, y, true); - } - - /** - * Draw string - * - * @param g Graphics2D - * @param str String - * @param x X - * @param y Y - */ - public static void drawString(Graphics2D g, String str, double x, double y) { - drawString(g, str, x, y, true); - } - - /** - * Draw string - * - * @param g Graphics2D - * @param str String - * @param x X - * @param y Y - * @param useExternalFont If use external font - */ - public static void drawString(Graphics2D g, String str, float x, float y, boolean useExternalFont) { - switch (getStringType(str)) { - case LATEX: - drawLaTeX(g, str, x, y, useExternalFont); - break; - case MIXING: - List strs = splitMixingString(str); - Dimension dim; - for (String s : strs) { - if (s.startsWith("$") && s.endsWith("$")) { - drawLaTeX(g, s, x, y, useExternalFont); - dim = getStringDimension(s, g, true); - x += dim.width; - } else { - dim = getStringDimension(s, g, false); - g.drawString(s, x, y - (float) (dim.getHeight() * 0.2)); - x += dim.width - 5; - } - } - break; - default: - FontMetrics fm = g.getFontMetrics(); - g.drawString(str, x, y - fm.getDescent()); - break; - } - } - - /** - * Draw string - * - * @param g Graphics2D - * @param str String - * @param x X - * @param y Y - * @param useExternalFont If use external font - */ - public static void drawString(Graphics2D g, String str, double x, double y, boolean useExternalFont) { - switch (getStringType(str)) { - case LATEX: - drawLaTeX(g, str, (float) x, (float) y, useExternalFont); - break; - case MIXING: - List strs = splitMixingString(str); - Dimension dim; - for (String s : strs) { - if (s.startsWith("$") && s.endsWith("$")) { - drawLaTeX(g, s, (float) x, (float) y, useExternalFont); - dim = getStringDimension(s, g, true); - x += dim.width; - } else { - dim = getStringDimension(s, g, false); - g.drawString(s, (float) x, (float) (y - dim.getHeight() * 0.2)); - x += dim.width - 5; - } - } - break; - default: - FontMetrics fm = g.getFontMetrics(); - g.drawString(str, (float) x, (float) (y - fm.getDescent())); - break; - } - } - -// /** -// * Draw string -// * -// * @param g Graphics2D -// * @param str String -// * @param x X -// * @param y Y -// * @param isLaTeX If is LaTeX -// */ -// public static void drawString(Graphics2D g, String str, float x, float y, boolean isLaTeX) { -// if (isLaTeX) { -// drawLaTeX(g, str, x, y); -// } else { -// g.drawString(str, x, y); -// } -// } - /** - * Draw LaTeX string - * - * @param g Graphics2D - * @param str String - * @param x X - * @param y Y - * @param useExternalFont If use external font - */ - public static void drawLaTeX(Graphics2D g, String str, float x, float y, boolean useExternalFont) { - float size = g.getFont().getSize2D(); - drawLaTeX(g, str, size, x, y, useExternalFont); - } - - /** - * Draw LaTeX string - * - * @param g Graphics2D - * @param str String - * @param size Size - * @param x X - * @param y Y - * @param useExternalFont If use external font - */ - public static void drawLaTeX(Graphics2D g, String str, float size, float x, float y, boolean useExternalFont) { - if (useExternalFont) { - //Set font - TeXFormula.registerExternalFont(Character.UnicodeBlock.BASIC_LATIN, g.getFont().getName()); - } else { - TeXFormula.registerExternalFont(Character.UnicodeBlock.BASIC_LATIN, null, null); - } - - // create a formula - TeXFormula formula = new TeXFormula(str); - - // render the formla to an icon of the same size as the formula. - TeXIcon icon = formula.createTeXIcon(TeXConstants.STYLE_TEXT, size); - - // insert a border - icon.setInsets(new Insets(5, 5, 5, 5)); - icon.setForeground(g.getColor()); - y = y - icon.getIconHeight() + (icon.getIconHeight() - icon.getTrueIconHeight()) * 0.6f; - //y = y - icon.getIconHeight() + size * 0.7f; - //y = y - icon.getTrueIconHeight() * 1.f; - Font font = g.getFont(); - icon.paintIcon(null, g, (int) x, (int) y); - g.setFont(font); - } - - // - // - /** - * Create wind barb from wind direction/speed - * - * @param windDir Wind direction - * @param windSpeed Wind speed - * @param value Value - * @param size Size - * @param sPoint Start point - * @return WindBarb - */ - public static WindBarb calWindBarb(float windDir, float windSpeed, double value, - float size, PointD sPoint) { - WindBarb aWB = new WindBarb(); - - windSpeed += 1; - aWB.windSpeed = windSpeed; - aWB.angle = windDir; - aWB.setValue(value); - aWB.size = size; - aWB.setPoint(sPoint); - aWB.windSpeesLine.W20 = (int) (windSpeed / 20); - aWB.windSpeesLine.W4 = (int) ((windSpeed - aWB.windSpeesLine.W20 * 20) / 4); - aWB.windSpeesLine.W2 = (int) ((windSpeed - aWB.windSpeesLine.W20 * 20 - - aWB.windSpeesLine.W4 * 4) / 2); - - return aWB; - } - - /** - * Create station model shape - * - * @param windDir Wind direction - * @param windSpeed Wind speed - * @param value Value - * @param size Size - * @param sPoint Location point - * @param weather Weather - * @param temp Temperature - * @param dewPoint Dew point - * @param pressure Pressure - * @param cloudCover Cloud cover - * @return Station model shape - */ - public static StationModelShape calStationModel(float windDir, float windSpeed, double value, - float size, PointD sPoint, int weather, int temp, int dewPoint, int pressure, int cloudCover) { - StationModelShape aSM = new StationModelShape(); - aSM.setPoint(sPoint); - aSM.setValue(value); - aSM.size = size; - aSM.temperature = temp; - aSM.dewPoint = dewPoint; - aSM.pressure = pressure; - aSM.windBarb = calWindBarb(windDir, windSpeed, value, size, sPoint); - aSM.weatherSymbol.size = size / 4 * 3; - //sPoint.X = sPoint.X - size / 2; - PointD aPoint = new PointD(sPoint.X - size / 2, sPoint.Y); - aSM.weatherSymbol.setPoint(aPoint); - aSM.weatherSymbol.weather = weather; - aSM.cloudCoverage.cloudCover = cloudCover; - aSM.cloudCoverage.size = size / 4 * 3; - aSM.cloudCoverage.sPoint = aPoint; - - return aSM; - } - - /** - * Draw wind arrow - * - * @param sP Start point - * @param aArraw The arrow - * @param g Graphics2D - * @param zoom Zoom - * @return Border rectangle - */ - public static Rectangle2D getArrawBorder(PointF sP, WindArrow aArraw, Graphics2D g, double zoom) { - PointF eP = new PointF(0, 0); - //PointF eP1 = new PointF(0, 0); - double len = aArraw.length; - double angle = aArraw.angle + 180; - if (angle >= 360) { - angle -= 360; - } - - len = len * zoom; - - eP.X = (int) (sP.X + len * Math.sin(angle * Math.PI / 180)); - eP.Y = (int) (sP.Y - len * Math.cos(angle * Math.PI / 180)); - - if (angle == 90) { - eP.Y = sP.Y; - } - - return new Rectangle2D.Double(Math.min(sP.X, eP.X), Math.min(sP.Y, eP.Y), - Math.abs(eP.X - sP.X), Math.abs(eP.Y - sP.Y)); - } - - /** - * Draw arrow line - * - * @param points Line points - * @param pb Legend - * @param arrowSize ArrowSize - * @param g Graphics2D - */ - public static void drawArrow(PointF[] points, PointBreak pb, int arrowSize, Graphics2D g) { - g.setColor(pb.getColor()); - g.setStroke(new BasicStroke(pb.getOutlineSize())); - drawPolyline(points, g); - - int n = points.length; - PointF aPoint = points[n - 2]; - PointF bPoint = points[n - 1]; - double U = bPoint.X - aPoint.X; - double V = bPoint.Y - aPoint.Y; - double angle = Math.atan((V) / (U)) * 180 / Math.PI; - angle = angle + 90; - if (U < 0) { - angle = angle + 180; - } - - if (angle >= 360) { - angle = angle - 360; - } - - Draw.drawArraw(g, bPoint, angle, arrowSize); - } - - /** - * Draw wind arrow - * - * @param aColor The color - * @param sP Start point - * @param aArraw The arrow - * @param g Graphics2D - * @param zoom Zoom - * @return Border rectangle - */ - public static Rectangle2D drawArraw(Color aColor, PointF sP, WindArrow aArraw, Graphics2D g, double zoom) { - PointF eP = new PointF(0, 0); - //PointF eP1 = new PointF(0, 0); - double len = aArraw.length; - double angle = aArraw.angle + 180; - if (angle >= 360) { - angle -= 360; - } - - len = len * zoom; - - eP.X = (int) (sP.X + len * Math.sin(angle * Math.PI / 180)); - eP.Y = (int) (sP.Y - len * Math.cos(angle * Math.PI / 180)); - - if (angle == 90) { - eP.Y = sP.Y; - } - - g.setColor(aColor); - g.draw(new Line2D.Float(sP.X, sP.Y, eP.X, eP.Y)); - drawArraw(g, eP, angle); - return new Rectangle2D.Double(Math.min(sP.X, eP.X), Math.min(sP.Y, eP.Y), - Math.abs(eP.X - sP.X), Math.abs(eP.Y - sP.Y)); - -// GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 5); -// path.moveTo(sP.X, sP.Y); -// path.lineTo(eP.X, eP.Y); -// -// eP1.X = (int) (eP.X - aArraw.size * Math.sin((angle + 20.0) * Math.PI / 180)); -// eP1.Y = (int) (eP.Y + aArraw.size * Math.cos((angle + 20.0) * Math.PI / 180)); -// //g.draw(new Line2D.Float(eP.X, eP.Y, eP1.X, eP1.Y)); -// path.moveTo(eP1.X, eP1.Y); -// path.lineTo(eP.X, eP.Y); -// -// eP1.X = (int) (eP.X - aArraw.size * Math.sin((angle - 20.0) * Math.PI / 180)); -// eP1.Y = (int) (eP.Y + aArraw.size * Math.cos((angle - 20.0) * Math.PI / 180)); -// //g.draw(new Line2D.Float(eP.X, eP.Y, eP1.X, eP1.Y)); -// path.lineTo(eP1.X, eP1.Y); -// g.draw(path); - } - - /** - * Draw wind arrow - * - * @param sP Start point - * @param aArraw The arrow - * @param pb PointBreak - * @param g Graphics2D - * @param zoom Zoom - * @return Border rectangle - */ - public static Rectangle2D drawArraw(PointF sP, WindArrow aArraw, ArrowBreak pb, Graphics2D g, double zoom) { - PointF eP = new PointF(0, 0); - //PointF eP1 = new PointF(0, 0); - double len = aArraw.length; - double angle = aArraw.angle + 180; - if (angle >= 360) { - angle -= 360; - } - - len = len * zoom; - - eP.X = (int) (sP.X + len * Math.sin(angle * Math.PI / 180)); - eP.Y = (int) (sP.Y - len * Math.cos(angle * Math.PI / 180)); - - if (angle == 90) { - eP.Y = sP.Y; - } - - g.setColor(pb.getColor()); - float width = pb.getWidth(); - g.setStroke(new BasicStroke(width)); - g.draw(new Line2D.Float(sP.X, sP.Y, eP.X, eP.Y)); - float headWidth = pb.getHeadWidth(); - float headLength = pb.getHeadLength(); - drawArraw(g, eP, angle, headLength, headWidth, pb.getOverhang()); - return new Rectangle2D.Double(Math.min(sP.X, eP.X), Math.min(sP.Y, eP.Y), - Math.abs(eP.X - sP.X), Math.abs(eP.Y - sP.Y)); - } - - /** - * Draw arraw - * - * @param g Graphics2D - * @param sP Start point - * @param angle Angle - */ - public static void drawArraw(Graphics2D g, PointF sP, double angle) { - GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 5); - Rectangle.Float rect = new Rectangle.Float(-4, -4, 8, 8); - PointF[] pt = new PointF[5]; - pt[0] = new PointF(rect.x, rect.y); - pt[1] = new PointF(rect.x + rect.width, rect.y + (rect.height / 2)); - pt[2] = new PointF(rect.x, rect.y + rect.height); - pt[3] = new PointF(rect.x + rect.width / 2, pt[1].Y); - pt[4] = pt[0]; - path.moveTo(pt[0].X, pt[0].Y); - for (int i = 1; i < 5; i++) { - path.lineTo(pt[i].X, pt[i].Y); - } - - AffineTransform tempTrans = g.getTransform(); - if (angle != 0) { - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform) tempTrans.clone(); - //myTrans.translate(tempTrans.getTranslateX() + sP.X, tempTrans.getTranslateY() + sP.Y); - myTrans.translate(sP.X, sP.Y); - double angle1 = angle - 90; - myTrans.rotate(angle1 * Math.PI / 180); - g.setTransform(myTrans); - } - path.closePath(); - g.fill(path); - - if (angle != 0) { - g.setTransform(tempTrans); - } - } - - /** - * Draw arraw - * - * @param g Graphics2D - * @param sP Start point - * @param angle Angle - * @param size Arrow size - */ - public static void drawArraw(Graphics2D g, PointF sP, double angle, int size) { - GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 5); - Rectangle.Float rect = new Rectangle.Float(-size, -size, size * 2, size * 2); - PointF[] pt = new PointF[5]; - pt[0] = new PointF(rect.x, rect.y); - pt[1] = new PointF(rect.x + rect.width, rect.y + (rect.height / 2)); - pt[2] = new PointF(rect.x, rect.y + rect.height); - pt[3] = new PointF(rect.x + rect.width / 2, pt[1].Y); - pt[4] = pt[0]; - path.moveTo(pt[0].X, pt[0].Y); - for (int i = 1; i < 5; i++) { - path.lineTo(pt[i].X, pt[i].Y); - } - - AffineTransform tempTrans = g.getTransform(); - if (angle != 0) { - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform) tempTrans.clone(); - //myTrans.translate(tempTrans.getTranslateX() + sP.X, tempTrans.getTranslateY() + sP.Y); - myTrans.translate(sP.X, sP.Y); - double angle1 = angle - 90; - myTrans.rotate(angle1 * Math.PI / 180); - g.setTransform(myTrans); - } - path.closePath(); - g.fill(path); - - if (angle != 0) { - g.setTransform(tempTrans); - } - } - - /** - * Draw arraw - * - * @param g Graphics2D - * @param sP Start point - * @param angle Angle - * @param length Arrow length - * @param width Arrow width - * @param overhang Overhang - */ - public static void drawArraw(Graphics2D g, PointF sP, double angle, float length, float width, - float overhang) { - PointF[] pt; - float x = -length; - float y = -width * 0.5f; - //Rectangle.Float rect = new Rectangle.Float(x, y, length, width); - if (overhang == 1) { - pt = new PointF[3]; - pt[0] = new PointF(x, y); - pt[1] = new PointF(x + length, y + (width / 2)); - pt[2] = new PointF(x, y + width); - } else { - x += length * (1 - overhang); - pt = new PointF[5]; - pt[0] = new PointF(x, y); - pt[1] = new PointF(x + length, y + (width / 2)); - pt[2] = new PointF(x, y + width); - pt[3] = new PointF(x + length * overhang, pt[1].Y); - pt[4] = pt[0]; - } - GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, pt.length); - path.moveTo(pt[0].X, pt[0].Y); - for (int i = 1; i < pt.length; i++) { - path.lineTo(pt[i].X, pt[i].Y); - } - - AffineTransform tempTrans = g.getTransform(); - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform) tempTrans.clone(); - //myTrans.translate(tempTrans.getTranslateX() + sP.X, tempTrans.getTranslateY() + sP.Y); - myTrans.translate(sP.X, sP.Y); - double angle1 = angle - 90; - if (angle1 != 0) { - myTrans.rotate(angle1 * Math.PI / 180); - } - g.setTransform(myTrans); - if (overhang == 1) { - g.draw(path); - } else { - path.closePath(); - g.fill(path); - } - - g.setTransform(tempTrans); - } - - /** - * Draw arraw - * - * @param g Graphics2D - * @param sP Start point - * @param angle Angle - * @param length Arrow length - * @param width Arrow width - * @param overhang Overhang - * @param fillColor Arrow fill color - * @param outlineColor Arrow outline color - */ - public static void drawArraw(Graphics2D g, PointF sP, double angle, float length, float width, - float overhang, Color fillColor, Color outlineColor) { - PointF[] pt; - float x = -length; - float y = -width * 0.5f; - //Rectangle.Float rect = new Rectangle.Float(x, y, length, width); - if (overhang == 1) { - pt = new PointF[3]; - pt[0] = new PointF(x, y); - pt[1] = new PointF(x + length, 0); - pt[2] = new PointF(x, y + width); - } else { - pt = new PointF[5]; - pt[0] = new PointF(x, y); - pt[1] = new PointF(x + length, 0); - pt[2] = new PointF(x, y + width); - pt[3] = new PointF(x + length * overhang, pt[1].Y); - pt[4] = pt[0]; - } - GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, pt.length); - path.moveTo(pt[0].X, pt[0].Y); - for (int i = 1; i < pt.length; i++) { - path.lineTo(pt[i].X, pt[i].Y); - } - - AffineTransform tempTrans = g.getTransform(); - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform) tempTrans.clone(); - //myTrans.translate(tempTrans.getTranslateX() + sP.X, tempTrans.getTranslateY() + sP.Y); - myTrans.translate(sP.X, sP.Y); - double angle1 = angle - 90; - if (angle1 != 0) { - myTrans.rotate(angle1 * Math.PI / 180); - } - g.setTransform(myTrans); - if (overhang == 1) { - g.setColor(fillColor); - g.draw(path); - } else { - if (fillColor != null) { - path.closePath(); - g.setColor(fillColor); - g.fill(path); - } - if (outlineColor != null) { - g.setColor(outlineColor); - g.draw(path); - } - } - - g.setTransform(tempTrans); - } - - /** - * Draw wind barb - * - * @param aColor Color - * @param sP Point - * @param aWB WindBarb - * @param g Grahics2D - * @param size Size - */ - public static void drawWindBarb(Color aColor, PointF sP, WindBarb aWB, Graphics2D g, float size) { - PointF eP; - PointF eP1; - double len = size * 2; - int i; - - double aLen = len; - - eP = new PointF(); - eP.X = (float) (sP.X + len * Math.sin(aWB.angle * Math.PI / 180)); - eP.Y = (float) (sP.Y - len * Math.cos(aWB.angle * Math.PI / 180)); - g.setColor(aColor); - g.draw(new Line2D.Float(sP.X, sP.Y, eP.X, eP.Y)); - - len = len / 2; - if (aWB.windSpeesLine.W20 > 0) { - for (i = 0; i < aWB.windSpeesLine.W20; i++) { - eP1 = new PointF(); - eP1.X = (float) (eP.X - len * Math.sin((aWB.angle - 105) * Math.PI / 180)); - eP1.Y = (float) (eP.Y + len * Math.cos((aWB.angle - 105) * Math.PI / 180)); - g.draw(new Line2D.Float(eP.X, eP.Y, eP1.X, eP1.Y)); - eP.X = (float) (eP.X - aLen / 8 * Math.sin((aWB.angle) * Math.PI / 180)); - eP.Y = (float) (eP.Y + aLen / 8 * Math.cos((aWB.angle) * Math.PI / 180)); - g.draw(new Line2D.Float(eP.X, eP.Y, eP1.X, eP1.Y)); - } - eP.X = (float) (eP.X - aLen / 8 * Math.sin((aWB.angle) * Math.PI / 180)); - eP.Y = (float) (eP.Y + aLen / 8 * Math.cos((aWB.angle) * Math.PI / 180)); - } - if (aWB.windSpeesLine.W4 > 0) { - for (i = 0; i < aWB.windSpeesLine.W4; i++) { - eP1 = new PointF(); - eP1.X = (float) (eP.X - len * Math.sin((aWB.angle - 120) * Math.PI / 180)); - eP1.Y = (float) (eP.Y + len * Math.cos((aWB.angle - 120) * Math.PI / 180)); - g.draw(new Line2D.Float(eP.X, eP.Y, eP1.X, eP1.Y)); - eP.X = (float) (eP.X - aLen / 8 * Math.sin((aWB.angle) * Math.PI / 180)); - eP.Y = (float) (eP.Y + aLen / 8 * Math.cos((aWB.angle) * Math.PI / 180)); - } - } - if (aWB.windSpeesLine.W2 > 0) { - len = len / 2; - eP1 = new PointF(); - eP1.X = (float) (eP.X - len * Math.sin((aWB.angle - 120) * Math.PI / 180)); - eP1.Y = (float) (eP.Y + len * Math.cos((aWB.angle - 120) * Math.PI / 180)); - g.draw(new Line2D.Float(eP.X, eP.Y, eP1.X, eP1.Y)); - } - } - - /** - * Draw wind barb - * - * @param sP Point - * @param aWB WindBarb - * @param pb PointBreak - * @param g Grahics2D - */ - public static void drawWindBarb(PointF sP, WindBarb aWB, PointBreak pb, Graphics2D g) { - PointF eP; - PointF eP1; - double len = pb.getSize() * 2; - int i; - - double aLen = len; - - eP = new PointF(); - eP.X = (float) (sP.X + len * Math.sin(aWB.angle * Math.PI / 180)); - eP.Y = (float) (sP.Y - len * Math.cos(aWB.angle * Math.PI / 180)); - g.setColor(pb.getColor()); - g.setStroke(new BasicStroke(pb.getOutlineSize())); - g.draw(new Line2D.Float(sP.X, sP.Y, eP.X, eP.Y)); - - len = len / 2; - if (aWB.windSpeesLine.W20 > 0) { - for (i = 0; i < aWB.windSpeesLine.W20; i++) { - eP1 = new PointF(); - eP1.X = (float) (eP.X - len * Math.sin((aWB.angle - 105) * Math.PI / 180)); - eP1.Y = (float) (eP.Y + len * Math.cos((aWB.angle - 105) * Math.PI / 180)); - g.draw(new Line2D.Float(eP.X, eP.Y, eP1.X, eP1.Y)); - eP.X = (float) (eP.X - aLen / 8 * Math.sin((aWB.angle) * Math.PI / 180)); - eP.Y = (float) (eP.Y + aLen / 8 * Math.cos((aWB.angle) * Math.PI / 180)); - g.draw(new Line2D.Float(eP.X, eP.Y, eP1.X, eP1.Y)); - } - eP.X = (float) (eP.X - aLen / 8 * Math.sin((aWB.angle) * Math.PI / 180)); - eP.Y = (float) (eP.Y + aLen / 8 * Math.cos((aWB.angle) * Math.PI / 180)); - } - if (aWB.windSpeesLine.W4 > 0) { - for (i = 0; i < aWB.windSpeesLine.W4; i++) { - eP1 = new PointF(); - eP1.X = (float) (eP.X - len * Math.sin((aWB.angle - 120) * Math.PI / 180)); - eP1.Y = (float) (eP.Y + len * Math.cos((aWB.angle - 120) * Math.PI / 180)); - g.draw(new Line2D.Float(eP.X, eP.Y, eP1.X, eP1.Y)); - eP.X = (float) (eP.X - aLen / 8 * Math.sin((aWB.angle) * Math.PI / 180)); - eP.Y = (float) (eP.Y + aLen / 8 * Math.cos((aWB.angle) * Math.PI / 180)); - } - } - if (aWB.windSpeesLine.W2 > 0) { - len = len / 2; - eP1 = new PointF(); - eP1.X = (float) (eP.X - len * Math.sin((aWB.angle - 120) * Math.PI / 180)); - eP1.Y = (float) (eP.Y + len * Math.cos((aWB.angle - 120) * Math.PI / 180)); - g.draw(new Line2D.Float(eP.X, eP.Y, eP1.X, eP1.Y)); - } - } - - /** - * Draw wind barb - * - * @param aColor Color - * @param sP Point - * @param aWB WindBarb - * @param g Grahics2D - * @param size Size - * @param cut Cut - */ - public static void drawWindBarb(Color aColor, PointF sP, WindBarb aWB, Graphics2D g, float size, float cut) { - PointF eP; - PointF eP1; - double len = size * 2; - int i; - - double aLen = len; - - eP = new PointF(); - eP.X = (float) (sP.X + len * Math.sin(aWB.angle * Math.PI / 180)); - eP.Y = (float) (sP.Y - len * Math.cos(aWB.angle * Math.PI / 180)); - PointF cutSP = new PointF(0, 0); - cutSP.X = (float) (sP.X + cut * Math.sin(aWB.angle * Math.PI / 180)); - cutSP.Y = (float) (sP.Y - cut * Math.cos(aWB.angle * Math.PI / 180)); - g.setColor(aColor); - g.draw(new Line2D.Float(cutSP.X, cutSP.Y, eP.X, eP.Y)); - - len = len / 2; - if (aWB.windSpeesLine.W20 > 0) { - for (i = 0; i < aWB.windSpeesLine.W20; i++) { - eP1 = new PointF(); - eP1.X = (float) (eP.X - len * Math.sin((aWB.angle - 105) * Math.PI / 180)); - eP1.Y = (float) (eP.Y + len * Math.cos((aWB.angle - 105) * Math.PI / 180)); - g.draw(new Line2D.Float(eP.X, eP.Y, eP1.X, eP1.Y)); - eP.X = (float) (eP.X - aLen / 8 * Math.sin((aWB.angle) * Math.PI / 180)); - eP.Y = (float) (eP.Y + aLen / 8 * Math.cos((aWB.angle) * Math.PI / 180)); - g.draw(new Line2D.Float(eP.X, eP.Y, eP1.X, eP1.Y)); - } - eP.X = (float) (eP.X - aLen / 8 * Math.sin((aWB.angle) * Math.PI / 180)); - eP.Y = (float) (eP.Y + aLen / 8 * Math.cos((aWB.angle) * Math.PI / 180)); - } - if (aWB.windSpeesLine.W4 > 0) { - for (i = 0; i < aWB.windSpeesLine.W4; i++) { - eP1 = new PointF(); - eP1.X = (float) (eP.X - len * Math.sin((aWB.angle - 120) * Math.PI / 180)); - eP1.Y = (float) (eP.Y + len * Math.cos((aWB.angle - 120) * Math.PI / 180)); - g.draw(new Line2D.Float(eP.X, eP.Y, eP1.X, eP1.Y)); - eP.X = (float) (eP.X - aLen / 8 * Math.sin((aWB.angle) * Math.PI / 180)); - eP.Y = (float) (eP.Y + aLen / 8 * Math.cos((aWB.angle) * Math.PI / 180)); - } - } - if (aWB.windSpeesLine.W2 > 0) { - len = len / 2; - eP1 = new PointF(); - eP1.X = (float) (eP.X - len * Math.sin((aWB.angle - 120) * Math.PI / 180)); - eP1.Y = (float) (eP.Y + len * Math.cos((aWB.angle - 120) * Math.PI / 180)); - g.draw(new Line2D.Float(eP.X, eP.Y, eP1.X, eP1.Y)); - } - } - - /** - * Draw point - * - * @param aPS Point style - * @param aP The point position - * @param color The color - * @param outlineColor Outline color - * @param aSize size - * @param drawOutline If draw outline - * @param drawFill If draw fill - * @param g Graphics2D - */ - public static void drawPoint(PointStyle aPS, PointF aP, Color color, Color outlineColor, - float aSize, Boolean drawOutline, Boolean drawFill, Graphics2D g) { - PointBreak aPB = new PointBreak(); - aPB.setMarkerType(MarkerType.Simple); - aPB.setStyle(aPS); - aPB.setColor(color); - aPB.setOutlineColor(outlineColor); - aPB.setSize(aSize); - aPB.setDrawOutline(drawOutline); - aPB.setDrawFill(drawFill); - - drawPoint(aP, aPB, g); - } - - /** - * Draw point - * - * @param aP Position - * @param aPB Point break - * @param g Graphics - */ - public static void drawPoint(PointF aP, PointBreak aPB, Graphics2D g) { - Rectangle clip = g.getClipBounds(); - if (clip != null) { - g.setClip(null); - if (aP.X >= clip.x && aP.X <= clip.x + clip.width && aP.Y >= clip.y - && aP.Y <= clip.y + clip.height) { - switch (aPB.getMarkerType()) { - case Simple: - drawPoint_Simple(aP, aPB, g); - break; - case Character: - drawPoint_Character(aP, aPB, g); - break; - case Image: - drawPoint_Image(aP, aPB, g); - break; - } - } - g.setClip(clip); - } else { - switch (aPB.getMarkerType()) { - case Simple: - drawPoint_Simple(aP, aPB, g); - break; - case Character: - drawPoint_Character(aP, aPB, g); - break; - case Image: - drawPoint_Image(aP, aPB, g); - break; - } - } - } - - /** - * Draw point - * - * @param aP Position - * @param aPB Point break - * @param g Graphics - */ - public static void drawMapPoint(PointF aP, PointBreak aPB, Graphics2D g) { - switch (aPB.getMarkerType()) { - case Simple: - drawPoint_Simple(aP, aPB, g); - break; - case Character: - drawPoint_Character(aP, aPB, g); - break; - case Image: - drawPoint_Image(aP, aPB, g); - break; - } - } - - private static void drawPoint_Simple(PointF aP, PointBreak aPB, Graphics2D g) { - AffineTransform tempTrans = g.getTransform(); - if (aPB.getAngle() != 0) { - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform) tempTrans.clone(); - myTrans.translate(aP.X, aP.Y); - //myTrans.translate(tempTrans.getTranslateX() + aP.X, tempTrans.getTranslateY() + aP.Y); - myTrans.rotate(aPB.getAngle() * Math.PI / 180); - g.setTransform(myTrans); - aP.X = 0; - aP.Y = 0; - } - - g.setStroke(new BasicStroke(1.0f)); - int[] xPoints; - int[] yPoints; - float aSize = aPB.getSize(); - boolean drawFill = aPB.isDrawFill(); - boolean drawOutline = aPB.isDrawOutline(); - Color color = aPB.getColor(); - Color outlineColor = aPB.getOutlineColor(); - float outlineSize = aPB.getOutlineSize(); - - GeneralPath path = new GeneralPath(); - - switch (aPB.getStyle()) { - case Circle: - aP.X = aP.X - aSize / 2.f; - aP.Y = aP.Y - aSize / 2.f; - Ellipse2D ellipse = new Ellipse2D.Float(aP.X, aP.Y, aSize, aSize); - if (drawFill) { - g.setColor(color); - g.fill(ellipse); - //g.fillOval((int) aP.X, (int) aP.Y, (int) aSize, (int) aSize); - } - if (drawOutline) { - g.setColor(outlineColor); - g.setStroke(new BasicStroke(outlineSize)); - g.draw(ellipse); - //g.drawOval((int) aP.X, (int) aP.Y, (int) aSize, (int) aSize); - } - break; - case DOUBLE_CIRCLE: - float x, - y; - x = aP.X - aSize / 2.f; - y = aP.Y - aSize / 2.f; - ellipse = new Ellipse2D.Float(x, y, aSize, aSize); - if (drawFill) { - g.setColor(color); - g.fill(ellipse); - } - if (drawOutline) { - g.setColor(outlineColor); - g.setStroke(new BasicStroke(outlineSize)); - g.draw(ellipse); - x = aP.X - aSize * 0.3f; - y = aP.Y - aSize * 0.3f; - ellipse = new Ellipse2D.Float(x, y, aSize * 0.6f, aSize * 0.6f); - g.draw(ellipse); - } - break; - case Square: - aP.X = aP.X - aSize / 2.f; - aP.Y = aP.Y - aSize / 2.f; - Rectangle2D rect = new Rectangle2D.Float(aP.X, aP.Y, aSize, aSize); - if (drawFill) { - g.setColor(color); - g.fill(rect); - //g.fillRect((int) aP.X, (int) aP.Y, (int) aSize, (int) aSize); - } - if (drawOutline) { - g.setColor(outlineColor); - g.setStroke(new BasicStroke(outlineSize)); - g.draw(rect); - //g.drawRect((int) aP.X, (int) aP.Y, (int) aSize, (int) aSize); - } - break; - case Diamond: - xPoints = new int[4]; - yPoints = new int[4]; - xPoints[0] = (int) (aP.X - aSize / 2); - yPoints[0] = (int) aP.Y; - xPoints[1] = (int) aP.X; - yPoints[1] = (int) (aP.Y - aSize / 2); - xPoints[2] = (int) (aP.X + aSize / 2); - yPoints[2] = (int) aP.Y; - xPoints[3] = (int) aP.X; - yPoints[3] = (int) (aP.Y + aSize / 2); - if (drawFill) { - g.setColor(color); - g.fillPolygon(xPoints, yPoints, xPoints.length); - } - if (drawOutline) { - g.setColor(outlineColor); - g.setStroke(new BasicStroke(outlineSize)); - g.drawPolygon(xPoints, yPoints, xPoints.length); - } - break; - case UpTriangle: - xPoints = new int[3]; - yPoints = new int[3]; - xPoints[0] = (int) aP.X; - yPoints[0] = (int) (aP.Y - aSize / 2); - xPoints[1] = (int) (aP.X + aSize / 4 * Math.sqrt(3)); - yPoints[1] = (int) (aP.Y + aSize / 4); - xPoints[2] = (int) (aP.X - aSize / 4 * Math.sqrt(3)); - yPoints[2] = (int) (aP.Y + aSize / 4); - if (drawFill) { - g.setColor(color); - g.fillPolygon(xPoints, yPoints, xPoints.length); - } - if (drawOutline) { - g.setColor(outlineColor); - g.setStroke(new BasicStroke(outlineSize)); - g.drawPolygon(xPoints, yPoints, xPoints.length); - } - break; - case DownTriangle: - xPoints = new int[3]; - yPoints = new int[3]; - xPoints[0] = (int) aP.X; - yPoints[0] = (int) (aP.Y + aSize / 2); - xPoints[1] = (int) (aP.X - aSize / 4 * Math.sqrt(3)); - yPoints[1] = (int) (aP.Y - aSize / 4); - xPoints[2] = (int) (aP.X + aSize / 4 * Math.sqrt(3)); - yPoints[2] = (int) (aP.Y - aSize / 4); - if (drawFill) { - g.setColor(color); - g.fillPolygon(xPoints, yPoints, xPoints.length); - } - if (drawOutline) { - g.setColor(outlineColor); - g.setStroke(new BasicStroke(outlineSize)); - g.drawPolygon(xPoints, yPoints, xPoints.length); - } - break; - case XCross: - path.moveTo(aP.X - aSize / 2, aP.Y - aSize / 2); - path.lineTo(aP.X + aSize / 2, aP.Y + aSize / 2); - path.moveTo(aP.X - aSize / 2, aP.Y + aSize / 2); - path.lineTo(aP.X + aSize / 2, aP.Y - aSize / 2); - path.closePath(); - if (drawFill || drawOutline) { - g.setColor(color); - g.setStroke(new BasicStroke(outlineSize)); - g.draw(path); - } - break; - case Plus: - path.moveTo(aP.X, aP.Y - aSize / 2); - path.lineTo(aP.X, aP.Y + aSize / 2); - path.moveTo(aP.X - aSize / 2, aP.Y); - path.lineTo(aP.X + aSize / 2, aP.Y); - path.closePath(); - if (drawFill || drawOutline) { - g.setColor(color); - g.setStroke(new BasicStroke(outlineSize)); - g.draw(path); - } - break; - case Minus: - path.moveTo(aP.X - aSize / 2, aP.Y); - path.lineTo(aP.X + aSize / 2, aP.Y); - path.closePath(); - if (drawFill || drawOutline) { - g.setColor(color); - g.setStroke(new BasicStroke(outlineSize)); - g.draw(path); - } - break; - case StarLines: - path.moveTo(aP.X - aSize / 2, aP.Y - aSize / 2); - path.lineTo(aP.X + aSize / 2, aP.Y + aSize / 2); - path.moveTo(aP.X - aSize / 2, aP.Y + aSize / 2); - path.lineTo(aP.X + aSize / 2, aP.Y - aSize / 2); - path.moveTo(aP.X, aP.Y - aSize / 2); - path.lineTo(aP.X, aP.Y + aSize / 2); - path.moveTo(aP.X - aSize / 2, aP.Y); - path.lineTo(aP.X + aSize / 2, aP.Y); - path.closePath(); - if (drawFill || drawOutline) { - g.setColor(color); - g.setStroke(new BasicStroke(outlineSize)); - g.draw(path); - } - break; - case Star: - float vRadius = aSize / 2; - //Calculate 5 end points - PointF[] vPoints = new PointF[5]; - double vAngle = 2.0 * Math.PI / 4 + Math.PI; - for (int i = 0; i < vPoints.length; i++) { - vAngle += 2.0 * Math.PI / (double) vPoints.length; - vPoints[i] = new PointF( - (float) (Math.cos(vAngle) * vRadius) + aP.X, - (float) (Math.sin(vAngle) * vRadius) + aP.Y); - } - //Calculate 5 cross points - PointF[] cPoints = new PointF[5]; - cPoints[0] = MIMath.getCrossPoint(vPoints[0], vPoints[2], vPoints[1], vPoints[4]); - cPoints[1] = MIMath.getCrossPoint(vPoints[1], vPoints[3], vPoints[0], vPoints[2]); - cPoints[2] = MIMath.getCrossPoint(vPoints[1], vPoints[3], vPoints[2], vPoints[4]); - cPoints[3] = MIMath.getCrossPoint(vPoints[0], vPoints[3], vPoints[2], vPoints[4]); - cPoints[4] = MIMath.getCrossPoint(vPoints[0], vPoints[3], vPoints[1], vPoints[4]); - //New points - xPoints = new int[10]; - yPoints = new int[10]; - for (int i = 0; i < 5; i++) { - xPoints[i * 2] = (int) vPoints[i].X; - yPoints[i * 2] = (int) vPoints[i].Y; - xPoints[i * 2 + 1] = (int) cPoints[i].X; - yPoints[i * 2 + 1] = (int) cPoints[i].Y; - } - if (drawFill) { - g.setColor(color); - g.fillPolygon(xPoints, yPoints, xPoints.length); - } - if (drawOutline) { - g.setColor(outlineColor); - g.setStroke(new BasicStroke(outlineSize)); - g.drawPolygon(xPoints, yPoints, xPoints.length); - } - break; - case CIRCLE_STAR: - vRadius = aSize * 0.4f; - //Calculate 5 end points - vPoints = new PointF[5]; - vAngle = 2.0 * Math.PI / 4 + Math.PI; - for (int i = 0; i < vPoints.length; i++) { - vAngle += 2.0 * Math.PI / (double) vPoints.length; - vPoints[i] = new PointF( - (float) (Math.cos(vAngle) * vRadius) + aP.X, - (float) (Math.sin(vAngle) * vRadius) + aP.Y); - } - //Calculate 5 cross points - cPoints = new PointF[5]; - cPoints[0] = MIMath.getCrossPoint(vPoints[0], vPoints[2], vPoints[1], vPoints[4]); - cPoints[1] = MIMath.getCrossPoint(vPoints[1], vPoints[3], vPoints[0], vPoints[2]); - cPoints[2] = MIMath.getCrossPoint(vPoints[1], vPoints[3], vPoints[2], vPoints[4]); - cPoints[3] = MIMath.getCrossPoint(vPoints[0], vPoints[3], vPoints[2], vPoints[4]); - cPoints[4] = MIMath.getCrossPoint(vPoints[0], vPoints[3], vPoints[1], vPoints[4]); - //New points - xPoints = new int[10]; - yPoints = new int[10]; - for (int i = 0; i < 5; i++) { - xPoints[i * 2] = (int) vPoints[i].X; - yPoints[i * 2] = (int) vPoints[i].Y; - xPoints[i * 2 + 1] = (int) cPoints[i].X; - yPoints[i * 2 + 1] = (int) cPoints[i].Y; - } - if (drawFill) { - g.setColor(color); - g.fillPolygon(xPoints, yPoints, xPoints.length); - } - if (drawOutline) { - g.setColor(outlineColor); - g.setStroke(new BasicStroke(outlineSize)); - //g.drawPolygon(xPoints, yPoints, xPoints.length); - x = aP.X - aSize * 0.5f; - y = aP.Y - aSize * 0.5f; - ellipse = new Ellipse2D.Float(x, y, aSize, aSize); - g.draw(ellipse); - } - break; - case Pentagon: - vRadius = aSize / 2; - //Calculate 5 end points - xPoints = new int[5]; - yPoints = new int[5]; - vAngle = 2.0 * Math.PI / 4 + Math.PI; - for (int i = 0; i < 5; i++) { - vAngle += 2.0 * Math.PI / (double) 5; - xPoints[i] = (int) (Math.cos(vAngle) * vRadius + aP.X); - yPoints[i] = (int) (Math.sin(vAngle) * vRadius + aP.Y); - } - if (drawFill) { - g.setColor(color); - g.fillPolygon(xPoints, yPoints, xPoints.length); - } - if (drawOutline) { - g.setColor(outlineColor); - g.setStroke(new BasicStroke(outlineSize)); - g.drawPolygon(xPoints, yPoints, xPoints.length); - } - break; - case UpSemiCircle: - aP.X = aP.X - aSize / 2; - aP.Y = aP.Y - aSize / 2; - if (drawFill) { - g.setColor(color); - g.fill(new Arc2D.Float(aP.X, aP.Y, aSize, aSize, 180, 180, Arc2D.CHORD)); - } - if (drawOutline) { - g.setColor(outlineColor); - g.setStroke(new BasicStroke(outlineSize)); - g.draw(new Arc2D.Float(aP.X, aP.Y, aSize, aSize, 180, 180, Arc2D.CHORD)); - } - break; - case DownSemiCircle: - aP.X = aP.X - aSize / 2; - aP.Y = aP.Y - aSize / 2; - if (drawFill) { - g.setColor(color); - g.fill(new Arc2D.Float(aP.X, aP.Y, aSize, aSize, 0, 180, Arc2D.CHORD)); - } - if (drawOutline) { - g.setColor(outlineColor); - g.setStroke(new BasicStroke(outlineSize)); - g.draw(new Arc2D.Float(aP.X, aP.Y, aSize, aSize, 0, 180, Arc2D.CHORD)); - } - break; - } - - if (aPB.getAngle() != 0) { - g.setTransform(tempTrans); - } - } - - private static void drawPoint_Simple_Up(PointF aP, PointBreak aPB, Graphics2D g) { - AffineTransform tempTrans = g.getTransform(); - if (aPB.getAngle() != 0) { - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform) tempTrans.clone(); - myTrans.translate(aP.X, aP.Y); - //myTrans.translate(tempTrans.getTranslateX() + aP.X, tempTrans.getTranslateY() + aP.Y); - myTrans.rotate(aPB.getAngle() * Math.PI / 180); - g.setTransform(myTrans); - aP.X = 0; - aP.Y = 0; - } - - int[] xPoints; - int[] yPoints; - float aSize = aPB.getSize(); - boolean drawFill = aPB.isDrawFill(); - boolean drawOutline = aPB.isDrawOutline(); - Color color = aPB.getColor(); - Color outlineColor = aPB.getOutlineColor(); - float outlineSize = aPB.getOutlineSize(); - - GeneralPath path = new GeneralPath(); - - switch (aPB.getStyle()) { - case Circle: - aP.X = aP.X - aSize / 2; - aP.Y = aP.Y - aSize; - - if (drawFill) { - g.setColor(color); - g.fillOval((int) aP.X, (int) aP.Y, (int) aSize, (int) aSize); - } - if (drawOutline) { - g.setColor(outlineColor); - g.setStroke(new BasicStroke(outlineSize)); - g.drawOval((int) aP.X, (int) aP.Y, (int) aSize, (int) aSize); - } - break; - case Square: - aP.X = aP.X - aSize / 2; - aP.Y = aP.Y - aSize; - - if (drawFill) { - g.setColor(color); - g.fillRect((int) aP.X, (int) aP.Y, (int) aSize, (int) aSize); - } - if (drawOutline) { - g.setColor(outlineColor); - g.setStroke(new BasicStroke(outlineSize)); - g.drawRect((int) aP.X, (int) aP.Y, (int) aSize, (int) aSize); - } - break; - case Diamond: - xPoints = new int[4]; - yPoints = new int[4]; - xPoints[0] = (int) (aP.X - aSize / 2); - yPoints[0] = (int) aP.Y; - xPoints[1] = (int) aP.X; - yPoints[1] = (int) (aP.Y - aSize / 2); - xPoints[2] = (int) (aP.X + aSize / 2); - yPoints[2] = (int) aP.Y; - xPoints[3] = (int) aP.X; - yPoints[3] = (int) (aP.Y + aSize / 2); - if (drawFill) { - g.setColor(color); - g.fillPolygon(xPoints, yPoints, xPoints.length); - } - if (drawOutline) { - g.setColor(outlineColor); - g.setStroke(new BasicStroke(outlineSize)); - g.drawPolygon(xPoints, yPoints, xPoints.length); - } - case UpTriangle: - xPoints = new int[3]; - yPoints = new int[3]; - xPoints[0] = (int) aP.X; - yPoints[0] = (int) (aP.Y - aSize * 3 / 4); - xPoints[1] = (int) (aP.X + aSize / 4 * Math.sqrt(3)); - yPoints[1] = (int) (aP.Y); - xPoints[2] = (int) (aP.X - aSize / 4 * Math.sqrt(3)); - yPoints[2] = (int) (aP.Y); - if (drawFill) { - g.setColor(color); - g.fillPolygon(xPoints, yPoints, xPoints.length); - } - if (drawOutline) { - g.setColor(outlineColor); - g.setStroke(new BasicStroke(outlineSize)); - g.drawPolygon(xPoints, yPoints, xPoints.length); - } - break; - } - - if (aPB.getAngle() != 0) { - g.setTransform(tempTrans); - } - } - - private static void drawPoint_Character(PointF aP, PointBreak aPB, Graphics2D g) { - AffineTransform tempTrans = g.getTransform(); - if (aPB.getAngle() != 0) { - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform) tempTrans.clone(); - myTrans.translate(aP.X, aP.Y); - myTrans.rotate(aPB.getAngle() * Math.PI / 180); - g.setTransform(myTrans); - aP.X = 0; - aP.Y = 0; - } - - String text = String.valueOf((char) aPB.getCharIndex()); - Font wFont = new Font(aPB.getFontName(), Font.PLAIN, (int) aPB.getSize()); - g.setFont(wFont); - FontMetrics metrics = g.getFontMetrics(); - PointF sPoint = (PointF) aP.clone(); - sPoint.X = sPoint.X - metrics.stringWidth(text) / 2; - sPoint.Y = sPoint.Y + metrics.getHeight() / 4; - //sPoint.X = sPoint.X - aPB.getSize() / 2; - //sPoint.Y = sPoint.Y + aPB.getSize() / 2; - - g.setColor(aPB.getColor()); - g.drawString(text, sPoint.X, sPoint.Y); - - if (aPB.getAngle() != 0) { - g.setTransform(tempTrans); - } - } - - private static void drawPoint_Image(PointF aP, PointBreak aPB, Graphics2D g) { - AffineTransform tempTrans = g.getTransform(); - if (aPB.getAngle() != 0) { - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform) tempTrans.clone(); - myTrans.translate(aP.X, aP.Y); - myTrans.rotate(aPB.getAngle() * Math.PI / 180); - g.setTransform(myTrans); - aP.X = 0; - aP.Y = 0; - } - - File imgFile = new File(aPB.getImagePath()); - if (!imgFile.exists()) { - //String path = System.getProperty("user.dir"); - File directory = new File("."); - String path = null; - try { - path = directory.getCanonicalPath(); - } catch (IOException ex) { - Logger.getLogger(Draw.class.getName()).log(Level.SEVERE, null, ex); - } - path = path + File.separator + "Image"; - aPB.setImagePath(path + File.separator + imgFile.getName()); - } - if (imgFile.exists()) { - Image image = null; - try { - image = ImageIO.read(imgFile); - } catch (IOException ex) { - Logger.getLogger(Draw.class.getName()).log(Level.SEVERE, null, ex); - } - - if (image != null) { - //((Bitmap)image).MakeTransparent(Color.White); - int width = (int) aPB.getSize(); - int height = width * image.getHeight(null) / image.getWidth(null); - PointF sPoint = aP; - sPoint.X = sPoint.X - width / 2; - sPoint.Y = sPoint.Y - height / 2; - g.drawImage(image, (int) sPoint.X, (int) sPoint.Y, width, height, null); - } - } - - if (aPB.getAngle() != 0) { - g.setTransform(tempTrans); - } - } - - /** - * Draws string at the specified coordinates with the specified alignment. - * - * @param g graphics context to draw - * @param x the x coordinate - * @param y the y coordinate - * @param s the string to draw - * @param x_align the alignment in x direction - * @param y_align the alignment in y direction - * @param useExternalFont Use external font or not - */ - public static void drawString(Graphics2D g, float x, float y, String s, XAlign x_align, YAlign y_align, boolean useExternalFont) { - Dimension dim = Draw.getStringDimension(s, g); - switch (y_align) { - case TOP: - y += dim.getHeight(); - break; - case CENTER: - y += dim.getHeight() / 2; - break; - } - switch (x_align) { - case LEFT: - drawString(g, s, x, y, useExternalFont); - break; - case RIGHT: - drawString(g, s, x - (float) dim.getWidth(), y, useExternalFont); - break; - case CENTER: - drawString(g, s, x - (float) dim.getWidth() / 2, y, useExternalFont); - break; - } - } - - /** - * Draws string at the specified coordinates with the specified alignment. - * - * @param g graphics context to draw - * @param x the x coordinate - * @param y the y coordinate - * @param s the string to draw - * @param x_align the alignment in x direction - * @param y_align the alignment in y direction - * @param useExternalFont Use external font or not - */ - public static void drawString(Graphics2D g, double x, double y, String s, XAlign x_align, YAlign y_align, boolean useExternalFont) { - Dimension dim = Draw.getStringDimension(s, g); - switch (y_align) { - case TOP: - y += dim.getHeight(); - break; - case CENTER: - y += dim.getHeight() / 2; - break; - } - switch (x_align) { - case LEFT: - drawString(g, s, x, y, useExternalFont); - break; - case RIGHT: - drawString(g, s, x - (float) dim.getWidth(), y, useExternalFont); - break; - case CENTER: - drawString(g, s, x - (float) dim.getWidth() / 2, y, useExternalFont); - break; - } - } - - /** - * Draw out string - * - * @param g Graphics2D - * @param x X location - * @param y Y location - * @param s String - * @param x_align X align - * @param y_align Y align - * @param angle Angle - * @param useExternalFont Use external font or not - */ - public static void drawString(Graphics2D g, float x, float y, String s, XAlign x_align, YAlign y_align, float angle, boolean useExternalFont) { - if (angle == 0) { - drawString(g, x, y, s, x_align, y_align, useExternalFont); - } else { - /*AffineTransform tempTrans = g.getTransform(); - AffineTransform myTrans = transform(g, x, y, s, x_align, y_align, angle); - g.setTransform(myTrans); - Draw.drawString(g, s, 0, 0, useExternalFont); - g.setTransform(tempTrans);*/ - - AffineTransform tempTrans = g.getTransform(); - AffineTransform myTrans = (AffineTransform)tempTrans.clone(); - myTrans.translate(x, y); - myTrans.rotate(-angle * Math.PI / 180); - g.setTransform(myTrans); - x = 0; y = 0; - Dimension labSize = Draw.getStringDimension(s, g); - switch (y_align) { - case TOP: - y += labSize.height; - break; - case CENTER: - y += labSize.height / 2.0f; - break; - } - switch (x_align) { - case RIGHT: - x = x - labSize.width; - break; - case CENTER: - x = x - labSize.width / 2.0f; - break; - } - Draw.drawString(g, s, x, y, useExternalFont); - g.setTransform(tempTrans); - } - } - - /** - * Draw out string - * - * @param g Graphics2D - * @param x X location - * @param y Y location - * @param s String - * @param x_align X align - * @param y_align Y align - * @param angle Angle - * @param useExternalFont Use external font or not - */ - public static void drawString(Graphics2D g, double x, double y, String s, XAlign x_align, YAlign y_align, float angle, boolean useExternalFont) { - drawString(g, (float)x, (float)y, s, x_align, y_align, angle, useExternalFont); - } - - /** - * Graphics transform - * - * @param g Graphics2D - * @param x X location - * @param y Y location - * @param s String - * @param x_align X align - * @param y_align Y align - * @param angle Angle - * @return AffineTransform - */ - public static AffineTransform transform_bak(Graphics2D g, float x, float y, String s, XAlign x_align, YAlign y_align, float angle) { - Dimension dim = getStringDimension(s, g); - AffineTransform tempTrans = g.getTransform(); - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform) tempTrans.clone(); - switch (x_align) { - case CENTER: - x -= (float)(dim.getWidth() * 0.5); - break; - case RIGHT: - x -= (float)dim.getWidth(); - break; - } - switch (y_align) { - case TOP: - y += (float)dim.getHeight(); - break; - case CENTER: - y += (float)(dim.getHeight() * 0.5); - break; - } - //myTrans.translate(tempTrans.getTranslateX() + x, tempTrans.getTranslateY() + y); - myTrans.translate(x, y); - myTrans.rotate(-angle * Math.PI / 180); - - return myTrans; - } - - /** - * Graphics transform - * - * @param g Graphics2D - * @param x X location - * @param y Y location - * @param s String - * @param x_align X align - * @param y_align Y align - * @param angle Angle - * @return AffineTransform - */ - public static AffineTransform transform(Graphics2D g, float x, float y, String s, XAlign x_align, YAlign y_align, float angle) { - Dimension dim = getStringDimension(s, g); - AffineTransform tempTrans = g.getTransform(); - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform) tempTrans.clone(); - switch (x_align) { - case LEFT: - switch (y_align) { - case CENTER: - if (angle == 90) { - x += (float) (dim.getHeight()); - y += (float) (dim.getWidth() * 0.5); - } else if (angle == -90) { - y -= (float) (dim.getWidth() * 0.5); - } else if (angle > 0) { - x += (float) (dim.getHeight() * Math.abs(Math.sin(Math.toRadians(angle)))); - y += (float) (dim.getHeight() * Math.cos(Math.toRadians(angle)) * 0.5); - } else { - y += (float) (dim.getHeight() * Math.cos(Math.toRadians(angle)) * 0.5); - } - break; - } - break; - case CENTER: - switch (y_align) { - case TOP: - if (angle == 90) { - x += (float) (dim.getHeight() * 0.5); - y += (float) (dim.getWidth()); - } else if (angle == -90) { - x -= (float) (dim.getHeight() * 0.5); - } else if (angle > 0) { - //x -= (float) (dim.getWidth() * Math.abs(Math.cos(Math.toRadians(angle)))); - //y += (float) (dim.getWidth() * Math.sin(Math.toRadians(angle))) + dim.getHeight(); - x -= (float) (dim.getWidth() * Math.abs(Math.cos(Math.toRadians(angle)))); - y += (float) (dim.getWidth() * Math.sin(Math.toRadians(angle))) + dim.getHeight() * 0.5 * Math.cos(Math.toRadians(angle)); - } else { - //y += (float) (dim.getHeight() * Math.cos(Math.toRadians(angle)) * 0.5); - y += (float) (dim.getHeight() * Math.abs(Math.cos(Math.toRadians(angle)))); - } - break; - } - break; - case RIGHT: - switch (y_align) { - case CENTER: - if (angle == 90) { - x -= (float) (dim.getHeight()); - y += (float) (dim.getWidth() * 0.5); - } else if (angle == -90) { - x -= (float) (dim.getHeight()); - y -= (float) (dim.getWidth() * 0.5); - } else if (angle > 0) { - x -= (float) (dim.getWidth() * Math.abs(Math.cos(Math.toRadians(angle)))); - y += (float) (dim.getHeight() * Math.cos(Math.toRadians(angle)) * 0.5); - } else { - y += (float) (dim.getHeight() * Math.cos(Math.toRadians(angle)) * 0.5); - } - break; - } - break; - } - //myTrans.translate(tempTrans.getTranslateX() + x, tempTrans.getTranslateY() + y); - myTrans.translate(x, y); - myTrans.rotate(-angle * Math.PI / 180); - - return myTrans; - } - - /** - * Graphics transform - * - * @param g Graphics2D - * @param x X location - * @param y Y location - * @param s String - * @param x_align X align - * @param y_align Y align - * @param angle Angle - * @return AffineTransform - */ - public static AffineTransform transform(Graphics2D g, double x, double y, String s, XAlign x_align, YAlign y_align, float angle) { - return transform(g, (float)x, (float)y, s, x_align, y_align, angle); - } - - /** - * Draw label point - * - * @param aPoint The screen point - * @param aLB The label break - * @param g Graphics2D - * @param rect The extent rectangle - */ - public static void drawLabelPoint(PointF aPoint, LabelBreak aLB, Graphics2D g, Rectangle rect) { - g.setColor(aLB.getColor()); - g.setFont(aLB.getFont()); - Dimension labSize = Draw.getStringDimension(aLB.getText(), g); - //FontMetrics metrics = g.getFontMetrics(aLB.getFont()); - //Dimension labSize = new Dimension(metrics.stringWidth(aLB.getText()), metrics.getHeight()); - switch (aLB.getAlignType()) { - case Center: - aPoint.X = aPoint.X - (float) labSize.getWidth() / 2; - break; - case Left: - aPoint.X = aPoint.X - (float) labSize.getWidth(); - break; - } - aLB.setYShift((float) labSize.getHeight() / 2); - aPoint.Y -= aLB.getYShift(); - aPoint.X += aLB.getXShift(); - float inx = aPoint.X; - float iny = aPoint.Y; - - AffineTransform tempTrans = g.getTransform(); - if (aLB.getAngle() != 0) { - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform) tempTrans.clone(); - myTrans.translate(aPoint.X, aPoint.Y); - myTrans.rotate(aLB.getAngle() * Math.PI / 180); - g.setTransform(myTrans); - aPoint.X = 0; - aPoint.Y = 0; - } - - //g.drawString(aLB.getText(), aPoint.X, aPoint.Y + metrics.getHeight() / 2); - Draw.drawString(g, aLB.getText(), aPoint.X, aPoint.Y + labSize.height / 2); - - rect.x = (int) aPoint.X; - rect.y = (int) aPoint.Y - labSize.height / 2; - rect.width = (int) labSize.getWidth(); - rect.height = (int) labSize.getHeight(); - - if (aLB.getAngle() != 0) { - g.setTransform(tempTrans); - rect.x = (int) inx; - rect.y = (int) iny; - } - } - - /** - * Draw label point - * - * @param x X - * @param y Y - * @param font Font - * @param text Text - * @param color Color - * @param g Graphics2D - * @param rect The extent rectangle - * @param angle Angle - */ - public static void drawLabelPoint(float x, float y, Font font, String text, Color color, float angle, Graphics2D g, Rectangle rect) { - g.setColor(color); - g.setFont(font); - Dimension labSize = Draw.getStringDimension(text, g); - //FontMetrics metrics = g.getFontMetrics(font); - //Dimension labSize = new Dimension(metrics.stringWidth(text), metrics.getHeight()); - x = x - (float) labSize.getWidth() / 2; - y -= (float) labSize.getHeight() / 2; - - float inx = x; - float iny = y; - - AffineTransform tempTrans = g.getTransform(); - if (angle != 0) { - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform) tempTrans.clone(); - myTrans.translate(x, y); - myTrans.rotate(angle * Math.PI / 180); - g.setTransform(myTrans); - x = 0; - y = 0; - } - - //g.drawString(text, x, y + metrics.getHeight() / 2); - Draw.drawString(g, text, x, y + labSize.height / 2); - - if (rect != null) { - rect.x = (int) x; - rect.y = (int) y - labSize.height / 2; - rect.width = (int) labSize.getWidth(); - rect.height = (int) labSize.getHeight(); - } - - if (angle != 0) { - g.setTransform(tempTrans); - if (rect != null) { - rect.x = (int) inx; - rect.y = (int) iny; - } - } - } - - /** - * Draw label point - * - * @param x X - * @param y Y - * @param font Font - * @param text Text - * @param color Color - * @param g Graphics2D - * @param rect The extent rectangle - * @param angle Angle - * @param useExternalFont If use external font - */ - public static void drawLabelPoint(float x, float y, Font font, String text, Color color, float angle, - Graphics2D g, Rectangle rect, boolean useExternalFont) { - g.setColor(color); - g.setFont(font); - Dimension labSize = Draw.getStringDimension(text, g); - //FontMetrics metrics = g.getFontMetrics(font); - //Dimension labSize = new Dimension(metrics.stringWidth(text), metrics.getHeight()); - x = x - (float) labSize.getWidth() / 2; - y -= (float) labSize.getHeight() / 2; - - float inx = x; - float iny = y; - - AffineTransform tempTrans = g.getTransform(); - if (angle != 0) { - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform) tempTrans.clone(); - myTrans.translate(x, y); - myTrans.rotate(angle * Math.PI / 180); - g.setTransform(myTrans); - x = 0; - y = 0; - } - - //g.drawString(text, x, y + metrics.getHeight() / 2); - Draw.drawString(g, text, x, y + labSize.height / 2, useExternalFont); - - if (rect != null) { - rect.x = (int) x; - rect.y = (int) y - labSize.height / 2; - rect.width = (int) labSize.getWidth(); - rect.height = (int) labSize.getHeight(); - } - - if (angle != 0) { - g.setTransform(tempTrans); - if (rect != null) { - rect.x = (int) inx; - rect.y = (int) iny; - } - } - } - - /** - * Draw label point - * - * @param x X - * @param y Y - * @param font Font - * @param text Text - * @param color Color - * @param g Graphics2D - * @param angle Angle - */ - public static void drawTickLabel(float x, float y, Font font, String text, Color color, float angle, Graphics2D g) { - g.setColor(color); - g.setFont(font); - Dimension labSize = Draw.getStringDimension(text, g); - if (angle == 0) { - x = x - (float) labSize.getWidth() / 2; - y -= (float) labSize.getHeight() / 2; - Draw.drawString(g, text, x, y + labSize.height / 2); - } else { - AffineTransform tempTrans = g.getTransform(); - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform) tempTrans.clone(); - myTrans.translate(x, y); - myTrans.translate(tempTrans.getTranslateX() + x, tempTrans.getTranslateY() + y); - myTrans.rotate(-angle * Math.PI / 180); - g.setTransform(myTrans); - if (angle == 90) { - x = -(float) (labSize.getWidth() - 10); - y = (float) (labSize.getHeight() / 3); - } else { - x = -(float) (labSize.getWidth() - 5); - y = 0; - } - Draw.drawString(g, text, x, y); - g.setTransform(tempTrans); - } - } - - /** - * Draw label point - * - * @param x X - * @param y Y - * @param font Font - * @param text Text - * @param color Color - * @param g Graphics2D - * @param angle Angle - */ - public static void drawTickLabel_Y(float x, float y, Font font, String text, Color color, float angle, Graphics2D g) { - g.setColor(color); - g.setFont(font); - Dimension labSize = Draw.getStringDimension(text, g); - if (angle == 0) { - //x = x - (float) labSize.getWidth() / 2; - //y -= (float) labSize.getHeight() / 2; - Draw.drawString(g, text, x, y); - } else { - AffineTransform tempTrans = g.getTransform(); - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform) tempTrans.clone(); - myTrans.translate(x, y); - myTrans.translate(tempTrans.getTranslateX() + x, tempTrans.getTranslateY() + y); - myTrans.rotate(-angle * Math.PI / 180); - g.setTransform(myTrans); - if (angle == 90) { - x = -(float) (labSize.getWidth() - 10); - y = (float) (labSize.getHeight() / 3); - } else { - x = -(float) (labSize.getWidth() - 5); - y = 0; - } - Draw.drawString(g, text, x, y); - g.setTransform(tempTrans); - } - } - - /** - * Draw label point - * - * @param x X - * @param y Y - * @param font Font - * @param text Text - * @param color Color - * @param g Graphics2D - * @param angle Angle - */ - public static void drawTickLabel_YRight(float x, float y, Font font, String text, Color color, float angle, Graphics2D g) { - g.setColor(color); - g.setFont(font); - Dimension labSize = Draw.getStringDimension(text, g); - if (angle == 0) { - y += (float) labSize.getHeight() * 0.5f; - Draw.drawString(g, text, x, y); - } else { - AffineTransform tempTrans = g.getTransform(); - //AffineTransform myTrans = new AffineTransform(); - AffineTransform myTrans = (AffineTransform) tempTrans.clone(); - if (angle == 90) { - x += (float) (labSize.getHeight()); - y += (float) (labSize.getWidth() * 0.5); - } else if (angle == -90) { - y -= (float) (labSize.getWidth() * 0.5); - } else if (angle > 0) { - x += (float) (labSize.getHeight() * Math.abs(Math.sin(Math.toRadians(angle)))); - y += (float) (labSize.getHeight() * Math.cos(Math.toRadians(angle)) * 0.5); - } else { - y += (float) (labSize.getHeight() * Math.cos(Math.toRadians(angle)) * 0.5); - } - //myTrans.translate(tempTrans.getTranslateX() + x, tempTrans.getTranslateY() + y); - myTrans.translate(x, y); - myTrans.rotate(-angle * Math.PI / 180); - g.setTransform(myTrans); - Draw.drawString(g, text, 0, 0); - g.setTransform(tempTrans); - } - } - -// /** -// * Draw label point (270 degress) -// * -// * @param x X -// * @param y Y -// * @param font Font -// * @param text Text -// * @param color Color -// * @param g Graphics2D -// * @param rect The extent rectangle -// */ -// public static void drawLabelPoint_270(float x, float y, Font font, String text, Color color, Graphics2D g, Rectangle rect) { -// //FontMetrics metrics = g.getFontMetrics(font); -// //Dimension labSize = new Dimension(metrics.stringWidth(text), metrics.getHeight()); -// g.setFont(font); -// Dimension labSize = Draw.getStringDimension(text, g); -// -// float inx = x; -// float iny = y; -// -// AffineTransform tempTrans = g.getTransform(); -// float angle = 270; -// g.translate(x, y); -// g.rotate(angle * Math.PI / 180); -// x = 0; -// y = 0; -// -// g.setColor(color); -// //g.setFont(font); -// if (Draw.isLaTeX(text)) { -// //Draw.drawLaTeX(g, text, x - labSize.width / 2, y - labSize.height); -// Draw.drawLaTeX(g, text, x - labSize.width / 2, y + labSize.height / 2, true); -// } else { -// g.drawString(text, x - labSize.width / 2, y + labSize.height * 3 / 4); -// } -// -// if (rect != null) { -// rect.x = (int) x; -// rect.y = (int) y - labSize.height / 2; -// rect.width = (int) labSize.getWidth(); -// rect.height = (int) labSize.getHeight(); -// } -// -// g.setTransform(tempTrans); -// if (rect != null) { -// rect.x = (int) inx; -// rect.y = (int) iny; -// } -// } -// /** -// * Draw label point (270 degress) -// * -// * @param x X -// * @param y Y -// * @param font Font -// * @param text Text -// * @param color Color -// * @param g Graphics2D -// * @param rect The extent rectangle -// * @param useExternalFont If use external font -// */ -// public static void drawLabelPoint_270(float x, float y, Font font, String text, Color color, -// Graphics2D g, Rectangle rect, boolean useExternalFont) { -// //FontMetrics metrics = g.getFontMetrics(font); -// //Dimension labSize = new Dimension(metrics.stringWidth(text), metrics.getHeight()); -// g.setFont(font); -// Dimension labSize = Draw.getStringDimension(text, g); -// -// float inx = x; -// float iny = y; -// -// AffineTransform tempTrans = g.getTransform(); -// float angle = 270; -// g.translate(x, y); -// g.rotate(angle * Math.PI / 180); -// x = 0; -// y = 0; -// -// g.setColor(color); -// //g.setFont(font); -// if (Draw.isLaTeX(text)) { -// //Draw.drawLaTeX(g, text, x - labSize.width / 2, y - labSize.height); -// Draw.drawLaTeX(g, text, x - labSize.width / 2, y + labSize.height / 2, useExternalFont); -// } else { -// g.drawString(text, x - labSize.width / 2, y + labSize.height * 3 / 4); -// } -// -// if (rect != null) { -// rect.x = (int) x; -// rect.y = (int) y - labSize.height / 2; -// rect.width = (int) labSize.getWidth(); -// rect.height = (int) labSize.getHeight(); -// } -// -// g.setTransform(tempTrans); -// if (rect != null) { -// rect.x = (int) inx; -// rect.y = (int) iny; -// } -// } - /** - * Draw station model shape - * - * @param aColor Color - * @param foreColor Foreground color - * @param sP Start point - * @param aSM Station model shape - * @param g Graphics2D - * @param size Size - * @param cut Cut - */ - public static void drawStationModel(Color aColor, Color foreColor, PointF sP, StationModelShape aSM, Graphics2D g, - float size, float cut) { - PointF sPoint = new PointF(0, 0); - g.setColor(aColor); - Font wFont; - String text; - - //Draw cloud coverage - if (aSM.cloudCoverage.cloudCover >= 0 && aSM.cloudCoverage.cloudCover <= 9) { - //Draw wind barb - drawWindBarb(aColor, sP, aSM.windBarb, g, size, cut); - text = String.valueOf((char) (aSM.cloudCoverage.cloudCover + 197)); - wFont = new Font("Weather", Font.PLAIN, (int) size); - FontMetrics metrics = g.getFontMetrics(wFont); - Dimension textSize = new Dimension(metrics.stringWidth(text), metrics.getHeight()); - sPoint.X = sP.X - (float) textSize.getWidth() / 2; - sPoint.Y = sP.Y - (float) textSize.getHeight() / 2; - g.setFont(wFont); - g.drawString(text, sPoint.X, sPoint.Y + metrics.getHeight() * 3 / 4); - } else { - //Draw wind barb - drawWindBarb(aColor, sP, aSM.windBarb, g, size); - - wFont = new Font("Arial", Font.PLAIN, (int) (size / 4 * 3)); - text = "M"; - FontMetrics metrics = g.getFontMetrics(wFont); - Dimension textSize = new Dimension(metrics.stringWidth(text), metrics.getHeight()); - sPoint.X = sP.X - (float) textSize.getWidth() / 2; - sPoint.Y = sP.Y - (float) textSize.getHeight() / 3 * 2; - g.setFont(wFont); - g.drawString(text, sPoint.X, sPoint.Y + metrics.getHeight() * 3 / 4); - wFont = new Font("Weather", Font.PLAIN, (int) size); - text = String.valueOf((char) 197); - metrics = g.getFontMetrics(wFont); - textSize = new Dimension(metrics.stringWidth(text), metrics.getHeight()); - sPoint.X = sP.X - (float) textSize.getWidth() / 2; - sPoint.Y = sP.Y - (float) textSize.getHeight() / 2; - g.setFont(wFont); - g.drawString(text, sPoint.X, sPoint.Y + metrics.getHeight() * 3 / 4); - } - - //Draw weather - if (aSM.weatherSymbol.weather >= 4 && aSM.weatherSymbol.weather <= 99) { - wFont = new Font("Weather", Font.PLAIN, (int) size); - text = String.valueOf((char) (aSM.weatherSymbol.weather + 100)); - FontMetrics metrics = g.getFontMetrics(wFont); - Dimension textSize = new Dimension(metrics.stringWidth(text), metrics.getHeight()); - sPoint.X = sP.X - (float) textSize.getHeight() - aSM.size / 2; - sPoint.Y = sP.Y - (float) textSize.getHeight() / 2; - text = String.valueOf((char) (aSM.weatherSymbol.weather + 28)); - if (aSM.weatherSymbol.weather == 99) { - text = String.valueOf((char) (aSM.weatherSymbol.weather + 97)); - } - g.setFont(wFont); - g.drawString(text, sPoint.X, sPoint.Y + metrics.getHeight() * 3 / 4); - } - - wFont = new Font("Arial", Font.PLAIN, (int) (size / 4 * 3)); - g.setFont(wFont); - FontMetrics metrics = g.getFontMetrics(wFont); - //Draw temperature - if (Math.abs(aSM.temperature) < 1000) { - g.setColor(Color.red); - text = String.valueOf(aSM.temperature); - Dimension textSize = new Dimension(metrics.stringWidth(text), metrics.getHeight()); - sPoint.X = sP.X - (float) textSize.getWidth() - size / 3; - sPoint.Y = sP.Y - (float) textSize.getHeight() - size / 3; - g.drawString(text, sPoint.X, sPoint.Y + metrics.getHeight() * 3 / 4); - } - - //Draw dew point - if (Math.abs(aSM.dewPoint) < 1000) { - g.setColor(Color.green); - text = String.valueOf(aSM.dewPoint); - Dimension textSize = new Dimension(metrics.stringWidth(text), metrics.getHeight()); - sPoint.X = sP.X - (float) textSize.getWidth() - size / 3; - sPoint.Y = sP.Y + size / 3; - g.drawString(text, sPoint.X, sPoint.Y + metrics.getHeight() * 3 / 4); - } - - //Draw pressure - if (Math.abs(aSM.pressure) < 1000) { - g.setColor(foreColor); - text = String.format("%1$03d", aSM.pressure); - sPoint.X = sP.X + size / 3; - sPoint.Y = sP.Y - metrics.getHeight() - size / 3; - g.drawString(text, sPoint.X, sPoint.Y + metrics.getHeight() * 3 / 4); - } - } - - // - // - /** - * Draw graphic - * - * @param points The points - * @param aGraphic The graphic - * @param g Graphics2D - * @param isEditingVertice Is editing vertice - */ - public static void drawGrahpic(PointF[] points, Graphic aGraphic, Graphics2D g, boolean isEditingVertice) { - Rectangle rect = new Rectangle(); - Extent aExtent = MIMath.getPointFsExtent(points); - rect.x = (int) aExtent.minX; - rect.y = (int) aExtent.minY; - rect.width = (int) aExtent.getWidth(); - rect.height = (int) aExtent.getHeight(); - - switch (aGraphic.getShape().getShapeType()) { - case Point: - switch (aGraphic.getLegend().getBreakType()) { - case PointBreak: - drawPoint((PointF) points[0].clone(), (PointBreak) aGraphic.getLegend(), g); - int aSize = (int) ((PointBreak) aGraphic.getLegend()).getSize() / 2 + 2; - rect.x = (int) points[0].X - aSize; - rect.y = (int) points[0].Y - aSize; - rect.width = aSize * 2; - rect.height = aSize * 2; - break; - case LabelBreak: - drawLabelPoint((PointF) points[0].clone(), (LabelBreak) aGraphic.getLegend(), g, rect); - break; - } - break; - case Polyline: - if (aGraphic.getLegend().getBreakType() == BreakTypes.ColorBreakCollection) { - drawPolyline(points, (ColorBreakCollection) aGraphic.getLegend(), g); - } else { - drawPolyline(points, (PolylineBreak) aGraphic.getLegend(), g); - } - break; - case Polygon: - PolygonShape pgs = (PolygonShape) aGraphic.getShape().clone(); - pgs.setPoints_keep(points); - drawPolygonShape(pgs, (PolygonBreak) aGraphic.getLegend(), g); - break; - case Rectangle: - drawPolygon(points, (PolygonBreak) aGraphic.getLegend(), g); - break; - case CurveLine: - drawCurveLine(points, (PolylineBreak) aGraphic.getLegend(), g); - break; - case CurvePolygon: - drawCurvePolygon(points, (PolygonBreak) aGraphic.getLegend(), g); - break; - case Circle: - drawCircle(points, (PolygonBreak) aGraphic.getLegend(), g); - break; - case Ellipse: - EllipseShape eshape = (EllipseShape) aGraphic.getShape(); - drawEllipse(points, eshape.getAngle(), (PolygonBreak) aGraphic.getLegend(), g); - break; - } - - //Draw selected rectangle - if (aGraphic.getShape().isSelected()) { - if (isEditingVertice) { - drawSelectedVertices(g, points); - } else { - float[] dashPattern = new float[]{2.0F, 1.0F}; - g.setColor(Color.cyan); - g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 10.0f, dashPattern, 0.0f)); - g.draw(rect); - switch (aGraphic.getShape().getShapeType()) { - case Point: - if (aGraphic.getLegend().getBreakType() == BreakTypes.PointBreak) { - drawSelectedCorners(g, rect); - } - break; - case Polyline: - case CurveLine: - case Polygon: - case Rectangle: - case Ellipse: - case CurvePolygon: - drawSelectedCorners(g, rect); - drawSelectedEdgeCenters(g, rect); - break; - case Circle: - drawSelectedCorners(g, rect); - break; - } - } - } - } - - /** - * Draw polyline - * - * @param points Points list - * @param g Graphics2D - */ - public static void drawPolyline(List points, Graphics2D g) { - GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, points.size()); - for (int i = 0; i < points.size(); i++) { - if (i == 0) { - path.moveTo(points.get(i).X, points.get(i).Y); - } else { - path.lineTo(points.get(i).X, points.get(i).Y); - } - } - - g.draw(path); - } - - /** - * Draw polyline - * - * @param points The points array - * @param g Graphics2D - */ - public static void drawPolyline(PointF[] points, Graphics2D g) { - GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, points.length); - for (int i = 0; i < points.length; i++) { - if (i == 0) { - path.moveTo(points[i].X, points[i].Y); - } else { - path.lineTo(points[i].X, points[i].Y); - } - } - - g.draw(path); - } - - /** - * Draw polyline - * - * @param points The points array - * @param g Graphics2D - */ - public static void drawPolyline(PointD[] points, Graphics2D g) { - GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, points.length); - for (int i = 0; i < points.length; i++) { - if (i == 0) { - path.moveTo(points[i].X, points[i].Y); - } else { - path.lineTo(points[i].X, points[i].Y); - } - } - - g.draw(path); - } - - /** - * Draw polyline - * - * @param points The points array - * @param g Graphics2D - * @param mvIdx Missing value index list - */ - public static void drawPolyline(PointF[] points, Graphics2D g, List mvIdx) { - GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, points.length - mvIdx.size()); - boolean isNew = true; - for (int i = 0; i < points.length; i++) { - if (mvIdx.contains(i)) { - isNew = true; - continue; - } - if (isNew) { - path.moveTo(points[i].X, points[i].Y); - isNew = false; - } else { - path.lineTo(points[i].X, points[i].Y); - } - } - - g.draw(path); - } - - /** - * Fill polygon - * - * @param points The points array - * @param g Graphics2D - * @param aPGB Polygon break - */ - public static void fillPolygon(PointF[] points, Graphics2D g, PolygonBreak aPGB) { - GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, points.length); - for (int i = 0; i < points.length; i++) { - if (i == 0) { - path.moveTo(points[i].X, points[i].Y); - } else { - path.lineTo(points[i].X, points[i].Y); - } - } - path.closePath(); - - if (aPGB != null) { - if (aPGB.isUsingHatchStyle()) { - int size = aPGB.getStyleSize(); - BufferedImage bi = getHatchImage(aPGB.getStyle(), size, aPGB.getColor(), aPGB.getBackColor()); - Rectangle2D rect = new Rectangle2D.Double(0, 0, size, size); - g.setPaint(new TexturePaint(bi, rect)); - g.fill(path); - } else { - g.fill(path); - } - } else { - g.fill(path); - } - } - - /** - * Fill polygon - * - * @param points The points array - * @param g Graphics2D - * @param aPGB Polygon break - */ - public static void fillPolygon(PointD[] points, Graphics2D g, PolygonBreak aPGB) { - GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, points.length); - for (int i = 0; i < points.length; i++) { - if (i == 0) { - path.moveTo(points[i].X, points[i].Y); - } else { - path.lineTo(points[i].X, points[i].Y); - } - } - path.closePath(); - - if (aPGB != null) { - if (aPGB.isUsingHatchStyle()) { - int size = aPGB.getStyleSize(); - BufferedImage bi = getHatchImage(aPGB.getStyle(), size, aPGB.getColor(), aPGB.getBackColor()); - Rectangle2D rect = new Rectangle2D.Double(0, 0, size, size); - g.setPaint(new TexturePaint(bi, rect)); - g.fill(path); - } else { - g.fill(path); - } - } else { - g.fill(path); - } - } - - /** - * Draw polygon shape with screen coordinates - * - * @param pgs Polygon shape - * @param pgb Polygon break - * @param g Graphics2D - */ - public static void drawPolygonShape(PolygonShape pgs, PolygonBreak pgb, Graphics2D g) { - for (Polygon polygon : pgs.getPolygons()) { - drawPolygon(polygon, pgb, g); - } - } - - /** - * Draw polygon with screen coordinate - * - * @param aPG Polygon shape - * @param aPGB Polygon break - * @param g Graphics2D - */ - public static void drawPolygon(Polygon aPG, PolygonBreak aPGB, Graphics2D g) { - int len = aPG.getOutLine().size(); - GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, len); - path.moveTo(0, 0); - PointD wPoint; - for (int i = 0; i < aPG.getOutLine().size(); i++) { - wPoint = aPG.getOutLine().get(i); - if (i == 0) { - path.moveTo(wPoint.X, wPoint.Y); - } else { - path.lineTo(wPoint.X, wPoint.Y); - } - } - - List newPList; - if (aPG.hasHole()) { - for (int h = 0; h < aPG.getHoleLines().size(); h++) { - newPList = (List) aPG.getHoleLines().get(h); - for (int j = 0; j < newPList.size(); j++) { - wPoint = newPList.get(j); - if (j == 0) { - path.moveTo(wPoint.X, wPoint.Y); - } else { - path.lineTo(wPoint.X, wPoint.Y); - } - } - } - } - path.closePath(); - - if (aPGB.isDrawFill()) { - //int alpha = (int)((1 - (double)transparencyPerc / 100.0) * 255); - //Color aColor = Color.FromArgb(alpha, aPGB.Color); - Color aColor = aPGB.getColor(); - if (aPGB.isUsingHatchStyle()) { - int size = aPGB.getStyleSize(); - BufferedImage bi = getHatchImage(aPGB.getStyle(), size, aPGB.getColor(), aPGB.getBackColor()); - Rectangle2D rect = new Rectangle2D.Double(0, 0, size, size); - g.setPaint(new TexturePaint(bi, rect)); - g.fill(path); - } else { - g.setColor(aColor); - g.fill(path); - } - } - - if (aPGB.isDrawOutline()) { - BasicStroke pen = new BasicStroke(aPGB.getOutlineSize()); - g.setStroke(pen); - g.setColor(aPGB.getOutlineColor()); - g.draw(path); - } - } - - /** - * Draw polygon - * - * @param points The points - * @param aPGB The polygon break - * @param g Graphics2D - */ - public static void drawPolygon(PointF[] points, PolygonBreak aPGB, Graphics2D g) { - if (aPGB.isDrawFill()) { - g.setColor(aPGB.getColor()); - fillPolygon(points, g, aPGB); - } - if (aPGB.isDrawOutline()) { - g.setColor(aPGB.getOutlineColor()); - g.setStroke(new BasicStroke(aPGB.getOutlineSize())); - drawPolyline(points, g); - } - } - - /** - * Draw polygon - * - * @param points The points - * @param aPGB The polygon break - * @param g Graphics2D - */ - public static void drawPolygon(PointD[] points, PolygonBreak aPGB, Graphics2D g) { - if (aPGB.isDrawFill()) { - g.setColor(aPGB.getColor()); - fillPolygon(points, g, aPGB); - } - if (aPGB.isDrawOutline()) { - g.setColor(aPGB.getOutlineColor()); - g.setStroke(new BasicStroke(aPGB.getOutlineSize())); - drawPolyline(points, g); - } - } - - /** - * Draw polygon - * - * @param points The points - * @param aColor Fill oclor - * @param outlineColor Outline color - * @param drawFill - * @param drawOutline - * @param g - */ - public static void drawPolygon(PointF[] points, Color aColor, Color outlineColor, - boolean drawFill, boolean drawOutline, Graphics2D g) { - if (drawFill) { - g.setColor(aColor); - fillPolygon(points, g, null); - } - if (drawOutline) { - g.setColor(outlineColor); - drawPolyline(points, g); - } - } - - /** - * Draw polygon - * - * @param points The points - * @param aColor Fill oclor - * @param outlineColor Outline color - * @param drawFill - * @param drawOutline - * @param g - */ - public static void drawPolygon(PointD[] points, Color aColor, Color outlineColor, - boolean drawFill, boolean drawOutline, Graphics2D g) { - if (drawFill) { - g.setColor(aColor); - fillPolygon(points, g, null); - } - if (drawOutline) { - g.setColor(outlineColor); - drawPolyline(points, g); - } - } - - /** - * Get hatch style image - * - * @param style Hatch style - * @param size - * @param stripeColor Stripe color - * @param backColor Background color - * @return Hatch style image - */ - public static BufferedImage getHatchImage(HatchStyle style, int size, Color stripeColor, Color backColor) { - BufferedImage bi = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); - Graphics2D g2 = bi.createGraphics(); - int alpha = backColor.getAlpha(); - if (alpha > 0) { - g2.setColor(backColor); - g2.fillRect(0, 0, size, size); - } - g2.setColor(stripeColor); - switch (style) { - case HORIZONTAL: - g2.drawLine(0, size / 2, size, size / 2); - break; - case VERTICAL: - g2.drawLine(size / 2, 0, size / 2, size); - break; - case FORWARD_DIAGONAL: - g2.drawLine(0, 0, size, size); - break; - case BACKWARD_DIAGONAL: - //g2.drawLine(size, 0, 0, size); - g2.draw(new Line2D.Float(0, size, size, 0)); - break; - case CROSS: - g2.drawLine(0, size / 2, size, size / 2); - g2.drawLine(size / 2, 0, size / 2, size); - break; - case DIAGONAL_CROSS: - g2.drawLine(0, 0, size, size); - g2.drawLine(0, size, size, 0); - break; - case DOT: - g2.fill(new Ellipse2D.Float(size / 2, size / 2, 2, 2)); - break; - } - return bi; - } - - /** - * Get dash pattern from LineStyle - * - * @param style The line style - * @return Dash pattern array - */ - public static float[] getDashPattern(LineStyles style) { - float[] dashPattern = {4.0f}; - switch (style) { - case SOLID: - dashPattern = null; - break; - case DASH: - dashPattern = new float[]{4.0f}; - break; - case DOT: - dashPattern = new float[]{2.0f}; - break; - case DASHDOT: - dashPattern = new float[]{10, 6, 2, 6}; - break; - case DASHDOTDOT: - dashPattern = new float[]{10, 6, 2, 6, 2, 6}; - break; - } - - return dashPattern; - } - - /** - * Draw arrow polyline - * - * @param points The points - * @param alb The arrow line break - * @param g Graphics2D - */ - public static void drawArrowLine(PointF[] points, ArrowLineBreak alb, Graphics2D g) { - int n = points.length; - PointF aPoint = points[n - 2]; - PointF bPoint = points[n - 1]; - double U = bPoint.X - aPoint.X; - double V = bPoint.Y - aPoint.Y; - double radian = Math.atan(V / U); - double angle = radian * 180 / Math.PI; - angle = angle + 90; - if (U < 0) { - angle = angle + 180; - } - if (angle >= 360) { - angle = angle - 360; - } - double dx = alb.getArrowHeadLength() * Math.cos(radian) * (1 - alb.getArrowOverhang()); - double dy = alb.getArrowHeadLength() * Math.sin(radian) * (1 - alb.getArrowOverhang()); - if (angle > 180) { - dx = -dx; - dy = -dy; - } - points[n - 1] = new PointF(bPoint.X - (float) dx, bPoint.Y - (float) dy); - - g.setColor(alb.getColor()); - float[] dashPattern = getDashPattern(alb.getStyle()); - g.setStroke(new BasicStroke(alb.getWidth(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dashPattern, 0.0f)); - drawPolyline(points, g); - - //Draw symbol - if (alb.getDrawSymbol()) { - Object rend = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING); - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - Rectangle clip = g.getClipBounds(); - PointF p; - if (clip != null) { - g.setClip(null); - for (int i = 0; i < points.length; i++) { - p = new PointF(points[i].X, points[i].Y); - if (p.X >= clip.x && p.X <= clip.x + clip.width && p.Y >= clip.y && p.Y <= clip.y + clip.height) { - if (i % alb.getSymbolInterval() == 0) { - drawPoint(alb.getSymbolStyle(), p, alb.getSymbolFillColor(), alb.getSymbolColor(), - alb.getSymbolSize(), true, alb.isFillSymbol(), g); - } - } - } - g.setClip(clip); - } else { - for (int i = 0; i < points.length; i++) { - if (i % alb.getSymbolInterval() == 0) { - p = new PointF(points[i].X, points[i].Y); - drawPoint(alb.getSymbolStyle(), p, alb.getSymbolFillColor(), alb.getSymbolColor(), - alb.getSymbolSize(), true, alb.isFillSymbol(), g); - } - } - } - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, rend); - } - - //Draw arrow - Draw.drawArraw(g, bPoint, angle, alb.getArrowHeadLength(), alb.getArrowHeadWidth(), - alb.getArrowOverhang(), alb.getArrowFillColor(), alb.getArrowOutlineColor()); - } - - /** - * Draw streamline - * - * @param points The points - * @param alb The streamline break - * @param g Graphics2D - */ - public static void drawStreamline(PointF[] points, StreamlineBreak alb, Graphics2D g) { - g.setColor(alb.getColor()); - float[] dashPattern = getDashPattern(alb.getStyle()); - g.setStroke(new BasicStroke(alb.getWidth(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dashPattern, 0.0f)); - drawPolyline(points, g); - - PointF p1, p2; - double u, v, radian, angle; - int interval = alb.getInterval() * 3; - for (int i = 0; i < points.length; i++) { - if (i > 0 && i < points.length - 2 && i % interval == 0) { - //Draw arraw - p1 = points[i]; - p2 = points[i + 1]; - u = p2.X - p1.X; - v = p2.Y - p1.Y; - radian = Math.atan(v / u); - angle = radian * 180 / Math.PI; - angle = angle + 90; - if (u < 0) { - angle = angle + 180; - } - if (angle >= 360) { - angle = angle - 360; - } - - //Draw arrow - Draw.drawArraw(g, p1, angle, alb.getArrowHeadLength(), alb.getArrowHeadWidth(), - alb.getArrowOverhang(), alb.getArrowFillColor(), alb.getArrowOutlineColor()); - } - } - - //Draw symbol - if (alb.getDrawSymbol()) { - Object rend = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING); - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - Rectangle clip = g.getClipBounds(); - PointF p; - if (clip != null) { - g.setClip(null); - for (int i = 0; i < points.length; i++) { - p = new PointF(points[i].X, points[i].Y); - if (p.X >= clip.x && p.X <= clip.x + clip.width && p.Y >= clip.y && p.Y <= clip.y + clip.height) { - if (i % alb.getSymbolInterval() == 0) { - drawPoint(alb.getSymbolStyle(), p, alb.getSymbolFillColor(), alb.getSymbolColor(), - alb.getSymbolSize(), true, alb.isFillSymbol(), g); - } - } - } - g.setClip(clip); - } else { - for (int i = 0; i < points.length; i++) { - if (i % alb.getSymbolInterval() == 0) { - p = new PointF(points[i].X, points[i].Y); - drawPoint(alb.getSymbolStyle(), p, alb.getSymbolFillColor(), alb.getSymbolColor(), - alb.getSymbolSize(), true, alb.isFillSymbol(), g); - } - } - } - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, rend); - } - } - - /** - * Draw polyline - * - * @param points The points - * @param aPLB The polyline break - * @param g Graphics2D - */ - public static void drawPolyline(PointF[] points, PolylineBreak aPLB, Graphics2D g) { - if (aPLB instanceof StreamlineBreak) { - drawStreamline(points, (StreamlineBreak) aPLB, g); - } else if (aPLB instanceof ArrowLineBreak) { - drawArrowLine(points, (ArrowLineBreak) aPLB, g); - } else { - if (aPLB.isUsingDashStyle()) { - g.setColor(aPLB.getColor()); - float[] dashPattern = getDashPattern(aPLB.getStyle()); - g.setStroke(new BasicStroke(aPLB.getWidth(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dashPattern, 0.0f)); - drawPolyline(points, g); - - //Draw symbol - if (aPLB.getDrawSymbol()) { - Object rend = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING); - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - Rectangle clip = g.getClipBounds(); - PointF p; - if (clip != null) { - g.setClip(null); - for (int i = 0; i < points.length; i++) { - p = new PointF(points[i].X, points[i].Y); - if (p.X >= clip.x && p.X <= clip.x + clip.width && p.Y >= clip.y && p.Y <= clip.y + clip.height) { - if (i % aPLB.getSymbolInterval() == 0) { - drawPoint(aPLB.getSymbolStyle(), p, aPLB.getSymbolFillColor(), aPLB.getSymbolColor(), - aPLB.getSymbolSize(), true, aPLB.isFillSymbol(), g); - } - } - } - g.setClip(clip); - } else { - for (int i = 0; i < points.length; i++) { - if (i % aPLB.getSymbolInterval() == 0) { - p = new PointF(points[i].X, points[i].Y); - drawPoint(aPLB.getSymbolStyle(), p, aPLB.getSymbolFillColor(), aPLB.getSymbolColor(), - aPLB.getSymbolSize(), true, aPLB.isFillSymbol(), g); - } - } - } - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, rend); - } - } else { - Polyline aPLine = new Polyline(); - aPLine.setPoints(points); - List pos = aPLine.getPositions(30); - float aSize = 16; - int i; - switch (aPLB.getStyle()) { - case COLDFRONT: - if (pos != null) { - PointBreak aPB = new PointBreak(); - aPB.setSize(aSize); - aPB.setColor(Color.blue); - aPB.setStyle(PointStyle.UpTriangle); - aPB.setOutlineColor(Color.blue); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - for (i = 0; i < pos.size(); i++) { - aPB.setAngle((float) pos.get(i)[2]); - drawPoint_Simple_Up(new PointF((float) pos.get(i)[0], (float) pos.get(i)[1]), aPB, g); - } - } - - g.setColor(Color.blue); - g.setStroke(new BasicStroke(aPLB.getWidth())); - drawPolyline(points, g); - break; - case WARMFRONT: - if (pos != null) { - PointBreak aPB = new PointBreak(); - aPB.setSize(aSize); - aPB.setColor(Color.red); - aPB.setStyle(PointStyle.UpSemiCircle); - aPB.setOutlineColor(Color.red); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - for (i = 0; i < pos.size(); i++) { - aPB.setAngle((float) pos.get(i)[2]); - drawPoint_Simple(new PointF((float) pos.get(i)[0], (float) pos.get(i)[1]), aPB, g); - } - } - - g.setColor(Color.red); - g.setStroke(new BasicStroke(aPLB.getWidth())); - drawPolyline(points, g); - break; - case OCCLUDEDFRONT: - Color aColor = new Color(255, 0, 255); - if (pos != null) { - PointBreak aPB = new PointBreak(); - aPB.setSize(aSize); - aPB.setColor(aColor); - aPB.setStyle(PointStyle.UpTriangle); - aPB.setOutlineColor(aColor); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - for (i = 0; i < pos.size(); i += 2) { - aPB.setAngle((float) pos.get(i)[2]); - drawPoint_Simple_Up(new PointF((float) pos.get(i)[0], (float) pos.get(i)[1]), aPB, g); - } - - aPB = new PointBreak(); - aPB.setSize(aSize); - aPB.setColor(aColor); - aPB.setStyle(PointStyle.UpSemiCircle); - aPB.setOutlineColor(aColor); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - for (i = 1; i < pos.size(); i += 2) { - aPB.setAngle((float) pos.get(i)[2]); - drawPoint_Simple(new PointF((float) pos.get(i)[0], (float) pos.get(i)[1]), aPB, g); - } - } - - g.setColor(aColor); - g.setStroke(new BasicStroke(aPLB.getWidth())); - drawPolyline(points, g); - break; - case STATIONARYFRONT: - if (pos != null) { - PointBreak aPB = new PointBreak(); - aPB.setSize(aSize); - aPB.setColor(Color.blue); - aPB.setStyle(PointStyle.UpTriangle); - aPB.setOutlineColor(Color.blue); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - for (i = 0; i < pos.size(); i += 2) { - aPB.setAngle((float) pos.get(i)[2]); - drawPoint_Simple_Up(new PointF((float) pos.get(i)[0], (float) pos.get(i)[1]), aPB, g); - } - - aPB = new PointBreak(); - aPB.setSize(aSize); - aPB.setColor(Color.red); - aPB.setStyle(PointStyle.DownSemiCircle); - aPB.setOutlineColor(Color.red); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - for (i = 1; i < pos.size(); i += 2) { - aPB.setAngle((float) pos.get(i)[2]); - drawPoint_Simple(new PointF((float) pos.get(i)[0], (float) pos.get(i)[1]), aPB, g); - } - } - - g.setColor(Color.blue); - g.setStroke(new BasicStroke(aPLB.getWidth())); - drawPolyline(points, g); - break; - case ARROWLINE: - g.setColor(aPLB.getColor()); - g.setStroke(new BasicStroke(aPLB.getWidth())); - //float[] dashPattern = getDashPattern(aPLB.getStyle()); - //g.setStroke(new BasicStroke(aPLB.getSize(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dashPattern, 0.0f)); - drawPolyline(points, g); - - int n = points.length; - PointF aPoint = points[n - 2]; - PointF bPoint = points[n - 1]; - double U = bPoint.X - aPoint.X; - double V = bPoint.Y - aPoint.Y; - double angle = Math.atan((V) / (U)) * 180 / Math.PI; - angle = angle + 90; - if (U < 0) { - angle = angle + 180; - } - - if (angle >= 360) { - angle = angle - 360; - } - - Draw.drawArraw(g, bPoint, angle, 8); - break; - } - } - } - } - - /** - * Draw polyline - * - * @param points The points - * @param pbc The polyline break collection - * @param g Graphics2D - */ - public static void drawPolyline(PointF[] points, ColorBreakCollection pbc, Graphics2D g) { - GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, points.length); - PointF p; - PolylineBreak aPLB; - List drawPs = new ArrayList<>(); - for (int i = 0; i < points.length; i++) { - p = points[i]; - if (i == 0) { - path.moveTo(p.X, p.Y); - } else { - path.lineTo(p.X, p.Y); - - aPLB = (PolylineBreak) pbc.get(i); - Color aColor = aPLB.getColor(); - Float size = aPLB.getWidth(); - float[] dashPattern = getDashPattern(aPLB.getStyle()); - BasicStroke pen = new BasicStroke(size, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dashPattern, 0.0f); - g.setColor(aColor); - g.setStroke(pen); - g.draw(path); - path.reset(); - path.moveTo(p.X, p.Y); - //Draw symbol - if (aPLB.getDrawSymbol()) { - Object rend = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING); - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - for (int j = 0; j < drawPs.size(); j++) { - Draw.drawPoint(aPLB.getSymbolStyle(), p, aPLB.getSymbolFillColor(), aPLB.getSymbolColor(), - aPLB.getSymbolSize(), true, aPLB.isFillSymbol(), g); - } - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, rend); - } - } - drawPs.add(p); - } - } - - /** - * Draw polyline - * - * @param points The points - * @param aPLB The polyline break - * @param g Graphics2D - * @param mvIdx Missing value index list - */ - public static void drawPolyline(PointF[] points, PolylineBreak aPLB, Graphics2D g, List mvIdx) { - if (aPLB.isUsingDashStyle()) { - g.setColor(aPLB.getColor()); - float[] dashPattern = getDashPattern(aPLB.getStyle()); - g.setStroke(new BasicStroke(aPLB.getWidth(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dashPattern, 0.0f)); - if (mvIdx.size() > 0) { - drawPolyline(points, g, mvIdx); - } else { - drawPolyline(points, g); - } - - //Draw symbol - if (aPLB.getDrawSymbol()) { - Object rend = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING); - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - - Rectangle clip = g.getClipBounds(); - PointF p; - if (clip != null) { - g.setClip(null); - for (int i = 0; i < points.length; i++) { - p = new PointF(points[i].X, points[i].Y); - if (p.X >= clip.x && p.X <= clip.x + clip.width && p.Y >= clip.y && p.Y <= clip.y + clip.height) { - if (mvIdx.contains(i)) { - continue; - } - if (i % aPLB.getSymbolInterval() == 0) { - drawPoint(aPLB.getSymbolStyle(), p, aPLB.getSymbolFillColor(), aPLB.getSymbolColor(), - aPLB.getSymbolSize(), true, aPLB.isFillSymbol(), g); - } - } - } - g.setClip(clip); - } else { - for (int i = 0; i < points.length; i++) { - if (mvIdx.contains(i)) { - continue; - } - - if (i % aPLB.getSymbolInterval() == 0) { - p = new PointF(points[i].X, points[i].Y); - drawPoint(aPLB.getSymbolStyle(), p, aPLB.getSymbolFillColor(), aPLB.getSymbolColor(), - aPLB.getSymbolSize(), true, aPLB.isFillSymbol(), g); - } - } - } - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, rend); - } - } else { - Polyline aPLine = new Polyline(); - aPLine.setPoints(points); - List pos = aPLine.getPositions(30); - float aSize = 16; - int i; - switch (aPLB.getStyle()) { - case COLDFRONT: - if (pos != null) { - PointBreak aPB = new PointBreak(); - aPB.setSize(aSize); - aPB.setColor(Color.blue); - aPB.setStyle(PointStyle.UpTriangle); - aPB.setOutlineColor(Color.blue); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - for (i = 0; i < pos.size(); i++) { - aPB.setAngle((float) pos.get(i)[2]); - drawPoint_Simple_Up(new PointF((float) pos.get(i)[0], (float) pos.get(i)[1]), aPB, g); - } - } - - g.setColor(Color.blue); - g.setStroke(new BasicStroke(aPLB.getWidth())); - drawPolyline(points, g); - break; - case WARMFRONT: - if (pos != null) { - PointBreak aPB = new PointBreak(); - aPB.setSize(aSize); - aPB.setColor(Color.red); - aPB.setStyle(PointStyle.UpSemiCircle); - aPB.setOutlineColor(Color.red); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - for (i = 0; i < pos.size(); i++) { - aPB.setAngle((float) pos.get(i)[2]); - drawPoint_Simple(new PointF((float) pos.get(i)[0], (float) pos.get(i)[1]), aPB, g); - } - } - - g.setColor(Color.red); - g.setStroke(new BasicStroke(aPLB.getWidth())); - drawPolyline(points, g); - break; - case OCCLUDEDFRONT: - Color aColor = new Color(255, 0, 255); - if (pos != null) { - PointBreak aPB = new PointBreak(); - aPB.setSize(aSize); - aPB.setColor(aColor); - aPB.setStyle(PointStyle.UpTriangle); - aPB.setOutlineColor(aColor); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - for (i = 0; i < pos.size(); i += 2) { - aPB.setAngle((float) pos.get(i)[2]); - drawPoint_Simple_Up(new PointF((float) pos.get(i)[0], (float) pos.get(i)[1]), aPB, g); - } - - aPB = new PointBreak(); - aPB.setSize(aSize); - aPB.setColor(aColor); - aPB.setStyle(PointStyle.UpSemiCircle); - aPB.setOutlineColor(aColor); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - for (i = 1; i < pos.size(); i += 2) { - aPB.setAngle((float) pos.get(i)[2]); - drawPoint_Simple(new PointF((float) pos.get(i)[0], (float) pos.get(i)[1]), aPB, g); - } - } - - g.setColor(aColor); - g.setStroke(new BasicStroke(aPLB.getWidth())); - drawPolyline(points, g); - break; - case STATIONARYFRONT: - if (pos != null) { - PointBreak aPB = new PointBreak(); - aPB.setSize(aSize); - aPB.setColor(Color.blue); - aPB.setStyle(PointStyle.UpTriangle); - aPB.setOutlineColor(Color.blue); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - for (i = 0; i < pos.size(); i += 2) { - aPB.setAngle((float) pos.get(i)[2]); - drawPoint_Simple_Up(new PointF((float) pos.get(i)[0], (float) pos.get(i)[1]), aPB, g); - } - - aPB = new PointBreak(); - aPB.setSize(aSize); - aPB.setColor(Color.red); - aPB.setStyle(PointStyle.DownSemiCircle); - aPB.setOutlineColor(Color.red); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - for (i = 1; i < pos.size(); i += 2) { - aPB.setAngle((float) pos.get(i)[2]); - drawPoint_Simple(new PointF((float) pos.get(i)[0], (float) pos.get(i)[1]), aPB, g); - } - } - - g.setColor(Color.blue); - g.setStroke(new BasicStroke(aPLB.getWidth())); - drawPolyline(points, g); - break; - } - } - } - - /** - * Draw polyline symbol - * - * @param aP The point - * @param width The width - * @param height The height - * @param aPLB The polyline break - * @param g Graphics2D - */ - public static void drawPolylineSymbol(PointF aP, float width, float height, PolylineBreak aPLB, Graphics2D g) { - if (aPLB.isUsingDashStyle()) { - PointF[] points = new PointF[4]; - PointF aPoint = new PointF(0, 0); - aPoint.X = aP.X - width / 2; - aPoint.Y = aP.Y + height / 2; - points[0] = aPoint; - aPoint = new PointF(); - aPoint.X = aP.X - width / 6; - aPoint.Y = aP.Y - height / 2; - points[1] = aPoint; - aPoint = new PointF(); - aPoint.X = aP.X + width / 6; - aPoint.Y = aP.Y + height / 2; - points[2] = aPoint; - aPoint = new PointF(); - aPoint.X = aP.X + width / 2; - aPoint.Y = aP.Y - height / 2; - points[3] = aPoint; - - g.setColor(aPLB.getColor()); - float[] dashPattern = getDashPattern(aPLB.getStyle()); - g.setStroke(new BasicStroke(aPLB.getWidth(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dashPattern, 0.0f)); - - if (aPLB.getDrawPolyline()) { - drawPolyline(points, g); - } - g.setStroke(new BasicStroke()); - - //Draw symbol - if (aPLB.getDrawSymbol()) { - drawPoint(aPLB.getSymbolStyle(), points[1], aPLB.getSymbolFillColor(), aPLB.getSymbolColor(), aPLB.getSymbolSize(), true, aPLB.isFillSymbol(), g); - drawPoint(aPLB.getSymbolStyle(), points[2], aPLB.getSymbolFillColor(), aPLB.getSymbolColor(), aPLB.getSymbolSize(), true, aPLB.isFillSymbol(), g); - } - } else { - PointF[] points = new PointF[2]; - PointF aPoint = new PointF(0, 0); - aPoint.X = aP.X - width / 2; - aPoint.Y = aP.Y; - points[0] = aPoint; - aPoint = new PointF(); - aPoint.X = aP.X + width / 2; - aPoint.Y = aP.Y; - points[1] = aPoint; - float lineWidth = 2.0f; - switch (aPLB.getStyle()) { - case COLDFRONT: - PointBreak aPB = new PointBreak(); - aPB.setSize(14); - aPB.setColor(Color.blue); - aPB.setStyle(PointStyle.UpTriangle); - aPB.setOutlineColor(Color.blue); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - drawPoint_Simple(new PointF(aP.X - aPB.getSize() * 2 / 3, aP.Y - aPB.getSize() / 4), aPB, g); - drawPoint_Simple(new PointF(aP.X + aPB.getSize() * 2 / 3, aP.Y - aPB.getSize() / 4), aPB, g); - - g.setColor(Color.blue); - g.setStroke(new BasicStroke(lineWidth)); - drawPolyline(points, g); - break; - case WARMFRONT: - aPB = new PointBreak(); - aPB.setSize(14); - aPB.setColor(Color.red); - aPB.setStyle(PointStyle.UpSemiCircle); - aPB.setOutlineColor(Color.red); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - drawPoint_Simple(new PointF(aP.X - aPB.getSize() * 2 / 3, aP.Y), aPB, g); - drawPoint_Simple(new PointF(aP.X + aPB.getSize() * 2 / 3, aP.Y), aPB, g); - - g.setColor(Color.red); - g.setStroke(new BasicStroke(lineWidth)); - drawPolyline(points, g); - break; - case OCCLUDEDFRONT: - Color aColor = new Color(255, 0, 255); - aPB = new PointBreak(); - aPB.setSize(14); - aPB.setColor(aColor); - aPB.setStyle(PointStyle.UpTriangle); - aPB.setOutlineColor(aColor); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - drawPoint_Simple(new PointF(aP.X - aPB.getSize() * 2 / 3, aP.Y - aPB.getSize() / 4), aPB, g); - aPB = new PointBreak(); - aPB.setSize(14); - aPB.setColor(aColor); - aPB.setStyle(PointStyle.UpSemiCircle); - aPB.setOutlineColor(aColor); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - drawPoint_Simple(new PointF(aP.X + aPB.getSize() * 2 / 3, aP.Y), aPB, g); - - g.setColor(aColor); - g.setStroke(new BasicStroke(lineWidth)); - drawPolyline(points, g); - break; - case STATIONARYFRONT: - aPB = new PointBreak(); - aPB.setSize(14); - aPB.setColor(Color.blue); - aPB.setStyle(PointStyle.UpTriangle); - aPB.setOutlineColor(Color.blue); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - drawPoint_Simple(new PointF(aP.X - aPB.getSize() * 2 / 3, aP.Y - aPB.getSize() / 4), aPB, g); - aPB = new PointBreak(); - aPB.setSize(14); - aPB.setColor(Color.red); - aPB.setStyle(PointStyle.DownSemiCircle); - aPB.setOutlineColor(Color.red); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - drawPoint_Simple(new PointF(aP.X + aPB.getSize() * 2 / 3, aP.Y), aPB, g); - - g.setColor(Color.blue); - g.setStroke(new BasicStroke(lineWidth)); - drawPolyline(points, g); - break; - case ARROWLINE: - g.setColor(aPLB.getColor()); - g.setStroke(new BasicStroke(lineWidth)); - //float[] dashPattern = getDashPattern(aPLB.getStyle()); - //g.setStroke(new BasicStroke(aPLB.getSize(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dashPattern, 0.0f)); - drawPolyline(points, g); - - int n = points.length; - aPoint = points[n - 2]; - PointF bPoint = points[n - 1]; - double U = bPoint.X - aPoint.X; - double V = bPoint.Y - aPoint.Y; - double angle = Math.atan((V) / (U)) * 180 / Math.PI; - angle = angle + 90; - if (U < 0) { - angle = angle + 180; - } - - if (angle >= 360) { - angle = angle - 360; - } - - Draw.drawArraw(g, bPoint, angle, 8); - break; - } - } - } - - /** - * Draw polyline symbol - * - * @param aP The point - * @param width The width - * @param height The height - * @param aPLB The polyline break - * @param g Graphics2D - */ - public static void drawPolylineSymbol_S(PointF aP, float width, float height, PolylineBreak aPLB, Graphics2D g) { - if (aPLB.isUsingDashStyle()) { - PointF[] points = new PointF[2]; - PointF aPoint = new PointF(0, 0); - aPoint.X = aP.X - width / 2; - aPoint.Y = aP.Y; - points[0] = aPoint; - aPoint = new PointF(); - aPoint.X = aP.X + width / 2; - aPoint.Y = aP.Y; - points[1] = aPoint; - - g.setColor(aPLB.getColor()); - float[] dashPattern = getDashPattern(aPLB.getStyle()); - g.setStroke(new BasicStroke(aPLB.getWidth(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dashPattern, 0.0f)); - - if (aPLB.getDrawPolyline()) { - drawPolyline(points, g); - } - g.setStroke(new BasicStroke()); - - //Draw symbol - if (aPLB.getDrawSymbol()) { - drawPoint(aPLB.getSymbolStyle(), aP, aPLB.getSymbolFillColor(), aPLB.getSymbolColor(), aPLB.getSymbolSize(), true, aPLB.isFillSymbol(), g); - } - } else { - PointF[] points = new PointF[2]; - PointF aPoint = new PointF(0, 0); - aPoint.X = aP.X - width / 2; - aPoint.Y = aP.Y; - points[0] = aPoint; - aPoint = new PointF(); - aPoint.X = aP.X + width / 2; - aPoint.Y = aP.Y; - points[1] = aPoint; - float lineWidth = 2.0f; - switch (aPLB.getStyle()) { - case COLDFRONT: - PointBreak aPB = new PointBreak(); - aPB.setSize(14); - aPB.setColor(Color.blue); - aPB.setStyle(PointStyle.UpTriangle); - aPB.setOutlineColor(Color.blue); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - drawPoint_Simple(new PointF(aP.X - aPB.getSize() * 2 / 3, aP.Y - aPB.getSize() / 4), aPB, g); - drawPoint_Simple(new PointF(aP.X + aPB.getSize() * 2 / 3, aP.Y - aPB.getSize() / 4), aPB, g); - - g.setColor(Color.blue); - g.setStroke(new BasicStroke(lineWidth)); - drawPolyline(points, g); - break; - case WARMFRONT: - aPB = new PointBreak(); - aPB.setSize(14); - aPB.setColor(Color.red); - aPB.setStyle(PointStyle.UpSemiCircle); - aPB.setOutlineColor(Color.red); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - drawPoint_Simple(new PointF(aP.X - aPB.getSize() * 2 / 3, aP.Y), aPB, g); - drawPoint_Simple(new PointF(aP.X + aPB.getSize() * 2 / 3, aP.Y), aPB, g); - - g.setColor(Color.red); - g.setStroke(new BasicStroke(lineWidth)); - drawPolyline(points, g); - break; - case OCCLUDEDFRONT: - Color aColor = new Color(255, 0, 255); - aPB = new PointBreak(); - aPB.setSize(14); - aPB.setColor(aColor); - aPB.setStyle(PointStyle.UpTriangle); - aPB.setOutlineColor(aColor); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - drawPoint_Simple(new PointF(aP.X - aPB.getSize() * 2 / 3, aP.Y - aPB.getSize() / 4), aPB, g); - aPB = new PointBreak(); - aPB.setSize(14); - aPB.setColor(aColor); - aPB.setStyle(PointStyle.UpSemiCircle); - aPB.setOutlineColor(aColor); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - drawPoint_Simple(new PointF(aP.X + aPB.getSize() * 2 / 3, aP.Y), aPB, g); - - g.setColor(aColor); - g.setStroke(new BasicStroke(lineWidth)); - drawPolyline(points, g); - break; - case STATIONARYFRONT: - aPB = new PointBreak(); - aPB.setSize(14); - aPB.setColor(Color.blue); - aPB.setStyle(PointStyle.UpTriangle); - aPB.setOutlineColor(Color.blue); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - drawPoint_Simple(new PointF(aP.X - aPB.getSize() * 2 / 3, aP.Y - aPB.getSize() / 4), aPB, g); - aPB = new PointBreak(); - aPB.setSize(14); - aPB.setColor(Color.red); - aPB.setStyle(PointStyle.DownSemiCircle); - aPB.setOutlineColor(Color.red); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - drawPoint_Simple(new PointF(aP.X + aPB.getSize() * 2 / 3, aP.Y), aPB, g); - - g.setColor(Color.blue); - g.setStroke(new BasicStroke(lineWidth)); - drawPolyline(points, g); - break; - case ARROWLINE: - g.setColor(aPLB.getColor()); - g.setStroke(new BasicStroke(lineWidth)); - //float[] dashPattern = getDashPattern(aPLB.getStyle()); - //g.setStroke(new BasicStroke(aPLB.getSize(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dashPattern, 0.0f)); - drawPolyline(points, g); - - int n = points.length; - aPoint = points[n - 2]; - PointF bPoint = points[n - 1]; - double U = bPoint.X - aPoint.X; - double V = bPoint.Y - aPoint.Y; - double angle = Math.atan((V) / (U)) * 180 / Math.PI; - angle = angle + 90; - if (U < 0) { - angle = angle + 180; - } - - if (angle >= 360) { - angle = angle - 360; - } - - Draw.drawArraw(g, bPoint, angle, 8); - break; - } - } - } - -// /** -// * Draw polygon symbol -// * -// * @param aP The point -// * @param width The width -// * @param height The height -// * @param aPGB The polygon break -// * @param transparencyPerc Transparency percent -// * @param g Graphics2D -// */ -// public static void drawPolygonSymbol(PointF aP, float width, float height, PolygonBreak aPGB, -// int transparencyPerc, Graphics2D g) { -// int alpha = (int) ((1 - (double) transparencyPerc / 100.0) * 255); -// Color c = aPGB.getColor(); -// Color aColor = new Color(c.getRed(), c.getGreen(), c.getBlue(), alpha); -//// Brush aBrush; -//// if (aPGB.UsingHatchStyle) -//// aBrush = new HatchBrush(aPGB.Style, aColor, aPGB.BackColor); -//// else -//// aBrush = new SolidBrush(aColor); -// -// aP.X = aP.X - width / 2; -// aP.Y = aP.Y - height / 2; -// if (aPGB.getDrawFill()) { -// g.setColor(aColor); -// g.fill(new Rectangle.Float(aP.X, aP.Y, width, height)); -// } -// if (aPGB.getDrawOutline()) { -// g.setColor(aPGB.getOutlineColor()); -// g.setStroke(new BasicStroke(aPGB.getOutlineSize())); -// g.draw(new Rectangle.Float(aP.X, aP.Y, width, height)); -// } -// } - /** - * Draw polygon symbol - * - * @param x X - * @param y Y - * @param width The width - * @param height The height - * @param aPGB The polygon break - * @param g Graphics2D - */ - public static void drawPolygonSymbol(double x, double y, double width, double height, PolygonBreak aPGB, - Graphics2D g) { - if (aPGB.isDrawFill()) { - if (aPGB.isUsingHatchStyle()) { - int size = aPGB.getStyleSize(); - BufferedImage bi = getHatchImage(aPGB.getStyle(), size, aPGB.getColor(), aPGB.getBackColor()); - Rectangle2D rect = new Rectangle2D.Double(0, 0, size, size); - g.setPaint(new TexturePaint(bi, rect)); - g.fill(new Rectangle.Double(x, y, width, height)); - } else { - g.setColor(aPGB.getColor()); - g.fill(new Rectangle.Double(x, y, width, height)); - g.draw(new Rectangle.Double(x, y, width, height)); - } - } - if (aPGB.isDrawOutline()) { - g.setColor(aPGB.getOutlineColor()); - g.setStroke(new BasicStroke(aPGB.getOutlineSize())); - g.draw(new Rectangle.Double(x, y, width, height)); - } - } - - /** - * Draw polygon symbol - * - * @param aP The center point - * @param width The width - * @param height The height - * @param aPGB The polygon break - * @param g Graphics2D - */ - public static void drawPolygonSymbol(PointF aP, float width, float height, PolygonBreak aPGB, - Graphics2D g) { - aP.X = aP.X - width / 2; - aP.Y = aP.Y - height / 2; - if (aPGB.isDrawFill()) { - if (aPGB.isUsingHatchStyle()) { - int size = aPGB.getStyleSize(); - BufferedImage bi = getHatchImage(aPGB.getStyle(), size, aPGB.getColor(), aPGB.getBackColor()); - Rectangle2D rect = new Rectangle2D.Double(0, 0, size, size); - g.setPaint(new TexturePaint(bi, rect)); - g.fill(new Rectangle.Float(aP.X, aP.Y, width, height)); - } else { - g.setColor(aPGB.getColor()); - g.fill(new Rectangle.Float(aP.X, aP.Y, width, height)); - } - } - if (aPGB.isDrawOutline()) { - g.setColor(aPGB.getOutlineColor()); - g.setStroke(new BasicStroke(aPGB.getOutlineSize())); - g.draw(new Rectangle.Float(aP.X, aP.Y, width, height)); - } - } - - /** - * Draw polygon symbol - * - * @param x X - * @param y Y - * @param aColor Fill color - * @param outlineColor Outline color - * @param width Width - * @param height Height - * @param drawFill If draw fill - * @param drawOutline If draw outline - * @param g Grahics2D - */ - public static void drawPolygonSymbol(double x, double y, Color aColor, Color outlineColor, - double width, double height, Boolean drawFill, Boolean drawOutline, Graphics2D g) { - if (drawFill) { - g.setColor(aColor); - g.fill(new Rectangle.Double(x, y, width, height)); - g.draw(new Rectangle.Double(x, y, width, height)); - } - if (drawOutline) { - g.setColor(outlineColor); - g.draw(new Rectangle.Double(x, y, width, height)); - } - } - - /** - * Draw polygon symbol - * - * @param aP The center point - * @param aColor Fill color - * @param outlineColor Outline color - * @param width Width - * @param height Height - * @param drawFill If draw fill - * @param drawOutline If draw outline - * @param g Grahics2D - */ - public static void drawPolygonSymbol(PointF aP, Color aColor, Color outlineColor, - float width, float height, Boolean drawFill, Boolean drawOutline, Graphics2D g) { - aP.X = aP.X - width / 2; - aP.Y = aP.Y - height / 2; - if (drawFill) { - g.setColor(aColor); - g.fill(new Rectangle.Float(aP.X, aP.Y, width, height)); - } - if (drawOutline) { - g.setColor(outlineColor); - g.draw(new Rectangle.Float(aP.X, aP.Y, width, height)); - } - } - - /** - * Draw rectangle - * - * @param aPoint Start point - * @param width Width - * @param height Height - * @param aPGB Polygon break - * @param g Graphics2D - */ - public static void drawRectangle(PointF aPoint, float width, float height, PolygonBreak aPGB, Graphics2D g) { - Color aColor = aPGB.getColor(); - if (aPGB.isDrawFill()) { - if (aPGB.isUsingHatchStyle()) { - int size = aPGB.getStyleSize(); - BufferedImage bi = getHatchImage(aPGB.getStyle(), size, aPGB.getColor(), aPGB.getBackColor()); - Rectangle2D rect = new Rectangle2D.Double(0, 0, size, size); - g.setPaint(new TexturePaint(bi, rect)); - g.fill(new Rectangle.Float(aPoint.X, aPoint.Y, width, height)); - } else { - g.setColor(aColor); - g.fill(new Rectangle.Float(aPoint.X, aPoint.Y, width, height)); - } - } - if (aPGB.isDrawOutline()) { - g.setColor(aPGB.getOutlineColor()); - g.setStroke(new BasicStroke(aPGB.getOutlineSize())); - g.draw(new Rectangle.Float(aPoint.X, aPoint.Y, width, height)); - } - } - - /** - * Draw pie - * - * @param aPoint Start point - * @param width Width - * @param height Height - * @param startAngle Start angle - * @param sweepAngle Sweep angle - * @param aPGB Polygon break - * @param g Graphics2D - */ - public static void drawPie(PointF aPoint, float width, float height, float startAngle, float sweepAngle, PolygonBreak aPGB, Graphics2D g) { - Color aColor = aPGB.getColor(); - if (aPGB.isDrawFill()) { - g.setColor(aColor); - g.fill(new Arc2D.Float(aPoint.X, aPoint.Y, width, height, startAngle, sweepAngle, Arc2D.PIE)); - } - if (aPGB.isDrawOutline()) { - g.setColor(aPGB.getOutlineColor()); - g.setStroke(new BasicStroke(aPGB.getOutlineSize())); - g.draw(new Arc2D.Float(aPoint.X, aPoint.Y, width, height, startAngle, sweepAngle, Arc2D.PIE)); - } - } - - /** - * Draw pie - * - * @param aPoint Start point - * @param width Width - * @param height Height - * @param startAngle Start angle - * @param sweepAngle Sweep angle - * @param aPGB Polygon break - * @param wedgeWidth Wedge width - * @param g Graphics2D - */ - public static void drawPie(PointF aPoint, float width, float height, float startAngle, - float sweepAngle, PolygonBreak aPGB, float wedgeWidth, Graphics2D g) { - Color aColor = aPGB.getColor(); - Arc2D.Float arc2D = new Arc2D.Float(aPoint.X, aPoint.Y, width, height, startAngle, sweepAngle, Arc2D.PIE); - Area area1 = new Area(arc2D); - Ellipse2D e2 = new Ellipse2D.Float(aPoint.X + wedgeWidth, aPoint.Y + wedgeWidth, width - wedgeWidth * 2, - height - wedgeWidth * 2); - Area area2 = new Area(e2); - area1.subtract(area2); - if (aPGB.isDrawFill()) { - g.setColor(aColor); - g.fill(area1); - } - if (aPGB.isDrawOutline()) { - g.setColor(aPGB.getOutlineColor()); - g.setStroke(new BasicStroke(aPGB.getOutlineSize())); - g.draw(area1); - } - } - - /** - * Draw curve line - * - * @param points The points - * @param aPLB The polyline break - * @param g Graphics2D - */ - public static void drawCurveLine(PointF[] points, PolylineBreak aPLB, Graphics2D g) { - List opoints = new ArrayList<>(); - int i; - for (i = 0; i < points.length; i++) { - opoints.add(new PointD(points[i].X, points[i].Y)); - } - - PointD[] rPoints = Spline.cardinalSpline((PointD[]) opoints.toArray(new PointD[opoints.size()]), 5); - PointF[] dPoints = new PointF[rPoints.length]; - for (i = 0; i < dPoints.length; i++) { - dPoints[i] = new PointF((float) rPoints[i].X, (float) rPoints[i].Y); - } - - drawPolyline(dPoints, aPLB, g); - } - - /** - * Draw curve line - * - * @param points The points list - * @param g Graphics2D - */ - public static void drawCurveLine(List points, Graphics2D g) { - PointD[] opoints = new PointD[points.size()]; - int i; - for (i = 0; i < points.size(); i++) { - opoints[i] = new PointD(points.get(i).X, points.get(i).Y); - } - - PointD[] rPoints = Spline.cardinalSpline(opoints, 5); - PointF[] dPoints = new PointF[rPoints.length]; - for (i = 0; i < dPoints.length; i++) { - dPoints[i] = new PointF((float) rPoints[i].X, (float) rPoints[i].Y); - } - - drawPolyline(dPoints, g); - } - - /** - * Draw curve line - * - * @param points The points - * @param g Graphics2D - */ - public static void drawCurveLine(PointF[] points, Graphics2D g) { - List opoints = new ArrayList<>(); - int i; - for (i = 0; i < points.length; i++) { - opoints.add(new PointD(points[i].X, points[i].Y)); - } - - PointD[] rPoints = Spline.cardinalSpline((PointD[]) opoints.toArray(), 5); - PointF[] dPoints = new PointF[rPoints.length]; - for (i = 0; i < dPoints.length; i++) { - dPoints[i] = new PointF((float) rPoints[i].X, (float) rPoints[i].Y); - } - - drawPolyline(dPoints, g); - } - - /** - * Draw curve polygon - * - * @param points The points - * @param aPGB Polygon break - * @param g Graphics2D - */ - public static void drawCurvePolygon(PointF[] points, PolygonBreak aPGB, Graphics2D g) { - List opoints = new ArrayList<>(); - int i; - for (i = 0; i < points.length; i++) { - opoints.add(new PointD(points[i].X, points[i].Y)); - } - - PointD[] rPoints = Spline.cardinalSpline((PointD[]) opoints.toArray(new PointD[opoints.size()]), 5); - PointF[] dPoints = new PointF[rPoints.length]; - for (i = 0; i < dPoints.length; i++) { - dPoints[i] = new PointF((float) rPoints[i].X, (float) rPoints[i].Y); - } - - drawPolygon(dPoints, aPGB, g); - } - - /** - * Draw circle - * - * @param points The points - * @param aPGB The polygon break - * @param g Graphics2D - */ - public static void drawCircle(PointF[] points, PolygonBreak aPGB, Graphics2D g) { - float radius = Math.abs(points[1].X - points[0].X); - - if (aPGB.isDrawFill()) { - g.setColor(aPGB.getColor()); - g.fill(new Ellipse2D.Float(points[0].X, points[0].Y - radius, radius * 2, radius * 2)); - } - if (aPGB.isDrawOutline()) { - g.setColor(aPGB.getOutlineColor()); - g.setStroke(new BasicStroke(aPGB.getOutlineSize())); - g.draw(new Ellipse2D.Float(points[0].X, points[0].Y - radius, radius * 2, radius * 2)); - } - } - - /** - * Draw ellipse - * - * @param points The points - * @param angle The angle - * @param aPGB The polygon break - * @param g Grahpics2D - */ - public static void drawEllipse(PointF[] points, float angle, PolygonBreak aPGB, Graphics2D g) { - float sx = Math.min(points[0].X, points[2].X); - float sy = Math.min(points[0].Y, points[2].Y); - float width = Math.abs(points[2].X - points[0].X); - float height = Math.abs(points[2].Y - points[0].Y); - - if (angle != 0) { - AffineTransform tempTrans = g.getTransform(); - AffineTransform myTrans = (AffineTransform) tempTrans.clone(); - myTrans.translate(sx + width / 2, sy + height / 2); - myTrans.rotate(Math.toRadians(angle)); - //AffineTransform myTrans = AffineTransform.getRotateInstance(Math.toRadians(angle), - // sx + width / 2 + tempTrans.getTranslateX(), sy + height / 2 + tempTrans.getTranslateY()); - g.setTransform(myTrans); - //sx += tempTrans.getTranslateX(); - //sy += tempTrans.getTranslateY(); - - if (aPGB.isDrawFill()) { - g.setColor(aPGB.getColor()); - g.fill(new Ellipse2D.Float(-width / 2, -height / 2, width, height)); - } - if (aPGB.isDrawOutline()) { - g.setColor(aPGB.getOutlineColor()); - g.setStroke(new BasicStroke(aPGB.getOutlineSize())); - g.draw(new Ellipse2D.Float(-width / 2, -height / 2, width, height)); - } - - g.setTransform(tempTrans); - } else { - - if (aPGB.isDrawFill()) { - g.setColor(aPGB.getColor()); - g.fill(new Ellipse2D.Float(sx, sy, width, height)); - } - if (aPGB.isDrawOutline()) { - g.setColor(aPGB.getOutlineColor()); - g.setStroke(new BasicStroke(aPGB.getOutlineSize())); - g.draw(new Ellipse2D.Float(sx, sy, width, height)); - } - } - } - - /** - * Draw ellipse - * - * @param points The points - * @param aPGB The polygon break - * @param g Grahpics2D - */ - public static void drawEllipse(PointF[] points, PolygonBreak aPGB, Graphics2D g) { - float sx = Math.min(points[0].X, points[2].X); - float sy = Math.min(points[0].Y, points[2].Y); - float width = Math.abs(points[2].X - points[0].X); - float height = Math.abs(points[2].Y - points[0].Y); - - if (aPGB.isDrawFill()) { - g.setColor(aPGB.getColor()); - g.fill(new Ellipse2D.Float(sx, sy, width, height)); - } - if (aPGB.isDrawOutline()) { - g.setColor(aPGB.getOutlineColor()); - g.setStroke(new BasicStroke(aPGB.getOutlineSize())); - g.draw(new Ellipse2D.Float(sx, sy, width, height)); - } - } - - /** - * Draw selected vertices rectangles - * - * @param g Graphics2D - * @param points The points - */ - public static void drawSelectedVertices(Graphics2D g, PointF[] points) { - drawSelectedVertices(g, points, 6, Color.black, Color.cyan); - } - - /** - * Draw selected vertices rectangles - * - * @param g Graphics2D - * @param points The points - * @param size The size - * @param outlineColor Outline coloe - * @param fillColor Fill color - */ - public static void drawSelectedVertices(Graphics2D g, PointF[] points, float size, Color outlineColor, Color fillColor) { - Rectangle.Float rect = new Rectangle.Float(0, 0, size, size); - - for (PointF aPoint : points) { - rect.x = aPoint.X - size / 2; - rect.y = aPoint.Y - size / 2; - g.setColor(fillColor); - g.fill(rect); - g.setColor(outlineColor); - g.setStroke(new BasicStroke(1)); - g.draw(rect); - } - } - - /** - * Draw selected vertice rectangles - * - * @param g Graphics2D - * @param point The point - * @param size The size - * @param outlineColor Outline coloe - * @param fillColor Fill color - */ - public static void drawSelectedVertice(Graphics2D g, PointF point, float size, Color outlineColor, Color fillColor) { - Rectangle.Float rect = new Rectangle.Float(0, 0, size, size); - - rect.x = point.X - size / 2; - rect.y = point.Y - size / 2; - g.setColor(fillColor); - g.fill(rect); - g.setColor(outlineColor); - g.setStroke(new BasicStroke(1)); - g.draw(rect); - } - - /** - * Draw selected four corner rectangles - * - * @param g Graphics2D - * @param gRect The rectangle - */ - public static void drawSelectedCorners(Graphics2D g, Rectangle gRect) { - int size = 6; - Rectangle rect = new Rectangle(gRect.x - size / 2, gRect.y - size / 2, size, size); - g.setColor(Color.cyan); - g.fill(rect); - g.setColor(Color.black); - g.draw(rect); - rect.y = gRect.y + gRect.height - size / 2; - g.setColor(Color.cyan); - g.fill(rect); - g.setColor(Color.black); - g.draw(rect); - rect.x = gRect.x + gRect.width - size / 2; - g.setColor(Color.cyan); - g.fill(rect); - g.setColor(Color.black); - g.draw(rect); - rect.y = gRect.y - size / 2; - g.setColor(Color.cyan); - g.fill(rect); - g.setColor(Color.black); - g.draw(rect); - } - - /** - * Draw selected four bouder edge center rectangles - * - * @param g Graphics2D - * @param gRect The rectangle - */ - public static void drawSelectedEdgeCenters(Graphics2D g, Rectangle gRect) { - int size = 6; - Rectangle rect = new Rectangle(gRect.x + gRect.width / 2 - size / 2, gRect.y - size / 2, size, size); - g.setColor(Color.cyan); - g.fill(rect); - g.setColor(Color.black); - g.draw(rect); - rect.y = gRect.y + gRect.height - size / 2; - g.setColor(Color.cyan); - g.fill(rect); - g.setColor(Color.black); - g.draw(rect); - rect.x = gRect.x - size / 2; - rect.y = gRect.y + gRect.height / 2 - size / 2; - g.setColor(Color.cyan); - g.fill(rect); - g.setColor(Color.black); - g.draw(rect); - rect.x = gRect.x + gRect.width - size / 2; - g.setColor(Color.cyan); - g.fill(rect); - g.setColor(Color.black); - g.draw(rect); - } - // - - // - /** - * Draw chart point - * - * @param aPoint Screen point - * @param aCB Chart break - * @param g Graphics2D - */ - public static void drawChartPoint(PointF aPoint, ChartBreak aCB, Graphics2D g) { - switch (aCB.getChartType()) { - case BarChart: - drawBarChartSymbol(aPoint, aCB, g); - break; - case PieChart: - List rStrs = null; - if (aCB.isDrawLabel()) { - List ratios = aCB.getPieRatios(); - rStrs = new ArrayList<>(); - for (float r : ratios) { - rStrs.add(String.valueOf((int) (r * 100)) + "%"); - } - } - drawPieChartSymbol(aPoint, aCB, g, rStrs); - break; - } - - } - - /** - * Draw bar chart symbol - * - * @param aPoint Start point - * @param aCB Chart break - * @param g Graphics2D - */ - public static void drawBarChartSymbol(PointF aPoint, ChartBreak aCB, Graphics2D g) { - Font font = new Font("Arial", Font.PLAIN, 8); - drawBarChartSymbol(aPoint, aCB, g, false, font); - } - - /** - * Draw bar chart symbol - * - * @param aPoint Start point - * @param aCB Chart break - * @param g Graphics2D - * @param drawValue If draw value - */ - public static void drawBarChartSymbol(PointF aPoint, ChartBreak aCB, Graphics2D g, boolean drawValue) { - drawBarChartSymbol(aPoint, aCB, g, drawValue, g.getFont()); - } - - /** - * Draw bar chart symbol - * - * @param sPoint Start point - * @param aCB Chart break - * @param g Graphics2D - * @param drawValue If draw value - * @param font Value font - */ - public static void drawBarChartSymbol(PointF sPoint, ChartBreak aCB, Graphics2D g, boolean drawValue, Font font) { - PointF aPoint = (PointF) sPoint.clone(); - List heights = aCB.getBarHeights(); - float y = aPoint.Y; - for (int i = 0; i < heights.size(); i++) { - if (heights.get(i) <= 0) { - aPoint.X += aCB.getBarWidth(); - continue; - } - - aPoint.Y = y - heights.get(i); - PolygonBreak aPGB = (PolygonBreak) aCB.getLegendScheme().getLegendBreaks().get(i); - if (aCB.isView3D()) { - Color aColor = ColorUtil.modifyBrightness(aPGB.getColor(), 0.5f); - PointF[] points = new PointF[4]; - points[0] = new PointF(aPoint.X, aPoint.Y); - points[1] = new PointF(aPoint.X + aCB.getBarWidth(), aPoint.Y); - points[2] = new PointF(points[1].X + aCB.getThickness(), points[1].Y - aCB.getThickness()); - points[3] = new PointF(points[0].X + aCB.getThickness(), points[0].Y - aCB.getThickness()); - g.setColor(aColor); - Draw.fillPolygon(points, g, aPGB); - g.setColor(aPGB.getOutlineColor()); - Draw.drawPolyline(points, g); - - points[0] = new PointF(aPoint.X + aCB.getBarWidth(), aPoint.Y); - points[1] = new PointF(aPoint.X + aCB.getBarWidth(), aPoint.Y + heights.get(i)); - points[2] = new PointF(points[1].X + aCB.getThickness(), points[1].Y - aCB.getThickness()); - points[3] = new PointF(points[0].X + aCB.getThickness(), points[0].Y - aCB.getThickness()); - g.setColor(aColor); - Draw.fillPolygon(points, g, aPGB); - g.setColor(aPGB.getOutlineColor()); - Draw.drawPolyline(points, g); - } - drawRectangle(aPoint, aCB.getBarWidth(), heights.get(i), aPGB, g); - - aPoint.X += aCB.getBarWidth(); - - if (i == heights.size() - 1) { - if (drawValue) { - //String vstr = String.valueOf(aCB.getChartData().get(i)); - String formatStr = "%1$." + String.valueOf(aCB.getDecimalDigits()) + "f"; - String vstr = String.format(formatStr, aCB.getChartData().get(i)); - FontMetrics metrics = g.getFontMetrics(font); - Dimension labSize = new Dimension(metrics.stringWidth(vstr), metrics.getHeight()); - aPoint.X += 5; - aPoint.Y = (float) (y - heights.get(i) / 2); - g.setColor(Color.black); - g.setFont(font); - g.drawString(vstr, aPoint.X, aPoint.Y + metrics.getHeight() / 2); - } - } - } - } - - /** - * Draw bar chart symbol - * - * @param aPoint Start point - * @param width Width - * @param height Height - * @param g Graphics2D - * @param aPGB Polygon beak - * @param isView3D Is view as 3D - * @param thickness 3D thickness - */ - public static void drawBar(PointF aPoint, int width, int height, PolygonBreak aPGB, Graphics2D g, boolean isView3D, - int thickness) { -// float y = aPoint.Y; -// aPoint.Y = y - height; -// if (isView3D) { -// Color aColor = ColorUtil.modifyBrightness(aPGB.getColor(), 0.5f); -// PointF[] points = new PointF[4]; -// points[0] = new PointF(aPoint.X, aPoint.Y); -// points[1] = new PointF(aPoint.X + width, aPoint.Y); -// points[2] = new PointF(points[1].X + thickness, points[1].Y - thickness); -// points[3] = new PointF(points[0].X + thickness, points[0].Y - thickness); -// g.setColor(aColor); -// Draw.fillPolygon(points, g); -// g.setColor(aPGB.getOutlineColor()); -// Draw.drawPolyline(points, g); -// -// points[0] = new PointF(aPoint.X + width, aPoint.Y); -// points[1] = new PointF(aPoint.X + width, aPoint.Y + height); -// points[2] = new PointF(points[1].X + thickness, points[1].Y - thickness); -// points[3] = new PointF(points[0].X + thickness, points[0].Y - thickness); -// g.setColor(aColor); -// Draw.fillPolygon(points, g); -// g.setColor(aPGB.getOutlineColor()); -// Draw.drawPolyline(points, g); -// } -// drawRectangle(aPoint, width, height, aPGB, g); - drawBar(aPoint, (float) width, (float) height, aPGB, g, isView3D, thickness); - } - - /** - * Draw bar chart symbol - * - * @param aPoint Start point - * @param width Width - * @param height Height - * @param g Graphics2D - * @param aPGB Polygon beak - * @param isView3D Is view as 3D - * @param thickness 3D thickness - */ - public static void drawBar(PointF aPoint, float width, float height, PolygonBreak aPGB, Graphics2D g, boolean isView3D, - int thickness) { - float y = aPoint.Y; - aPoint.Y = y - height; - if (isView3D) { - Color aColor = ColorUtil.modifyBrightness(aPGB.getColor(), 0.5f); - PointF[] points = new PointF[4]; - points[0] = new PointF(aPoint.X, aPoint.Y); - points[1] = new PointF(aPoint.X + width, aPoint.Y); - points[2] = new PointF(points[1].X + thickness, points[1].Y - thickness); - points[3] = new PointF(points[0].X + thickness, points[0].Y - thickness); - g.setColor(aColor); - Draw.fillPolygon(points, g, aPGB); - g.setColor(aPGB.getOutlineColor()); - Draw.drawPolyline(points, g); - - points[0] = new PointF(aPoint.X + width, aPoint.Y); - points[1] = new PointF(aPoint.X + width, aPoint.Y + height); - points[2] = new PointF(points[1].X + thickness, points[1].Y - thickness); - points[3] = new PointF(points[0].X + thickness, points[0].Y - thickness); - g.setColor(aColor); - Draw.fillPolygon(points, g, aPGB); - g.setColor(aPGB.getOutlineColor()); - Draw.drawPolyline(points, g); - } - drawRectangle(aPoint, width, height, aPGB, g); - } - - /** - * Draw pie chart symbol - * - * @param aPoint Start point - * @param aCB Chart break - * @param g Graphics2D - * @param labels Labels - */ - public static void drawPieChartSymbol(PointF aPoint, ChartBreak aCB, Graphics2D g, List labels) { - int width = aCB.getWidth(); - int height = aCB.getHeight(); - if (width <= 0 || height <= 0) { - return; - } - - PointF sPoint = new PointF(aPoint.X + width / 2, aPoint.Y - height / 2); - aPoint.Y -= height; - List> angles = aCB.getPieAngles(); - float startAngle, sweepAngle; - int i; - if (aCB.isView3D()) { - aPoint.Y = aPoint.Y + width / 6 - aCB.getThickness(); - for (i = 0; i < angles.size(); i++) { - startAngle = angles.get(i).get(0); - sweepAngle = angles.get(i).get(1); - PolygonBreak aPGB = (PolygonBreak) aCB.getLegendScheme().getLegendBreaks().get(i); - if (startAngle + sweepAngle > 180) { - PointF bPoint = new PointF(aPoint.X, aPoint.Y + aCB.getThickness()); - Color aColor = ColorUtil.modifyBrightness(aPGB.getColor(), 0.5f); - - g.setColor(aColor); - g.fill(new Arc2D.Float(bPoint.X, bPoint.Y, width, width * 2 / 3, startAngle, sweepAngle, Arc2D.PIE)); - g.setColor(aPGB.getOutlineColor()); - g.draw(new Arc2D.Float(bPoint.X, bPoint.Y, width, width * 2 / 3, startAngle, sweepAngle, Arc2D.PIE)); - } - } - float a = (float) width / 2; - float b = (float) width / 3; - float x0 = aPoint.X + a; - float y0 = aPoint.Y + b; - double sA, eA; - for (i = 0; i < angles.size(); i++) { - startAngle = angles.get(i).get(0); - sweepAngle = angles.get(i).get(1); - if (startAngle + sweepAngle > 180) { - sA = (360 - startAngle) / 180 * Math.PI; - eA = (360 - (startAngle + sweepAngle)) / 180 * Math.PI; - PolygonBreak aPGB = (PolygonBreak) aCB.getLegendScheme().getLegendBreaks().get(i); - PointF bPoint = MIMath.calEllipseCoordByAngle(x0, y0, a, b, eA); - PointF cPoint = new PointF(x0 - a, y0); - if (sA < Math.PI) { - cPoint = MIMath.calEllipseCoordByAngle(x0, y0, a, b, sA); - } - - Color aColor = ColorUtil.modifyBrightness(aPGB.getColor(), 0.5f); - PointF[] points = new PointF[5]; - points[0] = cPoint; - points[1] = new PointF(cPoint.X, cPoint.Y + aCB.getThickness()); - points[2] = new PointF(bPoint.X, bPoint.Y + aCB.getThickness()); - points[3] = bPoint; - points[4] = cPoint; - g.setColor(aColor); - Draw.fillPolygon(points, g, aPGB); - g.setColor(aPGB.getOutlineColor()); - g.draw(new Line2D.Float(points[0].X, points[0].Y, points[1].X, points[1].Y)); - g.draw(new Line2D.Float(points[2].X, points[2].Y, points[3].X, points[3].Y)); - } - } - for (i = 0; i < angles.size(); i++) { - startAngle = angles.get(i).get(0); - sweepAngle = angles.get(i).get(1); - PolygonBreak aPGB = (PolygonBreak) aCB.getLegendScheme().getLegendBreaks().get(i); - drawPie(aPoint, width, width * 2 / 3, startAngle, sweepAngle, aPGB, g); - } - } else { - for (i = 0; i < angles.size(); i++) { - startAngle = angles.get(i).get(0); - sweepAngle = angles.get(i).get(1); - PolygonBreak aPGB = (PolygonBreak) aCB.getLegendScheme().getLegendBreaks().get(i); - drawPie(aPoint, width, width, startAngle, sweepAngle, aPGB, g); - } - if (labels != null) { - FontMetrics metrics = g.getFontMetrics(); - float x, y, angle, w, h; - for (i = 0; i < angles.size(); i++) { - String label = labels.get(i); - if (label.equals("0%")) { - continue; - } - - startAngle = angles.get(i).get(0); - sweepAngle = angles.get(i).get(1); - angle = startAngle + sweepAngle / 2; - PointF lPoint = getPieLabelPoint(sPoint, width / 2, angle); - x = lPoint.X; - y = lPoint.Y; - h = metrics.getHeight(); - w = metrics.stringWidth(label); - if ((angle >= 0 && angle < 45) || (angle >= 315 && angle <= 360)) { - x = x + 3; - y = y + h / 2; - } else if (angle >= 45 && angle < 90) { - y = y - 3; - } else if (angle >= 90 && angle < 135) { - x = x - w - 3; - y = y - 3; - } else if (angle >= 135 && angle < 225) { - x = x - w - 3; - y = y + h / 2; - } else if (angle >= 225 && angle < 270) { - x = x - w - 3; - y = y + h / 2; - } else { - y = y + h; - } - g.drawString(label, x, y); - } - } - } - } - - /** - * Get pie wedge label point - * - * @param sPoint Center point - * @param r Radius - * @param angle Angle - * @return Label point - */ - public static PointF getPieLabelPoint(PointF sPoint, float r, float angle) { - float x = (float) (sPoint.X + r * Math.cos(angle * Math.PI / 180)); - float y = (float) (sPoint.Y - r * Math.sin(angle * Math.PI / 180)); - return new PointF(x, y); - } - // -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/form/ChartForm.form b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/form/ChartForm.form new file mode 100644 index 00000000..08ed8b15 --- /dev/null +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/form/ChartForm.form @@ -0,0 +1,25 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/form/ChartForm.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/form/ChartForm.java new file mode 100644 index 00000000..d9dfe1a2 --- /dev/null +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/form/ChartForm.java @@ -0,0 +1,95 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.meteoinfo.chart.form; + +import org.meteoinfo.chart.ChartPanel; +import org.meteoinfo.chart.MouseMode; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.image.BufferedImage; + +/** + * + * @author wyq + */ +public class ChartForm extends javax.swing.JFrame { + + private ChartPanel chartPanel; + + /** + * Creates new form ChartForm + * @param chartPanel Chart panel + */ + public ChartForm(ChartPanel chartPanel) { + initComponents(); + + this.chartPanel = chartPanel; + this.chartPanel.setMouseMode(MouseMode.ZOOM_IN); + this.getContentPane().add(this.chartPanel, BorderLayout.CENTER); + + BufferedImage image = null; + try { + image = ImageIO.read(this.getClass().getResource("/images/MeteoInfo.png")); + } catch (Exception e) { + } + this.setIconImage(image); + this.setTitle("MeteoInfo Chart Form"); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + pack(); + }// //GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(ChartForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(ChartForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(ChartForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(ChartForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + new ChartForm(new ChartPanel()).setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables +} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/graphic/ChartGraphic.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/graphic/ChartGraphic.java deleted file mode 100644 index 25addd77..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/graphic/ChartGraphic.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.graphic; - -import org.meteoinfo.common.PointD; -import org.meteoinfo.geometry.shape.PointShape; -import org.meteoinfo.chart.legend.ChartBreak; -import org.w3c.dom.Attr; -import org.w3c.dom.DOMException; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -/** - * - * @author Yaqiang Wang - */ -public class ChartGraphic extends Graphic { - - // - private PointD startPosition; - - // - // - /** - * Constructor - */ - public ChartGraphic() { - - } - - /** - * Constructor - * - * @param shape Point shape - * @param legend Chart break - */ - public ChartGraphic(PointShape shape, ChartBreak legend) { - super(shape, legend); - startPosition = (PointD) shape.getPoint().clone(); - } - - // - // - /** - * Get start position - * - * @return Start position - */ - public PointD getStartPosition() { - return startPosition; - } - - /** - * Set start postion - * - * @param value Start position - */ - public void setStartPosition(PointD value) { - startPosition = value; - } - - /** - * Set point shape - * - * @param aShape Point shape - */ - public void setShape(PointShape aShape) { - super.setShape(aShape); - startPosition = (PointD) aShape.getPoint().clone(); - } - - // - // - /** - * Export to XML document - * - * @param doc XML document - * @param parent Parent XML element - */ - @Override - public void exportToXML(Document doc, Element parent) { - Element graphic = doc.createElement("Graphic"); - this.addShape(doc, graphic, this.getShape()); - this.addLegend(doc, graphic, this.getLegend(), this.getShape().getShapeType()); - this.addStartPosition(doc, graphic, startPosition); - - parent.appendChild(graphic); - } - - private void addStartPosition(Document doc, Element parent, PointD pos) { - Element startPos = doc.createElement("StartPosition"); - - Attr xAttr = doc.createAttribute("X"); - Attr yAttr = doc.createAttribute("Y"); - - xAttr.setValue(String.valueOf(pos.X)); - yAttr.setValue(String.valueOf(pos.Y)); - - startPos.setAttributeNode(xAttr); - startPos.setAttributeNode(yAttr); - - parent.appendChild(startPos); - } - - /** - * Import from xml node - * - * @param graphicNode Graphic xml node - */ - @Override - public void importFromXML(Element graphicNode) { - Node shape = graphicNode.getElementsByTagName("Shape").item(0); - this.setShape((PointShape)loadShape(shape)); - - Node legend = graphicNode.getElementsByTagName("Legend").item(0); - this.setLegend(loadLegend(legend, this.getShape().getShapeType())); - - Node startPos = graphicNode.getElementsByTagName("StartPosition").item(0); - if (startPos != null) { - PointD sP = this.loadStartPosition(startPos); - if (sP != null) { - this.startPosition = sP; - } - } - } - - private PointD loadStartPosition(Node startPosNode) { - PointD sP = null; - try { - double x = Double.parseDouble(startPosNode.getAttributes().getNamedItem("X").getNodeValue()); - double y = Double.parseDouble(startPosNode.getAttributes().getNamedItem("Y").getNodeValue()); - sP = new PointD(x, y); - } catch (DOMException e) { - } catch (NumberFormatException e) { - } - - return sP; - } - // -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/graphic/Graphic.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/graphic/Graphic.java deleted file mode 100644 index 529c2c74..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/graphic/Graphic.java +++ /dev/null @@ -1,713 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.chart.graphic; - -import org.meteoinfo.common.Extent; -import org.meteoinfo.common.PointD; -import org.meteoinfo.geo.shape.*; -import org.meteoinfo.chart.legend.MarkerType; -import org.meteoinfo.chart.legend.PointStyle; -import org.meteoinfo.common.colors.ColorUtil; -import org.meteoinfo.chart.legend.BreakTypes; -import org.meteoinfo.chart.legend.ChartBreak; -import org.meteoinfo.chart.legend.ChartTypes; -import org.meteoinfo.chart.legend.ColorBreak; -import org.meteoinfo.chart.legend.LabelBreak; -import org.meteoinfo.chart.legend.LineStyles; -import org.meteoinfo.chart.legend.PointBreak; -import org.meteoinfo.chart.legend.PolygonBreak; -import org.meteoinfo.chart.legend.PolylineBreak; -import org.meteoinfo.chart.legend.VectorBreak; -import java.awt.Color; -import java.awt.Font; -import java.util.ArrayList; -import java.util.List; - -import org.meteoinfo.geometry.shape.*; -import org.meteoinfo.ui.resize.ResizeAbility; -import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - - /** - * Graphic class - * - * @author Yaqiang Wang - */ - public class Graphic { - // - - private Shape _shape = null; - private ColorBreak _legend = null; - private ResizeAbility _resizeAbility = ResizeAbility.ResizeAll; - // - // - - /** - * Constructor - */ - public Graphic() { - } - - /** - * Constructor - * - * @param shape a shape - * @param legend a legend - */ - public Graphic(Shape shape, ColorBreak legend) { - _shape = shape; - _legend = legend; - updateResizeAbility(); - } - // - // - - /** - * Get shape - * - * @return Shape - */ - public Shape getShape() { - return _shape; - } - - /** - * Set shape - * - * @param aShape a shape - */ - public void setShape(Shape aShape) { - _shape = aShape; - updateResizeAbility(); - } - - /** - * Get legend - * - * @return Legend - */ - public ColorBreak getLegend() { - return _legend; - } - - public void setLegend(ColorBreak legend) { - _legend = legend; - updateResizeAbility(); - updateResizeAbility(); - } - - /** - * Get resize ability - * - * @return Resize ability - */ - public ResizeAbility getResizeAbility() { - return _resizeAbility; - } - - /** - * Get extent - * - * @return The extent - */ - public Extent getExtent() { - return this._shape.getExtent(); - } - - /** - * Set extent - * @param value The extent - */ - public void setExtent(Extent value){ - this._shape.setExtent(value); - } - - /** - * Get is single legend or not - * @return Boolean - */ - public boolean isSingleLegend(){ - return true; - } - - /** - * Get if is GraphicCollection - * @return Boolean - */ - public boolean isCollection(){ - return false; - } - - // - // - /** - * Get graphics number - * @return 1 - */ - public int getNumGraphics(){ - return 1; - } - - /** - * Get Graphic by index - * @param idx Index - * @return Graphic - */ - public Graphic getGraphicN(int idx){ - return this; - } - - /** - * Get graphic list - * @return Graphic list - */ - public List getGraphics(){ - List gs = new ArrayList<>(); - gs.add(this); - return gs; - } - - private void updateResizeAbility() { - if (_shape != null && _legend != null) { - switch (_shape.getShapeType()) { - case Point: - switch (_legend.getBreakType()) { - case PointBreak: - _resizeAbility = ResizeAbility.SameWidthHeight; - break; - case LabelBreak: - case ChartBreak: - _resizeAbility = ResizeAbility.None; - break; - } - break; - case Circle: - _resizeAbility = ResizeAbility.SameWidthHeight; - break; - default: - _resizeAbility = ResizeAbility.ResizeAll; - break; - } - } - } - - /** - * Vertice edited update - * - * @param vIdx Vertice index - * @param newX New X - * @param newY New Y - */ - public void verticeMoveUpdate(int vIdx, double newX, double newY) { - List points = (List)_shape.getPoints(); - switch (_shape.getShapeType()){ - case Polygon: - case CurvePolygon: - case Rectangle: - int last = points.size() - 1; - if (vIdx == 0) { - if (points.get(0).X == points.get(last).X && points.get(0).Y == points.get(last).Y) { - points.get(last).X = newX; - points.get(last).Y = newY; - } - } else if (vIdx == last){ - if (points.get(0).X == points.get(last).X && points.get(0).Y == points.get(last).Y) { - points.get(0).X = newX; - points.get(0).Y = newY; - } - } - break; - } - - PointD aP = points.get(vIdx); - aP.X = newX; - aP.Y = newY; - //points.set(vIdx, aP); - _shape.setPoints(points); - } - - /** - * Vertice edited update - * - * @param vIdx Vertice index - * @param point The add vertice - */ - public void verticeAddUpdate(int vIdx, PointD point) { - List points = (List)_shape.getPoints(); - points.add(vIdx, point); - _shape.setPoints(points); - } - - /** - * Vertice edited update - * - * @param vIdx Vertice index - */ - public void verticeRemoveUpdate(int vIdx) { - List points = (List)_shape.getPoints(); - points.remove(vIdx); - _shape.setPoints(points); - } - - /** - * Export to XML document - * @param doc XML document - * @param parent Parent XML element - */ - public void exportToXML(Document doc, Element parent) { - Element graphic = doc.createElement("Graphic"); - addShape(doc, graphic, _shape); - addLegend(doc, graphic, _legend, _shape.getShapeType()); - - parent.appendChild(graphic); - } - - /** - * Add shape to XML document - * @param doc XML document - * @param parent Parent XML element - * @param aShape The shape - */ - protected void addShape(Document doc, Element parent, Shape aShape) { - Element shape = doc.createElement("Shape"); - boolean hasAngle = aShape.getShapeType() == ShapeTypes.Ellipse; - - //Add general attribute - Attr shapeType = doc.createAttribute("ShapeType"); - Attr visible = doc.createAttribute("Visible"); - Attr selected = doc.createAttribute("Selected"); - - //shapeType.InnerText = Enum.GetName(typeof(ShapeTypes), aShape.ShapeType); - shapeType.setValue(aShape.getShapeType().toString()); - visible.setValue(String.valueOf(aShape.isVisible())); - selected.setValue(String.valueOf(aShape.isSelected())); - - shape.setAttributeNode(shapeType); - shape.setAttributeNode(visible); - shape.setAttributeNode(selected); - - if (hasAngle){ - Attr angle = doc.createAttribute("Angle"); - angle.setValue(String.valueOf(((EllipseShape)aShape).getAngle())); - shape.setAttributeNode(angle); - } - - //Add points - Element points = doc.createElement("Points"); - List pointList = (List)aShape.getPoints(); - for (PointD aPoint : pointList) { - Element point = doc.createElement("Point"); - Attr x = doc.createAttribute("X"); - Attr y = doc.createAttribute("Y"); - x.setValue(String.valueOf(aPoint.X)); - y.setValue(String.valueOf(aPoint.Y)); - point.setAttributeNode(x); - point.setAttributeNode(y); - - points.appendChild(point); - } - - shape.appendChild(points); - - parent.appendChild(shape); - } - - /** - * Add legend to XML document - * @param doc XML document - * @param parent Parent XML element - * @param aLegend The legend - * @param shapeType The shape type - */ - protected void addLegend(Document doc, Element parent, ColorBreak aLegend, ShapeTypes shapeType) { - Element legend = doc.createElement("Legend"); - Attr color = doc.createAttribute("Color"); - color.setValue(ColorUtil.toHexEncoding(aLegend.getColor())); - legend.setAttributeNode(color); - - Attr legendType = doc.createAttribute("LegendType"); - Attr size; - Attr style; - Attr outlineColor; - Attr drawOutline; - Attr drawFill; - legendType.setValue(aLegend.getBreakType().toString()); - switch (aLegend.getBreakType()) { - case PointBreak: - PointBreak aPB = (PointBreak) aLegend; - outlineColor = doc.createAttribute("OutlineColor"); - size = doc.createAttribute("Size"); - style = doc.createAttribute("Style"); - drawOutline = doc.createAttribute("DrawOutline"); - drawFill = doc.createAttribute("DrawFill"); - Attr markerType = doc.createAttribute("MarkerType"); - Attr fontName = doc.createAttribute("FontName"); - Attr charIndex = doc.createAttribute("CharIndex"); - Attr imagePath = doc.createAttribute("ImagePath"); - Attr angle = doc.createAttribute("Angle"); - - //legendType.InnerText = "PointBreak"; - outlineColor.setValue(ColorUtil.toHexEncoding(aPB.getOutlineColor())); - size.setValue(String.valueOf(aPB.getSize())); - style.setValue(aPB.getStyle().toString()); - drawOutline.setValue(String.valueOf(aPB.isDrawOutline())); - drawFill.setValue(String.valueOf(aPB.isDrawFill())); - markerType.setValue(aPB.getMarkerType().toString()); - fontName.setValue(aPB.getFontName()); - charIndex.setValue(String.valueOf(aPB.getCharIndex())); - imagePath.setValue(aPB.getImagePath()); - angle.setValue(String.valueOf(aPB.getAngle())); - - legend.setAttributeNode(legendType); - legend.setAttributeNode(outlineColor); - legend.setAttributeNode(size); - legend.setAttributeNode(style); - legend.setAttributeNode(drawOutline); - legend.setAttributeNode(drawFill); - legend.setAttributeNode(markerType); - legend.setAttributeNode(fontName); - legend.setAttributeNode(charIndex); - legend.setAttributeNode(imagePath); - legend.setAttributeNode(angle); - break; - case LabelBreak: - LabelBreak aLB = (LabelBreak) aLegend; - Attr text = doc.createAttribute("Text"); - angle = doc.createAttribute("Angle"); - fontName = doc.createAttribute("FontName"); - Attr fontSize = doc.createAttribute("FontSize"); - Attr fontBold = doc.createAttribute("FontBold"); - Attr yShift = doc.createAttribute("YShift"); - - //legendType.InnerText = "LabelBreak"; - text.setValue(aLB.getText()); - angle.setValue(String.valueOf(aLB.getAngle())); - fontName.setValue(aLB.getFont().getName()); - fontSize.setValue(String.valueOf(aLB.getFont().getSize())); - fontBold.setValue(String.valueOf(aLB.getFont().isBold())); - yShift.setValue(String.valueOf(aLB.getYShift())); - - legend.setAttributeNode(legendType); - legend.setAttributeNode(text); - legend.setAttributeNode(angle); - legend.setAttributeNode(fontName); - legend.setAttributeNode(fontSize); - legend.setAttributeNode(fontBold); - legend.setAttributeNode(yShift); - break; - case ChartBreak: - ChartBreak aChB = (ChartBreak) aLegend; - Attr shapeIndex = doc.createAttribute("ShapeIndex"); - Attr chartType = doc.createAttribute("ChartType"); - Attr chartData = doc.createAttribute("ChartData"); - Attr xShift = doc.createAttribute("XShift"); - yShift = doc.createAttribute("YShift"); - fontName = doc.createAttribute("FontName"); - fontSize = doc.createAttribute("FontSize"); - Attr labelColor = doc.createAttribute("LabelColor"); - - shapeIndex.setValue(String.valueOf(aChB.getShapeIndex())); - //legendType.InnerText = "ChartBreak"; - chartType.setValue(aChB.getChartType().toString()); - String cdata = ""; - for (int i = 0; i < aChB.getItemNum(); i++) { - if (i == 0) { - cdata = String.valueOf(aChB.getChartData().get(i)); - } else { - cdata += "," + String.valueOf(aChB.getChartData().get(i)); - } - } - chartData.setValue(cdata); - xShift.setValue(String.valueOf(aChB.getXShift())); - yShift.setValue(String.valueOf(aChB.getYShift())); - fontName.setValue(aChB.getLabelFont().getFontName()); - fontSize.setValue(String.valueOf(aChB.getLabelFont().getSize())); - labelColor.setValue(ColorUtil.toHexEncoding(aChB.getLabelColor())); - - legend.setAttributeNode(legendType); - legend.setAttributeNode(shapeIndex); - legend.setAttributeNode(chartType); - legend.setAttributeNode(chartData); - legend.setAttributeNode(xShift); - legend.setAttributeNode(yShift); - legend.setAttributeNode(fontName); - legend.setAttributeNode(fontSize); - legend.setAttributeNode(labelColor); - break; - case VectorBreak: - //legendType.InnerText = "VectorBreak"; - legend.setAttributeNode(legendType); - break; - case PolylineBreak: - PolylineBreak aPLB = (PolylineBreak) aLegend; - size = doc.createAttribute("Size"); - style = doc.createAttribute("Style"); - Attr drawSymbol = doc.createAttribute("DrawSymbol"); - Attr symbolSize = doc.createAttribute("SymbolSize"); - Attr symbolStyle = doc.createAttribute("SymbolStyle"); - Attr symbolColor = doc.createAttribute("SymbolColor"); - Attr symbolInterval = doc.createAttribute("SymbolInterval"); - - //legendType.InnerText = "PolylineBreak"; - size.setValue(String.valueOf(aPLB.getWidth())); - style.setValue(aPLB.getStyle().toString()); - drawSymbol.setValue(String.valueOf(aPLB.getDrawSymbol())); - symbolSize.setValue(String.valueOf(aPLB.getSymbolSize())); - symbolStyle.setValue(String.valueOf(aPLB.getSymbolStyle())); - symbolColor.setValue(ColorUtil.toHexEncoding(aPLB.getSymbolColor())); - symbolInterval.setValue(String.valueOf(aPLB.getSymbolInterval())); - - legend.setAttributeNode(legendType); - legend.setAttributeNode(size); - legend.setAttributeNode(style); - legend.setAttributeNode(drawSymbol); - legend.setAttributeNode(symbolSize); - legend.setAttributeNode(symbolStyle); - legend.setAttributeNode(symbolColor); - legend.setAttributeNode(symbolInterval); - break; - case PolygonBreak: - PolygonBreak aPGB = (PolygonBreak) aLegend; - outlineColor = doc.createAttribute("OutlineColor"); - drawOutline = doc.createAttribute("DrawOutline"); - drawFill = doc.createAttribute("DrawFill"); - Attr outlineSize = doc.createAttribute("OutlineSize"); - //Attr usingHatchStyle = doc.createAttribute("UsingHatchStyle"); - //style = doc.createAttribute("Style"); - Attr backColor = doc.createAttribute("BackColor"); - //Attr transparencyPer = doc.createAttribute("TransparencyPercent"); - Attr isMaskout = doc.createAttribute("IsMaskout"); - - //legendType.InnerText = "PolygonBreak"; - outlineColor.setValue(ColorUtil.toHexEncoding(aPGB.getOutlineColor())); - drawOutline.setValue(String.valueOf(aPGB.isDrawOutline())); - drawFill.setValue(String.valueOf(aPGB.isDrawFill())); - outlineSize.setValue(String.valueOf(aPGB.getOutlineSize())); - //usingHatchStyle.setValue(String.valueOf(aPGB.getUsingHatchStyle())); - //style.setValue(String.valueOf(aPGB.getStyle())); - backColor.setValue(ColorUtil.toHexEncoding(aPGB.getBackColor())); - //transparencyPer.InnerText = aPGB.TransparencyPercent.ToString(); - isMaskout.setValue(String.valueOf(aPGB.isMaskout())); - - legend.setAttributeNode(legendType); - legend.setAttributeNode(outlineColor); - legend.setAttributeNode(drawOutline); - legend.setAttributeNode(drawFill); - legend.setAttributeNode(outlineSize); - //legend.setAttributeNode(usingHatchStyle); - //legend.setAttributeNode(style); - legend.setAttributeNode(backColor); - //legend.setAttributeNode(transparencyPer); - legend.setAttributeNode(isMaskout); - break; - } - - parent.appendChild(legend); - } - - /** - * Import from xml node - * - * @param graphicNode Graphic xml node - */ - public void importFromXML(Element graphicNode) { - Node shape = graphicNode.getElementsByTagName("Shape").item(0); - _shape = loadShape(shape); - - Node legend = graphicNode.getElementsByTagName("Legend").item(0); - _legend = loadLegend(legend, _shape.getShapeType()); - - updateResizeAbility(); - } - - protected Shape loadShape(Node shapeNode) { - Shape aShape = null; - try { - ShapeTypes shapeType = ShapeTypes.valueOf(shapeNode.getAttributes().getNamedItem("ShapeType").getNodeValue()); - switch (shapeType) { - case Point: - aShape = new PointShape(); - break; - case WindArraw: - aShape = new WindArrow(); - break; - case Polyline: - aShape = new PolylineShape(); - break; - case CurveLine: - aShape = new CurveLineShape(); - break; - case Circle: - aShape = new CircleShape(); - break; - case Polygon: - case Rectangle: - aShape = new PolygonShape(); - break; - case CurvePolygon: - aShape = new CurvePolygonShape(); - break; - case Ellipse: - aShape = new EllipseShape(); - break; - } - - aShape.setVisible(Boolean.parseBoolean(shapeNode.getAttributes().getNamedItem("Visible").getNodeValue())); - aShape.setSelected(Boolean.parseBoolean(shapeNode.getAttributes().getNamedItem("Selected").getNodeValue())); - if (aShape.getShapeType() == ShapeTypes.Ellipse){ - Node angleNode = shapeNode.getAttributes().getNamedItem("Angle"); - if (angleNode != null) - ((EllipseShape)aShape).setAngle(Float.parseFloat(angleNode.getNodeValue())); - } - - List pointList = new ArrayList<>(); - Node pointsNode = ((Element)shapeNode).getElementsByTagName("Points").item(0); - NodeList nl = ((Element)pointsNode).getElementsByTagName("Point"); - for (int i = 0; i < nl.getLength(); i++) { - Node pNode = nl.item(i); - PointD aPoint = new PointD(Double.parseDouble(pNode.getAttributes().getNamedItem("X").getNodeValue()), - Double.parseDouble(pNode.getAttributes().getNamedItem("Y").getNodeValue())); - pointList.add(aPoint); - } - aShape.setPoints(pointList); - } catch (Exception e) { - } - - return aShape; - } - - protected ColorBreak loadLegend(Node legendNode, ShapeTypes shapeType) { - ColorBreak legend = new ColorBreak(); - try { - Color color = ColorUtil.parseToColor(legendNode.getAttributes().getNamedItem("Color").getNodeValue()); - String legendType = legendNode.getAttributes().getNamedItem("LegendType").getNodeValue(); - BreakTypes breakType = BreakTypes.valueOf(legendType); - switch (breakType) { - case PointBreak: - PointBreak aPB = new PointBreak(); - try { - aPB.setColor(color); - aPB.setDrawFill(Boolean.parseBoolean(legendNode.getAttributes().getNamedItem("DrawFill").getNodeValue())); - aPB.setDrawOutline(Boolean.parseBoolean(legendNode.getAttributes().getNamedItem("DrawOutline").getNodeValue())); - aPB.setOutlineColor(ColorUtil.parseToColor(legendNode.getAttributes().getNamedItem("OutlineColor").getNodeValue())); - aPB.setSize(Float.parseFloat(legendNode.getAttributes().getNamedItem("Size").getNodeValue())); - aPB.setStyle(PointStyle.valueOf(legendNode.getAttributes().getNamedItem("Style").getNodeValue())); - aPB.setMarkerType(MarkerType.valueOf(legendNode.getAttributes().getNamedItem("MarkerType").getNodeValue())); - aPB.setFontName(legendNode.getAttributes().getNamedItem("FontName").getNodeValue()); - aPB.setCharIndex(Integer.parseInt(legendNode.getAttributes().getNamedItem("CharIndex").getNodeValue())); - aPB.setImagePath(legendNode.getAttributes().getNamedItem("ImagePath").getNodeValue()); - aPB.setAngle(Float.parseFloat(legendNode.getAttributes().getNamedItem("Angle").getNodeValue())); - } catch (Exception e) { - } finally { - legend = aPB; - } - break; - case LabelBreak: - LabelBreak aLB = new LabelBreak(); - try { - aLB.setColor(color); - aLB.setAngle(Float.parseFloat(legendNode.getAttributes().getNamedItem("Angle").getNodeValue())); - aLB.setText(legendNode.getAttributes().getNamedItem("Text").getNodeValue()); - String fontName = legendNode.getAttributes().getNamedItem("FontName").getNodeValue(); - float fontSize = Float.parseFloat(legendNode.getAttributes().getNamedItem("FontSize").getNodeValue()); - boolean fontBold = Boolean.parseBoolean(legendNode.getAttributes().getNamedItem("FontBold").getNodeValue()); - if (fontBold) { - aLB.setFont(new Font(fontName, Font.BOLD, (int) fontSize)); - } else { - aLB.setFont(new Font(fontName, Font.PLAIN, (int) fontSize)); - } - - aLB.setYShift(Float.parseFloat(legendNode.getAttributes().getNamedItem("YShift").getNodeValue())); - } catch (Exception e) { - } finally { - legend = aLB; - } - break; - case ChartBreak: - ChartBreak aChB = new ChartBreak(ChartTypes.BarChart); - try { - ChartTypes chartType = ChartTypes.valueOf(legendNode.getAttributes().getNamedItem("ChartType").getNodeValue()); - aChB = new ChartBreak(chartType); - aChB.setShapeIndex(Integer.parseInt(legendNode.getAttributes().getNamedItem("ShapeIndex").getNodeValue())); - List cData = new ArrayList(); - String[] cDataStr = legendNode.getAttributes().getNamedItem("ChartData").getNodeValue().split(","); - for (int i = 0; i < cDataStr.length; i++) { - cData.add(Float.parseFloat(cDataStr[i])); - } - - aChB.setChartData(cData); - aChB.setXShift(Integer.parseInt(legendNode.getAttributes().getNamedItem("XShift").getNodeValue())); - aChB.setYShift(Integer.parseInt(legendNode.getAttributes().getNamedItem("YShift").getNodeValue())); - String fontName = legendNode.getAttributes().getNamedItem("FontName").getNodeValue(); - float fontSize = Float.parseFloat(legendNode.getAttributes().getNamedItem("FontSize").getNodeValue()); - aChB.setLabelFont(new Font(fontName, Font.PLAIN, (int)fontSize)); - aChB.setLabelColor(ColorUtil.parseToColor(legendNode.getAttributes().getNamedItem("LabelColor").getNodeValue())); - } catch (Exception e) { - } finally { - legend = aChB; - } - break; - case VectorBreak: - VectorBreak aVB = new VectorBreak(); - try { - aVB.setColor(color); - } catch (Exception e) { - } finally { - legend = aVB; - } - break; - case PolylineBreak: - PolylineBreak aPLB = new PolylineBreak(); - try { - aPLB.setColor(color); - aPLB.setWidth(Float.parseFloat(legendNode.getAttributes().getNamedItem("Size").getNodeValue())); - aPLB.setStyle(LineStyles.valueOf(legendNode.getAttributes().getNamedItem("Style").getNodeValue())); - aPLB.setDrawSymbol(Boolean.parseBoolean(legendNode.getAttributes().getNamedItem("DrawSymbol").getNodeValue())); - aPLB.setSymbolSize(Float.parseFloat(legendNode.getAttributes().getNamedItem("SymbolSize").getNodeValue())); - aPLB.setSymbolStyle(PointStyle.valueOf(legendNode.getAttributes().getNamedItem("SymbolStyle").getNodeValue())); - aPLB.setSymbolColor(ColorUtil.parseToColor(legendNode.getAttributes().getNamedItem("SymbolColor").getNodeValue())); - aPLB.setSymbolInterval(Integer.parseInt(legendNode.getAttributes().getNamedItem("SymbolInterval").getNodeValue())); - } catch (Exception e) { - } finally { - legend = aPLB; - } - break; - case PolygonBreak: - PolygonBreak aPGB = new PolygonBreak(); - try { - aPGB.setColor(color); - aPGB.setDrawFill(Boolean.parseBoolean(legendNode.getAttributes().getNamedItem("DrawFill").getNodeValue())); - aPGB.setDrawOutline(Boolean.parseBoolean(legendNode.getAttributes().getNamedItem("DrawOutline").getNodeValue())); - aPGB.setOutlineSize(Float.parseFloat(legendNode.getAttributes().getNamedItem("OutlineSize").getNodeValue())); - aPGB.setOutlineColor(ColorUtil.parseToColor(legendNode.getAttributes().getNamedItem("OutlineColor").getNodeValue())); - //aPGB.UsingHatchStyle = bool.Parse(legendNode.Attributes["UsingHatchStyle"].InnerText); - //aPGB.Style = (HatchStyle)Enum.Parse(typeof(HatchStyle), legendNode.Attributes["Style"].InnerText, true); - aPGB.setBackColor(ColorUtil.parseToColor(legendNode.getAttributes().getNamedItem("BackColor").getNodeValue())); - //aPGB.TransparencyPercent = int.Parse(legendNode.Attributes["TransparencyPercent"].InnerText); - aPGB.setMaskout(Boolean.parseBoolean(legendNode.getAttributes().getNamedItem("IsMaskout").getNodeValue())); - } catch (Exception e) { - } { - legend = aPGB; - } - break; - } - } catch (Exception e) { - } - return legend; - } - // - } diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/graphic/GraphicCollection.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/graphic/GraphicCollection.java deleted file mode 100644 index cb038eb3..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/graphic/GraphicCollection.java +++ /dev/null @@ -1,692 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.chart.graphic; - -import org.meteoinfo.common.Extent; -import org.meteoinfo.common.MIMath; -import org.meteoinfo.common.PointD; -import org.meteoinfo.geometry.geoprocess.GeoComputation; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.NoSuchElementException; - -import org.meteoinfo.geo.shape.*; -import org.meteoinfo.chart.legend.LabelSet; -import org.meteoinfo.chart.legend.BreakTypes; -import org.meteoinfo.chart.legend.ColorBreak; -import org.meteoinfo.chart.legend.LabelBreak; -import org.meteoinfo.chart.legend.LegendScheme; -import org.meteoinfo.chart.legend.PointBreak; -import org.meteoinfo.geometry.shape.*; - -/** - * - * @author Yaqiang Wang - */ -public class GraphicCollection extends Graphic implements Iterator { - - // - private List graphics = new ArrayList<>(); - private Extent _extent = new Extent(); - protected boolean singleLegend = true; - private int index; - private LabelSet labelSet; - private List labelPoints; - protected LegendScheme legendScheme; - protected ColorBreak legendBreak; - // - // - - /** - * Constructor - */ - public GraphicCollection() { - this.index = 0; - labelSet = new LabelSet(); - labelPoints = new ArrayList<>(); - } - - // - // - /** - * Get graphic list - * - * @return Graphic list - */ - @Override - public List getGraphics() { - return this.graphics; - } - - /** - * Set graphic list - * - * @param value Graphic list - */ - public void setGraphics(List value) { - this.graphics = value; - } - - /** - * Get extent - * - * @return The extent - */ - @Override - public Extent getExtent() { - return _extent; - } - - /** - * Set extent - * - * @param value Extent - */ - @Override - public void setExtent(Extent value) { - this._extent = value; - } - - /** - * Get is single legend or not - * - * @return Boolean - */ - @Override - public boolean isSingleLegend() { - return this.singleLegend; - } - - /** - * Set is single legend or not - * - * @param value Boolean - */ - public void setSingleLegend(boolean value) { - this.singleLegend = value; - } - - /** - * Get label set - * - * @return Label set - */ - public LabelSet getLabelSet() { - return labelSet; - } - - /** - * Set label set - * - * @param ls Label set - */ - public void setLabelSet(LabelSet ls) { - labelSet = ls; - } - - /** - * Get label points - * - * @return The lable points - */ - public List getLabelPoints() { - return this.labelPoints; - } - - /** - * Set label points - * - * @param lps The lable points - */ - public void setLabelPoints(List lps) { - this.labelPoints = lps; - } - - /** - * Get legend scheme - * - * @return Legend scheme - */ - public LegendScheme getLegendScheme() { - return this.legendScheme; - } - - /** - * Set legend scheme - * - * @param value Legend scheme - */ - public void setLegendScheme(LegendScheme value) { - this.legendScheme = value; - } - - /** - * Get legend break - * - * @return Legend break - */ - public ColorBreak getLegendBreak() { - return this.legendBreak; - } - - /** - * Set legend break - * - * @param value Legend break - */ - public void setLegendBreak(ColorBreak value) { - this.legendBreak = value; - } - - /** - * Get is 3D or not - * - * @return Boolean - */ - public boolean is3D() { - return false; - } - - /** - * Get if is GraphicCollection - * - * @return Boolean - */ - @Override - public boolean isCollection() { - return true; - } - - // - // - /** - * Update extent - */ - public void updateExtent() { - int i = 0; - Extent extent; - for (Graphic g : this.graphics) { - if (g instanceof GraphicCollection) { - extent = g.getExtent(); - } else { - extent = g.getShape().getExtent(); - } - if (i == 0) { - _extent = extent; - } else { - _extent = MIMath.getLagerExtent(_extent, extent); - } - - i += 1; - } - } - - /** - * Add a graphic - * - * @param aGraphic The graphic - * @return Boolean - */ - public boolean add(Graphic aGraphic) { - boolean istrue = this.graphics.add(aGraphic); - - //Update extent - if (this.graphics.size() == 1) { - _extent = aGraphic.getExtent(); - } else { - _extent = MIMath.getLagerExtent(_extent, aGraphic.getExtent()); - } - - return istrue; - } - - /** - * Inset a graphic - * - * @param index Index - * @param aGraphic The graphic - */ - public void add(int index, Graphic aGraphic) { - this.graphics.add(index, aGraphic); - - //Update extent - if (this.graphics.size() == 1) { - _extent = aGraphic.getShape().getExtent(); - } else { - _extent = MIMath.getLagerExtent(_extent, aGraphic.getShape().getExtent()); - } - } - - /** - * Get a graphic by index - * - * @param idx Index - * @return Graphic - */ - public Graphic get(int idx) { - return this.graphics.get(idx); - } - - /** - * Index of - * - * @param g Graphic - * @return Index - */ - public int indexOf(Graphic g) { - return this.graphics.indexOf(g); - } - - /** - * Contains or not - * - * @param g Graphic - * @return Boolean - */ - public boolean contains(Graphic g) { - return this.graphics.contains(g); - } - - /** - * Get graphic list size - * - * @return Gaphic list size - */ - public int size() { - return this.graphics.size(); - } - - /** - * Get is empty or not - * - * @return Boolean - */ - public boolean isEmpty() { - return this.graphics.isEmpty(); - } - - /** - * Get graphics number - * - * @return 1 - */ - @Override - public int getNumGraphics() { - return this.size(); - } - - /** - * Get Graphic by index - * - * @param idx Index - * @return Graphic - */ - @Override - public Graphic getGraphicN(int idx) { - return this.get(idx); - } - - /** - * Remove a graphic - * - * @param aGraphic The graphic - * @return Boolean - */ - public boolean remove(Graphic aGraphic) { - boolean istrue = this.graphics.remove(aGraphic); - this.updateExtent(); - - return istrue; - } - - /** - * Remove a graphic by index - * - * @param index The index - * @return The removed graphic - */ - public Graphic remove(int index) { - Graphic ag = this.graphics.remove(index); - this.updateExtent(); - - return ag; - } - - /** - * Clear graphics - */ - public void clear() { - this.graphics.clear(); - } - - /** - * Add all - * - * @param gs Graphic list - */ - public void addAll(List gs) { - this.graphics.addAll(gs); - } - - /** - * Join this graphics with other graphics - * - * @param graphic Other graphics - */ - public void join(Graphic graphic) { - if (graphic.isCollection()) { - //Update extent - if (this.isEmpty()) { - _extent = graphic.getExtent(); - } else { - _extent = MIMath.getLagerExtent(_extent, graphic.getExtent()); - } - for (int i = 0; i < graphic.getNumGraphics(); i++) { - this.graphics.add(graphic.getGraphicN(i)); - } - } else { - this.add(graphic); - } - } - - /** - * Remove all - * - * @param gs Graphic list - */ - public void removeAll(List gs) { - this.graphics.removeAll(gs); - } - - /** - * Get legend - * - * @return Legend - */ - @Override - public ColorBreak getLegend() { - if (this.legendBreak != null) { - return this.legendBreak; - } else { - return this.graphics.get(0).getLegend(); - } - } - - /** - * Select graphics by an extent - * - * @param aExtent The extent - * @return Selected graphics - */ - public GraphicCollection selectGraphics(Extent aExtent) { - GraphicCollection selectedGraphics = new GraphicCollection(); - int i, j; - PointD aPoint = new PointD(); - aPoint.X = (aExtent.minX + aExtent.maxX) / 2; - aPoint.Y = (aExtent.minY + aExtent.maxY) / 2; - - for (Graphic aGraphic : this.graphics) { - switch (aGraphic.getShape().getShapeType()) { - case Point: - PointShape aPS = (PointShape) aGraphic.getShape(); - if (MIMath.pointInExtent(aPS.getPoint(), aExtent)) { - selectedGraphics.add(aGraphic); - } - break; - case Polyline: - case PolylineZ: - PolylineShape aPLS = (PolylineShape) aGraphic.getShape(); - if (MIMath.isExtentCross(aExtent, aPLS.getExtent())) { - for (j = 0; j < aPLS.getPoints().size(); j++) { - aPoint = aPLS.getPoints().get(j); - if (MIMath.pointInExtent(aPoint, aExtent)) { - selectedGraphics.add(aGraphic); - break; - } - } - } - break; - case Polygon: - case Rectangle: - PolygonShape aPGS = (PolygonShape) aGraphic.getShape(); - if (!(aPGS.getPartNum() > 1)) { - if (GeoComputation.pointInPolygon((List) aPGS.getPoints(), aPoint)) { - selectedGraphics.add(aGraphic); - } - } else { - for (int p = 0; p < aPGS.getPartNum(); p++) { - ArrayList pList = new ArrayList(); - if (p == aPGS.getPartNum() - 1) { - for (int pp = aPGS.parts[p]; pp < aPGS.getPointNum(); pp++) { - pList.add(aPGS.getPoints().get(pp)); - } - } else { - for (int pp = aPGS.parts[p]; pp < aPGS.parts[p + 1]; pp++) { - pList.add(aPGS.getPoints().get(pp)); - } - } - if (GeoComputation.pointInPolygon(pList, aPoint)) { - selectedGraphics.add(aGraphic); - break; - } - } - } - break; - } - } - - return selectedGraphics; - } - - @Override - public boolean hasNext() { - return index <= this.size() - 1; - } - - @Override - public Object next() { - if (index >= this.size()) { - throw new NoSuchElementException(); - } - - return this.get(index++); - } - - /** - * Add labels - */ - public void addLabels() { - addLabelsByColor(); - - labelSet.setDrawLabels(true); - } - - /** - * Get shapes - * - * @return Shapes - */ - public List getShapes() { - List shapes = new ArrayList<>(); - for (Graphic g : this.graphics) { - shapes.add(g.getShape()); - } - return shapes; - } - - /** - * Get shape type - * - * @return Shape type - */ - public ShapeTypes getShapeType() { - return this.graphics.get(0).getShape().getShapeType(); - } - - private double getMinValue() { - double min = Double.MAX_VALUE; - for (Graphic graphic : this.graphics) { - Shape shape = graphic.getShape(); - if (min > shape.getValue()) { - min = shape.getValue(); - } - } - return min; - } - - /** - * Add labels - */ - private void addLabelsByColor() { - if (labelSet.isAutoDecimal()) { - double min = getMinValue(); - labelSet.setDecimalDigits(MIMath.getDecimalNum(min)); - } - String dFormat = "%1$." + String.valueOf(labelSet.getDecimalDigits()) + "f"; - PointD aPoint; - for (Graphic graphic : this.graphics) { - ColorBreak cb = graphic.getLegend(); - Shape shape = graphic.getShape(); - PointShape aPS = new PointShape(); - switch (shape.getShapeType()) { - case Point: - case PointM: - case PointZ: - aPS.setPoint((PointD) ((PointShape) shape).getPoint().clone()); - break; - case Polyline: - case PolylineM: - case PolylineZ: - int pIdx = ((PolylineShape) shape).getPoints().size() / 2; - aPS.setPoint((PointD) ((PolylineShape) shape).getPoints().get(pIdx - 1).clone()); - break; - case Polygon: - case PolygonM: - Extent aExtent = shape.getExtent(); - aPoint = new PointD(); - aPoint.X = ((aExtent.minX + aExtent.maxX) / 2); - aPoint.Y = ((aExtent.minY + aExtent.maxY) / 2); - aPS.setPoint(aPoint); - break; - } - - LabelBreak aLP = new LabelBreak(); - //aLP.setText(DataConvert.removeTailingZeros(String.valueOf(shape.getValue()))); - aLP.setText(String.format(dFormat, shape.getValue())); - if (labelSet.isColorByLegend()) { - aLP.setColor(cb.getColor()); - } else { - aLP.setColor(labelSet.getLabelColor()); - } - aLP.setFont(labelSet.getLabelFont()); - aLP.setAlignType(labelSet.getLabelAlignType()); - aLP.setYShift(labelSet.getYOffset()); - aLP.setXShift(labelSet.getXOffset()); - Graphic aGraphic = new Graphic(aPS, aLP); - addLabel(aGraphic); - } - } - - /** - * Add label point - * - * @param aLP Label point - */ - public void addLabel(Graphic aLP) { - labelPoints.add(aLP); - } - - /** - * Add labels of contour layer dynamicly - * - * @param sExtent View extent of MapView - */ - public void addLabelsContourDynamic(Extent sExtent) { - if (labelSet.isAutoDecimal()) { - double min = getMinValue(); - labelSet.setDecimalDigits(MIMath.getDecimalNum(min)); - } - String dFormat = "%1$." + String.valueOf(labelSet.getDecimalDigits()) + "f"; - String text; - for (Graphic graphic : this.graphics) { - Shape shape = graphic.getShape(); - ColorBreak cb = graphic.getLegend(); - PolylineShape aPLS = (PolylineShape) shape; - Extent IExtent = aPLS.getExtent(); - if (IExtent.maxX - IExtent.minX > (sExtent.maxX - sExtent.minX) / 10 - || IExtent.maxY - IExtent.minY > (sExtent.maxY - sExtent.minY) / 10) { - LabelBreak aLP = new LabelBreak(); - int pIdx = aPLS.getPoints().size() / 2; - //PointF aPoint = new PointF(0, 0); - PointShape aPS = new PointShape(); - aPS.setPoint(aPLS.getPoints().get(pIdx - 1)); - //text = DataConvert.removeTailingZeros(String.valueOf(aPLS.getValue())); - text = String.format(dFormat, aPLS.getValue()); - aLP.setText(text); - aLP.setFont(labelSet.getLabelFont()); - aLP.setAlignType(labelSet.getLabelAlignType()); - aLP.setYShift(labelSet.getYOffset()); - if (labelSet.isColorByLegend()) { - aLP.setColor(cb.getColor()); - } else { - aLP.setColor(labelSet.getLabelColor()); - } - Graphic aGraphic = new Graphic(aPS, aLP); - addLabel(aGraphic); - } - } - - labelSet.setDrawLabels(true); - } - - /** - * Get arrow zoom - * - * @return Arrow zoom - */ - public float getArrowZoom() { - if (this.getLegend().getBreakType() == BreakTypes.PointBreak) { - float size = ((PointBreak) this.getLegend()).getSize(); - return size / 10; - } - - return 1.0f; - } - - /** - * Clip - * - * @param clipPolys Clipping polygons - * @return Clipped graphics - */ - public GraphicCollection clip(List clipPolys) { - GraphicCollection cgraphics = new GraphicCollection(); - for (PolygonShape aPGS : clipPolys) { - for (int i = 0; i < this.graphics.size(); i++) { - Shape bShape = this.graphics.get(i).getShape(); - Shape clipShape = bShape.intersection(aPGS); - if (clipShape != null) { - cgraphics.add(new Graphic(clipShape, this.graphics.get(i).getLegend())); - } - } - } - cgraphics.setSingleLegend(this.singleLegend); - cgraphics.setLegendScheme((LegendScheme) this.getLegendScheme().clone()); - - return cgraphics; - } - // -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/graphic/ImageGraphic.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/graphic/ImageGraphic.java deleted file mode 100644 index ca4bbc4b..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/graphic/ImageGraphic.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.meteoinfo.chart.graphic; - -import org.meteoinfo.geometry.shape.ImageShape; -import org.meteoinfo.chart.legend.ColorBreak; -import org.meteoinfo.chart.legend.LegendScheme; - -public class ImageGraphic extends Graphic{ - protected LegendScheme legendScheme; - - /** - * Constructor - */ - public ImageGraphic() { - super(); - } - - /** - * Constructor - * @param shape The image shape - * @param ls - */ - public ImageGraphic(ImageShape shape, LegendScheme ls) { - super(shape, new ColorBreak()); - this.legendScheme = ls; - } - - /** - * Get legend scheme - * - * @return Legend scheme - */ - public LegendScheme getLegendScheme() { - return this.legendScheme; - } - - /** - * Set legend scheme - * - * @param value Legend scheme - */ - public void setLegendScheme(LegendScheme value) { - this.legendScheme = value; - } -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/graphic/PolylineErrorShape.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/graphic/PolylineErrorShape.java deleted file mode 100644 index 9b3c2f9b..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/graphic/PolylineErrorShape.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.graphic; - -import org.meteoinfo.geometry.shape.PolylineShape; -import org.meteoinfo.geometry.shape.ShapeTypes; -import org.meteoinfo.ndarray.Array; - -import java.util.List; - -/** - * - * @author Yaqiang Wang - */ -public class PolylineErrorShape extends PolylineShape { - // - private double[] xerror; - private double[] yerror; - // - // - // - // - /** - * Get X error data - * @return X error data - */ - public double[] getXerror(){ - return this.xerror; - } - - /** - * Set X error data - * @param value X error data - */ - public void setXerror(double[] value){ - this.xerror = value; - } - - /** - * Set x error data - * @param value X error data - */ - public void setXerror(double value){ - this.xerror = new double[this.getPointNum()]; - for (int i = 0; i < this.xerror.length; i++){ - this.xerror[i] = value; - } - } - - /** - * Set X error data - * @param value X error data - */ - public void setXerror(List value){ - this.xerror = new double[value.size()]; - double v; - for (int i = 0; i < value.size(); i++){ - v = value.get(i).doubleValue(); - xerror[i] = v; - } - } - - /** - * Set X error data - * @param value X error data - */ - public void setXerror(Array value){ - this.xerror = new double[(int)value.getSize()]; - double v; - for (int i = 0; i < xerror.length; i++){ - v = value.getDouble(i); - xerror[i] = v; - } - } - - /** - * Get Y error data - * @return Y error data - */ - public double[] getYerror(){ - return this.yerror; - } - - /** - * Set Y error data - * @param value Y error data - */ - public void setYerror(double[] value){ - this.yerror = value; - } - - /** - * Set y error data - * @param value Y error data - */ - public void setYerror(double value){ - this.yerror = new double[this.getPointNum()]; - for (int i = 0; i < this.yerror.length; i++){ - this.yerror[i] = value; - } - } - - /** - * Set Y error data - * @param value Y error data - */ - public void setYerror(List value){ - this.yerror = new double[value.size()]; - double v; - for (int i = 0; i < value.size(); i++){ - v = value.get(i).doubleValue(); - yerror[i] = v; - } - } - - /** - * Set Y error data - * @param value Y error data - */ - public void setYerror(Array value){ - this.yerror = new double[(int)value.getSize()]; - double v; - for (int i = 0; i < yerror.length; i++){ - v = value.getDouble(i); - yerror[i] = v; - } - } - // - // - @Override - public ShapeTypes getShapeType(){ - return ShapeTypes.PolylineError; - } - - /** - * Get y error - * @param idx Index - * @return Y error - */ - public double getYerror(int idx){ - return this.yerror[idx]; - } - - /** - * Get x error - * @param idx Index - * @return X error - */ - public double getXerror(int idx){ - return this.xerror[idx]; - } - - /** - * Update extent - */ - public void updateExtent(){ - double min = 0, max = 0, v; - if (this.xerror != null){ - for (int i = 0; i < this.xerror.length; i++){ - v = this.xerror[i]; - if (i == 0){ - min = v; - max = v; - } else { - if (v < min) - min = v; - else if (v > max) - max = v; - } - } - this.getExtent().minX -= max; - this.getExtent().maxX += max; - } - if (this.yerror != null){ - for (int i = 0; i < this.yerror.length; i++){ - v = this.yerror[i]; - if (i == 0){ - min = v; - max = v; - } else { - if (v < min) - min = v; - else if (v > max) - max = v; - } - } - this.getExtent().minY -= max; - this.getExtent().maxY += max; - } - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/GLChartPanel.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/GLChartPanel.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/GLChartPanel.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/GLChartPanel.java index 46276ab1..bbf7f4cc 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/GLChartPanel.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/GLChartPanel.java @@ -8,7 +8,17 @@ package org.meteoinfo.chart.jogl; import com.jogamp.opengl.*; import com.jogamp.opengl.awt.GLJPanel; import com.jogamp.opengl.util.FPSAnimator; +import org.meteoinfo.chart.IChartPanel; +import org.meteoinfo.chart.MouseMode; +import org.meteoinfo.common.Extent3D; +import org.meteoinfo.image.ImageUtil; +import org.w3c.dom.Element; +import javax.imageio.*; +import javax.imageio.metadata.IIOMetadata; +import javax.imageio.plugins.jpeg.JPEGImageWriteParam; +import javax.imageio.stream.ImageOutputStream; +import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.awt.image.BufferedImage; @@ -17,17 +27,6 @@ import java.io.IOException; import java.util.Iterator; import java.util.logging.Level; import java.util.logging.Logger; -import javax.imageio.*; -import javax.imageio.metadata.IIOMetadata; -import javax.imageio.plugins.jpeg.JPEGImageWriteParam; -import javax.imageio.stream.ImageOutputStream; -import javax.swing.*; - -import org.meteoinfo.chart.IChartPanel; -import org.meteoinfo.chart.MouseMode; -import org.meteoinfo.common.Extent3D; -import org.meteoinfo.image.ImageUtil; -import org.w3c.dom.Element; /** * diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/GLForm.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/GLForm.java similarity index 93% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/GLForm.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/GLForm.java index 0c86ca4f..04e310d2 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/GLForm.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/GLForm.java @@ -1,42 +1,43 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.jogl; - -import com.jogamp.opengl.GLCapabilities; -import com.jogamp.opengl.GLProfile; -import javax.swing.JFrame; - -/** - * - * @author yaqiang - */ -public class GLForm extends JFrame{ - private Plot3DGL plt; - private GLChartPanel glcp; - - public GLForm(Plot3DGL plt) { - this.plt = plt; - final GLProfile gp = GLProfile.get(GLProfile.GL2); - GLCapabilities cap = new GLCapabilities(gp); - - glcp = new GLChartPanel(cap, plt); - glcp.setSize(400, 400); - - this.getContentPane().add(glcp); - - addWindowListener(new java.awt.event.WindowAdapter() { - public void windowClosing(java.awt.event.WindowEvent evt) { - formWindowClosing(); - } - }); - - glcp.animator_start(); - } - - private void formWindowClosing() { - glcp.animator_stop(); - } -} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.meteoinfo.chart.jogl; + +import com.jogamp.opengl.GLCapabilities; +import com.jogamp.opengl.GLProfile; + +import javax.swing.*; + +/** + * + * @author yaqiang + */ +public class GLForm extends JFrame{ + private Plot3DGL plt; + private GLChartPanel glcp; + + public GLForm(Plot3DGL plt) { + this.plt = plt; + final GLProfile gp = GLProfile.get(GLProfile.GL2); + GLCapabilities cap = new GLCapabilities(gp); + + glcp = new GLChartPanel(cap, plt); + glcp.setSize(400, 400); + + this.getContentPane().add(glcp); + + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + formWindowClosing(); + } + }); + + glcp.animator_start(); + } + + private void formWindowClosing() { + glcp.animator_stop(); + } +} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/IsosurfaceGraphics.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/IsosurfaceGraphics.java similarity index 96% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/IsosurfaceGraphics.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/IsosurfaceGraphics.java index 9136e4c6..667914e5 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/IsosurfaceGraphics.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/IsosurfaceGraphics.java @@ -5,13 +5,14 @@ */ package org.meteoinfo.chart.jogl; -import java.util.ArrayList; -import java.util.List; import org.meteoinfo.chart.plot3d.GraphicCollection3D; import org.meteoinfo.common.Extent3D; import org.meteoinfo.common.MIMath; -import org.meteoinfo.geoprocess.GeometryUtil; import org.meteoinfo.geometry.shape.PointZ; +import org.meteoinfo.geometry.geoprocess.GeometryUtil; + +import java.util.ArrayList; +import java.util.List; /** * diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/JOGLUtil.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/JOGLUtil.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/JOGLUtil.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/JOGLUtil.java index 07464e06..c98784e0 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/JOGLUtil.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/JOGLUtil.java @@ -6,30 +6,29 @@ package org.meteoinfo.chart.jogl; import com.jogamp.opengl.GL2; +import org.meteoinfo.chart.jogl.mc.CallbackMC; +import org.meteoinfo.chart.jogl.mc.MarchingCubes; +import org.meteoinfo.chart.plot3d.GraphicCollection3D; +import org.meteoinfo.common.Extent; +import org.meteoinfo.common.Extent3D; +import org.meteoinfo.geo.layer.ImageLayer; +import org.meteoinfo.geometry.graphic.Graphic; +import org.meteoinfo.geometry.graphic.GraphicCollection; +import org.meteoinfo.geometry.legend.ColorBreak; +import org.meteoinfo.geometry.legend.LegendScheme; +import org.meteoinfo.geometry.legend.PolygonBreak; +import org.meteoinfo.geometry.shape.ImageShape; +import org.meteoinfo.geometry.shape.PointZ; +import org.meteoinfo.ndarray.Array; +import org.meteoinfo.ndarray.Index; +import org.meteoinfo.ndarray.InvalidRangeException; +import org.meteoinfo.ndarray.math.ArrayUtil; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Random; -import org.meteoinfo.chart.jogl.mc.MarchingCubes; -import org.meteoinfo.chart.jogl.mc.CallbackMC; -import org.meteoinfo.chart.plot3d.GraphicCollection3D; -import org.meteoinfo.common.Extent; -import org.meteoinfo.common.Extent3D; -import org.meteoinfo.geometry.legend.ColorBreak; -import org.meteoinfo.geometry.legend.LegendScheme; -import org.meteoinfo.geometry.legend.PolygonBreak; -import org.meteoinfo.layer.ImageLayer; -import org.meteoinfo.ndarray.math.ArrayUtil; -import org.meteoinfo.ndarray.Array; -import org.meteoinfo.ndarray.Index; -import org.meteoinfo.ndarray.InvalidRangeException; -import org.meteoinfo.geometry.graphic.Graphic; -import org.meteoinfo.geometry.graphic.GraphicCollection; -import org.meteoinfo.geometry.shape.ImageShape; -import org.meteoinfo.geometry.shape.PointZ; - /** * * @author yaqiang @@ -157,7 +156,7 @@ public class JOGLUtil { * for map in 180 - 360 degree east * @param interpolation Interpolation * @return Graphics - * @throws java.io.IOException + * @throws IOException */ public static GraphicCollection createTexture(GL2 gl, ImageLayer layer, double offset, double xshift, String interpolation) throws IOException { diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/Lighting.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/Lighting.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/Lighting.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/Lighting.java index d952b93b..7ed467f4 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/Lighting.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/Lighting.java @@ -6,9 +6,8 @@ package org.meteoinfo.chart.jogl; import com.jogamp.opengl.GL2; -import com.jogamp.opengl.fixedfunc.GLLightingFunc; -import java.awt.Color; +import java.awt.*; import java.util.List; /** diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/ParticleGraphics.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/ParticleGraphics.java similarity index 100% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/ParticleGraphics.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/ParticleGraphics.java diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/Plot3DGL.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/Plot3DGL.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/Plot3DGL.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/Plot3DGL.java index f99de3da..d3fece94 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/Plot3DGL.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/Plot3DGL.java @@ -9,15 +9,33 @@ import com.jogamp.opengl.*; import com.jogamp.opengl.glu.GLU; import com.jogamp.opengl.glu.GLUquadric; import com.jogamp.opengl.glu.GLUtessellator; +import com.jogamp.opengl.math.VectorUtil; import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil; import com.jogamp.opengl.util.awt.TextRenderer; +import com.jogamp.opengl.util.gl2.GLUT; import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.awt.AWTTextureIO; -import com.jogamp.opengl.util.gl2.GLUT; -import com.jogamp.opengl.math.VectorUtil; -import java.awt.Color; -import java.awt.Font; -import java.awt.Graphics2D; +import org.meteoinfo.chart.*; +import org.meteoinfo.chart.axis.Axis; +import org.meteoinfo.chart.jogl.tessellator.Primitive; +import org.meteoinfo.chart.jogl.tessellator.TessPolygon; +import org.meteoinfo.chart.plot.GridLine; +import org.meteoinfo.chart.plot.Plot; +import org.meteoinfo.chart.plot.PlotType; +import org.meteoinfo.chart.plot3d.GraphicCollection3D; +import org.meteoinfo.common.*; +import org.meteoinfo.data.Dataset; +import org.meteoinfo.geometry.graphic.Graphic; +import org.meteoinfo.geometry.graphic.GraphicCollection; +import org.meteoinfo.geometry.legend.*; +import org.meteoinfo.geometry.shape.Shape; +import org.meteoinfo.geometry.shape.*; +import org.meteoinfo.geometry.geoprocess.GeometryUtil; +import org.meteoinfo.math.meteo.MeteoMath; + +import javax.imageio.ImageIO; +import javax.swing.*; +import java.awt.*; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.File; @@ -27,27 +45,6 @@ import java.util.List; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; -import javax.imageio.ImageIO; -import javax.swing.JFrame; - -import org.meteoinfo.chart.ChartColorBar; -import org.meteoinfo.chart.ChartLegend; -import org.meteoinfo.chart.ChartText; -import org.meteoinfo.chart.ChartText3D; -import org.meteoinfo.chart.Margin; -import org.meteoinfo.chart.axis.Axis; -import org.meteoinfo.chart.jogl.tessellator.Primitive; -import org.meteoinfo.chart.jogl.tessellator.TessPolygon; -import org.meteoinfo.chart.plot.*; -import org.meteoinfo.chart.plot3d.GraphicCollection3D; -import org.meteoinfo.common.*; -import org.meteoinfo.data.Dataset; -import org.meteoinfo.geometry.graphic.GraphicCollection; -import org.meteoinfo.geometry.legend.*; -import org.meteoinfo.geoprocess.GeometryUtil; -import org.meteoinfo.math.meteo.MeteoMath; -import org.meteoinfo.geometry.shape.*; -import org.meteoinfo.geometry.graphic.Graphic; /** * @@ -878,8 +875,8 @@ public class Plot3DGL extends Plot implements GLEventListener { if (this.sampleBuffers) gl.glEnable(GL2.GL_MULTISAMPLE); else { - gl.glEnable(GL.GL_LINE_SMOOTH); - gl.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST); + gl.glEnable(GL2.GL_LINE_SMOOTH); + gl.glHint(GL2.GL_LINE_SMOOTH_HINT, GL2.GL_NICEST); gl.glEnable(GL2.GL_POINT_SMOOTH); gl.glHint(GL2.GL_POINT_SMOOTH_HINT, GL2.GL_NICEST); //gl.glEnable(GL2.GL_POLYGON_SMOOTH); diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/SurfaceGraphics.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/SurfaceGraphics.java similarity index 100% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/SurfaceGraphics.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/SurfaceGraphics.java diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/TextureShape.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/TextureShape.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/TextureShape.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/TextureShape.java index b2d8342b..d696163e 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/TextureShape.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/TextureShape.java @@ -7,11 +7,12 @@ package org.meteoinfo.chart.jogl; import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureIO; -import java.io.File; -import java.io.IOException; import org.meteoinfo.geometry.shape.ImageShape; import org.meteoinfo.geometry.shape.ShapeTypes; +import java.io.File; +import java.io.IOException; + /** * * @author yaqiang diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/Transform.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/Transform.java similarity index 100% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/Transform.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/Transform.java diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/Triangle.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/Triangle.java similarity index 100% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/Triangle.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/Triangle.java diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/mc/BenchmarkHandler.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/mc/BenchmarkHandler.java similarity index 97% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/mc/BenchmarkHandler.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/mc/BenchmarkHandler.java index cd9bc85e..47430ec1 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/mc/BenchmarkHandler.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/mc/BenchmarkHandler.java @@ -1,799 +1,799 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.jogl.mc; - -import java.io.*; -import java.util.ArrayList; - -/** - * Created by Primoz on 11. 07. 2016. - */ -public class BenchmarkHandler { - - public static void benchmarkChar(File inputFile, File outFile, final int[] size, final float voxSize[], final char isoValue, int nThreadsMin, int nThreadsMax, int iterations) { - char[] scalarField; - - if (inputFile != null) { - System.out.println("PROGRESS: Reading input data."); - try { - int idx = 0; - scalarField = new char[size[0] * size[1] * size[2]]; - - DataInputStream in = new DataInputStream(new FileInputStream(inputFile)); - while (in.available() > 0) { - // Size does not match - if (idx >= scalarField.length) { - in.close(); - System.out.println("Invalid volume size was specified."); - return; - } - - scalarField[idx++] = (char) in.readByte(); - } - - in.close(); - - // Size does not match - if (idx != scalarField.length) { - System.out.println("Invalid volume size was specified."); - return; - } - } - catch (Exception e) { - System.out.println("Something went wrong while reading the volume"); - return; - } - } - else { - System.out.println("PROGRESS: Generating volume data."); - scalarField = VolumeGenerator.generateScalarFieldChar(size); - } - - final char[] finalScalarField = scalarField; - - System.out.println("PROGRESS: Performing benchmark."); - StringBuilder benchmarkResults = new StringBuilder(); - - for (int nThreads = nThreadsMin; nThreads <= nThreadsMax; nThreads++) { - - final ArrayList times = new ArrayList<>(); - - for (int it = 0; it < iterations; it++) { - - // TIMER - final long start = System.currentTimeMillis(); - - ArrayList threads = new ArrayList<>(); - final ArrayList> results = new ArrayList<>(); - - - // Thread work distribution - int remainder = size[2] % nThreads; - int segment = size[2] / nThreads; - - // Z axis offset for vertice position calculation - int zAxisOffset = 0; - - - for (int i = 0; i < nThreads; i++) { - // Distribute remainder among first (remainder) threads - int segmentSize = (remainder-- > 0) ? segment + 1 : segment; - - // Padding needs to be added to correctly close the gaps between segments - final int paddedSegmentSize = (i != nThreads - 1) ? segmentSize + 1 : segmentSize; - - - // Finished callback - final CallbackMC callback = new CallbackMC() { - @Override - public void run() { - results.add(getVertices()); - } - }; - - // Java... - final int finalZAxisOffset = zAxisOffset; - - // Start the thread - Thread t = new Thread() { - public void run() { - MarchingCubes.marchingCubesChar(finalScalarField, new int[]{size[0], size[1], paddedSegmentSize}, size[2], voxSize, isoValue, finalZAxisOffset, callback); - } - }; - - threads.add(t); - t.start(); - - // Correct offsets for next iteration - zAxisOffset += segmentSize; - } - - // Join the threads - for (int i = 0; i 0) { - // Size does not match - if (idx >= scalarField.length) { - in.close(); - System.out.println("Invalid volume size was specified."); - return; - } - - scalarField[idx++] = in.readShort(); - } - - in.close(); - - // Size does not match - if (idx != scalarField.length) { - System.out.println("Invalid volume size was specified."); - return; - } - } - catch (Exception e) { - System.out.println("Something went wrong while reading the volume"); - return; - } - } - else { - System.out.println("PROGRESS: Generating volume data."); - scalarField = VolumeGenerator.generateScalarFieldShort(size); - } - - final short[] finalScalarField = scalarField; - - System.out.println("PROGRESS: Performing benchmark."); - StringBuilder benchmarkResults = new StringBuilder(); - - for (int nThreads = nThreadsMin; nThreads <= nThreadsMax; nThreads++) { - - final ArrayList times = new ArrayList<>(); - - for (int it = 0; it < iterations; it++) { - - // TIMER - final long start = System.currentTimeMillis(); - - ArrayList threads = new ArrayList<>(); - final ArrayList> results = new ArrayList<>(); - - - // Thread work distribution - int remainder = size[2] % nThreads; - int segment = size[2] / nThreads; - - // Z axis offset for vertice position calculation - int zAxisOffset = 0; - - - for (int i = 0; i < nThreads; i++) { - // Distribute remainder among first (remainder) threads - int segmentSize = (remainder-- > 0) ? segment + 1 : segment; - - // Padding needs to be added to correctly close the gaps between segments - final int paddedSegmentSize = (i != nThreads - 1) ? segmentSize + 1 : segmentSize; - - - // Finished callback - final CallbackMC callback = new CallbackMC() { - @Override - public void run() { - results.add(getVertices()); - } - }; - - // Java... - final int finalZAxisOffset = zAxisOffset; - - // Start the thread - Thread t = new Thread() { - public void run() { - MarchingCubes.marchingCubesShort(finalScalarField, new int[]{size[0], size[1], paddedSegmentSize}, size[2], voxSize, isoValue, finalZAxisOffset, callback); - } - }; - - threads.add(t); - t.start(); - - // Correct offsets for next iteration - zAxisOffset += segmentSize; - } - - // Join the threads - for (int i = 0; i 0) { - // Size does not match - if (idx >= scalarField.length) { - in.close(); - System.out.println("Invalid volume size was specified."); - return; - } - - scalarField[idx++] = in.readInt(); - } - - in.close(); - - // Size does not match - if (idx != scalarField.length) { - System.out.println("Invalid volume size was specified."); - return; - } - } - catch (Exception e) { - System.out.println("Something went wrong while reading the volume"); - return; - } - } - else { - System.out.println("PROGRESS: Generating volume data."); - scalarField = VolumeGenerator.generateScalarFieldInt(size); - } - - final int[] finalScalarField = scalarField; - - System.out.println("PROGRESS: Performing benchmark."); - StringBuilder benchmarkResults = new StringBuilder(); - - for (int nThreads = nThreadsMin; nThreads <= nThreadsMax; nThreads++) { - - final ArrayList times = new ArrayList<>(); - - for (int it = 0; it < iterations; it++) { - - // TIMER - final long start = System.currentTimeMillis(); - - ArrayList threads = new ArrayList<>(); - final ArrayList> results = new ArrayList<>(); - - - // Thread work distribution - int remainder = size[2] % nThreads; - int segment = size[2] / nThreads; - - // Z axis offset for vertice position calculation - int zAxisOffset = 0; - - - for (int i = 0; i < nThreads; i++) { - // Distribute remainder among first (remainder) threads - int segmentSize = (remainder-- > 0) ? segment + 1 : segment; - - // Padding needs to be added to correctly close the gaps between segments - final int paddedSegmentSize = (i != nThreads - 1) ? segmentSize + 1 : segmentSize; - - - // Finished callback - final CallbackMC callback = new CallbackMC() { - @Override - public void run() { - results.add(getVertices()); - } - }; - - // Java... - final int finalZAxisOffset = zAxisOffset; - - // Start the thread - Thread t = new Thread() { - public void run() { - MarchingCubes.marchingCubesInt(finalScalarField, new int[]{size[0], size[1], paddedSegmentSize}, size[2], voxSize, isoValue, finalZAxisOffset, callback); - } - }; - - threads.add(t); - t.start(); - - // Correct offsets for next iteration - zAxisOffset += segmentSize; - } - - // Join the threads - for (int i = 0; i 0) { - // Size does not match - if (idx >= scalarField.length) { - in.close(); - System.out.println("Invalid volume size was specified."); - return; - } - - scalarField[idx++] = in.readFloat(); - } - - in.close(); - - // Size does not match - if (idx != scalarField.length) { - System.out.println("Invalid volume size was specified."); - return; - } - } - catch (Exception e) { - System.out.println("Something went wrong while reading the volume"); - return; - } - } - else { - System.out.println("PROGRESS: Generating volume data."); - scalarField = VolumeGenerator.generateScalarFieldFloat(size); - } - - final float[] finalScalarField = scalarField; - - System.out.println("PROGRESS: Performing benchmark."); - StringBuilder benchmarkResults = new StringBuilder(); - - for (int nThreads = nThreadsMin; nThreads <= nThreadsMax; nThreads++) { - - final ArrayList times = new ArrayList<>(); - - for (int it = 0; it < iterations; it++) { - - // TIMER - final long start = System.currentTimeMillis(); - - ArrayList threads = new ArrayList<>(); - final ArrayList> results = new ArrayList<>(); - - - // Thread work distribution - int remainder = size[2] % nThreads; - int segment = size[2] / nThreads; - - // Z axis offset for vertice position calculation - int zAxisOffset = 0; - - - for (int i = 0; i < nThreads; i++) { - // Distribute remainder among first (remainder) threads - int segmentSize = (remainder-- > 0) ? segment + 1 : segment; - - // Padding needs to be added to correctly close the gaps between segments - final int paddedSegmentSize = (i != nThreads - 1) ? segmentSize + 1 : segmentSize; - - - // Finished callback - final CallbackMC callback = new CallbackMC() { - @Override - public void run() { - results.add(getVertices()); - } - }; - - // Java... - final int finalZAxisOffset = zAxisOffset; - - // Start the thread - Thread t = new Thread() { - public void run() { - MarchingCubes.marchingCubesFloat(finalScalarField, new int[]{size[0], size[1], paddedSegmentSize}, size[2], voxSize, isoValue, finalZAxisOffset, callback); - } - }; - - threads.add(t); - t.start(); - - // Correct offsets for next iteration - zAxisOffset += segmentSize; - } - - // Join the threads - for (int i = 0; i 0) { - // Size does not match - if (idx >= scalarField.length) { - in.close(); - System.out.println("Invalid volume size was specified."); - return; - } - - scalarField[idx++] = in.readDouble(); - } - - in.close(); - - // Size does not match - if (idx != scalarField.length) { - System.out.println("Invalid volume size was specified."); - return; - } - } - catch (Exception e) { - System.out.println("Something went wrong while reading the volume"); - return; - } - } - else { - System.out.println("PROGRESS: Generating volume data."); - scalarField = VolumeGenerator.generateScalarFieldDouble(size); - } - - final double[] finalScalarField = scalarField; - - System.out.println("PROGRESS: Performing benchmark."); - StringBuilder benchmarkResults = new StringBuilder(); - - for (int nThreads = nThreadsMin; nThreads <= nThreadsMax; nThreads++) { - - final ArrayList times = new ArrayList<>(); - - for (int it = 0; it < iterations; it++) { - - // TIMER - final long start = System.currentTimeMillis(); - - ArrayList threads = new ArrayList<>(); - final ArrayList> results = new ArrayList<>(); - - - // Thread work distribution - int remainder = size[2] % nThreads; - int segment = size[2] / nThreads; - - // Z axis offset for vertice position calculation - int zAxisOffset = 0; - - - for (int i = 0; i < nThreads; i++) { - // Distribute remainder among first (remainder) threads - int segmentSize = (remainder-- > 0) ? segment + 1 : segment; - - // Padding needs to be added to correctly close the gaps between segments - final int paddedSegmentSize = (i != nThreads - 1) ? segmentSize + 1 : segmentSize; - - - // Finished callback - final CallbackMC callback = new CallbackMC() { - @Override - public void run() { - results.add(getVertices()); - } - }; - - // Java... - final int finalZAxisOffset = zAxisOffset; - - // Start the thread - Thread t = new Thread() { - public void run() { - MarchingCubes.marchingCubesDouble(finalScalarField, new int[]{size[0], size[1], paddedSegmentSize}, size[2], voxSize, isoValue, finalZAxisOffset, callback); - } - }; - - threads.add(t); - t.start(); - - // Correct offsets for next iteration - zAxisOffset += segmentSize; - } - - // Join the threads - for (int i = 0; i 0) { + // Size does not match + if (idx >= scalarField.length) { + in.close(); + System.out.println("Invalid volume size was specified."); + return; + } + + scalarField[idx++] = (char) in.readByte(); + } + + in.close(); + + // Size does not match + if (idx != scalarField.length) { + System.out.println("Invalid volume size was specified."); + return; + } + } + catch (Exception e) { + System.out.println("Something went wrong while reading the volume"); + return; + } + } + else { + System.out.println("PROGRESS: Generating volume data."); + scalarField = VolumeGenerator.generateScalarFieldChar(size); + } + + final char[] finalScalarField = scalarField; + + System.out.println("PROGRESS: Performing benchmark."); + StringBuilder benchmarkResults = new StringBuilder(); + + for (int nThreads = nThreadsMin; nThreads <= nThreadsMax; nThreads++) { + + final ArrayList times = new ArrayList<>(); + + for (int it = 0; it < iterations; it++) { + + // TIMER + final long start = System.currentTimeMillis(); + + ArrayList threads = new ArrayList<>(); + final ArrayList> results = new ArrayList<>(); + + + // Thread work distribution + int remainder = size[2] % nThreads; + int segment = size[2] / nThreads; + + // Z axis offset for vertice position calculation + int zAxisOffset = 0; + + + for (int i = 0; i < nThreads; i++) { + // Distribute remainder among first (remainder) threads + int segmentSize = (remainder-- > 0) ? segment + 1 : segment; + + // Padding needs to be added to correctly close the gaps between segments + final int paddedSegmentSize = (i != nThreads - 1) ? segmentSize + 1 : segmentSize; + + + // Finished callback + final CallbackMC callback = new CallbackMC() { + @Override + public void run() { + results.add(getVertices()); + } + }; + + // Java... + final int finalZAxisOffset = zAxisOffset; + + // Start the thread + Thread t = new Thread() { + public void run() { + MarchingCubes.marchingCubesChar(finalScalarField, new int[]{size[0], size[1], paddedSegmentSize}, size[2], voxSize, isoValue, finalZAxisOffset, callback); + } + }; + + threads.add(t); + t.start(); + + // Correct offsets for next iteration + zAxisOffset += segmentSize; + } + + // Join the threads + for (int i = 0; i 0) { + // Size does not match + if (idx >= scalarField.length) { + in.close(); + System.out.println("Invalid volume size was specified."); + return; + } + + scalarField[idx++] = in.readShort(); + } + + in.close(); + + // Size does not match + if (idx != scalarField.length) { + System.out.println("Invalid volume size was specified."); + return; + } + } + catch (Exception e) { + System.out.println("Something went wrong while reading the volume"); + return; + } + } + else { + System.out.println("PROGRESS: Generating volume data."); + scalarField = VolumeGenerator.generateScalarFieldShort(size); + } + + final short[] finalScalarField = scalarField; + + System.out.println("PROGRESS: Performing benchmark."); + StringBuilder benchmarkResults = new StringBuilder(); + + for (int nThreads = nThreadsMin; nThreads <= nThreadsMax; nThreads++) { + + final ArrayList times = new ArrayList<>(); + + for (int it = 0; it < iterations; it++) { + + // TIMER + final long start = System.currentTimeMillis(); + + ArrayList threads = new ArrayList<>(); + final ArrayList> results = new ArrayList<>(); + + + // Thread work distribution + int remainder = size[2] % nThreads; + int segment = size[2] / nThreads; + + // Z axis offset for vertice position calculation + int zAxisOffset = 0; + + + for (int i = 0; i < nThreads; i++) { + // Distribute remainder among first (remainder) threads + int segmentSize = (remainder-- > 0) ? segment + 1 : segment; + + // Padding needs to be added to correctly close the gaps between segments + final int paddedSegmentSize = (i != nThreads - 1) ? segmentSize + 1 : segmentSize; + + + // Finished callback + final CallbackMC callback = new CallbackMC() { + @Override + public void run() { + results.add(getVertices()); + } + }; + + // Java... + final int finalZAxisOffset = zAxisOffset; + + // Start the thread + Thread t = new Thread() { + public void run() { + MarchingCubes.marchingCubesShort(finalScalarField, new int[]{size[0], size[1], paddedSegmentSize}, size[2], voxSize, isoValue, finalZAxisOffset, callback); + } + }; + + threads.add(t); + t.start(); + + // Correct offsets for next iteration + zAxisOffset += segmentSize; + } + + // Join the threads + for (int i = 0; i 0) { + // Size does not match + if (idx >= scalarField.length) { + in.close(); + System.out.println("Invalid volume size was specified."); + return; + } + + scalarField[idx++] = in.readInt(); + } + + in.close(); + + // Size does not match + if (idx != scalarField.length) { + System.out.println("Invalid volume size was specified."); + return; + } + } + catch (Exception e) { + System.out.println("Something went wrong while reading the volume"); + return; + } + } + else { + System.out.println("PROGRESS: Generating volume data."); + scalarField = VolumeGenerator.generateScalarFieldInt(size); + } + + final int[] finalScalarField = scalarField; + + System.out.println("PROGRESS: Performing benchmark."); + StringBuilder benchmarkResults = new StringBuilder(); + + for (int nThreads = nThreadsMin; nThreads <= nThreadsMax; nThreads++) { + + final ArrayList times = new ArrayList<>(); + + for (int it = 0; it < iterations; it++) { + + // TIMER + final long start = System.currentTimeMillis(); + + ArrayList threads = new ArrayList<>(); + final ArrayList> results = new ArrayList<>(); + + + // Thread work distribution + int remainder = size[2] % nThreads; + int segment = size[2] / nThreads; + + // Z axis offset for vertice position calculation + int zAxisOffset = 0; + + + for (int i = 0; i < nThreads; i++) { + // Distribute remainder among first (remainder) threads + int segmentSize = (remainder-- > 0) ? segment + 1 : segment; + + // Padding needs to be added to correctly close the gaps between segments + final int paddedSegmentSize = (i != nThreads - 1) ? segmentSize + 1 : segmentSize; + + + // Finished callback + final CallbackMC callback = new CallbackMC() { + @Override + public void run() { + results.add(getVertices()); + } + }; + + // Java... + final int finalZAxisOffset = zAxisOffset; + + // Start the thread + Thread t = new Thread() { + public void run() { + MarchingCubes.marchingCubesInt(finalScalarField, new int[]{size[0], size[1], paddedSegmentSize}, size[2], voxSize, isoValue, finalZAxisOffset, callback); + } + }; + + threads.add(t); + t.start(); + + // Correct offsets for next iteration + zAxisOffset += segmentSize; + } + + // Join the threads + for (int i = 0; i 0) { + // Size does not match + if (idx >= scalarField.length) { + in.close(); + System.out.println("Invalid volume size was specified."); + return; + } + + scalarField[idx++] = in.readFloat(); + } + + in.close(); + + // Size does not match + if (idx != scalarField.length) { + System.out.println("Invalid volume size was specified."); + return; + } + } + catch (Exception e) { + System.out.println("Something went wrong while reading the volume"); + return; + } + } + else { + System.out.println("PROGRESS: Generating volume data."); + scalarField = VolumeGenerator.generateScalarFieldFloat(size); + } + + final float[] finalScalarField = scalarField; + + System.out.println("PROGRESS: Performing benchmark."); + StringBuilder benchmarkResults = new StringBuilder(); + + for (int nThreads = nThreadsMin; nThreads <= nThreadsMax; nThreads++) { + + final ArrayList times = new ArrayList<>(); + + for (int it = 0; it < iterations; it++) { + + // TIMER + final long start = System.currentTimeMillis(); + + ArrayList threads = new ArrayList<>(); + final ArrayList> results = new ArrayList<>(); + + + // Thread work distribution + int remainder = size[2] % nThreads; + int segment = size[2] / nThreads; + + // Z axis offset for vertice position calculation + int zAxisOffset = 0; + + + for (int i = 0; i < nThreads; i++) { + // Distribute remainder among first (remainder) threads + int segmentSize = (remainder-- > 0) ? segment + 1 : segment; + + // Padding needs to be added to correctly close the gaps between segments + final int paddedSegmentSize = (i != nThreads - 1) ? segmentSize + 1 : segmentSize; + + + // Finished callback + final CallbackMC callback = new CallbackMC() { + @Override + public void run() { + results.add(getVertices()); + } + }; + + // Java... + final int finalZAxisOffset = zAxisOffset; + + // Start the thread + Thread t = new Thread() { + public void run() { + MarchingCubes.marchingCubesFloat(finalScalarField, new int[]{size[0], size[1], paddedSegmentSize}, size[2], voxSize, isoValue, finalZAxisOffset, callback); + } + }; + + threads.add(t); + t.start(); + + // Correct offsets for next iteration + zAxisOffset += segmentSize; + } + + // Join the threads + for (int i = 0; i 0) { + // Size does not match + if (idx >= scalarField.length) { + in.close(); + System.out.println("Invalid volume size was specified."); + return; + } + + scalarField[idx++] = in.readDouble(); + } + + in.close(); + + // Size does not match + if (idx != scalarField.length) { + System.out.println("Invalid volume size was specified."); + return; + } + } + catch (Exception e) { + System.out.println("Something went wrong while reading the volume"); + return; + } + } + else { + System.out.println("PROGRESS: Generating volume data."); + scalarField = VolumeGenerator.generateScalarFieldDouble(size); + } + + final double[] finalScalarField = scalarField; + + System.out.println("PROGRESS: Performing benchmark."); + StringBuilder benchmarkResults = new StringBuilder(); + + for (int nThreads = nThreadsMin; nThreads <= nThreadsMax; nThreads++) { + + final ArrayList times = new ArrayList<>(); + + for (int it = 0; it < iterations; it++) { + + // TIMER + final long start = System.currentTimeMillis(); + + ArrayList threads = new ArrayList<>(); + final ArrayList> results = new ArrayList<>(); + + + // Thread work distribution + int remainder = size[2] % nThreads; + int segment = size[2] / nThreads; + + // Z axis offset for vertice position calculation + int zAxisOffset = 0; + + + for (int i = 0; i < nThreads; i++) { + // Distribute remainder among first (remainder) threads + int segmentSize = (remainder-- > 0) ? segment + 1 : segment; + + // Padding needs to be added to correctly close the gaps between segments + final int paddedSegmentSize = (i != nThreads - 1) ? segmentSize + 1 : segmentSize; + + + // Finished callback + final CallbackMC callback = new CallbackMC() { + @Override + public void run() { + results.add(getVertices()); + } + }; + + // Java... + final int finalZAxisOffset = zAxisOffset; + + // Start the thread + Thread t = new Thread() { + public void run() { + MarchingCubes.marchingCubesDouble(finalScalarField, new int[]{size[0], size[1], paddedSegmentSize}, size[2], voxSize, isoValue, finalZAxisOffset, callback); + } + }; + + threads.add(t); + t.start(); + + // Correct offsets for next iteration + zAxisOffset += segmentSize; + } + + // Join the threads + for (int i = 0; i vertices; - - void setVertices(ArrayList vertices) { - this.vertices = vertices; - } - - public ArrayList getVertices() { - return this.vertices; - } -} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.meteoinfo.chart.jogl.mc; + +import java.util.ArrayList; + +/** + * Created by Primoz on 8.7.2016. + */ +public abstract class CallbackMC implements Runnable { + private ArrayList vertices; + + void setVertices(ArrayList vertices) { + this.vertices = vertices; + } + + public ArrayList getVertices() { + return this.vertices; + } +} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/mc/ExtractHandler.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/mc/ExtractHandler.java similarity index 97% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/mc/ExtractHandler.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/mc/ExtractHandler.java index 48c28a5d..afabc5ae 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/mc/ExtractHandler.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/mc/ExtractHandler.java @@ -1,537 +1,537 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.jogl.mc; - -import java.io.*; -import java.util.ArrayList; - -/** - * Created by Primoz on 11. 07. 2016. - */ -public class ExtractHandler { - public static void extractHandlerChar(File inputFile, File outFile, final int[] size, final float voxSize[], final char isoValue, int nThreads) { - char[] scalarField; - - if (inputFile != null) { - System.out.println("PROGRESS: Reading input data."); - try { - int idx = 0; - scalarField = new char[size[0] * size[1] * size[2]]; - - DataInputStream in = new DataInputStream(new FileInputStream(inputFile)); - while (in.available() > 0) { - // Size does not match - if (idx >= scalarField.length) { - in.close(); - System.out.println("Invalid volume size was specified."); - return; - } - - scalarField[idx++] = (char) in.readByte(); - } - - in.close(); - - // Size does not match - if (idx != scalarField.length) { - System.out.println("Invalid volume size was specified."); - return; - } - } - catch (Exception e) { - System.out.println("Something went wrong while reading the volume"); - return; - } - } - else { - System.out.println("PROGRESS: Generating volume data."); - scalarField = VolumeGenerator.generateScalarFieldChar(size); - } - - final char[] finalScalarField = scalarField; - - ArrayList threads = new ArrayList<>(); - final ArrayList> results = new ArrayList<>(); - - // Thread work distribution - int remainder = size[2] % nThreads; - int segment = size[2] / nThreads; - - // Z axis offset for vertice position calculation - int zAxisOffset = 0; - - System.out.println("PROGRESS: Executing marching cubes."); - - for (int i = 0; i < nThreads; i++) { - // Distribute remainder among first (remainder) threads - int segmentSize = (remainder-- > 0) ? segment + 1 : segment; - - // Padding needs to be added to correctly close the gaps between segments - final int paddedSegmentSize = (i != nThreads - 1) ? segmentSize + 1 : segmentSize; - - - // Finished callback - final CallbackMC callback = new CallbackMC() { - @Override - public void run() { - results.add(getVertices()); - } - }; - - // Java... - final int finalZAxisOffset = zAxisOffset; - - // Start the thread - Thread t = new Thread() { - public void run() { - MarchingCubes.marchingCubesChar(finalScalarField, new int[]{size[0], size[1], paddedSegmentSize}, size[2], voxSize, isoValue, finalZAxisOffset, callback); - } - }; - - threads.add(t); - t.start(); - - // Correct offsets for next iteration - zAxisOffset += segmentSize; - } - - // Join the threads - for (int i = 0; i 0) { - // Size does not match - if (idx >= scalarField.length) { - in.close(); - System.out.println("Invalid volume size was specified."); - return; - } - - scalarField[idx++] = in.readShort(); - } - - in.close(); - - // Size does not match - if (idx != scalarField.length) { - System.out.println("Invalid volume size was specified."); - return; - } - } - catch (Exception e) { - System.out.println("Something went wrong while reading the volume"); - return; - } - } - else { - System.out.println("PROGRESS: Generating volume data."); - scalarField = VolumeGenerator.generateScalarFieldShort(size); - } - - final short[] finalScalarField = scalarField; - - ArrayList threads = new ArrayList<>(); - final ArrayList> results = new ArrayList<>(); - - // Thread work distribution - int remainder = size[2] % nThreads; - int segment = size[2] / nThreads; - - // Z axis offset for vertice position calculation - int zAxisOffset = 0; - - System.out.println("PROGRESS: Executing marching cubes."); - - for (int i = 0; i < nThreads; i++) { - // Distribute remainder among first (remainder) threads - int segmentSize = (remainder-- > 0) ? segment + 1 : segment; - - // Padding needs to be added to correctly close the gaps between segments - final int paddedSegmentSize = (i != nThreads - 1) ? segmentSize + 1 : segmentSize; - - - // Finished callback - final CallbackMC callback = new CallbackMC() { - @Override - public void run() { - results.add(getVertices()); - } - }; - - // Java... - final int finalZAxisOffset = zAxisOffset; - - // Start the thread - Thread t = new Thread() { - public void run() { - MarchingCubes.marchingCubesShort(finalScalarField, new int[]{size[0], size[1], paddedSegmentSize}, size[2], voxSize, isoValue, finalZAxisOffset, callback); - } - }; - - threads.add(t); - t.start(); - - // Correct offsets for next iteration - zAxisOffset += segmentSize; - } - - // Join the threads - for (int i = 0; i 0) { - // Size does not match - if (idx >= scalarField.length) { - in.close(); - System.out.println("Invalid volume size was specified."); - return; - } - - scalarField[idx++] = in.readInt(); - } - - in.close(); - - // Size does not match - if (idx != scalarField.length) { - System.out.println("Invalid volume size was specified."); - return; - } - } - catch (Exception e) { - System.out.println("Something went wrong while reading the volume"); - return; - } - } - else { - System.out.println("PROGRESS: Generating volume data."); - scalarField = VolumeGenerator.generateScalarFieldInt(size); - } - - final int[] finalScalarField = scalarField; - - ArrayList threads = new ArrayList<>(); - final ArrayList> results = new ArrayList<>(); - - // Thread work distribution - int remainder = size[2] % nThreads; - int segment = size[2] / nThreads; - - // Z axis offset for vertice position calculation - int zAxisOffset = 0; - - System.out.println("PROGRESS: Executing marching cubes."); - - for (int i = 0; i < nThreads; i++) { - // Distribute remainder among first (remainder) threads - int segmentSize = (remainder-- > 0) ? segment + 1 : segment; - - // Padding needs to be added to correctly close the gaps between segments - final int paddedSegmentSize = (i != nThreads - 1) ? segmentSize + 1 : segmentSize; - - - // Finished callback - final CallbackMC callback = new CallbackMC() { - @Override - public void run() { - results.add(getVertices()); - } - }; - - // Java... - final int finalZAxisOffset = zAxisOffset; - - // Start the thread - Thread t = new Thread() { - public void run() { - MarchingCubes.marchingCubesInt(finalScalarField, new int[]{size[0], size[1], paddedSegmentSize}, size[2], voxSize, isoValue, finalZAxisOffset, callback); - } - }; - - threads.add(t); - t.start(); - - // Correct offsets for next iteration - zAxisOffset += segmentSize; - } - - // Join the threads - for (int i = 0; i 0) { - // Size does not match - if (idx >= scalarField.length) { - in.close(); - System.out.println("Invalid volume size was specified."); - return; - } - - scalarField[idx++] = in.readFloat(); - } - - in.close(); - - // Size does not match - if (idx != scalarField.length) { - System.out.println("Invalid volume size was specified."); - return; - } - } - catch (Exception e) { - System.out.println("Something went wrong while reading the volume"); - return; - } - } - else { - System.out.println("PROGRESS: Generating volume data."); - scalarField = VolumeGenerator.generateScalarFieldFloat(size); - } - - final float[] finalScalarField = scalarField; - - // TIMER - ArrayList threads = new ArrayList<>(); - final ArrayList> results = new ArrayList<>(); - - // Thread work distribution - int remainder = size[2] % nThreads; - int segment = size[2] / nThreads; - - // Z axis offset for vertice position calculation - int zAxisOffset = 0; - - System.out.println("PROGRESS: Executing marching cubes."); - - for (int i = 0; i < nThreads; i++) { - // Distribute remainder among first (remainder) threads - int segmentSize = (remainder-- > 0) ? segment + 1 : segment; - - // Padding needs to be added to correctly close the gaps between segments - final int paddedSegmentSize = (i != nThreads - 1) ? segmentSize + 1 : segmentSize; - - - // Finished callback - final CallbackMC callback = new CallbackMC() { - @Override - public void run() { - results.add(getVertices()); - } - }; - - // Java... - final int finalZAxisOffset = zAxisOffset; - - // Start the thread - Thread t = new Thread() { - public void run() { - MarchingCubes.marchingCubesFloat(finalScalarField, new int[]{size[0], size[1], paddedSegmentSize}, size[2], voxSize, isoValue, finalZAxisOffset, callback); - } - }; - - threads.add(t); - t.start(); - - // Correct offsets for next iteration - zAxisOffset += segmentSize; - } - - // Join the threads - for (int i = 0; i 0) { - // Size does not match - if (idx >= scalarField.length) { - in.close(); - System.out.println("Invalid volume size was specified."); - return; - } - - scalarField[idx++] = in.readDouble(); - } - - in.close(); - - // Size does not match - if (idx != scalarField.length) { - System.out.println("Invalid volume size was specified."); - return; - } - } - catch (Exception e) { - System.out.println("Something went wrong while reading the volume"); - return; - } - } - else { - System.out.println("PROGRESS: Generating volume data."); - scalarField = VolumeGenerator.generateScalarFieldDouble(size); - } - - final double[] finalScalarField = scalarField; - - // TIMER - ArrayList threads = new ArrayList<>(); - final ArrayList> results = new ArrayList<>(); - - // Thread work distribution - int remainder = size[2] % nThreads; - int segment = size[2] / nThreads; - - // Z axis offset for vertice position calculation - int zAxisOffset = 0; - - System.out.println("PROGRESS: Executing marching cubes."); - for (int i = 0; i < nThreads; i++) { - // Distribute remainder among first (remainder) threads - int segmentSize = (remainder-- > 0) ? segment + 1 : segment; - - // Padding needs to be added to correctly close the gaps between segments - final int paddedSegmentSize = (i != nThreads - 1) ? segmentSize + 1 : segmentSize; - - - // Finished callback - final CallbackMC callback = new CallbackMC() { - @Override - public void run() { - results.add(getVertices()); - } - }; - - // Java... - final int finalZAxisOffset = zAxisOffset; - - // Start the thread - Thread t = new Thread() { - public void run() { - MarchingCubes.marchingCubesDouble(finalScalarField, new int[]{size[0], size[1], paddedSegmentSize}, size[2], voxSize, isoValue, finalZAxisOffset, callback); - } - }; - - threads.add(t); - t.start(); - - // Correct offsets for next iteration - zAxisOffset += segmentSize; - } - - // Join the threads - for (int i = 0; i > results, File outFile) { - try { - BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(outFile)); - - int idx = 0; - for (int i = 0; i < results.size(); i++) { - ArrayList resSeg = results.get(i); - - for (int j = 0; j < resSeg.size(); j++) { - if (idx % 3 == 0) { - stream.write(("f " + (idx + 1) + " " + (idx + 2) + " " + (idx + 3) + "\n").getBytes()); - } - idx ++; - - stream.write(("v " + resSeg.get(j)[0] + " " + resSeg.get(j)[1] + " " + resSeg.get(j)[2] + "\n").getBytes()); - } - } - - stream.flush(); - stream.close(); - } - catch (Exception e) { - System.out.println("Something went wrong while writing to the output file"); - return; - } - } -} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.meteoinfo.chart.jogl.mc; + +import java.io.*; +import java.util.ArrayList; + +/** + * Created by Primoz on 11. 07. 2016. + */ +public class ExtractHandler { + public static void extractHandlerChar(File inputFile, File outFile, final int[] size, final float voxSize[], final char isoValue, int nThreads) { + char[] scalarField; + + if (inputFile != null) { + System.out.println("PROGRESS: Reading input data."); + try { + int idx = 0; + scalarField = new char[size[0] * size[1] * size[2]]; + + DataInputStream in = new DataInputStream(new FileInputStream(inputFile)); + while (in.available() > 0) { + // Size does not match + if (idx >= scalarField.length) { + in.close(); + System.out.println("Invalid volume size was specified."); + return; + } + + scalarField[idx++] = (char) in.readByte(); + } + + in.close(); + + // Size does not match + if (idx != scalarField.length) { + System.out.println("Invalid volume size was specified."); + return; + } + } + catch (Exception e) { + System.out.println("Something went wrong while reading the volume"); + return; + } + } + else { + System.out.println("PROGRESS: Generating volume data."); + scalarField = VolumeGenerator.generateScalarFieldChar(size); + } + + final char[] finalScalarField = scalarField; + + ArrayList threads = new ArrayList<>(); + final ArrayList> results = new ArrayList<>(); + + // Thread work distribution + int remainder = size[2] % nThreads; + int segment = size[2] / nThreads; + + // Z axis offset for vertice position calculation + int zAxisOffset = 0; + + System.out.println("PROGRESS: Executing marching cubes."); + + for (int i = 0; i < nThreads; i++) { + // Distribute remainder among first (remainder) threads + int segmentSize = (remainder-- > 0) ? segment + 1 : segment; + + // Padding needs to be added to correctly close the gaps between segments + final int paddedSegmentSize = (i != nThreads - 1) ? segmentSize + 1 : segmentSize; + + + // Finished callback + final CallbackMC callback = new CallbackMC() { + @Override + public void run() { + results.add(getVertices()); + } + }; + + // Java... + final int finalZAxisOffset = zAxisOffset; + + // Start the thread + Thread t = new Thread() { + public void run() { + MarchingCubes.marchingCubesChar(finalScalarField, new int[]{size[0], size[1], paddedSegmentSize}, size[2], voxSize, isoValue, finalZAxisOffset, callback); + } + }; + + threads.add(t); + t.start(); + + // Correct offsets for next iteration + zAxisOffset += segmentSize; + } + + // Join the threads + for (int i = 0; i 0) { + // Size does not match + if (idx >= scalarField.length) { + in.close(); + System.out.println("Invalid volume size was specified."); + return; + } + + scalarField[idx++] = in.readShort(); + } + + in.close(); + + // Size does not match + if (idx != scalarField.length) { + System.out.println("Invalid volume size was specified."); + return; + } + } + catch (Exception e) { + System.out.println("Something went wrong while reading the volume"); + return; + } + } + else { + System.out.println("PROGRESS: Generating volume data."); + scalarField = VolumeGenerator.generateScalarFieldShort(size); + } + + final short[] finalScalarField = scalarField; + + ArrayList threads = new ArrayList<>(); + final ArrayList> results = new ArrayList<>(); + + // Thread work distribution + int remainder = size[2] % nThreads; + int segment = size[2] / nThreads; + + // Z axis offset for vertice position calculation + int zAxisOffset = 0; + + System.out.println("PROGRESS: Executing marching cubes."); + + for (int i = 0; i < nThreads; i++) { + // Distribute remainder among first (remainder) threads + int segmentSize = (remainder-- > 0) ? segment + 1 : segment; + + // Padding needs to be added to correctly close the gaps between segments + final int paddedSegmentSize = (i != nThreads - 1) ? segmentSize + 1 : segmentSize; + + + // Finished callback + final CallbackMC callback = new CallbackMC() { + @Override + public void run() { + results.add(getVertices()); + } + }; + + // Java... + final int finalZAxisOffset = zAxisOffset; + + // Start the thread + Thread t = new Thread() { + public void run() { + MarchingCubes.marchingCubesShort(finalScalarField, new int[]{size[0], size[1], paddedSegmentSize}, size[2], voxSize, isoValue, finalZAxisOffset, callback); + } + }; + + threads.add(t); + t.start(); + + // Correct offsets for next iteration + zAxisOffset += segmentSize; + } + + // Join the threads + for (int i = 0; i 0) { + // Size does not match + if (idx >= scalarField.length) { + in.close(); + System.out.println("Invalid volume size was specified."); + return; + } + + scalarField[idx++] = in.readInt(); + } + + in.close(); + + // Size does not match + if (idx != scalarField.length) { + System.out.println("Invalid volume size was specified."); + return; + } + } + catch (Exception e) { + System.out.println("Something went wrong while reading the volume"); + return; + } + } + else { + System.out.println("PROGRESS: Generating volume data."); + scalarField = VolumeGenerator.generateScalarFieldInt(size); + } + + final int[] finalScalarField = scalarField; + + ArrayList threads = new ArrayList<>(); + final ArrayList> results = new ArrayList<>(); + + // Thread work distribution + int remainder = size[2] % nThreads; + int segment = size[2] / nThreads; + + // Z axis offset for vertice position calculation + int zAxisOffset = 0; + + System.out.println("PROGRESS: Executing marching cubes."); + + for (int i = 0; i < nThreads; i++) { + // Distribute remainder among first (remainder) threads + int segmentSize = (remainder-- > 0) ? segment + 1 : segment; + + // Padding needs to be added to correctly close the gaps between segments + final int paddedSegmentSize = (i != nThreads - 1) ? segmentSize + 1 : segmentSize; + + + // Finished callback + final CallbackMC callback = new CallbackMC() { + @Override + public void run() { + results.add(getVertices()); + } + }; + + // Java... + final int finalZAxisOffset = zAxisOffset; + + // Start the thread + Thread t = new Thread() { + public void run() { + MarchingCubes.marchingCubesInt(finalScalarField, new int[]{size[0], size[1], paddedSegmentSize}, size[2], voxSize, isoValue, finalZAxisOffset, callback); + } + }; + + threads.add(t); + t.start(); + + // Correct offsets for next iteration + zAxisOffset += segmentSize; + } + + // Join the threads + for (int i = 0; i 0) { + // Size does not match + if (idx >= scalarField.length) { + in.close(); + System.out.println("Invalid volume size was specified."); + return; + } + + scalarField[idx++] = in.readFloat(); + } + + in.close(); + + // Size does not match + if (idx != scalarField.length) { + System.out.println("Invalid volume size was specified."); + return; + } + } + catch (Exception e) { + System.out.println("Something went wrong while reading the volume"); + return; + } + } + else { + System.out.println("PROGRESS: Generating volume data."); + scalarField = VolumeGenerator.generateScalarFieldFloat(size); + } + + final float[] finalScalarField = scalarField; + + // TIMER + ArrayList threads = new ArrayList<>(); + final ArrayList> results = new ArrayList<>(); + + // Thread work distribution + int remainder = size[2] % nThreads; + int segment = size[2] / nThreads; + + // Z axis offset for vertice position calculation + int zAxisOffset = 0; + + System.out.println("PROGRESS: Executing marching cubes."); + + for (int i = 0; i < nThreads; i++) { + // Distribute remainder among first (remainder) threads + int segmentSize = (remainder-- > 0) ? segment + 1 : segment; + + // Padding needs to be added to correctly close the gaps between segments + final int paddedSegmentSize = (i != nThreads - 1) ? segmentSize + 1 : segmentSize; + + + // Finished callback + final CallbackMC callback = new CallbackMC() { + @Override + public void run() { + results.add(getVertices()); + } + }; + + // Java... + final int finalZAxisOffset = zAxisOffset; + + // Start the thread + Thread t = new Thread() { + public void run() { + MarchingCubes.marchingCubesFloat(finalScalarField, new int[]{size[0], size[1], paddedSegmentSize}, size[2], voxSize, isoValue, finalZAxisOffset, callback); + } + }; + + threads.add(t); + t.start(); + + // Correct offsets for next iteration + zAxisOffset += segmentSize; + } + + // Join the threads + for (int i = 0; i 0) { + // Size does not match + if (idx >= scalarField.length) { + in.close(); + System.out.println("Invalid volume size was specified."); + return; + } + + scalarField[idx++] = in.readDouble(); + } + + in.close(); + + // Size does not match + if (idx != scalarField.length) { + System.out.println("Invalid volume size was specified."); + return; + } + } + catch (Exception e) { + System.out.println("Something went wrong while reading the volume"); + return; + } + } + else { + System.out.println("PROGRESS: Generating volume data."); + scalarField = VolumeGenerator.generateScalarFieldDouble(size); + } + + final double[] finalScalarField = scalarField; + + // TIMER + ArrayList threads = new ArrayList<>(); + final ArrayList> results = new ArrayList<>(); + + // Thread work distribution + int remainder = size[2] % nThreads; + int segment = size[2] / nThreads; + + // Z axis offset for vertice position calculation + int zAxisOffset = 0; + + System.out.println("PROGRESS: Executing marching cubes."); + for (int i = 0; i < nThreads; i++) { + // Distribute remainder among first (remainder) threads + int segmentSize = (remainder-- > 0) ? segment + 1 : segment; + + // Padding needs to be added to correctly close the gaps between segments + final int paddedSegmentSize = (i != nThreads - 1) ? segmentSize + 1 : segmentSize; + + + // Finished callback + final CallbackMC callback = new CallbackMC() { + @Override + public void run() { + results.add(getVertices()); + } + }; + + // Java... + final int finalZAxisOffset = zAxisOffset; + + // Start the thread + Thread t = new Thread() { + public void run() { + MarchingCubes.marchingCubesDouble(finalScalarField, new int[]{size[0], size[1], paddedSegmentSize}, size[2], voxSize, isoValue, finalZAxisOffset, callback); + } + }; + + threads.add(t); + t.start(); + + // Correct offsets for next iteration + zAxisOffset += segmentSize; + } + + // Join the threads + for (int i = 0; i > results, File outFile) { + try { + BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(outFile)); + + int idx = 0; + for (int i = 0; i < results.size(); i++) { + ArrayList resSeg = results.get(i); + + for (int j = 0; j < resSeg.size(); j++) { + if (idx % 3 == 0) { + stream.write(("f " + (idx + 1) + " " + (idx + 2) + " " + (idx + 3) + "\n").getBytes()); + } + idx ++; + + stream.write(("v " + resSeg.get(j)[0] + " " + resSeg.get(j)[1] + " " + resSeg.get(j)[2] + "\n").getBytes()); + } + } + + stream.flush(); + stream.close(); + } + catch (Exception e) { + System.out.println("Something went wrong while writing to the output file"); + return; + } + } +} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/mc/Main.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/mc/Main.java similarity index 97% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/mc/Main.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/mc/Main.java index 2507adac..198c8c17 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/mc/Main.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/mc/Main.java @@ -1,287 +1,287 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.jogl.mc; - -import java.io.File; - -public class Main { - - private static String usage = "This script may be executed in either benchmark or extract mode. Mode is specified by the first parameter [benchmark, extract].\nParameters: \n\t-input-vol\t Specifies path to the input volume. If this parameter is set volume dimensions(-vol-dim), data type(-data-type) and iso value(-iso) must also be given.\n\t-vol-dim\t Specifies the generated/read volume dimensions. Dimensions should be given as unsigned integers in format; -vol-dim X Y Z.\n\t-data-type\t Specifies the input file or generated data type. Options [char, uchar, short, ushort, int, uint, float, double].\n\t-vox-dim\t Specifies voxel dimensions used in mesh construction. Dimensions should be given as floating point numbers in format: -vox-dim X Y Z.\n\t-nThread\t Number of threads used in Marching cubes algorithm.This parameter can be either given as a single unsigned integer value or two unsigned integer values in benchmark mode, specifying the range of thread executions that will be tested.\n\t-iter\t\t Used only in benchmark mode to determine how many iterations should be executed for each configuration.\n\t-iso\t\t Isovalue that is used as a threshold for determining active voxels. Type should match the data type.\n\t-o\t\t Path to output file. In extract mode the mesh is written to file in .obj format [required]. In benchmark mode the results are written to file.\n";; - - private static boolean isUint (String input) { - try { - return (Integer.parseInt(input) >= 0); - } catch (NumberFormatException e) { - return false; - } - } - - private static boolean isFloat (String input) { - try { - Float.parseFloat(input); - return true; - } catch (NumberFormatException e) { - return false; - } - } - - public static void main(String[] args) { - - if (args.length < 1) { - System.out.println(usage); - return; - } else if (args[0].equals("-help")) { - System.out.println(usage); - } - - // Benchmark or extract mode - boolean benchmark = false; - - // Default num of threads is max available - int nThreadsMin = java.lang.Thread.activeCount(); - if (nThreadsMin == 0) { - nThreadsMin = 1; - } - int nThreadsMax = nThreadsMin; - - File inputFile = null; - File outFile = null; - String type = null; - String isoValueStr = null; - int iterations = 10; // Default 10 iterations per benchmark - - boolean customSizeSpecified = false; - int[] size = {64, 64, 64}; - float[] voxSize = {1.0f, 1.0f, 1.0f}; - - //region PARAMETER PARSING - // Read execution type - if (args[0].equals("benchmark")) { - benchmark = true; - } else if (!args[0].equals("extract")) { - System.out.println("Invalid execution type. Valid options [extract, benchmark]"); - return; - } - - // Flag parsing - for (int i = 1; i < args.length; i++) { - if (args[i].equals("-input-vol")) { - // Volume path specified - // Output file path is specified - if (i + 1 >= args.length || args[i + 1].charAt(0) == '-') { - System.out.println("Missing file path after -input-vol flag."); - return; - } - - // Store the file name and offset iterator - inputFile = new File(args[++i]); - - if (!inputFile.exists() || inputFile.isDirectory()) { - System.out.println("Specified volume file does not exist."); - return; - } - } else if (args[i].equals("-vol-dim")) { - // Volume dimensions are given - if (i + 3 >= args.length || args[i + 1].charAt(0) == '-' || args[i + 2].charAt(0) == '-' || args[i + 3].charAt(0) == '-') { - System.out.println("Missing volume dimensions after -vol-dim flag."); - return; - } - - String x = (args[++i]); - String y = (args[++i]); - String z = (args[++i]); - - if (!isUint(x) || !isUint(y) || !isUint(z)) { - System.out.println("Invalid volume dimensions format. Specify dimensions as three unsigned integers."); - return; - } - - customSizeSpecified = true; - size[0] = Integer.parseInt(x); - size[1] = Integer.parseInt(y); - size[2] = Integer.parseInt(z); - } else if (args[i].equals("-vox-dim")) { - // Voxel dimensions are given - if (i + 3 >= args.length) { - System.out.println("Missing voxel dimensions after -vox-dim flag."); - return; - } - - String x = args[++i]; - String y = args[++i]; - String z = args[++i]; - - if (!isFloat(x) || !isFloat(y) || !isFloat(z)) { - System.out.println("Invalid voxel dimensions format. Specify voxel dimensions as three positive floats."); - return; - } - - voxSize[0] = Float.parseFloat(x); - voxSize[0] = Float.parseFloat(y); - voxSize[0] = Float.parseFloat(z); - } else if (args[i].equals("-nThread")) { - // Number of threads is given - // FIRST VALUE - if (i + 1 >= args.length || args[i + 1].charAt(0) == '-') { - System.out.println("Missing number or range of threads after -nThread flag."); - return; - } - - // Validate first number - String tmp = args[++i]; - - if (!isUint(tmp)) { - System.out.println("Invalid nThread value format. Specify unsigned integer value or two if range."); - return; - } - - // Parse C-str - nThreadsMin = Integer.parseInt(tmp); - - // SECOND VALUE (If given) - if (i + 1 < args.length && args[i + 1].charAt(0) != '-') { - // Validate second number - tmp = args[++i]; - if (!isUint(tmp)) { - System.out.println("Invalid nThread value format. Specify unsigned integer value or two if range."); - return; - } - - // Parse C-str - nThreadsMax = Integer.parseInt(tmp); - } else { - nThreadsMax = nThreadsMin; - } - - } else if (args[i].equals("-iso")) { - // ISO value is given - if (i + 1 >= args.length) { - System.out.println("Missing iso value after -iso flag."); - return; - } - - isoValueStr = args[++i]; - - if (!isFloat(isoValueStr)) { - System.out.println("Invalid iso value format. Please specify float."); - return; - } - } else if (args[i].equals("-iter")) { - // ISO value is given - if (i + 1 >= args.length) { - System.out.println("Missing number of iterations after -iter flag."); - return; - } - - String iterationsStr = args[++i]; - - if (!isUint(iterationsStr)) { - System.out.println("Invalid iterations value format. Please specify unsigned integer."); - return; - } - - iterations = Integer.parseInt(iterationsStr); - } else if (args[i].equals("-o")) { - // Output file path is specified - if (i + 1 >= args.length || args[i + 1].charAt(0) == '-') { - System.out.println("Missing file path after -o flag."); - return; - } - - // Store the file name and offset iterator - outFile = new File(args[++i]); - - if (outFile.getParentFile() != null && !outFile.getParentFile().exists()) { - System.out.println("Specified output file path is invaild."); - } - } else if (args[i].equals("-data-type")) { - // Volume data type is specified - if (i + 1 >= args.length || args[i + 1].charAt(0) == '-') { - System.out.println("Missing type after -data-type flag."); - return; - } - - // Data type is specified (char, uchar, short, ushort, int, uint, float, double) - if (!args[i + 1].equals("char") && !args[i + 1].equals("uchar") && !args[i + 1].equals("short") && !args[i + 1].equals("ushort") && args[i + 1].equals("uint") && args[i + 1].equals("float") && args[i + 1].equals("double")) { - System.out.println("Invalid data type. Available data types: char, uchar, short, ushort, int, uint, float, double."); - return; - } - - type = args[++i]; - } else { - System.out.println("Unknown parameter: " + args[i]); - return; - } - } - - if (inputFile != null && (!customSizeSpecified || type == null || isoValueStr == null)) { - System.out.println("If custom volume is imported, you must input volume dimensions(-vol-dim), data type (-data-type) and iso value (-iso)."); - return; - } - //endregion - - if (benchmark) { - switch (type) { - case "char": - BenchmarkHandler.benchmarkChar(inputFile, outFile, size, voxSize, (char) ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0.5), nThreadsMin, nThreadsMax, iterations); - break; - case "uchar": - BenchmarkHandler.benchmarkChar(inputFile, outFile, size, voxSize, (char) ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0.5), nThreadsMin, nThreadsMax, iterations); - break; - case "short": - BenchmarkHandler.benchmarkShort(inputFile, outFile, size, voxSize, (short) ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0.5), nThreadsMin, nThreadsMax, iterations); - break; - case "ushort": - BenchmarkHandler.benchmarkShort(inputFile, outFile, size, voxSize, (short) ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0.5), nThreadsMin, nThreadsMax, iterations); - break; - case "int": - BenchmarkHandler.benchmarkInt(inputFile, outFile, size, voxSize, ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0), nThreadsMin, nThreadsMax, iterations); - break; - case "uint": - BenchmarkHandler.benchmarkInt(inputFile, outFile, size, voxSize, ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0), nThreadsMin, nThreadsMax, iterations); - break; - case "float": - BenchmarkHandler.benchmarkFloat(inputFile, outFile, size, voxSize, ((isoValueStr != null) ? Float.parseFloat(isoValueStr) : 0.5f), nThreadsMin, nThreadsMax, iterations); - break; - case "double": - BenchmarkHandler.benchmarkDouble(inputFile, outFile, size, voxSize, ((isoValueStr != null) ? Double.parseDouble(isoValueStr) : 0.5), nThreadsMin, nThreadsMax, iterations); - break; - } - } else { - if (outFile == null) { - System.out.println("To extract the data the output file path is needed (-o)."); - return; - } - - switch (type) { - case "char": - ExtractHandler.extractHandlerChar(inputFile, outFile, size, voxSize, (char) ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0.5), nThreadsMax); - break; - case "uchar": - ExtractHandler.extractHandlerChar(inputFile, outFile, size, voxSize, (char) ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0.5), nThreadsMax); - break; - case "short": - ExtractHandler.extractHandlerShort(inputFile, outFile, size, voxSize, (short) ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0.5), nThreadsMax); - break; - case "ushort": - ExtractHandler.extractHandlerShort(inputFile, outFile, size, voxSize, (short) ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0.5), nThreadsMax); - break; - case "int": - ExtractHandler.extractHandlerInt(inputFile, outFile, size, voxSize, ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0), nThreadsMax); - break; - case "uint": - ExtractHandler.extractHandlerInt(inputFile, outFile, size, voxSize, ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0), nThreadsMax); - break; - case "float": - ExtractHandler.extractHandlerFloat(inputFile, outFile, size, voxSize, ((isoValueStr != null) ? Float.parseFloat(isoValueStr) : 0.5f), nThreadsMax); - break; - case "double": - ExtractHandler.extractHandlerDouble(inputFile, outFile, size, voxSize, ((isoValueStr != null) ? Double.parseDouble(isoValueStr) : 0.5), nThreadsMax); - break; - } - } - } -} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.meteoinfo.chart.jogl.mc; + +import java.io.File; + +public class Main { + + private static String usage = "This script may be executed in either benchmark or extract mode. Mode is specified by the first parameter [benchmark, extract].\nParameters: \n\t-input-vol\t Specifies path to the input volume. If this parameter is set volume dimensions(-vol-dim), data type(-data-type) and iso value(-iso) must also be given.\n\t-vol-dim\t Specifies the generated/read volume dimensions. Dimensions should be given as unsigned integers in format; -vol-dim X Y Z.\n\t-data-type\t Specifies the input file or generated data type. Options [char, uchar, short, ushort, int, uint, float, double].\n\t-vox-dim\t Specifies voxel dimensions used in mesh construction. Dimensions should be given as floating point numbers in format: -vox-dim X Y Z.\n\t-nThread\t Number of threads used in Marching cubes algorithm.This parameter can be either given as a single unsigned integer value or two unsigned integer values in benchmark mode, specifying the range of thread executions that will be tested.\n\t-iter\t\t Used only in benchmark mode to determine how many iterations should be executed for each configuration.\n\t-iso\t\t Isovalue that is used as a threshold for determining active voxels. Type should match the data type.\n\t-o\t\t Path to output file. In extract mode the mesh is written to file in .obj format [required]. In benchmark mode the results are written to file.\n";; + + private static boolean isUint (String input) { + try { + return (Integer.parseInt(input) >= 0); + } catch (NumberFormatException e) { + return false; + } + } + + private static boolean isFloat (String input) { + try { + Float.parseFloat(input); + return true; + } catch (NumberFormatException e) { + return false; + } + } + + public static void main(String[] args) { + + if (args.length < 1) { + System.out.println(usage); + return; + } else if (args[0].equals("-help")) { + System.out.println(usage); + } + + // Benchmark or extract mode + boolean benchmark = false; + + // Default num of threads is max available + int nThreadsMin = Thread.activeCount(); + if (nThreadsMin == 0) { + nThreadsMin = 1; + } + int nThreadsMax = nThreadsMin; + + File inputFile = null; + File outFile = null; + String type = null; + String isoValueStr = null; + int iterations = 10; // Default 10 iterations per benchmark + + boolean customSizeSpecified = false; + int[] size = {64, 64, 64}; + float[] voxSize = {1.0f, 1.0f, 1.0f}; + + //region PARAMETER PARSING + // Read execution type + if (args[0].equals("benchmark")) { + benchmark = true; + } else if (!args[0].equals("extract")) { + System.out.println("Invalid execution type. Valid options [extract, benchmark]"); + return; + } + + // Flag parsing + for (int i = 1; i < args.length; i++) { + if (args[i].equals("-input-vol")) { + // Volume path specified + // Output file path is specified + if (i + 1 >= args.length || args[i + 1].charAt(0) == '-') { + System.out.println("Missing file path after -input-vol flag."); + return; + } + + // Store the file name and offset iterator + inputFile = new File(args[++i]); + + if (!inputFile.exists() || inputFile.isDirectory()) { + System.out.println("Specified volume file does not exist."); + return; + } + } else if (args[i].equals("-vol-dim")) { + // Volume dimensions are given + if (i + 3 >= args.length || args[i + 1].charAt(0) == '-' || args[i + 2].charAt(0) == '-' || args[i + 3].charAt(0) == '-') { + System.out.println("Missing volume dimensions after -vol-dim flag."); + return; + } + + String x = (args[++i]); + String y = (args[++i]); + String z = (args[++i]); + + if (!isUint(x) || !isUint(y) || !isUint(z)) { + System.out.println("Invalid volume dimensions format. Specify dimensions as three unsigned integers."); + return; + } + + customSizeSpecified = true; + size[0] = Integer.parseInt(x); + size[1] = Integer.parseInt(y); + size[2] = Integer.parseInt(z); + } else if (args[i].equals("-vox-dim")) { + // Voxel dimensions are given + if (i + 3 >= args.length) { + System.out.println("Missing voxel dimensions after -vox-dim flag."); + return; + } + + String x = args[++i]; + String y = args[++i]; + String z = args[++i]; + + if (!isFloat(x) || !isFloat(y) || !isFloat(z)) { + System.out.println("Invalid voxel dimensions format. Specify voxel dimensions as three positive floats."); + return; + } + + voxSize[0] = Float.parseFloat(x); + voxSize[0] = Float.parseFloat(y); + voxSize[0] = Float.parseFloat(z); + } else if (args[i].equals("-nThread")) { + // Number of threads is given + // FIRST VALUE + if (i + 1 >= args.length || args[i + 1].charAt(0) == '-') { + System.out.println("Missing number or range of threads after -nThread flag."); + return; + } + + // Validate first number + String tmp = args[++i]; + + if (!isUint(tmp)) { + System.out.println("Invalid nThread value format. Specify unsigned integer value or two if range."); + return; + } + + // Parse C-str + nThreadsMin = Integer.parseInt(tmp); + + // SECOND VALUE (If given) + if (i + 1 < args.length && args[i + 1].charAt(0) != '-') { + // Validate second number + tmp = args[++i]; + if (!isUint(tmp)) { + System.out.println("Invalid nThread value format. Specify unsigned integer value or two if range."); + return; + } + + // Parse C-str + nThreadsMax = Integer.parseInt(tmp); + } else { + nThreadsMax = nThreadsMin; + } + + } else if (args[i].equals("-iso")) { + // ISO value is given + if (i + 1 >= args.length) { + System.out.println("Missing iso value after -iso flag."); + return; + } + + isoValueStr = args[++i]; + + if (!isFloat(isoValueStr)) { + System.out.println("Invalid iso value format. Please specify float."); + return; + } + } else if (args[i].equals("-iter")) { + // ISO value is given + if (i + 1 >= args.length) { + System.out.println("Missing number of iterations after -iter flag."); + return; + } + + String iterationsStr = args[++i]; + + if (!isUint(iterationsStr)) { + System.out.println("Invalid iterations value format. Please specify unsigned integer."); + return; + } + + iterations = Integer.parseInt(iterationsStr); + } else if (args[i].equals("-o")) { + // Output file path is specified + if (i + 1 >= args.length || args[i + 1].charAt(0) == '-') { + System.out.println("Missing file path after -o flag."); + return; + } + + // Store the file name and offset iterator + outFile = new File(args[++i]); + + if (outFile.getParentFile() != null && !outFile.getParentFile().exists()) { + System.out.println("Specified output file path is invaild."); + } + } else if (args[i].equals("-data-type")) { + // Volume data type is specified + if (i + 1 >= args.length || args[i + 1].charAt(0) == '-') { + System.out.println("Missing type after -data-type flag."); + return; + } + + // Data type is specified (char, uchar, short, ushort, int, uint, float, double) + if (!args[i + 1].equals("char") && !args[i + 1].equals("uchar") && !args[i + 1].equals("short") && !args[i + 1].equals("ushort") && args[i + 1].equals("uint") && args[i + 1].equals("float") && args[i + 1].equals("double")) { + System.out.println("Invalid data type. Available data types: char, uchar, short, ushort, int, uint, float, double."); + return; + } + + type = args[++i]; + } else { + System.out.println("Unknown parameter: " + args[i]); + return; + } + } + + if (inputFile != null && (!customSizeSpecified || type == null || isoValueStr == null)) { + System.out.println("If custom volume is imported, you must input volume dimensions(-vol-dim), data type (-data-type) and iso value (-iso)."); + return; + } + //endregion + + if (benchmark) { + switch (type) { + case "char": + BenchmarkHandler.benchmarkChar(inputFile, outFile, size, voxSize, (char) ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0.5), nThreadsMin, nThreadsMax, iterations); + break; + case "uchar": + BenchmarkHandler.benchmarkChar(inputFile, outFile, size, voxSize, (char) ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0.5), nThreadsMin, nThreadsMax, iterations); + break; + case "short": + BenchmarkHandler.benchmarkShort(inputFile, outFile, size, voxSize, (short) ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0.5), nThreadsMin, nThreadsMax, iterations); + break; + case "ushort": + BenchmarkHandler.benchmarkShort(inputFile, outFile, size, voxSize, (short) ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0.5), nThreadsMin, nThreadsMax, iterations); + break; + case "int": + BenchmarkHandler.benchmarkInt(inputFile, outFile, size, voxSize, ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0), nThreadsMin, nThreadsMax, iterations); + break; + case "uint": + BenchmarkHandler.benchmarkInt(inputFile, outFile, size, voxSize, ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0), nThreadsMin, nThreadsMax, iterations); + break; + case "float": + BenchmarkHandler.benchmarkFloat(inputFile, outFile, size, voxSize, ((isoValueStr != null) ? Float.parseFloat(isoValueStr) : 0.5f), nThreadsMin, nThreadsMax, iterations); + break; + case "double": + BenchmarkHandler.benchmarkDouble(inputFile, outFile, size, voxSize, ((isoValueStr != null) ? Double.parseDouble(isoValueStr) : 0.5), nThreadsMin, nThreadsMax, iterations); + break; + } + } else { + if (outFile == null) { + System.out.println("To extract the data the output file path is needed (-o)."); + return; + } + + switch (type) { + case "char": + ExtractHandler.extractHandlerChar(inputFile, outFile, size, voxSize, (char) ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0.5), nThreadsMax); + break; + case "uchar": + ExtractHandler.extractHandlerChar(inputFile, outFile, size, voxSize, (char) ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0.5), nThreadsMax); + break; + case "short": + ExtractHandler.extractHandlerShort(inputFile, outFile, size, voxSize, (short) ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0.5), nThreadsMax); + break; + case "ushort": + ExtractHandler.extractHandlerShort(inputFile, outFile, size, voxSize, (short) ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0.5), nThreadsMax); + break; + case "int": + ExtractHandler.extractHandlerInt(inputFile, outFile, size, voxSize, ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0), nThreadsMax); + break; + case "uint": + ExtractHandler.extractHandlerInt(inputFile, outFile, size, voxSize, ((isoValueStr != null) ? Integer.parseInt(isoValueStr) : 0), nThreadsMax); + break; + case "float": + ExtractHandler.extractHandlerFloat(inputFile, outFile, size, voxSize, ((isoValueStr != null) ? Float.parseFloat(isoValueStr) : 0.5f), nThreadsMax); + break; + case "double": + ExtractHandler.extractHandlerDouble(inputFile, outFile, size, voxSize, ((isoValueStr != null) ? Double.parseDouble(isoValueStr) : 0.5), nThreadsMax); + break; + } + } + } +} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/mc/MarchingCubes.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/mc/MarchingCubes.java similarity index 98% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/mc/MarchingCubes.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/mc/MarchingCubes.java index 843d15b6..fb6ae306 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/mc/MarchingCubes.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/mc/MarchingCubes.java @@ -1,1080 +1,1081 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.jogl.mc; - -import java.util.ArrayList; -import org.meteoinfo.ndarray.Array; - -/** - * Created by Primoz on 11. 07. 2016. - */ -public class MarchingCubes { - static float[] lerp(float[] vec1, float[] vec2, float alpha){ - return new float[]{vec1[0] + (vec2[0] - vec1[0]) * alpha, vec1[1] + (vec2[1] - vec1[1]) * alpha, vec1[2] + (vec2[2] - vec1[2]) * alpha}; - } - - static void marchingCubesChar(char[] values, int[] volDim, int volZFull, float[] voxDim, char isoLevel, int offset, CallbackMC callback) { - - ArrayList vertices = new ArrayList<>(); - // Actual position along edge weighted according to function values. - float vertList[][] = new float[12][3]; - - - // Calculate maximal possible axis value (used in vertice normalization) - float maxX = voxDim[0] * (volDim[0] - 1); - float maxY = voxDim[1] * (volDim[1] - 1); - float maxZ = voxDim[2] * (volZFull - 1); - float maxAxisVal = Math.max(maxX, Math.max(maxY, maxZ)); - - // Volume iteration - for (int z = 0; z < volDim[2] - 1; z++) { - for (int y = 0; y < volDim[1] - 1; y++) { - for (int x = 0; x < volDim[0] - 1; x++) { - - // Indices pointing to cube vertices - // pyz ___________________ pxyz - // /| /| - // / | / | - // / | / | - // pz /___|______________/pxz| - // | | | | - // | | | | - // | py |______________|___| pxy - // | / | / - // | / | / - // | / | / - // |/__________________|/ - // p px - - int p = x + (volDim[0] * y) + (volDim[0] * volDim[1] * (z + offset)), - px = p + 1, - py = p + volDim[0], - pxy = py + 1, - pz = p + volDim[0] * volDim[1], - pxz = px + volDim[0] * volDim[1], - pyz = py + volDim[0] * volDim[1], - pxyz = pxy + volDim[0] * volDim[1]; - - // X Y Z - float position[] = new float[]{x * voxDim[0], y * voxDim[1], (z + offset) * voxDim[2]}; - - // Voxel intensities - char value0 = values[p], - value1 = values[px], - value2 = values[py], - value3 = values[pxy], - value4 = values[pz], - value5 = values[pxz], - value6 = values[pyz], - value7 = values[pxyz]; - - // Voxel is active if its intensity is above isolevel - int cubeindex = 0; - if (value0 > isoLevel) cubeindex |= 1; - if (value1 > isoLevel) cubeindex |= 2; - if (value2 > isoLevel) cubeindex |= 8; - if (value3 > isoLevel) cubeindex |= 4; - if (value4 > isoLevel) cubeindex |= 16; - if (value5 > isoLevel) cubeindex |= 32; - if (value6 > isoLevel) cubeindex |= 128; - if (value7 > isoLevel) cubeindex |= 64; - - // Fetch the triggered edges - int bits = TablesMC.MC_EDGE_TABLE[cubeindex]; - - // If no edge is triggered... skip - if (bits == 0) continue; - - // Interpolate the positions based od voxel intensities - float mu = 0.5f; - - // bottom of the cube - if ((bits & 1) != 0) { - mu = (isoLevel - value0) / (value1 - value0); - vertList[0] = lerp(position, new float[]{position[0] + voxDim[0], position[1], position[2]}, mu); - } - if ((bits & 2) != 0) { - mu = (isoLevel - value1) / (value3 - value1); - vertList[1] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, mu); - } - if ((bits & 4) != 0) { - mu = (isoLevel - value2) / (value3 - value2); - vertList[2] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, mu); - } - if ((bits & 8) != 0) { - mu = (isoLevel - value0) / (value2 - value0); - vertList[3] = lerp(position, new float[]{position[0], position[1] + voxDim[1], position[2]}, mu); - } - // top of the cube - if ((bits & 16) != 0) { - mu = (isoLevel - value4) / (value5 - value4); - vertList[4] = lerp(new float[]{position[0], position[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 32) != 0) { - mu = (isoLevel - value5) / (value7 - value5); - vertList[5] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 64) != 0) { - mu = (isoLevel - value6) / (value7 - value6); - vertList[6] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 128) != 0) { - mu = (isoLevel - value4) / (value6 - value4); - vertList[7] = lerp(new float[]{position[0], position[1], position[2] + voxDim[2]}, new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); - } - // vertical lines of the cube - if ((bits & 256) != 0) { - mu = (isoLevel - value0) / (value4 - value0); - vertList[8] = lerp(position, new float[]{position[0], position[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 512) != 0) { - mu = (isoLevel - value1) / (value5 - value1); - vertList[9] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2]}, new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 1024) != 0) { - mu = (isoLevel - value3) / (value7 - value3); - vertList[10] = lerp(new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, new float[]{position[0] + voxDim[0], position[1]+ voxDim[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 2048) != 0) { - mu = (isoLevel - value2) / (value6 - value2); - vertList[11] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2]}, new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); - } - - // construct triangles -- get correct vertices from triTable. - int i = 0; - // "Re-purpose cubeindex into an offset into triTable." - cubeindex <<= 4; - - while (TablesMC.MC_TRI_TABLE[cubeindex + i] != -1) { - int index1 = TablesMC.MC_TRI_TABLE[cubeindex + i]; - int index2 = TablesMC.MC_TRI_TABLE[cubeindex + i + 1]; - int index3 = TablesMC.MC_TRI_TABLE[cubeindex + i + 2]; - - // Add triangles vertices normalized with the maximal possible value - vertices.add(new float[] {vertList[index3][0] / maxAxisVal - 0.5f, vertList[index3][1] / maxAxisVal - 0.5f, vertList[index3][2] / maxAxisVal - 0.5f}); - vertices.add(new float[] {vertList[index2][0] / maxAxisVal - 0.5f, vertList[index2][1] / maxAxisVal - 0.5f, vertList[index2][2] / maxAxisVal - 0.5f}); - vertices.add(new float[] {vertList[index1][0] / maxAxisVal - 0.5f, vertList[index1][1] / maxAxisVal - 0.5f, vertList[index1][2] / maxAxisVal - 0.5f}); - - i += 3; - } - } - } - } - - callback.setVertices(vertices); - callback.run(); - } - - static void marchingCubesShort(short[] values, int[] volDim, int volZFull, float[] voxDim, short isoLevel, int offset, CallbackMC callback) { - - ArrayList vertices = new ArrayList<>(); - // Actual position along edge weighted according to function values. - float vertList[][] = new float[12][3]; - - - // Calculate maximal possible axis value (used in vertice normalization) - float maxX = voxDim[0] * (volDim[0] - 1); - float maxY = voxDim[1] * (volDim[1] - 1); - float maxZ = voxDim[2] * (volZFull - 1); - float maxAxisVal = Math.max(maxX, Math.max(maxY, maxZ)); - - // Volume iteration - for (int z = 0; z < volDim[2] - 1; z++) { - for (int y = 0; y < volDim[1] - 1; y++) { - for (int x = 0; x < volDim[0] - 1; x++) { - - // Indices pointing to cube vertices - // pyz ___________________ pxyz - // /| /| - // / | / | - // / | / | - // pz /___|______________/pxz| - // | | | | - // | | | | - // | py |______________|___| pxy - // | / | / - // | / | / - // | / | / - // |/__________________|/ - // p px - - int p = x + (volDim[0] * y) + (volDim[0] * volDim[1] * (z + offset)), - px = p + 1, - py = p + volDim[0], - pxy = py + 1, - pz = p + volDim[0] * volDim[1], - pxz = px + volDim[0] * volDim[1], - pyz = py + volDim[0] * volDim[1], - pxyz = pxy + volDim[0] * volDim[1]; - - // X Y Z - float position[] = new float[]{x * voxDim[0], y * voxDim[1], (z + offset) * voxDim[2]}; - - // Voxel intensities - short value0 = values[p], - value1 = values[px], - value2 = values[py], - value3 = values[pxy], - value4 = values[pz], - value5 = values[pxz], - value6 = values[pyz], - value7 = values[pxyz]; - - // Voxel is active if its intensity is above isolevel - int cubeindex = 0; - if (value0 > isoLevel) cubeindex |= 1; - if (value1 > isoLevel) cubeindex |= 2; - if (value2 > isoLevel) cubeindex |= 8; - if (value3 > isoLevel) cubeindex |= 4; - if (value4 > isoLevel) cubeindex |= 16; - if (value5 > isoLevel) cubeindex |= 32; - if (value6 > isoLevel) cubeindex |= 128; - if (value7 > isoLevel) cubeindex |= 64; - - // Fetch the triggered edges - int bits = TablesMC.MC_EDGE_TABLE[cubeindex]; - - // If no edge is triggered... skip - if (bits == 0) continue; - - // Interpolate the positions based od voxel intensities - float mu = 0.5f; - - // bottom of the cube - if ((bits & 1) != 0) { - mu = (isoLevel - value0) / (value1 - value0); - vertList[0] = lerp(position, new float[]{position[0] + voxDim[0], position[1], position[2]}, mu); - } - if ((bits & 2) != 0) { - mu = (isoLevel - value1) / (value3 - value1); - vertList[1] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, mu); - } - if ((bits & 4) != 0) { - mu = (isoLevel - value2) / (value3 - value2); - vertList[2] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, mu); - } - if ((bits & 8) != 0) { - mu = (isoLevel - value0) / (value2 - value0); - vertList[3] = lerp(position, new float[]{position[0], position[1] + voxDim[1], position[2]}, mu); - } - // top of the cube - if ((bits & 16) != 0) { - mu = (isoLevel - value4) / (value5 - value4); - vertList[4] = lerp(new float[]{position[0], position[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 32) != 0) { - mu = (isoLevel - value5) / (value7 - value5); - vertList[5] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 64) != 0) { - mu = (isoLevel - value6) / (value7 - value6); - vertList[6] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 128) != 0) { - mu = (isoLevel - value4) / (value6 - value4); - vertList[7] = lerp(new float[]{position[0], position[1], position[2] + voxDim[2]}, new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); - } - // vertical lines of the cube - if ((bits & 256) != 0) { - mu = (isoLevel - value0) / (value4 - value0); - vertList[8] = lerp(position, new float[]{position[0], position[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 512) != 0) { - mu = (isoLevel - value1) / (value5 - value1); - vertList[9] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2]}, new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 1024) != 0) { - mu = (isoLevel - value3) / (value7 - value3); - vertList[10] = lerp(new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, new float[]{position[0] + voxDim[0], position[1]+ voxDim[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 2048) != 0) { - mu = (isoLevel - value2) / (value6 - value2); - vertList[11] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2]}, new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); - } - - // construct triangles -- get correct vertices from triTable. - int i = 0; - // "Re-purpose cubeindex into an offset into triTable." - cubeindex <<= 4; - - while (TablesMC.MC_TRI_TABLE[cubeindex + i] != -1) { - int index1 = TablesMC.MC_TRI_TABLE[cubeindex + i]; - int index2 = TablesMC.MC_TRI_TABLE[cubeindex + i + 1]; - int index3 = TablesMC.MC_TRI_TABLE[cubeindex + i + 2]; - - // Add triangles vertices normalized with the maximal possible value - vertices.add(new float[] {vertList[index3][0] / maxAxisVal - 0.5f, vertList[index3][1] / maxAxisVal - 0.5f, vertList[index3][2] / maxAxisVal - 0.5f}); - vertices.add(new float[] {vertList[index2][0] / maxAxisVal - 0.5f, vertList[index2][1] / maxAxisVal - 0.5f, vertList[index2][2] / maxAxisVal - 0.5f}); - vertices.add(new float[] {vertList[index1][0] / maxAxisVal - 0.5f, vertList[index1][1] / maxAxisVal - 0.5f, vertList[index1][2] / maxAxisVal - 0.5f}); - - i += 3; - } - } - } - } - - callback.setVertices(vertices); - callback.run(); - } - - static void marchingCubesInt(int[] values, int[] volDim, int volZFull, float[] voxDim, int isoLevel, int offset, CallbackMC callback) { - - ArrayList vertices = new ArrayList<>(); - // Actual position along edge weighted according to function values. - float vertList[][] = new float[12][3]; - - - // Calculate maximal possible axis value (used in vertice normalization) - float maxX = voxDim[0] * (volDim[0] - 1); - float maxY = voxDim[1] * (volDim[1] - 1); - float maxZ = voxDim[2] * (volZFull - 1); - float maxAxisVal = Math.max(maxX, Math.max(maxY, maxZ)); - - // Volume iteration - for (int z = 0; z < volDim[2] - 1; z++) { - for (int y = 0; y < volDim[1] - 1; y++) { - for (int x = 0; x < volDim[0] - 1; x++) { - - // Indices pointing to cube vertices - // pyz ___________________ pxyz - // /| /| - // / | / | - // / | / | - // pz /___|______________/pxz| - // | | | | - // | | | | - // | py |______________|___| pxy - // | / | / - // | / | / - // | / | / - // |/__________________|/ - // p px - - int p = x + (volDim[0] * y) + (volDim[0] * volDim[1] * (z + offset)), - px = p + 1, - py = p + volDim[0], - pxy = py + 1, - pz = p + volDim[0] * volDim[1], - pxz = px + volDim[0] * volDim[1], - pyz = py + volDim[0] * volDim[1], - pxyz = pxy + volDim[0] * volDim[1]; - - // X Y Z - float position[] = new float[]{x * voxDim[0], y * voxDim[1], (z + offset) * voxDim[2]}; - - // Voxel intensities - int value0 = values[p], - value1 = values[px], - value2 = values[py], - value3 = values[pxy], - value4 = values[pz], - value5 = values[pxz], - value6 = values[pyz], - value7 = values[pxyz]; - - // Voxel is active if its intensity is above isolevel - int cubeindex = 0; - if (value0 > isoLevel) cubeindex |= 1; - if (value1 > isoLevel) cubeindex |= 2; - if (value2 > isoLevel) cubeindex |= 8; - if (value3 > isoLevel) cubeindex |= 4; - if (value4 > isoLevel) cubeindex |= 16; - if (value5 > isoLevel) cubeindex |= 32; - if (value6 > isoLevel) cubeindex |= 128; - if (value7 > isoLevel) cubeindex |= 64; - - // Fetch the triggered edges - int bits = TablesMC.MC_EDGE_TABLE[cubeindex]; - - // If no edge is triggered... skip - if (bits == 0) continue; - - // Interpolate the positions based od voxel intensities - float mu = 0.5f; - - // bottom of the cube - if ((bits & 1) != 0) { - mu = (isoLevel - value0) / (value1 - value0); - vertList[0] = lerp(position, new float[]{position[0] + voxDim[0], position[1], position[2]}, mu); - } - if ((bits & 2) != 0) { - mu = (isoLevel - value1) / (value3 - value1); - vertList[1] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, mu); - } - if ((bits & 4) != 0) { - mu = (isoLevel - value2) / (value3 - value2); - vertList[2] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, mu); - } - if ((bits & 8) != 0) { - mu = (isoLevel - value0) / (value2 - value0); - vertList[3] = lerp(position, new float[]{position[0], position[1] + voxDim[1], position[2]}, mu); - } - // top of the cube - if ((bits & 16) != 0) { - mu = (isoLevel - value4) / (value5 - value4); - vertList[4] = lerp(new float[]{position[0], position[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 32) != 0) { - mu = (isoLevel - value5) / (value7 - value5); - vertList[5] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 64) != 0) { - mu = (isoLevel - value6) / (value7 - value6); - vertList[6] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 128) != 0) { - mu = (isoLevel - value4) / (value6 - value4); - vertList[7] = lerp(new float[]{position[0], position[1], position[2] + voxDim[2]}, new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); - } - // vertical lines of the cube - if ((bits & 256) != 0) { - mu = (isoLevel - value0) / (value4 - value0); - vertList[8] = lerp(position, new float[]{position[0], position[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 512) != 0) { - mu = (isoLevel - value1) / (value5 - value1); - vertList[9] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2]}, new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 1024) != 0) { - mu = (isoLevel - value3) / (value7 - value3); - vertList[10] = lerp(new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, new float[]{position[0] + voxDim[0], position[1]+ voxDim[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 2048) != 0) { - mu = (isoLevel - value2) / (value6 - value2); - vertList[11] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2]}, new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); - } - - // construct triangles -- get correct vertices from triTable. - int i = 0; - // "Re-purpose cubeindex into an offset into triTable." - cubeindex <<= 4; - - while (TablesMC.MC_TRI_TABLE[cubeindex + i] != -1) { - int index1 = TablesMC.MC_TRI_TABLE[cubeindex + i]; - int index2 = TablesMC.MC_TRI_TABLE[cubeindex + i + 1]; - int index3 = TablesMC.MC_TRI_TABLE[cubeindex + i + 2]; - - // Add triangles vertices normalized with the maximal possible value - vertices.add(new float[] {vertList[index3][0] / maxAxisVal - 0.5f, vertList[index3][1] / maxAxisVal - 0.5f, vertList[index3][2] / maxAxisVal - 0.5f}); - vertices.add(new float[] {vertList[index2][0] / maxAxisVal - 0.5f, vertList[index2][1] / maxAxisVal - 0.5f, vertList[index2][2] / maxAxisVal - 0.5f}); - vertices.add(new float[] {vertList[index1][0] / maxAxisVal - 0.5f, vertList[index1][1] / maxAxisVal - 0.5f, vertList[index1][2] / maxAxisVal - 0.5f}); - - i += 3; - } - } - } - } - - callback.setVertices(vertices); - callback.run(); - } - - static void marchingCubesFloat(float[] values, int[] volDim, int volZFull, float[] voxDim, float isoLevel, int offset, CallbackMC callback) { - - ArrayList vertices = new ArrayList<>(); - // Actual position along edge weighted according to function values. - float vertList[][] = new float[12][3]; - - - // Calculate maximal possible axis value (used in vertice normalization) - float maxX = voxDim[0] * (volDim[0] - 1); - float maxY = voxDim[1] * (volDim[1] - 1); - float maxZ = voxDim[2] * (volZFull - 1); - float maxAxisVal = Math.max(maxX, Math.max(maxY, maxZ)); - - // Volume iteration - for (int z = 0; z < volDim[2] - 1; z++) { - for (int y = 0; y < volDim[1] - 1; y++) { - for (int x = 0; x < volDim[0] - 1; x++) { - - // Indices pointing to cube vertices - // pyz ___________________ pxyz - // /| /| - // / | / | - // / | / | - // pz /___|______________/pxz| - // | | | | - // | | | | - // | py |______________|___| pxy - // | / | / - // | / | / - // | / | / - // |/__________________|/ - // p px - - int p = x + (volDim[0] * y) + (volDim[0] * volDim[1] * (z + offset)), - px = p + 1, - py = p + volDim[0], - pxy = py + 1, - pz = p + volDim[0] * volDim[1], - pxz = px + volDim[0] * volDim[1], - pyz = py + volDim[0] * volDim[1], - pxyz = pxy + volDim[0] * volDim[1]; - - // X Y Z - float position[] = new float[]{x * voxDim[0], y * voxDim[1], (z + offset) * voxDim[2]}; - - // Voxel intensities - float value0 = values[p], - value1 = values[px], - value2 = values[py], - value3 = values[pxy], - value4 = values[pz], - value5 = values[pxz], - value6 = values[pyz], - value7 = values[pxyz]; - - // Voxel is active if its intensity is above isolevel - int cubeindex = 0; - if (value0 > isoLevel) cubeindex |= 1; - if (value1 > isoLevel) cubeindex |= 2; - if (value2 > isoLevel) cubeindex |= 8; - if (value3 > isoLevel) cubeindex |= 4; - if (value4 > isoLevel) cubeindex |= 16; - if (value5 > isoLevel) cubeindex |= 32; - if (value6 > isoLevel) cubeindex |= 128; - if (value7 > isoLevel) cubeindex |= 64; - - // Fetch the triggered edges - int bits = TablesMC.MC_EDGE_TABLE[cubeindex]; - - // If no edge is triggered... skip - if (bits == 0) continue; - - // Interpolate the positions based od voxel intensities - float mu = 0.5f; - - // bottom of the cube - if ((bits & 1) != 0) { - mu = (float) ((isoLevel - value0) / (value1 - value0)); - vertList[0] = lerp(position, new float[]{position[0] + voxDim[0], position[1], position[2]}, mu); - } - if ((bits & 2) != 0) { - mu = (float) ((isoLevel - value1) / (value3 - value1)); - vertList[1] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, mu); - } - if ((bits & 4) != 0) { - mu = (float) ((isoLevel - value2) / (value3 - value2)); - vertList[2] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, mu); - } - if ((bits & 8) != 0) { - mu = (float) ((isoLevel - value0) / (value2 - value0)); - vertList[3] = lerp(position, new float[]{position[0], position[1] + voxDim[1], position[2]}, mu); - } - // top of the cube - if ((bits & 16) != 0) { - mu = (float) ((isoLevel - value4) / (value5 - value4)); - vertList[4] = lerp(new float[]{position[0], position[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 32) != 0) { - mu = (float) ((isoLevel - value5) / (value7 - value5)); - vertList[5] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 64) != 0) { - mu = (float) ((isoLevel - value6) / (value7 - value6)); - vertList[6] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 128) != 0) { - mu = (float) ((isoLevel - value4) / (value6 - value4)); - vertList[7] = lerp(new float[]{position[0], position[1], position[2] + voxDim[2]}, new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); - } - // vertical lines of the cube - if ((bits & 256) != 0) { - mu = (float) ((isoLevel - value0) / (value4 - value0)); - vertList[8] = lerp(position, new float[]{position[0], position[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 512) != 0) { - mu = (float) ((isoLevel - value1) / (value5 - value1)); - vertList[9] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2]}, new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 1024) != 0) { - mu = (float) ((isoLevel - value3) / (value7 - value3)); - vertList[10] = lerp(new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, new float[]{position[0] + voxDim[0], position[1]+ voxDim[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 2048) != 0) { - mu = (float) ((isoLevel - value2) / (value6 - value2)); - vertList[11] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2]}, new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); - } - - // construct triangles -- get correct vertices from triTable. - int i = 0; - // "Re-purpose cubeindex into an offset into triTable." - cubeindex <<= 4; - - while (TablesMC.MC_TRI_TABLE[cubeindex + i] != -1) { - int index1 = TablesMC.MC_TRI_TABLE[cubeindex + i]; - int index2 = TablesMC.MC_TRI_TABLE[cubeindex + i + 1]; - int index3 = TablesMC.MC_TRI_TABLE[cubeindex + i + 2]; - - // Add triangles vertices normalized with the maximal possible value - vertices.add(new float[] {vertList[index3][0] / maxAxisVal - 0.5f, vertList[index3][1] / maxAxisVal - 0.5f, vertList[index3][2] / maxAxisVal - 0.5f}); - vertices.add(new float[] {vertList[index2][0] / maxAxisVal - 0.5f, vertList[index2][1] / maxAxisVal - 0.5f, vertList[index2][2] / maxAxisVal - 0.5f}); - vertices.add(new float[] {vertList[index1][0] / maxAxisVal - 0.5f, vertList[index1][1] / maxAxisVal - 0.5f, vertList[index1][2] / maxAxisVal - 0.5f}); - - i += 3; - } - } - } - } - - callback.setVertices(vertices); - callback.run(); - } - - static void marchingCubesDouble(double[] values, int[] volDim, int volZFull, float[] voxDim, double isoLevel, int offset, CallbackMC callback) { - - ArrayList vertices = new ArrayList<>(); - // Actual position along edge weighted according to function values. - float vertList[][] = new float[12][3]; - - - // Calculate maximal possible axis value (used in vertice normalization) - float maxX = voxDim[0] * (volDim[0] - 1); - float maxY = voxDim[1] * (volDim[1] - 1); - float maxZ = voxDim[2] * (volZFull - 1); - float maxAxisVal = Math.max(maxX, Math.max(maxY, maxZ)); - - // Volume iteration - for (int z = 0; z < volDim[2] - 1; z++) { - for (int y = 0; y < volDim[1] - 1; y++) { - for (int x = 0; x < volDim[0] - 1; x++) { - - // Indices pointing to cube vertices - // pyz ___________________ pxyz - // /| /| - // / | / | - // / | / | - // pz /___|______________/pxz| - // | | | | - // | | | | - // | py |______________|___| pxy - // | / | / - // | / | / - // | / | / - // |/__________________|/ - // p px - - int p = x + (volDim[0] * y) + (volDim[0] * volDim[1] * (z + offset)), - px = p + 1, - py = p + volDim[0], - pxy = py + 1, - pz = p + volDim[0] * volDim[1], - pxz = px + volDim[0] * volDim[1], - pyz = py + volDim[0] * volDim[1], - pxyz = pxy + volDim[0] * volDim[1]; - - // X Y Z - float position[] = new float[]{x * voxDim[0], y * voxDim[1], (z + offset) * voxDim[2]}; - - // Voxel intensities - double value0 = values[p], - value1 = values[px], - value2 = values[py], - value3 = values[pxy], - value4 = values[pz], - value5 = values[pxz], - value6 = values[pyz], - value7 = values[pxyz]; - - // Voxel is active if its intensity is above isolevel - int cubeindex = 0; - if (value0 > isoLevel) cubeindex |= 1; - if (value1 > isoLevel) cubeindex |= 2; - if (value2 > isoLevel) cubeindex |= 8; - if (value3 > isoLevel) cubeindex |= 4; - if (value4 > isoLevel) cubeindex |= 16; - if (value5 > isoLevel) cubeindex |= 32; - if (value6 > isoLevel) cubeindex |= 128; - if (value7 > isoLevel) cubeindex |= 64; - - // Fetch the triggered edges - int bits = TablesMC.MC_EDGE_TABLE[cubeindex]; - - // If no edge is triggered... skip - if (bits == 0) continue; - - // Interpolate the positions based od voxel intensities - float mu = 0.5f; - - // bottom of the cube - if ((bits & 1) != 0) { - mu = (float) ((isoLevel - value0) / (value1 - value0)); - vertList[0] = lerp(position, new float[]{position[0] + voxDim[0], position[1], position[2]}, mu); - } - if ((bits & 2) != 0) { - mu = (float) ((isoLevel - value1) / (value3 - value1)); - vertList[1] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, mu); - } - if ((bits & 4) != 0) { - mu = (float) ((isoLevel - value2) / (value3 - value2)); - vertList[2] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, mu); - } - if ((bits & 8) != 0) { - mu = (float) ((isoLevel - value0) / (value2 - value0)); - vertList[3] = lerp(position, new float[]{position[0], position[1] + voxDim[1], position[2]}, mu); - } - // top of the cube - if ((bits & 16) != 0) { - mu = (float) ((isoLevel - value4) / (value5 - value4)); - vertList[4] = lerp(new float[]{position[0], position[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 32) != 0) { - mu = (float) ((isoLevel - value5) / (value7 - value5)); - vertList[5] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 64) != 0) { - mu = (float) ((isoLevel - value6) / (value7 - value6)); - vertList[6] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 128) != 0) { - mu = (float) ((isoLevel - value4) / (value6 - value4)); - vertList[7] = lerp(new float[]{position[0], position[1], position[2] + voxDim[2]}, new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); - } - // vertical lines of the cube - if ((bits & 256) != 0) { - mu = (float) ((isoLevel - value0) / (value4 - value0)); - vertList[8] = lerp(position, new float[]{position[0], position[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 512) != 0) { - mu = (float) ((isoLevel - value1) / (value5 - value1)); - vertList[9] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2]}, new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 1024) != 0) { - mu = (float) ((isoLevel - value3) / (value7 - value3)); - vertList[10] = lerp(new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, new float[]{position[0] + voxDim[0], position[1]+ voxDim[1], position[2] + voxDim[2]}, mu); - } - if ((bits & 2048) != 0) { - mu = (float) ((isoLevel - value2) / (value6 - value2)); - vertList[11] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2]}, new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); - } - - // construct triangles -- get correct vertices from triTable. - int i = 0; - // "Re-purpose cubeindex into an offset into triTable." - cubeindex <<= 4; - - while (TablesMC.MC_TRI_TABLE[cubeindex + i] != -1) { - int index1 = TablesMC.MC_TRI_TABLE[cubeindex + i]; - int index2 = TablesMC.MC_TRI_TABLE[cubeindex + i + 1]; - int index3 = TablesMC.MC_TRI_TABLE[cubeindex + i + 2]; - - // Add triangles vertices normalized with the maximal possible value - vertices.add(new float[] {vertList[index3][0] / maxAxisVal - 0.5f, vertList[index3][1] / maxAxisVal - 0.5f, vertList[index3][2] / maxAxisVal - 0.5f}); - vertices.add(new float[] {vertList[index2][0] / maxAxisVal - 0.5f, vertList[index2][1] / maxAxisVal - 0.5f, vertList[index2][2] / maxAxisVal - 0.5f}); - vertices.add(new float[] {vertList[index1][0] / maxAxisVal - 0.5f, vertList[index1][1] / maxAxisVal - 0.5f, vertList[index1][2] / maxAxisVal - 0.5f}); - - i += 3; - } - } - } - } - - callback.setVertices(vertices); - callback.run(); - } - - public static ArrayList marchingCubes(Array values, Array xc, Array yc, Array zc, float isoLevel) { - - ArrayList vertices = new ArrayList<>(); - // Actual position along edge weighted according to function values. - float vertList[][] = new float[12][3]; - - int[] shape = values.getShape(); - int[] volDim = new int[]{shape[2], shape[1], shape[0]}; - - // Volume iteration - float xx, yy, zz; - for (int z = 0; z < volDim[2] - 1; z++) { - zz = zc.getFloat(z); - for (int y = 0; y < volDim[1] - 1; y++) { - yy = yc.getFloat(y); - for (int x = 0; x < volDim[0] - 1; x++) { - xx = xc.getFloat(x); - // Indices pointing to cube vertices - // pyz ___________________ pxyz - // /| /| - // / | / | - // / | / | - // pz /___|______________/pxz| - // | | | | - // | | | | - // | py |______________|___| pxy - // | / | / - // | / | / - // | / | / - // |/__________________|/ - // p px - - int p = x + (volDim[0] * y) + (volDim[0] * volDim[1] * z), - px = p + 1, - py = p + volDim[0], - pxy = py + 1, - pz = p + volDim[0] * volDim[1], - pxz = px + volDim[0] * volDim[1], - pyz = py + volDim[0] * volDim[1], - pxyz = pxy + volDim[0] * volDim[1]; - - // X, Y, Z position - //float position[] = new float[]{xx, yy, zz}; - - // Voxel intensities - float value0 = values.getFloat(p), - value1 = values.getFloat(px), - value2 = values.getFloat(py), - value3 = values.getFloat(pxy), - value4 = values.getFloat(pz), - value5 = values.getFloat(pxz), - value6 = values.getFloat(pyz), - value7 = values.getFloat(pxyz); - - // Voxel is active if its intensity is above isolevel - int cubeindex = 0; - if (value0 > isoLevel) cubeindex |= 1; - if (value1 > isoLevel) cubeindex |= 2; - if (value2 > isoLevel) cubeindex |= 8; - if (value3 > isoLevel) cubeindex |= 4; - if (value4 > isoLevel) cubeindex |= 16; - if (value5 > isoLevel) cubeindex |= 32; - if (value6 > isoLevel) cubeindex |= 128; - if (value7 > isoLevel) cubeindex |= 64; - - // Fetch the triggered edges - int bits = TablesMC.MC_EDGE_TABLE[cubeindex]; - - // If no edge is triggered... skip - if (bits == 0) continue; - - // Interpolate the positions based od voxel intensities - float mu = 0.5f; - - // bottom of the cube - if ((bits & 1) != 0) { - mu = (float) ((isoLevel - value0) / (value1 - value0)); - vertList[0] = lerp(new float[]{xx, yy, zz}, new float[]{xc.getFloat(x + 1), yy, zz}, mu); - } - if ((bits & 2) != 0) { - mu = (float) ((isoLevel - value1) / (value3 - value1)); - vertList[1] = lerp(new float[]{xc.getFloat(x + 1), yy, zz}, new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zz}, mu); - } - if ((bits & 4) != 0) { - mu = (float) ((isoLevel - value2) / (value3 - value2)); - vertList[2] = lerp(new float[]{xx, yc.getFloat(y + 1), zz}, new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zz}, mu); - } - if ((bits & 8) != 0) { - mu = (float) ((isoLevel - value0) / (value2 - value0)); - vertList[3] = lerp(new float[]{xx, yy, zz}, new float[]{xx, yc.getFloat(y + 1), zz}, mu); - } - // top of the cube - if ((bits & 16) != 0) { - mu = (float) ((isoLevel - value4) / (value5 - value4)); - vertList[4] = lerp(new float[]{xx, yy, zc.getFloat(z + 1)}, new float[]{xc.getFloat(x + 1), yy, zc.getFloat(z + 1)}, mu); - } - if ((bits & 32) != 0) { - mu = (float) ((isoLevel - value5) / (value7 - value5)); - vertList[5] = lerp(new float[]{xc.getFloat(x + 1), yy, zc.getFloat(z + 1)}, new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zc.getFloat(z + 1)}, mu); - } - if ((bits & 64) != 0) { - mu = (float) ((isoLevel - value6) / (value7 - value6)); - vertList[6] = lerp(new float[]{xx, yc.getFloat(y + 1), zc.getFloat(z + 1)}, new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zc.getFloat(z + 1)}, mu); - } - if ((bits & 128) != 0) { - mu = (float) ((isoLevel - value4) / (value6 - value4)); - vertList[7] = lerp(new float[]{xx, yy, zc.getFloat(z + 1)}, new float[]{xx, yc.getFloat(y + 1), zc.getFloat(z + 1)}, mu); - } - // vertical lines of the cube - if ((bits & 256) != 0) { - mu = (float) ((isoLevel - value0) / (value4 - value0)); - vertList[8] = lerp(new float[]{xx, yy, zz}, new float[]{xx, yy, zc.getFloat(z + 1)}, mu); - } - if ((bits & 512) != 0) { - mu = (float) ((isoLevel - value1) / (value5 - value1)); - vertList[9] = lerp(new float[]{xc.getFloat(x + 1), yy, zz}, new float[]{xc.getFloat(x + 1), yy, zc.getFloat(z + 1)}, mu); - } - if ((bits & 1024) != 0) { - mu = (float) ((isoLevel - value3) / (value7 - value3)); - vertList[10] = lerp(new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zz}, new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zc.getFloat(z + 1)}, mu); - } - if ((bits & 2048) != 0) { - mu = (float) ((isoLevel - value2) / (value6 - value2)); - vertList[11] = lerp(new float[]{xx, yc.getFloat(y + 1), zz}, new float[]{xx, yc.getFloat(y + 1), zc.getFloat(z + 1)}, mu); - } - - // construct triangles -- get correct vertices from triTable. - int i = 0; - // "Re-purpose cubeindex into an offset into triTable." - cubeindex <<= 4; - - while (TablesMC.MC_TRI_TABLE[cubeindex + i] != -1) { - int index1 = TablesMC.MC_TRI_TABLE[cubeindex + i]; - int index2 = TablesMC.MC_TRI_TABLE[cubeindex + i + 1]; - int index3 = TablesMC.MC_TRI_TABLE[cubeindex + i + 2]; - - // Add triangles vertices - vertices.add(new float[] {vertList[index3][0], vertList[index3][1], vertList[index3][2]}); - vertices.add(new float[] {vertList[index2][0], vertList[index2][1], vertList[index2][2]}); - vertices.add(new float[] {vertList[index1][0], vertList[index1][1], vertList[index1][2]}); - - i += 3; - } - } - } - } - - return vertices; - } - - public static void marchingCubes(Array values, Array xc, Array yc, Array zc, float isoLevel, - int len, int offset, CallbackMC callback) { - - ArrayList vertices = new ArrayList<>(); - // Actual position along edge weighted according to function values. - float vertList[][] = new float[12][3]; - - int[] shape = values.getShape(); - int[] volDim = new int[]{shape[2], shape[1], len}; - - // Volume iteration - float xx, yy, zz; - for (int z = offset; z < volDim[2] - 1 + offset; z++) { - zz = zc.getFloat(z); - for (int y = 0; y < volDim[1] - 1; y++) { - yy = yc.getFloat(y); - for (int x = 0; x < volDim[0] - 1; x++) { - xx = xc.getFloat(x); - // Indices pointing to cube vertices - // pyz ___________________ pxyz - // /| /| - // / | / | - // / | / | - // pz /___|______________/pxz| - // | | | | - // | | | | - // | py |______________|___| pxy - // | / | / - // | / | / - // | / | / - // |/__________________|/ - // p px - - int p = x + (volDim[0] * y) + (volDim[0] * volDim[1] * z), - px = p + 1, - py = p + volDim[0], - pxy = py + 1, - pz = p + volDim[0] * volDim[1], - pxz = px + volDim[0] * volDim[1], - pyz = py + volDim[0] * volDim[1], - pxyz = pxy + volDim[0] * volDim[1]; - - // X, Y, Z position - //float position[] = new float[]{xx, yy, zz}; - - // Voxel intensities - float value0 = values.getFloat(p), - value1 = values.getFloat(px), - value2 = values.getFloat(py), - value3 = values.getFloat(pxy), - value4 = values.getFloat(pz), - value5 = values.getFloat(pxz), - value6 = values.getFloat(pyz), - value7 = values.getFloat(pxyz); - - // Voxel is active if its intensity is above isolevel - int cubeindex = 0; - if (value0 > isoLevel) cubeindex |= 1; - if (value1 > isoLevel) cubeindex |= 2; - if (value2 > isoLevel) cubeindex |= 8; - if (value3 > isoLevel) cubeindex |= 4; - if (value4 > isoLevel) cubeindex |= 16; - if (value5 > isoLevel) cubeindex |= 32; - if (value6 > isoLevel) cubeindex |= 128; - if (value7 > isoLevel) cubeindex |= 64; - - // Fetch the triggered edges - int bits = TablesMC.MC_EDGE_TABLE[cubeindex]; - - // If no edge is triggered... skip - if (bits == 0) continue; - - // Interpolate the positions based od voxel intensities - float mu = 0.5f; - - // bottom of the cube - if ((bits & 1) != 0) { - mu = (float) ((isoLevel - value0) / (value1 - value0)); - vertList[0] = lerp(new float[]{xx, yy, zz}, new float[]{xc.getFloat(x + 1), yy, zz}, mu); - } - if ((bits & 2) != 0) { - mu = (float) ((isoLevel - value1) / (value3 - value1)); - vertList[1] = lerp(new float[]{xc.getFloat(x + 1), yy, zz}, new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zz}, mu); - } - if ((bits & 4) != 0) { - mu = (float) ((isoLevel - value2) / (value3 - value2)); - vertList[2] = lerp(new float[]{xx, yc.getFloat(y + 1), zz}, new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zz}, mu); - } - if ((bits & 8) != 0) { - mu = (float) ((isoLevel - value0) / (value2 - value0)); - vertList[3] = lerp(new float[]{xx, yy, zz}, new float[]{xx, yc.getFloat(y + 1), zz}, mu); - } - // top of the cube - if ((bits & 16) != 0) { - mu = (float) ((isoLevel - value4) / (value5 - value4)); - vertList[4] = lerp(new float[]{xx, yy, zc.getFloat(z + 1)}, new float[]{xc.getFloat(x + 1), yy, zc.getFloat(z + 1)}, mu); - } - if ((bits & 32) != 0) { - mu = (float) ((isoLevel - value5) / (value7 - value5)); - vertList[5] = lerp(new float[]{xc.getFloat(x + 1), yy, zc.getFloat(z + 1)}, new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zc.getFloat(z + 1)}, mu); - } - if ((bits & 64) != 0) { - mu = (float) ((isoLevel - value6) / (value7 - value6)); - vertList[6] = lerp(new float[]{xx, yc.getFloat(y + 1), zc.getFloat(z + 1)}, new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zc.getFloat(z + 1)}, mu); - } - if ((bits & 128) != 0) { - mu = (float) ((isoLevel - value4) / (value6 - value4)); - vertList[7] = lerp(new float[]{xx, yy, zc.getFloat(z + 1)}, new float[]{xx, yc.getFloat(y + 1), zc.getFloat(z + 1)}, mu); - } - // vertical lines of the cube - if ((bits & 256) != 0) { - mu = (float) ((isoLevel - value0) / (value4 - value0)); - vertList[8] = lerp(new float[]{xx, yy, zz}, new float[]{xx, yy, zc.getFloat(z + 1)}, mu); - } - if ((bits & 512) != 0) { - mu = (float) ((isoLevel - value1) / (value5 - value1)); - vertList[9] = lerp(new float[]{xc.getFloat(x + 1), yy, zz}, new float[]{xc.getFloat(x + 1), yy, zc.getFloat(z + 1)}, mu); - } - if ((bits & 1024) != 0) { - mu = (float) ((isoLevel - value3) / (value7 - value3)); - vertList[10] = lerp(new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zz}, new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zc.getFloat(z + 1)}, mu); - } - if ((bits & 2048) != 0) { - mu = (float) ((isoLevel - value2) / (value6 - value2)); - vertList[11] = lerp(new float[]{xx, yc.getFloat(y + 1), zz}, new float[]{xx, yc.getFloat(y + 1), zc.getFloat(z + 1)}, mu); - } - - // construct triangles -- get correct vertices from triTable. - int i = 0; - // "Re-purpose cubeindex into an offset into triTable." - cubeindex <<= 4; - - while (TablesMC.MC_TRI_TABLE[cubeindex + i] != -1) { - int index1 = TablesMC.MC_TRI_TABLE[cubeindex + i]; - int index2 = TablesMC.MC_TRI_TABLE[cubeindex + i + 1]; - int index3 = TablesMC.MC_TRI_TABLE[cubeindex + i + 2]; - - // Add triangles vertices - vertices.add(new float[] {vertList[index3][0], vertList[index3][1], vertList[index3][2]}); - vertices.add(new float[] {vertList[index2][0], vertList[index2][1], vertList[index2][2]}); - vertices.add(new float[] {vertList[index1][0], vertList[index1][1], vertList[index1][2]}); - - i += 3; - } - } - } - } - - callback.setVertices(vertices); - callback.run(); - } -} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.meteoinfo.chart.jogl.mc; + +import org.meteoinfo.ndarray.Array; + +import java.util.ArrayList; + +/** + * Created by Primoz on 11. 07. 2016. + */ +public class MarchingCubes { + static float[] lerp(float[] vec1, float[] vec2, float alpha){ + return new float[]{vec1[0] + (vec2[0] - vec1[0]) * alpha, vec1[1] + (vec2[1] - vec1[1]) * alpha, vec1[2] + (vec2[2] - vec1[2]) * alpha}; + } + + static void marchingCubesChar(char[] values, int[] volDim, int volZFull, float[] voxDim, char isoLevel, int offset, CallbackMC callback) { + + ArrayList vertices = new ArrayList<>(); + // Actual position along edge weighted according to function values. + float vertList[][] = new float[12][3]; + + + // Calculate maximal possible axis value (used in vertice normalization) + float maxX = voxDim[0] * (volDim[0] - 1); + float maxY = voxDim[1] * (volDim[1] - 1); + float maxZ = voxDim[2] * (volZFull - 1); + float maxAxisVal = Math.max(maxX, Math.max(maxY, maxZ)); + + // Volume iteration + for (int z = 0; z < volDim[2] - 1; z++) { + for (int y = 0; y < volDim[1] - 1; y++) { + for (int x = 0; x < volDim[0] - 1; x++) { + + // Indices pointing to cube vertices + // pyz ___________________ pxyz + // /| /| + // / | / | + // / | / | + // pz /___|______________/pxz| + // | | | | + // | | | | + // | py |______________|___| pxy + // | / | / + // | / | / + // | / | / + // |/__________________|/ + // p px + + int p = x + (volDim[0] * y) + (volDim[0] * volDim[1] * (z + offset)), + px = p + 1, + py = p + volDim[0], + pxy = py + 1, + pz = p + volDim[0] * volDim[1], + pxz = px + volDim[0] * volDim[1], + pyz = py + volDim[0] * volDim[1], + pxyz = pxy + volDim[0] * volDim[1]; + + // X Y Z + float position[] = new float[]{x * voxDim[0], y * voxDim[1], (z + offset) * voxDim[2]}; + + // Voxel intensities + char value0 = values[p], + value1 = values[px], + value2 = values[py], + value3 = values[pxy], + value4 = values[pz], + value5 = values[pxz], + value6 = values[pyz], + value7 = values[pxyz]; + + // Voxel is active if its intensity is above isolevel + int cubeindex = 0; + if (value0 > isoLevel) cubeindex |= 1; + if (value1 > isoLevel) cubeindex |= 2; + if (value2 > isoLevel) cubeindex |= 8; + if (value3 > isoLevel) cubeindex |= 4; + if (value4 > isoLevel) cubeindex |= 16; + if (value5 > isoLevel) cubeindex |= 32; + if (value6 > isoLevel) cubeindex |= 128; + if (value7 > isoLevel) cubeindex |= 64; + + // Fetch the triggered edges + int bits = TablesMC.MC_EDGE_TABLE[cubeindex]; + + // If no edge is triggered... skip + if (bits == 0) continue; + + // Interpolate the positions based od voxel intensities + float mu = 0.5f; + + // bottom of the cube + if ((bits & 1) != 0) { + mu = (isoLevel - value0) / (value1 - value0); + vertList[0] = lerp(position, new float[]{position[0] + voxDim[0], position[1], position[2]}, mu); + } + if ((bits & 2) != 0) { + mu = (isoLevel - value1) / (value3 - value1); + vertList[1] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, mu); + } + if ((bits & 4) != 0) { + mu = (isoLevel - value2) / (value3 - value2); + vertList[2] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, mu); + } + if ((bits & 8) != 0) { + mu = (isoLevel - value0) / (value2 - value0); + vertList[3] = lerp(position, new float[]{position[0], position[1] + voxDim[1], position[2]}, mu); + } + // top of the cube + if ((bits & 16) != 0) { + mu = (isoLevel - value4) / (value5 - value4); + vertList[4] = lerp(new float[]{position[0], position[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 32) != 0) { + mu = (isoLevel - value5) / (value7 - value5); + vertList[5] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 64) != 0) { + mu = (isoLevel - value6) / (value7 - value6); + vertList[6] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 128) != 0) { + mu = (isoLevel - value4) / (value6 - value4); + vertList[7] = lerp(new float[]{position[0], position[1], position[2] + voxDim[2]}, new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); + } + // vertical lines of the cube + if ((bits & 256) != 0) { + mu = (isoLevel - value0) / (value4 - value0); + vertList[8] = lerp(position, new float[]{position[0], position[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 512) != 0) { + mu = (isoLevel - value1) / (value5 - value1); + vertList[9] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2]}, new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 1024) != 0) { + mu = (isoLevel - value3) / (value7 - value3); + vertList[10] = lerp(new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, new float[]{position[0] + voxDim[0], position[1]+ voxDim[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 2048) != 0) { + mu = (isoLevel - value2) / (value6 - value2); + vertList[11] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2]}, new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); + } + + // construct triangles -- get correct vertices from triTable. + int i = 0; + // "Re-purpose cubeindex into an offset into triTable." + cubeindex <<= 4; + + while (TablesMC.MC_TRI_TABLE[cubeindex + i] != -1) { + int index1 = TablesMC.MC_TRI_TABLE[cubeindex + i]; + int index2 = TablesMC.MC_TRI_TABLE[cubeindex + i + 1]; + int index3 = TablesMC.MC_TRI_TABLE[cubeindex + i + 2]; + + // Add triangles vertices normalized with the maximal possible value + vertices.add(new float[] {vertList[index3][0] / maxAxisVal - 0.5f, vertList[index3][1] / maxAxisVal - 0.5f, vertList[index3][2] / maxAxisVal - 0.5f}); + vertices.add(new float[] {vertList[index2][0] / maxAxisVal - 0.5f, vertList[index2][1] / maxAxisVal - 0.5f, vertList[index2][2] / maxAxisVal - 0.5f}); + vertices.add(new float[] {vertList[index1][0] / maxAxisVal - 0.5f, vertList[index1][1] / maxAxisVal - 0.5f, vertList[index1][2] / maxAxisVal - 0.5f}); + + i += 3; + } + } + } + } + + callback.setVertices(vertices); + callback.run(); + } + + static void marchingCubesShort(short[] values, int[] volDim, int volZFull, float[] voxDim, short isoLevel, int offset, CallbackMC callback) { + + ArrayList vertices = new ArrayList<>(); + // Actual position along edge weighted according to function values. + float vertList[][] = new float[12][3]; + + + // Calculate maximal possible axis value (used in vertice normalization) + float maxX = voxDim[0] * (volDim[0] - 1); + float maxY = voxDim[1] * (volDim[1] - 1); + float maxZ = voxDim[2] * (volZFull - 1); + float maxAxisVal = Math.max(maxX, Math.max(maxY, maxZ)); + + // Volume iteration + for (int z = 0; z < volDim[2] - 1; z++) { + for (int y = 0; y < volDim[1] - 1; y++) { + for (int x = 0; x < volDim[0] - 1; x++) { + + // Indices pointing to cube vertices + // pyz ___________________ pxyz + // /| /| + // / | / | + // / | / | + // pz /___|______________/pxz| + // | | | | + // | | | | + // | py |______________|___| pxy + // | / | / + // | / | / + // | / | / + // |/__________________|/ + // p px + + int p = x + (volDim[0] * y) + (volDim[0] * volDim[1] * (z + offset)), + px = p + 1, + py = p + volDim[0], + pxy = py + 1, + pz = p + volDim[0] * volDim[1], + pxz = px + volDim[0] * volDim[1], + pyz = py + volDim[0] * volDim[1], + pxyz = pxy + volDim[0] * volDim[1]; + + // X Y Z + float position[] = new float[]{x * voxDim[0], y * voxDim[1], (z + offset) * voxDim[2]}; + + // Voxel intensities + short value0 = values[p], + value1 = values[px], + value2 = values[py], + value3 = values[pxy], + value4 = values[pz], + value5 = values[pxz], + value6 = values[pyz], + value7 = values[pxyz]; + + // Voxel is active if its intensity is above isolevel + int cubeindex = 0; + if (value0 > isoLevel) cubeindex |= 1; + if (value1 > isoLevel) cubeindex |= 2; + if (value2 > isoLevel) cubeindex |= 8; + if (value3 > isoLevel) cubeindex |= 4; + if (value4 > isoLevel) cubeindex |= 16; + if (value5 > isoLevel) cubeindex |= 32; + if (value6 > isoLevel) cubeindex |= 128; + if (value7 > isoLevel) cubeindex |= 64; + + // Fetch the triggered edges + int bits = TablesMC.MC_EDGE_TABLE[cubeindex]; + + // If no edge is triggered... skip + if (bits == 0) continue; + + // Interpolate the positions based od voxel intensities + float mu = 0.5f; + + // bottom of the cube + if ((bits & 1) != 0) { + mu = (isoLevel - value0) / (value1 - value0); + vertList[0] = lerp(position, new float[]{position[0] + voxDim[0], position[1], position[2]}, mu); + } + if ((bits & 2) != 0) { + mu = (isoLevel - value1) / (value3 - value1); + vertList[1] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, mu); + } + if ((bits & 4) != 0) { + mu = (isoLevel - value2) / (value3 - value2); + vertList[2] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, mu); + } + if ((bits & 8) != 0) { + mu = (isoLevel - value0) / (value2 - value0); + vertList[3] = lerp(position, new float[]{position[0], position[1] + voxDim[1], position[2]}, mu); + } + // top of the cube + if ((bits & 16) != 0) { + mu = (isoLevel - value4) / (value5 - value4); + vertList[4] = lerp(new float[]{position[0], position[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 32) != 0) { + mu = (isoLevel - value5) / (value7 - value5); + vertList[5] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 64) != 0) { + mu = (isoLevel - value6) / (value7 - value6); + vertList[6] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 128) != 0) { + mu = (isoLevel - value4) / (value6 - value4); + vertList[7] = lerp(new float[]{position[0], position[1], position[2] + voxDim[2]}, new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); + } + // vertical lines of the cube + if ((bits & 256) != 0) { + mu = (isoLevel - value0) / (value4 - value0); + vertList[8] = lerp(position, new float[]{position[0], position[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 512) != 0) { + mu = (isoLevel - value1) / (value5 - value1); + vertList[9] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2]}, new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 1024) != 0) { + mu = (isoLevel - value3) / (value7 - value3); + vertList[10] = lerp(new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, new float[]{position[0] + voxDim[0], position[1]+ voxDim[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 2048) != 0) { + mu = (isoLevel - value2) / (value6 - value2); + vertList[11] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2]}, new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); + } + + // construct triangles -- get correct vertices from triTable. + int i = 0; + // "Re-purpose cubeindex into an offset into triTable." + cubeindex <<= 4; + + while (TablesMC.MC_TRI_TABLE[cubeindex + i] != -1) { + int index1 = TablesMC.MC_TRI_TABLE[cubeindex + i]; + int index2 = TablesMC.MC_TRI_TABLE[cubeindex + i + 1]; + int index3 = TablesMC.MC_TRI_TABLE[cubeindex + i + 2]; + + // Add triangles vertices normalized with the maximal possible value + vertices.add(new float[] {vertList[index3][0] / maxAxisVal - 0.5f, vertList[index3][1] / maxAxisVal - 0.5f, vertList[index3][2] / maxAxisVal - 0.5f}); + vertices.add(new float[] {vertList[index2][0] / maxAxisVal - 0.5f, vertList[index2][1] / maxAxisVal - 0.5f, vertList[index2][2] / maxAxisVal - 0.5f}); + vertices.add(new float[] {vertList[index1][0] / maxAxisVal - 0.5f, vertList[index1][1] / maxAxisVal - 0.5f, vertList[index1][2] / maxAxisVal - 0.5f}); + + i += 3; + } + } + } + } + + callback.setVertices(vertices); + callback.run(); + } + + static void marchingCubesInt(int[] values, int[] volDim, int volZFull, float[] voxDim, int isoLevel, int offset, CallbackMC callback) { + + ArrayList vertices = new ArrayList<>(); + // Actual position along edge weighted according to function values. + float vertList[][] = new float[12][3]; + + + // Calculate maximal possible axis value (used in vertice normalization) + float maxX = voxDim[0] * (volDim[0] - 1); + float maxY = voxDim[1] * (volDim[1] - 1); + float maxZ = voxDim[2] * (volZFull - 1); + float maxAxisVal = Math.max(maxX, Math.max(maxY, maxZ)); + + // Volume iteration + for (int z = 0; z < volDim[2] - 1; z++) { + for (int y = 0; y < volDim[1] - 1; y++) { + for (int x = 0; x < volDim[0] - 1; x++) { + + // Indices pointing to cube vertices + // pyz ___________________ pxyz + // /| /| + // / | / | + // / | / | + // pz /___|______________/pxz| + // | | | | + // | | | | + // | py |______________|___| pxy + // | / | / + // | / | / + // | / | / + // |/__________________|/ + // p px + + int p = x + (volDim[0] * y) + (volDim[0] * volDim[1] * (z + offset)), + px = p + 1, + py = p + volDim[0], + pxy = py + 1, + pz = p + volDim[0] * volDim[1], + pxz = px + volDim[0] * volDim[1], + pyz = py + volDim[0] * volDim[1], + pxyz = pxy + volDim[0] * volDim[1]; + + // X Y Z + float position[] = new float[]{x * voxDim[0], y * voxDim[1], (z + offset) * voxDim[2]}; + + // Voxel intensities + int value0 = values[p], + value1 = values[px], + value2 = values[py], + value3 = values[pxy], + value4 = values[pz], + value5 = values[pxz], + value6 = values[pyz], + value7 = values[pxyz]; + + // Voxel is active if its intensity is above isolevel + int cubeindex = 0; + if (value0 > isoLevel) cubeindex |= 1; + if (value1 > isoLevel) cubeindex |= 2; + if (value2 > isoLevel) cubeindex |= 8; + if (value3 > isoLevel) cubeindex |= 4; + if (value4 > isoLevel) cubeindex |= 16; + if (value5 > isoLevel) cubeindex |= 32; + if (value6 > isoLevel) cubeindex |= 128; + if (value7 > isoLevel) cubeindex |= 64; + + // Fetch the triggered edges + int bits = TablesMC.MC_EDGE_TABLE[cubeindex]; + + // If no edge is triggered... skip + if (bits == 0) continue; + + // Interpolate the positions based od voxel intensities + float mu = 0.5f; + + // bottom of the cube + if ((bits & 1) != 0) { + mu = (isoLevel - value0) / (value1 - value0); + vertList[0] = lerp(position, new float[]{position[0] + voxDim[0], position[1], position[2]}, mu); + } + if ((bits & 2) != 0) { + mu = (isoLevel - value1) / (value3 - value1); + vertList[1] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, mu); + } + if ((bits & 4) != 0) { + mu = (isoLevel - value2) / (value3 - value2); + vertList[2] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, mu); + } + if ((bits & 8) != 0) { + mu = (isoLevel - value0) / (value2 - value0); + vertList[3] = lerp(position, new float[]{position[0], position[1] + voxDim[1], position[2]}, mu); + } + // top of the cube + if ((bits & 16) != 0) { + mu = (isoLevel - value4) / (value5 - value4); + vertList[4] = lerp(new float[]{position[0], position[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 32) != 0) { + mu = (isoLevel - value5) / (value7 - value5); + vertList[5] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 64) != 0) { + mu = (isoLevel - value6) / (value7 - value6); + vertList[6] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 128) != 0) { + mu = (isoLevel - value4) / (value6 - value4); + vertList[7] = lerp(new float[]{position[0], position[1], position[2] + voxDim[2]}, new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); + } + // vertical lines of the cube + if ((bits & 256) != 0) { + mu = (isoLevel - value0) / (value4 - value0); + vertList[8] = lerp(position, new float[]{position[0], position[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 512) != 0) { + mu = (isoLevel - value1) / (value5 - value1); + vertList[9] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2]}, new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 1024) != 0) { + mu = (isoLevel - value3) / (value7 - value3); + vertList[10] = lerp(new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, new float[]{position[0] + voxDim[0], position[1]+ voxDim[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 2048) != 0) { + mu = (isoLevel - value2) / (value6 - value2); + vertList[11] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2]}, new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); + } + + // construct triangles -- get correct vertices from triTable. + int i = 0; + // "Re-purpose cubeindex into an offset into triTable." + cubeindex <<= 4; + + while (TablesMC.MC_TRI_TABLE[cubeindex + i] != -1) { + int index1 = TablesMC.MC_TRI_TABLE[cubeindex + i]; + int index2 = TablesMC.MC_TRI_TABLE[cubeindex + i + 1]; + int index3 = TablesMC.MC_TRI_TABLE[cubeindex + i + 2]; + + // Add triangles vertices normalized with the maximal possible value + vertices.add(new float[] {vertList[index3][0] / maxAxisVal - 0.5f, vertList[index3][1] / maxAxisVal - 0.5f, vertList[index3][2] / maxAxisVal - 0.5f}); + vertices.add(new float[] {vertList[index2][0] / maxAxisVal - 0.5f, vertList[index2][1] / maxAxisVal - 0.5f, vertList[index2][2] / maxAxisVal - 0.5f}); + vertices.add(new float[] {vertList[index1][0] / maxAxisVal - 0.5f, vertList[index1][1] / maxAxisVal - 0.5f, vertList[index1][2] / maxAxisVal - 0.5f}); + + i += 3; + } + } + } + } + + callback.setVertices(vertices); + callback.run(); + } + + static void marchingCubesFloat(float[] values, int[] volDim, int volZFull, float[] voxDim, float isoLevel, int offset, CallbackMC callback) { + + ArrayList vertices = new ArrayList<>(); + // Actual position along edge weighted according to function values. + float vertList[][] = new float[12][3]; + + + // Calculate maximal possible axis value (used in vertice normalization) + float maxX = voxDim[0] * (volDim[0] - 1); + float maxY = voxDim[1] * (volDim[1] - 1); + float maxZ = voxDim[2] * (volZFull - 1); + float maxAxisVal = Math.max(maxX, Math.max(maxY, maxZ)); + + // Volume iteration + for (int z = 0; z < volDim[2] - 1; z++) { + for (int y = 0; y < volDim[1] - 1; y++) { + for (int x = 0; x < volDim[0] - 1; x++) { + + // Indices pointing to cube vertices + // pyz ___________________ pxyz + // /| /| + // / | / | + // / | / | + // pz /___|______________/pxz| + // | | | | + // | | | | + // | py |______________|___| pxy + // | / | / + // | / | / + // | / | / + // |/__________________|/ + // p px + + int p = x + (volDim[0] * y) + (volDim[0] * volDim[1] * (z + offset)), + px = p + 1, + py = p + volDim[0], + pxy = py + 1, + pz = p + volDim[0] * volDim[1], + pxz = px + volDim[0] * volDim[1], + pyz = py + volDim[0] * volDim[1], + pxyz = pxy + volDim[0] * volDim[1]; + + // X Y Z + float position[] = new float[]{x * voxDim[0], y * voxDim[1], (z + offset) * voxDim[2]}; + + // Voxel intensities + float value0 = values[p], + value1 = values[px], + value2 = values[py], + value3 = values[pxy], + value4 = values[pz], + value5 = values[pxz], + value6 = values[pyz], + value7 = values[pxyz]; + + // Voxel is active if its intensity is above isolevel + int cubeindex = 0; + if (value0 > isoLevel) cubeindex |= 1; + if (value1 > isoLevel) cubeindex |= 2; + if (value2 > isoLevel) cubeindex |= 8; + if (value3 > isoLevel) cubeindex |= 4; + if (value4 > isoLevel) cubeindex |= 16; + if (value5 > isoLevel) cubeindex |= 32; + if (value6 > isoLevel) cubeindex |= 128; + if (value7 > isoLevel) cubeindex |= 64; + + // Fetch the triggered edges + int bits = TablesMC.MC_EDGE_TABLE[cubeindex]; + + // If no edge is triggered... skip + if (bits == 0) continue; + + // Interpolate the positions based od voxel intensities + float mu = 0.5f; + + // bottom of the cube + if ((bits & 1) != 0) { + mu = (float) ((isoLevel - value0) / (value1 - value0)); + vertList[0] = lerp(position, new float[]{position[0] + voxDim[0], position[1], position[2]}, mu); + } + if ((bits & 2) != 0) { + mu = (float) ((isoLevel - value1) / (value3 - value1)); + vertList[1] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, mu); + } + if ((bits & 4) != 0) { + mu = (float) ((isoLevel - value2) / (value3 - value2)); + vertList[2] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, mu); + } + if ((bits & 8) != 0) { + mu = (float) ((isoLevel - value0) / (value2 - value0)); + vertList[3] = lerp(position, new float[]{position[0], position[1] + voxDim[1], position[2]}, mu); + } + // top of the cube + if ((bits & 16) != 0) { + mu = (float) ((isoLevel - value4) / (value5 - value4)); + vertList[4] = lerp(new float[]{position[0], position[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 32) != 0) { + mu = (float) ((isoLevel - value5) / (value7 - value5)); + vertList[5] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 64) != 0) { + mu = (float) ((isoLevel - value6) / (value7 - value6)); + vertList[6] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 128) != 0) { + mu = (float) ((isoLevel - value4) / (value6 - value4)); + vertList[7] = lerp(new float[]{position[0], position[1], position[2] + voxDim[2]}, new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); + } + // vertical lines of the cube + if ((bits & 256) != 0) { + mu = (float) ((isoLevel - value0) / (value4 - value0)); + vertList[8] = lerp(position, new float[]{position[0], position[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 512) != 0) { + mu = (float) ((isoLevel - value1) / (value5 - value1)); + vertList[9] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2]}, new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 1024) != 0) { + mu = (float) ((isoLevel - value3) / (value7 - value3)); + vertList[10] = lerp(new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, new float[]{position[0] + voxDim[0], position[1]+ voxDim[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 2048) != 0) { + mu = (float) ((isoLevel - value2) / (value6 - value2)); + vertList[11] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2]}, new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); + } + + // construct triangles -- get correct vertices from triTable. + int i = 0; + // "Re-purpose cubeindex into an offset into triTable." + cubeindex <<= 4; + + while (TablesMC.MC_TRI_TABLE[cubeindex + i] != -1) { + int index1 = TablesMC.MC_TRI_TABLE[cubeindex + i]; + int index2 = TablesMC.MC_TRI_TABLE[cubeindex + i + 1]; + int index3 = TablesMC.MC_TRI_TABLE[cubeindex + i + 2]; + + // Add triangles vertices normalized with the maximal possible value + vertices.add(new float[] {vertList[index3][0] / maxAxisVal - 0.5f, vertList[index3][1] / maxAxisVal - 0.5f, vertList[index3][2] / maxAxisVal - 0.5f}); + vertices.add(new float[] {vertList[index2][0] / maxAxisVal - 0.5f, vertList[index2][1] / maxAxisVal - 0.5f, vertList[index2][2] / maxAxisVal - 0.5f}); + vertices.add(new float[] {vertList[index1][0] / maxAxisVal - 0.5f, vertList[index1][1] / maxAxisVal - 0.5f, vertList[index1][2] / maxAxisVal - 0.5f}); + + i += 3; + } + } + } + } + + callback.setVertices(vertices); + callback.run(); + } + + static void marchingCubesDouble(double[] values, int[] volDim, int volZFull, float[] voxDim, double isoLevel, int offset, CallbackMC callback) { + + ArrayList vertices = new ArrayList<>(); + // Actual position along edge weighted according to function values. + float vertList[][] = new float[12][3]; + + + // Calculate maximal possible axis value (used in vertice normalization) + float maxX = voxDim[0] * (volDim[0] - 1); + float maxY = voxDim[1] * (volDim[1] - 1); + float maxZ = voxDim[2] * (volZFull - 1); + float maxAxisVal = Math.max(maxX, Math.max(maxY, maxZ)); + + // Volume iteration + for (int z = 0; z < volDim[2] - 1; z++) { + for (int y = 0; y < volDim[1] - 1; y++) { + for (int x = 0; x < volDim[0] - 1; x++) { + + // Indices pointing to cube vertices + // pyz ___________________ pxyz + // /| /| + // / | / | + // / | / | + // pz /___|______________/pxz| + // | | | | + // | | | | + // | py |______________|___| pxy + // | / | / + // | / | / + // | / | / + // |/__________________|/ + // p px + + int p = x + (volDim[0] * y) + (volDim[0] * volDim[1] * (z + offset)), + px = p + 1, + py = p + volDim[0], + pxy = py + 1, + pz = p + volDim[0] * volDim[1], + pxz = px + volDim[0] * volDim[1], + pyz = py + volDim[0] * volDim[1], + pxyz = pxy + volDim[0] * volDim[1]; + + // X Y Z + float position[] = new float[]{x * voxDim[0], y * voxDim[1], (z + offset) * voxDim[2]}; + + // Voxel intensities + double value0 = values[p], + value1 = values[px], + value2 = values[py], + value3 = values[pxy], + value4 = values[pz], + value5 = values[pxz], + value6 = values[pyz], + value7 = values[pxyz]; + + // Voxel is active if its intensity is above isolevel + int cubeindex = 0; + if (value0 > isoLevel) cubeindex |= 1; + if (value1 > isoLevel) cubeindex |= 2; + if (value2 > isoLevel) cubeindex |= 8; + if (value3 > isoLevel) cubeindex |= 4; + if (value4 > isoLevel) cubeindex |= 16; + if (value5 > isoLevel) cubeindex |= 32; + if (value6 > isoLevel) cubeindex |= 128; + if (value7 > isoLevel) cubeindex |= 64; + + // Fetch the triggered edges + int bits = TablesMC.MC_EDGE_TABLE[cubeindex]; + + // If no edge is triggered... skip + if (bits == 0) continue; + + // Interpolate the positions based od voxel intensities + float mu = 0.5f; + + // bottom of the cube + if ((bits & 1) != 0) { + mu = (float) ((isoLevel - value0) / (value1 - value0)); + vertList[0] = lerp(position, new float[]{position[0] + voxDim[0], position[1], position[2]}, mu); + } + if ((bits & 2) != 0) { + mu = (float) ((isoLevel - value1) / (value3 - value1)); + vertList[1] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, mu); + } + if ((bits & 4) != 0) { + mu = (float) ((isoLevel - value2) / (value3 - value2)); + vertList[2] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, mu); + } + if ((bits & 8) != 0) { + mu = (float) ((isoLevel - value0) / (value2 - value0)); + vertList[3] = lerp(position, new float[]{position[0], position[1] + voxDim[1], position[2]}, mu); + } + // top of the cube + if ((bits & 16) != 0) { + mu = (float) ((isoLevel - value4) / (value5 - value4)); + vertList[4] = lerp(new float[]{position[0], position[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 32) != 0) { + mu = (float) ((isoLevel - value5) / (value7 - value5)); + vertList[5] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 64) != 0) { + mu = (float) ((isoLevel - value6) / (value7 - value6)); + vertList[6] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 128) != 0) { + mu = (float) ((isoLevel - value4) / (value6 - value4)); + vertList[7] = lerp(new float[]{position[0], position[1], position[2] + voxDim[2]}, new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); + } + // vertical lines of the cube + if ((bits & 256) != 0) { + mu = (float) ((isoLevel - value0) / (value4 - value0)); + vertList[8] = lerp(position, new float[]{position[0], position[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 512) != 0) { + mu = (float) ((isoLevel - value1) / (value5 - value1)); + vertList[9] = lerp(new float[]{position[0] + voxDim[0], position[1], position[2]}, new float[]{position[0] + voxDim[0], position[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 1024) != 0) { + mu = (float) ((isoLevel - value3) / (value7 - value3)); + vertList[10] = lerp(new float[]{position[0] + voxDim[0], position[1] + voxDim[1], position[2]}, new float[]{position[0] + voxDim[0], position[1]+ voxDim[1], position[2] + voxDim[2]}, mu); + } + if ((bits & 2048) != 0) { + mu = (float) ((isoLevel - value2) / (value6 - value2)); + vertList[11] = lerp(new float[]{position[0], position[1] + voxDim[1], position[2]}, new float[]{position[0], position[1] + voxDim[1], position[2] + voxDim[2]}, mu); + } + + // construct triangles -- get correct vertices from triTable. + int i = 0; + // "Re-purpose cubeindex into an offset into triTable." + cubeindex <<= 4; + + while (TablesMC.MC_TRI_TABLE[cubeindex + i] != -1) { + int index1 = TablesMC.MC_TRI_TABLE[cubeindex + i]; + int index2 = TablesMC.MC_TRI_TABLE[cubeindex + i + 1]; + int index3 = TablesMC.MC_TRI_TABLE[cubeindex + i + 2]; + + // Add triangles vertices normalized with the maximal possible value + vertices.add(new float[] {vertList[index3][0] / maxAxisVal - 0.5f, vertList[index3][1] / maxAxisVal - 0.5f, vertList[index3][2] / maxAxisVal - 0.5f}); + vertices.add(new float[] {vertList[index2][0] / maxAxisVal - 0.5f, vertList[index2][1] / maxAxisVal - 0.5f, vertList[index2][2] / maxAxisVal - 0.5f}); + vertices.add(new float[] {vertList[index1][0] / maxAxisVal - 0.5f, vertList[index1][1] / maxAxisVal - 0.5f, vertList[index1][2] / maxAxisVal - 0.5f}); + + i += 3; + } + } + } + } + + callback.setVertices(vertices); + callback.run(); + } + + public static ArrayList marchingCubes(Array values, Array xc, Array yc, Array zc, float isoLevel) { + + ArrayList vertices = new ArrayList<>(); + // Actual position along edge weighted according to function values. + float vertList[][] = new float[12][3]; + + int[] shape = values.getShape(); + int[] volDim = new int[]{shape[2], shape[1], shape[0]}; + + // Volume iteration + float xx, yy, zz; + for (int z = 0; z < volDim[2] - 1; z++) { + zz = zc.getFloat(z); + for (int y = 0; y < volDim[1] - 1; y++) { + yy = yc.getFloat(y); + for (int x = 0; x < volDim[0] - 1; x++) { + xx = xc.getFloat(x); + // Indices pointing to cube vertices + // pyz ___________________ pxyz + // /| /| + // / | / | + // / | / | + // pz /___|______________/pxz| + // | | | | + // | | | | + // | py |______________|___| pxy + // | / | / + // | / | / + // | / | / + // |/__________________|/ + // p px + + int p = x + (volDim[0] * y) + (volDim[0] * volDim[1] * z), + px = p + 1, + py = p + volDim[0], + pxy = py + 1, + pz = p + volDim[0] * volDim[1], + pxz = px + volDim[0] * volDim[1], + pyz = py + volDim[0] * volDim[1], + pxyz = pxy + volDim[0] * volDim[1]; + + // X, Y, Z position + //float position[] = new float[]{xx, yy, zz}; + + // Voxel intensities + float value0 = values.getFloat(p), + value1 = values.getFloat(px), + value2 = values.getFloat(py), + value3 = values.getFloat(pxy), + value4 = values.getFloat(pz), + value5 = values.getFloat(pxz), + value6 = values.getFloat(pyz), + value7 = values.getFloat(pxyz); + + // Voxel is active if its intensity is above isolevel + int cubeindex = 0; + if (value0 > isoLevel) cubeindex |= 1; + if (value1 > isoLevel) cubeindex |= 2; + if (value2 > isoLevel) cubeindex |= 8; + if (value3 > isoLevel) cubeindex |= 4; + if (value4 > isoLevel) cubeindex |= 16; + if (value5 > isoLevel) cubeindex |= 32; + if (value6 > isoLevel) cubeindex |= 128; + if (value7 > isoLevel) cubeindex |= 64; + + // Fetch the triggered edges + int bits = TablesMC.MC_EDGE_TABLE[cubeindex]; + + // If no edge is triggered... skip + if (bits == 0) continue; + + // Interpolate the positions based od voxel intensities + float mu = 0.5f; + + // bottom of the cube + if ((bits & 1) != 0) { + mu = (float) ((isoLevel - value0) / (value1 - value0)); + vertList[0] = lerp(new float[]{xx, yy, zz}, new float[]{xc.getFloat(x + 1), yy, zz}, mu); + } + if ((bits & 2) != 0) { + mu = (float) ((isoLevel - value1) / (value3 - value1)); + vertList[1] = lerp(new float[]{xc.getFloat(x + 1), yy, zz}, new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zz}, mu); + } + if ((bits & 4) != 0) { + mu = (float) ((isoLevel - value2) / (value3 - value2)); + vertList[2] = lerp(new float[]{xx, yc.getFloat(y + 1), zz}, new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zz}, mu); + } + if ((bits & 8) != 0) { + mu = (float) ((isoLevel - value0) / (value2 - value0)); + vertList[3] = lerp(new float[]{xx, yy, zz}, new float[]{xx, yc.getFloat(y + 1), zz}, mu); + } + // top of the cube + if ((bits & 16) != 0) { + mu = (float) ((isoLevel - value4) / (value5 - value4)); + vertList[4] = lerp(new float[]{xx, yy, zc.getFloat(z + 1)}, new float[]{xc.getFloat(x + 1), yy, zc.getFloat(z + 1)}, mu); + } + if ((bits & 32) != 0) { + mu = (float) ((isoLevel - value5) / (value7 - value5)); + vertList[5] = lerp(new float[]{xc.getFloat(x + 1), yy, zc.getFloat(z + 1)}, new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zc.getFloat(z + 1)}, mu); + } + if ((bits & 64) != 0) { + mu = (float) ((isoLevel - value6) / (value7 - value6)); + vertList[6] = lerp(new float[]{xx, yc.getFloat(y + 1), zc.getFloat(z + 1)}, new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zc.getFloat(z + 1)}, mu); + } + if ((bits & 128) != 0) { + mu = (float) ((isoLevel - value4) / (value6 - value4)); + vertList[7] = lerp(new float[]{xx, yy, zc.getFloat(z + 1)}, new float[]{xx, yc.getFloat(y + 1), zc.getFloat(z + 1)}, mu); + } + // vertical lines of the cube + if ((bits & 256) != 0) { + mu = (float) ((isoLevel - value0) / (value4 - value0)); + vertList[8] = lerp(new float[]{xx, yy, zz}, new float[]{xx, yy, zc.getFloat(z + 1)}, mu); + } + if ((bits & 512) != 0) { + mu = (float) ((isoLevel - value1) / (value5 - value1)); + vertList[9] = lerp(new float[]{xc.getFloat(x + 1), yy, zz}, new float[]{xc.getFloat(x + 1), yy, zc.getFloat(z + 1)}, mu); + } + if ((bits & 1024) != 0) { + mu = (float) ((isoLevel - value3) / (value7 - value3)); + vertList[10] = lerp(new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zz}, new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zc.getFloat(z + 1)}, mu); + } + if ((bits & 2048) != 0) { + mu = (float) ((isoLevel - value2) / (value6 - value2)); + vertList[11] = lerp(new float[]{xx, yc.getFloat(y + 1), zz}, new float[]{xx, yc.getFloat(y + 1), zc.getFloat(z + 1)}, mu); + } + + // construct triangles -- get correct vertices from triTable. + int i = 0; + // "Re-purpose cubeindex into an offset into triTable." + cubeindex <<= 4; + + while (TablesMC.MC_TRI_TABLE[cubeindex + i] != -1) { + int index1 = TablesMC.MC_TRI_TABLE[cubeindex + i]; + int index2 = TablesMC.MC_TRI_TABLE[cubeindex + i + 1]; + int index3 = TablesMC.MC_TRI_TABLE[cubeindex + i + 2]; + + // Add triangles vertices + vertices.add(new float[] {vertList[index3][0], vertList[index3][1], vertList[index3][2]}); + vertices.add(new float[] {vertList[index2][0], vertList[index2][1], vertList[index2][2]}); + vertices.add(new float[] {vertList[index1][0], vertList[index1][1], vertList[index1][2]}); + + i += 3; + } + } + } + } + + return vertices; + } + + public static void marchingCubes(Array values, Array xc, Array yc, Array zc, float isoLevel, + int len, int offset, CallbackMC callback) { + + ArrayList vertices = new ArrayList<>(); + // Actual position along edge weighted according to function values. + float vertList[][] = new float[12][3]; + + int[] shape = values.getShape(); + int[] volDim = new int[]{shape[2], shape[1], len}; + + // Volume iteration + float xx, yy, zz; + for (int z = offset; z < volDim[2] - 1 + offset; z++) { + zz = zc.getFloat(z); + for (int y = 0; y < volDim[1] - 1; y++) { + yy = yc.getFloat(y); + for (int x = 0; x < volDim[0] - 1; x++) { + xx = xc.getFloat(x); + // Indices pointing to cube vertices + // pyz ___________________ pxyz + // /| /| + // / | / | + // / | / | + // pz /___|______________/pxz| + // | | | | + // | | | | + // | py |______________|___| pxy + // | / | / + // | / | / + // | / | / + // |/__________________|/ + // p px + + int p = x + (volDim[0] * y) + (volDim[0] * volDim[1] * z), + px = p + 1, + py = p + volDim[0], + pxy = py + 1, + pz = p + volDim[0] * volDim[1], + pxz = px + volDim[0] * volDim[1], + pyz = py + volDim[0] * volDim[1], + pxyz = pxy + volDim[0] * volDim[1]; + + // X, Y, Z position + //float position[] = new float[]{xx, yy, zz}; + + // Voxel intensities + float value0 = values.getFloat(p), + value1 = values.getFloat(px), + value2 = values.getFloat(py), + value3 = values.getFloat(pxy), + value4 = values.getFloat(pz), + value5 = values.getFloat(pxz), + value6 = values.getFloat(pyz), + value7 = values.getFloat(pxyz); + + // Voxel is active if its intensity is above isolevel + int cubeindex = 0; + if (value0 > isoLevel) cubeindex |= 1; + if (value1 > isoLevel) cubeindex |= 2; + if (value2 > isoLevel) cubeindex |= 8; + if (value3 > isoLevel) cubeindex |= 4; + if (value4 > isoLevel) cubeindex |= 16; + if (value5 > isoLevel) cubeindex |= 32; + if (value6 > isoLevel) cubeindex |= 128; + if (value7 > isoLevel) cubeindex |= 64; + + // Fetch the triggered edges + int bits = TablesMC.MC_EDGE_TABLE[cubeindex]; + + // If no edge is triggered... skip + if (bits == 0) continue; + + // Interpolate the positions based od voxel intensities + float mu = 0.5f; + + // bottom of the cube + if ((bits & 1) != 0) { + mu = (float) ((isoLevel - value0) / (value1 - value0)); + vertList[0] = lerp(new float[]{xx, yy, zz}, new float[]{xc.getFloat(x + 1), yy, zz}, mu); + } + if ((bits & 2) != 0) { + mu = (float) ((isoLevel - value1) / (value3 - value1)); + vertList[1] = lerp(new float[]{xc.getFloat(x + 1), yy, zz}, new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zz}, mu); + } + if ((bits & 4) != 0) { + mu = (float) ((isoLevel - value2) / (value3 - value2)); + vertList[2] = lerp(new float[]{xx, yc.getFloat(y + 1), zz}, new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zz}, mu); + } + if ((bits & 8) != 0) { + mu = (float) ((isoLevel - value0) / (value2 - value0)); + vertList[3] = lerp(new float[]{xx, yy, zz}, new float[]{xx, yc.getFloat(y + 1), zz}, mu); + } + // top of the cube + if ((bits & 16) != 0) { + mu = (float) ((isoLevel - value4) / (value5 - value4)); + vertList[4] = lerp(new float[]{xx, yy, zc.getFloat(z + 1)}, new float[]{xc.getFloat(x + 1), yy, zc.getFloat(z + 1)}, mu); + } + if ((bits & 32) != 0) { + mu = (float) ((isoLevel - value5) / (value7 - value5)); + vertList[5] = lerp(new float[]{xc.getFloat(x + 1), yy, zc.getFloat(z + 1)}, new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zc.getFloat(z + 1)}, mu); + } + if ((bits & 64) != 0) { + mu = (float) ((isoLevel - value6) / (value7 - value6)); + vertList[6] = lerp(new float[]{xx, yc.getFloat(y + 1), zc.getFloat(z + 1)}, new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zc.getFloat(z + 1)}, mu); + } + if ((bits & 128) != 0) { + mu = (float) ((isoLevel - value4) / (value6 - value4)); + vertList[7] = lerp(new float[]{xx, yy, zc.getFloat(z + 1)}, new float[]{xx, yc.getFloat(y + 1), zc.getFloat(z + 1)}, mu); + } + // vertical lines of the cube + if ((bits & 256) != 0) { + mu = (float) ((isoLevel - value0) / (value4 - value0)); + vertList[8] = lerp(new float[]{xx, yy, zz}, new float[]{xx, yy, zc.getFloat(z + 1)}, mu); + } + if ((bits & 512) != 0) { + mu = (float) ((isoLevel - value1) / (value5 - value1)); + vertList[9] = lerp(new float[]{xc.getFloat(x + 1), yy, zz}, new float[]{xc.getFloat(x + 1), yy, zc.getFloat(z + 1)}, mu); + } + if ((bits & 1024) != 0) { + mu = (float) ((isoLevel - value3) / (value7 - value3)); + vertList[10] = lerp(new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zz}, new float[]{xc.getFloat(x + 1), yc.getFloat(y + 1), zc.getFloat(z + 1)}, mu); + } + if ((bits & 2048) != 0) { + mu = (float) ((isoLevel - value2) / (value6 - value2)); + vertList[11] = lerp(new float[]{xx, yc.getFloat(y + 1), zz}, new float[]{xx, yc.getFloat(y + 1), zc.getFloat(z + 1)}, mu); + } + + // construct triangles -- get correct vertices from triTable. + int i = 0; + // "Re-purpose cubeindex into an offset into triTable." + cubeindex <<= 4; + + while (TablesMC.MC_TRI_TABLE[cubeindex + i] != -1) { + int index1 = TablesMC.MC_TRI_TABLE[cubeindex + i]; + int index2 = TablesMC.MC_TRI_TABLE[cubeindex + i + 1]; + int index3 = TablesMC.MC_TRI_TABLE[cubeindex + i + 2]; + + // Add triangles vertices + vertices.add(new float[] {vertList[index3][0], vertList[index3][1], vertList[index3][2]}); + vertices.add(new float[] {vertList[index2][0], vertList[index2][1], vertList[index2][2]}); + vertices.add(new float[] {vertList[index1][0], vertList[index1][1], vertList[index1][2]}); + + i += 3; + } + } + } + } + + callback.setVertices(vertices); + callback.run(); + } +} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/mc/TablesMC.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/mc/TablesMC.java similarity index 98% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/mc/TablesMC.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/mc/TablesMC.java index f76425db..8c125fdd 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/mc/TablesMC.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/mc/TablesMC.java @@ -1,303 +1,303 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.jogl.mc; - -/** - * Created by Primoz on 7.7.2016. - */ -public class TablesMC { - static int[] MC_EDGE_TABLE = { - 0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c, - 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00, - 0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c, - 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90, - 0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c, - 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30, - 0x3a0, 0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5, 0x4ac, - 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0, - 0x460, 0x569, 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c, - 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60, - 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff, 0x3f5, 0x2fc, - 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0, - 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55, 0x15c, - 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950, - 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc, - 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0, - 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc, - 0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0, - 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c, - 0x15c, 0x55, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650, - 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc, - 0x2fc, 0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0, - 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c, - 0x36c, 0x265, 0x16f, 0x66, 0x76a, 0x663, 0x569, 0x460, - 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac, - 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0, - 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c, - 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230, - 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c, - 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190, - 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c, - 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0 }; - - static int[] MC_TRI_TABLE = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1, - 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1, - 3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1, - 3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1, - 9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1, - 1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, - 9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, - 2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1, - 8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1, - 9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, - 4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1, - 3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1, - 1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1, - 4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1, - 4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1, - 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1, - 1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1, - 5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1, - 2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1, - 9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1, - 0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, - 2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1, - 10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, - 4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1, - 5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1, - 5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, - 9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1, - 0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1, - 1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1, - 10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1, - 8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1, - 2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, - 7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, - 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1, - 2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1, - 11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1, - 9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1, - 5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1, - 11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1, - 11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, - 1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1, - 9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1, - 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1, - 2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, - 0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, - 5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1, - 6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1, - 0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1, - 3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1, - 6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1, - 5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1, - 1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, - 10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1, - 6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, - 1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1, - 8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1, - 7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1, - 3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, - 5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1, - 0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, - 9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1, - 8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1, - 5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1, - 0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1, - 6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1, - 10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, - 10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1, - 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1, - 1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1, - 3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1, - 0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, - 10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1, - 0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1, - 3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1, - 6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1, - 9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1, - 8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1, - 3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1, - 6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1, - 0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1, - 10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1, - 10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1, - 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1, - 2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1, - 7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1, - 7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1, - 2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1, - 1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1, - 11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1, - 8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1, - 0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1, - 7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, - 10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, - 2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, - 6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1, - 7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1, - 2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, - 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1, - 10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1, - 10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1, - 0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1, - 7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1, - 6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1, - 8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1, - 9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1, - 6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1, - 1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1, - 4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1, - 10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1, - 8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, - 0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1, - 1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1, - 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1, - 10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1, - 4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1, - 10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, - 5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, - 11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1, - 9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, - 6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1, - 7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1, - 3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1, - 7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1, - 9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1, - 3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1, - 6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1, - 9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1, - 1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1, - 4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1, - 7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1, - 6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1, - 3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1, - 0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1, - 6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1, - 1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1, - 0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1, - 11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1, - 6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1, - 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1, - 9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1, - 1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1, - 1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1, - 10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1, - 0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1, - 5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1, - 10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1, - 11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1, - 0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1, - 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1, - 7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1, - 2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, - 8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1, - 9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1, - 9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1, - 1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1, - 9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1, - 9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, - 5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1, - 0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1, - 10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1, - 2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1, - 0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1, - 0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1, - 9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1, - 5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1, - 3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1, - 5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1, - 8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1, - 0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1, - 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1, - 0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1, - 1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1, - 3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1, - 4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1, - 9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1, - 11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1, - 11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1, - 2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1, - 9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1, - 3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1, - 1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1, - 4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1, - 4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1, - 0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1, - 3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1, - 3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1, - 0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1, - 9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1, - 1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; -} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.meteoinfo.chart.jogl.mc; + +/** + * Created by Primoz on 7.7.2016. + */ +public class TablesMC { + static int[] MC_EDGE_TABLE = { + 0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c, + 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00, + 0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c, + 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90, + 0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c, + 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30, + 0x3a0, 0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5, 0x4ac, + 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0, + 0x460, 0x569, 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c, + 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60, + 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff, 0x3f5, 0x2fc, + 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0, + 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55, 0x15c, + 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950, + 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc, + 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0, + 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc, + 0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0, + 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c, + 0x15c, 0x55, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650, + 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc, + 0x2fc, 0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0, + 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c, + 0x36c, 0x265, 0x16f, 0x66, 0x76a, 0x663, 0x569, 0x460, + 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac, + 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0, + 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c, + 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230, + 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c, + 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190, + 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c, + 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0 }; + + static int[] MC_TRI_TABLE = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1, + 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1, + 3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1, + 3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1, + 9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1, + 1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, + 9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, + 2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1, + 8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1, + 9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, + 4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1, + 3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1, + 1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1, + 4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1, + 4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1, + 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1, + 1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1, + 5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1, + 2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1, + 9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1, + 0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, + 2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1, + 10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, + 4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1, + 5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1, + 5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, + 9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1, + 0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1, + 1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1, + 10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1, + 8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1, + 2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, + 7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, + 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1, + 2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1, + 11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1, + 9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1, + 5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1, + 11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1, + 11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, + 1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1, + 9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1, + 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1, + 2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, + 5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1, + 6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1, + 0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1, + 3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1, + 6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1, + 5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1, + 1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, + 10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1, + 6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, + 1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1, + 8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1, + 7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1, + 3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, + 5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1, + 0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, + 9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1, + 8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1, + 5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1, + 0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1, + 6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1, + 10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, + 10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1, + 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1, + 1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1, + 3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1, + 0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, + 10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1, + 0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1, + 3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1, + 6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1, + 9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1, + 8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1, + 3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1, + 6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1, + 0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1, + 10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1, + 10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1, + 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1, + 2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1, + 7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1, + 7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1, + 2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1, + 1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1, + 11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1, + 8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1, + 0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1, + 7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, + 10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, + 2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, + 6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1, + 7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1, + 2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, + 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1, + 10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1, + 10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1, + 0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1, + 7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1, + 6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1, + 8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1, + 9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1, + 6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1, + 1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1, + 4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1, + 10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1, + 8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, + 0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1, + 1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1, + 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1, + 10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1, + 4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1, + 10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, + 5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, + 11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1, + 9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, + 6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1, + 7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1, + 3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1, + 7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1, + 9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1, + 3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1, + 6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1, + 9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1, + 1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1, + 4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1, + 7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1, + 6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1, + 3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1, + 0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1, + 6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1, + 1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1, + 0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1, + 11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1, + 6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1, + 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1, + 9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1, + 1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1, + 1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1, + 10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1, + 0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1, + 5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1, + 10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1, + 11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1, + 0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1, + 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1, + 7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1, + 2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, + 8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1, + 9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1, + 9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1, + 1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1, + 9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1, + 9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, + 5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1, + 0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1, + 10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1, + 2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1, + 0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1, + 0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1, + 9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1, + 5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1, + 3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1, + 5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1, + 8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1, + 0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1, + 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1, + 0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1, + 1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1, + 3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1, + 4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1, + 9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1, + 11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1, + 11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1, + 2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1, + 9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1, + 3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1, + 1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1, + 4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1, + 4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1, + 3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1, + 3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1, + 0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1, + 9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1, + 1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; +} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/mc/VolumeGenerator.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/mc/VolumeGenerator.java similarity index 97% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/mc/VolumeGenerator.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/mc/VolumeGenerator.java index b5b3bb6b..b2a89b49 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/mc/VolumeGenerator.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/mc/VolumeGenerator.java @@ -1,116 +1,116 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.jogl.mc; - -/** - * Created by Primoz on 11. 07. 2016. - */ -public class VolumeGenerator { - public static char[] generateScalarFieldChar(int []size) { - final char[] scalarField = new char[size[0] * size[1] * size[2]]; - float axisMin = -10; - float axisMax = 10; - float axisRange = axisMax - axisMin; - - for (int k = 0; k < size[0]; k++) { - for (int j = 0; j < size[1]; j++) { - for (int i = 0; i < size[2]; i++) { - // actual values - char x = (char) (axisMin + axisRange * i / (size[0] - 1)); - char y = (char) (axisMin + axisRange * j / (size[1] - 1)); - char z = (char) (axisMin + axisRange * k / (size[2] - 1)); - scalarField[k + size[1] * (j + size[2] * i)] = (char) (x * x + y * y - z * z - 25); - } - } - } - - return scalarField; - } - - public static short[] generateScalarFieldShort(int []size) { - final short[] scalarField = new short[size[0] * size[1] * size[2]]; - float axisMin = -10; - float axisMax = 10; - float axisRange = axisMax - axisMin; - - for (int k = 0; k < size[0]; k++) { - for (int j = 0; j < size[1]; j++) { - for (int i = 0; i < size[2]; i++) { - // actual values - short x = (short) (axisMin + axisRange * i / (size[0] - 1)); - short y = (short) (axisMin + axisRange * j / (size[1] - 1)); - short z = (short) (axisMin + axisRange * k / (size[2] - 1)); - scalarField[k + size[1] * (j + size[2] * i)] = (short) (x * x + y * y - z * z - 25); - } - } - } - - return scalarField; - } - - public static int[] generateScalarFieldInt(int []size) { - final int[] scalarField = new int[size[0] * size[1] * size[2]]; - float axisMin = -10; - float axisMax = 10; - float axisRange = axisMax - axisMin; - - for (int k = 0; k < size[0]; k++) { - for (int j = 0; j < size[1]; j++) { - for (int i = 0; i < size[2]; i++) { - // actual values - int x = (int) (axisMin + axisRange * i / (size[0] - 1)); - int y = (int) (axisMin + axisRange * j / (size[1] - 1)); - int z = (int) (axisMin + axisRange * k / (size[2] - 1)); - scalarField[k + size[1] * (j + size[2] * i)] = (int) (x * x + y * y - z * z - 25); - } - } - } - - return scalarField; - } - - public static float[] generateScalarFieldFloat(int []size) { - final float[] scalarField = new float[size[0] * size[1] * size[2]]; - float axisMin = -10; - float axisMax = 10; - float axisRange = axisMax - axisMin; - - for (int k = 0; k < size[0]; k++) { - for (int j = 0; j < size[1]; j++) { - for (int i = 0; i < size[2]; i++) { - // actual values - float x = axisMin + axisRange * i / (size[0] - 1); - float y = axisMin + axisRange * j / (size[1] - 1); - float z = axisMin + axisRange * k / (size[2] - 1); - scalarField[k + size[1] * (j + size[2] * i)] = x * x + y * y - z * z - 25; - } - } - } - - return scalarField; - } - - public static double[] generateScalarFieldDouble(int []size) { - final double[] scalarField = new double[size[0] * size[1] * size[2]]; - double axisMin = -10; - double axisMax = 10; - double axisRange = axisMax - axisMin; - - for (int k = 0; k < size[0]; k++) { - for (int j = 0; j < size[1]; j++) { - for (int i = 0; i < size[2]; i++) { - // actual values - double x = axisMin + axisRange * i / (size[0] - 1); - double y = axisMin + axisRange * j / (size[1] - 1); - double z = axisMin + axisRange * k / (size[2] - 1); - scalarField[k + size[1] * (j + size[2] * i)] = (x * x + y * y - z * z - 25); - } - } - } - - return scalarField; - } -} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.meteoinfo.chart.jogl.mc; + +/** + * Created by Primoz on 11. 07. 2016. + */ +public class VolumeGenerator { + public static char[] generateScalarFieldChar(int []size) { + final char[] scalarField = new char[size[0] * size[1] * size[2]]; + float axisMin = -10; + float axisMax = 10; + float axisRange = axisMax - axisMin; + + for (int k = 0; k < size[0]; k++) { + for (int j = 0; j < size[1]; j++) { + for (int i = 0; i < size[2]; i++) { + // actual values + char x = (char) (axisMin + axisRange * i / (size[0] - 1)); + char y = (char) (axisMin + axisRange * j / (size[1] - 1)); + char z = (char) (axisMin + axisRange * k / (size[2] - 1)); + scalarField[k + size[1] * (j + size[2] * i)] = (char) (x * x + y * y - z * z - 25); + } + } + } + + return scalarField; + } + + public static short[] generateScalarFieldShort(int []size) { + final short[] scalarField = new short[size[0] * size[1] * size[2]]; + float axisMin = -10; + float axisMax = 10; + float axisRange = axisMax - axisMin; + + for (int k = 0; k < size[0]; k++) { + for (int j = 0; j < size[1]; j++) { + for (int i = 0; i < size[2]; i++) { + // actual values + short x = (short) (axisMin + axisRange * i / (size[0] - 1)); + short y = (short) (axisMin + axisRange * j / (size[1] - 1)); + short z = (short) (axisMin + axisRange * k / (size[2] - 1)); + scalarField[k + size[1] * (j + size[2] * i)] = (short) (x * x + y * y - z * z - 25); + } + } + } + + return scalarField; + } + + public static int[] generateScalarFieldInt(int []size) { + final int[] scalarField = new int[size[0] * size[1] * size[2]]; + float axisMin = -10; + float axisMax = 10; + float axisRange = axisMax - axisMin; + + for (int k = 0; k < size[0]; k++) { + for (int j = 0; j < size[1]; j++) { + for (int i = 0; i < size[2]; i++) { + // actual values + int x = (int) (axisMin + axisRange * i / (size[0] - 1)); + int y = (int) (axisMin + axisRange * j / (size[1] - 1)); + int z = (int) (axisMin + axisRange * k / (size[2] - 1)); + scalarField[k + size[1] * (j + size[2] * i)] = (int) (x * x + y * y - z * z - 25); + } + } + } + + return scalarField; + } + + public static float[] generateScalarFieldFloat(int []size) { + final float[] scalarField = new float[size[0] * size[1] * size[2]]; + float axisMin = -10; + float axisMax = 10; + float axisRange = axisMax - axisMin; + + for (int k = 0; k < size[0]; k++) { + for (int j = 0; j < size[1]; j++) { + for (int i = 0; i < size[2]; i++) { + // actual values + float x = axisMin + axisRange * i / (size[0] - 1); + float y = axisMin + axisRange * j / (size[1] - 1); + float z = axisMin + axisRange * k / (size[2] - 1); + scalarField[k + size[1] * (j + size[2] * i)] = x * x + y * y - z * z - 25; + } + } + } + + return scalarField; + } + + public static double[] generateScalarFieldDouble(int []size) { + final double[] scalarField = new double[size[0] * size[1] * size[2]]; + double axisMin = -10; + double axisMax = 10; + double axisRange = axisMax - axisMin; + + for (int k = 0; k < size[0]; k++) { + for (int j = 0; j < size[1]; j++) { + for (int i = 0; i < size[2]; i++) { + // actual values + double x = axisMin + axisRange * i / (size[0] - 1); + double y = axisMin + axisRange * j / (size[1] - 1); + double z = axisMin + axisRange * k / (size[2] - 1); + scalarField[k + size[1] * (j + size[2] * i)] = (x * x + y * y - z * z - 25); + } + } + } + + return scalarField; + } +} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/tessellator/Primitive.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/tessellator/Primitive.java similarity index 100% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/tessellator/Primitive.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/tessellator/Primitive.java diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/tessellator/PrimitiveTessellator.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/tessellator/PrimitiveTessellator.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/tessellator/PrimitiveTessellator.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/tessellator/PrimitiveTessellator.java index 3d161ada..e73c39c8 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/tessellator/PrimitiveTessellator.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/tessellator/PrimitiveTessellator.java @@ -1,6 +1,5 @@ package org.meteoinfo.chart.jogl.tessellator; -import com.jogamp.opengl.GL2; import com.jogamp.opengl.glu.GLU; import com.jogamp.opengl.glu.GLUtessellator; import com.jogamp.opengl.glu.GLUtessellatorCallbackAdapter; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/tessellator/TessPolygon.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/tessellator/TessPolygon.java similarity index 100% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/tessellator/TessPolygon.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/tessellator/TessPolygon.java diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/tessellator/TriangleTessellator.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/tessellator/TriangleTessellator.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/tessellator/TriangleTessellator.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/tessellator/TriangleTessellator.java index 7c82bbc7..4f3b9732 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/jogl/tessellator/TriangleTessellator.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/tessellator/TriangleTessellator.java @@ -6,7 +6,6 @@ import com.jogamp.opengl.glu.GLUtessellator; import com.jogamp.opengl.glu.GLUtessellatorCallbackAdapter; import org.meteoinfo.chart.jogl.Triangle; import org.meteoinfo.geometry.shape.PointZ; -import org.meteoinfo.geometry.shape.Polygon; import org.meteoinfo.geometry.shape.PolygonZ; import java.util.ArrayList; diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/AbstractPlot2D.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/AbstractPlot2D.java index e96cded3..ca250acb 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/AbstractPlot2D.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/AbstractPlot2D.java @@ -10,7 +10,7 @@ import org.meteoinfo.chart.axis.Axis; import org.meteoinfo.chart.axis.LogAxis; import org.meteoinfo.common.Extent; import org.meteoinfo.common.PointF; -import org.meteoinfo.chart.drawing.Draw; +import org.meteoinfo.geo.drawing.Draw; import java.awt.*; import java.awt.geom.AffineTransform; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/CategoryPlot.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/CategoryPlot.java similarity index 94% rename from MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/CategoryPlot.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/CategoryPlot.java index cdcae975..28ffb861 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/chart/plot/CategoryPlot.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/CategoryPlot.java @@ -1,62 +1,63 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.plot; - -import java.awt.Graphics2D; -import java.awt.geom.Rectangle2D; -import org.meteoinfo.chart.Margin; -import org.meteoinfo.data.CategoryDataset; -import org.meteoinfo.data.Dataset; - -/** - * - * @author yaqiang - */ -public class CategoryPlot extends Plot{ - - CategoryDataset dataset; - - @Override - public Dataset getDataset(){ - return dataset; - } - - @Override - public void setDataset(Dataset value){ - dataset = (CategoryDataset)value; - } - - @Override - public PlotType getPlotType() { - return PlotType.CATEGORY; - } - - @Override - public void draw(Graphics2D g2, Rectangle2D area) { - - } - - @Override - public Rectangle2D getPositionArea() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public Margin getTightInset(Graphics2D g, Rectangle2D positionArea) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public Rectangle2D getPositionArea(Rectangle2D figureArea) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public Rectangle2D getOuterPositionArea(Rectangle2D area) { - return null; - } - -} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.meteoinfo.chart.plot; + +import org.meteoinfo.chart.Margin; +import org.meteoinfo.data.CategoryDataset; +import org.meteoinfo.data.Dataset; + +import java.awt.*; +import java.awt.geom.Rectangle2D; + +/** + * + * @author yaqiang + */ +public class CategoryPlot extends Plot{ + + CategoryDataset dataset; + + @Override + public Dataset getDataset(){ + return dataset; + } + + @Override + public void setDataset(Dataset value){ + dataset = (CategoryDataset)value; + } + + @Override + public PlotType getPlotType() { + return PlotType.CATEGORY; + } + + @Override + public void draw(Graphics2D g2, Rectangle2D area) { + + } + + @Override + public Rectangle2D getPositionArea() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public Margin getTightInset(Graphics2D g, Rectangle2D positionArea) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public Rectangle2D getPositionArea(Rectangle2D figureArea) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public Rectangle2D getOuterPositionArea(Rectangle2D area) { + return null; + } + +} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/GraphicFactory.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/GraphicFactory.java index 65f4f628..546277c9 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/GraphicFactory.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/GraphicFactory.java @@ -8,25 +8,28 @@ package org.meteoinfo.chart.plot; import org.apache.commons.lang3.ArrayUtils; import org.meteoinfo.chart.ChartText; import org.meteoinfo.chart.plot3d.GraphicCollection3D; -import org.meteoinfo.common.Extent; -import org.meteoinfo.common.Extent3D; -import org.meteoinfo.common.MIMath; -import org.meteoinfo.common.PointD; +import org.meteoinfo.common.*; import org.meteoinfo.data.GridArray; import org.meteoinfo.data.GridData; import org.meteoinfo.data.XYListDataset; import org.meteoinfo.data.analysis.Statistics; -import org.meteoinfo.drawing.ContourDraw; -import org.meteoinfo.drawing.Draw; -import org.meteoinfo.geoprocess.GeoComputation; -import org.meteoinfo.geoprocess.GeometryUtil; -import org.meteoinfo.layer.ImageLayer; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.legend.*; -import org.meteoinfo.math.ArrayMath; -import org.meteoinfo.math.ArrayUtil; +import org.meteoinfo.geo.drawing.ContourDraw; +import org.meteoinfo.geo.drawing.Draw; +import org.meteoinfo.geo.layer.ImageLayer; +import org.meteoinfo.geo.layer.VectorLayer; +import org.meteoinfo.geo.legend.LegendManage; +import org.meteoinfo.geometry.graphic.Graphic; +import org.meteoinfo.geometry.graphic.GraphicCollection; +import org.meteoinfo.geometry.graphic.ImageGraphic; +import org.meteoinfo.geometry.legend.*; +import org.meteoinfo.geometry.shape.Shape; +import org.meteoinfo.geometry.shape.*; +import org.meteoinfo.geometry.geoprocess.GeoComputation; +import org.meteoinfo.geometry.geoprocess.GeometryUtil; import org.meteoinfo.math.meteo.MeteoMath; -import org.meteoinfo.ndarray.InvalidRangeException; +import org.meteoinfo.ndarray.*; +import org.meteoinfo.ndarray.math.ArrayMath; +import org.meteoinfo.ndarray.math.ArrayUtil; import org.meteoinfo.ndarray.util.BigDecimalUtil; import wcontour.Contour; import wcontour.global.Point3D; @@ -735,7 +738,7 @@ public class GraphicFactory { * @return LineString graphics */ public static GraphicCollection createErrorLineString(Array xdata, Array ydata, Array xErrorLeft, - Array xErrorRight, Array yErrorBottom, Array yErrorUp, PolylineBreak cb, PolylineBreak ecb, float capSize) { + Array xErrorRight, Array yErrorBottom, Array yErrorUp, PolylineBreak cb, PolylineBreak ecb, float capSize) { GraphicCollection gc = new GraphicCollection(); PolylineShape pls; CapPolylineShape epls; @@ -2942,7 +2945,7 @@ public class GraphicFactory { * @return Graphics */ public static GraphicCollection createImage(GridArray gdata, LegendScheme ls, double offset, - String zdir, List sePoint, String interpolation) { + String zdir, List sePoint, String interpolation) { Graphic gg = createImage(gdata, ls); if (interpolation != null) { ((ImageShape) gg.getShape()).setInterpolation(interpolation); @@ -3053,17 +3056,17 @@ public class GraphicFactory { ArrayUtils.reverse(y); Object[] cbs = ContourDraw.tracingContourLines(gridData.data, cValues, x, y, gridData.missingValue, S1); - List ContourLines = (List) cbs[0]; + List ContourLines = (List) cbs[0]; if (ContourLines.isEmpty()) { return null; } if (isSmooth) { - ContourLines = wcontour.Contour.smoothLines(ContourLines); + ContourLines = Contour.smoothLines(ContourLines); } - wcontour.global.PolyLine aLine; + PolyLine aLine; double v; ColorBreak cbb = ls.findLegendBreak(0); GraphicCollection graphics = new GraphicCollection(); @@ -3142,17 +3145,17 @@ public class GraphicFactory { ArrayUtils.reverse(y); Object[] cbs = ContourDraw.tracingContourLines(gridData.data, cValues, x, y, gridData.missingValue, S1); - List ContourLines = (List) cbs[0]; + List ContourLines = (List) cbs[0]; if (ContourLines.isEmpty()) { return null; } if (isSmooth) { - ContourLines = wcontour.Contour.smoothLines(ContourLines); + ContourLines = Contour.smoothLines(ContourLines); } - wcontour.global.PolyLine aLine; + PolyLine aLine; double v; ColorBreak cbb; GraphicCollection3D graphics = new GraphicCollection3D(); @@ -3234,17 +3237,17 @@ public class GraphicFactory { ArrayUtils.reverse(yArray); Object[] cbs = ContourDraw.tracingContourLines(gridData.data, cValues, xArray, yArray, gridData.missingValue, S1); - List ContourLines = (List) cbs[0]; + List ContourLines = (List) cbs[0]; if (ContourLines.isEmpty()) { return null; } if (isSmooth) { - ContourLines = wcontour.Contour.smoothLines(ContourLines); + ContourLines = Contour.smoothLines(ContourLines); } - wcontour.global.PolyLine aLine; + PolyLine aLine; double v; ColorBreak cbb; GraphicCollection3D graphics = new GraphicCollection3D(); @@ -3346,11 +3349,11 @@ public class GraphicFactory { ArrayUtils.reverse(yArray); Object[] cbs = ContourDraw.tracingContourLines(gridData.data, cValues, xArray, yArray, gridData.missingValue, S1); - List contourLines = (List) cbs[0]; + List contourLines = (List) cbs[0]; List borders = (List) cbs[1]; if (isSmooth) { - contourLines = wcontour.Contour.smoothLines(contourLines); + contourLines = Contour.smoothLines(contourLines); } List contourPolygons = ContourDraw.tracingPolygons(gridData.data, contourLines, borders, cValues); @@ -3482,11 +3485,11 @@ public class GraphicFactory { ArrayUtils.reverse(yArray); Object[] cbs = ContourDraw.tracingContourLines(gridData.data, cValues, xArray, yArray, gridData.missingValue, S1); - List contourLines = (List) cbs[0]; + List contourLines = (List) cbs[0]; List borders = (List) cbs[1]; if (isSmooth) { - contourLines = wcontour.Contour.smoothLines(contourLines); + contourLines = Contour.smoothLines(contourLines); } List contourPolygons = ContourDraw.tracingPolygons(gridData.data, contourLines, borders, cValues); @@ -3644,11 +3647,11 @@ public class GraphicFactory { ArrayUtils.reverse(yArray); Object[] cbs = ContourDraw.tracingContourLines(gridData.data, cValues, xArray, yArray, gridData.missingValue, S1); - List contourLines = (List) cbs[0]; + List contourLines = (List) cbs[0]; List borders = (List) cbs[1]; if (isSmooth) { - contourLines = wcontour.Contour.smoothLines(contourLines); + contourLines = Contour.smoothLines(contourLines); } List contourPolygons = ContourDraw.tracingPolygons(gridData.data, contourLines, borders, cValues); @@ -4970,9 +4973,9 @@ public class GraphicFactory { double[][] v = (double[][])ArrayUtil.copyToNDJavaArray_Double(vdata); double[] x = (double[]) ArrayUtil.copyToNDJavaArray_Double(xdata); double[] y = (double[]) ArrayUtil.copyToNDJavaArray_Double(ydata); - List streamlines = wcontour.Contour.tracingStreamline(u, v, + List streamlines = Contour.tracingStreamline(u, v, x, y, density); - wcontour.global.PolyLine line; + PolyLine line; for (int i = 0; i < streamlines.size() - 1; i++) { line = streamlines.get(i); PolylineShape aPolyline = new PolylineShape(); @@ -5011,18 +5014,18 @@ public class GraphicFactory { GraphicCollection3D graphics = new GraphicCollection3D(); double[][] u = (double[][]) ArrayUtil.copyToNDJavaArray_Double(ua); double[][] v = (double[][]) ArrayUtil.copyToNDJavaArray_Double(va); - List streamlines; + List streamlines; if (xa.getRank() == 1) { double[] x = (double[]) ArrayUtil.copyToNDJavaArray_Double(xa); double[] y = (double[]) ArrayUtil.copyToNDJavaArray_Double(ya); - streamlines = wcontour.Contour.tracingStreamline(u, v, + streamlines = Contour.tracingStreamline(u, v, x, y, density); } else { xa = xa.copyIfView(); ya = ya.copyIfView(); double[][] x = (double[][]) ArrayUtil.copyToNDJavaArray_Double(xa); double[][] y = (double[][]) ArrayUtil.copyToNDJavaArray_Double(ya); - streamlines = wcontour.Contour.tracingStreamline(u, v, + streamlines = Contour.tracingStreamline(u, v, x, y, density); } @@ -5030,7 +5033,7 @@ public class GraphicFactory { int nx = u[0].length; ColorBreak cb = ls.getLegendBreak(0); if (data == null) { - for (wcontour.global.PolyLine line : streamlines) { + for (PolyLine line : streamlines) { PolylineZShape shape = new PolylineZShape(); List points = new ArrayList<>(); PointZ p; @@ -5063,7 +5066,7 @@ public class GraphicFactory { graphics.add(new Graphic(shape, cb)); } } else { - for (wcontour.global.PolyLine line : streamlines) { + for (PolyLine line : streamlines) { PolylineZShape shape = new PolylineZShape(); List points = new ArrayList<>(); PointZ p; @@ -5144,18 +5147,18 @@ public class GraphicFactory { GraphicCollection3D graphics = new GraphicCollection3D(); double[][] u = (double[][]) ArrayUtil.copyToNDJavaArray_Double(ua); double[][] v = (double[][]) ArrayUtil.copyToNDJavaArray_Double(va); - List streamlines; + List streamlines; if (xa.getRank() == 1) { double[] x = (double[]) ArrayUtil.copyToNDJavaArray_Double(xa); double[] y = (double[]) ArrayUtil.copyToNDJavaArray_Double(ya); - streamlines = wcontour.Contour.tracingStreamline(u, v, + streamlines = Contour.tracingStreamline(u, v, x, y, density); } else { xa = xa.copyIfView(); ya = ya.copyIfView(); double[][] x = (double[][]) ArrayUtil.copyToNDJavaArray_Double(xa); double[][] y = (double[][]) ArrayUtil.copyToNDJavaArray_Double(ya); - streamlines = wcontour.Contour.tracingStreamline(u, v, + streamlines = Contour.tracingStreamline(u, v, x, y, density); } @@ -5163,7 +5166,7 @@ public class GraphicFactory { int nx = u[0].length; ColorBreak cb = ls.getLegendBreak(0); if (data == null) { - for (wcontour.global.PolyLine line : streamlines) { + for (PolyLine line : streamlines) { PolylineZShape shape = new PolylineZShape(); List points = new ArrayList<>(); PointZ p; @@ -5183,7 +5186,7 @@ public class GraphicFactory { graphics.add(new Graphic(shape, cb)); } } else { - for (wcontour.global.PolyLine line : streamlines) { + for (PolyLine line : streamlines) { PolylineZShape shape = new PolylineZShape(); List points = new ArrayList<>(); PointZ p; diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/GridLine.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/GridLine.java index b99c1dae..fc1ab86e 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/GridLine.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/GridLine.java @@ -5,7 +5,7 @@ */ package org.meteoinfo.chart.plot; -import org.meteoinfo.chart.legend.LineStyles; +import org.meteoinfo.geometry.legend.LineStyles; import java.awt.*; diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/MapPlot.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/MapPlot.java index 37586011..f74137af 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/MapPlot.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/MapPlot.java @@ -7,23 +7,23 @@ package org.meteoinfo.chart.plot; import org.meteoinfo.chart.*; 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.common.*; import org.meteoinfo.data.Dataset; import org.meteoinfo.data.mapdata.webmap.IWebMapPanel; import org.meteoinfo.data.mapdata.webmap.TileLoadListener; -import org.meteoinfo.drawing.Draw; -import org.meteoinfo.layer.LayerCollection; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.legend.*; -import org.meteoinfo.map.GridLabel; -import org.meteoinfo.map.MapView; +import org.meteoinfo.geo.drawing.Draw; +import org.meteoinfo.geo.layer.LayerCollection; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.legend.MapFrame; +import org.meteoinfo.geo.mapview.MapView; +import org.meteoinfo.geometry.graphic.Graphic; +import org.meteoinfo.geometry.graphic.GraphicCollection; +import org.meteoinfo.geometry.legend.*; +import org.meteoinfo.geometry.shape.*; import org.meteoinfo.projection.KnownCoordinateSystems; +import org.meteoinfo.projection.ProjectionInfo; import org.meteoinfo.projection.ProjectionUtil; import org.meteoinfo.projection.Reproject; -import org.meteoinfo.projection.info.ProjectionInfo; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/PiePlot.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/PiePlot.java index 12b4a3f9..3c421af6 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/PiePlot.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/PiePlot.java @@ -6,13 +6,13 @@ package org.meteoinfo.chart.plot; import org.meteoinfo.common.PointF; -import org.meteoinfo.drawing.Draw; -import org.meteoinfo.legend.ColorBreak; -import org.meteoinfo.legend.PolygonBreak; -import org.meteoinfo.shape.ArcShape; -import org.meteoinfo.shape.Graphic; -import org.meteoinfo.shape.GraphicCollection; -import org.meteoinfo.shape.Shape; +import org.meteoinfo.geo.drawing.Draw; +import org.meteoinfo.geometry.graphic.Graphic; +import org.meteoinfo.geometry.graphic.GraphicCollection; +import org.meteoinfo.geometry.legend.ColorBreak; +import org.meteoinfo.geometry.legend.PolygonBreak; +import org.meteoinfo.geometry.shape.ArcShape; +import org.meteoinfo.geometry.shape.Shape; import java.awt.*; import java.awt.geom.AffineTransform; diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/Plot.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/Plot.java index 01c0c523..0480d1ae 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/Plot.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/Plot.java @@ -6,6 +6,7 @@ package org.meteoinfo.chart.plot; import org.meteoinfo.chart.Margin; +import org.meteoinfo.data.Dataset; import java.awt.*; import java.awt.geom.Ellipse2D; @@ -261,7 +262,19 @@ public abstract class Plot { public void setOuterPositionArea(Rectangle2D value){ this.outerPositionArea = value; } - + + /** + * Get dataset + * @return Dataset + */ + public abstract Dataset getDataset(); + + /** + * Set dataset + * @param dataset Dataset + */ + public abstract void setDataset(Dataset dataset); + /** * Get plot type * @return Plot type diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/Plot2D.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/Plot2D.java index 1a49c74b..df83075c 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/Plot2D.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/Plot2D.java @@ -17,22 +17,21 @@ import org.meteoinfo.chart.ChartLegend; import org.meteoinfo.chart.ChartText; import org.meteoinfo.chart.axis.LogAxis; import org.meteoinfo.chart.axis.TimeAxis; -import org.meteoinfo.chart.graphic.Graphic; -import org.meteoinfo.chart.graphic.GraphicCollection; -import org.meteoinfo.chart.graphic.ImageGraphic; -import org.meteoinfo.chart.graphic.PolylineErrorShape; -import org.meteoinfo.chart.legend.*; import org.meteoinfo.common.Extent; import org.meteoinfo.common.MIMath; import org.meteoinfo.common.PointD; import org.meteoinfo.common.PointF; -import org.meteoinfo.chart.drawing.Draw; -import org.meteoinfo.geometry.geoprocess.GeometryUtil; -import org.meteoinfo.geo.shape.*; -import org.meteoinfo.geometry.shape.*; +import org.meteoinfo.data.Dataset; +import org.meteoinfo.geo.drawing.Draw; +import org.meteoinfo.geometry.graphic.Graphic; +import org.meteoinfo.geometry.graphic.GraphicCollection; +import org.meteoinfo.geometry.graphic.ImageGraphic; +import org.meteoinfo.geometry.legend.*; import org.meteoinfo.geometry.shape.Polygon; import org.meteoinfo.geometry.shape.Shape; -import org.meteoinfo.legend.*; +import org.meteoinfo.geometry.shape.*; +import org.meteoinfo.geometry.geoprocess.GeometryUtil; +import org.meteoinfo.chart.shape.PolylineErrorShape; import java.awt.*; import java.awt.geom.*; @@ -40,7 +39,7 @@ import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; -import static org.meteoinfo.chart.drawing.Draw.getHatchImage; +import static org.meteoinfo.geo.drawing.Draw.getHatchImage; /** * @@ -1195,6 +1194,16 @@ public class Plot2D extends AbstractPlot2D { } } + @Override + public Dataset getDataset() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void setDataset(Dataset dataset) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + /** * Get legend scheme * diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/Plot3D.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/Plot3D.java index d584c771..4410a742 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/Plot3D.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/Plot3D.java @@ -8,20 +8,17 @@ package org.meteoinfo.chart.plot; import org.meteoinfo.chart.*; import org.meteoinfo.chart.axis.Axis; import org.meteoinfo.chart.axis.LogAxis; -import org.meteoinfo.chart.graphic.Graphic; -import org.meteoinfo.chart.graphic.GraphicCollection; -import org.meteoinfo.chart.legend.*; import org.meteoinfo.chart.plot3d.GraphicCollection3D; 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.chart.drawing.Draw; -import org.meteoinfo.geo.shape.*; -import org.meteoinfo.geometry.shape.*; +import org.meteoinfo.common.*; +import org.meteoinfo.data.DataMath; +import org.meteoinfo.data.Dataset; +import org.meteoinfo.geo.drawing.Draw; +import org.meteoinfo.geometry.graphic.Graphic; +import org.meteoinfo.geometry.graphic.GraphicCollection; +import org.meteoinfo.geometry.legend.*; import org.meteoinfo.geometry.shape.Shape; +import org.meteoinfo.geometry.shape.*; import org.meteoinfo.math.sort.QuickSort; import java.awt.*; @@ -652,6 +649,16 @@ public class Plot3D extends Plot { return new Rectangle2D.Double(x, y, w, h); } + @Override + public Dataset getDataset() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void setDataset(Dataset dataset) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + @Override public PlotType getPlotType() { return PlotType.XYZ; @@ -1931,9 +1938,9 @@ public class Plot3D extends Plot { g.setColor(this.xAxis.getLineColor()); g.drawLine(x[0], y[0], projection.x, projection.y); if (projection.x > x[0]) { - value = MIMath.getDSFromUV(projection.x - x[0], projection.y - y[0]); + value = DataMath.getDSFromUV(projection.x - x[0], projection.y - y[0]); } else { - value = MIMath.getDSFromUV(x[0] - projection.x, y[0] - projection.y); + value = DataMath.getDSFromUV(x[0] - projection.x, y[0] - projection.y); } xangle = (float) value[0]; xlen = (float) value[1]; @@ -1946,9 +1953,9 @@ public class Plot3D extends Plot { g.setColor(this.yAxis.getLineColor()); g.drawLine(x[0], y[0], projection.x, projection.y); if (projection.x > x[0]) { - value = MIMath.getDSFromUV(projection.x - x[0], projection.y - y[0]); + value = DataMath.getDSFromUV(projection.x - x[0], projection.y - y[0]); } else { - value = MIMath.getDSFromUV(x[0] - projection.x, y[0] - projection.y); + value = DataMath.getDSFromUV(x[0] - projection.x, y[0] - projection.y); } yangle = (float) value[0]; ylen = (float) value[1]; @@ -1994,11 +2001,11 @@ public class Plot3D extends Plot { } } //projection = projector.project(vi, factor_y * 10.5f, -10); - value = MIMath.getEndPoint(tickpos.x, tickpos.y, angle, this.xAxis.getTickLength()); + value = DataMath.getEndPoint(tickpos.x, tickpos.y, angle, this.xAxis.getTickLength()); g.setColor(this.xAxis.getLineColor()); //g.drawLine(projection.x, projection.y, tickpos.x, tickpos.y); g.drawLine(tickpos.x, tickpos.y, (int) value[0], (int) value[1]); - value = MIMath.getEndPoint(tickpos.x, tickpos.y, angle, this.xAxis.getTickLength() + 5); + value = DataMath.getEndPoint(tickpos.x, tickpos.y, angle, this.xAxis.getTickLength() + 5); tickpos = new Point((int) value[0], (int) value[1]); if (x_left) { //outString(g, tickpos.x, tickpos.y, s, XAlign.LEFT, YAlign.TOP); @@ -2020,7 +2027,7 @@ public class Plot3D extends Plot { tickpos = projector.project(0, factor_y * 10.f, -10); Dimension dim = Draw.getStringDimension(label, g); strWidth = (int) Math.abs((strWidth * Math.sin(Math.toRadians(angle)))); - value = MIMath.getEndPoint(tickpos.x, tickpos.y, angle, this.xAxis.getTickLength() + strWidth + dim.height + 5); + value = DataMath.getEndPoint(tickpos.x, tickpos.y, angle, this.xAxis.getTickLength() + strWidth + dim.height + 5); tickpos.x = (int) value[0]; tickpos.y = (int) value[1]; if (this.projector.getElevationAngle() < 10) { @@ -2075,10 +2082,10 @@ public class Plot3D extends Plot { g.drawLine(x[0], y[0], projection.x, projection.y); } } - value = MIMath.getEndPoint(tickpos.x, tickpos.y, angle, this.xAxis.getTickLength()); + value = DataMath.getEndPoint(tickpos.x, tickpos.y, angle, this.xAxis.getTickLength()); g.setColor(this.yAxis.getLineColor()); g.drawLine(tickpos.x, tickpos.y, (int) value[0], (int) value[1]); - value = MIMath.getEndPoint(tickpos.x, tickpos.y, angle, this.xAxis.getTickLength() + 5); + value = DataMath.getEndPoint(tickpos.x, tickpos.y, angle, this.xAxis.getTickLength() + 5); tickpos = new Point((int) value[0], (int) value[1]); if (y_left) { //outString(g, tickpos.x, tickpos.y, s, XAlign.LEFT, YAlign.TOP); @@ -2100,7 +2107,7 @@ public class Plot3D extends Plot { tickpos = projector.project(factor_x * 10.f, 0, -10); Dimension dim = Draw.getStringDimension(label, g); strWidth = (int) Math.abs((strWidth * Math.sin(Math.toRadians(angle)))); - value = MIMath.getEndPoint(tickpos.x, tickpos.y, angle, this.yAxis.getTickLength() + strWidth + dim.height + 5); + value = DataMath.getEndPoint(tickpos.x, tickpos.y, angle, this.yAxis.getTickLength() + strWidth + dim.height + 5); tickpos.x = (int) value[0]; tickpos.y = (int) value[1]; if (this.projector.getElevationAngle() < 10) { diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/PolarPlot.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/PolarPlot.java index 8320257f..4f84630e 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/PolarPlot.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/PolarPlot.java @@ -6,14 +6,12 @@ package org.meteoinfo.chart.plot; import org.meteoinfo.chart.Margin; -import org.meteoinfo.common.Extent; -import org.meteoinfo.common.MIMath; -import org.meteoinfo.drawing.Draw; -import org.meteoinfo.global.DataConvert; -import org.meteoinfo.legend.LineStyles; +import org.meteoinfo.common.*; +import org.meteoinfo.geo.drawing.Draw; +import org.meteoinfo.geometry.graphic.Graphic; +import org.meteoinfo.geometry.graphic.GraphicCollection; +import org.meteoinfo.geometry.legend.LineStyles; import org.meteoinfo.ndarray.util.BigDecimalUtil; -import org.meteoinfo.shape.Graphic; -import org.meteoinfo.shape.GraphicCollection; import java.awt.*; import java.awt.geom.Ellipse2D; @@ -22,7 +20,7 @@ import java.awt.geom.Rectangle2D; import java.util.ArrayList; import java.util.List; -import static org.meteoinfo.drawing.Draw.getDashPattern; +import static org.meteoinfo.geo.drawing.Draw.getDashPattern; /** * diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/SeriesLegend.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/SeriesLegend.java index ad9fcb8c..c4b54c40 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/SeriesLegend.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/SeriesLegend.java @@ -5,10 +5,10 @@ */ package org.meteoinfo.chart.plot; -import org.meteoinfo.legend.ColorBreak; -import org.meteoinfo.legend.PointBreak; -import org.meteoinfo.legend.PolygonBreak; -import org.meteoinfo.legend.PolylineBreak; +import org.meteoinfo.geometry.legend.ColorBreak; +import org.meteoinfo.geometry.legend.PointBreak; +import org.meteoinfo.geometry.legend.PolygonBreak; +import org.meteoinfo.geometry.legend.PolylineBreak; import java.awt.*; import java.util.ArrayList; diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/XAlign.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/XAlign.java deleted file mode 100644 index 2051c40d..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/XAlign.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.plot; - -/** - * - * @author Yaqiang Wang - */ -public enum XAlign { - LEFT, - CENTER, - RIGHT -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/XY1DPlot.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/XY1DPlot.java index 93e78982..f679e711 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/XY1DPlot.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/XY1DPlot.java @@ -13,9 +13,9 @@ import org.meteoinfo.common.MIMath; import org.meteoinfo.common.PointF; import org.meteoinfo.common.colors.ColorUtil; import org.meteoinfo.data.*; -import org.meteoinfo.drawing.Draw; -import org.meteoinfo.legend.*; -import org.meteoinfo.shape.ShapeTypes; +import org.meteoinfo.geo.drawing.Draw; +import org.meteoinfo.geometry.legend.*; +import org.meteoinfo.geometry.shape.ShapeTypes; import java.awt.*; import java.awt.geom.AffineTransform; diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/YAlign.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/YAlign.java deleted file mode 100644 index e1a54afe..00000000 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/YAlign.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.chart.plot; - -/** - * - * @author Yaqiang Wang - */ -public enum YAlign { - TOP, - CENTER, - BOTTOM -} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot3d/GraphicCollection3D.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot3d/GraphicCollection3D.java index 92e8f32c..3b08cec7 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot3d/GraphicCollection3D.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot3d/GraphicCollection3D.java @@ -5,7 +5,7 @@ */ package org.meteoinfo.chart.plot3d; -import org.meteoinfo.chart.graphic.GraphicCollection; +import org.meteoinfo.geometry.graphic.GraphicCollection; import java.util.List; diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot3d/Projector.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot3d/Projector.java index 2fb6900f..2db40e75 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot3d/Projector.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot3d/Projector.java @@ -21,7 +21,7 @@ *----------------------------------------------------------------------------------------*/ package org.meteoinfo.chart.plot3d; -import org.meteoinfo.common.MIMath; +import org.meteoinfo.data.DataMath; import java.awt.*; import java.util.ArrayList; @@ -425,7 +425,7 @@ public final class Projector { Point p2 = project(x2, y2, z2); float u = p2.x - p1.x; float v = p2.y - p1.y; - return MIMath.getDSFromUV(u, v); + return DataMath.getDSFromUV(u, v); } /** diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/shape/PolylineErrorShape.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/shape/PolylineErrorShape.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/shape/PolylineErrorShape.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/shape/PolylineErrorShape.java index b7ca812d..c930160c 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/shape/PolylineErrorShape.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/shape/PolylineErrorShape.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.shape; +package org.meteoinfo.chart.shape; import org.meteoinfo.geometry.shape.PolylineShape; import org.meteoinfo.geometry.shape.ShapeTypes; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/plot/PlotUtil.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/util/PlotUtil.java similarity index 95% rename from MeteoInfoLib/src/main/java/org/meteoinfo/plot/PlotUtil.java rename to meteoinfo-chart/src/main/java/org/meteoinfo/chart/util/PlotUtil.java index 995c58a7..fba71fa2 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/plot/PlotUtil.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/util/PlotUtil.java @@ -3,11 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.plot; - -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.List; +package org.meteoinfo.chart.util; import org.meteoinfo.chart.Chart; import org.meteoinfo.chart.ChartPanel; @@ -19,6 +15,10 @@ import org.meteoinfo.data.XYArrayDataset; import org.meteoinfo.data.XYDataset; import org.meteoinfo.geometry.legend.PointBreak; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.List; + /** * * @author yaqiang @@ -83,8 +83,8 @@ public class PlotUtil { * @param chart The chart * @param width Width * @param height Heigth - * @throws java.io.FileNotFoundException - * @throws java.lang.InterruptedException + * @throws FileNotFoundException + * @throws InterruptedException */ public static void exportToPicture(String fileName, Chart chart, int width, int height) throws FileNotFoundException, InterruptedException { diff --git a/MeteoInfoMap/src/main/resources/images/TSMI_AttriData.Image.png b/meteoinfo-chart/src/main/resources/images/AttributeTable.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/TSMI_AttriData.Image.png rename to meteoinfo-chart/src/main/resources/images/AttributeTable.png diff --git a/meteoinfo-chart/src/main/resources/images/Edit_tool.png b/meteoinfo-chart/src/main/resources/images/Edit_tool.png new file mode 100644 index 0000000000000000000000000000000000000000..534f615c57f14cc4faa014436134527c5772680f GIT binary patch literal 302 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4UEa{HEjtmSN`?>!lvVtU&J%W50 z7^>757#dm_7=8hT8eT9klo~KFyh>nTu$sZZAYL$MSD+10f+@+{-G$+Qd;gjJK%S?k zi(`n#@wb-^`9M}U{{NqOMWXpuW%io9>Sc^xmBB1*3Kx$_USxFPVGt0W(8=PG#Hy0S z&hm(5UFRLAZ~yrosD6qsIAck`FbAg7cmbgZgq$HN4S|t~y0x1R~149#C zLjzp{lMq95D^qhT15<4SBP#;~84n(F6b-rgDVb@NSTqmdKI;Vst E0Js}fuK)l5 literal 0 HcmV?d00001 diff --git a/MeteoInfoMap/src/main/resources/images/TSB_LabelSet.Image.png b/meteoinfo-chart/src/main/resources/images/Label.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/TSB_LabelSet.Image.png rename to meteoinfo-chart/src/main/resources/images/Label.png diff --git a/MeteoInfoMap/src/main/resources/images/Layers.png b/meteoinfo-chart/src/main/resources/images/Layers.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/Layers.png rename to meteoinfo-chart/src/main/resources/images/Layers.png diff --git a/MeteoInfoMap/src/main/resources/images/MeteoInfo_1_16x16x8.png b/meteoinfo-chart/src/main/resources/images/MeteoInfo.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/MeteoInfo_1_16x16x8.png rename to meteoinfo-chart/src/main/resources/images/MeteoInfo.png diff --git a/MeteoInfoLab/src/main/resources/images/Pan_Open_32x32x32.png b/meteoinfo-chart/src/main/resources/images/Pan_Open_32x32x32.png similarity index 100% rename from MeteoInfoLab/src/main/resources/images/Pan_Open_32x32x32.png rename to meteoinfo-chart/src/main/resources/images/Pan_Open_32x32x32.png diff --git a/meteoinfo-chart/src/main/resources/images/Properties.png b/meteoinfo-chart/src/main/resources/images/Properties.png new file mode 100644 index 0000000000000000000000000000000000000000..c629822fcc76983c285d2835bdcd144312f3035c GIT binary patch literal 714 zcmV;*0yX`KP)ZaRE4y z?avkmUK|^tK9U{KC_Jsbce}qvqe#T#sBLZrqZF~VHAsX&mSxB$6W-puWSTlhh?EU* zSL~5jXYQv=dn;>d8XFN9A4hR{IW$#8Y;_g-#s-+Kqo}UE{?n{~lPHQ(0-zp19sn%U z&lR?!eMhPs4g|ek)VbXVdcAPBw}a|Bl8FTL%}xAV|MElCxP>sroIO1~eKwn|GPd{{ zsgHg*o0>5?JdBRcPWUD#akQ-sq3LNHayVcxhWC+o@#Wc9A0!daMZ+-iR8_59Sy{ot z4MC~4>b z05HaI;P4q3hJmLKZlJj3Jo5H8fO8H?sh9y^jKMW=5aH8{2!%qhTCK>*$$`maLaEb( zQl}?9B~cXr4wyN$07@xbE?34_DWw^ANs=-Fx~_|qQq1@Fp{joXb8~Yro6YHjR4N6t z*_^i3)z#2-eH)-@n#dSKMej9GN@2I#cU@t|7&J}W3Fv#0kL#XwM59q85(!wXRscw! zEfxz33kxBN;tl{|jN$6ZZ=e(?D=YhFbxJ7+A<#4}{fCIEszeY3$g;fa)3+oD0#sEc w0P+EB2)Vhr7bQt5_^<5kKE#sAqz^#+H=gZBiQ&3KmH+?%07*qoM6N<$f&|b&{r~^~ literal 0 HcmV?d00001 diff --git a/meteoinfo-chart/src/main/resources/images/TSB_Add.Image.png b/meteoinfo-chart/src/main/resources/images/TSB_Add.Image.png new file mode 100644 index 0000000000000000000000000000000000000000..d76f26b94d8011dfc51103e43c166f2bb6c7ce66 GIT binary patch literal 175 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85o4Xn6XD`Cp%Ek#nZ(x#KJ#0VS(WfeiQkYlWYmhQc_YU%u-Y& z8Mt$UGArIpSS4s&;27B2w=k2zSte3;A&b$ZMS|fG0Wxen8w8H0GBX^gFEZI=vi2{~ OJO)o!KbLh*2~7ag@h)Ki literal 0 HcmV?d00001 diff --git a/meteoinfo-chart/src/main/resources/images/TSB_Area.Image.png b/meteoinfo-chart/src/main/resources/images/TSB_Area.Image.png new file mode 100644 index 0000000000000000000000000000000000000000..95892dc43e10a4bb1eb880fcc9833859487e46d4 GIT binary patch literal 165 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sEXgD|57Yp@DX(8|-rF~q_@IbnfWz@1lL<>ilM%PXEWs9e(~ zuv&7p;*zXm1}Rq<*xC{W*cME2U1hG})hqIpJu5wqjiJdY=gD6c6<(kz44$rjF6*2U FngGlnEwlgt literal 0 HcmV?d00001 diff --git a/meteoinfo-chart/src/main/resources/images/TSB_Del.Image.png b/meteoinfo-chart/src/main/resources/images/TSB_Del.Image.png new file mode 100644 index 0000000000000000000000000000000000000000..29bbd5b6a4586337f2bc574d5a9cf0c115b3d3bd GIT binary patch literal 149 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85o4Xn6XD`Cp%D3%hSa%#KJ#0L4x(L2FpL@zfOE@?2MMP{+pYa nG<h=u>w$%gz*1_G^~0wMx}J@)s`o;`aK zh(ToUS^I)tdV8PE+IH#4jVDjp-c_#;zoqm0@}mCr8X^bp^Sx%g8ofn&+m`p{I>}3B zOW2gzo?gi6w;J2TuddJ;DxbJ$=trI2x+r)Gh zJQ=nGO`1D--!*x879Cpjzxvx7#q$k|-TVKYKY8lVT1y*~FaMYO&o9vG;OYNS z|Nmd@n@?X$zy5b@oIGn%*HwW%jN3CGAN#Ms>`=#YvmuY;UITL`gC(z}-$mYo(gkj9 zZ4rN2jaft2z3a?Bbv~Y$Tb2=lr_7CTalz`2SEry3C{AXV=ch)(*-RxK7s_pF` zHo1u^WIj1sm0r(mb0%5fbIfYan$*-aX_ME-bgbAJHsRa#8_gw)((h*#X3vR9+~L^c zx{<#jo8iLh^Cym6-cxAY(Ce7FE}J)w+4i6fvr@}sn?CEA47<$T-mO@E>zu)w!hYM% zpS%%{9Ly5F}^)SALrClk!hbpPUz7 gGU3gku=+>br!psXvGpFd2ZkJjr>mdKI;Vst0Q2mh!2kdN literal 0 HcmV?d00001 diff --git a/meteoinfo-chart/src/main/resources/images/TSB_Feature.Image.png b/meteoinfo-chart/src/main/resources/images/TSB_Feature.Image.png new file mode 100644 index 0000000000000000000000000000000000000000..69e7744c8c266ac6c397116f18bd5a94e77ee35c GIT binary patch literal 394 zcmV;50d@X~P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGizW@LZzX3P}QzQTY0Ut?3K~y+Tg;TK+ zgD?#APVD3r*nm2%M@W$!s8Xqh5pqY9P^VD*vSo~|9KO>5#(KS8Z#Rx3Td}Syzn3R7 z`5XgN$U%X1xp|(sjcJ;y#0U@*nGgU=Ai)p3Z5y8el!+YVSVa#@WgoXQ5Wc;Wy^aBa zUQ_AyS{Q+rP#ugYxX8lw3_uM(aR>*H1gg3S;Qs)i#p8aH#1w;6-uGSd@hl7p!p1*u6{1-oD!Mf81%7d8qZc{Fi1YqXeiVuc*sHeCZnzj^QjY@42xDhS3k#~ ze`9OL9p*2L!FlRt$7b9+Q?$`y5%W`#-7Dt3s%pHMFRee}`=6OBUgyl4Dc literal 0 HcmV?d00001 diff --git a/MeteoInfoMap/src/main/resources/images/TSB_Open.Image.png b/meteoinfo-chart/src/main/resources/images/TSB_Open.Image.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/TSB_Open.Image.png rename to meteoinfo-chart/src/main/resources/images/TSB_Open.Image.png diff --git a/MeteoInfoLab/src/main/resources/images/TSB_Pan.Image.png b/meteoinfo-chart/src/main/resources/images/TSB_Pan.Image.png similarity index 100% rename from MeteoInfoLab/src/main/resources/images/TSB_Pan.Image.png rename to meteoinfo-chart/src/main/resources/images/TSB_Pan.Image.png diff --git a/meteoinfo-chart/src/main/resources/images/TSB_Reverse.Image.png b/meteoinfo-chart/src/main/resources/images/TSB_Reverse.Image.png new file mode 100644 index 0000000000000000000000000000000000000000..545db110ddf13cbc816bc25b955adc42e94dd29e GIT binary patch literal 652 zcmV;70(1R|P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGma{vGma{-JZxd#9M0wGC6K~y+TjgxIi zlVKEwU+a$)MG^fig@lkkEJ742Bm`w(1%l;|f~kQ-Lu1i2L{lf)#Igvr59nLWFbdY9 z`eCU>VPV1`sBJXo?A`XxIY(ghdEfJu*t)cycCgyd` z^J3=UJYG9*%tQamk1CrNhx!6hh{ftb#S)!J=9tPJdXU@r6$&o~t5+UO$)li%#WZg*`x9VX^ORKat*I!W)bbg}?z%uC=`31( z$}L@EF?LT}GoRNzg9BYo(5tlePoltL7XZmD`qyBd0CuNW-bD7<_b9sVki;hAv_Rq& ze}au?+}LM!Aj>e8_$}m^KBDm2PwZ)*L1vwbZB0Ijt14XLXQY{VHca{w&-IK*BERiB z_IFNU$3?FI)>pfccG7{(1{ZcWI;AsfSNyRuD{TVWRc}X5lT%FD=j~$Ls<-{$AK7qo m1VzSY$T~3~;+%V_x-J3}G(AY6mO7yT0000JwO=7#^rzMejCrmvzzY^dm;~Wf=~;OMnvr!dyZrYhRF<)4gA-0?0!SEEVwLN zt@rYDYk|i1@G-$Lu z{QrMHgRme+Jwx}}o!@wR40#+pUOY5SIKFrLe@BVK3@t2m%zZZh!R|^(c+mPQoWFVdQ&MBb@ E0DL5iC;$Ke literal 0 HcmV?d00001 diff --git a/meteoinfo-chart/src/main/resources/images/TSB_Up.Image.png b/meteoinfo-chart/src/main/resources/images/TSB_Up.Image.png new file mode 100644 index 0000000000000000000000000000000000000000..f0b8186351d736587a32953421cebc59c824e917 GIT binary patch literal 383 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85o4Xn6XD`Cp%Dsh^LEVh=qUehcH@7h4r#+5QF?s4H^vB~9W6oLOMdw#4tqWeH+PT-|cqBvP&#a7=%93Y{ zr3daEwCJAs@{Y*@yPFTT#GZ~@by(%!6GhW6DICmwM;f}PF<-OZc;iLli(aOiJG#>E zb$k4hJs@@Var^!z){aD`9*s|TTN?P(Ch}!>r?DT9x?a>iYjoU%ng7sV(N;wr1bE a2fShvCUxm?`o;hQjlt8^&t;ucLK6UPew-%& literal 0 HcmV?d00001 diff --git a/MeteoInfoLab/src/main/resources/images/TSB_ZoomIn.Image.png b/meteoinfo-chart/src/main/resources/images/TSB_ZoomIn.Image.png similarity index 100% rename from MeteoInfoLab/src/main/resources/images/TSB_ZoomIn.Image.png rename to meteoinfo-chart/src/main/resources/images/TSB_ZoomIn.Image.png diff --git a/MeteoInfoLab/src/main/resources/images/TSB_ZoomOut.Image.png b/meteoinfo-chart/src/main/resources/images/TSB_ZoomOut.Image.png similarity index 100% rename from MeteoInfoLab/src/main/resources/images/TSB_ZoomOut.Image.png rename to meteoinfo-chart/src/main/resources/images/TSB_ZoomOut.Image.png diff --git a/MeteoInfoMap/src/main/resources/images/TSB_ZoomToLayer.Image.png b/meteoinfo-chart/src/main/resources/images/TSB_ZoomToLayer.Image.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/TSB_ZoomToLayer.Image.png rename to meteoinfo-chart/src/main/resources/images/TSB_ZoomToLayer.Image.png diff --git a/meteoinfo-chart/src/main/resources/images/VertexEdit_32x32x32.png b/meteoinfo-chart/src/main/resources/images/VertexEdit_32x32x32.png new file mode 100644 index 0000000000000000000000000000000000000000..5969c27ff8586def4c2042a0cd7723826ccdbf9e GIT binary patch literal 175 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzwj^(N7l!{JxM1({$v}}5PZ!6K zh{JEETJr&wI$!*KU$Q(ogzJarFEMuAX$?wFc234kVh=vW`p#fvEv?^h%0)Ix{MOoQ ze{)wEW^-EDn>MgD`+i}&ulK T^|rPF?PKtC^>bP0l+XkKlkhwQ literal 0 HcmV?d00001 diff --git a/MeteoInfoLab/src/main/resources/images/find.png b/meteoinfo-chart/src/main/resources/images/ZoomToLayer.png similarity index 100% rename from MeteoInfoLab/src/main/resources/images/find.png rename to meteoinfo-chart/src/main/resources/images/ZoomToLayer.png diff --git a/MeteoInfoLab/src/main/resources/images/identifer_32x32x32.png b/meteoinfo-chart/src/main/resources/images/identifer_32x32x32.png similarity index 100% rename from MeteoInfoLab/src/main/resources/images/identifer_32x32x32.png rename to meteoinfo-chart/src/main/resources/images/identifer_32x32x32.png diff --git a/MeteoInfoLab/src/main/resources/images/information.png b/meteoinfo-chart/src/main/resources/images/information.png similarity index 100% rename from MeteoInfoLab/src/main/resources/images/information.png rename to meteoinfo-chart/src/main/resources/images/information.png diff --git a/meteoinfo-chart/src/main/resources/images/insert_vertice.png b/meteoinfo-chart/src/main/resources/images/insert_vertice.png new file mode 100644 index 0000000000000000000000000000000000000000..adfb1914eebfaaff2a143e3fb77306606bf875ce GIT binary patch literal 234 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzwj^(N7l!{JxM1({$v~0$o-U3d z5r^M~UF2#o;P|rW|Np12Pf9F4VVo===g~W{d|qD4wG0)aH#O;~5iI!rgw) e#TPUFFtK0OuQ^s4x8fbpsSKX3elF{r5}E*cW?e-9 literal 0 HcmV?d00001 diff --git a/meteoinfo-chart/src/main/resources/images/loading.png b/meteoinfo-chart/src/main/resources/images/loading.png new file mode 100644 index 0000000000000000000000000000000000000000..c65be32c23e470023ef11171cfe8eea1872231d6 GIT binary patch literal 3318 zcmVjzP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=00004XF*Lt006O$eEU(80000WV@Og>004R=004l4008;_004mL004C` z008P>0026e000+nl3&F}0006JNkl!&15YZtR4M^M zaH`bR(W#(&Ko_A95S*MH-JD!3Iu*gGLs4*YDilJYLZ)JA_&NA1gpjn)=GI&5IdHjf z&!2lf-h20)%d1G@GRPG!i3CW11W14cNPq-LfCR|-$<@EG$0AS#hQRi}1TqIa0#<=L z6ZD(FTi`WtkZRLP;`_)7@Cs-GA3eS~;W?lU-1XQ2o&fKX>?|qOSl4g)AgLHxZ+X2n zvevep>^JlNsUW&esy9JbSXWHY^{ne&1dwG(N0MGn(Vql@{f->x%z32vMz(w^-So*c zE(P!fxCVTkpszXx!1Y{pV5Due)8j5BwLYyI5C8xG07*qoM6N<$f_Kp< ARR910 literal 0 HcmV?d00001 diff --git a/meteoinfo-chart/src/main/resources/images/rotate.png b/meteoinfo-chart/src/main/resources/images/rotate.png new file mode 100644 index 0000000000000000000000000000000000000000..35e33771764865cd7cb6c71ab8d9f2094a2ebf37 GIT binary patch literal 410 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4UEa{HEjtmSN`?>!lvVtU&J%W50 z7^>757#dm_7=8hT8eT9klo~KFyh>nTu$sZZAYL$MSD+10f+@+{-G$+Qd;gjJKpuOE zr>`sfLv~&+9a%QDC$E7*i#%N%Lp+YZopO-xumX>Ba`ylKr|%`Q%wlTvy31Saq~YJ0 zocOINWtLrL=o$IMo(UUVF3f%*C}g%PVYaf;9+_$72Um-Rvnl25nbM|4A8bMtM2+Cu-T|?s#Ljx-l6DuQ2Z381K1A|4Cy7y2tNw! Mr>mdKI;Vst0N7237ytkO literal 0 HcmV?d00001 diff --git a/meteoinfo-chart/src/main/resources/images/star.bmp b/meteoinfo-chart/src/main/resources/images/star.bmp new file mode 100644 index 0000000000000000000000000000000000000000..15737cdab2e436c6830a1cce49913d80b9293889 GIT binary patch literal 17476 zcmeHu2UwF=`}eVGRU9Y|K#-XP5+DhLKo%j8Kp?EJWp4#!smO4FpeQ(T?_Ec$);e0X zt=3k%YinEW($@8M*yY}}|NB1AlMvLl_HF&H>$|S^NFa%t-@Vtl35^NR5qbi;5#kBY z8req|(v!a5>06hMS6#YvAx}N^6zSTvE9us)8|mJ?J9+x)r%8_AF;N!CjI;OCj$lyAT~BOWZ=MoWYC~NWboj@WXO;q#Mai9 z*xA_;dwY8_bm&mx;NU8jXg8goKdL&`_e)YKcy# zBVl1-Bs@Hv==FLM5fMQmBO{5yU?5RZQ6xG#n#9D!kl5H*5*HUoj7B4gkB=t_2?-=I zF_9!CC6VOhWRjASLQ+#x$?)OBNm^PONl#BF85tQQGc%K9Wo41<>}-;glS6WIb4gxa z9?8$oCj|usq_D7%6crVb5hF&Bkt0Wv;^JabQc^-nOH0Y9QKLv%Ss5uWFDDfh6{NDV zl2lbykBQd3hyYHMprU0ofiudgTL$B!oyCQKj`Cr%`j zCQTxfCr>5~4GpBRv5`!fGKDlXHIe4#W-@i^R5ESaG}6-2LZ(ljPG-!QL0Vf|Nn2YR znK^SNnKf$`nLT?pnKNe&nLBqbnKy49X>V^Q^XJbe3l=OO3l}aVixw>+ix)2@OO`Al zOP4Ms%a$!8%a<=FD^{!^D_5>0t5&Tdt5>fkYu2nGYuBzN>(;F!>({R*8#Zhp8#itw z&ph)C*|cdB*}Qo(*|KE|*}8QrdG^_7$#c&=N49O-Mz(L?PIm0rL7sp9d9rioPV&MF zFOXfkc9Gq?cauGP_K>}M_mUT1e388L(o1CDzI|l>{{7^@fdk~_mtQ8Yyz&Zp_0?C& z!Gj0Mp+kqrYp=aV4j(>DUVr^{^2Qr)kRwNqkfTSBk~iOclf3oTTjcGx-zM+8^A36U z-FL}*@4ZLffB${*!3Q6ZW54?p~neDu*r#x5i-+c28IdkR=IeYdjId|?H zIe-2FTeak ze*N`Va_Q0~a{2OQa^=bua`oy}a_!nRa{c;sa^uDga`Wa*a_iPDa{Kmea_7z+a`*0C za_`;y(0+x@7e!X5`dW9=@5wF|8EWp3kjp+m`Qo!Bp?!l+qLUc zkg(u9^%Q*J>GBk%<4Mub1!PRI8Q^YRAy+bop#v!aBJex`67XZ;;}OaPOMiAZzrw$w zqIeP%P;^W1?%kkFFrRKL8I*>9T?i)DSym}36et#lz6BJ)zd$LV9{x2Qm{>=2#G$ZI z8!@LR^W*6r@HRsQC7~-dgnxkslh!-1DInBkJ$v@*#XRT>B!r;>2}MN!4gZ(`gl8;{ zGTx&{&mMpYUsg~RT3NvtKEZ=TAZb(#R94;oF#!zo^us{x@Zpqc1jPgOC_Pra=}U$R zRtnv^gGRdjLpuO?kRre%?<{x+FqFdP!_a}U0O3#)Ksh}?3+M~~r4r1{o6vzlmTAC+ zBD~}D>5G)~rgET~=+P5i^Z+w}fB^RU-%x;NkK9v>N2Rmq3^vsN{rXw=v$m#B;2RLb zl0a>tci+B<|KCdhxo2cgMUUX1a0EwS=0Nj-hrR$}fCeN1{$a1)*8Q!mz#owU8jk*^ z1Q?%ZG!Ke5u?|ckI7Nl7XTSg(8~OvjAsJK*sE6LxHa7iwp(`*V_`51#WY5|iIveng zDrdkE77nyq?4d8sG=LPW2Mr$B7u^v<66)Y@5^zsf4(9FZZXGn=XL&2aS&Ky@eGy@<2L;z;Uy1`=!z{EYoZ-57n zN7(~9Fh3Z8~$Y&V&T#90iH!4fM&;{ zI}W4Rt{g6x5CIQI2X`NDjvZLy!vtVH{)<$=C?B&O<=)IZDjs>K z=&r7A?p#j+--FBL@;n7zo?H&c-ObI_oy&D|a`pE0b{%RvgdqTRV3Gh6ivLssCgro- z_hAi>W!}Nj33vo>4u|XEB@zidJv=?V#bPf{9tZ*66Yx2%e2GNhIt&N^5wJ!81W-3b z0{+wq03K`~(k*Zgw%4aG>vdpvVDTt;WSzt1d3f-J{{A8uN_mN;Qjvhq_w?ZLeMH_| zPl?>0@9yGYM+snbfD-7{6TOhu1Ai<53XheGN%)M@Q_VX%ySjnSsmS?!fw!+*;V%*j zMN*~0&&SJ4z!!-8r9w|%rAi{;xj2F$f&^GAq;5#P@J|DAC+P$C)b9okLU<6pE05

d+4zqH zV6uH=pN1U_ItY(;=j_h+_7;kTUIH&~AAnbA!Zk9vLaq+i%KXG4kw_Y(k@+gZ!&Ux5 zo(ni55P&vdL*oEy0Fn`A<3IEPlkHRKQ_t&w2i0@!c)={ zBGi6-a7H&E0Brz`a6o@H3NR-4Xa%s+2ji!4kJ=viy`8-ydL4v0PrgtV8Wt9*Qw0Rd z6q=}nw2U}oLQG0lLPTU(a7avQygnsAD^af$V`O3pKsSU)XbM9e1UwuEK>XcU-$T#0 z2IWJ{wRdoGqfW;cc=<>*QBg55VL=L|Dl|4VJ1-?^cv5CTN^D%D)-XKFm^h*&J3%M& z6MFGIcnkrM6EPA}6QC{tsSv86u4smxt$=DD0xxy_KK&r!qUnR(M#&ESdSZB;ED9%dHNiQf)OG=J0B<1HM7mX>+jtfx)NJKzDhXg%XQIuDdTT-5#nQlzT zEzK#Ytu4(kgsPQ+zCu(17@-s6g&2sz1W*9z+P$qH7(NQ0iM&?58RMhUcXUF>3sfr5 z*A>dp`0Sj5ocM^y=%j**>WbpBk)y{H7Um>pmX#OPG}jd;N9na1xxd&)07mHUiZ+NE zKodj(^ajR265xv6yLIB9X*QV1%fx*f8h9Y%xVn4zNY&a9O=w6+XlPXC$dM&E39*U8 zi^kU1RF18zs~uHVkX2GsS>4)Fla~}16%nG6L6i`90s-g*Gzw4)um+KWE|8F((3@Hs zfMx8VfftPrUC-GCOkW^Y=%OMc;2t8%P5v0emO(qxhEWGsXw-ZX8JQKK^P$ zVuCRtJ|RA-U~El&MQ-+pvI#BICr_C?qj`K?*_furmX(VdOY*YP5@RC6Lxbc}u{SjV zs(~ScZSCQsoE+?J2M-)z-MeS^uAK`JHuliOhuWvUXE)Rl&>`9KA@0kxap@Up8R;46 zIhB(dCRY@djcJ%QZ$@j&+_vV))r~XTR&8vrEge~qnUW9}6{Zae@b&Qm6QBZs&*AWR z?kEep!2|kQJ^fG;FpHmN{eGRVn=w2wHcF?G`U<@To@fCs?jBw~-aw11v!mTWYqWj9 z@1%VgEMncku#ZI#t9@s8PobZ`6tauNU#5;qFDV~YUS3gN+cs}b!}zAQW$Rb1T)uAE zqP96J*Y19CW#jmos*<9-%+#bP2-1FHDgd59B$4=uz#O^GLkC-<>C-}_a}Z|g9y2}_ zKZG7HnsK$Yb#*O^moJ#sHh+hUr!+N9TfAZ8;svX=zO;AG-hD4@S^xYi@4vgHeO5~YNMKZ9 zN|Y`{qgDn;0#qS7EjUAfpBKl`c3^*NEJTj00gU)fnUBf4=zK1&9FSjNaAbT+ zN}@5!U`#8X*fw+4>^TcJ?|N?CmOXF0`Nol>2lwnb^6?jMtXsNZCP-jhNk&3!R8)j6 zRHu)MiHZo*r~-ssCp*YO7Ni=xlZzV{j9&}{BxM)mXQ!p4=T|f> zSh94*s?GZk?S1j^@y|}2IC<>IdtaSDbzt+_rR_6YCRgTXrl+PPB_^e&0?9G@kU)`# zGgPBk4YO(3lmspKH{nCW(-*8CLq8S2JNmxJH&7jsm^-SfqNHdm#SdqKxz@;($lu$zh%$9SB{)KbNZW$SK#XF$BS34 z{c_^Sft_2|%xS2rsjjITKWW0aijld)V>D844<-a)C5Dj?LLXG(PzM6O*#J!5Ps>hB zeFL%Vfz0F1L+&NgK$$W)%$QM9KYjMhY18Mf-uvbUpPagQ>C$z$WxH`5zW;pc_|ccQ zEuS@Gdh4ut?X#yhj4RJiF=zsPp*4XZ3`qcMVOoZu0n&j$hX7c7m^Lsy2Y5f?J44AQ z^b3%y)S3{jP9Kw$IdWXf;?*mcuYLZ_FVA1Ra^uF$TX3}pj~kc2J$3xmt!q}V+qikt zx@B{xjjzZ}GK44td_@?9+?+89(Ig1n7+VHfL?EX0=#HgFZ-_o*n=qSAV_m*^%d$%@{wXvaGZi;&6)5pj8Eky*%8V8GPyh z7=a!L0JQY#2GJKAe(HWS^}BFT0Ll=3Y*I#kNoDnfrWtdWtlGG3?`t1^bLqzIyT38$ zzyE&!x4U<4-MIGS$=9~7m_Mg&+LQ@nM-^lwMCsIWf036b2NDltel`MGIG{-Z6d%J6 z>;91YY4n5WBY+654ue`dXJl2~lo|7uZP>o==*OpjxC-pE+#?nD@7}up^H=X4*tuzC z`}9fGWrdk3@zD`lHPoU)0T1yp^V0~(@J|E4Bk)b`5BN0t34DB|N=8-+%GWzGv4goHccF-I(%``I*BLV)UV^Kwodbrw&N_0Hz9N z0?@L z&zPK^Q&>__T|as1tVL_K?SKFD&)09=F`FNVA3X5th2w{wU%OxiFkf1flb#$Otq%qJ z6AO5VkNT$p@Xzs?^uyR66kmKFUyy&WHr!xLO3y8>s&AUPbn~7!K0W)(^_zDr><{p7 zTsn8+t^M0p&6`?RQJ4v`57Pue;UV(j^PmlIq?M=H{-FA|OaRpX(f`==!}$L&sJtQj zi6wzSp^?Va+>$Zlr_Ecs{<%E|-}~abtCs!;{NK8M>FlusJ2tLf*52A!Q&x~3Z_ozG zpbx>}*hBXJFuu9-WaA%9T%hTOo*PU+r8OjE6qb*hG2w? z$x2I(iwsps#a?XTZ7Kl3{~s(s82NYa0iC}&|JXUez)2vILi~+QNKQ@5$SEkP96xpT z{AC+nIQ;%cC%?ab<2EE8%s&u)Z{E0e<;bbasBd@ zD?gq8bpN`A^XJcNZLF&rkr5ve8l;d({e%K2K+ye6`S(!;C>wy8`ok1}oZKP$ilO|M zDMKRS((+5n%12LVU9e*9n&q1he|+-nRV+U6T)*<`x8IyQ_tmFw?OfX0*w8d(!kE&+ ztRzFI68m5eG(S`Q0rO}UAKFio`Ux>7fL@jX5bWQBFYxgTRENib1+iT)uYg%H>Pno;m%|JI6kH@Adtg=S``ps2EdSQIwSuAEj0LL-MEf zA9a76g3tmS>z_{eT{`MtHUZKCgqGi6|B+GAF^Sou#??=5ZmgRyd&BnUcOE%+>HD)^ zfA_<87tUQc_0h4n_w70G>b_muSI?-g9Fdb-G$J27Ff3Rh@$ux)z7HGE4)gDnevp5h z{g~SyY`=J#ESAwQIH=J%8rJhsVA=^~H%#PJZ(G zE3fW(X495!Th^~x+*DPPml~g#nwDzR2g^YK99I1%^F#B0u>Pg^Yyk!ZDBwc|b{q!v zzd-2g9}pBCpOKR{qO>GGr)2W11qU4S;C?IADV?*^Et08lIh# zo|IBp+dQLf>g>fkKR&u=*N#1h4jy=E*GmU>uUox-ZTrkQGw021ZE3D4NQ#fv1u27q zgVhRu9}hPttUefgs{V)Y83h17ox0Nsj0ylNa4$baXm~_ad~!mp!I)iHKdG_4v2Ee2 zN49O+wD!5(yS8uJv~|a}mFnLJ0@JG4#ck6Um_Af`3co8s-NvY z5x=AQ#47N?1`ua&v;>0LQvfici!|u9p@y{L%Ieyx>c*z^hn`)za@nE{TQ{v=w_??X z4J%rw&z{>-JHEcAwzg(WRY{sYNCBY-?gwCE&UJOPNA{up>J5`08vXE2+EjibK5GCd z0D9{{QxKHk5CZ-DWkDKEkWv+vm^-4hvbdzCX8O+U3)>gWnZ0Vw$|XzM+m|h0(lT+% zv}twaV@H>jmzR}{%ufmp^b-kS2^}ZL{FHy}Kw(0ZQ+grv}Pna~ZtY}nmL4JNgUQUKF z7<(UxeK?24>nKzA3B~V&=4TRssRPF0D<}Xh5C*@{g26q9M5T|1p;uaRUUA{%4a*uE znj7nz=FXnk(lQmsF>TYvmR44e8R$|fPy3pEij+&B?=6Qj5emgxH&g-rlNY{gbCyF(sQ8iPLGL)@snN`853jBtHm5A9Dp*t zFV#Lazts94!p9td_kPR-%z6Mc!7zM>dmkXc)5l+-3eksYbg{ijte(LhiNq`jXok=s}gf)ig(}Pt9$PuBIw!xVI4`rXdhF=Rl9G~we3*$<6vamwQ&Q5B!b5brAeGEt7OV|X zE5sb;DiTucVge049h*z!|21&<4q*P>g6o(#O~34A08VO-s(N zDuale4;EJho7zQ5Vc{`GW1>N=P^$u9{wkKMRf+%+XDHr;c7nH@Juv2n2GB_W-~!YK z(FC9n<#~&JMNo?=<@%8|g~p`R%v7T>r*uR?KJ1gHC1&O2<>se^skM=jQBj%zX`nyW zy?lvW2K^Vuo`yb}`PtFOBiLtS5MKYVEQ?Y(@bvgfx%gXdMDRKnY+jz&r*1(Ya~bAm~TJ)IkxcFl2}~ zz)W5n78`4fHAX6YAy-RfGG9JizChe_up8>ihXD-F&3*tg_yXgzY&E+|l;PmGU=jt?LBz`SkkFc8IMb z*Av2^i~Ru8+~*I)&su;<0PH1<1p%&Hp*Ar}<`*be2L<>AhQ%2o^x?s3H4KL}I&GLX zOeKbkX}GEK!I}pgA8#KA+PQGxB50W104un4qU=A?`lu+t1(+bjR>J55CKbT_0oOkw zO64PxNaX=yp;T+oX+uI3a+xduf`eKUq*40vaS?#$!Ef6#f)$`G5Pnqd1AK)(-d-?ghnskbROAVZAh3x7+~dV3d;Q<1-#|N>1o~USt=k_=7Q~9$dRY;OT8Wh-v?< zI+gt|LQIM$wpc}w8Fxj z5K4x-GqZ%mGLK;ovkt5t^yfB2U7xU1`cuI^IdT33wNKKoZURV zG0M=z9~XLDU0q!1-Uo`_wE00du;|3M2W(_w41BulUr7L+5TgLjLnr~10(*B4H+zVN z;0j2BGuH!xj593c;0hM*U(qkLJBE2Iw?X#EJu`6a4%2N~{r&|3D1gocfC#JyI&$2H z;?^JTpAEGi>f{Omp01xUD`>F$g-dW9=+yGe3vjsj(X~6>1cUPD&m~|c0963x5Y@pD zCs)To5RP&05J`Zg2uI8HJ6wLF;9&J&_LO<5dUpE^93OnUJDUI=w7Sl(O$4A9Fgobd zA6E)-?Gp?Uq`(M)**#?U4}mVae`rEC%bxZd>;`5R5bU2uAeImy)ntT7fK{J?xKRn7 z0KN!902=7pCFB?28Icj2S-?czsogW&!_p0{_YoDv4j=qr>Difi`U=Ak62MqtFROlo z?Q93occ?fSAcHx&q9s&5kTht591oX7(KWK;z-Tehu zz!g}k3Dfp1{=~&o+z^9QI*F-=9UuW_l0pk&pK;?k;z&sde5IZY)RD6f%ALz9^qx{(` z@Iy4ir(r4v5gZ7>6?hN=rGZj`l+c6F80s6+kcsCxi=AYKcGrBLx!?loHsh!PgAu ztmLWFQRe@?<~wKuyMd5Jd4ccf3n&DJ28c_b4)%enVK~QlgS=DGvq7ih1ONUr8jR5u z;h0D;5rKp-4=QvZ?rDhdX3_r(=twV6z@$Vo2~-Y%hIGJ#J_8Fu=uY7OMD!MtqGo`u zK!t!(fP;7zhk26~Jmxz1PZl5XPoJV8VgfbMz!Jft!Vi=UHF%n6|6On-9%Vpjz+e8e z_|-oK*947>Bj^7n>t@m6=Q1Rq7)(^4Qkd5!>?eax$uN_^>Vg4=?}!Zt|K3dR6L|uk vk3wL~fdMrmKXGuDBVZ93?R=gHxBvUl|4HD64Dk++0igc_&VjO- literal 0 HcmV?d00001 diff --git a/MeteoInfoLab/src/main/resources/images/zoom_in_32x32x32.png b/meteoinfo-chart/src/main/resources/images/zoom_in_32x32x32.png similarity index 100% rename from MeteoInfoLab/src/main/resources/images/zoom_in_32x32x32.png rename to meteoinfo-chart/src/main/resources/images/zoom_in_32x32x32.png diff --git a/MeteoInfoLab/src/main/resources/images/zoom_out_32x32x32.png b/meteoinfo-chart/src/main/resources/images/zoom_out_32x32x32.png similarity index 100% rename from MeteoInfoLab/src/main/resources/images/zoom_out_32x32x32.png rename to meteoinfo-chart/src/main/resources/images/zoom_out_32x32x32.png diff --git a/meteoinfo-data/pom.xml b/meteoinfo-data/pom.xml index 9012bbc9..9819e34e 100644 --- a/meteoinfo-data/pom.xml +++ b/meteoinfo-data/pom.xml @@ -16,6 +16,14 @@ 1.8 + + + unidata-all + Unidata All + https://artifacts.unidata.ucar.edu/repository/unidata-all/ + + + ${project.groupId} diff --git a/meteoinfo-data/src/main/java/org/meteoinfo/data/mapdata/geotiff/compression/DeflateCompression.java b/meteoinfo-data/src/main/java/org/meteoinfo/data/mapdata/geotiff/compression/DeflateCompression.java deleted file mode 100644 index c9ca0ea7..00000000 --- a/meteoinfo-data/src/main/java/org/meteoinfo/data/mapdata/geotiff/compression/DeflateCompression.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.data.mapdata.geotiff.compression; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.nio.ByteOrder; -import java.util.zip.DataFormatException; -import java.util.zip.Deflater; -import java.util.zip.Inflater; - -/** - * - * @author wyq - */ -public class DeflateCompression implements CompressionDecoder, CompressionEncoder { - - @Override - public byte[] decode(byte[] bytes, ByteOrder byteOrder) { - try { - Inflater inflater = new Inflater(); - inflater.setInput(bytes); - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(bytes.length); - byte[] buffer = new byte[1024]; - while (!inflater.finished()) { - int count = inflater.inflate(buffer); - outputStream.write(buffer, 0, count); - } - outputStream.close(); - byte[] output = outputStream.toByteArray(); - - return output; - } catch (IOException e) { - throw new TiffException("Failed close decoded byte stream", e); - } catch (DataFormatException e) { - throw new TiffException("Data format error while decoding stream", e); - } - } - - @Override - public boolean rowEncoding() { - return false; - } - - @Override - public byte[] encode(byte[] bytes, ByteOrder byteOrder) { - try { - Deflater deflater = new Deflater(); - deflater.setInput(bytes); - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(bytes.length); - deflater.finish(); - byte[] buffer = new byte[1024]; - while (!deflater.finished()) { - int count = deflater.deflate(buffer); // returns the generated code... index - outputStream.write(buffer, 0, count); - } - - outputStream.close(); - byte[] output = outputStream.toByteArray(); - return output; - } catch (IOException e) { - throw new TiffException("Failed close encoded stream", e); - } - } -} diff --git a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/MeteoDataInfo.java b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/MeteoDataInfo.java index bf2e4b94..80fcd1d8 100644 --- a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/MeteoDataInfo.java +++ b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/MeteoDataInfo.java @@ -22,6 +22,9 @@ import org.meteoinfo.data.meteodata.arl.ARLDataInfo; import org.meteoinfo.data.meteodata.ascii.ASCIIGridDataInfo; import org.meteoinfo.data.meteodata.ascii.LonLatStationDataInfo; import org.meteoinfo.data.meteodata.ascii.SurferGridDataInfo; +import org.meteoinfo.data.meteodata.awx.AWXDataInfo; +import org.meteoinfo.data.meteodata.bandraster.BILDataInfo; +import org.meteoinfo.data.meteodata.bandraster.GeoTiffDataInfo; import org.meteoinfo.data.meteodata.grads.GrADSDataInfo; import org.meteoinfo.data.meteodata.hysplit.HYSPLITConcDataInfo; import org.meteoinfo.data.meteodata.hysplit.HYSPLITPartDataInfo; @@ -43,9 +46,6 @@ import org.meteoinfo.data.meteodata.mm5.MM5DataInfo; import org.meteoinfo.data.meteodata.mm5.MM5IMDataInfo; import org.meteoinfo.data.mathparser.MathParser; import org.meteoinfo.data.mathparser.ParseException; -import org.meteoinfo.data.meteodata.awx.AWXDataInfo; -import org.meteoinfo.data.meteodata.bandraster.BILDataInfo; -import org.meteoinfo.data.meteodata.bandraster.GeoTiffDataInfo; import org.meteoinfo.data.meteodata.metar.METARDataInfo; import org.meteoinfo.data.meteodata.synop.SYNOPDataInfo; import org.meteoinfo.ndarray.Array; diff --git a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/ascii/ASCIIGridDataInfo.java b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/ascii/ASCIIGridDataInfo.java index 9f4ed6d4..2ec229b6 100644 --- a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/ascii/ASCIIGridDataInfo.java +++ b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/ascii/ASCIIGridDataInfo.java @@ -15,6 +15,7 @@ package org.meteoinfo.data.meteodata.ascii; import org.meteoinfo.common.MIMath; import org.meteoinfo.data.GridData; +import org.meteoinfo.data.meteodata.MeteoDataType; import org.meteoinfo.data.meteodata.DataInfo; import org.meteoinfo.ndarray.Dimension; import org.meteoinfo.ndarray.DimensionType; @@ -34,7 +35,6 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import org.meteoinfo.data.GridArray; -import org.meteoinfo.data.meteodata.MeteoDataType; import org.meteoinfo.ndarray.Array; import org.meteoinfo.ndarray.DataType; import org.meteoinfo.ndarray.IndexIterator; diff --git a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/bandraster/BILDataInfo.java b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/bandraster/BILDataInfo.java index be0a96af..194f1c73 100644 --- a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/bandraster/BILDataInfo.java +++ b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/bandraster/BILDataInfo.java @@ -28,11 +28,11 @@ import java.util.logging.Logger; import org.meteoinfo.common.DataConvert; import org.meteoinfo.data.GridArray; import org.meteoinfo.data.GridData; +import org.meteoinfo.data.meteodata.MeteoDataType; import org.meteoinfo.data.meteodata.DataInfo; import org.meteoinfo.ndarray.Dimension; import org.meteoinfo.ndarray.DimensionType; import org.meteoinfo.data.meteodata.IGridDataInfo; -import org.meteoinfo.data.meteodata.MeteoDataType; import org.meteoinfo.data.meteodata.Variable; import org.meteoinfo.ndarray.Array; import org.meteoinfo.ndarray.DataType; diff --git a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/bandraster/GeoTiffDataInfo.java b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/bandraster/GeoTiffDataInfo.java index 874ccd0a..7b329845 100644 --- a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/bandraster/GeoTiffDataInfo.java +++ b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/bandraster/GeoTiffDataInfo.java @@ -22,12 +22,12 @@ import java.util.logging.Logger; import org.meteoinfo.data.GridArray; import org.meteoinfo.data.GridData; import org.meteoinfo.data.mapdata.geotiff.GeoTiff; +import org.meteoinfo.data.meteodata.MeteoDataType; import org.meteoinfo.data.meteodata.DataInfo; import org.meteoinfo.ndarray.math.ArrayMath; import org.meteoinfo.ndarray.Dimension; import org.meteoinfo.ndarray.DimensionType; import org.meteoinfo.data.meteodata.IGridDataInfo; -import org.meteoinfo.data.meteodata.MeteoDataType; import org.meteoinfo.data.meteodata.Variable; import org.meteoinfo.ndarray.Array; import org.meteoinfo.ndarray.IndexIterator; diff --git a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/grads/GrADSDataInfo.java b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/grads/GrADSDataInfo.java index 2b2a7512..92c75543 100644 --- a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/grads/GrADSDataInfo.java +++ b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/grads/GrADSDataInfo.java @@ -17,6 +17,7 @@ import org.meteoinfo.common.DataConvert; import org.meteoinfo.common.Extent; import org.meteoinfo.common.util.JDateUtil; import org.meteoinfo.data.GridData; +import org.meteoinfo.data.meteodata.arl.ARLDataInfo; import org.meteoinfo.data.meteodata.DataInfo; import org.meteoinfo.ndarray.Dimension; import org.meteoinfo.ndarray.DimensionType; @@ -52,7 +53,6 @@ import org.meteoinfo.data.meteodata.IStationDataInfo; import org.meteoinfo.data.meteodata.MeteoDataType; import org.meteoinfo.data.meteodata.StationInfoData; import org.meteoinfo.data.meteodata.StationModelData; -import org.meteoinfo.data.meteodata.arl.ARLDataInfo; import org.meteoinfo.ndarray.Array; import org.meteoinfo.ndarray.DataType; import org.meteoinfo.ndarray.IndexIterator; diff --git a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/grads/VARDEFS.java b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/grads/VARDEFS.java index 26cb0acd..e889c03a 100644 --- a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/grads/VARDEFS.java +++ b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/grads/VARDEFS.java @@ -14,6 +14,7 @@ package org.meteoinfo.data.meteodata.grads; import org.meteoinfo.data.meteodata.Variable; + import java.util.ArrayList; import java.util.List; diff --git a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/grib2/GRIB2MessageIndex.java b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/grib2/GRIB2MessageIndex.java index 9c81e185..e93cbb6b 100644 --- a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/grib2/GRIB2MessageIndex.java +++ b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/grib2/GRIB2MessageIndex.java @@ -5,6 +5,7 @@ package org.meteoinfo.data.meteodata.grib2; import java.util.Date; + import org.meteoinfo.data.meteodata.Variable; /** diff --git a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/hysplit/HYSPLITConcDataInfo.java b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/hysplit/HYSPLITConcDataInfo.java index 9c0c0c71..0355956b 100644 --- a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/hysplit/HYSPLITConcDataInfo.java +++ b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/hysplit/HYSPLITConcDataInfo.java @@ -15,6 +15,7 @@ package org.meteoinfo.data.meteodata.hysplit; import org.meteoinfo.common.DataConvert; import org.meteoinfo.common.util.JDateUtil; +import org.meteoinfo.data.meteodata.arl.ARLDataInfo; import org.meteoinfo.data.meteodata.ascii.ASCIIGridDataInfo; import org.meteoinfo.data.GridData; import org.meteoinfo.data.meteodata.DataInfo; @@ -34,7 +35,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.meteoinfo.data.GridArray; import org.meteoinfo.data.meteodata.MeteoDataType; -import org.meteoinfo.data.meteodata.arl.ARLDataInfo; import org.meteoinfo.ndarray.Array; import org.meteoinfo.ndarray.DataType; import org.meteoinfo.ndarray.IndexIterator; @@ -226,7 +226,7 @@ public class HYSPLITConcDataInfo extends DataInfo implements IGridDataInfo { yDim.setValues(Y); this.setYDimension(yDim); this.addDimension(yDim); - List variables = new ArrayList<>(); + List variables = new ArrayList<>(); //Record #4 br.skipBytes(8); diff --git a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/hysplit/HYSPLITTrajDataInfo.java b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/hysplit/HYSPLITTrajDataInfo.java index 04cdf10e..a889b0c0 100644 --- a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/hysplit/HYSPLITTrajDataInfo.java +++ b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/hysplit/HYSPLITTrajDataInfo.java @@ -16,13 +16,13 @@ package org.meteoinfo.data.meteodata.hysplit; import org.meteoinfo.common.DataConvert; import org.meteoinfo.common.PointD; import org.meteoinfo.common.util.JDateUtil; +import org.meteoinfo.data.meteodata.Attribute; import org.meteoinfo.data.meteodata.DataInfo; -import org.meteoinfo.geometry.legend.*; +import org.meteoinfo.data.meteodata.MeteoDataType; +import org.meteoinfo.data.meteodata.Variable; import org.meteoinfo.ndarray.Dimension; import org.meteoinfo.ndarray.DimensionType; -import org.meteoinfo.data.meteodata.Variable; -import java.awt.Color; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; @@ -36,11 +36,6 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import org.meteoinfo.data.XYListDataset; -import org.meteoinfo.data.meteodata.MeteoDataType; -import org.meteoinfo.geometry.shape.PointZ; -import org.meteoinfo.geometry.shape.PointZShape; -import org.meteoinfo.geometry.shape.PolylineZShape; -import org.meteoinfo.geometry.shape.ShapeTypes; import org.meteoinfo.table.ColumnData; import org.meteoinfo.table.DataColumn; import org.meteoinfo.table.DataTable; @@ -50,8 +45,6 @@ import org.meteoinfo.ndarray.Index; import org.meteoinfo.ndarray.InvalidRangeException; import org.meteoinfo.ndarray.Range; import org.meteoinfo.ndarray.Section; -import org.meteoinfo.data.meteodata.Attribute; -import org.meteoinfo.table.Field; /** * diff --git a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/micaps/MICAPS2DataInfo.java b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/micaps/MICAPS2DataInfo.java index 4f58960e..b512d05a 100644 --- a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/micaps/MICAPS2DataInfo.java +++ b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/micaps/MICAPS2DataInfo.java @@ -39,7 +39,7 @@ import org.meteoinfo.data.meteodata.Attribute; * * @author Yaqiang Wang */ -public class MICAPS2DataInfo extends DataInfo implements IStationDataInfo{ +public class MICAPS2DataInfo extends DataInfo implements IStationDataInfo { // private String _description; private List _varList = new ArrayList<>(); diff --git a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/micaps/MICAPS7DataInfo.java b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/micaps/MICAPS7DataInfo.java index 08e27c4b..a64e33cb 100644 --- a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/micaps/MICAPS7DataInfo.java +++ b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/micaps/MICAPS7DataInfo.java @@ -13,7 +13,6 @@ */ package org.meteoinfo.data.meteodata.micaps; -import java.awt.Color; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; @@ -28,21 +27,14 @@ import java.util.logging.Logger; import org.meteoinfo.common.PointD; import org.meteoinfo.common.util.JDateUtil; +import org.meteoinfo.data.meteodata.Attribute; import org.meteoinfo.data.meteodata.DataInfo; -import org.meteoinfo.geometry.legend.LegendScheme; -import org.meteoinfo.geometry.legend.LegendType; -import org.meteoinfo.ndarray.Dimension; -import org.meteoinfo.ndarray.DimensionType; import org.meteoinfo.data.meteodata.MeteoDataType; import org.meteoinfo.data.meteodata.Variable; import org.meteoinfo.data.meteodata.hysplit.TrajectoryInfo; -import org.meteoinfo.ndarray.DataType; -import org.meteoinfo.geometry.shape.PointShape; -import org.meteoinfo.geometry.shape.PolylineShape; -import org.meteoinfo.geometry.shape.ShapeTypes; +import org.meteoinfo.ndarray.Dimension; +import org.meteoinfo.ndarray.DimensionType; import org.meteoinfo.ndarray.Array; -import org.meteoinfo.data.meteodata.Attribute; -import org.meteoinfo.table.Field; /** * diff --git a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/micaps/MICAPSDataInfo.java b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/micaps/MICAPSDataInfo.java index edafbefa..1a156f35 100644 --- a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/micaps/MICAPSDataInfo.java +++ b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/micaps/MICAPSDataInfo.java @@ -14,6 +14,7 @@ package org.meteoinfo.data.meteodata.micaps; import org.meteoinfo.data.meteodata.MeteoDataType; + import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; diff --git a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/netcdf/NCUtil.java b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/netcdf/NCUtil.java index ba854943..8c0953fe 100644 --- a/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/netcdf/NCUtil.java +++ b/meteoinfo-data/src/main/java/org/meteoinfo/data/meteodata/netcdf/NCUtil.java @@ -9,6 +9,7 @@ import java.util.ArrayList; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; + import org.meteoinfo.data.meteodata.Attribute; import org.meteoinfo.data.meteodata.Variable; import org.meteoinfo.ndarray.*; diff --git a/meteoinfo-geo/meteoinfo-geo.iml b/meteoinfo-geo/meteoinfo-geo.iml index f37e9381..ca5caf2c 100644 --- a/meteoinfo-geo/meteoinfo-geo.iml +++ b/meteoinfo-geo/meteoinfo-geo.iml @@ -38,7 +38,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/meteoinfo-geo/pom.xml b/meteoinfo-geo/pom.xml index e73a40fa..545207f6 100644 --- a/meteoinfo-geo/pom.xml +++ b/meteoinfo-geo/pom.xml @@ -16,6 +16,29 @@ 1.8 + + + central + Maven Central + https://repo1.maven.org/maven2/ + + + freehep + freehep + http://java.freehep.org/maven2/ + + + boundless + boundlessgeo + http://repo.boundlessgeo.com/main/ + + + ebi + ebiRepo + http://www.ebi.ac.uk/intact/maven/nexus/content/repositories/ebi-repo/ + + + ${project.groupId} @@ -32,6 +55,16 @@ meteoinfo-table ${project.version} + + ${project.groupId} + meteoinfo-image + ${project.version} + + + ${project.groupId} + meteoinfo-data + ${project.version} + ${project.groupId} wContour @@ -42,6 +75,56 @@ l2fprod-common-all 0.1 + + org.apache.commons + commons-lang3 + 3.12.0 + + + org.scilab.forge + jlatexmath + 1.0.7 + + + com.formdev + flatlaf + 1.0 + + + com.formdev + flatlaf-extras + 1.0 + + + org.freehep + freehep-util + 2.0.2 + + + org.freehep + freehep-graphicsio-emf + 2.4 + + + org.freehep + freehep-graphicsio-pdf + 2.4 + + + org.freehep + freehep-graphics2d + 2.4 + + + org.freehep + freehep-graphicsio-ps + 2.4 + + + com.itextpdf + itextpdf + 5.5.7 + \ No newline at end of file diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/analysis/GeoComputation.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/analysis/GeoComputation.java index 041d3d65..3e97e4dd 100644 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/analysis/GeoComputation.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/analysis/GeoComputation.java @@ -5,7 +5,7 @@ import org.meteoinfo.common.Extent; import org.meteoinfo.common.MIMath; import org.meteoinfo.common.PointD; import org.meteoinfo.geo.layer.VectorLayer; -import org.meteoinfo.geo.mapview.GridLabel; +import org.meteoinfo.common.GridLabel; import org.meteoinfo.geometry.geoprocess.BorderPoint; import org.meteoinfo.geometry.shape.Line; import org.meteoinfo.geometry.shape.PolygonShape; diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/analysis/GeometryUtil.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/analysis/GeometryUtil.java new file mode 100644 index 00000000..33bdfb45 --- /dev/null +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/analysis/GeometryUtil.java @@ -0,0 +1,956 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.meteoinfo.geo.analysis; + +import org.locationtech.jts.geom.Coordinate; +import org.locationtech.jts.geom.Geometry; +import org.locationtech.jts.geom.GeometryFactory; +import org.meteoinfo.common.Extent; +import org.meteoinfo.common.Extent3D; +import org.meteoinfo.common.PointD; +import org.meteoinfo.geo.layer.VectorLayer; +import org.meteoinfo.geometry.shape.*; +import org.meteoinfo.ndarray.Array; +import org.meteoinfo.ndarray.DataType; +import org.meteoinfo.ndarray.IndexIterator; +import org.meteoinfo.ndarray.InvalidRangeException; +import org.meteoinfo.ndarray.math.ArrayMath; + +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author wyq + */ +public class GeometryUtil { + + /** + * Get extent from point list + * + * @param PList point list + * @return extent + */ + public static Extent getPointsExtent(List PList) { + if (PList.get(0) instanceof PointZ){ + Extent3D cET = new Extent3D(); + for (int i = 0; i < PList.size(); i++) { + PointZ aP = (PointZ)PList.get(i); + if (i == 0) { + cET.minX = aP.X; + cET.maxX = aP.X; + cET.minY = aP.Y; + cET.maxY = aP.Y; + cET.minZ = aP.Z; + cET.maxZ = aP.Z; + } else { + if (cET.minX > aP.X) { + cET.minX = aP.X; + } else if (cET.maxX < aP.X) { + cET.maxX = aP.X; + } + + if (cET.minY > aP.Y) { + cET.minY = aP.Y; + } else if (cET.maxY < aP.Y) { + cET.maxY = aP.Y; + } + + if (cET.minZ > aP.Z) { + cET.minZ = aP.Z; + } else if (cET.maxZ < aP.Z) { + cET.maxZ = aP.Z; + } + } + } + + return cET; + } else { + Extent cET = new Extent(); + for (int i = 0; i < PList.size(); i++) { + PointD aP = PList.get(i); + if (i == 0) { + cET.minX = aP.X; + cET.maxX = aP.X; + cET.minY = aP.Y; + cET.maxY = aP.Y; + } else { + if (cET.minX > aP.X) { + cET.minX = aP.X; + } else if (cET.maxX < aP.X) { + cET.maxX = aP.X; + } + + if (cET.minY > aP.Y) { + cET.minY = aP.Y; + } else if (cET.maxY < aP.Y) { + cET.maxY = aP.Y; + } + } + } + + return cET; + } + } + + /** + * Get extent of the shapes + * + * @param shapes + * @return Extent + */ + public static Extent getExtent(List shapes) { + Extent extent = (Extent) shapes.get(0).getExtent().clone(); + double minx = extent.minX; + double maxx = extent.maxX; + double miny = extent.minY; + double maxy = extent.maxY; + Extent ext; + for (int i = 1; i < shapes.size(); i++) { + ext = shapes.get(i).getExtent(); + if (minx > ext.minX) { + minx = ext.minX; + } + if (maxx < ext.maxX) { + maxx = ext.maxX; + } + if (miny > ext.minY) { + miny = ext.minY; + } + if (maxy < ext.maxY) { + maxy = ext.maxY; + } + } + + extent.minX = minx; + extent.maxX = maxx; + extent.minY = miny; + extent.maxY = maxy; + + return extent; + } + + /** + * Get extent of the points + * + * @param points + * @return Extent + */ + public static Extent3D getExtent(PointZ[] points) { + PointZ p = points[0]; + double minx = p.X; + double maxx = p.X; + double miny = p.Y; + double maxy = p.Y; + double minz = p.Z; + double maxz = p.Z; + for (int i = 1; i < points.length; i++) { + if (minx > p.X) { + minx = p.M; + } + if (maxx < p.X) { + maxx = p.M; + } + if (miny > p.Y) { + miny = p.Y; + } + if (maxy < p.Y) { + maxy = p.Y; + } + if (minz > p.Z) { + minz = p.Z; + } + if (maxz < p.Z) { + maxz = p.Z; + } + } + + Extent3D extent = new Extent3D(); + extent.minX = minx; + extent.maxX = maxx; + extent.minY = miny; + extent.maxY = maxy; + extent.minZ = minz; + extent.maxZ = maxz; + + return extent; + } + + /** + * Get ellipse coordinate + * @param x0 Center x + * @param y0 Center y + * @param a Major axis + * @param b Minor axis + * @param angle Angle + * @return Coordinate on the ellipse + */ + public static PointD getEllipseXY(double x0, double y0, double a, double b, double angle) { + double rangle = Math.toRadians(angle); + double x = (a * b) / Math.sqrt(b * b + a * a * Math.tan(rangle) * Math.tan(rangle)); + if (angle > 90 && angle < 270){ + x = -x; + } + double y = Math.tan(rangle) * x; + if (angle > 0 && angle < 180) { + y = -Math.abs(y); + } + + return new PointD(x + x0, y + y0); + } + + /** + * Get ellipse coordinates + * @param x0 Center x + * @param y0 Center y + * @param a Major axis + * @param b Minor axis + * @param deltaAngle Delta angle + * @return Coordinate on the ellipse + */ + public static List getEllipseCoordinates(double x0, double y0, double a, double b, double deltaAngle) { + List points = new ArrayList<>(); + for (double angle = 0; angle <= 360; angle += deltaAngle){ + points.add(getEllipseXY(x0, y0, a, b, angle)); + } + + return points; + } + + /** + * Get ellipse coordinates + * @param x0 Center x + * @param y0 Center y + * @param a Major axis + * @param b Minor axis + * @return Coordinate on the ellipse + */ + public static List getEllipseCoordinates(double x0, double y0, double a, double b) { + List points = new ArrayList<>(); + double deltaAngle = 1; + for (double angle = 0; angle <= 360; angle += deltaAngle){ + points.add(getEllipseXY(x0, y0, a, b, angle)); + } + + return points; + } + + /** + * Computes the smallest convex Polygon that contains all the + * points + * + * @param x X array + * @param y Y array + * @return PolygonShape + */ + public static PolygonShape convexHull(Array x, Array y) { + int n = (int) x.getSize(); + List geos = new ArrayList<>(); + GeometryFactory factory = new GeometryFactory(); + IndexIterator xIter = x.getIndexIterator(); + IndexIterator yIter = y.getIndexIterator(); + double xx, yy; + while(xIter.hasNext()) { + xx = xIter.getDoubleNext(); + yy = yIter.getDoubleNext(); + if (!Double.isNaN(xx) && !Double.isNaN(yy)) { + Coordinate c = new Coordinate(xx, yy); + geos.add(factory.createPoint(c)); + } + } + Geometry gs = factory.createGeometryCollection(geos.toArray(new Geometry[geos.size()])); + Geometry ch = gs.convexHull(); + return new PolygonShape(ch); + } + + /** + * In polygon function + * + * @param a Array a + * @param x X dimension values + * @param y Y dimension values + * @param layer Polygon vector layer + * @return Result array with cell values of 1 inside polygons and -1 outside + * polygons + */ + public static Array inPolygon(Array a, List x, List y, VectorLayer layer) { + List polygons = (List) layer.getShapes(); + return inPolygon(a, x, y, polygons); + } + + /** + * In polygon function + * + * @param a Array a + * @param x X dimension values + * @param y Y dimension values + * @param ps Polygon shape + * @return Result array with cell values of 1 inside polygons and -1 outside + * polygons + */ + public static Array inPolygon(Array a, List x, List y, PolygonShape ps) { + List polygons = new ArrayList<>(); + polygons.add(ps); + return inPolygon(a, x, y, polygons); + } + + /** + * In polygon function + * + * @param a Array a + * @param x X dimension values + * @param y Y dimension values + * @param polygons PolygonShape list + * @return Result array with cell values of 1 inside polygons and -1 outside + * polygons + */ + public static Array inPolygon(Array a, List x, List y, List polygons) { + if (a.getRank() == 2) { + int xNum = x.size(); + int yNum = y.size(); + + Array r = Array.factory(DataType.INT, a.getShape()); + for (int i = 0; i < yNum; i++) { + for (int j = 0; j < xNum; j++) { + if (GeoComputation.pointInPolygons(polygons, new PointD(x.get(j).doubleValue(), y.get(i).doubleValue()))) { + r.setInt(i * xNum + j, 1); + } else { + r.setInt(i * xNum + j, -1); + } + } + } + + return r; + } else if (a.getRank() == 1) { + int n = x.size(); + Array r = Array.factory(DataType.INT, a.getShape()); + for (int i = 0; i < n; i++) { + if (GeoComputation.pointInPolygons(polygons, new PointD(x.get(i).doubleValue(), y.get(i).doubleValue()))) { + r.setInt(i, 1); + } else { + r.setInt(i, -1); + } + } + + return r; + } + + return null; + } + + /** + * In polygon function + * + * @param x X coordinates + * @param y Y coordinates + * @param polygons PolygonShape list + * @return Result boolean array + */ + public static Array inPolygon(Array x, Array y, List polygons) { + Array r = Array.factory(DataType.BOOLEAN, x.getShape()); + IndexIterator xIter = x.getIndexIterator(); + IndexIterator yIter = y.getIndexIterator(); + IndexIterator rIter = r.getIndexIterator(); + while (rIter.hasNext()){ + if (GeoComputation.pointInPolygons(polygons, new PointD(xIter.getDoubleNext(), + yIter.getDoubleNext()))) { + rIter.setBooleanNext(true); + } else { + rIter.setBooleanNext(false); + } + } + + return r; + } + + /** + * In polygon function + * + * @param a Array a + * @param x X dimension values + * @param y Y dimension values + * @param x_p X coordinate of the polygon + * @param y_p Y coordinate of the polygon + * @return Result array with cell values of 1 inside polygons and -1 outside + * polygons + */ + public static Array inPolygon(Array a, List x, List y, List x_p, List y_p) { + PolygonShape ps = new PolygonShape(); + List points = new ArrayList<>(); + for (int i = 0; i < x_p.size(); i++) { + points.add(new PointD(x_p.get(i).doubleValue(), y_p.get(i).doubleValue())); + } + ps.setPoints(points); + List shapes = new ArrayList<>(); + shapes.add(ps); + + return inPolygon(a, x, y, shapes); + } + + /** + * In polygon function + * + * @param x X coordinates + * @param y Y coordinates + * @param x_p X coordinate of the polygon + * @param y_p Y coordinate of the polygon + * @return Result boolean array + */ + public static Array inPolygon(Array x, Array y, Array x_p, Array y_p) { + PolygonShape ps = new PolygonShape(); + List points = new ArrayList<>(); + IndexIterator xIter = x_p.getIndexIterator(); + IndexIterator yIter = y_p.getIndexIterator(); + while (xIter.hasNext()) { + points.add(new PointD(xIter.getDoubleNext(), yIter.getDoubleNext())); + } + ps.setPoints(points); + List shapes = new ArrayList<>(); + shapes.add(ps); + + return inPolygon(x, y, shapes); + } + + /** + * Maskout function + * + * @param a Array a + * @param x X dimension values + * @param y Y dimension values + * @param layer VectorLayer + * @param missingValue Missing value + * @return Result array with cell values of missing outside polygons + */ + public static Array maskout(Array a, List x, List y, VectorLayer layer, Number missingValue) { + List polygons = (List) layer.getShapes(); + return maskout(a, x, y, polygons, missingValue); + } + + /** + * Maskout function + * + * @param a Array a + * @param x X dimension values + * @param y Y dimension values + * @param polygon Polygon shape + * @param missingValue Missing value + * @return Result array with cell values of missing outside polygons + */ + public static Array maskout(Array a, List x, List y, PolygonShape polygon, Number missingValue) { + List polygons = new ArrayList<>(); + polygons.add(polygon); + return maskout(a, x, y, polygons, missingValue); + } + + /** + * Maskout function + * + * @param a Array a + * @param x X Array + * @param y Y Array + * @param polygons Polygons for maskout + * @return Result array with cell values of missing outside polygons + */ + public static Array maskout(Array a, Array x, Array y, List polygons) { + Array r = Array.factory(a.getDataType(), a.getShape()); + IndexIterator aIter = a.getIndexIterator(); + IndexIterator xIter = x.getIndexIterator(); + IndexIterator yIter = y.getIndexIterator(); + int i = 0; + while (aIter.hasNext()){ + if (GeoComputation.pointInPolygons(polygons, new PointD(xIter.getDoubleNext(), + yIter.getDoubleNext()))) { + r.setObject(i, aIter.getObjectNext()); + } else { + r.setObject(i, Double.NaN); + aIter.next(); + } + i++; + } + return r; + } + + /** + * Maskin function + * + * @param a Array a + * @param x X Array + * @param y Y Array + * @param polygons Polygons for maskin + * @return Result array with cell values of missing inside polygons + */ + public static Array maskin(Array a, Array x, Array y, List polygons) { + Array r = Array.factory(a.getDataType(), a.getShape()); + IndexIterator aIter = a.getIndexIterator(); + IndexIterator xIter = x.getIndexIterator(); + IndexIterator yIter = y.getIndexIterator(); + int i = 0; + while(aIter.hasNext()) { + if (GeoComputation.pointInPolygons(polygons, new PointD(xIter.getDoubleNext(), + yIter.getDoubleNext()))) { + r.setObject(i, Double.NaN); + aIter.next(); + } else { + r.setObject(i, aIter.getObjectNext()); + } + i++; + } + return r; + } + + /** + * Maskout function + * + * @param a Array a + * @param x X Array + * @param y Y Array + * @param polygons Polygons for maskout + * @return Result arrays removing cells outside polygons + */ + public static Array[] maskout_Remove(Array a, Array x, Array y, List polygons) { + List rdata = new ArrayList<>(); + List rxdata = new ArrayList<>(); + List rydata = new ArrayList<>(); + IndexIterator aIter = a.getIndexIterator(); + IndexIterator xIter = x.getIndexIterator(); + IndexIterator yIter = y.getIndexIterator(); + double va, vx, vy; + while(aIter.hasNext()) { + va = aIter.getDoubleNext(); + vx = xIter.getDoubleNext(); + vy = yIter.getDoubleNext(); + if (GeoComputation.pointInPolygons(polygons, new PointD(vx, vy))) { + rdata.add(va); + rxdata.add(vx); + rydata.add(vy); + } + } + + int n = rdata.size(); + int[] shape = new int[1]; + shape[0] = n; + Array r = Array.factory(a.getDataType(), shape); + Array rx = Array.factory(x.getDataType(), shape); + Array ry = Array.factory(y.getDataType(), shape); + for (int i = 0; i < n; i++) { + r.setObject(i, rdata.get(i)); + rx.setDouble(i, rxdata.get(i)); + ry.setDouble(i, rydata.get(i)); + } + + return new Array[]{r, rx, ry}; + } + + /** + * Maskin function + * + * @param a Array a + * @param x X Array + * @param y Y Array + * @param polygons Polygons for maskin + * @return Result arrays removing cells inside polygons + */ + public static Array[] maskin_Remove(Array a, Array x, Array y, List polygons) { + List rdata = new ArrayList<>(); + List rxdata = new ArrayList<>(); + List rydata = new ArrayList<>(); + IndexIterator aIter = a.getIndexIterator(); + IndexIterator xIter = x.getIndexIterator(); + IndexIterator yIter = y.getIndexIterator(); + double va, vx, vy; + while(aIter.hasNext()) { + va = aIter.getDoubleNext(); + vx = xIter.getDoubleNext(); + vy = yIter.getDoubleNext(); + if (!GeoComputation.pointInPolygons(polygons, new PointD(vx, vy))) { + rdata.add(va); + rxdata.add(vx); + rydata.add(vy); + } + } + + int n = rdata.size(); + int[] shape = new int[1]; + shape[0] = n; + Array r = Array.factory(a.getDataType(), shape); + Array rx = Array.factory(x.getDataType(), shape); + Array ry = Array.factory(y.getDataType(), shape); + for (int i = 0; i < n; i++) { + r.setObject(i, rdata.get(i)); + rx.setDouble(i, rxdata.get(i)); + ry.setDouble(i, rydata.get(i)); + } + + return new Array[]{r, rx, ry}; + } + + /** + * Maskout function + * + * @param a Array a + * @param x X dimension values + * @param y Y dimension values + * @param polygons PolygonShape list + * @return Result array with cell values of missing outside polygons + */ + public static Array maskout(Array a, List x, List y, List polygons) { + return maskout(a, x, y, polygons, Double.NaN); + } + + /** + * Maskout function + * + * @param a Array a + * @param x X dimension values + * @param y Y dimension values + * @param polygons PolygonShape list + * @param missingValue Missing value + * @return Result array with cell values of missing outside polygons + */ + public static Array maskout(Array a, List x, List y, List polygons, Number missingValue) { + int xNum = x.size(); + int yNum = y.size(); + + Array r = Array.factory(a.getDataType(), a.getShape()); + IndexIterator iter = a.getIndexIterator(); + if (a.getRank() == 1) { + int i = 0; + while (iter.hasNext()) { + if (GeoComputation.pointInPolygons(polygons, new PointD(x.get(i).doubleValue(), y.get(i).doubleValue()))) { + r.setObject(i, iter.getObjectNext()); + } else { + r.setObject(i, missingValue); + iter.next(); + } + i++; + } + } else if (a.getRank() == 2) { + int idx; + for (int i = 0; i < yNum; i++) { + for (int j = 0; j < xNum; j++) { + idx = i * xNum + j; + if (GeoComputation.pointInPolygons(polygons, new PointD(x.get(j).doubleValue(), y.get(i).doubleValue()))) { + r.setObject(idx, iter.getObjectNext()); + } else { + r.setObject(idx, missingValue); + iter.next(); + } + } + } + } + + return r; + } + + /** + * Maskout function + * + * @param a Array a + * @param m Array mask + * @param missingValue Missing value + * @return Result array + */ + public static Array maskout(Array a, Array m, Number missingValue) { + Array r = Array.factory(a.getDataType(), a.getShape()); + IndexIterator aIter = a.getIndexIterator(); + IndexIterator mIter = m.getIndexIterator(); + double va, vm; + int i = 0; + while (aIter.hasNext()){ + va = aIter.getDoubleNext(); + vm = mIter.getDoubleNext(); + if (vm < 0) { + r.setObject(i, missingValue); + } else { + r.setObject(i, va); + } + i++; + } + + return r; + } + + /** + * Maskout function + * + * @param a Array a + * @param m Array mask + * @return Result array + */ + public static Array maskout(Array a, Array m) { + return maskout(a, m, Double.NaN); + } + + /** + * Maskin function + * + * @param a Array a + * @param m Array mask + * @return Result array + */ + public static Array maskin(Array a, Array m) { + Array r = Array.factory(a.getDataType(), a.getShape()); + IndexIterator aIter = a.getIndexIterator(); + IndexIterator mIter = m.getIndexIterator(); + double va, vm; + int i = 0; + while(aIter.hasNext()) { + va = aIter.getDoubleNext(); + vm = mIter.getDoubleNext(); + if (vm < 0) { + r.setObject(i, va); + } else { + r.setObject(i, Double.NaN); + } + i++; + } + + return r; + } + + /** + * Check if a polygon is convex + * @param points Outline point of the polygon + * @return Is convex or not + */ + public static boolean isConvex(List points) { + if (points.size() <= 5) + return true; + + PointD p0, p1, p2; + int sign = 0; + for (int i = 0; i < points.size() - 1; i++) { + p0 = points.get(i == 0 ? points.size() - 2 : i - 1); + p1 = points.get(i); + p2 = points.get(i + 1); + double dx1 = p1.X - p0.X; + double dy1 = p1.Y - p0.Y; + double dx2 = p2.X - p1.X; + double dy2 = p2.Y - p2.Y; + double z = dx1 * dy2 - dy1 * dx2; + int s = z >= 0.0 ? 1 : -1; + if(sign == 0) { + sign = s; + } else if(sign != s) { + return false; + } + } + return true; + } + + /** + * Check if a polygon is convex + * @param polygon The polygon + * @return Is convex or not + */ + public static boolean isConvex(Polygon polygon) { + return isConvex(polygon.getOutLine()); + } + + /** + * Get polygon shape coordinate arrays + * @param pgs The polygon shape + * @return Coordinate arrays + */ + public static Array[] getCoordinates(PolygonShape pgs) { + int n = pgs.getPointNum() + pgs.getPartNum() - 1; + int[] shape = new int[]{n}; + Array xArray = Array.factory(DataType.DOUBLE, shape); + Array yArray = Array.factory(DataType.DOUBLE, shape); + Array zArray = null; + boolean isZ = pgs instanceof PolygonZShape ? true : false; + if (isZ) { + zArray = Array.factory(DataType.DOUBLE, shape); + } + int i = 0; + for (Polygon polygon : pgs.getPolygons()) { + for (List points : polygon.getRings()) { + if (isZ) { + for (PointZ p : (List) points) { + xArray.setDouble(i, p.X); + yArray.setDouble(i, p.Y); + zArray.setDouble(i, p.Z); + i += 1; + } + if (i < n) { + xArray.setDouble(i, Double.NaN); + yArray.setDouble(i, Double.NaN); + zArray.setDouble(i, Double.NaN); + } + } else { + for (PointD p : (List) points) { + xArray.setDouble(i, p.X); + yArray.setDouble(i, p.Y); + i += 1; + } + if (i < n) { + xArray.setDouble(i, Double.NaN); + yArray.setDouble(i, Double.NaN); + } + } + i += 1; + } + } + + if (isZ) { + return new Array[]{xArray, yArray, zArray}; + } else { + return new Array[]{xArray, yArray}; + } + } + + /** + * Get polyline shape coordinate arrays + * @param pls The polygon shape + * @return Coordinate arrays + */ + public static Array[] getCoordinates(PolylineShape pls) { + int n = pls.getPointNum() + pls.getPartNum() - 1; + int[] shape = new int[]{n}; + Array xArray = Array.factory(DataType.DOUBLE, shape); + Array yArray = Array.factory(DataType.DOUBLE, shape); + Array zArray = null; + boolean isZ = pls instanceof PolylineZShape ? true : false; + if (isZ) { + zArray = Array.factory(DataType.DOUBLE, shape); + } + int i = 0; + for (Polyline polyline : pls.getPolylines()) { + if (isZ) { + for (PointZ p : (List) polyline.getPointList()) { + xArray.setDouble(i, p.X); + yArray.setDouble(i, p.Y); + zArray.setDouble(i, p.Z); + i += 1; + } + if (i < n) { + xArray.setDouble(i, Double.NaN); + yArray.setDouble(i, Double.NaN); + zArray.setDouble(i, Double.NaN); + } + } else { + for (PointD p : (List) polyline.getPointList()) { + xArray.setDouble(i, p.X); + yArray.setDouble(i, p.Y); + i += 1; + } + if (i < n) { + xArray.setDouble(i, Double.NaN); + yArray.setDouble(i, Double.NaN); + } + } + i += 1; + } + + if (isZ) { + return new Array[]{xArray, yArray, zArray}; + } else { + return new Array[]{xArray, yArray}; + } + } + + /** + * Get coordinate arrays of a vector layer + * @param layer The vector layer + * @return Coordinate arrays + */ + public static Array[] getCoordinates(VectorLayer layer) { + boolean isZ = layer.getShapeType().isZ(); + if (layer.getShapeType().isPoint()) { + int n = layer.getShapeNum(); + Array xArray = Array.factory(DataType.DOUBLE, new int[]{n}); + Array yArray = Array.factory(DataType.DOUBLE, new int[]{n}); + Array zArray = null; + if (isZ) { + zArray = Array.factory(DataType.DOUBLE, new int[]{n}); + int i = 0; + PointZ p; + for (PointShape shape : (List) layer.getShapes()) { + p = (PointZ) shape.getPoint(); + xArray.setDouble(i, p.X); + yArray.setDouble(i, p.Y); + zArray.setDouble(i, p.Z); + } + return new Array[]{xArray, yArray, zArray}; + } else { + int i = 0; + PointD p; + for (PointShape shape : (List) layer.getShapes()) { + p = (PointD) shape.getPoint(); + xArray.setDouble(i, p.X); + yArray.setDouble(i, p.Y); + } + return new Array[]{xArray, yArray}; + } + } else { + int n = 0; + for (Shape shape : layer.getShapes()) { + n += shape.getPointNum() + shape.getPartNum(); + } + n -= 1; + Array xArray = Array.factory(DataType.DOUBLE, new int[]{n}); + Array yArray = Array.factory(DataType.DOUBLE, new int[]{n}); + Array zArray = null; + if (isZ) { + zArray = Array.factory(DataType.DOUBLE, new int[]{n}); + } + int i = 0; + int[] origin = new int[1]; + int[] shape = new int[1]; + if (layer.getShapeType().isLine()) { + for (PolylineShape pls : (List) layer.getShapes()) { + Array[] arrays = getCoordinates(pls); + origin[0] = i; + shape[0] = (int) arrays[0].getSize(); + try { + ArrayMath.setSection(xArray, origin, shape, arrays[0]); + ArrayMath.setSection(yArray, origin, shape, arrays[1]); + if (isZ) + ArrayMath.setSection(zArray, origin, shape, arrays[2]); + i += shape[0]; + if (i < n) { + xArray.setDouble(i, Double.NaN); + yArray.setDouble(i, Double.NaN); + if (isZ) + zArray.setDouble(i, Double.NaN); + } + i += 1; + } catch (InvalidRangeException e) { + e.printStackTrace(); + } + } + } else { + for (PolygonShape pgs : (List) layer.getShapes()) { + Array[] arrays = getCoordinates(pgs); + origin[0] = i; + shape[0] = (int) arrays[0].getSize(); + try { + ArrayMath.setSection(xArray, origin, shape, arrays[0]); + ArrayMath.setSection(yArray, origin, shape, arrays[1]); + if (isZ) + ArrayMath.setSection(zArray, origin, shape, arrays[2]); + i += shape[0]; + if (i < n) { + xArray.setDouble(i, Double.NaN); + yArray.setDouble(i, Double.NaN); + if (isZ) + zArray.setDouble(i, Double.NaN); + } + i += 1; + } catch (InvalidRangeException e) { + e.printStackTrace(); + } + } + } + if (isZ) { + return new Array[]{xArray, yArray, zArray}; + } else { + return new Array[]{xArray, yArray}; + } + } + } + +} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/analysis/InterpolationSetting.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/analysis/InterpolationSetting.java index e0eb6346..81daa150 100644 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/analysis/InterpolationSetting.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/analysis/InterpolationSetting.java @@ -13,7 +13,7 @@ */ package org.meteoinfo.geo.analysis; -import org.meteoinfo.geo.data.GridDataSetting; +import org.meteoinfo.data.GridDataSetting; import java.util.ArrayList; import java.util.List; diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/analysis/ResampleMethods.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/analysis/ResampleMethods.java deleted file mode 100644 index e58452e6..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/analysis/ResampleMethods.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.geo.analysis; - -/** - * - * @author yaqiang - */ -public enum ResampleMethods { - Bilinear, - NearestNeighbor -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/analysis/Statistics.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/analysis/Statistics.java deleted file mode 100644 index 5ef3483a..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/analysis/Statistics.java +++ /dev/null @@ -1,233 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.geo.analysis; - -import org.meteoinfo.ndarray.Array; -import org.meteoinfo.ndarray.IndexIterator; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * - * @author Yaqiang Wang - */ -public class Statistics { - - /** - * Count the data value bigger then a threshold value - * - * @param aDataList The data list - * @param value Threshold value - * @return Count - */ - public static int valueCount(List aDataList, double value) { - int count = 0; - for (Double v : aDataList) { - if (v >= value) { - count += 1; - } - } - - return count; - } - - /** - * Sum funtion - * - * @param aDataList The data list - * @return Sum - */ - public static double sum(List aDataList) { - double aSum = 0.0; - - for (Double v : aDataList) { - aSum = aSum + v; - } - - return aSum; - } - - /** - * Mean funtion - * - * @param aDataList The data list - * @return Mean - */ - public static double mean(List aDataList) { - double aSum = 0.0; - - for (Double v : aDataList) { - aSum = aSum + v; - } - - return aSum / aDataList.size(); - } - - /** - * Maximum function - * - * @param aDataList The data list - * @return Maximum - */ - public static double maximum(List aDataList) { - double aMax; - - aMax = aDataList.get(0); - for (int i = 1; i < aDataList.size(); i++) { - aMax = Math.max(aMax, aDataList.get(i)); - } - - return aMax; - } - - /** - * Minimum function - * - * @param aDataList The data list - * @return Minimum - */ - public static double minimum(List aDataList) { - double aMin; - - aMin = aDataList.get(0); - for (int i = 1; i < aDataList.size(); i++) { - aMin = Math.min(aMin, aDataList.get(i)); - } - - return aMin; - } - - /** - * Median funtion - * - * @param aDataList The data list - * @return Median - */ - public static double median(List aDataList) { - Collections.sort(aDataList); - if (aDataList.size() % 2 == 0) { - return (aDataList.get(aDataList.size() / 2) + aDataList.get(aDataList.size() / 2 - 1)) / 2.0; - } else { - return aDataList.get(aDataList.size() / 2); - } - } - - /** - * Quantile function - * - * @param aDataList The data list - * @param aNum Quantile index - * @return Quantile value - */ - public static double quantile(List aDataList, int aNum) { - Collections.sort(aDataList); - double aData = 0; - switch (aNum) { - case 0: - aData = minimum(aDataList); - break; - case 1: - if ((aDataList.size() + 1) % 4 == 0) { - aData = aDataList.get((aDataList.size() + 1) / 4 - 1); - } else { - aData = aDataList.get((aDataList.size() + 1) / 4 - 1) + 0.75 * (aDataList.get((aDataList.size() + 1) / 4) - - aDataList.get((aDataList.size() + 1) / 4 - 1)); - } - break; - case 2: - aData = median(aDataList); - break; - case 3: - if ((aDataList.size() + 1) % 4 == 0) { - aData = aDataList.get((aDataList.size() + 1) * 3 / 4 - 1); - } else { - aData = aDataList.get((aDataList.size() + 1) * 3 / 4 - 1) + 0.25 * (aDataList.get((aDataList.size() + 1) * 3 / 4) - - aDataList.get((aDataList.size() + 1) * 3 / 4 - 1)); - } - break; - case 4: - aData = maximum(aDataList); - break; - } - - return aData; - } - - /** - * Quantile function - * - * @param a The data array - * @param aNum Quantile index - * @return Quantile value - */ - public static double quantile(Array a, int aNum) { - List dlist = new ArrayList<>(); - IndexIterator ii = a.getIndexIterator(); - double v; - while (ii.hasNext()) { - v = ii.getDoubleNext(); - if (!Double.isNaN(v)) - dlist.add(v); - } - if (dlist.size() <= 3) - return Double.NaN; - else - return quantile(dlist, aNum); - } - - /** - * Quantile function - * - * @param aDataList The data list - * @param qValue Quantile index - * @return Quantile value - */ - public static double quantile(List aDataList, double qValue) { - Collections.sort(aDataList); - double aData; - - if (qValue == 0) { - aData = minimum(aDataList); - } else if (qValue == 1) { - aData = maximum(aDataList); - } else { - aData = aDataList.get((int) (aDataList.size() * qValue) - 1); - } - - return aData; - } - - /** - * Standard deviation - * - * @param aDataList The data list - * @return Standard deviation value - */ - public static double standardDeviation(List aDataList) { - double theMean, theSqDev, theSumSqDev, theVariance, theStdDev, theValue; - int i; - - theMean = mean(aDataList); - theSumSqDev = 0; - for (i = 0; i < aDataList.size(); i++) { - theValue = aDataList.get(i); - theSqDev = (theValue - theMean) * (theValue - theMean); - theSumSqDev = theSqDev + theSumSqDev; - } - - if (aDataList.size() > 1) { - theVariance = theSumSqDev / (aDataList.size() - 1); - theStdDev = Math.sqrt(theVariance); - } else { - //theVariance = 0; - theStdDev = 0; - } - - return theStdDev; - } -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/GridArray.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/GridArray.java deleted file mode 100644 index 32d39c5a..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/GridArray.java +++ /dev/null @@ -1,984 +0,0 @@ -/* Copyright 2015 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.data; - -import java.io.BufferedWriter; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; - -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -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.util.BigDecimalUtil; -import org.meteoinfo.geo.analysis.ResampleMethods; -import org.meteoinfo.geo.util.LegendManage; -import org.meteoinfo.geo.projection.KnownCoordinateSystems; -import org.meteoinfo.geo.projection.info.ProjectionInfo; -import org.meteoinfo.geo.projection.ProjectionUtil; -import org.meteoinfo.geo.projection.Reproject; - -/** - * - * @author yaqiang - */ -public class GridArray { - - // - /** - * Grid data - */ - private Array data; - private Index2D index2D; - /// - /// x coordinate array - /// - public double[] xArray; - /// - /// y coordinate array - /// - public double[] yArray; - /// - /// Undef data - /// - public double missingValue; - /** - * Projection information - */ - public ProjectionInfo projInfo = null; - public String fieldName = "Data"; - private boolean _xStag = false; - private boolean _yStag = false; - // - // - - /** - * Constructor - */ - public GridArray() { - missingValue = -9999; - } - - /** - * Constructor - * - * @param aGridData The grid data - */ - public GridArray(GridArray aGridData) { - projInfo = aGridData.projInfo; - xArray = aGridData.xArray.clone(); - yArray = aGridData.yArray.clone(); - missingValue = aGridData.missingValue; - this.setData(aGridData.data.copy()); - } - - /** - * Constructor - * - * @param xStart xArray start - * @param xDelt xArray delt - * @param xNum xArray number - * @param yStart yArray start - * @param yDelt yArray delt - * @param yNum yArray number - */ - public GridArray(double xStart, double xDelt, int xNum, double yStart, double yDelt, int yNum) { - xArray = new double[xNum]; - yArray = new double[yNum]; - for (int i = 0; i < xNum; i++) { - xArray[i] = BigDecimalUtil.add(xStart, BigDecimalUtil.mul(xDelt, i)); - } - for (int i = 0; i < yNum; i++) { - yArray[i] = BigDecimalUtil.add(yStart, BigDecimalUtil.mul(yDelt, i)); - } - - missingValue = -9999; - int[] shape = new int[]{yNum, xNum}; - this.setData(Array.factory(DataType.DOUBLE, shape)); - } - - /** - * Constructor - * - * @param array Data array - * @param xdata X data - * @param ydata Y data - * @param missingValue Missing value - * @param projInfo Projection info - */ - public GridArray(Array array, List xdata, List ydata, double missingValue, ProjectionInfo projInfo) { - int yn = ydata.size(); - int xn = xdata.size(); - this.setData(array); - this.xArray = new double[xn]; - this.yArray = new double[yn]; - for (int i = 0; i < xn; i++) { - this.xArray[i] = xdata.get(i).doubleValue(); - } - for (int i = 0; i < yn; i++) { - this.yArray[i] = ydata.get(i).doubleValue(); - } - - this.missingValue = missingValue; - this.projInfo = projInfo; - } - - /** - * Constructor - * - * @param array Data array - * @param xdata X data - * @param ydata Y data - * @param missingValue Missing value - */ - public GridArray(Array array, Array xdata, Array ydata, Number missingValue) { - int yn = (int) ydata.getSize(); - int xn = (int) xdata.getSize(); - this.setData(array); - - this.xArray = new double[xn]; - this.yArray = new double[yn]; - IndexIterator iter = xdata.getIndexIterator(); - for (int i = 0; i < xn; i++) { - this.xArray[i] = iter.getDoubleNext(); - } - iter = ydata.getIndexIterator(); - for (int i = 0; i < yn; i++) { - this.yArray[i] = iter.getDoubleNext(); - } - - this.missingValue = missingValue.doubleValue(); - this.projInfo = KnownCoordinateSystems.geographic.world.WGS1984;; - } - // - // - - /** - * Get data array - * @return Data array - */ - public Array getData() { return this.data; } - - /** - * Set data array - * @param value Data array - */ - public void setData(Array value) { - this.data = value; - this.index2D = (Index2D) this.data.getIndex(); - } - - /** - * Get xArray number - * - * @return xArray number - */ - public int getXNum() { - return xArray.length; - } - - /** - * Get yArray number - * - * @return yArray number - */ - public int getYNum() { - return yArray.length; - } - - /** - * Get xArray delt - * - * @return xArray delt - */ - public double getXDelt() { - return BigDecimalUtil.sub(xArray[1], xArray[0]); - } - - /** - * Get yArray delt - * - * @return yArray delt - */ - public double getYDelt() { - return BigDecimalUtil.sub(yArray[1], yArray[0]); - } - - /** - * Get Extent - * - * @return Extent - */ - public Extent getExtent() { - Extent extent = new Extent(); - extent.minX = xArray[0]; - extent.maxX = xArray[xArray.length - 1]; - extent.minY = yArray[0]; - extent.maxY = yArray[yArray.length - 1]; - - return extent; - } - - /** - * Get if the data is global - * - * @return If the data is global - */ - public boolean isGlobal() { - boolean isGlobal = false; - if (MIMath.doubleEquals(xArray[getXNum() - 1] + getXDelt() - xArray[0], 360.0)) { - isGlobal = true; - } - - return isGlobal; - } - - /** - * Get if is x stagger - * - * @return Boolean - */ - public boolean isXStagger() { - return _xStag; - } - - /** - * Set if is x stagger - * - * @param value Boolean - */ - public void setXStagger(boolean value) { - _xStag = value; - } - - /** - * Get if is y stagger - * - * @return Boolean - */ - public boolean isYStagger() { - return _yStag; - } - - /** - * Set if is y stagger - * - * @param value Boolean - */ - public void setYStagger(boolean value) { - _yStag = value; - } - - /** - * Get value - * - * @param i I index - * @param j J index - * @return Value - */ - public Number getValue(int i, int j) { - switch (this.data.getDataType()) { - case UBYTE: - return data.getInt(this.index2D.set(i, j)); - case USHORT: - return data.getInt(this.index2D.set(i, j)); - case UINT: - return data.getLong(this.index2D.set(i, j)); - default: - return (Number) data.getObject(this.index2D.set(i, j)); - } - } - - /** - * Get double value - * - * @param i I index - * @param j J index - * @return Double value - */ - public double getDoubleValue(int i, int j) { - return data.getDouble(this.index2D.set(i, j)); - } - - // - // - // - /** - * Get dimensions - * - * @return Dimensions - */ - public List getDimensions() { - List dims = new ArrayList<>(); - Dimension ydim = new Dimension(DimensionType.Y); - ydim.setValues(this.yArray); - dims.add(ydim); - Dimension xdim = new Dimension(DimensionType.X); - xdim.setValues(this.xArray); - dims.add(xdim); - - return dims; - } - - // - // - /** - * Get minimum x - * - * @return Minimum x - */ - public double getXMin() { - return xArray[0]; - } - - /** - * Get maximum x - * - * @return Maximum x - */ - public double getXMax() { - return xArray[xArray.length - 1]; - } - - /** - * Get minimum y - * - * @return Minimum y - */ - public double getYMin() { - return yArray[0]; - } - - /** - * Get maximum y - * - * @return Maximum y - */ - public double getYMax() { - return yArray[yArray.length - 1]; - } - - /** - * Get minimum x of the grid border - * - * @return Minimum x of the grid border - */ - public double getBorderXMin() { - return this.getXMin() - this.getXDelt() / 2; - } - - /** - * Get maximum x of the grid border - * - * @return Maximum x of the grid border - */ - public double getBorderXMax() { - return this.getXMax() + this.getXDelt() / 2; - } - - /** - * Get minimum y of the grid border - * - * @return Minimum y of the grid border - */ - public double getBorderYMin() { - return this.getYMin() - this.getYDelt() / 2; - } - - /** - * Get maximum y of the grid border - * - * @return Maximum y of the grid border - */ - public double getBorderYMax() { - return this.getYMax() + this.getYDelt() / 2; - } - - /** - * Get i/j index of a point in the grid - * - * @param x The x coordinate - * @param y The y coordinate - * @return I/J index array - */ - public int[] getIJIndex(double x, double y) { - int xidx = -1; - int yidx = -1; - if (x >= this.getBorderXMin() && x <= this.getBorderXMax()) { - if (y >= this.getBorderYMin() && y <= this.getBorderYMax()) { - xidx = (int) ((x - this.getBorderXMin()) / this.getXDelt()); - yidx = (int) ((y - this.getBorderYMin()) / this.getYDelt()); - } - } - if (xidx >= this.getXNum() || yidx >= this.getYNum()) { - xidx = -1; - yidx = -1; - } - - return new int[]{xidx, yidx}; - } - - /** - * Test unique values - * - * @return True if unique value number less then 20 - */ - public boolean testUniqueValues() { - List values = new ArrayList<>(); - int vdNum = 0; - for (int i = 0; i < getYNum(); i++) { - for (int j = 0; j < getXNum(); j++) { - if (MIMath.doubleEquals(this.getValue(i, j).doubleValue(), missingValue)) { - continue; - } - - if (vdNum == 0) { - values.add(this.getValue(i, j)); - vdNum += 1; - } else if (!values.contains(this.getValue(i, j))) { - values.add(this.getValue(i, j)); - vdNum += 1; - } - if (vdNum > 20) { - return false; - } - } - } - - return true; - } - - /** - * Get unique values - * - * @return Unique values - */ - public List getUniqueValues() { - List values = new ArrayList<>(); - int vdNum = 0; - for (int i = 0; i < getYNum(); i++) { - for (int j = 0; j < getXNum(); j++) { - if (MIMath.doubleEquals(this.getValue(i, j).doubleValue(), missingValue)) { - continue; - } - - if (vdNum == 0) { - values.add(this.getValue(i, j)); - } else if (!values.contains(this.getValue(i, j))) { - values.add(this.getValue(i, j)); - } - vdNum += 1; - } - } - - return values; - } - - /** - * Get grid data setting - * - * @return Grid data setting - */ - public GridDataSetting getGridDataSetting() { - GridDataSetting gDataSet = new GridDataSetting(); - gDataSet.dataExtent = (Extent) this.getExtent().clone(); - gDataSet.xNum = this.getXNum(); - gDataSet.yNum = this.getYNum(); - return gDataSet; - } - - /** - * Get maximum and minimum values - * - * @param maxmin Max/Min array - * @return If has undefine data - */ - public boolean getMaxMinValue(double[] maxmin) { - double max = 0; - double min = 0; - int vdNum = 0; - boolean hasUndef = false; - IndexIterator iter = this.data.getIndexIterator(); - double v; - while (iter.hasNext()) { - v = iter.getDoubleNext(); - if (Double.isNaN(v) || MIMath.doubleEquals(v, missingValue)) { - hasUndef = true; - continue; - } - - if (vdNum == 0) { - min = v; - max = min; - } else { - if (min > v) { - min = v; - } - if (max < v) { - max = v; - } - } - vdNum += 1; - } - - maxmin[0] = max; - maxmin[1] = min; - return hasUndef; - } - - /** - * Minimum - * - * @return Minimum value - */ - public double min() { - return ArrayMath.getMinimum(data, missingValue); - } - - /** - * Maximum - * - * @return Maximum value - */ - public double max() { - return ArrayMath.getMaximum(data, missingValue); - } - - /** - * Get if has NaN value - * - * @return Boolean - */ - public boolean hasNaN() { - return ArrayMath.containsNaN(this.data); - } - - /** - * Project grid data - * - * @param toProj To projection - * @return Projected grid data - * @throws InvalidRangeException - */ - public GridArray project(ProjectionInfo toProj) throws InvalidRangeException { - if (this.projInfo == null) { - return null; - } - - return project(this.projInfo, toProj, ResampleMethods.NearestNeighbor); - } - - /** - * Project grid data - * - * @param fromProj From projection - * @param toProj To projection - * @return Porjected grid data - * @throws InvalidRangeException - */ - public GridArray project(ProjectionInfo fromProj, ProjectionInfo toProj) throws InvalidRangeException { - Array xx = ArrayUtil.array(this.xArray); - Array yy = ArrayUtil.array(this.yArray); - Object[] r = Reproject.reprojectGrid(data, xx, yy, fromProj, toProj); - GridArray rdata = new GridArray((Array) r[0], (Array) r[1], (Array) r[2], missingValue); - rdata.projInfo = toProj; - - return rdata; - } - - /** - * Project grid data - * - * @param fromProj From projection - * @param toProj To projection - * @param resampleMethod Interpolation method - * @return Porjected grid data - * @throws InvalidRangeException - */ - public GridArray project(ProjectionInfo fromProj, ProjectionInfo toProj, ResampleMethods resampleMethod) throws InvalidRangeException { - Extent aExtent; - int xnum = this.getXNum(); - int ynum = this.getYNum(); - if (this.isGlobal() || this.xArray[xnum - 1] - this.xArray[0] == 360) { - aExtent = ProjectionUtil.getProjectionGlobalExtent(toProj); - } else { - aExtent = ProjectionUtil.getProjectionExtent(fromProj, toProj, this.xArray, this.yArray); - } - - double xDelt = (aExtent.maxX - aExtent.minX) / (xnum - 1); - double yDelt = (aExtent.maxY - aExtent.minY) / (ynum - 1); - List x = new ArrayList<>(); - List y = new ArrayList<>(); - Array rx = Array.factory(DataType.DOUBLE, new int[]{xnum}); - Array ry = Array.factory(DataType.DOUBLE, new int[]{ynum}); - for (int i = 0; i < xnum; i++) { - x.add(this.xArray[i]); - rx.setDouble(i, aExtent.minX + i * xDelt); - } - - for (int i = 0; i < ynum; i++) { - y.add(this.yArray[i]); - ry.setDouble(i, aExtent.minY + i * yDelt); - } - Array[] rxy = ArrayUtil.meshgrid(rx, ry); - Array rrx = rxy[0]; - Array rry = rxy[1]; - - Array r = Reproject.reproject(data, x, y, rrx, rry, fromProj, toProj, missingValue, resampleMethod); - GridArray rdata = new GridArray(r, rx, ry, missingValue); - rdata.projInfo = toProj; - - return rdata; - } - - /** - * Save as Surfer ASCII data file - * - * @param aFile File path - */ - public void saveAsSurferASCIIFile(String aFile) { - try { - BufferedWriter sw = new BufferedWriter(new FileWriter(new File(aFile))); - sw.write("DSAA"); - sw.newLine(); - sw.write(String.valueOf(this.getXNum()) + " " + String.valueOf(this.getYNum())); - sw.newLine(); - sw.write(String.valueOf(xArray[0]) + " " + String.valueOf(xArray[xArray.length - 1])); - sw.newLine(); - sw.write(String.valueOf(yArray[0]) + " " + String.valueOf(yArray[yArray.length - 1])); - sw.newLine(); - double[] maxmin = new double[2]; - getMaxMinValue(maxmin); - sw.write(String.valueOf(maxmin[1]) + " " + String.valueOf(maxmin[0])); - Object value; - String aLine = ""; - for (int i = 0; i < this.getYNum(); i++) { - for (int j = 0; j < this.getXNum(); j++) { - value = this.getValue(i, j); - if (j == 0) { - aLine = value.toString(); - } else { - aLine = aLine + " " + value.toString(); - } - } - sw.newLine(); - sw.write(aLine); - } - sw.flush(); - sw.close(); - } catch (IOException ex) { - Logger.getLogger(GridData.class.getName()).log(Level.SEVERE, null, ex); - } - } - - /** - * Save as ESRI ASCII data file - * - * @param aFile File path - */ - public void saveAsESRIASCIIFile(String aFile) { - if (this.getXDelt() != this.getYDelt()){ - JOptionPane.showMessageDialog(null, "X cell size is not equal y cell size!", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - - try { - BufferedWriter sw = new BufferedWriter(new FileWriter(new File(aFile))); - sw.write("NCOLS " + String.valueOf(this.getXNum())); - sw.newLine(); - sw.write("NROWS " + String.valueOf(this.getYNum())); - sw.newLine(); - sw.write("XLLCENTER " + String.valueOf(xArray[0])); - sw.newLine(); - sw.write("YLLCENTER " + String.valueOf(yArray[0])); - sw.newLine(); - sw.write("CELLSIZE " + String.valueOf(this.getXDelt())); - sw.newLine(); - sw.write("NODATA_VALUE " + String.valueOf(this.missingValue)); - //sw.newLine(); - String value; - String aLine = ""; - int xn = this.getXNum(); - int yn = this.getYNum(); - for (int i = 0; i < yn; i++) { - for (int j = 0; j < xn; j++) { - value = this.getValue(yn - i - 1, j).toString(); - if (j == 0) { - aLine = value; - } else { - aLine = aLine + " " + value; - } - } - sw.newLine(); - sw.write(aLine); - } - sw.flush(); - sw.close(); - } catch (IOException ex) { - Logger.getLogger(GridData.class.getName()).log(Level.SEVERE, null, ex); - } - } - - /** - * Save as BIL data file - * - * @param fileName File path - * @throws IOException - */ - public void saveAsBILFile(String fileName) throws IOException { - try { - //Save data file - DataOutputStream outs = new DataOutputStream(new FileOutputStream(new File(fileName))); - int xn = this.getXNum(); - int yn = this.getYNum(); - for (int i = 0; i < yn; i++) { - for (int j = 0; j < xn; j++) { - outs.writeFloat((float)this.getDoubleValue(yn - i - 1, j)); - } - } - outs.close(); - - //Save header file - String hfn = fileName.replace(".bil", ".hdr"); - BufferedWriter sw = new BufferedWriter(new FileWriter(new File(hfn))); - sw.write("nrows " + String.valueOf(this.getYNum())); - sw.newLine(); - sw.write("ncols " + String.valueOf(this.getXNum())); - sw.newLine(); - sw.write("nbands 1"); - sw.newLine(); - sw.write("nbits 32"); - sw.newLine(); - sw.write("pixeltype float"); - sw.newLine(); - sw.write("byteorder M"); - sw.newLine(); - sw.write("layout bil"); - sw.newLine(); - sw.write("ulxmap " + String.valueOf(xArray[0])); - sw.newLine(); - sw.write("ulymap " + String.valueOf(yArray[yArray.length - 1])); - sw.newLine(); - sw.write("xdim " + String.valueOf(this.getXDelt())); - sw.newLine(); - sw.write("ydim " + String.valueOf(this.getYDelt())); - sw.newLine(); - - sw.flush(); - sw.close(); - } catch (IOException ex) { - Logger.getLogger(GridData.class.getName()).log(Level.SEVERE, null, ex); - } - } - - /** - * Save as MICAPS 4 data file - * @param aFile File path - * @param description Description - * @param aTime Data time - * @param hours Hours - * @param level Levels - * @param smooth Smooth coefficient - * @param boldValue Bold value - * @param floatFormat Float format - * @throws IOException - */ - public void saveAsMICAPS4File(String aFile, String description, LocalDateTime aTime, int hours, int level, - float smooth, float boldValue, String floatFormat) throws IOException { - //Get contour values - double[] CValues; - double undef = 9999; - double[] maxmin = new double[2]; - this.getMaxMinValue(maxmin); - double min = maxmin[1]; - double max = maxmin[0]; - CValues = LegendManage.createContourValues(min, max); - double cDelt = 0; - if (CValues.length > 1) - cDelt = CValues[1] - CValues[0]; - if (floatFormat == null) { - int dNum = MIMath.getDecimalNum(min); - floatFormat = "%." + String.valueOf(dNum) + "f"; - } - - //Write file - DateTimeFormatter format = DateTimeFormatter.ofPattern("yy MM dd HH"); - BufferedWriter sw = new BufferedWriter(new FileWriter(new File(aFile))); - sw.write("diamond 4 " + description); - sw.newLine(); - String aLine = format.format(aTime) + " " + String.valueOf(hours) + " " + String.valueOf(level); - sw.write(aLine); - sw.newLine(); - aLine = String.valueOf(this.getXDelt()) + " " + String.valueOf(this.getYDelt()) + " " - + String.valueOf(this.xArray[0]) + " " + String.valueOf(this.xArray[this.getXNum() - 1]) - + " " + String.valueOf(this.yArray[0]) + " " + String.valueOf(this.yArray[this.getYNum() - 1]); - sw.write(aLine); - sw.newLine(); - aLine = String.valueOf(this.getXNum()) + " " + String.valueOf(this.getYNum()) + " " - + String.valueOf(cDelt) + " " + String.valueOf(CValues[0]) + " " - + String.valueOf(CValues[CValues.length - 1]) + " " + String.valueOf(smooth) + " " - + String.valueOf(boldValue); - sw.write(aLine); - sw.newLine(); - double value; - for (int i = 0; i < this.getYNum(); i++) { - for (int j = 0; j < this.getXNum(); j++) { - value = this.getDoubleValue(i, j); - if (Double.isNaN(value)) { - value = undef; - } else if (MIMath.doubleEquals(value, this.missingValue)) { - value = undef; - } - - if (j == 0) { - aLine = String.format(floatFormat, value); - } else { - aLine = aLine + " " + String.format(floatFormat, value); - } - } - sw.write(aLine); - sw.newLine(); - } - - sw.close(); - } - - /** - * Save as MICAPS 4 data file - * @param aFile File path - * @param description Description - * @param aTime Data time - * @param hours Hours - * @param level Levels - * @param smooth Smooth coefficient - * @param boldValue Bold value - * @param floatFormat Float format - * @param projInfo Projection info - * @throws IOException - */ - public void saveAsMICAPS4File(String aFile, String description, LocalDateTime aTime, int hours, int level, - float smooth, float boldValue, String floatFormat, ProjectionInfo projInfo) throws IOException { - //Get contour values - double[] CValues; - double undef = 9999; - - double[] maxmin = new double[2]; - this.getMaxMinValue(maxmin); - double min = maxmin[1]; - double max = maxmin[0]; - CValues = LegendManage.createContourValues(min, max); - double cDelt = CValues[1] - CValues[0]; - if (floatFormat == null) { - int dNum = MIMath.getDecimalNum(min); - floatFormat = "%1$." + String.valueOf(dNum) + "f"; - } - - //Write file - DateTimeFormatter format = DateTimeFormatter.ofPattern("yy MM dd HH"); - BufferedWriter sw = new BufferedWriter(new FileWriter(new File(aFile))); - sw.write("diamond 4 " + description); - String aLine = format.format(aTime) + " " + String.valueOf(hours) + " " + String.valueOf(level); - sw.write(aLine); - sw.newLine(); - - double eCValue = CValues[CValues.length - 1]; - double xdelt = this.getXDelt(); - double ydelt = this.getYDelt(); - double sLon = this.xArray[0]; - double eLon = this.xArray[this.getXNum() - 1]; - double sLat = this.yArray[0]; - double eLat = this.yArray[this.getYNum() - 1]; - if (!projInfo.isLonLat()) { - switch (projInfo.getProjectionName()) { - case Lambert_Conformal_Conic: - eCValue = -1; - break; - case Mercator: - eCValue = -2; - break; - case North_Polar_Stereographic_Azimuthal: - eCValue = -3; - break; - } - ProjectionInfo toProj = KnownCoordinateSystems.geographic.world.WGS1984; - double[][] points = new double[2][]; - points[0] = new double[]{sLon, sLat}; - points[1] = new double[]{eLon, eLat}; - Reproject.reprojectPoints(points, projInfo, toProj, 0, 2); - xdelt = points[1][0]; - ydelt = points[0][1]; - sLon = points[0][0]; - sLat = points[0][1]; - eLon = points[1][0]; - eLat = points[1][1]; - } - aLine = String.valueOf(xdelt) + " " + String.valueOf(ydelt) + " " + String.valueOf(sLon) - + " " + String.valueOf(eLon) + " " + String.valueOf(sLat) + " " + String.valueOf(eLat); - sw.write(aLine); - sw.newLine(); - aLine = String.valueOf(this.getXNum()) + " " + String.valueOf(this.getYNum()) + " " - + String.valueOf(cDelt) + " " + String.valueOf(CValues[0]) + " " - + String.valueOf(eCValue) + " " + String.valueOf(smooth) + " " - + String.valueOf(boldValue); - sw.write(aLine); - sw.newLine(); - double value; - for (int i = 0; i < this.getYNum(); i++) { - for (int j = 0; j < this.getXNum(); j++) { - value = this.getDoubleValue(i, j); - if (Double.isNaN(value)) { - value = undef; - } else if (MIMath.doubleEquals(value, this.missingValue)) { - value = undef; - } - - if (j == 0) { - aLine = String.format(floatFormat, value); - } else { - aLine = aLine + " " + String.format(floatFormat, value); - } - } - sw.write(aLine); - sw.newLine(); - } - - sw.close(); - } - - /** - * Clone - * - * @return Grid data object - */ - @Override - public Object clone() { - GridArray newGriddata = new GridArray(this); - - return newGriddata; - } - // - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/GridData.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/GridData.java deleted file mode 100644 index c1dc9990..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/GridData.java +++ /dev/null @@ -1,3571 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.data; - -import java.io.BufferedReader; - -import org.meteoinfo.common.Extent; -import org.meteoinfo.common.MIMath; -import org.meteoinfo.common.PointD; -import org.meteoinfo.geo.analysis.GeoComputation; - -import java.io.BufferedWriter; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.meteoinfo.ndarray.Dimension; -import org.meteoinfo.ndarray.DimensionType; -import org.meteoinfo.geo.analysis.ResampleMethods; -import org.meteoinfo.common.DataConvert; -import org.meteoinfo.geo.layer.VectorLayer; -import org.meteoinfo.geo.projection.KnownCoordinateSystems; -import org.meteoinfo.geo.projection.info.ProjectionInfo; -import org.meteoinfo.geo.projection.ProjectionUtil; -import org.meteoinfo.geo.projection.Reproject; -import org.meteoinfo.geometry.shape.PolygonShape; -import org.meteoinfo.geometry.shape.ShapeTypes; -import org.meteoinfo.ndarray.Array; -import org.meteoinfo.ndarray.DataType; -import org.meteoinfo.ndarray.IndexIterator; -import org.meteoinfo.ndarray.util.BigDecimalUtil; - -/** - * - * @author yaqiang - */ -public class GridData { - - // - /** - * Grid data - */ - public double[][] data; - /// - /// x coordinate array - /// - public double[] xArray; - /// - /// y coordinate array - /// - public double[] yArray; - /// - /// Undef data - /// - public double missingValue; - /** - * Projection information - */ - public ProjectionInfo projInfo = null; - public String fieldName = "Data"; - private boolean _xStag = false; - private boolean _yStag = false; - // - // - - /** - * Constructor - */ - public GridData() { - missingValue = -9999; - } - - /** - * Constructor - * - * @param aGridData The grid data - */ - public GridData(GridData aGridData) { - projInfo = aGridData.projInfo; - xArray = aGridData.xArray.clone(); - yArray = aGridData.yArray.clone(); - missingValue = aGridData.missingValue; - data = new double[yArray.length][xArray.length]; - } - - /** - * Constructor - * - * @param xStart xArray start - * @param xDelt xArray delt - * @param xNum xArray number - * @param yStart yArray start - * @param yDelt yArray delt - * @param yNum yArray number - */ - public GridData(double xStart, double xDelt, int xNum, double yStart, double yDelt, int yNum) { - xArray = new double[xNum]; - yArray = new double[yNum]; - for (int i = 0; i < xNum; i++) { - xArray[i] = BigDecimalUtil.add(xStart, BigDecimalUtil.mul(xDelt, i)); - } - for (int i = 0; i < yNum; i++) { - yArray[i] = BigDecimalUtil.add(yStart, BigDecimalUtil.mul(yDelt, i)); - } - - missingValue = -9999; - data = new double[yNum][xNum]; - } - - /** - * Constructor - * - * @param array Data array - * @param xdata X data - * @param ydata Y data - * @param missingValue Missing value - * @param projInfo Projection info - */ - public GridData(Array array, List xdata, List ydata, double missingValue, ProjectionInfo projInfo) { - int yn = ydata.size(); - int xn = xdata.size(); - this.data = new double[yn][xn]; - IndexIterator iter = array.getIndexIterator(); - int idx = 0; - while (iter.hasNext()) { - double val = iter.getDoubleNext(); - if (java.lang.Double.isNaN(val)) { - data[idx / xn][idx % xn] = missingValue; - } else { - data[idx / xn][idx % xn] = val; - } - idx += 1; - } - - this.xArray = new double[xn]; - this.yArray = new double[yn]; - for (int i = 0; i < xn; i++) { - this.xArray[i] = xdata.get(i).doubleValue(); - } - for (int i = 0; i < yn; i++) { - this.yArray[i] = ydata.get(i).doubleValue(); - } - - this.missingValue = missingValue; - this.projInfo = projInfo; - } - - /** - * Constructor - * - * @param array Data array - * @param xdata X data - * @param ydata Y data - */ - public GridData(Array array, Array xdata, Array ydata) { - this(array, xdata, ydata, -9999.0); - } - - /** - * Constructor - * - * @param array Data array - * @param xdata X data - * @param ydata Y data - * @param missingValue Missing value - */ - public GridData(Array array, Array xdata, Array ydata, Number missingValue) { - int yn = (int) ydata.getSize(); - int xn = (int) xdata.getSize(); - this.data = new double[yn][xn]; - IndexIterator iter = array.getIndexIterator(); - int idx = 0; - while (iter.hasNext()) { - double val = iter.getDoubleNext(); - if (java.lang.Double.isNaN(val)) { - data[idx / xn][idx % xn] = missingValue.doubleValue(); - } else { - data[idx / xn][idx % xn] = val; - } - idx += 1; - } - - this.xArray = new double[xn]; - this.yArray = new double[yn]; - iter = xdata.getIndexIterator(); - int i = 0; - while(iter.hasNext()) { - this.xArray[i] = iter.getDoubleNext(); - i++; - } - iter = ydata.getIndexIterator(); - i = 0; - while(iter.hasNext()) { - this.yArray[i] = iter.getDoubleNext(); - i++; - } - - this.missingValue = missingValue.doubleValue(); - this.projInfo = KnownCoordinateSystems.geographic.world.WGS1984;; - } - // - // - - /** - * Get xArray number - * - * @return xArray number - */ - public int getXNum() { - return xArray.length; - } - - /** - * Get yArray number - * - * @return yArray number - */ - public int getYNum() { - return yArray.length; - } - - /** - * Get xArray delt - * - * @return xArray delt - */ - public double getXDelt() { - return xArray[1] - xArray[0]; - } - - /** - * Get yArray delt - * - * @return yArray delt - */ - public double getYDelt() { - return yArray[1] - yArray[0]; - } - - /** - * Get Extent - * - * @return Extent - */ - public Extent getExtent() { - Extent extent = new Extent(); - extent.minX = xArray[0]; - extent.maxX = xArray[xArray.length - 1]; - extent.minY = yArray[0]; - extent.maxY = yArray[yArray.length - 1]; - - return extent; - } - - /** - * Get if the data is global - * - * @return If the data is global - */ - public boolean isGlobal() { - boolean isGlobal = false; - if (MIMath.doubleEquals(xArray[getXNum() - 1] + getXDelt() - xArray[0], 360.0)) { - isGlobal = true; - } - - return isGlobal; - } - - /** - * Get if is x stagger - * - * @return Boolean - */ - public boolean isXStagger() { - return _xStag; - } - - /** - * Set if is x stagger - * - * @param value Boolean - */ - public void setXStagger(boolean value) { - _xStag = value; - } - - /** - * Get if is y stagger - * - * @return Boolean - */ - public boolean isYStagger() { - return _yStag; - } - - /** - * Set if is y stagger - * - * @param value Boolean - */ - public void setYStagger(boolean value) { - _yStag = value; - } - - /** - * Get value - * - * @param i I index - * @param j J index - * @return Value - */ - public Number getValue(int i, int j) { - return data[i][j]; - } - - /** - * Get double value - * - * @param i I index - * @param j J index - * @return Double value - */ - public double getDoubleValue(int i, int j) { - return data[i][j]; - } - - // - // - // - /** - * Add operation with another grid data - * - * @param bGrid The grid data - * @return Added grid data - */ - public GridData add(GridData bGrid) { - int xNum = this.getXNum(); - int yNum = this.getYNum(); - - GridData cGrid = new GridData(this); - for (int i = 0; i < yNum; i++) { - for (int j = 0; j < xNum; j++) { - if (MIMath.doubleEquals(data[i][j], missingValue) - || MIMath.doubleEquals(bGrid.data[i][j], bGrid.missingValue)) { - cGrid.data[i][j] = missingValue; - } else { - cGrid.data[i][j] = data[i][j] + bGrid.data[i][j]; - } - } - } - - return cGrid; - } - - /** - * Add operation with a double value - * - * @param value Double value - * @return Added grid data - */ - public GridData add(double value) { - int xNum = this.getXNum(); - int yNum = this.getYNum(); - - GridData cGrid = new GridData(this); - for (int i = 0; i < yNum; i++) { - for (int j = 0; j < xNum; j++) { - if (MIMath.doubleEquals(data[i][j], missingValue)) { - cGrid.data[i][j] = missingValue; - } else { - cGrid.data[i][j] = data[i][j] + value; - } - } - } - - return cGrid; - } - - /** - * Subtraction operation with another grid data - * - * @param bGrid The grid data - * @return Subtracted grid data - */ - public GridData sub(GridData bGrid) { - int xNum = this.getXNum(); - int yNum = this.getYNum(); - - GridData cGrid = new GridData(this); - for (int i = 0; i < yNum; i++) { - for (int j = 0; j < xNum; j++) { - if (MIMath.doubleEquals(data[i][j], missingValue) - || MIMath.doubleEquals(bGrid.data[i][j], bGrid.missingValue)) { - cGrid.data[i][j] = missingValue; - } else { - cGrid.data[i][j] = data[i][j] - bGrid.data[i][j]; - } - } - } - - return cGrid; - } - - /** - * Subtraction operation with a double value - * - * @param value The double value - * @return Subtracted grid data - */ - public GridData sub(double value) { - int xNum = this.getXNum(); - int yNum = this.getYNum(); - - GridData cGrid = new GridData(this); - for (int i = 0; i < yNum; i++) { - for (int j = 0; j < xNum; j++) { - if (MIMath.doubleEquals(data[i][j], missingValue)) { - cGrid.data[i][j] = missingValue; - } else { - cGrid.data[i][j] = data[i][j] - value; - } - } - } - - return cGrid; - } - - /** - * Multiply operation with another grid data - * - * @param bGrid The grid data - * @return Result grid data - */ - public GridData mul(GridData bGrid) { - int xNum = this.getXNum(); - int yNum = this.getYNum(); - - GridData cGrid = new GridData(this); - for (int i = 0; i < yNum; i++) { - for (int j = 0; j < xNum; j++) { - if (MIMath.doubleEquals(data[i][j], missingValue) - || MIMath.doubleEquals(bGrid.data[i][j], bGrid.missingValue)) { - cGrid.data[i][j] = missingValue; - } else { - cGrid.data[i][j] = data[i][j] * bGrid.data[i][j]; - } - } - } - - return cGrid; - } - - /** - * Multiply operation with a double value - * - * @param value Double value - * @return Result grid data - */ - public GridData mul(double value) { - int xNum = this.getXNum(); - int yNum = this.getYNum(); - - GridData cGrid = new GridData(this); - for (int i = 0; i < yNum; i++) { - for (int j = 0; j < xNum; j++) { - if (MIMath.doubleEquals(data[i][j], missingValue)) { - cGrid.data[i][j] = missingValue; - } else { - cGrid.data[i][j] = data[i][j] * value; - } - } - } - - return cGrid; - } - - /** - * Divide operation with another grid data - * - * @param bGrid The grid data - * @return Result grid data - */ - public GridData div(GridData bGrid) { - int xNum = this.getXNum(); - int yNum = this.getYNum(); - - GridData cGrid = new GridData(this); - for (int i = 0; i < yNum; i++) { - for (int j = 0; j < xNum; j++) { - if (MIMath.doubleEquals(data[i][j], missingValue) - || MIMath.doubleEquals(bGrid.data[i][j], bGrid.missingValue)) { - cGrid.data[i][j] = missingValue; - } else if (bGrid.data[i][j] == 0) { - cGrid.data[i][j] = missingValue; - } else { - cGrid.data[i][j] = data[i][j] / bGrid.data[i][j]; - } - } - } - - return cGrid; - } - - /** - * Divide operation with a double value - * - * @param value Double value - * @return Result grid data - */ - public GridData div(double value) { - int xNum = this.getXNum(); - int yNum = this.getYNum(); - - GridData cGrid = new GridData(this); - for (int i = 0; i < yNum; i++) { - for (int j = 0; j < xNum; j++) { - if (MIMath.doubleEquals(data[i][j], missingValue)) { - cGrid.data[i][j] = missingValue; - } else { - cGrid.data[i][j] = data[i][j] / value; - } - } - } - - return cGrid; - } - - /** - * Regrid data with double linear interpolation method - * - * @param gridData Result grid data - */ - public void regrid(GridData gridData) { - for (int i = 0; i < gridData.getYNum(); i++) { - for (int j = 0; j < gridData.getXNum(); j++) { - gridData.data[i][j] = toStation(gridData.xArray[j], gridData.yArray[i]); - } - } - } - - /** - * Interpolate grid data to a station point - * - * @param x X coordinate of the station - * @param y Y coordinate of the station - * @return Interpolated value - */ - public double toStation(double x, double y) { - double iValue = missingValue; - if (x < xArray[0] || x > xArray[this.getXNum() - 1] || y < yArray[0] || y > yArray[this.getYNum() - 1]) { - return iValue; - } - - //Get x/y index - double DX = this.getXDelt(); - double DY = this.getYDelt(); - int xIdx = 0, yIdx = 0; - xIdx = (int) ((x - xArray[0]) / DX); - yIdx = (int) ((y - yArray[0]) / DY); - if (xIdx == this.getXNum() - 1) { - xIdx = this.getXNum() - 2; - } - - if (yIdx == this.getYNum() - 1) { - yIdx = this.getYNum() - 2; - } - - int i1 = yIdx; - int j1 = xIdx; - int i2 = i1 + 1; - int j2 = j1 + 1; - double a = data[i1][j1]; - double b = data[i1][j2]; - double c = data[i2][j1]; - double d = data[i2][j2]; - List dList = new ArrayList<>(); - if (!MIMath.doubleEquals(a, missingValue)) { - dList.add(a); - } - if (!MIMath.doubleEquals(b, missingValue)) { - dList.add(b); - } - if (!MIMath.doubleEquals(c, missingValue)) { - dList.add(c); - } - if (!MIMath.doubleEquals(d, missingValue)) { - dList.add(d); - } - - if (dList.isEmpty()) { - return iValue; - } else if (dList.size() == 1) { - iValue = dList.get(0); - } else if (dList.size() <= 3) { - double aSum = 0; - for (double dd : dList) { - aSum += dd; - } - iValue = aSum / dList.size(); - } else { - double x1val = a + (c - a) * (y - yArray[i1]) / DY; - double x2val = b + (d - b) * (y - yArray[i1]) / DY; - iValue = x1val + (x2val - x1val) * (x - xArray[j1]) / DX; - } - - return iValue; - } - - /** - * Interpolate grid data to station points - * - * @param xlist X coordinate list - * @param ylist Y coordinate list - * @return Result data list - */ - public List toStation(List xlist, List ylist) { - List r = new ArrayList<>(); - double x, y, v; - for (int i = 0; i < xlist.size(); i++) { - x = xlist.get(i).doubleValue(); - y = ylist.get(i).doubleValue(); - v = this.toStation(x, y); - r.add(v); - } - - return r; - } - - /** - * Interpolate grid data to station data - * - * @param stData Station data - * @return Interpolated station data - */ - public StationData toStation(StationData stData) { - StationData nstData = new StationData(stData); - nstData.missingValue = this.missingValue; - if (this.projInfo.equals(stData.projInfo)) { - for (int i = 0; i < nstData.getStNum(); i++) { - nstData.setValue(i, this.toStation(nstData.getX(i), nstData.getY(i))); - } - } else { - nstData = this.project(projInfo, stData.projInfo, stData, ResampleMethods.Bilinear); - } - - return nstData; - } - - /** - * Interpolate grid data to station data - * - * @param stData Station table data - */ - public void toStation(StationTableData stData) { - //DataTable dataTable = stData.dataTable; - int lonIdx = stData.getLonIndex(); - int latIdx = stData.getLatIndex(); - double x, y; - try { - stData.addColumn(this.fieldName, DataType.FLOAT); - } catch (Exception ex) { - Logger.getLogger(GridData.class.getName()).log(Level.SEVERE, null, ex); - } - if (this.projInfo.equals(stData.getProjectionInfo())) { - for (int i = 0; i < stData.getRowCount(); i++) { - x = java.lang.Double.parseDouble(stData.getValue(i, lonIdx).toString()); - y = java.lang.Double.parseDouble(stData.getValue(i, latIdx).toString()); - stData.setValue(i, fieldName, this.toStation(x, y)); - } - } else { - StationData sdata = new StationData(); - for (int i = 0; i < stData.getRowCount(); i++) { - x = java.lang.Double.parseDouble(stData.getValue(i, lonIdx).toString()); - y = java.lang.Double.parseDouble(stData.getValue(i, latIdx).toString()); - sdata.addData("S_" + String.valueOf(i), x, y, 0); - } - sdata = this.project(projInfo, sdata.projInfo, sdata, ResampleMethods.Bilinear); - for (int i = 0; i < stData.getRowCount(); i++) { - stData.setValue(i, fieldName, sdata.getValue(i)); - } - } - } - - /** - * Interpolate grid data to stations imported from station file - * - * @param inFile Input station file - * @param outFile Output station file - * @throws UnsupportedEncodingException - * @throws FileNotFoundException - */ - public void toStation(String inFile, String outFile) throws UnsupportedEncodingException, FileNotFoundException, IOException { - if (!new File(inFile).exists()) { - return; - } - - BufferedReader sr = new BufferedReader(new InputStreamReader(new FileInputStream(inFile), "utf-8")); - BufferedWriter sw = new BufferedWriter(new FileWriter(new File(outFile))); - - //Header - String aLine = sr.readLine(); - aLine = aLine + ",data"; - sw.write(aLine); - sw.newLine(); - - //Data - String[] dArray; - String stId; - double x, y; - double value; - aLine = sr.readLine(); - while (aLine != null) { - aLine = aLine.trim(); - dArray = aLine.split(","); - if (dArray.length < 3) { - continue; - } - - stId = dArray[0].trim(); - x = java.lang.Double.parseDouble(dArray[1].trim()); - y = java.lang.Double.parseDouble(dArray[2].trim()); - value = toStation(x, y); - if (!java.lang.Double.isNaN(value)) { - aLine = aLine + "," + String.valueOf(value); - sw.write(aLine); - sw.newLine(); - } - aLine = sr.readLine(); - } - - sr.close(); - sw.close(); - } - - /** - * Set grid values by anthor grid data - overlay - * - * @param bGrid The grid data - * @return Result grid data - */ - public GridData setValue(GridData bGrid) { - Extent aExtent = this.getExtent(); - Extent bExtent = bGrid.getExtent(); - if (!MIMath.isExtentCross(aExtent, bExtent)) { - return this; - } - - int xNum = this.getXNum(); - int yNum = this.getYNum(); - double axdelt = this.getXDelt(); - double aydelt = this.getYDelt(); - int sXidx = 0; - int eXidx = xNum - 1; - int sYidx = 0; - int eYidx = yNum - 1; - if (aExtent.minX < bExtent.minX) { - sXidx = (int) ((bExtent.minX - aExtent.minX) / axdelt); - } - if (aExtent.maxX > bExtent.maxX) { - eXidx = (int) ((bExtent.maxX - aExtent.minX) / axdelt); - } - if (aExtent.minY < bExtent.minY) { - sYidx = (int) ((bExtent.minY - aExtent.minY) / aydelt); - } - if (aExtent.maxY > bExtent.maxY) { - eYidx = (int) ((bExtent.maxY - aExtent.minY) / aydelt); - } - - GridData cGrid = (GridData) this.clone(); - int xidx, yidx; - double bxdelt = bGrid.getXDelt(); - double bydelt = bGrid.getYDelt(); - for (int i = sYidx; i <= eYidx; i++) { - for (int j = sXidx; j <= eXidx; j++) { - xidx = (int) ((xArray[j] - bGrid.xArray[0]) / bxdelt); - if (xidx < 0 || xidx >= bGrid.getXNum()) { - continue; - } - yidx = (int) ((yArray[i] - bGrid.yArray[0]) / bydelt); - if (yidx < 0 || yidx >= bGrid.getYNum()) { - continue; - } - cGrid.data[i][j] = bGrid.data[yidx][xidx]; - } - } - - return cGrid; - } - - /** - * Set grid values by anthor grid data - overlay - * - * @param bGrid The grid data - * @param useMissingData if set missing data - * @return Result grid data - */ - public GridData setValue(GridData bGrid, boolean useMissingData) { - Extent aExtent = this.getExtent(); - Extent bExtent = bGrid.getExtent(); - if (!MIMath.isExtentCross(aExtent, bExtent)) { - return this; - } - - int xNum = this.getXNum(); - int yNum = this.getYNum(); - double axdelt = this.getXDelt(); - double aydelt = this.getYDelt(); - int sXidx = 0; - int eXidx = xNum - 1; - int sYidx = 0; - int eYidx = yNum - 1; - if (aExtent.minX < bExtent.minX) { - sXidx = (int) ((bExtent.minX - aExtent.minX) / axdelt); - } - if (aExtent.maxX > bExtent.maxX) { - eXidx = (int) ((bExtent.maxX - aExtent.minX) / axdelt); - } - if (aExtent.minY < bExtent.minY) { - sYidx = (int) ((bExtent.minY - aExtent.minY) / aydelt); - } - if (aExtent.maxY > bExtent.maxY) { - eYidx = (int) ((bExtent.maxY - aExtent.minY) / aydelt); - } - - GridData cGrid = (GridData) this.clone(); - int xidx, yidx; - double bxdelt = bGrid.getXDelt(); - double bydelt = bGrid.getYDelt(); - for (int i = sYidx; i <= eYidx; i++) { - for (int j = sXidx; j <= eXidx; j++) { - xidx = (int) ((xArray[j] - bGrid.xArray[0]) / bxdelt); - if (xidx < 0 || xidx >= bGrid.getXNum()) { - continue; - } - yidx = (int) ((yArray[i] - bGrid.yArray[0]) / bydelt); - if (yidx < 0 || yidx >= bGrid.getYNum()) { - continue; - } - if (useMissingData) { - if (MIMath.doubleEquals(bGrid.data[yidx][xidx], bGrid.missingValue)) { - continue; - } - } - cGrid.data[i][j] = bGrid.data[yidx][xidx]; - } - } - - return cGrid; - } - - /** - * Set constant value to all grid cells - * - * @param aValue The value - * @return Result grid data - */ - public GridData setValue(double aValue) { - int xNum = this.getXNum(); - int yNum = this.getYNum(); - - GridData cGrid = new GridData(this); - for (int i = 0; i < yNum; i++) { - for (int j = 0; j < xNum; j++) { - cGrid.data[i][j] = aValue; - } - } - - return cGrid; - } - - /** - * Replace a certain grid data value by a new value - * - * @param aValue Old value - * @param bValue New value - */ - public void replaceValue(double aValue, double bValue) { - for (int i = 0; i < getYNum(); i++) { - for (int j = 0; j < getXNum(); j++) { - if (data[i][j] == aValue) { - data[i][j] = bValue; - } - } - } - } - - /** - * Replace grid data value by a threshold - the values bigger/smaller than - * the threshold value will be replaced by the new value - * - * @param aValue Threshold value - * @param bValue New value - * @param bigger Bigger or smaller - */ - public void replaceValue(double aValue, double bValue, boolean bigger) { - for (int i = 0; i < getYNum(); i++) { - for (int j = 0; j < getXNum(); j++) { - if (bigger) { - if (data[i][j] > aValue) { - data[i][j] = bValue; - } - } else if (data[i][j] < aValue) { - data[i][j] = bValue; - } - } - } - } - - /** - * Merge grid values by anthor grid data - the two grids should have same - * extent replace missing value with valid data - * - * @param bGrid The grid data - * @return Result grid data - */ - public GridData merge(GridData bGrid) { - int xNum = this.getXNum(); - int yNum = this.getYNum(); - - GridData cGrid = (GridData) this.clone(); - for (int i = 0; i < yNum; i++) { - for (int j = 0; j < xNum; j++) { - if (MIMath.doubleEquals(data[i][j], missingValue) - && (!MIMath.doubleEquals(bGrid.data[i][j], bGrid.missingValue))) { - cGrid.data[i][j] = bGrid.data[i][j]; - } - } - } - - return cGrid; - } - - /** - * Maximum operation with another grid data - * - * @param bGrid The grid data - * @return Maximum grid data - */ - public GridData max(GridData bGrid) { - int xNum = this.getXNum(); - int yNum = this.getYNum(); - - GridData cGrid = new GridData(this); - for (int i = 0; i < yNum; i++) { - for (int j = 0; j < xNum; j++) { - if (MIMath.doubleEquals(data[i][j], missingValue) - || MIMath.doubleEquals(bGrid.data[i][j], bGrid.missingValue)) { - cGrid.data[i][j] = missingValue; - } else { - cGrid.data[i][j] = Math.max(data[i][j], bGrid.data[i][j]); - } - } - } - - return cGrid; - } - - /** - * Minimum operation with another grid data - * - * @param bGrid The grid data - * @return Minimum grid data - */ - public GridData min(GridData bGrid) { - int xNum = this.getXNum(); - int yNum = this.getYNum(); - - GridData cGrid = new GridData(this); - for (int i = 0; i < yNum; i++) { - for (int j = 0; j < xNum; j++) { - if (MIMath.doubleEquals(data[i][j], missingValue) - || MIMath.doubleEquals(bGrid.data[i][j], bGrid.missingValue)) { - cGrid.data[i][j] = missingValue; - } else { - cGrid.data[i][j] = Math.min(data[i][j], bGrid.data[i][j]); - } - } - } - - return cGrid; - } - - /** - * Calculate summary value - * - * @return Summary value - */ - public double sum() { - double sum = 0; - for (int i = 0; i < this.getYNum(); i++) { - for (int j = 0; j < this.getXNum(); j++) { - if (MIMath.doubleEquals(data[i][j], missingValue)) { - continue; - } - - sum += data[i][j]; - } - } - - return sum; - } - - /** - * Calculate average value - * - * @return Average value - */ - public double average() { - double ave = 0; - int vdNum = 0; - for (int i = 0; i < this.getYNum(); i++) { - for (int j = 0; j < this.getXNum(); j++) { - if (MIMath.doubleEquals(data[i][j], missingValue)) { - continue; - } - - ave += data[i][j]; - vdNum += 1; - } - } - - ave = ave / vdNum; - - return ave; - } - - /** - * Calculate average data array by another grid data and threshold values - * - * @param bGrid The grid data - * @param tValues Threshold values - * @return Average values - */ - public double[] average(GridData bGrid, double[] tValues) { - int vn = tValues.length; - int n = vn + 1; - double[] aves = new double[n]; - int[] vdNum = new int[n]; - int k; - double v, bv; - for (int i = 0; i < this.getYNum(); i++) { - for (int j = 0; j < this.getXNum(); j++) { - v = data[i][j]; - bv = bGrid.data[i][j]; - if (MIMath.doubleEquals(v, missingValue)) { - continue; - } - - if (MIMath.doubleEquals(bv, bGrid.missingValue)) { - continue; - } - - if (bv >= tValues[vn - 1]) { - k = vn; - } else { - for (k = 0; k < vn; k++) { - if (bv < tValues[k]) { - break; - } - } - } - aves[k] += v; - vdNum[k] += 1; - } - } - - for (k = 0; k < n; k++) { - if (vdNum[k] > 0) { - aves[k] = aves[k] / vdNum[k]; - } else { - aves[k] = missingValue; - } - } - - return aves; - } - - /** - * Simple statistics of the grid data - * - * @return Result array - average, standard deviation - */ - public double[] statistics() { - double theMean, theSqDev, theSumSqDev, theVariance, theStdDev, theValue; - - theMean = average(); - theSumSqDev = 0; - int vdNum = 0; - for (int i = 0; i < this.getYNum(); i++) { - for (int j = 0; j < this.getXNum(); j++) { - if (MIMath.doubleEquals(data[i][j], missingValue)) { - continue; - } - - theValue = data[i][j]; - theSqDev = (theValue - theMean) * (theValue - theMean); - theSumSqDev = theSqDev + theSumSqDev; - vdNum += 1; - } - } - - theVariance = theSumSqDev / (vdNum - 1); - theStdDev = Math.sqrt(theVariance); - double sem = theStdDev / Math.sqrt(vdNum); - - return new double[]{theMean, theStdDev, sem}; - } - // - // - - /** - * Calculate abstract grid data - * - * @return Result grid data - */ - public GridData abs() { - GridData gridData = new GridData(this); - for (int i = 0; i < gridData.getYNum(); i++) { - for (int j = 0; j < gridData.getXNum(); j++) { - if (MIMath.doubleEquals(data[i][j], missingValue)) { - gridData.data[i][j] = missingValue; - } else { - gridData.data[i][j] = Math.abs(data[i][j]); - } - } - } - - return gridData; - } - - /** - * Calculate anti-cosine grid data - * - * @return Result grid data - */ - public GridData acos() { - GridData gridData = new GridData(this); - for (int i = 0; i < gridData.getYNum(); i++) { - for (int j = 0; j < gridData.getXNum(); j++) { - if (MIMath.doubleEquals(data[i][j], missingValue)) { - gridData.data[i][j] = missingValue; - } else { - gridData.data[i][j] = Math.acos(data[i][j]); - } - } - } - - return gridData; - } - - /** - * Calculate anti-sine grid data - * - * @return Result grid data - */ - public GridData asin() { - GridData gridData = new GridData(this); - for (int i = 0; i < gridData.getYNum(); i++) { - for (int j = 0; j < gridData.getXNum(); j++) { - if (MIMath.doubleEquals(data[i][j], missingValue)) { - gridData.data[i][j] = missingValue; - } else { - gridData.data[i][j] = Math.asin(data[i][j]); - } - } - } - - return gridData; - } - - /** - * Calculate anti-tangent grid data - * - * @return Result grid data - */ - public GridData atan() { - GridData gridData = new GridData(this); - for (int i = 0; i < gridData.getYNum(); i++) { - for (int j = 0; j < gridData.getXNum(); j++) { - if (MIMath.doubleEquals(data[i][j], missingValue)) { - gridData.data[i][j] = missingValue; - } else { - gridData.data[i][j] = Math.atan(data[i][j]); - } - } - } - - return gridData; - } - - /** - * Calculate cosine grid data - * - * @return Result grid data - */ - public GridData cos() { - GridData gridData = new GridData(this); - for (int i = 0; i < gridData.getYNum(); i++) { - for (int j = 0; j < gridData.getXNum(); j++) { - if (MIMath.doubleEquals(data[i][j], missingValue)) { - gridData.data[i][j] = missingValue; - } else { - gridData.data[i][j] = Math.cos(data[i][j]); - } - } - } - - return gridData; - } - - /** - * Calculate sine grid data - * - * @return Result grid data - */ - public GridData sin() { - GridData gridData = new GridData(this); - for (int i = 0; i < gridData.getYNum(); i++) { - for (int j = 0; j < gridData.getXNum(); j++) { - if (MIMath.doubleEquals(data[i][j], missingValue)) { - gridData.data[i][j] = missingValue; - } else { - gridData.data[i][j] = Math.sin(data[i][j]); - } - } - } - - return gridData; - } - - /** - * Calculate tangent grid data - * - * @return Result grid data - */ - public GridData tan() { - GridData gridData = new GridData(this); - for (int i = 0; i < gridData.getYNum(); i++) { - for (int j = 0; j < gridData.getXNum(); j++) { - if (MIMath.doubleEquals(data[i][j], missingValue)) { - gridData.data[i][j] = missingValue; - } else { - gridData.data[i][j] = Math.abs(data[i][j]); - } - } - } - - return gridData; - } - - /** - * Calculate e raised specific power value of grid data - * - * @return Result grid data - */ - public GridData exp() { - GridData gridData = new GridData(this); - for (int i = 0; i < gridData.getYNum(); i++) { - for (int j = 0; j < gridData.getXNum(); j++) { - if (MIMath.doubleEquals(data[i][j], missingValue)) { - gridData.data[i][j] = missingValue; - } else { - gridData.data[i][j] = Math.exp(data[i][j]); - } - } - } - - return gridData; - } - - /** - * Calculate power grid data - * - * @param p Power value - * @return Result grid data - */ - public GridData pow(double p) { - GridData gridData = new GridData(this); - for (int i = 0; i < gridData.getYNum(); i++) { - for (int j = 0; j < gridData.getXNum(); j++) { - if (MIMath.doubleEquals(data[i][j], missingValue)) { - gridData.data[i][j] = missingValue; - } else { - gridData.data[i][j] = Math.pow(data[i][j], p); - } - } - } - - return gridData; - } - - /** - * Calculate square root grid data - * - * @return Result grid data - */ - public GridData sqrt() { - GridData gridData = new GridData(this); - for (int i = 0; i < gridData.getYNum(); i++) { - for (int j = 0; j < gridData.getXNum(); j++) { - if (MIMath.doubleEquals(data[i][j], missingValue)) { - gridData.data[i][j] = missingValue; - } else { - gridData.data[i][j] = Math.sqrt(data[i][j]); - } - } - } - - return gridData; - } - - /** - * Calculate logrithm grid data - * - * @return Result grid data - */ - public GridData log() { - GridData gridData = new GridData(this); - for (int i = 0; i < gridData.getYNum(); i++) { - for (int j = 0; j < gridData.getXNum(); j++) { - if (MIMath.doubleEquals(data[i][j], missingValue)) { - gridData.data[i][j] = missingValue; - } else { - gridData.data[i][j] = Math.log(data[i][j]); - } - } - } - - return gridData; - } - - /** - * Calculate base 10 logrithm grid data - * - * @return Result grid data - */ - public GridData log10() { - GridData gridData = new GridData(this); - for (int i = 0; i < gridData.getYNum(); i++) { - for (int j = 0; j < gridData.getXNum(); j++) { - if (MIMath.doubleEquals(data[i][j], missingValue)) { - gridData.data[i][j] = missingValue; - } else { - gridData.data[i][j] = Math.abs(data[i][j]); - } - } - } - - return gridData; - } - // - // - - /** - * Extend the grid data to global by add a new column data - */ - public void extendToGlobal() { - int yNum = getYNum(); - int xNum = getXNum(); - double[][] newGriddata = new double[yNum][xNum + 1]; - double[] newX = new double[xNum + 1]; - int i, j; - for (i = 0; i < xNum; i++) { - newX[i] = xArray[i]; - } - - newX[xNum] = newX[xNum - 1] + getXDelt(); - for (i = 0; i < yNum; i++) { - for (j = 0; j < xNum; j++) { - newGriddata[i][j] = data[i][j]; - } - newGriddata[i][xNum] = newGriddata[i][0]; - } - - data = newGriddata; - xArray = newX; - } - - /** - * Get array from data - * - * @return Array - */ - public Array getArray() { - int yn = this.getYNum(); - int xn = this.getXNum(); - int[] shape = new int[]{yn, xn}; - Array r = Array.factory(DataType.DOUBLE, shape); - for (int i = 0; i < yn; i++) { - for (int j = 0; j < xn; j++) { - r.setDouble(i * xn + j, this.data[i][j]); - } - } - - return r; - } - - /** - * Get dimensions - * - * @return Dimensions - */ - public List getDimensions() { - List dims = new ArrayList<>(); - Dimension ydim = new Dimension(DimensionType.Y); - ydim.setValues(this.yArray); - dims.add(ydim); - Dimension xdim = new Dimension(DimensionType.X); - xdim.setValues(this.xArray); - dims.add(xdim); - - return dims; - } - - // - // - /** - * Extract grid data by extent - * - * @param extent Extent - * @return Extracted grid data - */ - public GridData extract(Extent extent) { - return extract(extent.minX, extent.maxX, extent.minY, extent.maxY); - } - - /** - * Extract grid data by extent - * - * @param sX Start X - * @param eX End X - * @param sY Start Y - * @param eY End Y - * @return Grid data - */ - public GridData extract(double sX, double eX, double sY, double eY) { - if (eX <= sX || eY <= sY) { - return null; - } - - int xNum = this.getXNum(); - int yNum = this.getYNum(); - if (sX >= xArray[xNum - 2] || sY >= yArray[yNum - 2]) { - return null; - } - - GridData aGridData = new GridData(); - aGridData.projInfo = projInfo; - aGridData.missingValue = missingValue; - int sXidx = 0, eXidx = xNum - 1, sYidx = 0, eYidx = yNum - 1; - - //Get start x - int i; - if (sX <= xArray[0]) { - sXidx = 0; - } else { - for (i = 0; i < xNum; i++) { - if (sX <= xArray[i]) { - sXidx = i; - break; - } - } - } - - //Get end x - if (eX >= xArray[xNum - 1]) { - eXidx = xNum - 1; - } else { - for (i = sXidx; i < xNum; i++) { - if (MIMath.doubleEquals(eX, xArray[i])) { - eXidx = i; - break; - } else if (eX < xArray[i]) { - eXidx = i - 1; - break; - } - } - } - - //Get star y - if (sY <= yArray[0]) { - sYidx = 0; - } else { - for (i = 0; i < yNum; i++) { - if (sY <= yArray[i]) { - sYidx = i; - break; - } - } - } - - //Get end y - if (eY >= yArray[yNum - 1]) { - eYidx = yNum - 1; - } else { - for (i = sYidx; i < yNum; i++) { - if (MIMath.doubleEquals(eY, yArray[i])) { - eYidx = i; - break; - } else if (eY < yArray[i]) { - eYidx = i - 1; - break; - } - } - } - - int newXNum = eXidx - sXidx + 1; - double[] newX = new double[newXNum]; - for (i = sXidx; i <= eXidx; i++) { - newX[i - sXidx] = xArray[i]; - } - - int newYNum = eYidx - sYidx + 1; - double[] newY = new double[newYNum]; - for (i = sYidx; i <= eYidx; i++) { - newY[i - sYidx] = yArray[i]; - } - - aGridData.xArray = newX; - aGridData.yArray = newY; - - double[][] newData = new double[newYNum][newXNum]; - for (i = sYidx; i <= eYidx; i++) { - for (int j = sXidx; j <= eXidx; j++) { - newData[i - sYidx][j - sXidx] = data[i][j]; - } - } - aGridData.data = newData; - - return aGridData; - } - - /** - * Extract grid data by extent index - * - * @param sXIdx Start x index - * @param sYIdx Start y index - * @param xNum X number - * @param yNum Y number - * @return Extracted grid data - */ - public GridData extract(int sXIdx, int sYIdx, int xNum, int yNum) { - GridData aGridData = new GridData(); - aGridData.projInfo = projInfo; - aGridData.missingValue = missingValue; - int eXIdx = sXIdx + xNum - 1, eYIdx = sYIdx + yNum - 1; - double[] newX = new double[xNum]; - int i; - for (i = sXIdx; i <= eXIdx; i++) { - newX[i - sXIdx] = xArray[i]; - } - - double[] newY = new double[yNum]; - for (i = sYIdx; i <= eYIdx; i++) { - newY[i - sYIdx] = yArray[i]; - } - - aGridData.xArray = newX; - aGridData.yArray = newY; - - double[][] newData = new double[yNum][xNum]; - for (i = sYIdx; i <= eYIdx; i++) { - for (int j = sXIdx; j <= eXIdx; j++) { - newData[i - sYIdx][j - sXIdx] = data[i][j]; - } - } - aGridData.data = newData; - - return aGridData; - } - - /** - * Extract grid data by extent index - * - * @param sXIdx Start x index - * @param eXIdx End x index - * @param xstep X step - * @param sYIdx Start y index - * @param eYIdx End y index - * @param ystep Y step - * @return Extracted grid data - */ - public GridData extract(int sXIdx, int eXIdx, int xstep, int sYIdx, int eYIdx, int ystep) { - GridData aGridData = new GridData(); - aGridData.projInfo = projInfo; - aGridData.missingValue = missingValue; - int xNum = (eXIdx - sXIdx) / xstep; - int yNum = (eYIdx - sYIdx) / ystep; - double[] newX = new double[xNum]; - int i, idx = 0; - for (i = sXIdx; i < eXIdx; i += xstep) { - newX[idx] = xArray[i]; - idx += 1; - } - - double[] newY = new double[yNum]; - idx = 0; - for (i = sYIdx; i < eYIdx; i += ystep) { - newY[idx] = yArray[i]; - idx += 1; - } - - aGridData.xArray = newX; - aGridData.yArray = newY; - - double[][] newData = new double[yNum][xNum]; - int yidx = 0; - for (i = sYIdx; i < eYIdx; i += ystep) { - int xidx = 0; - for (int j = sXIdx; j < eXIdx; j += xstep) { - newData[yidx][xidx] = data[i][j]; - xidx += 1; - } - yidx += 1; - } - aGridData.data = newData; - - return aGridData; - } - - /** - * Set missing value - bigger or smaller than the given value - * - * @param value The given value - * @param isBigger Is bigger or not - */ - public void setMissingValue(double value, boolean isBigger) { - int xnum = this.getXNum(); - int ynum = this.getYNum(); - for (int i = 0; i < ynum; i++) { - for (int j = 0; j < xnum; j++) { - if (isBigger) { - if (this.data[i][j] > value) { - this.data[i][j] = this.missingValue; - } - } else if (this.data[i][j] < value) { - this.data[i][j] = this.missingValue; - } - } - } - } - - /** - * Skip the grid data by two dimension skip factor - * - * @param skipI Skip number in x coordinate - * @param skipJ Skip number in y coordinate - * @return Grid data - */ - public GridData skip(int skipI, int skipJ) { - int yNum = (getYNum() + skipI - 1) / skipI; - int xNum = (getXNum() + skipJ - 1) / skipJ; - int i, j, idxI, idxJ; - - GridData gdata = new GridData(); - gdata.missingValue = missingValue; - gdata.xArray = new double[xNum]; - gdata.yArray = new double[yNum]; - gdata.data = new double[yNum][xNum]; - - for (i = 0; i < yNum; i++) { - idxI = i * skipI; - gdata.yArray[i] = yArray[idxI]; - } - for (j = 0; j < xNum; j++) { - idxJ = j * skipJ; - gdata.xArray[j] = xArray[idxJ]; - } - for (i = 0; i < yNum; i++) { - idxI = i * skipI; - for (j = 0; j < xNum; j++) { - idxJ = j * skipJ; - gdata.data[i][j] = data[idxI][idxJ]; - } - } - - return gdata; - } - - /** - * Get a cell value by X/Y coordinate - nearest cell - * - * @param x X coordinate - * @param y Y coordinate - * @return Cell value - */ - public double getValue(double x, double y) { - double iValue = missingValue; - int xnum = this.getXNum(); - int ynum = this.getYNum(); - if (x < xArray[0] || x > xArray[xnum - 1] || y < yArray[0] || y > yArray[ynum - 1]) { - return iValue; - } - - //Get x/y index - int xIdx = 0, yIdx = 0; - xIdx = (int) ((x - xArray[0]) / this.getXDelt()); - yIdx = (int) ((y - yArray[0]) / this.getYDelt()); - if (xIdx == xnum - 1) { - xIdx = xnum - 2; - } - - if (yIdx == ynum - 1) { - yIdx = ynum - 2; - } - - int i1 = yIdx; - int j1 = xIdx; - int i2 = i1 + 1; - int j2 = j1 + 1; - - if (x - xArray[j1] < xArray[j2] - x) { - xIdx = j1; - if (y - yArray[i1] < yArray[i2] - y) { - yIdx = i1; - } else { - yIdx = i2; - } - } else { - xIdx = j2; - if (y - yArray[i1] < yArray[i2] - y) { - yIdx = i1; - } else { - yIdx = i2; - } - } - - iValue = data[yIdx][xIdx]; - return iValue; - } - // - // - - /** - * Interpolate grid data to a station point - * - * @param x X coordinate of the station - * @param y Y coordinate of the station - * @return Interpolated value - */ - public double toStation_Gaussian(double x, double y) { - double iValue = missingValue; - double xmin = this.getXMin(); - double xmax = this.getXMax(); - double ymin = this.getYMin(); - double ymax = this.getYMax(); - if (x < xmin || x > xmax || y < ymin || y > ymax) { - return iValue; - } - - //Get x/y index - double xdelta = this.getXDelt(); - int xIdx = (int) ((x - xmin) / xdelta); - int yIdx = 0; - int i; - int xnum = this.getXNum(); - int ynum = this.getYNum(); - - if (xIdx == xnum - 1) { - xIdx = xnum - 2; - } - - for (i = 0; i < ynum - 1; i++) { - if (y >= yArray[i] && y <= yArray[i + 1]) { - yIdx = i; - break; - } - } - if (yIdx == ynum - 1) { - yIdx = ynum - 2; - } - - int i1 = yIdx; - int j1 = xIdx; - int i2 = i1 + 1; - int j2 = j1 + 1; - double a = data[i1][j1]; - double b = data[i1][j2]; - double c = data[i2][j1]; - double d = data[i2][j2]; - List dList = new ArrayList<>(); - if (a != missingValue) { - dList.add(a); - } - if (b != missingValue) { - dList.add(b); - } - if (c != missingValue) { - dList.add(c); - } - if (d != missingValue) { - dList.add(d); - } - - if (dList.isEmpty()) { - return iValue; - } else if (dList.size() == 1) { - iValue = dList.get(0); - } else if (dList.size() <= 3) { - double aSum = 0; - for (double dd : dList) { - aSum += dd; - } - iValue = aSum / dList.size(); - } else { - double ydelta = yArray[i2] - yArray[i1]; - double x1val = a + (c - a) * (y - yArray[i1]) / ydelta; - double x2val = b + (d - b) * (y - yArray[i1]) / ydelta; - iValue = x1val + (x2val - x1val) * (x - xArray[j1]) / xdelta; - } - - return iValue; - } - - /** - * Convert Gassian grid to lat/lon grid - */ - public void gassianToLatLon() { - double ymin = this.getYMin(); - double ymax = this.getYMax(); - int xnum = this.getXNum(); - int ynum = this.getYNum(); - double delta = (ymax - ymin) / (ynum - 1); - double[] newY = new double[ynum]; - for (int i = 0; i < ynum; i++) { - newY[i] = ymin + i * delta; - } - - double[][] newData = new double[ynum][xnum]; - for (int i = 0; i < ynum; i++) { - for (int j = 0; j < xnum; j++) { - newData[i][j] = toStation_Gaussian(xArray[j], newY[i]); - } - } - - this.yArray = newY; - this.data = newData; - } - - /** - * Convert Gassian grid to lat/lon grid - only convert Y coordinate - */ - public void GassianToLatLon_Simple() { - double ymin = this.getYMin(); - double ymax = this.getYMax(); - int ynum = this.getYNum(); - double delta = (ymax - ymin) / (ynum - 1); - double[] newY = new double[ynum]; - for (int i = 0; i < ynum; i++) { - newY[i] = ymin + i * delta; - } - - this.yArray = newY; - } - // - // - - /** - * Get minimum x - * - * @return Minimum x - */ - public double getXMin() { - return xArray[0]; - } - - /** - * Get maximum x - * - * @return Maximum x - */ - public double getXMax() { - return xArray[xArray.length - 1]; - } - - /** - * Get minimum y - * - * @return Minimum y - */ - public double getYMin() { - return yArray[0]; - } - - /** - * Get maximum y - * - * @return Maximum y - */ - public double getYMax() { - return yArray[yArray.length - 1]; - } - - /** - * Get minimum x of the grid border - * - * @return Minimum x of the grid border - */ - public double getBorderXMin() { - return this.getXMin() - this.getXDelt() / 2; - } - - /** - * Get maximum x of the grid border - * - * @return Maximum x of the grid border - */ - public double getBorderXMax() { - return this.getXMax() + this.getXDelt() / 2; - } - - /** - * Get minimum y of the grid border - * - * @return Minimum y of the grid border - */ - public double getBorderYMin() { - return this.getYMin() - this.getYDelt() / 2; - } - - /** - * Get maximum y of the grid border - * - * @return Maximum y of the grid border - */ - public double getBorderYMax() { - return this.getYMax() + this.getYDelt() / 2; - } - - /** - * Get i/j index of a point in the grid - * - * @param x The x coordinate - * @param y The y coordinate - * @return I/J index array - */ - public int[] getIJIndex(double x, double y) { - int xidx = -1; - int yidx = -1; - if (x >= this.getBorderXMin() && x <= this.getBorderXMax()) { - if (y >= this.getBorderYMin() && y <= this.getBorderYMax()) { - xidx = (int) ((x - this.getBorderXMin()) / this.getXDelt()); - yidx = (int) ((y - this.getBorderYMin()) / this.getYDelt()); - } - } - if (xidx >= this.getXNum() || yidx >= this.getYNum()) { - xidx = -1; - yidx = -1; - } - - return new int[]{xidx, yidx}; - } - - /** - * Save as Surfer ASCII data file - * - * @param aFile File path - */ - public void saveAsSurferASCIIFile(String aFile) { - try { - BufferedWriter sw = new BufferedWriter(new FileWriter(new File(aFile))); - sw.write("DSAA"); - sw.newLine(); - sw.write(String.valueOf(this.getXNum()) + " " + String.valueOf(this.getYNum())); - sw.newLine(); - sw.write(String.valueOf(xArray[0]) + " " + String.valueOf(xArray[xArray.length - 1])); - sw.newLine(); - sw.write(String.valueOf(yArray[0]) + " " + String.valueOf(yArray[yArray.length - 1])); - sw.newLine(); - double[] maxmin = new double[2]; - getMaxMinValue(maxmin); - sw.write(String.valueOf(maxmin[1]) + " " + String.valueOf(maxmin[0])); - double value; - String aLine = ""; - for (int i = 0; i < this.getYNum(); i++) { - for (int j = 0; j < this.getXNum(); j++) { - if (MIMath.doubleEquals(data[i][j], missingValue)) { - value = -9999.0; - } else { - value = data[i][j]; - } - - if (j == 0) { - aLine = String.valueOf(value); - } else { - aLine = aLine + " " + String.valueOf(value); - } - } - sw.newLine(); - sw.write(aLine); - } - sw.flush(); - sw.close(); - } catch (IOException ex) { - Logger.getLogger(GridData.class.getName()).log(Level.SEVERE, null, ex); - } - } - - /** - * Save as ESRI ASCII data file - * - * @param aFile File path - */ - public void saveAsESRIASCIIFile(String aFile) { - try { - BufferedWriter sw = new BufferedWriter(new FileWriter(new File(aFile))); - sw.write("NCOLS " + String.valueOf(this.getXNum())); - sw.newLine(); - sw.write("NROWS " + String.valueOf(this.getYNum())); - sw.newLine(); - sw.write("XLLCENTER " + String.valueOf(xArray[0])); - sw.newLine(); - sw.write("YLLCENTER " + String.valueOf(yArray[0])); - sw.newLine(); - sw.write("CELLSIZE " + String.valueOf(this.getXDelt())); - sw.newLine(); - sw.write("NODATA_VALUE " + String.valueOf(this.missingValue)); - sw.newLine(); - double value; - String aLine = ""; - int xn = this.getXNum(); - int yn = this.getYNum(); - for (int i = 0; i < yn; i++) { - for (int j = 0; j < xn; j++) { - value = data[yn - i - 1][j]; - if (j == 0) { - aLine = String.valueOf(value); - } else { - aLine = aLine + " " + String.valueOf(value); - } - } - sw.newLine(); - sw.write(aLine); - } - sw.flush(); - sw.close(); - } catch (IOException ex) { - Logger.getLogger(GridData.class.getName()).log(Level.SEVERE, null, ex); - } - } - - /** - * Save as BIL data file - * - * @param fileName File path - * @throws IOException - */ - public void saveAsBILFile(String fileName) throws IOException { - try { - //Save data file - DataOutputStream outs = new DataOutputStream(new FileOutputStream(new File(fileName))); - int xn = this.getXNum(); - int yn = this.getYNum(); - for (int i = 0; i < yn; i++) { - for (int j = 0; j < xn; j++) { - outs.writeFloat((float) data[yn - i - 1][j]); - } - } - outs.close(); - - //Save header file - String hfn = fileName.replace(".bil", ".hdr"); - BufferedWriter sw = new BufferedWriter(new FileWriter(new File(hfn))); - sw.write("nrows " + String.valueOf(this.getYNum())); - sw.newLine(); - sw.write("ncols " + String.valueOf(this.getXNum())); - sw.newLine(); - sw.write("nbands 1"); - sw.newLine(); - sw.write("nbits 32"); - sw.newLine(); - sw.write("pixeltype float"); - sw.newLine(); - sw.write("byteorder M"); - sw.newLine(); - sw.write("layout bil"); - sw.newLine(); - sw.write("ulxmap " + String.valueOf(xArray[0])); - sw.newLine(); - sw.write("ulymap " + String.valueOf(yArray[yArray.length - 1])); - sw.newLine(); - sw.write("xdim " + String.valueOf(this.getXDelt())); - sw.newLine(); - sw.write("ydim " + String.valueOf(this.getYDelt())); - sw.newLine(); - - sw.flush(); - sw.close(); - } catch (IOException ex) { - Logger.getLogger(GridData.class.getName()).log(Level.SEVERE, null, ex); - } - } - - /** - * Save as station data file - * - * @param filePath File Path - * @param fieldName Field name - */ - public void saveAsStationData(String filePath, String fieldName) { - try { - BufferedWriter sw = new BufferedWriter(new FileWriter(new File(filePath))); - sw.write("Id,X,Y," + fieldName); - String aLine = ""; - int id = 1; - for (int i = 0; i < this.getYNum(); i++) { - for (int j = 0; j < this.getXNum(); j++) { - if (!MIMath.doubleEquals(data[i][j], missingValue)) { - aLine = String.valueOf(id) + "," + String.valueOf(xArray[j]) + "," + String.valueOf(yArray[i]) + "," + String.valueOf(data[i][j]); - sw.newLine(); - sw.write(aLine); - } - } - } - sw.flush(); - sw.close(); - } catch (IOException ex) { - Logger.getLogger(GridData.class.getName()).log(Level.SEVERE, null, ex); - } - } - - /** - * Get maximum and minimum values - * - * @param maxmin Max/Min array - * @return If has undefine data - */ - public boolean getMaxMinValue(double[] maxmin) { - double max = 0; - double min = 0; - int vdNum = 0; - boolean hasUndef = false; - for (int i = 0; i < getYNum(); i++) { - for (int j = 0; j < getXNum(); j++) { - if (java.lang.Double.isNaN(data[i][j]) || MIMath.doubleEquals(data[i][j], missingValue)) { - hasUndef = true; - continue; - } - - if (vdNum == 0) { - min = data[i][j]; - max = min; - } else { - if (min > data[i][j]) { - min = data[i][j]; - } - if (max < data[i][j]) { - max = data[i][j]; - } - } - vdNum += 1; - } - } - - maxmin[0] = max; - maxmin[1] = min; - return hasUndef; - } - - /** - * Get if has missing value - * - * @return Boolean - */ - public boolean hasMissing() { - boolean hasNaN = false; - for (int i = 0; i < getYNum(); i++) { - for (int j = 0; j < getXNum(); j++) { - if (java.lang.Double.isNaN(data[i][j]) || MIMath.doubleEquals(data[i][j], missingValue)) { - hasNaN = true; - break; - } - } - } - return hasNaN; - } - - /** - * Set missing value - * @param value Missing value - */ - public void setMissingValue(double value) { - if (java.lang.Double.isNaN(value)) { - value = -9999.; - int yn = this.getYNum(); - int xn = this.getXNum(); - for (int i = 0; i < yn; i++) { - for (int j = 0; j < xn; j++) { - if (java.lang.Double.isNaN(this.data[i][j])) - this.data[i][j] = value; - } - } - } - this.missingValue = value; - } - - - /** - * Get if has NaN value - * - * @return Boolean - */ - public boolean hasNaN() { - boolean hasNaN = false; - for (int i = 0; i < getYNum(); i++) { - for (int j = 0; j < getXNum(); j++) { - if (java.lang.Double.isNaN(data[i][j])) { - hasNaN = true; - break; - } - } - } - return hasNaN; - } - - /** - * Get maximum and minimum values - * - * @return Max/Min array - */ - public double[] getMaxMinValue() { - double max = 0; - double min = 0; - int vdNum = 0; - for (int i = 0; i < getYNum(); i++) { - for (int j = 0; j < getXNum(); j++) { - if (java.lang.Double.isNaN(data[i][j]) || MIMath.doubleEquals(data[i][j], missingValue)) { - continue; - } - - if (vdNum == 0) { - min = data[i][j]; - max = min; - } else { - if (min > data[i][j]) { - min = data[i][j]; - } - if (max < data[i][j]) { - max = data[i][j]; - } - } - vdNum += 1; - } - } - - return new double[]{max, min}; - } - - /** - * Get maximum value - * - * @return Maximum value - */ - public double getMaxValue() { - return this.getMaxMinValue()[0]; - } - - /** - * Get minimum value - * - * @return Minimum value - */ - public double getMinValue() { - return this.getMaxMinValue()[1]; - } - - /** - * Test unique values - * - * @return True if unique value number less then 20 - */ - public boolean testUniqueValues() { - List values = new ArrayList<>(); - int vdNum = 0; - for (int i = 0; i < getYNum(); i++) { - for (int j = 0; j < getXNum(); j++) { - if (MIMath.doubleEquals(this.getValue(i, j).doubleValue(), missingValue)) { - continue; - } - - if (vdNum == 0) { - values.add(this.getValue(i, j)); - vdNum += 1; - } else if (!values.contains(this.getValue(i, j))) { - values.add(this.getValue(i, j)); - vdNum += 1; - } - if (vdNum > 20) { - return false; - } - } - } - - return true; - } - - /** - * Get unique values - * - * @return Unique values - */ - public List getUniqueValues() { - List values = new ArrayList<>(); - int vdNum = 0; - for (int i = 0; i < getYNum(); i++) { - for (int j = 0; j < getXNum(); j++) { - if (MIMath.doubleEquals(this.getValue(i, j).doubleValue(), missingValue)) { - continue; - } - - if (vdNum == 0) { - values.add(this.getValue(i, j)); - } else if (!values.contains(this.getValue(i, j))) { - values.add(this.getValue(i, j)); - } - vdNum += 1; - } - } - - return values; - } - - /** - * Get grid data setting - * - * @return Grid data setting - */ - public GridDataSetting getGridDataSetting() { - GridDataSetting gDataSet = new GridDataSetting(); - gDataSet.dataExtent = (Extent) this.getExtent().clone(); - gDataSet.xNum = this.getXNum(); - gDataSet.yNum = this.getYNum(); - return gDataSet; - } - - /** - * Mask out grid data with a polygon shape - * - * @param aPGS The polygon shape - * @return Maskouted grid data - */ - public GridData maskout(PolygonShape aPGS) { - int xNum = this.getXNum(); - int yNum = this.getYNum(); - - GridData cGrid = new GridData(this); - for (int i = 0; i < yNum; i++) { - if (yArray[i] >= aPGS.getExtent().minY && yArray[i] <= aPGS.getExtent().maxY) { - for (int j = 0; j < xNum; j++) { - if (xArray[j] >= aPGS.getExtent().minX && xArray[j] <= aPGS.getExtent().maxX) { - if (GeoComputation.pointInPolygon(aPGS, new PointD(xArray[j], yArray[i]))) { - cGrid.data[i][j] = data[i][j]; - } else { - cGrid.data[i][j] = missingValue; - } - } else { - cGrid.data[i][j] = missingValue; - } - } - } else { - for (int j = 0; j < xNum; j++) { - cGrid.data[i][j] = missingValue; - } - } - } - - return cGrid; - } - - /** - * Mask out grid data with polygon shapes - * - * @param polygons The polygon shapes - * @return Maskouted grid data - */ - public GridData maskout(List polygons) { - int xNum = this.getXNum(); - int yNum = this.getYNum(); - - GridData cGrid = new GridData(this); - for (int i = 0; i < yNum; i++) { - for (int j = 0; j < xNum; j++) { - if (GeoComputation.pointInPolygons(polygons, new PointD(xArray[j], yArray[i]))) { - cGrid.data[i][j] = data[i][j]; - } else { - cGrid.data[i][j] = missingValue; - } - } - } - - return cGrid; - } - - /** - * Mask out grid data with a polygon layer - * - * @param maskLayer The polygon layer - * @return Maskouted grid data - */ - public GridData maskout(VectorLayer maskLayer) { - if (maskLayer.getShapeType() != ShapeTypes.Polygon) { - return this; - } - - int xNum = this.getXNum(); - int yNum = this.getYNum(); - GridData cGrid = new GridData(this); - for (int i = 0; i < yNum; i++) { - if (yArray[i] >= maskLayer.getExtent().minY && yArray[i] <= maskLayer.getExtent().maxY) { - for (int j = 0; j < xNum; j++) { - if (xArray[j] >= maskLayer.getExtent().minX && xArray[j] <= maskLayer.getExtent().maxX) { - if (GeoComputation.pointInPolygonLayer(maskLayer, new PointD(xArray[j], yArray[i]), false)) { - cGrid.data[i][j] = data[i][j]; - } else { - cGrid.data[i][j] = missingValue; - } - } else { - cGrid.data[i][j] = missingValue; - } - } - } else { - for (int j = 0; j < xNum; j++) { - cGrid.data[i][j] = missingValue; - } - } - } - - return cGrid; - } - - /** - * Mask out grid data by a mask grid data - * - * @param maskGrid Mask grid data - * @return Result grid data - */ - public GridData maskout(GridData maskGrid) { - GridData cGrid = new GridData(this); - int xnum = this.getXNum(); - int ynum = this.getYNum(); - for (int i = 0; i < ynum; i++) { - for (int j = 0; j < xnum; j++) { - if (maskGrid.data[i][j] >= 0) { - cGrid.data[i][j] = data[i][j]; - } else { - cGrid.data[i][j] = missingValue; - } - } - } - - return cGrid; - } - - /** - * Resample grid data - * - * @param toGridData The grid data - * @param method The resample method - * @return Result grid data - */ - public GridData resample(GridData toGridData, ResampleMethods method) { - GridData gridData; - if (this.projInfo.equals(toGridData.projInfo)) { - switch (method) { - case NearestNeighbor: - gridData = resample_Neighbor(toGridData.xArray, toGridData.yArray); - break; - default: - gridData = resample_Bilinear(toGridData.xArray, toGridData.yArray); - break; - } - } else { - gridData = this.project(toGridData.projInfo, toGridData.xArray, toGridData.yArray, method); - } - - gridData.projInfo = toGridData.projInfo; - - return gridData; - } - - private GridData resample_Neighbor(double[] newX, double[] newY) { - double[][] newdata = new double[newY.length][newX.length]; - int i, j, xIdx, yIdx; - double x, y; - - double[][] points = new double[1][]; - for (i = 0; i < newY.length; i++) { - y = newY[i]; - for (j = 0; j < newX.length; j++) { - points[0] = new double[]{newX[j], newY[i]}; - x = newX[j]; - if (x < xArray[0] || x > xArray[xArray.length - 1]) { - newdata[i][j] = missingValue; - } else if (y < yArray[0] || y > yArray[yArray.length - 1]) { - newdata[i][j] = missingValue; - } else { - xIdx = (int) ((x - xArray[0]) / getXDelt()); - yIdx = (int) ((y - yArray[0]) / getYDelt()); - newdata[i][j] = data[yIdx][xIdx]; - } - } - } - - GridData gData = new GridData(this); - gData.data = newdata; - gData.xArray = newX; - gData.yArray = newY; - - return gData; - } - - private GridData resample_Bilinear(double[] newX, double[] newY) { - //PointD[][] pos = new PointD[newY.length][newX.length]; - double[][] newdata = new double[newY.length][newX.length]; - int i, j; - double x, y; - - double[][] points = new double[1][]; - for (i = 0; i < newY.length; i++) { - y = newY[i]; - for (j = 0; j < newX.length; j++) { - points[0] = new double[]{newX[j], newY[i]}; - x = newX[j]; - if (x < xArray[0] || x > xArray[xArray.length - 1]) { - newdata[i][j] = missingValue; - } else if (y < yArray[0] || y > yArray[yArray.length - 1]) { - newdata[i][j] = missingValue; - } else { - newdata[i][j] = this.toStation(x, y); - } - } - } - - GridData gData = new GridData(this); - gData.data = newdata; - gData.xArray = newX; - gData.yArray = newY; - - return gData; - } - - /** - * Interpolate grid data - * - * @return Result grid data - */ - public GridData interpolate() { - int nxNum = this.xArray.length * 2 - 1; - int nyNum = this.yArray.length * 2 - 1; - double[] newX = new double[nxNum]; - double[] newY = new double[nyNum]; - - double[][] newData = interpolation_Grid(data, this.xArray, this.yArray, missingValue, newX, newY); - int i; - for (i = 0; i < nxNum; i++) { - if (i % 2 == 0) { - newX[i] = this.xArray[i / 2]; - } else { - newX[i] = (this.xArray[(i - 1) / 2] + this.xArray[(i - 1) / 2 + 1]) / 2; - } - } - for (i = 0; i < nyNum; i++) { - if (i % 2 == 0) { - newY[i] = this.yArray[i / 2]; - } else { - newY[i] = (this.yArray[(i - 1) / 2] + this.yArray[(i - 1) / 2 + 1]) / 2; - } - } - GridData gdata = new GridData(); - gdata.data = newData; - gdata.xArray = newX; - gdata.yArray = newY; - gdata.missingValue = this.missingValue; - - return gdata; - } - - /** - * Interpolate from grid data - * - * @param GridData input grid data - * @param X input x coordinates - * @param Y input y coordinates - * @param unDefData undefine data - * @param nX output x coordinate - * @param nY output y coordinate - * @return output grid data - */ - public double[][] interpolation_Grid(double[][] GridData, double[] X, double[] Y, double unDefData, - double[] nX, double[] nY) { - //int xNum = X.length; - //int yNum = Y.length; - int nxNum = X.length * 2 - 1; - int nyNum = Y.length * 2 - 1; - nX = new double[nxNum]; - nY = new double[nyNum]; - double[][] nGridData = new double[nyNum][nxNum]; - int i, j; - double a, b, c, d; - List dList; - for (i = 0; i < nxNum; i++) { - if (i % 2 == 0) { - nX[i] = X[i / 2]; - } else { - nX[i] = (X[(i - 1) / 2] + X[(i - 1) / 2 + 1]) / 2; - } - } - for (i = 0; i < nyNum; i++) { - if (i % 2 == 0) { - nY[i] = Y[i / 2]; - } else { - nY[i] = (Y[(i - 1) / 2] + Y[(i - 1) / 2 + 1]) / 2; - } - for (j = 0; j < nxNum; j++) { - if (i % 2 == 0 && j % 2 == 0) { - nGridData[i][j] = GridData[i / 2][j / 2]; - } else if (i % 2 == 0 && j % 2 != 0) { - a = GridData[i / 2][(j - 1) / 2]; - b = GridData[i / 2][(j - 1) / 2 + 1]; - dList = new ArrayList<>(); - if (a != unDefData) { - dList.add(a); - } - if (b != unDefData) { - dList.add(b); - } - - if (dList.isEmpty()) { - nGridData[i][j] = unDefData; - } else if (dList.size() == 1) { - nGridData[i][j] = dList.get(0); - } else { - nGridData[i][j] = (a + b) / 2; - } - } else if (i % 2 != 0 && j % 2 == 0) { - a = GridData[(i - 1) / 2][j / 2]; - b = GridData[(i - 1) / 2 + 1][j / 2]; - dList = new ArrayList<>(); - if (a != unDefData) { - dList.add(a); - } - if (b != unDefData) { - dList.add(b); - } - - if (dList.isEmpty()) { - nGridData[i][j] = unDefData; - } else if (dList.size() == 1) { - nGridData[i][j] = dList.get(0); - } else { - nGridData[i][j] = (a + b) / 2; - } - } else { - a = GridData[(i - 1) / 2][(j - 1) / 2]; - b = GridData[(i - 1) / 2][(j - 1) / 2 + 1]; - c = GridData[(i - 1) / 2 + 1][(j - 1) / 2 + 1]; - d = GridData[(i - 1) / 2 + 1][(j - 1) / 2]; - dList = new ArrayList<>(); - if (a != unDefData) { - dList.add(a); - } - if (b != unDefData) { - dList.add(b); - } - if (c != unDefData) { - dList.add(c); - } - if (d != unDefData) { - dList.add(d); - } - - if (dList.isEmpty()) { - nGridData[i][j] = unDefData; - } else if (dList.size() == 1) { - nGridData[i][j] = dList.get(0); - } else { - double aSum = 0; - for (double dd : dList) { - aSum += dd; - } - nGridData[i][j] = aSum / dList.size(); - } - } - } - } - - return nGridData; - } - - /** - * Interpolate grid data - * - * @return Result grid data - */ - public GridData interpolate_old() { - int nxNum = this.xArray.length * 2 - 1; - int nyNum = this.yArray.length * 2 - 1; - double[] newX = new double[nxNum]; - double[] newY = new double[nyNum]; - int i; - - for (i = 0; i < nxNum; i++) { - if (i % 2 == 0) { - newX[i] = this.xArray[i / 2]; - } else { - newX[i] = (this.xArray[(i - 1) / 2] + this.xArray[(i - 1) / 2 + 1]) / 2; - } - } - for (i = 0; i < nyNum; i++) { - if (i % 2 == 0) { - newY[i] = this.yArray[i / 2]; - } else { - newY[i] = (this.yArray[(i - 1) / 2] + this.yArray[(i - 1) / 2 + 1]) / 2; - } - } - - return this.resample_Bilinear(newX, newY); - } - - /** - * Project grid data - * - * @param toProj To projection - * @return Projected grid data - */ - public GridData project(ProjectionInfo toProj) { - if (this.projInfo == null) { - return null; - } - - return project(this.projInfo, toProj, ResampleMethods.NearestNeighbor); - } - - /** - * Project grid data - * - * @param fromProj From projection - * @param toProj To projection - * @return Porjected grid data - */ - public GridData project(ProjectionInfo fromProj, ProjectionInfo toProj) { - return project(fromProj, toProj, ResampleMethods.NearestNeighbor); - } - - /** - * Project grid data - * - * @param fromProj From projection - * @param toProj To projection - * @param resampleMethod Interpolation method - * @return Porjected grid data - */ - public GridData project(ProjectionInfo fromProj, ProjectionInfo toProj, ResampleMethods resampleMethod) { - Extent aExtent; - int xnum = this.getXNum(); - int ynum = this.getYNum(); - if (this.isGlobal() || this.xArray[xnum - 1] - this.xArray[0] == 360) { - aExtent = ProjectionUtil.getProjectionGlobalExtent(toProj); - } else { - aExtent = ProjectionUtil.getProjectionExtent(fromProj, toProj, this.xArray, this.yArray); - } - - double xDelt = (aExtent.maxX - aExtent.minX) / (xnum - 1); - double yDelt = (aExtent.maxY - aExtent.minY) / (ynum - 1); - double[] newX = new double[xnum]; - double[] newY = new double[ynum]; - for (int i = 0; i < newX.length; i++) { - newX[i] = aExtent.minX + i * xDelt; - } - - for (int i = 0; i < newY.length; i++) { - newY[i] = aExtent.minY + i * yDelt; - } - - GridData pGridData = project(fromProj, toProj, newX, newY, resampleMethod); - - return pGridData; - } - - /** - * Project grid data - * - * @param toProj To projection info - * @param newX New xArray coordinates - * @param newY New yArray coordinates - * @return Projected grid data - */ - public GridData project(ProjectionInfo toProj, double[] newX, double[] newY) { - if (this.projInfo == null) { - return null; - } - - return project_Neighbor(this.projInfo, toProj, newX, newY); - } - - /** - * Project grid data - * - * @param toProj To projection info - * @param newX New xArray coordinates - * @param newY New yArray coordinates - * @param resampleMethod Interpolation method - * @return Projected grid data - */ - public GridData project(ProjectionInfo toProj, double[] newX, double[] newY, - ResampleMethods resampleMethod) { - if (this.projInfo == null) { - return null; - } - - return project(this.projInfo, toProj, newX, newY, resampleMethod); - } - - /** - * Project grid data - * - * @param fromProj From projection info - * @param toProj To projection info - * @param newX New xArray coordinates - * @param newY New yArray coordinates - * @param resampleMethod Interpolation method - * @return Projected grid data - */ - public GridData project(ProjectionInfo fromProj, ProjectionInfo toProj, double[] newX, double[] newY, - ResampleMethods resampleMethod) { - switch (resampleMethod) { - case Bilinear: - return project_Bilinear(fromProj, toProj, newX, newY); - case NearestNeighbor: - return project_Neighbor(fromProj, toProj, newX, newY); - default: - return project_Bilinear(fromProj, toProj, newX, newY); - } - } - - /** - * Project grid data to station data - * - * @param fromProj From projection info - * @param toProj To projection info - * @param stData Station data - * @param resampleMethod Interpolation method - * @return Projected station data - */ - public StationData project(ProjectionInfo fromProj, ProjectionInfo toProj, StationData stData, - ResampleMethods resampleMethod) { - switch (resampleMethod) { - case Bilinear: - return project_Bilinear(fromProj, toProj, stData); - default: - return project_Bilinear(fromProj, toProj, stData); - } - } - - private GridData project_Neighbor(ProjectionInfo fromProj, ProjectionInfo toProj, double[] newX, double[] newY) { - double[][] newdata = new double[newY.length][newX.length]; - int i, j, xIdx, yIdx; - double x, y; - - double[][] points = new double[1][]; - for (i = 0; i < newY.length; i++) { - for (j = 0; j < newX.length; j++) { - points[0] = new double[]{newX[j], newY[i]}; - try { - Reproject.reprojectPoints(points, toProj, fromProj, 0, 1); - x = points[0][0]; - y = points[0][1]; - - if (x < xArray[0] || x > xArray[xArray.length - 1]) { - newdata[i][j] = missingValue; - } else if (y < yArray[0] || y > yArray[yArray.length - 1]) { - newdata[i][j] = missingValue; - } else { - xIdx = (int) ((x - xArray[0]) / getXDelt()); - yIdx = (int) ((y - yArray[0]) / getYDelt()); - newdata[i][j] = data[yIdx][xIdx]; - } - } catch (Exception e) { - newdata[i][j] = missingValue; - j++; - } - } - } - - GridData gData = new GridData(this); - gData.data = newdata; - gData.xArray = newX; - gData.yArray = newY; - - return gData; - } - - private GridData project_Bilinear(ProjectionInfo fromProj, ProjectionInfo toProj, double[] newX, double[] newY) { - //PointD[][] pos = new PointD[newY.length][newX.length]; - double[][] newdata = new double[newY.length][newX.length]; - int i, j; - double x, y; - - double[][] points = new double[1][]; - for (i = 0; i < newY.length; i++) { - for (j = 0; j < newX.length; j++) { - points[0] = new double[]{newX[j], newY[i]}; - try { - Reproject.reprojectPoints(points, toProj, fromProj, 0, 1); - x = points[0][0]; - y = points[0][1]; - - if (x < xArray[0] || x > xArray[xArray.length - 1]) { - newdata[i][j] = missingValue; - } else if (y < yArray[0] || y > yArray[yArray.length - 1]) { - newdata[i][j] = missingValue; - } else { - newdata[i][j] = this.toStation(x, y); - } - } catch (Exception e) { - newdata[i][j] = missingValue; - j++; - } - } - } - - GridData gData = new GridData(this); - gData.data = newdata; - gData.xArray = newX; - gData.yArray = newY; - - return gData; - } - - private StationData project_Bilinear(ProjectionInfo fromProj, ProjectionInfo toProj, StationData stData) { - int i; - double x, y; - StationData nsData = new StationData(stData); - nsData.missingValue = missingValue; - - double[][] points = new double[1][]; - for (i = 0; i < stData.getStNum(); i++) { - points[0] = new double[]{stData.getX(i), stData.getY(i)}; - try { - Reproject.reprojectPoints(points, toProj, fromProj, 0, 1); - x = points[0][0]; - y = points[0][1]; - - if (x < xArray[0] || x > xArray[xArray.length - 1]) { - nsData.setValue(i, missingValue); - } else if (y < yArray[0] || y > yArray[yArray.length - 1]) { - nsData.setValue(i, missingValue); - } else { - nsData.setValue(i, this.toStation(x, y)); - } - } catch (Exception e) { - nsData.setValue(i, missingValue); - i++; - } - } - - return nsData; - } - - /** - * Aggregate the grid data to coarser resolution - * - * @param toGridData To grid data - * @param isAverage If is average - */ - public void aggregate(GridData toGridData, boolean isAverage) { - int xnum = this.getXNum(); - int ynum = this.getYNum(); - int toXnum = toGridData.getXNum(); - int toYnum = toGridData.getYNum(); - int i, j, xIdx, yIdx; - int[][] nums = new int[toYnum][toXnum]; - double x, y, y0; - toGridData.setValue(0.0); - if (this.projInfo.equals(toGridData.projInfo)) { - for (i = 0; i < ynum; i++) { - y = yArray[i]; - for (j = 0; j < xnum; j++) { - x = xArray[j]; - int[] ij = toGridData.getIJIndex(x, y); - xIdx = ij[0]; - yIdx = ij[1]; - if (xIdx >= 0 && yIdx >= 0) { - toGridData.data[yIdx][xIdx] += this.data[i][j]; - nums[yIdx][xIdx] += 1; - } - } - } - } else { - double[][] points = new double[1][]; - for (i = 0; i < ynum; i++) { - y0 = yArray[i]; - for (j = 0; j < xnum; j++) { - x = xArray[j]; - y = y0; - points[0] = new double[]{x, y}; - try { - Reproject.reprojectPoints(points, this.projInfo, toGridData.projInfo, 0, 1); - x = points[0][0]; - y = points[0][1]; - if (java.lang.Double.isNaN(x) || java.lang.Double.isNaN(y)) { - continue; - } - - int[] ij = toGridData.getIJIndex(x, y); - xIdx = ij[0]; - yIdx = ij[1]; - if (xIdx >= 0 && yIdx >= 0) { - toGridData.data[yIdx][xIdx] += this.data[i][j]; - nums[yIdx][xIdx] += 1; - } - } catch (Exception e) { - j++; - continue; - } - } - } - } - - //Average - if (isAverage) { - for (i = 0; i < toYnum; i++) { - for (j = 0; j < toXnum; j++) { - if (nums[i][j] == 0) { - toGridData.data[i][j] = toGridData.missingValue; - } else { - toGridData.data[i][j] = toGridData.data[i][j] / nums[i][j]; - } - } - } - } - } - - /** - * Un stag grid data through x dimension - * - * @return Un stagged grid data - */ - public GridData unStagger_X() { - int xn = this.getXNum(); - int yn = this.getYNum(); - double dx = this.getXDelt(); - int xn_us = xn - 1; - int i, j; - GridData usData = new GridData(this); - usData.xArray = new double[xn_us]; - usData.data = new double[yn][xn_us]; - for (i = 0; i < yn; i++) { - for (j = 0; j < xn_us; j++) { - if (i == 0) { - usData.xArray[j] = xArray[j] + dx; - } - usData.data[i][j] = (this.data[i][j] + this.data[i][j + 1]) * 0.5; - } - } - - return usData; - } - - /** - * Un stag grid data through y dimension - * - * @return Un stagged grid data - */ - public GridData unStagger_Y() { - int xn = this.getXNum(); - int yn = this.getYNum(); - double dy = this.getYDelt(); - int yn_us = yn - 1; - int i, j; - GridData usData = new GridData(this); - usData.yArray = new double[yn_us]; - usData.data = new double[yn_us][xn]; - for (i = 0; i < yn_us; i++) { - for (j = 0; j < xn; j++) { - if (j == 0) { - usData.yArray[i] = yArray[i] + dy; - } - usData.data[i][j] = (this.data[i][j] + this.data[i + 1][j]) * 0.5; - } - } - - return usData; - } - - /** - * Clone - * - * @return Grid data object - */ - @Override - public Object clone() { - GridData newGriddata = new GridData(this); - newGriddata.data = data.clone(); - - return newGriddata; - } - - /** - * yArray reverse to the grid data - */ - public void yReverse() { - int xNum = getXNum(); - int yNum = getYNum(); - double[][] newdata = new double[yNum][xNum]; - for (int i = 0; i < yNum; i++) { - System.arraycopy(data[i], 0, newdata[yNum - i - 1], 0, xNum); - } - data = newdata; - } - - /** - * xArray reverse to the grid data - */ - public void xReverse() { - int xNum = getXNum(); - int yNum = getYNum(); - double[][] newdata = new double[yNum][xNum]; - for (int i = 0; i < yNum; i++) { - for (int j = 0; j < xNum; j++){ - newdata[i][j] = data[i][xNum - j - 1]; - } - } - data = newdata; - } - - // - // - // - /** - * GridData.Integer class - */ - public static class Byte extends GridData { - - private byte[][] data; - private int missingValue; - - /** - * Constructor - * - * @param yNum Y number - * @param xNum X number - */ - public Byte(int yNum, int xNum) { - data = new byte[yNum][xNum]; - missingValue = -9999; - } - - /** - * Get missing value - * - * @return Missing value - */ - public int getMissingValue() { - return this.missingValue; - } - - /** - * Set missing value - * - * @param value Missing value - */ - public void setMissingValue(int value) { - this.missingValue = value; - } - - /** - * Get value - * - * @param i I index - * @param j J index - * @return Value - */ - @Override - public Number getValue(int i, int j) { - return DataConvert.byte2Int(data[i][j]); - } - - /** - * Set value - * - * @param i I index - * @param j J index - * @param value Value - */ - public void setValue(int i, int j, byte value) { - data[i][j] = value; - } - - /** - * Get double value - * - * @param i I index - * @param j J index - * @return Double value - */ - @Override - public double getDoubleValue(int i, int j) { - return getValue(i, j).doubleValue(); - } - - /** - * Get maximum and minimum values - * - * @param maxmin Max/Min array - * @return If has undefine data - */ - @Override - public boolean getMaxMinValue(double[] maxmin) { - double max = 0; - double min = 0; - int vdNum = 0; - boolean hasUndef = false; - int v; - for (int i = 0; i < getYNum(); i++) { - for (int j = 0; j < getXNum(); j++) { - v = getValue(i, j).intValue(); - if (v == missingValue) { - hasUndef = true; - continue; - } - - if (vdNum == 0) { - min = v; - max = min; - } else { - if (min > v) { - min = v; - } - if (max < v) { - max = v; - } - } - vdNum += 1; - } - } - - maxmin[0] = max; - maxmin[1] = min; - return hasUndef; - } - - /** - * Convert to GridArray object - * - * @return GridArray object - */ - @Override - public GridArray toGridArray() { - Array a = Array.factory(DataType.DOUBLE, new int[]{this.getYNum(), this.getXNum()}); - int idx = 0; - for (int i = 0; i < this.getYNum(); i++) { - for (int j = 0; j < this.getXNum(); j++) { - a.setDouble(idx, this.data[i][j]); - idx += 1; - } - } - - GridArray r = new GridArray(); - r.setData(a); - r.xArray = this.xArray; - r.yArray = this.yArray; - r.projInfo = this.projInfo; - r.missingValue = this.missingValue; - return r; - } - } - - /** - * GridData.Integer class - */ - public static class Integer extends GridData { - - private final int[][] data; - private int missingValue; - - /** - * Constructor - * - * @param yNum Y number - * @param xNum X number - */ - public Integer(int yNum, int xNum) { - data = new int[yNum][xNum]; - missingValue = -9999; - } - - /** - * Get missing value - * - * @return Missing value - */ - public int getMissingValue() { - return this.missingValue; - } - - /** - * Set missing value - * - * @param value Missing value - */ - public void setMissingValue(int value) { - this.missingValue = value; - } - - /** - * Get value - * - * @param i I index - * @param j J index - * @return Value - */ - @Override - public Number getValue(int i, int j) { - return data[i][j]; - } - - /** - * Set value - * - * @param i I index - * @param j J index - * @param value Value - */ - public void setValue(int i, int j, int value) { - data[i][j] = value; - } - - /** - * Get double value - * - * @param i I index - * @param j J index - * @return Double value - */ - @Override - public double getDoubleValue(int i, int j) { - return data[i][j]; - } - - /** - * Get maximum and minimum values - * - * @param maxmin Max/Min array - * @return If has undefine data - */ - @Override - public boolean getMaxMinValue(double[] maxmin) { - double max = 0; - double min = 0; - int vdNum = 0; - boolean hasUndef = false; - for (int i = 0; i < getYNum(); i++) { - for (int j = 0; j < getXNum(); j++) { - if (data[i][j] == missingValue) { - hasUndef = true; - continue; - } - - if (vdNum == 0) { - min = data[i][j]; - max = min; - } else { - if (min > data[i][j]) { - min = data[i][j]; - } - if (max < data[i][j]) { - max = data[i][j]; - } - } - vdNum += 1; - } - } - - maxmin[0] = max; - maxmin[1] = min; - return hasUndef; - } - } - - /** - * GridData.Double class - */ - public static class Double extends GridData { - - private double[][] data; - private double missingValue; - - /** - * Constructor - * - * @param yNum Y number - * @param xNum X number - */ - public Double(int yNum, int xNum) { - data = new double[yNum][xNum]; - missingValue = -9999.0; - } - - /** - * Get missing value - * - * @return Missing value - */ - public double getMissingValue() { - return this.missingValue; - } - - /** - * Set missing value - * - * @param value Missing value - */ - public void setMissingValue(double value) { - this.missingValue = value; - } - - /** - * Get value - * - * @param i I index - * @param j J index - * @return Value - */ - @Override - public Number getValue(int i, int j) { - return data[i][j]; - } - - /** - * Set value - * - * @param i I index - * @param j J index - * @param value Value - */ - public void setValue(int i, int j, double value) { - data[i][j] = value; - } - - /** - * Get double value - * - * @param i I index - * @param j J index - * @return Double value - */ - @Override - public double getDoubleValue(int i, int j) { - return data[i][j]; - } - } - - /** - * GridData.Integer class - */ - public static class Float extends GridData { - - private float[][] data; - private float missingValue; - - /** - * Constructor - * - * @param yNum Y number - * @param xNum X number - */ - public Float(int yNum, int xNum) { - data = new float[yNum][xNum]; - missingValue = -9999; - } - - /** - * Get missing value - * - * @return Missing value - */ - public float getMissingValue() { - return this.missingValue; - } - - /** - * Set missing value - * - * @param value Missing value - */ - public void setMissingValue(float value) { - this.missingValue = value; - } - - /** - * Get value - * - * @param i I index - * @param j J index - * @return Value - */ - @Override - public Number getValue(int i, int j) { - return data[i][j]; - } - - /** - * Set value - * - * @param i I index - * @param j J index - * @param value Value - */ - public void setValue(int i, int j, float value) { - data[i][j] = value; - } - - /** - * Get double value - * - * @param i I index - * @param j J index - * @return Double value - */ - @Override - public double getDoubleValue(int i, int j) { - return data[i][j]; - } - } - - /** - * Convert to GridArray object - * - * @return GridArray object - */ - public GridArray toGridArray() { - Array a = Array.factory(DataType.DOUBLE, new int[]{this.getYNum(), this.getXNum()}); - int idx = 0; - for (int i = 0; i < this.getYNum(); i++) { - for (int j = 0; j < this.getXNum(); j++) { - a.setDouble(idx, this.getDoubleValue(i, j)); - idx += 1; - } - } - - GridArray r = new GridArray(); - r.setData(a); - r.xArray = this.xArray; - r.yArray = this.yArray; - r.projInfo = this.projInfo; - r.missingValue = this.missingValue; - return r; - } - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/GridDataSetting.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/GridDataSetting.java deleted file mode 100644 index 3433735f..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/GridDataSetting.java +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.data; - -import org.meteoinfo.common.Extent; - -/** - * - * @author yaqiang - */ -public class GridDataSetting { - /// - /// Data extent - /// - - public Extent dataExtent = new Extent(); - /// - /// X number - /// - public int xNum; - /// - /// Y number - /// - public int yNum; -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/StationData.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/StationData.java deleted file mode 100644 index fb36811c..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/StationData.java +++ /dev/null @@ -1,1554 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.data; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; - -import org.meteoinfo.common.Extent; -import org.meteoinfo.common.MIMath; -import org.meteoinfo.common.PointD; -import org.meteoinfo.geo.analysis.InterpolationSetting; - -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.meteoinfo.geometry.geoprocess.GeoComputation; -import org.meteoinfo.common.DataConvert; -import org.meteoinfo.geo.layer.VectorLayer; -import org.meteoinfo.geo.projection.info.ProjectionInfo; -import org.meteoinfo.geo.projection.Reproject; -import org.meteoinfo.geometry.shape.PolygonShape; -import org.meteoinfo.geometry.shape.ShapeTypes; -import org.meteoinfo.ndarray.Array; - - /** - * Template - * - * @author Yaqiang Wang - */ - public class StationData { - // - /// - /// station data: longitude, latitude, value - /// - - public double[][] data; - /// - /// Station identifer list - /// - public List stations; - /// - /// Data extent - /// - public Extent dataExtent; - /// - /// Undef data - /// - public double missingValue; - /** - * Projection information - */ - public ProjectionInfo projInfo = null; - // - // - - /** - * Constructor - */ - public StationData() { - data = new double[0][3]; - stations = new ArrayList<>(); - dataExtent = new Extent(); - missingValue = -9999; - } - - /** - * Constructor - * - * @param a Array data - * @param x Array x - * @param y Array y - * @param missingv Missing value - */ - public StationData(Array a, Array x, Array y, Number missingv) { - int n = (int) a.getSize(); - this.missingValue = missingv.doubleValue(); - stations = new ArrayList<>(); - dataExtent = new Extent(); - data = new double[n][3]; - for (int i = 0; i < n; i++) { - stations.add("s_" + String.valueOf(i + 1)); - data[i][0] = x.getDouble(i); - data[i][1] = y.getDouble(i); - data[i][2] = a.getDouble(i); - if (Double.isNaN(data[i][2])) - data[i][2] = missingv.doubleValue(); - //this.addData("s_" + String.valueOf(i + 1), x.getDouble(i), y.getDouble(i), a.getDouble(i)); - } - } - - /** - * Constructor - * - * @param aStData Station data - */ - public StationData(StationData aStData) { - projInfo = aStData.projInfo; - stations = aStData.stations; - dataExtent = aStData.dataExtent; - missingValue = aStData.missingValue; - data = new double[aStData.data.length][aStData.data[0].length]; - for (int i = 0; i < aStData.getStNum(); i++) { - data[i][0] = aStData.data[i][0]; - data[i][1] = aStData.data[i][1]; - } - } - // - // - - /** - * Get station number - * - * @return Station number - */ - public int getStNum() { - return data.length; - } - - /** - * Get X coordinates array - * - * @return X array - */ - public double[] getX() { - double[] x = new double[getStNum()]; - for (int i = 0; i < getStNum(); i++) { - x[i] = data[i][0]; - } - - return x; - } - - /** - * Get X coordinates array - * - * @return X array - */ - public List getXList() { - List x = new ArrayList<>(); - for (int i = 0; i < getStNum(); i++) { - x.add(data[i][0]); - } - - return x; - } - - /** - * Get Y coordinates array - * - * @return Y array - */ - public double[] getY() { - double[] y = new double[getStNum()]; - for (int i = 0; i < getStNum(); i++) { - y[i] = data[i][1]; - } - - return y; - } - - /** - * Get Y coordinates array - * - * @return Y array - */ - public List getYList() { - List y = new ArrayList<>(); - for (int i = 0; i < getStNum(); i++) { - y.add(data[i][1]); - } - - return y; - } - - /** - * Set data array - * - * @param value Data array - */ - public void setData(double[][] value) { - data = value; - this.updateExtent(); - } - // - // - - // - /** - * Add operator with another station data - * - * @param bStData Station data - * @return Result station data - */ - public StationData add(StationData bStData) { - if (!MIMath.isExtentCross(this.dataExtent, bStData.dataExtent)) { - return null; - } - - StationData cStData = new StationData(); - cStData.projInfo = bStData.projInfo; - String aStid; - int stIdx; - double x, y; - for (int i = 0; i < stations.size(); i++) { - aStid = stations.get(i); - if (aStid.equals("99999")) { - continue; - } - - double aValue = this.getValue(i); - if (aValue == missingValue) { - continue; - } - - stIdx = bStData.stations.indexOf(aStid); - if (stIdx >= 0) { - double bValue = bStData.getValue(stIdx); - if (bValue == bStData.missingValue) { - continue; - } - - x = this.getX(i); - y = this.getY(i); - cStData.addData(aStid, x, y, aValue + bValue); - } - } - - return cStData; - } - - /** - * Add operator with a double value - * - * @param value The value - * @return Result station data - */ - public StationData add(double value) { - StationData cStData = new StationData(); - cStData.projInfo = this.projInfo; - String aStid; - double x, y; - for (int i = 0; i < stations.size(); i++) { - aStid = stations.get(i); - - double aValue = this.getValue(i); - x = this.getX(i); - y = this.getY(i); - if (MIMath.doubleEquals(aValue, missingValue)) { - cStData.addData(aStid, x, y, aValue); - } else { - cStData.addData(aStid, x, y, aValue + value); - } - } - - return cStData; - } - - /** - * Subtract operator with another station data - * - * @param bStData Station data - * @return Result station data - */ - public StationData sub(StationData bStData) { - if (!MIMath.isExtentCross(this.dataExtent, bStData.dataExtent)) { - return null; - } - - StationData cStData = new StationData(); - String aStid; - int stIdx; - double x, y; - for (int i = 0; i < stations.size(); i++) { - aStid = stations.get(i); - if (aStid.equals("99999")) { - continue; - } - - double aValue = this.getValue(i); - if (aValue == missingValue) { - continue; - } - - stIdx = bStData.stations.indexOf(aStid); - if (stIdx >= 0) { - double bValue = bStData.getValue(stIdx); - if (bValue == bStData.missingValue) { - continue; - } - - x = this.getX(i); - y = this.getY(i); - cStData.addData(aStid, x, y, aValue - bValue); - } - } - - return cStData; - } - - /** - * Subtract operator with a double value - * - * @param value The value - * @return Result station data - */ - public StationData sub(double value) { - StationData cStData = new StationData(); - String aStid; - double x, y; - for (int i = 0; i < stations.size(); i++) { - aStid = stations.get(i); - - double aValue = this.getValue(i); - x = this.getX(i); - y = this.getY(i); - if (MIMath.doubleEquals(aValue, missingValue)) { - cStData.addData(aStid, x, y, aValue); - } else { - cStData.addData(aStid, x, y, aValue - value); - } - } - - return cStData; - } - - /** - * multiply operator with another station data - * - * @param bStData Station data - * @return Result station data - */ - public StationData mul(StationData bStData) { - if (!MIMath.isExtentCross(this.dataExtent, bStData.dataExtent)) { - return null; - } - - StationData cStData = new StationData(); - String aStid; - int stIdx; - double x, y; - for (int i = 0; i < stations.size(); i++) { - aStid = stations.get(i); - if (aStid.equals("99999")) { - continue; - } - - double aValue = this.getValue(i); - if (aValue == missingValue) { - continue; - } - - stIdx = bStData.stations.indexOf(aStid); - if (stIdx >= 0) { - double bValue = bStData.getValue(stIdx); - if (bValue == bStData.missingValue) { - continue; - } - - x = this.getX(i); - y = this.getY(i); - cStData.addData(aStid, x, y, aValue * bValue); - } - } - - return cStData; - } - - /** - * Multiply operator with a double value - * - * @param value The value - * @return Result station data - */ - public StationData mul(double value) { - StationData cStData = new StationData(); - String aStid; - double x, y; - for (int i = 0; i < stations.size(); i++) { - aStid = stations.get(i); - - double aValue = this.getValue(i); - x = this.getX(i); - y = this.getY(i); - if (MIMath.doubleEquals(aValue, missingValue)) { - cStData.addData(aStid, x, y, aValue); - } else { - cStData.addData(aStid, x, y, aValue * value); - } - } - - return cStData; - } - - /** - * Divide operator with another station data - * - * @param bStData Station data - * @return Result station data - */ - public StationData div(StationData bStData) { - if (!MIMath.isExtentCross(this.dataExtent, bStData.dataExtent)) { - return null; - } - - StationData cStData = new StationData(); - String aStid; - int stIdx; - double x, y; - for (int i = 0; i < stations.size(); i++) { - aStid = stations.get(i); - if (aStid.equals("99999")) { - continue; - } - - double aValue = this.getValue(i); - if (aValue == missingValue) { - continue; - } - - stIdx = bStData.stations.indexOf(aStid); - if (stIdx >= 0) { - double bValue = bStData.getValue(stIdx); - if (bValue == bStData.missingValue) { - continue; - } - - x = this.getX(i); - y = this.getY(i); - cStData.addData(aStid, x, y, aValue / bValue); - } - } - - return cStData; - } - - /** - * Divide operator with a double value - * - * @param value The value - * @return Result station data - */ - public StationData div(double value) { - StationData cStData = new StationData(); - String aStid; - double x, y; - for (int i = 0; i < stations.size(); i++) { - aStid = stations.get(i); - - double aValue = this.getValue(i); - x = this.getX(i); - y = this.getY(i); - if (MIMath.doubleEquals(aValue, missingValue)) { - cStData.addData(aStid, x, y, aValue); - } else { - cStData.addData(aStid, x, y, aValue / value); - } - } - - return cStData; - } - - // - // - - /** - * Calculate abstract station data - * - * @return Result station data - */ - public StationData abs() { - StationData stationData = new StationData(this); - for (int i = 0; i < stationData.getStNum(); i++) { - if (MIMath.doubleEquals(getValue(i), missingValue)) { - stationData.setValue(i, missingValue); - } else { - stationData.setValue(i, Math.abs(getValue(i))); - } - } - - return stationData; - } - - /** - * Calculate anti-cosine station data - * - * @return Result station data - */ - public StationData acos() { - StationData stationData = new StationData(this); - for (int i = 0; i < stationData.getStNum(); i++) { - if (MIMath.doubleEquals(getValue(i), missingValue)) { - stationData.setValue(i, missingValue); - } else { - stationData.setValue(i, Math.acos(getValue(i))); - } - } - - return stationData; - } - - /** - * Calculate anti-sine station data - * - * @return Result station data - */ - public StationData asin() { - StationData stationData = new StationData(this); - for (int i = 0; i < stationData.getStNum(); i++) { - if (MIMath.doubleEquals(getValue(i), missingValue)) { - stationData.setValue(i, missingValue); - } else { - stationData.setValue(i, Math.asin(getValue(i))); - } - } - - return stationData; - } - - /** - * Calculate anti-tangent station data - * - * @return Result station data - */ - public StationData atan() { - StationData stationData = new StationData(this); - for (int i = 0; i < stationData.getStNum(); i++) { - if (MIMath.doubleEquals(getValue(i), missingValue)) { - stationData.setValue(i, missingValue); - } else { - stationData.setValue(i, Math.atan(getValue(i))); - } - } - - return stationData; - } - - /** - * Calculate cosine station data - * - * @return Result station data - */ - public StationData cos() { - StationData stationData = new StationData(this); - for (int i = 0; i < stationData.getStNum(); i++) { - if (MIMath.doubleEquals(getValue(i), missingValue)) { - stationData.setValue(i, missingValue); - } else { - stationData.setValue(i, Math.cos(getValue(i))); - } - } - - return stationData; - } - - /** - * Calculate sine station data - * - * @return Result station data - */ - public StationData sin() { - StationData stationData = new StationData(this); - for (int i = 0; i < stationData.getStNum(); i++) { - if (MIMath.doubleEquals(getValue(i), missingValue)) { - stationData.setValue(i, missingValue); - } else { - stationData.setValue(i, Math.sin(getValue(i))); - } - } - - return stationData; - } - - /** - * Calculate tangent station data - * - * @return Result station data - */ - public StationData tan() { - StationData stationData = new StationData(this); - for (int i = 0; i < stationData.getStNum(); i++) { - if (MIMath.doubleEquals(getValue(i), missingValue)) { - stationData.setValue(i, missingValue); - } else { - stationData.setValue(i, Math.tan(getValue(i))); - } - } - - return stationData; - } - - /** - * Calculate e raised specific power value of station data - * - * @return Result station data - */ - public StationData exp() { - StationData stationData = new StationData(this); - for (int i = 0; i < stationData.getStNum(); i++) { - if (MIMath.doubleEquals(getValue(i), missingValue)) { - stationData.setValue(i, missingValue); - } else { - stationData.setValue(i, Math.exp(getValue(i))); - } - } - - return stationData; - } - - /** - * Calculate power station data - * - * @param p Power value - * @return Result station data - */ - public StationData pow(double p) { - StationData stationData = new StationData(this); - for (int i = 0; i < stationData.getStNum(); i++) { - if (MIMath.doubleEquals(getValue(i), missingValue)) { - stationData.setValue(i, missingValue); - } else { - stationData.setValue(i, Math.pow(getValue(i), p)); - } - } - - return stationData; - } - - /** - * Calculate square root station data - * - * @return Result station data - */ - public StationData sqrt() { - StationData stationData = new StationData(this); - for (int i = 0; i < stationData.getStNum(); i++) { - if (MIMath.doubleEquals(getValue(i), missingValue)) { - stationData.setValue(i, missingValue); - } else { - stationData.setValue(i, Math.sqrt(getValue(i))); - } - } - - return stationData; - } - - /** - * Calculate logrithm station data - * - * @return Result station data - */ - public StationData log() { - StationData stationData = new StationData(this); - for (int i = 0; i < stationData.getStNum(); i++) { - if (MIMath.doubleEquals(getValue(i), missingValue)) { - stationData.setValue(i, missingValue); - } else { - stationData.setValue(i, Math.log(getValue(i))); - } - } - - return stationData; - } - - /** - * Calculate base 10 logrithm station data - * - * @return Result station data - */ - public StationData log10() { - StationData stationData = new StationData(this); - for (int i = 0; i < stationData.getStNum(); i++) { - if (MIMath.doubleEquals(getValue(i), missingValue)) { - stationData.setValue(i, missingValue); - } else { - stationData.setValue(i, Math.log10(getValue(i))); - } - } - - return stationData; - } - // - // - - /** - * Add a data - * - * @param id Data identifer - * @param x X coordinate - * @param y Y coordinate - * @param value Value - */ - public void addData(String id, double x, double y, double value) { - stations.add(id); - int newSize = data.length + 1; - if (data.length == 0) { - data = new double[1][3]; - } else { - data = DataConvert.resizeArray2D(data, newSize); - } - data[newSize - 1][0] = x; - data[newSize - 1][1] = y; - data[newSize - 1][2] = value; - - if (newSize == 1) { - dataExtent.minX = x; - dataExtent.maxX = x; - dataExtent.minY = y; - dataExtent.maxY = y; - } else { - if (x < dataExtent.minX) { - dataExtent.minX = x; - } - if (x > dataExtent.maxX) { - dataExtent.maxX = x; - } - if (y < dataExtent.minY) { - dataExtent.minY = y; - } - if (y > dataExtent.maxY) { - dataExtent.maxY = y; - } - } - } - - /** - * Get station identifer by index - * - * @param idx Index - * @return Station identifer - */ - public String getStid(int idx) { - return stations.get(idx); - } - - /** - * Set station identifer by index - * - * @param idx Index - * @param value Station identifer - */ - public void setStid(int idx, String value) { - stations.set(idx, value); - } - - /** - * Get x coordinate by index - * - * @param idx Index - * @return X coordinate - */ - public double getX(int idx) { - return data[idx][0]; - } - - /** - * Get y coordinate by index - * - * @param idx Index - * @return Y coordinate - */ - public double getY(int idx) { - return data[idx][1]; - } - - /** - * Get data value by index - * - * @param idx Index - * @return Data value - */ - public double getValue(int idx) { - return data[idx][2]; - } - - /** - * Set data value by index - * - * @param idx Index - * @param value Data value - */ - public void setValue(int idx, double value) { - data[idx][2] = value; - } - - /** - * Get values - * @return Values - */ - public List getValues(){ - List values = new ArrayList<>(); - double v; - for (int i = 0; i getValidValues(){ - List values = new ArrayList<>(); - double v; - for (int i = 0; i polygonShapes) { - StationData stData = new StationData(); - stData.projInfo = this.projInfo; - stData.missingValue = this.missingValue; - for (int i = 0; i < this.getStNum(); i++) { - if (GeoComputation.pointInPolygons(polygonShapes, new PointD(this.getX(i), this.getY(i)))) { - stData.addData(this.getStid(i), this.getX(i), this.getY(i), this.getValue(i)); - } - } - - return stData; - } - - /** - * Maskout station data - * - * @param maskLayer Mask layer - * @return Result station data - */ - public StationData maskout(VectorLayer maskLayer) { - if (maskLayer.getShapeType() != ShapeTypes.Polygon) { - return this; - } - - List polygons = (List) maskLayer.getShapes(); - return this.maskout(polygons); - } - - /** - * Maskin station data - * - * @param polygonShape Mask polygon shape - * @return Result station data - */ - public StationData maskin(PolygonShape polygonShape) { - StationData stData = new StationData(); - stData.projInfo = this.projInfo; - stData.missingValue = this.missingValue; - for (int i = 0; i < this.getStNum(); i++) { - if (!GeoComputation.pointInPolygon(polygonShape, new PointD(this.getX(i), this.getY(i)))) { - stData.addData(this.getStid(i), this.getX(i), this.getY(i), this.getValue(i)); - } - } - - return stData; - } - - /** - * Maskin station data - * - * @param polygonShapes Mask polygon shapes - * @return Result station data - */ - public StationData maskin(List polygonShapes) { - StationData stData = new StationData(); - stData.projInfo = this.projInfo; - stData.missingValue = this.missingValue; - for (int i = 0; i < this.getStNum(); i++) { - if (!GeoComputation.pointInPolygons(polygonShapes, new PointD(this.getX(i), this.getY(i)))) { - stData.addData(this.getStid(i), this.getX(i), this.getY(i), this.getValue(i)); - } - } - - return stData; - } - - /** - * Maskin station data - * - * @param maskLayer Mask layer - * @return Result station data - */ - public StationData maskin(VectorLayer maskLayer) { - if (maskLayer.getShapeType() != ShapeTypes.Polygon) { - return this; - } - - List polygons = (List) maskLayer.getShapes(); - return this.maskin(polygons); - } - - /** - * Filter station data - * - * @param stations Station identifer list - * @return Result station data - */ - public StationData filter(List stations) { - StationData stData = new StationData(); - stData.projInfo = this.projInfo; - stData.missingValue = this.missingValue; - for (int i = 0; i < this.getStNum(); i++) { - if (stations.contains(this.getStid(i))) { - stData.addData(this.getStid(i), this.getX(i), this.getY(i), this.getValue(i)); - } - } - - return stData; - } - - /** - * Join an other station data - * - * @param indata Other station data - * @return Joined station data - */ - public StationData join(StationData indata) { - StationData stData = new StationData(this); - for (int i = 0; i < this.getStNum(); i++) { - stData.addData(this.getStid(i), this.getX(i), this.getY(i), this.getValue(i)); - } - for (int i = 0; i < indata.getStNum(); i++) { - if (!stData.stations.contains(indata.getStid(i))) { - stData.addData(indata.getStid(i), indata.getX(i), indata.getY(i), indata.getValue(i)); - } - } - - return stData; - } - - /** - * Project station data - * - * @param fromProj From projection info - * @param toProj To projection info - * @return Projected station data - */ - public StationData project(ProjectionInfo fromProj, ProjectionInfo toProj) { - int i; - double x, y; - StationData nsData = new StationData(); - nsData.missingValue = missingValue; - - double[][] points = new double[1][]; - for (i = 0; i < this.getStNum(); i++) { - points[0] = new double[]{this.getX(i), this.getY(i)}; - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, 1); - x = points[0][0]; - y = points[0][1]; - - nsData.addData(this.getStid(i), x, y, this.getValue(i)); - } catch (Exception e) { - i++; - } - } - - nsData.projInfo = toProj; - return nsData; - } - // - // - - /** - * Get station identifer index - * - * @param stid Station identifer - * @return Index - */ - public int getStidIndex(String stid) { - int idx = -1; - for (int i = 0; i < this.getStNum(); i++) { - if (this.getStid(i).trim().equals(stid.trim())) { - idx = i; - break; - } - } - return idx; - } - - /** - * Update data extent - */ - public void updateExtent() { - int stNum = this.getStNum(); - double minX, maxX, minY, maxY; - minX = 0; - maxX = 0; - minY = 0; - maxY = 0; - double lon, lat; - for (int i = 0; i < stNum; i++) { - lon = data[i][0]; - lat = data[i][1]; - if (i == 0) { - minX = lon; - maxX = minX; - minY = lat; - maxY = minY; - } else { - if (minX > lon) { - minX = lon; - } else if (maxX < lon) { - maxX = lon; - } - if (minY > lat) { - minY = lat; - } else if (maxY < lat) { - maxY = lat; - } - } - } - dataExtent.minX = minX; - dataExtent.maxX = maxX; - dataExtent.minY = minY; - dataExtent.maxY = maxY; - } - - // - // - /** - * Interpolate to grid data - * - * @param interSet Interpolation setting - * @return Grid data - */ - public GridData interpolateData(InterpolationSetting interSet) { - GridData aGridData = null; - double[] X; - double[] Y; - List values = createGridXY(interSet.getGridDataSetting()); - X = values.get(0); - Y = values.get(1); - switch (interSet.getInterpolationMethod()) { - case IDW_Radius: - this.filterData_Radius(interSet.getRadius(), interSet.getGridDataSetting().dataExtent); - aGridData = interpolate_Radius(data, - X, Y, interSet.getMinPointNum(), interSet.getRadius(), missingValue); - break; - case IDW_Neighbors: - this.filterData_Radius(interSet.getRadius(), interSet.getGridDataSetting().dataExtent); - aGridData = interpolate_Neighbor(data, X, Y, - interSet.getMinPointNum(), missingValue); - break; - case Cressman: - this.filterData_Radius(0, interSet.getGridDataSetting().dataExtent); - aGridData = interpolate_Cressman(data, X, Y, interSet.getRadiusList(), missingValue); - break; - case AssignPointToGrid: - this.filterData_Radius(0, interSet.getGridDataSetting().dataExtent); - aGridData = interpolate_Assign(data, X, Y, missingValue); - break; - } - - return aGridData; - } - - /** - * Interpolate by IDW radius method - * - * @param S Station data array - * @param X X coordinate array - * @param Y Y coordinate array - * @param minPNum Minimum point number - * @param radius Radius - * @param missingValue Missing value - * @return Grid data - */ - public GridData interpolate_Radius(double[][] S, double[] X, double[] Y, - int minPNum, double radius, double missingValue) { - double[][] dataArray; - dataArray = wcontour.Interpolate.interpolation_IDW_Radius(S, X, Y, minPNum, radius, missingValue); - - GridData gridData = new GridData(); - gridData.data = dataArray; - gridData.missingValue = missingValue; - gridData.xArray = X; - gridData.yArray = Y; - - return gridData; - } - - /** - * Interpolate by IDW radius method - * - * @param X X coordinate array - * @param Y Y coordinate array - * @param minPNum Minimum point number - * @param radius Radius - * @param missingValue Missing value - * @return Grid data - */ - public GridData interpolate_Radius(List X, List Y, - int minPNum, double radius, double missingValue) { - double[] nX = new double[X.size()]; - double[] nY = new double[Y.size()]; - for (int i = 0; i < X.size(); i++){ - nX[i] = X.get(i).doubleValue(); - } - for (int i = 0; i < Y.size(); i++){ - nY[i] = Y.get(i).doubleValue(); - } - - return this.interpolate_Radius(data, nX, nY, minPNum, radius, missingValue); - } - - /** - * Interpolate by IDW_Neighbor method - * - * @param S Station data array - * @param X X coordinate array - * @param Y Y coordinate array - * @param pNum Point number - * @param missingValue Missing value - * @return Grid data - */ - public GridData interpolate_Neighbor(double[][] S, double[] X, double[] Y, int pNum, double missingValue) { - double[][] dataArray = wcontour.Interpolate.interpolation_IDW_Neighbor(S, X, Y, pNum, missingValue); - - GridData gridData = new GridData(); - gridData.data = dataArray; - gridData.missingValue = missingValue; - gridData.xArray = X; - gridData.yArray = Y; - - return gridData; - } - - /** - * Interpolate by IDW_Neighbor method - * - * @param X X coordinate array - * @param Y Y coordinate array - * @param pNum Point number - * @param missingValue Missing value - * @return Grid data - */ - public GridData interpolate_Neighbor(List X, List Y, int pNum, double missingValue) { - double[] nX = new double[X.size()]; - double[] nY = new double[Y.size()]; - for (int i = 0; i < X.size(); i++){ - nX[i] = X.get(i).doubleValue(); - } - for (int i = 0; i < Y.size(); i++){ - nY[i] = Y.get(i).doubleValue(); - } - - return this.interpolate_Neighbor(data, nX, nY, pNum, missingValue); - } - - /** - * Interpolation by Cressman method - * - * @param S Station data array - * @param X X coordinate array - * @param Y Y coordinate array - * @param radList Radius list - * @param missingValue Missing value - * @return Grid data - */ - public GridData interpolate_Cressman(double[][] S, double[] X, double[] Y, - List radList, double missingValue) { - double[][] dataArray = wcontour.Interpolate.cressman(S, X, Y, missingValue, radList); - - GridData gridData = new GridData(); - gridData.data = dataArray; - gridData.missingValue = missingValue; - gridData.xArray = X; - gridData.yArray = Y; - - return gridData; - } - - /** - * Interpolation by Cressman method - * - * @param X X coordinate array - * @param Y Y coordinate array - * @param radList Radius list - * @param missingValue Missing value - * @return Grid data - */ - public GridData interpolate_Cressman(List X, List Y, - List radList, double missingValue) { - double[] nX = new double[X.size()]; - double[] nY = new double[Y.size()]; - for (int i = 0; i < X.size(); i++){ - nX[i] = X.get(i).doubleValue(); - } - for (int i = 0; i < Y.size(); i++){ - nY[i] = Y.get(i).doubleValue(); - } - - List rlist = new ArrayList<>(); - for (Number r : radList){ - rlist.add(r.doubleValue()); - } - return this.interpolate_Cressman(data, nX, nY, rlist, missingValue); - } - - /** - * Interpolation by assign method - * - * @param S Station data array - * @param X X coordinate array - * @param Y Y coordinate array - * @param missingValue Missing value - * @return Grid data - */ - public GridData interpolate_Assign(double[][] S, double[] X, double[] Y, double missingValue) { - double[][] dataArray = wcontour.Interpolate.assignPointToGrid(S, X, Y, missingValue); - - GridData gridData = new GridData(); - gridData.data = dataArray; - gridData.missingValue = missingValue; - gridData.xArray = X; - gridData.yArray = Y; - - return gridData; - } - - /** - * Interpolation by assign method - * - * @param X X coordinate array - * @param Y Y coordinate array - * @param missingValue Missing value - * @return Grid data - */ - public GridData interpolate_Assign(List X, List Y, double missingValue) { - double[] nX = new double[X.size()]; - double[] nY = new double[Y.size()]; - for (int i = 0; i < X.size(); i++){ - nX[i] = X.get(i).doubleValue(); - } - for (int i = 0; i < Y.size(); i++){ - nY[i] = Y.get(i).doubleValue(); - } - - return this.interpolate_Assign(data, nX, nY, missingValue); - } - - /** - * Create grid X/Y coordinate - * - * @param gSet - * @return X/Y coordinate array list - */ - public List createGridXY(GridDataSetting gSet) { - double xDelt = (gSet.dataExtent.maxX - gSet.dataExtent.minX) / (double) (gSet.xNum - 1); - double yDelt = (gSet.dataExtent.maxY - gSet.dataExtent.minY) / (double) (gSet.yNum - 1); - - return wcontour.Interpolate.createGridXY_Delt(gSet.dataExtent.minX, gSet.dataExtent.minY, - gSet.dataExtent.maxX, gSet.dataExtent.maxY, xDelt, yDelt); - } - - /** - * Filte station data by radius and extent - * - * @param radius Radius - * @param aExtent Data extent - */ - public void filterData_Radius(double radius, Extent aExtent) { - double[][] discretedData; - List disDataList = new ArrayList(); - List nstations = new ArrayList(); - int i; - for (i = 0; i < this.getStNum(); i++) { - if (MIMath.doubleEquals(data[i][2], missingValue)) { - continue; - } - if (data[i][0] + radius < aExtent.minX || data[i][0] - radius > aExtent.maxX - || data[i][1] + radius < aExtent.minY || data[i][1] - radius > aExtent.maxY) { - continue; - } else { - disDataList.add(new double[]{data[i][0], data[i][1], data[i][2]}); - nstations.add(this.stations.get(i)); - } - } - - discretedData = new double[disDataList.size()][3]; - i = 0; - for (double[] disData : disDataList) { - discretedData[i][0] = disData[0]; - discretedData[i][1] = disData[1]; - discretedData[i][2] = disData[2]; - i += 1; - } - - this.setData(discretedData); - stations = nstations; - } - // - // - - /** - * Get minimum value - * - * @return Minimum value - */ - public double getMinValue() { - return (double)this.getMinValueIndex()[0]; - } - - /** - * Get maximum value - * - * @return Maximum value - */ - public double getMaxValue() { - return (double)this.getMaxValueIndex()[0]; - } - - /** - * Get minimum value and index - * - * @return Minimum value and index - */ - public Object[] getMinValueIndex() { - double min = 0; - int vdNum = 0; - int idx = 0; - for (int i = 0; i < this.getStNum(); i++) { - if (MIMath.doubleEquals(data[i][2], missingValue)) { - continue; - } - - if (vdNum == 0) { - min = data[i][2]; - idx = i; - } else { - if (min > data[i][2]) { - min = data[i][2]; - idx = i; - } - } - vdNum += 1; - } - - return new Object[]{min, idx}; - } - - /** - * Get maximum value and index - * - * @return Maximum value and index - */ - public Object[] getMaxValueIndex() { - double max = 0; - int vdNum = 0; - int idx = 0; - for (int i = 0; i < this.getStNum(); i++) { - if (MIMath.doubleEquals(data[i][2], missingValue)) { - continue; - } - - if (vdNum == 0) { - max = data[i][2]; - idx = i; - } else { - if (max < data[i][2]) { - max = data[i][2]; - idx = i; - } - } - vdNum += 1; - } - - return new Object[]{max, idx}; - } - - /** - * Get maximum and minimum values - * - * @param maxmin Maximum and minimum value array - * @return Has missing value or not - */ - public boolean getMaxMinValue(double[] maxmin) { - double max = 0; - double min = 0; - int vdNum = 0; - boolean hasMissingValue = false; - for (int i = 0; i < this.getStNum(); i++) { - if (MIMath.doubleEquals(data[i][2], missingValue)) { - hasMissingValue = true; - continue; - } - - if (vdNum == 0) { - max = data[i][2]; - min = max; - } else { - if (max < data[i][2]) { - max = data[i][2]; - } - if (min > data[i][2]) { - min = data[i][2]; - } - } - vdNum += 1; - } - - maxmin[0] = max; - maxmin[1] = min; - return hasMissingValue; - } - - /** - * Calculate average value - * - * @return Average value - */ - public double average() { - double ave = 0; - int vdNum = 0; - double v; - for (int i = 0; i < this.getStNum(); i++) { - v = this.getValue(i); - if (MIMath.doubleEquals(v, missingValue)) { - continue; - } - - ave += v; - vdNum += 1; - } - - ave = ave / vdNum; - - return ave; - } - - /** - * Calculate summary value - * - * @return Summary value - */ - public double sum() { - double sum = 0; - double v; - for (int i = 0; i < this.getStNum(); i++) { - v = this.getValue(i); - if (MIMath.doubleEquals(v, missingValue)) { - continue; - } - - sum += v; - } - - return sum; - } - // - // - } diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/StationTableData.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/StationTableData.java deleted file mode 100644 index a84d104f..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/StationTableData.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.geo.data; - -import org.meteoinfo.common.util.GlobalUtil; -import org.meteoinfo.ndarray.DataType; -import org.meteoinfo.geo.projection.KnownCoordinateSystems; -import org.meteoinfo.geo.projection.info.ProjectionInfo; - -import javax.swing.*; -import java.io.*; -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author yaqiang - */ -public class StationTableData extends TableData{ - // - private ProjectionInfo projInfo; - private int stIdx; - private int lonIdx; - private int latIdx; - // - // - /** - * Constructor - */ - public StationTableData(){ - this.projInfo = KnownCoordinateSystems.geographic.world.WGS1984; - stIdx = 0; - lonIdx = 1; - latIdx = 2; - } - // - // - /** - * Get projection info - * @return Projection info - */ - public ProjectionInfo getProjectionInfo(){ - return this.projInfo; - } - - /** - * Set projection info - * @param value Projection info - */ - public void setProjectionInfo(ProjectionInfo value){ - this.projInfo = value; - } - - /** - * Get station column index - * @return Station column index - */ - public int getStationIndex(){ - return this.stIdx; - } - - /** - * Set station column index - * @param value Statin column index - */ - public void setStationIndex(int value){ - this.stIdx = value; - } - - /** - * Get longitude column index - * @return Longitude column index - */ - public int getLonIndex(){ - return this.lonIdx; - } - - /** - * Set longitude column index - * @param value Longitude column index - */ - public void setLonIndex(int value){ - this.latIdx = value; - } - - /** - * Get latitude column index - * @return Latitude column index - */ - public int getLatIndex(){ - return this.latIdx; - } - - /** - * Set Latitude column index - * @param value Latitude column index - */ - public void setLatIndex(int value){ - this.lonIdx = value; - } - // - // - /** - * Read data table from ASCII file - * - * @param fileName File name - * @param lonIdx Longitude index - * @param latIdx Latitude index - * @throws FileNotFoundException - */ - 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 - * - * @param fileName File name - * @param stIdx Station column index - * @param lonIdx Longitude column index - * @param latIdx Latitude column index - * @throws FileNotFoundException - */ - public void readASCIIFile(String fileName, int stIdx, int lonIdx, int latIdx) throws FileNotFoundException, IOException, Exception { - this.lonIdx = lonIdx; - this.latIdx = latIdx; - //DataTable dTable = new DataTable(); - - BufferedReader sr = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "utf-8")); - String title = sr.readLine().trim(); - //Determine separator - String separator = GlobalUtil.getDelimiter(title); - String[] titleArray = GlobalUtil.split(title, separator); - if (titleArray.length < 2) { - JOptionPane.showMessageDialog(null, "File Format Error!"); - sr.close(); - } else { - //Get fields - List dataIdxs = new ArrayList<>(); - String fieldName; - for (int i = 0; i < titleArray.length; i++) { - fieldName = titleArray[i]; - if (i == lonIdx || i == latIdx) - this.addColumn(fieldName, DataType.FLOAT); - else - this.addColumn(fieldName, DataType.STRING); - dataIdxs.add(i); - } - - String[] dataArray; - int rn = 0; - String line = sr.readLine(); - while (line != null) { - line = line.trim(); - if (line.isEmpty()) { - continue; - } - dataArray = GlobalUtil.split(line, separator); - this.addRow(); - int cn = 0; - for (int idx : dataIdxs) { - if (idx == lonIdx || idx == latIdx) - this.setValue(rn, cn, Float.parseFloat(dataArray[idx])); - else - this.setValue(rn, cn, dataArray[idx]); - cn++; - } - - rn += 1; - line = sr.readLine(); - } - - //dataTable = dTable; - sr.close(); - } - } - - /** - * Clone - * @return Cloned StationTableData object - */ - @Override - public Object clone(){ - StationTableData std = new StationTableData(); - std = (StationTableData)super.clone(); - //std.dataTable = (DataTable)this.dataTable.clone(); - std.missingValue = this.missingValue; - std.projInfo = this.projInfo; - std.stIdx = this.stIdx; - std.lonIdx = this.lonIdx; - std.latIdx = this.latIdx; - - return std; - } - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/TableData.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/TableData.java deleted file mode 100644 index 72f32f58..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/TableData.java +++ /dev/null @@ -1,1264 +0,0 @@ - /* Copyright 2014 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.data; - - import org.meteoinfo.common.MIMath; - import org.meteoinfo.common.util.GlobalUtil; - import org.meteoinfo.geo.analysis.Statistics; - import org.meteoinfo.ndarray.DataType; - import org.meteoinfo.table.DataColumn; - import org.meteoinfo.table.DataRow; - import org.meteoinfo.table.DataTable; - import org.meteoinfo.table.util.TableUtil; - - import javax.swing.*; - import java.io.*; - import java.time.LocalDateTime; - import java.time.format.DateTimeFormatter; - import java.util.ArrayList; - import java.util.Arrays; - import java.util.List; - - /** - * - * @author Yaqiang Wang - */ - public class TableData extends DataTable { - - // - //protected DataTable dataTable = new DataTable(); - protected double missingValue = -9999.0; - - // - // - /** - * Constructor - */ - public TableData() { - super(); - } - - /** - * Constructor - * - * @param dataTable The data table - */ - public TableData(DataTable dataTable) { - this.columns = dataTable.getColumns(); - this.readOnly = dataTable.isReadOnly(); - this.rows = dataTable.getRows(); - this.tableName = dataTable.getTableName(); - this.tag = dataTable.getTag(); - } - - // - // - // /** - // * Get data table - // * - // * @return Data table - // */ - // public DataTable getDataTable() { - // return dataTable; - // } - // - // /** - // * Set data table - // * - // * @param value Data table - // */ - // public void setDataTable(DataTable value) { - // dataTable = value; - // } - - /** - * Get time column name - * - * @return Time column name - */ - public String getTimeColName() { - return null; - } - - /** - * Get missing value - * - * @return Missing value - */ - public double getMissingValue() { - return missingValue; - } - - /** - * Set missing value - * - * @param value Missing value - */ - public void setMissingValue(double value) { - missingValue = value; - } - // - // - - // - - /** - * Add column data - * - * @param colName Column name - * @param dt Data type string - * @param colData The column data - * @throws Exception - */ - @Override - public void addColumnData(String colName, String dt, List colData) throws Exception { - DataType dataType = TableUtil.toDataTypes(dt); - switch (dataType) { - case DATE: - if (colData.get(0) instanceof LocalDateTime) { - this.addColumnData(colName, dataType, colData); - } else { - String dformat = TableUtil.getDateFormat(dt); - this.addColumn(new DataColumn(colName, dataType, dformat)); - this.setValues(colName, colData); - } - break; - default: - this.addColumnData(colName, dataType, colData); - break; - } - } - - /** - * Add column data - * - * @param index Column index - * @param colName Column name - * @param dt Data type string - * @param colData The column data - * @throws Exception - */ - public void addColumnData(int index, String colName, String dt, List colData) throws Exception { - DataType dataType = TableUtil.toDataTypes(dt); - switch (dataType) { - case DATE: - if (colData.get(0) instanceof LocalDateTime) { - this.addColumnData(index, colName, dataType, colData); - } else { - String dformat = TableUtil.getDateFormat(dt); - this.addColumn(index, new DataColumn(colName, dataType, dformat)); - this.setValues(colName, colData); - } - break; - default: - this.addColumnData(index, colName, dataType, colData); - break; - } - } - - /** - * Remove a column - * - * @param colName Column name - */ - public void removeColumn(String colName) { - this.removeColumn(this.findColumn(colName)); - } - - /** - * Get data row - * @param idx Index - * @return Data row - */ - public DataRow getRow(int idx){ - return this.getRows().get(idx); - } - - /** - * Get data columns - * - * @return Data columns - */ - public List getDataColumns() { - List cols = new ArrayList<>(); - for (DataColumn col : this.getColumns()) { - if (col.getDataType() != DataType.DATE) { - cols.add(col); - } - } - - return cols; - } - - /** - * Get column values - * - * @param col The data column - * @return Value list - */ - public List getValidColumnValues(DataColumn col) { - return this.getValidColumnValues(this.getRows(), col); - } - - /** - * Get column values - * - * @param rows The data row list - * @param col The data column - * @return Column values - */ - public List getValidColumnValues(List rows, DataColumn col) { - List values = new ArrayList<>(); - String colName = col.getColumnName(); - String vstr; - double value = Double.NaN; - for (DataRow row : rows) { - if (row.getValue(colName) == null) { - continue; - } - switch (col.getDataType()) { - case INT: - value = (double) (Integer) row.getValue(colName); - break; - case FLOAT: - value = (double) (Float) row.getValue(colName); - break; - case DOUBLE: - value = (Double) row.getValue(colName); - break; - case STRING: - vstr = (String) row.getValue(colName); - if (!vstr.isEmpty()) { - value = Double.parseDouble(vstr); - } else { - value = Double.NaN; - } - break; - } - if (!Double.isNaN(value) && !MIMath.doubleEquals(value, this.missingValue)) { - values.add(value); - } - } - - return values; - } - - /** - * Set column data - * - * @param colName Column name - * @param values Values - */ - @Override - public void setColumnData(String colName, List values) { - this.setValues(colName, values); - } - - /** - * Convert a data column to double data type - * - * @param colName The data column name - */ - public void columnToDouble(String colName) { - DataColumn col = this.findColumn(colName); - DataType oldType = col.getDataType(); - col.setDataType(DataType.DOUBLE); - Object value; - for (DataRow row : this.getRows()) { - value = row.getValue(colName); - switch (oldType) { - case INT: - row.setValue(col, (double) (Integer) value); - break; - case FLOAT: - row.setValue(col, (double) (Float) value); - break; - case STRING: - if (MIMath.isNumeric((String) value)) { - row.setValue(col, Double.parseDouble((String) value)); - } else { - row.setValue(col, Double.NaN); - } - break; - } - } - } - - /** - * Average data - * - * @param cols The data columns - * @return Result data table - * @throws Exception - */ - public DataTable average(List cols) throws Exception { - DataTable rTable = new DataTable(); - for (DataColumn col : cols) { - rTable.addColumn(col.getColumnName(), DataType.DOUBLE); - } - DataRow nRow = rTable.addRow(); - - for (DataColumn col : cols) { - List values = this.getValidColumnValues(col); - double mean = Statistics.mean(values); - nRow.setValue(col, mean); - } - - return rTable; - } - - /** - * Summary data - * - * @param cols The data columns - * @return Result data table - * @throws Exception - */ - public DataTable sum(List cols) throws Exception { - DataTable rTable = new DataTable(); - for (DataColumn col : cols) { - rTable.addColumn(col.getColumnName(), DataType.DOUBLE); - } - DataRow nRow = rTable.addRow(); - - for (DataColumn col : cols) { - List values = this.getValidColumnValues(col); - double mean = Statistics.sum(values); - nRow.setValue(col, mean); - } - - return rTable; - } - - /** - * Average data and calculate standard deviation - * - * @param cols The data columns - * @return Result data table - * @throws Exception - */ - public DataTable ave_stdev(List cols) throws Exception { - DataTable rTable = new DataTable(); - for (DataColumn col : cols) { - rTable.addColumn(col.getColumnName(), DataType.DOUBLE); - rTable.addColumn(col.getColumnName() + "_sd", DataType.DOUBLE); - } - DataRow nRow = rTable.addRow(); - - for (DataColumn col : cols) { - List values = this.getValidColumnValues(col); - double mean = Statistics.mean(values); - double stdev = Statistics.standardDeviation(values); - nRow.setValue(col.getColumnName(), mean); - nRow.setValue(col.getColumnName() + "_sd", stdev); - } - - return rTable; - } - - /** - * Get average data table - * - * @param dataColumns - * @return Average data table - * @throws Exception - */ - public DataTable statistics(List dataColumns) throws Exception { - DataTable rTable = new DataTable(); - rTable.addColumn("Type", DataType.STRING); - rTable.addColumn("Mean", DataType.DOUBLE); - rTable.addColumn("Minimum", DataType.DOUBLE); - rTable.addColumn("Q1", DataType.DOUBLE); - rTable.addColumn("Meadian", DataType.DOUBLE); - rTable.addColumn("Q3", DataType.DOUBLE); - rTable.addColumn("Maximum", DataType.DOUBLE); - rTable.addColumn("StdDev", DataType.DOUBLE); - rTable.addColumn("Count", DataType.INT); - - int i = 0; - for (DataColumn col : dataColumns) { - List values = this.getValidColumnValues(col); - double mean = Statistics.mean(values); - double min = Statistics.minimum(values); - double q1 = Statistics.quantile(values, 1); - double meadian = Statistics.median(values); - double q3 = Statistics.quantile(values, 3); - double max = Statistics.maximum(values); - double sd = Statistics.standardDeviation(values); - int n = values.size(); - - rTable.addRow(); - rTable.setValue(i, 0, col.getColumnName()); - rTable.setValue(i, 1, mean); - rTable.setValue(i, 2, min); - rTable.setValue(i, 3, q1); - rTable.setValue(i, 4, meadian); - rTable.setValue(i, 5, q3); - rTable.setValue(i, 6, max); - rTable.setValue(i, 7, sd); - rTable.setValue(i, 8, n); - - i++; - } - - return rTable; - } - - /** - * Get average data table - * - * @return Average data table - * @throws Exception - */ - public DataTable statistics() throws Exception { - return this.statistics(this.getDataColumns()); - } - - /** - * Read data table from ASCII file - * - * @param fileName File name - * @param formatSpec Format specifiers string - * @throws FileNotFoundException - */ - public void readASCIIFile(String fileName, String formatSpec) throws FileNotFoundException, IOException, Exception { - BufferedReader sr = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "UTF8")); - String title = sr.readLine().trim(); - //Determine separator - String delimiter = GlobalUtil.getDelimiter(title); - sr.close(); - this.readASCIIFile(fileName, delimiter, 0, formatSpec, "UTF8"); - } - - /** - * Read data table from ASCII file - * - * @param fileName File name - * @param delimiter Delimiter - * @param headerLines Number of lines to skip at begining of the file - * @param formatSpec Format specifiers string - * @param encoding Fle encoding - * @throws FileNotFoundException - */ - public void readASCIIFile(String fileName, String delimiter, int headerLines, String formatSpec, String encoding) throws FileNotFoundException, IOException, Exception { - //DataTable dTable = new DataTable(); - - BufferedReader sr = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), encoding)); - if (headerLines > 0) { - for (int i = 0; i < headerLines; i++) { - sr.readLine(); - } - } - - String title = sr.readLine().trim(); - String[] titleArray = GlobalUtil.split(title, delimiter); - int colNum = titleArray.length; - if (titleArray.length < 2) { - System.out.println("File Format Error!"); - sr.close(); - } else { - //Get fields - String[] colFormats; - if (formatSpec == null) { - colFormats = new String[colNum]; - for (int i = 0; i < colNum; i++) { - colFormats[i] = "C"; - } - } else { - colFormats = formatSpec.split("%"); - } - - int idx = 0; - for (String colFormat : colFormats) { - if (colFormat.isEmpty()) { - continue; - } - - switch (colFormat) { - case "C": - case "s": - this.addColumn(titleArray[idx], DataType.STRING); - break; - case "i": - this.addColumn(titleArray[idx], DataType.INT); - break; - case "f": - this.addColumn(titleArray[idx], DataType.FLOAT); - break; - case "d": - this.addColumn(titleArray[idx], DataType.DOUBLE); - break; - case "B": - this.addColumn(titleArray[idx], DataType.BOOLEAN); - break; - default: - if (colFormat.substring(0, 1).equals("{")) { //Date - int eidx = colFormat.indexOf("}"); - String formatStr = colFormat.substring(1, eidx); - this.addColumn(new DataColumn(titleArray[idx], DataType.DATE, formatStr)); - } else { - this.addColumn(titleArray[idx], DataType.STRING); - } - break; - } - - idx += 1; - } - - String[] dataArray; - int rn = 0; - String line = sr.readLine(); - while (line != null) { - line = line.trim(); - if (line.isEmpty()) { - line = sr.readLine(); - continue; - } - dataArray = GlobalUtil.split(line, delimiter); - - this.addRow(); - int cn = 0; - for (int i = 0; i < dataArray.length; i++) { - this.setValue(rn, cn, dataArray[i]); - cn++; - } - - rn += 1; - line = sr.readLine(); - } - - sr.close(); - } - } - - /** - * Read data table from ASCII file - * - * @param fileName File name - * @param dataColumns Data columns - * @throws FileNotFoundException - */ - public void readASCIIFile(String fileName, List dataColumns) throws FileNotFoundException, IOException, Exception { - //DataTable dTable = new DataTable(); - - BufferedReader sr = new BufferedReader(new FileReader(new File(fileName))); - String title = sr.readLine().trim(); - //Determine separator - String separator = GlobalUtil.getDelimiter(title); - String[] titleArray = GlobalUtil.split(title, separator); - if (titleArray.length < 2) { - JOptionPane.showMessageDialog(null, "File Format Error!"); - sr.close(); - } else { - //Get fields - for (DataColumn col : dataColumns) { - this.addColumn(col); - } - List dataIdxs = new ArrayList<>(); - String fieldName; - for (int i = 0; i < titleArray.length; i++) { - fieldName = titleArray[i]; - for (DataColumn col : dataColumns) { - if (fieldName.equals(col.getColumnName())) { - dataIdxs.add(i); - } - } - } - - String[] dataArray; - int rn = 0; - String line = sr.readLine(); - while (line != null) { - line = line.trim(); - if (line.isEmpty()) { - continue; - } - dataArray = GlobalUtil.split(line, separator); - this.addRow(); - int cn = 0; - for (int idx : dataIdxs) { - this.setValue(rn, cn, dataArray[idx]); - cn++; - } - - rn += 1; - line = sr.readLine(); - } - - //dataTable = dTable; - sr.close(); - } - } - - /** - * Read data table from ASCII file - * - * @param fileName File name - * @throws FileNotFoundException - */ - public void readASCIIFile(String fileName) throws FileNotFoundException, IOException, Exception { - //DataTable dTable = new DataTable(); - - BufferedReader sr = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "utf-8")); - String title = sr.readLine().trim(); - //Determine separator - String separator = GlobalUtil.getDelimiter(title); - String[] titleArray = GlobalUtil.split(title, separator); - if (titleArray.length < 2) { - JOptionPane.showMessageDialog(null, "File Format Error!"); - sr.close(); - } else { - //Get fields - List dataIdxs = new ArrayList<>(); - String fieldName; - for (int i = 0; i < titleArray.length; i++) { - fieldName = titleArray[i]; - this.addColumn(fieldName, DataType.STRING); - dataIdxs.add(i); - } - - String[] dataArray; - int rn = 0; - String line = sr.readLine(); - while (line != null) { - line = line.trim(); - if (line.isEmpty()) { - continue; - } - dataArray = GlobalUtil.split(line, separator); - this.addRow(); - int cn = 0; - for (int idx : dataIdxs) { - this.setValue(rn, cn, dataArray[idx]); - cn++; - } - - rn += 1; - line = sr.readLine(); - } - - //dataTable = dTable; - sr.close(); - } - } - - /** - * Convert a multi rows data table to single row data table - * - * @param inTable Input data table - multi rows - * @param firstColName The new first column name - * @param firstColValue The new first column value - * @return Result data table - * @throws Exception - */ - public DataTable toSingleRowTable(DataTable inTable, String firstColName, String firstColValue) throws Exception { - DataTable rTable = new DataTable(); - rTable.addColumn(firstColName, DataType.STRING); - List values = new ArrayList<>(); - - if (inTable.getColumnCount() == 2) { - DataColumn col = inTable.getColumns().get(1); - String colName = col.getColumnName(); - int r = 0; - for (DataRow row : inTable.getRows()) { - String rowName = row.getValue(0).toString(); - DataColumn newCol = new DataColumn(rowName, col.getDataType()); - rTable.addColumn(newCol); - values.add(inTable.getValue(r, colName)); - r++; - } - } else { - int i = 0; - for (DataColumn col : inTable.getColumns()) { - if (i > 0) { - String colName = col.getColumnName(); - int r = 0; - for (DataRow row : inTable.getRows()) { - String rowName = row.getValue(0).toString(); - DataColumn newCol = new DataColumn(rowName + "_" + colName, col.getDataType()); - rTable.addColumn(newCol); - values.add(inTable.getValue(r, colName)); - r++; - } - } - i++; - } - } - - rTable.addRow(); - rTable.setValue(0, 0, firstColValue); - int i = 1; - for (Object value : values) { - rTable.setValue(0, i, value); - i++; - } - - return rTable; - } - - /** - * Convert a multi rows data table to single row data table - * - * @param inTable Input data table - multi rows - * @return Result data table - * @throws Exception - */ - public DataTable toSingleRowTable(DataTable inTable) throws Exception { - DataTable rTable = new DataTable(); - List values = new ArrayList<>(); - - if (inTable.getColumnCount() == 2) { - DataColumn col = inTable.getColumns().get(1); - String colName = col.getColumnName(); - int r = 0; - for (DataRow row : inTable.getRows()) { - String rowName = row.getValue(0).toString(); - DataColumn newCol = new DataColumn(rowName, col.getDataType()); - rTable.addColumn(newCol); - values.add(inTable.getValue(r, colName)); - r++; - } - } else { - int i = 0; - for (DataColumn col : inTable.getColumns()) { - if (i > 0) { - String colName = col.getColumnName(); - int r = 0; - for (DataRow row : inTable.getRows()) { - String rowName = row.getValue(0).toString(); - DataColumn newCol = new DataColumn(rowName + "_" + colName, col.getDataType()); - rTable.addColumn(newCol); - values.add(inTable.getValue(r, colName)); - r++; - } - } - i++; - } - } - - rTable.addRow(); - int i = 0; - for (Object value : values) { - rTable.setValue(0, i, value); - i++; - } - - return rTable; - } - - /** - * Convert a multi rows data table to single row data table - * - * @return Result data table - * @throws Exception - */ - public DataTable toSingleRowTable() throws Exception { - DataTable rTable = new DataTable(); - List values = new ArrayList<>(); - - if (this.getColumnCount() == 2) { - DataColumn col = this.getColumns().get(1); - String colName = col.getColumnName(); - int r = 0; - for (DataRow row : this.getRows()) { - String rowName = row.getValue(0).toString(); - DataColumn newCol = new DataColumn(rowName, col.getDataType()); - rTable.addColumn(newCol); - values.add(this.getValue(r, colName)); - r++; - } - } else { - int i = 0; - for (DataColumn col : this.getColumns()) { - if (i > 0) { - String colName = col.getColumnName(); - int r = 0; - for (DataRow row : this.getRows()) { - String rowName = row.getValue(0).toString(); - DataColumn newCol = new DataColumn(rowName + "_" + colName, col.getDataType()); - rTable.addColumn(newCol); - values.add(this.getValue(r, colName)); - r++; - } - } - i++; - } - } - - rTable.addRow(); - int i = 0; - for (Object value : values) { - rTable.setValue(0, i, value); - i++; - } - - return rTable; - } - - /** - * Join data table - * - * @param tableData The input table data - * @param colName The column name for join - */ - public void join(TableData tableData, String colName) { - this.join(tableData, colName, colName, false); - } - - /** - * Join data table - * - * @param tableData The input table data - * @param thisColName The column name for join - * @param otherColName The other column name for join - */ - public void join(TableData tableData, String thisColName, String otherColName) { - this.join(tableData, thisColName, otherColName, false); - } - - /** - * Clone - * - * @return Cloned TableData object - */ - @Override - public Object clone() { - TableData td = (TableData) super.clone(); - td.missingValue = this.missingValue; - - return td; - } - // - - // - /** - * Get years - * - * @param tColName Time column name - * @return Year list - */ - public List getYears(String tColName) { - List years = new ArrayList<>(); - LocalDateTime ldt; - int year; - for (DataRow row : this.getRows()) { - ldt = (LocalDateTime) row.getValue(tColName); - year = ldt.getYear(); - if (!years.contains(year)) { - years.add(year); - } - } - - return years; - } - - /** - * Get year months - * - * @param tColName Time column name - * @return Year month list - */ - public List getYearMonths(String tColName) { - List yms = new ArrayList<>(); - DateTimeFormatter format =DateTimeFormatter.ofPattern("yyyyMM"); - String ym; - for (DataRow row : this.getRows()) { - ym = format.format((LocalDateTime) row.getValue(tColName)); - if (!yms.contains(ym)) { - yms.add(ym); - } - } - - return yms; - } - - /** - * Get data row list by year - * - * @param year The year - * @param tColName Time column name - * @return Data row list - */ - public List getDataByYear(int year, String tColName) { - List rows = new ArrayList<>(); - LocalDateTime ldt; - for (DataRow row : this.getRows()) { - ldt = (LocalDateTime) row.getValue(tColName); - if (ldt.getYear() == year) { - rows.add(row); - } - } - - return rows; - } - - /** - * Get data row list by year - * - * @param season The season - * @param tColName Time column name - * @return Data row list - */ - public List getDataBySeason(String season, String tColName) { - List months = this.getMonthsBySeason(season); - List rows = new ArrayList<>(); - LocalDateTime ldt; - int month; - for (DataRow row : this.getRows()) { - ldt = (LocalDateTime) row.getValue(tColName); - month = ldt.getMonthValue(); - if (months.contains(month)) { - rows.add(row); - } - } - - return rows; - } - - private List getMonthsBySeason(String season) { - List months = new ArrayList<>(); - if (season.equalsIgnoreCase("spring")) { - months.add(3); - months.add(4); - months.add(5); - } else if (season.equalsIgnoreCase("summer")) { - months.add(6); - months.add(7); - months.add(8); - } else if (season.equalsIgnoreCase("autumn")) { - months.add(9); - months.add(10); - months.add(11); - } else if (season.equalsIgnoreCase("winter")) { - months.add(12); - months.add(1); - months.add(2); - } - - return months; - } - - /** - * Get data row list by year and month - * - * @param yearMonth The year and month - * @param tColName Time column name - * @return Data row list - */ - public List getDataByYearMonth(String yearMonth, String tColName) { - int year = Integer.parseInt(yearMonth.substring(0, 4)); - int month = Integer.parseInt(yearMonth.substring(4)); - return this.getDataByYearMonth(year, month, tColName); - } - - /** - * Get data row list by year and month - * - * @param year The year - * @param month The month - * @param tColName Time column name - * @return Data row list - */ - public List getDataByYearMonth(int year, int month, String tColName) { - List rows = new ArrayList<>(); - LocalDateTime ldt; - for (DataRow row : this.getRows()) { - ldt = (LocalDateTime) row.getValue(tColName); - if (ldt.getYear() == year) { - if (ldt.getMonthValue() == month) { - rows.add(row); - } - } - } - - return rows; - } - - /** - * Get data row list by month - * - * @param month The month - * @param tColName Time column name - * @return Data row list - */ - public List getDataByMonth(int month, String tColName) { - List rows = new ArrayList<>(); - LocalDateTime ldt; - for (DataRow row : this.getRows()) { - ldt = (LocalDateTime) row.getValue(tColName); - if (ldt.getMonthValue() == month) { - rows.add(row); - } - } - - return rows; - } - - /** - * Get data row list by day of week - * - * @param dow Day of week - * @param tColName Time column name - * @return Data row list - */ - public List getDataByDayOfWeek(int dow, String tColName) { - dow = dow + 1; - if (dow == 8) { - dow = 1; - } - - List rows = new ArrayList<>(); - LocalDateTime ldt; - for (DataRow row : this.getRows()) { - ldt = (LocalDateTime) row.getValue(tColName); - if (ldt.getDayOfWeek().getValue() == dow) { - rows.add(row); - } - } - - return rows; - } - - /** - * Get data row list by hour - * - * @param hour The hour - * @param tColName Time column name - * @return Result data row list - */ - public List getDataByHour(int hour, String tColName) { - List rows = new ArrayList<>(); - LocalDateTime ldt; - for (DataRow row : this.getRows()) { - ldt = (LocalDateTime) row.getValue(tColName); - if (ldt.getHour() == hour) { - rows.add(row); - } - } - - return rows; - } - - /** - * Average year by year - * - * @param cols The data columns - * @param tColName The time column name - * @return Result data table - * @throws Exception - */ - public DataTable ave_Year(List cols, String tColName) throws Exception { - DataTable rTable = new DataTable(); - rTable.addColumn("Year", DataType.INT); - for (DataColumn col : cols) { - rTable.addColumn(col.getColumnName(), DataType.DOUBLE); - } - - List years = this.getYears(tColName); - for (int year : years) { - DataRow nRow = rTable.addRow(); - nRow.setValue(0, year); - List rows = this.getDataByYear(year, tColName); - for (DataColumn col : cols) { - List values = this.getValidColumnValues(rows, col); - nRow.setValue(col.getColumnName(), Statistics.mean(values)); - } - } - - return rTable; - } - - /** - * Average month by month - * - * @param cols The data columns - * @param tColName Time column name - * @return Result data table - * @throws Exception - */ - public DataTable ave_Month(List cols, String tColName) throws Exception { - DataTable rTable = new DataTable(); - rTable.addColumn("YearMonth", DataType.STRING); - for (DataColumn col : cols) { - rTable.addColumn(col.getColumnName(), DataType.DOUBLE); - } - - List yms = this.getYearMonths(tColName); - for (String ym : yms) { - DataRow nRow = rTable.addRow(); - nRow.setValue(0, ym); - List rows = this.getDataByYearMonth(ym, tColName); - for (DataColumn col : cols) { - List values = this.getValidColumnValues(rows, col); - nRow.setValue(col.getColumnName(), Statistics.mean(values)); - } - } - - return rTable; - } - - /** - * Average monthly - * - * @param cols The data columns - * @param tColName Time column name - * @return Result data table - * @throws Exception - */ - public DataTable ave_MonthOfYear(List cols, String tColName) throws Exception { - DataTable rTable = new DataTable(); - rTable.addColumn("Month", DataType.STRING); - for (DataColumn col : cols) { - rTable.addColumn(col.getColumnName(), DataType.DOUBLE); - } - - List monthNames = Arrays.asList(new String[]{"Jan", "Feb", "Mar", "Apr", "May", - "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}); - List months = new ArrayList<>(); - int i; - for (i = 1; i < 13; i++) { - months.add(i); - } - - i = 0; - for (int month : months) { - DataRow nRow = rTable.addRow(); - nRow.setValue(0, monthNames.get(i)); - List rows = this.getDataByMonth(month, tColName); - for (DataColumn col : cols) { - List values = this.getValidColumnValues(rows, col); - nRow.setValue(col.getColumnName(), Statistics.mean(values)); - } - i++; - } - - return rTable; - } - - /** - * Average seasonal - * - * @param cols The data columns - * @param tColName Time column name - * @return Result data table - * @throws Exception - */ - public DataTable ave_SeasonOfYear(List cols, String tColName) throws Exception { - DataTable rTable = new DataTable(); - rTable.addColumn("Season", DataType.STRING); - for (DataColumn col : cols) { - rTable.addColumn(col.getColumnName(), DataType.DOUBLE); - } - - List seasons = Arrays.asList(new String[]{"Spring", "Summer", "Autumn", "Winter"}); - for (String season : seasons) { - DataRow nRow = rTable.addRow(); - nRow.setValue(0, season); - List rows = this.getDataBySeason(season, tColName); - for (DataColumn col : cols) { - List values = this.getValidColumnValues(rows, col); - nRow.setValue(col.getColumnName(), Statistics.mean(values)); - } - } - - return rTable; - } - - /** - * Average by day of week - * - * @param cols The data columns - * @param tColName Time column name - * @return Result data table - * @throws Exception - */ - public DataTable ave_DayOfWeek(List cols, String tColName) throws Exception { - DataTable rTable = new DataTable(); - rTable.addColumn("Day", DataType.STRING); - for (DataColumn col : cols) { - rTable.addColumn(col.getColumnName(), DataType.DOUBLE); - } - - List dowNames = Arrays.asList(new String[]{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", - "Saturday"}); - List dows = new ArrayList<>(); - dows.add(7); - int i; - for (i = 1; i < 7; i++) { - dows.add(i); - } - - i = 0; - for (int dow : dows) { - DataRow nRow = rTable.addRow(); - nRow.setValue(0, dowNames.get(i)); - List rows = this.getDataByDayOfWeek(dow, tColName); - for (DataColumn col : cols) { - List values = this.getValidColumnValues(rows, col); - nRow.setValue(col.getColumnName(), Statistics.mean(values)); - } - i++; - } - - return rTable; - } - - /** - * Average by hour of day - * - * @param cols The data columns - * @param tColName Time column name - * @return Result data table - * @throws Exception - */ - public DataTable ave_HourOfDay(List cols, String tColName) throws Exception { - DataTable rTable = new DataTable(); - rTable.addColumn("Hour", DataType.INT); - for (DataColumn col : cols) { - rTable.addColumn(col.getColumnName(), DataType.DOUBLE); - } - - List hours = new ArrayList<>(); - for (int i = 0; i < 24; i++) { - hours.add(i); - } - - for (int hour : hours) { - DataRow nRow = rTable.addRow(); - nRow.setValue(0, hour); - List rows = this.getDataByHour(hour, tColName); - for (DataColumn col : cols) { - List values = this.getValidColumnValues(rows, col); - nRow.setValue(col.getColumnName(), Statistics.mean(values)); - } - } - - return rTable; - } - - /** - * SQL select - * @param expression SQL expression - * @return Result TableData - */ - @Override - public TableData sqlSelect(String expression){ - TableData r = new TableData((DataTable)super.sqlSelect(expression)); - return r; - } - - // - - // - } diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/ascii/ASCIIGridDataInfo.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/ascii/ASCIIGridDataInfo.java deleted file mode 100644 index 098c3dd5..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/ascii/ASCIIGridDataInfo.java +++ /dev/null @@ -1,584 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.data.ascii; - -import org.meteoinfo.common.MIMath; -import org.meteoinfo.data.GridData; -import org.meteoinfo.data.meteodata.DataInfo; -import org.meteoinfo.ndarray.Dimension; -import org.meteoinfo.ndarray.DimensionType; -import org.meteoinfo.data.meteodata.IGridDataInfo; -import org.meteoinfo.data.meteodata.Variable; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.meteoinfo.data.GridArray; -import org.meteoinfo.data.meteodata.MeteoDataType; -import org.meteoinfo.ndarray.Array; -import org.meteoinfo.ndarray.DataType; -import org.meteoinfo.ndarray.IndexIterator; -import org.meteoinfo.ndarray.InvalidRangeException; -import org.meteoinfo.ndarray.Range; -import org.meteoinfo.ndarray.Section; -import org.meteoinfo.data.meteodata.Attribute; -import org.meteoinfo.ndarray.util.BigDecimalUtil; - -/** - * - * @author yaqiang - */ -public class ASCIIGridDataInfo extends DataInfo implements IGridDataInfo { - - // - private DataType dataType; - - // - // - /** - * Constructor - */ - public ASCIIGridDataInfo() { - this.setDataType(MeteoDataType.ASCII_Grid); - } - // - // - // - // - - @Override - public void readDataInfo(String fileName) { - try { - this.setFileName(fileName); - - BufferedReader sr = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "utf-8")); - double xllCenter, yllCenter, cellSize, nodata_value; - int ncols, nrows, i; - String aLine; - String[] dataArray; - - aLine = sr.readLine(); - for (i = 1; i <= 5; i++) { - aLine = aLine + " " + sr.readLine(); - } - dataArray = aLine.split("\\s+"); - ncols = Integer.parseInt(dataArray[1]); - nrows = Integer.parseInt(dataArray[3]); - String xll = dataArray[4]; - xllCenter = Double.parseDouble(dataArray[5]); - String yll = dataArray[6]; - yllCenter = Double.parseDouble(dataArray[7]); - cellSize = Double.parseDouble(dataArray[9]); - nodata_value = Double.parseDouble(dataArray[11]); - if (xll.toLowerCase().equals("xllcorner")) { - xllCenter += cellSize * 0.5; - } - if (yll.toLowerCase().equals("yllcorner")) { - yllCenter += cellSize * 0.5; - } - - aLine = sr.readLine(); - aLine = aLine.trim(); - if (aLine.length() > 7 && aLine.substring(0, 7).equalsIgnoreCase("version")){ - aLine = sr.readLine(); - } - dataArray = aLine.split("\\s+"); - boolean isInt = true; - for (String dd : dataArray) { - if (dd.contains(".")) { - isInt = false; - break; - } - } - - this.setMissingValue(nodata_value); - double[] X = new double[ncols]; - X[0] = xllCenter; - for (i = 1; i < ncols; i++) { - X[i] = BigDecimalUtil.add(X[i - 1], cellSize); - } - if (X[ncols - 1] + cellSize - X[0] == 360) { - this.setGlobal(true); - } - - double[] Y = new double[nrows]; - Y[0] = yllCenter; - for (i = 1; i < nrows; i++) { - Y[i] = BigDecimalUtil.add(Y[i-1], cellSize); - } - - this.addAttribute(new Attribute("data_format", "ASCII grid data")); - - Dimension xDim = new Dimension(DimensionType.X); - xDim.setShortName("X"); - xDim.setValues(X); - this.setXDimension(xDim); - this.addDimension(xDim); - Dimension yDim = new Dimension(DimensionType.Y); - yDim.setShortName("Y"); - yDim.setValues(Y); - this.setYDimension(yDim); - this.addDimension(yDim); - - List variables = new ArrayList<>(); - Variable aVar = new Variable(); - aVar.setName("var"); - aVar.addDimension(yDim); - aVar.addDimension(xDim); - aVar.setFillValue(nodata_value); - if (isInt) { - this.dataType = DataType.INT; - } else { - this.dataType = DataType.FLOAT; - } - this.dataType = DataType.FLOAT; - aVar.setDataType(dataType); - aVar.addAttribute(new Attribute("fill_value", this.getMissingValue())); - variables.add(aVar); - this.setVariables(variables); - - sr.close(); - } catch (IOException ex) { - Logger.getLogger(ASCIIGridDataInfo.class.getName()).log(Level.SEVERE, null, ex); - } - } - - /** - * Get global attributes - * - * @return Global attributes - */ - @Override - public List getGlobalAttributes() { - return new ArrayList<>(); - } - - /** - * Read array data of a variable - * - * @param varName Variable name - * @return Array data - */ - @Override - public Array read(String varName) { - Variable var = this.getVariable(varName); - int n = var.getDimNumber(); - int[] origin = new int[n]; - int[] size = new int[n]; - int[] stride = new int[n]; - for (int i = 0; i < n; i++) { - origin[i] = 0; - size[i] = var.getDimLength(i); - stride[i] = 1; - } - - Array r = read(varName, origin, size, stride); - - return r; - } - - /** - * Read array data of the variable - * - * @param varName Variable name - * @param origin The origin array - * @param size The size array - * @param stride The stride array - * @return Array data - */ - @Override - public Array read(String varName, int[] origin, int[] size, int[] stride) { - try { - Section section = new Section(origin, size, stride); - Array dataArray = Array.factory(this.dataType, section.getShape()); - int rangeIdx = 0; - Range yRange = section.getRange(rangeIdx++); - Range xRange = section.getRange(rangeIdx); - //IndexIterator ii = dataArray.getIndexIterator(); - readXY(yRange, xRange, dataArray); - - return dataArray; - } catch (InvalidRangeException ex) { - Logger.getLogger(ASCIIGridDataInfo.class.getName()).log(Level.SEVERE, null, ex); - return null; - } - } - - private void readXY(Range yRange, Range xRange, Array data) { - try { - int xNum = this.getXDimension().getLength(); - int yNum = this.getYDimension().getLength(); - BufferedReader sr = new BufferedReader(new FileReader(new File(this.getFileName()))); - String[] dataArray; - int i, j; - String aLine; - - for (i = 0; i < 6; i++) { - sr.readLine(); - } - - List dataList = new ArrayList<>(); - int row = 0; - int nrow; - int drow = 0; - int idx, ii; - do { - aLine = sr.readLine(); - if (aLine == null) { - break; - } - dataArray = aLine.trim().split("\\s+"); - dataList.addAll(Arrays.asList(dataArray)); - if (row == 0) { - if (!MIMath.isNumeric(dataList.get(0))) { - aLine = sr.readLine(); - dataArray = aLine.trim().split("\\s+"); - dataList = Arrays.asList(dataArray); - } - } - for (i = 0; i < 100; i++) { - if (dataList.size() < xNum) { - aLine = sr.readLine(); - if (aLine == null) { - break; - } - dataArray = aLine.trim().split("\\s+"); - dataList.addAll(Arrays.asList(dataArray)); - } else { - break; - } - } - nrow = yNum - row - 1; - if (nrow >= yRange.first() && nrow <= yRange.last()) { - if ((nrow - yRange.first()) % yRange.stride() == 0) { - idx = (yRange.length() - drow - 1) * xRange.length(); - for (i = xRange.first(); i <= xRange.last(); i += xRange.stride()) { - if (this.dataType == DataType.INT) { - data.setObject(idx, Integer.parseInt(dataList.get(i))); - } else { - data.setObject(idx, Float.parseFloat(dataList.get(i))); - } - idx += 1; - } - drow += 1; - } - } - if (dataList.size() > xNum) { - dataList = dataList.subList(xNum, dataList.size() - 1); - } else { - dataList = new ArrayList<>(); - } - row += 1; - } while (aLine != null); - - sr.close(); - } catch (FileNotFoundException ex) { - Logger.getLogger(ASCIIGridDataInfo.class.getName()).log(Level.SEVERE, null, ex); - } catch (IOException ex) { - Logger.getLogger(ASCIIGridDataInfo.class.getName()).log(Level.SEVERE, null, ex); - } - } - - private void readXY_bak1(Range yRange, Range xRange, IndexIterator ii) { - try { - int xNum = this.getXDimension().getLength(); - BufferedReader sr = new BufferedReader(new FileReader(new File(this.getFileName()))); - String[] dataArray; - int i, j; - String aLine; - - for (i = 0; i < 6; i++) { - sr.readLine(); - } - - List dataList = new ArrayList<>(); - int row = 0; - do { - aLine = sr.readLine(); - if (aLine == null) { - break; - } - dataArray = aLine.trim().split("\\s+"); - dataList.addAll(Arrays.asList(dataArray)); - if (row == 0) { - if (!MIMath.isNumeric(dataList.get(0))) { - aLine = sr.readLine(); - dataArray = aLine.trim().split("\\s+"); - dataList = Arrays.asList(dataArray); - } - } - for (i = 0; i < 100; i++) { - if (dataList.size() < xNum) { - aLine = sr.readLine(); - if (aLine == null) { - break; - } - dataArray = aLine.trim().split("\\s+"); - dataList.addAll(Arrays.asList(dataArray)); - } else { - break; - } - } - if (row >= yRange.first() && row <= yRange.last()) { - if ((row - yRange.first()) % yRange.stride() == 0) { - for (i = xRange.first(); i <= xRange.last(); i += xRange.stride()) { - if (this.dataType == DataType.INT) { - ii.setObjectNext(Integer.parseInt(dataList.get(i))); - } else { - ii.setObjectNext(Float.parseFloat(dataList.get(i))); - } - } - } - } - if (dataList.size() > xNum) { - dataList = dataList.subList(xNum, dataList.size() - 1); - } else { - dataList = new ArrayList<>(); - } - row += 1; - } while (aLine != null); - - sr.close(); - } catch (FileNotFoundException ex) { - Logger.getLogger(ASCIIGridDataInfo.class.getName()).log(Level.SEVERE, null, ex); - } catch (IOException ex) { - Logger.getLogger(ASCIIGridDataInfo.class.getName()).log(Level.SEVERE, null, ex); - } - } - - private void readXY_bak(Range yRange, Range xRange, IndexIterator ii) { - try { - int xNum = this.getXDimension().getLength(); - int yNum = this.getYDimension().getLength(); - float[][] theData = new float[yNum][xNum]; - BufferedReader sr = new BufferedReader(new FileReader(new File(this.getFileName()))); - String[] dataArray; - int i, j; - String aLine; - - for (i = 0; i < 6; i++) { - sr.readLine(); - } - - List dataList = new ArrayList<>(); - int col = 0; - do { - aLine = sr.readLine(); - if (aLine == null) { - break; - } - dataArray = aLine.trim().split("\\s+"); - dataList.addAll(Arrays.asList(dataArray)); - if (col == 0) { - if (!MIMath.isNumeric(dataList.get(0))) { - aLine = sr.readLine(); - dataArray = aLine.trim().split("\\s+"); - dataList = Arrays.asList(dataArray); - } - } - for (i = 0; i < 100; i++) { - if (dataList.size() < xNum) { - aLine = sr.readLine(); - if (aLine == null) { - break; - } - dataArray = aLine.trim().split("\\s+"); - dataList.addAll(Arrays.asList(dataArray)); - } else { - break; - } - } - for (i = 0; i < xNum; i++) { - theData[col][i] = Float.parseFloat(dataList.get(i)); - } - if (dataList.size() > xNum) { - dataList = dataList.subList(xNum, dataList.size() - 1); - } else { - dataList = new ArrayList<>(); - } - col += 1; - } while (aLine != null); - - sr.close(); - - float[] data = new float[yNum * xNum]; - for (i = 0; i < yNum; i++) { - for (j = 0; j < xNum; j++) { - data[i * xNum + j] = theData[yNum - 1 - i][j]; - } - } - - for (int y = yRange.first(); y <= yRange.last(); - y += yRange.stride()) { - for (int x = xRange.first(); x <= xRange.last(); - x += xRange.stride()) { - int index = y * xNum + x; - ii.setFloatNext(data[index]); - } - } - } catch (FileNotFoundException ex) { - Logger.getLogger(ASCIIGridDataInfo.class.getName()).log(Level.SEVERE, null, ex); - } catch (IOException ex) { - Logger.getLogger(ASCIIGridDataInfo.class.getName()).log(Level.SEVERE, null, ex); - } - } - - /** - * Get grid data - * - * @param varName Variable name - * @return Grid data - */ - @Override - public GridArray getGridArray(String varName) { - GridArray ga = new GridArray(); - ga.setData(this.read(varName)); - ga.xArray = this.getXDimension().getValues(); - ga.yArray = this.getYDimension().getValues(); - ga.missingValue = this.getMissingValue(); - - return ga; - } - - @Override - public GridData getGridData_LonLat(int timeIdx, String varName, int levelIdx) { - try { - int xNum = this.getXDimension().getLength(); - int yNum = this.getYDimension().getLength(); - double[][] theData = new double[yNum][xNum]; - BufferedReader sr = new BufferedReader(new FileReader(new File(this.getFileName()))); - String[] dataArray; - int i, j; - String aLine; - - for (i = 0; i < 6; i++) { - sr.readLine(); - } - - List dataList = new ArrayList<>(); - int col = 0; - do { - aLine = sr.readLine(); - if (aLine == null) { - break; - } - dataArray = aLine.trim().split("\\s+"); - dataList.addAll(Arrays.asList(dataArray)); - if (col == 0) { - if (!MIMath.isNumeric(dataList.get(0))) { - aLine = sr.readLine(); - dataArray = aLine.trim().split("\\s+"); - dataList = Arrays.asList(dataArray); - } - } - for (i = 0; i < 100; i++) { - if (dataList.size() < xNum) { - aLine = sr.readLine(); - if (aLine == null) { - break; - } - dataArray = aLine.trim().split("\\s+"); - dataList.addAll(Arrays.asList(dataArray)); - } else { - break; - } - } - for (i = 0; i < xNum; i++) { - theData[col][i] = Double.parseDouble(dataList.get(i)); - } - if (dataList.size() > xNum) { - dataList = dataList.subList(xNum, dataList.size() - 1); - } else { - dataList = new ArrayList<>(); - } - col += 1; - } while (aLine != null); - - sr.close(); - - double[][] newGridData = new double[yNum][xNum]; - for (i = 0; i < yNum; i++) { - for (j = 0; j < xNum; j++) { - newGridData[i][j] = theData[yNum - 1 - i][j]; - } - } - - GridData aGridData = new GridData(); - aGridData.data = newGridData; - aGridData.xArray = this.getXDimension().getValues(); - aGridData.yArray = this.getYDimension().getValues(); - aGridData.missingValue = this.getMissingValue(); - - return aGridData; - } catch (IOException ex) { - Logger.getLogger(ASCIIGridDataInfo.class.getName()).log(Level.SEVERE, null, ex); - return null; - } - } - - @Override - public GridData getGridData_TimeLat(int lonIdx, String varName, int levelIdx) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public GridData getGridData_TimeLon(int latIdx, String varName, int levelIdx) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public GridData getGridData_LevelLat(int lonIdx, String varName, int timeIdx) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public GridData getGridData_LevelLon(int latIdx, String varName, int timeIdx) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public GridData getGridData_LevelTime(int latIdx, String varName, int lonIdx) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public GridData getGridData_Time(int lonIdx, int latIdx, String varName, int levelIdx) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public GridData getGridData_Level(int lonIdx, int latIdx, String varName, int timeIdx) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public GridData getGridData_Lon(int timeIdx, int latIdx, String varName, int levelIdx) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public GridData getGridData_Lat(int timeIdx, int lonIdx, String varName, int levelIdx) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/ascii/LonLatStationDataInfo.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/ascii/LonLatStationDataInfo.java deleted file mode 100644 index 795c1bf8..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/ascii/LonLatStationDataInfo.java +++ /dev/null @@ -1,378 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -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.meteodata.DataInfo; -import org.meteoinfo.data.meteodata.IStationDataInfo; -import org.meteoinfo.data.meteodata.StationInfoData; -import org.meteoinfo.data.meteodata.StationModelData; -import org.meteoinfo.data.meteodata.Variable; - -import java.io.BufferedReader; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.JOptionPane; -import org.meteoinfo.data.meteodata.MeteoDataType; -import org.meteoinfo.common.io.FileCharsetDetector; -import org.meteoinfo.ndarray.Array; -import org.meteoinfo.data.meteodata.Attribute; - - /** - * - * @author yaqiang - */ - public class LonLatStationDataInfo extends DataInfo implements IStationDataInfo { - // - - private List _fields = new ArrayList<>(); - private String delimiter = null; - - //private int lonIdx = 1; - //private int latIdx = 2; - // - // - - /** - * Constructor - */ - public LonLatStationDataInfo() { - this.setDataType(MeteoDataType.LonLatStation); - } - // - // - // - // - - @Override - public void readDataInfo(String fileName) { - BufferedReader sr = null; - try { - this.setFileName(fileName); - FileCharsetDetector chardet = new FileCharsetDetector(); - String charset = chardet.guestFileEncoding(this.getFileName()); - sr = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), charset)); - String[] dataArray, fieldArray; - String aLine = sr.readLine().trim(); //Title - delimiter = GlobalUtil.getDelimiter(aLine); - fieldArray = GlobalUtil.split(aLine, delimiter); - if (fieldArray.length < 4) { - JOptionPane.showMessageDialog(null, "The data should have at least four fields!"); - return; - } - _fields = Arrays.asList(fieldArray); - - //Judge field type - aLine = sr.readLine(); //First line - dataArray = GlobalUtil.split(aLine, delimiter); - List variables = new ArrayList<>(); - for (int i = 3; i < dataArray.length; i++) { - if (MIMath.isNumeric(dataArray[i])) { - Variable var = new Variable(); - var.setName(fieldArray[i]); - var.setStation(true); - variables.add(var); - } - } - this.setVariables(variables); - } catch (FileNotFoundException ex) { - Logger.getLogger(LonLatStationDataInfo.class.getName()).log(Level.SEVERE, null, ex); - } catch (IOException ex) { - Logger.getLogger(LonLatStationDataInfo.class.getName()).log(Level.SEVERE, null, ex); - } finally { - try { - sr.close(); - } catch (IOException ex) { - Logger.getLogger(LonLatStationDataInfo.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - - /** - * Get global attributes - * @return Global attributes - */ - @Override - public List getGlobalAttributes(){ - return new ArrayList<>(); - } - - @Override - public String generateInfoText() { - String dataInfo; - dataInfo = "File Name: " + this.getFileName(); - //dataInfo += System.getProperty("line.separator") + "Station Number: " + StationNum; - dataInfo += System.getProperty("line.separator") + "Fields: "; - for (String aField : _fields) { - dataInfo += System.getProperty("line.separator") + " " + aField; - } - - return dataInfo; - } - - /** - * Read array data of a variable - * - * @param varName Variable name - * @return Array data - */ - @Override - public Array read(String varName){ - return null; - } - - /** - * Read array data of the variable - * - * @param varName Variable name - * @param origin The origin array - * @param size The size array - * @param stride The stride array - * @return Array data - */ - @Override - public Array read(String varName, int[] origin, int[] size, int[] stride) { - return null; - } - - @Override - public StationData getStationData(int timeIdx, String varName, int levelIdx) { - try { - List dataList = new ArrayList<>(); - FileCharsetDetector chardet = new FileCharsetDetector(); - String charset = chardet.guestFileEncoding(this.getFileName()); - BufferedReader sr = new BufferedReader(new InputStreamReader(new FileInputStream(this.getFileName()), charset)); - sr.readLine(); - String line = sr.readLine(); - while (line != null) { - if (line.isEmpty()) { - line = sr.readLine(); - continue; - } - line = line.trim(); - dataList.add(GlobalUtil.split(line, delimiter)); - line = sr.readLine(); - } - sr.close(); - - StationData stationData = new StationData(); - List stations = new ArrayList<>(); - String stName; - int i; - double lon, lat, t; - - String[] dataArray; - double[][] discreteData = new double[dataList.size()][3]; - double minX, maxX, minY, maxY; - minX = 0; - maxX = 0; - minY = 0; - maxY = 0; - - //Get real variable index - int vIdx = _fields.indexOf(varName); - for (i = 0; i < dataList.size(); i++) { - dataArray = dataList.get(i); - stName = dataArray[0]; - lon = Double.parseDouble(dataArray[1]); - lat = Double.parseDouble(dataArray[2]); - if (dataArray.length <= vIdx) { - t = stationData.missingValue; - } else { - if (dataArray[vIdx].isEmpty()) { - t = stationData.missingValue; - } else { - t = Double.parseDouble(dataArray[vIdx]); - } - } - discreteData[i][0] = lon; - discreteData[i][1] = lat; - discreteData[i][2] = t; - stations.add(stName); - - if (i == 0) { - minX = lon; - maxX = minX; - minY = lat; - maxY = minY; - } else { - if (minX > lon) { - minX = lon; - } else if (maxX < lon) { - maxX = lon; - } - if (minY > lat) { - minY = lat; - } else if (maxY < lat) { - maxY = lat; - } - } - } - Extent dataExtent = new Extent(); - dataExtent.minX = minX; - dataExtent.maxX = maxX; - dataExtent.minY = minY; - dataExtent.maxY = maxY; - - stationData.data = discreteData; - stationData.dataExtent = dataExtent; - stationData.stations = stations; - - return stationData; - } catch (FileNotFoundException ex) { - Logger.getLogger(LonLatStationDataInfo.class.getName()).log(Level.SEVERE, null, ex); - return null; - } catch (IOException ex) { - Logger.getLogger(LonLatStationDataInfo.class.getName()).log(Level.SEVERE, null, ex); - return null; - } - } - - @Override - public StationInfoData getStationInfoData(int timeIdx, int levelIdx) { - BufferedReader sr = null; - try { - FileCharsetDetector chardet = new FileCharsetDetector(); - String charset = chardet.guestFileEncoding(this.getFileName()); - sr = new BufferedReader(new InputStreamReader(new FileInputStream(this.getFileName()), charset)); - List> dataList = new ArrayList<>(); - sr.readLine(); - String line = sr.readLine(); - while (line != null) { - if (line.isEmpty()) { - line = sr.readLine(); - continue; - } - line = line.trim(); - List aList = Arrays.asList(GlobalUtil.split(line, delimiter)); - dataList.add(aList); - line = sr.readLine(); - } - sr.close(); - StationInfoData stInfoData = new StationInfoData(); - stInfoData.setDataList(dataList); - stInfoData.setFields(_fields); - stInfoData.setVariables(this.getVariableNames()); - return stInfoData; - } catch (FileNotFoundException ex) { - Logger.getLogger(LonLatStationDataInfo.class.getName()).log(Level.SEVERE, null, ex); - } catch (IOException ex) { - Logger.getLogger(LonLatStationDataInfo.class.getName()).log(Level.SEVERE, null, ex); - } finally { - try { - sr.close(); - } catch (IOException ex) { - Logger.getLogger(LonLatStationDataInfo.class.getName()).log(Level.SEVERE, null, ex); - } - } - return null; - } - - @Override - public StationModelData getStationModelData(int timeIdx, int levelIdx) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - /** - * Get Lon/Lat station data - all data are missing data - * - * @return Null station data - * @throws FileNotFoundException - * @throws UnsupportedEncodingException - */ - public StationData getNullStationData() throws FileNotFoundException, UnsupportedEncodingException, IOException { - BufferedReader sr = new BufferedReader(new InputStreamReader(new FileInputStream(this.getFileName()), "utf-8")); - List dataList = new ArrayList<>(); - sr.readLine(); - String line = sr.readLine(); - while (line != null) { - if (line.isEmpty()) { - line = sr.readLine(); - continue; - } - dataList.add(line.split(",")); - line = sr.readLine(); - } - sr.close(); - - StationData stationData = new StationData(); - List stations = new ArrayList<>(); - String stName; - int i; - double lon, lat; - double t; - t = 0; - - String[] dataArray; - double[][] discreteData = new double[dataList.size()][3]; - double minX, maxX, minY, maxY; - minX = 0; - maxX = 0; - minY = 0; - maxY = 0; - - for (i = 0; i < dataList.size(); i++) { - dataArray = dataList.get(i); - stName = dataArray[0]; - lon = Double.parseDouble(dataArray[1]); - lat = Double.parseDouble(dataArray[2]); - t = stationData.missingValue; - discreteData[i][0] = lon; - discreteData[i][1] = lat; - discreteData[i][2] = t; - stations.add(stName); - - if (i == 0) { - minX = lon; - maxX = minX; - minY = lat; - maxY = minY; - } else { - if (minX > lon) { - minX = lon; - } else if (maxX < lon) { - maxX = lon; - } - if (minY > lat) { - minY = lat; - } else if (maxY < lat) { - maxY = lat; - } - } - } - Extent dataExtent = new Extent(); - dataExtent.minX = minX; - dataExtent.maxX = maxX; - dataExtent.minY = minY; - dataExtent.maxY = maxY; - - stationData.data = discreteData; - stationData.dataExtent = dataExtent; - stationData.stations = stations; - - return stationData; - } - // - } diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/ascii/SurferGridDataInfo.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/ascii/SurferGridDataInfo.java deleted file mode 100644 index e93ffa58..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/ascii/SurferGridDataInfo.java +++ /dev/null @@ -1,355 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.data.meteodata.ascii; - -import org.meteoinfo.geo.data.GridData; -import org.meteoinfo.data.meteodata.DataInfo; -import org.meteoinfo.ndarray.Dimension; -import org.meteoinfo.ndarray.DimensionType; -import org.meteoinfo.data.meteodata.IGridDataInfo; -import org.meteoinfo.data.meteodata.Variable; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.meteoinfo.data.GridArray; -import org.meteoinfo.data.meteodata.MeteoDataType; -import org.meteoinfo.ndarray.Array; -import org.meteoinfo.ndarray.DataType; -import org.meteoinfo.ndarray.IndexIterator; -import org.meteoinfo.ndarray.InvalidRangeException; -import org.meteoinfo.ndarray.Range; -import org.meteoinfo.ndarray.Section; -import org.meteoinfo.data.meteodata.Attribute; - - /** - * - * @author yaqiang - */ - public class SurferGridDataInfo extends DataInfo implements IGridDataInfo { - - // - // - // - - /** - * Constructor - */ - public SurferGridDataInfo() { - this.setDataType(MeteoDataType.Sufer_Grid); - } - // - // - // - // - - @Override - public void readDataInfo(String fileName) { - try { - this.setFileName(fileName); - - BufferedReader sr = new BufferedReader(new FileReader(new File(fileName))); - double xmin, ymin, xmax, ymax, zmin, zmax; - int xnum, ynum, i; - String aLine; - String[] dataArray; - - aLine = sr.readLine().trim(); - for (i = 1; i <= 4; i++) { - aLine = aLine + " " + sr.readLine().trim(); - } - - dataArray = aLine.split("\\s+"); - xnum = Integer.parseInt(dataArray[1]); - ynum = Integer.parseInt(dataArray[2]); - xmin = Double.parseDouble(dataArray[3]); - xmax = Double.parseDouble(dataArray[4]); - ymin = Double.parseDouble(dataArray[5]); - ymax = Double.parseDouble(dataArray[6]); - zmin = Double.parseDouble(dataArray[7]); - zmax = Double.parseDouble(dataArray[8]); - - double xdelt = (xmax - xmin) / (xnum - 1); - double ydelt = (ymax - ymin) / (ynum - 1); - double[] X = new double[xnum]; - for (i = 0; i < xnum; i++) { - X[i] = xmin + i * xdelt; - } - if (X[xnum - 1] + xdelt - X[0] == 360) { - this.setGlobal(true); - } - - double[] Y = new double[ynum]; - for (i = 0; i < ynum; i++) { - Y[i] = ymin + i * ydelt; - } - - Dimension xDim = new Dimension(DimensionType.X); - xDim.setValues(X); - this.setXDimension(xDim); - Dimension yDim = new Dimension(DimensionType.Y); - yDim.setValues(Y); - this.setYDimension(yDim); - - List variables = new ArrayList<>(); - Variable aVar = new Variable(); - aVar.setName("var"); - aVar.addDimension(yDim); - aVar.addDimension(xDim); - variables.add(aVar); - this.setVariables(variables); - - sr.close(); - } catch (IOException ex) { - Logger.getLogger(SurferGridDataInfo.class.getName()).log(Level.SEVERE, null, ex); - } - } - - /** - * Get global attributes - * @return Global attributes - */ - @Override - public List getGlobalAttributes(){ - return new ArrayList<>(); - } - - @Override - public String generateInfoText() { - String dataInfo; - dataInfo = "File Name: " + this.getFileName(); - dataInfo += System.getProperty("line.separator") + "Data Type: Sufer ASCII Grid"; - Dimension xdim = this.getXDimension(); - Dimension ydim = this.getYDimension(); - dataInfo += System.getProperty("line.separator") + "XNum = " + String.valueOf(xdim.getLength()) - + " YNum = " + String.valueOf(ydim.getLength()); - dataInfo += System.getProperty("line.separator") + "XMin = " + String.valueOf(xdim.getValues()[0]) - + " YMin = " + String.valueOf(ydim.getValues()[0]); - dataInfo += System.getProperty("line.separator") + "XSize = " + String.valueOf(xdim.getValues()[1] - xdim.getValues()[0]) - + " YSize = " + String.valueOf(ydim.getValues()[1] - ydim.getValues()[0]); - dataInfo += System.getProperty("line.separator") + "UNDEF = " + String.valueOf(this.getMissingValue()); - - return dataInfo; - } - - /** - * Read array data of a variable - * - * @param varName Variable name - * @return Array data - */ - @Override - public Array read(String varName){ - Variable var = this.getVariable(varName); - int n = var.getDimNumber(); - int[] origin = new int[n]; - int[] size = new int[n]; - int[] stride = new int[n]; - for (int i = 0; i < n; i++){ - origin[i] = 0; - size[i] = var.getDimLength(i); - stride[i] = 1; - } - - Array r = read(varName, origin, size, stride); - - return r; - } - - /** - * Read array data of the variable - * - * @param varName Variable name - * @param origin The origin array - * @param size The size array - * @param stride The stride array - * @return Array data - */ - @Override - public Array read(String varName, int[] origin, int[] size, int[] stride) { - try { - Section section = new Section(origin, size, stride); - Array dataArray = Array.factory(DataType.FLOAT, section.getShape()); - int rangeIdx = 0; - Range yRange = section.getRange(rangeIdx++); - Range xRange = section.getRange(rangeIdx); - IndexIterator ii = dataArray.getIndexIterator(); - readXY(yRange, xRange, ii); - - return dataArray; - } catch (InvalidRangeException ex) { - Logger.getLogger(SurferGridDataInfo.class.getName()).log(Level.SEVERE, null, ex); - return null; - } - } - - private void readXY(Range yRange, Range xRange, IndexIterator ii) { - try { - int xNum = this.getXDimension().getLength(); - int yNum = this.getYDimension().getLength(); - float[] data = new float[yNum * xNum]; - BufferedReader sr = new BufferedReader(new FileReader(new File(this.getFileName()))); - String[] dataArray; - int i, j; - String aLine; - - for (i = 0; i < 5; i++) { - sr.readLine(); - } - - int idx = 0; - aLine = sr.readLine(); - while (aLine != null) { - dataArray = aLine.trim().split("\\s+"); - for (String dstr : dataArray) { - data[idx] = Float.parseFloat(dstr); - idx += 1; - } - aLine = sr.readLine(); - } - sr.close(); - - for (int y = yRange.first(); y <= yRange.last(); - y += yRange.stride()) { - for (int x = xRange.first(); x <= xRange.last(); - x += xRange.stride()) { - int index = y * xNum + x; - ii.setFloatNext(data[index]); - } - } - } catch (FileNotFoundException ex) { - Logger.getLogger(SurferGridDataInfo.class.getName()).log(Level.SEVERE, null, ex); - } catch (IOException ex) { - Logger.getLogger(SurferGridDataInfo.class.getName()).log(Level.SEVERE, null, ex); - } - } - - /** - * Get grid data - * - * @param varName Variable name - * @return Grid data - */ - @Override - public GridArray getGridArray(String varName) { - return null; - } - - @Override - public GridData getGridData_LonLat(int timeIdx, String varName, int levelIdx) { - try { - int xNum = this.getXDimension().getLength(); - int yNum = this.getYDimension().getLength(); - double[][] theData = new double[yNum][xNum]; - BufferedReader sr = new BufferedReader(new FileReader(new File(this.getFileName()))); - String[] dataArray; - int i, j; - String aLine; - - for (i = 0; i < 5; i++) { - sr.readLine(); - } - - int ii, jj; - int d = 0; - aLine = sr.readLine(); - while (aLine != null) { - if (aLine.isEmpty()){ - aLine = sr.readLine(); - continue; - } - dataArray = aLine.trim().split("\\s+"); - for (String dstr : dataArray) { - ii = d / xNum; - jj = d % xNum; - if (ii >= yNum) { - d += 1; - break; - } - if (jj >= xNum) { - d += 1; - break; - } - theData[ii][jj] = Double.parseDouble(dstr); - d += 1; - } - aLine = sr.readLine(); - } - - sr.close(); - - GridData aGridData = new GridData(); - aGridData.data = theData; - aGridData.xArray = this.getXDimension().getValues(); - aGridData.yArray = this.getYDimension().getValues(); - aGridData.missingValue = this.getMissingValue(); - - return aGridData; - } catch (IOException ex) { - Logger.getLogger(SurferGridDataInfo.class.getName()).log(Level.SEVERE, null, ex); - return null; - } - } - - @Override - public GridData getGridData_TimeLat(int lonIdx, String varName, int levelIdx) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public GridData getGridData_TimeLon(int latIdx, String varName, int levelIdx) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public GridData getGridData_LevelLat(int lonIdx, String varName, int timeIdx) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public GridData getGridData_LevelLon(int latIdx, String varName, int timeIdx) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public GridData getGridData_LevelTime(int latIdx, String varName, int lonIdx) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public GridData getGridData_Time(int lonIdx, int latIdx, String varName, int levelIdx) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public GridData getGridData_Level(int lonIdx, int latIdx, String varName, int timeIdx) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public GridData getGridData_Lon(int timeIdx, int latIdx, String varName, int levelIdx) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public GridData getGridData_Lat(int timeIdx, int lonIdx, String varName, int levelIdx) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - // - } diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/FieldType.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/FieldType.java deleted file mode 100644 index d3deaa9a..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/FieldType.java +++ /dev/null @@ -1,80 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.data.geotiff; - -/** - * - * @author yaqiang - */ -public class FieldType { - // - - private static FieldType[] types = new FieldType[20]; - public static final FieldType BYTE = new FieldType("BYTE", 1, 1); - public static final FieldType ASCII = new FieldType("ASCII", 2, 1); - public static final FieldType SHORT = new FieldType("SHORT", 3, 2); - public static final FieldType LONG = new FieldType("LONG", 4, 4); - public static final FieldType RATIONAL = new FieldType("RATIONAL", 5, 8); - public static final FieldType SBYTE = new FieldType("SBYTE", 6, 1); - public static final FieldType UNDEFINED = new FieldType("UNDEFINED", 7, 1); - public static final FieldType SSHORT = new FieldType("SSHORT", 8, 2); - public static final FieldType SLONG = new FieldType("SLONG", 9, 4); - public static final FieldType SRATIONAL = new FieldType("SRATIONAL", 10, 8); - public static final FieldType FLOAT = new FieldType("FLOAT", 11, 4); - public static final FieldType DOUBLE = new FieldType("DOUBLE", 12, 8); - String name; - int code; - int size; - // - // - - /** - * Constructor - * - * @param name Name - * @param code Code - * @param size Size - */ - private FieldType(String name, int code, int size) { - this.name = name; - this.code = code; - this.size = size; - types[code] = this; - } - // - // - // - // - - /** - * Get field type - * - * @param code Field type code - * @return Field type - */ - static FieldType get(int code) { - return types[code]; - } - - /** - * To string - * - * @return String - */ - @Override - public String toString() { - return this.name; - } - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/GeoKey.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/GeoKey.java deleted file mode 100644 index 08f40553..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/GeoKey.java +++ /dev/null @@ -1,404 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.data.geotiff; - -import java.util.HashMap; - -/** - * - * @author yaqiang - */ -public class GeoKey { - // - - boolean isDouble = false; - boolean isString = false; - private int count; - private int[] value; - private double[] dvalue; - private String valueS; - protected Tag tag; - private TagValue tagValue; - private int id; - // - // - - /** - * Constructor - * - * @param tag Tag - * @param tagValue Tag value - */ - GeoKey(Tag tag, TagValue tagValue) { - this.tag = tag; - this.tagValue = tagValue; - this.count = 1; - } - - /** - * Constructor - * - * @param tag Tag - * @param value Value - */ - GeoKey(Tag tag, int value) { - this.tag = tag; - this.value = new int[1]; - this.value[0] = value; - this.count = 1; - } - - /** - * Constructor - * - * @param tag Tag - * @param value Int value array - */ - GeoKey(Tag tag, int[] value) { - this.tag = tag; - this.value = value; - this.count = value.length; - } - - /** - * Constructor - * - * @param tag Tag - * @param value Double value array - */ - GeoKey(Tag tag, double[] value) { - this.tag = tag; - this.dvalue = value; - this.count = value.length; - this.isDouble = true; - } - - /** - * Constructor - * - * @param tag Tag - * @param value Double value - */ - GeoKey(Tag tag, double value) { - this.tag = tag; - this.dvalue = new double[1]; - this.dvalue[0] = value; - this.count = 1; - this.isDouble = true; - } - - /** - * Constructor - * - * @param tag Tag - * @param value String value - */ - GeoKey(Tag tag, String value) { - this.tag = tag; - this.valueS = value; - this.count = 1; - this.isString = true; - } - - /** - * Constructor - * - * @param id Id - * @param v Value - */ - GeoKey(int id, int v) { - this.id = id; - this.count = 1; - - this.tag = Tag.get(id); - this.tagValue = TagValue.get(this.tag, v); - - if (this.tagValue == null) { - this.value = new int[1]; - this.value[0] = v; - } - } - // - // - - /** - * Get count - * - * @return Count - */ - int count() { - return this.count; - } - - /** - * Get tag code - * - * @return Tag code - */ - int tagCode() { - if (this.tag != null) { - return this.tag.code(); - } - return this.id; - } - - /** - * Get value - * - * @return Value - */ - int value() { - if (this.tagValue != null) { - return this.tagValue.value(); - } - return this.value[0]; - } - - /** - * Get value - * - * @param idx Index - * @return Value - */ - int value(int idx) { - if (idx == 0) { - return value(); - } - return this.value[idx]; - } - - /** - * Get double value - * - * @param idx Index - * @return Double value - */ - double valueD(int idx) { - return this.dvalue[idx]; - } - - /** - * Get string value - * - * @return String value - */ - String valueString() { - return this.valueS; - } - // - // - - /** - * To string - * - * @return String - */ - @Override - public String toString() { - StringBuilder sbuf = new StringBuilder(); - if (this.tag != null) { - sbuf.append(new StringBuilder().append(" geoKey = ").append(this.tag).toString()); - } else { - sbuf.append(new StringBuilder().append(" geoKey = ").append(this.id).toString()); - } - if (this.tagValue != null) { - sbuf.append(new StringBuilder().append(" value = ").append(this.tagValue).toString()); - } else { - sbuf.append(" values = "); - - if (this.valueS != null) { - sbuf.append(this.valueS); - } else if (this.isDouble) { - for (int i = 0; i < this.count; i++) { - sbuf.append(new StringBuilder().append(this.dvalue[i]).append(" ").toString()); - } - } else { - for (int i = 0; i < this.count; i++) { - sbuf.append(new StringBuilder().append(this.value[i]).append(" ").toString()); - } - } - } - return sbuf.toString(); - } - // - - static class TagValue - implements Comparable { - - private static HashMap map = new HashMap(); - public static final TagValue ModelType_Projected = new TagValue(Tag.GTModelTypeGeoKey, "Projected", 1); - public static final TagValue ModelType_Geographic = new TagValue(Tag.GTModelTypeGeoKey, "Geographic", 2); - public static final TagValue ModelType_Geocentric = new TagValue(Tag.GTModelTypeGeoKey, "Geocentric", 3); - public static final TagValue RasterType_Area = new TagValue(Tag.GTRasterTypeGeoKey, "Area", 1); - public static final TagValue RasterType_Point = new TagValue(Tag.GTRasterTypeGeoKey, "Point", 2); - public static final TagValue GeographicType_Clarke1866 = new TagValue(Tag.GeographicTypeGeoKey, "Clarke1866", 4008); - public static final TagValue GeographicType_GRS_80 = new TagValue(Tag.GeographicTypeGeoKey, "GRS_80", 4019); - public static final TagValue GeographicType_Sphere = new TagValue(Tag.GeographicTypeGeoKey, "Sphere", 4035); - public static final TagValue GeographicType_NAD83 = new TagValue(Tag.GeographicTypeGeoKey, "GCS_NAD83", 4269); - public static final TagValue GeographicType_WGS_84 = new TagValue(Tag.GeographicTypeGeoKey, "WGS_84", 4326); - public static final TagValue GeographicType_GCS_NAD27 = new TagValue(Tag.GeographicTypeGeoKey, "GCS_NAD27", 4267); - public static final TagValue GeogGeodeticDatum_WGS_84 = new TagValue(Tag.GeogGeodeticDatumGeoKey, "WGS_84", 4326); - public static final TagValue GeogPrimeMeridian_GREENWICH = new TagValue(Tag.GeogPrimeMeridianGeoKey, "Greenwich", 8901); - public static final TagValue ProjectedCSType_UserDefined = new TagValue(Tag.ProjectedCSTypeGeoKey, "UserDefined", 32767); - public static final TagValue ProjCoordTrans_LambertConfConic_2SP = new TagValue(Tag.ProjCoordTransGeoKey, "LambertConfConic_2SP", 8); - public static final TagValue ProjCoordTrans_LambertConfConic_1SP = new TagValue(Tag.ProjCoordTransGeoKey, "LambertConfConic_1SP", 9); - public static final TagValue ProjCoordTrans_Stereographic = new TagValue(Tag.ProjCoordTransGeoKey, "Stereographic", 14); - public static final TagValue ProjCoordTrans_TransverseMercator = new TagValue(Tag.ProjCoordTransGeoKey, "TransverseMercator", 1); - public static final TagValue ProjCoordTrans_AlbersConicalEqualArea = new TagValue(Tag.ProjCoordTransGeoKey, "AlbersConicalEqualArea", 11); - public static final TagValue ProjCoordTrans_AlbersEqualAreaEllipse = new TagValue(Tag.ProjCoordTransGeoKey, "AlbersEqualAreaEllipse", 11); - public static final TagValue ProjCoordTrans_Mercator = new TagValue(Tag.ProjCoordTransGeoKey, "Mercator", 7); - public static final TagValue ProjLinearUnits_METER = new TagValue(Tag.ProjLinearUnitsGeoKey, "Meter", 9001); - public static final TagValue GeogAngularUnits_DEGREE = new TagValue(Tag.GeogAngularUnitsGeoKey, "Degree", 9102); - public static final TagValue GeogGeodeticDatum6267 = new TagValue(Tag.GeogGeodeticDatumGeoKey, "North_American_1927", 6267); - private Tag tag; - private String name; - private int value; - - static TagValue get(Tag tag, int code) { - if (tag == null) { - return null; - } - return (TagValue) map.get(tag.name + code); - } - - private TagValue(Tag tag, String name, int value) { - this.tag = tag; - this.name = name; - this.value = value; - map.put(tag.name + value, this); - } - - public Tag tag() { - return this.tag; - } - - public int value() { - return this.value; - } - - @Override - public String toString() { - return this.value + " (" + this.name + ")"; - } - - @Override - public int compareTo(Object o) { - if (!(o instanceof TagValue)) { - return 0; - } - int ret = this.tag.compareTo(o); - if (ret != 0) { - return ret; - } - return this.value - ((TagValue) o).value; - } - } - - static class Tag - implements Comparable { - - private static HashMap map = new HashMap(); - public static final Tag GTModelTypeGeoKey = new Tag("GTModelTypeGeoKey", 1024); - public static final Tag GTRasterTypeGeoKey = new Tag("GTRasterTypeGeoKey", 1025); - public static final Tag GTCitationGeoKey = new Tag("GTCitationGeoKey", 1026); - public static final Tag GeographicTypeGeoKey = new Tag("GeographicTypeGeoKey", 2048); - public static final Tag GeogCitationGeoKey = new Tag("GeogCitationGeoKey", 2049); - public static final Tag GeogGeodeticDatumGeoKey = new Tag("GeogGeodeticDatumGeoKey", 2050); - public static final Tag GeogPrimeMeridianGeoKey = new Tag("GeogPrimeMeridianGeoKey", 2051); - public static final Tag GeogLinearUnitsGeoKey = new Tag("GeogLinearUnitsGeoKey", 2052); - public static final Tag GeogAngularUnitsGeoKey = new Tag("GeogAngularUnitsGeoKey", 2054); - public static final Tag GeogAngularUnitsSizeGeoKey = new Tag("GeogAngularUnitsSizeGeoKey", 2055); - public static final Tag GeogSemiMajorAxisGeoKey = new Tag("GeogSemiMajorAxisGeoKey", 2056); - public static final Tag GeogSemiMinorAxisGeoKey = new Tag("GeogSemiMinorAxisGeoKey", 2057); - public static final Tag GeogInvFlatteningGeoKey = new Tag("GeogInvFlatteningGeoKey", 2058); - public static final Tag GeogAzimuthUnitsGeoKey = new Tag("GeogAzimuthUnitsGeoKey", 2060); - public static final Tag ProjectedCSTypeGeoKey = new Tag("ProjectedCSTypeGeoKey,", 3072); - public static final Tag PCSCitationGeoKey = new Tag("PCSCitationGeoKey,", 3073); - public static final Tag ProjectionGeoKey = new Tag("ProjectionGeoKey,", 3074); - public static final Tag ProjCoordTransGeoKey = new Tag("ProjCoordTransGeoKey", 3075); - public static final Tag ProjLinearUnitsGeoKey = new Tag("ProjLinearUnitsGeoKey", 3076); - public static final Tag ProjLinearUnitsSizeGeoKey = new Tag("ProjLinearUnitsSizeGeoKey", 3077); - public static final Tag ProjStdParallel1GeoKey = new Tag("ProjStdParallel1GeoKey", 3078); - public static final Tag ProjStdParallel2GeoKey = new Tag("ProjStdParallel2GeoKey", 3079); - public static final Tag ProjNatOriginLongGeoKey = new Tag("ProjNatOriginLongGeoKey", 3080); - public static final Tag ProjNatOriginLatGeoKey = new Tag("ProjNatOriginLatGeoKey", 3081); - public static final Tag ProjFalseEastingGeoKey = new Tag("ProjFalseEastingGeoKey", 3082); - public static final Tag ProjFalseNorthingGeoKey = new Tag("ProjFalseNorthingGeoKey", 3083); - public static final Tag ProjFalseOriginLongGeoKey = new Tag("ProjFalseOriginLongGeoKey", 3084); - public static final Tag ProjFalseOriginLatGeoKey = new Tag("ProjFalseOriginLatGeoKey", 3085); - public static final Tag ProjFalseOriginEastingGeoKey = new Tag("ProjFalseOriginEastingGeoKey", 3086); - public static final Tag ProjFalseOriginNorthingGeoKey = new Tag("ProjFalseOriginNorthingGeoKey", 3087); - public static final Tag ProjCenterLongGeoKey = new Tag("ProjCenterLongGeoKey", 3088); - public static final Tag ProjCenterLatGeoKey = new Tag("ProjCenterLatGeoKey", 3089); - public static final Tag ProjCenterEastingGeoKey = new Tag("ProjCenterEastingGeoKey", 3090); - public static final Tag ProjCenterNorthingGeoKey = new Tag("ProjCenterNorthingGeoKey", 3091); - public static final Tag ProjScaleAtNatOriginGeoKey = new Tag("ProjScaleAtNatOriginGeoKey", 3092); - public static final Tag ProjScaleAtCenterGeoKey = new Tag("ProjScaleAtCenterGeoKey", 3093); - public static final Tag ProjAzimuthAngleGeoKey = new Tag("ProjAzimuthAngleGeoKey", 3094); - public static final Tag ProjStraightVertPoleLongGeoKey = new Tag("ProjStraightVertPoleLongGeoKey", 3095); - public static final Tag VerticalCSTypeGeoKey = new Tag("VerticalCSTypeGeoKey", 4096); - public static final Tag VerticalCitationGeoKey = new Tag("VerticalCitationGeoKey", 4097); - public static final Tag VerticalDatumGeoKey = new Tag("VerticalDatumGeoKey", 4098); - public static final Tag VerticalUnitsGeoKey = new Tag("VerticalUnitsGeoKey", 4099); - public static final Tag GeoKey_ProjCoordTrans = new Tag("GeoKey_ProjCoordTrans", 3075); - public static final Tag GeoKey_ProjStdParallel1 = new Tag("GeoKey_ProjStdParallel1", 3078); - public static final Tag GeoKey_ProjStdParallel2 = new Tag("GeoKey_ProjStdParallel2", 3079); - public static final Tag GeoKey_ProjNatOriginLong = new Tag("GeoKey_ProjNatOriginLong", 3080); - public static final Tag GeoKey_ProjNatOriginLat = new Tag("GeoKey_ProjNatOriginLat", 3081); - public static final Tag GeoKey_ProjCenterLong = new Tag("GeoKey_ProjCenterLong", 3088); - public static final Tag GeoKey_ProjFalseEasting = new Tag("GeoKey_ProjFalseEasting", 3082); - public static final Tag GeoKey_ProjFalseNorthing = new Tag("GeoKey_ProjFalseNorthing", 3083); - public static final Tag GeoKey_ProjFalseOriginLong = new Tag("GeoKey_ProjFalseOriginLong", 3084); - public static final Tag GeoKey_ProjFalseOriginLat = new Tag("GeoKey_ProjFalseOriginLat", 3085); - String name; - int code; - - static Tag get(int code) { - return (Tag) map.get(new Integer(code)); - } - - static Tag getOrMake(int code) { - Tag tag = get(code); - return tag != null ? tag : new Tag(code); - } - - private Tag(String name, int code) { - this.name = name; - this.code = code; - map.put(new Integer(code), this); - } - - Tag(int code) { - this.code = code; - } - - public int code() { - return this.code; - } - - @Override - public String toString() { - return this.code + " (" + this.name + ")"; - } - - @Override - public int compareTo(Object o) { - if (!(o instanceof Tag)) { - return 0; - } - Tag to = (Tag) o; - return this.code - to.code; - } - } -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/GeoTiff.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/GeoTiff.java deleted file mode 100644 index e61cc05d..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/GeoTiff.java +++ /dev/null @@ -1,1531 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.data.geotiff; - -import org.meteoinfo.common.DataConvert; -import org.meteoinfo.geo.data.GridData; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.io.RandomAccessFile; -import java.nio.Buffer; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.FloatBuffer; -import java.nio.channels.FileChannel; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.meteoinfo.geo.data.GridArray; -import org.meteoinfo.geo.data.geotiff.compression.CompressionDecoder; -import org.meteoinfo.geo.data.geotiff.compression.DeflateCompression; -import org.meteoinfo.geo.data.geotiff.compression.LZWCompression; -import org.meteoinfo.math.ArrayMath; -import org.meteoinfo.ndarray.util.BigDecimalUtil; -import org.meteoinfo.geo.projection.KnownCoordinateSystems; -import org.meteoinfo.geo.projection.info.ProjectionInfo; -import org.meteoinfo.ndarray.Array; -import org.meteoinfo.ndarray.DataType; -import org.meteoinfo.ndarray.Index; - -/** - * - * @author yaqiang - */ -public class GeoTiff { - // - - private String filename; - private RandomAccessFile file; - private FileChannel channel; - private List tags = new ArrayList(); - private ByteOrder byteOrder = ByteOrder.BIG_ENDIAN; - private boolean readonly; - private boolean showBytes = false; - private boolean debugRead = false; - private boolean debugReadGeoKey = false; - private boolean showHeaderBytes = false; - private int headerSize = 8; - private int firstIFD = 0; - private int lastIFD = 0; - private int startOverflowData = 0; - private int nextOverflowData = 0; - private List geokeys = new ArrayList(); - // - // - - /** - * Constructor - * - * @param filename File name - */ - public GeoTiff(String filename) { - this.filename = filename; - } - // - // - // - // - - /** - * Close - * - * @throws IOException IOException - */ - public void close() - throws IOException { - if (this.channel != null) { - if (!this.readonly) { - this.channel.force(true); - this.channel.truncate(this.nextOverflowData); - } - this.channel.close(); - } - if (this.file != null) { - this.file.close(); - } - } - - /** - * Add tag - * - * @param ifd IFDEntry - */ - void addTag(IFDEntry ifd) { - this.tags.add(ifd); - } - - /** - * Delete tag - * - * @param ifd IFDEntry - */ - void deleteTag(IFDEntry ifd) { - this.tags.remove(ifd); - } - - /** - * Set transform - * - * @param xStart X start - * @param yStart Y start - * @param xInc X inc - * @param yInc Y inc - */ - void setTransform(double xStart, double yStart, double xInc, double yInc) { - addTag(new IFDEntry(Tag.ModelTiepointTag, FieldType.DOUBLE).setValue(new double[]{0.0D, 0.0D, 0.0D, xStart, yStart, 0.0D})); - - addTag(new IFDEntry(Tag.ModelPixelScaleTag, FieldType.DOUBLE).setValue(new double[]{xInc, yInc, 0.0D})); - } - - /** - * Add geo key - * - * @param geokey Geo key - */ - void addGeoKey(GeoKey geokey) { - this.geokeys.add(geokey); - } - - /** - * Write geo keys - */ - private void writeGeoKeys() { - if (this.geokeys.isEmpty()) { - return; - } - - int extra_chars = 0; - int extra_ints = 0; - int extra_doubles = 0; - for (GeoKey geokey : this.geokeys) { - if (geokey.isDouble) { - extra_doubles += geokey.count(); - } else if (geokey.isString) { - extra_chars += geokey.valueString().length() + 1; - } else if (geokey.count() > 1) { - extra_ints += geokey.count(); - } - } - int n = (this.geokeys.size() + 1) * 4; - int[] values = new int[n + extra_ints]; - double[] dvalues = new double[extra_doubles]; - char[] cvalues = new char[extra_chars]; - int icounter = n; - int dcounter = 0; - int ccounter = 0; - - values[0] = 1; - values[1] = 1; - values[2] = 0; - values[3] = this.geokeys.size(); - int count = 4; - for (GeoKey geokey : this.geokeys) { - values[(count++)] = geokey.tagCode(); - - if (geokey.isDouble) { - values[(count++)] = Tag.GeoDoubleParamsTag.getCode(); - values[(count++)] = geokey.count(); - values[(count++)] = dcounter; - for (int k = 0; k < geokey.count(); k++) { - dvalues[(dcounter++)] = geokey.valueD(k); - } - } else if (geokey.isString) { - String s = geokey.valueString(); - values[(count++)] = Tag.GeoAsciiParamsTag.getCode(); - values[(count++)] = s.length(); - values[(count++)] = ccounter; - for (int k = 0; k < s.length(); k++) { - cvalues[(ccounter++)] = s.charAt(k); - } - cvalues[(ccounter++)] = '\000'; - } else if (geokey.count() > 1) { - values[(count++)] = Tag.GeoKeyDirectoryTag.getCode(); - values[(count++)] = geokey.count(); - values[(count++)] = icounter; - for (int k = 0; k < geokey.count(); k++) { - values[(icounter++)] = geokey.value(k); - } - } else { - values[(count++)] = 0; - values[(count++)] = 1; - values[(count++)] = geokey.value(); - } - } - - addTag(new IFDEntry(Tag.GeoKeyDirectoryTag, FieldType.SHORT).setValue(values)); - if (extra_doubles > 0) { - addTag(new IFDEntry(Tag.GeoDoubleParamsTag, FieldType.DOUBLE).setValue(dvalues)); - } - if (extra_chars > 0) { - addTag(new IFDEntry(Tag.GeoAsciiParamsTag, FieldType.ASCII).setValue(new String(cvalues))); - } - } - - /** - * Write data - * - * @param data Data array - * @param imageNumber Image number - * @return Int - * @throws IOException - */ - int writeData(byte[] data, int imageNumber) throws IOException { - if (this.file == null) { - init(); - } - if (imageNumber == 1) { - this.channel.position(this.headerSize); - } else { - this.channel.position(this.nextOverflowData); - } - ByteBuffer buffer = ByteBuffer.wrap(data); - this.channel.write(buffer); - - if (imageNumber == 1) { - this.firstIFD = (this.headerSize + data.length); - } else { - this.firstIFD = (data.length + this.nextOverflowData); - } - return this.nextOverflowData; - } - - /** - * Write data - * - * @param data Float data array - * @param imageNumber Image number - * @return Int - * @throws IOException - */ - int writeData(float[] data, int imageNumber) throws IOException { - if (this.file == null) { - init(); - } - if (imageNumber == 1) { - this.channel.position(this.headerSize); - } else { - this.channel.position(this.nextOverflowData); - } - - ByteBuffer direct = ByteBuffer.allocateDirect(4 * data.length); - FloatBuffer buffer = direct.asFloatBuffer(); - buffer.put(data); - - this.channel.write(direct); - - if (imageNumber == 1) { - this.firstIFD = (this.headerSize + 4 * data.length); - } else { - this.firstIFD = (4 * data.length + this.nextOverflowData); - } - return this.nextOverflowData; - } - - /** - * Write meta data - * - * @param imageNumber Image number - * @throws IOException - */ - void writeMetadata(int imageNumber) throws IOException { - if (this.file == null) { - init(); - } - - writeGeoKeys(); - - Collections.sort(this.tags); - int start = 0; - if (imageNumber == 1) { - start = writeHeader(this.channel); - } else { - this.channel.position(this.lastIFD); - ByteBuffer buffer = ByteBuffer.allocate(4); - if (this.debugRead) { - System.out.println("position before writing nextIFD= " + this.channel.position() + " IFD is " + this.firstIFD); - } - buffer.putInt(this.firstIFD); - ((Buffer)buffer).flip(); - this.channel.write(buffer); - } - writeIFD(this.channel, this.firstIFD); - } - - /** - * Write header - * - * @param channel File channel - * @return Int - * @throws IOException - */ - private int writeHeader(FileChannel channel) throws IOException { - channel.position(0L); - - ByteBuffer buffer = ByteBuffer.allocate(8); - buffer.put((byte) 77); - buffer.put((byte) 77); - buffer.putShort((short) 42); - buffer.putInt(this.firstIFD); - - ((Buffer)buffer).flip(); - channel.write(buffer); - - return this.firstIFD; - } - - /** - * Init tags - * - * @throws IOException - */ - public void initTags() throws IOException { - this.tags = new ArrayList(); - this.geokeys = new ArrayList(); - } - - /** - * Init - * - * @throws IOException - */ - private void init() throws IOException { - this.file = new RandomAccessFile(this.filename, "rw"); - this.channel = this.file.getChannel(); - if (this.debugRead) { - System.out.println("Opened file to write: '" + this.filename + "', size=" + this.channel.size()); - } - this.readonly = false; - } - - /** - * Write IFD - * - * @param channel File channel - * @param start Start - * @throws IOException - */ - private void writeIFD(FileChannel channel, int start) throws IOException { - channel.position(start); - - ByteBuffer buffer = ByteBuffer.allocate(2); - int n = this.tags.size(); - buffer.putShort((short) n); - ((Buffer)buffer).flip(); - channel.write(buffer); - - start += 2; - this.startOverflowData = (start + 12 * this.tags.size() + 4); - this.nextOverflowData = this.startOverflowData; - - for (IFDEntry elem : this.tags) { - writeIFDEntry(channel, elem, start); - start += 12; - } - - channel.position(this.startOverflowData - 4); - this.lastIFD = (this.startOverflowData - 4); - if (this.debugRead) { - System.out.println("pos before writing nextIFD= " + channel.position()); - } - buffer = ByteBuffer.allocate(4); - buffer.putInt(0); - ((Buffer)buffer).flip(); - channel.write(buffer); - } - - /** - * Write IFDEntry - * - * @param channel File channel - * @param ifd IFDEntry - * @param start Start - * @throws IOException - */ - private void writeIFDEntry(FileChannel channel, IFDEntry ifd, int start) throws IOException { - channel.position(start); - ByteBuffer buffer = ByteBuffer.allocate(12); - - buffer.putShort((short) ifd.tag.getCode()); - buffer.putShort((short) ifd.type.code); - buffer.putInt(ifd.count); - - int size = ifd.count * ifd.type.size; - if (size <= 4) { - int done = writeValues(buffer, ifd); - for (int k = 0; k < 4 - done; k++) { - buffer.put((byte) 0); - } - ((Buffer)buffer).flip(); - channel.write(buffer); - } else { - buffer.putInt(this.nextOverflowData); - ((Buffer)buffer).flip(); - channel.write(buffer); - - channel.position(this.nextOverflowData); - - ByteBuffer vbuffer = ByteBuffer.allocate(size); - writeValues(vbuffer, ifd); - ((Buffer)vbuffer).flip(); - channel.write(vbuffer); - this.nextOverflowData += size; - } - } - - /** - * Write values - * - * @param buffer ByteBuffer - * @param ifd IFDEntry - * @return Int - */ - private int writeValues(ByteBuffer buffer, IFDEntry ifd) { - int done = 0; - - if (ifd.type == FieldType.ASCII) { - return writeSValue(buffer, ifd); - } - if (ifd.type == FieldType.RATIONAL) { - for (int i = 0; i < ifd.count * 2; i++) { - done += writeIntValue(buffer, ifd, ifd.value[i]); - } - } else if (ifd.type == FieldType.FLOAT) { - for (int i = 0; i < ifd.count; i++) { - buffer.putFloat((float) ifd.valueD[i]); - } - done += ifd.count * 4; - } else if (ifd.type == FieldType.DOUBLE) { - for (int i = 0; i < ifd.count; i++) { - buffer.putDouble(ifd.valueD[i]); - } - done += ifd.count * 8; - } else { - for (int i = 0; i < ifd.count; i++) { - done += writeIntValue(buffer, ifd, ifd.value[i]); - } - } - return done; - } - - /** - * Write value - * - * @param buffer ByteBuffer - * @param ifd IFDEntry - * @param v Int value - * @return Int - */ - private int writeIntValue(ByteBuffer buffer, IFDEntry ifd, int v) { - switch (ifd.type.code) { - case 1: - buffer.put((byte) v); - return 1; - case 3: - buffer.putShort((short) v); - return 2; - case 4: - buffer.putInt(v); - return 4; - case 5: - buffer.putInt(v); - return 4; - case 2: - } - return 0; - } - - /** - * Write size value - * - * @param buffer ByteBuffer - * @param ifd IFDEntry - * @return Int - */ - private int writeSValue(ByteBuffer buffer, IFDEntry ifd) { - buffer.put(ifd.valueS.getBytes()); - int size = ifd.valueS.length(); - if (size % 2 == 1) { - size++; - } - return size; - } - - /** - * Read file - * - * @throws IOException - */ - public void read() - throws IOException { - this.file = new RandomAccessFile(this.filename, "r"); - this.channel = this.file.getChannel(); - if (this.debugRead) { - System.out.println("Opened file to read:'" + this.filename + "', size=" + this.channel.size()); - } - this.readonly = true; - - int nextOffset = readHeader(this.channel); - while (nextOffset > 0) { - nextOffset = readIFD(this.channel, nextOffset); - parseGeoInfo(); - } - } - - /** - * Find tag - * - * @param tag Tag - * @return IFDEntry - */ - IFDEntry findTag(Tag tag) { - if (tag == null) { - return null; - } - for (IFDEntry ifd : this.tags) { - if (ifd.tag == tag) { - return ifd; - } - } - return null; - } - - /** - * Read X/Y coordinates - * - * @return X/Y coordinates - */ - public List readXY() { - IFDEntry widthIFD = this.findTag(Tag.ImageWidth); - IFDEntry heightIFD = this.findTag(Tag.ImageLength); - int width = widthIFD.value[0]; - int height = heightIFD.value[0]; - double[] X = new double[width]; - double[] Y = new double[height]; - double minLon, maxLat, xdelta, ydelta; - IFDEntry modelTransformationTag = this.findTag(Tag.ModelTransformationTag); - if (modelTransformationTag != null){ - minLon = modelTransformationTag.valueD[3]; - maxLat = modelTransformationTag.valueD[7]; - xdelta = modelTransformationTag.valueD[0]; - ydelta = -modelTransformationTag.valueD[5]; - } else { - IFDEntry modelTiePointTag = findTag(Tag.ModelTiepointTag); - IFDEntry modelPixelScaleTag = findTag(Tag.ModelPixelScaleTag); - minLon = modelTiePointTag.valueD[3]; - maxLat = modelTiePointTag.valueD[4]; - xdelta = modelPixelScaleTag.valueD[0]; - ydelta = modelPixelScaleTag.valueD[1]; - } - for (int i = 0; i < width; i++) { - X[i] = BigDecimalUtil.add(minLon, BigDecimalUtil.mul(xdelta, i)); - } - for (int i = 0; i < height; i++) { - Y[height - i - 1] = BigDecimalUtil.sub(maxLat, BigDecimalUtil.mul(ydelta, i)); - } - - List xy = new ArrayList<>(); - xy.add(X); - xy.add(Y); - - return xy; - } - - /** - * Get grid data - * - * @return Grid data - */ - public int[][] readData() { - try { - //Grid data values - IFDEntry widthIFD = this.findTag(Tag.ImageWidth); - IFDEntry heightIFD = this.findTag(Tag.ImageLength); - int width = widthIFD.value[0]; - int height = heightIFD.value[0]; - int[] values1d = readData(width, height); - int[][] values = new int[height][width]; - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - values[height - i - 1][j] = values1d[i * width + j]; - } - } - values1d = null; - - return values; - } catch (IOException ex) { - Logger.getLogger(GeoTiff.class.getName()).log(Level.SEVERE, null, ex); - return null; - } - } - - /** - * Get grid data - * - * @return Grid data - */ - public GridArray getGridArray() { - try { - //Grid data values - IFDEntry widthIFD = this.findTag(Tag.ImageWidth); - IFDEntry heightIFD = this.findTag(Tag.ImageLength); - int width = widthIFD.value[0]; - int height = heightIFD.value[0]; - GridArray gData = new GridArray(); - gData.setData(readArray()); - - //Grid data coordinate - double[] X = new double[width]; - double[] Y = new double[height]; - IFDEntry modelTiePointTag = findTag(Tag.ModelTiepointTag); - IFDEntry modelPixelScaleTag = findTag(Tag.ModelPixelScaleTag); - double minLon = modelTiePointTag.valueD[3]; - double maxLat = modelTiePointTag.valueD[4]; - double xdelt = modelPixelScaleTag.valueD[0]; - double ydelt = modelPixelScaleTag.valueD[1]; - for (int i = 0; i < width; i++) { - X[i] = minLon + xdelt * i; - } - for (int i = 0; i < height; i++) { - Y[height - i - 1] = maxLat - ydelt * i; - } - - //gData.data = values; - gData.xArray = X; - gData.yArray = Y; - - //Get missing value - IFDEntry noDataTag = findTag(Tag.GDALNoData); - if (noDataTag != null) { - double missingValue = Double.parseDouble(noDataTag.valueS); - gData.missingValue = missingValue; - } - - //Projection - String projStr = getProjection(); - if (projStr != null) { - gData.projInfo = ProjectionInfo.factory(projStr); - } else { - gData.projInfo = KnownCoordinateSystems.geographic.world.WGS1984; - } - - return gData; - } catch (IOException ex) { - Logger.getLogger(GeoTiff.class.getName()).log(Level.SEVERE, null, ex); - return null; - } - } - - /** - * Get grid data - * - * @return Grid data - */ - public GridData getGridData() { - try { - //Grid data values - IFDEntry widthIFD = this.findTag(Tag.ImageWidth); - IFDEntry heightIFD = this.findTag(Tag.ImageLength); - int width = widthIFD.value[0]; - int height = heightIFD.value[0]; - GridData.Integer gData = new GridData.Integer(height, width); - int[] values1d = readData(width, height); - //int[][] values = new int[height][width]; - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - //values[height - i - 1][j] = values1d[i * width + j]; - gData.setValue(height - i - 1, j, values1d[i * width + j]); - } - } - values1d = null; - - //Grid data coordinate - double[] X = new double[width]; - double[] Y = new double[height]; - IFDEntry modelTiePointTag = findTag(Tag.ModelTiepointTag); - IFDEntry modelPixelScaleTag = findTag(Tag.ModelPixelScaleTag); - double minLon = modelTiePointTag.valueD[3]; - double maxLat = modelTiePointTag.valueD[4]; - double xdelt = modelPixelScaleTag.valueD[0]; - double ydelt = modelPixelScaleTag.valueD[1]; - for (int i = 0; i < width; i++) { - X[i] = minLon + xdelt * i; - } - for (int i = 0; i < height; i++) { - Y[height - i - 1] = maxLat - ydelt * i; - } - - //gData.data = values; - gData.xArray = X; - gData.yArray = Y; - - //Projection - String projStr = getProjection(); - if (projStr != null) { - gData.projInfo = ProjectionInfo.factory(projStr); - } else { - gData.projInfo = KnownCoordinateSystems.geographic.world.WGS1984; - } - - return gData; - } catch (IOException ex) { - Logger.getLogger(GeoTiff.class.getName()).log(Level.SEVERE, null, ex); - return null; - } - } - - /** - * Get grid data - * - * @return Grid data - */ - public GridData getGridData_Value() { - try { - //Grid data values - IFDEntry widthIFD = this.findTag(Tag.ImageWidth); - IFDEntry heightIFD = this.findTag(Tag.ImageLength); - int width = widthIFD.value[0]; - int height = heightIFD.value[0]; - GridData.Integer gData = new GridData.Integer(height, width); - int[] values1d = readData(width, height); - //int[][] values = new int[height][width]; - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - //values[height - i - 1][j] = values1d[i * width + j]; - gData.setValue(height - i - 1, j, values1d[i * width + j]); - } - } - values1d = null; - - return gData; - } catch (IOException ex) { - Logger.getLogger(GeoTiff.class.getName()).log(Level.SEVERE, null, ex); - return null; - } - } - - /** - * Read projection info - * - * @return Projection info - */ - public ProjectionInfo readProj() { - String projStr = getProjection(); - if (projStr != null) { - return ProjectionInfo.factory(projStr); - } else { - return KnownCoordinateSystems.geographic.world.WGS1984; - } - } - - private String getProjection() { - String projStr = null; - IFDEntry geoKeyDirectoryTag = findTag(Tag.GeoKeyDirectoryTag); - if (geoKeyDirectoryTag != null) { - GeoKey gtModelTypeGeoKey = geoKeyDirectoryTag.findGeoKey(GeoKey.Tag.GTModelTypeGeoKey); - if (gtModelTypeGeoKey.value() == 1) { - GeoKey projCoordTrans = geoKeyDirectoryTag.findGeoKey(GeoKey.Tag.GeoKey_ProjCoordTrans); - GeoKey projStdParallel1 = geoKeyDirectoryTag.findGeoKey(GeoKey.Tag.GeoKey_ProjStdParallel1); - double lat_1 = projStdParallel1 == null ? 0 : projStdParallel1.valueD(0); - GeoKey projStdParallel2 = geoKeyDirectoryTag.findGeoKey(GeoKey.Tag.GeoKey_ProjStdParallel2); - double lat_2 = projStdParallel2 == null ? 0 :projStdParallel2.valueD(0); - GeoKey projCenterLong = geoKeyDirectoryTag.findGeoKey(GeoKey.Tag.GeoKey_ProjNatOriginLong); - if (projCenterLong == null){ - projCenterLong = geoKeyDirectoryTag.findGeoKey(GeoKey.Tag.GeoKey_ProjCenterLong); - } - double lon_0 = projCenterLong == null ? 0 : projCenterLong.valueD(0); - GeoKey projNatOriginLat = geoKeyDirectoryTag.findGeoKey(GeoKey.Tag.GeoKey_ProjNatOriginLat); - double lat_0 = projNatOriginLat == null ? 0 : projNatOriginLat.valueD(0); - GeoKey projFalseEasting = geoKeyDirectoryTag.findGeoKey(GeoKey.Tag.GeoKey_ProjFalseEasting); - double x_0 = projFalseEasting == null ? 0 : projFalseEasting.valueD(0); - GeoKey projFalseNorthing = geoKeyDirectoryTag.findGeoKey(GeoKey.Tag.GeoKey_ProjFalseNorthing); - double y_0 = projFalseNorthing == null ? 0 : projFalseNorthing.valueD(0); - GeoKey projScaleAtNatOrigin = geoKeyDirectoryTag.findGeoKey(GeoKey.Tag.ProjScaleAtNatOriginGeoKey); - double k_0 = projScaleAtNatOrigin == null ? 1 : projScaleAtNatOrigin.valueD(0); - switch (projCoordTrans.value()) { - case 1: //Transverse Mercator - projStr = "+proj=tmerc" - + "+lat_0=" + String.valueOf(lat_0) - + "+lon_0=" + String.valueOf(lon_0) - + "+k_0=" + String.valueOf(k_0) - + "+x_0=" + String.valueOf(x_0) - + "+y_0=" + String.valueOf(y_0); - break; - case 11: //AlbersEqualArea - projStr = "+proj=aea" - + "+lat_1=" + String.valueOf(lat_1) - + "+lat_2=" + String.valueOf(lat_2) - + "+lon_0=" + String.valueOf(lon_0) - + "+lat_0=" + String.valueOf(lat_0) - + "+x_0=" + String.valueOf(x_0) - + "+y_0=" + String.valueOf(y_0); - break; - } - } - } - - return projStr; - } - - /** - * Test read data - * - * @param width Width - * @param height Height - * @return Data - * @throws IOException - */ - public int[] readData(int width, int height) throws IOException { - int[] values = new int[width * height]; - IFDEntry bitsPerSampleTag = findTag(Tag.BitsPerSample); - int bitsPerSample = bitsPerSampleTag.value[0]; - IFDEntry tileOffsetTag = findTag(Tag.TileOffsets); - ByteBuffer buffer; - if (tileOffsetTag != null) { - int tileOffset = tileOffsetTag.value[0]; - IFDEntry tileSizeTag = findTag(Tag.TileByteCounts); - IFDEntry tileLengthTag = findTag(Tag.TileLength); - IFDEntry tileWidthTag = findTag(Tag.TileWidth); - int tileWidth = tileWidthTag.value[0]; - int tileHeight = tileLengthTag.value[0]; - int hTileNum = (width + tileWidth - 1) / tileWidth; - int vTileNum = (height + tileHeight - 1) / tileHeight; - int tileSize = tileSizeTag.value[0]; - System.out.println("tileOffset =" + tileOffset + " tileSize=" + tileSize); - int idx; - int tileIdx, vIdx, hIdx; - if (bitsPerSample == 8) { - for (int i = 0; i < vTileNum; i++) { - for (int j = 0; j < hTileNum; j++) { - tileIdx = i * hTileNum + j; - tileOffset = tileOffsetTag.value[tileIdx]; - tileSize = tileSizeTag.value[tileIdx]; - buffer = testReadData(tileOffset, tileSize); - for (int h = 0; h < tileHeight; h++) { - vIdx = i * tileHeight + h; - if (vIdx == height) { - break; - } - for (int w = 0; w < tileWidth; w++) { - hIdx = j * tileWidth + w; - if (hIdx == width) { - break; - } - idx = vIdx * width + hIdx; - values[idx] = buffer.get(); - } - } - } - } - } else if (bitsPerSample == 16) { - for (int i = 0; i < vTileNum; i++) { - for (int j = 0; j < hTileNum; j++) { - tileIdx = i * hTileNum + j; - tileOffset = tileOffsetTag.value[tileIdx]; - tileSize = tileSizeTag.value[tileIdx]; - buffer = testReadData(tileOffset, tileSize); - for (int h = 0; h < tileHeight; h++) { - vIdx = i * tileHeight + h; - if (vIdx == height) { - break; - } - for (int w = 0; w < tileWidth; w++) { - hIdx = j * tileWidth + w; - if (hIdx == width) { - break; - } - idx = vIdx * width + hIdx; - values[idx] = buffer.getShort(); - } - } - } - } - } - } else { - IFDEntry stripOffsetTag = findTag(Tag.StripOffsets); - if (stripOffsetTag != null) { - int stripNum = stripOffsetTag.count; - int stripOffset; - IFDEntry stripSizeTag = findTag(Tag.StripByteCounts); - int stripSize = stripSizeTag.value[0]; - IFDEntry rowsPerStripTag = findTag(Tag.RowsPerStrip); - int rowNum = rowsPerStripTag.value[0]; - //System.out.println("stripOffset =" + stripOffset + " stripSize=" + stripSize); - int n = 0; - for (int i = 0; i < stripNum; i++) { - stripOffset = stripOffsetTag.value[i]; - buffer = testReadData(stripOffset, stripSize); - for (int j = 0; j < width * rowNum; j++) { - values[n] = buffer.getShort(); - n += 1; - } - } - } - } - - return values; - } - - /** - * Get band number - * - * @return Band number - */ - public int getBandNum() { - IFDEntry samplesPerPixelTag = findTag(Tag.SamplesPerPixel); - int samplesPerPixel = samplesPerPixelTag.value[0]; //Number of bands - return samplesPerPixel; - } - - /** - * Test read data - * - * @return Data - * @throws IOException - */ - public Array readArray() throws IOException { - IFDEntry widthIFD = this.findTag(Tag.ImageWidth); - IFDEntry heightIFD = this.findTag(Tag.ImageLength); - int width = widthIFD.value[0]; - int height = heightIFD.value[0]; - IFDEntry samplesPerPixelTag = findTag(Tag.SamplesPerPixel); - int samplesPerPixel = samplesPerPixelTag.value[0]; //Number of bands - //int[] values = new int[width * height]; - IFDEntry bitsPerSampleTag = findTag(Tag.BitsPerSample); - int bitsPerSample = bitsPerSampleTag.value[0]; - int[] shape; - if (samplesPerPixel == 1) { - shape = new int[]{height, width}; - } else { - shape = new int[]{height, width, samplesPerPixel}; - } -// if (samplesPerPixel == 1) { -// shape = new int[]{width, height}; -// } else { -// shape = new int[]{width, height, samplesPerPixel}; -// } - DataType dataType = DataType.INT; - IFDEntry sampleFormatTag = findTag(Tag.SampleFormat); - int sampleFormat = 0; - if (sampleFormatTag != null) { - sampleFormat = sampleFormatTag.value[0]; - } - switch (bitsPerSample) { - case 32: - switch (sampleFormat) { - case 3: - dataType = DataType.FLOAT; - break; - } - break; - } - Array r = Array.factory(dataType, shape); - IFDEntry compressionTag = findTag(Tag.Compression); - CompressionDecoder cDecoder = null; - if (compressionTag != null){ - int compression = compressionTag.value[0]; - if (compression > 1){ - switch (compression) { - case 5: - cDecoder = new LZWCompression(); - break; - case 8: - cDecoder = new DeflateCompression(); - break; - } - } - } - IFDEntry tileOffsetTag = findTag(Tag.TileOffsets); - ByteBuffer buffer; - if (tileOffsetTag != null) { - Index index = r.getIndex(); - int tileOffset; - IFDEntry tileSizeTag = findTag(Tag.TileByteCounts); - IFDEntry tileLengthTag = findTag(Tag.TileLength); - IFDEntry tileWidthTag = findTag(Tag.TileWidth); - int tileWidth = tileWidthTag.value[0]; - int tileHeight = tileLengthTag.value[0]; - int hTileNum = (width + tileWidth - 1) / tileWidth; - int vTileNum = (height + tileHeight - 1) / tileHeight; - int tileSize; - //System.out.println("tileOffset =" + tileOffset + " tileSize=" + tileSize); - int tileIdx, vIdx, hIdx; - switch (bitsPerSample) { - case 8: - for (int i = 0; i < vTileNum; i++) { - for (int j = 0; j < hTileNum; j++) { - tileIdx = i * hTileNum + j; - tileOffset = tileOffsetTag.value[tileIdx]; - tileSize = tileSizeTag.value[tileIdx]; - buffer = testReadData(tileOffset, tileSize); - for (int h = 0; h < tileHeight; h++) { - vIdx = i * tileHeight + h; - if (vIdx == height) { - break; - } - for (int w = 0; w < tileWidth; w++) { - hIdx = j * tileWidth + w; - if (hIdx == width) { - break; - } - index.set0(vIdx); - index.set1(hIdx); - if (samplesPerPixel == 1) { - r.setInt(index, DataConvert.byte2Int(buffer.get())); - } else { - for (int k = 0; k < samplesPerPixel; k++) { - index.set2(k); - r.setInt(index, DataConvert.byte2Int(buffer.get())); - } - } - } - } - } - } - break; - case 16: - for (int i = 0; i < vTileNum; i++) { - for (int j = 0; j < hTileNum; j++) { - tileIdx = i * hTileNum + j; - tileOffset = tileOffsetTag.value[tileIdx]; - tileSize = tileSizeTag.value[tileIdx]; - buffer = testReadData(tileOffset, tileSize); - for (int h = 0; h < tileHeight; h++) { - vIdx = i * tileHeight + h; - if (vIdx == height) { - break; - } - for (int w = 0; w < tileWidth; w++) { - hIdx = j * tileWidth + w; - if (hIdx == width) { - break; - } - index.set0(vIdx); - index.set1(hIdx); - if (samplesPerPixel == 1) { - r.setInt(index, buffer.getShort()); - } else { - for (int k = 0; k < samplesPerPixel; k++) { - index.set2(k); - r.setInt(index, buffer.getShort()); - } - } - } - } - } - } - break; - case 32: - int size = tileHeight * tileWidth * 4; - for (int i = 0; i < vTileNum; i++) { - for (int j = 0; j < hTileNum; j++) { - tileIdx = i * hTileNum + j; - tileOffset = tileOffsetTag.value[tileIdx]; - tileSize = tileSizeTag.value[tileIdx]; - if (tileSize == 0) - continue; - - buffer = testReadData(tileOffset, tileSize); - if (cDecoder != null){ - buffer = ByteBuffer.wrap(cDecoder.decode(buffer.array(), byteOrder)); - if (buffer.limit() < size){ - ByteBuffer nbuffer = ByteBuffer.allocate(size); - nbuffer.put(buffer.array()); - buffer = nbuffer; - ((Buffer)buffer).position(0); - } - buffer.order(byteOrder); - } - for (int h = 0; h < tileHeight; h++) { - vIdx = i * tileHeight + h; - if (vIdx == height) { - break; - } - index.set0(vIdx); - for (int w = 0; w < tileWidth; w++) { - hIdx = j * tileWidth + w; - if (hIdx == width) { - buffer.get(new byte[(tileWidth - w) * 4]); - break; - } - index.set1(hIdx); - if (samplesPerPixel == 1) { - if (dataType == DataType.FLOAT) { - r.setFloat(index, buffer.getFloat()); - } else { - r.setInt(index, buffer.getInt()); - } - } else { - for (int k = 0; k < samplesPerPixel; k++) { - index.set2(k); - if (dataType == DataType.FLOAT) { - r.setFloat(index, buffer.getFloat()); - } else { - r.setInt(index, buffer.getInt()); - } - } - } - } - } - } - } - break; - default: - break; - } - } else { - IFDEntry stripOffsetTag = findTag(Tag.StripOffsets); - if (stripOffsetTag != null) { - int stripNum = stripOffsetTag.count; - int stripOffset; - IFDEntry stripSizeTag = findTag(Tag.StripByteCounts); - int stripSize = stripSizeTag.value[0]; - IFDEntry rowsPerStripTag = findTag(Tag.RowsPerStrip); - int rowNum = rowsPerStripTag.value[0]; - //System.out.println("stripOffset =" + stripOffset + " stripSize=" + stripSize); - int idx = 0; - switch (bitsPerSample) { - case 8: - for (int i = 0; i < stripNum; i++) { - stripOffset = stripOffsetTag.value[i]; - buffer = testReadData(stripOffset, stripSize); - for (int j = 0; j < width * rowNum; j++) { - for (int k = 0; k < samplesPerPixel; k++) { - r.setInt(idx, DataConvert.byte2Int(buffer.get())); - idx += 1; - } - } - } - break; - case 16: - for (int i = 0; i < stripNum; i++) { - stripOffset = stripOffsetTag.value[i]; - buffer = testReadData(stripOffset, stripSize); - for (int j = 0; j < width * rowNum; j++) { - for (int k = 0; k < samplesPerPixel; k++) { - if (dataType == DataType.FLOAT) { - r.setFloat(idx, buffer.getShort()); - } else { - r.setInt(idx, buffer.getShort()); - } - idx += 1; - } - } - } - break; - case 32: - for (int i = 0; i < stripNum; i++) { - stripOffset = stripOffsetTag.value[i]; - stripSize = stripSizeTag.value[i]; - buffer = testReadData(stripOffset, stripSize); - if (cDecoder != null){ - buffer = ByteBuffer.wrap(cDecoder.decode(buffer.array(), byteOrder)); - buffer.order(byteOrder); - } - for (int j = 0; j < width * rowNum; j++) { - for (int k = 0; k < samplesPerPixel; k++) { - r.setFloat(idx, buffer.getFloat()); - idx += 1; - } - } - } - break; - } - } - } - - r = ArrayMath.flip(r, 0); - return r; - } - - /** - * Test read data - * - * @param offset Offset - * @param size Size - * @throws IOException - */ - private ByteBuffer testReadData(int offset, int size) throws IOException { - this.channel.position(offset); - ByteBuffer buffer = ByteBuffer.allocate(size); - buffer.order(this.byteOrder); - - this.channel.read(buffer); - ((Buffer)buffer).flip(); - -// for (int i = 0; i < size / 4; i++) { -// System.out.println(i + ": " + buffer.getFloat()); -// } - return buffer; - } - - /** - * Read header - * - * @param channel File channel - * @return Int - * @throws IOException - */ - private int readHeader(FileChannel channel) throws IOException { - channel.position(0L); - - ByteBuffer buffer = ByteBuffer.allocate(8); - channel.read(buffer); - ((Buffer)buffer).flip(); - if (this.showHeaderBytes) { - printBytes(System.out, "header", buffer, 4); - buffer.rewind(); - } - - byte b = buffer.get(); - if (b == 73) { - this.byteOrder = ByteOrder.LITTLE_ENDIAN; - } - buffer.order(this.byteOrder); - ((Buffer)buffer).position(4); - int firstIFD = buffer.getInt(); - if (this.debugRead) { - System.out.println(" firstIFD == " + firstIFD); - } - - return firstIFD; - } - - /** - * Read IFD - * - * @param channel File channel - * @param start Start - * @return Int - * @throws IOException - */ - private int readIFD(FileChannel channel, int start) throws IOException { - channel.position(start); - - ByteBuffer buffer = ByteBuffer.allocate(2); - buffer.order(this.byteOrder); - - int n = channel.read(buffer); - ((Buffer)buffer).flip(); - if (this.showBytes) { - printBytes(System.out, "IFD", buffer, 2); - buffer.rewind(); - } - short nentries = buffer.getShort(); - if (this.debugRead) { - System.out.println(" nentries = " + nentries); - } - - start += 2; - for (int i = 0; i < nentries; i++) { - IFDEntry ifd = readIFDEntry(channel, start); - if (this.debugRead) { - System.out.println(i + " == " + ifd); - } - - this.tags.add(ifd); - start += 12; - } - - if (this.debugRead) { - System.out.println(" looking for nextIFD at pos == " + channel.position() + " start = " + start); - } - channel.position(start); - buffer = ByteBuffer.allocate(4); - buffer.order(this.byteOrder); - n = channel.read(buffer); - ((Buffer)buffer).flip(); - int nextIFD = buffer.getInt(); - if (this.debugRead) { - System.out.println(" nextIFD == " + nextIFD); - } - return nextIFD; - } - - /** - * Read IFDEntry - * - * @param channel File channel - * @param start Start - * @return IFDEntry - * @throws IOException - */ - private IFDEntry readIFDEntry(FileChannel channel, int start) throws IOException { - if (this.debugRead) { - System.out.println("readIFDEntry starting position to " + start); - } - - channel.position(start); - ByteBuffer buffer = ByteBuffer.allocate(12); - buffer.order(this.byteOrder); - channel.read(buffer); - ((Buffer)buffer).flip(); - if (this.showBytes) { - printBytes(System.out, "IFDEntry bytes", buffer, 12); - } - - ((Buffer)buffer).position(0); - int code = readUShortValue(buffer); - Tag tag = Tag.get(code); - if (tag == null) { - tag = new Tag(code); - } - FieldType type = FieldType.get(readUShortValue(buffer)); - int count = buffer.getInt(); - - IFDEntry ifd = new IFDEntry(tag, type, count); - - if (ifd.count * ifd.type.size <= 4) { - readValues(buffer, ifd); - } else { - int offset = buffer.getInt(); - if (this.debugRead) { - System.out.println("position to " + offset); - } - channel.position(offset); - ByteBuffer vbuffer = ByteBuffer.allocate(ifd.count * ifd.type.size); - vbuffer.order(this.byteOrder); - channel.read(vbuffer); - ((Buffer)vbuffer).flip(); - readValues(vbuffer, ifd); - } - - return ifd; - } - - /** - * Read values - * - * @param buffer ByteBuffer - * @param ifd IFDEntry - */ - private void readValues(ByteBuffer buffer, IFDEntry ifd) { - if (ifd.type == FieldType.ASCII) { - ifd.valueS = readSValue(buffer, ifd); - } else if (ifd.type == FieldType.RATIONAL) { - ifd.value = new int[ifd.count * 2]; - for (int i = 0; i < ifd.count * 2; i++) { - ifd.value[i] = readIntValue(buffer, ifd); - } - } else if (ifd.type == FieldType.FLOAT) { - ifd.valueD = new double[ifd.count]; - for (int i = 0; i < ifd.count; i++) { - ifd.valueD[i] = buffer.getFloat(); - } - } else if (ifd.type == FieldType.DOUBLE) { - ifd.valueD = new double[ifd.count]; - for (int i = 0; i < ifd.count; i++) { - ifd.valueD[i] = buffer.getDouble(); - } - } else { - ifd.value = new int[ifd.count]; - for (int i = 0; i < ifd.count; i++) { - ifd.value[i] = readIntValue(buffer, ifd); - } - } - } - - /** - * Read int vlaue - * - * @param buffer ByteBuffer - * @param ifd IFDEntry - * @return Int value - */ - private int readIntValue(ByteBuffer buffer, IFDEntry ifd) { - switch (ifd.type.code) { - case 1: - return buffer.get(); - case 2: - return buffer.get(); - case 3: - return readUShortValue(buffer); - case 4: - return buffer.getInt(); - case 5: - return buffer.getInt(); - } - return 0; - } - - /** - * Read short vlaue - * - * @param buffer ByteBuffer - * @return Short value - */ - private int readUShortValue(ByteBuffer buffer) { - return buffer.getShort() & 0xFFFF; - } - - /** - * Read string vlaue - * - * @param buffer ByteBuffer - * @param ifd IFDEntry - * @return String value - */ - private String readSValue(ByteBuffer buffer, IFDEntry ifd) { - byte[] dst = new byte[ifd.count]; - buffer.get(dst); - return new String(dst); - } - - /** - * Print bytes - * - * @param ps PrintStream - * @param head Head string - * @param buffer ByteBuffer - * @param n N - */ - private void printBytes(PrintStream ps, String head, ByteBuffer buffer, int n) { - ps.print(head + " == "); - for (int i = 0; i < n; i++) { - byte b = buffer.get(); - int ub = b < 0 ? b + 256 : b; - ps.print(ub + "("); - ps.write(b); - ps.print(") "); - } - ps.println(); - } - - private void parseGeoInfo() { - IFDEntry keyDir = findTag(Tag.GeoKeyDirectoryTag); - IFDEntry dparms = findTag(Tag.GeoDoubleParamsTag); - IFDEntry aparams = findTag(Tag.GeoAsciiParamsTag); - - if (null == keyDir) { - return; - } - - int nkeys = keyDir.value[3]; - if (this.debugReadGeoKey) { - System.out.println("parseGeoInfo nkeys = " + nkeys + " keyDir= " + keyDir); - } - int pos = 4; - - for (int i = 0; i < nkeys; i++) { - int id = keyDir.value[(pos++)]; - int location = keyDir.value[(pos++)]; - int vcount = keyDir.value[(pos++)]; - int offset = keyDir.value[(pos++)]; - - GeoKey.Tag tag = GeoKey.Tag.getOrMake(id); - - GeoKey key = null; - if (location == 0) { - key = new GeoKey(id, offset); - } else { - IFDEntry data = findTag(Tag.get(location)); - if (data == null) { - System.out.println("********ERROR parseGeoInfo: cant find Tag code = " + location); - } else if (data.tag == Tag.GeoDoubleParamsTag) { - double[] dvalue = new double[vcount]; - for (int k = 0; k < vcount; k++) { - dvalue[k] = data.valueD[(offset + k)]; - } - key = new GeoKey(tag, dvalue); - } else if (data.tag == Tag.GeoKeyDirectoryTag) { - int[] value = new int[vcount]; - for (int k = 0; k < vcount; k++) { - value[k] = data.value[(offset + k)]; - } - key = new GeoKey(tag, value); - } else if (data.tag == Tag.GeoAsciiParamsTag) { - String value = data.valueS.substring(offset, offset + vcount); - key = new GeoKey(tag, value); - } - - } - - if (key != null) { - keyDir.addGeoKey(key); - if (this.debugReadGeoKey) { - System.out.println(" yyy add geokey=" + key); - } - } - } - } - - /** - * Show Info - * - * @param out PrintStream - */ - public void showInfo(PrintStream out) { - out.println("Geotiff file= " + this.filename); - for (int i = 0; i < this.tags.size(); i++) { - IFDEntry ifd = (IFDEntry) this.tags.get(i); - out.println(i + " IFDEntry == " + ifd); - } - } - - /** - * Show info - * - * @return Infostring - */ - public String showInfo() { - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - showInfo(new PrintStream(bout)); - return bout.toString(); - } - - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/IFDEntry.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/IFDEntry.java deleted file mode 100644 index fd5d4e5f..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/IFDEntry.java +++ /dev/null @@ -1,236 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.data.geotiff; - -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author yaqiang - */ -public class IFDEntry implements Comparable{ - // - - protected Tag tag; - protected FieldType type; - protected int count; - protected int[] value; - protected double[] valueD; - protected String valueS; - protected List geokeys = null; - // - // - - /** - * Constructor - * - * @param tag Tag - * @param type Field type - */ - IFDEntry(Tag tag, FieldType type) { - this.tag = tag; - this.type = type; - this.count = 1; - } - - /** - * Constructor - * - * @param tag Tag - * @param type Field type - * @param count Count - */ - IFDEntry(Tag tag, FieldType type, int count) { - this.tag = tag; - this.type = type; - this.count = count; - } - // - // - // - // - - /** - * Set value - * - * @param v Value - * @return IFDEntry - */ - public IFDEntry setValue(int v) { - this.value = new int[1]; - this.value[0] = v; - return this; - } - - /** - * Set value - * - * @param n Value 1 - * @param d Value 2 - * @return IFDEntry - */ - public IFDEntry setValue(int n, int d) { - this.value = new int[2]; - this.value[0] = n; - this.value[1] = d; - return this; - } - - /** - * Set value - * - * @param n Value 1 - * @param d Value 2 - * @param f Value 3 - * @return IFDEntry - */ - public IFDEntry setValue(int n, int d, int f) { - this.value = new int[3]; - this.value[0] = n; - this.value[1] = d; - this.value[2] = f; - return this; - } - - /** - * Set value - * - * @param v Value array - * @return IFDEntry - */ - public IFDEntry setValue(int[] v) { - this.count = v.length; - this.value = ((int[]) v.clone()); - return this; - } - - /** - * Set value - * - * @param v Value - * @return IFDEntry - */ - public IFDEntry setValue(double v) { - this.count = 1; - this.valueD = new double[1]; - this.valueD[0] = v; - return this; - } - - /** - * Set vlaue - * - * @param v Value array - * @return IDFEntry - */ - public IFDEntry setValue(double[] v) { - this.count = v.length; - this.valueD = ((double[]) v.clone()); - return this; - } - - /** - * Set value - * - * @param v Value - * @return IFDEntry - */ - public IFDEntry setValue(String v) { - this.count = v.length(); - this.valueS = v; - return this; - } - - /** - * Add GeoKey - * - * @param geokey GeoKey - */ - public void addGeoKey(GeoKey geokey) { - if (this.geokeys == null) { - this.geokeys = new ArrayList(); - } - this.geokeys.add(geokey); - } - - /** - * Find a GeoKey - * @param tag The GeoKey tag - * @return Found GeoKey - */ - public GeoKey findGeoKey(GeoKey.Tag tag){ - for (GeoKey geoKey : this.geokeys){ - if (geoKey.tag == tag) - return geoKey; - } - - return null; - } - - /** - * Compare to - * - * @param o Object - * @return Int - */ - @Override - public int compareTo(Object o) { - return this.tag.compareTo(((IFDEntry) o).tag); - } - - /** - * To string - * - * @return String - */ - @Override - public String toString() { - StringBuilder sbuf = new StringBuilder(); - sbuf.append(new StringBuilder().append(" tag = ").append(this.tag).toString()); - sbuf.append(new StringBuilder().append(" type = ").append(this.type).toString()); - sbuf.append(new StringBuilder().append(" count = ").append(this.count).toString()); - sbuf.append(" values = "); - - if (this.type == FieldType.ASCII) { - sbuf.append(this.valueS); - } else if (this.type == FieldType.RATIONAL) { - for (int i = 0; i < 2; i += 2) { - if (i > 1) { - sbuf.append(", "); - } - sbuf.append(new StringBuilder().append(this.value[i]).append("/").append(this.value[(i + 1)]).toString()); - } - } else if ((this.type == FieldType.DOUBLE) || (this.type == FieldType.FLOAT)) { - for (int i = 0; i < this.count; i++) { - sbuf.append(new StringBuilder().append(this.valueD[i]).append(" ").toString()); - } - } else { - int n = Math.min(this.count, 30); - for (int i = 0; i < n; i++) { - sbuf.append(new StringBuilder().append(this.value[i]).append(" ").toString()); - } - } - if (this.geokeys != null) { - sbuf.append("\n"); - for (int i = 0; i < this.geokeys.size(); i++) { - GeoKey elem = (GeoKey) this.geokeys.get(i); - sbuf.append(new StringBuilder().append(" ").append(elem).append("\n").toString()); - } - } - - return sbuf.toString(); - } - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/Tag.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/Tag.java deleted file mode 100644 index a14795e1..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/Tag.java +++ /dev/null @@ -1,124 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.data.geotiff; - -import java.util.HashMap; - - /** - * - * @author yaqiang - */ - public class Tag implements Comparable { - // - - private static HashMap map = new HashMap(); - public static final Tag NewSubfileType = new Tag("NewSubfileType", 254); - public static final Tag ImageWidth = new Tag("ImageWidth", 256); - public static final Tag ImageLength = new Tag("ImageLength", 257); - public static final Tag BitsPerSample = new Tag("BitsPerSample", 258); - public static final Tag Compression = new Tag("Compression", 259); - public static final Tag PhotometricInterpretation = new Tag("PhotometricInterpretation", 262); - public static final Tag FillOrder = new Tag("FillOrder", 266); - public static final Tag DocumentName = new Tag("DocumentName", 269); - public static final Tag ImageDescription = new Tag("ImageDescription", 270); - public static final Tag StripOffsets = new Tag("StripOffsets", 273); - public static final Tag Orientation = new Tag("Orientation", 274); - public static final Tag SamplesPerPixel = new Tag("SamplesPerPixel", 277); - public static final Tag RowsPerStrip = new Tag("RowsPerStrip", 278); - public static final Tag StripByteCounts = new Tag("StripByteCounts", 279); - public static final Tag XResolution = new Tag("XResolution", 282); - public static final Tag YResolution = new Tag("YResolution", 283); - public static final Tag PlanarConfiguration = new Tag("PlanarConfiguration", 284); - public static final Tag ResolutionUnit = new Tag("ResolutionUnit", 296); - public static final Tag PageNumber = new Tag("PageNumber", 297); - public static final Tag Software = new Tag("Software", 305); - public static final Tag ColorMap = new Tag("ColorMap", 320); - public static final Tag TileWidth = new Tag("TileWidth", 322); - public static final Tag TileLength = new Tag("TileLength", 323); - public static final Tag TileOffsets = new Tag("TileOffsets", 324); - public static final Tag TileByteCounts = new Tag("TileByteCounts", 325); - public static final Tag SampleFormat = new Tag("SampleFormat", 339); - public static final Tag SMinSampleValue = new Tag("SMinSampleValue", 340); - public static final Tag SMaxSampleValue = new Tag("SMaxSampleValue", 341); - public static final Tag ModelPixelScaleTag = new Tag("ModelPixelScaleTag", 33550); - public static final Tag IntergraphMatrixTag = new Tag("IntergraphMatrixTag", 33920); - public static final Tag ModelTiepointTag = new Tag("ModelTiepointTag", 33922); - public static final Tag ModelTransformationTag = new Tag("ModelTransformationTag", 34264); - public static final Tag GeoKeyDirectoryTag = new Tag("GeoKeyDirectoryTag", 34735); - public static final Tag GeoDoubleParamsTag = new Tag("GeoDoubleParamsTag", 34736); - public static final Tag GeoAsciiParamsTag = new Tag("GeoAsciiParamsTag", 34737); - public static final Tag GDALNoData = new Tag("GDALNoDataTag", 42113); - private String name; - private int code; - // - // - - static Tag get(int code) { - return (Tag) map.get(new Integer(code)); - } - - private Tag(String name, int code) { - this.name = name; - this.code = code; - map.put(new Integer(code), this); - } - - Tag(int code) { - this.code = code; - } - // - // - - /** - * Get name - * - * @return Name - */ - public String getName() { - return this.name; - } - - /** - * Get code - * - * @return Code - */ - public int getCode() { - return this.code; - } - // - // - - /** - * To string - * - * @return String - */ - @Override - public String toString() { - return this.code + " (" + this.name + ")"; - } - - /** - * Compare to - * - * @param o Object - * @return Int - */ - @Override - public int compareTo(Object o) { - return this.code - ((Tag) o).getCode(); - } - // - } diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/ByteReader.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/ByteReader.java deleted file mode 100644 index e24febf6..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/ByteReader.java +++ /dev/null @@ -1,394 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.geo.data.geotiff.compression; - -import java.io.UnsupportedEncodingException; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; - -/** - * Read through a byte array - * - * @author osbornb - */ -public class ByteReader { - - /** - * Next byte index to read - */ - private int nextByte = 0; - - /** - * Bytes to read - */ - private final byte[] bytes; - - /** - * Byte order - */ - private ByteOrder byteOrder = null; - - /** - * Constructor - * - * @param bytes bytes - */ - public ByteReader(byte[] bytes) { - this(bytes, ByteOrder.BIG_ENDIAN); - } - - /** - * Constructor - * - * @param bytes bytes - * @param byteOrder byte order - */ - public ByteReader(byte[] bytes, ByteOrder byteOrder) { - this.bytes = bytes; - this.byteOrder = byteOrder; - } - - /** - * Get the next byte to be read - * - * @return next byte to be read - */ - public int getNextByte() { - return nextByte; - } - - /** - * Set the next byte to be read - * - * @param nextByte next byte - */ - public void setNextByte(int nextByte) { - this.nextByte = nextByte; - } - - /** - * Get the byte order - * - * @return byte order - */ - public ByteOrder getByteOrder() { - return byteOrder; - } - - /** - * Set the byte order - * - * @param byteOrder byte order - */ - public void setByteOrder(ByteOrder byteOrder) { - this.byteOrder = byteOrder; - } - - /** - * Check if there is at least one more byte left to read - * - * @return true more bytes left to read - */ - public boolean hasByte() { - return hasBytes(1); - } - - /** - * Check if there is at least one more byte left to read - * - * @param offset byte offset - * @return true more bytes left to read - */ - public boolean hasByte(int offset) { - return hasBytes(offset, 1); - } - - /** - * Check if there are the provided number of bytes left to read - * - * @param count number of bytes - * @return true if has at least the number of bytes left - */ - public boolean hasBytes(int count) { - return hasBytes(nextByte, count); - } - - /** - * Check if there are the provided number of bytes left to read - * - * @param offset byte offset - * @param count number of bytes - * @return true if has at least the number of bytes left - */ - public boolean hasBytes(int offset, int count) { - return offset + count <= bytes.length; - } - - /** - * Read a String from the provided number of bytes - * - * @param num number of bytes - * @return String - * @throws UnsupportedEncodingException - */ - public String readString(int num) throws UnsupportedEncodingException { - String value = readString(nextByte, num); - nextByte += num; - return value; - } - - /** - * Read a String from the provided number of bytes - * - * @param offset byte offset - * @param num number of bytes - * @return String - * @throws UnsupportedEncodingException - */ - public String readString(int offset, int num) - throws UnsupportedEncodingException { - verifyRemainingBytes(offset, num); - String value = null; - if (num != 1 || bytes[offset] != 0) { - value = new String(bytes, offset, num, StandardCharsets.US_ASCII); - } - return value; - } - - /** - * Read a byte - * - * @return byte - */ - public byte readByte() { - byte value = readByte(nextByte); - nextByte++; - return value; - } - - /** - * Read a byte - * - * @param offset byte offset - * @return byte - */ - public byte readByte(int offset) { - verifyRemainingBytes(offset, 1); - byte value = bytes[offset]; - return value; - } - - /** - * Read an unsigned byte - * - * @return unsigned byte as short - */ - public short readUnsignedByte() { - short value = readUnsignedByte(nextByte); - nextByte++; - return value; - } - - /** - * Read an unsigned byte - * - * @param offset byte offset - * @return unsigned byte as short - */ - public short readUnsignedByte(int offset) { - return ((short) (readByte(offset) & 0xff)); - } - - /** - * Read a number of bytes - * - * @param num number of bytes - * @return bytes - */ - public byte[] readBytes(int num) { - byte[] readBytes = readBytes(nextByte, num); - nextByte += num; - return readBytes; - } - - /** - * Read a number of bytes - * - * @param offset byte offset - * @param num number of bytes - * @return bytes - */ - public byte[] readBytes(int offset, int num) { - verifyRemainingBytes(offset, num); - byte[] readBytes = Arrays.copyOfRange(bytes, offset, offset + num); - return readBytes; - } - - /** - * Read a short - * - * @return short - */ - public short readShort() { - short value = readShort(nextByte); - nextByte += 2; - return value; - } - - /** - * Read a short - * - * @param offset byte offset - * @return short - */ - public short readShort(int offset) { - verifyRemainingBytes(offset, 2); - short value = ByteBuffer.wrap(bytes, offset, 2).order(byteOrder) - .getShort(); - return value; - } - - /** - * Read an unsigned short - * - * @return unsigned short as int - */ - public int readUnsignedShort() { - int value = readUnsignedShort(nextByte); - nextByte += 2; - return value; - } - - /** - * Read an unsigned short - * - * @param offset byte offset - * @return unsigned short as int - */ - public int readUnsignedShort(int offset) { - return (readShort(offset) & 0xffff); - } - - /** - * Read an integer - * - * @return integer - */ - public int readInt() { - int value = readInt(nextByte); - nextByte += 4; - return value; - } - - /** - * Read an integer - * - * @param offset byte offset - * @return integer - */ - public int readInt(int offset) { - verifyRemainingBytes(offset, 4); - int value = ByteBuffer.wrap(bytes, offset, 4).order(byteOrder).getInt(); - return value; - } - - /** - * Read an unsigned int - * - * @return unsigned int as long - */ - public long readUnsignedInt() { - long value = readUnsignedInt(nextByte); - nextByte += 4; - return value; - } - - /** - * Read an unsigned int - * - * @param offset byte offset - * @return unsigned int as long - */ - public long readUnsignedInt(int offset) { - return ((long) readInt(offset) & 0xffffffffL); - } - - /** - * Read a float - * - * @return float - */ - public float readFloat() { - float value = readFloat(nextByte); - nextByte += 4; - return value; - } - - /** - * Read a float - * - * @param offset byte offset - * @return float - */ - public float readFloat(int offset) { - verifyRemainingBytes(offset, 4); - float value = ByteBuffer.wrap(bytes, offset, 4).order(byteOrder) - .getFloat(); - return value; - } - - /** - * Read a double - * - * @return double - */ - public double readDouble() { - double value = readDouble(nextByte); - nextByte += 8; - return value; - } - - /** - * Read a double - * - * @param offset byte offset - * @return double - */ - public double readDouble(int offset) { - verifyRemainingBytes(offset, 8); - double value = ByteBuffer.wrap(bytes, offset, 8).order(byteOrder) - .getDouble(); - return value; - } - - /** - * Get the byte length - * - * @return byte length - */ - public int byteLength() { - return bytes.length; - } - - /** - * Verify with the remaining bytes that there are enough remaining to read - * the provided amount - * - * @param offset byte offset - * @param bytesToRead number of bytes to read - */ - private void verifyRemainingBytes(int offset, int bytesToRead) { - if (offset + bytesToRead > bytes.length) { - throw new IllegalStateException( - "No more remaining bytes to read. Total Bytes: " - + bytes.length + ", Byte offset: " + offset - + ", Attempted to read: " + bytesToRead); - } - } - -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/CompressionDecoder.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/CompressionDecoder.java deleted file mode 100644 index 7eaf7657..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/CompressionDecoder.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.geo.data.geotiff.compression; - -import java.nio.ByteOrder; - -/** - * Compression decoder interface - * - * @author osbornb - */ -public interface CompressionDecoder { - - /** - * Decode the bytes - * - * @param bytes bytes to decode - * @param byteOrder byte order - * @return decoded bytes - */ - public byte[] decode(byte[] bytes, ByteOrder byteOrder); - -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/CompressionEncoder.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/CompressionEncoder.java deleted file mode 100644 index e4434918..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/CompressionEncoder.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.geo.data.geotiff.compression; - -import java.nio.ByteOrder; - -/** - * Compression encoder interface. Encode either on a per row or block basis - * - * @author osbornb - */ -public interface CompressionEncoder { - - /** - * True to encode on a per row basis, false to encode on a per block / strip - * basis - * - * @return true for row encoding - */ - public boolean rowEncoding(); - - /** - * Encode the bytes - * - * @param bytes bytes to encode - * @param byteOrder byte order - * @return encoded block of bytes - */ - public byte[] encode(byte[] bytes, ByteOrder byteOrder); - -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/DeflateCompression.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/DeflateCompression.java deleted file mode 100644 index f1a75e2f..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/DeflateCompression.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.geo.data.geotiff.compression; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.nio.ByteOrder; -import java.util.zip.DataFormatException; -import java.util.zip.Deflater; -import java.util.zip.Inflater; - -/** - * - * @author wyq - */ -public class DeflateCompression implements CompressionDecoder, CompressionEncoder { - - @Override - public byte[] decode(byte[] bytes, ByteOrder byteOrder) { - try { - Inflater inflater = new Inflater(); - inflater.setInput(bytes); - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(bytes.length); - byte[] buffer = new byte[1024]; - while (!inflater.finished()) { - int count = inflater.inflate(buffer); - outputStream.write(buffer, 0, count); - } - outputStream.close(); - byte[] output = outputStream.toByteArray(); - - return output; - } catch (IOException e) { - throw new TiffException("Failed close decoded byte stream", e); - } catch (DataFormatException e) { - throw new TiffException("Data format error while decoding stream", e); - } - } - - @Override - public boolean rowEncoding() { - return false; - } - - @Override - public byte[] encode(byte[] bytes, ByteOrder byteOrder) { - try { - Deflater deflater = new Deflater(); - deflater.setInput(bytes); - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(bytes.length); - deflater.finish(); - byte[] buffer = new byte[1024]; - while (!deflater.finished()) { - int count = deflater.deflate(buffer); // returns the generated code... index - outputStream.write(buffer, 0, count); - } - - outputStream.close(); - byte[] output = outputStream.toByteArray(); - return output; - } catch (IOException e) { - throw new TiffException("Failed close encoded stream", e); - } - } -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/LZWCompression.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/LZWCompression.java deleted file mode 100644 index 508064c9..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/LZWCompression.java +++ /dev/null @@ -1,287 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.geo.data.geotiff.compression; - -import java.io.ByteArrayOutputStream; -import java.nio.ByteOrder; -import java.util.HashMap; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * LZW Compression - * - * @author osbornb - */ -public class LZWCompression implements CompressionDecoder, CompressionEncoder { - - /** - * Logger - */ - private static final Logger logger = Logger.getLogger(LZWCompression.class - .getName()); - - /** - * Clear code - */ - private static final int CLEAR_CODE = 256; - - /** - * End of information code - */ - private static final int EOI_CODE = 257; - - /** - * Min bits - */ - private static final int MIN_BITS = 9; - - /** - * Table entries - */ - private Map table = new HashMap<>(); - - /** - * Current max table code - */ - private int maxCode; - - /** - * Current byte length - */ - private int byteLength; - - /** - * Current byte compression position - */ - private int position; - - /** - * {@inheritDoc} - */ - @Override - public byte[] decode(byte[] bytes, ByteOrder byteOrder) { - - // Create the byte reader and decoded stream to write to - ByteReader reader = new ByteReader(bytes, byteOrder); - ByteArrayOutputStream decodedStream = new ByteArrayOutputStream(); - - // Initialize the table, starting position, and old code - initializeTable(); - position = 0; - int oldCode = 0; - - // Read codes until end of input - int code = getNextCode(reader); - while (code != EOI_CODE) { - - // If a clear code - if (code == CLEAR_CODE) { - - // Reset the table - initializeTable(); - - // Read past clear codes - code = getNextCode(reader); - while (code == CLEAR_CODE) { - code = getNextCode(reader); - } - if (code == EOI_CODE) { - break; - } - if (code > CLEAR_CODE) { - throw new TiffException("Corrupted code at scan line: " - + code); - } - - // Write the code value - Integer[] value = table.get(code); - writeValue(decodedStream, value); - oldCode = code; - - } else { - - // If already in the table - Integer[] value = table.get(code); - if (value != null) { - - // Write the code value - writeValue(decodedStream, value); - - // Create new value and add to table - Integer[] newValue = concat(table.get(oldCode), - table.get(code)[0]); - addToTable(newValue); - oldCode = code; - - } else { - - // Create and write new value from old value - Integer[] oldValue = table.get(oldCode); - Integer[] newValue = concat(oldValue, oldValue[0]); - writeValue(decodedStream, newValue); - - // Write value to the table - addToTable(code, newValue); - oldCode = code; - } - } - - // Get the next code - code = getNextCode(reader); - } - - byte[] decoded = decodedStream.toByteArray(); - - return decoded; - } - - /** - * Initialize the table and byte length - */ - private void initializeTable() { - table.clear(); - for (int i = 0; i <= 257; i++) { - table.put(i, new Integer[]{i}); - } - maxCode = 257; - byteLength = MIN_BITS; - } - - /** - * Check the byte length and increase if needed - */ - private void checkByteLength() { - if (maxCode >= Math.pow(2, byteLength) - 2) { - byteLength++; - } - } - - /** - * Add the value to the table - * - * @param value value - */ - private void addToTable(Integer[] value) { - addToTable(maxCode + 1, value); - } - - /** - * Add the code and value to the table - * - * @param code code - * @param value value - */ - private void addToTable(int code, Integer[] value) { - table.put(code, value); - maxCode = Math.max(maxCode, code); - checkByteLength(); - } - - /** - * Concatenate the two values - * - * @param first first value - * @param second second value - * @return concatenated value - */ - private Integer[] concat(Integer[] first, Integer second) { - return concat(first, new Integer[]{second}); - } - - /** - * Concatenate the two values - * - * @param first first value - * @param second second value - * @return concatenated value - */ - private Integer[] concat(Integer[] first, Integer[] second) { - Integer[] combined = new Integer[first.length + second.length]; - System.arraycopy(first, 0, combined, 0, first.length); - System.arraycopy(second, 0, combined, first.length, second.length); - return combined; - } - - /** - * Write the value to the decoded stream - * - * @param decodedStream decoded byte stream - * @param value value - */ - private void writeValue(ByteArrayOutputStream decodedStream, Integer[] value) { - for (int i = 0; i < value.length; i++) { - decodedStream.write(value[i]); - } - } - - /** - * Get the next code - * - * @param reader byte reader - * @return code - */ - private int getNextCode(ByteReader reader) { - int nextByte = getByte(reader); - position += byteLength; - return nextByte; - } - - /** - * Get the next byte - * - * @param reader byte reader - * @return byte - */ - private int getByte(ByteReader reader) { - - int d = position % 8; - int a = (int) Math.floor(position / 8.0); - int de = 8 - d; - int ef = (position + byteLength) - ((a + 1) * 8); - int fg = 8 * (a + 2) - (position + byteLength); - int dg = (a + 2) * 8 - position; - fg = Math.max(0, fg); - if (a >= reader.byteLength()) { - logger.log(Level.WARNING, - "End of data reached without an end of input code"); - return EOI_CODE; - } - int chunk1 = ((int) reader.readUnsignedByte(a)) - & ((int) (Math.pow(2, 8 - d) - 1)); - chunk1 = chunk1 << (byteLength - de); - int chunks = chunk1; - if (a + 1 < reader.byteLength()) { - int chunk2 = reader.readUnsignedByte(a + 1) >>> fg; - chunk2 = chunk2 << Math.max(0, byteLength - dg); - chunks += chunk2; - } - if (ef > 8 && a + 2 < reader.byteLength()) { - int hi = (a + 3) * 8 - (position + byteLength); - int chunk3 = reader.readUnsignedByte(a + 2) >>> hi; - chunks += chunk3; - } - return chunks; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean rowEncoding() { - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public byte[] encode(byte[] bytes, ByteOrder byteOrder) { - throw new TiffException("LZW encoder is not yet implemented"); - } - -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/TiffException.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/TiffException.java deleted file mode 100644 index a2b3da46..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/geotiff/compression/TiffException.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.geo.data.geotiff.compression; - -/** - * TIFF exception - * - * @author osbornb - */ -public class TiffException extends RuntimeException { - - /** - * Serial version id - */ - private static final long serialVersionUID = 1L; - - /** - * Constructor - */ - public TiffException() { - super(); - } - - /** - * Constructor - * - * @param message - */ - public TiffException(String message) { - super(message); - } - - /** - * Constructor - * - * @param message - * @param throwable - */ - public TiffException(String message, Throwable throwable) { - super(message, throwable); - } - - /** - * Constructor - * - * @param throwable - */ - public TiffException(Throwable throwable) { - super(throwable); - } - -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/mapdata/MapDataType.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/mapdata/MapDataType.java deleted file mode 100644 index fb259b9a..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/mapdata/MapDataType.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.geo.data.mapdata; - -/** - * - * @author Yaqiang Wang - */ -public enum MapDataType { - SHAPE, - WMP, - IMAGE, - GEO_TIFF, - BIL, - GRADS, - ESRI_ASCII_GRID, - SURFER_ASCII_GRID, -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/mapdata/ShapeFileManage.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/mapdata/ShapeFileManage.java deleted file mode 100644 index f778ed5e..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/mapdata/ShapeFileManage.java +++ /dev/null @@ -1,1033 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.data.mapdata; - - import org.meteoinfo.common.Extent; - import org.meteoinfo.common.PointD; - import org.meteoinfo.common.io.EndianDataOutputStream; - import org.meteoinfo.geo.layer.VectorLayer; - import org.meteoinfo.geo.layer.LayerDrawType; - import org.meteoinfo.geo.util.LegendManage; - import org.meteoinfo.geo.projection.info.ProjectionInfo; - import org.meteoinfo.geometry.shape.Shape; - import org.meteoinfo.geometry.shape.*; - import org.meteoinfo.table.AttributeTable; - - import java.awt.*; - import java.io.*; - import java.nio.Buffer; - import java.nio.ByteBuffer; - import java.nio.ByteOrder; - import java.util.ArrayList; - import java.util.List; - import java.util.logging.Level; - import java.util.logging.Logger; - - /** - * Shape file read and write - * - * @author yaqiang - */ - public class ShapeFileManage { - - private final static String ENCODING = "UTF-8"; - - /** - * Load shape file - * - * @param shpfilepath Shape file path - * @return Vector layer - * @throws IOException - * @throws FileNotFoundException - */ - public static VectorLayer loadShapeFile(String shpfilepath) throws IOException, FileNotFoundException, Exception { - String cpgfilepath = shpfilepath.replaceFirst(shpfilepath.substring(shpfilepath.lastIndexOf(".")), ".cpg"); - File cpgFile = new File(cpgfilepath); - String encoding = ENCODING; - if (cpgFile.exists()){ - BufferedReader sr = new BufferedReader(new FileReader(cpgFile)); - String ec = sr.readLine().trim(); - sr.close(); - encoding = ec; - } - return loadShapeFile(shpfilepath, encoding); - } - - /** - * Load shape file - * - * @param shpfilepath Shape file path - * @param encoding Encoding - * @return Vector layer - * @throws IOException - * @throws FileNotFoundException - */ - public static VectorLayer loadShapeFile(String shpfilepath, String encoding) throws IOException, FileNotFoundException, Exception { - //Set file names - String shxfilepath = shpfilepath.replace(shpfilepath.substring(shpfilepath.lastIndexOf(".")), ".shx"); - String dbffilepath = shpfilepath.replace(shpfilepath.substring(shpfilepath.lastIndexOf(".")), ".dbf"); - String projfilepath = shpfilepath.replace(shpfilepath.substring(shpfilepath.lastIndexOf(".")), ".prj"); - File shpFile = new File(shpfilepath); - File dbfFile = new File(dbffilepath); - File shxFile = new File(shxfilepath); - File prjFile = new File(projfilepath); - if (!shxFile.exists()) { - shxfilepath = shxfilepath.replace(".shx", ".SHX"); - shxFile = new File(shxfilepath); - } - if (!dbfFile.exists()) { - dbffilepath = dbffilepath.replace(".dbf", ".DBF"); - dbfFile = new File(dbffilepath); - } - if (!prjFile.exists()) { - projfilepath = projfilepath.replace(".prj", ".PRJ"); - prjFile = new File(projfilepath); - } - - //Read shx file - if ("".equals(shxfilepath)) { - // MessageBox.Show("Open shx file error"); - return null; - } - - long BytesSum = shxFile.length(); //Get file byte length - int shapeNum = (int) (BytesSum - 100) / 8; //Get total number of records - loadShxFile(shxFile); - - //Open shp file - DataInputStream br = new DataInputStream(new BufferedInputStream(new FileInputStream(shpFile))); - VectorLayer aLayer; - //byte[] arr = new byte[(int)shpFile.length()]; - byte[] arr = new byte[100]; - br.read(arr); - ByteBuffer buffer = ByteBuffer.wrap(arr); - buffer.order(ByteOrder.LITTLE_ENDIAN); - ((Buffer)buffer).position(32); - //br.skipBytes(32); //先读出36个字节,紧接着是Box边界合 - int aShapeType = buffer.getInt(); - ShapeTypes aST = ShapeTypes.valueOf(aShapeType); - //aLayer = new VectorLayer(aST); - Extent aExtent = new Extent(); - aExtent.minX = buffer.getDouble(); //读出整个shp图层的边界合 - aExtent.minY = buffer.getDouble(); - aExtent.maxX = buffer.getDouble(); - aExtent.maxY = buffer.getDouble(); - - //br.skipBytes(32); // shp中尚未使用的边界盒 - //buffer.position(buffer.position() + 32); - - //Get Shape Data - switch (aST) { - case Point://single point - aLayer = readPointShapes(br, shapeNum); - break; - case PointZ: - aLayer = readPointZShapes(br, shapeNum); - break; - case Polyline: //Polyline layer - aLayer = readPolylineShapes(br, shapeNum); - break; - case PolylineZ: - aLayer = readPolylineZShapes(br, shapeNum); - break; - case Polygon: //Polygon layer - aLayer = readPolygonShapes(br, shapeNum); - break; - case PolygonM: - aLayer = readPolygonMShapes(br, shapeNum); - break; - case PolygonZ: - aLayer = readPolygonZShapes(br, shapeNum); - break; - default: - System.out.println("The shape type is not supported: " + aST.toString()); - return null; - } - br.close(); - - if (aLayer != null) { - aLayer.setExtent(aExtent); - - //Layer property - aLayer.setLayerDrawType(LayerDrawType.Map); - aLayer.setFileName(shpfilepath); - aLayer.setLayerName(shpFile.getName()); - aLayer.setVisible(true); - - //read out the layer attribute information - AttributeTable attrTable = loadDbfFile(shpfilepath, encoding); - aLayer.setAttributeTable(attrTable); - - //Get projection information - if (prjFile.exists()) { - aLayer.setProjInfo(loadProjFile(prjFile)); - } - } - - return aLayer; - - } - - private static void readHeader(DataInputStream br) throws IOException { - int i; - - int FileCode = swapByteOrder(br.readInt()); - for (i = 0; i < 5; i++) { - br.readInt(); - } - int FileLength = swapByteOrder(br.readInt()); - int Version = br.readInt(); - int aShapeType = br.readInt(); - Extent aExtent = new Extent(); - aExtent.minX = br.readDouble(); - aExtent.minY = br.readDouble(); - aExtent.maxX = br.readDouble(); - aExtent.maxY = br.readDouble(); - for (i = 0; i < 4; i++) { - br.readDouble(); - } - } - - private static VectorLayer readPointShapes(DataInputStream br, int shapeNum) throws IOException { - int RecordNum, ContentLength, aShapeType; - double x, y; - VectorLayer aLayer = new VectorLayer(ShapeTypes.Point); - byte[] bytes = new byte[28 * shapeNum]; - br.read(bytes); - ByteBuffer buffer = ByteBuffer.wrap(bytes); - - for (int i = 0; i < shapeNum; i++) { - - //br.ReadBytes(12); //记录头8个字节和一个int(4个字节)的shapetype - buffer.order(ByteOrder.BIG_ENDIAN); - RecordNum = buffer.getInt(); - ContentLength = buffer.getInt(); - - buffer.order(ByteOrder.LITTLE_ENDIAN); - aShapeType = buffer.getInt(); - - x = buffer.getDouble(); - y = buffer.getDouble(); - - PointShape aP = new PointShape(); - PointD aPoint = new PointD(); - aPoint.X = x; - aPoint.Y = y; - aP.setPoint(aPoint); - aLayer.addShape(aP); - } - - //Create legend scheme - aLayer.setLegendScheme(LegendManage.createSingleSymbolLegendScheme(ShapeTypes.Point, Color.black, 5)); - return aLayer; - } - - private static VectorLayer readPointZShapes(DataInputStream br, int shapeNum) throws IOException { - int RecordNum, ContentLength, aShapeType; - double x, y, z, m; - VectorLayer aLayer = new VectorLayer(ShapeTypes.PointZ); - byte[] bytes = new byte[44 * shapeNum]; - br.read(bytes); - ByteBuffer buffer = ByteBuffer.wrap(bytes); - - for (int i = 0; i < shapeNum; i++) { - - //br.ReadBytes(12); //记录头8个字节和一个int(4个字节)的shapetype - buffer.order(ByteOrder.BIG_ENDIAN); - RecordNum = buffer.getInt(); - ContentLength = buffer.getInt(); - - buffer.order(ByteOrder.LITTLE_ENDIAN); - aShapeType = buffer.getInt(); - - x = buffer.getDouble(); - y = buffer.getDouble(); - z = buffer.getDouble(); - m = buffer.getDouble(); - - PointZShape aP = new PointZShape(); - PointZ aPoint = new PointZ(); - aPoint.X = x; - aPoint.Y = y; - aPoint.Z = z; - aPoint.M = m; - aP.setPoint(aPoint); - aLayer.addShape(aP); - } - - //Create legend scheme - aLayer.setLegendScheme(LegendManage.createSingleSymbolLegendScheme(ShapeTypes.Point, Color.black, 5)); - return aLayer; - } - - private static VectorLayer readPolylineShapes(DataInputStream br, int shapeNum) throws IOException { - VectorLayer aLayer = new VectorLayer(ShapeTypes.Polyline); - int RecordNum, ContentLength, aShapeType; - double x, y; - byte[] bytes; - ByteBuffer buffer; - - //PointD aPoint; - for (int i = 0; i < shapeNum; i++) { - bytes = new byte[8]; - br.read(bytes); - buffer = ByteBuffer.wrap(bytes); - //br.skipBytes(12); - buffer.order(ByteOrder.BIG_ENDIAN); - RecordNum = buffer.getInt(); - ContentLength = buffer.getInt(); - - bytes = new byte[ContentLength * 2]; - br.read(bytes); - buffer = ByteBuffer.wrap(bytes); - buffer.order(ByteOrder.LITTLE_ENDIAN); - aShapeType = buffer.getInt(); - - PolylineShape aPL = new PolylineShape(); - Extent extent = new Extent(); - extent.minX = buffer.getDouble(); - extent.minY = buffer.getDouble(); - extent.maxX = buffer.getDouble(); - extent.maxY = buffer.getDouble(); - aPL.setExtent(extent); - - aPL.setPartNum(buffer.getInt()); - int numPoints = buffer.getInt(); - aPL.parts = new int[aPL.getPartNum()]; - List points = new ArrayList<>(); - - //firstly read out parts begin pos in file - for (int j = 0; j < aPL.getPartNum(); j++) { - aPL.parts[j] = buffer.getInt(); - } - - //read out coordinates - for (int j = 0; j < numPoints; j++) { - x = buffer.getDouble(); - y = buffer.getDouble(); - PointD aPoint = new PointD(); - aPoint.X = x; - aPoint.Y = y; - points.add(aPoint); - } - aPL.setPoints(points); - aLayer.addShape(aPL); - } - - //Create legend scheme - aLayer.setLegendScheme(LegendManage.createSingleSymbolLegendScheme(ShapeTypes.Polyline, Color.darkGray, 1.0F)); - - return aLayer; - } - - private static VectorLayer readPolylineZShapes(DataInputStream br, int shapeNum) throws IOException { - VectorLayer aLayer = new VectorLayer(ShapeTypes.PolylineZ); - int RecordNum, ContentLength, aShapeType; - double x, y; - byte[] bytes; - ByteBuffer buffer; - - //PointD aPoint; - for (int i = 0; i < shapeNum; i++) { - //br.skipBytes(12); - bytes = new byte[8]; - br.read(bytes); - buffer = ByteBuffer.wrap(bytes); - //br.skipBytes(12); - buffer.order(ByteOrder.BIG_ENDIAN); - RecordNum = buffer.getInt(); - ContentLength = buffer.getInt(); - - bytes = new byte[ContentLength * 2]; - br.read(bytes); - buffer = ByteBuffer.wrap(bytes); - buffer.order(ByteOrder.LITTLE_ENDIAN); - aShapeType = buffer.getInt(); - - //Read bounding box - PolylineZShape aPL = new PolylineZShape(); - Extent extent = new Extent(); - extent.minX = buffer.getDouble(); - extent.minY = buffer.getDouble(); - extent.maxX = buffer.getDouble(); - extent.maxY = buffer.getDouble(); - aPL.setExtent(extent); - - aPL.setPartNum(buffer.getInt()); - int numPoints = buffer.getInt(); - aPL.parts = new int[aPL.getPartNum()]; - List points = new ArrayList<>(); - - //firstly read out parts begin position in file - for (int j = 0; j < aPL.getPartNum(); j++) { - aPL.parts[j] = buffer.getInt(); - } - - //read out coordinates - for (int j = 0; j < numPoints; j++) { - x = buffer.getDouble(); - y = buffer.getDouble(); - PointD aPoint = new PointD(); - aPoint.X = x; - aPoint.Y = y; - points.add(aPoint); - } - //aPL.Points = points; - - //Read Z - double zmin = buffer.getDouble(); - double zmax = buffer.getDouble(); - double[] zArray = new double[numPoints]; - for (int j = 0; j < numPoints; j++) { - zArray[j] = buffer.getDouble(); - } - - //Read measure - double mmin = buffer.getDouble(); - double mmax = buffer.getDouble(); - double[] mArray = new double[numPoints]; - for (int j = 0; j < numPoints; j++) { - mArray[j] = buffer.getDouble(); - } - - //Get pointZ list - List pointZs = new ArrayList<>(); - for (int j = 0; j < numPoints; j++) { - pointZs.add(new PointZ(points.get(j).X, points.get(j).Y, zArray[j], mArray[j])); - } - - aPL.setPoints(pointZs); - aLayer.addShape(aPL); - } - - //Create legend scheme - aLayer.setLegendScheme(LegendManage.createSingleSymbolLegendScheme(ShapeTypes.Polyline, Color.darkGray, 1.0F)); - - return aLayer; - } - - private static VectorLayer readPolygonShapes(DataInputStream br, int shapeNum) throws IOException { - VectorLayer aLayer = new VectorLayer(ShapeTypes.Polygon); - int RecordNum, ContentLength, aShapeType; - double x, y; - byte[] bytes; - ByteBuffer buffer; - - for (int i = 0; i < shapeNum; i++) { - //br.skipBytes(12); - bytes = new byte[8]; - br.read(bytes); - buffer = ByteBuffer.wrap(bytes); - //br.skipBytes(12); - buffer.order(ByteOrder.BIG_ENDIAN); - RecordNum = buffer.getInt(); - ContentLength = buffer.getInt(); - - bytes = new byte[ContentLength * 2]; - br.read(bytes); - buffer = ByteBuffer.wrap(bytes); - buffer.order(ByteOrder.LITTLE_ENDIAN); - aShapeType = buffer.getInt(); - - PolygonShape aSPG = new PolygonShape(); - Extent extent = new Extent(); - extent.minX = buffer.getDouble(); - extent.minY = buffer.getDouble(); - extent.maxX = buffer.getDouble(); - extent.maxY = buffer.getDouble(); - aSPG.setExtent(extent); - aSPG.setPartNum(buffer.getInt()); - int numPoints = buffer.getInt(); - aSPG.parts = new int[aSPG.getPartNum()]; - List points = new ArrayList<>(); - - //firstly read out parts begin pos in file - for (int j = 0; j < aSPG.getPartNum(); j++) { - aSPG.parts[j] = buffer.getInt(); - } - - //read out coordinates - for (int j = 0; j < numPoints; j++) { - x = buffer.getDouble(); - y = buffer.getDouble(); - PointD aPoint = new PointD(); - aPoint.X = x; - aPoint.Y = y; - points.add(aPoint); - } - aSPG.setPoints(points); - aLayer.addShape(aSPG); - } - - //Create legend scheme - aLayer.setLegendScheme(LegendManage.createSingleSymbolLegendScheme(ShapeTypes.Polygon, new Color(255, 251, 195), 1.0F)); - - return aLayer; - } - - private static VectorLayer readPolygonMShapes(DataInputStream br, int shapeNum) throws IOException { - VectorLayer aLayer = new VectorLayer(ShapeTypes.PolygonM); - int RecordNum, ContentLength, aShapeType; - double x, y; - byte[] bytes; - ByteBuffer buffer; - - for (int i = 0; i < shapeNum; i++) { - //br.skipBytes(12); - bytes = new byte[8]; - br.read(bytes); - buffer = ByteBuffer.wrap(bytes); - //br.skipBytes(12); - buffer.order(ByteOrder.BIG_ENDIAN); - RecordNum = buffer.getInt(); - ContentLength = buffer.getInt(); - - bytes = new byte[ContentLength * 2]; - br.read(bytes); - buffer = ByteBuffer.wrap(bytes); - buffer.order(ByteOrder.LITTLE_ENDIAN); - aShapeType = buffer.getInt(); - - PolygonMShape aSPG = new PolygonMShape(); - Extent extent = new Extent(); - extent.minX = buffer.getDouble(); - extent.minY = buffer.getDouble(); - extent.maxX = buffer.getDouble(); - extent.maxY = buffer.getDouble(); - aSPG.setExtent(extent); - aSPG.setPartNum(buffer.getInt()); - int numPoints = buffer.getInt(); - aSPG.parts = new int[aSPG.getPartNum()]; - List points = new ArrayList<>(); - - //firstly read out parts begin pos in file - for (int j = 0; j < aSPG.getPartNum(); j++) { - aSPG.parts[j] = buffer.getInt(); - } - - //read out coordinates - for (int j = 0; j < numPoints; j++) { - x = buffer.getDouble(); - y = buffer.getDouble(); - PointD aPoint = new PointD(); - aPoint.X = x; - aPoint.Y = y; - points.add(aPoint); - } - - //Read measure - double mmin = buffer.getDouble(); - double mmax = buffer.getDouble(); - double[] mArray = new double[numPoints]; - for (int j = 0; j < numPoints; j++) { - mArray[j] = buffer.getDouble(); - } - - //Get pointM list - List pointMs = new ArrayList<>(); - for (int j = 0; j < numPoints; j++) { - pointMs.add(new PointM(points.get(j).X, points.get(j).Y, mArray[j])); - } - - aSPG.setPoints(pointMs); - aLayer.addShape(aSPG); - } - - //Create legend scheme - aLayer.setLegendScheme(LegendManage.createSingleSymbolLegendScheme(ShapeTypes.Polygon, new Color(255, 251, 195), 1.0F)); - - return aLayer; - } - - private static VectorLayer readPolygonZShapes(DataInputStream br, int shapeNum) throws IOException { - VectorLayer aLayer = new VectorLayer(ShapeTypes.PolygonZ); - int RecordNum, ContentLength, aShapeType; - double x, y; - byte[] bytes; - ByteBuffer buffer; - - for (int i = 0; i < shapeNum; i++) { - //br.skipBytes(12); - bytes = new byte[8]; - br.read(bytes); - buffer = ByteBuffer.wrap(bytes); - //br.skipBytes(12); - buffer.order(ByteOrder.BIG_ENDIAN); - RecordNum = buffer.getInt(); - ContentLength = buffer.getInt(); - - bytes = new byte[ContentLength * 2]; - br.read(bytes); - buffer = ByteBuffer.wrap(bytes); - buffer.order(ByteOrder.LITTLE_ENDIAN); - aShapeType = buffer.getInt(); - - PolygonZShape aSPG = new PolygonZShape(); - Extent extent = new Extent(); - extent.minX = buffer.getDouble(); - extent.minY = buffer.getDouble(); - extent.maxX = buffer.getDouble(); - extent.maxY = buffer.getDouble(); - aSPG.setExtent(extent); - aSPG.setPartNum(buffer.getInt()); - int numPoints = buffer.getInt(); - aSPG.parts = new int[aSPG.getPartNum()]; - List points = new ArrayList<>(); - - //firstly read out parts begin pos in file - for (int j = 0; j < aSPG.getPartNum(); j++) { - aSPG.parts[j] = buffer.getInt(); - } - - //read out coordinates - for (int j = 0; j < numPoints; j++) { - x = buffer.getDouble(); - y = buffer.getDouble(); - PointD aPoint = new PointD(); - aPoint.X = x; - aPoint.Y = y; - points.add(aPoint); - } - - //Read Z - double zmin = buffer.getDouble(); - double zmax = buffer.getDouble(); - double[] zArray = new double[numPoints]; - for (int j = 0; j < numPoints; j++) { - zArray[j] = buffer.getDouble(); - } - - //Read measure - double mmin = buffer.getDouble(); - double mmax = buffer.getDouble(); - double[] mArray = new double[numPoints]; - for (int j = 0; j < numPoints; j++) { - mArray[j] = buffer.getDouble(); - } - - //Get pointZ list - List pointZs = new ArrayList<>(); - for (int j = 0; j < numPoints; j++) { - pointZs.add(new PointZ(points.get(j).X, points.get(j).Y, zArray[j], mArray[j])); - } - - aSPG.setPoints(pointZs); - aLayer.addShape(aSPG); - } - - //Create legend scheme - aLayer.setLegendScheme(LegendManage.createSingleSymbolLegendScheme(ShapeTypes.Polygon, new Color(255, 251, 195), 1.0F)); - - return aLayer; - } - - private static void loadShxFile(File shxFile) throws FileNotFoundException, IOException { - DataInputStream bridx = new DataInputStream(new BufferedInputStream(new FileInputStream(shxFile))); - long BytesSum = shxFile.length(); //Get file byte length - int shapeNum = (int) (BytesSum - 100) / 8; //Get total number of records - readHeader(bridx); - - int OffSet = 0, ContentLength = 0; - for (int i = 0; i < shapeNum; i++) { - OffSet = swapByteOrder(bridx.readInt()); - ContentLength = swapByteOrder(bridx.readInt()); - } - - bridx.close(); - } - - // /** - // * Load DBF data file - // * @param shpFileName Shape file name - // * @return Attribute table - // * @throws Exception - // */ - // public static AttributeTable loadDbfFile(String shpFileName) throws Exception{ - // AttributeTable attrTable = new AttributeTable(); - // attrTable.open(shpFileName); - // attrTable.fill(attrTable.getNumRecords()); - // - // return attrTable; - // } - - /** - * Load DBF data file - * @param shpFileName Shape file name - * @param encoding Encoding - * @return Attribute table - * @throws Exception - */ - public static AttributeTable loadDbfFile(String shpFileName, String encoding) throws Exception{ - AttributeTable attrTable = new AttributeTable(); - attrTable.setEncoding(encoding); - attrTable.open(shpFileName); - attrTable.fill(attrTable.getNumRecords()); - - return attrTable; - } - - /** - * Load projection file - * @param projFile Projection file - * @return Projection infomation - * @throws FileNotFoundException - * @throws IOException - */ - public static ProjectionInfo loadProjFile(File projFile) throws FileNotFoundException, IOException { - BufferedReader sr = new BufferedReader(new FileReader(projFile)); - String line; - StringBuilder buffer = new StringBuilder(); - while ((line = sr.readLine()) != null) { - buffer.append(line); - } - - String esriString = buffer.toString(); - sr.close(); - - ProjectionInfo projInfo = ProjectionInfo.factoryESRI(esriString); - - return projInfo; - } - - /** - * Save shape file - * @param shpfilepath Shape file path - * @param aLayer Vector layer - * @return Boolean - * @throws IOException*/ - public static boolean saveShapeFile(String shpfilepath, VectorLayer aLayer) throws IOException { - String shxfilepath = shpfilepath.replace(shpfilepath.substring(shpfilepath.lastIndexOf(".")), ".shx"); - String dbffilepath = shpfilepath.replace(shpfilepath.substring(shpfilepath.lastIndexOf(".")), ".dbf"); - String projFilePath = shpfilepath.replace(shpfilepath.substring(shpfilepath.lastIndexOf(".")), ".prj"); - - switch (aLayer.getShapeType()) { - case Point: - case PointZ: - case Polyline: - case PolylineZ: - case Polygon: - case PolygonZ: - writeShxFile(shxfilepath, aLayer); - writeShpFile(shpfilepath, aLayer); - writeDbfFile(dbffilepath, aLayer); - writeProjFile(projFilePath, aLayer); - return true; - - default: - return false; - } - } - - /** - * Save shape file - * @param shpfilepath Shape file path - * @param aLayer Vector layer - * @param encoding Encoding - * @return Boolean - * @throws IOException*/ - public static boolean saveShapeFile(String shpfilepath, VectorLayer aLayer, String encoding) throws IOException { - String shxfilepath = shpfilepath.replace(shpfilepath.substring(shpfilepath.lastIndexOf(".")), ".shx"); - String dbffilepath = shpfilepath.replace(shpfilepath.substring(shpfilepath.lastIndexOf(".")), ".dbf"); - String projFilePath = shpfilepath.replace(shpfilepath.substring(shpfilepath.lastIndexOf(".")), ".prj"); - - switch (aLayer.getShapeType()) { - case Point: - case PointZ: - case Polyline: - case PolylineZ: - case Polygon: - case PolygonZ: - writeShxFile(shxfilepath, aLayer); - writeShpFile(shpfilepath, aLayer); - writeDbfFile(dbffilepath, aLayer, encoding); - writeProjFile(projFilePath, aLayer); - return true; - - default: - return false; - } - } - - private static void writeShpFile(String shpfilepath, VectorLayer aLayer) throws FileNotFoundException, IOException { - File shpFile = new File(shpfilepath); - EndianDataOutputStream bw = new EndianDataOutputStream(new BufferedOutputStream(new FileOutputStream(shpFile))); - - //Write header - int FileLength = getShpFileLength(aLayer); - writeHeader(bw, aLayer, FileLength); - - //Write records - int RecordNumber; - - for (int i = 0; i < aLayer.getShapeNum(); i++) { - Shape aShape = aLayer.getShapes().get(i); - RecordNumber = i + 1; - writeRecord(bw, RecordNumber, aShape, aLayer.getShapeType()); - } - - //Close - bw.close(); - } - - private static int getShpFileLength(VectorLayer aLayer) { - int fileLength = 50; - - for (int i = 0; i < aLayer.getShapeNum(); i++) { - Shape aShape = aLayer.getShapes().get(i); - int cLen = getContentLength(aShape, aLayer.getShapeType()); - fileLength += 4 + cLen; - } - - return fileLength; - } - - private static int getContentLength(Shape aShape, ShapeTypes aST) { - int contentLength = 0; - switch (aST) { - case Point: - contentLength = 2 + 4 * 2; - break; - case PointZ: - contentLength = 2 + 4 * 4; - break; - case Polyline: - PolylineShape aPLS = (PolylineShape) aShape; - contentLength = 2 + 4 * 4 + 2 + 2 + 2 * aPLS.getPartNum() + 4 * 2 * aPLS.getPointNum(); - break; - case PolylineZ: - PolylineZShape aPLZS = (PolylineZShape) aShape; - contentLength = 2 + 4 * 4 + 2 + 2 + 2 * aPLZS.getPartNum() + 4 * 2 * aPLZS.getPointNum() - + 4 + 4 + 4 * aPLZS.getPointNum() + 4 + 4 + 4 * aPLZS.getPointNum(); - break; - case Polygon: - PolygonShape aPGS = (PolygonShape) aShape; - contentLength = 2 + 4 * 4 + 2 + 2 + 2 * aPGS.getPartNum() + 4 * 2 * aPGS.getPointNum(); - break; - case PolygonZ: - PolygonZShape aPGZS = (PolygonZShape) aShape; - contentLength = 2 + 4 * 4 + 2 + 2 + 2 * aPGZS.getPartNum() + 4 * 2 * aPGZS.getPointNum() - + 4 + 4 + 4 * aPGZS.getPointNum() + 4 + 4 + 4 * aPGZS.getPointNum(); - break; - } - - return contentLength; - } - - private static void writeRecord(EndianDataOutputStream bw, int RecordNumber, Shape aShape, ShapeTypes aST) throws IOException { - int ContentLength, i; - - ContentLength = getContentLength(aShape, aST); - bw.writeIntBE(RecordNumber); - bw.writeIntBE(ContentLength); - bw.writeIntLE(aST.getValue()); - switch (aST) { - case Point: - PointShape aPS = (PointShape) aShape; - bw.writeDoubleLE(aPS.getPoint().X); - bw.writeDoubleLE(aPS.getPoint().Y); - break; - case Polyline: - PolylineShape aPLS = (PolylineShape) aShape; - bw.writeDoubleLE(aPLS.getExtent().minX); - bw.writeDoubleLE(aPLS.getExtent().minY); - bw.writeDoubleLE(aPLS.getExtent().maxX); - bw.writeDoubleLE(aPLS.getExtent().maxY); - bw.writeIntLE(aPLS.getPartNum()); - bw.writeIntLE(aPLS.getPointNum()); - for (i = 0; i < aPLS.getPartNum(); i++) { - bw.writeIntLE(aPLS.parts[i]); - } - for (i = 0; i < aPLS.getPointNum(); i++) { - bw.writeDoubleLE((aPLS.getPoints().get(i)).X); - bw.writeDoubleLE((aPLS.getPoints().get(i)).Y); - } - break; - case PolylineZ: - PolylineZShape aPLZS = (PolylineZShape) aShape; - bw.writeDoubleLE(aPLZS.getExtent().minX); - bw.writeDoubleLE(aPLZS.getExtent().minY); - bw.writeDoubleLE(aPLZS.getExtent().maxX); - bw.writeDoubleLE(aPLZS.getExtent().maxY); - bw.writeIntLE(aPLZS.getPartNum()); - bw.writeIntLE(aPLZS.getPointNum()); - for (i = 0; i < aPLZS.getPartNum(); i++) { - bw.writeIntLE(aPLZS.parts[i]); - } - for (i = 0; i < aPLZS.getPointNum(); i++) { - bw.writeDoubleLE((aPLZS.getPoints().get(i)).X); - bw.writeDoubleLE((aPLZS.getPoints().get(i)).Y); - } - bw.writeDoubleLE(aPLZS.getZRange()[0]); - bw.writeDoubleLE(aPLZS.getZRange()[1]); - for (i = 0; i < aPLZS.getPointNum(); i++) { - bw.writeDoubleLE(aPLZS.getZArray()[i]); - } - bw.writeDoubleLE(aPLZS.getMRange()[0]); - bw.writeDoubleLE(aPLZS.getMRange()[1]); - for (i = 0; i < aPLZS.getPointNum(); i++) { - bw.writeDoubleLE(aPLZS.getMArray()[i]); - } - break; - case Polygon: - PolygonShape aPGS = (PolygonShape) aShape; - bw.writeDoubleLE(aPGS.getExtent().minX); - bw.writeDoubleLE(aPGS.getExtent().minY); - bw.writeDoubleLE(aPGS.getExtent().maxX); - bw.writeDoubleLE(aPGS.getExtent().maxY); - bw.writeIntLE(aPGS.getPartNum()); - bw.writeIntLE(aPGS.getPointNum()); - for (i = 0; i < aPGS.getPartNum(); i++) { - bw.writeIntLE(aPGS.parts[i]); - } - for (i = 0; i < aPGS.getPointNum(); i++) { - bw.writeDoubleLE((aPGS.getPoints().get(i)).X); - bw.writeDoubleLE((aPGS.getPoints().get(i)).Y); - } - break; - case PolygonZ: - PolygonZShape aPGZS = (PolygonZShape) aShape; - bw.writeDoubleLE(aPGZS.getExtent().minX); - bw.writeDoubleLE(aPGZS.getExtent().minY); - bw.writeDoubleLE(aPGZS.getExtent().maxX); - bw.writeDoubleLE(aPGZS.getExtent().maxY); - bw.writeIntLE(aPGZS.getPartNum()); - bw.writeIntLE(aPGZS.getPointNum()); - for (i = 0; i < aPGZS.getPartNum(); i++) { - bw.writeIntLE(aPGZS.parts[i]); - } - for (i = 0; i < aPGZS.getPointNum(); i++) { - bw.writeDoubleLE((aPGZS.getPoints().get(i)).X); - bw.writeDoubleLE((aPGZS.getPoints().get(i)).Y); - } - bw.writeDoubleLE(aPGZS.getZRange()[0]); - bw.writeDoubleLE(aPGZS.getZRange()[1]); - for (i = 0; i < aPGZS.getPointNum(); i++) { - bw.writeDoubleLE(aPGZS.getZArray()[i]); - } - bw.writeDoubleLE(aPGZS.getMRange()[0]); - bw.writeDoubleLE(aPGZS.getMRange()[1]); - for (i = 0; i < aPGZS.getPointNum(); i++) { - bw.writeDoubleLE(aPGZS.getMArray()[i]); - } - break; - } - } - - private static void writeHeader(EndianDataOutputStream bw, VectorLayer aLayer, int FileLength) throws IOException { - int i; - int FileCode = 9994; - //FileCode = swapByteOrder(FileCode); - int Unused = 0; - //Unused = swapByteOrder(Unused); - //FileLength = swapByteOrder(FileLength); - int Version = 1000; - int aShapeType = aLayer.getShapeType().getValue(); - - bw.writeIntBE(FileCode); - for (i = 0; i < 5; i++) { - bw.writeIntBE(Unused); - } - bw.writeIntBE(FileLength); - bw.writeIntLE(Version); - bw.writeIntLE(aShapeType); - bw.writeDoubleLE(aLayer.getExtent().minX); - bw.writeDoubleLE(aLayer.getExtent().minY); - bw.writeDoubleLE(aLayer.getExtent().maxX); - bw.writeDoubleLE(aLayer.getExtent().maxY); - for (i = 0; i < 4; i++) { - bw.writeDoubleLE(0.0); - } - } - - private static void writeShxFile(String shxfilepath, VectorLayer aLayer) throws IOException { - File shxFile = new File(shxfilepath); - EndianDataOutputStream bw = new EndianDataOutputStream(new BufferedOutputStream(new FileOutputStream(shxFile))); - - //Write header - int FileLength = aLayer.getShapeNum() * 4 + 50; - writeHeader(bw, aLayer, FileLength); - - //Write content - int OffSet, ContentLength; - OffSet = 50; - - for (int i = 0; i < aLayer.getShapeNum(); i++) { - Shape aShape = aLayer.getShapes().get(i); - ContentLength = getContentLength(aShape, aLayer.getShapeType()); - - bw.writeIntBE(OffSet); - bw.writeIntBE(ContentLength); - - OffSet = OffSet + 4 + ContentLength; - } - - //Close - bw.close(); - } - - private static void writeDbfFile(String dbffilepath, VectorLayer aLayer) { - aLayer.getAttributeTable().saveAs(dbffilepath, true); - } - - private static void writeDbfFile(String dbffilepath, VectorLayer aLayer, String encoding) { - AttributeTable attTable = aLayer.getAttributeTable(); - attTable.setEncoding(encoding); - attTable.saveAs(dbffilepath, true); - } - - private static void writeProjFile(String projFilePath, VectorLayer aLayer) { - BufferedWriter sw = null; - try { - String esriString = aLayer.getProjInfo().toEsriString(); - sw = new BufferedWriter(new FileWriter(new File(projFilePath))); - sw.write(esriString); - sw.flush(); - sw.close(); - } catch (IOException ex) { - Logger.getLogger(ShapeFileManage.class.getName()).log(Level.SEVERE, null, ex); - } finally { - try { - sw.close(); - } catch (IOException ex) { - Logger.getLogger(ShapeFileManage.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - - /** - * Swaps the byte order of an int32 - * - * @param i Integer - * @return Byte order swapped int - */ - private static int swapByteOrder(int i) { - byte[] buffer = intToBytes(i); - return ((buffer[3] & 0xff) << 24) | ((buffer[2] & 0xff) << 16) - | ((buffer[1] & 0xff) << 8) | (buffer[0] & 0xff); - } - - private static byte[] intToBytes(int i) { - byte[] result = new byte[4]; - result[0] = (byte) ((i >> 24) & 0xFF); - result[1] = (byte) ((i >> 16) & 0xFF); - result[2] = (byte) ((i >> 8) & 0xFF); - result[3] = (byte) (i & 0xFF); - return result; - } - - private static int bytesToInt(byte[] buffer){ - return ((buffer[3] & 0xff) << 24) | ((buffer[2] & 0xff) << 16) - | ((buffer[1] & 0xff) << 8) | (buffer[0] & 0xff); - } - } diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/drawing/ContourDraw.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/drawing/ContourDraw.java similarity index 99% rename from meteoinfo-chart/src/main/java/org/meteoinfo/chart/drawing/ContourDraw.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/drawing/ContourDraw.java index 791a17c3..80d9be5f 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/drawing/ContourDraw.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/drawing/ContourDraw.java @@ -11,7 +11,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.chart.drawing; +package org.meteoinfo.geo.drawing; import org.meteoinfo.common.MIMath; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/drawing/Draw.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/drawing/Draw.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/drawing/Draw.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/drawing/Draw.java index db4b06f1..8ed1cf6a 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/drawing/Draw.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/drawing/Draw.java @@ -11,11 +11,11 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.drawing; +package org.meteoinfo.geo.drawing; import org.meteoinfo.common.*; import org.meteoinfo.geometry.legend.*; -import org.meteoinfo.geoprocess.Spline; +import org.meteoinfo.geometry.geoprocess.Spline; import org.meteoinfo.common.colors.ColorUtil; import org.meteoinfo.geometry.graphic.Graphic; import org.meteoinfo.geometry.shape.Polyline; diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/drawing/StringType.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/drawing/StringType.java similarity index 88% rename from meteoinfo-chart/src/main/java/org/meteoinfo/chart/drawing/StringType.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/drawing/StringType.java index 7bc4fe8b..0b008220 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/drawing/StringType.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/drawing/StringType.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.chart.drawing; +package org.meteoinfo.geo.drawing; /** * diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/global/FontChooser.form b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui/FontChooser.form similarity index 100% rename from MeteoInfoLib/src/main/java/org/meteoinfo/global/FontChooser.form rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui/FontChooser.form diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/global/FontChooser.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui/FontChooser.java similarity index 98% rename from MeteoInfoLib/src/main/java/org/meteoinfo/global/FontChooser.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui/FontChooser.java index 4ea5a310..a90abe49 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/global/FontChooser.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui/FontChooser.java @@ -2,11 +2,10 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.global; +package org.meteoinfo.geo.gui; -import java.awt.Font; -import java.awt.GraphicsEnvironment; -import javax.swing.DefaultListModel; +import javax.swing.*; +import java.awt.*; /** * diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/global/FrmMeasurement.form b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui/FrmMeasurement.form similarity index 100% rename from MeteoInfoLib/src/main/java/org/meteoinfo/global/FrmMeasurement.form rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui/FrmMeasurement.form diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/global/FrmMeasurement.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui/FrmMeasurement.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/global/FrmMeasurement.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui/FrmMeasurement.java index 6f71cd70..f545f7ce 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/global/FrmMeasurement.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui/FrmMeasurement.java @@ -11,7 +11,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.global; +package org.meteoinfo.geo.gui; import com.formdev.flatlaf.extras.FlatSVGIcon; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/global/FrmProperty.form b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui/FrmProperty.form similarity index 100% rename from MeteoInfoLib/src/main/java/org/meteoinfo/global/FrmProperty.form rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui/FrmProperty.form diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/global/FrmProperty.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui/FrmProperty.java similarity index 98% rename from MeteoInfoLib/src/main/java/org/meteoinfo/global/FrmProperty.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui/FrmProperty.java index 6e7ba5c2..89f7d226 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/global/FrmProperty.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui/FrmProperty.java @@ -2,13 +2,14 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.global; +package org.meteoinfo.geo.gui; -import org.meteoinfo.layout.MapLayout; -import org.meteoinfo.map.MapView; import com.l2fprod.common.model.DefaultBeanInfoResolver; import com.l2fprod.common.propertysheet.Property; import com.l2fprod.common.propertysheet.PropertySheet; +import org.meteoinfo.geo.layout.MapLayout; +import org.meteoinfo.geo.mapview.MapView; + import java.beans.BeanInfo; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/gui/MainToolBar.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui/MainToolBar.java similarity index 93% rename from MeteoInfoLib/src/main/java/org/meteoinfo/gui/MainToolBar.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui/MainToolBar.java index ab9b1f04..828c132e 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/gui/MainToolBar.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/gui/MainToolBar.java @@ -1,270 +1,269 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.gui; - -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JToolBar; -import org.meteoinfo.layer.FrmLabelSet; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.layout.MapLayout; -import org.meteoinfo.layout.MouseMode; -import org.meteoinfo.legend.LayersLegend; -import org.meteoinfo.map.MapView; -import org.meteoinfo.map.MouseTools; - -/** - * - * @author Yaqiang Wang - */ -public class MainToolBar extends JToolBar { - - // - MapView mapView; - MapLayout mapLayout; - JButton jButton_Select; - JButton jButton_ZoomIn; - JButton jButton_ZoomOut; - JButton jButton_Pan; - JButton jButton_FullExtent; - JButton jButton_ZoomToLayer; - JButton jButton_Identifer; - JButton jButton_Label; - JLabel jLabel_Status; - JButton currentTool; - - // - // - /** - * Constructor - * @param toc Table of contents - * @param jLabel_Status Label for selected button - */ - public MainToolBar(LayersLegend toc, JLabel jLabel_Status){ - this(toc.getActiveMapFrame().getMapView(), toc.getMapLayout(), jLabel_Status); - } - - /** - * Constructor - * - * @param mapView MapView - * @param mapLayout MapLayout - * @param jLabel_Status Label for selected button - */ - public MainToolBar(MapView mapView, MapLayout mapLayout, JLabel jLabel_Status) { - this.mapView = mapView; - this.mapLayout = mapLayout; - this.jLabel_Status = jLabel_Status; - - jButton_Select = new JButton(); - jButton_Select.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_None.Image.png"))); // NOI18N - jButton_Select.setToolTipText("Select"); - jButton_Select.setFocusable(false); - jButton_Select.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton_Select.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButton_Select.addActionListener(new java.awt.event.ActionListener() { - @Override - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton_SelectActionPerformed(evt); - } - }); - this.add(jButton_Select); - - jButton_ZoomIn = new JButton(); - jButton_ZoomIn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_ZoomIn.Image.png"))); // NOI18N - jButton_ZoomIn.setToolTipText("Zoom In"); - jButton_ZoomIn.setFocusable(false); - jButton_ZoomIn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton_ZoomIn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButton_ZoomIn.addActionListener(new java.awt.event.ActionListener() { - @Override - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton_ZoomInActionPerformed(evt); - } - }); - this.add(jButton_ZoomIn); - - jButton_ZoomOut = new JButton(); - jButton_ZoomOut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_ZoomOut.Image.png"))); // NOI18N - jButton_ZoomOut.setToolTipText("Zoom Out"); - jButton_ZoomOut.setFocusable(false); - jButton_ZoomOut.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton_ZoomOut.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButton_ZoomOut.addActionListener(new java.awt.event.ActionListener() { - @Override - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton_ZoomOutActionPerformed(evt); - } - }); - this.add(jButton_ZoomOut); - - jButton_Pan = new JButton(); - jButton_Pan.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_Pan.Image.png"))); // NOI18N - jButton_Pan.setToolTipText("Pan"); - jButton_Pan.setFocusable(false); - jButton_Pan.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton_Pan.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButton_Pan.addActionListener(new java.awt.event.ActionListener() { - @Override - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton_PanActionPerformed(evt); - } - }); - this.add(jButton_Pan); - - jButton_FullExtent = new JButton(); - jButton_FullExtent.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_FullExent.Image.png"))); // NOI18N - jButton_FullExtent.setToolTipText("Full Extent"); - jButton_FullExtent.setFocusable(false); - jButton_FullExtent.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton_FullExtent.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButton_FullExtent.addActionListener(new java.awt.event.ActionListener() { - @Override - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton_FullExtentActionPerformed(evt); - } - }); - this.add(jButton_FullExtent); - - jButton_ZoomToLayer = new JButton(); - jButton_ZoomToLayer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_ZoomToLayer.Image.png"))); // NOI18N - jButton_ZoomToLayer.setToolTipText("Zoom to Layer"); - jButton_ZoomToLayer.setFocusable(false); - jButton_ZoomToLayer.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton_ZoomToLayer.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButton_ZoomToLayer.addActionListener(new java.awt.event.ActionListener() { - @Override - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton_ZoomToLayerActionPerformed(evt); - } - }); - this.add(jButton_ZoomToLayer); - - jButton_Identifer = new JButton(); - jButton_Identifer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/information.png"))); // NOI18N - jButton_Identifer.setToolTipText("Identifer"); - jButton_Identifer.setFocusable(false); - jButton_Identifer.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton_Identifer.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButton_Identifer.addActionListener(new java.awt.event.ActionListener() { - @Override - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton_IdentiferActionPerformed(evt); - } - }); - this.add(jButton_Identifer); - this.add(new Separator()); - - jButton_Label = new JButton(); - jButton_Label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_LabelSet.Image.png"))); // NOI18N - jButton_Label.setToolTipText("Label"); - jButton_Label.setFocusable(false); - jButton_Label.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton_Label.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jButton_Label.addActionListener(new java.awt.event.ActionListener() { - @Override - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton_LabelActionPerformed(evt); - } - }); - this.add(jButton_Label); - - //this.currentTool = this.jButton_Select; - } - - private void jButton_SelectActionPerformed(java.awt.event.ActionEvent evt) { - // TODO add your handling code here: - this.mapView.setMouseTool(MouseTools.SelectElements); - if (this.mapLayout != null) { - this.mapLayout.setMouseMode(MouseMode.Select); - } - - setCurrentTool((JButton) evt.getSource()); - } - - private void jButton_ZoomInActionPerformed(java.awt.event.ActionEvent evt) { - // TODO add your handling code here: - this.mapView.setMouseTool(MouseTools.Zoom_In); - if (this.mapLayout != null) { - this.mapLayout.setMouseMode(MouseMode.Map_ZoomIn); - } - - setCurrentTool((JButton) evt.getSource()); - } - - private void jButton_ZoomOutActionPerformed(java.awt.event.ActionEvent evt) { - // TODO add your handling code here: - this.mapView.setMouseTool(MouseTools.Zoom_Out); - if (this.mapLayout != null) { - this.mapLayout.setMouseMode(MouseMode.Map_ZoomOut); - } - - setCurrentTool((JButton) evt.getSource()); - } - - private void jButton_PanActionPerformed(java.awt.event.ActionEvent evt) { - // TODO add your handling code here: - this.mapView.setMouseTool(MouseTools.Pan); - if (this.mapLayout != null) { - this.mapLayout.setMouseMode(MouseMode.Map_Pan); - } - - setCurrentTool((JButton) evt.getSource()); - } - - private void jButton_FullExtentActionPerformed(java.awt.event.ActionEvent evt) { - // TODO add your handling code here: - this.mapView.zoomToExtent(this.mapView.getExtent()); - } - - private void jButton_ZoomToLayerActionPerformed(java.awt.event.ActionEvent evt) { - MapLayer layer = this.mapView.getSelectedLayer(); - if (layer != null){ - this.mapView.zoomToExtent(layer.getExtent()); - } - } - - private void jButton_IdentiferActionPerformed(java.awt.event.ActionEvent evt) { - // TODO add your handling code here: - this.mapView.setMouseTool(MouseTools.Identifer); - if (this.mapLayout != null) { - this.mapLayout.setMouseMode(MouseMode.Map_Identifer); - } - - setCurrentTool((JButton) evt.getSource()); - } - - private void jButton_LabelActionPerformed(java.awt.event.ActionEvent evt) { - MapLayer aMLayer = this.mapView.getSelectedLayer(); - if (aMLayer.getLayerType() == LayerTypes.VectorLayer) { - VectorLayer aLayer = (VectorLayer) aMLayer; - if (aLayer.getShapeNum() > 0) { - FrmLabelSet aFrmLabel = new FrmLabelSet(null, false, this.mapView); - aFrmLabel.setLayer(aLayer); - //aFrmLabel.setLocationRelativeTo(this); - aFrmLabel.setVisible(true); - } - } - } - - private void setCurrentTool(JButton currentTool) { - if (!(this.currentTool == null)) { - this.currentTool.setSelected(false); - } - this.currentTool = currentTool; - this.currentTool.setSelected(true); - if (this.jLabel_Status != null) { - jLabel_Status.setText(currentTool.getToolTipText()); - } - } - // - // - // - // - // -} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.meteoinfo.geo.gui; + +import org.meteoinfo.geo.layer.FrmLabelSet; +import org.meteoinfo.geo.layer.LayerTypes; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.layer.VectorLayer; +import org.meteoinfo.geo.layout.MapLayout; +import org.meteoinfo.geo.layout.MouseMode; +import org.meteoinfo.geo.legend.LayersLegend; +import org.meteoinfo.geo.mapview.MapView; +import org.meteoinfo.geo.mapview.MouseTools; + +import javax.swing.*; + +/** + * + * @author Yaqiang Wang + */ +public class MainToolBar extends JToolBar { + + // + MapView mapView; + MapLayout mapLayout; + JButton jButton_Select; + JButton jButton_ZoomIn; + JButton jButton_ZoomOut; + JButton jButton_Pan; + JButton jButton_FullExtent; + JButton jButton_ZoomToLayer; + JButton jButton_Identifer; + JButton jButton_Label; + JLabel jLabel_Status; + JButton currentTool; + + // + // + /** + * Constructor + * @param toc Table of contents + * @param jLabel_Status Label for selected button + */ + public MainToolBar(LayersLegend toc, JLabel jLabel_Status){ + this(toc.getActiveMapFrame().getMapView(), toc.getMapLayout(), jLabel_Status); + } + + /** + * Constructor + * + * @param mapView MapView + * @param mapLayout MapLayout + * @param jLabel_Status Label for selected button + */ + public MainToolBar(MapView mapView, MapLayout mapLayout, JLabel jLabel_Status) { + this.mapView = mapView; + this.mapLayout = mapLayout; + this.jLabel_Status = jLabel_Status; + + jButton_Select = new JButton(); + jButton_Select.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_None.Image.png"))); // NOI18N + jButton_Select.setToolTipText("Select"); + jButton_Select.setFocusable(false); + jButton_Select.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jButton_Select.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton_Select.addActionListener(new java.awt.event.ActionListener() { + @Override + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton_SelectActionPerformed(evt); + } + }); + this.add(jButton_Select); + + jButton_ZoomIn = new JButton(); + jButton_ZoomIn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_ZoomIn.Image.png"))); // NOI18N + jButton_ZoomIn.setToolTipText("Zoom In"); + jButton_ZoomIn.setFocusable(false); + jButton_ZoomIn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jButton_ZoomIn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton_ZoomIn.addActionListener(new java.awt.event.ActionListener() { + @Override + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton_ZoomInActionPerformed(evt); + } + }); + this.add(jButton_ZoomIn); + + jButton_ZoomOut = new JButton(); + jButton_ZoomOut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_ZoomOut.Image.png"))); // NOI18N + jButton_ZoomOut.setToolTipText("Zoom Out"); + jButton_ZoomOut.setFocusable(false); + jButton_ZoomOut.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jButton_ZoomOut.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton_ZoomOut.addActionListener(new java.awt.event.ActionListener() { + @Override + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton_ZoomOutActionPerformed(evt); + } + }); + this.add(jButton_ZoomOut); + + jButton_Pan = new JButton(); + jButton_Pan.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_Pan.Image.png"))); // NOI18N + jButton_Pan.setToolTipText("Pan"); + jButton_Pan.setFocusable(false); + jButton_Pan.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jButton_Pan.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton_Pan.addActionListener(new java.awt.event.ActionListener() { + @Override + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton_PanActionPerformed(evt); + } + }); + this.add(jButton_Pan); + + jButton_FullExtent = new JButton(); + jButton_FullExtent.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_FullExent.Image.png"))); // NOI18N + jButton_FullExtent.setToolTipText("Full Extent"); + jButton_FullExtent.setFocusable(false); + jButton_FullExtent.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jButton_FullExtent.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton_FullExtent.addActionListener(new java.awt.event.ActionListener() { + @Override + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton_FullExtentActionPerformed(evt); + } + }); + this.add(jButton_FullExtent); + + jButton_ZoomToLayer = new JButton(); + jButton_ZoomToLayer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_ZoomToLayer.Image.png"))); // NOI18N + jButton_ZoomToLayer.setToolTipText("Zoom to Layer"); + jButton_ZoomToLayer.setFocusable(false); + jButton_ZoomToLayer.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jButton_ZoomToLayer.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton_ZoomToLayer.addActionListener(new java.awt.event.ActionListener() { + @Override + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton_ZoomToLayerActionPerformed(evt); + } + }); + this.add(jButton_ZoomToLayer); + + jButton_Identifer = new JButton(); + jButton_Identifer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/information.png"))); // NOI18N + jButton_Identifer.setToolTipText("Identifer"); + jButton_Identifer.setFocusable(false); + jButton_Identifer.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jButton_Identifer.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton_Identifer.addActionListener(new java.awt.event.ActionListener() { + @Override + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton_IdentiferActionPerformed(evt); + } + }); + this.add(jButton_Identifer); + this.add(new Separator()); + + jButton_Label = new JButton(); + jButton_Label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_LabelSet.Image.png"))); // NOI18N + jButton_Label.setToolTipText("Label"); + jButton_Label.setFocusable(false); + jButton_Label.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jButton_Label.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton_Label.addActionListener(new java.awt.event.ActionListener() { + @Override + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton_LabelActionPerformed(evt); + } + }); + this.add(jButton_Label); + + //this.currentTool = this.jButton_Select; + } + + private void jButton_SelectActionPerformed(java.awt.event.ActionEvent evt) { + // TODO add your handling code here: + this.mapView.setMouseTool(MouseTools.SelectElements); + if (this.mapLayout != null) { + this.mapLayout.setMouseMode(MouseMode.Select); + } + + setCurrentTool((JButton) evt.getSource()); + } + + private void jButton_ZoomInActionPerformed(java.awt.event.ActionEvent evt) { + // TODO add your handling code here: + this.mapView.setMouseTool(MouseTools.Zoom_In); + if (this.mapLayout != null) { + this.mapLayout.setMouseMode(MouseMode.Map_ZoomIn); + } + + setCurrentTool((JButton) evt.getSource()); + } + + private void jButton_ZoomOutActionPerformed(java.awt.event.ActionEvent evt) { + // TODO add your handling code here: + this.mapView.setMouseTool(MouseTools.Zoom_Out); + if (this.mapLayout != null) { + this.mapLayout.setMouseMode(MouseMode.Map_ZoomOut); + } + + setCurrentTool((JButton) evt.getSource()); + } + + private void jButton_PanActionPerformed(java.awt.event.ActionEvent evt) { + // TODO add your handling code here: + this.mapView.setMouseTool(MouseTools.Pan); + if (this.mapLayout != null) { + this.mapLayout.setMouseMode(MouseMode.Map_Pan); + } + + setCurrentTool((JButton) evt.getSource()); + } + + private void jButton_FullExtentActionPerformed(java.awt.event.ActionEvent evt) { + // TODO add your handling code here: + this.mapView.zoomToExtent(this.mapView.getExtent()); + } + + private void jButton_ZoomToLayerActionPerformed(java.awt.event.ActionEvent evt) { + MapLayer layer = this.mapView.getSelectedLayer(); + if (layer != null){ + this.mapView.zoomToExtent(layer.getExtent()); + } + } + + private void jButton_IdentiferActionPerformed(java.awt.event.ActionEvent evt) { + // TODO add your handling code here: + this.mapView.setMouseTool(MouseTools.Identifer); + if (this.mapLayout != null) { + this.mapLayout.setMouseMode(MouseMode.Map_Identifer); + } + + setCurrentTool((JButton) evt.getSource()); + } + + private void jButton_LabelActionPerformed(java.awt.event.ActionEvent evt) { + MapLayer aMLayer = this.mapView.getSelectedLayer(); + if (aMLayer.getLayerType() == LayerTypes.VectorLayer) { + VectorLayer aLayer = (VectorLayer) aMLayer; + if (aLayer.getShapeNum() > 0) { + FrmLabelSet aFrmLabel = new FrmLabelSet(null, false, this.mapView); + aFrmLabel.setLayer(aLayer); + //aFrmLabel.setLocationRelativeTo(this); + aFrmLabel.setVisible(true); + } + } + } + + private void setCurrentTool(JButton currentTool) { + if (!(this.currentTool == null)) { + this.currentTool.setSelected(false); + } + this.currentTool = currentTool; + this.currentTool.setSelected(true); + if (this.jLabel_Status != null) { + jLabel_Status.setText(currentTool.getToolTipText()); + } + } + // + // + // + // + // +} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/ChartSet.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/ChartSet.java index 715b8aff..67999aed 100644 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/ChartSet.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/ChartSet.java @@ -15,6 +15,7 @@ package org.meteoinfo.geo.layer; import java.awt.Color; import java.awt.Font; + import org.meteoinfo.geometry.legend.AlignType; import org.meteoinfo.geometry.legend.ChartTypes; import org.meteoinfo.geometry.legend.LegendScheme; @@ -29,7 +30,7 @@ import java.util.List; */ public class ChartSet { // - + private ChartTypes _chartType; private boolean _drawCharts; private List _fieldNames; @@ -51,7 +52,7 @@ import java.util.List; private int decimalDigits; // // - + /** * Constructor */ @@ -76,7 +77,7 @@ import java.util.List; } // // - + /** * Get chart type * @@ -85,7 +86,7 @@ import java.util.List; public ChartTypes getChartType() { return _chartType; } - + /** * Set chart type * @@ -94,7 +95,7 @@ import java.util.List; public void setChartType(ChartTypes type) { _chartType = type; } - + /** * Set chart type * @param tstr Chart type string @@ -109,7 +110,7 @@ import java.util.List; break; } } - + /** * Set if draw charts * @@ -118,7 +119,7 @@ import java.util.List; public boolean isDrawCharts() { return _drawCharts; } - + /** * Set if draw charts * @@ -127,7 +128,7 @@ import java.util.List; public void setDrawCharts(boolean istrue) { _drawCharts = istrue; } - + /** * Get field names * @@ -136,7 +137,7 @@ import java.util.List; public List getFieldNames() { return _fieldNames; } - + /** * Set field names * @@ -145,7 +146,7 @@ import java.util.List; public void setFieldNames(List names) { _fieldNames = names; } - + /** * Get x shift * @@ -154,7 +155,7 @@ import java.util.List; public int getXShift() { return _xShift; } - + /** * Set x shift * @@ -163,7 +164,7 @@ import java.util.List; public void setXShift(int shift) { _xShift = shift; } - + /** * Get y shift * @@ -172,7 +173,7 @@ import java.util.List; public int getYShift() { return _yShift; } - + /** * Set y shift * @@ -181,7 +182,7 @@ import java.util.List; public void setYShift(int shift) { _yShift = shift; } - + /** * Get legend scheme * @@ -190,7 +191,7 @@ import java.util.List; public LegendScheme getLegendScheme() { return _legendScheme; } - + /** * Set legend scheme * @@ -199,7 +200,7 @@ import java.util.List; public void setLegendScheme(LegendScheme ls) { _legendScheme = ls; } - + /** * Get maximum size * @@ -208,7 +209,7 @@ import java.util.List; public int getMaxSize() { return _maxSize; } - + /** * Set maximum size * @@ -217,7 +218,7 @@ import java.util.List; public void setMaxSize(int size) { _maxSize = size; } - + /** * Get minimum size * @@ -226,7 +227,7 @@ import java.util.List; public int getMinSize() { return _minSize; } - + /** * Set minimum size * @@ -235,7 +236,7 @@ import java.util.List; public void setMinSize(int size) { _minSize = size; } - + /** * Get maximum value * @@ -244,11 +245,11 @@ import java.util.List; public float getMaxValue() { return _maxValue; } - + public void setMaxValue(float value) { _maxValue = value; } - + /** * Get minimum value * @@ -257,7 +258,7 @@ import java.util.List; public float getMinValue() { return _minValue; } - + /** * Set minimum value * @@ -266,7 +267,7 @@ import java.util.List; public void setMinValue(float value) { _minValue = value; } - + /** * Get bar width * @@ -275,7 +276,7 @@ import java.util.List; public int getBarWidth() { return _barWidth; } - + /** * Set bar width * @@ -284,7 +285,7 @@ import java.util.List; public void setBarWidth(int width) { _barWidth = width; } - + /** * Get if avoid collision * @@ -293,7 +294,7 @@ import java.util.List; public boolean isAvoidCollision() { return _avoidCollision; } - + /** * Set if avoid collision * @@ -302,7 +303,7 @@ import java.util.List; public void setAvoidCollision(boolean istrue) { _avoidCollision = istrue; } - + /** * Get align type * @@ -311,7 +312,7 @@ import java.util.List; public AlignType getAlignType() { return _alignType; } - + /** * Set align type * @@ -320,7 +321,7 @@ import java.util.List; public void setAlignType(AlignType type) { _alignType = type; } - + /** * Set align type * @param tstr Align type string @@ -340,8 +341,8 @@ import java.util.List; this._alignType = AlignType.None; break; } - } - + } + /** * Get if view 3D * @@ -350,7 +351,7 @@ import java.util.List; public boolean isView3D() { return _view3D; } - + /** * Set if view 3D * @@ -359,7 +360,7 @@ import java.util.List; public void setView3D(boolean istrue) { _view3D = istrue; } - + /** * Get 3D thickness * @@ -368,7 +369,7 @@ import java.util.List; public int getThickness() { return _thickness; } - + /** * Set 3D thickness * @@ -377,7 +378,7 @@ import java.util.List; public void setThickness(int value) { _thickness = value; } - + /** * Get if draw label * @return Boolean @@ -385,7 +386,7 @@ import java.util.List; public boolean isDrawLabel(){ return this.drawLabel; } - + /** * Set if draw label * @param value Boolean @@ -393,7 +394,7 @@ import java.util.List; public void setDrawLabel(boolean value){ this.drawLabel = value; } - + /** * Get label font * @return Label font @@ -401,7 +402,7 @@ import java.util.List; public Font getLabelFont(){ return this.labelFont; } - + /** * Set label font * @param value Label font @@ -409,7 +410,7 @@ import java.util.List; public void setLabelFont(Font value){ this.labelFont = value; } - + /** * Get label color * @return Label color @@ -417,7 +418,7 @@ import java.util.List; public Color getLabelColor(){ return this.labelColor; } - + /** * Set label color * @param value Label color @@ -425,7 +426,7 @@ import java.util.List; public void setLabelColor(Color value){ this.labelColor = value; } - + /** * Get decimal digits * @return Decimal digits @@ -433,7 +434,7 @@ import java.util.List; public int getDecimalDigits(){ return this.decimalDigits; } - + /** * Set decimal digits * @param value Decimal digits diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/FrmChartLabel.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/FrmChartLabel.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/layer/FrmChartLabel.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/FrmChartLabel.java index 6e74ba35..728474e4 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/FrmChartLabel.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/FrmChartLabel.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.layer; +package org.meteoinfo.geo.layer; import com.l2fprod.common.swing.JFontChooser; import java.awt.Color; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/FrmLabelSet.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/FrmLabelSet.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/layer/FrmLabelSet.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/FrmLabelSet.java index 5b6c44e5..454722a9 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/FrmLabelSet.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/FrmLabelSet.java @@ -2,11 +2,11 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.layer; +package org.meteoinfo.geo.layer; import org.meteoinfo.geometry.legend.AlignType; import org.meteoinfo.geometry.legend.LabelBreak; -import org.meteoinfo.map.MapView; +import org.meteoinfo.geo.mapview.MapView; import org.meteoinfo.geometry.shape.ShapeTypes; import com.l2fprod.common.swing.JFontChooser; import java.awt.Color; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/FrmLayerProperty.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/FrmLayerProperty.java similarity index 98% rename from MeteoInfoLib/src/main/java/org/meteoinfo/layer/FrmLayerProperty.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/FrmLayerProperty.java index 3c428190..7cd12457 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layer/FrmLayerProperty.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/FrmLayerProperty.java @@ -2,16 +2,17 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.layer; +package org.meteoinfo.geo.layer; import com.formdev.flatlaf.extras.FlatSVGIcon; import org.meteoinfo.common.GenericFileFilter; import org.meteoinfo.common.MIMath; +import org.meteoinfo.geo.legend.LegendView; import org.meteoinfo.geometry.legend.*; import org.meteoinfo.ndarray.DataType; -import org.meteoinfo.legend.FrmLegendBreaks; -import org.meteoinfo.legend.LegendManage; -import org.meteoinfo.legend.MapFrame; +import org.meteoinfo.geo.legend.FrmLegendBreaks; +import org.meteoinfo.geo.legend.LegendManage; +import org.meteoinfo.geo.legend.MapFrame; import org.meteoinfo.geometry.shape.ShapeTypes; import com.l2fprod.common.model.DefaultBeanInfoResolver; import com.l2fprod.common.propertysheet.PropertySheet; @@ -75,7 +76,7 @@ public class FrmLayerProperty extends javax.swing.JDialog { jButton_Apply = new javax.swing.JButton(); jTabbedPane1 = new javax.swing.JTabbedPane(); jPanel_General = new javax.swing.JPanel(); - propertySheetPanel1 = new com.l2fprod.common.propertysheet.PropertySheetPanel(); + propertySheetPanel1 = new PropertySheetPanel(); jPanel_Legend = new javax.swing.JPanel(); jToolBar1 = new javax.swing.JToolBar(); jButton_ImportLegend = new javax.swing.JButton(); @@ -90,7 +91,7 @@ public class FrmLayerProperty extends javax.swing.JDialog { jButton_ReverseBreaks = new javax.swing.JButton(); jSeparator3 = new javax.swing.JToolBar.Separator(); jButton_MakeBreaks = new javax.swing.JButton(); - legendView1 = new org.meteoinfo.legend.LegendView(); + legendView1 = new LegendView(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jComboBox_LegendType = new javax.swing.JComboBox(); @@ -98,7 +99,7 @@ public class FrmLayerProperty extends javax.swing.JDialog { jPanel_Chart = new javax.swing.JPanel(); jLabel3 = new javax.swing.JLabel(); jComboBox_ChartType = new javax.swing.JComboBox(); - legendView_Chart = new org.meteoinfo.legend.LegendView(); + legendView_Chart = new LegendView(); jPanel1 = new javax.swing.JPanel(); jLabel4 = new javax.swing.JLabel(); jTextField_Minimum = new javax.swing.JTextField(); @@ -1456,13 +1457,13 @@ public class FrmLayerProperty extends javax.swing.JDialog { } } } catch (ClassNotFoundException ex) { - java.util.logging.Logger.getLogger(FrmLayerProperty.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + Logger.getLogger(FrmLayerProperty.class.getName()).log(Level.SEVERE, null, ex); } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(FrmLayerProperty.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + Logger.getLogger(FrmLayerProperty.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(FrmLayerProperty.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + Logger.getLogger(FrmLayerProperty.class.getName()).log(Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(FrmLayerProperty.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + Logger.getLogger(FrmLayerProperty.class.getName()).log(Level.SEVERE, null, ex); } // @@ -1529,8 +1530,8 @@ public class FrmLayerProperty extends javax.swing.JDialog { private javax.swing.JTextField jTextField_XShift; private javax.swing.JTextField jTextField_YShift; private javax.swing.JToolBar jToolBar1; - private org.meteoinfo.legend.LegendView legendView1; - private org.meteoinfo.legend.LegendView legendView_Chart; - private com.l2fprod.common.propertysheet.PropertySheetPanel propertySheetPanel1; + private LegendView legendView1; + private LegendView legendView_Chart; + private PropertySheetPanel propertySheetPanel1; // End of variables declaration//GEN-END:variables } diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/ImageLayer.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/ImageLayer.java index b2f301b4..0a50cab3 100644 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/ImageLayer.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/ImageLayer.java @@ -19,8 +19,6 @@ import com.l2fprod.common.beans.editor.ComboBoxPropertyEditor; import org.meteoinfo.common.Extent; import org.meteoinfo.common.util.GlobalUtil; import org.meteoinfo.geometry.shape.ShapeTypes; -import org.meteoinfo.layer.WorldFilePara; - import java.awt.Color; import java.awt.Image; import java.awt.RenderingHints; diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/LabelSet.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/LabelSet.java index d865b655..61f0d2f4 100644 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/LabelSet.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/LabelSet.java @@ -15,6 +15,7 @@ package org.meteoinfo.geo.layer; import org.meteoinfo.common.util.GlobalUtil; import org.meteoinfo.geometry.legend.AlignType; + import java.awt.Color; import java.awt.Font; diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/LayerCollection.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/LayerCollection.java index fde83e15..50ec30a9 100644 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/LayerCollection.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/LayerCollection.java @@ -21,11 +21,11 @@ import java.util.ArrayList; */ public class LayerCollection extends ArrayList { // - + private int _selectedLayer; // // - + /** * Constructor */ @@ -34,7 +34,7 @@ import java.util.ArrayList; } // // - + /** * Get selected layer * @@ -43,7 +43,7 @@ import java.util.ArrayList; public int getSelectedLayer() { return _selectedLayer; } - + /** * Set selected layer handle * @@ -52,7 +52,7 @@ import java.util.ArrayList; public void setSelectedLayer(int handle) { _selectedLayer = handle; } - + // // // diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/MapLayer.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/MapLayer.java index 790a1868..de54cde6 100644 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/MapLayer.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/MapLayer.java @@ -15,8 +15,8 @@ package org.meteoinfo.geo.layer; import org.meteoinfo.common.Extent; import org.meteoinfo.geometry.legend.LegendScheme; -import org.meteoinfo.geo.projection.KnownCoordinateSystems; -import org.meteoinfo.geo.projection.info.ProjectionInfo; +import org.meteoinfo.projection.KnownCoordinateSystems; +import org.meteoinfo.projection.ProjectionInfo; import org.meteoinfo.geometry.shape.ShapeTypes; /** @@ -26,7 +26,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; */ public class MapLayer implements Cloneable { // - + private LayerTypes _layerType; private ShapeTypes _shapeType; private int _handle; @@ -44,7 +44,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; private VisibleScale _visibleScale; // // - + /** * Constructor */ @@ -64,7 +64,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; } // // - + /** * Get layer type * @@ -73,7 +73,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public LayerTypes getLayerType() { return _layerType; } - + /** * Set layer type * @@ -82,7 +82,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public void setLayerType(LayerTypes lt) { _layerType = lt; } - + /** * Get shape type * @@ -91,7 +91,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public ShapeTypes getShapeType() { return _shapeType; } - + /** * Set shape type * @@ -100,7 +100,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public void setShapeType(ShapeTypes st) { _shapeType = st; } - + /** * Get layer draw type * @@ -109,7 +109,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public LayerDrawType getLayerDrawType() { return _layerDrawType; } - + /** * Set layer draw type * @@ -118,7 +118,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public void setLayerDrawType(LayerDrawType ldt) { _layerDrawType = ldt; } - + /** * Get file name * @@ -127,7 +127,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public String getFileName() { return _fileName; } - + /** * Set file name * @@ -136,7 +136,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public void setFileName(String fn) { _fileName = fn; } - + /** * Get layer handle * @@ -145,7 +145,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public int getHandle() { return _handle; } - + /** * Set layer handle * @@ -154,7 +154,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public void setHandle(int handle) { _handle = handle; } - + /** * Get layer name * @@ -163,7 +163,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public String getLayerName() { return _layerName; } - + /** * Set layer name * @@ -172,7 +172,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public void setLayerName(String lName) { _layerName = lName; } - + /** * Get extent * @@ -181,7 +181,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public Extent getExtent() { return _extent; } - + /** * Set extent * @@ -190,7 +190,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public void setExtent(Extent extent) { _extent = extent; } - + /** * Get if layer is visible * @@ -199,7 +199,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public boolean isVisible() { return _visible; } - + /** * Set if layer is visible * @@ -208,7 +208,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public void setVisible(boolean isTrue) { _visible = isTrue; } - + /** * Get legend scheme * @@ -217,7 +217,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public LegendScheme getLegendScheme() { return _legendScheme; } - + /** * Get if is maskout * @return Boolean @@ -225,7 +225,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public boolean isMaskout(){ return this._isMaskout; } - + /** * Set if is maskout * @param istrue Boolean @@ -233,7 +233,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public void setMaskout(boolean istrue){ this._isMaskout = istrue; } - + /** * Set legend scheme * @@ -242,7 +242,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public void setLegendScheme(LegendScheme ls) { _legendScheme = ls; } - + /** * Get transparency percent * @@ -251,7 +251,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public int getTransparency() { return this._transparencyPerc; } - + /** * Set transparency percent * @@ -260,7 +260,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public void setTransparency(int trans) { this._transparencyPerc = trans; } - + /** * Get if is expanded * @@ -269,7 +269,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public boolean isExpanded() { return this._expanded; } - + /** * Set if expand * @@ -278,7 +278,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public void setExpanded(boolean istrue) { this._expanded = istrue; } - + /** * Get projection info * @return Projection info @@ -286,7 +286,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public ProjectionInfo getProjInfo(){ return _projInfo; } - + /** * Set projection info * @param projInfo Projection info @@ -294,7 +294,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public void setProjInfo(ProjectionInfo projInfo){ _projInfo = projInfo; } - + /** * Get tag * @return Tag @@ -302,7 +302,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public String getTag(){ return _tag; } - + /** * Set tag * @param value Tag value @@ -310,7 +310,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public void setTag(String value){ _tag = value; } - + /** * Get visible scale * @return Visible scale @@ -318,7 +318,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public VisibleScale getVisibleScale(){ return _visibleScale; } - + /** * Set visible scale * @param value Visible scale @@ -335,16 +335,16 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public boolean hasLegendScheme(){ return this._legendScheme != null; } - + @Override public Object clone() throws CloneNotSupportedException { MapLayer aLayer = (MapLayer)super.clone(); if (_legendScheme != null) aLayer._legendScheme = (LegendScheme)this._legendScheme.clone(); - + return aLayer; } - + /** * To string * @return String @@ -353,7 +353,7 @@ import org.meteoinfo.geometry.shape.ShapeTypes; public String toString(){ return this.getLayerName(); } - + /** * To string * @return String @@ -363,20 +363,20 @@ import org.meteoinfo.geometry.shape.ShapeTypes; str += System.getProperty("line.separator") + "Layer file: " + this.getFileName(); str += System.getProperty("line.separator") + "Layer type: " + this.getLayerType(); str += System.getProperty("line.separator") + "Shape type: " + this.getShapeType(); - + return str; } - + /** * Save layer to a file */ public void saveFile(){} - + /** * Save layer to a file * @param fileName File name */ public void saveFile(String fileName){} // - + } diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/RasterLayer.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/RasterLayer.java index 1604e1c9..86101fdc 100644 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/RasterLayer.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/RasterLayer.java @@ -19,7 +19,7 @@ import org.meteoinfo.common.Extent; import org.meteoinfo.common.GenericFileFilter; import org.meteoinfo.common.MIMath; import org.meteoinfo.common.util.GlobalUtil; -import org.meteoinfo.geometry.legend.LegendScheme; +import org.meteoinfo.data.GridArray; import org.meteoinfo.geometry.legend.LegendScheme; import org.meteoinfo.geometry.shape.ShapeTypes; import java.awt.Color; @@ -32,9 +32,9 @@ import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JFileChooser; import javax.swing.JOptionPane; -import org.meteoinfo.geo.data.GridArray; -import org.meteoinfo.geo.data.mapdata.MapDataManage; -import org.meteoinfo.geo.projection.info.ProjectionInfo; + +import org.meteoinfo.geo.mapdata.MapDataManage; +import org.meteoinfo.projection.ProjectionInfo; import org.meteoinfo.ndarray.Index; /** diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/VectorLayer.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/VectorLayer.java index dadc9dd2..8353e972 100644 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/VectorLayer.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/VectorLayer.java @@ -13,29 +13,14 @@ */ package org.meteoinfo.geo.layer; -import org.meteoinfo.common.Extent; -import org.meteoinfo.common.GenericFileFilter; -import org.meteoinfo.common.MIMath; -import org.meteoinfo.common.PointD; -import org.meteoinfo.table.AttributeTable; -import org.meteoinfo.table.Field; -import org.meteoinfo.geo.data.mapdata.ShapeFileManage; +import org.meteoinfo.common.*; +import org.meteoinfo.geo.mapdata.ShapeFileManage; +import org.meteoinfo.geometry.legend.*; import org.meteoinfo.geometry.geoprocess.GeoComputation; import org.meteoinfo.common.colors.ColorUtil; -import org.meteoinfo.geo.layer.ChartSet; -import org.meteoinfo.geo.layer.LabelSet; -import org.meteoinfo.geo.layer.LayerTypes; -import org.meteoinfo.geo.layer.MapLayer; -import org.meteoinfo.geo.projection.info.ProjectionInfo; -import org.meteoinfo.table.DataColumn; -import org.meteoinfo.table.DataRow; +import org.meteoinfo.projection.ProjectionInfo; +import org.meteoinfo.table.*; import org.meteoinfo.ndarray.DataType; -import org.meteoinfo.geometry.legend.ChartBreak; -import org.meteoinfo.geometry.legend.ColorBreak; -import org.meteoinfo.geometry.legend.LabelBreak; -import org.meteoinfo.geometry.legend.LegendType; -import org.meteoinfo.geometry.legend.PolygonBreak; -import org.meteoinfo.geometry.legend.PolylineBreak; import org.meteoinfo.geometry.graphic.Graphic; import org.meteoinfo.geometry.shape.PointShape; import org.meteoinfo.geometry.shape.PolygonShape; @@ -64,16 +49,12 @@ import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.sax.SAXTransformerFactory; import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.stream.StreamResult; -import org.meteoinfo.common.DataConvert; + import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; import org.locationtech.jts.operation.union.CascadedPolygonUnion; -import org.meteoinfo.table.DataColumnCollection; -import org.meteoinfo.table.DataTable; -import org.meteoinfo.geo.util.LegendManage; -import org.meteoinfo.geometry.legend.LegendScheme; -import org.meteoinfo.geometry.legend.PointBreak; +import org.meteoinfo.geo.legend.LegendManage; import org.meteoinfo.geometry.graphic.ChartGraphic; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/WebMapLayer.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/WebMapLayer.java index 4cf13b2b..06b50021 100644 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/WebMapLayer.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/WebMapLayer.java @@ -24,10 +24,9 @@ import org.meteoinfo.common.Extent; import org.meteoinfo.common.PointD; import org.meteoinfo.data.mapdata.webmap.*; import org.meteoinfo.data.mapdata.webmap.empty.EmptyTileFactory; -import org.meteoinfo.global.util.GeoUtil; import org.meteoinfo.projection.KnownCoordinateSystems; import org.meteoinfo.projection.Reproject; -import org.meteoinfo.shape.ShapeTypes; +import org.meteoinfo.geometry.shape.ShapeTypes; /** * diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/Edge.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/Edge.java similarity index 92% rename from MeteoInfoLib/src/main/java/org/meteoinfo/layout/Edge.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/Edge.java index 9ed6f45f..d09497a5 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/Edge.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/Edge.java @@ -1,31 +1,31 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layout; - -/** - * - * @author yaqiang - */ -public enum Edge { - - None, - TopLeft, - Top, - TopRight, - Right, - BottomRight, - Bottom, - BottomLeft, - Left -} + /* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.layout; + +/** + * + * @author yaqiang + */ +public enum Edge { + + None, + TopLeft, + Top, + TopRight, + Right, + BottomRight, + Bottom, + BottomLeft, + Left +} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/ElementType.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/ElementType.java similarity index 92% rename from MeteoInfoLib/src/main/java/org/meteoinfo/layout/ElementType.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/ElementType.java index 4ca09c94..95603055 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/ElementType.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/ElementType.java @@ -1,29 +1,29 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layout; - -/** - * - * @author yaqiang - */ -public enum ElementType { - - LayoutMap, - LayoutIllustration, - LayoutLegend, - LayoutGraphic, - LayoutScaleBar, - LayoutNorthArraw, - LayoutChart -} +/* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.layout; + +/** + * + * @author yaqiang + */ +public enum ElementType { + + LayoutMap, + LayoutIllustration, + LayoutLegend, + LayoutGraphic, + LayoutScaleBar, + LayoutNorthArraw, + LayoutChart +} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/FrmPageSet.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/FrmPageSet.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/layout/FrmPageSet.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/FrmPageSet.java index 5efe90e3..62d55956 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/FrmPageSet.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/FrmPageSet.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.layout; +package org.meteoinfo.geo.layout; import java.util.ArrayList; import java.util.List; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayerUpdateTypes.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayerUpdateTypes.java similarity index 93% rename from MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayerUpdateTypes.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayerUpdateTypes.java index 08cfd4ba..e809e7ba 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayerUpdateTypes.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayerUpdateTypes.java @@ -1,38 +1,38 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layout; - -/** - * - * @author Yaqiang Wang - */ -public enum LayerUpdateTypes { - /// - /// Not update - /// - - NotUpdate, - /// - /// First meteorological layer - /// - FirstMeteoLayer, - /// - /// Last added layer - /// - LastAddedLayer, - /// - /// First expanded layer - /// - FirstExpandedLayer -} + /* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.layout; + +/** + * + * @author Yaqiang Wang + */ +public enum LayerUpdateTypes { + /// + /// Not update + /// + + NotUpdate, + /// + /// First meteorological layer + /// + FirstMeteoLayer, + /// + /// Last added layer + /// + LastAddedLayer, + /// + /// First expanded layer + /// + FirstExpandedLayer +} diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartElement.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayoutElement.java similarity index 76% rename from meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartElement.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayoutElement.java index 912c60d9..9c74347e 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/ChartElement.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayoutElement.java @@ -11,24 +11,25 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.chart; +package org.meteoinfo.geo.layout; import org.meteoinfo.common.PointF; +import org.meteoinfo.geometry.graphic.ResizeAbility; import org.meteoinfo.ui.event.ILocationChangedListener; import org.meteoinfo.ui.event.ISizeChangedListener; import org.meteoinfo.ui.event.LocationChangedEvent; import org.meteoinfo.ui.event.SizeChangedEvent; import java.awt.Color; +import java.awt.Graphics2D; import java.awt.Rectangle; import javax.swing.event.EventListenerList; -import org.meteoinfo.ui.resize.ResizeAbility; /** * * @author yaqiang */ - public abstract class ChartElement { + public abstract class LayoutElement { // public void addLocationChangedListener(ILocationChangedListener listener) { @@ -75,12 +76,13 @@ import org.meteoinfo.ui.resize.ResizeAbility; // // private final EventListenerList _listeners = new EventListenerList(); - protected float x; - protected float y; - protected float width; - protected float height; - protected Color _foreColor; - protected Color _backColor; + private int _left; + private int _top; + private int _width; + private int _height; + private ElementType _elementType; + private Color _foreColor; + private Color _backColor; private boolean _selected; private ResizeAbility _resizeAbility; private boolean _visible = true; @@ -88,7 +90,7 @@ import org.meteoinfo.ui.resize.ResizeAbility; // // - public ChartElement() { + public LayoutElement() { _foreColor = Color.black; _backColor = Color.white; _selected = false; @@ -116,12 +118,12 @@ import org.meteoinfo.ui.resize.ResizeAbility; } /** - * Get x + * Get left * - * @return x + * @return Left */ - public float getX() { - return x; + public int getLeft() { + return _left; } /** @@ -129,27 +131,27 @@ import org.meteoinfo.ui.resize.ResizeAbility; * * @param left */ - public void setX(float left) { - x = left; + public void setLeft(int left) { + _left = left; this.fireLocationChangedEvent(); } /** - * Get y + * Get top * - * @return Y + * @return Top */ - public float getY() { - return y; + public int getTop() { + return _top; } /** - * Set y + * Set top * - * @param top Y + * @param top Top */ - public void setY(float top) { - y = top; + public void setTop(int top) { + _top = top; this.fireLocationChangedEvent(); } @@ -158,8 +160,8 @@ import org.meteoinfo.ui.resize.ResizeAbility; * * @return Width */ - public float getWidth() { - return width; + public int getWidth() { + return _width; } /** @@ -167,8 +169,8 @@ import org.meteoinfo.ui.resize.ResizeAbility; * * @param width Width */ - public void setWidth(float width) { - this.width = width; + public void setWidth(int width) { + _width = width; this.fireSizeChangedEvent(); } @@ -177,8 +179,8 @@ import org.meteoinfo.ui.resize.ResizeAbility; * * @return Height */ - public float getHeight() { - return height; + public int getHeight() { + return _height; } /** @@ -186,8 +188,8 @@ import org.meteoinfo.ui.resize.ResizeAbility; * * @param height Height */ - public void setHeight(float height) { - this.height = height; + public void setHeight(int height) { + _height = height; this.fireSizeChangedEvent(); } @@ -196,8 +198,8 @@ import org.meteoinfo.ui.resize.ResizeAbility; * * @return Right */ - public float getRight() { - return x + width; + public int getRight() { + return _left + _width; } /** @@ -205,8 +207,8 @@ import org.meteoinfo.ui.resize.ResizeAbility; * * @return Bottom */ - public float getBottom() { - return y + height; + public int getBottom() { + return _top + _height; } /** @@ -214,8 +216,26 @@ import org.meteoinfo.ui.resize.ResizeAbility; * * @return Bounds rectangle */ - public Rectangle.Float getBounds() { - return new Rectangle.Float(x, y, width, height); + public Rectangle getBounds() { + return new Rectangle(_left, _top, _width, _height); + } + + /** + * Get element type + * + * @return The element type + */ + public ElementType getElementType() { + return _elementType; + } + + /** + * Set element type + * + * @param type Element type + */ + public void setElementType(ElementType type) { + _elementType = type; } /** @@ -223,7 +243,7 @@ import org.meteoinfo.ui.resize.ResizeAbility; * * @return Foreground color */ - public Color getForeground() { + public Color getForeColor() { return _foreColor; } @@ -232,7 +252,7 @@ import org.meteoinfo.ui.resize.ResizeAbility; * * @param color Foreground color */ - public void setForeground(Color color) { + public void setForeColor(Color color) { _foreColor = color; } @@ -241,7 +261,7 @@ import org.meteoinfo.ui.resize.ResizeAbility; * * @return Background color */ - public Color getBackground() { + public Color getBackColor() { return _backColor; } @@ -250,7 +270,7 @@ import org.meteoinfo.ui.resize.ResizeAbility; * * @param color Background color */ - public void setBackground(Color color) { + public void setBackColor(Color color) { _backColor = color; } @@ -308,6 +328,22 @@ import org.meteoinfo.ui.resize.ResizeAbility; // // + /** + * Paint method + * + * @param g Graphics2D + */ + public abstract void paint(Graphics2D g); + + /** + * Paint on layout method + * + * @param g Grahpics2D + * @param pageLocation Page location + * @param zoom Zoom + */ + public abstract void paintOnLayout(Graphics2D g, PointF pageLocation, float zoom); + /** * Move update method */ diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutGraphic.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayoutGraphic.java similarity index 98% rename from MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutGraphic.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayoutGraphic.java index a17a0f40..be9c62ec 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutGraphic.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayoutGraphic.java @@ -11,22 +11,23 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.layout; +package org.meteoinfo.geo.layout; import org.meteoinfo.common.DataConvert; import org.meteoinfo.common.Extent; import org.meteoinfo.common.PointD; import org.meteoinfo.common.PointF; -import org.meteoinfo.drawing.Draw; +import org.meteoinfo.geo.drawing.Draw; +import org.meteoinfo.geometry.graphic.ResizeAbility; import org.meteoinfo.geometry.legend.*; import org.meteoinfo.ui.event.IMapViewUpdatedListener; import org.meteoinfo.ui.event.ISizeChangedListener; import org.meteoinfo.ui.event.MapViewUpdatedEvent; import org.meteoinfo.ui.event.SizeChangedEvent; -import org.meteoinfo.layer.LayerDrawType; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layer.VectorLayer; +import org.meteoinfo.geo.layer.LayerDrawType; +import org.meteoinfo.geo.layer.LayerTypes; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.layer.VectorLayer; import org.meteoinfo.geometry.graphic.Graphic; import org.meteoinfo.geometry.shape.PointShape; import org.meteoinfo.geometry.shape.ShapeTypes; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutLegend.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayoutLegend.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutLegend.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayoutLegend.java index 77189d71..fae3523f 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutLegend.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayoutLegend.java @@ -11,18 +11,19 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.layout; +package org.meteoinfo.geo.layout; import org.meteoinfo.common.DataConvert; import org.meteoinfo.common.PointF; -import org.meteoinfo.drawing.Draw; +import org.meteoinfo.geo.drawing.Draw; +import org.meteoinfo.geometry.graphic.ResizeAbility; import org.meteoinfo.geometry.legend.*; import org.meteoinfo.ui.event.IMapViewUpdatedListener; import org.meteoinfo.ui.event.MapViewUpdatedEvent; -import org.meteoinfo.layer.LayerDrawType; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layer.VectorLayer; +import org.meteoinfo.geo.layer.LayerDrawType; +import org.meteoinfo.geo.layer.LayerTypes; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.layer.VectorLayer; import org.meteoinfo.geometry.shape.ShapeTypes; import com.l2fprod.common.beans.BaseBeanInfo; import com.l2fprod.common.beans.ExtendedPropertyDescriptor; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutMap.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayoutMap.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutMap.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayoutMap.java index 98551b11..6ccc1a40 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutMap.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayoutMap.java @@ -11,7 +11,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.layout; +package org.meteoinfo.geo.layout; import com.l2fprod.common.beans.BaseBeanInfo; import com.l2fprod.common.beans.ExtendedPropertyDescriptor; @@ -19,13 +19,14 @@ import com.l2fprod.common.beans.editor.ComboBoxPropertyEditor; import org.meteoinfo.common.Extent; import org.meteoinfo.common.MIMath; import org.meteoinfo.common.PointF; +import org.meteoinfo.geometry.graphic.ResizeAbility; import org.meteoinfo.geometry.legend.LineStyles; import org.meteoinfo.ui.event.ILayersUpdatedListener; import org.meteoinfo.ui.event.IMapViewUpdatedListener; import org.meteoinfo.ui.event.LayersUpdatedEvent; import org.meteoinfo.ui.event.MapViewUpdatedEvent; -import org.meteoinfo.legend.GridLabelPosition; -import org.meteoinfo.legend.MapFrame; +import org.meteoinfo.geo.legend.GridLabelPosition; +import org.meteoinfo.geo.legend.MapFrame; import org.meteoinfo.common.GridLabel; import java.awt.BasicStroke; import java.awt.Color; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutNorthArrow.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayoutNorthArrow.java similarity index 98% rename from MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutNorthArrow.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayoutNorthArrow.java index 958ebf06..7a325c44 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/LayoutNorthArrow.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayoutNorthArrow.java @@ -11,11 +11,12 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.layout; +package org.meteoinfo.geo.layout; import com.l2fprod.common.beans.BaseBeanInfo; import org.meteoinfo.common.PointF; -import org.meteoinfo.drawing.Draw; +import org.meteoinfo.geo.drawing.Draw; +import org.meteoinfo.geometry.graphic.ResizeAbility; import java.awt.BasicStroke; import java.awt.Color; diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayoutScaleBar.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayoutScaleBar.java new file mode 100644 index 00000000..a8c0c39d --- /dev/null +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LayoutScaleBar.java @@ -0,0 +1,731 @@ + /* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.layout; + +import com.l2fprod.common.beans.BaseBeanInfo; +import com.l2fprod.common.beans.ExtendedPropertyDescriptor; +import com.l2fprod.common.beans.editor.ComboBoxPropertyEditor; +import org.meteoinfo.common.PointF; +import org.meteoinfo.geometry.graphic.ResizeAbility; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.RenderingHints; +import java.awt.geom.AffineTransform; +import java.awt.geom.Line2D; + + /** + * + * @author Yaqiang Wang + */ + public class LayoutScaleBar extends LayoutElement { + // + + private LayoutMap _layoutMap; + private boolean _antiAlias; + private Font _font; + private ScaleBarType _scaleBarType; + private ScaleBarUnits _unit; + private String _unitText; + private int _numBreaks; + private boolean _drawNeatLine; + private Color _neatLineColor; + private float _neatLineSize; + private boolean _drawScaleText; + private float _yShiftScale = 2.0f; + // + // + + /** + * Constructor + * + * @param layoutMap The layout map + */ + public LayoutScaleBar(LayoutMap layoutMap) { + super(); + this.setElementType(ElementType.LayoutScaleBar); + this.setResizeAbility(ResizeAbility.ResizeAll); + + this.setWidth(200); + this.setHeight(50); + _layoutMap = layoutMap; + _antiAlias = true; + _scaleBarType = ScaleBarType.SCALELINE_1; + _drawNeatLine = false; + _neatLineColor = Color.black; + _neatLineSize = 1; + _font = new Font("Arial", Font.PLAIN, 12); + _unit = ScaleBarUnits.KILOMETERS; + _unitText = "km"; + _numBreaks = 4; + _drawScaleText = false; + } + // + // + + /** + * Get layout map + * + * @return The layout map + */ + public LayoutMap getLayoutMap() { + return _layoutMap; + } + + /** + * Get scale bar type + * + * @return Scale bar type + */ + public ScaleBarType getScaleBarType() { + return _scaleBarType; + } + + /** + * Set scale bar type + * + * @param type Scale bar type + */ + public void setScaleBarType(ScaleBarType type) { + _scaleBarType = type; + } + + /** + * Get if draw neat line + * + * @return If draw neat line + */ + public boolean isDrawNeatLine() { + return _drawNeatLine; + } + + /** + * Set if draw neat line + * + * @param istrue If draw neat line + */ + public void setDrawNeatLine(boolean istrue) { + _drawNeatLine = istrue; + } + + /** + * Get neat line color + * + * @return Neat line color + */ + public Color getNeatLineColor() { + return _neatLineColor; + } + + /** + * Set neat line color + * + * @param color Neat line color + */ + public void setNeatLineColor(Color color) { + _neatLineColor = color; + } + + /** + * Get neat line size + * + * @return Neat line size + */ + public float getNeatLineSize() { + return _neatLineSize; + } + + /** + * Set neat line size + * + * @param size Neat line size + */ + public void setNeatLineSize(float size) { + _neatLineSize = size; + } + + /** + * Get font + * + * @return The font + */ + public Font getFont() { + return _font; + } + + /** + * Set font + * + * @param font The font + */ + public void setFont(Font font) { + _font = font; + } + + /** + * Get break number + * + * @return The break number + */ + public int getBreakNumber() { + return _numBreaks; + } + + /** + * Set break number + * + * @param num Break number + */ + public void setBreakNumber(int num) { + _numBreaks = num; + } + + /** + * Get if draw scale text + * + * @return If draw scale text + */ + public boolean isDrawScaleText() { + return _drawScaleText; + } + + /** + * Set if draw scale text + * + * @param istrue If draw scale text + */ + public void setDrawScaleText(boolean istrue) { + _drawScaleText = istrue; + } + // + // + + @Override + public void paint(Graphics2D g) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void paintOnLayout(Graphics2D g, PointF pageLocation, float zoom) { + if (this.isVisible()) { + paintGraphics(g, pageLocation, zoom); + } + } + + /** + * Paint graphics + * + * @param g Graphics + * @param pageLocation Page location + * @param zoom Zoom + */ + public void paintGraphics(Graphics2D g, PointF pageLocation, float zoom) { + AffineTransform oldMatrix = g.getTransform(); + PointF aP = pageToScreen(this.getLeft(), this.getTop(), pageLocation, zoom); + g.translate(aP.X, aP.Y); + g.scale(zoom, zoom); + if (_antiAlias) { + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + } else { + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); + } + + //Draw background color + if (this.isDrawBackColor()){ + g.setColor(this.getBackColor()); + g.fill(new Rectangle.Float(0, 0, this.getWidth() * zoom, this.getHeight() * zoom)); + } + + drawScaleBar(g, zoom); + + //Draw neatline + if (_drawNeatLine) { + Rectangle.Float mapRect = new Rectangle.Float(_neatLineSize - 1, _neatLineSize - 1, + (this.getWidth() - _neatLineSize) * zoom, (this.getHeight() - _neatLineSize) * zoom); + g.setColor(_neatLineColor); + g.setStroke(new BasicStroke(_neatLineSize)); + g.draw(mapRect); + } + + g.setTransform(oldMatrix); + } + + private void drawScaleBar(Graphics2D g, float zoom) { + Font aFont = new Font(_font.getFontName(), _font.getStyle(), (int) (_font.getSize() * zoom)); + //Calculates the width of one break in greographic units + FontMetrics metrics = g.getFontMetrics(aFont); + float unitLegnth = metrics.stringWidth(_unitText) * 2; + float widthNoUnit = (this.getWidth() * zoom - unitLegnth); + long geoBreakWidth = (long) (getGeoWidth(widthNoUnit / _numBreaks)); + + //If the geobreakWidth is less than 1 we return and don't draw anything + if (geoBreakWidth < 1) { + return; + } + + double n = Math.pow(10, String.valueOf(geoBreakWidth).length() - 1); + geoBreakWidth = (long) (Math.floor(geoBreakWidth / n) * n); + + long breakWidth = (long) (getWidth(geoBreakWidth)); + FontMetrics metrics1 = g.getFontMetrics(_font); + float fontHeight = metrics1.getHeight() * zoom; + float leftStart = metrics1.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F; + + //Draw scale text + double scale = geoBreakWidth * getConversionFactor(_unit) * 100 / (breakWidth / 96 * 2.539999918) * zoom; + if (_drawScaleText) { + g.setFont(aFont); + g.setColor(this.getForeColor()); + g.drawString("1 : " + String.format("{0:0,0}", scale), + leftStart - (metrics.stringWidth(String.valueOf(Math.abs(0))) / 2), fontHeight * 2.5F); + } + + //Draw scale bar + switch (_scaleBarType) { + case SCALELINE_1: + drawScaleLine1(g, zoom, aFont, breakWidth, geoBreakWidth); + break; + case SCALELINE_2: + drawScaleLine2(g, zoom, aFont, breakWidth, geoBreakWidth); + break; + case ALTERNATING_BAR: + drawAlternatingBar(g, zoom, aFont, breakWidth, geoBreakWidth); + break; + } + } + + private double getConversionFactor(ScaleBarUnits unit) { + switch (unit) { + case KILOMETERS: + return 1000; + default: + return 1; + } + } + + private double getGeoWidth(double width) { + double geoWidth = width / _layoutMap.getMapFrame().getMapView().getXScale() / getConversionFactor(_unit); + if (_layoutMap.getMapFrame().getMapView().getProjection().isLonLatMap()) { + geoWidth = geoWidth * getLonDistScale(); + } + + return geoWidth; + } + + private double getWidth(double geoWidth) { + double width = geoWidth * _layoutMap.getMapFrame().getMapView().getXScale() * getConversionFactor(_unit); + if (_layoutMap.getMapFrame().getMapView().getProjection().isLonLatMap()) { + width = width / getLonDistScale(); + } + + return width; + } + + private double getLonDistScale() { + //Get meters of one longitude degree + double pY = (_layoutMap.getMapFrame().getMapView().getViewExtent().maxY + _layoutMap.getMapFrame().getMapView().getViewExtent().minY) / 2; + double ProjX = 0, ProjY = pY, pProjX = 1, pProjY = pY; + double dx = Math.abs(ProjX - pProjX); + double dy = Math.abs(ProjY - pProjY); + double dist; + double y = (ProjY + pProjY) / 2; + double factor = Math.cos(y * Math.PI / 180); + dx *= factor; + dist = Math.sqrt(dx * dx + dy * dy); + dist = dist * 111319.5; + + return dist; + } + + private void drawScaleLine1(Graphics2D g, float zoom, Font aFont, long breakWidth, long geoBreakWidth) { + FontMetrics metrics = g.getFontMetrics(_font); + float fontHeight = metrics.getHeight() * zoom; + float leftStart = metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F; + int yShift = 10; + + g.setColor(this.getForeColor()); + g.setStroke(new BasicStroke(zoom)); + g.draw(new Line2D.Float(leftStart, fontHeight * 1.6f + yShift, leftStart + (breakWidth * _numBreaks), fontHeight * 1.6f + yShift)); + FontMetrics metrics1 = g.getFontMetrics(aFont); + g.setFont(aFont); + for (int i = 0; i <= _numBreaks; i++) { + g.draw(new Line2D.Float(leftStart, fontHeight * 1.1f + yShift, leftStart, fontHeight * 1.6f + yShift)); + g.drawString(String.valueOf(Math.abs(geoBreakWidth * i)), + leftStart - (metrics1.stringWidth(String.valueOf(Math.abs(geoBreakWidth * i))) / 2), yShift * _yShiftScale); + leftStart = leftStart + breakWidth; + } + g.drawString(_unitText, leftStart - breakWidth + (fontHeight / 2), fontHeight * 1.1f + yShift * _yShiftScale); + } + + private void drawScaleLine2(Graphics2D g, float zoom, Font aFont, long breakWidth, long geoBreakWidth) { + FontMetrics metrics = g.getFontMetrics(_font); + float fontHeight = metrics.getHeight() * zoom; + float leftStart = metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F; + int yShift = 5; + + g.setColor(this.getForeColor()); + g.draw(new Line2D.Float(leftStart, fontHeight * 1.6f + yShift, leftStart + (breakWidth * _numBreaks), fontHeight * 1.6f + yShift)); + FontMetrics metrics1 = g.getFontMetrics(aFont); + g.setFont(aFont); + for (int i = 0; i <= _numBreaks; i++) { + g.draw(new Line2D.Float(leftStart, fontHeight * 1.1f + yShift, leftStart, fontHeight + (fontHeight * 1.1f) + yShift)); + g.drawString(String.valueOf(Math.abs(geoBreakWidth * i)), + leftStart - (metrics1.stringWidth(String.valueOf(Math.abs(geoBreakWidth * i))) / 2), yShift * _yShiftScale); + leftStart = leftStart + breakWidth; + } + g.drawString(_unitText, leftStart - breakWidth + (fontHeight / 2), fontHeight * 1.1f + yShift * _yShiftScale); + } + + private void drawAlternatingBar(Graphics2D g, float zoom, Font aFont, long breakWidth, long geoBreakWidth) { + FontMetrics metrics = g.getFontMetrics(_font); + float fontHeight = metrics.getHeight() * zoom; + float leftStart = metrics.stringWidth(String.valueOf(Math.abs(geoBreakWidth))) / 2F; + int yShift = 5; + float rHeight = fontHeight / 2; + FontMetrics metrics1 = g.getFontMetrics(aFont); + + boolean isFill = false; + for (int i = 0; i <= _numBreaks; i++) { + if (i < _numBreaks) { + if (isFill) { + g.setColor(this.getForeColor()); + g.fill(new Rectangle.Float(leftStart, fontHeight * 1.1f + yShift, breakWidth, rHeight)); + } else { + g.setColor(this.getForeColor()); + g.draw(new Rectangle.Float(leftStart, fontHeight * 1.1f + yShift, breakWidth, rHeight)); + } + } + + g.setColor(this.getForeColor()); + g.setFont(aFont); + g.drawString(String.valueOf(Math.abs(geoBreakWidth * i)), + leftStart - (metrics1.stringWidth(String.valueOf(Math.abs(geoBreakWidth * i))) / 2), yShift * _yShiftScale); + leftStart = leftStart + breakWidth; + isFill = !isFill; + } + g.setColor(this.getForeColor()); + g.setFont(aFont); + g.drawString(_unitText, leftStart - breakWidth + (fontHeight / 2), fontHeight * 1.1f + yShift * _yShiftScale); + } + + @Override + public void moveUpdate() { + } + + @Override + public void resizeUpdate() { + } + // + // + + public class LayoutScaleBarBean { + + LayoutScaleBarBean() { + } + // + + /** + * Get scale bar type + * + * @return Scale bar type + */ + public String getScaleBarType() { + return _scaleBarType.toString(); + } + + /** + * Set scale bar type + * + * @param type Scale bar type + */ + public void setScaleBarType(String type) { + _scaleBarType = ScaleBarType.valueOf(type); + } + + /** + * Get if draw neat line + * + * @return If draw neat line + */ + public boolean isDrawNeatLine() { + return _drawNeatLine; + } + + /** + * Set if draw neat line + * + * @param istrue If draw neat line + */ + public void setDrawNeatLine(boolean istrue) { + _drawNeatLine = istrue; + } + + /** + * Get neat line color + * + * @return Neat line color + */ + public Color getNeatLineColor() { + return _neatLineColor; + } + + /** + * Set neat line color + * + * @param color Neat line color + */ + public void setNeatLineColor(Color color) { + _neatLineColor = color; + } + + /** + * Get neat line size + * + * @return Neat line size + */ + public float getNeatLineSize() { + return _neatLineSize; + } + + /** + * Set neat line size + * + * @param size Neat line size + */ + public void setNeatLineSize(float size) { + _neatLineSize = size; + } + + /** + * Get font + * + * @return The font + */ + public Font getFont() { + return _font; + } + + /** + * Set font + * + * @param font The font + */ + public void setFont(Font font) { + _font = font; + } + + /** + * Get break number + * + * @return The break number + */ + public int getBreakNumber() { + return _numBreaks; + } + + /** + * Set break number + * + * @param num Break number + */ + public void setBreakNumber(int num) { + _numBreaks = num; + } + + /** + * Get if draw scale text + * + * @return If draw scale text + */ + public boolean isDrawScaleText() { + return _drawScaleText; + } + + /** + * Set if draw scale text + * + * @param istrue If draw scale text + */ + public void setDrawScaleText(boolean istrue) { + _drawScaleText = istrue; + } + + /** + * Get is draw backcolor + * @return Boolean + */ + public boolean isDrawBackColor(){ + return LayoutScaleBar.this.isDrawBackColor(); + } + + /** + * Set is draw backcolor + * @param value Boolean + */ + public void setDrawBackColor(boolean value){ + LayoutScaleBar.this.setDrawBackColor(value); + } + + /** + * Get background color + * + * @return Background color + */ + public Color getBackColor() { + return LayoutScaleBar.this.getBackColor(); + } + + /** + * Set background color + * + * @param c Background color + */ + public void setBackColor(Color c) { + LayoutScaleBar.this.setBackColor(c); + } + + /** + * Get foreground color + * + * @return Foreground color + */ + public Color getForeColor() { + return LayoutScaleBar.this.getForeColor(); + } + + /** + * Set foreground color + * + * @param c Foreground color + */ + public void setForeColor(Color c) { + LayoutScaleBar.this.setForeColor(c); + } + + /** + * Get left + * + * @return Left + */ + public int getLeft() { + return LayoutScaleBar.this.getLeft(); + } + + /** + * Set left + * + * @param left Left + */ + public void setLeft(int left) { + LayoutScaleBar.this.setLeft(left); + } + + /** + * Get top + * + * @return Top + */ + public int getTop() { + return LayoutScaleBar.this.getTop(); + } + + /** + * Set top + * + * @param top Top + */ + public void setTop(int top) { + LayoutScaleBar.this.setTop(top); + } + + /** + * Get width + * + * @return Width + */ + public int getWidth() { + return LayoutScaleBar.this.getWidth(); + } + + /** + * Set width + * + * @param width Width + */ + public void setWidth(int width) { + LayoutScaleBar.this.setWidth(width); + } + + /** + * Get height + * + * @return Height + */ + public int getHeight() { + return LayoutScaleBar.this.getHeight(); + } + + /** + * Set height + * + * @param height Height + */ + public void setHeight(int height) { + LayoutScaleBar.this.setHeight(height); + } + // + } + + public static class LayoutScaleBarBeanBeanInfo extends BaseBeanInfo { + + public LayoutScaleBarBeanBeanInfo() { + super(LayoutScaleBarBean.class); + ExtendedPropertyDescriptor e = addProperty("scaleBarType"); + e.setCategory("General").setDisplayName("Scale Bar Type"); + e.setPropertyEditorClass(ScaleBarTypeEditor.class); + addProperty("drawBackColor").setCategory("General").setDisplayName("Draw Background"); + addProperty("backColor").setCategory("General").setDisplayName("Background"); + addProperty("foreColor").setCategory("General").setDisplayName("Foreground"); + addProperty("font").setCategory("General").setDisplayName("Font"); + addProperty("drawScaleText").setCategory("General").setDisplayName("Draw Scale Text"); + addProperty("drawNeatLine").setCategory("Neat Line").setDisplayName("Draw Neat Line"); + addProperty("neatLineColor").setCategory("Neat Line").setDisplayName("Neat Line Color"); + addProperty("neatLineSize").setCategory("Neat Line").setDisplayName("Neat Line Size"); + addProperty("left").setCategory("Location").setDisplayName("Left"); + addProperty("top").setCategory("Location").setDisplayName("Top"); + addProperty("width").setCategory("Location").setDisplayName("Width"); + addProperty("height").setCategory("Location").setDisplayName("Height"); + } + } + + public static class ScaleBarTypeEditor extends ComboBoxPropertyEditor { + + public ScaleBarTypeEditor() { + super(); + ScaleBarType[] lutypes = ScaleBarType.values(); + String[] types = new String[lutypes.length]; + int i = 0; + for (ScaleBarType type : lutypes) { + types[i] = type.toString(); + i += 1; + } + setAvailableValues(types); + } + } + // + } diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/LegendStyles.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LegendStyles.java similarity index 93% rename from MeteoInfoLib/src/main/java/org/meteoinfo/layout/LegendStyles.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LegendStyles.java index cbfbbe90..094379e8 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/LegendStyles.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/LegendStyles.java @@ -1,34 +1,34 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layout; - -/** - * - * @author Yaqiang - */ -public enum LegendStyles { - /// - /// vertical bar - /// - - Bar_Vertical, - /// - /// horizontal bar - /// - Bar_Horizontal, - /// - /// normal - /// - Normal -} + /* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.layout; + +/** + * + * @author Yaqiang + */ +public enum LegendStyles { + /// + /// vertical bar + /// + + Bar_Vertical, + /// + /// horizontal bar + /// + Bar_Horizontal, + /// + /// normal + /// + Normal +} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/MapLayout.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/MapLayout.java new file mode 100644 index 00000000..18e45fa7 --- /dev/null +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/MapLayout.java @@ -0,0 +1,4445 @@ + /* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.layout; + +import com.itextpdf.awt.PdfGraphics2D; +import com.itextpdf.text.DocumentException; +import com.itextpdf.text.pdf.PdfContentByte; +import com.itextpdf.text.pdf.PdfTemplate; +import com.itextpdf.text.pdf.PdfWriter; +import org.meteoinfo.common.MIMath; +import org.meteoinfo.common.PointD; +import org.meteoinfo.common.PointF; +import org.meteoinfo.common.util.GlobalUtil; +import org.meteoinfo.geo.drawing.Draw; +import org.meteoinfo.geometry.legend.*; +import org.meteoinfo.geo.analysis.GeoComputation; +import org.meteoinfo.common.colors.ColorUtil; +import org.meteoinfo.ui.event.ActiveMapFrameChangedEvent; +import org.meteoinfo.ui.event.ElementSelectedEvent; +import org.meteoinfo.ui.event.IActiveMapFrameChangedListener; +import org.meteoinfo.ui.event.IElementSelectedListener; +import org.meteoinfo.ui.event.IMapFramesUpdatedListener; +import org.meteoinfo.ui.event.IMapViewUpdatedListener; +import org.meteoinfo.ui.event.IZoomChangedListener; +import org.meteoinfo.ui.event.MapFramesUpdatedEvent; +import org.meteoinfo.ui.event.MapViewUpdatedEvent; +import org.meteoinfo.ui.event.ZoomChangedEvent; +import org.meteoinfo.geo.gui.FrmMeasurement; +import org.meteoinfo.geo.gui.FrmMeasurement.MeasureTypes; +import org.meteoinfo.geo.gui.FrmProperty; +import org.meteoinfo.geo.layer.LayerTypes; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.layer.VectorLayer; +import org.meteoinfo.geo.legend.FrmLabelSymbolSet; +import org.meteoinfo.geo.legend.FrmPointSymbolSet; +import org.meteoinfo.geo.legend.FrmPolygonSymbolSet; +import org.meteoinfo.geo.legend.FrmPolylineSymbolSet; +import org.meteoinfo.geo.legend.GridLabelPosition; +import org.meteoinfo.geo.legend.MapFrame; +import org.meteoinfo.geo.mapview.FrmIdentifer; +import org.meteoinfo.geometry.shape.CircleShape; +import org.meteoinfo.geometry.shape.CurveLineShape; +import org.meteoinfo.geometry.shape.CurvePolygonShape; +import org.meteoinfo.geometry.shape.EllipseShape; +import org.meteoinfo.geometry.graphic.Graphic; +import org.meteoinfo.geometry.shape.PointShape; +import org.meteoinfo.geometry.shape.PolygonShape; +import org.meteoinfo.geometry.shape.PolylineShape; +import org.meteoinfo.geometry.shape.RectangleShape; +import org.meteoinfo.geometry.shape.ShapeTypes; +import org.meteoinfo.geometry.shape.WindArrow; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.AdjustmentEvent; +import java.awt.event.AdjustmentListener; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.geom.AffineTransform; +import java.awt.image.AffineTransformOp; +import java.awt.image.BufferedImage; +import java.awt.print.PageFormat; +import java.awt.print.Printable; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.imageio.IIOImage; +import javax.imageio.ImageIO; +import javax.imageio.ImageTypeSpecifier; +import javax.imageio.ImageWriteParam; +import javax.imageio.ImageWriter; +import javax.imageio.metadata.IIOMetadata; +import javax.imageio.plugins.jpeg.JPEGImageWriteParam; +import javax.imageio.stream.ImageOutputStream; +import javax.print.DocFlavor; +import javax.print.DocPrintJob; +import javax.print.PrintException; +import javax.print.PrintService; +import javax.print.SimpleDoc; +import javax.print.StreamPrintServiceFactory; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JScrollBar; +import javax.swing.JSeparator; +import javax.swing.SwingUtilities; +import javax.swing.event.EventListenerList; +import javax.swing.table.DefaultTableModel; +import javax.swing.undo.UndoableEdit; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import org.freehep.graphics2d.VectorGraphics; +import org.freehep.graphicsio.emf.EMFGraphics2D; +import org.freehep.graphicsio.ps.PSGraphics2D; +import org.meteoinfo.data.mapdata.webmap.IWebMapPanel; +import org.meteoinfo.data.mapdata.webmap.TileLoadListener; +import org.meteoinfo.ui.event.IUndoEditListener; +import org.meteoinfo.ui.event.UndoEditEvent; +import org.meteoinfo.image.ImageUtil; +import org.meteoinfo.geo.layer.RasterLayer; +import org.meteoinfo.geo.layer.WebMapLayer; +import org.meteoinfo.geo.mapview.FrmIdentiferGrid; +import org.meteoinfo.geo.mapview.MapView; +import org.meteoinfo.geometry.shape.Shape; +import org.w3c.dom.Attr; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + + /** + * + * @author yaqiang + */ + public class MapLayout extends JPanel implements IWebMapPanel { + + // + private final EventListenerList _listeners = new EventListenerList(); + private final TileLoadListener tileLoadListener = new TileLoadListener(this); + private FrmIdentifer frmIdentifier = null; + private FrmIdentiferGrid frmIdentifierGrid = null; + private FrmMeasurement _frmMeasure = null; + private JScrollBar _vScrollBar; + private JScrollBar _hScrollBar; + private boolean _lockViewUpdate = false; + private List _mapFrames = new ArrayList<>(); + private final List _layoutElements = new ArrayList<>(); + private LayoutMap _currentLayoutMap; + private BufferedImage _layoutBitmap = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB); + private BufferedImage _tempImage = null; + private boolean newPaint = false; + private boolean doubleBuffer = true; + private boolean _antiAlias = false; + private FrmLabelSymbolSet _frmLabelSymbolSet = null; + private FrmPointSymbolSet _frmPointSymbolSet = null; + private FrmPolylineSymbolSet _frmPolylineSymbolSet = null; + private FrmPolygonSymbolSet _frmPolygonSymbolSet = null; + private Rectangle _pageBounds; + private Color _pageForeColor = Color.black; + private Color _pageBackColor = Color.white; + private PaperSize _paperSize = new PaperSize(); + private final List _paperSizeList = new ArrayList<>(); + private boolean _isLandscape; + private float _zoom = 1.0f; + private PointF _pageLocation = new PointF(0, 0); + private PointBreak _defPointBreak = new PointBreak(); + private LabelBreak _defLabelBreak = new LabelBreak(); + private PolylineBreak _defPolylineBreak = new PolylineBreak(); + private PolygonBreak _defPolygonBreak = new PolygonBreak(); + private final int _xShift = 0; + private final int _yShift = 0; + private MouseMode _mouseMode = MouseMode.Default; + private List _selectedElements = new ArrayList<>(); + private Rectangle _selectedRectangle = new Rectangle(); + private final Point _mouseDownPos = new Point(0, 0); + private Point _mouseLastPos = new Point(0, 0); + private final Point _mouseDownPoint = new Point(0, 0); + private Edge _resizeSelectedEdge = Edge.None; + private boolean _startNewGraphic = true; + private List _graphicPoints = new ArrayList<>(); + private final List _editingVertices = new ArrayList<>(); + private int _editingVerticeIndex; + private boolean _dragMode = false; + // + + // + public MapLayout() { + super(); + this.setLayout(new BorderLayout()); + initComponents(); + + this.addComponentListener(new ComponentAdapter() { + @Override + public void componentResized(ComponentEvent e) { + onComponentResized(e); + } + }); + this.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + try { + onMouseClicked(e); + } catch (CloneNotSupportedException ex) { + Logger.getLogger(MapLayout.class.getName()).log(Level.SEVERE, null, ex); + } + } + + @Override + public void mousePressed(MouseEvent e) { + onMousePressed(e); + } + + @Override + public void mouseReleased(MouseEvent e) { + try { + onMouseReleased(e); + } catch (CloneNotSupportedException ex) { + Logger.getLogger(MapLayout.class.getName()).log(Level.SEVERE, null, ex); + } + } + }); + this.addMouseMotionListener(new MouseMotionAdapter() { + @Override + public void mouseMoved(MouseEvent e) { + onMouseMoved(e); + } + + @Override + public void mouseDragged(MouseEvent e) { + onMouseDragged(e); + } + }); + // this.addMouseWheelListener(new MouseWheelListener() { + // @Override + // public void mouseWheelMoved(MouseWheelEvent e) { + // onMouseWheelMoved(e); + // } + // }); + this.addKeyListener(new KeyListener() { + @Override + public void keyTyped(KeyEvent e) { + } + + @Override + public void keyPressed(KeyEvent e) { + onKeyPressed(e); + } + + @Override + public void keyReleased(KeyEvent e) { + } + }); + + this.setBackground(Color.lightGray); + this.setForeground(Color.black); + //Set page + PaperSize aPS = new PaperSize("A4", 827, 1169); + _paperSizeList.add(aPS); + aPS = new PaperSize("Letter", 850, 1100); + _paperSizeList.add(aPS); + aPS = new PaperSize("A5", 583, 827); + _paperSizeList.add(aPS); + aPS = new PaperSize("Custom", 500, 750); + _paperSizeList.add(aPS); + _isLandscape = true; + + //Set default size + _pageBounds = new Rectangle(); + _pageBounds.x = 0; + _pageBounds.y = 0; + _pageBounds.width = 730; + _pageBounds.height = 480; + _zoom = 1.0F; + this.setPaperSize(aPS); + + //Add a default map frame + MapFrame aMF = new MapFrame(); + aMF.setActive(true); + aMF.setLayoutBounds(new Rectangle(40, 36, 606, 420)); + _mapFrames.add(aMF); + LayoutMap layoutMap = new LayoutMap(aMF, this.tileLoadListener); + this.addElement(layoutMap); + + _defPointBreak.setSize(10); + _defLabelBreak.setText("Text"); + _defLabelBreak.setFont(new Font(GlobalUtil.getDefaultFontName(), Font.PLAIN, 12)); + _defPolylineBreak.setColor(Color.red); + _defPolylineBreak.setWidth(2); + _defPolygonBreak.setColor(new Color(104, 255, 104, 125)); + } + + private void initComponents() { + _vScrollBar = new JScrollBar(JScrollBar.VERTICAL); + _vScrollBar.addAdjustmentListener(new AdjustmentListener() { + @Override + public void adjustmentValueChanged(AdjustmentEvent e) { + onScrollValueChanged(e); + } + }); + this.add(_vScrollBar, BorderLayout.EAST); + + _hScrollBar = new JScrollBar(JScrollBar.HORIZONTAL); + _hScrollBar.addAdjustmentListener(new AdjustmentListener() { + @Override + public void adjustmentValueChanged(AdjustmentEvent e) { + onScrollValueChanged(e); + } + }); + this.add(_hScrollBar, BorderLayout.SOUTH); + + this._vScrollBar.setLocation(this.getWidth() - this._vScrollBar.getWidth(), 0); + if (this._hScrollBar.isVisible()) { + this._vScrollBar.setSize(21, this.getHeight() - 21); + } else { + this._vScrollBar.setSize(21, this.getHeight()); + } + + this._hScrollBar.setLocation(0, this.getHeight() - this._hScrollBar.getHeight()); + if (this._vScrollBar.isVisible()) { + this._hScrollBar.setSize(this.getWidth() - 21, 21); + } else { + this._hScrollBar.setSize(this.getWidth(), 21); + } + } + // + + // + public void addMapFramesUpdatedListener(IMapFramesUpdatedListener listener) { + this._listeners.add(IMapFramesUpdatedListener.class, listener); + } + + public void removeMapFramesUpdatedListener(IMapFramesUpdatedListener listener) { + this._listeners.remove(IMapFramesUpdatedListener.class, listener); + } + + public void fireMapFramesUpdatedEvent() { + fireMapFramesUpdatedEvent(new MapFramesUpdatedEvent(this)); + } + + private void fireMapFramesUpdatedEvent(MapFramesUpdatedEvent event) { + Object[] listeners = _listeners.getListenerList(); + for (int i = 0; i < listeners.length; i = i + 2) { + if (listeners[i] == IMapFramesUpdatedListener.class) { + ((IMapFramesUpdatedListener) listeners[i + 1]).mapFramesUpdatedEvent(event); + } + } + } + + public void addActiveMapFrameChangedListener(IActiveMapFrameChangedListener listener) { + this._listeners.add(IActiveMapFrameChangedListener.class, listener); + } + + public void removeActiveMapFrameChangedListener(IActiveMapFrameChangedListener listener) { + this._listeners.remove(IActiveMapFrameChangedListener.class, listener); + } + + public void fireActiveMapFrameChangedEvent() { + fireActiveMapFrameChangedEvent(new ActiveMapFrameChangedEvent(this)); + } + + private void fireActiveMapFrameChangedEvent(ActiveMapFrameChangedEvent event) { + Object[] listeners = _listeners.getListenerList(); + for (int i = 0; i < listeners.length; i = i + 2) { + if (listeners[i] == IActiveMapFrameChangedListener.class) { + ((IActiveMapFrameChangedListener) listeners[i + 1]).activeMapFrameChangedEvent(event); + } + } + } + + public void addElementSelectedListener(IElementSelectedListener listener) { + this._listeners.add(IElementSelectedListener.class, listener); + } + + public void removeElementSelectedListener(IElementSelectedListener listener) { + this._listeners.remove(IElementSelectedListener.class, listener); + } + + public void fireElementSelectedEvent() { + fireElementSelectedEvent(new ElementSelectedEvent(this)); + } + + private void fireElementSelectedEvent(ElementSelectedEvent event) { + Object[] listeners = _listeners.getListenerList(); + for (int i = 0; i < listeners.length; i = i + 2) { + if (listeners[i] == IElementSelectedListener.class) { + ((IElementSelectedListener) listeners[i + 1]).elementSelectedEvent(event); + } + } + } + + public void addZoomChangedListener(IZoomChangedListener listener) { + this._listeners.add(IZoomChangedListener.class, listener); + } + + public void removeZoomChangedListener(IZoomChangedListener listener) { + this._listeners.remove(IZoomChangedListener.class, listener); + } + + public void fireZoomChangedEvent() { + fireZoomChangedEvent(new ZoomChangedEvent(this)); + } + + private void fireZoomChangedEvent(ZoomChangedEvent event) { + Object[] listeners = _listeners.getListenerList(); + for (int i = 0; i < listeners.length; i = i + 2) { + if (listeners[i] == IZoomChangedListener.class) { + ((IZoomChangedListener) listeners[i + 1]).zoomChangedEvent(event); + } + } + } + + public void addUndoEditListener(IUndoEditListener listener) { + this._listeners.add(IUndoEditListener.class, listener); + } + + public void removeUndoEditListener(IUndoEditListener listener) { + this._listeners.remove(IUndoEditListener.class, listener); + } + + public void fireUndoEditEvent(UndoableEdit undoEdit) { + fireUndoEditEvent(new UndoEditEvent(this), undoEdit); + } + + private void fireUndoEditEvent(UndoEditEvent event, UndoableEdit undoEdit) { + Object[] listeners = _listeners.getListenerList(); + for (int i = 0; i < listeners.length; i = i + 2) { + if (listeners[i] == IUndoEditListener.class) { + ((IUndoEditListener) listeners[i + 1]).undoEditEvent(event, undoEdit); + } + } + } + + public void onScrollValueChanged(AdjustmentEvent e) { + if (e.getSource() == _vScrollBar) { + //_vScrollBar.setValue(e.getValue()); + //this._yShift = - this._vScrollBar.getValue(); + int y = -e.getValue(); + if (y == 1) { + y = 0; + } + this._pageLocation.Y = y; + } + if (e.getSource() == _hScrollBar) { + //_hScrollBar.setValue(e.getValue()); + //this._xShift = - this._hScrollBar.getValue(); + int x = -e.getValue(); + if (x == 1) { + x = 0; + } + this._pageLocation.X = x; + } + //this.paintGraphics(); + this.repaintNew(); + //this.repaint(); + } + + void onComponentResized(ComponentEvent e) { + if (this.getWidth() > 0 && this.getHeight() > 0) { + this._vScrollBar.setLocation(this.getWidth() - this._vScrollBar.getWidth(), 0); + if (this._hScrollBar.isVisible()) { + this._vScrollBar.setSize(this._vScrollBar.getWidth(), this.getHeight() - this._vScrollBar.getWidth()); + } else { + this._vScrollBar.setSize(this._vScrollBar.getWidth(), this.getHeight()); + } + + this._hScrollBar.setLocation(0, this.getHeight() - this._hScrollBar.getHeight()); + if (this._vScrollBar.isVisible()) { + this._hScrollBar.setSize(this.getWidth() - this._hScrollBar.getHeight(), this._hScrollBar.getHeight()); + } else { + this._hScrollBar.setSize(this.getWidth(), this._hScrollBar.getHeight()); + } + + //this.paintGraphics(); + this.repaintNew(); + } + } + + void onMousePressed(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1) { + //int left = e.getX(); + //int top = e.getY(); + Point pageP = screenToPage(e.getX(), e.getY()); + Graphics2D g = (Graphics2D) this.getGraphics(); + LayoutMap aLM = getLayoutMap(pageP); + if (aLM != null) { + _currentLayoutMap = aLM; + } + + switch (_mouseMode) { + case Map_Pan: + Rectangle mapRect = pageToScreen(_currentLayoutMap.getBounds()); + _tempImage = new BufferedImage(mapRect.width - 2, + mapRect.height - 2, BufferedImage.TYPE_INT_ARGB); + Graphics2D tg = _tempImage.createGraphics(); + tg.setColor(_currentLayoutMap.getMapFrame().getMapView().getBackground()); + tg.fill(mapRect); + tg.drawImage(_layoutBitmap, -mapRect.x - 1, -mapRect.y - 1, this); + tg.dispose(); + break; + case Select: + List tempGraphics = selectElements(pageP, _selectedElements, 3); + if (tempGraphics.size() > 0) { + _selectedRectangle = (Rectangle) _selectedElements.get(0).getBounds().clone(); + _selectedRectangle = pageToScreen(_selectedRectangle); + if (_resizeSelectedEdge == Edge.None) { + _mouseMode = MouseMode.MoveSelection; + } else { + _mouseMode = MouseMode.ResizeSelected; + } + } else { + _mouseMode = MouseMode.CreateSelection; + } + + break; + case New_Point: + PointShape aPS = new PointShape(); + aPS.setPoint(new PointD(pageP.x, pageP.y)); + Graphic aGraphic = new Graphic(aPS, (PointBreak) _defPointBreak.clone()); + LayoutGraphic aLayoutGraphic = new LayoutGraphic(aGraphic, this); + addElement(aLayoutGraphic); + //this.paintGraphics(); + this.repaintNew(); + UndoableEdit edit = (new MapLayoutUndoRedo()).new AddElementEdit(this, aLayoutGraphic); + this.fireUndoEditEvent(edit); + break; + case New_Label: + aPS = new PointShape(); + aPS.setPoint(new PointD(pageP.x, pageP.y)); + aGraphic = new Graphic(aPS, (LabelBreak) _defLabelBreak.clone()); + aLayoutGraphic = new LayoutGraphic(aGraphic, this); + addElement(aLayoutGraphic); + //this.paintGraphics(); + this.repaintNew(); + edit = (new MapLayoutUndoRedo()).new AddElementEdit(this, aLayoutGraphic); + this.fireUndoEditEvent(edit); + break; + case New_Polyline: + case New_Polygon: + case New_Curve: + case New_CurvePolygon: + case New_Freehand: + case Map_SelectFeatures_Polygon: + case Map_SelectFeatures_Lasso: + if (_startNewGraphic) { + _graphicPoints = new ArrayList<>(); + _startNewGraphic = false; + } + _graphicPoints.add(new PointF(e.getX(), e.getY())); + break; + case EditVertices: + if (_selectedElements.size() > 0) { + _editingVerticeIndex = selectEditVertices(pageP, ((LayoutGraphic) _selectedElements.get(0)).getGraphic().getShape(), + _editingVertices); + if (_editingVerticeIndex >= 0) { + _mouseMode = MouseMode.InEditingVertices; + } + } + break; + case Map_Measurement: + if (_frmMeasure == null) { + break; + } + if (_frmMeasure.isVisible()) { + switch (_frmMeasure.getMeasureType()) { + case Length: + case Area: + if (_startNewGraphic) { + _graphicPoints = new ArrayList<>(); + _startNewGraphic = false; + } + _frmMeasure.setPreviousValue(_frmMeasure.getTotalValue()); + _graphicPoints.add(new PointF(e.getX(), e.getY())); + break; + case Feature: + MapLayer aMLayer = _currentLayoutMap.getMapFrame().getMapView().getSelectedLayer(); + if (aMLayer != null) { + if (aMLayer.getLayerType() == LayerTypes.VectorLayer) { + VectorLayer aLayer = (VectorLayer) aMLayer; + if (aLayer.getShapeType() != ShapeTypes.Point) { + PointF mapP = pageToScreen(_currentLayoutMap.getLeft(), _currentLayoutMap.getTop()); + PointF aPoint = new PointF(e.getX() - mapP.X, e.getY() - mapP.Y); + List selectedShapes = _currentLayoutMap.getMapFrame().getMapView().selectShapes(aLayer, aPoint); + if (selectedShapes.size() > 0) { + int shapeIdx = selectedShapes.get(0); + Shape aShape = aLayer.getShapes().get(shapeIdx); + aLayer.setIdentiferShape(shapeIdx); + _currentLayoutMap.getMapFrame().getMapView().setDrawIdentiferShape(true); + //this.repaint(); + this.repaintOld(); + //_currentLayoutMap.getMapFrame().getMapView().drawIdShape((Graphics2D) this.getGraphics(), aLayer.getShapes().get(shapeIdx), rect); + double value = 0.0; + switch (aShape.getShapeType()) { + case Polyline: + case PolylineZ: + _frmMeasure.setArea(false); + if (_currentLayoutMap.getMapFrame().getMapView().getProjection().isLonLatMap()) { + value = GeoComputation.getDistance(((PolylineShape) aShape).getPoints(), true); + } else { + value = ((PolylineShape) aShape).getLength(); + value *= _currentLayoutMap.getMapFrame().getMapView().getProjection().getProjInfo().getCoordinateReferenceSystem().getProjection().getFromMetres(); + } + break; + case Polygon: + case PolygonM: + case PolygonZ: + _frmMeasure.setArea(true); + if (_currentLayoutMap.getMapFrame().getMapView().getProjection().isLonLatMap()) { + value = ((PolygonShape) aShape).getSphericalArea(); + } else { + value = ((PolygonShape) aShape).getArea(); + } + value *= _currentLayoutMap.getMapFrame().getMapView().getProjection().getProjInfo().getCoordinateReferenceSystem().getProjection().getFromMetres() + * _currentLayoutMap.getMapFrame().getMapView().getProjection().getProjInfo().getCoordinateReferenceSystem().getProjection().getFromMetres(); + break; + } + _frmMeasure.setCurrentValue(value); + } + } + } + } + break; + } + } + break; + } + } else if (e.getButton() == MouseEvent.BUTTON3) { + switch (_mouseMode) { + case Map_Measurement: + if (_frmMeasure.isVisible()) { + switch (_frmMeasure.getMeasureType()) { + case Length: + case Area: + _startNewGraphic = true; + _frmMeasure.setTotalValue(0); + break; + } + } + break; + } + } + + _mouseDownPoint.x = e.getX(); + _mouseDownPoint.y = e.getY(); + _mouseLastPos = new Point(_mouseDownPoint.x, _mouseDownPoint.y); + } + + void onMouseDragged(MouseEvent e) { + _dragMode = true; + int deltaX = e.getX() - _mouseLastPos.x; + int deltaY = e.getY() - _mouseLastPos.y; + _mouseLastPos.x = e.getX(); + _mouseLastPos.y = e.getY(); + + Point pageP = screenToPage(e.getX(), e.getY()); + + Graphics2D g = (Graphics2D) this.getGraphics(); + //Pen aPen = new Pen(Color.Red); + //aPen.DashStyle = DashStyle.Dash; + //Rectangle rect = new Rectangle(); + _vScrollBar.setCursor(Cursor.getDefaultCursor()); + _hScrollBar.setCursor(Cursor.getDefaultCursor()); + //this.setCursor(Cursor.getDefaultCursor()); + + switch (_mouseMode) { + case Map_ZoomIn: + if (isInLayoutMaps(pageP)) { + this.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(Toolkit.getDefaultToolkit(). + getImage(this.getClass().getResource("/images/zoom_in_32x32x32.png")), new Point(8, 8), "Zoom In")); + + //this.repaint(); + this.repaintOld(); + } + break; + case Map_Pan: + if (isInLayoutMaps(pageP)) { + this.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(Toolkit.getDefaultToolkit(). + getImage(this.getClass().getResource("/images/Pan_Open_32x32x32.png")), new Point(8, 8), "Pan")); + + Rectangle mapRect = pageToScreen(_currentLayoutMap.getBounds()); + g.setClip(mapRect); + Color aColor = _currentLayoutMap.getMapFrame().getBackColor(); + if (aColor.getAlpha() == 255) { + aColor = Color.white; + } + g.setColor(aColor); + int aX = e.getX() - _mouseDownPoint.x; + int aY = e.getY() - _mouseDownPoint.y; + aX = (int) (aX / _zoom); + aY = (int) (aY / _zoom); + if (aX > 0) { + if (mapRect.x >= 0) { + g.fillRect(mapRect.x, mapRect.y, aX, mapRect.height); + } else { + g.fillRect(0, mapRect.y, aX, mapRect.height); + } + } else { + if (mapRect.x <= this.getWidth()) { + g.fillRect(mapRect.x + mapRect.width + aX, mapRect.y, Math.abs(aX), mapRect.height); + } else { + g.fillRect(this.getWidth() + aX, mapRect.y, Math.abs(aX), mapRect.height); + } + } + if (aY > 0) { + if (mapRect.y >= 0) { + g.fillRect(mapRect.x, mapRect.y, mapRect.width, aY); + } else { + g.fillRect(mapRect.x, 0, mapRect.width, aY); + } + } else { + if (mapRect.y + mapRect.height <= this.getX() + this.getHeight()) { + g.fillRect(mapRect.x, mapRect.y + mapRect.height + aY, mapRect.width, Math.abs(aY)); + } else { + g.fillRect(mapRect.x, this.getY() + this.getHeight() + aY, mapRect.width, Math.abs(aY)); + } + } + int startX = mapRect.x + aX; + int startY = mapRect.y + aY; + AffineTransformOp aop = new AffineTransformOp(new AffineTransform(), AffineTransformOp.TYPE_BILINEAR); + g.drawImage(_tempImage, aop, startX, startY); + //g.drawImage(_tempImage, startX, startY, this); + g.setColor(this.getForeground()); + g.draw(mapRect); + } + break; + case Map_SelectFeatures_Rectangle: + //this.repaint(); + this.repaintOld(); + break; + case MoveSelection: + this.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); + //this.repaint(); + this.repaintOld(); + break; + case ResizeSelected: + LayoutElement oElement = _selectedElements.get(0); + switch (oElement.getResizeAbility()) { + case SameWidthHeight: + switch (_resizeSelectedEdge) { + case TopLeft: + _selectedRectangle.x += deltaX; + _selectedRectangle.y += deltaX; + _selectedRectangle.width -= deltaX; + _selectedRectangle.height -= deltaX; + break; + case BottomRight: + _selectedRectangle.width += deltaX; + _selectedRectangle.height += deltaX; + break; + case TopRight: + _selectedRectangle.y += deltaY; + _selectedRectangle.width -= deltaY; + _selectedRectangle.height -= deltaY; + break; + case BottomLeft: + _selectedRectangle.x += deltaX; + _selectedRectangle.width -= deltaX; + _selectedRectangle.height -= deltaX; + break; + } + break; + case ResizeAll: + switch (_resizeSelectedEdge) { + case TopLeft: + _selectedRectangle.x += deltaX; + _selectedRectangle.y += deltaY; + _selectedRectangle.width -= deltaX; + _selectedRectangle.height -= deltaY; + break; + case BottomRight: + _selectedRectangle.width += deltaX; + _selectedRectangle.height += deltaY; + break; + case Top: + _selectedRectangle.y += deltaY; + _selectedRectangle.height -= deltaY; + break; + case Bottom: + _selectedRectangle.height += deltaY; + break; + case TopRight: + _selectedRectangle.y += deltaY; + _selectedRectangle.width += deltaX; + _selectedRectangle.height -= deltaY; + break; + case BottomLeft: + _selectedRectangle.x += deltaX; + _selectedRectangle.width -= deltaX; + _selectedRectangle.height += deltaY; + break; + case Left: + _selectedRectangle.x += deltaX; + _selectedRectangle.width -= deltaX; + break; + case Right: + _selectedRectangle.width += deltaX; + break; + } + break; + } + //this.repaint(); + this.repaintOld(); + break; + case New_Rectangle: + case New_Ellipse: + case New_Freehand: + case New_Circle: + case Map_SelectFeatures_Polygon: + case Map_SelectFeatures_Lasso: + case Map_SelectFeatures_Circle: + //this.repaint(); + this.repaintOld(); + break; + case InEditingVertices: + //this.repaint(); + this.repaintOld(); + break; + } + } + + void onMouseMoved(MouseEvent e) { + //int deltaX = e.getX() - _mouseLastPos.x; + //int deltaY = e.getY() - _mouseLastPos.y; + _mouseLastPos.x = e.getX(); + _mouseLastPos.y = e.getY(); + + Point pageP = screenToPage(e.getX(), e.getY()); + + Graphics2D g = (Graphics2D) this.getGraphics(); + //Pen aPen = new Pen(Color.Red); + //aPen.DashStyle = DashStyle.Dash; + //Rectangle rect = new Rectangle(); + _vScrollBar.setCursor(Cursor.getDefaultCursor()); + _hScrollBar.setCursor(Cursor.getDefaultCursor()); + //this.setCursor(Cursor.getDefaultCursor()); + + switch (_mouseMode) { + case Map_ZoomIn: + if (isInLayoutMaps(pageP)) { + this.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(Toolkit.getDefaultToolkit(). + getImage(this.getClass().getResource("/images/zoom_in_32x32x32.png")), new Point(8, 8), "Zoom In")); + } + break; + case Map_ZoomOut: + if (isInLayoutMaps(pageP)) { + this.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(Toolkit.getDefaultToolkit(). + getImage(this.getClass().getResource("/images/zoom_out_32x32x32.png")), new Point(8, 8), "Zoom Out")); + } + break; + case Map_Pan: + if (isInLayoutMaps(pageP)) { + this.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(Toolkit.getDefaultToolkit(). + getImage(this.getClass().getResource("/images/Pan_Open_32x32x32.png")), new Point(8, 8), "Pan")); + } + break; + case Map_Identifer: + if (isInLayoutMaps(pageP)) { + this.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(Toolkit.getDefaultToolkit(). + getImage(this.getClass().getResource("/images/identifer_32x32x32.png")), new Point(8, 8), "Identifer")); + } + break; + case Map_SelectFeatures_Rectangle: + //case Map_SelectFeatures_Polygon: + //case Map_SelectFeatures_Lasso: + //case Map_SelectFeatures_Circle: + if (isInLayoutMaps(pageP)) { + this.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); + } + break; + case Select: + if (_selectedElements.size() > 0) { + List tempElements = selectElements(pageP, _selectedElements, 3); + if (tempElements.size() > 0) { + //Change mouse cursor + Rectangle aRect = (Rectangle) _selectedElements.get(0).getBounds().clone(); + _resizeSelectedEdge = intersectElementEdge(aRect, new PointF(pageP.x, pageP.y), 3F); + switch (_selectedElements.get(0).getResizeAbility()) { + case SameWidthHeight: + switch (_resizeSelectedEdge) { + case TopLeft: + case BottomRight: + this.setCursor(Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR)); + break; + case TopRight: + case BottomLeft: + this.setCursor(Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR)); + break; + default: + this.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); + break; + } + break; + case ResizeAll: + switch (_resizeSelectedEdge) { + case TopLeft: + case BottomRight: + this.setCursor(Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR)); + break; + case Top: + case Bottom: + this.setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR)); + break; + case TopRight: + case BottomLeft: + this.setCursor(Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR)); + break; + case Left: + case Right: + this.setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); + break; + case None: + this.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); + break; + } + break; + default: + this.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); + break; + } + } else { + this.setCursor(Cursor.getDefaultCursor()); + } + } else { + this.setCursor(Cursor.getDefaultCursor()); + } + + break; + case MoveSelection: + break; + case ResizeSelected: + break; + case New_Polyline: + case New_Polygon: + case New_Curve: + case New_CurvePolygon: + case Map_SelectFeatures_Polygon: + if (!_startNewGraphic) { + //this.repaint(); + this.repaintOld(); + } + break; + case EditVertices: + if (_selectedElements.size() > 0) { + _editingVerticeIndex = selectEditVertices(pageP, ((LayoutGraphic) _selectedElements.get(0)).getGraphic().getShape(), + _editingVertices); + Toolkit toolkit = Toolkit.getDefaultToolkit(); + if (_editingVerticeIndex >= 0) { + this.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(Toolkit.getDefaultToolkit(). + getImage(this.getClass().getResource("/images/VertexEdit_32x32x32.png")), new Point(8, 8), "Vertices edit")); + } else { + Image image = toolkit.getImage(this.getClass().getResource("/images/Edit_tool.png")); + this.setCursor(toolkit.createCustomCursor(image, new Point(2, 2), "Edit Tool")); + } + } + break; + case Map_Measurement: + if (isInLayoutMaps(pageP)) { + this.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); + } + + if (_frmMeasure == null) { + break; + } + if (_frmMeasure.isVisible()) { + switch (_frmMeasure.getMeasureType()) { + case Length: + case Area: + if (!_startNewGraphic) { + //Draw graphic + //g.SmoothingMode = SmoothingMode.AntiAlias; + //this.repaint(); + this.repaintOld(); + PointF[] fpoints = (PointF[]) _graphicPoints.toArray(new PointF[_graphicPoints.size()]); + PointF[] points = new PointF[fpoints.length + 1]; + System.arraycopy(fpoints, 0, points, 0, fpoints.length); + points[_graphicPoints.size()] = new PointF(e.getX(), e.getY()); + + //Calculate + PointF mapP = pageToScreen(_currentLayoutMap.getLeft(), _currentLayoutMap.getTop()); + PointF aPoint = new PointF(e.getX() - mapP.X, e.getY() - mapP.Y); + float[] pXY = _currentLayoutMap.getMapFrame().getMapView().screenToProj(aPoint.X, aPoint.Y); + if (_frmMeasure.getMeasureType() == MeasureTypes.Length) { + aPoint = new PointF(_mouseDownPoint.x - mapP.X, _mouseDownPoint.y - mapP.Y); + float[] pPXY = _currentLayoutMap.getMapFrame().getMapView().screenToProj(aPoint.X, aPoint.Y); + double dx = Math.abs(pXY[0] - pPXY[0]); + double dy = Math.abs(pXY[1] - pPXY[1]); + double dist; + if (_currentLayoutMap.getMapFrame().getMapView().getProjection().isLonLatMap()) { + double y = (pXY[1] + pPXY[1]) / 2; + double factor = Math.cos(y * Math.PI / 180); + dx *= factor; + dist = Math.sqrt(dx * dx + dy * dy); + dist = dist * 111319.5; + } else { + dist = Math.sqrt(dx * dx + dy * dy); + dist *= _currentLayoutMap.getMapFrame().getMapView().getProjection().getProjInfo().getCoordinateReferenceSystem().getProjection().getFromMetres(); + } + + _frmMeasure.setCurrentValue(dist); + } else { + List mPoints = new ArrayList<>(); + for (int i = 0; i < points.length; i++) { + aPoint = new PointF(points[i].X - mapP.X, points[i].Y - mapP.Y); + pXY = _currentLayoutMap.getMapFrame().getMapView().screenToProj(aPoint.X, aPoint.Y); + mPoints.add(new PointD(pXY[0], pXY[1])); + } + double area = GeoComputation.getArea(mPoints); + if (_currentLayoutMap.getMapFrame().getMapView().getProjection().isLonLatMap()) { + area = area * 111319.5 * 111319.5; + } else { + area *= _currentLayoutMap.getMapFrame().getMapView().getProjection().getProjInfo().getCoordinateReferenceSystem().getProjection().getFromMetres() + * _currentLayoutMap.getMapFrame().getMapView().getProjection().getProjInfo().getCoordinateReferenceSystem().getProjection().getFromMetres(); + } + _frmMeasure.setCurrentValue(area); + } + } + break; + } + } + break; + } + } + + void onMouseReleased(MouseEvent e) throws CloneNotSupportedException { + _dragMode = false; + double MinX, MaxX, MinY, MaxY, ZoomF; + Point pageP = screenToPage(e.getX(), e.getY()); + switch (_mouseMode) { + case Map_ZoomIn: + MinX = Math.min(e.getX(), _mouseDownPoint.x); + MinY = Math.min(e.getY(), _mouseDownPoint.y); + MaxX = Math.max(e.getX(), _mouseDownPoint.x); + MaxY = Math.max(e.getY(), _mouseDownPoint.y); + if (MaxX - MinX < 5) { + if (e.getButton() == MouseEvent.BUTTON1) { + ZoomF = 0.75; + } else { + ZoomF = 1.5; + } + MinX = pageP.x - (_currentLayoutMap.getWidth() / 2 * ZoomF); + MaxX = pageP.x + (_currentLayoutMap.getWidth() / 2 * ZoomF); + MinY = pageP.y - (_currentLayoutMap.getHeight() / 2 * ZoomF); + MaxY = pageP.y + (_currentLayoutMap.getHeight() / 2 * ZoomF); + } else { + PointF minP = screenToPage((float) MinX, (float) MinY); + PointF maxP = screenToPage((float) MaxX, (float) MaxY); + MinX = minP.X; + MinY = minP.Y; + MaxX = maxP.X; + MaxY = maxP.Y; + } + + MinX -= _currentLayoutMap.getLeft(); + MinY -= _currentLayoutMap.getTop(); + MaxX -= _currentLayoutMap.getLeft(); + MaxY -= _currentLayoutMap.getTop(); + if (MaxX - MinX > 0.001) { + _currentLayoutMap.getMapFrame().getMapView().zoomToExtentScreen(MinX, MaxX, MinY, MaxY, _zoom); + } + break; + case Map_ZoomOut: + if (e.getButton() == MouseEvent.BUTTON1) { + ZoomF = 1.5; + } else { + ZoomF = 0.75; + } + MinX = pageP.x - (_currentLayoutMap.getWidth() / 2 * ZoomF); + MaxX = pageP.x + (_currentLayoutMap.getWidth() / 2 * ZoomF); + MinY = pageP.y - (_currentLayoutMap.getHeight() / 2 * ZoomF); + MaxY = pageP.y + (_currentLayoutMap.getHeight() / 2 * ZoomF); + + MinX -= _currentLayoutMap.getLeft(); + MinY -= _currentLayoutMap.getTop(); + MaxX -= _currentLayoutMap.getLeft(); + MaxY -= _currentLayoutMap.getTop(); + if (MaxX - MinX > 0.001) { + _currentLayoutMap.getMapFrame().getMapView().zoomToExtentScreen(MinX, MaxX, MinY, MaxY, _zoom); + } + break; + case Map_Pan: + if (e.getButton() == MouseEvent.BUTTON1) { + int deltaX = e.getX() - _mouseDownPoint.x; + int deltaY = e.getY() - _mouseDownPoint.y; + deltaX = (int) (deltaX / _zoom); + deltaY = (int) (deltaY / _zoom); + MinX = -deltaX; + MinY = -deltaY; + MaxX = _currentLayoutMap.getWidth() - deltaX; + MaxY = _currentLayoutMap.getHeight() - deltaY; + _currentLayoutMap.getMapFrame().getMapView().zoomToExtentScreen(MinX, MaxX, MinY, MaxY, _zoom); + } + break; + } + + if (e.getButton() == MouseEvent.BUTTON1) { + switch (_mouseMode) { + case Map_SelectFeatures_Rectangle: + if (_currentLayoutMap.getMapFrame().getMapView().getSelectedLayerHandle() < 0) { + return; + } + MapLayer aMLayer = _currentLayoutMap.getMapFrame().getMapView().getSelectedLayer(); + if (aMLayer == null) { + return; + } + if (aMLayer.getLayerType() != LayerTypes.VectorLayer) { + return; + } + + VectorLayer aLayer = (VectorLayer) aMLayer; + PointF mapP = pageToScreen(_currentLayoutMap.getLeft(), _currentLayoutMap.getTop()); + Point aPoint = new Point(e.getX() - (int) mapP.X, e.getY() - (int) mapP.Y); + Point bPoint = new Point(_mouseDownPoint.x - (int) mapP.X, _mouseDownPoint.y - (int) mapP.Y); + int minx = Math.min(bPoint.x, aPoint.x); + int miny = Math.min(bPoint.y, aPoint.y); + int width = Math.abs(aPoint.x - bPoint.x); + int height = Math.abs(aPoint.y - bPoint.y); + Rectangle.Float rect = new Rectangle.Float(minx, miny, width, height); + List selectedShapes = _currentLayoutMap.getMapFrame().getMapView().selectShapes(aLayer, rect); + if (!(e.isControlDown() || e.isShiftDown())) { + aLayer.clearSelectedShapes(); + } + if (selectedShapes.size() > 0) { + for (int shapeIdx : selectedShapes) { + Shape shape = aLayer.getShapes().get(shapeIdx); + shape.setSelected(!shape.isSelected()); + } + _currentLayoutMap.getMapFrame().getMapView().fireShapeSelectedEvent(); + } + //this.paintGraphics(); + this.repaintNew(); + break; + case CreateSelection: + //Remove selected graphics + for (LayoutElement aElement : _selectedElements) { + aElement.setSelected(false); + } + _selectedElements.clear(); + + //Select elements + if (Math.abs(e.getX() - _mouseDownPoint.x) > 2 || Math.abs(e.getY() - _mouseDownPoint.y) > 2) { + //this.paintGraphics(); + this.repaintNew(); + return; + } + + //Point mousePoint = new Point(_mouseDownPoint.X, _mouseDownPoint.Y); + _selectedElements = selectElements(pageP, _layoutElements, 0); + if (_selectedElements.size() > 0) { + for (int i = 0; i < _selectedElements.size() - 1; i++) { + _selectedElements.remove(_selectedElements.size() - 1); + } + _selectedElements.get(0).setSelected(true); + if (_selectedElements.get(0).getElementType() == ElementType.LayoutMap) { + setActiveMapFrame(((LayoutMap) _selectedElements.get(0)).getMapFrame()); + } + } + this.fireElementSelectedEvent(); + + _mouseMode = MouseMode.Select; + //this.paintGraphics(); + this.repaintNew(); + break; + case MoveSelection: + //Select elements + if (Math.abs(e.getX() - _mouseDownPoint.x) < 2 && Math.abs(e.getY() - _mouseDownPoint.y) < 2) { + LayoutElement aElement = _selectedElements.get(0); + _selectedElements = selectElements(pageP, _layoutElements, 0); + if (_selectedElements.size() > 1) { + aElement.setSelected(false); + int idx = _selectedElements.indexOf(aElement); + if (idx == 0) { + idx = _selectedElements.size() - 1; + } else { + idx -= 1; + } + if (idx < 0) { + idx = 0; + } + aElement = _selectedElements.get(idx); + _selectedElements.clear(); + _selectedElements.add(aElement); + _selectedElements.get(0).setSelected(true); + if (_selectedElements.get(0).getElementType() == ElementType.LayoutMap) { + setActiveMapFrame(((LayoutMap) _selectedElements.get(0)).getMapFrame()); + } + } + this.fireElementSelectedEvent(); + } else { + int deltaX = (int) ((e.getX() - _mouseDownPoint.x) / _zoom); + int deltaY = (int) ((e.getY() - _mouseDownPoint.y) / _zoom); + for (LayoutElement aElement : _selectedElements) { + aElement.setLeft(aElement.getLeft() + deltaX); + aElement.setTop(aElement.getTop() + deltaY); + aElement.moveUpdate(); + } + UndoableEdit edit = (new MapLayoutUndoRedo()).new MoveElementsEdit(this, _selectedElements, deltaX, deltaY); + this.fireUndoEditEvent(edit); + } + + _mouseMode = MouseMode.Select; + //this.paintGraphics(); + this.repaintNew(); + break; + case ResizeSelected: + _mouseMode = MouseMode.Select; + LayoutElement oElement = _selectedElements.get(0); + if (_selectedRectangle.width < 3) { + _selectedRectangle.width = 3; + } + if (_selectedRectangle.height < 3) { + _selectedRectangle.height = 3; + } + + UndoableEdit edit = (new MapLayoutUndoRedo()).new ResizeElementEdit(this, oElement, _selectedRectangle); + this.fireUndoEditEvent(edit); + PointF minP = screenToPage((float) _selectedRectangle.x, (float) _selectedRectangle.y); + PointF maxP = screenToPage((float) _selectedRectangle.x + _selectedRectangle.width, _selectedRectangle.y + _selectedRectangle.height); + oElement.setLeft((int) minP.X); + oElement.setTop((int) minP.Y); + oElement.setWidth((int) (maxP.X - minP.X)); + oElement.setHeight((int) (maxP.Y - minP.Y)); + oElement.resizeUpdate(); + //this.paintGraphics(); + this.repaintNew(); + break; + case New_Rectangle: + case New_Ellipse: + if (e.getButton() == MouseEvent.BUTTON1) { + if (e.getX() - _mouseDownPoint.x < 2 || e.getY() - _mouseDownPoint.y < 2) { + return; + } + + _startNewGraphic = true; + _graphicPoints = new ArrayList<>(); + _graphicPoints.add(new PointF(_mouseDownPoint.x, _mouseDownPoint.y)); + _graphicPoints.add(new PointF(_mouseDownPoint.x, e.getY())); + _graphicPoints.add(new PointF(e.getX(), e.getY())); + _graphicPoints.add(new PointF(e.getX(), _mouseDownPoint.y)); + List points = new ArrayList<>(); + for (PointF cPoint : _graphicPoints) { + PointF dPoint = screenToPage(cPoint.X, cPoint.Y); + points.add(new PointD(dPoint.X, dPoint.Y)); + } + + Graphic aGraphic = null; + switch (_mouseMode) { + case New_Rectangle: + RectangleShape aPGS = new RectangleShape(); + points.add((PointD) points.get(0).clone()); + aPGS.setPoints(points); + aGraphic = new Graphic(aPGS, (PolygonBreak) _defPolygonBreak.clone()); + break; + case New_Ellipse: + EllipseShape aES = new EllipseShape(); + aES.setPoints(points); + aGraphic = new Graphic(aES, (PolygonBreak) _defPolygonBreak.clone()); + break; + } + + if (aGraphic != null) { + LayoutGraphic lg = new LayoutGraphic(aGraphic, this); + addElement(lg); + //this.paintGraphics(); + this.repaintNew(); + edit = (new MapLayoutUndoRedo()).new AddElementEdit(this, lg); + this.fireUndoEditEvent(edit); + } else { + //this.repaint(); + this.repaintOld(); + } + } + break; + case New_Freehand: + if (e.getButton() == MouseEvent.BUTTON1) { + _startNewGraphic = true; + if (_graphicPoints.size() < 2) { + break; + } + + List points = new ArrayList<>(); + for (PointF cPoint : _graphicPoints) { + PointF dPoint = screenToPage(cPoint.X, cPoint.Y); + points.add(new PointD(dPoint.X, dPoint.Y)); + } + + PolylineShape aPLS = new PolylineShape(); + aPLS.setPoints(points); + Graphic aGraphic = new Graphic(aPLS, (PolylineBreak) _defPolylineBreak.clone()); + LayoutGraphic lg = new LayoutGraphic(aGraphic, this); + addElement(lg); + //this.paintGraphics(); + this.repaintNew(); + edit = (new MapLayoutUndoRedo()).new AddElementEdit(this, lg); + this.fireUndoEditEvent(edit); + } + break; + case New_Circle: + if (e.getButton() == MouseEvent.BUTTON1) { + if (e.getX() - _mouseDownPoint.x < 2 || e.getY() - _mouseDownPoint.y < 2) { + return; + } + + float radius = (float) Math.sqrt(Math.pow(e.getX() - _mouseDownPoint.x, 2) + + Math.pow(e.getY() - _mouseDownPoint.y, 2)); + _startNewGraphic = true; + _graphicPoints = new ArrayList<>(); + _graphicPoints.add(new PointF(_mouseDownPoint.x - radius, _mouseDownPoint.y)); + _graphicPoints.add(new PointF(_mouseDownPoint.x, _mouseDownPoint.y - radius)); + _graphicPoints.add(new PointF(_mouseDownPoint.x + radius, _mouseDownPoint.y)); + _graphicPoints.add(new PointF(_mouseDownPoint.x, _mouseDownPoint.y + radius)); + List points = new ArrayList<>(); + for (PointF cPoint : _graphicPoints) { + PointF dPoint = screenToPage(cPoint.X, cPoint.Y); + points.add(new PointD(dPoint.X, dPoint.Y)); + } + + CircleShape aPGS = new CircleShape(); + aPGS.setPoints(points); + Graphic aGraphic = new Graphic(aPGS, (PolygonBreak) _defPolygonBreak.clone()); + LayoutGraphic lg = new LayoutGraphic(aGraphic, this); + addElement(lg); + //this.paintGraphics(); + this.repaintNew(); + edit = (new MapLayoutUndoRedo()).new AddElementEdit(this, lg); + this.fireUndoEditEvent(edit); + } + break; + case InEditingVertices: + LayoutGraphic lg = (LayoutGraphic) _selectedElements.get(0); + edit = (new MapLayoutUndoRedo()).new MoveGraphicVerticeEdit(this, lg, _editingVerticeIndex, + pageP.x, pageP.y); + this.fireUndoEditEvent(edit); + lg.verticeEditUpdate(_editingVerticeIndex, pageP.x, pageP.y); + _mouseMode = MouseMode.EditVertices; + //this.paintGraphics(); + this.repaintNew(); + break; + } + } + } + + void onMouseClicked(MouseEvent e) throws CloneNotSupportedException { + int clickTimes = e.getClickCount(); + if (clickTimes == 1) { + Point pageP = screenToPage(e.getX(), e.getY()); + if (e.getButton() == MouseEvent.BUTTON1) { + switch (_mouseMode) { + case Map_Identifer: + MapLayer aMLayer = _currentLayoutMap.getMapFrame().getMapView().getSelectedLayer(); + if (aMLayer == null) { + return; + } + if (aMLayer.getLayerType() == LayerTypes.ImageLayer) { + return; + } + + PointF mapP = pageToScreen(_currentLayoutMap.getLeft(), _currentLayoutMap.getTop()); + PointF aPoint = new PointF(e.getX() - mapP.X, e.getY() - mapP.Y); + if (aMLayer.getLayerType() == LayerTypes.VectorLayer) { + VectorLayer aLayer = (VectorLayer) aMLayer; + List selectedShapes = _currentLayoutMap.getMapFrame().getMapView().selectShapes(aLayer, aPoint); + if (selectedShapes.size() > 0) { + if (frmIdentifier == null) { + frmIdentifier = new FrmIdentifer((JFrame) SwingUtilities.getWindowAncestor(this), false, _currentLayoutMap.getMapFrame().getMapView()); + frmIdentifier.addWindowListener(new WindowAdapter() { + @Override + public void windowClosed(WindowEvent e) { + _currentLayoutMap.getMapFrame().getMapView().setDrawIdentiferShape(false); + //repaint(); + repaintOld(); + } + }); + } + frmIdentifier.setMapView(_currentLayoutMap.getMapFrame().getMapView()); + + String[] colNames = {"Field", "Value"}; + String fieldStr, valueStr; + int shapeIdx = selectedShapes.get(0); + aLayer.setIdentiferShape(shapeIdx); + _currentLayoutMap.getMapFrame().getMapView().setDrawIdentiferShape(true); + + Object[][] tData = new Object[aLayer.getFieldNumber() + 1][2]; + fieldStr = "Index"; + valueStr = String.valueOf(shapeIdx); + tData[0][0] = fieldStr; + tData[0][1] = valueStr; + if (aLayer.getShapeNum() > 0) { + for (int i = 0; i < aLayer.getFieldNumber(); i++) { + fieldStr = aLayer.getFieldName(i); + valueStr = aLayer.getCellValue(i, shapeIdx).toString(); + tData[i + 1][0] = fieldStr; + tData[i + 1][1] = valueStr; + } + } + DefaultTableModel dtm = new DefaultTableModel(tData, colNames) { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }; + this.frmIdentifier.getTable().setModel(dtm); + this.frmIdentifier.repaint(); + if (!this.frmIdentifier.isVisible()) { + this.frmIdentifier.setLocation(e.getX(), e.getY()); + this.frmIdentifier.setVisible(true); + } + + //this.repaint(); + this.repaintOld(); + //Rectangle rect = getElementViewExtent(_currentLayoutMap); + //_currentLayoutMap.getMapFrame().getMapView().drawIdShape(this.createGraphics(), aLayer.getShapes().get(shapeIdx), rect); + } + } else if (aMLayer.getLayerType() == LayerTypes.RasterLayer) { + RasterLayer aRLayer = (RasterLayer) aMLayer; + int[] ijIdx = _currentLayoutMap.getMapFrame().getMapView().selectGridCell(aRLayer, aPoint); + if (ijIdx != null) { + int iIdx = ijIdx[0]; + int jIdx = ijIdx[1]; + double aValue = aRLayer.getCellValue(iIdx, jIdx); + if (frmIdentifierGrid == null) { + frmIdentifierGrid = new FrmIdentiferGrid((JFrame) SwingUtilities.getWindowAncestor(this), false); + } + + frmIdentifierGrid.setIIndex(iIdx); + frmIdentifierGrid.setJIndex(jIdx); + frmIdentifierGrid.setCellValue(aValue); + if (!this.frmIdentifierGrid.isVisible()) { + //this._frmIdentiferGrid.setLocation(e.getX(), e.getY()); + this.frmIdentifierGrid.setLocationRelativeTo(this); + this.frmIdentifierGrid.setVisible(true); + } + } + } + break; + // case Map_SelectFeatures_Rectangle: + // aMLayer = _currentLayoutMap.getMapFrame().getMapView().getSelectedLayer(); + // if (aMLayer == null) { + // return; + // } + // + // if (aMLayer.getLayerType() != LayerTypes.VectorLayer) { + // return; + // } + // + // VectorLayer aLayer = (VectorLayer) aMLayer; + // if (!e.isControlDown() && !e.isShiftDown()) { + // aLayer.clearSelectedShapes(); + // //_currentLayoutMap.getMapFrame().getMapView().paintLayers(); + // } + // + // mapP = pageToScreen(_currentLayoutMap.getLeft(), _currentLayoutMap.getTop()); + // aPoint = new PointF(e.getX() - mapP.X, e.getY() - mapP.Y); + // List selectedShapes = _currentLayoutMap.getMapFrame().getMapView().selectShapes(aLayer, aPoint); + // this._layoutBitmap = GlobalUtil.deepCopy(this._tempImage); + // if (selectedShapes.size() > 0) { + // int shapeIdx = selectedShapes.get(0); + // Shape selShape = aLayer.getShapes().get(shapeIdx); + // Rectangle rect = getElementViewExtent(_currentLayoutMap); + // if (!e.isControlDown() && !e.isShiftDown()) { + // selShape.setSelected(true); + // _currentLayoutMap.getMapFrame().getMapView().drawIdShape((Graphics2D) this._layoutBitmap.getGraphics(), selShape, rect); + // } else { + // selShape.setSelected(!selShape.isSelected()); + // for (int sIdx : aLayer.getSelectedShapeIndexes()) { + // _currentLayoutMap.getMapFrame().getMapView().drawIdShape((Graphics2D) this._layoutBitmap.getGraphics(), aLayer.getShapes().get(sIdx), rect); + // } + // } + // this.repaint(); + // } else { + // if (!e.isControlDown() && !e.isShiftDown()) { + // this.repaint(); + // } + // } + // break; + } + } else if (e.getButton() == MouseEvent.BUTTON3 && _mouseMode == MouseMode.Select) { + if (_selectedElements.isEmpty()) { + return; + } + + JPopupMenu jPopupMenu_Element = new JPopupMenu(); + JMenu jMenu_Order = new JMenu("Order"); + jPopupMenu_Element.add(jMenu_Order); + + JMenuItem jMenuItem_BTF = new JMenuItem("Bring to Front"); + jMenuItem_BTF.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + onBringToFrontClick(e); + } + }); + jMenu_Order.add(jMenuItem_BTF); + + JMenuItem jMenuItem_STB = new JMenuItem("Send to Back"); + jMenuItem_STB.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + onSendToBackClick(e); + } + }); + jMenu_Order.add(jMenuItem_STB); + + JMenuItem jMenuItem_BF = new JMenuItem("Bring Forward"); + jMenuItem_BF.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + onBringForwardClick(e); + } + }); + jMenu_Order.add(jMenuItem_BF); + + JMenuItem jMenuItem_SB = new JMenuItem("Send Backward"); + jMenuItem_SB.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + onSendBackwardClick(e); + } + }); + jMenu_Order.add(jMenuItem_SB); + + jPopupMenu_Element.add(new JSeparator()); + + JMenuItem jMenuItem_Remove = new JMenuItem("Remove"); + jMenuItem_Remove.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + onRemoveElementClick(e); + } + }); + jPopupMenu_Element.add(jMenuItem_Remove); + + switch (_mouseMode) { + case Select: + case MoveSelection: + case ResizeSelected: + if (_selectedElements.size() > 0) { + LayoutElement aElement = _selectedElements.get(0); + if (MIMath.pointInRectangle(pageP, aElement.getBounds())) { + if (aElement.getElementType() == ElementType.LayoutGraphic) { + Graphic aGraphic = ((LayoutGraphic) aElement).getGraphic(); + if (aGraphic.getLegend().getBreakType() == BreakTypes.PolylineBreak || aGraphic.getLegend().getBreakType() == BreakTypes.PolygonBreak) { + JMenuItem jMenuItem_Reverse = new JMenuItem("Reverse"); + jMenuItem_Reverse.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + onReverseGraphicClick(e); + } + }); + jPopupMenu_Element.add(jMenuItem_Reverse); + + if (aGraphic.getShape().getShapeType() == ShapeTypes.Polyline || aGraphic.getShape().getShapeType() == ShapeTypes.Polygon) { + jPopupMenu_Element.add(new JSeparator()); + JMenuItem jMenuItem_Smooth = new JMenuItem("Smooth Graphic"); + jMenuItem_Smooth.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + onGraphicSmoothClick(e); + } + }); + jPopupMenu_Element.add(jMenuItem_Smooth); + } + + if (aGraphic.getShape().getShapeType() == ShapeTypes.Ellipse) { + JMenuItem jMenuItem_Angle = new JMenuItem("Set Angle"); + jMenuItem_Angle.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + onGraphicAngleClick(e); + } + }); + jPopupMenu_Element.add(jMenuItem_Angle); + } + } + } + } + } + break; + } + + jPopupMenu_Element.show(this, e.getX(), e.getY()); + } + } else if (clickTimes == 2) { + Point pageP = screenToPage(e.getX(), e.getY()); + switch (_mouseMode) { + case Select: + case MoveSelection: + case ResizeSelected: + if (_selectedElements.isEmpty()) { + return; + } + + LayoutElement aElement = _selectedElements.get(0); + _selectedElements = selectElements(pageP, _layoutElements, 0); + if (_selectedElements.size() > 1) { + aElement.setSelected(false); + int idx = _selectedElements.indexOf(aElement); + idx += 2; + if (idx > _selectedElements.size() - 1) { + idx = idx - _selectedElements.size(); + } + aElement = _selectedElements.get(idx); + _selectedElements.clear(); + _selectedElements.add(aElement); + _selectedElements.get(0).setSelected(true); + } + //this.paintGraphics(); + this.repaintNew(); + + if (aElement.getElementType() == ElementType.LayoutGraphic) { + Graphic aGraphic = ((LayoutGraphic) aElement).getGraphic(); + showSymbolSetForm(aGraphic); + } else { + FrmProperty aFrmProperty = new FrmProperty((JFrame) SwingUtilities.getWindowAncestor(this), true, false); + Object object = aElement; + switch (aElement.getElementType()) { + case LayoutLegend: + object = ((LayoutLegend) aElement).new LayoutLegendBean(); + break; + case LayoutMap: + object = ((LayoutMap) aElement).new LayoutMapBean(); + break; + case LayoutNorthArraw: + object = ((LayoutNorthArrow) aElement).new LayoutNorthArrowBean(); + break; + case LayoutScaleBar: + object = ((LayoutScaleBar) aElement).new LayoutScaleBarBean(); + break; + } + aFrmProperty.setObject(object); + aFrmProperty.setParent(this); + aFrmProperty.setLocationRelativeTo(this); + aFrmProperty.setVisible(true); + } + setMouseMode(MouseMode.Select); + this.fireElementSelectedEvent(); + break; + case New_Polyline: + case New_Polygon: + case New_Curve: + case New_CurvePolygon: + case New_Freehand: + case Map_SelectFeatures_Polygon: + if (!_startNewGraphic) { + _startNewGraphic = true; + _graphicPoints.remove(_graphicPoints.size() - 1); + + if (_mouseMode == MouseMode.Map_SelectFeatures_Polygon) { + PointF mapP = pageToScreen(_currentLayoutMap.getLeft(), _currentLayoutMap.getTop()); + List points = new ArrayList<>(); + MapView currentMapView = _currentLayoutMap.getMapFrame().getMapView(); + for (PointF aPoint : _graphicPoints) { + float[] pXY = currentMapView.screenToProj(aPoint.X - mapP.X, aPoint.Y - mapP.Y); + points.add(new PointD(pXY[0], pXY[1])); + } + + MapLayer aMLayer = _currentLayoutMap.getMapFrame().getMapView().getSelectedLayer(); + if (aMLayer == null) { + return; + } + if (aMLayer.getLayerType() != LayerTypes.VectorLayer) { + return; + } + + PolygonShape aPGS = new PolygonShape(); + points.add((PointD) points.get(0).clone()); + aPGS.setPoints(points); + VectorLayer aLayer = (VectorLayer) aMLayer; + if (!e.isControlDown() && !e.isShiftDown()) { + aLayer.clearSelectedShapes(); + } + aLayer.selectShapes(aPGS); + _currentLayoutMap.getMapFrame().getMapView().fireShapeSelectedEvent(); + } else { + List points = new ArrayList<>(); + for (PointF aPoint : _graphicPoints) { + PointF bPoint = screenToPage(aPoint.X, aPoint.Y); + points.add(new PointD(bPoint.X, bPoint.Y)); + } + + Graphic aGraphic = null; + switch (_mouseMode) { + case New_Polyline: + case New_Freehand: + PolylineShape aPLS = new PolylineShape(); + aPLS.setPoints(points); + aGraphic = new Graphic(aPLS, (PolylineBreak) _defPolylineBreak.clone()); + break; + case New_Polygon: + if (points.size() > 2) { + PolygonShape aPGS = new PolygonShape(); + points.add((PointD) points.get(0).clone()); + aPGS.setPoints(points); + aGraphic = new Graphic(aPGS, (PolygonBreak) _defPolygonBreak.clone()); + } + break; + case New_Curve: + CurveLineShape aCLS = new CurveLineShape(); + aCLS.setPoints(points); + aGraphic = new Graphic(aCLS, (PolylineBreak) _defPolylineBreak.clone()); + break; + case New_CurvePolygon: + if (points.size() > 2) { + CurvePolygonShape aCPS = new CurvePolygonShape(); + points.add((PointD) points.get(0).clone()); + aCPS.setPoints(points); + aGraphic = new Graphic(aCPS, (PolygonBreak) _defPolygonBreak.clone()); + } + break; + } + + if (aGraphic != null) { + LayoutGraphic lg = new LayoutGraphic(aGraphic, this); + addElement(lg); + //this.paintGraphics(); + this.repaintNew(); + UndoableEdit edit = (new MapLayoutUndoRedo()).new AddElementEdit(this, lg); + this.fireUndoEditEvent(edit); + } else { + this.repaint(); + } + } + } + break; + } + } + } + + private void onRemoveElementClick(ActionEvent e) { + this.onRemoveElementClick(); + } + + private void onBringToFrontClick(ActionEvent e) { + LayoutElement aLE = _selectedElements.get(0); + int idx = _layoutElements.indexOf(aLE); + if (idx < _layoutElements.size() - 1) { + _layoutElements.remove(aLE); + _layoutElements.add(aLE); + //this.paintGraphics(); + this.repaintNew(); + } + } + + private void onSendToBackClick(ActionEvent e) { + LayoutElement aLE = _selectedElements.get(0); + int idx = _layoutElements.indexOf(aLE); + if (idx > 0) { + _layoutElements.remove(aLE); + _layoutElements.add(0, aLE); + //this.paintGraphics(); + this.repaintNew(); + } + } + + private void onBringForwardClick(ActionEvent e) { + LayoutElement aLE = _selectedElements.get(0); + int idx = _layoutElements.indexOf(aLE); + if (idx < _layoutElements.size() - 1) { + _layoutElements.remove(aLE); + _layoutElements.add(idx + 1, aLE); + //this.paintGraphics(); + this.repaintNew(); + } + } + + private void onSendBackwardClick(ActionEvent e) { + LayoutElement aLE = _selectedElements.get(0); + int idx = _layoutElements.indexOf(aLE); + if (idx > 0) { + _layoutElements.remove(aLE); + _layoutElements.add(idx - 1, aLE); + //this.paintGraphics(); + this.repaintNew(); + } + } + + private void onReverseGraphicClick(ActionEvent e) { + LayoutElement aElement = _selectedElements.get(0); + Graphic aGraphic = ((LayoutGraphic) aElement).getGraphic(); + List points = (List) aGraphic.getShape().getPoints(); + Collections.reverse(points); + aGraphic.getShape().setPoints(points); + + //this.paintGraphics(); + this.repaintNew(); + } + + private void onGraphicSmoothClick(ActionEvent e) { + LayoutElement aElement = _selectedElements.get(0); + Graphic aGraphic = ((LayoutGraphic) aElement).getGraphic(); + List pointList = new ArrayList<>(); + List newPoints = new ArrayList<>(); + + for (PointD aP : aGraphic.getShape().getPoints()) { + pointList.add(new wcontour.global.PointD(aP.X, aP.Y)); + } + + if (aGraphic.getShape().getShapeType() == ShapeTypes.Polygon) { + pointList.add(pointList.get(0)); + } + + pointList = wcontour.Contour.smoothPoints(pointList); + for (wcontour.global.PointD aP : pointList) { + newPoints.add(new PointD(aP.X, aP.Y)); + } + aGraphic.getShape().setPoints(newPoints); + ((LayoutGraphic) aElement).updateControlSize(); + //this.paintGraphics(); + this.repaintNew(); + } + + private void onGraphicAngleClick(ActionEvent e) { + LayoutElement aElement = _selectedElements.get(0); + Graphic aGraphic = ((LayoutGraphic) aElement).getGraphic(); + EllipseShape es = (EllipseShape)aGraphic.getShape(); + String angleStr = JOptionPane.showInputDialog(this, "Ellipse angle:", es.getAngle()); + if (angleStr != null){ + es.setAngle(Float.parseFloat(angleStr)); + //this.paintGraphics(); + this.repaintNew(); + } + } + + private void showSymbolSetForm(ColorBreak aCB) { + switch (aCB.getBreakType()) { + case PointBreak: + PointBreak aPB = (PointBreak) aCB; + + if (_frmPointSymbolSet == null) { + _frmPointSymbolSet = new FrmPointSymbolSet((JFrame) SwingUtilities.getWindowAncestor(this), false, this); + _frmPointSymbolSet.setLocationRelativeTo(this); + _frmPointSymbolSet.setVisible(true); + } + _frmPointSymbolSet.setPointBreak(aPB); + _frmPointSymbolSet.setVisible(true); + break; + case LabelBreak: + LabelBreak aLB = (LabelBreak) aCB; + + if (_frmLabelSymbolSet == null) { + _frmLabelSymbolSet = new FrmLabelSymbolSet((JFrame) SwingUtilities.getWindowAncestor(this), false, this); + _frmLabelSymbolSet.setLocationRelativeTo(this); + _frmLabelSymbolSet.setVisible(true); + } + _frmLabelSymbolSet.setLabelBreak(aLB); + _frmLabelSymbolSet.setVisible(true); + break; + case PolylineBreak: + PolylineBreak aPLB = (PolylineBreak) aCB; + + if (_frmPolylineSymbolSet == null) { + _frmPolylineSymbolSet = new FrmPolylineSymbolSet((JFrame) SwingUtilities.getWindowAncestor(this), false, this); + _frmPolylineSymbolSet.setLocationRelativeTo(this); + _frmPolylineSymbolSet.setVisible(true); + } + _frmPolylineSymbolSet.setPolylineBreak(aPLB); + _frmPolylineSymbolSet.setVisible(true); + break; + case PolygonBreak: + PolygonBreak aPGB = (PolygonBreak) aCB; + + if (_frmPolygonSymbolSet == null) { + _frmPolygonSymbolSet = new FrmPolygonSymbolSet((JFrame) SwingUtilities.getWindowAncestor(this), false, this); + _frmPolygonSymbolSet.setLocationRelativeTo(this); + _frmPolygonSymbolSet.setVisible(true); + } + _frmPolygonSymbolSet.setPolygonBreak(aPGB); + _frmPolygonSymbolSet.setVisible(true); + break; + } + } + + private void showSymbolSetForm(Graphic graphic) { + Shape shape = graphic.getShape(); + ColorBreak aCB = graphic.getLegend(); + switch (aCB.getBreakType()) { + case PointBreak: + PointBreak aPB = (PointBreak) aCB; + + if (_frmPointSymbolSet == null) { + _frmPointSymbolSet = new FrmPointSymbolSet((JFrame) SwingUtilities.getWindowAncestor(this), false, this); + _frmPointSymbolSet.setLocationRelativeTo(this); + _frmPointSymbolSet.setVisible(true); + } + _frmPointSymbolSet.setPointBreak(aPB); + _frmPointSymbolSet.setVisible(true); + break; + case LabelBreak: + LabelBreak aLB = (LabelBreak) aCB; + + if (_frmLabelSymbolSet == null) { + _frmLabelSymbolSet = new FrmLabelSymbolSet((JFrame) SwingUtilities.getWindowAncestor(this), false, this); + _frmLabelSymbolSet.setLocationRelativeTo(this); + _frmLabelSymbolSet.setVisible(true); + } + _frmLabelSymbolSet.setLabelBreak(aLB); + _frmLabelSymbolSet.setVisible(true); + break; + case PolylineBreak: + PolylineBreak aPLB = (PolylineBreak) aCB; + + if (_frmPolylineSymbolSet == null) { + _frmPolylineSymbolSet = new FrmPolylineSymbolSet((JFrame) SwingUtilities.getWindowAncestor(this), false, this); + _frmPolylineSymbolSet.setLocationRelativeTo(this); + _frmPolylineSymbolSet.setVisible(true); + } + _frmPolylineSymbolSet.setPolylineBreak(aPLB); + _frmPolylineSymbolSet.setVisible(true); + break; + case PolygonBreak: + PolygonBreak aPGB = (PolygonBreak) aCB; + + if (_frmPolygonSymbolSet == null) { + _frmPolygonSymbolSet = new FrmPolygonSymbolSet((JFrame) SwingUtilities.getWindowAncestor(this), false, this); + _frmPolygonSymbolSet.setLocationRelativeTo(this); + _frmPolygonSymbolSet.setVisible(true); + } + _frmPolygonSymbolSet.setPolygonBreak(aPGB); + _frmPolygonSymbolSet.setVisible(true); + break; + case VectorBreak: + WindArrow wa = (WindArrow) shape; + //VectorBreak vb = (VectorBreak) aCB; + Object[] lens = {5, 10, 15, 20, 25, 30}; + Object lenObj = JOptionPane.showInputDialog((JFrame) SwingUtilities.getWindowAncestor(this), + "Select wind speed:", "Selection", JOptionPane.PLAIN_MESSAGE, null, lens, (int) wa.length); + if (lenObj != null) { + wa.length = Integer.parseInt(lenObj.toString()); + //this.paintGraphics(); + this.repaintNew(); + } + break; + } + } + + void onKeyPressed(KeyEvent e) { + if (_mouseMode == MouseMode.Select) { + switch (e.getKeyCode()) { + case KeyEvent.VK_DELETE: + onRemoveElementClick(); + break; + case KeyEvent.VK_LEFT: + case KeyEvent.VK_RIGHT: + case KeyEvent.VK_UP: + case KeyEvent.VK_DOWN: + int x = 0; + int y = 0; + int d = 5; + if (e.isControlDown()) { + d = 1; + } + switch (e.getKeyCode()) { + case KeyEvent.VK_LEFT: + x = -d; + break; + case KeyEvent.VK_RIGHT: + x = d; + break; + case KeyEvent.VK_UP: + y = -d; + break; + case KeyEvent.VK_DOWN: + y = d; + break; + } + for (int i = 0; i < _layoutElements.size(); i++) { + LayoutElement aElement = _layoutElements.get(i); + if (aElement.isSelected()) { + if (x != 0) { + aElement.setLeft(aElement.getLeft() + x); + } + if (y != 0) { + aElement.setTop(aElement.getTop() + y); + } + aElement.moveUpdate(); + } + } + //this.paintGraphics(); + this.repaintNew(); + break; + } + } + } + + private void onRemoveElementClick() { + UndoableEdit edit = (new MapLayoutUndoRedo()).new RemoveElementsEdit(this, _selectedElements); + this.fireUndoEditEvent(edit); + for (LayoutElement element : _selectedElements) { + removeElement(element); + } + + _selectedElements.clear(); + _startNewGraphic = true; + //paintGraphics(); + this.repaintNew(); + } + + // + // + /** + * Get if using off screen image double buffering. + * Using double buffering will be faster but lower view quality in + * high dpi screen computer. + * + * @return Boolean + */ + public boolean isDoubleBuffer() { + return this.doubleBuffer; + } + + /** + * Set using off screen image double buffering or not. + * @param value Boolean + */ + public void setDoubleBuffer(boolean value) { + this.doubleBuffer = value; + } + + /** + * Get if lock view update + * + * @return If lock view update + */ + public boolean isLockViewUpdate() { + return _lockViewUpdate; + } + + /** + * Set if lock view update + * + * @param istrue If lock view update + */ + public void setLockViewUpdate(boolean istrue) { + _lockViewUpdate = istrue; + } + + /** + * Get map frames + * + * @return Map frames + */ + public List getMapFrames() { + return _mapFrames; + } + + /** + * Set map frames + * + * @param mfs Map frames + */ + public void setMapFrames(List mfs) { + _mapFrames = mfs; + _mapFrames = new ArrayList<>(); + for (MapFrame mf : mfs) { + boolean isInsert = false; + for (int i = 0; i < _mapFrames.size(); i++) { + MapFrame amf = _mapFrames.get(i); + if (mf.getOrder() < amf.getOrder()) { + _mapFrames.add(i, mf); + isInsert = true; + break; + } + } + + if (!isInsert) { + _mapFrames.add(mf); + } + } + } + + /** + * Get active map frame + * + * @return Active map frame + */ + public MapFrame getActiveMapFrame() { + for (MapFrame mf : _mapFrames) { + if (mf.isActive()) { + return mf; + } + } + + return null; + } + + /** + * Get active layout map + * + * @return Active layout map + */ + public LayoutMap getActiveLayoutMap() { + LayoutMap aLM = null; + for (LayoutMap lm : this.getLayoutMaps()) { + if (lm.getMapFrame().isActive()) { + aLM = lm; + break; + } + } + return aLM; + } + + /** + * Get if is landscape + * + * @return Boolean + */ + public boolean isLandscape() { + return _isLandscape; + } + + /** + * Set if is landscape + * + * @param istrue + */ + public void setLandscape(boolean istrue) { + _isLandscape = istrue; + Rectangle.Float aRect = paperToScreen(new Rectangle.Float(0, 0, this.getPaperWidth(), this.getPaperHeight())); + _pageBounds.width = (int) aRect.width; + _pageBounds.height = (int) aRect.height; + } + + /** + * Get mouse mode + * + * @return The mouse mode + */ + public MouseMode getMouseMode() { + return _mouseMode; + } + + /** + * Set mouse mode + * + * @param mm The mouse mode + */ + public void setMouseMode(MouseMode mm) { + _mouseMode = mm; + switch (_mouseMode) { + case New_Label: + case New_Point: + case New_Polyline: + case New_Polygon: + case New_Rectangle: + case New_Circle: + case New_Curve: + case New_CurvePolygon: + case New_Ellipse: + case New_Freehand: + this.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); + break; + case Map_Measurement: + this.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); + break; + case Map_SelectFeatures_Rectangle: + case Map_SelectFeatures_Polygon: + case Map_SelectFeatures_Lasso: + case Map_SelectFeatures_Circle: + this.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); + this._tempImage = GlobalUtil.deepCopy(this._layoutBitmap); + break; + } + } + + /** + * Get if antialias + * + * @return Boolean + */ + public boolean isAntiAlias() { + return _antiAlias; + } + + /** + * Set if antialias + * + * @param istrue Boolean + */ + public void setAntiAlias(boolean istrue) { + _antiAlias = istrue; + } + + /** + * Get page foreground color + * + * @return Page foreground color + */ + public Color getPageForeColor() { + return this._pageForeColor; + } + + /** + * Set page foreground color + * + * @param c Page foreground color + */ + public void setPageForeColor(Color c) { + _pageForeColor = c; + } + + /** + * Get page background color + * + * @return Page background color + */ + public Color getPageBackColor() { + return _pageBackColor; + } + + /** + * Set page background color + * + * @param c Page background color + */ + public void setPageBackColor(Color c) { + _pageBackColor = c; + + if (c == Color.black) { + _pageForeColor = Color.white; + } else if (c == Color.white) { + _pageForeColor = Color.black; + } + } + + /** + * Get paper size + * + * @return Paper size + */ + public PaperSize getPaperSize() { + return _paperSize; + } + + /** + * Set paper size + * + * @param ps Paper size + */ + public void setPaperSize(PaperSize ps) { + _paperSize = ps; + Rectangle.Float aRect = paperToScreen(new Rectangle.Float(0, 0, getPaperWidth(), getPaperHeight())); + _pageBounds.width = (int) aRect.width; + _pageBounds.height = (int) aRect.height; + } + + /** + * Set paper size + * + * @param width Width + * @param height Height + */ + public void setPaperSize(int width, int height) { + PaperSize ps = new PaperSize("Custom", width, height); + setPaperSize(ps); + } + + /** + * Get the width of the paper in 1/100 of an inch + */ + private int getPaperWidth() { + if (_isLandscape) { + return _paperSize.getHeight(); + } + return _paperSize.getWidth(); + } + + /** + * Gets the heigh of the paper in 1/100 of an inch + */ + private int getPaperHeight() { + if (_isLandscape) { + return _paperSize.getWidth(); + } + return _paperSize.getHeight(); + } + + /** + * Get layout map elements + * + * @return The layout map elements + */ + public List getLayoutMaps() { + List layoutMaps = new ArrayList<>(); + for (LayoutElement aLE : _layoutElements) { + if (aLE.getElementType() == ElementType.LayoutMap) { + layoutMaps.add((LayoutMap) aLE); + } + } + return layoutMaps; + } + + /** + * Get selected elements + * + * @return Selected elements + */ + public List getSelectedElements() { + return _selectedElements; + } + + /// + /// Get or set page bounds + /// + /** + * Get page bounds + * + * @return Page bounds + */ + public Rectangle getPageBounds() { + return _pageBounds; + } + + /** + * Set page bounds + * + * @param pb Page bounds + */ + public void setPageBounds(Rectangle pb) { + _pageBounds = pb; + } + + /** + * Get page location + * + * @return Page location + */ + public PointF getPageLocation() { + return _pageLocation; + } + + /** + * Set page location + * + * @param p Page location + */ + public void setPageLocation(PointF p) { + _pageLocation = p; + } + + /** + * Get zoom + * + * @return Zoom + */ + public float getZoom() { + return _zoom; + } + + /** + * Set zoom + * + * @param zoom Zoom + */ + public void setZoom(float zoom) { + _zoom = zoom; + this.fireZoomChangedEvent(); + } + + /** + * Get default point break + * + * @return Default point break + */ + public PointBreak getDefPointBreak() { + return _defPointBreak; + } + + /** + * Set default point break + * + * @param pb Default point break + */ + public void setDefPointBreak(PointBreak pb) { + _defPointBreak = pb; + } + + /** + * Get default label break + * + * @return Default label break + */ + public LabelBreak getDefLabelBreak() { + return _defLabelBreak; + } + + /** + * Set default label break + * + * @param lb Default label break + */ + public void setDefLabelBreak(LabelBreak lb) { + _defLabelBreak = lb; + } + + /** + * Get default polyline break + * + * @return Default polyline break + */ + public PolylineBreak getDefPolylineBreak() { + return _defPolylineBreak; + } + + /** + * Set default polyline break + * + * @param pb Default polyline break + */ + public void setDefPolylineBreak(PolylineBreak pb) { + _defPolylineBreak = pb; + } + + /** + * Get default polygon break + * + * @return Default polygon break + */ + public PolygonBreak getDefPolygonBreak() { + return _defPolygonBreak; + } + + /** + * Set default polygon break + * + * @param pb Default polygon break + */ + public void setDefPolygonBreak(PolygonBreak pb) { + _defPolygonBreak = pb; + } + + /** + * Get measurement form + * + * @return Measurement form + */ + public FrmMeasurement getMeasurementForm() { + return _frmMeasure; + } + + /** + * set measurement form + * + * @param form Measurement form + */ + public void setMeasurementForm(FrmMeasurement form) { + _frmMeasure = form; + } + + /** + * Get view image + * + * @return View image + */ + public BufferedImage getViewImage() { + BufferedImage aImage = new BufferedImage(_pageBounds.width, _pageBounds.height, BufferedImage.TYPE_INT_ARGB); + Graphics2D g = aImage.createGraphics(); + paintGraphics(g); + return aImage; + } + + // + // + // + @Override + public int getWebMapZoom(){ + WebMapLayer layer = this.getActiveMapFrame().getMapView().getWebMapLayer(); + if (layer != null){ + return layer.getZoom(); + } + return 0; + } + + @Override + public void reDraw(){ + //this.paintGraphics(); + this.repaintNew(); + } + + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + + Graphics2D g2 = (Graphics2D) g; + g2.setColor(this.getBackground()); + g2.clearRect(0, 0, this.getWidth(), this.getHeight()); + g2.fillRect(0, 0, this.getWidth(), this.getHeight()); + + if (this.newPaint) { + this.paintGraphicsAll(g2); + } else { + //g2.drawImage(this._layoutBitmap, _xShift, _yShift, this.getBackground(), this); + AffineTransform mx = new AffineTransform(); + mx.translate((float) _xShift, (float) _yShift); + AffineTransformOp aop = new AffineTransformOp(mx, AffineTransformOp.TYPE_BILINEAR); + g2.drawImage(this._layoutBitmap, aop, 0, 0); + } + + if (this._dragMode) { + Rectangle rect = new Rectangle(); + float dash1[] = {2.0f}; + switch (this._mouseMode) { + case Map_ZoomIn: + rect.width = Math.abs(_mouseLastPos.x - _mouseDownPoint.x); + rect.height = Math.abs(_mouseLastPos.y - _mouseDownPoint.y); + rect.x = Math.min(_mouseLastPos.x, _mouseDownPoint.x); + rect.y = Math.min(_mouseLastPos.y, _mouseDownPoint.y); + //g2.setColor(this.getForeground()); + g2.setColor(Color.black); + g2.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f)); + g2.draw(rect); + break; + case MoveSelection: + rect.x = _selectedRectangle.x + _mouseLastPos.x - _mouseDownPoint.x; + rect.y = _selectedRectangle.y + _mouseLastPos.y - _mouseDownPoint.y; + rect.width = _selectedRectangle.width; + rect.height = _selectedRectangle.height; + g2.setColor(Color.red); + g2.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f)); + g2.draw(rect); + break; + case ResizeSelected: + g2.setColor(Color.red); + g2.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f)); + g2.draw(_selectedRectangle); + break; + case CreateSelection: + case New_Rectangle: + case New_Ellipse: + case Map_SelectFeatures_Rectangle: + int sx = Math.min(_mouseDownPoint.x, _mouseLastPos.x); + int sy = Math.min(_mouseDownPoint.y, _mouseLastPos.y); + g2.setColor(this.getForeground()); + g2.draw(new Rectangle(sx, sy, Math.abs(_mouseLastPos.x - _mouseDownPoint.x), + Math.abs(_mouseLastPos.y - _mouseDownPoint.y))); + break; + case New_Freehand: + case Map_SelectFeatures_Lasso: + List points = new ArrayList<>(_graphicPoints); + points.add(new PointF(_mouseLastPos.x, _mouseLastPos.y)); + g2.setColor(this.getForeground()); + _graphicPoints.add(new PointF(_mouseLastPos.x, _mouseLastPos.y)); + Draw.drawPolyline(points, g2); + break; + case New_Circle: + case Map_SelectFeatures_Circle: + int radius = (int) Math.sqrt(Math.pow(_mouseLastPos.x - _mouseDownPoint.x, 2) + + Math.pow(_mouseLastPos.y - _mouseDownPoint.y, 2)); + g2.setColor(this.getForeground()); + g2.drawLine(_mouseDownPoint.x, _mouseDownPoint.y, _mouseLastPos.x, _mouseLastPos.y); + g2.drawOval(_mouseDownPoint.x - radius, _mouseDownPoint.y - radius, + radius * 2, radius * 2); + break; + case InEditingVertices: + PointF p1 = pageToScreen((float) _editingVertices.get(1).X, (float) _editingVertices.get(1).Y); + PointF p2 = pageToScreen((float) _editingVertices.get(2).X, (float) _editingVertices.get(2).Y); + g2.setColor(Color.black); + g2.drawLine((int) p1.X, (int) p1.Y, _mouseLastPos.x, _mouseLastPos.y); + if (_editingVertices.size() == 3) { + g2.drawLine((int) p2.X, (int) p2.Y, _mouseLastPos.x, _mouseLastPos.y); + } + + Rectangle nRect = new Rectangle(_mouseLastPos.x - 3, _mouseLastPos.y - 3, 6, 6); + g2.setColor(Color.cyan); + g2.fill(nRect); + g2.setColor(Color.black); + g2.draw(nRect); + break; + } + } + + switch (this._mouseMode) { + case New_Polyline: + case New_Polygon: + case New_Curve: + case New_CurvePolygon: + case Map_SelectFeatures_Polygon: + if (!_startNewGraphic) { + List points = new ArrayList<>(_graphicPoints); + points.add(new PointF(_mouseLastPos.x, _mouseLastPos.y)); + g2.setColor(this.getForeground()); + switch (_mouseMode) { + case New_Polyline: + Draw.drawPolyline(points, g2); + break; + case New_Polygon: + points.add(points.get(0)); + Draw.drawPolyline(points, g2); + break; + case New_Curve: + Draw.drawCurveLine(points, g2); + break; + case New_CurvePolygon: + points.add(points.get(0)); + Draw.drawCurveLine(points, g2); + break; + } + } + break; + case Map_Measurement: + if (!_startNewGraphic) { + //Draw graphic + //g.SmoothingMode = SmoothingMode.AntiAlias; + PointF[] fpoints = (PointF[]) _graphicPoints.toArray(new PointF[_graphicPoints.size()]); + PointF[] points = new PointF[fpoints.length + 1]; + System.arraycopy(fpoints, 0, points, 0, fpoints.length); + points[_graphicPoints.size()] = new PointF(_mouseLastPos.x, _mouseLastPos.y); + + if (_frmMeasure.getMeasureType() == MeasureTypes.Length) { + g2.setColor(Color.red); + g2.setStroke(new BasicStroke(2)); + Draw.drawPolyline(points, g2); + } else { + PointF[] ppoints = new PointF[points.length + 1]; + System.arraycopy(points, 0, ppoints, 0, points.length); + ppoints[ppoints.length - 1] = _graphicPoints.get(0); + Color aColor = new Color(Color.blue.getRed(), Color.blue.getGreen(), Color.blue.getBlue(), 100); + g2.setColor(aColor); + PolygonBreak aPB = new PolygonBreak(); + aPB.setColor(aColor); + Draw.drawPolygon(ppoints, aPB, g2); + g2.setColor(Color.red); + Draw.drawPolyline(ppoints, g2); + } + } + break; + } + + if (this._currentLayoutMap != null) { + if (this._currentLayoutMap.getMapFrame().getMapView().isDrawIdentiferShape()) { + int selLayerHandle = this._currentLayoutMap.getMapFrame().getMapView().getSelectedLayerHandle(); + if (selLayerHandle >= 0) { + MapLayer aLayer = this._currentLayoutMap.getMapFrame().getMapView().getLayerByHandle(selLayerHandle); + if (aLayer.getLayerType() == LayerTypes.VectorLayer) { + VectorLayer vLayer = (VectorLayer) aLayer; + Rectangle rect = getElementViewExtent(_currentLayoutMap); + this._currentLayoutMap.getMapFrame().getMapView().drawIdShape(g2, vLayer.getShapes().get(vLayer.getIdentiferShape()), rect); + } + } + } + } + } + + /** + * New paint + */ + public void repaintNew() { + if (this.doubleBuffer) { + this.newPaint = false; + this.paintGraphics(); + } else { + this.newPaint = true; + this.repaint(); + this.updateViewImage(); + } + } + + private void repaintOld() { + if (this.doubleBuffer) { + this.repaint(); + } else { + this.newPaint = false; + this.repaint(); + } + } + + private void updateViewImage() { + if (this.getWidth() < 5 || this.getHeight() < 5) { + return; + } + + int width = this.getWidth(); + int height = this.getHeight(); + + this._layoutBitmap = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); + Graphics2D g = this._layoutBitmap.createGraphics(); + this.print(g); + g.dispose(); + } + + public void paintGraphicsAll(Graphics2D g) { + if (this._lockViewUpdate) { + return; + } + + if (this.getWidth() < 10 || this.getHeight() < 10) { + return; + } + + if ((this._pageBounds.width < 2) || (this._pageBounds.height < 2)) { + return; + } + + g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + + //Judge if show scroll bar + int pageHeight = (int) (_pageBounds.height * _zoom); + int pageWidth = (int) (_pageBounds.width * _zoom); + if (pageHeight > this.getHeight()) { + int sHeight = pageHeight - this.getHeight() + 40; + _vScrollBar.setMinimum(0); + _vScrollBar.setMaximum(pageHeight); + _vScrollBar.setVisibleAmount(pageHeight - sHeight); + _vScrollBar.setUnitIncrement(pageHeight / 10); + _vScrollBar.setBlockIncrement(pageHeight / 5); + if (_vScrollBar.getWidth() == 0) { + _vScrollBar.setSize(21, this._vScrollBar.getHeight()); + } + + if (_vScrollBar.isVisible() == false) { + _vScrollBar.setValue(0); + _vScrollBar.setVisible(true); + } + } else { + _pageBounds.y = 0; + this._pageLocation.Y = 0; + _vScrollBar.setVisible(false); + } + + if (pageWidth > this.getWidth()) { + int sWidth = pageWidth - this.getWidth() + 40; + _hScrollBar.setMinimum(0); + _hScrollBar.setMaximum(pageWidth); + _hScrollBar.setVisibleAmount(pageWidth - sWidth); + _hScrollBar.setUnitIncrement(pageWidth / 10); + _hScrollBar.setBlockIncrement(pageWidth / 5); + if (this._hScrollBar.getHeight() == 0) { + this._hScrollBar.setSize(this._hScrollBar.getWidth(), 21); + } + + if (_hScrollBar.isVisible() == false) { + _hScrollBar.setValue(0); + _hScrollBar.setVisible(true); + } + } else { + _pageBounds.x = 0; + this._pageLocation.X = 0; + _hScrollBar.setVisible(false); + } + + //Draw bound rectangle + Rectangle.Float aRect = pageToScreen(_pageBounds.x, _pageBounds.y, _pageBounds.width, _pageBounds.height); + g.setColor(_pageBackColor); + g.fill(aRect); + + //Draw layout elements + paintGraphicsOnLayout(g); + } + + public void paintGraphics() { + if (this._lockViewUpdate) { + return; + } + + if (this.getWidth() < 10 || this.getHeight() < 10) { + return; + } + + if ((this._pageBounds.width < 2) || (this._pageBounds.height < 2)) { + return; + } + + _layoutBitmap = new BufferedImage(this.getWidth(), + this.getHeight(), BufferedImage.TYPE_INT_ARGB); + Graphics2D g = _layoutBitmap.createGraphics(); + g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + + //Judge if show scroll bar + int pageHeight = (int) (_pageBounds.height * _zoom); + int pageWidth = (int) (_pageBounds.width * _zoom); + if (pageHeight > this.getHeight()) { + int sHeight = pageHeight - this.getHeight() + 40; + _vScrollBar.setMinimum(0); + _vScrollBar.setMaximum(pageHeight); + _vScrollBar.setVisibleAmount(pageHeight - sHeight); + _vScrollBar.setUnitIncrement(pageHeight / 10); + _vScrollBar.setBlockIncrement(pageHeight / 5); + if (_vScrollBar.getWidth() == 0) { + _vScrollBar.setSize(21, this._vScrollBar.getHeight()); + } + + if (_vScrollBar.isVisible() == false) { + _vScrollBar.setValue(0); + _vScrollBar.setVisible(true); + } + } else { + _pageBounds.y = 0; + this._pageLocation.Y = 0; + _vScrollBar.setVisible(false); + } + + if (pageWidth > this.getWidth()) { + int sWidth = pageWidth - this.getWidth() + 40; + _hScrollBar.setMinimum(0); + _hScrollBar.setMaximum(pageWidth); + _hScrollBar.setVisibleAmount(pageWidth - sWidth); + _hScrollBar.setUnitIncrement(pageWidth / 10); + _hScrollBar.setBlockIncrement(pageWidth / 5); + if (this._hScrollBar.getHeight() == 0) { + this._hScrollBar.setSize(this._hScrollBar.getWidth(), 21); + } + + if (_hScrollBar.isVisible() == false) { + _hScrollBar.setValue(0); + _hScrollBar.setVisible(true); + } + } else { + _pageBounds.x = 0; + this._pageLocation.X = 0; + _hScrollBar.setVisible(false); + } + + //Draw bound rectangle + Rectangle.Float aRect = pageToScreen(_pageBounds.x, _pageBounds.y, _pageBounds.width, _pageBounds.height); + g.setColor(_pageBackColor); + g.fill(aRect); + + //Draw layout elements + paintGraphicsOnLayout(g); + + g.dispose(); + this.repaint(); + } + + /** + * Paint graphics on layout + * + * @param g Graphics2D + */ + public void paintGraphicsOnLayout(Graphics2D g) { + //g.SmoothingMode = _smoothingMode; + //g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; + + for (LayoutElement aElement : _layoutElements) { + if (!aElement.isVisible()) { + continue; + } + + aElement.paintOnLayout(g, _pageLocation, _zoom); + } + + //Draws the selection rectangle around each selected item + for (LayoutElement aElement : _layoutElements) { + if (!aElement.isVisible()) { + continue; + } + + if (aElement.isSelected()) { + if (_mouseMode == MouseMode.EditVertices) { + LayoutGraphic aLG = (LayoutGraphic) aElement; + List points = (List) aLG.getGraphic().getShape().getPoints(); + drawSelectedVertices(g, points); + } else { + float[] dashPattern = new float[]{2.0F, 1.0F}; + Rectangle aRect = pageToScreen(aElement.getBounds()); + g.setColor(Color.cyan); + g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 10.0f, dashPattern, 0.0f)); + g.draw(aRect); + + switch (aElement.getResizeAbility()) { + case SameWidthHeight: + drawSelectedConers(g, aElement); + break; + case ResizeAll: + drawSelectedConers(g, aElement); + drawSelectedEdgeCenters(g, aElement); + break; + } + } + } + } + } + + /** + * Paint graphics + * + * @param g Graphics2D + */ + public void paintGraphics(Graphics2D g) { + g.setColor(this._pageBackColor); + g.fillRect(0, 0, _pageBounds.width, _pageBounds.height); + + for (LayoutElement aElement : _layoutElements) { + if (!aElement.isVisible()) { + continue; + } + + //aElement.Paint(g); + aElement.paintOnLayout(g, new PointF(0, 0), 1); + } + } + + private void drawSelectedConers(Graphics2D g, LayoutElement aElement) { + Rectangle elementRect = pageToScreen(aElement.getBounds()); + int size = 6; + Rectangle rect = new Rectangle(elementRect.x - size / 2, elementRect.y - size / 2, size, size); + g.setColor(Color.cyan); + g.fill(rect); + g.setColor(Color.black); + g.draw(rect); + rect.y = elementRect.y + elementRect.height - size / 2; + g.setColor(Color.cyan); + g.fill(rect); + g.setColor(Color.black); + g.draw(rect); + rect.x = elementRect.x + elementRect.width - size / 2; + g.setColor(Color.cyan); + g.fill(rect); + g.setColor(Color.black); + g.draw(rect); + rect.y = elementRect.y - size / 2; + g.setColor(Color.cyan); + g.fill(rect); + g.setColor(Color.black); + g.draw(rect); + } + + private void drawSelectedEdgeCenters(Graphics2D g, LayoutElement aElement) { + Rectangle elementRect = pageToScreen(aElement.getBounds()); + int size = 6; + Rectangle rect = new Rectangle(elementRect.x + elementRect.width / 2 - size / 2, elementRect.y - size / 2, size, size); + g.setColor(Color.cyan); + g.fill(rect); + g.setColor(Color.black); + g.draw(rect); + rect.y = elementRect.y + elementRect.height - size / 2; + g.setColor(Color.cyan); + g.fill(rect); + g.setColor(Color.black); + g.draw(rect); + rect.x = elementRect.x - size / 2; + rect.y = elementRect.y + elementRect.height / 2 - size / 2; + g.setColor(Color.cyan); + g.fill(rect); + g.setColor(Color.black); + g.draw(rect); + rect.x = elementRect.x + elementRect.width - size / 2; + g.setColor(Color.cyan); + g.fill(rect); + g.setColor(Color.black); + g.draw(rect); + } + + private void drawSelectedVertices(Graphics2D g, List points) { + int size = 6; + Rectangle rect = new Rectangle(0, 0, size, size); + + for (PointD aPoint : points) { + PointF aP = pageToScreen((float) aPoint.X, (float) aPoint.Y); + rect.x = (int) aP.X - size / 2; + rect.y = (int) aP.Y - size / 2; + g.setColor(Color.cyan); + g.fill(rect); + g.setColor(Color.black); + g.draw(rect); + } + } + + /** + * Export to a picture file + * + * @param aFile File path + * @throws FileNotFoundException + * @throws PrintException + */ + public void exportToPicture(String aFile) throws FileNotFoundException, PrintException, IOException { + if (aFile.endsWith(".ps")) { + DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; + String mimeType = "application/postscript"; + StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, mimeType); + FileOutputStream out = new FileOutputStream(aFile); + if (factories.length > 0) { + PrintService service = factories[0].getPrintService(out); + SimpleDoc doc = new SimpleDoc(new Printable() { + @Override + public int print(Graphics g, PageFormat pf, int page) { + if (page >= 1) { + return Printable.NO_SUCH_PAGE; + } else { + double sf1 = pf.getImageableWidth() / (_pageBounds.width + 1); + double sf2 = pf.getImageableHeight() / (_pageBounds.height + 1); + double s = Math.min(sf1, sf2); + Graphics2D g2 = (Graphics2D) g; + g2.translate((pf.getWidth() - pf.getImageableWidth()) / 2, (pf.getHeight() - pf.getImageableHeight()) / 2); + g2.scale(s, s); + + paintGraphics(g2); + return Printable.PAGE_EXISTS; + } + } + }, flavor, null); + DocPrintJob job = service.createPrintJob(); + PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet(); + job.print(doc, attributes); + out.close(); + } + } else if (aFile.endsWith(".eps")) { + int width = this.getPaperWidth(); + int height = this.getPaperHeight(); + // EPSGraphics2D g = new EPSGraphics2D(0.0, 0.0, width, height); + // paintGraphics(g); + // FileOutputStream file = new FileOutputStream(aFile); + // try { + // file.write(g.getBytes()); + // } finally { + // file.close(); + // g.dispose(); + // } + + Properties p = new Properties(); + p.setProperty("PageSize", "A5"); + VectorGraphics g = new PSGraphics2D(new File(aFile), new Dimension(width, height)); + //g.setProperties(p); + g.startExport(); + this.paintGraphics(g); + g.endExport(); + g.dispose(); + } else if (aFile.endsWith(".pdf")) { + int width = this.getPaperWidth(); + int height = this.getPaperHeight(); + try { + com.itextpdf.text.Document document = new com.itextpdf.text.Document(new com.itextpdf.text.Rectangle(width, height)); + PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(aFile)); + document.open(); + PdfContentByte cb = writer.getDirectContent(); + PdfTemplate pdfTemp = cb.createTemplate(width, height); + Graphics2D g2 = new PdfGraphics2D(pdfTemp, width, height, true); + this.paintGraphics(g2); + g2.dispose(); + cb.addTemplate(pdfTemp, 0, 0); + document.close(); + } catch (DocumentException | FileNotFoundException e) { + e.printStackTrace(); + } + } else if (aFile.endsWith(".emf")) { + int width = this.getPaperWidth(); + int height = this.getPaperHeight(); + VectorGraphics g = new EMFGraphics2D(new File(aFile), new Dimension(width, height)); + //g.setProperties(p); + g.startExport(); + this.paintGraphics(g); + g.endExport(); + g.dispose(); + } else { + String extension = aFile.substring(aFile.lastIndexOf('.') + 1); + BufferedImage aImage; + if (extension.equalsIgnoreCase("bmp")) + aImage = new BufferedImage(_pageBounds.width, _pageBounds.height, BufferedImage.TYPE_INT_RGB); + else + aImage = new BufferedImage(_pageBounds.width, _pageBounds.height, BufferedImage.TYPE_INT_ARGB); + Graphics2D g = aImage.createGraphics(); + paintGraphics(g); + if (extension.equalsIgnoreCase("jpg")) { + BufferedImage newImage = new BufferedImage(aImage.getWidth(), aImage.getHeight(), BufferedImage.TYPE_INT_RGB); + newImage.createGraphics().drawImage(aImage, 0, 0, Color.BLACK, null); + ImageIO.write(newImage, extension, new File(aFile)); + } else { + ImageIO.write(aImage, extension, new File(aFile)); + } + } + } + + /** + * Export to a picture file + * + * @param fileName File path + * @param dpi DPI + * @throws FileNotFoundException + * @throws PrintException + */ + public void exportToPicture(String fileName, Integer dpi) throws FileNotFoundException, PrintException, IOException { + if (dpi == null) { + exportToPicture(fileName); + } else { + File output = new File(fileName); + output.delete(); + + int width = _pageBounds.width; + int height = _pageBounds.height; + String formatName = fileName.substring(fileName.lastIndexOf('.') + 1); + if (formatName.equals("jpg")) { + formatName = "jpeg"; + saveImage_Jpeg(fileName, width, height, dpi); + return; + } + + double scaleFactor = dpi / 72.0; + BufferedImage image = new BufferedImage((int)(width * scaleFactor), (int)(height * scaleFactor), BufferedImage.TYPE_INT_ARGB); + Graphics2D g = image.createGraphics(); + AffineTransform at = g.getTransform(); + at.scale(scaleFactor, scaleFactor); + g.setTransform(at); + paintGraphics(g); + for (Iterator iw = ImageIO.getImageWritersByFormatName(formatName); iw.hasNext();) { + ImageWriter writer = iw.next(); + ImageWriteParam writeParam = writer.getDefaultWriteParam(); + ImageTypeSpecifier typeSpecifier = ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_ARGB); + IIOMetadata metadata = writer.getDefaultImageMetadata(typeSpecifier, writeParam); + if (metadata.isReadOnly() || !metadata.isStandardMetadataFormatSupported()) { + continue; + } + + ImageUtil.setDPI(metadata, dpi); + + final ImageOutputStream stream = ImageIO.createImageOutputStream(output); + try { + writer.setOutput(stream); + writer.write(metadata, new IIOImage(image, null, metadata), writeParam); + } finally { + stream.close(); + } + break; + } + g.dispose(); + } + } + + private boolean saveImage_Jpeg(String file, int width, int height, int dpi) { + double scaleFactor = dpi / 72.0; + BufferedImage bufferedImage = new BufferedImage((int)(width * scaleFactor), (int)(height * scaleFactor), BufferedImage.TYPE_INT_RGB); + Graphics2D g = bufferedImage.createGraphics(); + AffineTransform at = g.getTransform(); + at.scale(scaleFactor, scaleFactor); + g.setTransform(at); + paintGraphics(g); + + try { + // Image writer + ImageWriter imageWriter = ImageIO.getImageWritersBySuffix("jpeg").next(); + ImageOutputStream ios = ImageIO.createImageOutputStream(new File(file)); + imageWriter.setOutput(ios); + + // Compression + JPEGImageWriteParam jpegParams = (JPEGImageWriteParam) imageWriter.getDefaultWriteParam(); + jpegParams.setCompressionMode(JPEGImageWriteParam.MODE_EXPLICIT); + jpegParams.setCompressionQuality(0.85f); + + // Metadata (dpi) + IIOMetadata data = imageWriter.getDefaultImageMetadata(new ImageTypeSpecifier(bufferedImage), jpegParams); + Element tree = (Element) data.getAsTree("javax_imageio_jpeg_image_1.0"); + Element jfif = (Element) tree.getElementsByTagName("app0JFIF").item(0); + jfif.setAttribute("Xdensity", Integer.toString(dpi)); + jfif.setAttribute("Ydensity", Integer.toString(dpi)); + jfif.setAttribute("resUnits", "1"); // density is dots per inch + data.setFromTree("javax_imageio_jpeg_image_1.0", tree); + + // Write and clean up + imageWriter.write(null, new IIOImage(bufferedImage, null, data), jpegParams); + ios.close(); + imageWriter.dispose(); + } catch (Exception e) { + return false; + } + g.dispose(); + + return true; + } + + // + // + + /** + * Convert screen coordinate to page coordinate + * + * @param screenX Screen x + * @param screenY Screen y + * @return Page position + */ + public Point screenToPage(int screenX, int screenY) { + float x = (screenX - _pageLocation.X) / _zoom; + float y = (screenY - _pageLocation.Y) / _zoom; + return (new Point((int) x, (int) y)); + } + + /** + * Convert screen coordinate to page coordinate + * + * @param screenX Screen x + * @param screenY Screen y + * @return Page position + */ + public PointF screenToPage(float screenX, float screenY) { + float x = (screenX - _pageLocation.X) / _zoom; + float y = (screenY - _pageLocation.Y) / _zoom; + return (new PointF(x, y)); + } + + private PointF pageToScreen(float pageX, float pageY) { + float x = pageX * _zoom + _pageLocation.X; + float y = pageY * _zoom + _pageLocation.Y; + return (new PointF(x, y)); + } + + private Rectangle.Float pageToScreen(float pageX, float pageY, float pageW, float pageH) { + PointF screenTL = pageToScreen(pageX, pageY); + PointF screenBR = pageToScreen(pageX + pageW, pageY + pageH); + return new Rectangle.Float(screenTL.X, screenTL.Y, screenBR.X - screenTL.X, screenBR.Y - screenTL.Y); + } + + private Rectangle pageToScreen(Rectangle rect) { + PointF screenTL = pageToScreen(rect.x, rect.y); + PointF screenBR = pageToScreen(rect.x + rect.width, rect.y + rect.height); + return new Rectangle((int) screenTL.X, (int) screenTL.Y, (int) (screenBR.X - screenTL.X), (int) (screenBR.Y - screenTL.Y)); + } + + private Rectangle.Float paperToScreen(Rectangle.Float paper) { + return paperToScreen(paper.x, paper.y, paper.width, paper.height); + } + + /** + * Converts a rectangle in paper coordiants in 1/100 of an inch to screen + * coordinants + * + * @param paperX Paper x + * @param paperY Paper Y + * @param paperW Paper width + * @param paperH Paper height + * @return Screen rectangle + */ + private Rectangle.Float paperToScreen(float paperX, float paperY, float paperW, float paperH) { + PointF screenTL = paperToScreen(paperX, paperY); + PointF screenBR = paperToScreen(paperX + paperW, paperY + paperH); + return new Rectangle.Float(screenTL.X, screenTL.Y, screenBR.X - screenTL.X, screenBR.Y - screenTL.Y); + } + + /** + * Converts between a point in paper coordinants in 1/100th of an inch to + * screen coordinants + * + * @param paperX Paper x + * @param paperY Paper y + * @return Screen point + */ + private PointF paperToScreen(float paperX, float paperY) { + float screenX = (paperX / 100F * 96F * _zoom) + _pageLocation.X; + float screenY = (paperY / 100F * 96F * _zoom) + _pageLocation.Y; + return (new PointF(screenX, screenY)); + } + // + // + + /** + * Update the order of the map frames + */ + public void updateMapFrameOrder() { + List lms = getLayoutMaps(); + for (int i = 0; i < lms.size(); i++) { + lms.get(i).getMapFrame().setOrder(i); + } + } + + /** + * Update map frames + * + * @param mapFrames The map frames + */ + public void updateMapFrames(List mapFrames) { + for (MapFrame mf : mapFrames) { + boolean isNew = true; + for (MapFrame aMF : _mapFrames) { + if (mf == aMF) { + isNew = false; + break; + } + } + if (isNew) { + LayoutMap aLM = new LayoutMap(mf, this.tileLoadListener); + addElement(aLM); + } + } + + for (int i = 0; i < _mapFrames.size(); i++) { + MapFrame mf = _mapFrames.get(i); + boolean isNew = true; + for (MapFrame aMF : mapFrames) { + if (mf == aMF) { + isNew = false; + break; + } + } + if (isNew) { + LayoutMap aLM = getLayoutMap(mf); + if (aLM != null) { + removeElement(aLM); + i -= 1; + } + } + } + + this.setMapFrames(mapFrames); + } + + /** + * Add a layout element + * + * @param aElement The layout element + */ + public void addElement(LayoutElement aElement) { + _layoutElements.add(aElement); + if (aElement.getElementType() == ElementType.LayoutMap) { + final LayoutMap aLM = (LayoutMap) aElement; + aLM.addMapViewUpdatedListener(new IMapViewUpdatedListener() { + @Override + public void mapViewUpdatedEvent(MapViewUpdatedEvent event) { + //if (aLM.getMapFrame().isFireMapViewUpdate()) { + //paintGraphics(); + repaintNew(); + //} + } + }); + if (aLM.getMapFrame().isActive()) { + _currentLayoutMap = aLM; + } + } + } + + /** + * Remove a layout element + * + * @param aElement The layout element + */ + public void removeElement(LayoutElement aElement) { + switch (aElement.getElementType()) { + case LayoutMap: + if (this.getLayoutMaps().size() == 1) { + JOptionPane.showMessageDialog(this, "There is at least one layout map!"); + return; + } + + LayoutMap aLM = (LayoutMap) aElement; + for (int i = 0; i < _layoutElements.size(); i++) { + LayoutElement aLE = _layoutElements.get(i); + switch (aLE.getElementType()) { + case LayoutLegend: + if (((LayoutLegend) aLE).getLayoutMap() == aLM) { + _layoutElements.remove(aLE); + i -= 1; + } + break; + case LayoutScaleBar: + if (((LayoutScaleBar) aLE).getLayoutMap() == aLM) { + _layoutElements.remove(aLE); + i -= 1; + } + break; + case LayoutNorthArraw: + if (((LayoutNorthArrow) aLE).getLayoutMap() == aLM) { + _layoutElements.remove(aLE); + i -= 1; + } + break; + } + } + _mapFrames.remove(aLM.getMapFrame()); + _layoutElements.remove(aElement); + if (_mapFrames.size() > 0) { + setActiveMapFrame(_mapFrames.get(0)); + } + this.fireMapFramesUpdatedEvent(); + break; + default: + _layoutElements.remove(aElement); + break; + } + // if (this._selectedElements.contains(aElement)){ + // this._selectedElements.remove(aElement); + // } + } + + /** + * Add a text label element + * + * @param text The text + * @param x Center x + * @param y Center y + * @return Text layout graphic + */ + public LayoutGraphic addText(String text, int x, int y) { + return addText(text, x, y, _defLabelBreak.getFont().getFontName(), _defLabelBreak.getFont().getSize()); + } + + /** + * Add a text label element + * + * @param text The text + * @param x Center x + * @param y Center y + * @param fontSize Font size + * @return Text layout graphic + */ + public LayoutGraphic addText(String text, int x, int y, float fontSize) { + return addText(text, x, y, _defLabelBreak.getFont().getName(), fontSize); + } + + /** + * Add a text label element + * + * @param text The text + * @param x Center x + * @param y Center y + * @param fontName Font name + * @param fontSize Font size + * @return Text layout graphic + */ + public LayoutGraphic addText(String text, int x, int y, String fontName, float fontSize) { + PointShape aPS = new PointShape(); + aPS.setPoint(new PointD(x, y)); + LabelBreak aLB = (LabelBreak) _defLabelBreak.clone(); + aLB.setText(text); + aLB.setFont(new Font(fontName, Font.PLAIN, (int) fontSize)); + Graphic aGraphic = new Graphic(aPS, aLB); + LayoutGraphic aLayoutGraphic = new LayoutGraphic(aGraphic, this); + addElement(aLayoutGraphic); + + return aLayoutGraphic; + } + + public LayoutGraphic addWindArrow(int left, int top) { + WindArrow aWindArraw = new WindArrow(); + //aWindArraw.setPoint(new PointD(left, top)); + aWindArraw.angle = 270; + aWindArraw.length = 20; + VectorBreak aVB = new VectorBreak(); + aVB.setColor(Color.black); + LayoutGraphic wag = new LayoutGraphic(new Graphic(aWindArraw, aVB), this, + this.getActiveLayoutMap()); + wag.setLeft(left); + wag.setTop(top); + addElement(wag); + + return wag; + } + + /** + * Add a layout legend + * + * @param left Left + * @param top Top + * @return Layout legend + */ + public LayoutLegend addLegend(int left, int top) { + LayoutMap aLM = getActiveLayoutMap(); + LayoutLegend aLL = new LayoutLegend(this, aLM); + aLL.setLeft(left); + aLL.setTop(top); + if (aLM.getMapFrame().getMapView().getLayerNum() > 0) { + for (MapLayer aLayer : aLM.getMapFrame().getMapView().getLayers()) { + if (aLayer.getLayerType() != LayerTypes.ImageLayer) { + aLL.setLegendLayer(aLayer); + } + } + } + + addElement(aLL); + + return aLL; + } + + /** + * Add a layout scale bar + * + * @param left Left + * @param top Top + * @return Layout scale bar + */ + public LayoutScaleBar addScaleBar(int left, int top) { + LayoutMap aLM = getActiveLayoutMap(); + LayoutScaleBar aLSB = new LayoutScaleBar(aLM); + aLSB.setLeft(left); + aLSB.setTop(top); + addElement(aLSB); + + return aLSB; + } + + /** + * Add a layout north arrow + * + * @param left Left + * @param top Top + * @return Layout north arrow + */ + public LayoutNorthArrow addNorthArrow(int left, int top) { + LayoutMap aLM = getActiveLayoutMap(); + LayoutNorthArrow aLNA = new LayoutNorthArrow(aLM); + aLNA.setLeft(left); + aLNA.setTop(top); + addElement(aLNA); + + return aLNA; + } + +// /** +// * Add a layout chart +// * +// * @param left Left +// * @param top Top +// * @return Layout chart +// */ +// public LayoutChart addChart(int left, int top) { +// LayoutChart chart = new LayoutChart(); +// chart.setLeft(left); +// chart.setTop(top); +// addElement(chart); +// +// return chart; +// } + + /** + * Get layout graphic list + * + * @return Layout graphic list + */ + public List getLayoutGraphics() { + List graphics = new ArrayList<>(); + for (LayoutElement aLE : _layoutElements) { + if (aLE.getElementType() == ElementType.LayoutGraphic) { + graphics.add((LayoutGraphic) aLE); + } + } + + return graphics; + } + + /** + * Get text graphic list + * + * @return Text graphic list + */ + public List getTexts() { + List texts = new ArrayList<>(); + List graphics = getLayoutGraphics(); + for (LayoutGraphic aLG : graphics) { + if (aLG.getGraphic().getLegend().getBreakType() == BreakTypes.LabelBreak) { + texts.add(aLG); + } + } + + return texts; + } + + /** + * Get a text graphic by text string + * + * @param text Text string + * @return Text graphic + */ + public LayoutGraphic getText(String text) { + List texts = getTexts(); + for (LayoutGraphic aLG : texts) { + if (((LabelBreak) aLG.getGraphic().getLegend()).getText().equals(text)) { + return aLG; + } + } + + return null; + } + + /** + * Get layout legend list + * + * @return Layout legend list + */ + public List getLegends() { + List legends = new ArrayList<>(); + for (LayoutElement aLE : _layoutElements) { + if (aLE.getElementType() == ElementType.LayoutLegend) { + legends.add((LayoutLegend) aLE); + } + } + + return legends; + } + + /** + * Set a map frame as active + * + * @param mapFrame The map frame + */ + public void setActiveMapFrame(MapFrame mapFrame) { + for (MapFrame mf : _mapFrames) { + mf.setActive(false); + } + + mapFrame.setActive(true); + this.fireActiveMapFrameChangedEvent(); + } + + private LayoutMap getLayoutMap(MapFrame mapFrame) { + LayoutMap aLM = null; + for (LayoutMap lm : this.getLayoutMaps()) { + if (lm.getMapFrame() == mapFrame) { + aLM = lm; + break; + } + } + + return aLM; + } + + private LayoutMap getLayoutMap(Point aPoint) { + for (int i = getLayoutMaps().size() - 1; i >= 0; i--) { + LayoutMap aLM = getLayoutMaps().get(i); + if (MIMath.pointInRectangle(aPoint, aLM.getBounds())) { + return aLM; + } + } + + return null; + } + + private int getLayoutMapIndex(LayoutMap aLM) { + return getLayoutMaps().indexOf(aLM); + } + + /** + * If has legend element + * + * @return Boolean + */ + public boolean hasLegendElement() { + for (LayoutElement aLE : _layoutElements) { + if (aLE.getElementType() == ElementType.LayoutLegend) { + return true; + } + } + return false; + } + + private List selectElements(Point aPoint, List baseElements, int limit) { + List selectedElements = new ArrayList<>(); + for (int i = baseElements.size() - 1; i >= 0; i--) { + LayoutElement element = baseElements.get(i); + if (element.isVisible()) { + Rectangle rect = (Rectangle) element.getBounds().clone(); + if (rect.width < 5) { + rect.width = 5; + rect.x -= 2.5; + } + if (rect.height < 5) { + rect.height = 5; + rect.y -= 2.5; + } + rect.width += limit; + rect.height += limit; + if (MIMath.pointInRectangle(aPoint, rect)) { + selectedElements.add(element); + } + } + } + + return selectedElements; + } + + private Rectangle getElementViewExtent(LayoutElement aLE) { + PointF aP = aLE.pageToScreen(aLE.getLeft(), aLE.getTop(), _pageLocation, _zoom); + Rectangle rect = new Rectangle((int) aP.X, (int) aP.Y, (int) (aLE.getWidth() * _zoom), (int) (aLE.getHeight() * _zoom)); + + return rect; + } + + private int selectEditVertices(Point aPoint, Shape aShape, List vertices) { + List points = (List) aShape.getPoints(); + int buffer = 4; + Rectangle rect = new Rectangle(aPoint.x - buffer / 2, aPoint.y - buffer / 2, buffer, buffer); + vertices.clear(); + PointD aPD; + int vIdx = -1; + for (int i = 0; i < points.size(); i++) { + if (MIMath.pointInRectangle(points.get(i), rect)) { + vIdx = i; + vertices.add(points.get(i)); + switch (aShape.getShapeType()) { + case Polyline: + case CurveLine: + if (i == 0) { + vertices.add(points.get(i + 1)); + } else if (i == points.size() - 1) { + vertices.add(points.get(i - 1)); + } else { + vertices.add(points.get(i - 1)); + vertices.add(points.get(i + 1)); + } + break; + default: + if (i == 0) { + vertices.add(points.get(i + 1)); + aPD = points.get(points.size() - 1); + if (aPD.X == points.get(i).X && aPD.Y == points.get(i).Y) { + vertices.add(points.get(points.size() - 2)); + } else { + vertices.add(aPD); + } + } else if (i == points.size() - 1) { + vertices.add(points.get(i - 1)); + aPD = points.get(0); + if (aPD.X == points.get(i).X && aPD.Y == points.get(i).Y) { + vertices.add(points.get(1)); + } else { + vertices.add(points.get(0)); + } + } else { + vertices.add(points.get(i - 1)); + vertices.add(points.get(i + 1)); + } + break; + } + break; + // if (aShape.getShapeType() == ShapeTypes.Polyline) { + // if (i == 0) { + // vertices.add(points.get(i + 1)); + // } else if (i == points.size() - 1) { + // vertices.add(points.get(i - 1)); + // } else { + // vertices.add(points.get(i - 1)); + // vertices.add(points.get(i + 1)); + // } + // } else { + // if (i == 0) { + // vertices.add(points.get(i + 1)); + // aPD = points.get(points.size() - 1); + // if (aPD.X == points.get(i).X && aPD.Y == points.get(i).Y) { + // vertices.add(points.get(points.size() - 2)); + // } else { + // vertices.add(aPD); + // } + // } else if (i == points.size() - 1) { + // vertices.add(points.get(i - 1)); + // aPD = points.get(0); + // if (aPD.X == points.get(i).X && aPD.Y == points.get(i).Y) { + // vertices.add(points.get(1)); + // } else { + // vertices.add(points.get(0)); + // } + // } else { + // vertices.add(points.get(i - 1)); + // vertices.add(points.get(i + 1)); + // } + // } + } + } + + return vIdx; + } + + private boolean isInLayoutMaps(Point aPoint) { + for (LayoutMap aLM : getLayoutMaps()) { + if (MIMath.pointInRectangle(aPoint, aLM.getBounds())) { + return true; + } + } + + return false; + } + + private static Edge intersectElementEdge(Rectangle screen, PointF pt, float limit) { + Rectangle.Float ptRect = new Rectangle.Float(pt.X - limit, pt.Y - limit, 2F * limit, 2F * limit); + if ((pt.X >= screen.x - limit && pt.X <= screen.x + limit) && (pt.Y >= screen.y - limit && pt.Y <= screen.y + limit)) { + return Edge.TopLeft; + } + if ((pt.X >= screen.x + screen.width - limit && pt.X <= screen.x + screen.width + limit) && (pt.Y >= screen.y - limit && pt.Y <= screen.y + limit)) { + return Edge.TopRight; + } + if ((pt.X >= screen.x + screen.width - limit && pt.X <= screen.x + screen.width + limit) && (pt.Y >= screen.y + screen.height - limit && pt.Y <= screen.y + screen.height + limit)) { + return Edge.BottomRight; + } + if ((pt.X >= screen.x - limit && pt.X <= screen.x + limit) && (pt.Y >= screen.y + screen.height - limit && pt.Y <= screen.y + screen.height + limit)) { + return Edge.BottomLeft; + } + if (ptRect.intersects(new Rectangle.Float(screen.x, screen.y, screen.width, 1F))) { + return Edge.Top; + } + if (ptRect.intersects(new Rectangle.Float(screen.x, screen.y, 1F, screen.height))) { + return Edge.Left; + } + if (ptRect.intersects(new Rectangle.Float(screen.x, screen.y + screen.height, screen.width, 1F))) { + return Edge.Bottom; + } + if (ptRect.intersects(new Rectangle.Float(screen.x + screen.width, screen.y, 1F, screen.height))) { + return Edge.Right; + } + return Edge.None; + } + // + + // + private void updatePageSet() { + Rectangle.Float aRect = paperToScreen(new Rectangle.Float(0, 0, this.getPaperWidth(), this.getPaperHeight())); + _pageBounds.width = (int) aRect.width; + _pageBounds.height = (int) aRect.height; + } + + /** + * Show measurment form + */ + public void showMeasurementForm() { + if (_frmMeasure == null) { + _frmMeasure = new FrmMeasurement((JFrame) SwingUtilities.getWindowAncestor(this), false); + _frmMeasure.addWindowListener(new WindowAdapter() { + @Override + public void windowClosed(WindowEvent e) { + _currentLayoutMap.getMapFrame().getMapView().setDrawIdentiferShape(false); + //repaint(); + repaintOld(); + } + }); + _frmMeasure.setLocationRelativeTo(this); + _frmMeasure.setVisible(true); + } else if (!_frmMeasure.isVisible()) { + _frmMeasure.setVisible(true); + } + } + + // + // + /** + * Export project XML content + * + * @param m_Doc XML document + * @param parent Parent XML element + */ + public void exportProjectXML(Document m_Doc, Element parent) { + exportLayout(m_Doc, parent); + } + + private void exportLayout(Document m_Doc, Element parent) { + Element layout = m_Doc.createElement("Layout"); + + //Add attribute + Attr BackColor = m_Doc.createAttribute("BackColor"); + Attr ForeColor = m_Doc.createAttribute("ForeColor"); + Attr SmoothingMode = m_Doc.createAttribute("SmoothingMode"); + Attr PaperSizeName = m_Doc.createAttribute("PaperSizeName"); + Attr PaperSizeWidth = m_Doc.createAttribute("PaperSizeWidth"); + Attr PaperSizeHeight = m_Doc.createAttribute("PaperSizeHeight"); + Attr Landscape = m_Doc.createAttribute("Landscape"); + + BackColor.setValue(ColorUtil.toHexEncoding(_pageBackColor)); + ForeColor.setValue(ColorUtil.toHexEncoding(_pageForeColor)); + SmoothingMode.setValue(String.valueOf(_antiAlias)); + PaperSizeName.setValue(_paperSize.getName()); + PaperSizeWidth.setValue(String.valueOf(_paperSize.getWidth())); + PaperSizeHeight.setValue(String.valueOf(_paperSize.getHeight())); + Landscape.setValue(String.valueOf(_isLandscape)); + + layout.setAttributeNode(BackColor); + layout.setAttributeNode(ForeColor); + layout.setAttributeNode(SmoothingMode); + layout.setAttributeNode(PaperSizeName); + layout.setAttributeNode(PaperSizeWidth); + layout.setAttributeNode(PaperSizeHeight); + layout.setAttributeNode(Landscape); + + parent.appendChild(layout); + + //Add layout elements + addLayoutElements(m_Doc, layout); + } + + private void addLayoutElements(Document doc, Element parent) { + Element layoutElements = doc.createElement("LayoutElements"); + for (LayoutElement aElement : _layoutElements) { + switch (aElement.getElementType()) { + case LayoutMap: + addLayoutMapElement(doc, layoutElements, (LayoutMap) aElement); + break; + case LayoutIllustration: + //AddIllustrationElement(ref doc, layoutElements, (LayoutIllustrationMap)aElement); + break; + case LayoutLegend: + addLayoutLegendElement(doc, layoutElements, (LayoutLegend) aElement); + break; + case LayoutGraphic: + addLayoutGraphicElement(doc, layoutElements, (LayoutGraphic) aElement); + break; + case LayoutScaleBar: + addLayoutScaleBarElement(doc, layoutElements, (LayoutScaleBar) aElement); + break; + case LayoutNorthArraw: + addLayoutNorthArrowElement(doc, layoutElements, (LayoutNorthArrow) aElement); + break; + } + } + parent.appendChild(layoutElements); + } + + private void addLayoutMapElement(Document m_Doc, Element parent, LayoutMap aMap) { + Element layoutMap = m_Doc.createElement("LayoutMap"); + Attr elementType = m_Doc.createAttribute("ElementType"); + Attr left = m_Doc.createAttribute("Left"); + Attr top = m_Doc.createAttribute("Top"); + Attr width = m_Doc.createAttribute("Width"); + Attr height = m_Doc.createAttribute("Height"); + Attr DrawMapNeatLine = m_Doc.createAttribute("DrawNeatLine"); + Attr MapNeatLineColor = m_Doc.createAttribute("NeatLineColor"); + Attr MapNeatLineSize = m_Doc.createAttribute("NeatLineSize"); + Attr GridLineColor = m_Doc.createAttribute("GridLineColor"); + Attr GridLineSize = m_Doc.createAttribute("GridLineSize"); + Attr GridLineStyle = m_Doc.createAttribute("GridLineStyle"); + Attr DrawGridLine = m_Doc.createAttribute("DrawGridLine"); + Attr DrawGridLabel = m_Doc.createAttribute("DrawGridLabel"); + Attr GridFontName = m_Doc.createAttribute("GridFontName"); + Attr GridFontSize = m_Doc.createAttribute("GridFontSize"); + Attr GridXDelt = m_Doc.createAttribute("GridXDelt"); + Attr GridYDelt = m_Doc.createAttribute("GridYDelt"); + Attr GridXOrigin = m_Doc.createAttribute("GridXOrigin"); + Attr GridYOrigin = m_Doc.createAttribute("GridYOrigin"); + Attr gridLabelPosition = m_Doc.createAttribute("GridLabelPosition"); + Attr drawDegreeSymbol = m_Doc.createAttribute("DrawDegreeSymbol"); + Attr drawBackColor = m_Doc.createAttribute("DrawBackColor"); + + elementType.setValue(aMap.getElementType().toString()); + left.setValue(String.valueOf(aMap.getLeft())); + top.setValue(String.valueOf(aMap.getTop())); + width.setValue(String.valueOf(aMap.getWidth())); + height.setValue(String.valueOf(aMap.getHeight())); + DrawMapNeatLine.setValue(String.valueOf(aMap.isDrawNeatLine())); + MapNeatLineColor.setValue(ColorUtil.toHexEncoding(aMap.getNeatLineColor())); + MapNeatLineSize.setValue(String.valueOf(aMap.getNeatLineSize())); + GridLineColor.setValue(ColorUtil.toHexEncoding(aMap.getGridLineColor())); + GridLineSize.setValue(String.valueOf(aMap.getGridLineSize())); + GridLineStyle.setValue(aMap.getGridLineStyle().toString()); + DrawGridLine.setValue(String.valueOf(aMap.isDrawGridLine())); + DrawGridLabel.setValue(String.valueOf(aMap.isDrawGridLabel())); + GridFontName.setValue(aMap.getGridFont().getFontName()); + GridFontSize.setValue(String.valueOf(aMap.getGridFont().getSize())); + GridXDelt.setValue(String.valueOf(aMap.getGridXDelt())); + GridYDelt.setValue(String.valueOf(aMap.getGridYDelt())); + GridXOrigin.setValue(String.valueOf(aMap.getGridXOrigin())); + GridYOrigin.setValue(String.valueOf(aMap.getGridYOrigin())); + gridLabelPosition.setValue(aMap.getGridLabelPosition().toString()); + drawDegreeSymbol.setValue(String.valueOf(aMap.isDrawDegreeSymbol())); + drawBackColor.setValue(String.valueOf(aMap.isDrawBackColor())); + + layoutMap.setAttributeNode(elementType); + layoutMap.setAttributeNode(left); + layoutMap.setAttributeNode(top); + layoutMap.setAttributeNode(width); + layoutMap.setAttributeNode(height); + layoutMap.setAttributeNode(DrawMapNeatLine); + layoutMap.setAttributeNode(MapNeatLineColor); + layoutMap.setAttributeNode(MapNeatLineSize); + layoutMap.setAttributeNode(GridLineColor); + layoutMap.setAttributeNode(GridLineSize); + layoutMap.setAttributeNode(GridLineStyle); + layoutMap.setAttributeNode(DrawGridLine); + layoutMap.setAttributeNode(DrawGridLabel); + layoutMap.setAttributeNode(GridFontName); + layoutMap.setAttributeNode(GridFontSize); + layoutMap.setAttributeNode(GridXDelt); + layoutMap.setAttributeNode(GridYDelt); + layoutMap.setAttributeNode(GridXOrigin); + layoutMap.setAttributeNode(GridYOrigin); + layoutMap.setAttributeNode(gridLabelPosition); + layoutMap.setAttributeNode(drawDegreeSymbol); + layoutMap.setAttributeNode(drawBackColor); + + parent.appendChild(layoutMap); + } + + private void addLayoutLegendElement(Document doc, Element parent, LayoutLegend aLegend) { + Element Legend = doc.createElement("LayoutLegend"); + Attr elementType = doc.createAttribute("ElementType"); + Attr layoutMapIndex = doc.createAttribute("LayoutMapIndex"); + Attr legendLayer = doc.createAttribute("LegendLayer"); + Attr LegendStyle = doc.createAttribute("LegendStyle"); + Attr layerUpdateType = doc.createAttribute("LayerUpdateType"); + Attr BackColor = doc.createAttribute("BackColor"); + Attr DrawNeatLine = doc.createAttribute("DrawNeatLine"); + Attr NeatLineColor = doc.createAttribute("NeatLineColor"); + Attr NeatLineSize = doc.createAttribute("NeatLineSize"); + Attr drawChartBreaks = doc.createAttribute("DrawChartBreaks"); + Attr Left = doc.createAttribute("Left"); + Attr Top = doc.createAttribute("Top"); + Attr Width = doc.createAttribute("Width"); + Attr Height = doc.createAttribute("Height"); + Attr FontName = doc.createAttribute("FontName"); + Attr FontSize = doc.createAttribute("FontSize"); + Attr colNum = doc.createAttribute("ColumnNumber"); + Attr drawBackColor = doc.createAttribute("DrawBackColor"); + Attr forceDrawOutline = doc.createAttribute("ForceDrawOutline"); + + elementType.setValue(aLegend.getElementType().toString()); + layoutMapIndex.setValue(String.valueOf(getLayoutMapIndex(aLegend.getLayoutMap()))); + legendLayer.setValue(aLegend.getLayerName()); + LegendStyle.setValue(aLegend.getLegendStyle().toString()); + layerUpdateType.setValue(aLegend.getLayerUpdateType().toString()); + BackColor.setValue(ColorUtil.toHexEncoding(aLegend.getBackColor())); + DrawNeatLine.setValue(String.valueOf(aLegend.isDrawNeatLine())); + NeatLineColor.setValue(ColorUtil.toHexEncoding(aLegend.getNeatLineColor())); + NeatLineSize.setValue(String.valueOf(aLegend.getNeatLineSize())); + drawChartBreaks.setValue(String.valueOf(aLegend.isDrawChartBreaks())); + Left.setValue(String.valueOf(aLegend.getLeft())); + Top.setValue(String.valueOf(aLegend.getTop())); + Width.setValue(String.valueOf(aLegend.getWidth())); + Height.setValue(String.valueOf(aLegend.getHeight())); + FontName.setValue(aLegend.getFont().getFontName()); + FontSize.setValue(String.valueOf(aLegend.getFont().getSize())); + colNum.setValue(String.valueOf(aLegend.getColumnNumber())); + drawBackColor.setValue(String.valueOf(aLegend.isDrawBackColor())); + forceDrawOutline.setValue(String.valueOf(aLegend.isForceDrawOutline())); + + Legend.setAttributeNode(elementType); + Legend.setAttributeNode(layoutMapIndex); + Legend.setAttributeNode(legendLayer); + Legend.setAttributeNode(LegendStyle); + Legend.setAttributeNode(layerUpdateType); + Legend.setAttributeNode(BackColor); + Legend.setAttributeNode(DrawNeatLine); + Legend.setAttributeNode(NeatLineColor); + Legend.setAttributeNode(NeatLineSize); + Legend.setAttributeNode(drawChartBreaks); + Legend.setAttributeNode(Left); + Legend.setAttributeNode(Top); + Legend.setAttributeNode(Width); + Legend.setAttributeNode(Height); + Legend.setAttributeNode(FontName); + Legend.setAttributeNode(FontSize); + Legend.setAttributeNode(colNum); + Legend.setAttributeNode(drawBackColor); + Legend.setAttributeNode(forceDrawOutline); + + parent.appendChild(Legend); + } + + private void addLayoutScaleBarElement(Document doc, Element parent, LayoutScaleBar aScaleBar) { + Element scaleBar = doc.createElement("LayoutScaleBar"); + Attr elementType = doc.createAttribute("ElementType"); + Attr layoutMapIndex = doc.createAttribute("LayoutMapIndex"); + Attr scaleBarType = doc.createAttribute("ScaleBarType"); + Attr BackColor = doc.createAttribute("BackColor"); + Attr foreColor = doc.createAttribute("ForeColor"); + Attr DrawNeatLine = doc.createAttribute("DrawNeatLine"); + Attr NeatLineColor = doc.createAttribute("NeatLineColor"); + Attr NeatLineSize = doc.createAttribute("NeatLineSize"); + Attr Left = doc.createAttribute("Left"); + Attr Top = doc.createAttribute("Top"); + Attr Width = doc.createAttribute("Width"); + Attr Height = doc.createAttribute("Height"); + Attr FontName = doc.createAttribute("FontName"); + Attr FontSize = doc.createAttribute("FontSize"); + Attr drawScaleText = doc.createAttribute("DrawScaleText"); + Attr drawBackColor = doc.createAttribute("DrawBackColor"); + + elementType.setValue(aScaleBar.getElementType().toString()); + layoutMapIndex.setValue(String.valueOf(getLayoutMapIndex(aScaleBar.getLayoutMap()))); + scaleBarType.setValue(aScaleBar.getScaleBarType().toString()); + BackColor.setValue(ColorUtil.toHexEncoding(aScaleBar.getBackColor())); + foreColor.setValue(ColorUtil.toHexEncoding(aScaleBar.getForeColor())); + DrawNeatLine.setValue(String.valueOf(aScaleBar.isDrawNeatLine())); + NeatLineColor.setValue(ColorUtil.toHexEncoding(aScaleBar.getNeatLineColor())); + NeatLineSize.setValue(String.valueOf(aScaleBar.getNeatLineSize())); + Left.setValue(String.valueOf(aScaleBar.getLeft())); + Top.setValue(String.valueOf(aScaleBar.getTop())); + Width.setValue(String.valueOf(aScaleBar.getWidth())); + Height.setValue(String.valueOf(aScaleBar.getHeight())); + FontName.setValue(aScaleBar.getFont().getFontName()); + FontSize.setValue(String.valueOf(aScaleBar.getFont().getSize())); + drawScaleText.setValue(String.valueOf(aScaleBar.isDrawScaleText())); + drawBackColor.setValue(String.valueOf(aScaleBar.isDrawBackColor())); + + scaleBar.setAttributeNode(elementType); + scaleBar.setAttributeNode(layoutMapIndex); + scaleBar.setAttributeNode(scaleBarType); + scaleBar.setAttributeNode(BackColor); + scaleBar.setAttributeNode(foreColor); + scaleBar.setAttributeNode(DrawNeatLine); + scaleBar.setAttributeNode(NeatLineColor); + scaleBar.setAttributeNode(NeatLineSize); + scaleBar.setAttributeNode(Left); + scaleBar.setAttributeNode(Top); + scaleBar.setAttributeNode(Width); + scaleBar.setAttributeNode(Height); + scaleBar.setAttributeNode(FontName); + scaleBar.setAttributeNode(FontSize); + scaleBar.setAttributeNode(drawScaleText); + scaleBar.setAttributeNode(drawBackColor); + + parent.appendChild(scaleBar); + } + + private void addLayoutNorthArrowElement(Document doc, Element parent, LayoutNorthArrow aNorthArrow) { + Element northArrow = doc.createElement("LayoutNorthArrow"); + Attr elementType = doc.createAttribute("ElementType"); + Attr layoutMapIndex = doc.createAttribute("LayoutMapIndex"); + Attr BackColor = doc.createAttribute("BackColor"); + Attr foreColor = doc.createAttribute("ForeColor"); + Attr DrawNeatLine = doc.createAttribute("DrawNeatLine"); + Attr NeatLineColor = doc.createAttribute("NeatLineColor"); + Attr NeatLineSize = doc.createAttribute("NeatLineSize"); + Attr Left = doc.createAttribute("Left"); + Attr Top = doc.createAttribute("Top"); + Attr Width = doc.createAttribute("Width"); + Attr Height = doc.createAttribute("Height"); + Attr angle = doc.createAttribute("Angle"); + Attr drawBackColor = doc.createAttribute("DrawBackColor"); + + elementType.setValue(aNorthArrow.getElementType().toString()); + layoutMapIndex.setValue(String.valueOf(getLayoutMapIndex(aNorthArrow.getLayoutMap()))); + BackColor.setValue(ColorUtil.toHexEncoding(aNorthArrow.getBackColor())); + foreColor.setValue(ColorUtil.toHexEncoding(aNorthArrow.getForeColor())); + DrawNeatLine.setValue(String.valueOf(aNorthArrow.isDrawNeatLine())); + NeatLineColor.setValue(ColorUtil.toHexEncoding(aNorthArrow.getNeatLineColor())); + NeatLineSize.setValue(String.valueOf(aNorthArrow.getNeatLineSize())); + Left.setValue(String.valueOf(aNorthArrow.getLeft())); + Top.setValue(String.valueOf(aNorthArrow.getTop())); + Width.setValue(String.valueOf(aNorthArrow.getWidth())); + Height.setValue(String.valueOf(aNorthArrow.getHeight())); + angle.setValue(String.valueOf(aNorthArrow.getAngle())); + drawBackColor.setValue(String.valueOf(aNorthArrow.isDrawBackColor())); + + northArrow.setAttributeNode(elementType); + northArrow.setAttributeNode(layoutMapIndex); + northArrow.setAttributeNode(BackColor); + northArrow.setAttributeNode(foreColor); + northArrow.setAttributeNode(DrawNeatLine); + northArrow.setAttributeNode(NeatLineColor); + northArrow.setAttributeNode(NeatLineSize); + northArrow.setAttributeNode(Left); + northArrow.setAttributeNode(Top); + northArrow.setAttributeNode(Width); + northArrow.setAttributeNode(Height); + northArrow.setAttributeNode(angle); + northArrow.setAttributeNode(drawBackColor); + + parent.appendChild(northArrow); + } + + private void addLayoutGraphicElement(Document doc, Element parent, LayoutGraphic aLayoutGraphic) { + Element layoutGraphic = doc.createElement("LayoutGraphic"); + Attr elementType = doc.createAttribute("ElementType"); + Attr isTitle = doc.createAttribute("IsTitle"); + Attr left = doc.createAttribute("Left"); + Attr top = doc.createAttribute("Top"); + Attr width = doc.createAttribute("Width"); + Attr height = doc.createAttribute("Height"); + + elementType.setValue(aLayoutGraphic.getElementType().toString()); + isTitle.setValue(String.valueOf(aLayoutGraphic.isTitle())); + left.setValue(String.valueOf(aLayoutGraphic.getLeft())); + top.setValue(String.valueOf(aLayoutGraphic.getTop())); + width.setValue(String.valueOf(aLayoutGraphic.getWidth())); + height.setValue(String.valueOf(aLayoutGraphic.getHeight())); + + layoutGraphic.setAttributeNode(elementType); + layoutGraphic.setAttributeNode(isTitle); + layoutGraphic.setAttributeNode(left); + layoutGraphic.setAttributeNode(top); + layoutGraphic.setAttributeNode(width); + layoutGraphic.setAttributeNode(height); + + //Add graphic + Graphic aGraphic = aLayoutGraphic.getGraphic(); + aGraphic.exportToXML(doc, layoutGraphic); + + //Append in parent + parent.appendChild(layoutGraphic); + } + + /** + * Load project file + * + * @param aFile The project file + * @throws ParserConfigurationException + * @throws SAXException + * @throws IOException + */ + public void loadProjectFile(String aFile) throws ParserConfigurationException, SAXException, IOException { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + Document doc = db.parse(aFile); + + Element root = doc.getDocumentElement(); + + Properties property = System.getProperties(); + String path = System.getProperty("user.dir"); + property.setProperty("user.dir", new File(aFile).getAbsolutePath()); + String pPath = new File(aFile).getParent(); + + //Load map frames content + List mfs = new ArrayList<>(); + Element mapFrames = (Element) root.getElementsByTagName("MapFrames").item(0); + if (mapFrames == null) { + MapFrame mf = new MapFrame(); + mf.importProjectXML(pPath, root); + mf.setActive(true); + mfs.add(mf); + } else { + NodeList mfNodes = mapFrames.getElementsByTagName("MapFrame"); + for (int i = 0; i < mfNodes.getLength(); i++) { + Node mapFrame = mfNodes.item(i); + MapFrame mf = new MapFrame(); + mf.importProjectXML(pPath, (Element) mapFrame); + mfs.add(mf); + } + } + + this.setMapFrames(mfs); + //Load MapLayout content + this.importProjectXML(root); + + property.setProperty("user.dir", path); + } + + /** + * Import project XML element + * + * @param parent Parent element + */ + public void importProjectXML(Element parent) { + loadLayout(parent); + } + + private void loadLayout(Element parent) { + Node layout = parent.getElementsByTagName("Layout").item(0); + try { + _pageBackColor = ColorUtil.parseToColor(layout.getAttributes().getNamedItem("BackColor").getNodeValue()); + _pageForeColor = ColorUtil.parseToColor(layout.getAttributes().getNamedItem("ForeColor").getNodeValue()); + this.setAntiAlias(Boolean.parseBoolean(layout.getAttributes().getNamedItem("SmoothingMode").getNodeValue())); + _paperSize.setName(layout.getAttributes().getNamedItem("PaperSizeName").getNodeValue()); + _paperSize.setWidth(Integer.parseInt(layout.getAttributes().getNamedItem("PaperSizeWidth").getNodeValue())); + _paperSize.setHeight(Integer.parseInt(layout.getAttributes().getNamedItem("PaperSizeHeight").getNodeValue())); + _isLandscape = Boolean.parseBoolean(layout.getAttributes().getNamedItem("Landscape").getNodeValue()); + + updatePageSet(); + + loadLayoutElements((Element) layout); + } catch (Exception e) { + } + } + + private void loadLayoutElements(Element parent) { + _layoutElements.clear(); + _selectedElements.clear(); + + Node layoutElements = parent.getElementsByTagName("LayoutElements").item(0); + //Load layout maps + NodeList layoutNodes = ((Element) layoutElements).getElementsByTagName("LayoutMap"); + for (int i = 0; i < layoutNodes.getLength(); i++) { + Node elementNode = layoutNodes.item(i); + MapFrame aMF; + if (_mapFrames.size() > i) { + aMF = _mapFrames.get(i); + } else { + aMF = new MapFrame(); + } + + LayoutMap aLM = new LayoutMap(aMF, this.tileLoadListener); + loadLayoutMapElement(elementNode, aLM); + addElement(aLM); + } + + //Load other elements + for (int i = 0; i < layoutElements.getChildNodes().getLength(); i++) { + Node elementNode = layoutElements.getChildNodes().item(i); + if (elementNode.getNodeType() != Node.ELEMENT_NODE) { + continue; + } + ElementType aType = ElementType.valueOf(elementNode.getAttributes().getNamedItem("ElementType").getNodeValue()); + switch (aType) { + case LayoutIllustration: + break; + case LayoutLegend: + LayoutLegend aLL = loadLayoutLegendElement(elementNode); + addElement(aLL); + break; + case LayoutGraphic: + LayoutGraphic aLG = loadLayoutGraphicElement(elementNode); + if (aLG.getGraphic().getShape().getShapeType() == ShapeTypes.WindArraw) { + ((WindArrow) aLG.getGraphic().getShape()).angle = 270; + } + addElement(aLG); + break; + case LayoutScaleBar: + LayoutScaleBar aLSB = loadLayoutScaleBarElement(elementNode); + if (aLSB != null) { + addElement(aLSB); + } + break; + case LayoutNorthArraw: + LayoutNorthArrow aLNA = loadLayoutNorthArrowElement(elementNode); + if (aLNA != null) { + addElement(aLNA); + } + break; + } + } + } + + private void loadLayoutMapElement(Node layoutMap, LayoutMap aLM) { + try { + aLM.setLeft(Integer.parseInt(layoutMap.getAttributes().getNamedItem("Left").getNodeValue())); + aLM.setTop(Integer.parseInt(layoutMap.getAttributes().getNamedItem("Top").getNodeValue())); + aLM.setWidth(Integer.parseInt(layoutMap.getAttributes().getNamedItem("Width").getNodeValue())); + aLM.setHeight(Integer.parseInt(layoutMap.getAttributes().getNamedItem("Height").getNodeValue())); + aLM.setDrawNeatLine(Boolean.parseBoolean(layoutMap.getAttributes().getNamedItem("DrawNeatLine").getNodeValue())); + aLM.setNeatLineColor(ColorUtil.parseToColor(layoutMap.getAttributes().getNamedItem("NeatLineColor").getNodeValue())); + aLM.setNeatLineSize(Float.parseFloat(layoutMap.getAttributes().getNamedItem("NeatLineSize").getNodeValue())); + aLM.setGridLineColor(ColorUtil.parseToColor(layoutMap.getAttributes().getNamedItem("GridLineColor").getNodeValue())); + aLM.setGridLineSize(Float.parseFloat(layoutMap.getAttributes().getNamedItem("GridLineSize").getNodeValue())); + aLM.setGridLineStyle(LineStyles.valueOf(layoutMap.getAttributes().getNamedItem("GridLineStyle").getNodeValue())); + aLM.setDrawGridLine(Boolean.parseBoolean(layoutMap.getAttributes().getNamedItem("DrawGridLine").getNodeValue())); + aLM.setDrawGridLabel(Boolean.parseBoolean(layoutMap.getAttributes().getNamedItem("DrawGridLabel").getNodeValue())); + String fontName = layoutMap.getAttributes().getNamedItem("GridFontName").getNodeValue(); + float fontSize = Float.parseFloat(layoutMap.getAttributes().getNamedItem("GridFontSize").getNodeValue()); + aLM.setGridFont(new Font(fontName, Font.PLAIN, (int) fontSize)); + aLM.setGridXDelt(Double.parseDouble(layoutMap.getAttributes().getNamedItem("GridXDelt").getNodeValue())); + aLM.setGridYDelt(Double.parseDouble(layoutMap.getAttributes().getNamedItem("GridYDelt").getNodeValue())); + aLM.setGridXOrigin(Float.parseFloat(layoutMap.getAttributes().getNamedItem("GridXOrigin").getNodeValue())); + aLM.setGridYOrigin(Float.parseFloat(layoutMap.getAttributes().getNamedItem("GridYOrigin").getNodeValue())); + aLM.setGridLabelPosition(GridLabelPosition.valueOf(layoutMap.getAttributes().getNamedItem("GridLabelPosition").getNodeValue())); + aLM.setDrawDegreeSymbol(Boolean.parseBoolean(layoutMap.getAttributes().getNamedItem("DrawDegreeSymbol").getNodeValue())); + aLM.setDrawBackColor(Boolean.parseBoolean(layoutMap.getAttributes().getNamedItem("DrawBackColor").getNodeValue())); + } catch (Exception e) { + } + } + + private LayoutLegend loadLayoutLegendElement(Node layoutLegend) { + LayoutLegend aLL = null; + try { + int layoutMapIdx = Integer.parseInt(layoutLegend.getAttributes().getNamedItem("LayoutMapIndex").getNodeValue()); + String legendLayerName = layoutLegend.getAttributes().getNamedItem("LegendLayer").getNodeValue(); + LayoutMap aLM = this.getLayoutMaps().get(layoutMapIdx); + MapLayer legendLayer = aLM.getMapFrame().getMapView().getLayer(legendLayerName); + aLL = new LayoutLegend(this, aLM); + aLL.setLegendLayer(legendLayer); + } catch (Exception e) { + aLL = new LayoutLegend(this, this.getLayoutMaps().get(0)); + aLL.setLegendLayer(aLL.getLayoutMap().getMapFrame().getMapView().getLayers().get(0)); + } + + try { + aLL.setLegendStyle(LegendStyles.valueOf(layoutLegend.getAttributes().getNamedItem("LegendStyle").getNodeValue())); + aLL.setBackColor(ColorUtil.parseToColor(layoutLegend.getAttributes().getNamedItem("BackColor").getNodeValue())); + aLL.setDrawNeatLine(Boolean.parseBoolean(layoutLegend.getAttributes().getNamedItem("DrawNeatLine").getNodeValue())); + aLL.setNeatLineColor(ColorUtil.parseToColor(layoutLegend.getAttributes().getNamedItem("NeatLineColor").getNodeValue())); + aLL.setNeatLineSize(Float.parseFloat(layoutLegend.getAttributes().getNamedItem("NeatLineSize").getNodeValue())); + aLL.setLeft(Integer.parseInt(layoutLegend.getAttributes().getNamedItem("Left").getNodeValue())); + aLL.setTop(Integer.parseInt(layoutLegend.getAttributes().getNamedItem("Top").getNodeValue())); + aLL.setWidth(Integer.parseInt(layoutLegend.getAttributes().getNamedItem("Width").getNodeValue())); + aLL.setHeight(Integer.parseInt(layoutLegend.getAttributes().getNamedItem("Height").getNodeValue())); + String fontName = layoutLegend.getAttributes().getNamedItem("FontName").getNodeValue(); + float fontSize = Float.parseFloat(layoutLegend.getAttributes().getNamedItem("FontSize").getNodeValue()); + aLL.setFont(new Font(fontName, Font.PLAIN, (int) fontSize)); + aLL.setLayerUpdateType(LayerUpdateTypes.valueOf(layoutLegend.getAttributes().getNamedItem("LayerUpdateType").getNodeValue())); + aLL.setColumnNumber(Integer.parseInt(layoutLegend.getAttributes().getNamedItem("ColumnNumber").getNodeValue())); + aLL.setDrawBackColor(Boolean.parseBoolean(layoutLegend.getAttributes().getNamedItem("DrawBackColor").getNodeValue())); + aLL.setDrawChartBreaks(Boolean.parseBoolean(layoutLegend.getAttributes().getNamedItem("DrawChartBreaks").getNodeValue())); + aLL.setForceDrawOutline(Boolean.parseBoolean(layoutLegend.getAttributes().getNamedItem("ForceDrawOutline").getNodeValue())); + } catch (Exception e) { + } + + return aLL; + } + + private LayoutScaleBar loadLayoutScaleBarElement(Node layoutScaleBar) { + LayoutScaleBar aLSB = null; + try { + int layoutMapIdx = Integer.parseInt(layoutScaleBar.getAttributes().getNamedItem("LayoutMapIndex").getNodeValue()); + LayoutMap aLM = this.getLayoutMaps().get(layoutMapIdx); + aLSB = new LayoutScaleBar(aLM); + } catch (Exception e) { + aLSB = new LayoutScaleBar(this.getLayoutMaps().get(0)); + } + + try { + aLSB.setScaleBarType(ScaleBarType.valueOf(layoutScaleBar.getAttributes().getNamedItem("ScaleBarType").getNodeValue())); + aLSB.setBackColor(ColorUtil.parseToColor(layoutScaleBar.getAttributes().getNamedItem("BackColor").getNodeValue())); + aLSB.setForeColor(ColorUtil.parseToColor(layoutScaleBar.getAttributes().getNamedItem("ForeColor").getNodeValue())); + aLSB.setDrawNeatLine(Boolean.parseBoolean(layoutScaleBar.getAttributes().getNamedItem("DrawNeatLine").getNodeValue())); + aLSB.setNeatLineColor(ColorUtil.parseToColor(layoutScaleBar.getAttributes().getNamedItem("NeatLineColor").getNodeValue())); + aLSB.setNeatLineSize(Float.parseFloat(layoutScaleBar.getAttributes().getNamedItem("NeatLineSize").getNodeValue())); + aLSB.setLeft(Integer.parseInt(layoutScaleBar.getAttributes().getNamedItem("Left").getNodeValue())); + aLSB.setTop(Integer.parseInt(layoutScaleBar.getAttributes().getNamedItem("Top").getNodeValue())); + aLSB.setWidth(Integer.parseInt(layoutScaleBar.getAttributes().getNamedItem("Width").getNodeValue())); + aLSB.setHeight(Integer.parseInt(layoutScaleBar.getAttributes().getNamedItem("Height").getNodeValue())); + String fontName = layoutScaleBar.getAttributes().getNamedItem("FontName").getNodeValue(); + float fontSize = Float.parseFloat(layoutScaleBar.getAttributes().getNamedItem("FontSize").getNodeValue()); + aLSB.setFont(new Font(fontName, Font.PLAIN, (int) fontSize)); + aLSB.setDrawScaleText(Boolean.parseBoolean(layoutScaleBar.getAttributes().getNamedItem("DrawScaleText").getNodeValue())); + aLSB.setDrawBackColor(Boolean.parseBoolean(layoutScaleBar.getAttributes().getNamedItem("DrawBackColor").getNodeValue())); + } catch (Exception e) { + } + + return aLSB; + } + + private LayoutNorthArrow loadLayoutNorthArrowElement(Node layoutNorthArrow) { + LayoutNorthArrow aLNA = null; + try { + int layoutMapIdx = Integer.parseInt(layoutNorthArrow.getAttributes().getNamedItem("LayoutMapIndex").getNodeValue()); + LayoutMap aLM = this.getLayoutMaps().get(layoutMapIdx); + aLNA = new LayoutNorthArrow(aLM); + } catch (Exception e) { + aLNA = new LayoutNorthArrow(this.getLayoutMaps().get(0)); + } + + try { + aLNA.setBackColor(ColorUtil.parseToColor(layoutNorthArrow.getAttributes().getNamedItem("BackColor").getNodeValue())); + aLNA.setForeColor(ColorUtil.parseToColor(layoutNorthArrow.getAttributes().getNamedItem("ForeColor").getNodeValue())); + aLNA.setDrawNeatLine(Boolean.parseBoolean(layoutNorthArrow.getAttributes().getNamedItem("DrawNeatLine").getNodeValue())); + aLNA.setNeatLineColor(ColorUtil.parseToColor(layoutNorthArrow.getAttributes().getNamedItem("NeatLineColor").getNodeValue())); + aLNA.setNeatLineSize(Float.parseFloat(layoutNorthArrow.getAttributes().getNamedItem("NeatLineSize").getNodeValue())); + aLNA.setLeft(Integer.parseInt(layoutNorthArrow.getAttributes().getNamedItem("Left").getNodeValue())); + aLNA.setTop(Integer.parseInt(layoutNorthArrow.getAttributes().getNamedItem("Top").getNodeValue())); + aLNA.setWidth(Integer.parseInt(layoutNorthArrow.getAttributes().getNamedItem("Width").getNodeValue())); + aLNA.setHeight(Integer.parseInt(layoutNorthArrow.getAttributes().getNamedItem("Height").getNodeValue())); + aLNA.setAngle(Float.parseFloat(layoutNorthArrow.getAttributes().getNamedItem("Angle").getNodeValue())); + aLNA.setDrawBackColor(Boolean.parseBoolean(layoutNorthArrow.getAttributes().getNamedItem("DrawBackColor").getNodeValue())); + } catch (Exception e) { + } + + return aLNA; + } + + private LayoutGraphic loadLayoutGraphicElement(Node layoutGraphic) { + Graphic aGraphic = new Graphic(); + Node graphicNode = ((Element) layoutGraphic).getElementsByTagName("Graphic").item(0); + aGraphic.importFromXML((Element) graphicNode); + + LayoutGraphic aLG; + if (aGraphic.getShape().getShapeType() == ShapeTypes.WindArraw) { + aLG = new LayoutGraphic(aGraphic, this, this.getActiveLayoutMap()); + } else { + aLG = new LayoutGraphic(aGraphic, this); + } + + aLG.setIsTitle(Boolean.parseBoolean(layoutGraphic.getAttributes().getNamedItem("IsTitle").getNodeValue())); + + return aLG; + } + // + // + } diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/MapLayoutBeanInfo.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/MapLayoutBeanInfo.java similarity index 56% rename from MeteoInfoLib/src/main/java/org/meteoinfo/layout/MapLayoutBeanInfo.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/MapLayoutBeanInfo.java index f491a84e..12c962c4 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/MapLayoutBeanInfo.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/MapLayoutBeanInfo.java @@ -1,29 +1,29 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layout; - -import com.l2fprod.common.beans.BaseBeanInfo; - -/** - * - * @author Yaqiang - */ -public class MapLayoutBeanInfo extends BaseBeanInfo { - public MapLayoutBeanInfo(){ - super(MapLayout.class); - addProperty("antiAlias").setCategory("General").setDisplayName("AntiAlias"); - addProperty("pageBackColor").setCategory("General").setDisplayName("Background"); - addProperty("pageForeColor").setCategory("General").setDisplayName("Foreground"); - } -} + /* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.layout; + +import com.l2fprod.common.beans.BaseBeanInfo; + + /** + * + * @author Yaqiang + */ + public class MapLayoutBeanInfo extends BaseBeanInfo { + public MapLayoutBeanInfo(){ + super(MapLayout.class); + addProperty("antiAlias").setCategory("General").setDisplayName("AntiAlias"); + addProperty("pageBackColor").setCategory("General").setDisplayName("Background"); + addProperty("pageForeColor").setCategory("General").setDisplayName("Foreground"); + } + } diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/MapLayoutUndoRedo.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/MapLayoutUndoRedo.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/layout/MapLayoutUndoRedo.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/MapLayoutUndoRedo.java index 1b10d64c..5b68dbb7 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/MapLayoutUndoRedo.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/MapLayoutUndoRedo.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.layout; +package org.meteoinfo.geo.layout; import org.meteoinfo.common.PointF; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/MouseMode.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/MouseMode.java similarity index 95% rename from MeteoInfoLib/src/main/java/org/meteoinfo/layout/MouseMode.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/MouseMode.java index ebf62539..3ad54a8c 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/MouseMode.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/MouseMode.java @@ -1,142 +1,142 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layout; - -/** - * - * @author yaqiang - */ -public enum MouseMode { - /// - /// The cursor is currently in default mode - /// - - Default, - /// - /// The cursor is currently in select mode - /// - Select, - /// - /// The cursor is currently being used to create a new selection - /// - CreateSelection, - /// - /// The cursor is currently is move selection mode - /// - MoveSelection, - /// - /// The cursor is in resize mode because its over the edge of a selected item - /// - ResizeSelected, - /// - /// When in this mode the user can click on the map select an area and an element is inserted at that spot - /// - InsertNewElement, - /// - /// In this mode a cross hair is shown letting the user create a new Insert rectangle - /// - StartInsertNewElement, - /// - /// Puts the mouse into a mode that allows map panning - /// - StartPanMap, - /// - /// The mouse is actually panning a map - /// - PanMap, - /// - /// New point - /// - New_Point, - /// - /// New label - /// - New_Label, - /// - /// New polyline - /// - New_Polyline, - /// - /// New freehand - /// - New_Freehand, - /// - /// New curve - /// - New_Curve, - /// - /// New curve polygon - /// - New_CurvePolygon, - /// - /// New polygon - /// - New_Polygon, - /// - /// New rectangle - /// - New_Rectangle, - /// - /// New ellipse - /// - New_Ellipse, - /// - /// New circle - /// - New_Circle, - /// - /// Edit vertices of polyline or polygon - /// - EditVertices, - /// - /// In editing vertices status - /// - InEditingVertices, - /// - /// Map zoom in - /// - Map_ZoomIn, - /// - /// Map zoom out - /// - Map_ZoomOut, - /// - /// Map pan - /// - Map_Pan, - /// - /// Map identifer - /// - Map_Identifer, - /// - /// Map select Features - /// - Map_SelectFeatures_Rectangle, - Map_SelectFeatures_Polygon, - Map_SelectFeatures_Lasso, - Map_SelectFeatures_Circle, - /// - /// Map measurement - /// - Map_Measurement, - Map_Edit_Tool, - Map_Edit_MoveSelection, - Map_Edit_NewFeature, - Map_Edit_FeatureVertices, - Map_Edit_AddRing, - Map_Edit_FillRing, - Map_Edit_DeleteRing, - Map_Edit_ReformFeature, - Map_Edit_SplitFeature, -} +/* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.layout; + +/** + * + * @author yaqiang + */ +public enum MouseMode { + /// + /// The cursor is currently in default mode + /// + + Default, + /// + /// The cursor is currently in select mode + /// + Select, + /// + /// The cursor is currently being used to create a new selection + /// + CreateSelection, + /// + /// The cursor is currently is move selection mode + /// + MoveSelection, + /// + /// The cursor is in resize mode because its over the edge of a selected item + /// + ResizeSelected, + /// + /// When in this mode the user can click on the map select an area and an element is inserted at that spot + /// + InsertNewElement, + /// + /// In this mode a cross hair is shown letting the user create a new Insert rectangle + /// + StartInsertNewElement, + /// + /// Puts the mouse into a mode that allows map panning + /// + StartPanMap, + /// + /// The mouse is actually panning a map + /// + PanMap, + /// + /// New point + /// + New_Point, + /// + /// New label + /// + New_Label, + /// + /// New polyline + /// + New_Polyline, + /// + /// New freehand + /// + New_Freehand, + /// + /// New curve + /// + New_Curve, + /// + /// New curve polygon + /// + New_CurvePolygon, + /// + /// New polygon + /// + New_Polygon, + /// + /// New rectangle + /// + New_Rectangle, + /// + /// New ellipse + /// + New_Ellipse, + /// + /// New circle + /// + New_Circle, + /// + /// Edit vertices of polyline or polygon + /// + EditVertices, + /// + /// In editing vertices status + /// + InEditingVertices, + /// + /// Map zoom in + /// + Map_ZoomIn, + /// + /// Map zoom out + /// + Map_ZoomOut, + /// + /// Map pan + /// + Map_Pan, + /// + /// Map identifer + /// + Map_Identifer, + /// + /// Map select Features + /// + Map_SelectFeatures_Rectangle, + Map_SelectFeatures_Polygon, + Map_SelectFeatures_Lasso, + Map_SelectFeatures_Circle, + /// + /// Map measurement + /// + Map_Measurement, + Map_Edit_Tool, + Map_Edit_MoveSelection, + Map_Edit_NewFeature, + Map_Edit_FeatureVertices, + Map_Edit_AddRing, + Map_Edit_FillRing, + Map_Edit_DeleteRing, + Map_Edit_ReformFeature, + Map_Edit_SplitFeature, +} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/NorthArrowType.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/NorthArrowType.java similarity index 96% rename from MeteoInfoLib/src/main/java/org/meteoinfo/layout/NorthArrowType.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/NorthArrowType.java index 9c4f1a7d..8e2674c9 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/NorthArrowType.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/NorthArrowType.java @@ -11,7 +11,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.layout; +package org.meteoinfo.geo.layout; /** * North arrow types diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/PaperSize.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/PaperSize.java similarity index 94% rename from MeteoInfoLib/src/main/java/org/meteoinfo/layout/PaperSize.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/PaperSize.java index ea8983a3..bb4e1c7c 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/PaperSize.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/PaperSize.java @@ -1,97 +1,97 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layout; - -/** - * - * @author yaqiang - */ -public class PaperSize { - // - private String _name; - private int _width; - private int _height; - // - // - /** - * Constructor - */ - public PaperSize(){ - - } - - /** - * Constructor - * @param name Name - * @param width Width - * @param height Height - */ - public PaperSize(String name, int width, int height){ - this._name = name; - this._width = width; - this._height = height; - } - // - // - /** - * Get name - * @return Name - */ - public String getName(){ - return _name; - } - - /** - * Set name - * @param name Name - */ - public void setName(String name){ - _name = name; - } - - /** - * Get width - * @return Width - */ - public int getWidth(){ - return _width; - } - - /** - * Set width - * @param width Width - */ - public void setWidth(int width){ - _width = width; - } - - /** - * Get height - * @return Height - */ - public int getHeight(){ - return _height; - } - - /** - * Set height - * @param height Height - */ - public void setHeight(int height){ - _height = height; - } - // - // - // -} + /* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.layout; + +/** + * + * @author yaqiang + */ +public class PaperSize { + // + private String _name; + private int _width; + private int _height; + // + // + /** + * Constructor + */ + public PaperSize(){ + + } + + /** + * Constructor + * @param name Name + * @param width Width + * @param height Height + */ + public PaperSize(String name, int width, int height){ + this._name = name; + this._width = width; + this._height = height; + } + // + // + /** + * Get name + * @return Name + */ + public String getName(){ + return _name; + } + + /** + * Set name + * @param name Name + */ + public void setName(String name){ + _name = name; + } + + /** + * Get width + * @return Width + */ + public int getWidth(){ + return _width; + } + + /** + * Set width + * @param width Width + */ + public void setWidth(int width){ + _width = width; + } + + /** + * Get height + * @return Height + */ + public int getHeight(){ + return _height; + } + + /** + * Set height + * @param height Height + */ + public void setHeight(int height){ + _height = height; + } + // + // + // +} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/ResizeAbility.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/ResizeAbility.java similarity index 92% rename from MeteoInfoLib/src/main/java/org/meteoinfo/layout/ResizeAbility.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/ResizeAbility.java index 69c01e2a..f24ddd3f 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/ResizeAbility.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/ResizeAbility.java @@ -1,26 +1,26 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.layout; - -/** - * Resize ability enum - * - * @author Yaqiang - */ -public enum ResizeAbility { - - None, - SameWidthHeight, - ResizeAll; -} + /* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.layout; + +/** + * Resize ability enum + * + * @author Yaqiang + */ +public enum ResizeAbility { + + None, + SameWidthHeight, + ResizeAll; +} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/ScaleBarType.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/ScaleBarType.java similarity index 96% rename from MeteoInfoLib/src/main/java/org/meteoinfo/layout/ScaleBarType.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/ScaleBarType.java index b6fd9a73..bfdc0a54 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/ScaleBarType.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/ScaleBarType.java @@ -11,7 +11,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.layout; +package org.meteoinfo.geo.layout; /** * Template diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/ScaleBarUnits.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/ScaleBarUnits.java similarity index 97% rename from MeteoInfoLib/src/main/java/org/meteoinfo/layout/ScaleBarUnits.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/ScaleBarUnits.java index a2fd46ca..c3e123de 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/layout/ScaleBarUnits.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layout/ScaleBarUnits.java @@ -11,7 +11,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.layout; +package org.meteoinfo.geo.layout; /** * Template diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmColorSymbolSet.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmColorSymbolSet.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmColorSymbolSet.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmColorSymbolSet.java index 891ea8af..f90b92b3 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmColorSymbolSet.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmColorSymbolSet.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.legend; +package org.meteoinfo.geo.legend; import org.meteoinfo.geometry.legend.ColorBreak; diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmLabelSymbolSet.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmLabelSymbolSet.java new file mode 100644 index 00000000..891c382d --- /dev/null +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmLabelSymbolSet.java @@ -0,0 +1,310 @@ + /* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.legend; + +import org.meteoinfo.geometry.legend.LabelBreak; +import org.meteoinfo.geo.layout.MapLayout; +import org.meteoinfo.geo.mapview.MapView; +import com.l2fprod.common.swing.JFontChooser; +import java.awt.Color; +import java.awt.Font; +import javax.swing.JColorChooser; + + /** + * + * @author Yaqiang Wang + */ + public class FrmLabelSymbolSet extends javax.swing.JDialog { + + private Object _parent = null; + private LabelBreak _labelBreak = null; + private boolean _isLoading = false; + + /** + * Creates new form FrmLabelSymbolSet + * @param parent + * @param modal + */ + public FrmLabelSymbolSet(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + } + + /** + * Creates new form FrmLabelSymbolSet + * @param parent + * @param modal + * @param tparent + */ + public FrmLabelSymbolSet(java.awt.Frame parent, boolean modal, Object tparent) { + super(parent, modal); + initComponents(); + + _parent = tparent; + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jScrollPane1 = new javax.swing.JScrollPane(); + jTextArea_Text = new javax.swing.JTextArea(); + jPanel1 = new javax.swing.JPanel(); + jButton_Font = new javax.swing.JButton(); + jLabel1 = new javax.swing.JLabel(); + jSpinner_Angle = new javax.swing.JSpinner(); + jLabel_Color = new javax.swing.JLabel(); + jButton_OK = new javax.swing.JButton(); + jButton_Apply = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + jTextArea_Text.setColumns(20); + jTextArea_Text.setRows(5); + jTextArea_Text.setWrapStyleWord(true); + jScrollPane1.setViewportView(jTextArea_Text); + + jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + + jButton_Font.setText("Font"); + jButton_Font.setPreferredSize(new java.awt.Dimension(81, 30)); + jButton_Font.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton_FontActionPerformed(evt); + } + }); + + jLabel1.setText("Angle:"); + + jSpinner_Angle.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.0f), Float.valueOf(-360.0f), Float.valueOf(360.0f), Float.valueOf(1.0f))); + jSpinner_Angle.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + jSpinner_AngleStateChanged(evt); + } + }); + + jLabel_Color.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel_Color.setText("Color"); + jLabel_Color.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + jLabel_Color.setOpaque(true); + jLabel_Color.setPreferredSize(new java.awt.Dimension(34, 22)); + jLabel_Color.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jLabel_ColorMouseClicked(evt); + } + }); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jButton_Font, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE) + .addComponent(jLabel_Color, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jSpinner_Angle, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jButton_Font, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel_Color, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1) + .addComponent(jSpinner_Angle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + jButton_OK.setText("OK"); + jButton_OK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton_OKActionPerformed(evt); + } + }); + + jButton_Apply.setText("Apply"); + jButton_Apply.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton_ApplyActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jButton_OK, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(58, 58, 58) + .addComponent(jButton_Apply, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(49, 49, 49)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jButton_OK) + .addComponent(jButton_Apply)) + .addContainerGap(17, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + private void jButton_OKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_OKActionPerformed + // TODO add your handling code here: + _labelBreak.setText(this.jTextArea_Text.getText()); + if (_parent.getClass() == MapView.class) { + ((MapView) _parent).setDefLabelBreak(_labelBreak); + ((MapView) _parent).paintLayers(); + } else if (_parent.getClass() == MapLayout.class) { + ((MapLayout) _parent).setDefLabelBreak(_labelBreak); + ((MapLayout) _parent).paintGraphics(); + } + + this.dispose(); + }//GEN-LAST:event_jButton_OKActionPerformed + + private void jButton_ApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_ApplyActionPerformed + // TODO add your handling code here: + _labelBreak.setText(this.jTextArea_Text.getText()); + if (_parent.getClass() == MapView.class) { + ((MapView) _parent).paintLayers(); + } else if (_parent.getClass() == MapLayout.class) { + ((MapLayout) _parent).paintGraphics(); + } + }//GEN-LAST:event_jButton_ApplyActionPerformed + + private void jLabel_ColorMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel_ColorMouseClicked + // TODO add your handling code here: + Color aColor = JColorChooser.showDialog(this, null, this.jLabel_Color.getBackground()); + this.jLabel_Color.setBackground(aColor); + this.jTextArea_Text.setForeground(aColor); + _labelBreak.setColor(aColor); + }//GEN-LAST:event_jLabel_ColorMouseClicked + + private void jButton_FontActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_FontActionPerformed + // TODO add your handling code here: + //FontChooser fontChooser = new FontChooser(this, true, _labelBreak.getFont()); + //fontChooser.setVisible(true); + Font aFont = JFontChooser.showDialog(this, null, _labelBreak.getFont()); + if (aFont != null) { + this.jTextArea_Text.setFont(aFont); + _labelBreak.setFont(aFont); + } + }//GEN-LAST:event_jButton_FontActionPerformed + + private void jSpinner_AngleStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner_AngleStateChanged + // TODO add your handling code here: + if (_isLoading) { + return; + } + + float angle = Float.parseFloat(this.jSpinner_Angle.getValue().toString()); + _labelBreak.setAngle(angle); + }//GEN-LAST:event_jSpinner_AngleStateChanged + + /** + * Set label break + * + * @param lb The label break + */ + public void setLabelBreak(LabelBreak lb) { + _labelBreak = lb; + + _isLoading = true; + this.jTextArea_Text.setText(_labelBreak.getText()); + this.jTextArea_Text.setForeground(_labelBreak.getColor()); + this.jTextArea_Text.setFont(_labelBreak.getFont()); + this.jLabel_Color.setBackground(_labelBreak.getColor()); + this.jSpinner_Angle.setValue(_labelBreak.getAngle()); + _isLoading = false; + } + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(FrmLabelSymbolSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(FrmLabelSymbolSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(FrmLabelSymbolSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(FrmLabelSymbolSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the dialog */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + FrmLabelSymbolSet dialog = new FrmLabelSymbolSet(new javax.swing.JFrame(), true); + dialog.addWindowListener(new java.awt.event.WindowAdapter() { + @Override + public void windowClosing(java.awt.event.WindowEvent e) { + System.exit(0); + } + }); + dialog.setVisible(true); + } + }); + } + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton_Apply; + private javax.swing.JButton jButton_Font; + private javax.swing.JButton jButton_OK; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel_Color; + private javax.swing.JPanel jPanel1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JSpinner jSpinner_Angle; + private javax.swing.JTextArea jTextArea_Text; + // End of variables declaration//GEN-END:variables + } diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLegendBreaks.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmLegendBreaks.java similarity index 96% rename from MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLegendBreaks.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmLegendBreaks.java index eb222bbb..415b74f1 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLegendBreaks.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmLegendBreaks.java @@ -2,11 +2,11 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.legend; +package org.meteoinfo.geo.legend; import org.meteoinfo.geometry.legend.ColorBreak; import org.meteoinfo.geometry.legend.LegendScheme; -import org.meteoinfo.layer.FrmLayerProperty; +import org.meteoinfo.geo.layer.FrmLayerProperty; import org.meteoinfo.ndarray.util.BigDecimalUtil; import org.meteoinfo.geometry.shape.ShapeTypes; import java.awt.Color; @@ -198,15 +198,15 @@ public class FrmLegendBreaks extends javax.swing.JDialog { jLabel_From.setText("from:"); - jTextField_StartValue.setPreferredSize(new java.awt.Dimension(89, 24)); + jTextField_StartValue.setPreferredSize(new Dimension(89, 24)); jLabel_To.setText("to:"); - jTextField_EndValue.setPreferredSize(new java.awt.Dimension(89, 24)); + jTextField_EndValue.setPreferredSize(new Dimension(89, 24)); jLabel_Interval.setText("Interval:"); - jTextField_Interval.setPreferredSize(new java.awt.Dimension(89, 24)); + jTextField_Interval.setPreferredSize(new Dimension(89, 24)); jCheckBox_Log.setText("Log"); jCheckBox_Log.addActionListener(new java.awt.event.ActionListener() { @@ -472,13 +472,13 @@ public class FrmLegendBreaks extends javax.swing.JDialog { } } } catch (ClassNotFoundException ex) { - java.util.logging.Logger.getLogger(FrmLegendBreaks.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + Logger.getLogger(FrmLegendBreaks.class.getName()).log(Level.SEVERE, null, ex); } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(FrmLegendBreaks.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + Logger.getLogger(FrmLegendBreaks.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(FrmLegendBreaks.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + Logger.getLogger(FrmLegendBreaks.class.getName()).log(Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(FrmLegendBreaks.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + Logger.getLogger(FrmLegendBreaks.class.getName()).log(Level.SEVERE, null, ex); } // diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLegendSet.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmLegendSet.java similarity index 76% rename from MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLegendSet.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmLegendSet.java index fc58e4bd..89a9fc0c 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmLegendSet.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmLegendSet.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.legend; +package org.meteoinfo.geo.legend; import com.formdev.flatlaf.extras.FlatSVGIcon; import org.meteoinfo.common.GenericFileFilter; @@ -22,7 +22,7 @@ import org.xml.sax.SAXException; * * @author yaqiang */ -public class FrmLegendSet extends javax.swing.JDialog { +public class FrmLegendSet extends JDialog { private LegendScheme _legendScheme = null; private boolean _isOK = false; @@ -56,24 +56,24 @@ public class FrmLegendSet extends javax.swing.JDialog { // //GEN-BEGIN:initComponents private void initComponents() { - jToolBar1 = new javax.swing.JToolBar(); - jButton_ImportLegend = new javax.swing.JButton(); - jButton_ExportLegend = new javax.swing.JButton(); - jSeparator1 = new javax.swing.JToolBar.Separator(); - jButton_AddBreak = new javax.swing.JButton(); - jButton_RemoveBreak = new javax.swing.JButton(); - jButton_RemoveAllBreaks = new javax.swing.JButton(); - jSeparator2 = new javax.swing.JToolBar.Separator(); - jButton_MoveBreakUp = new javax.swing.JButton(); - jButton_MoveBreakDown = new javax.swing.JButton(); - jButton_ReverseBreaks = new javax.swing.JButton(); - jSeparator3 = new javax.swing.JToolBar.Separator(); - jButton_MakeBreaks = new javax.swing.JButton(); - legendView1 = new org.meteoinfo.legend.LegendView(); - jButton_OK = new javax.swing.JButton(); - jButton_Cancel = new javax.swing.JButton(); + jToolBar1 = new JToolBar(); + jButton_ImportLegend = new JButton(); + jButton_ExportLegend = new JButton(); + jSeparator1 = new JToolBar.Separator(); + jButton_AddBreak = new JButton(); + jButton_RemoveBreak = new JButton(); + jButton_RemoveAllBreaks = new JButton(); + jSeparator2 = new JToolBar.Separator(); + jButton_MoveBreakUp = new JButton(); + jButton_MoveBreakDown = new JButton(); + jButton_ReverseBreaks = new JButton(); + jSeparator3 = new JToolBar.Separator(); + jButton_MakeBreaks = new JButton(); + legendView1 = new LegendView(); + jButton_OK = new JButton(); + jButton_Cancel = new JButton(); - setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); jToolBar1.setFloatable(false); jToolBar1.setRollover(true); @@ -82,8 +82,8 @@ public class FrmLegendSet extends javax.swing.JDialog { jButton_ImportLegend.setIcon(new FlatSVGIcon("org/meteoinfo/icons/file-open.svg")); jButton_ImportLegend.setToolTipText("Import Legend"); jButton_ImportLegend.setFocusable(false); - jButton_ImportLegend.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton_ImportLegend.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton_ImportLegend.setHorizontalTextPosition(SwingConstants.CENTER); + jButton_ImportLegend.setVerticalTextPosition(SwingConstants.BOTTOM); jButton_ImportLegend.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_ImportLegendActionPerformed(evt); @@ -95,8 +95,8 @@ public class FrmLegendSet extends javax.swing.JDialog { jButton_ExportLegend.setIcon(new FlatSVGIcon("org/meteoinfo/icons/file-save.svg")); jButton_ExportLegend.setToolTipText("Export Legend"); jButton_ExportLegend.setFocusable(false); - jButton_ExportLegend.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton_ExportLegend.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton_ExportLegend.setHorizontalTextPosition(SwingConstants.CENTER); + jButton_ExportLegend.setVerticalTextPosition(SwingConstants.BOTTOM); jButton_ExportLegend.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_ExportLegendActionPerformed(evt); @@ -109,8 +109,8 @@ public class FrmLegendSet extends javax.swing.JDialog { jButton_AddBreak.setIcon(new FlatSVGIcon("org/meteoinfo/icons/add.svg")); jButton_AddBreak.setToolTipText("Add Break"); jButton_AddBreak.setFocusable(false); - jButton_AddBreak.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton_AddBreak.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton_AddBreak.setHorizontalTextPosition(SwingConstants.CENTER); + jButton_AddBreak.setVerticalTextPosition(SwingConstants.BOTTOM); jButton_AddBreak.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_AddBreakActionPerformed(evt); @@ -122,8 +122,8 @@ public class FrmLegendSet extends javax.swing.JDialog { jButton_RemoveBreak.setIcon(new FlatSVGIcon("org/meteoinfo/icons/remove.svg")); jButton_RemoveBreak.setToolTipText("Remove Break"); jButton_RemoveBreak.setFocusable(false); - jButton_RemoveBreak.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton_RemoveBreak.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton_RemoveBreak.setHorizontalTextPosition(SwingConstants.CENTER); + jButton_RemoveBreak.setVerticalTextPosition(SwingConstants.BOTTOM); jButton_RemoveBreak.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_RemoveBreakActionPerformed(evt); @@ -135,8 +135,8 @@ public class FrmLegendSet extends javax.swing.JDialog { jButton_RemoveAllBreaks.setIcon(new FlatSVGIcon("org/meteoinfo/icons/delete.svg")); jButton_RemoveAllBreaks.setToolTipText("Remove All Breaks"); jButton_RemoveAllBreaks.setFocusable(false); - jButton_RemoveAllBreaks.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton_RemoveAllBreaks.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton_RemoveAllBreaks.setHorizontalTextPosition(SwingConstants.CENTER); + jButton_RemoveAllBreaks.setVerticalTextPosition(SwingConstants.BOTTOM); jButton_RemoveAllBreaks.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_RemoveAllBreaksActionPerformed(evt); @@ -149,8 +149,8 @@ public class FrmLegendSet extends javax.swing.JDialog { jButton_MoveBreakUp.setIcon(new FlatSVGIcon("org/meteoinfo/icons/up-arrow.svg")); jButton_MoveBreakUp.setToolTipText("Move Break Up"); jButton_MoveBreakUp.setFocusable(false); - jButton_MoveBreakUp.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton_MoveBreakUp.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton_MoveBreakUp.setHorizontalTextPosition(SwingConstants.CENTER); + jButton_MoveBreakUp.setVerticalTextPosition(SwingConstants.BOTTOM); jButton_MoveBreakUp.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_MoveBreakUpActionPerformed(evt); @@ -162,8 +162,8 @@ public class FrmLegendSet extends javax.swing.JDialog { jButton_MoveBreakDown.setIcon(new FlatSVGIcon("org/meteoinfo/icons/down-arrow.svg")); jButton_MoveBreakDown.setToolTipText("Move Break Down"); jButton_MoveBreakDown.setFocusable(false); - jButton_MoveBreakDown.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton_MoveBreakDown.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton_MoveBreakDown.setHorizontalTextPosition(SwingConstants.CENTER); + jButton_MoveBreakDown.setVerticalTextPosition(SwingConstants.BOTTOM); jButton_MoveBreakDown.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_MoveBreakDownActionPerformed(evt); @@ -175,8 +175,8 @@ public class FrmLegendSet extends javax.swing.JDialog { jButton_ReverseBreaks.setIcon(new FlatSVGIcon("org/meteoinfo/icons/up-down.svg")); jButton_ReverseBreaks.setToolTipText("Reverse Breaks"); jButton_ReverseBreaks.setFocusable(false); - jButton_ReverseBreaks.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton_ReverseBreaks.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton_ReverseBreaks.setHorizontalTextPosition(SwingConstants.CENTER); + jButton_ReverseBreaks.setVerticalTextPosition(SwingConstants.BOTTOM); jButton_ReverseBreaks.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_ReverseBreaksActionPerformed(evt); @@ -188,8 +188,8 @@ public class FrmLegendSet extends javax.swing.JDialog { //jButton_MakeBreaks.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_MakeBreaks.Image.png"))); // NOI18N jButton_MakeBreaks.setIcon(new FlatSVGIcon("org/meteoinfo/icons/colors.svg")); jButton_MakeBreaks.setFocusable(false); - jButton_MakeBreaks.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton_MakeBreaks.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton_MakeBreaks.setHorizontalTextPosition(SwingConstants.CENTER); + jButton_MakeBreaks.setVerticalTextPosition(SwingConstants.BOTTOM); jButton_MakeBreaks.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_MakeBreaksActionPerformed(evt); @@ -197,14 +197,14 @@ public class FrmLegendSet extends javax.swing.JDialog { }); jToolBar1.add(jButton_MakeBreaks); - javax.swing.GroupLayout legendView1Layout = new javax.swing.GroupLayout(legendView1); + GroupLayout legendView1Layout = new GroupLayout(legendView1); legendView1.setLayout(legendView1Layout); legendView1Layout.setHorizontalGroup( - legendView1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + legendView1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGap(0, 382, Short.MAX_VALUE) ); legendView1Layout.setVerticalGroup( - legendView1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + legendView1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGap(0, 342, Short.MAX_VALUE) ); @@ -224,29 +224,29 @@ public class FrmLegendSet extends javax.swing.JDialog { } }); - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + GroupLayout layout = new GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE) - .addComponent(legendView1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE) + layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(jToolBar1, GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE) + .addComponent(legendView1, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addGap(68, 68, 68) - .addComponent(jButton_OK, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jButton_OK, GroupLayout.PREFERRED_SIZE, 71, GroupLayout.PREFERRED_SIZE) .addGap(69, 69, 69) - .addComponent(jButton_Cancel, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(jButton_Cancel, GroupLayout.PREFERRED_SIZE, 82, GroupLayout.PREFERRED_SIZE) + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(legendView1, javax.swing.GroupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE) + .addComponent(jToolBar1, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(legendView1, GroupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE) .addGap(18, 18, 18) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE, false) - .addComponent(jButton_OK, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jButton_Cancel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE, false) + .addComponent(jButton_OK, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jButton_Cancel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); @@ -481,27 +481,27 @@ public class FrmLegendSet extends javax.swing.JDialog { * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { - for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { - javax.swing.UIManager.setLookAndFeel(info.getClassName()); + UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { - java.util.logging.Logger.getLogger(FrmLegendSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + Logger.getLogger(FrmLegendSet.class.getName()).log(Level.SEVERE, null, ex); } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(FrmLegendSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + Logger.getLogger(FrmLegendSet.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(FrmLegendSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (javax.swing.UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(FrmLegendSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + Logger.getLogger(FrmLegendSet.class.getName()).log(Level.SEVERE, null, ex); + } catch (UnsupportedLookAndFeelException ex) { + Logger.getLogger(FrmLegendSet.class.getName()).log(Level.SEVERE, null, ex); } // /* Create and display the dialog */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { - FrmLegendSet dialog = new FrmLegendSet(new javax.swing.JDialog(), true); + FrmLegendSet dialog = new FrmLegendSet(new JDialog(), true); dialog.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent e) { @@ -513,21 +513,21 @@ public class FrmLegendSet extends javax.swing.JDialog { }); } // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton jButton_AddBreak; - private javax.swing.JButton jButton_Cancel; - private javax.swing.JButton jButton_ExportLegend; - private javax.swing.JButton jButton_ImportLegend; - private javax.swing.JButton jButton_MakeBreaks; - private javax.swing.JButton jButton_MoveBreakDown; - private javax.swing.JButton jButton_MoveBreakUp; - private javax.swing.JButton jButton_OK; - private javax.swing.JButton jButton_RemoveAllBreaks; - private javax.swing.JButton jButton_RemoveBreak; - private javax.swing.JButton jButton_ReverseBreaks; - private javax.swing.JToolBar.Separator jSeparator1; - private javax.swing.JToolBar.Separator jSeparator2; - private javax.swing.JToolBar.Separator jSeparator3; - private javax.swing.JToolBar jToolBar1; - private org.meteoinfo.legend.LegendView legendView1; + private JButton jButton_AddBreak; + private JButton jButton_Cancel; + private JButton jButton_ExportLegend; + private JButton jButton_ImportLegend; + private JButton jButton_MakeBreaks; + private JButton jButton_MoveBreakDown; + private JButton jButton_MoveBreakUp; + private JButton jButton_OK; + private JButton jButton_RemoveAllBreaks; + private JButton jButton_RemoveBreak; + private JButton jButton_ReverseBreaks; + private JToolBar.Separator jSeparator1; + private JToolBar.Separator jSeparator2; + private JToolBar.Separator jSeparator3; + private JToolBar jToolBar1; + private LegendView legendView1; // End of variables declaration//GEN-END:variables } diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPointSymbolSet.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmPointSymbolSet.java similarity index 97% rename from MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPointSymbolSet.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmPointSymbolSet.java index 808c6877..472593cf 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPointSymbolSet.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmPointSymbolSet.java @@ -2,17 +2,17 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.legend; +package org.meteoinfo.geo.legend; -import org.meteoinfo.common.util.FontUtil; +import org.meteoinfo.ui.util.FontUtil; import org.meteoinfo.common.util.GlobalUtil; import org.meteoinfo.geometry.legend.MarkerType; import org.meteoinfo.geometry.legend.PointBreak; import org.meteoinfo.geometry.legend.PointStyle; import org.meteoinfo.ui.event.ISelectedCellChangedListener; import org.meteoinfo.ui.event.SelectedCellChangedEvent; -import org.meteoinfo.layout.MapLayout; -import org.meteoinfo.map.MapView; +import org.meteoinfo.geo.layout.MapLayout; +import org.meteoinfo.geo.mapview.MapView; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; @@ -162,7 +162,7 @@ public class FrmPointSymbolSet extends javax.swing.JDialog { jSpinner_OutlineSize = new javax.swing.JSpinner(); jButton_OK = new javax.swing.JButton(); jButton_Apply = new javax.swing.JButton(); - symbolControl1 = new org.meteoinfo.legend.SymbolControl(); + symbolControl1 = new SymbolControl(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setResizable(false); @@ -678,13 +678,13 @@ public class FrmPointSymbolSet extends javax.swing.JDialog { } } } catch (ClassNotFoundException ex) { - java.util.logging.Logger.getLogger(FrmPointSymbolSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + Logger.getLogger(FrmPointSymbolSet.class.getName()).log(Level.SEVERE, null, ex); } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(FrmPointSymbolSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + Logger.getLogger(FrmPointSymbolSet.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(FrmPointSymbolSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + Logger.getLogger(FrmPointSymbolSet.class.getName()).log(Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(FrmPointSymbolSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + Logger.getLogger(FrmPointSymbolSet.class.getName()).log(Level.SEVERE, null, ex); } // @@ -723,6 +723,6 @@ public class FrmPointSymbolSet extends javax.swing.JDialog { private javax.swing.JSpinner jSpinner_Angle; private javax.swing.JSpinner jSpinner_OutlineSize; private javax.swing.JSpinner jSpinner_Size; - private org.meteoinfo.legend.SymbolControl symbolControl1; + private SymbolControl symbolControl1; // End of variables declaration//GEN-END:variables } diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPolygonSymbolSet.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmPolygonSymbolSet.java similarity index 98% rename from MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPolygonSymbolSet.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmPolygonSymbolSet.java index 9c076d15..4dc7739a 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/FrmPolygonSymbolSet.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmPolygonSymbolSet.java @@ -2,12 +2,12 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.legend; +package org.meteoinfo.geo.legend; import org.meteoinfo.geometry.legend.HatchStyle; import org.meteoinfo.geometry.legend.PolygonBreak; -import org.meteoinfo.layout.MapLayout; -import org.meteoinfo.map.MapView; +import org.meteoinfo.geo.layout.MapLayout; +import org.meteoinfo.geo.mapview.MapView; import java.awt.Color; import java.awt.Dimension; import javax.swing.JColorChooser; @@ -124,7 +124,7 @@ public class FrmPolygonSymbolSet extends javax.swing.JDialog { jLabel_BackColor = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jSpinner_TransParency = new javax.swing.JSpinner(); - symbolControl1 = new org.meteoinfo.legend.SymbolControl(); + symbolControl1 = new SymbolControl(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); @@ -243,8 +243,8 @@ public class FrmPolygonSymbolSet extends javax.swing.JDialog { } }); - symbolControl1.setCellSize(new java.awt.Dimension(50, 40)); - symbolControl1.setPreferredSize(new java.awt.Dimension(200, 50)); + symbolControl1.setCellSize(new Dimension(50, 40)); + symbolControl1.setPreferredSize(new Dimension(200, 50)); symbolControl1.setShapeType(org.meteoinfo.geometry.shape.ShapeTypes.Polygon); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); @@ -527,6 +527,6 @@ public class FrmPolygonSymbolSet extends javax.swing.JDialog { private javax.swing.JPanel jPanel1; private javax.swing.JSpinner jSpinner_OutlineSize; private javax.swing.JSpinner jSpinner_TransParency; - private org.meteoinfo.legend.SymbolControl symbolControl1; + private SymbolControl symbolControl1; // End of variables declaration//GEN-END:variables } diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmPolylineSymbolSet.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmPolylineSymbolSet.java new file mode 100644 index 00000000..9dd78b05 --- /dev/null +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/FrmPolylineSymbolSet.java @@ -0,0 +1,602 @@ + /* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.legend; + +import org.meteoinfo.geometry.legend.LineStyles; +import org.meteoinfo.geometry.legend.PointStyle; +import org.meteoinfo.geometry.legend.PolylineBreak; +import org.meteoinfo.ui.event.ISelectedCellChangedListener; +import org.meteoinfo.ui.event.SelectedCellChangedEvent; +import org.meteoinfo.geo.layout.MapLayout; +import org.meteoinfo.geo.mapview.MapView; +import java.awt.Color; +import java.awt.Dimension; +import java.util.Arrays; +import javax.swing.JColorChooser; + + /** + * + * @author Yaqiang Wang + */ + public class FrmPolylineSymbolSet extends javax.swing.JDialog { + + private Object _parent = null; + private PolylineBreak _polylineBreak = null; + private boolean isLoading = false; + + /** + * Creates new form FrmPolylineSymbolSet + * @param parent + * @param modal + */ + public FrmPolylineSymbolSet(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + + this.setTitle("Polyline Symbol Set"); + } + + /** + * Creates new form FrmPolylineSymbolSet + * @param parent + * @param modal + * @param tparent + */ + public FrmPolylineSymbolSet(java.awt.Dialog parent, boolean modal, Object tparent) { + super(parent, modal); + initComponents(); + + this.setTitle("Polyline Symbol Set"); + if (tparent.getClass() == LegendView.class){ + this.jButton_Apply.setVisible(false); + this.jButton_OK.setVisible(false); + this.setPreferredSize(new Dimension(this.getWidth(), this.getHeight() - 40)); + } + + this.symbolControl1.addSelectedCellChangedListener(new ISelectedCellChangedListener() { + @Override + public void selectedCellChangedEvent(SelectedCellChangedEvent event) { + onSelectedCellChanged(event); + } + }); + + this._parent = tparent; + } + + /** + * Creates new form FrmPolylineSymbolSet + * @param parent + * @param modal + * @param tparent + */ + public FrmPolylineSymbolSet(java.awt.Frame parent, boolean modal, Object tparent) { + super(parent, modal); + initComponents(); + + this.setTitle("Polyline Symbol Set"); + if (tparent.getClass() == LegendView.class){ + this.jButton_Apply.setVisible(false); + this.jButton_OK.setVisible(false); + this.setPreferredSize(new Dimension(this.getWidth(), this.getHeight() - 40)); + } + + this.symbolControl1.addSelectedCellChangedListener(new ISelectedCellChangedListener() { + @Override + public void selectedCellChangedEvent(SelectedCellChangedEvent event) { + onSelectedCellChanged(event); + } + }); + + this._parent = tparent; + } + + private void onSelectedCellChanged(SelectedCellChangedEvent event) { + if (isLoading) { + return; + } + + _polylineBreak.setStyle(LineStyles.values()[symbolControl1.getSelectedCell()]); + if (_parent.getClass() == LegendView.class) { + ((LegendView) _parent).setLegendBreak_PolylineStyle(_polylineBreak.getStyle()); + } + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + symbolControl1 = new SymbolControl(); + jLabel1 = new javax.swing.JLabel(); + jSpinner_Size = new javax.swing.JSpinner(); + jLabel2 = new javax.swing.JLabel(); + jLabel_Color = new javax.swing.JLabel(); + jCheckBox_DrawShape = new javax.swing.JCheckBox(); + jCheckBox_DrawPointSymbol = new javax.swing.JCheckBox(); + jPanel1 = new javax.swing.JPanel(); + jLabel3 = new javax.swing.JLabel(); + jSpinner_SymbolSize = new javax.swing.JSpinner(); + jLabel4 = new javax.swing.JLabel(); + jLabel_SymbolColor = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + jSpinner_SymbolInterval = new javax.swing.JSpinner(); + jComboBox_SymbolStyle = new javax.swing.JComboBox(); + jCheckBox_DrawFill = new javax.swing.JCheckBox(); + jLabel6 = new javax.swing.JLabel(); + jLabel_FillColor = new javax.swing.JLabel(); + jButton_Apply = new javax.swing.JButton(); + jButton_OK = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setResizable(false); + + symbolControl1.setCellSize(new Dimension(50, 40)); + symbolControl1.setPreferredSize(new Dimension(200, 50)); + symbolControl1.setShapeType(org.meteoinfo.geometry.shape.ShapeTypes.Polyline); + + jLabel1.setText("Size:"); + + jSpinner_Size.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(1.0f), Float.valueOf(1.0f), Float.valueOf(100.0f), Float.valueOf(0.5f))); + jSpinner_Size.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + jSpinner_SizeStateChanged(evt); + } + }); + + jLabel2.setText("Color:"); + + jLabel_Color.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + jLabel_Color.setOpaque(true); + jLabel_Color.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jLabel_ColorMouseClicked(evt); + } + }); + + jCheckBox_DrawShape.setText("Draw Shape"); + jCheckBox_DrawShape.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jCheckBox_DrawShapeActionPerformed(evt); + } + }); + + jCheckBox_DrawPointSymbol.setText("Draw Point Symbol"); + jCheckBox_DrawPointSymbol.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jCheckBox_DrawPointSymbolActionPerformed(evt); + } + }); + + jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Point Symbol")); + jPanel1.setToolTipText("Outline"); + jPanel1.setName("Outline"); // NOI18N + + jLabel3.setText("Size:"); + + jSpinner_SymbolSize.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(1.0f), Float.valueOf(1.0f), Float.valueOf(100.0f), Float.valueOf(0.5f))); + jSpinner_SymbolSize.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + jSpinner_SymbolSizeStateChanged(evt); + } + }); + + jLabel4.setText("Outline Color:"); + + jLabel_SymbolColor.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + jLabel_SymbolColor.setOpaque(true); + jLabel_SymbolColor.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jLabel_SymbolColorMouseClicked(evt); + } + }); + + jLabel5.setText("Interval:"); + + jSpinner_SymbolInterval.setModel(new javax.swing.SpinnerNumberModel(1, 1, 100, 1)); + jSpinner_SymbolInterval.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + jSpinner_SymbolIntervalStateChanged(evt); + } + }); + + jComboBox_SymbolStyle.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + jComboBox_SymbolStyle.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jComboBox_SymbolStyleActionPerformed(evt); + } + }); + + jCheckBox_DrawFill.setText("Draw Fill"); + jCheckBox_DrawFill.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jCheckBox_DrawFillActionPerformed(evt); + } + }); + + jLabel6.setText("Fill Color:"); + + jLabel_FillColor.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + jLabel_FillColor.setOpaque(true); + jLabel_FillColor.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jLabel_FillColorMouseClicked(evt); + } + }); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jComboBox_SymbolStyle, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addGap(0, 5, Short.MAX_VALUE) + .addComponent(jLabel3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jSpinner_SymbolSize, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jCheckBox_DrawFill))) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addComponent(jLabel5) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jSpinner_SymbolInterval, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addComponent(jLabel4) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel_SymbolColor, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addComponent(jLabel6) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel_FillColor, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel_SymbolColor, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(jSpinner_SymbolSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4))) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jCheckBox_DrawFill) + .addComponent(jLabel6)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel_FillColor, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(2, 2, 2))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel5) + .addComponent(jSpinner_SymbolInterval, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jComboBox_SymbolStyle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + jButton_Apply.setText("Apply"); + jButton_Apply.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton_ApplyActionPerformed(evt); + } + }); + + jButton_OK.setText("OK"); + jButton_OK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton_OKActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(symbolControl1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGap(31, 31, 31) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jSpinner_Size, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jCheckBox_DrawShape)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel_Color, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jCheckBox_DrawPointSymbol)))) + .addContainerGap()) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jButton_OK, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(58, 58, 58) + .addComponent(jButton_Apply, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(52, 52, 52)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(symbolControl1, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1) + .addComponent(jSpinner_Size, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jCheckBox_DrawShape)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel2) + .addComponent(jLabel_Color, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jCheckBox_DrawPointSymbol))) + .addGap(18, 18, 18) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jButton_Apply) + .addComponent(jButton_OK, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + private void jSpinner_SizeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner_SizeStateChanged + // TODO add your handling code here: + float size = Float.parseFloat(this.jSpinner_Size.getValue().toString()); + _polylineBreak.setWidth(size); + if (_parent.getClass() == LegendView.class) { + ((LegendView) _parent).setLegendBreak_Size(size); + } + }//GEN-LAST:event_jSpinner_SizeStateChanged + + private void jLabel_ColorMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel_ColorMouseClicked + // TODO add your handling code here: + Color aColor = JColorChooser.showDialog(rootPane, null, this.jLabel_Color.getBackground()); + this.jLabel_Color.setBackground(aColor); + _polylineBreak.setColor(aColor); + if (_parent.getClass() == LegendView.class) { + ((LegendView) _parent).setLegendBreak_Color(aColor); + } + }//GEN-LAST:event_jLabel_ColorMouseClicked + + private void jCheckBox_DrawShapeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox_DrawShapeActionPerformed + // TODO add your handling code here: + _polylineBreak.setDrawShape(this.jCheckBox_DrawShape.isSelected()); + if (_parent.getClass() == LegendView.class) { + ((LegendView) _parent).setLegendBreak_DrawShape(this.jCheckBox_DrawShape.isSelected()); + } + }//GEN-LAST:event_jCheckBox_DrawShapeActionPerformed + + private void jCheckBox_DrawPointSymbolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox_DrawPointSymbolActionPerformed + // TODO add your handling code here: + _polylineBreak.setDrawSymbol(this.jCheckBox_DrawPointSymbol.isSelected()); + if (_parent.getClass() == LegendView.class) { + ((LegendView) _parent).setLegendBreak_DrawSymbol(this.jCheckBox_DrawPointSymbol.isSelected()); + } + }//GEN-LAST:event_jCheckBox_DrawPointSymbolActionPerformed + + private void jSpinner_SymbolSizeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner_SymbolSizeStateChanged + // TODO add your handling code here: + float size = Float.parseFloat(this.jSpinner_SymbolSize.getValue().toString()); + _polylineBreak.setSymbolSize(size); + if (_parent.getClass() == LegendView.class) { + ((LegendView) _parent).setLegendBreak_SymbolSize(size); + } + }//GEN-LAST:event_jSpinner_SymbolSizeStateChanged + + private void jLabel_SymbolColorMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel_SymbolColorMouseClicked + // TODO add your handling code here: + Color aColor = JColorChooser.showDialog(rootPane, null, this.jLabel_SymbolColor.getBackground()); + this.jLabel_SymbolColor.setBackground(aColor); + _polylineBreak.setSymbolColor(aColor); + if (_parent.getClass() == LegendView.class) { + ((LegendView) _parent).setLegendBreak_SymbolColor(aColor); + } + }//GEN-LAST:event_jLabel_SymbolColorMouseClicked + + private void jSpinner_SymbolIntervalStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner_SymbolIntervalStateChanged + // TODO add your handling code here: + int interval = Integer.parseInt(this.jSpinner_SymbolInterval.getValue().toString()); + _polylineBreak.setSymbolInterval(interval); + if (_parent.getClass() == LegendView.class) { + ((LegendView) _parent).setLegendBreak_SymbolInterval(interval); + } + }//GEN-LAST:event_jSpinner_SymbolIntervalStateChanged + + private void jComboBox_SymbolStyleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox_SymbolStyleActionPerformed + // TODO add your handling code here: + if (isLoading){ + return; + } + + _polylineBreak.setSymbolStyle(PointStyle.valueOf(this.jComboBox_SymbolStyle.getSelectedItem().toString())); + if (_parent.getClass() == LegendView.class) { + ((LegendView)_parent).setLegendBreak_SymbolStyle(_polylineBreak.getSymbolStyle()); + } + }//GEN-LAST:event_jComboBox_SymbolStyleActionPerformed + + private void jButton_ApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_ApplyActionPerformed + // TODO add your handling code here: + if (_parent.getClass() == MapView.class) { + ((MapView) _parent).paintLayers(); + } else if (_parent.getClass() == MapLayout.class) { + ((MapLayout) _parent).paintGraphics(); + } + }//GEN-LAST:event_jButton_ApplyActionPerformed + + private void jButton_OKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_OKActionPerformed + // TODO add your handling code here: + if (_parent.getClass() == MapView.class) { + ((MapView) _parent).setDefPolylineBreak(_polylineBreak); + ((MapView) _parent).paintLayers(); + } else if (_parent.getClass() == MapLayout.class) { + ((MapLayout) _parent).setDefPolylineBreak(_polylineBreak); + ((MapLayout) _parent).paintGraphics(); + } + + this.dispose(); + }//GEN-LAST:event_jButton_OKActionPerformed + + private void jCheckBox_DrawFillActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox_DrawFillActionPerformed + // TODO add your handling code here: + _polylineBreak.setFillSymbol(this.jCheckBox_DrawFill.isSelected()); + if (_parent.getClass() == LegendView.class) { + //((LegendView) _parent).setLegendBreak_DrawFill(this.jCheckBox_DrawFill.isSelected()); + ((LegendView) _parent).repaint(); + } + }//GEN-LAST:event_jCheckBox_DrawFillActionPerformed + + private void jLabel_FillColorMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel_FillColorMouseClicked + // TODO add your handling code here: + Color c = JColorChooser.showDialog(rootPane, null, this.jLabel_FillColor.getBackground()); + if (c == null) + return; + + Color aColor = new Color(c.getRed(), c.getGreen(), c.getBlue()); + this.jLabel_FillColor.setBackground(aColor); + _polylineBreak.setSymbolFillColor(aColor); + if (_parent.getClass() == LegendView.class) { + //((LegendView) _parent).setLegendBreak_Color(aColor); + ((LegendView) _parent).repaint(); + } + }//GEN-LAST:event_jLabel_FillColorMouseClicked + + /** + * Set polyline break + * + * @param plb The polyline break + */ + public void setPolylineBreak(PolylineBreak plb) { + _polylineBreak = plb; + updateProperties(); + } + + private void updateProperties() { + isLoading = true; + + this.jLabel_Color.setBackground(_polylineBreak.getColor()); + this.jSpinner_Size.setValue(_polylineBreak.getWidth()); + this.jCheckBox_DrawShape.setSelected(_polylineBreak.isDrawShape()); + this.jCheckBox_DrawPointSymbol.setSelected(_polylineBreak.getDrawSymbol()); + this.jSpinner_SymbolSize.setValue(_polylineBreak.getSymbolSize()); + this.jLabel_SymbolColor.setBackground(_polylineBreak.getSymbolColor()); + this.jSpinner_SymbolInterval.setValue(_polylineBreak.getSymbolInterval()); + this.jComboBox_SymbolStyle.removeAllItems(); + for (PointStyle sName : PointStyle.values()) { + this.jComboBox_SymbolStyle.addItem(sName); + } + this.jComboBox_SymbolStyle.setSelectedItem(_polylineBreak.getSymbolStyle()); + this.jCheckBox_DrawFill.setSelected(_polylineBreak.isFillSymbol()); + this.jLabel_FillColor.setBackground(_polylineBreak.getSymbolFillColor()); + + //symbolControl1.setSymbolNumber(LineStyles.values().length); + if (_parent.getClass() == LegendView.class) { + symbolControl1.setSymbolNumber(5); + } else { + symbolControl1.setSymbolNumber(LineStyles.values().length); + } + + symbolControl1.setSelectedCell(Arrays.asList(LineStyles.values()).indexOf(_polylineBreak.getStyle())); + + isLoading = false; + } + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(FrmPolylineSymbolSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(FrmPolylineSymbolSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(FrmPolylineSymbolSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(FrmPolylineSymbolSet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the dialog */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + FrmPolylineSymbolSet dialog = new FrmPolylineSymbolSet(new javax.swing.JFrame(), true); + dialog.addWindowListener(new java.awt.event.WindowAdapter() { + @Override + public void windowClosing(java.awt.event.WindowEvent e) { + System.exit(0); + } + }); + dialog.setVisible(true); + } + }); + } + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton_Apply; + private javax.swing.JButton jButton_OK; + private javax.swing.JCheckBox jCheckBox_DrawFill; + private javax.swing.JCheckBox jCheckBox_DrawPointSymbol; + private javax.swing.JCheckBox jCheckBox_DrawShape; + private javax.swing.JComboBox jComboBox_SymbolStyle; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel_Color; + private javax.swing.JLabel jLabel_FillColor; + private javax.swing.JLabel jLabel_SymbolColor; + private javax.swing.JPanel jPanel1; + private javax.swing.JSpinner jSpinner_Size; + private javax.swing.JSpinner jSpinner_SymbolInterval; + private javax.swing.JSpinner jSpinner_SymbolSize; + private SymbolControl symbolControl1; + // End of variables declaration//GEN-END:variables + } diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/GridLabelPosition.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/GridLabelPosition.java similarity index 92% rename from MeteoInfoLib/src/main/java/org/meteoinfo/legend/GridLabelPosition.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/GridLabelPosition.java index 1d64e8e7..e7572417 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/GridLabelPosition.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/GridLabelPosition.java @@ -1,27 +1,27 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.legend; - -/** - * - * @author yaqiang - */ -public enum GridLabelPosition { - - LEFT_BOTTOM, - LEFT_UP, - RIGHT_BOTTOM, - RIGHT_UP, - ALL -} + /* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.legend; + +/** + * + * @author yaqiang + */ +public enum GridLabelPosition { + + LEFT_BOTTOM, + LEFT_UP, + RIGHT_BOTTOM, + RIGHT_UP, + ALL +} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/GroupNode.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/GroupNode.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/legend/GroupNode.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/GroupNode.java index 8c0d9886..a47e110d 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/GroupNode.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/GroupNode.java @@ -11,7 +11,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.legend; +package org.meteoinfo.geo.legend; import com.l2fprod.common.beans.BaseBeanInfo; import org.meteoinfo.geometry.legend.Constants; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/ItemNode.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/ItemNode.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/legend/ItemNode.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/ItemNode.java index a49eb4dc..291c7931 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/ItemNode.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/ItemNode.java @@ -11,7 +11,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.legend; +package org.meteoinfo.geo.legend; import org.meteoinfo.geometry.legend.Constants; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/LayerNode.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/LayerNode.java similarity index 97% rename from MeteoInfoLib/src/main/java/org/meteoinfo/legend/LayerNode.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/LayerNode.java index 68189940..5a348d60 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/LayerNode.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/LayerNode.java @@ -11,14 +11,14 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.legend; +package org.meteoinfo.geo.legend; import org.meteoinfo.geometry.legend.ChartBreak; import org.meteoinfo.geometry.legend.Constants; import org.meteoinfo.geometry.legend.LegendScheme; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layer.VectorLayer; +import org.meteoinfo.geo.layer.LayerTypes; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.layer.VectorLayer; import org.meteoinfo.geometry.shape.ShapeTypes; import java.util.ArrayList; import java.util.List; @@ -241,7 +241,7 @@ public class LayerNode extends ItemNode { * Clone * * @return LayerNode object - * @throws java.lang.CloneNotSupportedException + * @throws CloneNotSupportedException */ @Override public Object clone() throws CloneNotSupportedException { diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/LayersLegend.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/LayersLegend.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/legend/LayersLegend.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/LayersLegend.java index 7def880d..12480631 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/LayersLegend.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/LayersLegend.java @@ -11,14 +11,14 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.legend; +package org.meteoinfo.geo.legend; import com.formdev.flatlaf.extras.FlatSVGIcon; import org.meteoinfo.common.Extent; import org.meteoinfo.common.GenericFileFilter; import org.meteoinfo.common.PointF; -import org.meteoinfo.data.mapdata.MapDataManage; -import org.meteoinfo.drawing.Draw; +import org.meteoinfo.geo.mapdata.MapDataManage; +import org.meteoinfo.geo.drawing.Draw; import org.meteoinfo.geometry.legend.*; import org.meteoinfo.ui.event.ActiveMapFrameChangedEvent; import org.meteoinfo.ui.event.IActiveMapFrameChangedListener; @@ -26,11 +26,11 @@ import org.meteoinfo.ui.event.ILayersUpdatedListener; import org.meteoinfo.ui.event.IMapFramesUpdatedListener; import org.meteoinfo.ui.event.LayersUpdatedEvent; import org.meteoinfo.ui.event.MapFramesUpdatedEvent; -import org.meteoinfo.layer.FrmLayerProperty; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.layout.MapLayout; +import org.meteoinfo.geo.layer.FrmLayerProperty; +import org.meteoinfo.geo.layer.LayerTypes; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.layer.VectorLayer; +import org.meteoinfo.geo.layout.MapLayout; import java.awt.BasicStroke; import java.awt.BorderLayout; import java.awt.Color; @@ -64,15 +64,15 @@ import javax.swing.undo.UndoableEdit; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import org.meteoinfo.data.mapdata.FrmAttriData; +import org.meteoinfo.geo.mapdata.FrmAttriData; import org.meteoinfo.data.mapdata.webmap.WebMapProvider; -import org.meteoinfo.global.FrmProperty; +import org.meteoinfo.geo.gui.FrmProperty; import org.meteoinfo.ui.event.INodeSelectedListener; import org.meteoinfo.ui.event.NodeSelectedEvent; -import org.meteoinfo.layer.FrmLabelSet; -import org.meteoinfo.layer.WebMapLayer; -import org.meteoinfo.map.MapView; -import org.meteoinfo.map.MapViewUndoRedo; +import org.meteoinfo.geo.layer.FrmLabelSet; +import org.meteoinfo.geo.layer.WebMapLayer; +import org.meteoinfo.geo.mapview.MapView; +import org.meteoinfo.geo.mapview.MapViewUndoRedo; import org.meteoinfo.projection.ProjectionInfo; import org.meteoinfo.projection.ProjectionNames; import org.w3c.dom.Document; @@ -1780,9 +1780,9 @@ public class LayersLegend extends JPanel { * Import project XML content * * @param fileName XML file name - * @throws org.xml.sax.SAXException - * @throws java.io.IOException - * @throws javax.xml.parsers.ParserConfigurationException + * @throws SAXException + * @throws IOException + * @throws ParserConfigurationException */ public void importProjectXML(String fileName) throws SAXException, IOException, ParserConfigurationException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/LegendManage.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/LegendManage.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/legend/LegendManage.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/LegendManage.java index 2ebccee6..57308835 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/LegendManage.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/LegendManage.java @@ -11,14 +11,14 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.legend; +package org.meteoinfo.geo.legend; import org.meteoinfo.common.DataConvert; import org.meteoinfo.common.MIMath; import org.meteoinfo.data.GridArray; import org.meteoinfo.data.GridData; import org.meteoinfo.data.StationData; -import org.meteoinfo.drawing.ContourDraw; +import org.meteoinfo.geo.drawing.ContourDraw; import org.meteoinfo.geometry.legend.*; import org.meteoinfo.ndarray.util.BigDecimalUtil; import org.meteoinfo.geometry.shape.ShapeTypes; @@ -31,7 +31,7 @@ import java.util.List; import java.util.Random; import org.meteoinfo.common.colors.ColorMap; -import org.meteoinfo.layer.VectorLayer; +import org.meteoinfo.geo.layer.VectorLayer; import org.meteoinfo.geometry.shape.PointShape; import org.meteoinfo.geometry.shape.PolygonShape; import org.meteoinfo.geometry.shape.PolylineShape; @@ -1358,7 +1358,7 @@ public class LegendManage { * @param n Level number * @param ct Color table name * @return LegendScheme - * @throws java.io.IOException + * @throws IOException */ public static LegendScheme createLegendScheme(GridData gdata, int n, ColorMap ct) throws IOException { if (ct != null) { diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/LegendNode.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/LegendNode.java new file mode 100644 index 00000000..4ea0ab5f --- /dev/null +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/LegendNode.java @@ -0,0 +1,95 @@ + /* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.legend; + +import org.meteoinfo.geometry.legend.ColorBreak; +import org.meteoinfo.geometry.shape.ShapeTypes; + + /** + * + * @author yaqiang + */ + public class LegendNode extends ItemNode { + // + + private ShapeTypes _shapeType; + private ColorBreak _legendBreak; + // + // + // + // + + /** + * Get shape type + * + * @return The shape type + */ + public ShapeTypes getShapeType() { + return _shapeType; + } + + /** + * Set shape type + * + * @param type The shape type + */ + public void setShapeType(ShapeTypes type) { + _shapeType = type; + } + + /** + * Get legend break + * + * @return The legend break + */ + public ColorBreak getLegendBreak() { + return _legendBreak; + } + + /** + * Set legend break + * + * @param aCB The legend break + */ + public void setLegendBreak(ColorBreak aCB) { + _legendBreak = aCB; + } + // + // + + /** + * Clone + * + * @return LegendNode object + */ + @Override + public Object clone() { + LegendNode aLN = new LegendNode(); + aLN.setShapeType(_shapeType); + aLN.setLegendBreak(_legendBreak); + + return aLN; + } + + @Override + public int getDrawHeight() { + return this.getHeight(); + } + + @Override + public int getExpandedHeight() { + return this.getHeight(); + } + // + } diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/LegendSchemeControl.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/LegendSchemeControl.java new file mode 100644 index 00000000..fa1401cb --- /dev/null +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/LegendSchemeControl.java @@ -0,0 +1,67 @@ + /* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.legend; + +import org.meteoinfo.geometry.legend.LegendScheme; +import org.meteoinfo.geo.gui.FrmProperty; +import org.meteoinfo.geo.layer.MapLayer; +import javax.swing.JPanel; + + /** + * + * @author Yaqiang Wang + */ + public class LegendSchemeControl extends JPanel { + // + + public FrmProperty m_FrmSS = null; + private MapLayer _mapLayer; + //Form m_FrmMeteoData = new Form(); + LegendScheme _legendScheme = null; + LayersLegend m_LayersTV = new LayersLegend(); + boolean m_IfFrmMeteoData = false; + boolean _ifCreateLegendScheme = false; + // + // + + /** + * Constructor + */ + public LegendSchemeControl() { + initComponents(); + } + + /** + * Constructor + * + * @param ifFrmMeteoData If is from meteo data + * @param mapLayer The map layer + * @param aLayersTV The layersLegend + */ + public LegendSchemeControl(boolean ifFrmMeteoData, MapLayer mapLayer, LayersLegend aLayersTV) { + initComponents(); + + m_IfFrmMeteoData = ifFrmMeteoData; + _mapLayer = mapLayer; + m_LayersTV = aLayersTV; + } + + private void initComponents() { + } + // + // + // + // + // + } diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/LegendView.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/LegendView.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/legend/LegendView.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/LegendView.java index 328c2afb..a01a3a1b 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/LegendView.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/LegendView.java @@ -11,11 +11,11 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.legend; +package org.meteoinfo.geo.legend; import org.meteoinfo.common.MIMath; import org.meteoinfo.common.PointF; -import org.meteoinfo.drawing.Draw; +import org.meteoinfo.geo.drawing.Draw; import org.meteoinfo.geometry.legend.*; import java.awt.BorderLayout; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/MapFrame.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/MapFrame.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/legend/MapFrame.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/MapFrame.java index 1abdd924..83413a65 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/MapFrame.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/MapFrame.java @@ -11,7 +11,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.legend; +package org.meteoinfo.geo.legend; import com.l2fprod.common.beans.BaseBeanInfo; import org.meteoinfo.common.colors.ColorUtil; @@ -26,11 +26,11 @@ import org.meteoinfo.ui.event.LayersUpdatedEvent; import org.meteoinfo.ui.event.LayoutBoundsChangedEvent; import org.meteoinfo.ui.event.MapViewUpdatedEvent; import org.meteoinfo.ui.event.ViewExtentChangedEvent; -import org.meteoinfo.layer.ImageLayer; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.map.MapView; +import org.meteoinfo.geo.layer.ImageLayer; +import org.meteoinfo.geo.layer.LayerTypes; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.layer.VectorLayer; +import org.meteoinfo.geo.mapview.MapView; import java.awt.Color; import java.awt.Font; import java.awt.Rectangle; @@ -41,9 +41,9 @@ import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; import javax.swing.event.EventListenerList; -import static org.meteoinfo.layer.LayerTypes.WebMapLayer; -import org.meteoinfo.layer.RasterLayer; -import org.meteoinfo.layer.WebMapLayer; + +import org.meteoinfo.geo.layer.RasterLayer; +import org.meteoinfo.geo.layer.WebMapLayer; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/NodeTypes.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/NodeTypes.java similarity index 92% rename from MeteoInfoLib/src/main/java/org/meteoinfo/legend/NodeTypes.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/NodeTypes.java index 84005f4c..57a7f975 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/NodeTypes.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/NodeTypes.java @@ -1,25 +1,25 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.legend; - -/** - * - * @author yaqiang - */ -public enum NodeTypes { - - LayerNode, - MapFrameNode, - GroupNode -} +/* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.legend; + +/** + * + * @author yaqiang + */ +public enum NodeTypes { + + LayerNode, + MapFrameNode, + GroupNode +} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/SymbolControl.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/SymbolControl.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/legend/SymbolControl.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/SymbolControl.java index a9b410be..e83f9740 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/SymbolControl.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/SymbolControl.java @@ -11,10 +11,10 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.legend; +package org.meteoinfo.geo.legend; import org.meteoinfo.common.PointF; -import org.meteoinfo.drawing.Draw; +import org.meteoinfo.geo.drawing.Draw; import org.meteoinfo.geometry.legend.*; import org.meteoinfo.ui.event.ISelectedCellChangedListener; import org.meteoinfo.ui.event.SelectedCellChangedEvent; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/Test.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/Test.java similarity index 90% rename from MeteoInfoLib/src/main/java/org/meteoinfo/legend/Test.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/Test.java index 6643f8b1..7c2f242e 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/legend/Test.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/legend/Test.java @@ -1,34 +1,34 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.legend; - -import java.awt.Graphics; -import javax.swing.JPanel; - -/** - * - * @author User - */ -public class Test extends JPanel { - private boolean isOk = false; - public Test(){ - isOk = false; - } - - public boolean getIsOK(){ - return isOk; - } - - public void setIsOK(boolean istrue){ - isOk = istrue; - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - - g.drawString("Test", 20, 20); - } -} +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.meteoinfo.geo.legend; + +import java.awt.Graphics; +import javax.swing.JPanel; + +/** + * + * @author User + */ +public class Test extends JPanel { + private boolean isOk = false; + public Test(){ + isOk = false; + } + + public boolean getIsOK(){ + return isOk; + } + + public void setIsOK(boolean istrue){ + isOk = istrue; + } + + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + + g.drawString("Test", 20, 20); + } +} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/data/mapdata/FrmAddField.form b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapdata/FrmAddField.form similarity index 100% rename from MeteoInfoLib/src/main/java/org/meteoinfo/data/mapdata/FrmAddField.form rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapdata/FrmAddField.form diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/data/mapdata/FrmAddField.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapdata/FrmAddField.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/data/mapdata/FrmAddField.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapdata/FrmAddField.java index 5177cc82..390cae60 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/data/mapdata/FrmAddField.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapdata/FrmAddField.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.data.mapdata; +package org.meteoinfo.geo.mapdata; import org.meteoinfo.ndarray.DataType; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/data/mapdata/FrmAttriData.form b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapdata/FrmAttriData.form similarity index 100% rename from MeteoInfoLib/src/main/java/org/meteoinfo/data/mapdata/FrmAttriData.form rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapdata/FrmAttriData.form diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapdata/FrmAttriData.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapdata/FrmAttriData.java new file mode 100644 index 00000000..996112a8 --- /dev/null +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapdata/FrmAttriData.java @@ -0,0 +1,414 @@ + /* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.mapdata; + + import com.formdev.flatlaf.extras.FlatSVGUtils; + import org.meteoinfo.geo.layer.VectorLayer; + import org.meteoinfo.ndarray.DataType; + import org.meteoinfo.table.*; + + import javax.swing.*; + import javax.swing.table.JTableHeader; + import java.awt.event.MouseAdapter; + import java.awt.event.MouseEvent; + import java.io.File; + import java.util.List; + import java.util.logging.Level; + import java.util.logging.Logger; + + /** + * + * @author Yaqiang Wang + */ + public class FrmAttriData extends JFrame { + + private VectorLayer _layer; + private DataTable _dataTable; + private boolean _isEditing = false; + + /** + * Creates new form FrmAttriData + */ + public FrmAttriData() { + initComponents(); + + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + this.setIconImages(FlatSVGUtils.createWindowIconImages("/org/meteoinfo/icons/table.svg")); + + //this.jTable1.setColumnSelectionAllowed(true); + //this.jTable1.setRowSelectionAllowed(false); + final JTableHeader header = this.jTable1.getTableHeader(); + header.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + + if (!e.isShiftDown()) { + jTable1.clearSelection(); + } + + //Get column index of the mouse point + int pick = header.columnAtPoint(e.getPoint()); + + //set select model + //jTable1.addColumnSelectionInterval(pick, pick); + jTable1.setColumnSelectionAllowed(true); + jTable1.setRowSelectionAllowed(false); + jTable1.setColumnSelectionInterval(pick, pick); + + if (_isEditing) { + jMenuItem_RemoveField.setEnabled(true); + jMenuItem_RenameField.setEnabled(true); + } + } + }); + this.jTable1.setDefaultEditor(Object.class, new MyCellEditor()); + this.jTable1.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + jTable1.clearSelection(); + int pick = jTable1.rowAtPoint(e.getPoint()); + jTable1.setColumnSelectionAllowed(false); + jTable1.setRowSelectionAllowed(true); + jTable1.setRowSelectionInterval(pick, pick); + + if (jMenuItem_RemoveField.isEnabled()) { + jMenuItem_RemoveField.setEnabled(false); + } + if (jMenuItem_RenameField.isEnabled()) { + jMenuItem_RenameField.setEnabled(false); + } + } + }); + + this.jMenuItem_AddField.setEnabled(false); + this.jMenuItem_RemoveField.setEnabled(false); + this.jMenuItem_RenameField.setEnabled(false); + this.jMenuItem_StopEdit.setEnabled(false); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jScrollPane1 = new JScrollPane(); + jTable1 = new JTable(); + jMenuBar1 = new JMenuBar(); + jMenu_Edit = new JMenu(); + jMenuItem_StartEdit = new JMenuItem(); + jMenuItem_StopEdit = new JMenuItem(); + jSeparator1 = new JPopupMenu.Separator(); + jMenuItem_AddField = new JMenuItem(); + jMenuItem_RemoveField = new JMenuItem(); + jMenuItem_RenameField = new JMenuItem(); + + setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + + jTable1.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null} + }, + new String [] { + "Title 1", "Title 2", "Title 3", "Title 4" + } + )); + jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + jScrollPane1.setViewportView(jTable1); + + jMenu_Edit.setText("Edit"); + + jMenuItem_StartEdit.setText("Start Edit"); + jMenuItem_StartEdit.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem_StartEditActionPerformed(evt); + } + }); + jMenu_Edit.add(jMenuItem_StartEdit); + + jMenuItem_StopEdit.setText("Stop Edit"); + jMenuItem_StopEdit.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem_StopEditActionPerformed(evt); + } + }); + jMenu_Edit.add(jMenuItem_StopEdit); + jMenu_Edit.add(jSeparator1); + + jMenuItem_AddField.setText("Add Field"); + jMenuItem_AddField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem_AddFieldActionPerformed(evt); + } + }); + jMenu_Edit.add(jMenuItem_AddField); + + jMenuItem_RemoveField.setText("Remove Field"); + jMenuItem_RemoveField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem_RemoveFieldActionPerformed(evt); + } + }); + jMenu_Edit.add(jMenuItem_RemoveField); + + jMenuItem_RenameField.setText("Rename Field"); + jMenuItem_RenameField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem_RenameFieldActionPerformed(evt); + } + }); + jMenu_Edit.add(jMenuItem_RenameField); + + jMenuBar1.add(jMenu_Edit); + + setJMenuBar(jMenuBar1); + + GroupLayout layout = new GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 580, Short.MAX_VALUE) + .addGap(0, 0, 0)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE) + .addGap(0, 0, 0)) + ); + + pack(); + }// //GEN-END:initComponents + + private void jMenuItem_StartEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_StartEditActionPerformed + // TODO add your handling code here: + this.jMenuItem_StartEdit.setEnabled(false); + this.jMenuItem_AddField.setEnabled(true); + this.jMenuItem_StopEdit.setEnabled(true); + if (this.jTable1.getSelectedColumnCount() > 0) { + this.jMenuItem_RemoveField.setEnabled(true); + this.jMenuItem_RenameField.setEnabled(true); + } + this._isEditing = true; + + DataTableModel dataTableModel = new DataTableModel(_dataTable) { + @Override + public boolean isCellEditable(int row, int column) { + return true; + } + }; + this.jTable1.setModel(dataTableModel); + }//GEN-LAST:event_jMenuItem_StartEditActionPerformed + + private void jMenuItem_StopEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_StopEditActionPerformed + // TODO add your handling code here: + this.jMenuItem_StartEdit.setEnabled(true); + this.jMenuItem_AddField.setEnabled(false); + this.jMenuItem_RemoveField.setEnabled(false); + this.jMenuItem_RenameField.setEnabled(false); + this.jMenuItem_StopEdit.setEnabled(false); + this._isEditing = false; + + int result = JOptionPane.showConfirmDialog(null, "If save the edition?", "Confirm", JOptionPane.YES_NO_OPTION); + if (result == JOptionPane.YES_OPTION) { + this.saveDataTable(); + } else { + _dataTable = _layer.getAttributeTable().getTable().cloneTable_Field(); + } + + DataTableModel dataTableModel = new DataTableModel(_dataTable) { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }; + this.jTable1.setModel(dataTableModel); + }//GEN-LAST:event_jMenuItem_StopEditActionPerformed + + private void jMenuItem_AddFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_AddFieldActionPerformed + // TODO add your handling code here: + FrmAddField frmField = new FrmAddField(null, true); + frmField.setLocationRelativeTo(this); + frmField.setVisible(true); + if (frmField.isOK()) { + String fieldName = frmField.getFieldName(); + if (fieldName.isEmpty()) { + JOptionPane.showMessageDialog(null, "Field name is empty!"); + return; + } + List fieldNames = _layer.getFieldNames(); + if (fieldNames.contains(fieldName)) { + JOptionPane.showMessageDialog(null, "Field name has exist in the data table!"); + return; + } + DataType dataType = frmField.getDataType(); + try { + _dataTable.addColumn(new Field(fieldName, dataType)); + //this.jTable1.revalidate(); + DataTableModel dataTableModel = new DataTableModel(_dataTable) { + @Override + public boolean isCellEditable(int row, int column) { + return true; + } + }; + this.jTable1.setModel(dataTableModel); + } catch (Exception ex) { + Logger.getLogger(FrmAttriData.class.getName()).log(Level.SEVERE, null, ex); + } + } + }//GEN-LAST:event_jMenuItem_AddFieldActionPerformed + + private void jMenuItem_RemoveFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_RemoveFieldActionPerformed + // TODO add your handling code here: + if (this.jTable1.getSelectedColumnCount() == 0) { + JOptionPane.showMessageDialog(null, "Please select one field firstly!"); + return; + } + + int fieldIdx = this.jTable1.getSelectedColumn(); + String fieldName = this.jTable1.getColumnName(fieldIdx); + int result = JOptionPane.showConfirmDialog(null, "If remove the field: " + fieldName + "?", "Confirm", + JOptionPane.YES_NO_OPTION); + if (result == JOptionPane.YES_OPTION) { + _dataTable.removeColumn(_dataTable.getColumns().get(fieldName)); + DataTableModel dataTableModel = new DataTableModel(_dataTable) { + @Override + public boolean isCellEditable(int row, int column) { + return true; + } + }; + this.jTable1.setModel(dataTableModel); + } + }//GEN-LAST:event_jMenuItem_RemoveFieldActionPerformed + + private void jMenuItem_RenameFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_RenameFieldActionPerformed + // TODO add your handling code here: + if (this.jTable1.getSelectedColumnCount() == 0) { + JOptionPane.showMessageDialog(null, "Please select one field firstly!"); + return; + } + + int fieldIdx = this.jTable1.getSelectedColumn(); + String fieldName = this.jTable1.getColumnName(fieldIdx); + String result = JOptionPane.showInputDialog(this, "Please input new field name:", fieldName); + if (result != null) { + if (result.isEmpty()){ + JOptionPane.showMessageDialog(null, "The field name is empty!"); + return; + } + List fieldNames = _dataTable.getColumnNames(); + if (fieldNames.contains(result)){ + JOptionPane.showMessageDialog(null, "The field name is exist!"); + return; + } + _dataTable.renameColumn(_dataTable.getColumns().get(fieldName), result); + DataTableModel dataTableModel = new DataTableModel(_dataTable) { + @Override + public boolean isCellEditable(int row, int column) { + return true; + } + }; + this.jTable1.setModel(dataTableModel); + } + }//GEN-LAST:event_jMenuItem_RenameFieldActionPerformed + + /** + * Set vector layer + * + * @param aLayer The vector layer + */ + public void setLayer(VectorLayer aLayer) { + _layer = aLayer; + _dataTable = _layer.getAttributeTable().getTable().cloneTable_Field(); + this.setTitle("Attribute Data - " + _layer.getLayerName()); + DataTableModel dataTableModel = new DataTableModel(_dataTable); + this.jTable1.setModel(dataTableModel); + this.jScrollPane1.setRowHeaderView(new RowHeaderTable(this.jTable1, 40)); + } + + private void saveDataTable() { + // for (int i = 0; i < _layer.getFieldNumber(); i++){ + // for (int j = 0; j < _layer.getShapeNum(); j++){ + // _layer.editCellValue(i, j, this.jTable1.getModel().getValueAt(j, i)); + // } + // } + + _layer.getAttributeTable().setTable(_dataTable.cloneTable_Field()); + if (new File(_layer.getFileName()).exists()) + _layer.getAttributeTable().save(); + else + _layer.saveFile(); + } + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + Logger.getLogger(FrmAttriData.class.getName()).log(Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + Logger.getLogger(FrmAttriData.class.getName()).log(Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + Logger.getLogger(FrmAttriData.class.getName()).log(Level.SEVERE, null, ex); + } catch (UnsupportedLookAndFeelException ex) { + Logger.getLogger(FrmAttriData.class.getName()).log(Level.SEVERE, null, ex); + } + // + + /* Create and display the dialog */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + FrmAttriData dialog = new FrmAttriData(); + dialog.addWindowListener(new java.awt.event.WindowAdapter() { + @Override + public void windowClosing(java.awt.event.WindowEvent e) { + System.exit(0); + } + }); + dialog.setVisible(true); + } + }); + } + // Variables declaration - do not modify//GEN-BEGIN:variables + private JMenuBar jMenuBar1; + private JMenuItem jMenuItem_AddField; + private JMenuItem jMenuItem_RemoveField; + private JMenuItem jMenuItem_RenameField; + private JMenuItem jMenuItem_StartEdit; + private JMenuItem jMenuItem_StopEdit; + private JMenu jMenu_Edit; + private JScrollPane jScrollPane1; + private JPopupMenu.Separator jSeparator1; + private JTable jTable1; + // End of variables declaration//GEN-END:variables + } diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/mapdata/MapDataManage.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapdata/MapDataManage.java similarity index 98% rename from meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/mapdata/MapDataManage.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapdata/MapDataManage.java index b539c7fd..e69c98f4 100644 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/data/mapdata/MapDataManage.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapdata/MapDataManage.java @@ -11,31 +11,32 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.geo.data.mapdata; +package org.meteoinfo.geo.mapdata; +import org.meteoinfo.common.DataConvert; import org.meteoinfo.common.Extent; import org.meteoinfo.common.PointD; import org.meteoinfo.common.io.IOUtil; import org.meteoinfo.common.util.GlobalUtil; -import org.meteoinfo.geo.data.GridArray; -import org.meteoinfo.geo.data.GridData; -import org.meteoinfo.geo.data.geotiff.GeoTiff; -//import org.meteoinfo.data.meteodata.DrawMeteoData; +import org.meteoinfo.data.GridArray; +import org.meteoinfo.data.GridData; +import org.meteoinfo.data.mapdata.MapDataType; +import org.meteoinfo.data.mapdata.geotiff.GeoTiff; import org.meteoinfo.data.meteodata.ascii.ASCIIGridDataInfo; import org.meteoinfo.data.meteodata.ascii.SurferGridDataInfo; import org.meteoinfo.data.meteodata.bandraster.BILDataInfo; -import org.meteoinfo.geometry.geoprocess.GeometryUtil; -import org.meteoinfo.common.DataConvert; import org.meteoinfo.geo.layer.*; -import org.meteoinfo.geo.util.LegendManage; +import org.meteoinfo.geo.legend.LegendManage; +import org.meteoinfo.geo.meteodata.DrawMeteoData; import org.meteoinfo.geometry.legend.LegendScheme; import org.meteoinfo.geometry.legend.LegendType; -import org.meteoinfo.ndarray.Array; -import org.meteoinfo.ndarray.DataType; -import org.meteoinfo.geo.projection.KnownCoordinateSystems; -import org.meteoinfo.geo.projection.info.ProjectionInfo; import org.meteoinfo.geometry.shape.Shape; import org.meteoinfo.geometry.shape.*; +import org.meteoinfo.geometry.geoprocess.GeometryUtil; +import org.meteoinfo.ndarray.Array; +import org.meteoinfo.ndarray.DataType; +import org.meteoinfo.projection.KnownCoordinateSystems; +import org.meteoinfo.projection.ProjectionInfo; import org.meteoinfo.table.Field; import javax.imageio.ImageIO; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/data/mapdata/ShapeFileManage.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapdata/ShapeFileManage.java similarity index 95% rename from MeteoInfoLib/src/main/java/org/meteoinfo/data/mapdata/ShapeFileManage.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapdata/ShapeFileManage.java index c0a65857..def3e02a 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/data/mapdata/ShapeFileManage.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapdata/ShapeFileManage.java @@ -11,47 +11,28 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.data.mapdata; +package org.meteoinfo.geo.mapdata; -import org.meteoinfo.common.Extent; -import org.meteoinfo.common.PointD; -import org.meteoinfo.common.io.EndianDataOutputStream; -import org.meteoinfo.layer.LayerDrawType; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.legend.LegendManage; -import org.meteoinfo.geometry.shape.PointShape; -import org.meteoinfo.geometry.shape.PointZ; -import org.meteoinfo.geometry.shape.PolygonShape; -import org.meteoinfo.geometry.shape.PolylineShape; -import org.meteoinfo.geometry.shape.PolylineZShape; -import org.meteoinfo.geometry.shape.Shape; -import org.meteoinfo.geometry.shape.ShapeTypes; -import java.awt.Color; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.DataInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.nio.Buffer; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.meteoinfo.projection.ProjectionInfo; -import org.meteoinfo.geometry.shape.PointM; -import org.meteoinfo.geometry.shape.PointZShape; -import org.meteoinfo.geometry.shape.PolygonMShape; -import org.meteoinfo.geometry.shape.PolygonZShape; -import org.meteoinfo.table.AttributeTable; + import org.meteoinfo.common.Extent; + import org.meteoinfo.common.PointD; + import org.meteoinfo.common.io.EndianDataOutputStream; + import org.meteoinfo.geo.layer.LayerDrawType; + import org.meteoinfo.geo.layer.VectorLayer; + import org.meteoinfo.geo.legend.LegendManage; + import org.meteoinfo.geometry.shape.Shape; + import org.meteoinfo.geometry.shape.*; + import org.meteoinfo.projection.ProjectionInfo; + import org.meteoinfo.table.AttributeTable; + + import java.awt.*; + import java.io.*; + import java.nio.Buffer; + import java.nio.ByteBuffer; + import java.nio.ByteOrder; + import java.util.ArrayList; + import java.util.List; + import java.util.logging.Level; + import java.util.logging.Logger; /** * Shape file read and write @@ -68,7 +49,7 @@ public class ShapeFileManage { * @param shpfilepath Shape file path * @return Vector layer * @throws IOException - * @throws java.io.FileNotFoundException + * @throws FileNotFoundException */ public static VectorLayer loadShapeFile(String shpfilepath) throws IOException, FileNotFoundException, Exception { String cpgfilepath = shpfilepath.replaceFirst(shpfilepath.substring(shpfilepath.lastIndexOf(".")), ".cpg"); @@ -90,7 +71,7 @@ public class ShapeFileManage { * @param encoding Encoding * @return Vector layer * @throws IOException - * @throws java.io.FileNotFoundException + * @throws FileNotFoundException */ public static VectorLayer loadShapeFile(String shpfilepath, String encoding) throws IOException, FileNotFoundException, Exception { //Set file names @@ -724,7 +705,7 @@ public class ShapeFileManage { * @param shpfilepath Shape file path * @param aLayer Vector layer * @return Boolean - * @throws java.io.IOException*/ + * @throws IOException*/ public static boolean saveShapeFile(String shpfilepath, VectorLayer aLayer) throws IOException { String shxfilepath = shpfilepath.replace(shpfilepath.substring(shpfilepath.lastIndexOf(".")), ".shx"); String dbffilepath = shpfilepath.replace(shpfilepath.substring(shpfilepath.lastIndexOf(".")), ".dbf"); @@ -754,7 +735,7 @@ public class ShapeFileManage { * @param aLayer Vector layer * @param encoding Encoding * @return Boolean - * @throws java.io.IOException*/ + * @throws IOException*/ public static boolean saveShapeFile(String shpfilepath, VectorLayer aLayer, String encoding) throws IOException { String shxfilepath = shpfilepath.replace(shpfilepath.substring(shpfilepath.lastIndexOf(".")), ".shx"); String dbffilepath = shpfilepath.replace(shpfilepath.substring(shpfilepath.lastIndexOf(".")), ".dbf"); diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/map/FeatureUndoableEdit.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/FeatureUndoableEdit.java similarity index 89% rename from MeteoInfoLib/src/main/java/org/meteoinfo/map/FeatureUndoableEdit.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/FeatureUndoableEdit.java index cb56b376..fd171f80 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/map/FeatureUndoableEdit.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/FeatureUndoableEdit.java @@ -1,18 +1,18 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.map; - -import javax.swing.undo.AbstractUndoableEdit; - -/** - * - * @author yaqiang - */ -public class FeatureUndoableEdit extends AbstractUndoableEdit{ - public boolean isFeatureEdit(){ - return true; - } -} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.meteoinfo.geo.mapview; + +import javax.swing.undo.AbstractUndoableEdit; + +/** + * + * @author yaqiang + */ +public class FeatureUndoableEdit extends AbstractUndoableEdit{ + public boolean isFeatureEdit(){ + return true; + } +} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/FrmIdentifer.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/FrmIdentifer.java new file mode 100644 index 00000000..6a6743d8 --- /dev/null +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/FrmIdentifer.java @@ -0,0 +1,174 @@ + /* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.mapview; + +import javax.swing.JTable; + + /** + * + * @author Yaqiang Wang + */ + public class FrmIdentifer extends javax.swing.JDialog { + + private MapView _mapView; + + /** + * Creates new form FrmIdentifer + */ + public FrmIdentifer(java.awt.Frame parent, boolean modal, MapView mapView) { + super(parent, modal); + _mapView = mapView; + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jScrollPane1 = new javax.swing.JScrollPane(); + jTable1 = new JTable(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosed(java.awt.event.WindowEvent evt) { + formWindowClosed(evt); + } + }); + + jTable1.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {null, null}, + {null, null}, + {null, null}, + {null, null} + }, + new String [] { + "Field", "Value" + } + ) { + Class[] types = new Class [] { + String.class, String.class + }; + + public Class getColumnClass(int columnIndex) { + return types [columnIndex]; + } + }); + jScrollPane1.setViewportView(jTable1); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 220, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 226, Short.MAX_VALUE) + ); + + pack(); + }// //GEN-END:initComponents + + private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed + // TODO add your handling code here: + // if (_mapView != null){ + // _mapView.setDrawIdentiferShape(false); + // _mapView.repaint(); + // } + }//GEN-LAST:event_formWindowClosed + + /** + * Set map view + * @return Map view + */ + public MapView getMapView(){ + return _mapView; + } + + /** + * Set map view + * @param mapView Map view + */ + public void setMapView(MapView mapView){ + _mapView = mapView; + } + + /** + * Get JTable + * @return JTable + */ + public JTable getTable(){ + return this.jTable1; + } + + /** + * Set JTable + * @param table JTable + */ + public void setTable(JTable table){ + this.jTable1 = table; + } + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(FrmIdentifer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(FrmIdentifer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(FrmIdentifer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(FrmIdentifer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the dialog */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + FrmIdentifer dialog = new FrmIdentifer(new javax.swing.JFrame(), true, new MapView()); + dialog.addWindowListener(new java.awt.event.WindowAdapter() { + @Override + public void windowClosing(java.awt.event.WindowEvent e) { + System.exit(0); + } + }); + dialog.setVisible(true); + } + }); + } + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JScrollPane jScrollPane1; + private JTable jTable1; + // End of variables declaration//GEN-END:variables + } diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmIdentiferGrid.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/FrmIdentiferGrid.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmIdentiferGrid.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/FrmIdentiferGrid.java index 139dafdb..a4ce6953 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmIdentiferGrid.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/FrmIdentiferGrid.java @@ -11,7 +11,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.map; +package org.meteoinfo.geo.mapview; /** * diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmVerticeEdit.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/FrmVerticeEdit.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmVerticeEdit.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/FrmVerticeEdit.java index 8b856670..f4b51585 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/map/FrmVerticeEdit.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/FrmVerticeEdit.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.map; +package org.meteoinfo.geo.mapview; import org.meteoinfo.common.PointD; diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/GridLabel.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/GridLabel.java deleted file mode 100644 index dfd11137..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/GridLabel.java +++ /dev/null @@ -1,190 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.mapview; - - import org.meteoinfo.common.Direction; - import org.meteoinfo.common.PointD; - - /** - * - * @author Yaqiang Wang - */ -public class GridLabel { - // - - private Direction _labDirection; - private String _labString; - private PointD _labPoint; - private PointD coord; - private boolean _isLon; - private boolean _isBorder; - private float _value; - private float angle; - // - // - /** - * Constructor - */ - public GridLabel() { - _labDirection = Direction.East; - _isLon = true; - _isBorder = true; - this.angle = Float.NaN; - } - // - // - - /** - * Get label direction - * - * @return Label direction - */ - public Direction getLabDirection() { - return _labDirection; - } - - /** - * Set label direction - * - * @param dir Label direction - */ - public void setLabDirection(Direction dir) { - _labDirection = dir; - } - - /** - * Get label string - * - * @return label string - */ - public String getLabString() { - return _labString; - } - - /** - * Set label string - * - * @param str Label string - */ - public void setLabString(String str) { - _labString = str; - } - - /** - * Get label point - * - * @return Label Point - */ - public PointD getLabPoint() { - return _labPoint; - } - - /** - * Set label point - * - * @param p Label Point - */ - public void setLabPoint(PointD p) { - _labPoint = p; - } - - /** - * Get coordinate - * @return Coordinate - */ - public PointD getCoord() { - return this.coord; - } - - /** - * Set coordinate - * @param value Coordinate - */ - public void setCoord(PointD value) { - this.coord = value; - } - - /** - * Get if is longitude - * - * @return Boolean - */ - public boolean isLongitude() { - return _isLon; - } - - /** - * Set if is longitude - * - * @param istrue Boolean - */ - public void setLongitude(boolean istrue) { - _isLon = istrue; - } - - /** - * Get if is border - * - * @return Boolean - */ - public boolean isBorder() { - return _isBorder; - } - - /** - * Set if is border - * - * @param istrue Boolean - */ - public void setBorder(boolean istrue) { - _isBorder = istrue; - } - - /** - * Get value - * - * @return Value - */ - public float getValue() { - return _value; - } - - /** - * Set value - * - * @param value Value - */ - public void setValue(float value) { - _value = value; - } - - /** - * Get angle - * @return Angle - */ - public float getAngle() { - return this.angle; - } - - /** - * Set angle - * @param value Angle - */ - public void setAnge(float value){ - this.angle = value; - } - // - // - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/map/MapView.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/MapView.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/map/MapView.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/MapView.java index c329b92d..2ae7f1f6 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/map/MapView.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/MapView.java @@ -11,7 +11,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.map; +package org.meteoinfo.geo.mapview; import com.itextpdf.awt.PdfGraphics2D; import com.itextpdf.text.DocumentException; @@ -20,12 +20,12 @@ import com.itextpdf.text.pdf.PdfTemplate; import com.itextpdf.text.pdf.PdfWriter; import org.meteoinfo.common.*; import org.meteoinfo.common.util.GlobalUtil; -import org.meteoinfo.data.mapdata.MapDataManage; -import org.meteoinfo.drawing.Draw; +import org.meteoinfo.geo.mapdata.MapDataManage; +import org.meteoinfo.geo.drawing.Draw; import org.meteoinfo.geo.util.GeoProjectionUtil; import org.meteoinfo.geometry.legend.*; -import org.meteoinfo.geoprocess.GeometryUtil; -import org.meteoinfo.geoprocess.GeoComputation; +import org.meteoinfo.geometry.geoprocess.GeometryUtil; +import org.meteoinfo.geo.analysis.GeoComputation; import org.meteoinfo.common.colors.ColorUtil; import org.meteoinfo.table.Field; import org.meteoinfo.ui.event.GraphicSelectedEvent; @@ -36,25 +36,25 @@ import org.meteoinfo.ui.event.IViewExtentChangedListener; import org.meteoinfo.ui.event.LayersUpdatedEvent; import org.meteoinfo.ui.event.ProjectionChangedEvent; import org.meteoinfo.ui.event.ViewExtentChangedEvent; -import org.meteoinfo.global.FrmMeasurement; -import org.meteoinfo.global.FrmMeasurement.MeasureTypes; +import org.meteoinfo.geo.gui.FrmMeasurement; +import org.meteoinfo.geo.gui.FrmMeasurement.MeasureTypes; import org.meteoinfo.ndarray.DataType; import org.meteoinfo.ndarray.util.BigDecimalUtil; -import org.meteoinfo.layer.ChartSet; -import org.meteoinfo.layer.ImageLayer; -import org.meteoinfo.layer.LabelSet; -import org.meteoinfo.layer.LayerCollection; -import org.meteoinfo.layer.LayerDrawType; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layer.RasterLayer; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.layout.Edge; -import org.meteoinfo.legend.FrmLabelSymbolSet; -import org.meteoinfo.legend.FrmPointSymbolSet; -import org.meteoinfo.legend.FrmPolygonSymbolSet; -import org.meteoinfo.legend.FrmPolylineSymbolSet; -import org.meteoinfo.legend.LegendManage; +import org.meteoinfo.geo.layer.ChartSet; +import org.meteoinfo.geo.layer.ImageLayer; +import org.meteoinfo.geo.layer.LabelSet; +import org.meteoinfo.geo.layer.LayerCollection; +import org.meteoinfo.geo.layer.LayerDrawType; +import org.meteoinfo.geo.layer.LayerTypes; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.layer.RasterLayer; +import org.meteoinfo.geo.layer.VectorLayer; +import org.meteoinfo.geo.layout.Edge; +import org.meteoinfo.geo.legend.FrmLabelSymbolSet; +import org.meteoinfo.geo.legend.FrmPointSymbolSet; +import org.meteoinfo.geo.legend.FrmPolygonSymbolSet; +import org.meteoinfo.geo.legend.FrmPolylineSymbolSet; +import org.meteoinfo.geo.legend.LegendManage; import org.meteoinfo.projection.KnownCoordinateSystems; import org.meteoinfo.projection.ProjectionInfo; import org.meteoinfo.projection.ProjectionNames; @@ -149,7 +149,7 @@ import org.meteoinfo.data.mapdata.webmap.GeoPosition; import org.meteoinfo.data.mapdata.webmap.IWebMapPanel; import org.meteoinfo.data.mapdata.webmap.TileLoadListener; import org.meteoinfo.data.mapdata.webmap.WebMapProvider; -import static org.meteoinfo.drawing.Draw.getHatchImage; +import static org.meteoinfo.geo.drawing.Draw.getHatchImage; import org.meteoinfo.common.DataConvert; import org.meteoinfo.ui.event.IShapeSelectedListener; import org.meteoinfo.ui.event.IUndoEditListener; @@ -157,8 +157,8 @@ import org.meteoinfo.ui.event.ShapeSelectedEvent; import org.meteoinfo.ui.event.UndoEditEvent; import org.meteoinfo.data.mapdata.webmap.GeoUtil; import org.meteoinfo.image.ImageUtil; -import org.meteoinfo.layer.VisibleScale; -import org.meteoinfo.layer.WebMapLayer; +import org.meteoinfo.geo.layer.VisibleScale; +import org.meteoinfo.geo.layer.WebMapLayer; import org.meteoinfo.projection.Reproject; import org.meteoinfo.geometry.graphic.ChartGraphic; import org.meteoinfo.geometry.shape.PointZShape; @@ -2580,7 +2580,7 @@ public class MapView extends JPanel implements IWebMapPanel { tData[i + 1][1] = valueStr; } } - DefaultTableModel dtm = new javax.swing.table.DefaultTableModel(tData, colNames) { + DefaultTableModel dtm = new DefaultTableModel(tData, colNames) { @Override public boolean isCellEditable(int row, int column) { return false; @@ -6514,8 +6514,8 @@ public class MapView extends JPanel implements IWebMapPanel { * Export to a picture file * * @param aFile File path - * @throws java.io.FileNotFoundException - * @throws javax.print.PrintException + * @throws FileNotFoundException + * @throws PrintException */ public void exportToPicture(String aFile) throws FileNotFoundException, PrintException, IOException { if (aFile.endsWith(".ps")) { @@ -6628,8 +6628,8 @@ public class MapView extends JPanel implements IWebMapPanel { * * @param fileName File path * @param dpi DPI - * @throws java.io.FileNotFoundException - * @throws javax.print.PrintException + * @throws FileNotFoundException + * @throws PrintException */ public void exportToPicture(String fileName, Integer dpi) throws FileNotFoundException, PrintException, IOException { if (dpi == null) { @@ -9774,7 +9774,7 @@ public class MapView extends JPanel implements IWebMapPanel { * * @param aILayer Raster layer XML node * @return Raster layer - * @throws java.lang.Exception + * @throws Exception */ public RasterLayer loadRasterLayer(Node aILayer) throws Exception { String aFile = aILayer.getAttributes().getNamedItem("FileName").getNodeValue(); @@ -9832,7 +9832,7 @@ public class MapView extends JPanel implements IWebMapPanel { * * @param wmLayer Web map layer XML node * @return Web map layer - * @throws java.lang.Exception + * @throws Exception */ public WebMapLayer loadWebMapLayer(Node wmLayer) throws Exception { WebMapLayer aLayer = new WebMapLayer(); diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/MapViewBeanInfo.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/MapViewBeanInfo.java new file mode 100644 index 00000000..b906b115 --- /dev/null +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/MapViewBeanInfo.java @@ -0,0 +1,34 @@ + /* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.mapview; + +import com.l2fprod.common.beans.BaseBeanInfo; + + /** + * + * @author Yaqiang + */ + public class MapViewBeanInfo extends BaseBeanInfo { + public MapViewBeanInfo(){ + super(MapView.class); + addProperty("antiAlias").setCategory("General").setDisplayName("AntiAlias"); + addProperty("background").setCategory("General").setDisplayName("Background"); + addProperty("foreground").setCategory("General").setDisplayName("Foreground"); + addProperty("xYScaleFactor").setCategory("General").setDisplayName("XYScaleFactor"); + addProperty("selectColor").setCategory("General").setDisplayName("Select Color"); + addProperty("multiGlobalDraw").setCategory("General").setDisplayName("MultiGlobalDraw"); + addProperty("pointAntiAlias").setCategory("General").setDisplayName("Point AntiAlias"); + addProperty("highSpeedWheelZoom").setCategory("General").setDisplayName("HighSpeedWheelZoom"); + } + } diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/map/MapViewUndoRedo.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/MapViewUndoRedo.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/map/MapViewUndoRedo.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/MapViewUndoRedo.java index b3562dda..a69c8e01 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/map/MapViewUndoRedo.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/MapViewUndoRedo.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.map; +package org.meteoinfo.geo.mapview; import java.awt.Point; import java.awt.Rectangle; @@ -15,7 +15,7 @@ import javax.swing.undo.AbstractUndoableEdit; import org.meteoinfo.common.Extent; import org.meteoinfo.common.PointD; -import org.meteoinfo.layer.VectorLayer; +import org.meteoinfo.geo.layer.VectorLayer; import org.meteoinfo.geometry.graphic.Graphic; import org.meteoinfo.geometry.shape.PolygonShape; import org.meteoinfo.geometry.shape.Shape; diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/MaskOut.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/MaskOut.java new file mode 100644 index 00000000..09c1f575 --- /dev/null +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/MaskOut.java @@ -0,0 +1,209 @@ + /* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.mapview; + +import com.l2fprod.common.beans.BaseBeanInfo; +import com.l2fprod.common.beans.ExtendedPropertyDescriptor; +import com.l2fprod.common.beans.editor.ComboBoxPropertyEditor; +import java.util.ArrayList; +import java.util.List; +import org.meteoinfo.geo.layer.LayerTypes; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geometry.shape.ShapeTypes; + + /** + * + * @author yaqiang + */ + public class MaskOut { + // + + private static MapView _mapView; + private boolean _setMaskLayer; + private String _maskLayer; + private List _layerList; + // + // + + /** + * Constructor + * + * @param aMapView + */ + public MaskOut(MapView aMapView) { + _mapView = aMapView; + _setMaskLayer = false; + _maskLayer = ""; + } + // + // + + /** + * Set map view + * @param mapView Map view + */ + public void setMapView(MapView mapView){ + _mapView = mapView; + } + + /** + * Get polygon map layers + * + * @return The polygon layer names + */ + public List getPolygonMapLayers() { + return _layerList; + } + + /** + * Set polygon map layers + * + * @param layers The polygon layer names + */ + public void setPolygonMapLayers(List layers) { + _layerList = layers; + } + + /** + * Get if is mask out + * + * @return Boolean + */ + public boolean isMask() { + return _setMaskLayer; + } + + /** + * Set if is mask out + * + * @param istrue Boolean + */ + public void setMask(boolean istrue) { + _setMaskLayer = istrue; + _mapView.paintLayers(); + } + + /** + * Get mask layer name + * + * @return The mask layer name + */ + public String getMaskLayer() { + return _maskLayer; + } + + /** + * Set mask layer name + * + * @param lname The layer name + */ + public void setMaskLayer(String lname) { + _maskLayer = lname; + _mapView.paintLayers(); + } + // + // + + /** + * Get layer names + * + * @return Layer names + */ + public static List getLayerNames() { + List layerNames = new ArrayList<>(); + for (MapLayer aLayer : _mapView.getLayers()) { + if (aLayer.getLayerType() == LayerTypes.VectorLayer) { + if (aLayer.getShapeType() == ShapeTypes.Polygon) { + layerNames.add(aLayer.getLayerName()); + } + } + } + + return layerNames; + } + // + + // + public class MaskOutBean { + + public MaskOutBean() { + } + + // + /** + * Get if is mask out + * + * @return Boolean + */ + public boolean isMask() { + return _setMaskLayer; + } + + /** + * Set if is mask out + * + * @param istrue Boolean + */ + public void setMask(boolean istrue) { + _setMaskLayer = istrue; + _mapView.paintLayers(); + } + + /** + * Get mask layer name + * + * @return The mask layer name + */ + public String getMaskLayer() { + return _maskLayer; + } + + /** + * Set mask layer name + * + * @param lname The layer name + */ + public void setMaskLayer(String lname) { + _maskLayer = lname; + _mapView.paintLayers(); + } + // + } + + public static class MaskOutBeanBeanInfo extends BaseBeanInfo { + + public MaskOutBeanBeanInfo() { + super(MaskOutBean.class); + ExtendedPropertyDescriptor e = addProperty("maskLayer"); + e.setCategory("General").setPropertyEditorClass(LayerNameEditor.class); + e.setDisplayName("Layer Name"); + e.setShortDescription("The name of the layers can be used as maskout"); + e = addProperty("mask"); + e.setCategory("General").setDisplayName("Is Maskout"); + } + } + + public static class LayerNameEditor extends ComboBoxPropertyEditor { + + public LayerNameEditor() { + super(); + String[] names = (String[]) getLayerNames().toArray(new String[0]); + setAvailableValues(names); + // Icon[] icons = new Icon[4]; + // Arrays.fill(icons, UIManager.getIcon("Tree.openIcon")); + // setAvailableIcons(icons); + } + } + // + } diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/map/MouseTools.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/MouseTools.java similarity index 94% rename from MeteoInfoLib/src/main/java/org/meteoinfo/map/MouseTools.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/MouseTools.java index 2e92fa6d..4da54c96 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/map/MouseTools.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/MouseTools.java @@ -1,58 +1,58 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.map; - -/** - * - * @author Yaqiang Wang - */ -public enum MouseTools { - - Zoom_In, - Zoom_Out, - Pan, - Identifer, - SelectElements, - MoveSelection, - ResizeSelection, - CreateSelection, - SelectFeatures_Rectangle, - SelectFeatures_Polygon, - SelectFeatures_Lasso, - SelectFeatures_Circle, - New_Point, - New_Label, - New_Polyline, - New_Freehand, - New_Curve, - New_CurvePolygon, - New_Polygon, - New_Rectangle, - New_Ellipse, - New_Circle, - EditVertices, - InEditingVertices, - Measurement, - Edit_Tool, - Edit_MoveSelection, - Edit_NewFeature, - Edit_FeatureVertices, - Edit_InEditingVertices, - Edit_AddRing, - Edit_FillRing, - Edit_DeleteRing, - Edit_ReformFeature, - Edit_SplitFeature, - None -} + /* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.mapview; + +/** + * + * @author Yaqiang Wang + */ +public enum MouseTools { + + Zoom_In, + Zoom_Out, + Pan, + Identifer, + SelectElements, + MoveSelection, + ResizeSelection, + CreateSelection, + SelectFeatures_Rectangle, + SelectFeatures_Polygon, + SelectFeatures_Lasso, + SelectFeatures_Circle, + New_Point, + New_Label, + New_Polyline, + New_Freehand, + New_Curve, + New_CurvePolygon, + New_Polygon, + New_Rectangle, + New_Ellipse, + New_Circle, + EditVertices, + InEditingVertices, + Measurement, + Edit_Tool, + Edit_MoveSelection, + Edit_NewFeature, + Edit_FeatureVertices, + Edit_InEditingVertices, + Edit_AddRing, + Edit_FillRing, + Edit_DeleteRing, + Edit_ReformFeature, + Edit_SplitFeature, + None +} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/map/ProjectionSet.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/ProjectionSet.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/map/ProjectionSet.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/ProjectionSet.java index 60389759..c4fc35ef 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/map/ProjectionSet.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/ProjectionSet.java @@ -11,7 +11,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.map; +package org.meteoinfo.geo.mapview; import org.meteoinfo.common.Extent; import org.meteoinfo.common.MIMath; @@ -19,8 +19,8 @@ import org.meteoinfo.common.PointD; import org.meteoinfo.geo.util.GeoProjectionUtil; import org.meteoinfo.ui.event.IProjectionChangedListener; import org.meteoinfo.ui.event.ProjectionChangedEvent; -import org.meteoinfo.layer.RasterLayer; -import org.meteoinfo.layer.VectorLayer; +import org.meteoinfo.geo.layer.RasterLayer; +import org.meteoinfo.geo.layer.VectorLayer; import org.meteoinfo.projection.KnownCoordinateSystems; import org.meteoinfo.projection.ProjectionInfo; import org.meteoinfo.projection.Reproject; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/data/meteodata/DrawMeteoData.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/meteodata/DrawMeteoData.java similarity index 98% rename from MeteoInfoLib/src/main/java/org/meteoinfo/data/meteodata/DrawMeteoData.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/meteodata/DrawMeteoData.java index 5cba6ffe..190460ca 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/data/meteodata/DrawMeteoData.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/meteodata/DrawMeteoData.java @@ -11,34 +11,36 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.data.meteodata; +package org.meteoinfo.geo.meteodata; import org.apache.commons.lang3.ArrayUtils; -import org.meteoinfo.data.DataMath; -import org.meteoinfo.data.GridData; -import org.meteoinfo.data.StationData; -import org.meteoinfo.dataframe.DataFrame; -import org.meteoinfo.geometry.geoprocess.GeometryUtil; -import org.meteoinfo.table.Field; -import org.meteoinfo.drawing.ContourDraw; -import org.meteoinfo.drawing.Draw; -import org.meteoinfo.geometry.legend.MarkerType; -import org.meteoinfo.geoprocess.GeoComputation; +import org.meteoinfo.common.Extent; import org.meteoinfo.common.MIMath; import org.meteoinfo.common.PointD; +import org.meteoinfo.data.*; +import org.meteoinfo.data.meteodata.StationInfoData; +import org.meteoinfo.data.meteodata.StationModel; +import org.meteoinfo.data.meteodata.StationModelData; +import org.meteoinfo.dataframe.DataFrame; +import org.meteoinfo.geo.drawing.ContourDraw; +import org.meteoinfo.geo.drawing.Draw; +import org.meteoinfo.geo.layer.*; +import org.meteoinfo.geo.legend.LegendManage; +import org.meteoinfo.geometry.geoprocess.GeometryUtil; +import org.meteoinfo.geometry.graphic.Graphic; +import org.meteoinfo.geometry.legend.*; +import org.meteoinfo.geometry.shape.*; +import org.meteoinfo.geometry.geoprocess.GeoComputation; +import org.meteoinfo.math.meteo.MeteoMath; +import org.meteoinfo.ndarray.Array; import org.meteoinfo.ndarray.DataType; -import org.meteoinfo.layer.LayerDrawType; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.legend.LegendManage; -import org.meteoinfo.geometry.legend.LegendScheme; import org.meteoinfo.ndarray.IndexIterator; -import org.meteoinfo.geometry.shape.PointShape; -import org.meteoinfo.geometry.shape.PolygonShape; -import org.meteoinfo.geometry.shape.PolylineShape; -import org.meteoinfo.geometry.shape.ShapeTypes; -import org.meteoinfo.geometry.shape.WindArrow; -import org.meteoinfo.geometry.shape.WindBarb; -import java.awt.Color; +import org.meteoinfo.ndarray.math.ArrayUtil; +import org.meteoinfo.table.Field; +import wcontour.global.PolyLine; +import wcontour.global.Polygon; + +import java.awt.*; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.Arrays; @@ -46,25 +48,6 @@ import java.util.Collections; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -import org.meteoinfo.ndarray.math.ArrayUtil; -import org.meteoinfo.data.GridArray; -import org.meteoinfo.data.XYListDataset; -import org.meteoinfo.common.Extent; -import org.meteoinfo.layer.ImageLayer; -import org.meteoinfo.layer.RasterLayer; -import org.meteoinfo.layer.WorldFilePara; -import org.meteoinfo.geometry.legend.ArrowBreak; -import org.meteoinfo.geometry.legend.LegendType; -import org.meteoinfo.geometry.legend.PointBreak; -import org.meteoinfo.math.meteo.MeteoMath; -import org.meteoinfo.geometry.graphic.Graphic; -import org.meteoinfo.geometry.shape.ImageShape; -import org.meteoinfo.geometry.shape.PointZ; -import org.meteoinfo.geometry.shape.PolylineZShape; -import org.meteoinfo.geometry.shape.StationModelShape; -import org.meteoinfo.ndarray.Array; -import wcontour.global.PolyLine; -import wcontour.global.Polygon; /** * Template @@ -710,7 +693,7 @@ public class DrawMeteoData { ArrayUtils.reverse(yArray); Object[] cbs = ContourDraw.tracingContourLines(gridData.data, cValues, xArray, yArray, gridData.missingValue, S1); - List ContourLines = (List) cbs[0]; + List ContourLines = (List) cbs[0]; if (ContourLines.isEmpty()) { return null; @@ -720,7 +703,7 @@ public class DrawMeteoData { ContourLines = wcontour.Contour.smoothLines(ContourLines); } - wcontour.global.PolyLine aLine; + PolyLine aLine; double aValue; VectorLayer aLayer = new VectorLayer(ShapeTypes.Polyline); Field aDC = new Field(fieldName, DataType.DOUBLE); @@ -799,7 +782,7 @@ public class DrawMeteoData { int[][] S1 = new int[data.length][data[0].length]; Object[] cbs = ContourDraw.tracingContourLines(data, cValues, xArray, yArray, missingValue, S1); - List ContourLines = (List) cbs[0]; + List ContourLines = (List) cbs[0]; if (ContourLines.isEmpty()) { return null; @@ -814,7 +797,7 @@ public class DrawMeteoData { Field aDC = new Field(fieldName, DataType.DOUBLE); aLayer.editAddField(aDC); - for (wcontour.global.PolyLine aLine : ContourLines) { + for (PolyLine aLine : ContourLines) { aValue = aLine.Value; PolylineShape aPolyline = new PolylineShape(); PointD aPoint; @@ -912,8 +895,8 @@ public class DrawMeteoData { * @return Vector layer */ public static VectorLayer createShadedLayer(GridData gridData, LegendScheme aLS, String lName, String fieldName, boolean isSmooth) { - List ContourLines; - List ContourPolygons; + List ContourLines; + List ContourPolygons; LegendScheme ls = aLS.convertTo(ShapeTypes.Polygon); Object[] ccs = LegendManage.getContoursAndColors(ls); @@ -935,7 +918,7 @@ public class DrawMeteoData { ArrayUtils.reverse(yArray); Object[] cbs = ContourDraw.tracingContourLines(gridData.data, cValues, xArray, yArray, gridData.missingValue, S1); - ContourLines = (List) cbs[0]; + ContourLines = (List) cbs[0]; List borders = (List) cbs[1]; if (isSmooth) { @@ -1694,10 +1677,10 @@ public class DrawMeteoData { vGridData = uvData[1]; } - List streamlines = wcontour.Contour.tracingStreamline(uGridData.data, vGridData.data, + List streamlines = wcontour.Contour.tracingStreamline(uGridData.data, vGridData.data, uGridData.xArray, vGridData.yArray, uGridData.missingValue, density); - wcontour.global.PolyLine aLine; + PolyLine aLine; VectorLayer aLayer = new VectorLayer(ShapeTypes.Polyline); aLayer.editAddField("ID", DataType.INT); @@ -3220,7 +3203,7 @@ public class DrawMeteoData { public static VectorLayer meshLayer(Array x_s, Array y_s, Array a, LegendScheme ls, double lonlim) { VectorLayer layer = new VectorLayer(ShapeTypes.Polygon); String fieldName = "Data"; - Field aDC = new Field(fieldName, org.meteoinfo.ndarray.DataType.DOUBLE); + Field aDC = new Field(fieldName, DataType.DOUBLE); layer.editAddField(aDC); int[] shape = x_s.getShape(); @@ -3280,7 +3263,7 @@ public class DrawMeteoData { public static VectorLayer meshLayer(Array x_s, Array y_s, Array a, LegendScheme ls) { VectorLayer layer = new VectorLayer(ShapeTypes.Polygon); String fieldName = "Data"; - Field aDC = new Field(fieldName, org.meteoinfo.ndarray.DataType.DOUBLE); + Field aDC = new Field(fieldName, DataType.DOUBLE); layer.editAddField(aDC); int[] shape = x_s.getShape(); diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/data/meteodata/TrajDataInfo.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/meteodata/TrajDataInfo.java similarity index 93% rename from MeteoInfoLib/src/main/java/org/meteoinfo/data/meteodata/TrajDataInfo.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/meteodata/TrajDataInfo.java index 70e8e324..e73a0511 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/data/meteodata/TrajDataInfo.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/meteodata/TrajDataInfo.java @@ -11,9 +11,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.data.meteodata; +package org.meteoinfo.geo.meteodata; -import org.meteoinfo.layer.VectorLayer; +import org.meteoinfo.geo.layer.VectorLayer; /** * diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/plot/MainPlot.form b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/plot/MainPlot.form similarity index 96% rename from MeteoInfoLib/src/main/java/org/meteoinfo/plot/MainPlot.form rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/plot/MainPlot.form index 575ef70f..9e42f1b3 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/plot/MainPlot.form +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/plot/MainPlot.form @@ -71,7 +71,7 @@ - + @@ -110,13 +110,13 @@ - + - + diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/plot/MainPlot.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/plot/MainPlot.java similarity index 92% rename from MeteoInfoLib/src/main/java/org/meteoinfo/plot/MainPlot.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/plot/MainPlot.java index fc754bef..147af871 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/plot/MainPlot.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/plot/MainPlot.java @@ -2,15 +2,19 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.plot; +package org.meteoinfo.geo.plot; -import javax.swing.JFrame; +import org.meteoinfo.geo.layout.MapLayout; +import org.meteoinfo.geo.legend.LayersLegend; +import org.meteoinfo.geo.mapview.MapView; + +import javax.swing.*; /** * * @author yaqiang */ -public class MainPlot extends javax.swing.JFrame { +public class MainPlot extends JFrame { /** * Creates new form MainPlot @@ -33,10 +37,10 @@ public class MainPlot extends javax.swing.JFrame { jSplitPane1 = new javax.swing.JSplitPane(); jTabbedPane_Map = new javax.swing.JTabbedPane(); jPanel_Map = new javax.swing.JPanel(); - mapView1 = new org.meteoinfo.map.MapView(); + mapView1 = new MapView(); jPanel_Layout = new javax.swing.JPanel(); - mapLayout1 = new org.meteoinfo.layout.MapLayout(); - layersLegend1 = new org.meteoinfo.legend.LayersLegend(); + mapLayout1 = new MapLayout(); + layersLegend1 = new LayersLegend(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); @@ -136,8 +140,8 @@ public class MainPlot extends javax.swing.JFrame { private javax.swing.JPanel jPanel_Map; private javax.swing.JSplitPane jSplitPane1; private javax.swing.JTabbedPane jTabbedPane_Map; - private org.meteoinfo.legend.LayersLegend layersLegend1; - private org.meteoinfo.layout.MapLayout mapLayout1; - private org.meteoinfo.map.MapView mapView1; + private LayersLegend layersLegend1; + private MapLayout mapLayout1; + private MapView mapView1; // End of variables declaration//GEN-END:variables } diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/plot/MapLayoutPlot.form b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/plot/MapLayoutPlot.form similarity index 96% rename from MeteoInfoLib/src/main/java/org/meteoinfo/plot/MapLayoutPlot.form rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/plot/MapLayoutPlot.form index 124b0943..9b4ef38e 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/plot/MapLayoutPlot.form +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/plot/MapLayoutPlot.form @@ -33,7 +33,7 @@ - + diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/plot/MapLayoutPlot.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/plot/MapLayoutPlot.java similarity index 92% rename from MeteoInfoLib/src/main/java/org/meteoinfo/plot/MapLayoutPlot.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/plot/MapLayoutPlot.java index e18e59bd..de0d8194 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/plot/MapLayoutPlot.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/plot/MapLayoutPlot.java @@ -2,30 +2,31 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.plot; +package org.meteoinfo.geo.plot; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import javax.swing.JFrame; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import org.meteoinfo.layout.MapLayout; -import org.meteoinfo.legend.MapFrame; +import org.meteoinfo.geo.layout.MapLayout; +import org.meteoinfo.geo.legend.MapFrame; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; +import javax.swing.*; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + /** * * @author yaqiang */ -public class MapLayoutPlot extends javax.swing.JFrame { +public class MapLayoutPlot extends JFrame { /** * Creates new form MapLayoutPlot @@ -45,7 +46,7 @@ public class MapLayoutPlot extends javax.swing.JFrame { // //GEN-BEGIN:initComponents private void initComponents() { - mapLayout1 = new org.meteoinfo.layout.MapLayout(); + mapLayout1 = new MapLayout(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); @@ -76,9 +77,9 @@ public class MapLayoutPlot extends javax.swing.JFrame { * Load project file * * @param aFile - * @throws javax.xml.parsers.ParserConfigurationException - * @throws org.xml.sax.SAXException - * @throws java.io.IOException + * @throws ParserConfigurationException + * @throws SAXException + * @throws IOException */ public void loadProjectFile(String aFile) throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @@ -153,6 +154,6 @@ public class MapLayoutPlot extends javax.swing.JFrame { }); } // Variables declaration - do not modify//GEN-BEGIN:variables - private org.meteoinfo.layout.MapLayout mapLayout1; + private MapLayout mapLayout1; // End of variables declaration//GEN-END:variables } diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/plugin/IApplication.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/plugin/IApplication.java similarity index 90% rename from MeteoInfoLib/src/main/java/org/meteoinfo/plugin/IApplication.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/plugin/IApplication.java index 4e7ff0d9..daa2fedf 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/plugin/IApplication.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/plugin/IApplication.java @@ -1,86 +1,86 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.plugin; - -import javax.swing.*; - -import org.meteoinfo.legend.LayersLegend; -import org.meteoinfo.map.MapView; - -/** - * - * @author yaqiang - */ -public interface IApplication { - /** - * Get MapView object - * @return MapView object - */ - public MapView getMapView(); - - /** - * Get LayersLegend object - * @return LayersLegend object - */ - public LayersLegend getMapDocument(); - - /** - * Get main menu bar object - * @return Main menu bar object - */ - public JMenuBar getMainMenuBar(); - - /** - * Get plugin menu - * @return Plugin menu - */ - public JMenu getPluginMenu(); - - /** - * Get tool bar panel - * @return Tool bar panel - */ - public JPanel getToolBarPanel(); - - /** - * Get current tool - * @return Current tool - */ - public AbstractButton getCurrentTool(); - - /** - * Set current tool - * @param value Current tool - */ - public void setCurrentTool(AbstractButton value); - - /** - * Get progress bar - * @return The main progress bar - */ - public JProgressBar getProgressBar(); - - /** - * Get progress bar label - * @return The progress bar label - */ - public JLabel getProgressBarLabel(); - - /** - * Open project file - * @param fileName The project file name - */ - public void openProjectFile(String fileName); - -} + /* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.plugin; + +import javax.swing.*; + +import org.meteoinfo.geo.legend.LayersLegend; +import org.meteoinfo.geo.mapview.MapView; + +/** + * + * @author yaqiang + */ +public interface IApplication { + /** + * Get MapView object + * @return MapView object + */ + public MapView getMapView(); + + /** + * Get LayersLegend object + * @return LayersLegend object + */ + public LayersLegend getMapDocument(); + + /** + * Get main menu bar object + * @return Main menu bar object + */ + public JMenuBar getMainMenuBar(); + + /** + * Get plugin menu + * @return Plugin menu + */ + public JMenu getPluginMenu(); + + /** + * Get tool bar panel + * @return Tool bar panel + */ + public JPanel getToolBarPanel(); + + /** + * Get current tool + * @return Current tool + */ + public AbstractButton getCurrentTool(); + + /** + * Set current tool + * @param value Current tool + */ + public void setCurrentTool(AbstractButton value); + + /** + * Get progress bar + * @return The main progress bar + */ + public JProgressBar getProgressBar(); + + /** + * Get progress bar label + * @return The progress bar label + */ + public JLabel getProgressBarLabel(); + + /** + * Open project file + * @param fileName The project file name + */ + public void openProjectFile(String fileName); + +} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/plugin/IPlugin.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/plugin/IPlugin.java similarity index 94% rename from MeteoInfoLib/src/main/java/org/meteoinfo/plugin/IPlugin.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/plugin/IPlugin.java index af58ec9b..b01ac2cb 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/plugin/IPlugin.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/plugin/IPlugin.java @@ -1,90 +1,90 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.plugin; - -/** - * - * @author yaqiang - */ -public interface IPlugin { - /** - * Get application - * @return Application - */ - public IApplication getApplication(); - - /** - * Set application - * @param app Application - */ - public void setApplication(IApplication app); - - /** - * Get plugin name - * @return Plugin name - */ - public String getName(); - - /** - * Set plugin name - * @param value Plugin name - */ - public void setName(String value); - - /** - * Get plugin author - * @return Plugin author - */ - public String getAuthor(); - - /** - * Set plugin author - * @param value Plugin author - */ - public void setAuthor(String value); - - /** - * Get plugin version - * @return Plugin version - */ - public String getVersion(); - - /** - * Set plugin version - * @param value Plugin version - */ - public void setVersion(String value); - - /** - * Get plugin description - * @return Plugin description - */ - public String getDescription(); - - /** - * Set plugin description - * @param value Description - */ - public void setDescription(String value); - - /** - * Plugin load - */ - public void load(); - - /** - * Plugin unload - */ - public void unload(); -} +/* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.geo.plugin; + +/** + * + * @author yaqiang + */ +public interface IPlugin { + /** + * Get application + * @return Application + */ + public IApplication getApplication(); + + /** + * Set application + * @param app Application + */ + public void setApplication(IApplication app); + + /** + * Get plugin name + * @return Plugin name + */ + public String getName(); + + /** + * Set plugin name + * @param value Plugin name + */ + public void setName(String value); + + /** + * Get plugin author + * @return Plugin author + */ + public String getAuthor(); + + /** + * Set plugin author + * @param value Plugin author + */ + public void setAuthor(String value); + + /** + * Get plugin version + * @return Plugin version + */ + public String getVersion(); + + /** + * Set plugin version + * @param value Plugin version + */ + public void setVersion(String value); + + /** + * Get plugin description + * @return Plugin description + */ + public String getDescription(); + + /** + * Set plugin description + * @param value Description + */ + public void setDescription(String value); + + /** + * Plugin load + */ + public void load(); + + /** + * Plugin unload + */ + public void unload(); +} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/plugin/PluginBase.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/plugin/PluginBase.java similarity index 92% rename from MeteoInfoLib/src/main/java/org/meteoinfo/plugin/PluginBase.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/plugin/PluginBase.java index 7313db3b..5e542133 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/plugin/PluginBase.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/plugin/PluginBase.java @@ -1,77 +1,77 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.plugin; - -/** - * - * @author yaqiang - */ -public abstract class PluginBase implements IPlugin{ - private IApplication _application = null; - private String _name; - private String _author; - private String _version; - private String _description; - - @Override - public IApplication getApplication() { - return this._application; - } - - @Override - public void setApplication(IApplication app) { - this._application = app; - } - - @Override - public String getName() { - return this._name; - } - - @Override - public void setName(String value) { - this._name = value; - } - - @Override - public String getAuthor() { - return this._author; - } - - @Override - public void setAuthor(String value) { - this._author = value; - } - - @Override - public String getVersion() { - return this._version; - } - - @Override - public void setVersion(String value) { - this._version = value; - } - - @Override - public String getDescription() { - return this._description; - } - - @Override - public void setDescription(String value) { - this._description = value; - } - - @Override - public void load() { - - } - - @Override - public void unload() { - - } -} +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.meteoinfo.geo.plugin; + +/** + * + * @author yaqiang + */ +public abstract class PluginBase implements IPlugin{ + private IApplication _application = null; + private String _name; + private String _author; + private String _version; + private String _description; + + @Override + public IApplication getApplication() { + return this._application; + } + + @Override + public void setApplication(IApplication app) { + this._application = app; + } + + @Override + public String getName() { + return this._name; + } + + @Override + public void setName(String value) { + this._name = value; + } + + @Override + public String getAuthor() { + return this._author; + } + + @Override + public void setAuthor(String value) { + this._author = value; + } + + @Override + public String getVersion() { + return this._version; + } + + @Override + public void setVersion(String value) { + this._version = value; + } + + @Override + public String getDescription() { + return this._description; + } + + @Override + public void setDescription(String value) { + this._description = value; + } + + @Override + public void load() { + + } + + @Override + public void unload() { + + } +} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/CoordinateSystemCategory.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/CoordinateSystemCategory.java deleted file mode 100644 index 27733302..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/CoordinateSystemCategory.java +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection; - -/** - * - * @author Yaqiang Wang - */ -public class CoordinateSystemCategory { - -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/GeoGraphicSystem.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/GeoGraphicSystem.java deleted file mode 100644 index d8e0f0e2..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/GeoGraphicSystem.java +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection; - -/** - * - * @author Yaqiang - */ -public class GeoGraphicSystem { - public final World world; - - /** - * Constructor - */ - public GeoGraphicSystem(){ - world = new World(); - } -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/KnownCoordinateSystems.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/KnownCoordinateSystems.java deleted file mode 100644 index 9e900965..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/KnownCoordinateSystems.java +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection; - -/** - * - * @author Yaqiang Wang - */ -public class KnownCoordinateSystems { - public static GeoGraphicSystem geographic = new GeoGraphicSystem(); -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/ProjRegistry.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/ProjRegistry.java deleted file mode 100644 index 5afab877..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/ProjRegistry.java +++ /dev/null @@ -1,458 +0,0 @@ -/** ***************************************************************************** - * Copyright 2009, 2017 Martin Davis - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.meteoinfo.geo.projection; - -import org.locationtech.proj4j.datum.Datum; -import org.locationtech.proj4j.datum.Ellipsoid; -import org.locationtech.proj4j.proj.*; - -import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Supplies predefined values for various library classes such as - * {@link Ellipsoid}, {@link Datum}, and {@link Projection}. - * - * @author Martin Davis - */ -public class ProjRegistry { - - public ProjRegistry() { - super(); - initialize(); - } - - public final static Datum[] datums - = { - Datum.WGS84, - Datum.GGRS87, - Datum.NAD27, - Datum.NAD83, - Datum.POTSDAM, - Datum.CARTHAGE, - Datum.HERMANNSKOGEL, - Datum.IRE65, - Datum.NZGD49, - Datum.OSEB36 - }; - - public Datum getDatum(String code) { - for (int i = 0; i < datums.length; i++) { - if (datums[i].getCode().equals(code)) { - return datums[i]; - } - } - return null; - } - - public final static Ellipsoid[] ellipsoids - = { - Ellipsoid.SPHERE, - new Ellipsoid("MERIT", 6378137.0, 0.0, 298.257, "MERIT 1983"), - new Ellipsoid("SGS85", 6378136.0, 0.0, 298.257, "Soviet Geodetic System 85"), - Ellipsoid.GRS80, - new Ellipsoid("IAU76", 6378140.0, 0.0, 298.257, "IAU 1976"), - Ellipsoid.AIRY, - Ellipsoid.MOD_AIRY, - new Ellipsoid("APL4.9", 6378137.0, 0.0, 298.25, "Appl. Physics. 1965"), - new Ellipsoid("NWL9D", 6378145.0, 298.25, 0.0, "Naval Weapons Lab., 1965"), - new Ellipsoid("andrae", 6377104.43, 300.0, 0.0, "Andrae 1876 (Den., Iclnd.)"), - new Ellipsoid("aust_SA", 6378160.0, 0.0, 298.25, "Australian Natl & S. Amer. 1969"), - new Ellipsoid("GRS67", 6378160.0, 0.0, 298.2471674270, "GRS 67 (IUGG 1967)"), - Ellipsoid.BESSEL, - new Ellipsoid("bess_nam", 6377483.865, 0.0, 299.1528128, "Bessel 1841 (Namibia)"), - Ellipsoid.CLARKE_1866, - Ellipsoid.CLARKE_1880, - new Ellipsoid("CPM", 6375738.7, 0.0, 334.29, "Comm. des Poids et Mesures 1799"), - new Ellipsoid("delmbr", 6376428.0, 0.0, 311.5, "Delambre 1810 (Belgium)"), - new Ellipsoid("engelis", 6378136.05, 0.0, 298.2566, "Engelis 1985"), - Ellipsoid.EVEREST, - new Ellipsoid("evrst48", 6377304.063, 0.0, 300.8017, "Everest 1948"), - new Ellipsoid("evrst56", 6377301.243, 0.0, 300.8017, "Everest 1956"), - new Ellipsoid("evrst69", 6377295.664, 0.0, 300.8017, "Everest 1969"), - new Ellipsoid("evrstSS", 6377298.556, 0.0, 300.8017, "Everest (Sabah & Sarawak)"), - new Ellipsoid("fschr60", 6378166.0, 0.0, 298.3, "Fischer (Mercury Datum) 1960"), - new Ellipsoid("fschr60m", 6378155.0, 0.0, 298.3, "Modified Fischer 1960"), - new Ellipsoid("fschr68", 6378150.0, 0.0, 298.3, "Fischer 1968"), - new Ellipsoid("helmert", 6378200.0, 0.0, 298.3, "Helmert 1906"), - new Ellipsoid("hough", 6378270.0, 0.0, 297.0, "Hough"), - Ellipsoid.INTERNATIONAL, - Ellipsoid.INTERNATIONAL_1967, - Ellipsoid.KRASSOVSKY, - new Ellipsoid("kaula", 6378163.0, 0.0, 298.24, "Kaula 1961"), - new Ellipsoid("lerch", 6378139.0, 0.0, 298.257, "Lerch 1979"), - new Ellipsoid("mprts", 6397300.0, 0.0, 191.0, "Maupertius 1738"), - new Ellipsoid("plessis", 6376523.0, 6355863.0, 0.0, "Plessis 1817 France)"), - new Ellipsoid("SEasia", 6378155.0, 6356773.3205, 0.0, "Southeast Asia"), - new Ellipsoid("walbeck", 6376896.0, 6355834.8467, 0.0, "Walbeck"), - Ellipsoid.WGS60, - Ellipsoid.WGS66, - Ellipsoid.WGS72, - Ellipsoid.WGS84, - new Ellipsoid("NAD27", 6378249.145, 0.0, 293.4663, "NAD27: Clarke 1880 mod."), - new Ellipsoid("NAD83", 6378137.0, 0.0, 298.257222101, "NAD83: GRS 1980 (IUGG, 1980)"),}; - - public Ellipsoid getEllipsoid(String name) { - for (int i = 0; i < ellipsoids.length; i++) { - if (ellipsoids[i].shortName.equals(name)) { - return ellipsoids[i]; - } - } - return null; - } - - private Map projRegistry; - private Map projRegistryEsri; - - private void register(String name, Class cls, String description) { - projRegistry.put(name, cls); - } - - private void registerEsri(String name, Class cls, String description) { - projRegistryEsri.put(name, cls); - } - - public Projection getProjection(String name) { -// if ( projRegistry == null ) -// initialize(); - Class cls = (Class) projRegistry.get(name); - if (cls != null) { - try { - Projection projection = (Projection) cls.newInstance(); - if (projection != null) { - projection.setName(name); - } - return projection; - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InstantiationException e) { - e.printStackTrace(); - } - } - return null; - } - - /** - * Get projection +proj= name - * - * @param proj The projection - * @return Proj4 +proj= name - */ - public String getProj4Name(Projection proj) { - for (Entry entry : projRegistry.entrySet()) { - if (entry.getValue().equals(proj.getClass())) { - return (String) entry.getKey(); - } - } - return null; - } - - public Projection getProjectionEsri(String name) { -// if ( projRegistry == null ) -// initialize(); - Class cls = (Class) projRegistryEsri.get(name); - if (cls != null) { - try { - Projection projection = (Projection) cls.getDeclaredConstructor().newInstance(); - if (projection != null) { - projection.setName(name); - } - return projection; - } catch (IllegalAccessException | InstantiationException e) { - e.printStackTrace(); - } catch (NoSuchMethodException | SecurityException | IllegalArgumentException | InvocationTargetException ex) { - Logger.getLogger(ProjRegistry.class.getName()).log(Level.SEVERE, null, ex); - } - } - return null; - } - - private synchronized void initialize() { - initializeProj4(); - initializeEsri(); - } - - private synchronized void initializeProj4() { - // guard against race condition - if (projRegistry != null) { - return; - } - projRegistry = new HashMap(); - register("aea", AlbersProjection.class, "Albers Equal Area"); - register("aeqd", EquidistantAzimuthalProjection.class, "Azimuthal Equidistant"); - register("airy", AiryProjection.class, "Airy"); - register("aitoff", AitoffProjection.class, "Aitoff"); - register("alsk", Projection.class, "Mod. Stereographics of Alaska"); - register("apian", Projection.class, "Apian Globular I"); - register("august", AugustProjection.class, "August Epicycloidal"); - register("bacon", Projection.class, "Bacon Globular"); - register("bipc", BipolarProjection.class, "Bipolar conic of western hemisphere"); - register("boggs", BoggsProjection.class, "Boggs Eumorphic"); - register("bonne", BonneProjection.class, "Bonne (Werner lat_1=90)"); - register("cass", CassiniProjection.class, "Cassini"); - register("cc", CentralCylindricalProjection.class, "Central Cylindrical"); - register("cea", CylindricalEqualAreaProjection.class, "Equal Area Cylindrical"); -// register( "chamb", Projection.class, "Chamberlin Trimetric" ); - register("collg", CollignonProjection.class, "Collignon"); - register("crast", CrasterProjection.class, "Craster Parabolic (Putnins P4)"); - register("denoy", DenoyerProjection.class, "Denoyer Semi-Elliptical"); - register("eck1", Eckert1Projection.class, "Eckert I"); - register("eck2", Eckert2Projection.class, "Eckert II"); -// register( "eck3", Eckert3Projection.class, "Eckert III" ); - register("eck4", Eckert4Projection.class, "Eckert IV"); - register("eck5", Eckert5Projection.class, "Eckert V"); - register("eck6", Eckert6Projection.class, "Eckert VI"); - register("eqc", PlateCarreeProjection.class, "Equidistant Cylindrical (Plate Caree)"); - register("eqdc", EquidistantConicProjection.class, "Equidistant Conic"); - register("euler", EulerProjection.class, "Euler"); - register("fahey", FaheyProjection.class, "Fahey"); - register("fouc", FoucautProjection.class, "Foucaut"); - register("fouc_s", FoucautSinusoidalProjection.class, "Foucaut Sinusoidal"); - register("gall", GallProjection.class, "Gall (Gall Stereographic)"); -// register( "gins8", Projection.class, "Ginsburg VIII (TsNIIGAiK)" ); -// register( "gn_sinu", Projection.class, "General Sinusoidal Series" ); - register("gnom", GnomonicAzimuthalProjection.class, "Gnomonic"); - register("goode", GoodeProjection.class, "Goode Homolosine"); -// register( "gs48", Projection.class, "Mod. Stererographics of 48 U.S." ); -// register( "gs50", Projection.class, "Mod. Stererographics of 50 U.S." ); - register("hammer", HammerProjection.class, "Hammer & Eckert-Greifendorff"); - register("hatano", HatanoProjection.class, "Hatano Asymmetrical Equal Area"); -// register( "imw_p", Projection.class, "Internation Map of the World Polyconic" ); - register("kav5", KavraiskyVProjection.class, "Kavraisky V"); -// register( "kav7", Projection.class, "Kavraisky VII" ); - register("krovak", KrovakProjection.class, "Krovak"); -// register( "labrd", Projection.class, "Laborde" ); - register("laea", LambertAzimuthalEqualAreaProjection.class, "Lambert Azimuthal Equal Area"); - register("lagrng", LagrangeProjection.class, "Lagrange"); - register("larr", LarriveeProjection.class, "Larrivee"); - register("lask", LaskowskiProjection.class, "Laskowski"); - register("latlong", LongLatProjection.class, "Lat/Long (Geodetic alias)"); - register("longlat", LongLatProjection.class, "Lat/Long (Geodetic alias)"); - register("latlon", LongLatProjection.class, "Lat/Long (Geodetic alias)"); - register("lonlat", LongLatProjection.class, "Lat/Long (Geodetic)"); - register("lcc", LambertConformalConicProjection.class, "Lambert Conformal Conic"); - register("leac", LambertEqualAreaConicProjection.class, "Lambert Equal Area Conic"); -// register( "lee_os", Projection.class, "Lee Oblated Stereographic" ); - register("loxim", LoximuthalProjection.class, "Loximuthal"); - register("lsat", LandsatProjection.class, "Space oblique for LANDSAT"); -// register( "mbt_s", Projection.class, "McBryde-Thomas Flat-Polar Sine" ); - register("mbt_fps", McBrydeThomasFlatPolarSine2Projection.class, "McBryde-Thomas Flat-Pole Sine (No. 2)"); - register("mbtfpp", McBrydeThomasFlatPolarParabolicProjection.class, "McBride-Thomas Flat-Polar Parabolic"); - register("mbtfpq", McBrydeThomasFlatPolarQuarticProjection.class, "McBryde-Thomas Flat-Polar Quartic"); -// register( "mbtfps", Projection.class, "McBryde-Thomas Flat-Polar Sinusoidal" ); - register("merc", MercatorProjection.class, "Mercator"); -// register( "mil_os", Projection.class, "Miller Oblated Stereographic" ); - register("mill", MillerProjection.class, "Miller Cylindrical"); -// register( "mpoly", Projection.class, "Modified Polyconic" ); - register("moll", MolleweideProjection.class, "Mollweide"); - register("murd1", Murdoch1Projection.class, "Murdoch I"); - register("murd2", Murdoch2Projection.class, "Murdoch II"); - register("murd3", Murdoch3Projection.class, "Murdoch III"); - register("nell", NellProjection.class, "Nell"); -// register( "nell_h", Projection.class, "Nell-Hammer" ); - register("nicol", NicolosiProjection.class, "Nicolosi Globular"); - register("nsper", PerspectiveProjection.class, "Near-sided perspective"); - register("nzmg", NewZealandMapGridProjection.class, "New Zealand Map Grid"); -// register( "ob_tran", Projection.class, "General Oblique Transformation" ); -// register( "ocea", Projection.class, "Oblique Cylindrical Equal Area" ); -// register( "oea", Projection.class, "Oblated Equal Area" ); - register("omerc", ObliqueMercatorProjection.class, "Oblique Mercator"); -// register( "ortel", Projection.class, "Ortelius Oval" ); - register("ortho", OrthographicAzimuthalProjection.class, "Orthographic"); - register("pconic", PerspectiveConicProjection.class, "Perspective Conic"); - register("poly", PolyconicProjection.class, "Polyconic (American)"); -// register( "putp1", Projection.class, "Putnins P1" ); - register("putp2", PutninsP2Projection.class, "Putnins P2"); -// register( "putp3", Projection.class, "Putnins P3" ); -// register( "putp3p", Projection.class, "Putnins P3'" ); - register("putp4p", PutninsP4Projection.class, "Putnins P4'"); - register("putp5", PutninsP5Projection.class, "Putnins P5"); - register("putp5p", PutninsP5PProjection.class, "Putnins P5'"); -// register( "putp6", Projection.class, "Putnins P6" ); -// register( "putp6p", Projection.class, "Putnins P6'" ); - register("qua_aut", QuarticAuthalicProjection.class, "Quartic Authalic"); - register("robin", RobinsonProjection.class, "Robinson"); - register("rpoly", RectangularPolyconicProjection.class, "Rectangular Polyconic"); - register("sinu", SinusoidalProjection.class, "Sinusoidal (Sanson-Flamsteed)"); - register("somerc", SwissObliqueMercatorProjection.class, "Swiss Oblique Mercator"); - register("stere", StereographicAzimuthalProjection.class, "Stereographic"); - register("sterea", ObliqueStereographicAlternativeProjection.class, "Oblique Stereographic Alternative"); - register("tcc", TranverseCentralCylindricalProjection.class, "Transverse Central Cylindrical"); - register("tcea", TransverseCylindricalEqualArea.class, "Transverse Cylindrical Equal Area"); -// register( "tissot", TissotProjection.class, "Tissot Conic" ); - register("tmerc", TransverseMercatorProjection.class, "Transverse Mercator"); - register("etmerc", ExtendedTransverseMercatorProjection.class, "Extended Transverse Mercator"); -// register( "tpeqd", Projection.class, "Two Point Equidistant" ); -// register( "tpers", Projection.class, "Tilted perspective" ); -// register( "ups", Projection.class, "Universal Polar Stereographic" ); -// register( "urm5", Projection.class, "Urmaev V" ); - register("urmfps", UrmaevFlatPolarSinusoidalProjection.class, "Urmaev Flat-Polar Sinusoidal"); - register("utm", TransverseMercatorProjection.class, "Universal Transverse Mercator (UTM)"); - register("vandg", VanDerGrintenProjection.class, "van der Grinten (I)"); -// register( "vandg2", Projection.class, "van der Grinten II" ); -// register( "vandg3", Projection.class, "van der Grinten III" ); -// register( "vandg4", Projection.class, "van der Grinten IV" ); - register("vitk1", VitkovskyProjection.class, "Vitkovsky I"); - register("wag1", Wagner1Projection.class, "Wagner I (Kavraisky VI)"); - register("wag2", Wagner2Projection.class, "Wagner II"); - register("wag3", Wagner3Projection.class, "Wagner III"); - register("wag4", Wagner4Projection.class, "Wagner IV"); - register("wag5", Wagner5Projection.class, "Wagner V"); -// register( "wag6", Projection.class, "Wagner VI" ); - register("wag7", Wagner7Projection.class, "Wagner VII"); - register("weren", WerenskioldProjection.class, "Werenskiold I"); -// register( "wink1", Projection.class, "Winkel I" ); -// register( "wink2", Projection.class, "Winkel II" ); - register("wintri", WinkelTripelProjection.class, "Winkel Tripel"); - } - - private synchronized void initializeEsri() { - // guard against race condition - if (projRegistryEsri != null) { - return; - } - projRegistryEsri = new HashMap(); - registerEsri("Albers", AlbersProjection.class, "Albers Equal Area"); - registerEsri("Azimuthal_Equidistant", EquidistantAzimuthalProjection.class, "Azimuthal Equidistant"); - registerEsri("Airy", AiryProjection.class, "Airy"); - registerEsri("Aitoff", AitoffProjection.class, "Aitoff"); - //registerEsri( "Alaska_Albers_Equal_Area_Conic", Projection.class, "Mod. Stereographics of Alaska" ); - //registerEsri( "apian", Projection.class, "Apian Globular I" ); - registerEsri("August", AugustProjection.class, "August Epicycloidal"); - //registerEsri( "bacon", Projection.class, "Bacon Globular" ); - registerEsri("Bipolar_Oblique_Conformal_Conic", BipolarProjection.class, "Bipolar conic of western hemisphere"); - registerEsri("Boggs", BoggsProjection.class, "Boggs Eumorphic"); - registerEsri("Bonne", BonneProjection.class, "Bonne (Werner lat_1=90)"); - registerEsri("Cassini", CassiniProjection.class, "Cassini"); - registerEsri("Central_Cylindrical", CentralCylindricalProjection.class, "Central Cylindrical"); - registerEsri("Cylindrical_Equal_Area", CylindricalEqualAreaProjection.class, "Equal Area Cylindrical"); -// registerEsri( "chamb", Projection.class, "Chamberlin Trimetric" ); - registerEsri("Collignon", CollignonProjection.class, "Collignon"); - registerEsri("Craster_Parabolic", CrasterProjection.class, "Craster Parabolic (Putnins P4)"); - registerEsri("Denoyer_Semi", DenoyerProjection.class, "Denoyer Semi-Elliptical"); - registerEsri("Eckert_I", Eckert1Projection.class, "Eckert I"); - registerEsri("Eckert_II", Eckert2Projection.class, "Eckert II"); -// registerEsri( "eck3", Eckert3Projection.class, "Eckert III" ); - registerEsri("Eckert_II", Eckert4Projection.class, "Eckert IV"); - registerEsri("Eckert_V", Eckert5Projection.class, "Eckert V"); - registerEsri("Eckert_VI", Eckert6Projection.class, "Eckert VI"); - registerEsri("Equidistant_Cylindrical", PlateCarreeProjection.class, "Equidistant Cylindrical (Plate Caree)"); - registerEsri("Equidistant_Conic", EquidistantConicProjection.class, "Equidistant Conic"); - registerEsri("Euler", EulerProjection.class, "Euler"); - registerEsri("Fahey", FaheyProjection.class, "Fahey"); - registerEsri("Foucaut", FoucautProjection.class, "Foucaut"); - registerEsri("Foucaut_Sinusoidal", FoucautSinusoidalProjection.class, "Foucaut Sinusoidal"); - registerEsri("Gall_Stereographic", GallProjection.class, "Gall (Gall Stereographic)"); - registerEsri("geos", GeostationarySatelliteProjection.class, "Geostationary Satellite"); -// registerEsri( "gins8", Projection.class, "Ginsburg VIII (TsNIIGAiK)" ); -// registerEsri( "gn_sinu", Projection.class, "General Sinusoidal Series" ); - registerEsri("Gnomonic", GnomonicAzimuthalProjection.class, "Gnomonic"); - registerEsri("Goode_Homolosine", GoodeProjection.class, "Goode Homolosine"); -// registerEsri( "gs48", Projection.class, "Mod. Stererographics of 48 U.S." ); -// registerEsri( "gs50", Projection.class, "Mod. Stererographics of 50 U.S." ); - registerEsri("Hammer_Aitoff", HammerProjection.class, "Hammer & Eckert-Greifendorff"); - registerEsri("Hatano_Asymmetrical_Equal_Area", HatanoProjection.class, "Hatano Asymmetrical Equal Area"); -// registerEsri( "imw_p", Projection.class, "Internation Map of the World Polyconic" ); - registerEsri("Kavraisky_V", KavraiskyVProjection.class, "Kavraisky V"); -// registerEsri( "kav7", Projection.class, "Kavraisky VII" ); -// registerEsri( "labrd", Projection.class, "Laborde" ); - registerEsri("Lambert_Azimuthal_Equal_Area", LambertAzimuthalEqualAreaProjection.class, "Lambert Azimuthal Equal Area"); - registerEsri("Lagrange", LagrangeProjection.class, "Lagrange"); - registerEsri("Larrivee", LarriveeProjection.class, "Larrivee"); - registerEsri("Laskowski", LaskowskiProjection.class, "Laskowski"); - registerEsri("WGS84", LongLatProjection.class, "Lat/Long"); - //registerEsri( "longlat", LongLatProjection.class, "Lat/Long" ); - registerEsri("Lambert_Conformal_Conic", LambertConformalConicProjection.class, "Lambert Conformal Conic"); - registerEsri("Lambert_Equal_Area_Conic", LambertEqualAreaConicProjection.class, "Lambert Equal Area Conic"); -// registerEsri( "lee_os", Projection.class, "Lee Oblated Stereographic" ); - registerEsri("Loximuthal", LoximuthalProjection.class, "Loximuthal"); - registerEsri("Space_Oblique_Mercator", LandsatProjection.class, "Space oblique for LANDSAT"); - registerEsri("McBryde_Thomas_Flat_Polar_Sine", McBrydeThomasFlatPolarSine1Projection.class, "McBryde-Thomas Flat-Polar Sine"); - registerEsri("McBryde_Thomas_Flat_Polar_Sine2", McBrydeThomasFlatPolarSine2Projection.class, "McBryde-Thomas Flat-Pole Sine (No. 2)"); - registerEsri("McBryde_Thomas_Flat_Polar_Parabolic", McBrydeThomasFlatPolarParabolicProjection.class, "McBride-Thomas Flat-Polar Parabolic"); - registerEsri("McBryde_Thomas_Flat_Polar_Quartic", McBrydeThomasFlatPolarQuarticProjection.class, "McBryde-Thomas Flat-Polar Quartic"); -// registerEsri( "mbtfps", Projection.class, "McBryde-Thomas Flat-Polar Sinusoidal" ); - registerEsri("Mercator", MercatorProjection.class, "Mercator"); -// registerEsri( "mil_os", Projection.class, "Miller Oblated Stereographic" ); - registerEsri("MillerCylindrical", MillerProjection.class, "Miller Cylindrical"); -// registerEsri( "mpoly", Projection.class, "Modified Polyconic" ); - registerEsri("Mollweide", MolleweideProjection.class, "Mollweide"); - registerEsri("Murdoch_I", Murdoch1Projection.class, "Murdoch I"); - registerEsri("Murdoch_II", Murdoch2Projection.class, "Murdoch II"); - registerEsri("Murdoch_III", Murdoch3Projection.class, "Murdoch III"); - registerEsri("Nell", NellProjection.class, "Nell"); -// registerEsri( "nell_h", Projection.class, "Nell-Hammer" ); - registerEsri("Nicolosi_Globular", NicolosiProjection.class, "Nicolosi Globular"); - registerEsri("Perspective", PerspectiveProjection.class, "Near-sided perspective"); -// registerEsri( "nzmg", Projection.class, "New Zealand Map Grid" ); -// registerEsri( "ob_tran", Projection.class, "General Oblique Transformation" ); -// registerEsri( "ocea", Projection.class, "Oblique Cylindrical Equal Area" ); -// registerEsri( "oea", Projection.class, "Oblated Equal Area" ); - registerEsri("Hotine_Oblique_Mercator", ObliqueMercatorProjection.class, "Oblique Mercator"); -// registerEsri( "ortel", Projection.class, "Ortelius Oval" ); - registerEsri("Orthographic", OrthographicAzimuthalProjection.class, "Orthographic"); - registerEsri("Perspective_Conic", PerspectiveConicProjection.class, "Perspective Conic"); - registerEsri("Polyconic", PolyconicProjection.class, "Polyconic (American)"); -// registerEsri( "putp1", Projection.class, "Putnins P1" ); - registerEsri("Putnins_P2", PutninsP2Projection.class, "Putnins P2"); -// registerEsri( "putp3", Projection.class, "Putnins P3" ); -// registerEsri( "putp3p", Projection.class, "Putnins P3'" ); - registerEsri("Putnins_P4", PutninsP4Projection.class, "Putnins P4'"); - registerEsri("Putnins_P5", PutninsP5Projection.class, "Putnins P5"); - registerEsri("Putnins_P5P", PutninsP5PProjection.class, "Putnins P5'"); -// registerEsri( "putp6", Projection.class, "Putnins P6" ); -// registerEsri( "putp6p", Projection.class, "Putnins P6'" ); - registerEsri("Quartic_Authalic", QuarticAuthalicProjection.class, "Quartic Authalic"); - registerEsri("Robinson", RobinsonProjection.class, "Robinson"); - registerEsri("Rectangular_Polyconic", RectangularPolyconicProjection.class, "Rectangular Polyconic"); - registerEsri("Sinusoidal", SinusoidalProjection.class, "Sinusoidal (Sanson-Flamsteed)"); - registerEsri("Swiss_Oblique_Mercator", SwissObliqueMercatorProjection.class, "Swiss Oblique Mercator"); - registerEsri("stere", StereographicAzimuthalProjection.class, "Stereographic"); - registerEsri("Stereographic", StereographicAzimuthalProjection.class, "Stereographic"); - registerEsri("sterea", ObliqueStereographicAlternativeProjection.class, "Oblique Stereographic Alternative"); - registerEsri("Tranverse_Central_Cylindrical", TranverseCentralCylindricalProjection.class, "Transverse Central Cylindrical"); - registerEsri("Transverse_Cylindrical_Equal_Area", TransverseCylindricalEqualArea.class, "Transverse Cylindrical Equal Area"); -// registerEsri( "tissot", TissotProjection.class, "Tissot Conic" ); - registerEsri("Transverse_Mercator", TransverseMercatorProjection.class, "Transverse Mercator"); -// registerEsri( "tpeqd", Projection.class, "Two Point Equidistant" ); -// registerEsri( "tpers", Projection.class, "Tilted perspective" ); -// registerEsri( "ups", Projection.class, "Universal Polar Stereographic" ); -// registerEsri( "urm5", Projection.class, "Urmaev V" ); - registerEsri("Urmaev_Flat_Polar_Sinusoidal", UrmaevFlatPolarSinusoidalProjection.class, "Urmaev Flat-Polar Sinusoidal"); - registerEsri("Universal_Transverse_Mercator", TransverseMercatorProjection.class, "Universal Transverse Mercator (UTM)"); - registerEsri("Van_der_Grinten_I", VanDerGrintenProjection.class, "van der Grinten (I)"); -// registerEsri( "vandg2", Projection.class, "van der Grinten II" ); -// registerEsri( "vandg3", Projection.class, "van der Grinten III" ); -// registerEsri( "vandg4", Projection.class, "van der Grinten IV" ); - registerEsri("Vitkovsky_I", VitkovskyProjection.class, "Vitkovsky I"); - registerEsri("Wagner_I", Wagner1Projection.class, "Wagner I (Kavraisky VI)"); - registerEsri("Wagner_II", Wagner2Projection.class, "Wagner II"); - registerEsri("Wagner_III", Wagner3Projection.class, "Wagner III"); - registerEsri("Wagner_IV", Wagner4Projection.class, "Wagner IV"); - registerEsri("Wagner_V", Wagner5Projection.class, "Wagner V"); -// registerEsri( "wag6", Projection.class, "Wagner VI" ); - registerEsri("Wagner_VII", Wagner7Projection.class, "Wagner VII"); - registerEsri("Werenskiold_I", WerenskioldProjection.class, "Werenskiold I"); -// registerEsri( "wink1", Projection.class, "Winkel I" ); -// registerEsri( "wink2", Projection.class, "Winkel II" ); - registerEsri("Winkel_Tripel", WinkelTripelProjection.class, "Winkel Tripel"); - } - -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/ProjectionNames.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/ProjectionNames.java deleted file mode 100644 index 7e852c1d..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/ProjectionNames.java +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection; - -/** - * - * @author Yaqiang Wang - */ -public enum ProjectionNames { - LongLat("longlat"), - Lambert_Conformal_Conic("lcc"), - Lambert_Equal_Area_Conic("leac"), - Lambert_Azimuthal_Equal_Area("laea"), - Albers_Equal_Area("aea"), - Stereographic_Azimuthal("stere"), - North_Polar_Stereographic_Azimuthal("stere"), - South_Polar_Stereographic_Azimuthal("stere"), - Mercator("merc"), - Robinson("robin"), - Molleweide("moll"), - Orthographic_Azimuthal("ortho"), - Geostationary_Satellite("geos"), - Oblique_Stereographic_Alternative("sterea"), - Transverse_Mercator("tmerc"), - Sinusoidal("sinu"), - Cylindrical_Equal_Area("cea"), - Hammer_Eckert("hammer"), - Wagner3("wag3"), - Undefine(null); - - private final String proj4Name; - - /** - * Constructor - * @param proj4Name Proj4 name - */ - private ProjectionNames(String proj4Name) { - this.proj4Name = proj4Name; - } - - /** - * Get proj4 name - * @return Porj4 name - */ - public String getProj4Name() { - return this.proj4Name; - } - - /** - * Get projection name - * @param proj4Name Proj4 name - * @return Projection name - */ - public static ProjectionNames getName(String proj4Name) { - for (ProjectionNames name : ProjectionNames.values()) { - if (name.proj4Name.equals(proj4Name)) { - return name; - } - } - return null; - } -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/ProjectionUtil.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/ProjectionUtil.java deleted file mode 100644 index 1a257b57..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/ProjectionUtil.java +++ /dev/null @@ -1,1542 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection; - -import org.meteoinfo.common.Extent; -import org.meteoinfo.common.MIMath; -import org.meteoinfo.common.PointD; -import org.meteoinfo.geometry.graphic.Graphic; -import org.meteoinfo.geometry.graphic.GraphicCollection; -import org.meteoinfo.geometry.shape.*; -import org.meteoinfo.table.Field; -import org.meteoinfo.geometry.geoprocess.GeoComputation; -import org.meteoinfo.geometry.geoprocess.GeometryUtil; -import org.meteoinfo.geo.layer.RasterLayer; -import org.meteoinfo.geo.layer.VectorLayer; -import org.meteoinfo.ndarray.math.ArrayUtil; -import org.meteoinfo.ndarray.Array; -import org.meteoinfo.ndarray.InvalidRangeException; -import org.meteoinfo.geo.projection.info.ProjectionInfo; -import org.meteoinfo.shape.*; -import org.meteoinfo.table.DataColumn; -import org.meteoinfo.table.DataRow; -import org.meteoinfo.table.DataTable; - -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * - * @author Yaqiang Wang - */ -public class ProjectionUtil { - - /** - * Get global extent of a projection - * - * @param toProj To projection - * @return Extent - */ - public static Extent getProjectionGlobalExtent(ProjectionInfo toProj) { - ProjectionInfo fromProj = KnownCoordinateSystems.geographic.world.WGS1984; - double x, y, minX = Double.NaN, minY = Double.NaN, maxX = Double.NaN, maxY = Double.NaN; - int si = -90; - int ei = 90; - switch (toProj.getProjectionName()) { - case Lambert_Conformal_Conic: - si = -80; - break; - case North_Polar_Stereographic_Azimuthal: - si = 0; - break; - case South_Polar_Stereographic_Azimuthal: - ei = 0; - break; - } - for (int i = si; i <= ei; i++) { - y = i; - for (int j = -180; j <= 180; j++) { - x = i; - double[][] points = new double[1][]; - points[0] = new double[]{x, y}; - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, 1); - x = points[0][0]; - y = points[0][1]; - if (Double.isNaN(x) || Double.isNaN(y)) { - continue; - } - if (Double.isNaN(minX)) { - minX = x; - minY = y; - } else { - if (x < minX) { - minX = x; - } - if (y < minY) { - minY = y; - } - } - if (Double.isNaN(maxX)) { - maxX = x; - maxY = y; - } else { - if (x > maxX) { - maxX = x; - } - if (y > maxY) { - maxY = y; - } - } - } catch (Exception e) { - } - } - } - - Extent aExtent = new Extent(); - aExtent.minX = minX; - aExtent.maxX = maxX; - aExtent.minY = minY; - aExtent.maxY = maxY; - return aExtent; - } - - /** - * Get projected extent - * - * @param fromProj From projection - * @param toProj To projection - * @param x X coordinate - * @param y Y coordinate - * @return Extent - */ - public static Extent getProjectionExtent(ProjectionInfo fromProj, ProjectionInfo toProj, List x, List y) { - double[] X = new double[x.size()]; - double[] Y = new double[y.size()]; - for (int i = 0; i < X.length; i++) { - X[i] = x.get(i).doubleValue(); - } - for (int i = 0; i < Y.length; i++) { - Y[i] = y.get(i).doubleValue(); - } - return getProjectionExtent(fromProj, toProj, X, Y); - } - - /** - * Get projected extent - * - * @param fromProj From projection - * @param toProj To projection - * @param x X coordinate - * @param y Y coordinate - * @return Extent - */ - public static Extent getProjectionExtent(ProjectionInfo fromProj, ProjectionInfo toProj, - Array x, Array y) { - x = x.copyIfView(); - y = y.copyIfView(); - double[] X = (double[])ArrayUtil.copyToNDJavaArray_Double(x); - double[] Y = (double[])ArrayUtil.copyToNDJavaArray_Double(y); - return getProjectionExtent(fromProj, toProj, X, Y); - } - - /** - * Get projected extent - * - * @param fromProj From projection - * @param toProj To projection - * @param X X coordinate - * @param Y Y coordinate - * @return Extent - */ - public static Extent getProjectionExtent(ProjectionInfo fromProj, ProjectionInfo toProj, double[] X, double[] Y) { - double x, y, minX = Double.NaN, minY = Double.NaN, maxX = Double.NaN, maxY = Double.NaN; - int i, j; - int minXI = X.length, minYI = Y.length, maxXI = -1, maxYI = -1; - for (i = 0; i < Y.length; i++) { - for (j = 0; j < X.length; j++) { - double[][] points = new double[1][]; - points[0] = new double[]{X[j], Y[i]}; - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, 1); - x = points[0][0]; - y = points[0][1]; - if (Double.isNaN(x) || Double.isNaN(y)) { - continue; - } - - if (Double.isNaN(minY)) { - minY = y; - minYI = i; - } - if (i == minYI) { - if (y < minY) { - minY = y; - } - } else if (i > minYI) { - break; - } - } catch (Exception e) { - } - } - } - - for (i = Y.length - 1; i >= 0; i--) { - for (j = 0; j < X.length; j++) { - double[][] points = new double[1][]; - points[0] = new double[]{X[j], Y[i]}; - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, 1); - x = points[0][0]; - y = points[0][1]; - if (Double.isNaN(x) || Double.isNaN(y)) { - continue; - } - - if (Double.isNaN(maxY)) { - maxY = y; - maxYI = i; - } - if (i == maxYI) { - if (y > maxY) { - maxY = y; - } - } else if (i < maxYI) { - break; - } - } catch (Exception e) { - } - } - } - - for (j = 0; j < X.length; j++) { - for (i = 0; i < Y.length; i++) { - double[][] points = new double[1][]; - points[0] = new double[]{X[j], Y[i]}; - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, 1); - x = points[0][0]; - y = points[0][1]; - if (Double.isNaN(x) || Double.isNaN(y)) { - continue; - } - - if (Double.isNaN(minX)) { - minX = x; - minXI = j; - } - if (j == minXI) { - if (x < minX) { - minX = x; - } - } else if (j > minXI) { - break; - } - } catch (Exception e) { - } - } - } - - for (j = X.length - 1; j >= 0; j--) { - for (i = 0; i < Y.length; i++) { - double[][] points = new double[1][]; - points[0] = new double[]{X[j], Y[i]}; - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, 1); - x = points[0][0]; - y = points[0][1]; - if (Double.isNaN(x) || Double.isNaN(y)) { - continue; - } - - if (Double.isNaN(maxX)) { - maxX = x; - maxXI = j; - } - if (j == maxXI) { - if (x > maxX) { - maxX = x; - } - } else if (j < maxXI) { - break; - } - } catch (Exception e) { - } - } - } - - if (Double.isNaN(minX)) { - return null; - } - if (Double.isNaN(minY)) { - return null; - } - if (Double.isNaN(maxX)) { - return null; - } - if (Double.isNaN(maxY)) { - return null; - } - - if (toProj.isLonLat()) { - if (maxX < minX && maxX < 0) { - maxX += 360; - } - } - Extent aExtent = new Extent(); - aExtent.minX = minX; - aExtent.maxX = maxX; - aExtent.minY = minY; - aExtent.maxY = maxY; - - return aExtent; - } - - /** - * Get projected extent - * - * @param fromProj From projection - * @param toProj To projection - * @param X X coordinate - * @param Y Y coordinate - * @return Extent - */ - public static Extent getProjectionExtent_bak2(ProjectionInfo fromProj, ProjectionInfo toProj, double[] X, double[] Y) { - double x, y, minX = Double.NaN, minY = Double.NaN, maxX = Double.NaN, maxY = Double.NaN; - int i, j; - for (i = 0; i < Y.length; i++) { - for (j = 0; j < X.length; j++) { - double[][] points = new double[1][]; - points[0] = new double[]{X[j], Y[i]}; - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, 1); - x = points[0][0]; - y = points[0][1]; - if (Double.isNaN(x) || Double.isNaN(y)) { - continue; - } - - if (Double.isNaN(minX)) { - minX = x; - minY = y; - maxX = x; - maxY = y; - } else { - if (x < minX) { - minX = x; - } else if (x > maxX) { - maxX = x; - } - if (y < minY) { - minY = y; - } else if (y > maxY) { - maxY = y; - } - } - } catch (Exception e) { - } - } - } - - Extent aExtent = new Extent(); - aExtent.minX = minX; - aExtent.maxX = maxX; - aExtent.minY = minY; - aExtent.maxY = maxY; - - return aExtent; - } - - /** - * Get projected extent - * - * @param fromProj From projection - * @param toProj To projection - * @param X X coordinate - * @param Y Y coordinate - * @return Extent - */ - public static Extent getProjectionExtent_bak(ProjectionInfo fromProj, ProjectionInfo toProj, double[] X, double[] Y) { - double x, y, minX = Double.NaN, minY = Double.NaN, maxX = Double.NaN, maxY = Double.NaN; - int i; - for (i = 0; i < Y.length; i++) { - switch (toProj.getProjectionName()) { - case Lambert_Conformal_Conic: - if (Y[i] < -80) { - continue; - } - break; - case North_Polar_Stereographic_Azimuthal: - if (Y[i] < 0) { - continue; - } - break; - case South_Polar_Stereographic_Azimuthal: - if (Y[i] > 0) { - continue; - } - break; - } - double[][] points = new double[1][]; - points[0] = new double[]{X[0], Y[i]}; - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, 1); - x = points[0][0]; - y = points[0][1]; - if (Double.isNaN(x) || Double.isNaN(y)) { - continue; - } - - if (Double.isNaN(minX)) { - minX = x; - minY = y; - } else { - if (x < minX) { - minX = x; - } - if (y < minY) { - minY = y; - } - } - } catch (Exception e) { - continue; - } - - points[0] = new double[]{X[X.length - 1], Y[i]}; - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, 1); - x = points[0][0]; - y = points[0][1]; - if (Double.isNaN(x) || Double.isNaN(y)) { - continue; - } - - if (Double.isNaN(maxX)) { - maxY = y; - maxX = x; - } else { - if (x > maxX) { - maxX = x; - } - if (y > maxY) { - maxY = y; - } - } - } catch (Exception e) { - } - } - - int yIdx = 0; - int eyIdx = Y.length - 1; - switch (toProj.getProjectionName()) { - case Lambert_Conformal_Conic: - for (i = 0; i < Y.length; i++) { - if (Y[i] >= -80) { - yIdx = i; - break; - } - } - break; - case North_Polar_Stereographic_Azimuthal: - for (i = 0; i < Y.length; i++) { - if (Y[i] >= 0) { - yIdx = i; - break; - } - } - break; - case South_Polar_Stereographic_Azimuthal: - for (i = 0; i < Y.length; i++) { - if (Y[i] > 0) { - eyIdx = i - 1; - break; - } - } - break; - } - if (eyIdx < 0) { - eyIdx = 0; - } - - for (i = 0; i < X.length; i++) { - double[][] points = new double[1][]; - points[0] = new double[]{X[i], Y[yIdx]}; - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, 1); - x = points[0][0]; - y = points[0][1]; - if (Double.isNaN(x) || Double.isNaN(y)) { - continue; - } - - if (Double.isNaN(minX)) { - minX = x; - minY = y; - } else { - if (x < minX) { - minX = x; - } - if (y < minY) { - minY = y; - } - } - } catch (Exception e) { - continue; - } - - points[0] = new double[]{X[i], Y[eyIdx]}; - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, 1); - x = points[0][0]; - y = points[0][1]; - if (Double.isNaN(x) || Double.isNaN(y)) { - continue; - } - - if (Double.isNaN(maxX)) { - maxX = x; - maxY = y; - } else { - if (x > maxX) { - maxX = x; - } - if (y > maxY) { - maxY = y; - } - } - } catch (Exception e) { - } - } - - Extent aExtent = new Extent(); - aExtent.minX = minX; - aExtent.maxX = maxX; - aExtent.minY = minY; - aExtent.maxY = maxY; - - return aExtent; - } - - /** - * Project vector layer - * - * @param oLayer The layer - * @param toProj To projection info - */ - public static void projectLayer(VectorLayer oLayer, ProjectionInfo toProj) { - double refLon = toProj.getCoordinateReferenceSystem().getProjection().getProjectionLongitudeDegrees(); - refLon += 180; - if (refLon > 180) { - refLon = refLon - 360; - } else if (refLon < -180) { - refLon = refLon + 360; - } - projectLayer(oLayer, toProj, refLon, true); - } - - /** - * Project vector layer - * - * @param oLayer The layer - * @param toProj To projection info - * @param projectLabels If projectLabels - */ - public static void projectLayer(VectorLayer oLayer, ProjectionInfo toProj, boolean projectLabels) { - double refLon = toProj.getCoordinateReferenceSystem().getProjection().getProjectionLongitudeDegrees(); - refLon += 180; - if (refLon > 180) { - refLon = refLon - 360; - } else if (refLon < -180) { - refLon = refLon + 360; - } - projectLayer(oLayer, toProj, refLon, projectLabels); - } - - /** - * Project vector layer - * - * @param oLayer The layer - * @param toProj To projection info - * @param refCutLon Reference clip longitude - */ - public static void projectLayer(VectorLayer oLayer, ProjectionInfo toProj, double refCutLon) { - projectLayer(oLayer, toProj, refCutLon, true); - } - - /** - * Project vector layer - * - * @param oLayer The layer - * @param toProj To projection info - * @param refCutLon Reference clip longitude - * @param projectLabels If project labels - */ - public static void projectLayer(VectorLayer oLayer, ProjectionInfo toProj, double refCutLon, boolean projectLabels) { - ProjectionInfo fromProj = oLayer.getOriginProjInfo(); - if (fromProj.equals(toProj)) { - if (oLayer.isProjected()) { - oLayer.getOriginData(); - } - - return; - } - - if (oLayer.isProjected()) { - oLayer.getOriginData(); - } else { - oLayer.updateOriginData(); - } - - double refLon = refCutLon; - if (oLayer.getExtent().maxX > 180 && oLayer.getExtent().minX > refLon) { - refLon += 360; - } - - //coordinate transform process - int i, s; - ArrayList newPoints = new ArrayList(); - Extent lExtent = new Extent(); - - DataTable aTable = new DataTable(); - for (DataColumn aDC : oLayer.getAttributeTable().getTable().getColumns()) { - Field bDC = new Field(aDC.getColumnName(), aDC.getDataType()); - aTable.getColumns().add(bDC); - } - - //aLayer.AttributeTable.Table.Rows.Clear(); - float cutoff = toProj.getCutoff(); - switch (oLayer.getShapeType()) { - case Point: - case PointM: - case PointZ: - case WeatherSymbol: - case WindArraw: - case WindBarb: - case StationModel: - List shapePoints = new ArrayList<>(); - newPoints.clear(); - for (s = 0; s < oLayer.getShapeNum(); s++) { - PointShape aPS = (PointShape) oLayer.getShapes().get(s); - if (fromProj.getProjectionName() == ProjectionNames.LongLat) { - switch (toProj.getProjectionName()) { - case Lambert_Conformal_Conic: - if (aPS.getPoint().Y < cutoff) { - continue; - } - break; - case North_Polar_Stereographic_Azimuthal: - if (aPS.getPoint().Y < cutoff) { - continue; - } - break; - case South_Polar_Stereographic_Azimuthal: - if (aPS.getPoint().Y > cutoff) { - continue; - } - break; - case Mercator: - if (aPS.getPoint().Y > cutoff || aPS.getPoint().Y < -cutoff) { - continue; - } - break; - } - } - aPS = projectPointShape(aPS, fromProj, toProj); - if (aPS != null) { - shapePoints.add(aPS); - newPoints.add(aPS.getPoint()); - - DataRow aDR = oLayer.getAttributeTable().getTable().getRows().get(s); - try { - aTable.addRow(aDR); - } catch (Exception ex) { - Logger.getLogger(ProjectionUtil.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - oLayer.setShapes(new ArrayList<>(shapePoints)); - oLayer.setExtent(GeometryUtil.getPointsExtent(newPoints)); - - break; - case Polyline: - case PolylineM: - case PolylineZ: - List newPolylines = new ArrayList<>(); - for (s = 0; s < oLayer.getShapeNum(); s++) { - PolylineShape aPLS = (PolylineShape) oLayer.getShapes().get(s); - List plsList = new ArrayList<>(); - if (fromProj.getProjectionName() == ProjectionNames.LongLat) { - switch (toProj.getProjectionName()) { - case Lambert_Conformal_Conic: - if (aPLS.getExtent().minY < cutoff) { - aPLS = GeoComputation.clipPolylineShape_Lat(aPLS, cutoff, true); - } - break; - case North_Polar_Stereographic_Azimuthal: - if (aPLS.getExtent().minY < cutoff) { - //continue; - aPLS = GeoComputation.clipPolylineShape_Lat(aPLS, cutoff, true); - } - break; - case South_Polar_Stereographic_Azimuthal: - if (aPLS.getExtent().maxY > cutoff) { - //continue; - aPLS = GeoComputation.clipPolylineShape_Lat(aPLS, cutoff, false); - } - break; - case Mercator: - if (aPLS.getExtent().maxY > cutoff) { - aPLS = GeoComputation.clipPolylineShape_Lat(aPLS, cutoff, false); - } - if (aPLS.getExtent().minY < -cutoff) { - aPLS = GeoComputation.clipPolylineShape_Lat(aPLS, -cutoff, true); - } - break; - } - if (aPLS == null) { - continue; - } - -// aPLS = GeoComputation.clipPolylineShape_Lon(aPLS, refLon); -// if (aPLS == null) { -// continue; -// } - if (aPLS.getExtent().minX <= refLon && aPLS.getExtent().maxX >= refLon) { - switch (toProj.getProjectionName()) { - case North_Polar_Stereographic_Azimuthal: - case South_Polar_Stereographic_Azimuthal: - plsList.add(aPLS); - break; - default: - plsList.add(GeoComputation.clipPolylineShape_Lon(aPLS, refLon)); - break; - } - } else { - plsList.add(aPLS); - } - } else { - plsList.add(aPLS); - } - for (i = 0; i < plsList.size(); i++) { - aPLS = plsList.get(i); - aPLS = projectPolylineShape(aPLS, fromProj, toProj); - if (aPLS != null) { - newPolylines.add(aPLS); - - DataRow aDR = oLayer.getAttributeTable().getTable().getRows().get(s); - try { - aTable.addRow(aDR); - } catch (Exception ex) { - Logger.getLogger(ProjectionUtil.class.getName()).log(Level.SEVERE, null, ex); - } - - if (s == 0 && i == 0) { - lExtent = (Extent) aPLS.getExtent().clone(); - } else { - lExtent = MIMath.getLagerExtent(lExtent, aPLS.getExtent()); - } - } - } - } - oLayer.setShapes(new ArrayList<>(newPolylines)); - newPolylines.clear(); - oLayer.setExtent(lExtent); - break; - case Polygon: - case PolygonM: - case PolygonZ: - List newPolygons = new ArrayList<>(); - for (s = 0; s < oLayer.getShapeNum(); s++) { - DataRow aDR = oLayer.getAttributeTable().getTable().getRows().get(s); - PolygonShape aPGS = (PolygonShape) oLayer.getShapes().get(s); - List pgsList = new ArrayList<>(); - if (fromProj.getProjectionName() == ProjectionNames.LongLat) { - switch (toProj.getProjectionName()) { - case Lambert_Conformal_Conic: - if (aPGS.getExtent().minY < cutoff) { - aPGS = GeoComputation.clipPolygonShape_Lat(aPGS, cutoff, true); - } - break; - case North_Polar_Stereographic_Azimuthal: - if (aPGS.getExtent().minY < cutoff) { - //continue; - aPGS = GeoComputation.clipPolygonShape_Lat(aPGS, cutoff, true); - } - break; - case South_Polar_Stereographic_Azimuthal: - if (aPGS.getExtent().maxY > cutoff) { - //continue; - aPGS = GeoComputation.clipPolygonShape_Lat(aPGS, cutoff, false); - } - break; - case Mercator: - if (aPGS.getExtent().maxY > cutoff) { - aPGS = GeoComputation.clipPolygonShape_Lat(aPGS, cutoff, false); - } - if (aPGS.getExtent().minY < -cutoff) { - aPGS = GeoComputation.clipPolygonShape_Lat(aPGS, -cutoff, true); - } - break; - } - if (aPGS == null) { - continue; - } - - if (aPGS.getExtent().minX <= refLon && aPGS.getExtent().maxX >= refLon) { - switch (toProj.getProjectionName()) { - case North_Polar_Stereographic_Azimuthal: - case South_Polar_Stereographic_Azimuthal: - pgsList.add(aPGS); - break; - default: - pgsList.add(GeoComputation.clipPolygonShape_Lon(aPGS, refLon)); - break; - } - } else { - pgsList.add(aPGS); - } - } else { - pgsList.add(aPGS); - } - for (i = 0; i < pgsList.size(); i++) { - aPGS = pgsList.get(i); - aPGS = projectPolygonShape(aPGS, fromProj, toProj); - if (aPGS != null) { - newPolygons.add(aPGS); - - aTable.getRows().add(aDR); - - if (s == 0) { - lExtent = (Extent) aPGS.getExtent().clone(); - } else { - lExtent = MIMath.getLagerExtent(lExtent, aPGS.getExtent()); - } - } - } - } - oLayer.setShapes(new ArrayList<>(newPolygons)); - newPolygons.clear(); - oLayer.setExtent(lExtent); - break; - } - oLayer.getAttributeTable().setTable(aTable); - oLayer.setProjInfo(toProj); - - if (oLayer.getLabelPoints().size() > 0) { - if (projectLabels) { - oLayer.setLabelPoints(projectGraphics(oLayer.getLabelPoints(), fromProj, toProj)); - } else { - oLayer.setLabelPoints(new ArrayList<>(oLayer.getLabelPoints())); - } - } - } - - /** - * Project raster layer - * - * @param oLayer The layer - * @param toProj To projection - */ - public static void projectLayer(RasterLayer oLayer, ProjectionInfo toProj) { - try { - if (oLayer.getProjInfo().toProj4String().equals(toProj.toProj4String())) { - if (oLayer.isProjected()) { - oLayer.getOriginData(); - oLayer.updateGridData(); - if (oLayer.getLegendScheme().getBreakNum() < 50) { - oLayer.updateImage(); - } else { - oLayer.setPaletteByLegend(); - } - } - return; - } - - if (!oLayer.isProjected()) { - oLayer.updateOriginData(); - } else { - oLayer.getOriginData(); - } - - oLayer.setGridData(oLayer.getGridData().project(oLayer.getProjInfo(), toProj)); - oLayer.updateImage(oLayer.getLegendScheme()); - } catch (InvalidRangeException ex) { - Logger.getLogger(ProjectionUtil.class.getName()).log(Level.SEVERE, null, ex); - } - } - - /** - * Project layer angle - * - * @param oLayer The layer - * @param fromProj From projection - * @param toProj To projection - * @return VectorLayer - */ - public static VectorLayer projectLayerAngle(VectorLayer oLayer, ProjectionInfo fromProj, ProjectionInfo toProj) { - //coordinate transform process - ArrayList newPoints = new ArrayList(); - - VectorLayer aLayer = (VectorLayer) oLayer.clone(); - - //aLayer.AttributeTable.Table = oLayer.AttributeTable.Table.Clone(); - DataTable aTable = new DataTable(); - for (DataColumn aDC : oLayer.getAttributeTable().getTable().getColumns()) { - Field bDC = new Field(aDC.getColumnName(), aDC.getDataType()); - aTable.getColumns().add(bDC); - } - - int s; - List vectors = new ArrayList<>(); - newPoints.clear(); - for (s = 0; s < aLayer.getShapeNum(); s++) { - PointShape aPS = (PointShape) aLayer.getShapes().get(s); - if (fromProj.getProjectionName() == ProjectionNames.LongLat) { - switch (toProj.getProjectionName()) { - case Lambert_Conformal_Conic: - case North_Polar_Stereographic_Azimuthal: - if (aPS.getPoint().X < -89) { - continue; - } - break; - case South_Polar_Stereographic_Azimuthal: - if (aPS.getPoint().Y > 89) { - continue; - } - break; - } - } - double[] fromP = new double[]{aPS.getPoint().X, aPS.getPoint().Y}; - double[] toP; - double[][] points = new double[1][]; - points[0] = (double[]) fromP.clone(); - try { - //Reproject point back to fromProj - Reproject.reprojectPoints(points, toProj, fromProj, 0, points.length); - toP = points[0]; - switch (aLayer.getLayerDrawType()) { - case Vector: - ((WindArrow) aPS).angle = projectAngle(((WindArrow) aPS).angle, toP, fromP, fromProj, toProj); - break; - case Barb: - ((WindBarb) aPS).angle = projectAngle(((WindBarb) aPS).angle, toP, fromP, fromProj, toProj); - break; - case StationModel: - ((StationModelShape) aPS).windBarb.angle = projectAngle(((StationModelShape) aPS).windBarb.angle, toP, fromP, fromProj, toProj); - break; - } - newPoints.add(aPS.getPoint()); - vectors.add(aPS); - - DataRow aDR = oLayer.getAttributeTable().getTable().getRows().get(s); - aTable.getRows().add(aDR); - } catch (Exception e) { - } - } - aLayer.setShapes(new ArrayList<>(vectors)); - aLayer.setExtent(GeometryUtil.getPointsExtent(newPoints)); - aLayer.getAttributeTable().setTable(aTable); - - return aLayer; - } - - /** - * Project wind layer - * - * @param oLayer Origin layer - * @param toProj To projection - * @param IfReprojectAngle If reproject wind angle - */ - public static void projectWindLayer(VectorLayer oLayer, ProjectionInfo toProj, boolean IfReprojectAngle) { - ProjectionInfo fromProj = oLayer.getProjInfo(); - if (fromProj.toProj4String().equals(toProj.toProj4String())) { - if (oLayer.isProjected()) { - oLayer.getOriginData(); - } - - return; - } - - if (oLayer.isProjected()) { - oLayer.getOriginData(); - } else { - oLayer.updateOriginData(); - } - - //Set reference longitude - double refLon = toProj.getRefCutLon(); - if (oLayer.getExtent().maxX > 180 && oLayer.getExtent().minX > refLon) { - refLon += 360; - } - - //coordinate transform process - int s; - //PointD wPoint = new PointD(); - PointD aPoint; - List newPoints = new ArrayList<>(); - //Extent lExtent = new Extent(); - - DataTable aTable = new DataTable(); - for (DataColumn aDC : oLayer.getAttributeTable().getTable().getColumns()) { - Field bDC = new Field(aDC.getColumnName(), aDC.getDataType()); - aTable.getColumns().add(bDC); - } - - List shapes = new ArrayList<>(); - newPoints.clear(); - for (s = 0; s < oLayer.getShapeNum(); s++) { - PointShape aPS = (PointShape) oLayer.getShapes().get(s); - if (fromProj.getProjectionName() == ProjectionNames.LongLat) { - switch (toProj.getProjectionName()) { - case Lambert_Conformal_Conic: - case North_Polar_Stereographic_Azimuthal: - if (aPS.getPoint().Y < -89) { - continue; - } - break; - case South_Polar_Stereographic_Azimuthal: - if (aPS.getPoint().Y > 89) { - continue; - } - break; - } - } - double[] fromP = new double[]{aPS.getPoint().X, aPS.getPoint().Y}; - double[] toP; - double[][] points = new double[1][]; - points[0] = (double[]) fromP.clone(); - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, points.length); - toP = points[0]; - aPoint = new PointD(); - aPoint.X = (float) toP[0]; - aPoint.Y = (float) toP[1]; - aPS.setPoint(aPoint); - if (IfReprojectAngle) { - switch (oLayer.getLayerDrawType()) { - case Vector: - ((WindArrow) aPS).angle = projectAngle(((WindArrow) aPS).angle, fromP, toP, fromProj, toProj); - break; - case Barb: - ((WindBarb) aPS).angle = projectAngle(((WindBarb) aPS).angle, fromP, toP, fromProj, toProj); - break; - case StationModel: - ((StationModelShape) aPS).windBarb.angle = projectAngle(((StationModelShape) aPS).windBarb.angle, fromP, toP, fromProj, toProj); - break; - } - } - newPoints.add(aPoint); - shapes.add(aPS); - - DataRow aDR = oLayer.getAttributeTable().getTable().getRows().get(s); - aTable.getRows().add(aDR); - } catch (Exception e) { - } - } - oLayer.setShapes(new ArrayList<>(shapes)); - oLayer.setExtent(GeometryUtil.getPointsExtent(newPoints)); - oLayer.getAttributeTable().setTable(aTable); - - if (oLayer.getLabelPoints().size() > 0) { - oLayer.setLabelPoints(projectGraphics(oLayer.getLabelPoints(), fromProj, toProj)); - } - } - - private static PointShape projectPointShape(PointShape aPS, ProjectionInfo fromProj, ProjectionInfo toProj) { - PointShape newPS = (PointShape) aPS.clone(); - double[][] points = new double[1][]; - PointD oP = newPS.getPoint(); - points[0] = new double[]{oP.X, oP.Y}; - double[] fromP = new double[]{oP.X, oP.Y}; - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, points.length); - if (!Double.isNaN(points[0][0]) && !Double.isNaN(points[0][1])) { - double[] toP = points[0]; - PointD rp = (PointD) oP.clone(); - rp.X = points[0][0]; - rp.Y = points[0][1]; - newPS.setPoint(rp); - switch (aPS.getShapeType()) { - case WindBarb: - ((WindBarb) newPS).angle = projectAngle(((WindBarb) newPS).angle, fromP, toP, fromProj, toProj); - break; - case WindArraw: - ((WindArrow) newPS).angle = projectAngle(((WindArrow) newPS).angle, fromP, toP, fromProj, toProj); - break; - case StationModel: - ((StationModelShape) newPS).windBarb.angle = projectAngle(((StationModelShape) newPS).windBarb.angle, fromP, toP, fromProj, toProj); - break; - } - return newPS; - } else { - return null; - } - } catch (Exception e) { - return null; - } - } - - private static PolylineShape projectPolylineShape(PolylineShape aPLS, ProjectionInfo fromProj, ProjectionInfo toProj) { - List polyLines = new ArrayList<>(); - for (int i = 0; i < aPLS.getPolylines().size(); i++) { - List newPoints = new ArrayList<>(); - Polyline aPL = aPLS.getPolylines().get(i); - Polyline bPL; - double x; - for (int j = 0; j < aPL.getPointList().size(); j++) { - double[][] points = new double[1][]; - PointD wPoint = aPL.getPointList().get(j); - x = wPoint.X; - if (fromProj.isLonLat()) { - if (x > 180) { - x -= 360; - } else if (x < -180) { - x += 360; - } - } - points[0] = new double[]{x, wPoint.Y}; - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, points.length); - if (!Double.isNaN(points[0][0]) && !Double.isNaN(points[0][1])) { - //wPoint = new PointD(); - wPoint.X = points[0][0]; - wPoint.Y = points[0][1]; - newPoints.add(wPoint); - } - } catch (Exception e) { - break; - } - } - - if (newPoints.size() > 1) { - bPL = new Polyline(); - bPL.setPointList(newPoints); - polyLines.add(bPL); - } - } - - if (polyLines.size() > 0) { - aPLS.setPolylines(polyLines); - - return aPLS; - } else { - return null; - } - } - - /** - * Project angle - * - * @param oAngle The angle - * @param fromP1 From point - * @param toP1 To point - * @param fromProj From projection - * @param toProj To projection - * @return Projected angle - */ - public static double projectAngle(double oAngle, double[] fromP1, double[] toP1, ProjectionInfo fromProj, ProjectionInfo toProj) { - double pAngle = oAngle; - double[] fromP2; - double[] toP2; - double[][] points = new double[1][]; - - if (fromP1[1] == 90) { - fromP2 = new double[]{fromP1[0], fromP1[1] - 10}; - points[0] = (double[]) fromP2.clone(); - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, points.length); - toP2 = points[0]; - double x, y; - x = toP2[0] - toP1[0]; - y = toP2[1] - toP1[1]; - double aLen = Math.sqrt(x * x + y * y); - double angle = Math.asin(x / aLen) * 180 / Math.PI; - if (x < 0 && y < 0) { - angle = 180.0 - angle; - } else if (x > 0 && y < 0) { - angle = 180.0 - angle; - } else if (x < 0 && y > 0) { - angle = 360.0 + angle; - } - if (aLen == 0) { - System.out.print("Error"); - } - pAngle = oAngle + (angle - 180); - if (pAngle > 360) { - pAngle = pAngle - 360; - } else if (pAngle < 0) { - pAngle = pAngle + 360; - } - } catch (Exception e) { - } - } else { - fromP2 = new double[]{fromP1[0] + 10, fromP1[1]}; - points[0] = (double[]) fromP2.clone(); - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, points.length); - toP2 = points[0]; - - double x, y; - x = toP2[0] - toP1[0]; - y = toP2[1] - toP1[1]; - double aLen = Math.sqrt(x * x + y * y); - if (aLen == 0) { - return pAngle; - } - - double angle = Math.asin(x / aLen) * 180 / Math.PI; - if (Double.isNaN(angle)) { - return pAngle; - } - - if (x < 0 && y < 0) { - angle = 180.0 - angle; - } else if (x > 0 && y < 0) { - angle = 180.0 - angle; - } else if (x < 0 && y > 0) { - angle = 360.0 + angle; - } - - pAngle = oAngle + (angle - 90); - if (pAngle > 360) { - pAngle = pAngle - 360; - } else if (pAngle < 0) { - pAngle = pAngle + 360; - } - } catch (Exception e) { - } - } - - return pAngle; - } - - /** - * Project polygon shape - * - * @param aPGS A polygon shape - * @param fromProj From projection - * @param toProj To porjection - * @return Projected polygon shape - */ - public static PolygonShape projectPolygonShape(PolygonShape aPGS, ProjectionInfo fromProj, ProjectionInfo toProj) { - List polygons = new ArrayList<>(); - for (int i = 0; i < aPGS.getPolygons().size(); i++) { - Polygon aPG = aPGS.getPolygons().get(i); - Polygon bPG = null; - for (int r = 0; r < aPG.getRingNumber(); r++) { - List pList = (List) aPG.getRings().get(r); - List newPoints = new ArrayList<>(); - for (int j = 0; j < pList.size(); j++) { - double[][] points = new double[1][]; - PointD wPoint = pList.get(j); - points[0] = new double[]{wPoint.X, wPoint.Y}; - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, points.length); - if (!Double.isNaN(points[0][0]) && !Double.isNaN(points[0][1])) { - wPoint = new PointD(); - wPoint.X = points[0][0]; - wPoint.Y = points[0][1]; - newPoints.add(wPoint); - } - } catch (Exception e) { - break; - } - } - - if (r == 0) { - if (newPoints.size() > 2) { - bPG = new Polygon(); - bPG.setOutLine(newPoints); - } else { - break; - } - } else { - if (newPoints.size() > 2) { - bPG.addHole(newPoints); - } - } - } - - if (bPG != null) { - polygons.add(bPG); - } - } - - if (polygons.size() > 0) { - aPGS.setPolygons(polygons); - - return aPGS; - } else { - return null; - } - } - - /** - * Project graphic - * - * @param graphic The graphic - * @param fromProj From projection - * @param toProj To projection - * @return Projected graphic - */ - public static Graphic projectGraphic(Graphic graphic, ProjectionInfo fromProj, ProjectionInfo toProj) { - Shape shape = projectShape(graphic.getShape(), fromProj, toProj); - return new Graphic(shape, graphic.getLegend()); - } - - private static GraphicCollection projectGraphics(GraphicCollection aGCollection, ProjectionInfo fromProj, ProjectionInfo toProj) { - GraphicCollection newGCollection = new GraphicCollection(); - for (Graphic aGraphic : aGCollection.getGraphics()) { - aGraphic.setShape(projectShape(aGraphic.getShape(), fromProj, toProj)); - if (aGraphic.getShape() != null) { - newGCollection.add(aGraphic); - } - } - - return newGCollection; - } - - private static List projectGraphics(List graphics, ProjectionInfo fromProj, ProjectionInfo toProj) { - List newGraphics = new ArrayList<>(); - for (Graphic aGraphic : graphics) { - Shape aShape = projectShape(aGraphic.getShape(), fromProj, toProj); - if (aShape != null) { - newGraphics.add(new Graphic(aShape, aGraphic.getLegend())); - } - } - - return newGraphics; - } - - private static Shape projectShape(Shape aShape, ProjectionInfo fromProj, ProjectionInfo toProj) { - Shape newShape; - switch (aShape.getShapeType()) { - case Point: - case PointM: - newShape = projectPointShape((PointShape) aShape, fromProj, toProj); - break; - case Polyline: - case PolylineM: - newShape = projectPolylineShape((PolylineShape) aShape, fromProj, toProj); - break; - case CurveLine: - newShape = projectCurvelineShape((CurveLineShape) aShape, fromProj, toProj); - break; - case Polygon: - case PolygonM: - case Rectangle: - newShape = projectPolygonShape((PolygonShape) aShape, fromProj, toProj); - break; - case CurvePolygon: - newShape = projectCurvePolygonShape((CurvePolygonShape) aShape, fromProj, toProj); - break; - case Circle: - newShape = projectCircleShape((CircleShape) aShape, fromProj, toProj); - break; - case Ellipse: - newShape = projectEllipseShape((EllipseShape) aShape, fromProj, toProj); - break; - default: - newShape = null; - break; - } - - return newShape; - } - - private static CurveLineShape projectCurvelineShape(CurveLineShape aPLS, ProjectionInfo fromProj, ProjectionInfo toProj) { - List polyLines = new ArrayList<>(); - for (int i = 0; i < aPLS.getPolylines().size(); i++) { - List newPoints = new ArrayList<>(); - Polyline aPL = aPLS.getPolylines().get(i); - Polyline bPL; - for (int j = 0; j < aPL.getPointList().size(); j++) { - double[][] points = new double[1][]; - PointD wPoint = aPL.getPointList().get(j); - points[0] = new double[]{wPoint.X, wPoint.Y}; - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, points.length); - if (!Double.isNaN(points[0][0]) && !Double.isNaN(points[0][1])) { - wPoint = new PointD(); - wPoint.X = points[0][0]; - wPoint.Y = points[0][1]; - newPoints.add(wPoint); - } - } catch (Exception e) { - break; - } - } - - if (newPoints.size() > 1) { - bPL = new Polyline(); - bPL.setPointList(newPoints); - polyLines.add(bPL); - } - } - - if (polyLines.size() > 0) { - aPLS.setPolylines(polyLines); - - return aPLS; - } else { - return null; - } - } - - private static CurvePolygonShape projectCurvePolygonShape(CurvePolygonShape aPGS, ProjectionInfo fromProj, ProjectionInfo toProj) { - List polygons = new ArrayList<>(); - for (int i = 0; i < aPGS.getPolygons().size(); i++) { - Polygon aPG = aPGS.getPolygons().get(i); - Polygon bPG = null; - for (int r = 0; r < aPG.getRingNumber(); r++) { - List pList = (List) aPG.getRings().get(r); - List newPoints = new ArrayList<>(); - for (int j = 0; j < pList.size(); j++) { - double[][] points = new double[1][]; - PointD wPoint = pList.get(j); - points[0] = new double[]{wPoint.X, wPoint.Y}; - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, points.length); - if (!Double.isNaN(points[0][0]) && !Double.isNaN(points[0][1])) { - wPoint = new PointD(); - wPoint.X = points[0][0]; - wPoint.Y = points[0][1]; - newPoints.add(wPoint); - } - } catch (Exception e) { - break; - } - } - - if (r == 0) { - if (newPoints.size() > 2) { - bPG = new Polygon(); - bPG.setOutLine(newPoints); - } else { - break; - } - } else { - if (newPoints.size() > 2) { - bPG.addHole(newPoints); - } - } - } - - if (bPG != null) { - polygons.add(bPG); - } - } - - if (polygons.size() > 0) { - aPGS.setPolygons(polygons); - - return aPGS; - } else { - return null; - } - } - - private static CircleShape projectCircleShape(CircleShape aCS, ProjectionInfo fromProj, ProjectionInfo toProj) { - double radius = Math.abs(aCS.getPoints().get(1).X - aCS.getPoints().get(0).X); - double[][] points = new double[1][]; - PointD centerPoint = new PointD(aCS.getPoints().get(0).X + radius, aCS.getPoints().get(0).Y); - points[0] = new double[]{centerPoint.X, centerPoint.Y}; - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, points.length); - if (!Double.isNaN(points[0][0]) && !Double.isNaN(points[0][1])) { - centerPoint.X = points[0][0]; - centerPoint.Y = points[0][1]; - } else { - return null; - } - } catch (Exception e) { - return null; - } - - points = new double[1][]; - PointD leftPoint = aCS.getPoints().get(0); - points[0] = new double[]{leftPoint.X, leftPoint.Y}; - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, points.length); - if (!Double.isNaN(points[0][0]) && !Double.isNaN(points[0][1])) { - leftPoint.X = points[0][0]; - leftPoint.Y = points[0][1]; - } else { - return null; - } - } catch (Exception e) { - return null; - } - - radius = Math.abs(centerPoint.X - leftPoint.X); - List newPoints = new ArrayList<>(); - newPoints.add(new PointD(centerPoint.X - radius, centerPoint.Y)); - newPoints.add(new PointD(centerPoint.X, centerPoint.Y - radius)); - newPoints.add(new PointD(centerPoint.X + radius, centerPoint.Y)); - newPoints.add(new PointD(centerPoint.X, centerPoint.Y + radius)); - CircleShape newCS = new CircleShape(); - newCS.setPoints(newPoints); - - return newCS; - } - - private static EllipseShape projectEllipseShape(EllipseShape aES, ProjectionInfo fromProj, ProjectionInfo toProj) { - double xRadius = Math.abs(aES.getPoints().get(2).X - aES.getPoints().get(0).X) / 2; - double yRadius = Math.abs(aES.getPoints().get(2).Y - aES.getPoints().get(0).Y) / 2; - double[][] points = new double[1][]; - PointD centerPoint = new PointD(aES.getExtent().minX + xRadius, aES.getExtent().minY + yRadius); - points[0] = new double[]{centerPoint.X, centerPoint.Y}; - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, points.length); - if (!Double.isNaN(points[0][0]) && !Double.isNaN(points[0][1])) { - centerPoint.X = points[0][0]; - centerPoint.Y = points[0][1]; - } else { - return null; - } - } catch (Exception e) { - return null; - } - - points = new double[1][]; - PointD lbPoint = new PointD(aES.getExtent().minX, aES.getExtent().minY); - points[0] = new double[]{lbPoint.X, lbPoint.Y}; - try { - Reproject.reprojectPoints(points, fromProj, toProj, 0, points.length); - if (!Double.isNaN(points[0][0]) && !Double.isNaN(points[0][1])) { - lbPoint.X = points[0][0]; - lbPoint.Y = points[0][1]; - } else { - return null; - } - } catch (Exception e) { - return null; - } - - xRadius = Math.abs(centerPoint.X - lbPoint.X); - yRadius = Math.abs(centerPoint.Y - lbPoint.Y); - List newPoints = new ArrayList<>(); - newPoints.add(new PointD(centerPoint.X - xRadius, centerPoint.Y - yRadius)); - newPoints.add(new PointD(centerPoint.X - xRadius, centerPoint.Y + yRadius)); - newPoints.add(new PointD(centerPoint.X + xRadius, centerPoint.Y + yRadius)); - newPoints.add(new PointD(centerPoint.X + xRadius, centerPoint.Y - yRadius)); - EllipseShape newES = new EllipseShape(); - newES.setPoints(newPoints); - - return newES; - } - -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/Reproject.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/Reproject.java deleted file mode 100644 index bf23ca86..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/Reproject.java +++ /dev/null @@ -1,585 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection; - -import org.locationtech.proj4j.CoordinateReferenceSystem; -import org.locationtech.proj4j.CoordinateTransform; -import org.locationtech.proj4j.CoordinateTransformFactory; -import org.locationtech.proj4j.ProjCoordinate; -import org.meteoinfo.common.Extent; -import org.meteoinfo.common.PointD; -import org.meteoinfo.geometry.geoprocess.GeometryUtil; -import org.meteoinfo.geo.analysis.ResampleMethods; -import org.meteoinfo.math.ArrayUtil; -import org.meteoinfo.ndarray.*; -import org.meteoinfo.geo.projection.info.ProjectionInfo; -import org.meteoinfo.geometry.shape.PolygonShape; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * - * @author Yaqiang Wang - */ -public class Reproject { - - private static final CoordinateTransformFactory ctFactory = new CoordinateTransformFactory(); - - /** - * Reproject a point - * @param x X - * @param y Y - * @param source Source projection info - * @param dest Destination projection info - * @return Projected point - */ - public static PointD reprojectPoint(double x, double y, ProjectionInfo source, ProjectionInfo dest) { - double[][] points = new double[1][]; - points[0] = new double[]{x, y}; - Reproject.reprojectPoints(points, source, dest, 0, points.length); - PointD rPoint = new PointD(points[0][0], points[0][1]); - - return rPoint; - } - - /** - * Reproject a point - * @param point The point - * @param source Source projection info - * @param dest Destination projection info - * @return Projected point - */ - public static PointD reprojectPoint(PointD point, ProjectionInfo source, ProjectionInfo dest) { - return reprojectPoint(point.X, point.Y, source, dest); - } - - /** - * Reproject a point - * @param points The points - * @param source Source projection info - * @param dest Destination projection info - */ - public static void reprojectPoints(double[][] points, ProjectionInfo source, ProjectionInfo dest) { - reprojectPoints(points, source, dest, 0, points.length); - } - - /** - * Reproject points - * - * @param points The points - * @param source Source projection info - * @param dest Destination projection info - * @param startIndex Start index - * @param numPoints Point number - */ - public static void reprojectPoints(double[][] points, ProjectionInfo source, ProjectionInfo dest, int startIndex, int numPoints) { - CoordinateTransform trans = ctFactory.createTransform(source.getCoordinateReferenceSystem(), dest.getCoordinateReferenceSystem()); - if (source.getProjectionName() == ProjectionNames.LongLat) { - for (int i = startIndex; i < startIndex + numPoints; i++) { - if (i >= points.length) { - break; - } - if (points[i][0] > 180.0) { - points[i][0] -= 360; - } else if (points[i][0] < -180) { - points[i][0] += 360; - } - } - } - for (int i = startIndex; i < startIndex + numPoints; i++) { - if (i >= points.length) { - break; - } - ProjCoordinate p1 = new ProjCoordinate(points[i][0], points[i][1]); - ProjCoordinate p2 = new ProjCoordinate(); - trans.transform(p1, p2); - points[i][0] = p2.x; - points[i][1] = p2.y; - } - } - - /** - * Project grid data - * - * @param data Data array - * @param xx X array - * @param yy Y array - * @param fromProj From projection - * @param toProj To projection - * @param method Resample method - * @return Porjected grid data - * @throws InvalidRangeException - */ - public static Object[] reproject(Array data, List xx, List yy, CoordinateReferenceSystem fromProj, - CoordinateReferenceSystem toProj, ResampleMethods method) throws InvalidRangeException { - return reproject(data, xx, yy, ProjectionInfo.factory(fromProj), ProjectionInfo.factory(toProj), method); - } - - /** - * Project grid data - * - * @param data Data array - * @param xx X array - * @param yy Y array - * @param fromProj From projection - * @param toProj To projection - * @return Porjected grid data - * @throws InvalidRangeException - */ - public static Object[] reprojectGrid(Array data, Array xx, Array yy, ProjectionInfo fromProj, - ProjectionInfo toProj) throws InvalidRangeException { - //Get destination projection extent - Extent aExtent; - int xnum = (int)xx.getSize(); - int ynum = (int)yy.getSize(); - aExtent = ProjectionUtil.getProjectionExtent(fromProj, toProj, xx, yy); - - double xDelt = (aExtent.maxX - aExtent.minX) / (xnum - 1); - double yDelt = (aExtent.maxY - aExtent.minY) / (ynum - 1); - int i; - Array rx = Array.factory(DataType.DOUBLE, new int[]{xnum}); - Array ry = Array.factory(DataType.DOUBLE, new int[]{ynum}); - for (i = 0; i < xnum; i++) { - rx.setDouble(i, aExtent.minX + i * xDelt); - } - for (i = 0; i < ynum; i++) { - ry.setDouble(i, aExtent.minY + i * yDelt); - } - - //Projection data - Array[] gxy = ArrayUtil.meshgrid(xx, yy); - Array[] pxy = reproject(gxy[0], gxy[1], fromProj, toProj); - Array px = pxy[0]; - Array py = pxy[1]; - - //Interpolation data - Array r = ArrayUtil.interpolation_Nearest(px, py, data, rx, ry, Double.POSITIVE_INFINITY); - - //Convexhull maskout - PolygonShape polyshape = GeometryUtil.convexHull(px, py); - Array[] rxy = ArrayUtil.meshgrid(rx, ry); - List pss = new ArrayList<>(); - pss.add(polyshape); - r = GeometryUtil.maskout(r, rxy[0], rxy[1], pss); - - return new Object[]{r, rx, ry}; - } - - /** - * Project grid data - * - * @param data Data array - * @param xx X array - * @param yy Y array - * @param fromProj From projection - * @param toProj To projection - * @param method Resample method - * @return Porjected grid data - * @throws InvalidRangeException - */ - public static Object[] reproject(Array data, List xx, List yy, ProjectionInfo fromProj, - ProjectionInfo toProj, ResampleMethods method) throws InvalidRangeException { - Extent aExtent; - int xnum = xx.size(); - int ynum = yy.size(); - aExtent = ProjectionUtil.getProjectionExtent(fromProj, toProj, xx, yy); - - double xDelt = (aExtent.maxX - aExtent.minX) / (xnum - 1); - double yDelt = (aExtent.maxY - aExtent.minY) / (ynum - 1); - int i; - Array rx = Array.factory(DataType.DOUBLE, new int[]{xnum}); - Array ry = Array.factory(DataType.DOUBLE, new int[]{ynum}); - for (i = 0; i < xnum; i++) { - rx.setDouble(i, aExtent.minX + i * xDelt); - } - - for (i = 0; i < ynum; i++) { - ry.setDouble(i, aExtent.minY + i * yDelt); - } - - Array[] rr = ArrayUtil.meshgrid(rx, ry); - - Array r = reproject(data, xx, yy, rr[0], rr[1], fromProj, toProj, method); - - return new Object[]{r, rx, ry}; - } - - /** - * Project grid data - * - * @param data Data array - * @param xx X array - * @param yy Y array - * @param fromProj From projection - * @param toProj To projection - * @return Porjected grid data - * @throws InvalidRangeException - */ - public static Object[] reproject(Array data, List xx, List yy, ProjectionInfo fromProj, - ProjectionInfo toProj) throws InvalidRangeException { - return reproject(data, xx, yy, fromProj, toProj, ResampleMethods.NearestNeighbor); - } - - /** - * Reproject - * - * @param data Data array - * @param x X array - * @param y Y array - * @param rx Result x array - * @param ry Result y array - * @param fromProj From projection - * @param toProj To projection - * @param fill_value Fill value - * @param resampleMethod Resample method - * @return Result arrays - * @throws InvalidRangeException - */ - public static Array reproject(Array data, List x, List y, Array rx, Array ry, - ProjectionInfo fromProj, ProjectionInfo toProj, double fill_value, ResampleMethods resampleMethod) throws InvalidRangeException { - int n = (int) rx.getSize(); - int[] dshape = data.getShape(); - int[] shape; - if (rx.getRank() == 1) { - shape = new int[1]; - shape[0] = rx.getShape()[0]; - } else { - shape = new int[data.getRank()]; - for (int i = 0; i < shape.length; i++) { - if (i == shape.length - 2) { - shape[i] = rx.getShape()[0]; - } else if (i == shape.length - 1) { - shape[i] = rx.getShape()[1]; - } else { - shape[i] = data.getShape()[i]; - } - } - } - Array r = Array.factory(data.getDataType(), shape); - - double[][] points = new double[n][]; - for (int i = 0; i < n; i++) { - points[i] = new double[]{rx.getDouble(i), ry.getDouble(i)}; - } - if (!fromProj.equals(toProj)) { - Reproject.reprojectPoints(points, toProj, fromProj, 0, points.length); - } - double xx, yy; - if (resampleMethod == ResampleMethods.Bilinear) { - if (shape.length <= 2) { - for (int i = 0; i < n; i++) { - xx = points[i][0]; - yy = points[i][1]; - if (Double.isNaN(xx) || Double.isNaN(yy)) { - r.setObject(i, Double.NaN); - } else { - r.setObject(i, ArrayUtil.toStation(data, x, y, xx, yy, fill_value)); - } - } - } else { - Index indexr = r.getIndex(); - int[] current, cc = null; - boolean isNew; - Array ndata = null; - int k; - for (int i = 0; i < r.getSize(); i++) { - current = indexr.getCurrentCounter(); - isNew = true; - if (i > 0) { - for (int j = 0; j < shape.length - 2; j++) { - if (cc[j] != current[j]) { - isNew = false; - break; - } - } - } - cc = Arrays.copyOf(current, current.length); - if (isNew) { - List ranges = new ArrayList<>(); - for (int j = 0; j < shape.length - 2; j++) { - ranges.add(new Range(current[j], current[j], 1)); - } - ranges.add(new Range(0, dshape[dshape.length - 2] - 1, 1)); - ranges.add(new Range(0, dshape[dshape.length - 1] - 1, 1)); - ndata = data.section(ranges).reduce(); - } - k = current[shape.length - 2] * shape[shape.length - 1] + current[shape.length - 1]; - xx = points[k][0]; - yy = points[k][1]; - if (Double.isNaN(xx) || Double.isNaN(yy)) { - r.setObject(i, Double.NaN); - } else { - r.setObject(i, ArrayUtil.toStation(ndata, x, y, xx, yy, fill_value)); - } - indexr.incr(); - } - } - } else if (shape.length <= 2) { - for (int i = 0; i < n; i++) { - xx = points[i][0]; - yy = points[i][1]; - if (Double.isNaN(xx) || Double.isNaN(yy)) { - r.setObject(i, Double.NaN); - } else { - r.setObject(i, ArrayUtil.toStation_Neighbor(data, x, y, xx, yy, fill_value)); - } - } - } else { - Index indexr = r.getIndex(); - int[] current, cc = null; - boolean isNew; - Array ndata = null; - int k; - for (int i = 0; i < r.getSize(); i++) { - current = indexr.getCurrentCounter(); - isNew = true; - if (i > 0) { - for (int j = 0; j < shape.length - 2; j++) { - if (cc[j] != current[j]) { - isNew = false; - break; - } - } - } - cc = Arrays.copyOf(current, current.length); - if (isNew) { - List ranges = new ArrayList<>(); - for (int j = 0; j < shape.length - 2; j++) { - ranges.add(new Range(current[j], current[j], 1)); - } - ranges.add(new Range(0, dshape[dshape.length - 2] - 1, 1)); - ranges.add(new Range(0, dshape[dshape.length - 1] - 1, 1)); - ndata = data.section(ranges).reduce(); - } - k = current[shape.length - 2] * shape[shape.length - 1] + current[shape.length - 1]; - xx = points[k][0]; - yy = points[k][1]; - if (Double.isNaN(xx) || Double.isNaN(yy)) { - r.setObject(i, Double.NaN); - } else { - r.setObject(i, ArrayUtil.toStation_Neighbor(ndata, x, y, xx, yy, fill_value)); - } - indexr.incr(); - } - } - - return r; - } - - /** - * Reproject - * - * @param data Data array - * @param x X array - * @param y Y array - * @param rx Result x array - * @param ry Result y array - * @param fromProj From projection - * @param toProj To projection - * @param resampleMethod Resample method - * @return Result arrays - * @throws InvalidRangeException - */ - public static Array reproject(Array data, List x, List y, Array rx, Array ry, - ProjectionInfo fromProj, ProjectionInfo toProj, ResampleMethods resampleMethod) throws InvalidRangeException { - int n = (int) rx.getSize(); - int[] dshape = data.getShape(); - int[] shape; - if (rx.getRank() == 1) { - shape = new int[1]; - shape[0] = rx.getShape()[0]; - } else { - shape = new int[data.getRank()]; - for (int i = 0; i < shape.length; i++) { - if (i == shape.length - 2) { - shape[i] = rx.getShape()[0]; - } else if (i == shape.length - 1) { - shape[i] = rx.getShape()[1]; - } else { - shape[i] = data.getShape()[i]; - } - } - } - Array r = Array.factory(data.getDataType(), shape); - - double[][] points = new double[n][]; - for (int i = 0; i < n; i++) { - points[i] = new double[]{rx.getDouble(i), ry.getDouble(i)}; - } - if (!fromProj.equals(toProj)) { - Reproject.reprojectPoints(points, toProj, fromProj, 0, points.length); - } - double xx, yy; - if (resampleMethod == ResampleMethods.Bilinear) { - if (shape.length <= 2) { - for (int i = 0; i < n; i++) { - xx = points[i][0]; - yy = points[i][1]; - r.setObject(i, ArrayUtil.toStation(data, x, y, xx, yy)); - } - } else { - Index indexr = r.getIndex(); - int[] current, cc = null; - boolean isNew; - Array ndata = null; - int k; - for (int i = 0; i < r.getSize(); i++) { - current = indexr.getCurrentCounter(); - isNew = true; - if (i > 0) { - for (int j = 0; j < shape.length - 2; j++) { - if (cc[j] != current[j]) { - isNew = false; - break; - } - } - } - cc = Arrays.copyOf(current, current.length); - if (isNew) { - List ranges = new ArrayList<>(); - for (int j = 0; j < shape.length - 2; j++) { - ranges.add(new Range(current[j], current[j], 1)); - } - ranges.add(new Range(0, dshape[dshape.length - 2] - 1, 1)); - ranges.add(new Range(0, dshape[dshape.length - 1] - 1, 1)); - ndata = data.section(ranges).reduce(); - } - k = current[shape.length - 2] * shape[shape.length - 1] + current[shape.length - 1]; - xx = points[k][0]; - yy = points[k][1]; - r.setObject(i, ArrayUtil.toStation(ndata, x, y, xx, yy)); - indexr.incr(); - } - } - } else if (shape.length == 2) { - for (int i = 0; i < n; i++) { - xx = points[i][0]; - yy = points[i][1]; - r.setObject(i, ArrayUtil.toStation_Neighbor(data, x, y, xx, yy)); - } - } else { - Index indexr = r.getIndex(); - int[] current, cc = null; - boolean isNew; - Array ndata = null; - int k; - for (int i = 0; i < r.getSize(); i++) { - current = indexr.getCurrentCounter(); - isNew = true; - if (i > 0) { - for (int j = 0; j < shape.length - 2; j++) { - if (cc[j] != current[j]) { - isNew = false; - break; - } - } - } - cc = Arrays.copyOf(current, current.length); - if (isNew) { - List ranges = new ArrayList<>(); - for (int j = 0; j < shape.length - 2; j++) { - ranges.add(new Range(current[j], current[j], 1)); - } - ranges.add(new Range(0, dshape[dshape.length - 2] - 1, 1)); - ranges.add(new Range(0, dshape[dshape.length - 1] - 1, 1)); - ndata = data.section(ranges).reduce(); - } - k = current[shape.length - 2] * shape[shape.length - 1] + current[shape.length - 1]; - xx = points[k][0]; - yy = points[k][1]; - r.setObject(i, ArrayUtil.toStation_Neighbor(ndata, x, y, xx, yy)); - indexr.incr(); - } - } - - return r; - } - - /** - * Reproject - * - * @param data Data array - * @param x X array - * @param y Y array - * @param rx Result x array - * @param ry Result y array - * @param fromProj From projection - * @param toProj To projection - * @param fill_value Fill value - * @param resampleMethod Resample method - * @return Result arrays - */ - public static Array reproject(Array data, List x, List y, List rx, List ry, - ProjectionInfo fromProj, ProjectionInfo toProj, double fill_value, ResampleMethods resampleMethod) { - int n = rx.size() * ry.size(); - int[] shape = new int[]{ry.size(), rx.size()}; - Array r = Array.factory(data.getDataType(), shape); - - double[][] points = new double[n][]; - for (int i = 0; i < ry.size(); i++) { - for (int j = 0; j < rx.size(); j++) { - points[i * rx.size() + j] = new double[]{rx.get(j).doubleValue(), ry.get(i).doubleValue()}; - } - } - if (!fromProj.equals(toProj)) { - Reproject.reprojectPoints(points, toProj, fromProj, 0, points.length); - } - double xx, yy; - if (resampleMethod == ResampleMethods.Bilinear) { - for (int i = 0; i < n; i++) { - xx = points[i][0]; - yy = points[i][1]; - r.setObject(i, ArrayUtil.toStation(data, x, y, xx, yy, fill_value)); - } - } else { - for (int i = 0; i < n; i++) { - xx = points[i][0]; - yy = points[i][1]; - r.setObject(i, ArrayUtil.toStation_Neighbor(data, x, y, xx, yy, fill_value)); - } - } - - return r; - } - - /** - * Reproject - * - * @param x X array - * @param y Y array - * @param fromProj From projection - * @param toProj To projection - * @return Result arrays - */ - public static Array[] reproject(Array x, Array y, ProjectionInfo fromProj, ProjectionInfo toProj) { - Array rx = Array.factory(DataType.DOUBLE, x.getShape()); - Array ry = Array.factory(DataType.DOUBLE, x.getShape()); - int n = (int) x.getSize(); - double[][] points = new double[n][]; - IndexIterator iterX = x.getIndexIterator(); - IndexIterator iterY = y.getIndexIterator(); - for (int i = 0; i < n; i++) { - points[i] = new double[]{iterX.getDoubleNext(), iterY.getDoubleNext()}; - } - Reproject.reprojectPoints(points, fromProj, toProj, 0, points.length); - for (int i = 0; i < n; i++) { - rx.setDouble(i, points[i][0]); - ry.setDouble(i, points[i][1]); - } - - return new Array[]{rx, ry}; - } -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/World.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/World.java deleted file mode 100644 index b93c0ae4..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/World.java +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection; - -import org.locationtech.proj4j.CRSFactory; -import org.meteoinfo.geo.projection.info.ProjectionInfo; - -/** - * - * @author Yaqiang Wang - */ -public class World extends CoordinateSystemCategory { - // - CRSFactory _crsFactory = new CRSFactory(); - public final ProjectionInfo WGS1984; - // - // - /** - * Constructor - */ - public World(){ - final String WGS84_PARAM = "+title=long/lat:WGS84 +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees"; - WGS1984 = ProjectionInfo.factory(_crsFactory.createFromParameters("WGS84", WGS84_PARAM)); - } - // - // - // - // - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Albers.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Albers.java deleted file mode 100644 index cc46b78c..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Albers.java +++ /dev/null @@ -1,94 +0,0 @@ -/* Copyright 2012 - Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection.info; - -import java.util.ArrayList; -import java.util.List; -import org.locationtech.proj4j.CoordinateReferenceSystem; -import org.meteoinfo.common.PointD; -import org.meteoinfo.geo.projection.KnownCoordinateSystems; -import org.meteoinfo.geo.projection.ProjectionNames; -import org.meteoinfo.geo.projection.ProjectionUtil; -import org.meteoinfo.geometry.shape.PolygonShape; - -/** - * - * @author Yaqiang Wang - */ -public class Albers extends ProjectionInfo { - - // - // - // - /** - * Construction - * - * @param crs Coorinate reference system - */ - public Albers(CoordinateReferenceSystem crs) { - this.crs = crs; - } - - // - // - /** - * Get projection name - * - * @return Projection name - */ - @Override - public ProjectionNames getProjectionName() { - return ProjectionNames.Albers_Equal_Area; - } - - // - // - @Override - void updateBoundary() { - double epsilon = 1e-10; - double cenLon = this.getCenterLon(); - double minLon = cenLon - 180 + epsilon; - double maxLon = cenLon + 180 - epsilon; - double minLat = -90; - double maxLat = 90; - List points = new ArrayList<>(); - double lon = minLon; - double lat = minLat; - while (lon < maxLon) { - points.add(new PointD(lon, lat)); - lon += 1; - } - lon = maxLon; - while (lat < maxLat) { - points.add(new PointD(lon, lat)); - lat += 1; - } - lat = maxLat; - while (lon > minLon) { - points.add(new PointD(lon, lat)); - lon -= 1; - } - lon = minLon; - while (lat > minLat) { - points.add(new PointD(lon, lat)); - lat -= 1; - } - lat = minLat; - points.add(new PointD(lon, lat)); - PolygonShape ps = new PolygonShape(); - ps.setPoints(points); - this.boundary = ProjectionUtil.projectPolygonShape(ps, KnownCoordinateSystems.geographic.world.WGS1984, this); - } - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Common.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Common.java deleted file mode 100644 index 7d9875f2..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Common.java +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright 2012 - Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection.info; - -import org.meteoinfo.geo.projection.ProjectionNames; -import org.locationtech.proj4j.CoordinateReferenceSystem; - -/** - * - * @author Yaqiang Wang - */ -public class Common extends ProjectionInfo { - - // - // - // - /** - * Construction - * - * @param crs Coorinate reference system - */ - public Common(CoordinateReferenceSystem crs) { - this.crs = crs; - } - - // - // - /** - * Get projection name - * - * @return Projection name - */ - @Override - public ProjectionNames getProjectionName() { - return ProjectionNames.Undefine; - } - - // - // - - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/GeostationarySatellite.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/GeostationarySatellite.java deleted file mode 100644 index 357b343d..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/GeostationarySatellite.java +++ /dev/null @@ -1,130 +0,0 @@ -/* Copyright 2012 - Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection.info; - -import java.util.List; - -import org.meteoinfo.common.Direction; -import org.meteoinfo.common.PointD; -import org.meteoinfo.geo.mapview.GridLabel; -import org.meteoinfo.geo.projection.ProjectionNames; -import org.locationtech.proj4j.CoordinateReferenceSystem; -import org.meteoinfo.geometry.shape.PolygonShape; - -/** - * - * @author Yaqiang Wang - */ -public class GeostationarySatellite extends ProjectionInfo { - - // - // - // - /** - * Construction - * - * @param crs Coorinate reference system - */ - public GeostationarySatellite(CoordinateReferenceSystem crs) { - this.crs = crs; - } - - // - // - /** - * Get projection name - * - * @return Projection name - */ - @Override - public ProjectionNames getProjectionName() { - return ProjectionNames.Geostationary_Satellite; - } - - // - // - @Override - void updateBoundary() { - double epsilon = 1e-10; - double a = this.crs.getDatum().getEllipsoid().getA(); - double b = this.crs.getDatum().getEllipsoid().getB(); - double h = this.crs.getProjection().getHeightOfOrbit(); - double max_x = h * Math.asin(a / (a + h)); - double max_y = h * Math.asin(b / (a + h)); - double easting = this.crs.getProjection().getFalseEasting(); - double northing = this.crs.getProjection().getFalseNorthing(); - List points = ellipse_boundary(max_x, max_y, easting, northing, 201); - PolygonShape ps = new PolygonShape(); - ps.setPoints(points); - this.boundary = ps; - } - - @Override - public Object[] checkGridLabel(GridLabel gl, float shift) { - float angle = gl.getAngle(); - double v = gl.getValue(); - float xShift = 0.f; - float yShift = 0.f; - XAlign xAlign = XAlign.CENTER; - YAlign yAlign = YAlign.CENTER; - if (v == 0) { - if (angle == 90) { - xShift = shift; - xAlign = XAlign.LEFT; - } else if (angle == 270) { - xShift = -shift; - xAlign = XAlign.RIGHT; - } else if (angle < 90) { - xShift = shift; - xAlign = XAlign.LEFT; - yAlign = YAlign.BOTTOM; - } else if (angle > 90 && angle <= 180) { - xShift = shift; - xAlign = XAlign.LEFT; - yAlign = YAlign.TOP; - } else if (angle > 180 && angle < 270) { - xShift = -shift; - xAlign = XAlign.RIGHT; - yAlign = YAlign.TOP; - } else if (angle > 270 && angle <= 360) { - xShift = -shift; - xAlign = XAlign.RIGHT; - yAlign = YAlign.BOTTOM; - } - } else if (v > 0) { - if (gl.getLabDirection() == Direction.East) { - xShift = shift; - xAlign = XAlign.LEFT; - yAlign = YAlign.BOTTOM; - } else { - xShift = -shift; - xAlign = XAlign.RIGHT; - yAlign = YAlign.BOTTOM; - } - } else { - if (gl.getLabDirection() == Direction.East) { - xShift = shift; - xAlign = XAlign.LEFT; - yAlign = YAlign.TOP; - } else { - xShift = -shift; - xAlign = XAlign.RIGHT; - yAlign = YAlign.TOP; - } - } - - return new Object[]{xShift, yShift, xAlign, yAlign}; - } - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Hammer.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Hammer.java deleted file mode 100644 index 42bd2a2a..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Hammer.java +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright 2012 - Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection.info; - -import java.util.ArrayList; -import java.util.List; - -import org.meteoinfo.common.PointD; -import org.meteoinfo.geo.projection.KnownCoordinateSystems; -import org.meteoinfo.geo.projection.ProjectionNames; -import org.meteoinfo.geo.projection.ProjectionUtil; -import org.locationtech.proj4j.CoordinateReferenceSystem; -import org.meteoinfo.geometry.shape.PolygonShape; - -/** - * - * @author Yaqiang Wang - */ -public class Hammer extends ProjectionInfo { - - // - // - // - /** - * Construction - * - * @param crs Coorinate reference system - */ - public Hammer(CoordinateReferenceSystem crs) { - this.crs = crs; - } - - // - // - /** - * Get projection name - * - * @return Projection name - */ - @Override - public ProjectionNames getProjectionName() { - return ProjectionNames.Hammer_Eckert; - } - - // - // - @Override - void updateBoundary() { - double epsilon = 1e-10; - double cenLon = this.getCenterLon(); - double minLon = cenLon - 180 + epsilon; - double maxLon = cenLon + 180 - epsilon; - double minLat = -90; - double maxLat = 90; - List points = new ArrayList<>(); - double lon = minLon; - double lat = minLat; - lon = maxLon; - while (lat < maxLat) { - points.add(new PointD(lon, lat)); - lat += 1; - } - lat = maxLat; - lon = minLon; - while (lat > minLat) { - points.add(new PointD(lon, lat)); - lat -= 1; - } - lat = minLat; - points.add(new PointD(lon, lat)); - PolygonShape ps = new PolygonShape(); - ps.setPoints(points); - this.boundary = ProjectionUtil.projectPolygonShape(ps, KnownCoordinateSystems.geographic.world.WGS1984, this); - } - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/LambertAzimuthalEqualArea.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/LambertAzimuthalEqualArea.java deleted file mode 100644 index 88264a0c..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/LambertAzimuthalEqualArea.java +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright 2012 - Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection.info; - -import java.util.List; - -import org.meteoinfo.common.PointD; -import org.meteoinfo.geo.projection.KnownCoordinateSystems; -import org.meteoinfo.geo.projection.ProjectionNames; -import org.meteoinfo.geo.projection.Reproject; -import org.locationtech.proj4j.CoordinateReferenceSystem; -import org.meteoinfo.geometry.shape.PolygonShape; - -/** - * - * @author Yaqiang Wang - */ -public class LambertAzimuthalEqualArea extends ProjectionInfo { - - // - // - // - /** - * Construction - * - * @param crs Coorinate reference system - */ - public LambertAzimuthalEqualArea(CoordinateReferenceSystem crs) { - this.crs = crs; - } - - // - // - /** - * Get projection name - * - * @return Projection name - */ - @Override - public ProjectionNames getProjectionName() { - return ProjectionNames.Lambert_Azimuthal_Equal_Area; - } - - // - // - @Override - void updateBoundary() { - double epsilon = 1e-10; - double a = this.crs.getDatum().getEllipsoid().getA(); - double cenLat = this.getCenterLat(); - double cenLon = this.getCenterLon(); - double lon = cenLon + 180 - epsilon; - double sign = Math.signum(cenLat); - if (sign == 0) - sign = 1; - double lat = -cenLat + sign * 0.01; - PointD p = Reproject.reprojectPoint(lon, lat, KnownCoordinateSystems.geographic.world.WGS1984, this); - double x = p.X; - double max_y = p.Y; - double easting = this.crs.getProjection().getFalseEasting(); - double northing = this.crs.getProjection().getFalseNorthing(); - List points = this.ellipse_boundary(a * 1.9999, max_y - northing, easting, northing, 61); - PolygonShape ps = new PolygonShape(); - ps.setPoints(points); - this.boundary = ps; - } - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/LambertConformalConic.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/LambertConformalConic.java deleted file mode 100644 index 507d303d..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/LambertConformalConic.java +++ /dev/null @@ -1,99 +0,0 @@ -/* Copyright 2012 - Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection.info; - -import java.util.ArrayList; -import java.util.List; - -import org.meteoinfo.common.PointD; -import org.meteoinfo.geo.projection.KnownCoordinateSystems; -import org.meteoinfo.geo.projection.ProjectionNames; -import org.meteoinfo.geo.projection.ProjectionUtil; -import org.locationtech.proj4j.CoordinateReferenceSystem; -import org.meteoinfo.geometry.shape.PolygonShape; - -/** - * - * @author Yaqiang Wang - */ -public class LambertConformalConic extends ProjectionInfo { - - // - // - // - /** - * Construction - * - * @param crs Coorinate reference system - */ - public LambertConformalConic(CoordinateReferenceSystem crs) { - this.crs = crs; - this.cutoff = -80.f; - } - - // - // - /** - * Get projection name - * - * @return Projection name - */ - @Override - public ProjectionNames getProjectionName() { - return ProjectionNames.Lambert_Conformal_Conic; - } - - // - // - /** - * Set latitude cutoff - * @param value Latitude cutoff - */ - @Override - public void setCutoff(float value) { - this.cutoff = value; - this.updateBoundary(); - } - - @Override - void updateBoundary() { - double epsilon = 1e-10; - double cenLon = this.getCenterLon(); - List points = new ArrayList<>(); - double lon = cenLon - 180 + epsilon; - double lat = this.cutoff; - while (lon < cenLon + 180 - epsilon) { - points.add(new PointD(lon, lat)); - lon += 1; - } - lon = cenLon + 180 - epsilon; - points.add(new PointD(lon, lat)); - lat += 1; - while (lat < 90) { - points.add(new PointD(lon, lat)); - lat += 1; - } - points.add(new PointD(lon, 90)); - lon = cenLon - 180 + epsilon; - while (lat > this.cutoff) { - points.add(new PointD(lon, lat)); - lat -= 1; - } - - PolygonShape ps = new PolygonShape(); - ps.setPoints(points); - this.boundary = ProjectionUtil.projectPolygonShape(ps, KnownCoordinateSystems.geographic.world.WGS1984, this); - } - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/LambertEqualAreaConic.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/LambertEqualAreaConic.java deleted file mode 100644 index eb7611b7..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/LambertEqualAreaConic.java +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright 2012 - Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection.info; - -import java.util.ArrayList; -import java.util.List; - -import org.meteoinfo.common.PointD; -import org.meteoinfo.geo.projection.KnownCoordinateSystems; -import org.meteoinfo.geo.projection.ProjectionNames; -import org.meteoinfo.geo.projection.ProjectionUtil; -import org.locationtech.proj4j.CoordinateReferenceSystem; -import org.meteoinfo.geometry.shape.PolygonShape; - -/** - * - * @author Yaqiang Wang - */ -public class LambertEqualAreaConic extends ProjectionInfo { - - // - // - // - /** - * Construction - * - * @param crs Coorinate reference system - */ - public LambertEqualAreaConic(CoordinateReferenceSystem crs) { - this.crs = crs; - } - - // - // - /** - * Get projection name - * - * @return Projection name - */ - @Override - public ProjectionNames getProjectionName() { - return ProjectionNames.Lambert_Equal_Area_Conic; - } - - // - // - @Override - void updateBoundary() { - double epsilon = 1e-10; - double cenLon = this.getCenterLon(); - double minLon = cenLon - 180 + epsilon; - double maxLon = cenLon + 180 - epsilon; - double minLat = -90; - double maxLat = 90; - List points = new ArrayList<>(); - double lon = minLon; - double lat = minLat; - while (lon < maxLon) { - points.add(new PointD(lon, lat)); - lon += 1; - } - lon = maxLon; - while (lat < maxLat) { - points.add(new PointD(lon, lat)); - lat += 1; - } - lat = maxLat; - while (lon > minLon) { - points.add(new PointD(lon, lat)); - lon -= 1; - } - lon = minLon; - while (lat > minLat) { - points.add(new PointD(lon, lat)); - lat -= 1; - } - lat = minLat; - points.add(new PointD(lon, lat)); - PolygonShape ps = new PolygonShape(); - ps.setPoints(points); - this.boundary = ProjectionUtil.projectPolygonShape(ps, KnownCoordinateSystems.geographic.world.WGS1984, this); - } - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/LongLat.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/LongLat.java deleted file mode 100644 index bc387876..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/LongLat.java +++ /dev/null @@ -1,48 +0,0 @@ - /* Copyright 2012 - Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection.info; - -import org.meteoinfo.geo.projection.ProjectionNames; -import org.locationtech.proj4j.CoordinateReferenceSystem; - - /** - * - * @author Yaqiang Wang - */ - public class LongLat extends ProjectionInfo { - // - // - // - /** - * Construction - * @param crs Coorinate reference system - */ - public LongLat(CoordinateReferenceSystem crs) { - this.crs = crs; - } - // - // - /** - * Get projection name - * - * @return Projection name - */ - @Override - public ProjectionNames getProjectionName() { - return ProjectionNames.LongLat; - } - // - // - // - } diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Mercator.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Mercator.java deleted file mode 100644 index c9cc08ab..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Mercator.java +++ /dev/null @@ -1,89 +0,0 @@ -/* Copyright 2012 - Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection.info; - -import java.util.ArrayList; -import java.util.List; - -import org.meteoinfo.common.PointD; -import org.meteoinfo.geo.projection.KnownCoordinateSystems; -import org.meteoinfo.geo.projection.ProjectionNames; -import org.meteoinfo.geo.projection.ProjectionUtil; -import org.locationtech.proj4j.CoordinateReferenceSystem; -import org.meteoinfo.geometry.shape.PolygonShape; - -/** - * - * @author Yaqiang Wang - */ -public class Mercator extends ProjectionInfo { - - // - // - // - /** - * Construction - * - * @param crs Coorinate reference system - */ - public Mercator(CoordinateReferenceSystem crs) { - this.crs = crs; - this.cutoff = 85.0511f; - } - - // - // - /** - * Get projection name - * - * @return Projection name - */ - @Override - public ProjectionNames getProjectionName() { - return ProjectionNames.Mercator; - } - - // - // - /** - * Set latitude cutoff - * - * @param value Latitude cutoff - */ - @Override - public void setCutoff(float value) { - this.cutoff = value; - this.updateBoundary(); - } - - @Override - void updateBoundary() { - double epsilon = 1e-10; - double cenLon = this.getCenterLon(); - double minLon = cenLon - 180 + epsilon; - double maxLon = cenLon + 180 - epsilon; - double minLat = -this.cutoff; - double maxLat = this.cutoff; - List points = new ArrayList<>(); - points.add(new PointD(minLon, minLat)); - points.add(new PointD(maxLon, minLat)); - points.add(new PointD(maxLon, maxLat)); - points.add(new PointD(minLon, maxLat)); - points.add(new PointD(minLon, minLat)); - PolygonShape ps = new PolygonShape(); - ps.setPoints(points); - this.boundary = ProjectionUtil.projectPolygonShape(ps, KnownCoordinateSystems.geographic.world.WGS1984, this); - } - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Molleweide.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Molleweide.java deleted file mode 100644 index d0df12aa..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Molleweide.java +++ /dev/null @@ -1,146 +0,0 @@ -/* Copyright 2012 - Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection.info; - -import java.util.ArrayList; -import java.util.List; - -import org.meteoinfo.common.Direction; -import org.meteoinfo.common.PointD; -import org.meteoinfo.geo.mapview.GridLabel; -import org.meteoinfo.geo.projection.KnownCoordinateSystems; -import org.meteoinfo.geo.projection.ProjectionNames; -import org.meteoinfo.geo.projection.ProjectionUtil; -import org.locationtech.proj4j.CoordinateReferenceSystem; -import org.meteoinfo.geometry.shape.PolygonShape; - -/** - * - * @author Yaqiang Wang - */ -public class Molleweide extends ProjectionInfo { - - // - // - // - /** - * Construction - * - * @param crs Coorinate reference system - */ - public Molleweide(CoordinateReferenceSystem crs) { - this.crs = crs; - } - - // - // - /** - * Get projection name - * - * @return Projection name - */ - @Override - public ProjectionNames getProjectionName() { - return ProjectionNames.Molleweide; - } - - // - // - @Override - void updateBoundary() { - double epsilon = 1e-10; - double cenLon = this.getCenterLon(); - double minLon = cenLon - 180 + epsilon; - double maxLon = cenLon + 180 - epsilon; - double minLat = -90; - double maxLat = 90; - List points = new ArrayList<>(); - double lon = minLon; - double lat = minLat; - lon = maxLon; - while (lat < maxLat) { - points.add(new PointD(lon, lat)); - lat += 1; - } - lat = maxLat; - lon = minLon; - while (lat > minLat) { - points.add(new PointD(lon, lat)); - lat -= 1; - } - lat = minLat; - points.add(new PointD(lon, lat)); - PolygonShape ps = new PolygonShape(); - ps.setPoints(points); - this.boundary = ProjectionUtil.projectPolygonShape(ps, KnownCoordinateSystems.geographic.world.WGS1984, this); - } - - @Override - public Object[] checkGridLabel(GridLabel gl, float shift) { - float angle = gl.getAngle(); - double v = gl.getValue(); - float xShift = 0.f; - float yShift = 0.f; - XAlign xAlign = XAlign.CENTER; - YAlign yAlign = YAlign.CENTER; - if (v == 0) { - if (angle == 90) { - xShift = shift; - xAlign = XAlign.LEFT; - } else if (angle == 270) { - xShift = -shift; - xAlign = XAlign.RIGHT; - } else if (angle < 90) { - xShift = shift; - xAlign = XAlign.LEFT; - yAlign = YAlign.BOTTOM; - } else if (angle > 90 && angle <= 180) { - xShift = shift; - xAlign = XAlign.LEFT; - yAlign = YAlign.TOP; - } else if (angle > 180 && angle < 270) { - xShift = -shift; - xAlign = XAlign.RIGHT; - yAlign = YAlign.TOP; - } else if (angle > 270 && angle <= 360) { - xShift = -shift; - xAlign = XAlign.RIGHT; - yAlign = YAlign.BOTTOM; - } - } else if (v > 0) { - if (gl.getLabDirection() == Direction.East) { - xShift = shift; - xAlign = XAlign.LEFT; - yAlign = YAlign.BOTTOM; - } else { - xShift = -shift; - xAlign = XAlign.RIGHT; - yAlign = YAlign.BOTTOM; - } - } else { - if (gl.getLabDirection() == Direction.East) { - xShift = shift; - xAlign = XAlign.LEFT; - yAlign = YAlign.TOP; - } else { - xShift = -shift; - xAlign = XAlign.RIGHT; - yAlign = YAlign.TOP; - } - } - - return new Object[]{xShift, yShift, xAlign, yAlign}; - } - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/OrthographicAzimuthal.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/OrthographicAzimuthal.java deleted file mode 100644 index 3bd11bc8..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/OrthographicAzimuthal.java +++ /dev/null @@ -1,126 +0,0 @@ -/* Copyright 2012 - Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection.info; - -import java.util.List; - -import org.meteoinfo.common.Direction; -import org.meteoinfo.common.PointD; -import org.meteoinfo.geo.mapview.GridLabel; -import org.meteoinfo.geo.projection.ProjectionNames; -import org.locationtech.proj4j.CoordinateReferenceSystem; -import org.meteoinfo.geometry.shape.PolygonShape; - -/** - * - * @author Yaqiang Wang - */ -public class OrthographicAzimuthal extends ProjectionInfo { - - // - // - // - /** - * Construction - * - * @param crs Coorinate reference system - */ - public OrthographicAzimuthal(CoordinateReferenceSystem crs) { - this.crs = crs; - } - - // - // - /** - * Get projection name - * - * @return Projection name - */ - @Override - public ProjectionNames getProjectionName() { - return ProjectionNames.Orthographic_Azimuthal; - } - - // - // - @Override - void updateBoundary() { - double a = this.crs.getDatum().getEllipsoid().getA(); - double b = this.crs.getDatum().getEllipsoid().getB(); - double easting = this.crs.getProjection().getFalseEasting(); - double northing = this.crs.getProjection().getFalseNorthing(); - List points = ellipse_boundary(a, b, easting, northing, 201); - PolygonShape ps = new PolygonShape(); - ps.setPoints(points); - this.boundary = ps; - } - - @Override - public Object[] checkGridLabel(GridLabel gl, float shift) { - float angle = gl.getAngle(); - double v = gl.getValue(); - float xShift = 0.f; - float yShift = 0.f; - XAlign xAlign = XAlign.CENTER; - YAlign yAlign = YAlign.CENTER; - if (v == 0) { - if (angle == 90) { - xShift = shift; - xAlign = XAlign.LEFT; - } else if (angle == 270) { - xShift = -shift; - xAlign = XAlign.RIGHT; - } else if (angle < 90) { - xShift = shift; - xAlign = XAlign.LEFT; - yAlign = YAlign.BOTTOM; - } else if (angle > 90 && angle <= 180) { - xShift = shift; - xAlign = XAlign.LEFT; - yAlign = YAlign.TOP; - } else if (angle > 180 && angle < 270) { - xShift = -shift; - xAlign = XAlign.RIGHT; - yAlign = YAlign.TOP; - } else if (angle > 270 && angle <= 360) { - xShift = -shift; - xAlign = XAlign.RIGHT; - yAlign = YAlign.BOTTOM; - } - } else if (v > 0) { - if (gl.getLabDirection() == Direction.East) { - xShift = shift; - xAlign = XAlign.LEFT; - yAlign = YAlign.BOTTOM; - } else { - xShift = -shift; - xAlign = XAlign.RIGHT; - yAlign = YAlign.BOTTOM; - } - } else { - if (gl.getLabDirection() == Direction.East) { - xShift = shift; - xAlign = XAlign.LEFT; - yAlign = YAlign.TOP; - } else { - xShift = -shift; - xAlign = XAlign.RIGHT; - yAlign = YAlign.TOP; - } - } - - return new Object[]{xShift, yShift, xAlign, yAlign}; - } - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/ProjectionInfo.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/ProjectionInfo.java deleted file mode 100644 index f4f888dc..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/ProjectionInfo.java +++ /dev/null @@ -1,667 +0,0 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection.info; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.meteoinfo.common.PointD; -import org.meteoinfo.geo.mapview.GridLabel; -import org.meteoinfo.ndarray.math.ArrayUtil; -import org.meteoinfo.geo.projection.ProjectionNames; -import org.locationtech.proj4j.CRSFactory; -import org.locationtech.proj4j.CoordinateReferenceSystem; -import org.locationtech.proj4j.InvalidValueException; -import org.locationtech.proj4j.datum.Datum; -import org.locationtech.proj4j.datum.Ellipsoid; -import org.locationtech.proj4j.parser.Proj4Keyword; -import org.locationtech.proj4j.parser.Proj4Parser; -import org.locationtech.proj4j.proj.Projection; -import org.meteoinfo.geometry.shape.PolygonShape; -import org.meteoinfo.ndarray.Array; -import org.meteoinfo.geo.projection.ProjRegistry; - - /** - * - * @author Yaqiang Wang - */ - public abstract class ProjectionInfo { - // - - protected CoordinateReferenceSystem crs; - protected PolygonShape boundary; - protected float cutoff = Float.NaN; //Latitude cutoff - valiad for some speciafic projections - // - // - /** - * Create new ProjectionInfo with crs - * @param crs Coordinate reference system - * @return Projection info - */ - public static ProjectionInfo factory(CoordinateReferenceSystem crs) { - ProjectionInfo projInfo; - Projection proj = crs.getProjection(); - switch (proj.toString()) { - case "LongLat": - projInfo = new LongLat(crs); - break; - case "Albers Equal Area": - projInfo = new Albers(crs); - break; - case "Lambert Conformal Conic": - projInfo = new LambertConformalConic(crs); - break; - case "Lambert Equal Area Conic": - projInfo = new LambertEqualAreaConic(crs); - break; - case "Lambert Azimuthal Equal Area": - projInfo = new LambertAzimuthalEqualArea(crs); - break; - case "Stereographic Azimuthal": - projInfo = new StereographicAzimuthal(crs); - break; - case "Mercator": - projInfo = new Mercator(crs); - break; - case "Robinson": - projInfo = new Robinson(crs); - break; - case "Molleweide": - projInfo = new Molleweide(crs); - break; - case "Geostationary Satellite": - projInfo = new GeostationarySatellite(crs); - break; - case "Sinusoidal": - projInfo = new Sinusoidal(crs); - break; - case "Orthographic Azimuthal": - projInfo = new OrthographicAzimuthal(crs); - break; - case "Hammer Eckert": - projInfo = new Hammer(crs); - break; - case "Universal Tranverse Mercator": - case "Transverse Mercator": - projInfo = new TransverseMercator(crs); - break; - case "Wagner III": - projInfo = new Wagner3(crs); - break; - default: - projInfo = new Common(crs); - break; - } - - projInfo.updateBoundary(); - - return projInfo; - } - - /** - * Create new ProjectionInfo with crs - * @param proj4Str proj4 string - * @return Projection info - */ - public static ProjectionInfo factory(String proj4Str) { - CRSFactory crsFactory = new CRSFactory(); - proj4Str = proj4Str.replace("+", " +"); - proj4Str = proj4Str.trim(); - return factory(crsFactory.createFromParameters("custom", proj4Str)); - } - - /** - * Create new ProjectionInfo with ESRI projection string - * @param esriStr ESRI projection string - * @return Projection info - */ - public static ProjectionInfo factoryESRI(String esriStr) { - CRSFactory crsFactory = new CRSFactory(); - ProjRegistry registry = new ProjRegistry(); - String[] params = getParameterArray(esriStringToProj4Params(registry, esriStr)); - Proj4Parser parser = new Proj4Parser(crsFactory.getRegistry()); - CoordinateReferenceSystem crs = parser.parse("custom", params); - return factory(crs); - } - - /** - * Create new ProjectionInfo with crs - * @param name ProjectionName - * @return Projection info - */ - public static ProjectionInfo factory(ProjectionNames name) { - CRSFactory crsFactory = new CRSFactory(); - String proj4Str = "+proj=" + name.getProj4Name(); - return factory(crsFactory.createFromParameters("custom", proj4Str)); - } - - // - // - - /** - * Get CoordinateReferenceSystem - * - * @return CoordinateReferenceSystem - */ - public CoordinateReferenceSystem getCoordinateReferenceSystem() { - return crs; - } - - /** - * Get projection name - * - * @return Projection name - */ - public abstract ProjectionNames getProjectionName(); - - /** - * Get if is Lon/Lat projection - * - * @return Boolean - */ - public boolean isLonLat(){ - return this.getProjectionName() == ProjectionNames.LongLat; - } - - /** - * Get center longitude - * @return Center longitude - */ - public double getCenterLon(){ - return this.crs.getProjection().getProjectionLongitudeDegrees(); - } - - /** - * Get center latitude - * @return Center latitude - */ - public double getCenterLat() { - return this.crs.getProjection().getProjectionLatitudeDegrees(); - } - - /** - * Get map boundary - * @return Map boundary - */ - public PolygonShape getBoundary(){ - return this.boundary; - } - - /** - * Set map boundary - * @param value Map boundary - */ - public void setBoundary(PolygonShape value) { - this.boundary = value; - } - - /** - * Get latitude cutoff - * @return Latitude cutoff - */ - public float getCutoff(){ - return this.cutoff; - } - - /** - * Set latitude cutoff - * @param value Latitude cutoff - */ - public void setCutoff(float value) { } - - /** - * Set latitude cutoff - * @param value Latitude cutoff - */ - public void setCutoff_bak(float value) { - this.cutoff = value; - this.updateBoundary(); - } - - // - // - /** - * Get valid parameters - * @return Valid parameters - */ - public List getValidParas() { - return new ArrayList<>(); - } - - /** - * Check grid label - * @param gl The grid label - * @param shift Shift - * @return Array of x/y shift and align - */ - public Object[] checkGridLabel(GridLabel gl, float shift) { - float angle = gl.getAngle(); - float xShift = 0.f; - float yShift = 0.f; - XAlign xAlign = XAlign.CENTER; - YAlign yAlign = YAlign.CENTER; - if (angle == 0) { - yShift = -shift; - yAlign = YAlign.BOTTOM; - } else if (angle == 180) { - yShift = shift; - yAlign = YAlign.TOP; - } else if (angle == 90) { - xShift = shift; - xAlign = XAlign.LEFT; - } else if (angle == 270) { - xShift = -shift; - xAlign = XAlign.RIGHT; - } else if (angle > 0 && angle <= 45) { - yShift = -shift; - xAlign = XAlign.LEFT; - yAlign = YAlign.BOTTOM; - } else if (angle > 45 && angle < 90) { - yShift = shift; - xAlign = XAlign.LEFT; - yAlign = YAlign.BOTTOM; - } else if (angle > 90 && angle <= 135) { - xShift = shift; - xAlign = XAlign.LEFT; - yAlign = YAlign.TOP; - } else if (angle > 135 && angle < 180) { - yShift = shift; - xAlign = XAlign.LEFT; - yAlign = YAlign.TOP; - } else if (angle > 180 && angle <= 225) { - yShift = shift; - xAlign = XAlign.RIGHT; - yAlign = YAlign.TOP; - } else if (angle > 225 && angle < 270) { - xShift = -shift; - xAlign = XAlign.RIGHT; - yAlign = YAlign.TOP; - } else if (angle > 270 && angle <= 315) { - xShift = -shift; - xAlign = XAlign.RIGHT; - yAlign = YAlign.BOTTOM; - } else if (angle > 315 && angle < 360) { - yShift = -shift; - xAlign = XAlign.RIGHT; - yAlign = YAlign.BOTTOM; - } - - return new Object[]{xShift, yShift, xAlign, yAlign}; - } - - void updateBoundary() {} - - /** - * Define a projection boundary using an ellipse.This type of boundary is used by several projections. - * @param semimajor - * @param semiminor - * @param easting - * @param northing - * @param n - * @return Ellipse boundary - */ - protected List ellipse_boundary(double semimajor, double semiminor, double easting, double northing, int n) { - Array t = ArrayUtil.lineSpace(0, -2 * Math.PI, n, true); - List r = new ArrayList<>(); - double x, y; - for (int i = 0; i < t.getSize(); i++) { - x = semimajor * Math.cos(t.getDouble(i)) + easting; - y = semiminor * Math.sin(t.getDouble(i)) + northing; - r.add(new PointD(x, y)); - } - - return r; - } - - /** - * Get reference cut longitude for projection operation - * @return Refrence cut longitude - */ - public double getRefCutLon() { - double refLon = this.getCoordinateReferenceSystem().getProjection().getProjectionLongitudeDegrees(); - refLon += 180; - if (refLon > 180) { - refLon = refLon - 360; - } else if (refLon < -180) { - refLon = refLon + 360; - } - return refLon; - } - - /** - * Get proj4 string - * - * @return Proj4 string - */ - public String toProj4String() { - return crs.getParameterString(); - } - - /** - * Calculates the inverse of the flattening factor, commonly saved to ESRI - * projections, or else provided as the "rf" parameter for Proj4 strings.This is simply calculated - * as a / (a - b) where a is the semi-major axis and b is the semi-minor axis. - * - * @param ellipsoid - * @return Inverse flatting - */ - public double getInverseFlattening(Ellipsoid ellipsoid) { - if (ellipsoid.poleRadius == ellipsoid.equatorRadius) { - return 0; // prevent divide by zero for spheres. - } - return (ellipsoid.equatorRadius) / (ellipsoid.equatorRadius - ellipsoid.poleRadius); - } - - private static String[] getParameterArray(Map params) { - String[] args = new String[params.size()]; - int i = 0; - Set key = params.keySet(); - for (String s : key) { - args[i] = "+" + s + "=" + params.get(s); - i += 1; - } - - return args; - } - - /** - * Convert ESRI projection string to Proj4 param map - * @param registry Registry - * @param esriString ESRI projection string - * @return Proj4 param map - */ - public static Map esriStringToProj4Params(ProjRegistry registry, String esriString) { - Map params = new HashMap(); - String key, value, name; - int iStart, iEnd; - - //Projection - if (!esriString.contains("PROJCS")) { - key = Proj4Keyword.proj; - value = "longlat"; - params.put(key, value); - } else { - Projection projection = null; - iStart = esriString.indexOf("PROJECTION") + 12; - iEnd = esriString.indexOf("]", iStart) - 1; - String s = esriString.substring(iStart, iEnd); - if (s != null) { - projection = registry.getProjectionEsri(s); - if (projection == null) { - throw new InvalidValueException("Unknown projection: " + s); - } - } - - String proj4Name = registry.getProj4Name(projection); - key = Proj4Keyword.proj; - value = proj4Name; - params.put(key, value); - } - - //Datum - if (esriString.contains("DATUM")) { - iStart = esriString.indexOf("DATUM") + 7; - iEnd = esriString.indexOf(",", iStart) - 1; - if (iEnd > iStart) { - key = Proj4Keyword.datum; - value = esriString.substring(iStart, iEnd); - if (value.equals("D_WGS_1984")) { - value = "WGS84"; - } else { - value = "WGS84"; - } - params.put(key, value); - } - } - - //Ellipsoid - if (esriString.contains("SPHEROID")) { - iStart = esriString.indexOf("SPHEROID") + 9; - iEnd = esriString.indexOf("]", iStart); - if (iEnd > iStart) { - String extracted = esriString.substring(iStart, iEnd); - String[] terms = extracted.split(","); - name = terms[0]; - name = name.substring(1, name.length() - 1); - if (name.equals("WGS_1984")) { - name = "WGS84"; - } else { - name = "WGS84"; - } - key = Proj4Keyword.ellps; - value = name; - params.put(key, value); - key = Proj4Keyword.a; - value = terms[1]; - params.put(key, value); - key = Proj4Keyword.rf; - value = terms[2]; - params.put(key, value); - } - } - - // //Primem - // if (esriString.contains("PRIMEM")) { - // iStart = esriString.indexOf("PRIMEM") + 7; - // iEnd = esriString.indexOf("]", iStart); - // if (iEnd > iStart) { - // String extracted = esriString.substring(iStart, iEnd); - // String[] terms = extracted.split(","); - // name = terms[0]; - // name = name.substring(1, name.length() - 1); - // key = Proj4Keyword.pm; - // value = terms[1]; - // params.put(key, value); - // } - // } - - //Projection parameters - value = getParameter("False_Easting", esriString); - if (value != null) { - key = Proj4Keyword.x_0; - params.put(key, value); - } - value = getParameter("False_Northing", esriString); - if (value != null) { - key = Proj4Keyword.y_0; - params.put(key, value); - } - value = getParameter("Central_Meridian", esriString); - if (value != null) { - key = Proj4Keyword.lon_0; - params.put(key, value); - } - value = getParameter("Standard_Parallel_1", esriString); - if (value != null) { - key = Proj4Keyword.lat_1; - params.put(key, value); - } - value = getParameter("Standard_Parallel_2", esriString); - if (value != null) { - key = Proj4Keyword.lat_2; - params.put(key, value); - } - value = getParameter("Scale_Factor", esriString); - if (value != null) { - key = Proj4Keyword.k_0; - params.put(key, value); - } - value = getParameter("Latitude_Of_Origin", esriString); - if (value != null) { - key = Proj4Keyword.lat_0; - params.put(key, value); - } - - //Unit - - return params; - } - - private static String getParameter(String name, String esriString) { - String result = null; - String par = "PARAMETER[\"" + name; - int iStart = esriString.toLowerCase().indexOf(par.toLowerCase()); - if (iStart >= 0) { - iStart += 13 + name.length(); - int iEnd = esriString.indexOf(",", iStart) - 1; - result = esriString.substring(iStart, iEnd); - } - return result; - } - - public String toEsriString(Ellipsoid ellipsoid) { - return "SPHEROID[\"" + ellipsoid.getName() + "\"," + ellipsoid.getEquatorRadius() + "," + getInverseFlattening(ellipsoid) + "]"; - } - - public String toEsriString(Datum datum) { - return "DATUM[\"" + datum.getName() + "\"," + toEsriString(datum.getEllipsoid()) + "]"; - } - - /** - * Get Esri projection string - * @return Esri projection string - */ - public String toEsriString(){ - String result = ""; - String geoName = "GCS_WGS_1984"; - Projection proj = this.crs.getProjection(); - if (proj.getName().equals("longlat")) { - result = "GEOGCS[\"" + geoName + "\"," + toEsriString(this.crs.getDatum()) + "," + "PRIMEM[\"Greenwich\",0.0]" - + "," + "UNIT[\"Degree\",0.0174532925199433]" + "]"; - return result; - } else { - String name = "Custom"; - result = "PROJCS[\"" + name + "\"," + "GEOGCS[\"" + geoName + "\"," + toEsriString(this.crs.getDatum()) + "," - + "PRIMEM[\"Greenwich\",0.0]" + "," + "UNIT[\"Degree\",0.0174532925199433]" + "]" + ", "; - } - - result += "PROJECTION[\"" + proj.getName() + "\"],"; - result += "PARAMETER[\"False_Easting\"," + String.valueOf(proj.getFalseEasting()) + "],"; - result += "PARAMETER[\"False_Northing\"," + String.valueOf(proj.getFalseNorthing()) + "],"; - result += "PARAMETER[\"Central_Meridian\"," + String.valueOf(proj.getProjectionLongitudeDegrees()) + "],"; - result += "PARAMETER[\"Standard_Parallel_1\"," + String.valueOf(proj.getProjectionLatitude1Degrees()) + "],"; - result += "PARAMETER[\"Standard_Parallel_2\"," + String.valueOf(proj.getProjectionLatitude2Degrees()) + "],"; - result += "PARAMETER[\"Scale_Factor\"," + String.valueOf(proj.getScaleFactor()) + "],"; - result += "PARAMETER[\"Latitude_Of_Origin\"," + String.valueOf(proj.getProjectionLatitudeDegrees()) + "],"; - result += "UNIT[\"Meter\",1.0]]"; - return result; - - } - - /** - * To string - * @return String - Proj4 string - */ - @Override - public String toString(){ - return crs.getParameterString(); - } - - /** - * Check if two projections are equals - * @param projA Projection A. - * @param projB Projection B. - * @return Boolean - */ - public boolean equals(Projection projA, Projection projB){ - if (!projA.getName().equals(projB.getName())) - return false; - if (projA.getEquatorRadius() != projB.getEquatorRadius()) - return false; - if (projA.getEllipsoid().eccentricity != projB.getEllipsoid().eccentricity) - return false; - if (!projA.getEllipsoid().isEqual(projA.getEllipsoid(), 0.0000001)) - return false; - if (projA.getEllipsoid().eccentricity2 != projB.getEllipsoid().eccentricity2) - return false; - if (projA.getFalseEasting() != projB.getFalseEasting()) - return false; - if (projA.getFalseNorthing() != projB.getFalseNorthing()) - return false; - if (projA.getFromMetres() != projB.getFromMetres()) - return false; - // if (projA.getHeightOfOrbit() != projB.getHeightOfOrbit()) - // return false; - if (projA.getProjectionLatitudeDegrees() != projB.getProjectionLatitudeDegrees()) - return false; - if (projA.getProjectionLatitude1Degrees() != projB.getProjectionLatitude1Degrees()) - return false; - // if (this.getProjectionLatitude2Degrees() != projB.getProjectionLatitude2Degrees()) - // return false; - if (projA.getProjectionLongitudeDegrees() != projB.getProjectionLongitudeDegrees()) - return false; - if (projA.getScaleFactor() != projB.getScaleFactor()) - return false; - if (projA.getTrueScaleLatitudeDegrees() != projB.getTrueScaleLatitudeDegrees()) - return false; - - return true; - } - - /** - * Determine if the projection is same with another projection - * - * @param projInfo Projection info - * @return Boolean - */ - public boolean equals(ProjectionInfo projInfo){ - if (this.getProjectionName() == ProjectionNames.LongLat && projInfo.getProjectionName() == ProjectionNames.LongLat) - return true; - else { - String proj4Str1 = this.toProj4String(); - String proj4Str2 = projInfo.toProj4String(); - if (proj4Str1.equals(proj4Str2)) - return true; - else { - if (!this.crs.getDatum().isEqual(projInfo.crs.getDatum())) - return false; - return equals(this.crs.getProjection(), projInfo.crs.getProjection()); - } - } - } - - /** - * Calculate scale factor from standard parallel - * - * @param stP Standard parallel - * @return Scale factor - */ - public static double calScaleFactorFromStandardParallel(double stP) { - double e = 0.081819191; - stP = Math.PI * stP / 180; - double tF; - if (stP > 0) { - tF = Math.tan(Math.PI / 4.0 - stP / 2.0) * (Math.pow((1.0 + e * Math.sin(stP)) / (1.0 - e * Math.sin(stP)), e / 2.0)); - } else { - tF = Math.tan(Math.PI / 4.0 + stP / 2.0) / (Math.pow((1.0 + e * Math.sin(stP)) / (1.0 - e * Math.sin(stP)), e / 2.0)); - } - - double mF = Math.cos(stP) / Math.pow(1.0 - e * e * Math.pow(Math.sin(stP), 2.0), 0.5); - double k0 = mF * (Math.pow(Math.pow(1.0 + e, 1.0 + e) * Math.pow(1.0 - e, 1.0 - e), 0.5)) / (2.0 * tF); - - return k0; - } - - /** - * Clone - * @return ProjectionInfo object - */ - public Object clone() { - return ProjectionInfo.factory(this.toProj4String()); - } - // - } diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Robinson.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Robinson.java deleted file mode 100644 index 41e6967e..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Robinson.java +++ /dev/null @@ -1,164 +0,0 @@ -/* Copyright 2012 - Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection.info; - -import java.util.ArrayList; -import java.util.List; - -import org.meteoinfo.common.Direction; -import org.meteoinfo.common.PointD; -import org.meteoinfo.geo.mapview.GridLabel; -import org.meteoinfo.geo.projection.KnownCoordinateSystems; -import org.meteoinfo.geo.projection.ProjectionNames; -import org.meteoinfo.geo.projection.ProjectionUtil; -import org.locationtech.proj4j.CoordinateReferenceSystem; -import org.meteoinfo.geometry.shape.PolygonShape; - -/** - * - * @author Yaqiang Wang - */ -public class Robinson extends ProjectionInfo { - - // - // - // - /** - * Construction - * - * @param crs Coorinate reference system - */ - public Robinson(CoordinateReferenceSystem crs) { - this.crs = crs; - } - - // - // - /** - * Get projection name - * - * @return Projection name - */ - @Override - public ProjectionNames getProjectionName() { - return ProjectionNames.Robinson; - } - - // - // - @Override - void updateBoundary() { - double epsilon = 1e-10; - double cenLon = this.getCenterLon(); - double minLon = cenLon - 180 + epsilon; - double maxLon = cenLon + 180 - epsilon; - double minLat = -90; - double maxLat = 90; - List points = new ArrayList<>(); - double lon = minLon; - double lat = minLat; - while (lon < maxLon) { - points.add(new PointD(lon, lat)); - lon += 1; - } - lon = maxLon; - while (lat < maxLat) { - points.add(new PointD(lon, lat)); - lat += 1; - } - lat = maxLat; - while (lon > minLon) { - points.add(new PointD(lon, lat)); - lon -= 1; - } - lon = minLon; - while (lat > minLat) { - points.add(new PointD(lon, lat)); - lat -= 1; - } - lat = minLat; - points.add(new PointD(lon, lat)); - PolygonShape ps = new PolygonShape(); - ps.setPoints(points); - this.boundary = ProjectionUtil.projectPolygonShape(ps, KnownCoordinateSystems.geographic.world.WGS1984, this); - } - - @Override - public Object[] checkGridLabel(GridLabel gl, float shift) { - float angle = gl.getAngle(); - double v = gl.getValue(); - float xShift = 0.f; - float yShift = 0.f; - XAlign xAlign = XAlign.CENTER; - YAlign yAlign = YAlign.CENTER; - if (gl.isLongitude()) { - if (gl.getLabDirection() == Direction.South) { - yShift = shift; - yAlign = YAlign.TOP; - } else { - yShift = -shift; - yAlign = YAlign.BOTTOM; - } - } else { - if (v == 0) { - if (angle == 90) { - xShift = shift; - xAlign = XAlign.LEFT; - } else if (angle == 270) { - xShift = -shift; - xAlign = XAlign.RIGHT; - } else if (angle < 90) { - xShift = shift; - xAlign = XAlign.LEFT; - yAlign = YAlign.BOTTOM; - } else if (angle > 90 && angle <= 180) { - xShift = shift; - xAlign = XAlign.LEFT; - yAlign = YAlign.TOP; - } else if (angle > 180 && angle < 270) { - xShift = -shift; - xAlign = XAlign.RIGHT; - yAlign = YAlign.TOP; - } else if (angle > 270 && angle <= 360) { - xShift = -shift; - xAlign = XAlign.RIGHT; - yAlign = YAlign.BOTTOM; - } - } else if (v > 0) { - if (gl.getLabDirection() == Direction.East) { - xShift = shift; - xAlign = XAlign.LEFT; - yAlign = YAlign.BOTTOM; - } else { - xShift = -shift; - xAlign = XAlign.RIGHT; - yAlign = YAlign.BOTTOM; - } - } else { - if (gl.getLabDirection() == Direction.East) { - xShift = shift; - xAlign = XAlign.LEFT; - yAlign = YAlign.TOP; - } else { - xShift = -shift; - xAlign = XAlign.RIGHT; - yAlign = YAlign.TOP; - } - } - } - - return new Object[]{xShift, yShift, xAlign, yAlign}; - } - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Sinusoidal.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Sinusoidal.java deleted file mode 100644 index 6a619945..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Sinusoidal.java +++ /dev/null @@ -1,97 +0,0 @@ -/* Copyright 2012 - Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection.info; - -import java.util.ArrayList; -import java.util.List; - -import org.meteoinfo.common.PointD; -import org.meteoinfo.geo.projection.KnownCoordinateSystems; -import org.meteoinfo.geo.projection.ProjectionNames; -import org.meteoinfo.geo.projection.ProjectionUtil; -import org.locationtech.proj4j.CoordinateReferenceSystem; -import org.meteoinfo.geometry.shape.PolygonShape; - -/** - * - * @author Yaqiang Wang - */ -public class Sinusoidal extends ProjectionInfo { - - // - // - // - /** - * Construction - * - * @param crs Coorinate reference system - */ - public Sinusoidal(CoordinateReferenceSystem crs) { - this.crs = crs; - } - - // - // - /** - * Get projection name - * - * @return Projection name - */ - @Override - public ProjectionNames getProjectionName() { - return ProjectionNames.Sinusoidal; - } - - // - // - /** - * Get valid parameters - * @return Valid parameters - */ - @Override - public List getValidParas() { - List paras = new ArrayList<>(); - paras.add("lon_0"); - return paras; - } - - @Override - void updateBoundary() { - double epsilon = 1e-10; - double cenLon = this.getCenterLon(); - double minLon = cenLon - 180 + epsilon; - double maxLon = cenLon + 180 - epsilon; - double minLat = -90; - double maxLat = 90; - List points = new ArrayList<>(); - double lon = maxLon; - double lat = minLat; - while (lat < maxLat) { - points.add(new PointD(lon, lat)); - lat += 1; - } - lat = maxLat; - lon = minLon; - while (lat > minLat) { - points.add(new PointD(lon, lat)); - lat -= 1; - } - lat = minLat; - points.add(new PointD(lon, lat)); - PolygonShape ps = new PolygonShape(); - ps.setPoints(points); - this.boundary = ProjectionUtil.projectPolygonShape(ps, KnownCoordinateSystems.geographic.world.WGS1984, this); - } - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/StereographicAzimuthal.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/StereographicAzimuthal.java deleted file mode 100644 index 5219dc4c..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/StereographicAzimuthal.java +++ /dev/null @@ -1,108 +0,0 @@ -/* Copyright 2012 - Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection.info; - -import java.util.ArrayList; -import java.util.List; - -import org.meteoinfo.common.PointD; -import org.meteoinfo.geo.projection.KnownCoordinateSystems; -import org.meteoinfo.geo.projection.ProjectionNames; -import org.meteoinfo.geo.projection.ProjectionUtil; -import org.locationtech.proj4j.CoordinateReferenceSystem; -import org.meteoinfo.geometry.shape.PolygonShape; - -/** - * - * @author Yaqiang Wang - */ -public class StereographicAzimuthal extends ProjectionInfo { - - // - // - // - /** - * Construction - * - * @param crs Coorinate reference system - */ - public StereographicAzimuthal(CoordinateReferenceSystem crs) { - this.crs = crs; - this.cutoff = 0.f; - } - - // - // - /** - * Get projection name - * - * @return Projection name - */ - @Override - public ProjectionNames getProjectionName() { - if (this.isNorthPolar()) { - return ProjectionNames.North_Polar_Stereographic_Azimuthal; - } else if (this.isSouthPolar()) { - return ProjectionNames.South_Polar_Stereographic_Azimuthal; - } else { - return ProjectionNames.Stereographic_Azimuthal; - } - } - - // - // - /** - * Check is north polar or not - * - * @return Boolean - */ - public boolean isNorthPolar() { - return this.crs.getProjection().getProjectionLatitudeDegrees() == 90; - } - - /** - * Check is south polar or not - * - * @return Boolean - */ - public boolean isSouthPolar() { - return this.crs.getProjection().getProjectionLatitudeDegrees() == -90; - } - - /** - * Set latitude cutoff - * - * @param value Latitude cutoff - */ - @Override - public void setCutoff(float value) { - this.cutoff = value; - this.updateBoundary(); - } - - @Override - void updateBoundary() { - List points = new ArrayList<>(); - double lon = -180; - double lat = this.cutoff; - while (lon <= 180) { - points.add(new PointD(lon, lat)); - lon += 1; - } - PolygonShape ps = new PolygonShape(); - ps.setPoints(points); - this.boundary = ProjectionUtil.projectPolygonShape(ps, KnownCoordinateSystems.geographic.world.WGS1984, this); - } - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/TransverseMercator.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/TransverseMercator.java deleted file mode 100644 index 4c6ba4f7..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/TransverseMercator.java +++ /dev/null @@ -1,85 +0,0 @@ -/* Copyright 2012 - Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection.info; - -import java.util.ArrayList; -import java.util.List; - -import org.meteoinfo.common.PointD; -import org.meteoinfo.geo.projection.ProjectionNames; -import org.locationtech.proj4j.CoordinateReferenceSystem; -import org.meteoinfo.geometry.shape.PolygonShape; - -/** - * - * @author Yaqiang Wang - */ -public class TransverseMercator extends ProjectionInfo { - - // - // - // - /** - * Construction - * - * @param crs Coorinate reference system - */ - public TransverseMercator(CoordinateReferenceSystem crs) { - this.crs = crs; - this.cutoff = 85.0511f; - } - - // - // - /** - * Get projection name - * - * @return Projection name - */ - @Override - public ProjectionNames getProjectionName() { - return ProjectionNames.Transverse_Mercator; - } - - // - // - /** - * Set latitude cutoff - * - * @param value Latitude cutoff - */ - @Override - public void setCutoff(float value) { - this.cutoff = value; - this.updateBoundary(); - } - - @Override - void updateBoundary() { - double x0 = -2e7; - double x1 = 2e7; - double y0 = -1e7; - double y1 = 1e7; - List points = new ArrayList<>(); - points.add(new PointD(x0, y0)); - points.add(new PointD(x1, y0)); - points.add(new PointD(x1, y1)); - points.add(new PointD(x0, y1)); - points.add(new PointD(x0, y0)); - PolygonShape ps = new PolygonShape(); - ps.setPoints(points); - this.boundary = ps; - } - // -} diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Wagner3.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Wagner3.java deleted file mode 100644 index f0a70dd5..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/projection/info/Wagner3.java +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright 2012 - Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.projection.info; - -import java.util.ArrayList; -import java.util.List; - -import org.meteoinfo.common.PointD; -import org.meteoinfo.geo.projection.KnownCoordinateSystems; -import org.meteoinfo.geo.projection.ProjectionNames; -import org.meteoinfo.geo.projection.ProjectionUtil; -import org.locationtech.proj4j.CoordinateReferenceSystem; -import org.meteoinfo.geometry.shape.PolygonShape; - -/** - * - * @author Yaqiang Wang - */ -public class Wagner3 extends ProjectionInfo { - - // - // - // - /** - * Construction - * - * @param crs Coorinate reference system - */ - public Wagner3(CoordinateReferenceSystem crs) { - this.crs = crs; - } - - // - // - /** - * Get projection name - * - * @return Projection name - */ - @Override - public ProjectionNames getProjectionName() { - return ProjectionNames.Wagner3; - } - - // - // - @Override - void updateBoundary() { - double epsilon = 1e-10; - double cenLon = this.getCenterLon(); - double minLon = cenLon - 180 + epsilon; - double maxLon = cenLon + 180 - epsilon; - double minLat = -90; - double maxLat = 90; - List points = new ArrayList<>(); - double lon = minLon; - double lat = minLat; - while (lon < maxLon) { - points.add(new PointD(lon, lat)); - lon += 1; - } - lon = maxLon; - while (lat < maxLat) { - points.add(new PointD(lon, lat)); - lat += 1; - } - lat = maxLat; - while (lon > minLon) { - points.add(new PointD(lon, lat)); - lon -= 1; - } - lon = minLon; - while (lat > minLat) { - points.add(new PointD(lon, lat)); - lat -= 1; - } - lat = minLat; - points.add(new PointD(lon, lat)); - PolygonShape ps = new PolygonShape(); - ps.setPoints(points); - this.boundary = ProjectionUtil.projectPolygonShape(ps, KnownCoordinateSystems.geographic.world.WGS1984, this); - } - // -} diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/geo/util/GeoMathUtil.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/util/GeoMathUtil.java similarity index 99% rename from MeteoInfoLib/src/main/java/org/meteoinfo/geo/util/GeoMathUtil.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/util/GeoMathUtil.java index 10446255..8153e802 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/geo/util/GeoMathUtil.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/util/GeoMathUtil.java @@ -4,11 +4,11 @@ import org.meteoinfo.common.PointD; import org.meteoinfo.data.GridData; import org.meteoinfo.data.GridDataSetting; import org.meteoinfo.data.StationData; +import org.meteoinfo.geo.layer.VectorLayer; import org.meteoinfo.geometry.geoprocess.GeoComputation; import org.meteoinfo.geometry.shape.PolygonShape; import org.meteoinfo.geometry.shape.ShapeTypes; -import org.meteoinfo.geoprocess.analysis.InterpolationSetting; -import org.meteoinfo.layer.VectorLayer; +import org.meteoinfo.geo.analysis.InterpolationSetting; import java.util.ArrayList; import java.util.List; diff --git a/MeteoInfoLib/src/main/java/org/meteoinfo/geo/util/GeoProjectionUtil.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/util/GeoProjectionUtil.java similarity index 98% rename from MeteoInfoLib/src/main/java/org/meteoinfo/geo/util/GeoProjectionUtil.java rename to meteoinfo-geo/src/main/java/org/meteoinfo/geo/util/GeoProjectionUtil.java index a65c0bb7..b30d0ed8 100644 --- a/MeteoInfoLib/src/main/java/org/meteoinfo/geo/util/GeoProjectionUtil.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/util/GeoProjectionUtil.java @@ -17,11 +17,11 @@ import org.meteoinfo.common.Extent; import org.meteoinfo.common.MIMath; import org.meteoinfo.common.PointD; import org.meteoinfo.data.GridArray; +import org.meteoinfo.geo.layer.RasterLayer; +import org.meteoinfo.geo.layer.VectorLayer; import org.meteoinfo.geometry.shape.*; -import org.meteoinfo.geoprocess.GeoComputation; -import org.meteoinfo.geoprocess.GeometryUtil; -import org.meteoinfo.layer.RasterLayer; -import org.meteoinfo.layer.VectorLayer; +import org.meteoinfo.geometry.geoprocess.GeoComputation; +import org.meteoinfo.geometry.geoprocess.GeometryUtil; import org.meteoinfo.math.interpolate.InterpUtil; import org.meteoinfo.ndarray.Array; import org.meteoinfo.ndarray.DataType; @@ -29,12 +29,12 @@ import org.meteoinfo.ndarray.InvalidRangeException; import org.meteoinfo.ndarray.math.ArrayUtil; import org.meteoinfo.projection.ProjectionInfo; import org.meteoinfo.projection.ProjectionNames; +import org.meteoinfo.projection.ProjectionUtil; import org.meteoinfo.projection.Reproject; import org.meteoinfo.table.DataColumn; import org.meteoinfo.table.DataRow; import org.meteoinfo.table.DataTable; import org.meteoinfo.table.Field; -import org.meteoinfo.projection.ProjectionUtil; import java.util.ArrayList; import java.util.List; @@ -56,7 +56,7 @@ public class GeoProjectionUtil { * @param fromProj From projection * @param toProj To projection * @return Porjected grid data - * @throws org.meteoinfo.ndarray.InvalidRangeException + * @throws InvalidRangeException */ public static Object[] reprojectGrid(Array data, Array xx, Array yy, ProjectionInfo fromProj, ProjectionInfo toProj) throws InvalidRangeException { @@ -419,7 +419,7 @@ public class GeoProjectionUtil { * @param fromProj From projection * @param toProj To projection * @return Porjected grid data - * @throws org.meteoinfo.ndarray.InvalidRangeException + * @throws InvalidRangeException */ public static GridArray project(GridArray gridArray, ProjectionInfo fromProj, ProjectionInfo toProj) throws InvalidRangeException { Array xx = ArrayUtil.array(gridArray.xArray); diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/util/LegendManage.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/util/LegendManage.java deleted file mode 100644 index 3b89a7f6..00000000 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/util/LegendManage.java +++ /dev/null @@ -1,1854 +0,0 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.geo.util; - -import org.meteoinfo.common.MIMath; -import org.meteoinfo.common.colors.ColorMap; -import org.meteoinfo.geo.data.GridArray; -import org.meteoinfo.geo.data.GridData; -import org.meteoinfo.geo.data.StationData; -import org.meteoinfo.drawing.ContourDraw; -import org.meteoinfo.common.DataConvert; -import org.meteoinfo.geo.layer.VectorLayer; -import org.meteoinfo.geometry.legend.*; -import org.meteoinfo.ndarray.util.BigDecimalUtil; -import org.meteoinfo.geometry.shape.Shape; -import org.meteoinfo.geometry.shape.*; - -import java.awt.*; -import java.io.IOException; -import java.text.DecimalFormat; -import java.text.NumberFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -/** - * Legend manage class - * - * @author yaqiang - */ -public class LegendManage { - - /** - * Create legend scheme from grid data - * - * @param aGridData Grid data - * @param aLT Legend type - * @param aST Shape type - * @return Legend scheme - */ - public static LegendScheme createLegendSchemeFromGridData(GridData aGridData, - LegendType aLT, ShapeTypes aST) { - LegendScheme aLS; - double[] CValues; - Color[] colors; - double[] maxmin = new double[2]; - boolean hasUndef = aGridData.getMaxMinValue(maxmin); - double MinData = maxmin[1]; - double MaxData = maxmin[0]; - - CValues = createContourValues(MinData, MaxData); - colors = createRainBowColors(CValues.length + 1); - -// List values = new ArrayList(); -// //String dFormat = "%1$." + String.valueOf(MIMath.getDecimalNum(CValues[0])) + "f"; -// for (double v : CValues) { -// //values.add(String.format(dFormat, v)); -// values.add(String.valueOf(v)); -// } - //Generate lengendscheme - if (aLT == LegendType.UniqueValue) { - aLS = createUniqValueLegendScheme(CValues, colors, - aST, MinData, MaxData, hasUndef, aGridData.missingValue); - } else { - aLS = createGraduatedLegendScheme(CValues, colors, - aST, MinData, MaxData, hasUndef, aGridData.missingValue); - } - - return aLS; - } - - /** - * Create legend scheme from grid data - * - * @param aGridData Grid data - * @param aLT Legend type - * @param aST Shape type - * @return Legend scheme - */ - public static LegendScheme createLegendSchemeFromGridData(GridArray aGridData, - LegendType aLT, ShapeTypes aST) { - LegendScheme aLS; - double[] CValues; - Color[] colors; - double[] maxmin = new double[2]; - boolean hasUndef = aGridData.getMaxMinValue(maxmin); - double MinData = maxmin[1]; - double MaxData = maxmin[0]; - - CValues = createContourValues(MinData, MaxData); - colors = createRainBowColors(CValues.length + 1); - -// List values = new ArrayList(); -// //String dFormat = "%1$." + String.valueOf(MIMath.getDecimalNum(CValues[0])) + "f"; -// for (double v : CValues) { -// //values.add(String.format(dFormat, v)); -// values.add(String.valueOf(v)); -// } - //Generate lengendscheme - if (aLT == LegendType.UniqueValue) { - aLS = createUniqValueLegendScheme(CValues, colors, - aST, MinData, MaxData, hasUndef, aGridData.missingValue); - } else { - aLS = createGraduatedLegendScheme(CValues, colors, - aST, MinData, MaxData, hasUndef, aGridData.missingValue); - } - - return aLS; - } - - /** - * Create legend scheme from station data - * - * @param stationData Station data - * @param aLT Legend type - * @param aST Shape type - * @return Legend scheme - */ - public static LegendScheme createLegendSchemeFromStationData(StationData stationData, - LegendType aLT, ShapeTypes aST) { - LegendScheme aLS; - double[] CValues; - Color[] colors; - double MinData; - double MaxData; - double[] minmax = new double[2]; - boolean hasNoData = ContourDraw.getMinMaxValueFDiscreteData(stationData.data, stationData.missingValue, minmax); - MinData = minmax[0]; - MaxData = minmax[1]; - CValues = createContourValues(MinData, MaxData); - colors = createRainBowColors(CValues.length + 1); - - //Generate lengendscheme - if (aLT == LegendType.UniqueValue) { - aLS = createUniqValueLegendScheme(CValues, colors, - aST, MinData, MaxData, hasNoData, stationData.missingValue); - } else { - aLS = createGraduatedLegendScheme(CValues, colors, - aST, MinData, MaxData, hasNoData, stationData.missingValue); - } - - return aLS; - } - - /** - * Create single symbol legend scheme - * - * @param shapeType The shape type - * @return Legend scheme - */ - public static LegendScheme createSingleSymbolLegendScheme(ShapeTypes shapeType) { - if (shapeType.isPoint()) { - return createSingleSymbolLegendScheme(shapeType, Color.green, 8.0f); - } else if (shapeType.isLine()) { - return createSingleSymbolLegendScheme(shapeType, Color.blue, 1.0f); - } else { - return createSingleSymbolLegendScheme(shapeType, Color.cyan, 1.0f); - } - } - - /** - * Create single symbol legend scheme - * - * @param aST Shape type - * @param aColor Color - * @param size Size - * @return Legend scheme - */ - public static LegendScheme createSingleSymbolLegendScheme(ShapeTypes aST, Color aColor, - float size) { - LegendScheme legendScheme = new LegendScheme(aST); - legendScheme.setLegendType(LegendType.SingleSymbol); - legendScheme.setShapeType(aST); - legendScheme.setMinValue(0); - legendScheme.setMaxValue(0); - legendScheme.setUndefValue(-9999); - legendScheme.setLegendBreaks(new ArrayList()); - if (aST.isPoint()) { - PointBreak aPB = new PointBreak(); - aPB.setColor(aColor); - aPB.setOutlineColor(Color.black); - aPB.setSize(size); - aPB.setNoData(false); - aPB.setDrawFill(true); - aPB.setDrawOutline(true); - aPB.setDrawShape(true); - aPB.setStyle(PointStyle.Circle); - aPB.setStartValue(0); - aPB.setEndValue(0); - aPB.setCaption(""); - legendScheme.getLegendBreaks().add(aPB); - } else if (aST.isLine()) { - PolylineBreak aPLB = new PolylineBreak(); - aPLB.setColor(aColor); - aPLB.setDrawPolyline(true); - aPLB.setWidth(size); - aPLB.setStyle(LineStyles.SOLID); - aPLB.setStartValue(0); - aPLB.setEndValue(0); - aPLB.setCaption(""); - aPLB.setSymbolColor(aColor); - legendScheme.getLegendBreaks().add(aPLB); - } else if (aST.isPolygon()) { - PolygonBreak aPGB = new PolygonBreak(); - aPGB.setColor(aColor); - aPGB.setDrawFill(true); - aPGB.setDrawOutline(true); - aPGB.setDrawShape(true); - aPGB.setOutlineColor(Color.gray); - aPGB.setOutlineSize(size); - aPGB.setStartValue(0); - aPGB.setEndValue(0); - aPGB.setCaption(""); - legendScheme.getLegendBreaks().add(aPGB); - - } - - return legendScheme; - } - - /** - * Create unique value legend scheme - * - * @param CValues The values - * @param captions The captions - * @param colors The colors - * @param aST The shape type - * @param min Minimum value - * @param max Maximum value - * @param hasNodata If has undefine data - * @param unDef Undefine data - * @return The legend scheme - */ - public static LegendScheme createUniqValueLegendScheme(List CValues, List captions, Color[] colors, ShapeTypes aST, - double min, double max, boolean hasNodata, double unDef) { - LegendScheme legendScheme = new LegendScheme(aST); - legendScheme.setLegendType(LegendType.UniqueValue); - legendScheme.setShapeType(aST); - legendScheme.setMinValue(min); - legendScheme.setMaxValue(max); - legendScheme.setUndefValue(unDef); - int i; - //List idxList = new ArrayList(); - if (aST.isPoint()) { - for (i = 1; i < colors.length; i++) { - PointBreak aPB = new PointBreak(); - aPB.setColor(colors[i]); - aPB.setStartValue(CValues.get(i - 1)); - aPB.setEndValue(aPB.getStartValue()); - if (colors.length <= 13) { - aPB.setSize((float) i / 2 + 2); - } else { - aPB.setSize(5); - } - aPB.setStyle(PointStyle.Circle); - aPB.setOutlineColor(Color.black); - aPB.setNoData(false); - aPB.setDrawOutline(true); - aPB.setDrawFill(true); - aPB.setDrawShape(true); - aPB.setCaption(captions.get(i - 1)); - - legendScheme.getLegendBreaks().add(aPB); - } - legendScheme.setHasNoData(false); - } else if (aST.isLine()) { - for (i = 1; i < colors.length; i++) { - PolylineBreak aPLB = new PolylineBreak(); - aPLB.setColor(colors[i]); - aPLB.setStartValue(CValues.get(i - 1)); - aPLB.setEndValue(aPLB.getStartValue()); - aPLB.setWidth(1.0F); - aPLB.setStyle(LineStyles.SOLID); - aPLB.setDrawPolyline(true); - aPLB.setCaption(captions.get(i - 1)); - aPLB.setSymbolColor(aPLB.getColor()); - aPLB.setSymbolStyle(PointStyle.Circle); - - legendScheme.getLegendBreaks().add(aPLB); - } - legendScheme.setHasNoData(false); - } else if (aST.isPolygon()) { - for (i = 1; i < colors.length; i++) { - PolygonBreak aPGB = new PolygonBreak(); - aPGB.setColor(colors[i]); - aPGB.setOutlineColor(Color.gray); - aPGB.setOutlineSize(1.0F); - aPGB.setDrawFill(true); - aPGB.setDrawOutline(true); - aPGB.setDrawShape(true); - aPGB.setStartValue(CValues.get(i - 1)); - aPGB.setEndValue(aPGB.getStartValue()); - aPGB.setCaption(captions.get(i - 1)); - //aPGB.Style = (HatchStyle)idxList[i]; - - legendScheme.getLegendBreaks().add(aPGB); - } - legendScheme.setHasNoData(false); - } - - return legendScheme; - } - - /** - * Create unique value legend scheme - * - * @param CValues The values - * @param captions The captions - * @param colors The colors - * @param aST The shape type - * @param min Minimum value - * @param max Maximum value - * @return The legend scheme - */ - public static LegendScheme createUniqValueLegendScheme(List CValues, List captions, Color[] colors, ShapeTypes aST, - double min, double max) { - LegendScheme legendScheme = new LegendScheme(aST); - legendScheme.setLegendType(LegendType.UniqueValue); - legendScheme.setShapeType(aST); - legendScheme.setMinValue(min); - legendScheme.setMaxValue(max); - int i; - if (aST.isPoint()) { - for (i = 1; i < colors.length; i++) { - PointBreak aPB = new PointBreak(); - aPB.setColor(colors[i]); - aPB.setStartValue(CValues.get(i - 1)); - aPB.setEndValue(aPB.getStartValue()); - if (colors.length <= 13) { - aPB.setSize((float) i / 2 + 2); - } else { - aPB.setSize(5); - } - aPB.setStyle(PointStyle.Circle); - aPB.setOutlineColor(Color.black); - aPB.setNoData(false); - aPB.setDrawOutline(true); - aPB.setDrawFill(true); - aPB.setDrawShape(true); - aPB.setCaption(captions.get(i - 1)); - - legendScheme.getLegendBreaks().add(aPB); - } - legendScheme.setHasNoData(false); - } else if (aST.isLine()) { - for (i = 1; i < colors.length; i++) { - PolylineBreak aPLB = new PolylineBreak(); - aPLB.setColor(colors[i]); - aPLB.setStartValue(CValues.get(i - 1)); - aPLB.setEndValue(aPLB.getStartValue()); - aPLB.setWidth(1.0F); - aPLB.setStyle(LineStyles.SOLID); - aPLB.setDrawPolyline(true); - aPLB.setCaption(captions.get(i - 1)); - aPLB.setSymbolColor(aPLB.getColor()); - aPLB.setSymbolStyle(PointStyle.Circle); - - legendScheme.getLegendBreaks().add(aPLB); - } - legendScheme.setHasNoData(false); - } else if (aST.isPolygon()) { - for (i = 1; i < colors.length; i++) { - PolygonBreak aPGB = new PolygonBreak(); - aPGB.setColor(colors[i]); - aPGB.setOutlineColor(Color.gray); - aPGB.setOutlineSize(1.0F); - aPGB.setDrawFill(true); - aPGB.setDrawOutline(true); - aPGB.setDrawShape(true); - aPGB.setStartValue(CValues.get(i - 1)); - aPGB.setEndValue(aPGB.getStartValue()); - aPGB.setCaption(captions.get(i - 1)); - //aPGB.Style = (HatchStyle)idxList[i]; - - legendScheme.getLegendBreaks().add(aPGB); - } - legendScheme.setHasNoData(false); - } - - return legendScheme; - } - - /** - * Create unique value legend scheme - * - * @param n Legend break number - * @param aST The shape type - * @return The legend scheme - */ - public static LegendScheme createUniqValueLegendScheme(int n, ShapeTypes aST) { - LegendScheme legendScheme = new LegendScheme(aST); - legendScheme.setLegendType(LegendType.UniqueValue); - legendScheme.setShapeType(aST); - Color[] colors; - - if (n <= 13) { - colors = LegendManage.createRainBowColors(n); - } else { - colors = LegendManage.createRandomColors(n); - } - - int i; - if (aST.isPoint()) { - for (i = 0; i < colors.length; i++) { - PointBreak aPB = new PointBreak(); - aPB.setColor(colors[i]); - aPB.setStartValue(i); - aPB.setEndValue(i); - aPB.setSize(6); - aPB.setStyle(PointStyle.Circle); - aPB.setOutlineColor(Color.black); - aPB.setNoData(false); - aPB.setDrawOutline(true); - aPB.setDrawFill(true); - aPB.setDrawShape(true); - aPB.setCaption(String.valueOf(i)); - - legendScheme.getLegendBreaks().add(aPB); - } - legendScheme.setHasNoData(false); - } else if (aST.isLine()) { - int ii = 0; - for (i = 0; i < colors.length; i++) { - PolylineBreak aPLB = new PolylineBreak(); - aPLB.setColor(colors[i]); - aPLB.setStartValue(i); - aPLB.setEndValue(i); - aPLB.setWidth(1.0F); - aPLB.setStyle(LineStyles.SOLID); - aPLB.setDrawPolyline(true); - aPLB.setCaption(String.valueOf(i)); - aPLB.setSymbolColor(aPLB.getColor()); - aPLB.setSymbolStyle(PointStyle.values()[ii]); - ii += 1; - if (ii == PointStyle.values().length) { - ii = 0; - } - - legendScheme.getLegendBreaks().add(aPLB); - } - legendScheme.setHasNoData(false); - } else if (aST.isPolygon()) { - for (i = 0; i < colors.length; i++) { - PolygonBreak aPGB = new PolygonBreak(); - aPGB.setColor(colors[i]); - aPGB.setOutlineColor(Color.gray); - aPGB.setOutlineSize(1.0F); - aPGB.setDrawFill(true); - aPGB.setDrawOutline(true); - aPGB.setDrawShape(true); - aPGB.setStartValue(i); - aPGB.setEndValue(i); - aPGB.setCaption(String.valueOf(i)); - //aPGB.Style = (HatchStyle)idxList[i]; - - legendScheme.getLegendBreaks().add(aPGB); - } - legendScheme.setHasNoData(false); - } - - return legendScheme; - } - - /** - * Create unique value legend scheme - * - * @param values Values - * @param aST The shape type - * @return The legend scheme - */ - public static LegendScheme createUniqValueLegendScheme(List values, ShapeTypes aST) { - Color[] colors; - int n = values.size(); - if (n <= 13) { - colors = LegendManage.createRainBowColors(n); - } else { - colors = LegendManage.createRandomColors(n); - } - return LegendManage.createUniqValueLegendScheme(values, colors, aST); - } - - /** - * Create unique value legend scheme - * - * @param values Values - * @param cmap Color map - * @param aST The shape type - * @return The legend scheme - */ - public static LegendScheme createUniqValueLegendScheme(List values, ColorMap cmap, ShapeTypes aST) { - int n = values.size(); - Color[] colors = cmap.getColors(n); - return LegendManage.createUniqValueLegendScheme(values, colors, aST); - } - - /** - * Create unique value legend scheme - * - * @param values Values - * @param colors Colors - * @param aST The shape type - * @return The legend scheme - */ - public static LegendScheme createUniqValueLegendScheme(List values, Color[] colors, ShapeTypes aST) { - LegendScheme legendScheme = new LegendScheme(aST); - legendScheme.setLegendType(LegendType.UniqueValue); - legendScheme.setShapeType(aST); - - int i; - if (aST.isPoint()) { - for (i = 0; i < colors.length; i++) { - PointBreak aPB = new PointBreak(); - aPB.setColor(colors[i]); - aPB.setStartValue(values.get(i)); - aPB.setEndValue(values.get(i)); - aPB.setSize(6); - aPB.setStyle(PointStyle.Circle); - aPB.setOutlineColor(Color.black); - aPB.setNoData(false); - aPB.setDrawOutline(true); - aPB.setDrawFill(true); - aPB.setDrawShape(true); - aPB.setCaption(String.valueOf(values.get(i))); - - legendScheme.addLegendBreak(aPB); - } - legendScheme.setHasNoData(false); - } else if (aST.isLine()) { - int ii = 0; - for (i = 0; i < colors.length; i++) { - PolylineBreak aPLB = new PolylineBreak(); - aPLB.setColor(colors[i]); - aPLB.setStartValue(values.get(i)); - aPLB.setEndValue(values.get(i)); - aPLB.setWidth(1.0F); - aPLB.setStyle(LineStyles.SOLID); - aPLB.setDrawPolyline(true); - aPLB.setCaption(String.valueOf(values.get(i))); - aPLB.setSymbolColor(aPLB.getColor()); - aPLB.setSymbolStyle(PointStyle.values()[ii]); - ii += 1; - if (ii == PointStyle.values().length) { - ii = 0; - } - - legendScheme.addLegendBreak(aPLB); - } - legendScheme.setHasNoData(false); - } else if (aST.isPolygon()) { - for (i = 0; i < colors.length; i++) { - PolygonBreak aPGB = new PolygonBreak(); - aPGB.setColor(colors[i]); - aPGB.setOutlineColor(Color.gray); - aPGB.setOutlineSize(1.0F); - aPGB.setDrawFill(true); - aPGB.setDrawOutline(true); - aPGB.setDrawShape(true); - aPGB.setStartValue(values.get(i)); - aPGB.setEndValue(values.get(i)); - aPGB.setCaption(String.valueOf(values.get(i))); - //aPGB.Style = (HatchStyle)idxList[i]; - - legendScheme.addLegendBreak(aPGB); - } - legendScheme.setHasNoData(false); - } else { - for (i = 0; i < colors.length; i++) { - ColorBreak aPGB = new ColorBreak(); - aPGB.setColor(colors[i]); - aPGB.setDrawShape(true); - aPGB.setStartValue(values.get(i)); - aPGB.setEndValue(values.get(i)); - aPGB.setCaption(String.valueOf(values.get(i))); - //aPGB.Style = (HatchStyle)idxList[i]; - - legendScheme.addLegendBreak(aPGB); - } - legendScheme.setHasNoData(false); - } - - return legendScheme; - } - - /** - * Create unique value legend scheme - * - * @param values Values - * @param colors Colors - * @param aST The shape type - * @return The legend scheme - */ - public static LegendScheme createUniqValueLegendScheme(List values, List colors, ShapeTypes aST) { - Color[] cols = colors.toArray(new Color[0]); - return createUniqValueLegendScheme(values, cols, aST); - } - - /** - * Create unique value legend scheme - * - * @param CValues The values - * @param colors The colors - * @param aST The shape type - * @param min Minimum value - * @param max Maximum value - * @param hasNodata If has undefine data - * @param unDef Undefine data - * @return The legend scheme - */ - public static LegendScheme createUniqValueLegendScheme(List CValues, Color[] colors, ShapeTypes aST, - double min, double max, boolean hasNodata, double unDef) { - return createUniqValueLegendScheme(CValues, CValues, colors, aST, min, max, hasNodata, unDef); - } - - /** - * Create unique value legend scheme - * - * @param CValues The values - * @param colors The colors - * @param aST The shape type - * @param min Minimum value - * @param max Maximum value - * @param hasNodata If has undefine data - * @param unDef Undefine data - * @return The legend scheme - */ - public static LegendScheme createUniqValueLegendScheme(double[] CValues, Color[] colors, ShapeTypes aST, - double min, double max, Boolean hasNodata, double unDef) { - List values = new ArrayList<>(); - List captions = new ArrayList<>(); - String dFormat = "%1$." + String.valueOf(MIMath.getDecimalNum(CValues[0])) + "f"; - for (double v : CValues) { - captions.add(String.format(dFormat, v)); - values.add(String.valueOf(v)); - } - - return createUniqValueLegendScheme(values, captions, colors, aST, min, max, hasNodata, unDef); - } - - /** - * Create unique value legend scheme - * - * @param CValues The values - * @param colors The colors - * @param aST The shape type - * @param min Minimum value - * @param max Maximum value - * @return The legend scheme - */ - public static LegendScheme createUniqValueLegendScheme(double[] CValues, Color[] colors, ShapeTypes aST, - double min, double max) { - List values = new ArrayList<>(); - List captions = new ArrayList<>(); - String dFormat = "%1$." + String.valueOf(MIMath.getDecimalNum(CValues[0])) + "f"; - for (double v : CValues) { - captions.add(String.format(dFormat, v)); - values.add(String.valueOf(v)); - } - - return createUniqValueLegendScheme(values, captions, colors, aST, min, max); - } - - /** - * Create unique value legend scheme from a vector layer - * - * @param aLayer Vector layer - * @param min Minimum - * @param max Maximum - * @return Legend scheme - */ - public static LegendScheme createUniqValueLegendScheme(VectorLayer aLayer, double min, double max) { - double[] CValues; - Color[] colors; - List valueList = new ArrayList<>(); - - switch (aLayer.getShapeType()) { - case Point: - for (Shape aPS : aLayer.getShapes()) { - if (!valueList.contains(((PointShape) aPS).getValue())) { - valueList.add(((PointShape) aPS).getValue()); - } - } - break; - case Polyline: - case PolylineZ: - for (Shape aPLS : aLayer.getShapes()) { - if (!valueList.contains(((PolylineShape) aPLS).getValue())) { - valueList.add(((PolylineShape) aPLS).getValue()); - } - } - break; - default: - for (Shape aPGS : aLayer.getShapes()) { - if (!valueList.contains(((PolygonShape) aPGS).lowValue)) { - valueList.add(((PolygonShape) aPGS).lowValue); - } - } - break; - } - - CValues = new double[valueList.size()]; - for (int i = 0; i < valueList.size(); i++) { - CValues[i] = valueList.get(i); - } - - if (CValues.length <= 13) { - colors = createRainBowColors(CValues.length); - } else { - colors = createRandomColors(CValues.length); - } - Color[] newcolors = new Color[colors.length + 1]; - newcolors[0] = Color.white; - for (int i = 1; i < newcolors.length; i++) { - newcolors[i] = colors[i - 1]; - } - - LegendScheme aLS = createUniqValueLegendScheme(CValues, newcolors, - aLayer.getShapeType(), min, max, false, -9999); - - return aLS; - } - - /** - * Create graduated color legend scheme - * - * @param CValues The values - * @param colors The colors - * @param aST Shape type - * @param min Minimum value - * @param max Maximum value - * @param hasNodata Is has no data - * @param unDef Undefine data - * @return The legend scheme - */ - public static LegendScheme createGraduatedLegendScheme(double[] CValues, Color[] colors, ShapeTypes aST, - double min, double max, Boolean hasNodata, double unDef) { - if (CValues.length > 1){ - if (min >= CValues[0]) { - min = CValues[0] - (CValues[1] - CValues[0]); - } - if (max <= CValues[CValues.length - 1]) { - max = CValues[CValues.length - 1] + (CValues[CValues.length - 1] - CValues[CValues.length - 2]); - } - //max += CValues[1] - CValues[0]; - } - - LegendScheme legendScheme = new LegendScheme(aST); - legendScheme.setLegendType(LegendType.GraduatedColor); - legendScheme.setShapeType(aST); - legendScheme.setMinValue(min); - legendScheme.setMaxValue(max); - legendScheme.setUndefValue(unDef); - int i; - if (aST.isPoint()) { - for (i = 0; i < colors.length; i++) { - PointBreak aPB = new PointBreak(); - aPB.setColor(colors[i]); - aPB.setOutlineColor(Color.black); - aPB.setNoData(false); - aPB.setDrawOutline(true); - aPB.setDrawFill(true); - aPB.setDrawShape(true); - if (i == 0) { - aPB.setStartValue(min); - } else { - aPB.setStartValue(CValues[i - 1]); - } - if (i == colors.length - 1) { - aPB.setEndValue(max); - } else { - aPB.setEndValue(CValues[i]); - } - //aPB.setSize((float) i / 2 + 2); - aPB.setSize(8); - aPB.setStyle(PointStyle.Circle); - if (aPB.getStartValue() == aPB.getEndValue()) { - aPB.setCaption(DataConvert.removeTailingZeros(aPB.getStartValue().toString())); - } else if (i == 0) { - aPB.setCaption("< " + DataConvert.removeTailingZeros(aPB.getEndValue().toString())); - } else if (i == colors.length - 1) { - aPB.setCaption("> " + DataConvert.removeTailingZeros(aPB.getStartValue().toString())); - } else { - aPB.setCaption(DataConvert.removeTailingZeros(aPB.getStartValue().toString()) - + " - " + DataConvert.removeTailingZeros(aPB.getEndValue().toString())); - } - - legendScheme.addLegendBreak(aPB); - } - legendScheme.setHasNoData(false); - if (hasNodata) { - PointBreak aPB = new PointBreak(); - aPB.setColor(Color.gray); - aPB.setOutlineColor(Color.black); - aPB.setStartValue(unDef); - aPB.setEndValue(aPB.getStartValue()); - aPB.setSize(1); - aPB.setStyle(PointStyle.Circle); - aPB.setCaption("NoData"); - aPB.setNoData(true); - aPB.setDrawShape(true); - aPB.setDrawOutline(true); - legendScheme.addLegendBreak(aPB); - legendScheme.setHasNoData(true); - } - } else if (aST.isLine()) { - for (i = 0; i < colors.length; i++) { - PolylineBreak aPLB = new PolylineBreak(); - aPLB.setColor(colors[i]); - aPLB.setWidth(1.0F); - aPLB.setStyle(LineStyles.SOLID); - aPLB.setDrawPolyline(true); - if (i == 0) { - aPLB.setStartValue(min); - } else { - aPLB.setStartValue(CValues[i - 1]); - } - if (i == colors.length - 1) { - aPLB.setEndValue(max); - } else { - aPLB.setEndValue(CValues[i]); - } - if (aPLB.getStartValue() == aPLB.getEndValue()) { - aPLB.setCaption(DataConvert.removeTailingZeros(aPLB.getStartValue().toString())); - } else if (i == 0) { - aPLB.setCaption("< " + DataConvert.removeTailingZeros(aPLB.getEndValue().toString())); - } else if (i == colors.length - 1) { - aPLB.setCaption("> " + DataConvert.removeTailingZeros(aPLB.getStartValue().toString())); - } else { - aPLB.setCaption(DataConvert.removeTailingZeros(aPLB.getStartValue().toString()) - + " - " + DataConvert.removeTailingZeros(aPLB.getEndValue().toString())); - } - aPLB.setSymbolColor(aPLB.getColor()); - if (i < PointStyle.values().length) { - aPLB.setSymbolStyle(PointStyle.values()[i]); - } - - legendScheme.addLegendBreak(aPLB); - } - legendScheme.setHasNoData(false); - } else if (aST.isPolygon()) { - for (i = 0; i < colors.length; i++) { - PolygonBreak aPGB = new PolygonBreak(); - aPGB.setColor(colors[i]); - aPGB.setOutlineColor(Color.gray); - aPGB.setOutlineSize(1.0F); - aPGB.setDrawFill(true); - aPGB.setDrawOutline(false); - aPGB.setDrawShape(true); - if (i == 0) { - aPGB.setStartValue(min); - } else { - aPGB.setStartValue(CValues[i - 1]); - } - if (i == colors.length - 1) { - aPGB.setEndValue(max); - } else { - aPGB.setEndValue(CValues[i]); - } - if (aPGB.getStartValue() == aPGB.getEndValue()) { - aPGB.setCaption(DataConvert.removeTailingZeros(aPGB.getStartValue().toString())); - } else if (i == 0) { - aPGB.setCaption("< " + DataConvert.removeTailingZeros(aPGB.getEndValue().toString())); - } else if (i == colors.length - 1) { - aPGB.setCaption("> " + DataConvert.removeTailingZeros(aPGB.getStartValue().toString())); - } else { - aPGB.setCaption(DataConvert.removeTailingZeros(aPGB.getStartValue().toString()) - + " - " + DataConvert.removeTailingZeros(aPGB.getEndValue().toString())); - } -// if (Enum.IsDefined(typeof(HatchStyle), i)) -// aPGB.Style = (HatchStyle)i; - - legendScheme.addLegendBreak(aPGB); - } - legendScheme.setHasNoData(false); - } else { - for (i = 0; i < colors.length; i++) { - ColorBreak aCB = new ColorBreak(); - aCB.setColor(colors[i]); - //System.out.println(aCB.getColor().getAlpha()); - if (i == 0) { - aCB.setStartValue(min); - } else { - aCB.setStartValue(CValues[i - 1]); - } - if (i == colors.length - 1) { - aCB.setEndValue(max); - } else { - aCB.setEndValue(CValues[i]); - } - if (aCB.getStartValue() == aCB.getEndValue()) { - aCB.setCaption(DataConvert.removeTailingZeros(aCB.getStartValue().toString())); - } else if (i == 0) { - aCB.setCaption("< " + DataConvert.removeTailingZeros(aCB.getEndValue().toString())); - } else if (i == colors.length - 1) { - aCB.setCaption("> " + DataConvert.removeTailingZeros(aCB.getStartValue().toString())); - } else { - aCB.setCaption(DataConvert.removeTailingZeros(aCB.getStartValue().toString()) - + " - " + DataConvert.removeTailingZeros(aCB.getEndValue().toString())); - } - - legendScheme.addLegendBreak(aCB); - } - legendScheme.setHasNoData(false); - if (hasNodata) { - ColorBreak aCB = new ColorBreak(); - aCB.setColor(new Color(230, 230, 230, 0)); - aCB.setStartValue(unDef); - aCB.setEndValue(aCB.getStartValue()); - aCB.setCaption("NoData"); - aCB.setNoData(true); - legendScheme.addLegendBreak(aCB); - legendScheme.setHasNoData(true); - } - } - - return legendScheme; - } - - /** - * Create legend scheme - * @param values Value list - * @param colors Color list - * @return Legend scheme - */ - public static LegendScheme createLegendScheme(List values, List colors) { - if (values.size() == colors.size()) { - return createUniqValueLegendScheme(values, colors, ShapeTypes.Image); - } else { - double[] vs = new double[values.size()]; - for (int i = 0; i < vs.length; i++) { - vs[i] = values.get(i).doubleValue(); - } - Color[] cs = new Color[values.size()]; - for (int i = 0; i < cs.length; i++) { - cs[i] = colors.get(i); - } - return createGraduatedLegendScheme(vs, cs, ShapeTypes.Image, -Double.MAX_VALUE, Double.MIN_VALUE); - } - } - - /** - * Create graduated color legend scheme - * - * @param values The values - * @param colors The colors - * @param aST Shape type - * @param min Minimum value - * @param max Maximum value - * @return The legend scheme - */ - public static LegendScheme createGraduatedLegendScheme(double[] values, Color[] colors, ShapeTypes aST, - double min, double max) { - double unDef = -9999.0; - boolean hasNodata = false; - return createGraduatedLegendScheme(values, colors, aST, min, max, hasNodata, unDef); - } - - /** - * Create colors from start and end color - * - * @param sColor Start color - * @param eColor End color - * @param cNum Color number - * @return Color array - */ - public static Color[] createColors(Color sColor, Color eColor, int cNum) { - Color[] colors = new Color[cNum]; - int sR, sG, sB, eR, eG, eB; - int rStep, gStep, bStep; - int i; - - sR = sColor.getRed(); - sG = sColor.getGreen(); - sB = sColor.getBlue(); - eR = eColor.getRed(); - eG = eColor.getGreen(); - eB = eColor.getBlue(); - rStep = (int) ((eR - sR) / cNum); - gStep = (int) ((eG - sG) / cNum); - bStep = (int) ((eB - sB) / cNum); - for (i = 0; i < colors.length; i++) { - colors[i] = new Color(sR + i * rStep, sG + i * gStep, sB + i * bStep); - } - - return colors; - } - - /** - * Create contour values by interval - * - * @param min Miminum value - * @param max Maximum value - * @param interval Interval value - * @return Value array - */ - public static double[] createContourValuesInterval(double min, double max, double interval) { - double[] cValues; - int cNum = (int) ((max - min) / interval) + 1; - int i; - - cValues = new double[cNum]; - for (i = 0; i < cNum; i++) { - //cValues[i] = min + i * interval; - cValues[i] = BigDecimalUtil.add(min, BigDecimalUtil.mul(i, interval)); - } - - return cValues; - } - - /** - * Create legend scheme - * - * @param shapeType Shape type - * @param values Values - * @param colors Colors - * @return Legend scheme - */ - public static LegendScheme createLegendScheme(ShapeTypes shapeType, List values, List colors) { - LegendScheme ls; - Color[] cols = new Color[colors.size()]; - for (int i = 0; i < colors.size(); i++) { - cols[i] = colors.get(i); - } - - if (values.size() == colors.size()) { - ls = LegendManage.createUniqValueLegendScheme(values, cols, shapeType); - } else { - int n = values.size(); - double[] vals = new double[n]; - for (int i = 0; i < n; i++) { - vals[i] = values.get(i).doubleValue(); - } - double min = values.get(0).doubleValue() - (values.get(1).doubleValue() - values.get(0).doubleValue()); - double max = values.get(n - 1).doubleValue() + (values.get(n - 1).doubleValue() - values.get(n - 2).doubleValue()); - ls = LegendManage.createGraduatedLegendScheme(vals, cols, shapeType, min, max); - } - - return ls; - } - - /** - * Create legend scheme - * - * @param min Minimum - * @param max Maximum - * @return LegendScheme - */ - public static LegendScheme createLegendScheme(double min, double max) { - double[] values = createContourValues(min, max); - Color[] colors = createRainBowColors(values.length + 1); - return createLegendScheme(min, max, values, colors, LegendType.GraduatedColor, ShapeTypes.Image, false, -9999.0); - } - - /** - * Create legend scheme - * - * @param min Minimum - * @param max Maximum - * @param ct Color table - * @return LegendScheme - */ - public static LegendScheme createLegendScheme(double min, double max, ColorMap ct) { - double[] values = createContourValues(min, max); - Color[] colors = ct.getColors(values.length + 1); - return createLegendScheme(min, max, values, colors, LegendType.GraduatedColor, ShapeTypes.Image, false, -9999.0); - } - - /** - * Create legend scheme - * - * @param min Minimum - * @param max Maximum - * @param ct Color table - * @param missingValue Missing value - * @return LegendScheme - */ - public static LegendScheme createLegendScheme(double min, double max, ColorMap ct, double missingValue) { - double[] values = createContourValues(min, max); - Color[] colors = ct.getColors(values.length + 1); - return createLegendScheme(min, max, values, colors, LegendType.GraduatedColor, ShapeTypes.Image, true, missingValue); - } - - /** - * Create legend scheme - * - * @param min Minimum - * @param max Maximum - * @param interval Interval - * @param legendType Legend type - * @param shapeType Shape type - * @return LegendScheme - */ - public static LegendScheme createLegendScheme(double min, double max, double interval, - LegendType legendType, ShapeTypes shapeType) { - return createLegendScheme(min, max, interval, legendType, shapeType, false, -9999.0); - } - - /** - * Create legend scheme - * - * @param min Minimum - * @param max Maximum - * @param interval Interval - * @param legendType Legend type - * @param shapeType Shape type - * @param hasNodata Has missing value or not - * @param unDef Missing value - * @return LegendScheme - */ - public static LegendScheme createLegendScheme(double min, double max, double interval, - LegendType legendType, ShapeTypes shapeType, boolean hasNodata, double unDef) { - double[] values = MIMath.getIntervalValues(min, max, interval); - Color[] colors = createRainBowColors(values.length + 1); - - LegendScheme ls; - if (legendType == LegendType.UniqueValue) { - ls = createUniqValueLegendScheme(values, colors, - shapeType, min, max, hasNodata, unDef); - } else { - ls = createGraduatedLegendScheme(values, colors, - shapeType, min, max, hasNodata, unDef); - } - - return ls; - } - - /** - * Create legend scheme - * - * @param min Minimum - * @param max Maximum - * @param n Level number - * @return LegendScheme - */ - public static LegendScheme createLegendScheme(double min, double max, int n) { - return createLegendScheme(min, max, n, LegendType.GraduatedColor, ShapeTypes.Image, false, -9999.0); - } - - /** - * Create legend scheme - * - * @param min Minimum - * @param max Maximum - * @param n Level number - * @param legendType Legend type - * @param shapeType Shape type - * @return LegendScheme - */ - public static LegendScheme createLegendScheme(double min, double max, int n, - LegendType legendType, ShapeTypes shapeType) { - return createLegendScheme(min, max, n, legendType, shapeType, false, -9999.0); - } - - /** - * Create legend scheme - * - * @param min Minimum - * @param max Maximum - * @param values Values - * @param colors Colors - * @param legendType Legend type - * @param shapeType Shape type - * @param hasNodata Has missing value or not - * @param unDef Missing value - * @return LegendScheme - */ - public static LegendScheme createLegendScheme(double min, double max, double[] values, Color[] colors, - LegendType legendType, ShapeTypes shapeType, boolean hasNodata, double unDef) { - - LegendScheme ls; - if (legendType == LegendType.UniqueValue) { - ls = createUniqValueLegendScheme(values, colors, - shapeType, min, max, hasNodata, unDef); - } else { - ls = createGraduatedLegendScheme(values, colors, - shapeType, min, max, hasNodata, unDef); - } - - return ls; - } - - /** - * Create legend scheme - * - * @param min Minimum - * @param max Maximum - * @param n Level number - * @param legendType Legend type - * @param shapeType Shape type - * @param hasNodata Has missing value or not - * @param unDef Missing value - * @return LegendScheme - */ - public static LegendScheme createLegendScheme(double min, double max, int n, - LegendType legendType, ShapeTypes shapeType, boolean hasNodata, double unDef) { - double[] values = MIMath.getIntervalValues(min, max, n); - Color[] colors = createRainBowColors(values.length + 1); - - return createLegendScheme(min, max, values, colors, legendType, shapeType, hasNodata, unDef); - } - - /** - * Create legend scheme - * - * @param min Minimum - * @param max Maximum - * @param n Level number - * @param ct Color table - * @param legendType Legend type - * @param shapeType Shape type - * @param hasNodata Has missing value or not - * @param unDef Missing value - * @return LegendScheme - */ - public static LegendScheme createLegendScheme(double min, double max, int n, ColorMap ct, - LegendType legendType, ShapeTypes shapeType, boolean hasNodata, double unDef) { - double[] values = MIMath.getIntervalValues(min, max, n); - Color[] colors = ct.getColors(values.length + 1); - - return createLegendScheme(min, max, values, colors, legendType, shapeType, hasNodata, unDef); - } - - /** - * Create legend scheme - * - * @param min Minimum - * @param max Maximum - * @param levs Level values - * @param ct Color table - * @param legendType Legend type - * @param shapeType Shape type - * @param hasNodata Has missing value or not - * @param unDef Missing value - * @return LegendScheme - */ - public static LegendScheme createLegendScheme(double min, double max, List levs, ColorMap ct, - LegendType legendType, ShapeTypes shapeType, boolean hasNodata, double unDef) { - double[] values = new double[levs.size()]; - for (int i = 0; i < levs.size(); i++){ - values[i] = levs.get(i).doubleValue(); - } - Color[] colors = ct.getColors(values.length + 1); - - return createLegendScheme(min, max, values, colors, legendType, shapeType, hasNodata, unDef); - } - - /** - * Create legend scheme - * - * @param min Minimum - * @param max Maximum - * @param levs Level values - * @param ct Color table - * @return LegendScheme - */ - public static LegendScheme createLegendScheme(double min, double max, List levs, ColorMap ct) { - if (levs.size() == ct.getColorCount()){ - return createUniqValueLegendScheme(levs, ct.getColors(), ShapeTypes.Image); - } - - double[] values = new double[levs.size()]; - for (int i = 0; i < levs.size(); i++) { - values[i] = levs.get(i).doubleValue(); - } - Color[] colors = ct.getColors(levs.size() + 1); - - return createLegendScheme(min, max, values, colors, LegendType.GraduatedColor, ShapeTypes.Image, false, -9999.0); - } - - /** - * Create legend scheme - * - * @param min Minimum - * @param max Maximum - * @param n Level number - * @param ct Color table - * @return LegendScheme - */ - public static LegendScheme createLegendScheme(double min, double max, int n, ColorMap ct) { - double[] values = MIMath.getIntervalValues(min, max, n); - Color[] colors = ct.getColors(values.length + 1); - - return createLegendScheme(min, max, values, colors, LegendType.GraduatedColor, ShapeTypes.Image, false, -9999.0); - } - - /** - * Create legend scheme - * - * @param gdata Grid data - * @param interval Interval - * @param legendType Legend type - * @param shapeType Shape type - * @return LegendScheme - */ - public static LegendScheme createLegendScheme(GridData gdata, double interval, - LegendType legendType, ShapeTypes shapeType) { - double[] maxmin = new double[2]; - boolean hasUndef = gdata.getMaxMinValue(maxmin); - double min = maxmin[1]; - double max = maxmin[0]; - return createLegendScheme(min, max, interval, legendType, shapeType, hasUndef, gdata.missingValue); - } - - /** - * Create legend scheme - * - * @param gdata Grid data - * @param n Level number - * @param legendType Legend type - * @param shapeType Shape type - * @return LegendScheme - */ - public static LegendScheme createLegendScheme(GridData gdata, int n, - LegendType legendType, ShapeTypes shapeType) { - double[] maxmin = new double[2]; - boolean hasUndef = gdata.getMaxMinValue(maxmin); - double min = maxmin[1]; - double max = maxmin[0]; - return createLegendScheme(min, max, n, legendType, shapeType, hasUndef, gdata.missingValue); - } - - /** - * Create legend scheme - * - * @param gdata Grid data - * @param n Level number - * @param ct Color table - * @param legendType Legend type - * @param shapeType Shape type - * @return LegendScheme - */ - public static LegendScheme createLegendScheme(GridData gdata, int n, ColorMap ct, - LegendType legendType, ShapeTypes shapeType) { - double[] maxmin = new double[2]; - boolean hasUndef = gdata.getMaxMinValue(maxmin); - double min = maxmin[1]; - double max = maxmin[0]; - return createLegendScheme(min, max, n, ct, legendType, shapeType, hasUndef, gdata.missingValue); - } - - /** - * Create legend scheme - * - * @param gdata Grid data - * @param n Level number - * @param ct Color table name - * @return LegendScheme - * @throws IOException - */ - public static LegendScheme createLegendScheme(GridData gdata, int n, ColorMap ct) throws IOException { - if (ct != null) { - return createLegendScheme(gdata, n, ct, LegendType.GraduatedColor, ShapeTypes.Image); - } else { - return createLegendScheme(gdata, n, LegendType.GraduatedColor, ShapeTypes.Image); - } - } - - /** - * Create legend scheme - * - * @param stdata Station data - * @param n Level number - * @param ct Color table name - * @param legendType Legend type - * @param shapeType Shape type - * @return Legend scheme - * @throws IOException - */ - public static LegendScheme createLegendScheme(StationData stdata, int n, ColorMap ct, - LegendType legendType, ShapeTypes shapeType) throws IOException { - double[] maxmin = new double[2]; - boolean hasMissingValue = stdata.getMaxMinValue(maxmin); - double max = maxmin[0]; - double min = maxmin[1]; - if (ct != null) { - return createLegendScheme(min, max, n, ct, legendType, shapeType, hasMissingValue, stdata.missingValue); - } else { - return createLegendScheme(min, max, n, legendType, shapeType, hasMissingValue, stdata.missingValue); - } - } - - /** - * Create image legend from grid data - * - * @param gdata Grid data - * @param cmap Color map - * @return Legend scheme - */ - public static LegendScheme createImageLegend(GridData gdata, ColorMap cmap) { - boolean isUnique = gdata.testUniqueValues(); - LegendScheme ls; - if (isUnique) { - List values = gdata.getUniqueValues(); - ls = LegendManage.createUniqValueLegendScheme(values, cmap, ShapeTypes.Polygon); - } else if (gdata.hasMissing()) { - ls = LegendManage.createLegendScheme(gdata.getMinValue(), gdata.getMaxValue(), cmap, Double.NaN); - } else { - ls = LegendManage.createLegendScheme(gdata.getMinValue(), gdata.getMaxValue(), cmap); - } - - return ls; - } - - /** - * Create image legend from grid data - * - * @param gdata Grid data - * @param cmap Color map - * @return Legend scheme - */ - public static LegendScheme createImageLegend(GridArray gdata, ColorMap cmap) { - boolean isUnique = gdata.testUniqueValues(); - LegendScheme ls; - if (isUnique) { - List values = gdata.getUniqueValues(); - ls = LegendManage.createUniqValueLegendScheme(values, cmap, ShapeTypes.Polygon); - } else if (gdata.hasNaN()) { - ls = LegendManage.createLegendScheme(gdata.min(), gdata.max(), cmap, Double.NaN); - } else { - ls = LegendManage.createLegendScheme(gdata.min(), gdata.max(), cmap); - } - - return ls; - } - - /** - * Create image legend from grid data - * - * @param gdata Grid data - * @param n Legend break number - * @param cmap Color map - * @return Legend scheme - */ - public static LegendScheme createImageLegend(GridData gdata, int n, ColorMap cmap) { - LegendScheme ls; - if (gdata.hasMissing()) { - ls = LegendManage.createLegendScheme(gdata.getMinValue(), gdata.getMaxValue(), n, cmap, - LegendType.GraduatedColor, ShapeTypes.Image, true, Double.NaN); - } else { - ls = LegendManage.createLegendScheme(gdata.getMinValue(), gdata.getMaxValue(), n, cmap, - LegendType.GraduatedColor, ShapeTypes.Image, false, Double.NaN); - } - - return ls; - } - - /** - * Create image legend from grid data - * - * @param gdata Grid data - * @param n Legend break number - * @param cmap Color map - * @return Legend scheme - */ - public static LegendScheme createImageLegend(GridArray gdata, int n, ColorMap cmap) { - LegendScheme ls; - if (gdata.hasNaN()) { - ls = LegendManage.createLegendScheme(gdata.min(), gdata.max(), n, cmap, - LegendType.GraduatedColor, ShapeTypes.Image, true, Double.NaN); - } else { - ls = LegendManage.createLegendScheme(gdata.min(), gdata.max(), n, cmap, - LegendType.GraduatedColor, ShapeTypes.Image, false, Double.NaN); - } - - return ls; - } - - /** - * Create image legend from grid data - * - * @param gdata Grid data - * @param levs Legend break values - * @param cmap Color map - * @return Legend scheme - */ - public static LegendScheme createImageLegend(GridData gdata, List levs, ColorMap cmap) { - LegendScheme ls; - if (cmap.getColorCount() == levs.size()){ - ls = LegendManage.createUniqValueLegendScheme(levs, cmap, ShapeTypes.Image); - } else { - if (gdata.hasMissing()) { - ls = LegendManage.createLegendScheme(gdata.getMinValue(), gdata.getMaxValue(), levs, cmap, - LegendType.GraduatedColor, ShapeTypes.Image, true, Double.NaN); - } else { - ls = LegendManage.createLegendScheme(gdata.getMinValue(), gdata.getMaxValue(), levs, cmap, - LegendType.GraduatedColor, ShapeTypes.Image, false, Double.NaN); - } - } - - return ls; - } - - /** - * Create image legend from grid data - * - * @param gdata Grid data - * @param levs Legend break values - * @param cmap Color map - * @return Legend scheme - */ - public static LegendScheme createImageLegend(GridArray gdata, List levs, ColorMap cmap) { - LegendScheme ls; - if (cmap.getColorCount() == levs.size()){ - ls = LegendManage.createUniqValueLegendScheme(levs, cmap, ShapeTypes.Image); - } else { - if (gdata.hasNaN()) { - ls = LegendManage.createLegendScheme(gdata.min(), gdata.max(), levs, cmap, - LegendType.GraduatedColor, ShapeTypes.Image, true, Double.NaN); - } else { - ls = LegendManage.createLegendScheme(gdata.min(), gdata.max(), levs, cmap, - LegendType.GraduatedColor, ShapeTypes.Image, false, Double.NaN); - } - } - - return ls; - } - - /** - * Create random colors - * - * @param cNum Color number - * @return The random colors - */ - public static Color[] createRandomColors(int cNum) { - Color[] colors = new Color[cNum]; - int i; - Random randomColor = new Random(); - - for (i = 0; i < cNum; i++) { - colors[i] = new Color(randomColor.nextInt(256), - randomColor.nextInt(256), randomColor.nextInt(256)); - } - - return colors; - } - - /** - * Create rainbow colors - * - * @param cNum Color number - * @return Rainbow color array - */ - public static Color[] createRainBowColors(int cNum) { - if (cNum > 13) { - //return getRainBowColors_HSL(cNum); - return getRainBowColors_HSV(cNum); - } - - List colorList = new ArrayList<>(); - - colorList.add(new Color(160, 0, 200)); - colorList.add(new Color(110, 0, 220)); - colorList.add(new Color(30, 60, 255)); - colorList.add(new Color(0, 160, 255)); - colorList.add(new Color(0, 200, 200)); - colorList.add(new Color(0, 210, 140)); - colorList.add(new Color(0, 220, 0)); - colorList.add(new Color(160, 230, 50)); - colorList.add(new Color(230, 220, 50)); - colorList.add(new Color(230, 175, 45)); - colorList.add(new Color(240, 130, 40)); - colorList.add(new Color(250, 60, 60)); - colorList.add(new Color(240, 0, 130)); - - switch (cNum) { - case 12: - colorList.remove(new Color(0, 210, 140)); - break; - case 11: - colorList.remove(new Color(0, 210, 140)); - colorList.remove(new Color(30, 60, 255)); - break; - case 10: - colorList.remove(new Color(0, 210, 140)); - colorList.remove(new Color(30, 60, 255)); - colorList.remove(new Color(230, 175, 45)); - break; - case 9: - colorList.remove(new Color(0, 210, 140)); - colorList.remove(new Color(30, 60, 255)); - colorList.remove(new Color(230, 175, 45)); - colorList.remove(new Color(160, 230, 50)); - break; - case 8: - colorList.remove(new Color(0, 210, 140)); - colorList.remove(new Color(30, 60, 255)); - colorList.remove(new Color(230, 175, 45)); - colorList.remove(new Color(160, 230, 50)); - colorList.remove(new Color(110, 0, 220)); - break; - case 7: - colorList.remove(new Color(0, 210, 140)); - colorList.remove(new Color(30, 60, 255)); - colorList.remove(new Color(230, 175, 45)); - colorList.remove(new Color(160, 230, 50)); - colorList.remove(new Color(110, 0, 220)); - colorList.remove(new Color(0, 200, 200)); - break; - case 6: - colorList.remove(new Color(0, 210, 140)); - colorList.remove(new Color(30, 60, 255)); - colorList.remove(new Color(230, 175, 45)); - colorList.remove(new Color(160, 230, 50)); - colorList.remove(new Color(110, 0, 220)); - colorList.remove(new Color(0, 200, 200)); - colorList.remove(new Color(240, 130, 40)); - break; - case 5: - colorList.remove(new Color(0, 210, 140)); - colorList.remove(new Color(30, 60, 255)); - colorList.remove(new Color(230, 175, 45)); - colorList.remove(new Color(160, 230, 50)); - colorList.remove(new Color(110, 0, 220)); - colorList.remove(new Color(0, 200, 200)); - colorList.remove(new Color(240, 130, 40)); - colorList.remove(new Color(160, 0, 200)); - break; - } - - Color[] colors = new Color[cNum]; - for (int i = 0; i < cNum; i++) { - colors[i] = colorList.get(i); - } - - return colors; - } - -// public static Color[] getRainBowColors_HSL(int cNum) -// { -// double delta = 1.0 / cNum; -// Color[] colors = new Color[cNum]; -// int n = cNum - 1; -// for (double i = 0; i < 1; i += delta) -// { -// if (n == -1) { -// break; -// } -// -// ColorUtil.HSL hsl = new ColorUtils.HSL(i, 0.5, 0.5); -// colors[n] = ColorUtils.HSLToRGB(hsl); -// n -= 1; -// } -// -// return colors; -// } - /** - * Get rainbow color by HSV/HSB - * - * @param cNum Color number - * @return Rainbow colors - */ - public static Color[] getRainBowColors_HSV(int cNum) { - double p = 360.0 / cNum; - Color[] colors = new Color[cNum]; - for (int i = 0; i < cNum; i++) { - colors[cNum - i - 1] = Color.getHSBColor((float) (i * p), 1.0f, 1.0f); - } - - return colors; - } - - /** - * Create contour values by minimum and maximum values - * - * @param min Minimum value - * @param max Maximum value - * @return Contour values - */ - public static double[] createContourValues(double min, double max) { - double[] cValues; - int i, cNum, aD, aE; - double cDelt, range, newMin; - String eStr; - - range = BigDecimalUtil.sub(max, min); - if (range == 0.0) { - //cNum = 1; - cValues = new double[1]; - cValues[0] = min; - return cValues; - } - - NumberFormat formatter = new DecimalFormat("#.####E0"); - eStr = formatter.format(range); - //eStr = String.format("%1$E", range); - aD = Integer.parseInt(eStr.substring(0, 1)); - aE = (int) Math.floor(Math.log10(range)); -// int idx = eStr.indexOf("E"); -// if (idx < 0) { -// aE = 0; -// } else { -// aE = Integer.parseInt(eStr.substring(eStr.indexOf("E") + 1)); -// } - if (aD > 5) { - cDelt = Math.pow(10, aE); - cNum = aD; - //newMin = Convert.ToInt32((min + cDelt) / Math.Pow(10, aE)) * Math.Pow(10, aE); - newMin = BigDecimalUtil.mul((int) (min / cDelt + 1), cDelt); - } else if (aD == 5) { - cDelt = BigDecimalUtil.mul(aD, Math.pow(10, aE - 1)); - //cDelt = aD * Math.pow(10, aE - 1); - cNum = 10; - //newMin = Convert.ToInt32((min + cDelt) / Math.Pow(10, aE)) * Math.Pow(10, aE); - newMin = BigDecimalUtil.mul((int) (min / cDelt + 1), cDelt); - cNum++; - } else { - //cDelt = aD * Math.pow(10, aE - 1); - cDelt = BigDecimalUtil.pow(10, aE - 1); - cDelt = BigDecimalUtil.mul(aD, cDelt); - cNum = 10; - //newMin = Convert.ToInt32((min + cDelt) / Math.Pow(10, aE - 1)) * Math.Pow(10, aE - 1); - int newDelta = (int) (min / cDelt + 1); - newMin = BigDecimalUtil.mul(newDelta, cDelt); - } - - if (newMin + (cNum - 1) * cDelt > max) { - cNum -= 1; - } - cValues = new double[cNum]; - for (i = 0; i < cNum; i++) { - //cValues[i] = newMin + i * cDelt; - cValues[i] = BigDecimalUtil.add(newMin, BigDecimalUtil.mul(i, cDelt)); - } - - return cValues; - } - - /** - * Get contour values and colors from legend scheme - * - * @param aLS The legend scheme - * @return Contour and color values - */ - public static Object[] getContoursAndColors(LegendScheme aLS) { - int i; - double[] cValues; - Color[] colors; - if (aLS.getHasNoData()) { - cValues = new double[aLS.getBreakNum() - 2]; - colors = new Color[aLS.getBreakNum() - 1]; - } else { - cValues = new double[aLS.getBreakNum() - 1]; - colors = new Color[aLS.getBreakNum()]; - } - ShapeTypes st = aLS.getShapeType(); - if (st.isPoint()) { - for (i = 0; i < aLS.getBreakNum(); i++) { - PointBreak aPB = (PointBreak) aLS.getLegendBreaks().get(i); - if (!aPB.isNoData()) { - colors[i] = aPB.getColor(); - if (i > 0) { - cValues[i - 1] = Double.parseDouble(aPB.getStartValue().toString()); - } - } - } - } else if (st.isLine()) { - if (aLS.getLegendType() == LegendType.UniqueValue) { - cValues = new double[aLS.getBreakNum()]; - colors = new Color[aLS.getBreakNum() + 1]; - colors[0] = Color.white; - for (i = 0; i < aLS.getBreakNum(); i++) { - PolylineBreak aPLB = (PolylineBreak) aLS.getLegendBreaks().get(i); - colors[i + 1] = aPLB.getColor(); - cValues[i] = Double.parseDouble(aPLB.getStartValue().toString()); - } - } else { - for (i = 0; i < aLS.getBreakNum(); i++) { - PolylineBreak aPLB = (PolylineBreak) aLS.getLegendBreaks().get(i); - colors[i] = aPLB.getColor(); - if (i > 0) { - cValues[i - 1] = Double.parseDouble(aPLB.getStartValue().toString()); - } - } - } - } else if (st.isPolygon()) { - for (i = 0; i < aLS.getBreakNum(); i++) { - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(i); - colors[i] = aPGB.getColor(); - if (i > 0) { - cValues[i - 1] = Double.parseDouble(aPGB.getStartValue().toString()); - } - } - } - - return new Object[]{cValues, colors}; - } - - /** - * Set contour values and colors from a legend scheme - * - * @param aLS Legend scheme - * @param cValues Value array - * @param colors Color array - */ - public static void setContoursAndColors(LegendScheme aLS, double[] cValues, Color[] colors) { - int i; - if (aLS.getHasNoData()) { - cValues = new double[aLS.getBreakNum() - 2]; - colors = new Color[aLS.getBreakNum() - 1]; - } else { - cValues = new double[aLS.getBreakNum() - 1]; - colors = new Color[aLS.getBreakNum()]; - } - ShapeTypes st = aLS.getShapeType(); - if (st.isPoint()) { - for (i = 0; i < aLS.getBreakNum(); i++) { - PointBreak aPB = (PointBreak) aLS.getLegendBreaks().get(i); - if (!aPB.isNoData()) { - colors[i] = aPB.getColor(); - if (i > 0) { - cValues[i - 1] = Double.parseDouble(aPB.getStartValue().toString()); - } - } - } - } else if (st.isLine()) { - if (aLS.getLegendType() == LegendType.UniqueValue) { - cValues = new double[aLS.getBreakNum()]; - colors = new Color[aLS.getBreakNum() + 1]; - colors[0] = Color.white; - for (i = 0; i < aLS.getBreakNum(); i++) { - PolylineBreak aPLB = (PolylineBreak) aLS.getLegendBreaks().get(i); - colors[i + 1] = aPLB.getColor(); - cValues[i] = Double.parseDouble(aPLB.getStartValue().toString()); - } - } else { - for (i = 0; i < aLS.getBreakNum(); i++) { - PolylineBreak aPLB = (PolylineBreak) aLS.getLegendBreaks().get(i); - colors[i] = aPLB.getColor(); - if (i > 0) { - cValues[i - 1] = Double.parseDouble(aPLB.getStartValue().toString()); - } - } - } - } else if (st.isPolygon()) { - for (i = 0; i < aLS.getBreakNum(); i++) { - PolygonBreak aPGB = (PolygonBreak) aLS.getLegendBreaks().get(i); - colors[i] = aPGB.getColor(); - if (i > 0) { - cValues[i - 1] = Double.parseDouble(aPGB.getStartValue().toString()); - } - } - } - } -} diff --git a/MeteoInfoLab/MeteoInfoLab.iml b/meteoinfo-lab/meteoinfo-lab.iml similarity index 93% rename from MeteoInfoLab/MeteoInfoLab.iml rename to meteoinfo-lab/meteoinfo-lab.iml index 851d4fe8..0cb9e917 100644 --- a/MeteoInfoLab/MeteoInfoLab.iml +++ b/meteoinfo-lab/meteoinfo-lab.iml @@ -1,13 +1,13 @@ - - - - - - - + + + + + + + @@ -21,8 +21,11 @@ - + + + + @@ -31,6 +34,7 @@ + @@ -39,40 +43,41 @@ - - - + - - - - - + + + + - - - - - - - - - + + + + + + + + + - - - - - - - + + - + + + + + + + + + + @@ -99,17 +104,13 @@ - - - - - - - + + + \ No newline at end of file diff --git a/MeteoInfoLab/milconfig.xml b/meteoinfo-lab/milconfig.xml similarity index 90% rename from MeteoInfoLab/milconfig.xml rename to meteoinfo-lab/milconfig.xml index b9486fd0..c0411bbd 100644 --- a/MeteoInfoLab/milconfig.xml +++ b/meteoinfo-lab/milconfig.xml @@ -22,13 +22,11 @@ - - @@ -36,5 +34,5 @@
- + diff --git a/MeteoInfoLab/nbactions.xml b/meteoinfo-lab/nbactions.xml similarity index 84% rename from MeteoInfoLab/nbactions.xml rename to meteoinfo-lab/nbactions.xml index 65f13b2d..22b42476 100644 --- a/MeteoInfoLab/nbactions.xml +++ b/meteoinfo-lab/nbactions.xml @@ -1,46 +1,47 @@ - - - - debug - - jar - - - process-classes - org.codehaus.mojo:exec-maven-plugin:1.5.0:exec - - - -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} -XX:MaxDirectMemorySize=2G -classpath %classpath org.meteoinfo.laboratory.MeteoInfoLab - java - true - - - - run - - jar - - - process-classes - org.codehaus.mojo:exec-maven-plugin:1.5.0:exec - - - -XX:MaxDirectMemorySize=2G -classpath %classpath org.meteoinfo.laboratory.MeteoInfoLab - java - - - - profile - - jar - - - process-classes - org.codehaus.mojo:exec-maven-plugin:1.5.0:exec - - - -XX:MaxDirectMemorySize=2G -classpath %classpath org.meteoinfo.laboratory.MeteoInfoLab - java - - - + + + + debug + + jar + + + process-classes + org.codehaus.mojo:exec-maven-plugin:1.5.0:exec + + + -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} + -XX:MaxDirectMemorySize=2G -classpath %classpath org.meteoinfo.lab.MeteoInfoLab + java + true + + + + run + + jar + + + process-classes + org.codehaus.mojo:exec-maven-plugin:1.5.0:exec + + + -XX:MaxDirectMemorySize=2G -classpath %classpath org.meteoinfo.lab.MeteoInfoLab + java + + + + profile + + jar + + + process-classes + org.codehaus.mojo:exec-maven-plugin:1.5.0:exec + + + -XX:MaxDirectMemorySize=2G -classpath %classpath org.meteoinfo.lab.MeteoInfoLab + java + + + diff --git a/MeteoInfoLab/pom.xml b/meteoinfo-lab/pom.xml similarity index 91% rename from MeteoInfoLab/pom.xml rename to meteoinfo-lab/pom.xml index c93eee20..f6d55ba2 100644 --- a/MeteoInfoLab/pom.xml +++ b/meteoinfo-lab/pom.xml @@ -6,12 +6,12 @@ MeteoInfo 3.0.0 - MeteoInfoLab + meteoinfo-lab jar ${project.groupId} - MeteoInfoLib + meteoinfo-chart ${project.version} @@ -29,6 +29,11 @@ docking-frames-core 2.0.0 + + org.slf4j + slf4j-simple + 1.7.19 + ${project.groupId} - MeteoInfoLib + meteoinfo-chart ${project.version} @@ -39,7 +39,7 @@ - org.meteoinfo.desktop.MeteoInfoMap + org.meteoinfo.map.MeteoInfoMap true lib/ diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/MeteoInfoMap.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/MeteoInfoMap.java similarity index 97% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/MeteoInfoMap.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/MeteoInfoMap.java index f342ca55..79e420aa 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/MeteoInfoMap.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/MeteoInfoMap.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop; +package org.meteoinfo.map; import com.formdev.flatlaf.FlatDarculaLaf; import com.formdev.flatlaf.FlatDarkLaf; @@ -21,11 +21,11 @@ import javax.swing.*; import javax.xml.parsers.ParserConfigurationException; import org.meteoinfo.common.DataConvert; -import org.meteoinfo.common.util.FontUtil; +import org.meteoinfo.ui.util.FontUtil; import org.meteoinfo.common.util.GlobalUtil; -import org.meteoinfo.desktop.config.Options; -import org.meteoinfo.desktop.forms.FrmMain; -import org.meteoinfo.desktop.forms.FrmTextEditor; +import org.meteoinfo.map.config.Options; +import org.meteoinfo.map.forms.FrmMain; +import org.meteoinfo.map.forms.FrmTextEditor; import org.python.core.PyString; import org.python.core.PySystemState; import org.python.util.InteractiveConsole; @@ -203,7 +203,7 @@ public class MeteoInfoMap { if (isDebug) { startupPath = System.getProperty("user.dir"); if (startupPath.endsWith("MeteoInfo")) { - startupPath += "/MeteoInfoMap"; + startupPath += "/meteoinfo-map"; } } else { startupPath = GlobalUtil.getAppPath(FrmMain.class); @@ -363,7 +363,7 @@ public class MeteoInfoMap { } //registerFonts(); - org.meteoinfo.common.util.FontUtil.registerWeatherFont(); + FontUtil.registerWeatherFont(); FrmMain frame = new FrmMain(startupPath, options); frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); //frame.setLocationRelativeTo(null); diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/StackWindow.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/StackWindow.java similarity index 95% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/StackWindow.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/StackWindow.java index b424c144..1617139c 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/StackWindow.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/StackWindow.java @@ -1,70 +1,70 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.desktop; - -import org.meteoinfo.console.editor.JTextAreaPrintStream; - -import java.awt.EventQueue; -import javax.swing.JFrame; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; - -/** - * - * @author wyq - */ -public class StackWindow extends JFrame implements Thread.UncaughtExceptionHandler { - - private final JTextArea textArea; - JTextAreaPrintStream printStream; - - public StackWindow( - String title, final int width, final int height) { - super(title); - setSize(width, height); - - textArea = new JTextArea(); - JScrollPane pane = new JScrollPane(textArea); - textArea.setEditable(false); - getContentPane().add(pane); - printStream = new JTextAreaPrintStream(System.out, textArea); - - addWindowListener(new java.awt.event.WindowAdapter() { - @Override - public void windowClosing(java.awt.event.WindowEvent evt) { - formWindowClosed(evt); - } - }); - } - - @Override - public void uncaughtException(Thread t, Throwable e) { - addStackInfo(e); - } - - public void addStackInfo(final Throwable t) { - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - // Bring window to foreground - setVisible(true); - toFront(); - // Convert stack dump to string - //StringWriter sw = new StringWriter(); - //PrintWriter out = new PrintWriter(sw); - //t.printStackTrace(out); - // Add string to end of text area - //textArea.append(sw.toString()); - t.printStackTrace(printStream); - textArea.setCaretPosition(0); - } - }); - } - - private void formWindowClosed(java.awt.event.WindowEvent evt){ - textArea.setText(""); - } -} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.meteoinfo.map; + +import org.meteoinfo.console.editor.JTextAreaPrintStream; + +import java.awt.EventQueue; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; + +/** + * + * @author wyq + */ +public class StackWindow extends JFrame implements Thread.UncaughtExceptionHandler { + + private final JTextArea textArea; + JTextAreaPrintStream printStream; + + public StackWindow( + String title, final int width, final int height) { + super(title); + setSize(width, height); + + textArea = new JTextArea(); + JScrollPane pane = new JScrollPane(textArea); + textArea.setEditable(false); + getContentPane().add(pane); + printStream = new JTextAreaPrintStream(System.out, textArea); + + addWindowListener(new java.awt.event.WindowAdapter() { + @Override + public void windowClosing(java.awt.event.WindowEvent evt) { + formWindowClosed(evt); + } + }); + } + + @Override + public void uncaughtException(Thread t, Throwable e) { + addStackInfo(e); + } + + public void addStackInfo(final Throwable t) { + EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + // Bring window to foreground + setVisible(true); + toFront(); + // Convert stack dump to string + //StringWriter sw = new StringWriter(); + //PrintWriter out = new PrintWriter(sw); + //t.printStackTrace(out); + // Add string to end of text area + //textArea.append(sw.toString()); + t.printStackTrace(printStream); + textArea.setCaretPosition(0); + } + }); + } + + private void formWindowClosed(java.awt.event.WindowEvent evt){ + textArea.setText(""); + } +} diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/config/EncodingUtil.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/config/EncodingUtil.java similarity index 94% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/config/EncodingUtil.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/config/EncodingUtil.java index be643ae4..a832942e 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/config/EncodingUtil.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/config/EncodingUtil.java @@ -1,53 +1,53 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.desktop.config; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.StringReader; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * - * @author yaqiang - */ -public class EncodingUtil { - - private static final Pattern pep263EncodingPattern = Pattern.compile("#.*coding[:=]\\s*([-\\w.]+)"); - - public static String matchEncoding(String inputStr) { - Matcher matcher = pep263EncodingPattern.matcher(inputStr); - boolean matchFound = matcher.find(); - - if ((matchFound) && (matcher.groupCount() == 1)) { - String groupStr = matcher.group(1); - return groupStr; - } - return null; - } - - public static String findEncoding(BufferedReader br) - throws IOException { - String encoding = null; - for (int i = 0; i < 2; i++) { - String strLine = br.readLine(); - if (strLine == null) { - break; - } - String result = matchEncoding(strLine); - if (result != null) { - encoding = result; - break; - } - } - return encoding; - } - - public static String findEncoding(String text) throws IOException{ - return findEncoding(new BufferedReader(new StringReader(text))); - } -} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.meteoinfo.map.config; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.StringReader; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * @author yaqiang + */ +public class EncodingUtil { + + private static final Pattern pep263EncodingPattern = Pattern.compile("#.*coding[:=]\\s*([-\\w.]+)"); + + public static String matchEncoding(String inputStr) { + Matcher matcher = pep263EncodingPattern.matcher(inputStr); + boolean matchFound = matcher.find(); + + if ((matchFound) && (matcher.groupCount() == 1)) { + String groupStr = matcher.group(1); + return groupStr; + } + return null; + } + + public static String findEncoding(BufferedReader br) + throws IOException { + String encoding = null; + for (int i = 0; i < 2; i++) { + String strLine = br.readLine(); + if (strLine == null) { + break; + } + String result = matchEncoding(strLine); + if (result != null) { + encoding = result; + break; + } + } + return encoding; + } + + public static String findEncoding(String text) throws IOException{ + return findEncoding(new BufferedReader(new StringReader(text))); + } +} diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/config/GenericFileFilter.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/config/GenericFileFilter.java similarity index 95% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/config/GenericFileFilter.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/config/GenericFileFilter.java index 118d7255..197510c2 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/config/GenericFileFilter.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/config/GenericFileFilter.java @@ -1,117 +1,117 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.desktop.config; - -import java.io.File; -import javax.swing.filechooser.FileFilter; - -/** - * - * @author yaqiang - */ -public class GenericFileFilter extends FileFilter { - - private static final boolean ONE = true; - private String fileExt; - private String[] fileExts; - private boolean type = false; - private String description; - private int length; - private String extension; - - /** - * This is the constructor - it takes in the following:-
filesExtsIn - - * this is the array of file extensions that you wish to create a file - * filter for.
description - this is the description that will be - * displayed in the file chooser dialog box. - * @param filesExtsIn File extensions - * @param description Description - */ - public GenericFileFilter(String[] filesExtsIn, String description) { - if (filesExtsIn.length == 1) {//we only have one file - type = ONE; - fileExt = filesExtsIn[0]; - } else { - fileExts = filesExtsIn; - length = fileExts.length; - } - this.description = description; - } - - /** - * Get file extent - * - * @return File extent - */ - public String getFileExtent(){ - return fileExt; - } - - /** - * This is the method to allow a file to bee added to the displayed list or - * not. This method is called by the model that handles the FileChooser - * dialog - * @param f File - * @return Boolean - */ - @Override - public boolean accept(File f) { - if (f.isDirectory()) { - return true; - } - extension = getExtension(f); - if (extension != null) { - if (type) { - return check(fileExt); - } else { - for (int i = 0; i < length; i++) { - if (check(fileExts[i])) { - return true; - } - } - } - } - return false; - } - - /** - * This checks to see if the extension (stored) is the same as the file type - * stored at construction time. The "in" being the value passed over. - */ - private boolean check(String in) { - return extension.equalsIgnoreCase(in); - } - - /** - * This is the method defined by the model - * @return - */ - @Override - public String getDescription() { - return description; - } - - /** - * This is the method to get the file extension from the file name - */ - private String getExtension(File file) { - String filename = file.getName(); - int len = filename.length(); - int i = filename.lastIndexOf('.'); - if (i > 0 && i < len - 1) { - return filename.substring(i + 1).toLowerCase(); - } - return null; - } -} +/* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.map.config; + +import java.io.File; +import javax.swing.filechooser.FileFilter; + +/** + * + * @author yaqiang + */ +public class GenericFileFilter extends FileFilter { + + private static final boolean ONE = true; + private String fileExt; + private String[] fileExts; + private boolean type = false; + private String description; + private int length; + private String extension; + + /** + * This is the constructor - it takes in the following:-
filesExtsIn - + * this is the array of file extensions that you wish to create a file + * filter for.
description - this is the description that will be + * displayed in the file chooser dialog box. + * @param filesExtsIn File extensions + * @param description Description + */ + public GenericFileFilter(String[] filesExtsIn, String description) { + if (filesExtsIn.length == 1) {//we only have one file + type = ONE; + fileExt = filesExtsIn[0]; + } else { + fileExts = filesExtsIn; + length = fileExts.length; + } + this.description = description; + } + + /** + * Get file extent + * + * @return File extent + */ + public String getFileExtent(){ + return fileExt; + } + + /** + * This is the method to allow a file to bee added to the displayed list or + * not. This method is called by the model that handles the FileChooser + * dialog + * @param f File + * @return Boolean + */ + @Override + public boolean accept(File f) { + if (f.isDirectory()) { + return true; + } + extension = getExtension(f); + if (extension != null) { + if (type) { + return check(fileExt); + } else { + for (int i = 0; i < length; i++) { + if (check(fileExts[i])) { + return true; + } + } + } + } + return false; + } + + /** + * This checks to see if the extension (stored) is the same as the file type + * stored at construction time. The "in" being the value passed over. + */ + private boolean check(String in) { + return extension.equalsIgnoreCase(in); + } + + /** + * This is the method defined by the model + * @return + */ + @Override + public String getDescription() { + return description; + } + + /** + * This is the method to get the file extension from the file name + */ + private String getExtension(File file) { + String filename = file.getName(); + int len = filename.length(); + int i = filename.lastIndexOf('.'); + if (i > 0 && i < len - 1) { + return filename.substring(i + 1).toLowerCase(); + } + return null; + } +} diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/config/MapFileFilter.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/config/MapFileFilter.java similarity index 94% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/config/MapFileFilter.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/config/MapFileFilter.java index f06e5e90..684af44a 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/config/MapFileFilter.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/config/MapFileFilter.java @@ -1,58 +1,58 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.desktop.config; - -import java.io.File; -import javax.swing.filechooser.FileFilter; - -/** - * - * @author yaqiang - */ -public class MapFileFilter extends FileFilter { - - @Override - public boolean accept(File f) { - - if (f.isDirectory()) { - return true; - } - - //get the extension of the file - String extension = getExtension(f); - //check to see if the extension is equal to "html" or "htm" - if ((extension.equals("shp")) || (extension.equals("wmp"))) { - return true; - } - //default -- fall through. False is return on all - //occasions except: - //a) the file is a directory - //b) the file's extension is what we are looking for. - return false; - } - - @Override - public String getDescription() { - return "Shape File (*.shp)"; - } - - private String getExtension(File f) { - String s = f.getName(); - int i = s.lastIndexOf('.'); - if (i > 0 && i < s.length() - 1) { - return s.substring(i + 1).toLowerCase(); - } - return ""; - } -} +/* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.map.config; + +import java.io.File; +import javax.swing.filechooser.FileFilter; + +/** + * + * @author yaqiang + */ +public class MapFileFilter extends FileFilter { + + @Override + public boolean accept(File f) { + + if (f.isDirectory()) { + return true; + } + + //get the extension of the file + String extension = getExtension(f); + //check to see if the extension is equal to "html" or "htm" + if ((extension.equals("shp")) || (extension.equals("wmp"))) { + return true; + } + //default -- fall through. False is return on all + //occasions except: + //a) the file is a directory + //b) the file's extension is what we are looking for. + return false; + } + + @Override + public String getDescription() { + return "Shape File (*.shp)"; + } + + private String getExtension(File f) { + String s = f.getName(); + int i = s.lastIndexOf('.'); + if (i > 0 && i < s.length() - 1) { + return s.substring(i + 1).toLowerCase(); + } + return ""; + } +} diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/config/Options.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/config/Options.java similarity index 99% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/config/Options.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/config/Options.java index 745ac9e4..d1430fb6 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/config/Options.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/config/Options.java @@ -11,7 +11,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.desktop.config; +package org.meteoinfo.map.config; import java.awt.Dimension; import java.awt.Font; diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/config/Plugin.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/config/Plugin.java similarity index 92% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/config/Plugin.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/config/Plugin.java index 1103b942..145fac77 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/config/Plugin.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/config/Plugin.java @@ -1,129 +1,129 @@ - /* Copyright 2012 - Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.desktop.config; - -import org.meteoinfo.plugin.IPlugin; -import org.meteoinfo.plugin.PluginBase; - -/** - * - * @author Yaqiang Wang - */ -public class Plugin extends PluginBase{ - // - //private String _name; - private String _jarFileName; - private String _className; - private IPlugin _pluginObject = null; - private boolean _isLoad = false; - // - // - // - // - - /** - * Get jar file name - * @return Jar file name - */ - public String getJarFileName(){ - return this._jarFileName; - } - - /** - * Set jar file name - * @param value Jar file name - */ - public void setJarFileName(String value){ - this._jarFileName = value; - } - - /** - * Get jar path in 'plugins' folder - * @return Jar path - */ - public String getJarPath(){ - String path = this._jarFileName; - int idx = path.indexOf("plugins"); - if (idx >= 0){ - path = path.substring(idx + 8); - } - - return path; - } - - /** - * Get class name - * @return Class name - */ - public String getClassName(){ - return this._className; - } - - /** - * Set class name - * @param value Class name - */ - public void setClassName(String value){ - this._className = value; - } - - /** - * Get plugin object - * @return Plugin object - */ - public IPlugin getPluginObject(){ - return this._pluginObject; - } - - /** - * Set plugin object - * @param value Plugin object - */ - public void setPluginObject(IPlugin value){ - this._pluginObject = value; - if (value != null){ - this.setName(value.getName()); - this.setAuthor(value.getAuthor()); - this.setVersion(value.getVersion()); - this.setDescription(value.getDescription()); - } - } - - /** - * Get if load the plugin - * @return Boolean - */ - public boolean isLoad(){ - return this._isLoad; - } - - /** - * Set if load the plugin - * @param value Boolean - */ - public void setLoad(boolean value){ - this._isLoad = value; - } - // - // - /** - * Override toString method - * @return String - */ - @Override - public String toString(){ - return this.getName(); - } - // -} + /* Copyright 2012 - Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.map.config; + +import org.meteoinfo.geo.plugin.IPlugin; +import org.meteoinfo.geo.plugin.PluginBase; + +/** + * + * @author Yaqiang Wang + */ +public class Plugin extends PluginBase{ + // + //private String _name; + private String _jarFileName; + private String _className; + private IPlugin _pluginObject = null; + private boolean _isLoad = false; + // + // + // + // + + /** + * Get jar file name + * @return Jar file name + */ + public String getJarFileName(){ + return this._jarFileName; + } + + /** + * Set jar file name + * @param value Jar file name + */ + public void setJarFileName(String value){ + this._jarFileName = value; + } + + /** + * Get jar path in 'plugins' folder + * @return Jar path + */ + public String getJarPath(){ + String path = this._jarFileName; + int idx = path.indexOf("plugins"); + if (idx >= 0){ + path = path.substring(idx + 8); + } + + return path; + } + + /** + * Get class name + * @return Class name + */ + public String getClassName(){ + return this._className; + } + + /** + * Set class name + * @param value Class name + */ + public void setClassName(String value){ + this._className = value; + } + + /** + * Get plugin object + * @return Plugin object + */ + public IPlugin getPluginObject(){ + return this._pluginObject; + } + + /** + * Set plugin object + * @param value Plugin object + */ + public void setPluginObject(IPlugin value){ + this._pluginObject = value; + if (value != null){ + this.setName(value.getName()); + this.setAuthor(value.getAuthor()); + this.setVersion(value.getVersion()); + this.setDescription(value.getDescription()); + } + } + + /** + * Get if load the plugin + * @return Boolean + */ + public boolean isLoad(){ + return this._isLoad; + } + + /** + * Set if load the plugin + * @param value Boolean + */ + public void setLoad(boolean value){ + this._isLoad = value; + } + // + // + /** + * Override toString method + * @return String + */ + @Override + public String toString(){ + return this.getName(); + } + // +} diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/config/PluginCollection.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/config/PluginCollection.java similarity index 97% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/config/PluginCollection.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/config/PluginCollection.java index b466ead6..0b13a01a 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/config/PluginCollection.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/config/PluginCollection.java @@ -1,197 +1,197 @@ - /* Copyright 2012 - Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.desktop.config; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.util.ArrayList; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -/** - * - * @author Yaqiang Wang - */ -public class PluginCollection extends ArrayList { - // - private String _pluginPath; - private String _pluginConfigFile; - // - // - // - // - /** - * Get plugin path - * @return Plugin path - */ - public String getPluginPath(){ - return this._pluginPath; - } - - /** - * Set plugin path - * @param value Plugin path - */ - public void setPluginPath(String value){ - this._pluginPath = value; - } - - /** - * Get plugin configure file - * @return Plugin configure file - */ - public String getPluginConfigFile(){ - return this._pluginConfigFile; - } - - /** - * Set plugin configure file - * @param value Plugin configure file - */ - public void setPluginConfigFile(String value){ - this._pluginConfigFile = value; - } - // - // - /** - * Save plugin configure file - * @throws ParserConfigurationException - */ - public void saveConfigFile() throws ParserConfigurationException{ - this.saveConfigFile(this._pluginConfigFile); - } - - /** - * Save plugin configure file - * - * @param fileName File name - * @throws javax.xml.parsers.ParserConfigurationException - */ - public void saveConfigFile(String fileName) throws ParserConfigurationException { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - Document doc = builder.newDocument(); - - //Plugins - Element pluginsElem = doc.createElement("Plugins"); - for (Plugin plugin : this){ - Element pluginElem = doc.createElement("Plugin"); - Attr pluginNameAttr = doc.createAttribute("Name"); - Attr pluginAuthorAttr = doc.createAttribute("Author"); - Attr pluginVersionAttr = doc.createAttribute("Version"); - Attr pluginDescriptionAttr = doc.createAttribute("Description"); - Attr pluginJarPathAttr = doc.createAttribute("JarPath"); - Attr pluginClassNameAttr = doc.createAttribute("ClassName"); - Attr pluginIsLoadAttr = doc.createAttribute("IsLoad"); - - pluginNameAttr.setValue(plugin.getName()); - pluginAuthorAttr.setValue(plugin.getAuthor()); - pluginVersionAttr.setValue(plugin.getVersion()); - pluginDescriptionAttr.setValue(plugin.getDescription()); - pluginJarPathAttr.setValue(plugin.getJarPath()); - pluginClassNameAttr.setValue(plugin.getClassName()); - pluginIsLoadAttr.setValue(String.valueOf(plugin.isLoad())); - - pluginElem.setAttributeNode(pluginNameAttr); - pluginElem.setAttributeNode(pluginAuthorAttr); - pluginElem.setAttributeNode(pluginVersionAttr); - pluginElem.setAttributeNode(pluginDescriptionAttr); - pluginElem.setAttributeNode(pluginJarPathAttr); - pluginElem.setAttributeNode(pluginClassNameAttr); - pluginElem.setAttributeNode(pluginIsLoadAttr); - - pluginsElem.appendChild(pluginElem); - } - doc.appendChild(pluginsElem); - - try { - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer transformer = tf.newTransformer(); - DOMSource source = new DOMSource(doc); - transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); - PrintWriter pw = new PrintWriter(new FileOutputStream(fileName)); - StreamResult result = new StreamResult(pw); - transformer.transform(source, result); - } catch (TransformerException mye) { - } catch (IOException exp) { - } - } - - /** - * Load plugin configure file - * - * @param fileName File name - * @throws javax.xml.parsers.ParserConfigurationException - * @throws org.xml.sax.SAXException - * @throws java.io.IOException - */ - public void loadConfigFile(String fileName) throws ParserConfigurationException, SAXException, IOException { - if (!new File(fileName).exists()) - return; - - this._pluginConfigFile = fileName; - BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "UTF-8")); - InputSource is = new InputSource(br); - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); - Document doc = db.parse(is); - try { - //Plugins - this.clear(); - Element pluginsElem = doc.getDocumentElement(); - NodeList pluginNodeList = pluginsElem.getElementsByTagName("Plugin"); - for (int i = 0; i < pluginNodeList.getLength(); i++){ - Node pluginNode = pluginNodeList.item(i); - Plugin plugin = new Plugin(); - NamedNodeMap attrs = pluginNode.getAttributes(); - plugin.setName(attrs.getNamedItem("Name").getNodeValue()); - plugin.setAuthor(attrs.getNamedItem("Author").getNodeValue()); - plugin.setVersion(attrs.getNamedItem("Version").getNodeValue()); - plugin.setDescription(attrs.getNamedItem("Description").getNodeValue()); - String jarPath = attrs.getNamedItem("JarPath").getNodeValue(); - jarPath = this._pluginPath + File.separator + jarPath; - if (!new File(jarPath).exists()) - continue; - plugin.setJarFileName(jarPath); - plugin.setClassName(attrs.getNamedItem("ClassName").getNodeValue()); - plugin.setLoad(Boolean.parseBoolean(attrs.getNamedItem("IsLoad").getNodeValue())); - this.add(plugin); - } - } catch (Exception e) { - } - } - // -} + /* Copyright 2012 - Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.map.config; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.util.ArrayList; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import org.w3c.dom.Attr; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +/** + * + * @author Yaqiang Wang + */ +public class PluginCollection extends ArrayList { + // + private String _pluginPath; + private String _pluginConfigFile; + // + // + // + // + /** + * Get plugin path + * @return Plugin path + */ + public String getPluginPath(){ + return this._pluginPath; + } + + /** + * Set plugin path + * @param value Plugin path + */ + public void setPluginPath(String value){ + this._pluginPath = value; + } + + /** + * Get plugin configure file + * @return Plugin configure file + */ + public String getPluginConfigFile(){ + return this._pluginConfigFile; + } + + /** + * Set plugin configure file + * @param value Plugin configure file + */ + public void setPluginConfigFile(String value){ + this._pluginConfigFile = value; + } + // + // + /** + * Save plugin configure file + * @throws ParserConfigurationException + */ + public void saveConfigFile() throws ParserConfigurationException{ + this.saveConfigFile(this._pluginConfigFile); + } + + /** + * Save plugin configure file + * + * @param fileName File name + * @throws javax.xml.parsers.ParserConfigurationException + */ + public void saveConfigFile(String fileName) throws ParserConfigurationException { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + Document doc = builder.newDocument(); + + //Plugins + Element pluginsElem = doc.createElement("Plugins"); + for (Plugin plugin : this){ + Element pluginElem = doc.createElement("Plugin"); + Attr pluginNameAttr = doc.createAttribute("Name"); + Attr pluginAuthorAttr = doc.createAttribute("Author"); + Attr pluginVersionAttr = doc.createAttribute("Version"); + Attr pluginDescriptionAttr = doc.createAttribute("Description"); + Attr pluginJarPathAttr = doc.createAttribute("JarPath"); + Attr pluginClassNameAttr = doc.createAttribute("ClassName"); + Attr pluginIsLoadAttr = doc.createAttribute("IsLoad"); + + pluginNameAttr.setValue(plugin.getName()); + pluginAuthorAttr.setValue(plugin.getAuthor()); + pluginVersionAttr.setValue(plugin.getVersion()); + pluginDescriptionAttr.setValue(plugin.getDescription()); + pluginJarPathAttr.setValue(plugin.getJarPath()); + pluginClassNameAttr.setValue(plugin.getClassName()); + pluginIsLoadAttr.setValue(String.valueOf(plugin.isLoad())); + + pluginElem.setAttributeNode(pluginNameAttr); + pluginElem.setAttributeNode(pluginAuthorAttr); + pluginElem.setAttributeNode(pluginVersionAttr); + pluginElem.setAttributeNode(pluginDescriptionAttr); + pluginElem.setAttributeNode(pluginJarPathAttr); + pluginElem.setAttributeNode(pluginClassNameAttr); + pluginElem.setAttributeNode(pluginIsLoadAttr); + + pluginsElem.appendChild(pluginElem); + } + doc.appendChild(pluginsElem); + + try { + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer transformer = tf.newTransformer(); + DOMSource source = new DOMSource(doc); + transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); + PrintWriter pw = new PrintWriter(new FileOutputStream(fileName)); + StreamResult result = new StreamResult(pw); + transformer.transform(source, result); + } catch (TransformerException mye) { + } catch (IOException exp) { + } + } + + /** + * Load plugin configure file + * + * @param fileName File name + * @throws javax.xml.parsers.ParserConfigurationException + * @throws org.xml.sax.SAXException + * @throws java.io.IOException + */ + public void loadConfigFile(String fileName) throws ParserConfigurationException, SAXException, IOException { + if (!new File(fileName).exists()) + return; + + this._pluginConfigFile = fileName; + BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "UTF-8")); + InputSource is = new InputSource(br); + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + Document doc = db.parse(is); + try { + //Plugins + this.clear(); + Element pluginsElem = doc.getDocumentElement(); + NodeList pluginNodeList = pluginsElem.getElementsByTagName("Plugin"); + for (int i = 0; i < pluginNodeList.getLength(); i++){ + Node pluginNode = pluginNodeList.item(i); + Plugin plugin = new Plugin(); + NamedNodeMap attrs = pluginNode.getAttributes(); + plugin.setName(attrs.getNamedItem("Name").getNodeValue()); + plugin.setAuthor(attrs.getNamedItem("Author").getNodeValue()); + plugin.setVersion(attrs.getNamedItem("Version").getNodeValue()); + plugin.setDescription(attrs.getNamedItem("Description").getNodeValue()); + String jarPath = attrs.getNamedItem("JarPath").getNodeValue(); + jarPath = this._pluginPath + File.separator + jarPath; + if (!new File(jarPath).exists()) + continue; + plugin.setJarFileName(jarPath); + plugin.setClassName(attrs.getNamedItem("ClassName").getNodeValue()); + plugin.setLoad(Boolean.parseBoolean(attrs.getNamedItem("IsLoad").getNodeValue())); + this.add(plugin); + } + } catch (Exception e) { + } + } + // +} diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/config/ProjectFile.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/config/ProjectFile.java similarity index 95% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/config/ProjectFile.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/config/ProjectFile.java index 4cc60417..8b13d140 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/config/ProjectFile.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/config/ProjectFile.java @@ -1,190 +1,190 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.desktop.config; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Properties; -import javax.swing.JFrame; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import org.meteoinfo.desktop.forms.FrmMain; -import org.meteoinfo.map.MapView; -import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; - -/** - * - * @author Yaqiang Wang - */ -public class ProjectFile { - // - - private String _fileName; - private String _pathFileName; - private FrmMain _mainForm; - // - // - - /** - * Constructor - * - * @param mainForm Main form - */ - public ProjectFile(JFrame mainForm) { - _fileName = ""; - _pathFileName = ""; - _mainForm = (FrmMain)mainForm; - } - // - // - - /** - * Get project file name - * - * @return The porject file name - */ - public String getFileName() { - return _fileName; - } - - /** - * Set project file name - * - * @param fn File name - */ - public void setFileName(String fn) { - _fileName = fn; - } - - /** - * Get configure file name - * - * @return Configure file name - */ - public String getConfigureFileName() { - return _pathFileName; - } - // - // - // - - /** - * Save project file - * - * @param aFile File name - * @throws javax.xml.parsers.ParserConfigurationException - */ - public void saveProjFile(String aFile) throws ParserConfigurationException { - _fileName = aFile; - - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - Document doc = builder.newDocument(); - Element root = doc.createElement("MeteoInfo"); - File af = new File(aFile); - Attr fn = doc.createAttribute("File"); - Attr type = doc.createAttribute("Type"); - fn.setValue(af.getName()); - type.setValue("projectfile"); - root.setAttributeNode(fn); - root.setAttributeNode(type); - doc.appendChild(root); - - //Add language element - //addLanguageElement(doc, root, Thread.CurrentThread.CurrentUICulture.Name); - - //Add LayersLegend content - _mainForm.getMapDocument().getMapLayout().updateMapFrameOrder(); - _mainForm.getMapDocument().exportProjectXML(doc, root, _fileName); - - //Add MapLayout content - _mainForm.getMapDocument().getMapLayout().exportProjectXML(doc, root); - - //Save project file - try { - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer transformer = tf.newTransformer(); - DOMSource source = new DOMSource(doc); - - Properties properties = transformer.getOutputProperties(); - properties.setProperty(OutputKeys.ENCODING, "UTF-8"); - properties.setProperty(OutputKeys.INDENT, "yes"); - properties.setProperty("{http://xml.apache.org/xslt}indent-amount", "2"); - transformer.setOutputProperties(properties); -// transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); -// transformer.setOutputProperty(OutputKeys.INDENT, "yes"); -// transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); - //PrintWriter pw = new PrintWriter(new FileOutputStream(aFile)); - FileOutputStream out = new FileOutputStream(aFile); - StreamResult result = new StreamResult(out); - transformer.transform(source, result); - } catch (TransformerException mye) { - } catch (IOException exp) { - } - } - - // - // - /** - * Load project file - * - * @param aFile - * @throws javax.xml.parsers.ParserConfigurationException - * @throws org.xml.sax.SAXException - * @throws java.io.IOException - */ - public void loadProjFile(String aFile) throws ParserConfigurationException, SAXException, IOException { - _fileName = aFile; - - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); - Document doc = db.parse(new File(aFile)); - - Element root = doc.getDocumentElement(); - - Properties property = System.getProperties(); - String path = System.getProperty("user.dir"); - property.setProperty("user.dir", new File(aFile).getAbsolutePath()); - String pPath = new File(aFile).getParent(); - - //Load elements - //_mainForm.getMapDocument().getActiveMapFrame().getMapView().setLockViewUpdate(true); - MapView mapView = _mainForm.getMapDocument().getActiveMapFrame().getMapView(); - mapView.setLockViewUpdate(true); - //LoadLanguageElement(root); - //Load map frames content - _mainForm.getMapDocument().importProjectXML(pPath, root); - _mainForm.getMapDocument().getMapLayout().setMapFrames(_mainForm.getMapDocument().getMapFrames()); - //Load MapLayout content - _mainForm.getMapDocument().getMapLayout().importProjectXML(root); - //_mainForm.getMapDocument().getActiveMapFrame().getMapView().setLockViewUpdate(false); - //_mainForm.getMapDocument().getActiveMapFrame().getMapView().paintLayers(); - - property.setProperty("user.dir", path); - } - - // - // -} +/* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.map.config; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Properties; +import javax.swing.JFrame; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import org.meteoinfo.map.forms.FrmMain; +import org.meteoinfo.geo.mapview.MapView; +import org.w3c.dom.Attr; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.xml.sax.SAXException; + +/** + * + * @author Yaqiang Wang + */ +public class ProjectFile { + // + + private String _fileName; + private String _pathFileName; + private FrmMain _mainForm; + // + // + + /** + * Constructor + * + * @param mainForm Main form + */ + public ProjectFile(JFrame mainForm) { + _fileName = ""; + _pathFileName = ""; + _mainForm = (FrmMain)mainForm; + } + // + // + + /** + * Get project file name + * + * @return The porject file name + */ + public String getFileName() { + return _fileName; + } + + /** + * Set project file name + * + * @param fn File name + */ + public void setFileName(String fn) { + _fileName = fn; + } + + /** + * Get configure file name + * + * @return Configure file name + */ + public String getConfigureFileName() { + return _pathFileName; + } + // + // + // + + /** + * Save project file + * + * @param aFile File name + * @throws javax.xml.parsers.ParserConfigurationException + */ + public void saveProjFile(String aFile) throws ParserConfigurationException { + _fileName = aFile; + + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + Document doc = builder.newDocument(); + Element root = doc.createElement("MeteoInfo"); + File af = new File(aFile); + Attr fn = doc.createAttribute("File"); + Attr type = doc.createAttribute("Type"); + fn.setValue(af.getName()); + type.setValue("projectfile"); + root.setAttributeNode(fn); + root.setAttributeNode(type); + doc.appendChild(root); + + //Add language element + //addLanguageElement(doc, root, Thread.CurrentThread.CurrentUICulture.Name); + + //Add LayersLegend content + _mainForm.getMapDocument().getMapLayout().updateMapFrameOrder(); + _mainForm.getMapDocument().exportProjectXML(doc, root, _fileName); + + //Add MapLayout content + _mainForm.getMapDocument().getMapLayout().exportProjectXML(doc, root); + + //Save project file + try { + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer transformer = tf.newTransformer(); + DOMSource source = new DOMSource(doc); + + Properties properties = transformer.getOutputProperties(); + properties.setProperty(OutputKeys.ENCODING, "UTF-8"); + properties.setProperty(OutputKeys.INDENT, "yes"); + properties.setProperty("{http://xml.apache.org/xslt}indent-amount", "2"); + transformer.setOutputProperties(properties); +// transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); +// transformer.setOutputProperty(OutputKeys.INDENT, "yes"); +// transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); + //PrintWriter pw = new PrintWriter(new FileOutputStream(aFile)); + FileOutputStream out = new FileOutputStream(aFile); + StreamResult result = new StreamResult(out); + transformer.transform(source, result); + } catch (TransformerException mye) { + } catch (IOException exp) { + } + } + + // + // + /** + * Load project file + * + * @param aFile + * @throws javax.xml.parsers.ParserConfigurationException + * @throws org.xml.sax.SAXException + * @throws java.io.IOException + */ + public void loadProjFile(String aFile) throws ParserConfigurationException, SAXException, IOException { + _fileName = aFile; + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + Document doc = db.parse(new File(aFile)); + + Element root = doc.getDocumentElement(); + + Properties property = System.getProperties(); + String path = System.getProperty("user.dir"); + property.setProperty("user.dir", new File(aFile).getAbsolutePath()); + String pPath = new File(aFile).getParent(); + + //Load elements + //_mainForm.getMapDocument().getActiveMapFrame().getMapView().setLockViewUpdate(true); + MapView mapView = _mainForm.getMapDocument().getActiveMapFrame().getMapView(); + mapView.setLockViewUpdate(true); + //LoadLanguageElement(root); + //Load map frames content + _mainForm.getMapDocument().importProjectXML(pPath, root); + _mainForm.getMapDocument().getMapLayout().setMapFrames(_mainForm.getMapDocument().getMapFrames()); + //Load MapLayout content + _mainForm.getMapDocument().getMapLayout().importProjectXML(root); + //_mainForm.getMapDocument().getActiveMapFrame().getMapView().setLockViewUpdate(false); + //_mainForm.getMapDocument().getActiveMapFrame().getMapView().paintLayers(); + + property.setProperty("user.dir", path); + } + + // + // +} diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/event/CurrentToolChangedEvent.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/event/CurrentToolChangedEvent.java similarity index 92% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/event/CurrentToolChangedEvent.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/event/CurrentToolChangedEvent.java index 833fa670..a71b52bd 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/event/CurrentToolChangedEvent.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/event/CurrentToolChangedEvent.java @@ -1,30 +1,30 @@ -/* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.desktop.event; - -import java.util.EventObject; - -/** - * - * @author Yaqiang Wang - */ -public class CurrentToolChangedEvent extends EventObject { - /** - * Constructor - * @param source Source object - */ - public CurrentToolChangedEvent(Object source){ - super(source); - } -} +/* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.map.event; + +import java.util.EventObject; + +/** + * + * @author Yaqiang Wang + */ +public class CurrentToolChangedEvent extends EventObject { + /** + * Constructor + * @param source Source object + */ + public CurrentToolChangedEvent(Object source){ + super(source); + } +} diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/event/ICurrentToolChangedListener.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/event/ICurrentToolChangedListener.java similarity index 92% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/event/ICurrentToolChangedListener.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/event/ICurrentToolChangedListener.java index 592925e8..dbc8dcda 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/event/ICurrentToolChangedListener.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/event/ICurrentToolChangedListener.java @@ -1,24 +1,24 @@ - /* Copyright 2012 Yaqiang Wang, - * yaqiang.wang@gmail.com - * - * 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 - * the Free Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * General Public License for more details. - */ -package org.meteoinfo.desktop.event; - -import java.util.EventListener; - -/** - * - * @author yaqiang - */ -public interface ICurrentToolChangedListener extends EventListener { - public void currentToolChangedEvent(CurrentToolChangedEvent event); -} + /* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.map.event; + +import java.util.EventListener; + +/** + * + * @author yaqiang + */ +public interface ICurrentToolChangedListener extends EventListener { + public void currentToolChangedEvent(CurrentToolChangedEvent event); +} diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmAbout.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmAbout.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmAbout.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmAbout.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmAbout.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmAbout.java similarity index 99% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmAbout.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmAbout.java index 01cdfbc1..5a265c60 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmAbout.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmAbout.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import org.meteoinfo.common.util.GlobalUtil; diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmAddField.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmAddField.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmAddField.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmAddField.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmAddField.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmAddField.java similarity index 99% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmAddField.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmAddField.java index 9ae34f57..929ed30c 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmAddField.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmAddField.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import org.meteoinfo.ndarray.DataType; diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmAddXYData.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmAddXYData.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmAddXYData.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmAddXYData.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmAddXYData.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmAddXYData.java similarity index 99% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmAddXYData.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmAddXYData.java index b29fa9d2..7d3a0527 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmAddXYData.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmAddXYData.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import java.awt.Color; import java.io.BufferedReader; @@ -23,9 +23,9 @@ import org.meteoinfo.common.MIMath; import org.meteoinfo.common.PointD; import org.meteoinfo.common.util.GlobalUtil; import org.meteoinfo.ndarray.DataType; -import org.meteoinfo.layer.LayerDrawType; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.legend.LegendManage; +import org.meteoinfo.geo.layer.LayerDrawType; +import org.meteoinfo.geo.layer.VectorLayer; +import org.meteoinfo.geo.legend.LegendManage; import org.meteoinfo.geometry.shape.PointShape; import org.meteoinfo.geometry.shape.ShapeTypes; import org.meteoinfo.table.Field; diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmArrivalTimes.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmArrivalTimes.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmArrivalTimes.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmArrivalTimes.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmArrivalTimes.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmArrivalTimes.java similarity index 98% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmArrivalTimes.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmArrivalTimes.java index b1a6c29c..97561a02 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmArrivalTimes.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmArrivalTimes.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; /** * diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmBuffer.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmBuffer.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmBuffer.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmBuffer.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmBuffer.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmBuffer.java similarity index 97% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmBuffer.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmBuffer.java index f0d4c105..e2801438 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmBuffer.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmBuffer.java @@ -2,16 +2,16 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import java.awt.Cursor; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.map.MapView; +import org.meteoinfo.geo.layer.LayerTypes; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.layer.VectorLayer; +import org.meteoinfo.geo.mapview.MapView; /** * diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmClipping.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmClipping.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmClipping.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmClipping.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmClipping.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmClipping.java similarity index 98% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmClipping.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmClipping.java index e9274c6c..121f702d 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmClipping.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmClipping.java @@ -2,17 +2,17 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import java.awt.Cursor; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; import javax.swing.JOptionPane; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.map.MapView; +import org.meteoinfo.geo.layer.LayerTypes; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.layer.VectorLayer; +import org.meteoinfo.geo.mapview.MapView; /** * diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmConsole.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmConsole.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmConsole.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmConsole.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmConsole.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmConsole.java similarity index 99% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmConsole.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmConsole.java index 9e95f7f1..7eee4639 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmConsole.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmConsole.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import java.awt.BorderLayout; import java.awt.Cursor; diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmConvexhull.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmConvexhull.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmConvexhull.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmConvexhull.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmConvexhull.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmConvexhull.java similarity index 97% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmConvexhull.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmConvexhull.java index 99f32b49..add9f929 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmConvexhull.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmConvexhull.java @@ -2,16 +2,16 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import java.awt.Cursor; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.map.MapView; +import org.meteoinfo.geo.layer.LayerTypes; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.layer.VectorLayer; +import org.meteoinfo.geo.mapview.MapView; /** * diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmDataInfo.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmDataInfo.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmDataInfo.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmDataInfo.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmDataInfo.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmDataInfo.java similarity index 98% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmDataInfo.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmDataInfo.java index be83ab73..a40cf5a7 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmDataInfo.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmDataInfo.java @@ -11,9 +11,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; -import java.awt.*; import java.awt.image.BufferedImage; import java.io.BufferedWriter; import java.io.File; @@ -26,7 +25,7 @@ import javax.swing.JFileChooser; import javax.swing.JFrame; import com.formdev.flatlaf.extras.FlatSVGIcon; -import org.meteoinfo.desktop.config.GenericFileFilter; +import org.meteoinfo.map.config.GenericFileFilter; /** * diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmDifference.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmDifference.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmDifference.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmDifference.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmDifference.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmDifference.java similarity index 98% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmDifference.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmDifference.java index 263a38b9..20bad6b6 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmDifference.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmDifference.java @@ -2,17 +2,17 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import java.awt.Cursor; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; import javax.swing.JOptionPane; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.map.MapView; +import org.meteoinfo.geo.layer.LayerTypes; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.layer.VectorLayer; +import org.meteoinfo.geo.mapview.MapView; import org.meteoinfo.geometry.shape.PolygonShape; /** diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmGifAnimator.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmGifAnimator.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmGifAnimator.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmGifAnimator.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmGifAnimator.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmGifAnimator.java similarity index 99% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmGifAnimator.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmGifAnimator.java index b448bfb4..bb7023e9 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmGifAnimator.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmGifAnimator.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import java.awt.Cursor; import java.io.File; @@ -11,7 +11,7 @@ import java.util.List; import javax.swing.DefaultListModel; import javax.swing.JFileChooser; import javax.swing.JOptionPane; -import org.meteoinfo.desktop.config.GenericFileFilter; +import org.meteoinfo.map.config.GenericFileFilter; import org.meteoinfo.image.ImageUtil; /** diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmGridSet.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmGridSet.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmGridSet.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmGridSet.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmGridSet.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmGridSet.java similarity index 99% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmGridSet.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmGridSet.java index 3774d0c9..805e8449 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmGridSet.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmGridSet.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import org.meteoinfo.data.GridDataSetting; diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmInterpolate.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmInterpolate.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmInterpolate.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmInterpolate.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmInterpolate.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmInterpolate.java similarity index 99% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmInterpolate.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmInterpolate.java index 9f05fc1f..d3792ceb 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmInterpolate.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmInterpolate.java @@ -2,14 +2,14 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import java.util.ArrayList; import java.util.List; import org.meteoinfo.data.GridDataSetting; -import org.meteoinfo.geoprocess.analysis.InterpolationMethods; -import org.meteoinfo.geoprocess.analysis.InterpolationSetting; +import org.meteoinfo.geo.analysis.InterpolationMethods; +import org.meteoinfo.geo.analysis.InterpolationSetting; /** * diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmIntersection.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmIntersection.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmIntersection.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmIntersection.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmIntersection.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmIntersection.java similarity index 98% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmIntersection.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmIntersection.java index 54a22ab1..aa328032 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmIntersection.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmIntersection.java @@ -2,17 +2,17 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import java.awt.Cursor; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; import javax.swing.JOptionPane; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.map.MapView; +import org.meteoinfo.geo.layer.LayerTypes; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.layer.VectorLayer; +import org.meteoinfo.geo.mapview.MapView; /** * diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmJoinNCFiles.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmJoinNCFiles.form similarity index 99% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmJoinNCFiles.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmJoinNCFiles.form index f362a1a1..18aff7d0 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmJoinNCFiles.form +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmJoinNCFiles.form @@ -100,7 +100,7 @@ - + diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmJoinNCFiles.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmJoinNCFiles.java similarity index 99% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmJoinNCFiles.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmJoinNCFiles.java index f9404684..c1f86a04 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmJoinNCFiles.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmJoinNCFiles.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import java.awt.Cursor; import java.io.File; @@ -14,7 +14,7 @@ import javax.swing.DefaultListModel; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import org.meteoinfo.data.meteodata.netcdf.NetCDFDataInfo; -import org.meteoinfo.desktop.config.GenericFileFilter; +import org.meteoinfo.map.config.GenericFileFilter; /** * diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmMain.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmMain.java similarity index 97% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmMain.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmMain.java index 61dca5b8..28df3a2c 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmMain.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmMain.java @@ -11,7 +11,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import java.awt.BorderLayout; import java.awt.Component; @@ -61,14 +61,15 @@ import org.meteoinfo.common.MIMath; import org.meteoinfo.common.PointF; import org.meteoinfo.common.util.GlobalUtil; import org.meteoinfo.data.mapdata.webmap.WebMapProvider; -import org.meteoinfo.desktop.config.GenericFileFilter; -import org.meteoinfo.desktop.config.Options; -import org.meteoinfo.desktop.config.Plugin; -import org.meteoinfo.desktop.config.PluginCollection; -import org.meteoinfo.desktop.config.ProjectFile; -import org.meteoinfo.data.mapdata.FrmAttriData; -import org.meteoinfo.data.mapdata.MapDataManage; -import org.meteoinfo.global.FrmProperty; +import org.meteoinfo.map.config.GenericFileFilter; +import org.meteoinfo.map.config.Options; +import org.meteoinfo.map.config.Plugin; +import org.meteoinfo.map.config.PluginCollection; +import org.meteoinfo.map.config.ProjectFile; +import org.meteoinfo.geo.mapdata.FrmAttriData; +import org.meteoinfo.geo.mapdata.MapDataManage; +import org.meteoinfo.geo.layer.*; +import org.meteoinfo.geo.gui.FrmProperty; import org.meteoinfo.common.colors.ColorUtil; import org.meteoinfo.ui.WrappingLayout; import org.meteoinfo.ui.event.ActiveMapFrameChangedEvent; @@ -86,28 +87,27 @@ import org.meteoinfo.ui.event.ShapeSelectedEvent; import org.meteoinfo.ui.event.UndoEditEvent; import org.meteoinfo.ui.event.ZoomChangedEvent; //import org.meteoinfo.help.Help; -import org.meteoinfo.layer.*; -import org.meteoinfo.layout.ElementType; -import org.meteoinfo.layout.FrmPageSet; -import org.meteoinfo.layout.LayoutGraphic; -import org.meteoinfo.layout.LayoutLegend; -import org.meteoinfo.layout.LayoutNorthArrow; -import org.meteoinfo.layout.LayoutScaleBar; -import org.meteoinfo.layout.MapLayout; -import org.meteoinfo.layout.MapLayoutUndoRedo; -import org.meteoinfo.layout.MouseMode; -import org.meteoinfo.legend.ItemNode; -import org.meteoinfo.legend.LayerNode; -import org.meteoinfo.legend.LayersLegend; -import org.meteoinfo.legend.MapFrame; -import org.meteoinfo.legend.NodeTypes; -import org.meteoinfo.map.FeatureUndoableEdit; -import org.meteoinfo.map.MapView; -import org.meteoinfo.map.MapViewUndoRedo; -import org.meteoinfo.map.MaskOut; -import org.meteoinfo.map.MouseTools; -import org.meteoinfo.plugin.IApplication; -import org.meteoinfo.plugin.IPlugin; +import org.meteoinfo.geo.layout.ElementType; +import org.meteoinfo.geo.layout.FrmPageSet; +import org.meteoinfo.geo.layout.LayoutGraphic; +import org.meteoinfo.geo.layout.LayoutLegend; +import org.meteoinfo.geo.layout.LayoutNorthArrow; +import org.meteoinfo.geo.layout.LayoutScaleBar; +import org.meteoinfo.geo.layout.MapLayout; +import org.meteoinfo.geo.layout.MapLayoutUndoRedo; +import org.meteoinfo.geo.layout.MouseMode; +import org.meteoinfo.geo.legend.ItemNode; +import org.meteoinfo.geo.legend.LayerNode; +import org.meteoinfo.geo.legend.LayersLegend; +import org.meteoinfo.geo.legend.MapFrame; +import org.meteoinfo.geo.legend.NodeTypes; +import org.meteoinfo.geo.mapview.FeatureUndoableEdit; +import org.meteoinfo.geo.mapview.MapView; +import org.meteoinfo.geo.mapview.MapViewUndoRedo; +import org.meteoinfo.geo.mapview.MaskOut; +import org.meteoinfo.geo.mapview.MouseTools; +import org.meteoinfo.geo.plugin.IApplication; +import org.meteoinfo.geo.plugin.IPlugin; import org.meteoinfo.projection.KnownCoordinateSystems; import org.meteoinfo.projection.ProjectionInfo; import org.meteoinfo.projection.ProjectionNames; @@ -115,7 +115,7 @@ import org.meteoinfo.projection.Reproject; import org.meteoinfo.geometry.shape.Shape; import org.meteoinfo.geometry.shape.ShapeTypes; import org.meteoinfo.ndarray.DataType; -import org.meteoinfo.data.mapdata.ShapeFileManage; +import org.meteoinfo.geo.mapdata.ShapeFileManage; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.operation.union.UnaryUnionOp; import org.meteoinfo.geometry.shape.ShapeFactory; @@ -358,10 +358,10 @@ public class FrmMain extends JFrame implements IApplication { jSplitPane1 = new javax.swing.JSplitPane(); jTabbedPane_Main = new javax.swing.JTabbedPane(); jPanel_MapTab = new javax.swing.JPanel(); - _mapView = new org.meteoinfo.map.MapView(); + _mapView = new MapView(); jPanel_LayoutTab = new javax.swing.JPanel(); - _mapLayout = new org.meteoinfo.layout.MapLayout(); - _mapDocument = new org.meteoinfo.legend.LayersLegend(); + _mapLayout = new MapLayout(); + _mapDocument = new LayersLegend(); jPanel_Status = new javax.swing.JPanel(); jLabel_Status = new javax.swing.JLabel(); jLabel_Coordinate = new javax.swing.JLabel(); @@ -459,7 +459,7 @@ public class FrmMain extends JFrame implements IApplication { //Split button //jSplitButton_AddLayer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Add_Layer.png"))); - jSplitButton_AddLayer.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/add-layer-plus.svg")); + jSplitButton_AddLayer.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/add-layer-plus.svg")); jSplitButton_AddLayer.setText(" "); jSplitButton_AddLayer.setToolTipText(bundle.getString("FrmMain.jMenuItem_AddLayer.toolTipText")); jSplitButton_AddLayer.setArrowColor(ColorUtil.parseToColor("#6E6E6E")); @@ -472,19 +472,19 @@ public class FrmMain extends JFrame implements IApplication { } }); //jMenuItem_AddLayer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/select_rectangle.png"))); - jMenuItem_AddLayer.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/add-layer-plus.svg")); + jMenuItem_AddLayer.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/add-layer-plus.svg")); jMenuItem_AddLayer.setText(bundle.getString("FrmMain.jMenuItem_AddLayer.text")); jMenuItem_AddLayer.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { - jSplitButton_AddLayer.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/add-layer-plus.svg")); + jSplitButton_AddLayer.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/add-layer-plus.svg")); jSplitButton_AddLayer.setText(" "); jSplitButton_AddLayer.setToolTipText(bundle.getString("FrmMain.jMenuItem_AddLayer.toolTipText")); jButton_AddLayerActionPerformed(e); } }); jPopupMenu_AddLayer.add(jMenuItem_AddLayer); - jMenuItem_AddWebLayer.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/add-web-layer.svg")); + jMenuItem_AddWebLayer.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/add-web-layer.svg")); jMenuItem_AddWebLayer.setText(bundle.getString("FrmMain.jMenuItem_AddWebLayer.text")); jMenuItem_AddWebLayer.addActionListener(new java.awt.event.ActionListener() { @Override @@ -526,7 +526,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Base.add(jSeparator1); //jButton_SelectElement.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Arrow.png"))); // NOI18N - jButton_SelectElement.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/select.svg")); + jButton_SelectElement.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/select.svg")); jButton_SelectElement.setToolTipText(bundle.getString("FrmMain.jButton_SelectElement.toolTipText")); // NOI18N jButton_SelectElement.setFocusable(false); jButton_SelectElement.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -540,7 +540,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Base.add(jButton_SelectElement); //jButton_ZoomIn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_ZoomIn.Image.png"))); // NOI18N - jButton_ZoomIn.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/zoom-in.svg")); + jButton_ZoomIn.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/zoom-in.svg")); jButton_ZoomIn.setToolTipText(bundle.getString("FrmMain.jButton_ZoomIn.toolTipText")); // NOI18N jButton_ZoomIn.setFocusable(false); jButton_ZoomIn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -554,7 +554,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Base.add(jButton_ZoomIn); //jButton_ZoomOut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_ZoomOut.Image.png"))); // NOI18N - jButton_ZoomOut.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/zoom-out.svg")); + jButton_ZoomOut.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/zoom-out.svg")); jButton_ZoomOut.setToolTipText(bundle.getString("FrmMain.jButton_ZoomOut.toolTipText")); // NOI18N jButton_ZoomOut.setFocusable(false); jButton_ZoomOut.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -568,8 +568,8 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Base.add(jButton_ZoomOut); //jButton_Pan.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_Pan.Image.png"))); // NOI18N - //jButton_Pan.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/pan.svg")); - jButton_Pan.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/hand.svg")); + //jButton_Pan.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/pan.svg")); + jButton_Pan.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/hand.svg")); jButton_Pan.setToolTipText(bundle.getString("FrmMain.jButton_Pan.toolTipText")); // NOI18N jButton_Pan.setFocusable(false); jButton_Pan.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -583,7 +583,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Base.add(jButton_Pan); //jButton_FullExtent.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_FullExent.Image.png"))); // NOI18N - jButton_FullExtent.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/full-extent.svg")); + jButton_FullExtent.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/full-extent.svg")); jButton_FullExtent.setToolTipText(bundle.getString("FrmMain.jButton_FullExtent.toolTipText")); // NOI18N jButton_FullExtent.setFocusable(false); jButton_FullExtent.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -597,7 +597,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Base.add(jButton_FullExtent); //jButton_ZoomToLayer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_ZoomToLayer.Image.png"))); // NOI18N - jButton_ZoomToLayer.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/zoom-layer.svg")); + jButton_ZoomToLayer.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/zoom-layer.svg")); jButton_ZoomToLayer.setToolTipText(bundle.getString("FrmMain.jButton_ZoomToLayer.toolTipText")); // NOI18N jButton_ZoomToLayer.setFocusable(false); jButton_ZoomToLayer.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -611,7 +611,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Base.add(jButton_ZoomToLayer); //jButton_ZoomToExtent.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_ZoomToExtent.Image.png"))); // NOI18N - jButton_ZoomToExtent.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/zoom-extent.svg")); + jButton_ZoomToExtent.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/zoom-extent.svg")); jButton_ZoomToExtent.setToolTipText(bundle.getString("FrmMain.jButton_ZoomToExtent.toolTipText")); // NOI18N jButton_ZoomToExtent.setFocusable(false); jButton_ZoomToExtent.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -625,7 +625,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Base.add(jButton_ZoomToExtent); //jButton_ZoomUndo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_PreTime.Image.png"))); // NOI18N - jButton_ZoomUndo.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/undo.svg")); + jButton_ZoomUndo.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/undo.svg")); jButton_ZoomUndo.setToolTipText(bundle.getString("FrmMain.jButton_ZoomUndo.toolTipText")); // NOI18N jButton_ZoomUndo.setFocusable(false); jButton_ZoomUndo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -640,7 +640,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Base.add(jButton_ZoomUndo); //jButton_ZoomRedo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_NextTime.Image.png"))); // NOI18N - jButton_ZoomRedo.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/redo.svg")); + jButton_ZoomRedo.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/redo.svg")); jButton_ZoomRedo.setToolTipText(bundle.getString("FrmMain.jButton_ZoomRedo.toolTipText")); // NOI18N jButton_ZoomRedo.setFocusable(false); jButton_ZoomRedo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -656,7 +656,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Base.add(new JSeparator()); //jButton_Identifer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/information.png"))); // NOI18N - jButton_Identifer.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/information.svg")); + jButton_Identifer.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/information.svg")); jButton_Identifer.setToolTipText(bundle.getString("FrmMain.jButton_Identifer.toolTipText")); // NOI18N jButton_Identifer.setFocusable(false); jButton_Identifer.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -672,7 +672,7 @@ public class FrmMain extends JFrame implements IApplication { //Split button //jSplitButton_SelectFeature.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/select_rectangle.png"))); - jSplitButton_SelectFeature.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/select-rectangle.svg")); + jSplitButton_SelectFeature.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/select-rectangle.svg")); jSplitButton_SelectFeature.setText(" "); jSplitButton_SelectFeature.setToolTipText(bundle.getString("FrmMain.jButton_SelectFeature.toolTipText_Rectangle")); jSplitButton_SelectFeature.setArrowColor(ColorUtil.parseToColor("#6E6E6E")); @@ -694,13 +694,13 @@ public class FrmMain extends JFrame implements IApplication { } }); //jMenuItem_SelByRectangle.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/select_rectangle.png"))); - jMenuItem_SelByRectangle.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/select-rectangle.svg")); + jMenuItem_SelByRectangle.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/select-rectangle.svg")); jMenuItem_SelByRectangle.setText(bundle.getString("FrmMain.jMenuItem_SelByRectangle.text")); jMenuItem_SelByRectangle.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { //jSplitButton_SelectFeature.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/select_rectangle.png"))); - jSplitButton_SelectFeature.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/select-rectangle.svg")); + jSplitButton_SelectFeature.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/select-rectangle.svg")); jSplitButton_SelectFeature.setText(" "); jSplitButton_SelectFeature.setToolTipText(bundle.getString("FrmMain.jButton_SelectFeature.toolTipText_Rectangle")); jButton_SelByRectangleActionPerformed(e); @@ -709,13 +709,13 @@ public class FrmMain extends JFrame implements IApplication { }); jPopupMenu_SelectFeature.add(jMenuItem_SelByRectangle); //jMenuItem_SelByPolygon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/select_polygon.png"))); - jMenuItem_SelByPolygon.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/select-polygon.svg")); + jMenuItem_SelByPolygon.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/select-polygon.svg")); jMenuItem_SelByPolygon.setText(bundle.getString("FrmMain.jMenuItem_SelByPolygon.text")); jMenuItem_SelByPolygon.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { //jSplitButton_SelectFeature.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/select_polygon.png"))); - jSplitButton_SelectFeature.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/select-polygon.svg")); + jSplitButton_SelectFeature.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/select-polygon.svg")); jSplitButton_SelectFeature.setText(" "); jSplitButton_SelectFeature.setToolTipText(bundle.getString("FrmMain.jButton_SelectFeature.toolTipText_Polygon")); jButton_SelByPolygonActionPerformed(e); @@ -724,13 +724,13 @@ public class FrmMain extends JFrame implements IApplication { }); jPopupMenu_SelectFeature.add(jMenuItem_SelByPolygon); //jMenuItem_SelByLasso.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/select_lasso.png"))); - jMenuItem_SelByLasso.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/select-lasso.svg")); + jMenuItem_SelByLasso.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/select-lasso.svg")); jMenuItem_SelByLasso.setText(bundle.getString("FrmMain.jMenuItem_SelByLasso.text")); jMenuItem_SelByLasso.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { //jSplitButton_SelectFeature.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/select_lasso.png"))); - jSplitButton_SelectFeature.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/select-lasso.svg")); + jSplitButton_SelectFeature.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/select-lasso.svg")); jSplitButton_SelectFeature.setText(" "); jSplitButton_SelectFeature.setToolTipText(bundle.getString("FrmMain.jButton_SelectFeature.toolTipText_Lasso")); jButton_SelByLassoActionPerformed(e); @@ -739,13 +739,13 @@ public class FrmMain extends JFrame implements IApplication { }); jPopupMenu_SelectFeature.add(jMenuItem_SelByLasso); //jMenuItem_SelByCircle.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/select_circle.png"))); - jMenuItem_SelByCircle.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/select-circle.svg")); + jMenuItem_SelByCircle.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/select-circle.svg")); jMenuItem_SelByCircle.setText(bundle.getString("FrmMain.jMenuItem_SelByCircle.text")); jMenuItem_SelByCircle.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { //jSplitButton_SelectFeature.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/select_circle.png"))); - jSplitButton_SelectFeature.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/select-circle.svg")); + jSplitButton_SelectFeature.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/select-circle.svg")); jSplitButton_SelectFeature.setText(" "); jSplitButton_SelectFeature.setToolTipText(bundle.getString("FrmMain.jButton_SelectFeature.toolTipText_Circle")); jButton_SelByCircleActionPerformed(e); @@ -791,7 +791,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Base.add(jSeparator3); //jButton_SavePicture.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Save_Image.png"))); // NOI18N - jButton_SavePicture.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/figure-output.svg")); + jButton_SavePicture.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/figure-output.svg")); jButton_SavePicture.setToolTipText(bundle.getString("FrmMain.jButton_SavePicture.toolTipText")); // NOI18N jButton_SavePicture.setFocusable(false); jButton_SavePicture.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -810,7 +810,7 @@ public class FrmMain extends JFrame implements IApplication { //jToolBar_Graphic.add(jSeparator4); //jButton_NewLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_NewLabel.Image.png"))); // NOI18N - jButton_NewLabel.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/new-text.svg")); + jButton_NewLabel.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/new-text.svg")); jButton_NewLabel.setToolTipText(bundle.getString("FrmMain.jButton_NewLabel.toolTipText")); // NOI18N jButton_NewLabel.setFocusable(false); jButton_NewLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -824,7 +824,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Graphic.add(jButton_NewLabel); //jButton_NewPoint.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_NewPoint.Image.png"))); // NOI18N - jButton_NewPoint.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/new-point.svg")); + jButton_NewPoint.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/new-point.svg")); jButton_NewPoint.setToolTipText(bundle.getString("FrmMain.jButton_NewPoint.toolTipText")); // NOI18N jButton_NewPoint.setFocusable(false); jButton_NewPoint.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -838,7 +838,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Graphic.add(jButton_NewPoint); //jButton_NewPolyline.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_NewPolyline.Image.png"))); // NOI18N - jButton_NewPolyline.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/new-line.svg")); + jButton_NewPolyline.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/new-line.svg")); jButton_NewPolyline.setToolTipText(bundle.getString("FrmMain.jButton_NewPolyline.toolTipText")); // NOI18N jButton_NewPolyline.setFocusable(false); jButton_NewPolyline.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -852,7 +852,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Graphic.add(jButton_NewPolyline); //jButton_NewFreehand.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_NewFreehand.Image.png"))); // NOI18N - jButton_NewFreehand.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/new-line-hand.svg")); + jButton_NewFreehand.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/new-line-hand.svg")); jButton_NewFreehand.setToolTipText(bundle.getString("FrmMain.jButton_NewFreehand.toolTipText")); // NOI18N jButton_NewFreehand.setFocusable(false); jButton_NewFreehand.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -866,7 +866,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Graphic.add(jButton_NewFreehand); //jButton_NewCurve.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_NewCurve.Image.png"))); // NOI18N - jButton_NewCurve.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/new-curve.svg")); + jButton_NewCurve.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/new-curve.svg")); jButton_NewCurve.setToolTipText(bundle.getString("FrmMain.jButton_NewCurve.toolTipText")); // NOI18N jButton_NewCurve.setFocusable(false); jButton_NewCurve.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -880,7 +880,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Graphic.add(jButton_NewCurve); //jButton_NewPolygon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_NewPolygon.Image.png"))); // NOI18N - jButton_NewPolygon.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/new-polygon.svg")); + jButton_NewPolygon.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/new-polygon.svg")); jButton_NewPolygon.setToolTipText(bundle.getString("FrmMain.jButton_NewPolygon.toolTipText")); // NOI18N jButton_NewPolygon.setFocusable(false); jButton_NewPolygon.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -894,7 +894,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Graphic.add(jButton_NewPolygon); //jButton_NewCurvePolygon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_NewCurvePolygon.Image.png"))); // NOI18N - jButton_NewCurvePolygon.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/new-polygon-curve.svg")); + jButton_NewCurvePolygon.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/new-polygon-curve.svg")); jButton_NewCurvePolygon.setToolTipText(bundle.getString("FrmMain.jButton_NewCurvePolygon.toolTipText")); // NOI18N jButton_NewCurvePolygon.setFocusable(false); jButton_NewCurvePolygon.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -908,7 +908,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Graphic.add(jButton_NewCurvePolygon); //jButton_NewRectangle.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_NewRectangle.Image.png"))); // NOI18N - jButton_NewRectangle.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/new-rectangle.svg")); + jButton_NewRectangle.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/new-rectangle.svg")); jButton_NewRectangle.setToolTipText(bundle.getString("FrmMain.jButton_NewRectangle.toolTipText")); // NOI18N jButton_NewRectangle.setFocusable(false); jButton_NewRectangle.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -922,7 +922,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Graphic.add(jButton_NewRectangle); //jButton_NewCircle.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_NewCircle.Image.png"))); // NOI18N - jButton_NewCircle.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/new-circle.svg")); + jButton_NewCircle.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/new-circle.svg")); jButton_NewCircle.setToolTipText(bundle.getString("FrmMain.jButton_NewCircle.toolTipText")); // NOI18N jButton_NewCircle.setFocusable(false); jButton_NewCircle.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -936,7 +936,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Graphic.add(jButton_NewCircle); //jButton_NewEllipse.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_NewEllipse.Image.png"))); // NOI18N - jButton_NewEllipse.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/new-ellipse.svg")); + jButton_NewEllipse.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/new-ellipse.svg")); jButton_NewEllipse.setToolTipText(bundle.getString("FrmMain.jButton_NewEllipse.toolTipText")); // NOI18N jButton_NewEllipse.setFocusable(false); jButton_NewEllipse.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -950,7 +950,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Graphic.add(jButton_NewEllipse); //jButton_EditVertices.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_EditVertices.Image.png"))); // NOI18N - jButton_EditVertices.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/edit-vertices.svg")); + jButton_EditVertices.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/edit-vertices.svg")); jButton_EditVertices.setToolTipText(bundle.getString("FrmMain.jButton_EditVertices.toolTipText")); // NOI18N jButton_EditVertices.setFocusable(false); jButton_EditVertices.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -969,7 +969,7 @@ public class FrmMain extends JFrame implements IApplication { //jToolBar_Layout.add(jSeparator15); //jButton_PageSet.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/page_portrait.png"))); // NOI18N - jButton_PageSet.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/page-setting.svg")); + jButton_PageSet.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/page-setting.svg")); jButton_PageSet.setToolTipText(bundle.getString("FrmMain.jButton_PageSet.toolTipText")); // NOI18N jButton_PageSet.setFocusable(false); jButton_PageSet.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -983,7 +983,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Layout.add(jButton_PageSet); //jButton_PageZoomIn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_PageZoomIn.Image.png"))); // NOI18N - jButton_PageZoomIn.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/page-zoom-in.svg")); + jButton_PageZoomIn.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/page-zoom-in.svg")); jButton_PageZoomIn.setToolTipText(bundle.getString("FrmMain.jButton_PageZoomIn.toolTipText")); // NOI18N jButton_PageZoomIn.setFocusable(false); jButton_PageZoomIn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -997,7 +997,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Layout.add(jButton_PageZoomIn); //jButton_PageZoomOut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_PageZoomOut.Image.png"))); // NOI18N - jButton_PageZoomOut.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/page-zoom-out.svg")); + jButton_PageZoomOut.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/page-zoom-out.svg")); jButton_PageZoomOut.setToolTipText(bundle.getString("FrmMain.jButton_PageZoomOut.toolTipText")); // NOI18N jButton_PageZoomOut.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1008,7 +1008,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Layout.add(jButton_PageZoomOut); //jButton_FitToScreen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ZoomFullMap.png"))); // NOI18N - jButton_FitToScreen.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/page-zoom-window.svg")); + jButton_FitToScreen.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/page-zoom-window.svg")); jButton_FitToScreen.setToolTipText(bundle.getString("FrmMain.jButton_FitToScreen.toolTipText")); // NOI18N jButton_FitToScreen.setFocusable(false); jButton_FitToScreen.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -1038,7 +1038,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Edit.setRollover(true); //jButton_EditStartOrEnd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/edit_16.png"))); // NOI18N - jButton_EditStartOrEnd.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/edit-status.svg")); + jButton_EditStartOrEnd.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/edit-status.svg")); jButton_EditStartOrEnd.setToolTipText(bundle.getString("FrmMain.jButton_EditStartOrEnd.toolTipText")); // NOI18N jButton_EditStartOrEnd.setFocusable(false); jButton_EditStartOrEnd.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -1068,7 +1068,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Edit.add(new javax.swing.JToolBar.Separator()); //jButton_EditTool.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/location_arrow.png"))); // NOI18N - jButton_EditTool.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/edit-tool.svg")); + jButton_EditTool.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/edit-tool.svg")); jButton_EditTool.setToolTipText(bundle.getString("FrmMain.jButton_EditTool.toolTipText")); // NOI18N jButton_EditTool.setFocusable(false); jButton_EditTool.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -1083,7 +1083,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Edit.add(jButton_EditTool); //jButton_EditNewFeature.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/new_document_16.png"))); // NOI18N - jButton_EditNewFeature.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/edit-add-feature.svg")); + jButton_EditNewFeature.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/edit-add-feature.svg")); jButton_EditNewFeature.setToolTipText(bundle.getString("FrmMain.jButton_EditNewFeature.toolTipText")); // NOI18N jButton_EditNewFeature.setFocusable(false); jButton_EditNewFeature.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -1113,7 +1113,7 @@ public class FrmMain extends JFrame implements IApplication { jToolBar_Edit.add(jButton_EditRemoveFeature); //jButton_EditFeatureVertices.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_EditVertices.Image.png"))); // NOI18N - jButton_EditFeatureVertices.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/edit-vertices.svg")); + jButton_EditFeatureVertices.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/edit-vertices.svg")); jButton_EditFeatureVertices.setToolTipText(bundle.getString("FrmMain.jButton_EditFeatureVertices.toolTipText")); // NOI18N jButton_EditFeatureVertices.setFocusable(false); jButton_EditFeatureVertices.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -1278,7 +1278,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Edit.setMnemonic(KeyEvent.VK_E); //jMenuItem_Undo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_Undo.Image.png"))); // NOI18N - jMenuItem_Undo.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/undo.svg")); + jMenuItem_Undo.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/undo.svg")); jMenuItem_Undo.setText(bundle.getString("FrmMain.jMenuItem_Undo.text")); // NOI18N jMenuItem_Undo.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, java.awt.event.InputEvent.CTRL_MASK)); jMenuItem_Undo.addActionListener(new java.awt.event.ActionListener() { @@ -1291,7 +1291,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Edit.add(jMenuItem_Undo); //jMenuItem_Redo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_Redo.Image.png"))); // NOI18N - jMenuItem_Redo.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/redo.svg")); + jMenuItem_Redo.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/redo.svg")); jMenuItem_Redo.setText(bundle.getString("FrmMain.jMenuItem_Redo.text")); // NOI18N jMenuItem_Redo.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Y, java.awt.event.InputEvent.CTRL_MASK)); jMenuItem_Redo.addActionListener(new java.awt.event.ActionListener() { @@ -1308,7 +1308,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Edit.setMnemonic(KeyEvent.VK_E); //jMenuItem_Cut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSMI_EditCut.Image.png"))); // NOI18N - jMenuItem_Cut.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/menu-cut.svg")); + jMenuItem_Cut.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/menu-cut.svg")); jMenuItem_Cut.setText(bundle.getString("FrmMain.jMenuItem_Cut.text")); // NOI18N jMenuItem_Cut.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK)); jMenuItem_Cut.addActionListener(new java.awt.event.ActionListener() { @@ -1321,7 +1321,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Edit.add(jMenuItem_Cut); //jMenuItem_Copy.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/menuEditCopy.Image.png"))); // NOI18N - jMenuItem_Copy.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/copy.svg")); + jMenuItem_Copy.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/copy.svg")); jMenuItem_Copy.setText(bundle.getString("FrmMain.jMenuItem_Copy.text")); // NOI18N jMenuItem_Copy.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK)); jMenuItem_Copy.addActionListener(new java.awt.event.ActionListener() { @@ -1334,7 +1334,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Edit.add(jMenuItem_Copy); //jMenuItem_Paste.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/pasteToolStripButton.Image.png"))); // NOI18N - jMenuItem_Paste.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/menu-paste.svg")); + jMenuItem_Paste.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/menu-paste.svg")); jMenuItem_Paste.setText(bundle.getString("FrmMain.jMenuItem_Paste.text")); // NOI18N jMenuItem_Paste.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.CTRL_MASK)); jMenuItem_Paste.addActionListener(new java.awt.event.ActionListener() { @@ -1347,7 +1347,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Edit.add(jMenuItem_Paste); jMenu_Edit.add(new javax.swing.JPopupMenu.Separator()); - jMenuItem_NewLayer.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/new-layer.svg")); + jMenuItem_NewLayer.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/new-layer.svg")); jMenuItem_NewLayer.setText(bundle.getString("FrmMain.jMenuItem_NewLayer.text")); // NOI18N jMenuItem_NewLayer.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1359,7 +1359,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Edit.add(new javax.swing.JPopupMenu.Separator()); //jMenuItem_AddRing.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ring_add.png"))); // NOI18N - jMenuItem_AddRing.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/add-ring.svg")); + jMenuItem_AddRing.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/add-ring.svg")); jMenuItem_AddRing.setText(bundle.getString("FrmMain.jMenuItem_AddRing.text")); // NOI18N jMenuItem_AddRing.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1371,7 +1371,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Edit.add(jMenuItem_AddRing); //jMenuItem_FillRing.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ring.png"))); // NOI18N - jMenuItem_FillRing.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/fill-ring.svg")); + jMenuItem_FillRing.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/fill-ring.svg")); jMenuItem_FillRing.setText(bundle.getString("FrmMain.jMenuItem_FillRing.text")); // NOI18N jMenuItem_FillRing.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1383,7 +1383,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Edit.add(jMenuItem_FillRing); //jMenuItem_DeleteRing.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ring_delete.png"))); // NOI18N - jMenuItem_DeleteRing.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/delete-ring.svg")); + jMenuItem_DeleteRing.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/delete-ring.svg")); jMenuItem_DeleteRing.setText(bundle.getString("FrmMain.jMenuItem_DeleteRing.text")); // NOI18N jMenuItem_DeleteRing.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1395,7 +1395,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Edit.add(jMenuItem_DeleteRing); //jMenuItem_ReformFeature.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/reform_edit.png"))); // NOI18N - jMenuItem_ReformFeature.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/reshape-feature.svg")); + jMenuItem_ReformFeature.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/reshape-feature.svg")); jMenuItem_ReformFeature.setText(bundle.getString("FrmMain.jMenuItem_ReformFeature.text")); // NOI18N jMenuItem_ReformFeature.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1407,7 +1407,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Edit.add(jMenuItem_ReformFeature); //jMenuItem_SplitFeature.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/split.png"))); // NOI18N - jMenuItem_SplitFeature.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/split-feature.svg")); + jMenuItem_SplitFeature.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/split-feature.svg")); jMenuItem_SplitFeature.setText(bundle.getString("FrmMain.jMenuItem_SplitFeature.text")); // NOI18N jMenuItem_SplitFeature.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1419,7 +1419,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Edit.add(jMenuItem_SplitFeature); //jMenuItem_MergeFeature.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/merge.png"))); // NOI18N - jMenuItem_MergeFeature.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/merge-feature.svg")); + jMenuItem_MergeFeature.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/merge-feature.svg")); jMenuItem_MergeFeature.setText(bundle.getString("FrmMain.jMenuItem_MergeFeature.text")); // NOI18N jMenuItem_MergeFeature.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1459,7 +1459,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_View.add(jMenuItem_AttributeData); jMenu_View.add(jSeparator5); - jMenuItem_LayoutProperty.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/layout-setting.svg")); + jMenuItem_LayoutProperty.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/layout-setting.svg")); jMenuItem_LayoutProperty.setText(bundle.getString("FrmMain.jMenuItem_LayoutProperty.text")); // NOI18N jMenuItem_LayoutProperty.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1470,7 +1470,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_View.add(jMenuItem_LayoutProperty); jMenu_View.add(jSeparator6); - jMenuItem_MapProperty.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/map-setting.svg")); + jMenuItem_MapProperty.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/map-setting.svg")); jMenuItem_MapProperty.setText(bundle.getString("FrmMain.jMenuItem_MapProperty.text")); // NOI18N jMenuItem_MapProperty.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1490,7 +1490,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_View.add(jMenuItem_MaskOut); jMenu_View.add(jSeparator7); - jMenuItem_Projection.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/lon-lat.svg")); + jMenuItem_Projection.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/lon-lat.svg")); jMenuItem_Projection.setText(bundle.getString("FrmMain.jMenuItem_Projection.text")); // NOI18N jMenuItem_Projection.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1505,7 +1505,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Insert.setText(bundle.getString("FrmMain.jMenu_Insert.text")); // NOI18N jMenu_Insert.setMnemonic(KeyEvent.VK_V); - jMenuItem_InsertMapFrame.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/add-layer.svg")); + jMenuItem_InsertMapFrame.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/add-layer.svg")); jMenuItem_InsertMapFrame.setText(bundle.getString("FrmMain.jMenuItem_InsertMapFrame.text")); // NOI18N jMenuItem_InsertMapFrame.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1516,7 +1516,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Insert.add(jMenuItem_InsertMapFrame); jMenu_Insert.add(jSeparator10); - jMenuItem_InsertTitle.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/title.svg")); + jMenuItem_InsertTitle.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/title.svg")); jMenuItem_InsertTitle.setText(bundle.getString("FrmMain.jMenuItem_InsertTitle.text")); // NOI18N jMenuItem_InsertTitle.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1526,7 +1526,7 @@ public class FrmMain extends JFrame implements IApplication { }); jMenu_Insert.add(jMenuItem_InsertTitle); - jMenuItem_InsertText.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/text.svg")); + jMenuItem_InsertText.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/text.svg")); jMenuItem_InsertText.setText(bundle.getString("FrmMain.jMenuItem_InsertText.text")); // NOI18N jMenuItem_InsertText.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1537,7 +1537,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Insert.add(jMenuItem_InsertText); jMenu_Insert.add(jSeparator8); - jMenuItem_InsertLegend.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/legend.svg")); + jMenuItem_InsertLegend.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/legend.svg")); //jMenuItem_InsertLegend.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSMI_InsertLegend.Image.png"))); // NOI18N jMenuItem_InsertLegend.setText(bundle.getString("FrmMain.jMenuItem_InsertLegend.text")); // NOI18N jMenuItem_InsertLegend.addActionListener(new java.awt.event.ActionListener() { @@ -1548,7 +1548,7 @@ public class FrmMain extends JFrame implements IApplication { }); jMenu_Insert.add(jMenuItem_InsertLegend); - jMenuItem_InsertScaleBar.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/scale-bar.svg")); + jMenuItem_InsertScaleBar.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/scale-bar.svg")); jMenuItem_InsertScaleBar.setText(bundle.getString("FrmMain.jMenuItem_InsertScaleBar.text")); // NOI18N jMenuItem_InsertScaleBar.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1558,7 +1558,7 @@ public class FrmMain extends JFrame implements IApplication { }); jMenu_Insert.add(jMenuItem_InsertScaleBar); - jMenuItem_InsertNorthArrow.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/north-arrow.svg")); + jMenuItem_InsertNorthArrow.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/north-arrow.svg")); jMenuItem_InsertNorthArrow.setText(bundle.getString("FrmMain.jMenuItem_InsertNorthArrow.text")); // NOI18N jMenuItem_InsertNorthArrow.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1569,7 +1569,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Insert.add(jMenuItem_InsertNorthArrow); jMenu_Insert.add(jSeparator9); - jMenuItem_InsertWindArrow.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/wind-arrow.svg")); + jMenuItem_InsertWindArrow.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/wind-arrow.svg")); jMenuItem_InsertWindArrow.setText(bundle.getString("FrmMain.jMenuItem_InsertWindArrow.text")); // NOI18N jMenuItem_InsertWindArrow.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1584,7 +1584,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Selection.setText(bundle.getString("FrmMain.jMenu_Selection.text")); // NOI18N jMenu_Selection.setMnemonic(KeyEvent.VK_S); - jMenuItem_SelByAttr.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/select-attr.svg")); + jMenuItem_SelByAttr.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/select-attr.svg")); jMenuItem_SelByAttr.setText(bundle.getString("FrmMain.jMenuItem_SelByAttr.text")); // NOI18N jMenuItem_SelByAttr.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1594,7 +1594,7 @@ public class FrmMain extends JFrame implements IApplication { }); jMenu_Selection.add(jMenuItem_SelByAttr); - jMenuItem_SelByLocation.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/select-location.svg")); + jMenuItem_SelByLocation.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/select-location.svg")); jMenuItem_SelByLocation.setText(bundle.getString("FrmMain.jMenuItem_SelByLocation.text")); // NOI18N jMenuItem_SelByLocation.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1605,7 +1605,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Selection.add(jMenuItem_SelByLocation); jMenu_Selection.add(jSeparator11); - jMenuItem_ClearSelection.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/cancel.svg")); + jMenuItem_ClearSelection.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/cancel.svg")); jMenuItem_ClearSelection.setText(bundle.getString("FrmMain.jMenuItem_ClearSelection.text")); // NOI18N jMenuItem_ClearSelection.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1621,7 +1621,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_GeoProcessing.setText(bundle.getString("FrmMain.jMenu_GeoProcessing.text")); jMenu_GeoProcessing.setMnemonic(KeyEvent.VK_G); - jMenuItem_Buffer.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/buffer.svg")); + jMenuItem_Buffer.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/buffer.svg")); jMenuItem_Buffer.setText(bundle.getString("FrmMain.jMenuItem_Buffer.text")); // NOI18N jMenuItem_Buffer.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1631,7 +1631,7 @@ public class FrmMain extends JFrame implements IApplication { }); jMenu_GeoProcessing.add(jMenuItem_Buffer); - jMenuItem_Clipping.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/clip.svg")); + jMenuItem_Clipping.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/clip.svg")); jMenuItem_Clipping.setText(bundle.getString("FrmMain.jMenuItem_Clipping.text")); // NOI18N jMenuItem_Clipping.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1641,7 +1641,7 @@ public class FrmMain extends JFrame implements IApplication { }); jMenu_GeoProcessing.add(jMenuItem_Clipping); - jMenuItem_Convexhull.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/convexhull.svg")); + jMenuItem_Convexhull.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/convexhull.svg")); jMenuItem_Convexhull.setText(bundle.getString("FrmMain.jMenuItem_Convexhull.text")); // NOI18N jMenuItem_Convexhull.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1651,7 +1651,7 @@ public class FrmMain extends JFrame implements IApplication { }); jMenu_GeoProcessing.add(jMenuItem_Convexhull); - jMenuItem_Intersection.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/intersection.svg")); + jMenuItem_Intersection.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/intersection.svg")); jMenuItem_Intersection.setText(bundle.getString("FrmMain.jMenuItem_Intersection.text")); // NOI18N jMenuItem_Intersection.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1661,7 +1661,7 @@ public class FrmMain extends JFrame implements IApplication { }); jMenu_GeoProcessing.add(jMenuItem_Intersection); - jMenuItem_Difference.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/difference.svg")); + jMenuItem_Difference.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/difference.svg")); jMenuItem_Difference.setText(bundle.getString("FrmMain.jMenuItem_Difference.text")); // NOI18N jMenuItem_Difference.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1671,7 +1671,7 @@ public class FrmMain extends JFrame implements IApplication { }); jMenu_GeoProcessing.add(jMenuItem_Difference); - jMenuItem_SymDifference.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/system-difference.svg")); + jMenuItem_SymDifference.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/system-difference.svg")); jMenuItem_SymDifference.setText(bundle.getString("FrmMain.jMenuItem_SymDifference.text")); // NOI18N jMenuItem_SymDifference.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1688,7 +1688,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Tools.setMnemonic(KeyEvent.VK_T); //jMenuItem_Script.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/snake.png"))); // NOI18N - jMenuItem_Script.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/editor.svg")); + jMenuItem_Script.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/editor.svg")); jMenuItem_Script.setText(bundle.getString("FrmMain.jMenuItem_Script.text")); // NOI18N jMenuItem_Script.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1699,7 +1699,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Tools.add(jMenuItem_Script); /*//jMenuItem_ScriptConsole.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/console.png"))); // NOI18N - jMenuItem_ScriptConsole.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/console.svg")); + jMenuItem_ScriptConsole.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/console.svg")); jMenuItem_ScriptConsole.setText(bundle.getString("FrmMain.jMenuItem_ScriptConsole.text")); // NOI18N jMenuItem_ScriptConsole.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1710,7 +1710,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Tools.add(jMenuItem_ScriptConsole);*/ jMenu_Tools.add(jSeparator16); - jMenuItem_Options.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/tools.svg")); + jMenuItem_Options.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/tools.svg")); jMenuItem_Options.setText(bundle.getString("FrmMain.jMenuItem_Options.text")); // NOI18N jMenuItem_Options.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1721,7 +1721,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Tools.add(jMenuItem_Options); jMenu_Tools.add(jSeparator17); - jMenuItem_OutputMapData.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/map-out.svg")); + jMenuItem_OutputMapData.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/map-out.svg")); jMenuItem_OutputMapData.setText(bundle.getString("FrmMain.jMenuItem_OutputMapData.text")); // NOI18N jMenuItem_OutputMapData.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1731,7 +1731,7 @@ public class FrmMain extends JFrame implements IApplication { }); jMenu_Tools.add(jMenuItem_OutputMapData); - jMenuItem_AddXYData.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/chart-points.svg")); + jMenuItem_AddXYData.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/chart-points.svg")); jMenuItem_AddXYData.setText(bundle.getString("FrmMain.jMenuItem_AddXYData.text")); // NOI18N jMenuItem_AddXYData.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1741,7 +1741,7 @@ public class FrmMain extends JFrame implements IApplication { }); jMenu_Tools.add(jMenuItem_AddXYData); - jMenuItem_Animator.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/gif.svg")); + jMenuItem_Animator.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/gif.svg")); jMenuItem_Animator.setText(bundle.getString("FrmMain.jMenuItem_Animator.text")); // NOI18N jMenuItem_Animator.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1767,7 +1767,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Plugin.setText(bundle.getString("FrmMain.jMenu_Plugin.text")); // NOI18N jMenu_Plugin.setMnemonic(KeyEvent.VK_L); - jMenuItem_PluginManager.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/plugin-setting.svg")); + jMenuItem_PluginManager.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/plugin-setting.svg")); //jMenuItem_PluginManager.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/plugin_edit_green.png"))); // NOI18N jMenuItem_PluginManager.setText(bundle.getString("FrmMain.jMenuItem_PluginManager.text")); // NOI18N jMenuItem_PluginManager.addActionListener(new java.awt.event.ActionListener() { @@ -1784,7 +1784,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Help.setText(bundle.getString("FrmMain.jMenu_Help.text")); // NOI18N jMenu_Help.setMnemonic(KeyEvent.VK_H); - jMenuItem_About.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/information.svg")); + jMenuItem_About.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/information.svg")); jMenuItem_About.setText(bundle.getString("FrmMain.jMenuItem_About.text")); // NOI18N jMenuItem_About.addActionListener(new java.awt.event.ActionListener() { @Override @@ -1795,7 +1795,7 @@ public class FrmMain extends JFrame implements IApplication { jMenu_Help.add(jMenuItem_About); jMenu_Help.add(jSeparator12); - jMenuItem_Help.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/help.svg")); + jMenuItem_Help.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/help.svg")); jMenuItem_Help.setText(bundle.getString("FrmMain.jMenuItem_Help.text")); // NOI18N //jMenuItem_Help.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/help.png"))); jMenuItem_Help.addActionListener(new java.awt.event.ActionListener() { @@ -1829,8 +1829,8 @@ public class FrmMain extends JFrame implements IApplication { this.jComboBox_PageZoom.setSelectedItem(String.valueOf((int) (_mapDocument.getMapLayout().getZoom() * 100)) + "%"); //this._loadedPluginIcon = new ImageIcon(ImageIO.read(this.getClass().getResource("/images/plugin_green.png"))); //this._unloadedPluginIcon = new ImageIcon(ImageIO.read(this.getClass().getResource("/images/plugin_unsel.png"))); - this._loadedPluginIcon = new FlatSVGIcon("org/meteoinfo/desktop/icons/plugin-loaded.svg"); - this._unloadedPluginIcon = new FlatSVGIcon("org/meteoinfo/desktop/icons/plugin.svg"); + this._loadedPluginIcon = new FlatSVGIcon("org/meteoinfo/map/icons/plugin-loaded.svg"); + this._unloadedPluginIcon = new FlatSVGIcon("org/meteoinfo/map/icons/plugin.svg"); this.loadDefaultPojectFile(); //this.loadConfigureFile(); @@ -3871,9 +3871,9 @@ public class FrmMain extends JFrame implements IApplication { } }); } - private org.meteoinfo.legend.LayersLegend _mapDocument; - private org.meteoinfo.layout.MapLayout _mapLayout; - private org.meteoinfo.map.MapView _mapView; + private LayersLegend _mapDocument; + private MapLayout _mapLayout; + private MapView _mapView; private org.meteoinfo.ui.JSplitButton jSplitButton_AddLayer; private javax.swing.JPopupMenu jPopupMenu_AddLayer; private javax.swing.JMenuItem jMenuItem_AddLayer; diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmMeteoData.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmMeteoData.java similarity index 99% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmMeteoData.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmMeteoData.java index 2c396aca..44e5e06f 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmMeteoData.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmMeteoData.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import java.awt.BasicStroke; import java.awt.Color; @@ -44,21 +44,23 @@ import org.meteoinfo.data.GridData; import org.meteoinfo.data.GridDataSetting; import org.meteoinfo.data.StationData; import org.meteoinfo.data.meteodata.*; -import org.meteoinfo.desktop.config.GenericFileFilter; +import org.meteoinfo.map.config.GenericFileFilter; +import org.meteoinfo.geo.legend.FrmLegendSet; +import org.meteoinfo.geo.legend.LegendManage; +import org.meteoinfo.geo.meteodata.*; import org.meteoinfo.data.meteodata.grads.GrADSDataInfo; import org.meteoinfo.data.meteodata.micaps.MICAPS7DataInfo; import org.meteoinfo.data.meteodata.netcdf.NetCDFDataInfo; import org.meteoinfo.common.colors.ColorUtil; import org.meteoinfo.geo.util.GeoMathUtil; import org.meteoinfo.geometry.legend.*; -import org.meteoinfo.legend.*; -import org.meteoinfo.geoprocess.analysis.InterpolationMethods; -import org.meteoinfo.geoprocess.analysis.InterpolationSetting; +import org.meteoinfo.geo.analysis.InterpolationMethods; +import org.meteoinfo.geo.analysis.InterpolationSetting; import org.meteoinfo.image.AnimatedGifEncoder; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layer.RasterLayer; -import org.meteoinfo.layer.VectorLayer; +import org.meteoinfo.geo.layer.LayerTypes; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.layer.RasterLayer; +import org.meteoinfo.geo.layer.VectorLayer; import org.meteoinfo.projection.ProjectionInfo; import org.meteoinfo.geometry.shape.ShapeTypes; @@ -109,7 +111,7 @@ public class FrmMeteoData extends javax.swing.JDialog { _parent = (FrmMain) parent; - this.setIconImages(FlatSVGUtils.createWindowIconImages("/org/meteoinfo/desktop/icons/meteo-data.svg")); + this.setIconImages(FlatSVGUtils.createWindowIconImages("/org/meteoinfo/map/icons/meteo-data.svg")); initComponents(); @@ -558,7 +560,7 @@ public class FrmMeteoData extends javax.swing.JDialog { jToolBar1.add(jSplitButton_OpenData); //jButton_DataInfo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/information.png"))); // NOI18N - jButton_DataInfo.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/information.svg")); + jButton_DataInfo.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/information.svg")); jButton_DataInfo.setToolTipText(bundle.getString("FrmMeteoData.jButton_DataInfo.toolTipText")); // NOI18N jButton_DataInfo.setFocusable(false); jButton_DataInfo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -573,7 +575,7 @@ public class FrmMeteoData extends javax.swing.JDialog { jToolBar1.add(jSeparator1); //jButton_Draw.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_Draw.Image.png"))); // NOI18N - jButton_Draw.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/draw-layer.svg")); + jButton_Draw.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/draw-layer.svg")); jButton_Draw.setToolTipText(bundle.getString("FrmMeteoData.jButton_Draw.toolTipText")); // NOI18N jButton_Draw.setFocusable(false); jButton_Draw.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -616,7 +618,7 @@ public class FrmMeteoData extends javax.swing.JDialog { jToolBar1.add(jSeparator2); //jButton_PreTime.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_PreTime.Image.png"))); // NOI18N - jButton_PreTime.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/left-arrow.svg")); + jButton_PreTime.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/left-arrow.svg")); jButton_PreTime.setToolTipText(bundle.getString("FrmMeteoData.jButton_PreTime.toolTipText")); // NOI18N jButton_PreTime.setFocusable(false); jButton_PreTime.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -630,7 +632,7 @@ public class FrmMeteoData extends javax.swing.JDialog { jToolBar1.add(jButton_PreTime); //jButton_NexTime.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_NextTime.Image.png"))); // NOI18N - jButton_NexTime.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/right-arrow.svg")); + jButton_NexTime.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/right-arrow.svg")); jButton_NexTime.setToolTipText(bundle.getString("FrmMeteoData.jButton_NexTime.toolTipText")); // NOI18N jButton_NexTime.setFocusable(false); jButton_NexTime.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -644,7 +646,7 @@ public class FrmMeteoData extends javax.swing.JDialog { jToolBar1.add(jButton_NexTime); //jButton_Animator.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/animation-1.png"))); // NOI18N - jButton_Animator.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/animator.svg")); + jButton_Animator.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/animator.svg")); jButton_Animator.setToolTipText(bundle.getString("FrmMeteoData.jButton_Animator.toolTipText")); // NOI18N jButton_Animator.setFocusable(false); jButton_Animator.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -658,7 +660,7 @@ public class FrmMeteoData extends javax.swing.JDialog { jToolBar1.add(jButton_Animator); //jButton_CreateAnimatorFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Animation-2.png"))); // NOI18N - jButton_CreateAnimatorFile.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/animator-file.svg")); + jButton_CreateAnimatorFile.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/animator-file.svg")); jButton_CreateAnimatorFile.setToolTipText(bundle.getString("FrmMeteoData.jButton_CreateAnimatorFile.toolTipText")); // NOI18N jButton_CreateAnimatorFile.setFocusable(false); jButton_CreateAnimatorFile.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -673,7 +675,7 @@ public class FrmMeteoData extends javax.swing.JDialog { jToolBar1.add(jSeparator3); //jButton_DrawSetting.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_DrawSetting.Image.png"))); // NOI18N - jButton_DrawSetting.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/legend-setting.svg")); + jButton_DrawSetting.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/legend-setting.svg")); jButton_DrawSetting.setToolTipText(bundle.getString("FrmMeteoData.jButton_DrawSetting.toolTipText")); // NOI18N jButton_DrawSetting.setFocusable(false); jButton_DrawSetting.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -687,7 +689,7 @@ public class FrmMeteoData extends javax.swing.JDialog { jToolBar1.add(jButton_DrawSetting); //jButton_Setting.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Setting-1.png"))); // NOI18N - jButton_Setting.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/tools.svg")); + jButton_Setting.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/tools.svg")); jButton_Setting.setToolTipText(bundle.getString("FrmMeteoData.jButton_Setting.toolTipText")); // NOI18N jButton_Setting.setFocusable(false); jButton_Setting.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -702,7 +704,7 @@ public class FrmMeteoData extends javax.swing.JDialog { jToolBar1.add(jSeparator4); //jButton_SectionPlot.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/chart-5.png"))); // NOI18N - jButton_SectionPlot.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/section-chart.svg")); + jButton_SectionPlot.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/section-chart.svg")); jButton_SectionPlot.setToolTipText(bundle.getString("FrmMeteoData.jButton_SectionPlot.toolTipText")); // NOI18N jButton_SectionPlot.setFocusable(false); jButton_SectionPlot.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -716,7 +718,7 @@ public class FrmMeteoData extends javax.swing.JDialog { jToolBar1.add(jButton_SectionPlot); //jButton_1DPlot.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/chart.png"))); // NOI18N - jButton_1DPlot.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/chart-line-bar.svg")); + jButton_1DPlot.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/chart-line-bar.svg")); jButton_1DPlot.setToolTipText(bundle.getString("FrmMeteoData.jButton_1DPlot.toolTipText")); // NOI18N jButton_1DPlot.setFocusable(false); jButton_1DPlot.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -1399,7 +1401,7 @@ public class FrmMeteoData extends javax.swing.JDialog { @Override protected String doInBackground() throws Exception { //jButton_Animator.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/stop.png"))); - jButton_Animator.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/stop.svg")); + jButton_Animator.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/stop.svg")); _isRunning = true; _useSameLegendScheme = true; _useSameGridInterSet = true; @@ -1408,7 +1410,7 @@ public class FrmMeteoData extends javax.swing.JDialog { _enableAnimation = true; _isRunning = false; //jButton_Animator.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/animation-1.png"))); - jButton_Animator.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/animator.svg")); + jButton_Animator.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/animator.svg")); return ""; } @@ -1437,7 +1439,7 @@ public class FrmMeteoData extends javax.swing.JDialog { _enableAnimation = true; _isRunning = false; //jButton_Animator.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/animation-1.png"))); - jButton_Animator.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/animator.svg")); + jButton_Animator.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/animator.svg")); encoder.finish(); return ""; } diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmOneDim.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmOneDim.form similarity index 87% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmOneDim.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmOneDim.form index 39a0189d..e41b93ec 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmOneDim.form +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmOneDim.form @@ -4,7 +4,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -56,10 +56,10 @@ - + - + @@ -74,10 +74,10 @@ - + - + @@ -90,10 +90,10 @@ - + - + @@ -106,10 +106,10 @@ - + - + @@ -124,10 +124,10 @@ - + - + @@ -140,10 +140,10 @@ - + - + @@ -156,10 +156,10 @@ - + - + @@ -255,7 +255,7 @@ - + @@ -277,7 +277,7 @@ - + @@ -384,7 +384,7 @@ - + @@ -406,7 +406,7 @@ - + @@ -452,7 +452,7 @@ - + @@ -486,7 +486,7 @@ - + @@ -522,7 +522,7 @@ - + @@ -544,7 +544,7 @@ - + diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmOneDim.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmOneDim.java similarity index 98% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmOneDim.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmOneDim.java index 7627bce5..41198ea0 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmOneDim.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmOneDim.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import java.awt.Cursor; import java.awt.event.ActionEvent; @@ -39,13 +39,13 @@ import org.meteoinfo.data.meteodata.Variable; import org.meteoinfo.geometry.legend.*; import org.meteoinfo.ndarray.Dimension; import org.meteoinfo.data.meteodata.hysplit.HYSPLITTrajDataInfo; -import org.meteoinfo.desktop.config.GenericFileFilter; +import org.meteoinfo.map.config.GenericFileFilter; import org.meteoinfo.image.AnimatedGifEncoder; -import org.meteoinfo.layer.LayerDrawType; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layout.LayoutChart; -import org.meteoinfo.layout.MapLayout; -import org.meteoinfo.legend.LegendManage; +import org.meteoinfo.geo.layer.LayerDrawType; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.chart.LayoutChart; +import org.meteoinfo.geo.layout.MapLayout; +import org.meteoinfo.geo.legend.LegendManage; import org.meteoinfo.geometry.shape.ShapeTypes; /** @@ -158,7 +158,7 @@ public class FrmOneDim extends javax.swing.JFrame { jToolBar1.setRollover(true); //jButton_DataInfo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/information.png"))); // NOI18N - jButton_DataInfo.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/information.svg")); + jButton_DataInfo.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/information.svg")); java.util.ResourceBundle bundle1 = java.util.ResourceBundle.getBundle("bundle/Bundle_FrmMeteoData"); // NOI18N jButton_DataInfo.setToolTipText(bundle1.getString("FrmMeteoData.jButton_DataInfo.toolTipText")); // NOI18N jButton_DataInfo.setFocusable(false); @@ -173,7 +173,7 @@ public class FrmOneDim extends javax.swing.JFrame { jToolBar1.add(jSeparator1); //jButton_Draw.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_Draw.Image.png"))); // NOI18N - jButton_Draw.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/draw-layer.svg")); + jButton_Draw.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/draw-layer.svg")); jButton_Draw.setToolTipText(bundle1.getString("FrmMeteoData.jButton_Draw.toolTipText")); // NOI18N jButton_Draw.setFocusable(false); jButton_Draw.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -213,7 +213,7 @@ public class FrmOneDim extends javax.swing.JFrame { jToolBar1.add(jSeparator2); //jButton_PreTime.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_PreTime.Image.png"))); // NOI18N - jButton_PreTime.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/left-arrow.svg")); + jButton_PreTime.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/left-arrow.svg")); jButton_PreTime.setToolTipText(bundle1.getString("FrmMeteoData.jButton_PreTime.toolTipText")); // NOI18N jButton_PreTime.setFocusable(false); jButton_PreTime.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -226,7 +226,7 @@ public class FrmOneDim extends javax.swing.JFrame { jToolBar1.add(jButton_PreTime); //jButton_NexTime.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_NextTime.Image.png"))); // NOI18N - jButton_NexTime.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/right-arrow.svg")); + jButton_NexTime.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/right-arrow.svg")); jButton_NexTime.setToolTipText(bundle1.getString("FrmMeteoData.jButton_NexTime.toolTipText")); // NOI18N jButton_NexTime.setFocusable(false); jButton_NexTime.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -239,7 +239,7 @@ public class FrmOneDim extends javax.swing.JFrame { jToolBar1.add(jButton_NexTime); //jButton_Animator.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/animation-1.png"))); // NOI18N - jButton_Animator.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/animator.svg")); + jButton_Animator.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/animator.svg")); jButton_Animator.setToolTipText(bundle1.getString("FrmMeteoData.jButton_Animator.toolTipText")); // NOI18N jButton_Animator.setFocusable(false); jButton_Animator.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -1060,7 +1060,10 @@ public class FrmOneDim extends javax.swing.JFrame { private void onAddToLayoutClick() { MapLayout mapLayout = mainGUI.getMapDocument().getMapLayout(); - LayoutChart chart = mapLayout.addChart(100, 100); + LayoutChart chart = new LayoutChart(); + chart.setLeft(100); + chart.setTop(100); + mapLayout.addElement(chart); chart.setChart(this._chartPanel.getChart()); mapLayout.paintGraphics(); } diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmOpenData.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmOpenData.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmOpenData.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmOpenData.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmOpenData.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmOpenData.java similarity index 99% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmOpenData.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmOpenData.java index 24d78065..1f559fd8 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmOpenData.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmOpenData.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; /** * diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmOptions.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmOptions.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmOptions.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmOptions.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmOptions.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmOptions.java similarity index 99% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmOptions.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmOptions.java index ae79a7c4..fb27152c 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmOptions.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmOptions.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import com.formdev.flatlaf.FlatDarculaLaf; import com.formdev.flatlaf.FlatDarkLaf; @@ -16,7 +16,7 @@ import javax.swing.JFrame; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; -import org.meteoinfo.desktop.config.Options; +import org.meteoinfo.map.config.Options; /** * diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmOutputMapData.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmOutputMapData.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmOutputMapData.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmOutputMapData.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmOutputMapData.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmOutputMapData.java similarity index 99% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmOutputMapData.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmOutputMapData.java index cc2f8459..1fbc218d 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmOutputMapData.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmOutputMapData.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import java.awt.Cursor; import java.io.BufferedWriter; @@ -24,11 +24,11 @@ import org.meteoinfo.common.MIMath; import org.meteoinfo.common.PointD; import org.meteoinfo.data.GridDataSetting; import org.meteoinfo.data.meteodata.Variable; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.desktop.config.GenericFileFilter; +import org.meteoinfo.geo.layer.LayerTypes; +import org.meteoinfo.geo.layer.VectorLayer; +import org.meteoinfo.map.config.GenericFileFilter; import org.meteoinfo.data.meteodata.grads.GrADSDataInfo; -import org.meteoinfo.geoprocess.GeoComputation; +import org.meteoinfo.geometry.geoprocess.GeoComputation; import org.meteoinfo.geometry.shape.PointShape; import org.meteoinfo.geometry.shape.PolygonShape; import org.meteoinfo.geometry.shape.PolylineShape; diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmPluginManager.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmPluginManager.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmPluginManager.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmPluginManager.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmPluginManager.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmPluginManager.java similarity index 98% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmPluginManager.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmPluginManager.java index d3af8f56..24a68f7b 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmPluginManager.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmPluginManager.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import java.io.File; import java.io.IOException; @@ -14,8 +14,8 @@ import javax.swing.DefaultListModel; import javax.swing.JFrame; import org.meteoinfo.common.util.GlobalUtil; -import org.meteoinfo.desktop.config.Plugin; -import org.meteoinfo.desktop.config.PluginCollection; +import org.meteoinfo.map.config.Plugin; +import org.meteoinfo.map.config.PluginCollection; import org.meteoinfo.ui.CheckBoxListEntry; /** diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmProjection.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmProjection.form similarity index 85% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmProjection.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmProjection.form index b15428d1..7ab55e5b 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmProjection.form +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmProjection.form @@ -76,7 +76,7 @@ - + @@ -100,7 +100,7 @@ - + @@ -192,7 +192,7 @@ - + @@ -201,7 +201,7 @@ - + @@ -210,7 +210,7 @@ - + @@ -219,7 +219,7 @@ - + @@ -228,7 +228,7 @@ - + @@ -237,7 +237,7 @@ - + @@ -246,7 +246,7 @@ - + @@ -257,7 +257,7 @@ - + @@ -267,7 +267,7 @@ - + diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmProjection.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmProjection.java similarity index 99% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmProjection.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmProjection.java index 58b0496d..75a22e3b 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmProjection.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmProjection.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import org.meteoinfo.projection.KnownCoordinateSystems; import org.meteoinfo.projection.ProjectionInfo; diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmSectionPlot.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSectionPlot.form similarity index 99% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmSectionPlot.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSectionPlot.form index 305c119f..e15fcc96 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmSectionPlot.form +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSectionPlot.form @@ -4,7 +4,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -62,7 +62,7 @@ - + @@ -901,13 +901,13 @@ - + - + diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmSectionPlot.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSectionPlot.java similarity index 98% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmSectionPlot.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSectionPlot.java index eed1607e..06824d09 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmSectionPlot.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSectionPlot.java @@ -2,13 +2,16 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import com.formdev.flatlaf.extras.FlatSVGIcon; import org.meteoinfo.common.Extent; import org.meteoinfo.common.PointF; import org.meteoinfo.data.GridData; import org.meteoinfo.data.meteodata.*; +import org.meteoinfo.geo.layout.*; +import org.meteoinfo.geo.legend.LayersLegend; +import org.meteoinfo.geo.meteodata.*; import org.meteoinfo.geometry.legend.LegendScheme; import org.meteoinfo.geometry.legend.LegendType; import org.meteoinfo.geometry.legend.PointBreak; @@ -40,20 +43,16 @@ import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import org.meteoinfo.ndarray.DimensionType; -import org.meteoinfo.layer.FrmLabelSet; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.layout.FrmPageSet; -import org.meteoinfo.layout.LayoutLegend; -import org.meteoinfo.layout.LegendStyles; -import org.meteoinfo.layout.MouseMode; -import org.meteoinfo.legend.FrmLegendSet; -import org.meteoinfo.legend.LayerNode; -import org.meteoinfo.legend.LegendManage; -import org.meteoinfo.legend.MapFrame; -import org.meteoinfo.legend.NodeTypes; -import org.meteoinfo.desktop.config.GenericFileFilter; +import org.meteoinfo.geo.layer.FrmLabelSet; +import org.meteoinfo.geo.layer.LayerTypes; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.layer.VectorLayer; +import org.meteoinfo.geo.legend.FrmLegendSet; +import org.meteoinfo.geo.legend.LayerNode; +import org.meteoinfo.geo.legend.LegendManage; +import org.meteoinfo.geo.legend.MapFrame; +import org.meteoinfo.geo.legend.NodeTypes; +import org.meteoinfo.map.config.GenericFileFilter; import org.meteoinfo.image.AnimatedGifEncoder; import org.meteoinfo.geometry.shape.ShapeTypes; @@ -182,8 +181,8 @@ public class FrmSectionPlot extends javax.swing.JFrame { jList_Stations = new javax.swing.JList(); jComboBox_Variable = new javax.swing.JComboBox(); jPanel_Layers = new javax.swing.JPanel(); - layersLegend1 = new org.meteoinfo.legend.LayersLegend(); - mapLayout1 = new org.meteoinfo.layout.MapLayout(); + layersLegend1 = new LayersLegend(); + mapLayout1 = new MapLayout(); jToolBar2 = new javax.swing.JToolBar(); jLabel_Coordinate = new javax.swing.JLabel(); jLabel_Status = new javax.swing.JLabel(); @@ -201,7 +200,7 @@ public class FrmSectionPlot extends javax.swing.JFrame { jToolBar1.setRollover(true); //jButton_DataInfo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/information.png"))); // NOI18N - jButton_DataInfo.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/information.svg")); + jButton_DataInfo.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/information.svg")); java.util.ResourceBundle bundle1 = java.util.ResourceBundle.getBundle("bundle/Bundle_FrmMeteoData"); // NOI18N jButton_DataInfo.setToolTipText(bundle1.getString("FrmMeteoData.jButton_DataInfo.toolTipText")); // NOI18N jButton_DataInfo.setFocusable(false); @@ -216,7 +215,7 @@ public class FrmSectionPlot extends javax.swing.JFrame { jToolBar1.add(jSeparator1); //jButton_Draw.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/MeteoInfo_1_16x16x8.png"))); // NOI18N - jButton_Draw.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/draw-layer.svg")); + jButton_Draw.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/draw-layer.svg")); jButton_Draw.setToolTipText(bundle1.getString("FrmMeteoData.jButton_Draw.toolTipText")); // NOI18N jButton_Draw.setFocusable(false); jButton_Draw.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -256,7 +255,7 @@ public class FrmSectionPlot extends javax.swing.JFrame { jToolBar1.add(jSeparator2); //jButton_PreTime.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_PreTime.Image.png"))); // NOI18N - jButton_PreTime.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/left-arrow.svg")); + jButton_PreTime.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/left-arrow.svg")); jButton_PreTime.setToolTipText(bundle1.getString("FrmMeteoData.jButton_PreTime.toolTipText")); // NOI18N jButton_PreTime.setFocusable(false); jButton_PreTime.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -269,7 +268,7 @@ public class FrmSectionPlot extends javax.swing.JFrame { jToolBar1.add(jButton_PreTime); //jButton_NexTime.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_NextTime.Image.png"))); // NOI18N - jButton_NexTime.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/right-arrow.svg")); + jButton_NexTime.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/right-arrow.svg")); jButton_NexTime.setToolTipText(bundle1.getString("FrmMeteoData.jButton_NexTime.toolTipText")); // NOI18N jButton_NexTime.setFocusable(false); jButton_NexTime.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -282,7 +281,7 @@ public class FrmSectionPlot extends javax.swing.JFrame { jToolBar1.add(jButton_NexTime); //jButton_Animator.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/animation-1.png"))); // NOI18N - jButton_Animator.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/animator.svg")); + jButton_Animator.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/animator.svg")); jButton_Animator.setFocusable(false); jButton_Animator.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jButton_Animator.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); @@ -294,7 +293,7 @@ public class FrmSectionPlot extends javax.swing.JFrame { jToolBar1.add(jButton_Animator); //jButton_CreateAnimatorFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Animation-2.png"))); // NOI18N - jButton_CreateAnimatorFile.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/animator-file.svg")); + jButton_CreateAnimatorFile.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/animator-file.svg")); jButton_CreateAnimatorFile.setToolTipText(bundle1.getString("FrmMeteoData.jButton_CreateAnimatorFile.toolTipText")); // NOI18N jButton_CreateAnimatorFile.setFocusable(false); jButton_CreateAnimatorFile.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -308,7 +307,7 @@ public class FrmSectionPlot extends javax.swing.JFrame { jToolBar1.add(jSeparator3); //jButton_DrawSetting.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_DrawSetting.Image.png"))); // NOI18N - jButton_DrawSetting.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/legend-setting.svg")); + jButton_DrawSetting.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/legend-setting.svg")); jButton_DrawSetting.setToolTipText(bundle1.getString("FrmMeteoData.jButton_DrawSetting.toolTipText")); // NOI18N jButton_DrawSetting.setFocusable(false); jButton_DrawSetting.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -322,7 +321,7 @@ public class FrmSectionPlot extends javax.swing.JFrame { jToolBar1.add(jSeparator4); //jButton_SelectElement.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Arrow.png"))); // NOI18N - jButton_SelectElement.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/select.svg")); + jButton_SelectElement.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/select.svg")); java.util.ResourceBundle bundle2 = java.util.ResourceBundle.getBundle("bundle/Bundle_FrmMain"); // NOI18N jButton_SelectElement.setToolTipText(bundle2.getString("FrmMain.jButton_SelectElement.toolTipText")); // NOI18N jButton_SelectElement.setFocusable(false); @@ -336,7 +335,7 @@ public class FrmSectionPlot extends javax.swing.JFrame { jToolBar1.add(jButton_SelectElement); //jButton_ZoomIn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_ZoomIn.Image.png"))); // NOI18N - jButton_ZoomIn.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/zoom-in.svg")); + jButton_ZoomIn.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/zoom-in.svg")); jButton_ZoomIn.setToolTipText(bundle2.getString("FrmMain.jButton_ZoomIn.toolTipText")); // NOI18N jButton_ZoomIn.setFocusable(false); jButton_ZoomIn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -349,7 +348,7 @@ public class FrmSectionPlot extends javax.swing.JFrame { jToolBar1.add(jButton_ZoomIn); //jButton_ZoomOut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_ZoomOut.Image.png"))); // NOI18N - jButton_ZoomOut.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/zoom-out.svg")); + jButton_ZoomOut.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/zoom-out.svg")); jButton_ZoomOut.setToolTipText(bundle2.getString("FrmMain.jButton_ZoomOut.toolTipText")); // NOI18N jButton_ZoomOut.setFocusable(false); jButton_ZoomOut.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -362,7 +361,7 @@ public class FrmSectionPlot extends javax.swing.JFrame { jToolBar1.add(jButton_ZoomOut); //jButton_Pan.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_Pan.Image.png"))); // NOI18N - jButton_Pan.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/hand.svg")); + jButton_Pan.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/hand.svg")); jButton_Pan.setToolTipText(bundle2.getString("FrmMain.jButton_Pan.toolTipText")); // NOI18N jButton_Pan.setFocusable(false); jButton_Pan.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -375,7 +374,7 @@ public class FrmSectionPlot extends javax.swing.JFrame { jToolBar1.add(jButton_Pan); //jButton_FullExtent.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_FullExent.Image.png"))); // NOI18N - jButton_FullExtent.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/full-extent.svg")); + jButton_FullExtent.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/full-extent.svg")); jButton_FullExtent.setToolTipText(bundle2.getString("FrmMain.jButton_FullExtent.toolTipText")); // NOI18N jButton_FullExtent.setFocusable(false); jButton_FullExtent.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -388,7 +387,7 @@ public class FrmSectionPlot extends javax.swing.JFrame { jToolBar1.add(jButton_FullExtent); //jButton_ZoomToLayer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_ZoomToLayer.Image.png"))); // NOI18N - jButton_ZoomToLayer.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/zoom-layer.svg")); + jButton_ZoomToLayer.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/zoom-layer.svg")); jButton_ZoomToLayer.setToolTipText(bundle2.getString("FrmMain.jButton_ZoomToLayer.toolTipText")); // NOI18N jButton_ZoomToLayer.setFocusable(false); jButton_ZoomToLayer.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -401,7 +400,7 @@ public class FrmSectionPlot extends javax.swing.JFrame { jToolBar1.add(jButton_ZoomToLayer); //jButton_Identifer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/information.png"))); // NOI18N - jButton_Identifer.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/information.svg")); + jButton_Identifer.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/information.svg")); jButton_Identifer.setToolTipText(bundle2.getString("FrmMain.jButton_Identifer.toolTipText")); // NOI18N jButton_Identifer.setFocusable(false); jButton_Identifer.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -429,7 +428,7 @@ public class FrmSectionPlot extends javax.swing.JFrame { jToolBar1.add(jSeparator6); //jButton_PageSet.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/page_portrait.png"))); // NOI18N - jButton_PageSet.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/page-setting.svg")); + jButton_PageSet.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/page-setting.svg")); jButton_PageSet.setToolTipText(bundle2.getString("FrmMain.jButton_PageSet.toolTipText")); // NOI18N jButton_PageSet.setFocusable(false); jButton_PageSet.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -442,7 +441,7 @@ public class FrmSectionPlot extends javax.swing.JFrame { jToolBar1.add(jButton_PageSet); //jButton_PageZoomIn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_PageZoomIn.Image.png"))); // NOI18N - jButton_PageZoomIn.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/page-zoom-in.svg")); + jButton_PageZoomIn.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/page-zoom-in.svg")); jButton_PageZoomIn.setToolTipText(bundle2.getString("FrmMain.jButton_PageZoomIn.toolTipText")); // NOI18N jButton_PageZoomIn.setFocusable(false); jButton_PageZoomIn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -455,7 +454,7 @@ public class FrmSectionPlot extends javax.swing.JFrame { jToolBar1.add(jButton_PageZoomIn); //jButton_PageZoomOut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_PageZoomOut.Image.png"))); // NOI18N - jButton_PageZoomOut.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/page-zoom-out.svg")); + jButton_PageZoomOut.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/page-zoom-out.svg")); jButton_PageZoomOut.setToolTipText(bundle2.getString("FrmMain.jButton_PageZoomOut.toolTipText")); // NOI18N jButton_PageZoomOut.setFocusable(false); jButton_PageZoomOut.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -468,7 +467,7 @@ public class FrmSectionPlot extends javax.swing.JFrame { jToolBar1.add(jButton_PageZoomOut); //jButton_FitToScreen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ZoomFullMap.png"))); // NOI18N - jButton_FitToScreen.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/page-zoom-window.svg")); + jButton_FitToScreen.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/page-zoom-window.svg")); jButton_FitToScreen.setToolTipText(bundle2.getString("FrmMain.jButton_FitToScreen.toolTipText")); // NOI18N jButton_FitToScreen.setFocusable(false); jButton_FitToScreen.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -493,7 +492,7 @@ public class FrmSectionPlot extends javax.swing.JFrame { jToolBar1.add(jSeparator7); //jButton_SavePicture.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Save_Image.png"))); // NOI18N - jButton_SavePicture.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/figure-output.svg")); + jButton_SavePicture.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/figure-output.svg")); jButton_SavePicture.setToolTipText(bundle2.getString("FrmMain.jButton_SavePicture.toolTipText")); // NOI18N jButton_SavePicture.setFocusable(false); jButton_SavePicture.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -2181,7 +2180,7 @@ public class FrmSectionPlot extends javax.swing.JFrame { private javax.swing.JTabbedPane jTabbedPane1; private javax.swing.JToolBar jToolBar1; private javax.swing.JToolBar jToolBar2; - private org.meteoinfo.legend.LayersLegend layersLegend1; - private org.meteoinfo.layout.MapLayout mapLayout1; + private LayersLegend layersLegend1; + private MapLayout mapLayout1; // End of variables declaration//GEN-END:variables } diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmSelectByAttributes.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSelectByAttributes.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmSelectByAttributes.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSelectByAttributes.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmSelectByAttributes.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSelectByAttributes.java similarity index 99% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmSelectByAttributes.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSelectByAttributes.java index 5b42e03f..00040feb 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmSelectByAttributes.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSelectByAttributes.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import java.awt.Cursor; import java.util.ArrayList; @@ -12,9 +12,9 @@ import javax.swing.DefaultListModel; import javax.swing.ListSelectionModel; import org.meteoinfo.table.DataRow; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layer.VectorLayer; +import org.meteoinfo.geo.layer.LayerTypes; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.layer.VectorLayer; import org.meteoinfo.geometry.shape.Shape; /** diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmSelectByLocation.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSelectByLocation.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmSelectByLocation.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSelectByLocation.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmSelectByLocation.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSelectByLocation.java similarity index 98% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmSelectByLocation.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSelectByLocation.java index ed4aa253..dec12cc6 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmSelectByLocation.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSelectByLocation.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import java.awt.Cursor; import java.util.ArrayList; @@ -10,11 +10,11 @@ import java.util.List; import javax.swing.JOptionPane; import org.meteoinfo.common.PointD; -import org.meteoinfo.geoprocess.GeoComputation; -import org.meteoinfo.geoprocess.SpatialQueryTypes; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layer.VectorLayer; +import org.meteoinfo.geo.analysis.GeoComputation; +import org.meteoinfo.geometry.geoprocess.SpatialQueryTypes; +import org.meteoinfo.geo.layer.LayerTypes; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.layer.VectorLayer; import org.meteoinfo.geometry.shape.PolygonShape; import org.meteoinfo.geometry.shape.Shape; import org.meteoinfo.geometry.shape.ShapeTypes; diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmSymDifference.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSymDifference.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmSymDifference.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSymDifference.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmSymDifference.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSymDifference.java similarity index 98% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmSymDifference.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSymDifference.java index f68263c9..c792d646 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmSymDifference.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSymDifference.java @@ -2,17 +2,17 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import java.awt.Cursor; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; import javax.swing.JOptionPane; -import org.meteoinfo.layer.LayerTypes; -import org.meteoinfo.layer.MapLayer; -import org.meteoinfo.layer.VectorLayer; -import org.meteoinfo.map.MapView; +import org.meteoinfo.geo.layer.LayerTypes; +import org.meteoinfo.geo.layer.MapLayer; +import org.meteoinfo.geo.layer.VectorLayer; +import org.meteoinfo.geo.mapview.MapView; import org.meteoinfo.geometry.shape.PolygonShape; /** diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmTextEditor.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmTextEditor.form similarity index 93% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmTextEditor.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmTextEditor.form index 03f2528b..1b5f0d65 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmTextEditor.form +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmTextEditor.form @@ -16,7 +16,7 @@ - + @@ -30,7 +30,7 @@ - + @@ -44,7 +44,7 @@ - + @@ -66,7 +66,7 @@ - + @@ -98,7 +98,7 @@ - + @@ -112,7 +112,7 @@ - + @@ -126,7 +126,7 @@ - + @@ -145,7 +145,7 @@ - + @@ -229,7 +229,7 @@ - + @@ -243,7 +243,7 @@ - + @@ -257,7 +257,7 @@ - + @@ -271,7 +271,7 @@ - + @@ -290,7 +290,7 @@ - + @@ -304,7 +304,7 @@ - + @@ -320,7 +320,7 @@ - + diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmTextEditor.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmTextEditor.java similarity index 97% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmTextEditor.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmTextEditor.java index 497d5b3a..c7a27538 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmTextEditor.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmTextEditor.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import com.formdev.flatlaf.extras.FlatSVGIcon; import com.formdev.flatlaf.extras.FlatSVGUtils; @@ -25,8 +25,8 @@ import org.meteoinfo.console.JConsole; import org.meteoinfo.console.jython.JIntrospect; import org.meteoinfo.console.editor.MITextEditorPane; import org.meteoinfo.console.jython.PythonInteractiveInterpreter; -import org.meteoinfo.desktop.config.EncodingUtil; -import org.meteoinfo.desktop.config.GenericFileFilter; +import org.meteoinfo.map.config.EncodingUtil; +import org.meteoinfo.map.config.GenericFileFilter; import org.meteoinfo.console.editor.TextEditor; import org.fife.ui.rsyntaxtextarea.SyntaxConstants; import org.fife.ui.rsyntaxtextarea.TextEditorPane; @@ -109,7 +109,7 @@ public class FrmTextEditor extends javax.swing.JFrame { this.initializeConsole(); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - this.setIconImages(FlatSVGUtils.createWindowIconImages("/org/meteoinfo/desktop/icons/jython.svg")); + this.setIconImages(FlatSVGUtils.createWindowIconImages("/org/meteoinfo/map/icons/jython.svg")); this.setScriptLanguage(_scriptLanguage); addNewTextEditor("New file"); this._splitPanelSize = this.jSplitPane1.getBounds().getSize(); @@ -219,7 +219,7 @@ public class FrmTextEditor extends javax.swing.JFrame { jToolBar1.setPreferredSize(new java.awt.Dimension(74, 25)); //jButton_NewFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_NewFile.Image.png"))); // NOI18N - jButton_NewFile.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/file-new.svg")); + jButton_NewFile.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/file-new.svg")); jButton_NewFile.setToolTipText("New File"); jButton_NewFile.setFocusable(false); jButton_NewFile.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -245,7 +245,7 @@ public class FrmTextEditor extends javax.swing.JFrame { jToolBar1.add(jButton_OpenFile); //jButton_CloseFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/closefile.png"))); // NOI18N - jButton_CloseFile.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/file-close-all.svg")); + jButton_CloseFile.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/file-close-all.svg")); jButton_CloseFile.setToolTipText("Close File"); jButton_CloseFile.setFocusable(false); jButton_CloseFile.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -272,7 +272,7 @@ public class FrmTextEditor extends javax.swing.JFrame { jToolBar1.add(jSeparator1); //jButton_Undo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_Undo.Image.png"))); // NOI18N - jButton_Undo.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/undo.svg")); + jButton_Undo.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/undo.svg")); jButton_Undo.setToolTipText("Undo"); jButton_Undo.setFocusable(false); jButton_Undo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -285,7 +285,7 @@ public class FrmTextEditor extends javax.swing.JFrame { jToolBar1.add(jButton_Undo); //jButton_Redo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_Redo.Image.png"))); // NOI18N - jButton_Redo.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/redo.svg")); + jButton_Redo.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/redo.svg")); jButton_Redo.setToolTipText("Redo"); jButton_Redo.setFocusable(false); jButton_Redo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -299,7 +299,7 @@ public class FrmTextEditor extends javax.swing.JFrame { jToolBar1.add(jSeparator2); //jButton_RunScript.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_RunScript.Image.png"))); // NOI18N - jButton_RunScript.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/execute.svg")); + jButton_RunScript.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/execute.svg")); jButton_RunScript.setToolTipText("Run Script"); jButton_RunScript.setFocusable(false); jButton_RunScript.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -330,7 +330,7 @@ public class FrmTextEditor extends javax.swing.JFrame { jMenuItem_NewFile.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK)); //jMenuItem_NewFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_NewFile.Image.png"))); // NOI18N - jMenuItem_NewFile.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/file-new.svg")); + jMenuItem_NewFile.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/file-new.svg")); jMenuItem_NewFile.setText("New"); jMenuItem_NewFile.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -371,7 +371,7 @@ public class FrmTextEditor extends javax.swing.JFrame { jMenuItem_CloseFile.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, java.awt.event.InputEvent.CTRL_MASK)); //jMenuItem_CloseFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/closefile.png"))); // NOI18N - jMenuItem_CloseFile.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/file-close-all.svg")); + jMenuItem_CloseFile.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/file-close-all.svg")); jMenuItem_CloseFile.setText("Close"); jMenuItem_CloseFile.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -396,7 +396,7 @@ public class FrmTextEditor extends javax.swing.JFrame { jMenuItem_Cut.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK)); //jMenuItem_Cut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSMI_EditCut.Image.png"))); // NOI18N - jMenuItem_Cut.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/menu-cut.svg")); + jMenuItem_Cut.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/menu-cut.svg")); jMenuItem_Cut.setText("Cut"); jMenuItem_Cut.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -407,7 +407,7 @@ public class FrmTextEditor extends javax.swing.JFrame { jMenuItem_Copy.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK)); //jMenuItem_Copy.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/menuEditCopy.Image.png"))); // NOI18N - jMenuItem_Copy.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/copy.svg")); + jMenuItem_Copy.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/copy.svg")); jMenuItem_Copy.setText("Copy"); jMenuItem_Copy.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -418,7 +418,7 @@ public class FrmTextEditor extends javax.swing.JFrame { jMenuItem_Paste.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.CTRL_MASK)); //jMenuItem_Paste.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/pasteToolStripButton.Image.png"))); // NOI18N - jMenuItem_Paste.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/menu-paste.svg")); + jMenuItem_Paste.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/menu-paste.svg")); jMenuItem_Paste.setText("Paste"); jMenuItem_Paste.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -433,7 +433,7 @@ public class FrmTextEditor extends javax.swing.JFrame { jMenu_Options.setText("Options"); //jMenuItem_SetFont.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/miSetFont.Image.png"))); // NOI18N - jMenuItem_SetFont.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/font.svg")); + jMenuItem_SetFont.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/font.svg")); jMenuItem_SetFont.setText("Set Font"); jMenuItem_SetFont.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmUVSet.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmUVSet.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmUVSet.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmUVSet.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmUVSet.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmUVSet.java similarity index 99% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmUVSet.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmUVSet.java index a6864ab1..5ef45552 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmUVSet.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmUVSet.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import org.meteoinfo.data.meteodata.DataInfo; import org.meteoinfo.data.meteodata.MeteoDataInfo; diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmViewData.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmViewData.form similarity index 94% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmViewData.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmViewData.form index 852f0133..1cee0689 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmViewData.form +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmViewData.form @@ -11,7 +11,7 @@ - + @@ -39,7 +39,7 @@ - + @@ -55,7 +55,7 @@ - + @@ -69,7 +69,7 @@ - + @@ -80,7 +80,7 @@ - + diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmViewData.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmViewData.java similarity index 98% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmViewData.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmViewData.java index 559ac6da..08ccc6e3 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmViewData.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmViewData.java @@ -2,7 +2,7 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import java.awt.Cursor; import java.awt.image.BufferedImage; @@ -23,7 +23,7 @@ import org.meteoinfo.data.GridData; import org.meteoinfo.data.StationData; import org.meteoinfo.data.XYListDataset; import org.meteoinfo.data.meteodata.ascii.LonLatStationDataInfo; -import org.meteoinfo.desktop.config.GenericFileFilter; +import org.meteoinfo.map.config.GenericFileFilter; import org.meteoinfo.projection.KnownCoordinateSystems; import org.meteoinfo.table.RowHeaderTable; import org.meteoinfo.projection.ProjectionInfo; @@ -217,7 +217,7 @@ public class FrmViewData extends javax.swing.JFrame { jToolBar1.add(jSeparator1); //jButton_ToStation.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TSB_NewPoint.Image.png"))); // NOI18N - jButton_ToStation.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/new-point.svg")); + jButton_ToStation.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/new-point.svg")); jButton_ToStation.setToolTipText("To Station Data"); jButton_ToStation.setFocusable(false); jButton_ToStation.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -230,7 +230,7 @@ public class FrmViewData extends javax.swing.JFrame { jToolBar1.add(jButton_ToStation); //jButton_Stat.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Statictics.png"))); // NOI18N - jButton_Stat.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/statistics.svg")); + jButton_Stat.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/statistics.svg")); jButton_Stat.setToolTipText("Statistics"); jButton_Stat.setFocusable(false); jButton_Stat.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); @@ -238,7 +238,7 @@ public class FrmViewData extends javax.swing.JFrame { jToolBar1.add(jButton_Stat); //jButton_Chart.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/chart.png"))); // NOI18N - jButton_Chart.setIcon(new FlatSVGIcon("org/meteoinfo/desktop/icons/chart-line.svg")); + jButton_Chart.setIcon(new FlatSVGIcon("org/meteoinfo/map/icons/chart-line.svg")); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("bundle/Bundle_FrmMeteoData"); // NOI18N jButton_Chart.setToolTipText(bundle.getString("FrmMeteoData.jButton_1DPlot.toolTipText")); // NOI18N jButton_Chart.setFocusable(false); diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmZoomToExtent.form b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmZoomToExtent.form similarity index 100% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmZoomToExtent.form rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmZoomToExtent.form diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmZoomToExtent.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmZoomToExtent.java similarity index 99% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmZoomToExtent.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmZoomToExtent.java index c3ac1939..48342cc4 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/FrmZoomToExtent.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmZoomToExtent.java @@ -11,10 +11,10 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import org.meteoinfo.common.Extent; -import org.meteoinfo.map.MapView; +import org.meteoinfo.geo.mapview.MapView; import javax.swing.JOptionPane; /** diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/ImageFileChooser.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/ImageFileChooser.java similarity index 94% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/ImageFileChooser.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/ImageFileChooser.java index 40a539b4..2aeda404 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/ImageFileChooser.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/ImageFileChooser.java @@ -1,99 +1,99 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.meteoinfo.desktop.forms; - -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import javax.swing.DefaultComboBoxModel; -import javax.swing.JComboBox; -import javax.swing.JFileChooser; -import javax.swing.JLabel; -import javax.swing.JPanel; -import org.meteoinfo.desktop.config.GenericFileFilter; - -/** - * - * @author Yaqiang Wang - */ -public class ImageFileChooser extends JFileChooser { - - JComboBox dpiCB; - JPanel panel; - - /** - * Constructor - */ - public ImageFileChooser() { - super(); - dpiCB = new JComboBox(); - DefaultComboBoxModel cbm = new DefaultComboBoxModel(); - cbm.addElement("Default"); - cbm.addElement("150"); - cbm.addElement("300"); - cbm.addElement("600"); - cbm.addElement("900"); - cbm.addElement("1200"); - dpiCB.setModel(cbm); - dpiCB.setEditable(true); - panel = new JPanel(new GridBagLayout()); - GridBagConstraints constraints = new GridBagConstraints(); - constraints.anchor = GridBagConstraints.WEST; - constraints.insets = new Insets(5, 10, 0, 0); - constraints.gridx = 0; - constraints.gridy = 0; - panel.add(new JLabel("DPI:"), constraints); - constraints.gridy = 1; - panel.add(dpiCB, constraints); - setAccessory(panel); - //panel.setVisible(false); - - this.addPropertyChangeListener(new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent pce) { - String prop = pce.getPropertyName(); - - //If a file became selected, find out which one. - if (JFileChooser.FILE_FILTER_CHANGED_PROPERTY.equals(prop)) { - GenericFileFilter filter = (GenericFileFilter) pce.getNewValue(); - if (filter != null){ - switch (filter.getFileExtent().toLowerCase()) { - case "png": - case "jpg": - case "bmp": - case "gif": - panel.setVisible(true); - break; - default: - panel.setVisible(false); - break; - } - repaint(); - } - } - } - }); - } - - /** - * Get DPI - * - * @return DPI - */ - public Integer getDPI() { - if (!this.dpiCB.isVisible()) - return null; - - String dpiStr = this.dpiCB.getSelectedItem().toString(); - if (dpiStr.equals("Default")) { - return null; - } else { - return Integer.parseInt(dpiStr); - } - } -} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.meteoinfo.map.forms; + +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import org.meteoinfo.map.config.GenericFileFilter; + +/** + * + * @author Yaqiang Wang + */ +public class ImageFileChooser extends JFileChooser { + + JComboBox dpiCB; + JPanel panel; + + /** + * Constructor + */ + public ImageFileChooser() { + super(); + dpiCB = new JComboBox(); + DefaultComboBoxModel cbm = new DefaultComboBoxModel(); + cbm.addElement("Default"); + cbm.addElement("150"); + cbm.addElement("300"); + cbm.addElement("600"); + cbm.addElement("900"); + cbm.addElement("1200"); + dpiCB.setModel(cbm); + dpiCB.setEditable(true); + panel = new JPanel(new GridBagLayout()); + GridBagConstraints constraints = new GridBagConstraints(); + constraints.anchor = GridBagConstraints.WEST; + constraints.insets = new Insets(5, 10, 0, 0); + constraints.gridx = 0; + constraints.gridy = 0; + panel.add(new JLabel("DPI:"), constraints); + constraints.gridy = 1; + panel.add(dpiCB, constraints); + setAccessory(panel); + //panel.setVisible(false); + + this.addPropertyChangeListener(new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent pce) { + String prop = pce.getPropertyName(); + + //If a file became selected, find out which one. + if (JFileChooser.FILE_FILTER_CHANGED_PROPERTY.equals(prop)) { + GenericFileFilter filter = (GenericFileFilter) pce.getNewValue(); + if (filter != null){ + switch (filter.getFileExtent().toLowerCase()) { + case "png": + case "jpg": + case "bmp": + case "gif": + panel.setVisible(true); + break; + default: + panel.setVisible(false); + break; + } + repaint(); + } + } + } + }); + } + + /** + * Get DPI + * + * @return DPI + */ + public Integer getDPI() { + if (!this.dpiCB.isVisible()) + return null; + + String dpiStr = this.dpiCB.getSelectedItem().toString(); + if (dpiStr.equals("Default")) { + return null; + } else { + return Integer.parseInt(dpiStr); + } + } +} diff --git a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/ShapeFileChooser.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/ShapeFileChooser.java similarity index 98% rename from MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/ShapeFileChooser.java rename to meteoinfo-map/src/main/java/org/meteoinfo/map/forms/ShapeFileChooser.java index 547c2a0e..c21cc7aa 100644 --- a/MeteoInfoMap/src/main/java/org/meteoinfo/desktop/forms/ShapeFileChooser.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/ShapeFileChooser.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package org.meteoinfo.desktop.forms; +package org.meteoinfo.map.forms; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; diff --git a/MeteoInfoMap/src/main/resources/bundle/Bundle_FrmMain.properties b/meteoinfo-map/src/main/resources/bundle/Bundle_FrmMain.properties similarity index 100% rename from MeteoInfoMap/src/main/resources/bundle/Bundle_FrmMain.properties rename to meteoinfo-map/src/main/resources/bundle/Bundle_FrmMain.properties diff --git a/MeteoInfoMap/src/main/resources/bundle/Bundle_FrmMain_zh_CN.properties b/meteoinfo-map/src/main/resources/bundle/Bundle_FrmMain_zh_CN.properties similarity index 100% rename from MeteoInfoMap/src/main/resources/bundle/Bundle_FrmMain_zh_CN.properties rename to meteoinfo-map/src/main/resources/bundle/Bundle_FrmMain_zh_CN.properties diff --git a/MeteoInfoMap/src/main/resources/bundle/Bundle_FrmMeteoData.properties b/meteoinfo-map/src/main/resources/bundle/Bundle_FrmMeteoData.properties similarity index 100% rename from MeteoInfoMap/src/main/resources/bundle/Bundle_FrmMeteoData.properties rename to meteoinfo-map/src/main/resources/bundle/Bundle_FrmMeteoData.properties diff --git a/MeteoInfoMap/src/main/resources/bundle/Bundle_FrmMeteoData_zh_CN.properties b/meteoinfo-map/src/main/resources/bundle/Bundle_FrmMeteoData_zh_CN.properties similarity index 98% rename from MeteoInfoMap/src/main/resources/bundle/Bundle_FrmMeteoData_zh_CN.properties rename to meteoinfo-map/src/main/resources/bundle/Bundle_FrmMeteoData_zh_CN.properties index c1fce32d..f4fde77f 100644 --- a/MeteoInfoMap/src/main/resources/bundle/Bundle_FrmMeteoData_zh_CN.properties +++ b/meteoinfo-map/src/main/resources/bundle/Bundle_FrmMeteoData_zh_CN.properties @@ -1,24 +1,24 @@ - -FrmMeteoData.jButton_RemoveAllData.text=\u79fb\u9664\u5168\u90e8 -FrmMeteoData.jCheckBox_ColorVar.text=\u7740\u8272 -FrmMeteoData.jCheckBox_Smooth.text=\u5e73\u6ed1 -FrmMeteoData.jLabel4.text=\u56fe\u5f62: -FrmMeteoData.jLabel2.text=\u65f6\u6b21: -FrmMeteoData.jLabel3.text=\u9ad8\u5ea6: -FrmMeteoData.jButton_OpenData.toolTipText=\u6253\u5f00\u6570\u636e\u6587\u4ef6 -FrmMeteoData.jButton_DataInfo.toolTipText=\u663e\u793a\u6570\u636e\u4fe1\u606f -FrmMeteoData.jButton_Draw.toolTipText=\u7ed8\u5236\u6570\u636e\u56fe\u5f62 -FrmMeteoData.jButton_ViewData.toolTipText=\u663e\u793a\u6570\u636e -FrmMeteoData.jButton_ClearDraw.toolTipText=\u5220\u9664\u6570\u636e\u56fe\u5f62 -FrmMeteoData.jButton_PreTime.toolTipText=\u4e0a\u4e00\u65f6\u6b21 -FrmMeteoData.jButton_NexTime.toolTipText=\u4e0b\u4e00\u65f6\u6b21 -FrmMeteoData.jButton_Animator.toolTipText=\u52a8\u753b -FrmMeteoData.jButton_CreateAnimatorFile.toolTipText=\u521b\u5efa\u52a8\u753b\u6587\u4ef6 -FrmMeteoData.jButton_DrawSetting.toolTipText=\u56fe\u4f8b\u8bbe\u7f6e -FrmMeteoData.jButton_Setting.toolTipText=\u8bbe\u7f6e -FrmMeteoData.jButton_SectionPlot.toolTipText=\u622a\u9762\u56fe -FrmMeteoData.jButton_1DPlot.toolTipText=\u4e00\u7ef4\u56fe -FrmMeteoData.jLabel_Variable.text=\u53d8\u91cf: -FrmMeteoData.jSplitButton_Stat.toolTipText=\u7edf\u8ba1 -FrmMeteoData.jMenuItem_ArrivalTime.text=\u5230\u8fbe\u65f6\u95f4 + +FrmMeteoData.jButton_RemoveAllData.text=\u79fb\u9664\u5168\u90e8 +FrmMeteoData.jCheckBox_ColorVar.text=\u7740\u8272 +FrmMeteoData.jCheckBox_Smooth.text=\u5e73\u6ed1 +FrmMeteoData.jLabel4.text=\u56fe\u5f62: +FrmMeteoData.jLabel2.text=\u65f6\u6b21: +FrmMeteoData.jLabel3.text=\u9ad8\u5ea6: +FrmMeteoData.jButton_OpenData.toolTipText=\u6253\u5f00\u6570\u636e\u6587\u4ef6 +FrmMeteoData.jButton_DataInfo.toolTipText=\u663e\u793a\u6570\u636e\u4fe1\u606f +FrmMeteoData.jButton_Draw.toolTipText=\u7ed8\u5236\u6570\u636e\u56fe\u5f62 +FrmMeteoData.jButton_ViewData.toolTipText=\u663e\u793a\u6570\u636e +FrmMeteoData.jButton_ClearDraw.toolTipText=\u5220\u9664\u6570\u636e\u56fe\u5f62 +FrmMeteoData.jButton_PreTime.toolTipText=\u4e0a\u4e00\u65f6\u6b21 +FrmMeteoData.jButton_NexTime.toolTipText=\u4e0b\u4e00\u65f6\u6b21 +FrmMeteoData.jButton_Animator.toolTipText=\u52a8\u753b +FrmMeteoData.jButton_CreateAnimatorFile.toolTipText=\u521b\u5efa\u52a8\u753b\u6587\u4ef6 +FrmMeteoData.jButton_DrawSetting.toolTipText=\u56fe\u4f8b\u8bbe\u7f6e +FrmMeteoData.jButton_Setting.toolTipText=\u8bbe\u7f6e +FrmMeteoData.jButton_SectionPlot.toolTipText=\u622a\u9762\u56fe +FrmMeteoData.jButton_1DPlot.toolTipText=\u4e00\u7ef4\u56fe +FrmMeteoData.jLabel_Variable.text=\u53d8\u91cf: +FrmMeteoData.jSplitButton_Stat.toolTipText=\u7edf\u8ba1 +FrmMeteoData.jMenuItem_ArrivalTime.text=\u5230\u8fbe\u65f6\u95f4 FrmMeteoData.jMenu_OpenData.text=\u6253\u5f00 \ No newline at end of file diff --git a/MeteoInfoMap/src/main/resources/bundle/Bundle_FrmOneDim.properties b/meteoinfo-map/src/main/resources/bundle/Bundle_FrmOneDim.properties similarity index 100% rename from MeteoInfoMap/src/main/resources/bundle/Bundle_FrmOneDim.properties rename to meteoinfo-map/src/main/resources/bundle/Bundle_FrmOneDim.properties diff --git a/MeteoInfoMap/src/main/resources/bundle/Bundle_FrmOneDim_zh_CN.properties b/meteoinfo-map/src/main/resources/bundle/Bundle_FrmOneDim_zh_CN.properties similarity index 100% rename from MeteoInfoMap/src/main/resources/bundle/Bundle_FrmOneDim_zh_CN.properties rename to meteoinfo-map/src/main/resources/bundle/Bundle_FrmOneDim_zh_CN.properties diff --git a/MeteoInfoMap/src/main/resources/bundle/Bundle_FrmProjection.properties b/meteoinfo-map/src/main/resources/bundle/Bundle_FrmProjection.properties similarity index 100% rename from MeteoInfoMap/src/main/resources/bundle/Bundle_FrmProjection.properties rename to meteoinfo-map/src/main/resources/bundle/Bundle_FrmProjection.properties diff --git a/MeteoInfoMap/src/main/resources/bundle/Bundle_FrmProjection_zh_CN.properties b/meteoinfo-map/src/main/resources/bundle/Bundle_FrmProjection_zh_CN.properties similarity index 100% rename from MeteoInfoMap/src/main/resources/bundle/Bundle_FrmProjection_zh_CN.properties rename to meteoinfo-map/src/main/resources/bundle/Bundle_FrmProjection_zh_CN.properties diff --git a/MeteoInfoMap/src/main/resources/bundle/Bundle_FrmSectionPlot.properties b/meteoinfo-map/src/main/resources/bundle/Bundle_FrmSectionPlot.properties similarity index 100% rename from MeteoInfoMap/src/main/resources/bundle/Bundle_FrmSectionPlot.properties rename to meteoinfo-map/src/main/resources/bundle/Bundle_FrmSectionPlot.properties diff --git a/MeteoInfoMap/src/main/resources/bundle/Bundle_FrmSectionPlot_zh_CN.properties b/meteoinfo-map/src/main/resources/bundle/Bundle_FrmSectionPlot_zh_CN.properties similarity index 100% rename from MeteoInfoMap/src/main/resources/bundle/Bundle_FrmSectionPlot_zh_CN.properties rename to meteoinfo-map/src/main/resources/bundle/Bundle_FrmSectionPlot_zh_CN.properties diff --git a/MeteoInfoMap/src/main/resources/images/Add_Layer.png b/meteoinfo-map/src/main/resources/images/Add_Layer.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/Add_Layer.png rename to meteoinfo-map/src/main/resources/images/Add_Layer.png diff --git a/MeteoInfoMap/src/main/resources/images/Animation-2.png b/meteoinfo-map/src/main/resources/images/Animation-2.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/Animation-2.png rename to meteoinfo-map/src/main/resources/images/Animation-2.png diff --git a/MeteoInfoMap/src/main/resources/images/Arrow.png b/meteoinfo-map/src/main/resources/images/Arrow.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/Arrow.png rename to meteoinfo-map/src/main/resources/images/Arrow.png diff --git a/MeteoInfoMap/src/main/resources/images/Close_File.png b/meteoinfo-map/src/main/resources/images/Close_File.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/Close_File.png rename to meteoinfo-map/src/main/resources/images/Close_File.png diff --git a/MeteoInfoMap/src/main/resources/images/Disk_1_16x16x8.png b/meteoinfo-map/src/main/resources/images/Disk_1_16x16x8.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/Disk_1_16x16x8.png rename to meteoinfo-map/src/main/resources/images/Disk_1_16x16x8.png diff --git a/MeteoInfoMap/src/main/resources/images/Folder_1_16x16x8.png b/meteoinfo-map/src/main/resources/images/Folder_1_16x16x8.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/Folder_1_16x16x8.png rename to meteoinfo-map/src/main/resources/images/Folder_1_16x16x8.png diff --git a/meteoinfo-map/src/main/resources/images/Layers.png b/meteoinfo-map/src/main/resources/images/Layers.png new file mode 100644 index 0000000000000000000000000000000000000000..23132ccae2b44b1666a059c814e749992cd3f0e4 GIT binary patch literal 131 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`UY;(FAr`&K2@)9xI^5sctFrz1 z@9$u(tZd}EEGP$&qYUYerTK!ZkUVxiDd zLWu3f9z+F?x%JqB(0?Ib%wfmF?t9s!JFxKW?3?+%Z+4#Cxp%BKPynn6u|eo@TF&9X zL^TxVx-o*ug|^2JUwm^|pO(M)eCh3HkJqa$%{ZncE8v(^XA8*oB7mlyk;#R&rpf*B zv4|G$LVp1L0djuDdbP!e*Gs&qeHu2JdG_5)Qc#VURLj$Q7W7VdG8Y{0cy<3CZ|{h<}S4(ni9oh@h4G z(7!1QaR(~a+mp;H37Kj?WngP zAW1v%Y{bn(%D*DnV`pS@|4>JE-7Qrj_xQmYCzrd};Q#Mz9X0$Anw`4G-P4-K7rh;i zfB$*!@!x;%bRuQ{fy8ZNZ2!lwG&}VX3$8Hj3a44T1@}wfK^tl^Hvj+t07*qoM6N<$ Ef|6nKPyhe` literal 0 HcmV?d00001 diff --git a/MeteoInfoMap/src/main/resources/images/MeteoInfo_logo.png b/meteoinfo-map/src/main/resources/images/MeteoInfo_logo.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/MeteoInfo_logo.png rename to meteoinfo-map/src/main/resources/images/MeteoInfo_logo.png diff --git a/MeteoInfoMap/src/main/resources/images/Save_Image.png b/meteoinfo-map/src/main/resources/images/Save_Image.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/Save_Image.png rename to meteoinfo-map/src/main/resources/images/Save_Image.png diff --git a/MeteoInfoMap/src/main/resources/images/Setting-1.png b/meteoinfo-map/src/main/resources/images/Setting-1.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/Setting-1.png rename to meteoinfo-map/src/main/resources/images/Setting-1.png diff --git a/MeteoInfoMap/src/main/resources/images/Setting.png b/meteoinfo-map/src/main/resources/images/Setting.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/Setting.png rename to meteoinfo-map/src/main/resources/images/Setting.png diff --git a/MeteoInfoMap/src/main/resources/images/Statictics.png b/meteoinfo-map/src/main/resources/images/Statictics.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/Statictics.png rename to meteoinfo-map/src/main/resources/images/Statictics.png diff --git a/MeteoInfoMap/src/main/resources/images/TSB_ClearDrawing.Image.png b/meteoinfo-map/src/main/resources/images/TSB_ClearDrawing.Image.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/TSB_ClearDrawing.Image.png rename to meteoinfo-map/src/main/resources/images/TSB_ClearDrawing.Image.png diff --git a/MeteoInfoMap/src/main/resources/images/TSB_Draw.Image.png b/meteoinfo-map/src/main/resources/images/TSB_Draw.Image.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/TSB_Draw.Image.png rename to meteoinfo-map/src/main/resources/images/TSB_Draw.Image.png diff --git a/MeteoInfoMap/src/main/resources/images/TSB_DrawSetting.Image.png b/meteoinfo-map/src/main/resources/images/TSB_DrawSetting.Image.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/TSB_DrawSetting.Image.png rename to meteoinfo-map/src/main/resources/images/TSB_DrawSetting.Image.png diff --git a/MeteoInfoMap/src/main/resources/images/TSB_EditVertices.Image.png b/meteoinfo-map/src/main/resources/images/TSB_EditVertices.Image.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/TSB_EditVertices.Image.png rename to meteoinfo-map/src/main/resources/images/TSB_EditVertices.Image.png diff --git a/meteoinfo-map/src/main/resources/images/TSB_FullExent.Image.png b/meteoinfo-map/src/main/resources/images/TSB_FullExent.Image.png new file mode 100644 index 0000000000000000000000000000000000000000..03470f7ac281fd01efb215ce5776db7deaf478de GIT binary patch literal 666 zcmV;L0%iS)P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGma{vGma{-JZxd#9M0xwBKK~y+Tb(2p> z6k!;~zi}Wd=pwoqc&Us?Bca{3Ll9(tR@=a|aVw&N+Oby2K$OM2MU5jB6r>BCV)wA9 ztr;C+*^|3k)WVi_2=Nq45C%bXsDtwKz3;Tnt~(7p4Bt2J^LyTRW3o}+)^K00R~;M`m%PN!y|O|7v03nDX_jO7`O=Sia&SUic2bTxKF&p_P$ zhNeiK<#xMEL1d<+!B004{~iaeNq3gQI6vPASIl657nX?$&L<{!kX;*rWw1bQ2D& zCo<$>8p1!1O5X?$c3(!r*@tMq5VF67ayV*1{4W_)5r}cCl*)VZ8P&LaPx$2#pyWTG zE)?%mOR{ildq1{Z@~*FGfBT6EcmpYTyW%+Nzf%4;5^;}Aqe4m`RUMhY&elmbwq1KC z=bkQl`wpjqAS5a-76A%vmz@Kr(^UX%ygSwY1>pz7?C85qEdT%j07*qoM6N<$f`;EF A1poj5 literal 0 HcmV?d00001 diff --git a/meteoinfo-map/src/main/resources/images/TSB_LabelSet.Image.png b/meteoinfo-map/src/main/resources/images/TSB_LabelSet.Image.png new file mode 100644 index 0000000000000000000000000000000000000000..94b529d2ded0f0b3df05b34d4dbfc67480029fe9 GIT binary patch literal 191 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85o4Xn6XD`Cp%Cu#M8ww#KJ#0L1Nnj`wQtul6o9|{Qqyyd{H9S zyvuEZ_5@z%GEpCyn+!bB8zmVob?ERJF}O0^b=$RrVY&H*zdjl~32cJ0%ojc!m^H1_ fmsz1yS&o6BaP4l7p!p1*u6{1-oD!MyF<4;FGr9A;e%s z`$Ut|H=?*SF8V93?R&ICrK9%6?>Y8DWqD_kG*yGk-ga=9Dy%vGZ+Xa_6Iw#HhAumj z)1DU;Y!LEfvHNYETk?8~qgByb70D}tW#%F0I)2z~PrkfgaX()}^d?T0!-eUJG0Ky6 icbsET+}ZtNn@#p}zc~!27eoS`#Ng@b=d#Wzp$PyQcUFY} literal 0 HcmV?d00001 diff --git a/MeteoInfoMap/src/main/resources/images/TSB_PageZoomIn.Image.png b/meteoinfo-map/src/main/resources/images/TSB_PageZoomIn.Image.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/TSB_PageZoomIn.Image.png rename to meteoinfo-map/src/main/resources/images/TSB_PageZoomIn.Image.png diff --git a/MeteoInfoMap/src/main/resources/images/TSB_PageZoomOut.Image.png b/meteoinfo-map/src/main/resources/images/TSB_PageZoomOut.Image.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/TSB_PageZoomOut.Image.png rename to meteoinfo-map/src/main/resources/images/TSB_PageZoomOut.Image.png diff --git a/meteoinfo-map/src/main/resources/images/TSB_Pan.Image.png b/meteoinfo-map/src/main/resources/images/TSB_Pan.Image.png new file mode 100644 index 0000000000000000000000000000000000000000..86168cd42090314d732360bd5958f5c1da972ed7 GIT binary patch literal 389 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85o4Xn6XD`Cp%Dsl&6bhh=qS{@NL1v3Ovc`Wl78RE+kgZfo~c7qFG-t%=UIu`2MYT?-dD!_=K-_I$!lM_9>LQ zFjVGq@ij29ZfM+_ar;?uV{w_%={~M@r4^5~6lQTRiMTa`JA(P@wizexv@$iw^Gvw$ z?#xA}P4Vp-6SAy!G3(q~*Uh-Rx-hsPq(X3Uf?Yz={wM!hHd#M*7H#d}tV!7ymmL!M g>HMy{4&1+(*UPaBZ~Ej~2n;#~Pgg&ebxsLQ0M~|^!2kdN literal 0 HcmV?d00001 diff --git a/MeteoInfoMap/src/main/resources/images/TSB_PreTime.Image.png b/meteoinfo-map/src/main/resources/images/TSB_PreTime.Image.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/TSB_PreTime.Image.png rename to meteoinfo-map/src/main/resources/images/TSB_PreTime.Image.png diff --git a/MeteoInfoMap/src/main/resources/images/TSB_Redo.Image.png b/meteoinfo-map/src/main/resources/images/TSB_Redo.Image.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/TSB_Redo.Image.png rename to meteoinfo-map/src/main/resources/images/TSB_Redo.Image.png diff --git a/MeteoInfoMap/src/main/resources/images/TSB_RemoveDataLayes.Image.png b/meteoinfo-map/src/main/resources/images/TSB_RemoveDataLayes.Image.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/TSB_RemoveDataLayes.Image.png rename to meteoinfo-map/src/main/resources/images/TSB_RemoveDataLayes.Image.png diff --git a/MeteoInfoMap/src/main/resources/images/TSB_RunScript.Image.png b/meteoinfo-map/src/main/resources/images/TSB_RunScript.Image.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/TSB_RunScript.Image.png rename to meteoinfo-map/src/main/resources/images/TSB_RunScript.Image.png diff --git a/MeteoInfoMap/src/main/resources/images/TSB_SelectFeatures.Image.png b/meteoinfo-map/src/main/resources/images/TSB_SelectFeatures.Image.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/TSB_SelectFeatures.Image.png rename to meteoinfo-map/src/main/resources/images/TSB_SelectFeatures.Image.png diff --git a/MeteoInfoMap/src/main/resources/images/TSB_Setting.Image.png b/meteoinfo-map/src/main/resources/images/TSB_Setting.Image.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/TSB_Setting.Image.png rename to meteoinfo-map/src/main/resources/images/TSB_Setting.Image.png diff --git a/MeteoInfoMap/src/main/resources/images/TSB_Undo.Image.png b/meteoinfo-map/src/main/resources/images/TSB_Undo.Image.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/TSB_Undo.Image.png rename to meteoinfo-map/src/main/resources/images/TSB_Undo.Image.png diff --git a/MeteoInfoMap/src/main/resources/images/TSB_ViewData.Image.png b/meteoinfo-map/src/main/resources/images/TSB_ViewData.Image.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/TSB_ViewData.Image.png rename to meteoinfo-map/src/main/resources/images/TSB_ViewData.Image.png diff --git a/meteoinfo-map/src/main/resources/images/TSB_ZoomIn.Image.png b/meteoinfo-map/src/main/resources/images/TSB_ZoomIn.Image.png new file mode 100644 index 0000000000000000000000000000000000000000..b64d9cb6e13b9c22c281ba987e0b17a119089068 GIT binary patch literal 408 zcmV;J0cZY+P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGma{vGma{-JZxd#9M0WC>HK~y+TV_<-S z7{BxX!#yveV2~J09xn~jxOL~#|EJ&n`+xQG-~SJO{r!LY+n@hiw!8!zh*vYnmbDvR z{y*{tqB+QKJ{Uj!gD?cIOF%ZPx$*b^xzGPG3;-E&5UI2Lm<^qt-APjOHUIRb@v})Z;utIbLKmogD`{Vxv zqZ4EU$PkcoVSx#GP literal 0 HcmV?d00001 diff --git a/meteoinfo-map/src/main/resources/images/TSB_ZoomOut.Image.png b/meteoinfo-map/src/main/resources/images/TSB_ZoomOut.Image.png new file mode 100644 index 0000000000000000000000000000000000000000..425c7d4709c2d9412c9e3160e5c378273b36330c GIT binary patch literal 399 zcmV;A0dW3_P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGma{vGma{-JZxd#9M0VGL8K~y+TV_<-S z7{BxX!#yveV2~J09xn~jxOL~#|EJ&n`+xQG-~V@i{`-IX+n@hiw!8!zh*vYnmbDvR z{y*{tq8Vnu(?5UVhTwGx$c8mH{{BDr8PfoeAxED6#_tM{0ec?({vRE-4l4$^2(LFl zlA9j>!)X90TnHKf^8&~l$X)^24ssn{13&?^YTZk)LYM(CLqGw$W&7j*1fvsV1IQ4N zbCF%JdflV{6-B51@1K+L|K&7({LzV?h(LUh%`>uW|NpyH_y70f=KoKpi4vEvkQ2@V zN8bOhXNv#-|8_RmkSCJ}xCC3OgB$XEGT4x3GsMYr$;;_tV3&NmSn&VOJbUsCxz;27 tfBoFa|4Z_wlWqXWdm!(Str=VR002VGS$s?16374m002ovPDHLkV1mBWva0|9 literal 0 HcmV?d00001 diff --git a/MeteoInfoMap/src/main/resources/images/TSB_ZoomToExtent.Image.png b/meteoinfo-map/src/main/resources/images/TSB_ZoomToExtent.Image.png similarity index 100% rename from MeteoInfoMap/src/main/resources/images/TSB_ZoomToExtent.Image.png rename to meteoinfo-map/src/main/resources/images/TSB_ZoomToExtent.Image.png diff --git a/meteoinfo-map/src/main/resources/images/TSB_ZoomToLayer.Image.png b/meteoinfo-map/src/main/resources/images/TSB_ZoomToLayer.Image.png new file mode 100644 index 0000000000000000000000000000000000000000..fa3fd13b4baa6ea6e15871a9188170ac096cfdf8 GIT binary patch literal 280 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85o4Xn6XD`Cp%DZt*47)h=u>w$-Z1I20X2MBl}+pzLI>#bxbTa+xR{*drJBkaB@&yG*NU#SiT~?1(Qui@lUWL4%6_x`rKZm> zS$F&I*KbUj3#ZHWD7X=^bGB~tch!hua^59GA@!UDv z`#+-qlgr#RL$}55t_%qR#mBe)QZZSw#YZD7OFunx>Ur56e41M;ST5Bn_ggnM%T798 VaOX`YpE1zk44$rjF6*2UngD{3V?Y1^ literal 0 HcmV?d00001 diff --git a/meteoinfo-map/src/main/resources/images/TSMI_AttriData.Image.png b/meteoinfo-map/src/main/resources/images/TSMI_AttriData.Image.png new file mode 100644 index 0000000000000000000000000000000000000000..caecf9204a2a980167c173cff5d054f9919a45df GIT binary patch literal 594 zcmV-Y0G$M^sT||XqUFsI3sxFPBsI6A3YP+h|{aUxq zjOsfMzQP z-PAc6EN9S;pP+g)2$k^=6+?R{@85-@cYBHUGJwH;DI}7A@fLmS-ndBtI_EA}bN`3kxfi7e|GK(j;6kj#wHEq@ncN#xXfML_-JDdN|67}K=R`E27~2Ro-Re5!JZ0JZ4|(Zn6b zy*wtC<(l&G%mH&j9GHkUgHe2}a*BY;;R8gjZb6G_Os@#C9aw+!WJK{RQ9#aj$q359 zJqECnM%paZtY3iT7cUb9eAY-tQ1or#k^pS0k2lW+aDfd(i^Cqn zENdfeJiB+ZTLMnSKV84J)T-9zc=G(1EDzLX93c9m0%wpq7-d6x!-Ede%F`b{>)O*I<0BhX1yZHXX{Mu}7jwgR- zQ%@3@${EcY@`iZ_-Vs&nM3w4V^Y+6+GLI88ZoZ%vO&OuV~Br_3}>NGFTMP%cXj!D{nbuhp=km(d4oGW(> zpE#n5CrPK`T0O>Dft=qqWLrmr0heZkG)*%hcQ%5L98uzlQ%|KD^Wl|o z^3`7?X;jW#tHpdU58eF%KkpoLWVQid0MG8->>{m5y|xcsROG|~sus8y2i~a$E-2&o z-}ZU*_(hu#R(|=madu2^M)UT=MVYP2`Q;=@TRwJ-@}eW>w`Fc?XR~?koc{xV6W$x3 S91.8 + + + boundless + boundlessgeo + http://repo.boundlessgeo.com/main/ + + + ${project.groupId} diff --git a/meteoinfo-ui/src/main/java/org/meteoinfo/ui/plugin/IApplication.java b/meteoinfo-ui/src/main/java/org/meteoinfo/ui/plugin/IApplication.java new file mode 100644 index 00000000..fcfb55d7 --- /dev/null +++ b/meteoinfo-ui/src/main/java/org/meteoinfo/ui/plugin/IApplication.java @@ -0,0 +1,72 @@ + /* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.ui.plugin; + + import javax.swing.*; + + /** + * + * @author yaqiang + */ + public interface IApplication { + + /** + * Get main menu bar object + * @return Main menu bar object + */ + public JMenuBar getMainMenuBar(); + + /** + * Get plugin menu + * @return Plugin menu + */ + public JMenu getPluginMenu(); + + /** + * Get tool bar panel + * @return Tool bar panel + */ + public JPanel getToolBarPanel(); + + /** + * Get current tool + * @return Current tool + */ + public AbstractButton getCurrentTool(); + + /** + * Set current tool + * @param value Current tool + */ + public void setCurrentTool(AbstractButton value); + + /** + * Get progress bar + * @return The main progress bar + */ + public JProgressBar getProgressBar(); + + /** + * Get progress bar label + * @return The progress bar label + */ + public JLabel getProgressBarLabel(); + + /** + * Open project file + * @param fileName The project file name + */ + public void openProjectFile(String fileName); + + } diff --git a/meteoinfo-ui/src/main/java/org/meteoinfo/ui/plugin/IPlugin.java b/meteoinfo-ui/src/main/java/org/meteoinfo/ui/plugin/IPlugin.java new file mode 100644 index 00000000..ca5703da --- /dev/null +++ b/meteoinfo-ui/src/main/java/org/meteoinfo/ui/plugin/IPlugin.java @@ -0,0 +1,90 @@ +/* Copyright 2012 Yaqiang Wang, + * yaqiang.wang@gmail.com + * + * 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 + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + */ +package org.meteoinfo.ui.plugin; + +/** + * + * @author yaqiang + */ +public interface IPlugin { + /** + * Get application + * @return Application + */ + public IApplication getApplication(); + + /** + * Set application + * @param app Application + */ + public void setApplication(IApplication app); + + /** + * Get plugin name + * @return Plugin name + */ + public String getName(); + + /** + * Set plugin name + * @param value Plugin name + */ + public void setName(String value); + + /** + * Get plugin author + * @return Plugin author + */ + public String getAuthor(); + + /** + * Set plugin author + * @param value Plugin author + */ + public void setAuthor(String value); + + /** + * Get plugin version + * @return Plugin version + */ + public String getVersion(); + + /** + * Set plugin version + * @param value Plugin version + */ + public void setVersion(String value); + + /** + * Get plugin description + * @return Plugin description + */ + public String getDescription(); + + /** + * Set plugin description + * @param value Description + */ + public void setDescription(String value); + + /** + * Plugin load + */ + public void load(); + + /** + * Plugin unload + */ + public void unload(); +} diff --git a/meteoinfo-ui/src/main/java/org/meteoinfo/ui/plugin/PluginBase.java b/meteoinfo-ui/src/main/java/org/meteoinfo/ui/plugin/PluginBase.java new file mode 100644 index 00000000..414c0bff --- /dev/null +++ b/meteoinfo-ui/src/main/java/org/meteoinfo/ui/plugin/PluginBase.java @@ -0,0 +1,77 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.meteoinfo.ui.plugin; + +/** + * + * @author yaqiang + */ +public abstract class PluginBase implements IPlugin { + private IApplication _application = null; + private String _name; + private String _author; + private String _version; + private String _description; + + @Override + public IApplication getApplication() { + return this._application; + } + + @Override + public void setApplication(IApplication app) { + this._application = app; + } + + @Override + public String getName() { + return this._name; + } + + @Override + public void setName(String value) { + this._name = value; + } + + @Override + public String getAuthor() { + return this._author; + } + + @Override + public void setAuthor(String value) { + this._author = value; + } + + @Override + public String getVersion() { + return this._version; + } + + @Override + public void setVersion(String value) { + this._version = value; + } + + @Override + public String getDescription() { + return this._description; + } + + @Override + public void setDescription(String value) { + this._description = value; + } + + @Override + public void load() { + + } + + @Override + public void unload() { + + } +} diff --git a/meteoinfo-common/src/main/java/org/meteoinfo/common/util/FontUtil.java b/meteoinfo-ui/src/main/java/org/meteoinfo/ui/util/FontUtil.java similarity index 91% rename from meteoinfo-common/src/main/java/org/meteoinfo/common/util/FontUtil.java rename to meteoinfo-ui/src/main/java/org/meteoinfo/ui/util/FontUtil.java index cbe40969..a783a925 100644 --- a/meteoinfo-common/src/main/java/org/meteoinfo/common/util/FontUtil.java +++ b/meteoinfo-ui/src/main/java/org/meteoinfo/ui/util/FontUtil.java @@ -11,18 +11,18 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ -package org.meteoinfo.common.util; +package org.meteoinfo.ui.util; -import java.awt.Font; -import java.awt.FontFormatException; -import java.awt.GraphicsEnvironment; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; + import org.meteoinfo.common.util.GlobalUtil; + + import java.awt.*; + import java.io.File; + import java.io.IOException; + import java.io.InputStream; + import java.util.ArrayList; + import java.util.List; + import java.util.logging.Level; + import java.util.logging.Logger; //import org.meteoinfo.drawing.Draw; //import org.meteoinfo.legend.MapFrame; diff --git a/meteoinfo-ui/src/main/resources/fonts/WeatherSymbol.ttf b/meteoinfo-ui/src/main/resources/fonts/WeatherSymbol.ttf new file mode 100644 index 0000000000000000000000000000000000000000..38ae0382c7523a0be2844de5e9a91c04d02f5b02 GIT binary patch literal 39364 zcmeFa30PD|x-eW-XX&PC8fc)K9h#;&b~vbH*7-NhvW--PX<2a0Cj1qO6M6(-X9EI-V|JG?hG|rv-XYT)h&-XkR zE$W;)Rd2mpy;b$r0>TI(PxLrq(1`mVu*AKY*0Bg7JPJ~aC)Z7y{iny0zl03$BgFlA z>ZJPFH*Z2t^!z^fE}uH1vHFDUjXxly*@e*bk87q(s=E5js=vcG`aQk|61>mJN5b<} z2+=il^A%iWI<_w zg;IJ480@D&1&8F^TFwfuA?}ztj;e_o%JyeNXd@zjC_oGP1`=}eA|p{MitHm?w>TbK zWyyFaAn@YZf6yF!KPtol9Qhp@#?3~NtQ?v68Z?&42E1QH!Lk>SQnm=fawKP7L_XXL zi03LGPC@=MAEaRZf>^Q;#WH_F(NH#pIgOOePv`(&g%EQQRlxU1;1nxMLGT#`Lp>_) zeh7a8IP(zCevH)gI|QYN2`M2~L5TENh(bL8K5$bhdlbp#FC&F~9|X_^npeID^1X=E zfYW~V0BR@qqx-pGXgrBT9c&rmA&-K_WFDFhX^${9Xgaq5naMu%3i~4Dn}LcUuH?@m z4GrWQlu0U35_1wc_{GSdTtqAn^^j1+LOF_Gpj0p5$0eW#m;}^55M&nAP6IQ;9mtC) zYG{x}BVG#oAnp$oH-0rz(BJ{I@zo#?ci{Qzn<6|z3^+(ZdLQ^s;JXvjA(ryc^!|KO zOv~}IJ!r1%BAUksqD8VF&^+!NG+TB7waeA0jr$1I$Ua2Hkp76Q0fl|F&xVTm)2M>8 z124v)+1y<87=IDq3`2`KGn&bJqEa#qO(09W*}DvAq~9d|4$+AL-58`DXoj|dWMTdCruFyh9rs%|E_@bzgWi&X zK7x;f@F@iDmd;6a)IeP&{q+G1S~sO#!X0R%-}rv|Y2QP?4dQpjO)rJRSGr;F&_i?3 z{|uC8H$weO-8`0LQ~}SB#;%0`__Ooe-&1|fIKJQ{XgJ4 zJP+jKQr-Ebvi)sFHW~6kUMUa2lgdE80e(rmf^=GsB<~9lQ}`4vO`~n;Hy}eA9*1-q z({BKS!lbxJG2Fe30scuN8WvMJF-)JmLg}jeLI^>aXpydE2^A&_# z_};J6cgBiBp)EN%1sbzA7xxX!Z71KrhCo9EhA#%tRrpl_EC<}35iL`DXC-9 z(lau%vUA4fj?23*|NesUg%1?{ruerd50*YuHlciC#UxZYxoS%F)S7A2YiHEWoHcvS z-1>R*A8uIC_(;>E&5yM_-ulGCC)=KCf4bwDMbCCVw|L3YWy@ErT(x@5^J`yNw|>Km z8(-S=^5$2%ez)a6w*Dux?f2XNu;Y(AU)}ZE?$`IcvG>h=Z|#5kz&r20_x`~T4t;p| zqaz<5{p8r6(D6Ta|K-GAPkwspv(smKK0k|Cb`OyJSM)eAtQb9peQ_9$z!n^fQ*jy| zj~~Dj@Fd)TTktY`lN=(4Ne}ZF^9=JW^Aht3t7PwI%h-wR((tzMpCSVy!y}_2VrEW_UiQ=QYqtsCWQNd9WQN}1! zR8G{Ss404)_tEPN$UqEAgO9=A5NHTBL>ulkj5H(~W*8nfJZX5^@T_6E;U&X1!%o9q z!#>0Nh9ib!hEs+wV-jOhW71+OVkXB_$JAaXm$^Oy^D%@X(MGJs;W!eHz;SpCPRE6~ z2$$nZya4FxB_9A?p8{P^0$tBBFSD3cvE$itc1if-;a4L4BDIl`5?yhTjzPL!{smnR z>6Q%A6#KV{W8AH_Tig1 zZ-QmM>4E?~*UcLcV19J-X9zz+@V^Otl<19+bEE6B>j&5OuJ2rLy7s!>aP4tDePQi| z;ci7g*LH5@`Jc``dH$R8U!Q9@5AEgrljnTS3+IE+2cDgNw(&eZcjDaUbIU$o_4%gH z7a{a{7cF#_9Q+hgbn@6q=7oN=A``pm^M ze?N2n%;#tReCDGw2hZ$3^VXT&2%Y);nODv{es- zFQX?>8<><;=u7kzdJZi@>(PIp%`k6%24l1kEk~EpkEj!^Mo*)6(HZmu+JLsApU@TX z4QxW&(1+*)^m|l^CZi>&3Vnp8phM^|`UD+8AETq_BC1Bm(J}NVv>i=F-=n4IFX+#x z8`Yq%&^M?9O-IvEEviE^&`h)u%|dg~Y%~|uqxonadKfjJOK1Ul1T~^2)QlcQucMbx z3wjK!LM!?jeT&|}1T&b$9OkhM^&uygV-Kvrp2&qnti)beg>Is2=pX1hI)Toi^XLy~ z2fBfJ(cjPov=>jq({U}Hf&PxZz;$44&Z1N3Gjtk#j!vQ;^hdOlL=ioD4edtnk!bWP z+68`vC(t{n9sNx1LC>S_fFrMB;HtsJx&zJGrWJESo_Gfvryi&eKzE6JHBhjPU zV~NKukH30cQ3NXz6*Y=AiamvgZ!Jg?`x_IX`W#i%M(JG~X& z^SrnD5TAQ}=KAdM4flOq&8j2S#p);2@A~=pRr`J5Khl3|02@#p@V@3A&7+#XYD2a2 zw3h?72Ju08L0f}0!DYc~g8vf2hh&8;2-y|#WoTe%a%gGj?9it}H-zpA{d4H0&}(7J zu+*@5VNZvx4cig+e%N2az7BJStHXzdSA>5YkrA;j;?syPBiYEOBL5cY)CKBh>-K=% z>C*e_i}aiI??uvXyJ8(~JvUN4vT)>rkzd+I+N%He-~V#pe>w1fh69MuaV-b`V6-bk zNaw5bHNYk18~a*)<0D841HY_xo6N%4 zgcunw@D?0%qcGQI%iXrEaMt*o+%fSpraT;$mQtm+Pi^Z+4)-fuYT@=&FYJqD5BKD~ zAEHicv?v@q^Fs3s9uG{js11H!3!Z+Kody`B!-(u6H=OYY?7Wc{MF1Lvi(%AumW#K? zYk46?P;>EqL|}0Y)UL6|bHjZ^r*q3TCnkLv@&j)?zj@1nLOE7k-?~*4o$TA5`}eHb zvUxw@#jAc=4BlrSm2-=h967{l_lVbgRM2Cw3Wez08bA&oCR$3j>86wE;Z7i!joY%V!Ur@ebfo0TO zv^~Z^<479I)SR7VVhqs%ydm0GZD6$!3u+R^yZY2YxCU3p`HBtVavy>_aB7l5Y!lmf z9~taJf-DDXvxHEL`H_FK!oi`zX1s2}W_5_+vQP->Wo>W--M7lXG(YMez}( zRf#JOs>!z1EW!Km5*s$CEwCorcw$K$L;Tfp!x=wVzgqv0&oIAx4E| zR*%^0>+-Y%*m>|}QKk{$Q+smSgRCQAu`i^;8W1wsM7)M!of}~eU;DdwR?6w7d0XiFy zVDpg~uXoGL?B>qSzVDV&XBSe!iid;UBIWahc8O?SU4MQW`;a~OGqU=6H`zyHc1tJx z^nJe!eyF8^DZI?qUytYQrIiCE-8Bx>iILAuktqV5SHSWU(RgEyk$GV9l}jKdt!yb? zdqgR!$VTqC%j7z#_T+cs_Evm_Y?kPP`8#JN+rWl^uMqPAATS$Ri3+?nH zcUJ5X!6xk#k3e13UmbCsHhpr$$9(h%@mczoFgqGKhsiM*AOe%om^3VUk4p= z7MAC{R94vB_|Epmo*J-zB_HEFY+AlEZ(-xx+kZF;ev9Hya0bPk+ENy=Oe4rr>i-NL zEN8&`@tb0%n1y$V8(`vJ!2(CV#KFA>*#qall*+{3>?J9ni)yJS)W?D0S5s1;<=f*K zA;zEwGeNXqDePbeh@U;a#u}1o4lq~7r5FXPDJ)j2*5Sg~dY!*Y&W_2em@5P*E;CRuNF>%bjM&%6bpVa~WHA3cu#CF*aN=27B9d@`^gm zh|vW0>&Nu-#1rcRm@09zBw%On z5&6;6PkR}b*LZ4IF2g$RBGnm?^P8T|zj-n7xLs&(SB5^->EuZ&7;^V`jW7=2fd+cj z2qb`2`X@5i1$bgw^#C5fPf3?8S(2NXF(8C7Y)bArtXq8iu;M6g5MPmh`6ZshsblIu z2)gE$5H$#ao9!3XBGxHfN5}$&^Q?lgkuEoHz~lqfZd_!bjg)3Odc2KluuD1^v{I@K zwiFV98N1je|KbZ=a7Z0 zKryb>DUS5$M06-CJb*Q0&xIAn)^_q^F1Jy;`Rw+Tyu607$ve%-%gXZwo^4&+9pMPe zG8AM+ml?*T+0Xi~?3nnMTjCy2l41$en+!hHsoZ(VdE&6;J%&oq~I|Z$ThsKi2 z?Eqc%LP=;0aMT*0=X8Qq3q819$AI*qUxEHbdlz-E2FR!?+@T4~1)dkJ_)9-_qMEJq z7Iz%!nqF#@C-mU3cCn0Tm)k?+y7ryj@hh5&znfIt)nho(V{~=bMMMKJq_xc0(n5~q zGR168PPw))h``9Y%S@4ga6UgA!ms6@DpB1MEmQDX^EwB@Yf#95>3 z#1M+wnMyW0yIkd2okMmh7S1^yb{~+FSe}xx)spyJX}*E=d-w7d@5awhwI>;~ick3_ zmD|B&!3YJ~rJ39HKPey1$g-|Vd_m1t_>x&F@zr-WgM1W@vpAw%EG62NHjq!-&hAmG zB>8M{%jd+baJ^eTLUW6&kjke3$EZ*;|rQf{|y2K6D8B?e8~rlNf4YT z9Ih79N<&g<(I|4=q2Kzt#^I7PZDteM?mA^DF}pU0dF^;BjFhEmcI^yLB+!)saLGn? zbKMkYY^Sx*p|0B+`f6KS8j(sFcjum>%k5w0CP3;%CtwmHBT7YDcRj)a%k-R^OzrY z1i;Ky?5#966tkE50^K3KG&V@>Njz2NX6yE#pzYjo@wC`=9Oes0@g6eu;*q{m=)5jM zCw8f_^7QgI@)tH$?kTy_jrF+fILvCKaW_ZjaeOz7q22wXH|3|D&LE*f#x(8^3R2?Q zAtxoIfaq@6`NOWWM7MbHVlJ({y?6iO#bje=C)w2APG!S^9w3vNfMn&eVcV1zVwm3uN zu}#D^ z(l6jM3NrU4@wl^^G;VZWWOBATRq}ji=pPxY^V$|t$>oQLavf=1?D}r0>-!~3h2hA01^v+4<0#VBDeA7_Cgq5uDfv+Mb@xExB=VNw-tzr#_eE2*^ zfq-*;Ev(+SY^OmX#1_K5vkRNLSz-CB?swZL`cCzip!<;=|Bb76*XMV84Y$4hZ8-(6 z$VtdI;IS(6LFrYV>wdLx(_>cbFest6kv3ZwHg>yWg%vwt<=t8sJBlVytsD;x=1s0l zs*BEmZi9b&-M7<9YA9`LMJ}Z+TV+|k^49BEAB(eg6)OO4xemZB&)32gQBswHwIJ3W zPwRGNxRJ3HNXVGFm6SJ1!@xUiAED!c4#eW6(0(ZI0ly&_fkRiC0=Z@Ji??qo*q{~# zZ!yGbPAJ1#=$o9x8mxiGUmw${T{@L3*3sps#;#vFmbJd1IhFFv6iT80LKN zoa;J#50nQFyaQg+_>1-7j`rgPzPO>B6K>NBA!Z2H(YIku-x8YHh|MZKDK<@q)hdIt z3*Nhwd~)oVNbILHo@!zBn^lU$*fHTaz&rXxGaKIJ&8NnuM!>6)`6|4wEld$2BpC!_ z)7g#sh#60X$s-I&2BWd1X9KLOG`{|8N0p7zDVM2oYJLNF}8?}Ys$|e9U z@wd~##0ack1dfMkKX^&pZYj|IID5PWkMzb`I>m?*s23l%N}BH0JrMVg;$DTXf0d^v zAMu`0W_a|$A4@Vy<~-UsjrR}Gv%sVk>hGOpa@&5vG z>isp`rt!FO1sQBox!#uVZlh!DAAc;)DIP+`)OJdSxzaw7F+$TH(D!jZ76zFXQ+j)o04t+_T;NreI~SI2R3{mVhQ zj&xJ;7SYSHcAwy7v=`Y&C+x(j=cyhrut$K!Z-9MQK^@@#zf)`PUZ)WAT|EhV!CRha zN(zO&HTupUt8gzW)pFqvMX~>lQ^Q!VF^sld<)S&93JI8&so>agm9Q z;_8Umi$djLLXy#FYQ6Ll;Dgb0+(F)Ft^m!@x@cRMC?>f09M2aNZmXG;Ze}hx#Ea3b zljrAlVld7GnQ%f=`&v;s>PbH{{v9kl~g({>NID zwU3&YlV*u1Si`gS(etu0%wf)}x02aT{doI!VR&Y^9zP0?l2%4CYA76fe z(!{{NFco3BEdzBAt_M6q{qgw@OX9|O_d(G4TIJ7iSGKW z6W_(xg#EN?>%;?KKPzFUz8NNcR8INf#M1r|#jAWGxju%a>dStcI{9l-M)!n*OaOolB;RMr}Fl3&acz|VTS zL~gT)8m%Ar$M0?t=XUUHtZmwu1XJ)O@jZpNf2F4<8*;!B067hCqGTLzgZ zg1p3qfea#VrwGfypbt2u!6hx|VWx36|Jc(JRR!gvXPlX!AE$(&pctDbFBl*5v197N?~tRqiNaur#TpH;wg>DOs; z>|=z&jU-D5sr0_@>FDPi@ z5;tHV&S*n0^wc^*=O-}O(WGqT#mm@dQCsV}`SZ2dix+P^+q8_$$~PX?tP#Z=OyJj1 z+Zrs-7e%V`{y2m$W(9zGPe0TQ@f{db_+RqvaWV|mu9uJ(kvoCD3*P22#|g|07iSwRn}1^Kzf>FJ(p`4#z@g(Z-ag)|^}AZLMSybEub z!^V&*@B5w+o_R*73%l<*<1^wDM$Z(R7ZCmIvy|v(jnA-a?j%~AeJ86V8xTk;Ws8|& zuvZ9nX$s)dg1rkmJ5Co*;G|ftEY=U3#RIXun`4>c=7y4zmihVlR0ou3t86<{1$^|B zX0$0#N|pjnIJ(*wAcOgLfX^g@11m6!`31mZ2EK{?H zY;&0p;hrz~tMAF0pHz}^i$dik9!z<%=GzpU;05hig?nZD;G75JUIT%3l)Gu1O18c4 zbUL3-mMA2KQN*o51KUMJO^tOuX>O3&QpoyS{$o2e`gan6_AjS6umxB z#flDJAC+rSiwbWwPK&7(Tr<7Z1j&oVRnxFuUFL0!j1IDt1M7jBc9cbSaMyr?fp?A& zz=I)UWHA=lw4kONc~aDPQ9a9=OeOI)y;khP3+3Cq69l=+BgUgDrD2qu4`cZVrBdms zR4RPs5lV%ZQmN-IM=bMC8JTFzUM3cJvaZqk(>vHw_H}l-&lS=56RZI&iSL$^+VRBy-44%`{ilidY7sx!X=Loq>zBLaUFp5ospOt^(>0Uy!N$2&$Y zzr=Oum=u?l6E+I`*D%u%|BjRRPHzkBzv6X#p>2|x=L3l>P~o9aC_UsVK1d<=k}D#v z-YUWe1vU8COtCQgaLtvou05gKSCd?J72D|bf!Op8n-S&DHmXPak5)SZa!I4V!_N`W zh6Q&aeL}l}4CE|4>>mNW$N-Soh&0vt1kYckC`|F4@1hEF4++3&` zKVFlnHWvmJ0CAk8N4I1%7Tx#jsAH&p{f|+&&Ihx;|5Id&rFLi@1MT?)uYlFGVK5Fv z;CzHO49liN8u8r>*IB$y{<=EC8lX_gO&&FAk0#3H5kwK8g0}3dP^dkkyuczVjbdAl zXC~ROp|BvQEGtX#0>82#rU|e%_Q+5@@#`Z0wLv>ax_>>)I)UX`^DcUsu6m21C z4@!aOmH4DVQ|6W3qHk%@SB7P`7@GUr`7NBs{P(e@68X0g8V&ote-_K9+%6%WsO~QL4^AS?&<$M z>}enUZ&4ub_QksY89Ky`1+=X*chK@Lr10yo|92PZvef}ME zUDMLi0A=7S5Bu!i=MKUikYEJ+oPMzj1Qt+zH8NPI_Z>Rjs>pO~S|Jx# zkSNDhR{1TSzmpCngi?E4l!jBJI0++)f;dAVXBXnoay*TMzgfuk{;XjOxudQV?jeMb zy+Yz2#ieHu7ufap-^6BUr~6-Ec4R)Gm|1Ol&DOz3?Y}}&+!3)@D~)qjiG}phnqbUX z3i$Grce3<;d`Ez7$d>l`-noxv2nXpNwE=g4FwoQb(V-y>XTf^NB~d_Z)%}*7u`X31)2pXx&BLu z-ATPR04D0cpdPl$YPs99x~G8JJNfiq@MyjeW!CHYe3EC>n~YJ!-#0IBySKd6hq4IH zKe3DXS#qCZt++T4m-vgvjDp2r;0sBC$zV1KL?DHQokKag#Ldxv#Y=IAHa}mR zIlmU?&%#?sQ*3BOMQBcdtvsZ(G(?r9ust8#;A=No^^S&{2*Z|ax&|U=uE6@3Pyf!n zJFq6wd~QhB$vaZXY1rk{?oFn_Mm?Fhk$8)8Kjn@f+_OLy#p~oJ6#(+U1AfobygRCa}S0q$w^m zwSfy(ApHR z8|OaC5p!1>M4clj*q|v{nC#CJxe%M^V-);HhU!$Tx294~97*y;wg3fD=ITNfQHFm) zOgnFM3|FfIBK(ymUzH)q-;-g(4WkrlKaT((MUdRzlb7=jRu!azEn?FC1CYr(KvyJ; zu9OS9L0@kqn2&b_}`>74lG9I&jh#?#=zzUXKZCD;i$`|gz58khLEfIGe zT}-~g!q=F*eN@c4_y@7r!Q0=&JDFD3_D;XiOK~U3*&si(9)DqkP4H91DzQFMnR5ca zducu12)-d&FLWkH;SMP!3K^`|rt^*bMa5f!NNvjzTwdrZ7f&Bm;a&1_}75VJh zfX`cix=CWCI44n&^(TDz(o1-A31V)FH+zA$DyT!+oiJF7FJ-Rn4#qClkX*}6w4;UW zEZ&Qi$*ym(@e(lhV=?pk%VIH9N(o%(>RilK$PcU)7rPqdC0)1@{6{9(F*FgVoSC4= z?8Zl+dP?R0FEk<+__z@6KjL9_28(=t;MIX+Q3e<@fjPnPTFOyg(jMX$f8f=nm(8vh z$s`fTB&W9GeMZBz9`WME?P8f-fAvF#y?S7woy=SoL<;1uEyX>G%rC_}IG}T(Cq$X^ zF+KzbnuF=0EBK(H-ld?gyd*!Uj*9P&>b8(J@$#GPM0a#AK43KT_K1JKyhSWcin#JI z(`YA;D0i*Em-w_V#C&m`c(Er$k@X3F4-QKCo|JUtrU-kC8u@alLkqKOU#;DjZqFSc zDF#{u&_s5}caPi~^2uv>zhJm_O1!Y(aG_Y16!QH?+>YLFJv_K@53-yeb4jA(tFs|& znEqpY7!E>&KrL8mcO85gJ@s=Z`sDg);E+WJ9Qxb!4Pr@B*wqjCLPh2!u|Qnw#`j}< z5Le?MX>SSxu&(ko0IPpLlOLQuggtQ53B)#1{tT(`f?&9*~y<51F<{N8( zm(U8KT(wjV_8z%Qba6htd3^PawXm^k8&~wgjkT2TH=U5T8rls9V<9Q8JNIVJ;>vZN z<)`0R#a-;(Le`OeO*b}B*l_z;8Ss$eGzfb)$#oIF^hOuAr}rdh?1G$!6%iSXYT_E&Kkl8|y$SbRO~leLWcNFkoewoDyn;Gn|xw zxn*ntK2qj7RRIs8wT!?n1>oPjo1)Cl_DcD{WvIjR*o{OlD*8H0*i9XMaM=%r8yN_< zoKw&|9z^iK+;ZmZ9_y>z_C(Zn5*b;8{0(;qP!2v^p$q7jgY4XXsF>xKRmk!u3_r%{TX7N z^CY|9xkB8LftS_4DB25!M%`Tgu( zsBahoCy={Ft&Y1@V>0fqF-i~r015b)jQ#xK)B+5$l8H4goCNsGwDGo)!-+mhMFQ}n zGaKrDM-b!JG=Hvme#7(P7qOMS9UYjfDz8=8XVrDIi`^aVb#-?6lnRzDkta-Bl%L;G zlPE7y4+d zOkI>OMEY5UN!wb+j&0dCiSm(yyDSL*DSM=!u3Q9*E&nsL`7*He6F)JxVb(UnGLetX zpD&)?_=0#owo2@H4)fKMr_1egW+)wUT8^<;gXR3JMlYOX5ou<68ev zS-HJ67hg0zNXqKPFE>b3Zp0CDXU%WeQB_-8S$3&~G=GULT8q|CXT1N}n#9DKXYV%{ z{6-opx3%WwwQj4#TU;NLku*?xS-4dsPnO95&%y2vLy15w-3=tH)^pcU*k}(2b$J!^hjLmJS7zK~4 ztG!lk%`3A_SszfN%BgC}%5IsKjlZaYABVLhLl81btYM)lmA48?*zFZ9x$qVy^RpHu z>suyk)9VW@mf{Agcjc%-c9hs9e8Cs#!6>;!Qb~qwJNrum!(? zPps*b7%Ok^B=&jmGiFpp?yzCG6{CD~KH+-cc>-uxfe@^xe8Q*_@8y1kdr`s8(;c_E zN^WuQ9HK6P@f&=5N0v=8;F|}G;1F&4U`XH>N1sTU$io#z4I+!3WS;1O|A7xR!w>)1 zV=!V^2;-9ySOcT&=w4WbdH|II1loQR;NaKot%)8g)zW4(*qRuMiUwK{L{>dK+>)6J z4~WdJw}TS_ni+1bsjXUvPmmLHW=s>WFMUpQn#;ayZuze4!AiMxN>xj<_@*VNV$4sis;k>L zp}gXuqEF_N`j45q;^LrSZ-4kDK-maemJl4I3{oXl<(mu{CAQ*Xe{YyW0RP~oQ8;$o zCGo(~Prdy%TQX?9ZlfOSuzkdEBIs01tQO;$O)c~H5DPQm=|@|{54LR)kJ_eV-<7Ly z@T{8oill~ym8--zR;_GoNKnk=9=x$1U(6jdak`N`Xsj(y%f*+-q9*a!mRM@@wqa{i zV@vD)8FS`LpYroFOm?neU zh2mQZXQV?|Ctw=_vsNR5ZrP15te*}bJRDPu{cKi!z{q$3k~I`T18@Vsn^2u+CIybk z3&&2|YE}n;)}1W?$>ayXwAmHwV4fabNHviVR-U_XvZJoVaQ}!zD1$@fa+){-%-;PY zqMZKoVo`{Y&}!k8Tu zPmHA>g0-VgwwHG`WmmfFRaR{<@of~lH*XYA&8uxxlzY~cPs42IV(eQpdA4GLXG?EH zc{$StFvfbYUgcfQ*&TB#W{z#0Y{ykzUNokk9MzUN9ofxYkXCdxPMo=U|I1?wn^DWkZ@^JR^>*J za8CI#QVhRs_KDdb;fnT*ID#d=)lmIGIhQ@ly*j zi)^42m{%xhOg|NjEtnc#+LTG#O;P69f?`E^3Ojk_t{tn2iOsn&HKhRGBYXu= z=}kv=l5c>{n0;Y0H@I2sw|iYWH6&B`VOI;;{=*wB_6XN{Gj$HIZ+$F|`C-8Ou?xH( z>y~kO%DpRaY40xY-K%bp2`?<9&Vk9`1fjl(Zv5f*t8o{dHFqGMxd6JRfjttzNC%!( zSaYB)8H~z6JC+QO-DY*$7-%B21xHcmy)`c0E~qd*I9$eUO!< z*Si*47(=WWvavok?Ue~-T`3mFv&V$=(s;Q%ZGMThGC!>#zBFCvr46AVEv-Odh3tLB zbFE`CGR9c#U;+vB9o>8xp>tVZXaO*AVd9`0b2Wkh;mec||e+V>RWApR6N1Wy68yg}6MDVQV%9kv`2~)!&`|K+0JPcY7~jFv!1*yP^~hm>DggxpE)C~-SbB$z zLISp8wP3U73u%!$-IyYisZdAC`Jle`4Dr1-azV(q*^FsANH0o@jMRyIdHLQ9@t~yp zaK9bPegyaNQrw}A+p(t=fxA{81yehnjeXErHJW+hB&9&7bA*J2g*XcG9j^RBvX(jP zoIHwIcTyrlZx6{f2sxpnM)hqdETr{taA)6felA1zVFtpvy%7k8#(slbx(h*2DU67< zu(iNFkI`shUaRko9%N(k*wCy6)&okszhJisMq`E!cneH67XkBcoMhWFa7r7w zCm-;_$k zyrl35*C}}tH+%EGO|_<;7@g6Q5v1jHtR^%z)sT`!%Mg~QWGnLH+36d0uB|rji4Dt&HR?<&&y@kk0>z8Z5w&R?hc zMbHGec|K3}vSh=NpJ0bOIRrcS31xz>U3+x4;i;w(v$0Q&vE>;9|M|;Ndwb*d2XCf_ z_%;Xc=RVmR)enQ|1sDNfgJFJv;EyiYd1Mi)S@z>^2`%H8sq~$>O$aTkC)O zH?ckb*`MCp@}8v@dwo_fMy)z|a@E@IZl>y-m_L8Zfd#X%xhE3_(jzf{?`rYXstL+9 z;tg@mrz=+f^{=Z}d@Au_5}M5ZMz)q(5Uc^Wm_X|WH-9jW*0Maf7Q!)G$ZQwC7k8}x z!53KdzQt!K4H`aBL5=>16X*{K!Sh z>j`K%drDSIZ+3xuU}Zcj*fr7i_!t2UBfah`S}ThI*R2LFKd{3-Njo__^XuSfv9?Qh z5Sw*T|9H&x7sAcF5@^7yUJm_0{BvZ?&ByS;y=uBPq~6P1ocGnM-PuGV_}?{*6hL)${&6PwPL!V|qaLh|ELUmgft*GaNAkm7D5mQeRqfJQ^JsJJfReSgg*qg^f&OC(mFx* z0?3l?`HV!qK1e71W)W^C;jX`l3&qFjNmSX(uCwA}?q~cs+@Gm)>r#JNkOtH=Sb8WV z#tEAUh)Wb#i>q8W2~3S{hr9xkY6r8dblsGB|Dvkf>Qdj1DfW#whpzS%JUit3`2?*eJf$n2Lk2@SXpNhd#j}%TB@oAE2QL%x>T*tY*M0 zoO(^6#ro;|Jo?82QQ&impTImQjuAKIlQD&^M={1R;y)68``d)1q9XpGUc!AMevAFZ z15Soqh~c+aAeYlvPolc@Qhb0_#2Cd^a=^j5mP4_Yad?2~4qb zD>*pHmG64FhCJr%Vv1c)$*PoF?Rnl=!0eE1>N~gLjUCHe%WA*=x)%0UxN%~qg5HBw zvg>{0H8A3X9?1PW4ExirQXfTs%c5e0<&M|Ko6T|aXU50JPst9lL<@$7?2Mf3Tx;os zn8s3B3b*&Q*Io-$CGwWnUfap6pk^5OSdPkN8<LR<)1!hSy(wo8zZE_gF3Vu5SBe-gA?yIy00`9A9Zis>u~d@MZ$>>^G|hI?@(}!$k(W5?f%l|*mrA({_5Xf|mf3sj7q_lW zG`5MlR$5-t^TGD-K65q125|rEISK{%BWoP=7YJ-aBZ+Z+Cbo;Mu5%<3FA!f5Rrm^i z2$$l2h#ul5%;P7(?(~XR#mB+!_}gj2QAoh4_;A zvgm^^!%gH9@wLNZi}Vx32_k5ys;?qw9_Ty@6#{u>;e~bN(7R~J_za9Sq;0ug)e}TX65aj=uKYMn5(VRI& z6;G>rH=SXhP(58SY3XxI-HG|LN7k3(m@}mfi>FTMbnDG*+UMY<;B^W>k?vlW(d(j; z2^W5QESZ%plbXhOd$`{8@k(zY?@n$?RnZp}yu35yOK+Xbbo~T=jyyEu!LnJU%pI|K z8Wt-D?I0-v2}$GzGQ{o+2hMp<&&<`ix*2>rBD3sqnDgF7@5r3 z%kWQaSvs5S$=|;}-<2bKx$nF6dq3FhT2=M^_f=$iIxFkDVskw@;o!ju^QYg+2{$myFC&+X*KLUS2 zV8mndzO!dwpC^|>1KzY~3D&tnqdbNM-KezqScBES=Yz{u-LKpU6_6PQ?cJXQ4 z5gM}ZH|1$+PptWExaOV?bHofwP06OQ_xO#-OLM5kjUTCLdY$o&4YWQJVlGY_>mQu> z!u?7?kl#D$p!js?#(ralwK~KAzT~kaQ@KAetj87BrPZj-aqi$T3_$u~VPcdgQL#IuJ(vbU&5$Bk5 znISb(?<4rW>T0lIZJ=jQ@~2>~J_=T?QsMsC9Fzxl%@?5(7}r#Q?Wlpf^k;+Ld;#2- z|2SGlwJsdT+rnY)qJj1RW3d0HxNDDZ>bTOHk#uECvSdrP2=|LE|&&sW0lo#S)2$hs(Te5Ur8{I z>E^1|-oME(rplb~_UixsHlb_({`m|0j682Vbci(12ye~KI(VK8N8EnDKNchFhL4R1 zc|${_F@D_brdbaP-#dAd@N>dD@woDcooElW+)(9x@sNSEZv4$Z?JAnc+U>aU=2IAF z@}NgMtnq6OV0OsXYU~~(CL=1txMRl&Pj>s87keaaiVjiZcspzmC|Fam=CeXSk+_tV z=A@rB9}BO>kHIWm3ii6Zl`PK7@*rG|u3(0jcxoy!{-E_dH5gC;!m+qG93wBK-cqI4 z;_>F9o7pX#T~%c_&>D0&Hpsa#bG2d>;53o4C-qOfpgW`MxS+d0>=|!pMvm!@{nq?# z1AX-&(?dTooiqyBy5nZL=Zxj4`Aa7)Cuy7IY>_bjl;x?%EZ?>^TFzKB7c8#{51%og znZLz!*6KKC`H|XqD707qTZ2C4Ex+}dZ|J*z+|oW_YY&$FV7SjyShKwR+NquGTO4bH zqm{}npGJj03IFh!b^rbm>-MYry=2HmmOmQZJonTi%lE$fF6Ay=!h-1E=@*6fgd1LX zfjn^Og$ozx*$a1{pTBfz!>@kz>~H5k{IKmKQhDimk|F#-c<9olfj^RaE?*|6x(_~| z)!j7CEm@Iw@I;lmslDop{D-D*R#cj@b4FHWuFTzd#pGnxfykMM_MhAOW9_w-Ly!Jy zxJ6~S?L}|-4a;v8E<@@vr`XIL*BpZ;FVh=e1AT~1_^M1P5{UT{EO8vgTYVB=6$OTM zuSeV+wTPG9;?05pfo(706H%k#a@n)O1aX4b;}o|!SYm=N1R|i5P+@m)mAMuue{$CJ zP^?`_alMFL3aw10l|q4?vue^%V8mdF|2hhUDkJ5tTHoo~s*Cn~tzNxanSJ1Ri}1^) zs-kjpd%V?NwfxxL5ktMB*1qD#UR_y1-#s~*O9X?lrKGf{ySTVnlWoXQR_5z+3@Sx- zYgtKmPg$YQSeT*IauCI6)oQhnmwiP^Nq2Wikx!egRT|Xliaah;m*LNDEoC^0e3_;U zWfrAX`38Lkxnx{cTHMuBTHLI&AXuraE--32jYhk{TGVsxni5CZ)%C@hmU|mw1>3U= z7v(mqjhpjLQA6>=O48_St#fS1Z{xB`%5$6M71g)h79w=Z;iCesz_es7T~unXB(pV# z4{aqhh|p(EN~^x1*j`mhhV4fWZ=qX`d__2GR^{sJ%*DCI_McQ8J~Bn<)}ugRR8nfv zE~&HH?BplaVt5FtpAk{ilvJ@v7Do3G^?P{#d3Yeywl2k)cHC%d*I4bEr9@-48;RXa z)Mm9E0ao~+m~3URUE^)?+Nf*J+pI#d1IEgay`-MNuSHJvW-Jy7C$4jx;yVvhO z`+Ds7#n6-UPrho+uhK2$Op7?q(UR*f>m4$#-EJRR(tWMU(b4Q!IcPSxoDShX9p$;f zoZOYm*^T2bTJfL(ul%t3{p8Qc>Ofkl0lW@DbDDiqfo$nM-()QQNVU?d z^b)hithuisx2$xeKA%`O8-9LmplRctg3|ti&4${t4bHWn2l#ChtHzgF%i9wxHkM5o zsxr+-s}|{ssvPP}-Ao5}on!x`p-S!C?P|>}y`{s8J5)-{b*HN8`z*e9>$a^`J98&= z&Wy}$H%xwbjlSjAwU!kX>H?RQt|4WQKmO((;r;mB?%nF6_E=R_=Irq1Kxa|e9;D!$iROQs6>31yD4+^EJF(^z7E1^2Sl_U0|JE-T9`UtHF2(r?RO6`^*cDXXky zvS~$6HGgF}j-e{cwbes|YyED|>b$l4OI@|arPa=GxWCd z1LuDKMB@1Z=jq7tU!Of-buY`uE0TWvzPtl zD6wy(#FkDnR>R`VOmR?*#~aRK>DPZR{B9)PHnU==ZFXpASh-|wgx|2IW29@QYi>|@ zYk!UK+}c_9Tt{HAW6l>JfE6)c{~q7m>fvD5Zr`3h;grU8-~9c9!ZUqBcfYWOez~7= zy`+7BoDq5kgy(wa|JXl2OYZC^-|HhCgY+7Qb-s2$_)eeD+IyK?*+KfE0{*j*+ofHY00WyXv{dheKFN9r%=Vs>a(+FRF`OSmqkar(^`B^fItA>7e>WNQ2 zdE(UXgr6!yRaMkl&_8I-$*NyELLE@O{+bXzd66^;mB;tZoiPeGy>RK6kRUf7dHp2m zFT6Vz-(5rYzWw$>J-vZ4LK~(ULS-D?v0&+{d`7rK(2;*7Hy-@5`nHh*T0pju8)-qN zXa2qUo9AC)c}01Qsto%xOs0{{t>&=$wbsx=;#Dyzyz-JTEl~0pwY>S8tQR9^Pnpj@ zFRT~lGC1<|h#JWvBurOj+$&Vh|Chks^dxzgd`wWZ%uCF^j96TBEsDoXtiTSIAr-gIE&k{MU`ZAk&l2pI~K^NUM+vZuH`LowXPCIp_ zy4=DN(-4MgAj zzdu*-w>}p_{uj?2sG;9~nY$HxYZ+Ln*>H*$icDq*exLx&Y0SB0LkXF+461hI3gB{MeL-@D1O0=D?U^g#7N-nVR;YnCQ zze_3IiT+o<&JDPD@h`v6$*-}6duQoQrNw>D5ofgdz#;3Y&BuR#sJ_3ruD{$|zdhJl zl2iOG-KeXx+-}~G_)hmUd9AFe+n1H!(zeFd!quDdm-YP z=5A=s2=2u-tmvoz4`)*pibdpKQ47*P7aR%3o*uLYB$xtrC1GYiB^9npOQXiBy)T&t z``dCFEoMEtFq*=IJKj4zy-$SEqp(7JT7)?k4l9c+jYbT=D8d;c{GJG7?1rw;ACfTc zlZLfJmOc|{41}FKVXzWqNrkJ@(x?@i$nD8ATw1sm7FmBUhHDuQN#1mfE}a&`^=aV- z5q?$-&jxIuH;Awqu!$ZL;oP+Jd4RK%I4x=61%M5d-5XC-MPeEWXGvO`vNX6#On+WX z&(81}=$j1ANaHyp4Zl7uT%Y8B{f=pV+&{+K+7|7IB%-#l$kenyykl{L&FOG7H`v-k zA=^N3Vlp1H4e&8Ox}6UU@DquUKf00k$0zydvJHGR7L0^#jSUV*I&53Tk46*z=ni12 z6S39Vg5h91=nvVVe2DkQ`1O;)m~A`~j@xGZG22)a82NxL5etSVY^xC5!9pTYTT?@m zZ9E#8vUP)#`ZbY>;8+6~#i{F2#SW5%wc-}&wY-mC1m{ww6n;nu*Fi$)M@RtAs3HK1 zl;2W5qkIm(?<>zLAA>w`2c(ER`VO=p;M&j|7a=SHDMS>$F+fvD!Eo$=o@)cboX{b1 zK*N;5?Vu5YI{<0;1Xita$i$hChsy)Qc02>3e*zdoA{QGG=10m&F~u^-Jy^;ZFhoGb z2L0a#k;4BJZd0s6j#1=Ei1>CO596sW=`!9J90ax?=me39@fby}5Pp7vtf23)k!^MI}zj! z0&hdIM*9#VwGrbjh>;=XXB?)tn%HiC7LS%tm8u$5y{azU`P{2&mScYnTw&zz1Ml1M z3&0ma8%6P#5XO)0Cw`|=7y$Wk^yH6i(p1uki zu>+{1^@>6CosE!)4?&md8py>*AVJ#<={O8qqn-n(iE*)42JvQWMcqt^^)ap3hWd!1 zbrYzi8A#A~;9l7|$kBH}C+~Vl({F_J*S*YME-dBV47tHAiv2j9bpSHCL(ot=4C}T> zvFCHU;ttf|R~2_*_vdTS_&5%Wy7wsVRon;bwI{G2bP~6*KA?C|@epKqk0>66_1x2< zU0T?i6>ZEid$VU0-@~5KS;bR|r->T3fIo-bX$`E+{s22oKZ3>GAH(kMOR%;pS=l`= zTG)LJc6DEeo!g(odhJEU8zcjkY~O?(+h4-2?c1<@`y1H2g{52A`F$65b>D{t-Ak~c z`vI)-ex&#vk?iJvtoS5pFZWZTXBKstC0)hmFkDC!&%mB7Eb0;?$%Z{{6ETxql1D69 z(dI)jr4Y-oVpzLk7Yy34$yosnjVjpfs)17MBC?p&k|m^$)DvdU#erQoCsZWeq=|T- zMCgNF)H0m>xB^p-<)n?QAniE)-hoMLC+zKYk#5pMu=K=4`U|+yzn@$M3*ZCTn_Eu? z$p*5KTup|si+>HQ^o_uJ_Ga=$*ajaZW0IWmS~KNSq|d zb~1x?@(!|-%#rKJF0z|kkKO+pvCY4i+(f=a_K}+jHnzxqaw|DN4w6IUHgcF8ff~$L z$nE3~awqvJxr-blUn5_~rR#T-d&s@8+WZZ2f_#&lB=?gC$b;k|@-TUXJW3uTr^spY zIC+A63upVEgjMM8knfT+im$^u^!LeG@)T?ZJ_Cbb&%w^#^W+>(+y0RJh`fL~*NfyO z=u-WZ`~!KJoF}i4SIKMSXXGEr>*NCYIr%4Yk-S0vnf!vhN!}vAB)=kWlV6kHkblAA z>>Vs8-zD#n_sPGJOXT0l2joNY5wsTm1G*3YiB;bx4&5@0k z(+XNit7tW?!KE3C=wez+m(V&|Pa81bbkIiXq%P{FP1HlZ)JL0PBe{iML0jo^+D2E< zcDj;w&?{*tT}8WSH|?RTX)j$vzd-wFKkPHCr2}*wj;;>U4Rj;UU=7h>dJVmnj?hhX zGn9h-bd-+K0Ojd8ouHF6NVm|fG(@Lpm`3O{-3EKiF&d`{x}DC@S-OMnq;vE-x{L0n z*V7y5jdTy)OK+lIqWkF0^vm=Xx}V-k572}35Drxxrbp;e`W1RRy@TGVZU`qrq3m!Z zJmrsW#pgN7#}m=8Le-gwMl^|VaFxT+m~@@YbvQekMc1)1l`d^hAQJbFjq%~Q zrhUpk7L9~8e#zz9N2C09p7V>2radwd3G-Vue#zB!j0K}(iK+1rKdT#CfVCYmLhYCg za#xP|ftm|Q&Xu6!k83)U1oy$9^qND3tU_>{u z0BgHs1lkE1)OTUtGUb;_ub)Ws=(-p3>LwRpRrjbrs+z=u>xlPD>BzX=>F6~)OgIjc~7x3z~EWrBSG)DAW|ICA?=EEU>I1n7;*7(N~ah?l_ zj($ygx=@;jTO(CaNOV+dPrDf5F(>z?Cls_z0aM(W`iN&Ll=}BJM z8JgFLe=SF3$T8D8UlSh&BLvi(8NVYwVpL;oHgm7)T9ZiNe7dqN+e4) zD3vN9I_kkFUOaVzJ+lVW%aoN!_h|-`O`nil-NpqDbu(%3P#U~r0p^CKvhEZe?XcW; zwL4`{9g2h}V%m1bij`-#Hx%f}j|j(HT$1_h1kagY^AVK{kj;p24)l+WskiLQ0eq zMDjnQr50(aR`PMby33E3QXH>b&2CMSo@y9TO3+iUp9G|01l7I%>1jV+gsIVhpMD`h z`x5l(AiAT-0lg}y9GHx#*99l0{L1zIgeJ+2@~X+8vID=XVnK;ad$XS5OL1gOCQSLY zez_v_d|HVzz=%{mtUMx=n~>sDS;auLm|r!DKjF4ay%C|M+ya3~r> zrrs(REhH9AVsd2%4JYVqP!o~Lr;JWUxEL#3qgr&7ag;GhUpbBPjo}A&)Dc$kdWJT| zmhmsx)F*LDt(J@wJz6od2xj`ngTY3J!|6&vO^q_-l%a)Kw;a|aLmnCO%8*Znnp2R+ zAwx0^Pl`sPTgKNYV`-GJG|E_ZkdK#rs0-pcx0|T zat@E2!z1VL$T_?+S6-PHugr^A=EW;x_R5&OGG?!g*(+oA$(Vg|d3`bspG?Ci)9}eO zd@>E6Ov5MB@X0iqWg5*gjb@ofvrMB|rqL|ZXqIU-%QUIqke800;{-R#O!HwCi^0wWZQTeT}{qRJ{HFe z3Ua4ROf`8X>6+BXCo$=f;FxYaxIG2yW8fp4jL7syqmh{qKOWbJP-0pux>1HhiVQ?% z!V)wZiBC#UVmc7kCo=@XqcL8Kt1Kqjr`jLV2g4{U3Kxe!O~-Fb1h@M`e0YpkPeu|k zJ`2?lV!|(f2;W96ON_b;#iwO(G@h|;6?y~yF+hX>IAp+;j6y|AX&mkp;7b9`DZrBg zyeXh53Aj^uoT=2TsO>Yxh1EmQ7c79(G4{5XwW~An3mjV z(jN#*{?Itbrfnf!%#SZXFuZ*f>oh*jASp^4ndZaEz}Qp}-4()K^t0`juW!xGTV-aokPssQr&=L-7Y D4`61= literal 0 HcmV?d00001 diff --git a/pom.xml b/pom.xml index 4f780485..9429c4c3 100644 --- a/pom.xml +++ b/pom.xml @@ -14,8 +14,8 @@ MeteoInfoLib - MeteoInfoMap - MeteoInfoLab + meteoinfo-map + meteoinfo-lab meteoinfo-console meteoinfo-ndarray meteoinfo-math