📄 geointersectionlayer.java
字号:
LatLonPoint llHolder = new LatLonPoint(); Geo g = new Geo(0, 0); int[] pix = new int[(int) (h * w)]; for (double j = 0; j < h; j++) { for (double i = 0; i < w; i++) { boolean inShape = s.contains(i + x, j + y); p.inverse((int) (i + x), (int) (j + y), llHolder); g.initialize(llHolder.getLatitude(), llHolder.getLongitude()); boolean inGeo = Intersection.isPointInPolygon(g, rawll, false); int val = 0; if (inShape == inGeo) { val = 0x6200FF00; } else { val = 0x62ff0000; } pix[(int) (w * j + i)] = val; } } OMRaster omr = new OMRaster((int) x, (int) y, (int) w, (int) h, pix); omr.setSelectPaint(OMColor.clear); // omr.setSelected(true); omr.generate(p); return omr; } return SinkGraphic.getSharedInstance(); } protected JPanel getFileListControl() { if (fileListControl == null) { fileListControl = PaletteHelper.createHorizontalPanel("Shape Files Being Used for Intersections"); } return fileListControl; } public void rebuildFileListControl() { JPanel p = getFileListControl(); p.setBackground(Color.white); Color light = Color.white; Color dark = Color.LIGHT_GRAY; Color current = dark; p.removeAll(); GridBagLayout gridbag = new GridBagLayout(); p.setLayout(gridbag); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.NORTHWEST; c.gridx = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; getRegionIndex(false).clear(); for (Iterator it = fileDataList.iterator(); it.hasNext();) { Object obj = it.next(); if (obj instanceof EsriGraphicList) { EsriGraphicList shapeList = (EsriGraphicList) obj; JPanel control = (JPanel) shapeList.getAttribute(SHAPE_CONTROL_ATTRIBUTE); if (control != null) { control.setBackground(current); Component[] comps = control.getComponents(); for (int i = 0; i < comps.length; i++) { comps[i].setBackground(current); } if (current == dark) current = light; else current = dark; gridbag.setConstraints(control, c); p.add(control); } addToRegionIndex(shapeList, getRegionIndex(false)); } } if (fileDataList.size() == 0) { JLabel label = new JLabel("No Shape Files Loaded", JButton.CENTER); c.anchor = GridBagConstraints.CENTER; gridbag.setConstraints(label, c); p.add(label); } c.fill = GridBagConstraints.BOTH; c.weighty = 1; JLabel filler = new JLabel(""); gridbag.setConstraints(filler, c); p.add(filler); p.revalidate(); } JPanel fileListControl; JPanel panel = null; JCheckBox showCrossingsButton; JCheckBox pointCheckButton; public Component getGUI() { if (panel == null) { panel = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); panel.setLayout(gridbag); c.gridx = GridBagConstraints.REMAINDER; c.weightx = 1.0; c.insets = new Insets(1, 5, 1, 5); c.fill = GridBagConstraints.HORIZONTAL; JPanel daPanel1 = PaletteHelper.createHorizontalPanel("Paint Settings for Shapes"); daPanel1.add(shapeDA.getGUI()); JPanel daPanel2 = PaletteHelper.createHorizontalPanel("Paint Settings for Intersected Shapes"); daPanel2.add(shapeDASelected.getGUI()); gridbag.setConstraints(daPanel1, c); gridbag.setConstraints(daPanel2, c); panel.add(daPanel1); panel.add(daPanel2); c.weighty = 1.0; c.fill = GridBagConstraints.BOTH; JPanel tablePanel = getFileListControl(); gridbag.setConstraints(tablePanel, c); panel.add(tablePanel); JPanel checkPanel = new JPanel(); GridBagLayout gb = new GridBagLayout(); checkPanel.setLayout(gb); GridBagConstraints c2 = new GridBagConstraints(); c2.anchor = GridBagConstraints.WEST; c2.gridx = GridBagConstraints.REMAINDER; showCrossingsButton = new JCheckBox("Show Crossing Points", showCrossingPoints); showCrossingsButton.setToolTipText("<html>Show ordered points where drawn lines cross Shapes."); showCrossingsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { setShowCrossingPoints(((JCheckBox) ae.getSource()).isSelected()); doPrepare(); } }); gb.setConstraints(showCrossingsButton, c2); checkPanel.add(showCrossingsButton); pointCheckButton = new JCheckBox("Click Creates Image Mask", showCrossingPoints); pointCheckButton.setToolTipText("<html>When clicking on Shape, create image mask that shows Geo point<br>intersection vs. Java 2D. Green is good."); pointCheckButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { setCreatePointCheck(((JCheckBox) ae.getSource()).isSelected()); doPrepare(); } }); gb.setConstraints(pointCheckButton, c2); checkPanel.add(pointCheckButton); c.weightx = 0; c.weighty = 0; c.fill = GridBagConstraints.NONE; gridbag.setConstraints(checkPanel, c); panel.add(checkPanel); JButton addButton = new JButton("Add Shape File..."); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { addShapeFileFromUser(); } }); c.insets = new Insets(5, 5, 5, 5); gridbag.setConstraints(addButton, c); panel.add(addButton); } return panel; } public static class OMPolyRegion extends GeoRegion.Impl { public OMPoly poly; public OMPolyRegion(OMPoly omp) { super(omp.getLatLonArray(), false); poly = omp; } public Object getRegionId() { return GeoIntersectionLayer.OMPolyRegion.this; } } public static class OMLineSegment implements GeoSegment { Geo[] geos; float[] segArray; public OMLineSegment(OMLine oml) { segArray = oml.getLL(); geos = new Geo[2]; geos[0] = new Geo(segArray[0], segArray[1]); geos[1] = new Geo(segArray[2], segArray[3]); } /* * (non-Javadoc) * * @see com.bbn.openmap.geo.GeoSegment#getSeg() */ public Geo[] getSeg() { return geos; } /* * (non-Javadoc) * * @see com.bbn.openmap.geo.GeoSegment#getSegArray() */ public float[] getSegArray() { return segArray; } /* * (non-Javadoc) * * @see com.bbn.openmap.geo.GeoSegment#getSegId() */ public Object getSegId() { return this; } public BoundingCircle getBoundingCircle() { return new BoundingCircle.Impl(getSeg()); } } protected class RemoveShapesActionListener implements ActionListener { protected OMGraphicList mainDataList; protected OMGraphicList toBeRemoved; public RemoveShapesActionListener(OMGraphicList mdl, OMGraphicList tbr) { mainDataList = mdl; toBeRemoved = tbr; } public void actionPerformed(ActionEvent ae) { mainDataList.remove(toBeRemoved); rebuildFileListControl(); GeoIntersectionLayer.this.doPrepare(); } } public boolean isShowCrossingPoints() { return showCrossingPoints; } public void setShowCrossingPoints(boolean showCrossingPoints) { this.showCrossingPoints = showCrossingPoints; } public void propertyChange(PropertyChangeEvent evt) { shapeDA.setTo(fileDataList); repaint(); } public DrawingAttributes getShapeDA() { return shapeDA; } public void setShapeDA(DrawingAttributes shapeDA) { this.shapeDA = shapeDA; } public DrawingAttributes getShapeDASelected() { return shapeDASelected; } public void setShapeDASelected(DrawingAttributes shapeDASelected) { this.shapeDASelected = shapeDASelected; } public boolean isCreatePointCheck() { return createPointCheck; } public void setCreatePointCheck(boolean createPointCheck) { this.createPointCheck = createPointCheck; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -