📄 demolayer.java
字号:
combo.setFillPaint(Color.green); omList.add(combo); OMAreaList combo1 = new OMAreaList(); combo1.addOMGraphic(new OMLine(66.618519f, 141.563497f, 66.028244f, 140.193964f, OMGraphic.LINETYPE_GREATCIRCLE)); combo1.addOMGraphic(new OMLine(66.028244f, 140.193964f, 66.968058f, 137.611042f, OMGraphic.LINETYPE_RHUMB)); combo1.addOMGraphic(new OMLine(66.968058f, 137.611042f, 67.558261f, 139.033958f, OMGraphic.LINETYPE_GREATCIRCLE)); combo1.addOMGraphic(new OMLine(67.558261f, 139.033958f, 66.618519f, 141.563497f, OMGraphic.LINETYPE_RHUMB)); combo1.setLinePaint(Color.red); combo1.setFillPaint(Color.blue); omList.add(combo1); combo1 = new OMAreaList(); combo1.addOMGraphic(new OMLine(65.495278f, 55.488889f, 65.022778f, 55.749167f, OMGraphic.LINETYPE_GREATCIRCLE)); combo1.addOMGraphic(new OMLine(65.022778f, 55.749167f, 64.970278f, 55.208611f, OMGraphic.LINETYPE_RHUMB)); combo1.addOMGraphic(new OMLine(64.970278f, 55.208611f, 65.442778f, 54.948889f, OMGraphic.LINETYPE_GREATCIRCLE)); combo1.addOMGraphic(new OMLine(65.442778f, 54.948889f, 65.495278f, 55.488889f, OMGraphic.LINETYPE_RHUMB)); combo1.setLinePaint(Color.blue); combo1.setFillPaint(Color.red); omList.add(combo1); // OMArc arc1 = new OMArc(100, 100, 200, 200, 0f, -45f); // arc1.setLinePaint(Color.blue); // arc1.setFillPaint(Color.yellow); // arc1.setArcType(java.awt.geom.Arc2D.PIE); // omList.add(arc1); OMText text = new OMText(30f, 80f, "Testing FontSizer", OMText.JUSTIFY_CENTER); text.setFontSizer(new FontSizer(30000000f, 1, 5, 40)); omList.add(text); if (srl != null) { ImageIcon ii = srl.getIcon("SFPPV-----*****", new Dimension(100, 100)); if (ii != null) { OMScalingIcon omsi = new OMScalingIcon(20f, -50f, ii); omsi.setBaseScale(1000000); omsi.setMinScale(1000000); omsi.setMaxScale(5000000); omList.add(omsi); SymbolPart sp = srl.getSymbolPartForCode("SFPPV-----*****"); if (sp != null) { omsi.putAttribute(OMGraphic.TOOLTIP, sp.getDescription()); } } else { Debug.output("DemoLayer: couldn't create symbol from SymbolReferenceLibrary"); } } return omList; } public void setProperties(String prefix, Properties props) { super.setProperties(prefix, props); setAddToBeanContext(true); } /** * This is an important Layer method to override. The prepare * method gets called when the layer is added to the map, or when * the map projection changes. We need to make sure the * OMGraphicList returned from this method is what we want painted * on the map. The OMGraphics need to be generated with the * current projection. We test for a null OMGraphicList in the * layer to see if we need to create the OMGraphics. This layer * doesn't change it's OMGraphics for different projections, if * your layer does, you need to clear out the OMGraphicList and * add the OMGraphics you want for the current projection. */ public OMGraphicList prepare() { OMGraphicList list = getList(); if (list == null) { list = init(); } list.generate(getProjection()); return list; } protected GraphicAttributes getFilterGA() { if (filterGA == null) { filterGA = new GraphicAttributes(); filterGA.setLinePaint(Color.red); filterGA.setRenderType(OMGraphic.RENDERTYPE_LATLON); filterGA.setLineType(OMGraphic.LINETYPE_GREATCIRCLE); BasicStroke filterStroke = new BasicStroke(1f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10f, new float[] { 3, 3 }, 0f); filterGA.setStroke(filterStroke); } return (GraphicAttributes) filterGA.clone(); } public java.awt.Component getGUI() { JPanel panel = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); panel.setLayout(gridbag); JPanel box = PaletteHelper.createVerticalPanel(" Create Filters for Map "); box.setLayout(new java.awt.GridLayout(0, 1)); // JButton button = new JButton("Add and Edit Offset Line"); // button.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent event) { // DrawingTool dt = getDrawingTool(); // if (dt != null) { // OMLine line = new OMLine(42f, -72f, -50, -70, 200, 200); // line.setStroke(new java.awt.BasicStroke(5)); // line.setLinePaint(java.awt.Color.red); // line.setFillPaint(java.awt.Color.green); // line = (OMLine) getDrawingTool().edit(line, layer); // if (line != null) { // getList().add(line); // } else { // Debug.error("DemoLayer: Drawing tool can't create OMLine"); // } // } else { // Debug.output("DemoLayer can't find a drawing tool"); // } // } // }); // box.add(button); // button = new JButton("Add and Edit XY Line"); // button.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent event) { // DrawingTool dt = getDrawingTool(); // if (dt != null) { // OMLine line = new OMLine(200, 200, 420, 520); // line.setLinePaint(java.awt.Color.blue); // line.setFillPaint(java.awt.Color.green); // line = (OMLine) getDrawingTool().edit(line, layer); // if (line != null) { // getList().add(line); // } else { // Debug.error("DemoLayer: Drawing tool can't create OMLine"); // } // } else { // Debug.output("DemoLayer can't find a drawing tool"); // } // } // }); // box.add(button); // button = new JButton("Add and Edit LatLon Line, no GUI"); // button.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent event) { // DrawingTool dt = getDrawingTool(); // if (dt != null) { // OMLine line = new OMLine(30f, -60f, 42f, -72f, // OMGraphic.LINETYPE_GREATCIRCLE); // line.setStroke(new java.awt.BasicStroke(5)); // line.setLinePaint(java.awt.Color.red); // line.setFillPaint(java.awt.Color.green); // line = (OMLine) getDrawingTool().edit(line, layer, false); // if (line != null) { // getList().add(line); // } else { // Debug.error("DemoLayer: Drawing tool can't create OMLine"); // } // } else { // Debug.output("DemoLayer can't find a drawing tool"); // } // } // }); // box.add(button); // button = new JButton("Create XY Line"); // button.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent event) { // DrawingTool dt = getDrawingTool(); // if (dt != null) { // OMLine line = (OMLine) // getDrawingTool().create("com.bbn.openmap.omGraphics.OMLine", // layer); // if (line != null) { // getList().add(line); // } else { // Debug.error("DemoLayer: Drawing tool can't create OMLine"); // } // } else { // Debug.output("DemoLayer can't find a drawing tool"); // } // } // }); // box.add(button); // button = new JButton("Create Offset Line"); // button.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent event) { // DrawingTool dt = getDrawingTool(); // GraphicAttributes ga = new GraphicAttributes(); // ga.setRenderType(OMGraphic.RENDERTYPE_OFFSET); // if (dt != null) { // OMLine line = (OMLine) // getDrawingTool().create("com.bbn.openmap.omGraphics.OMLine", // ga, layer); // if (line != null) { // getList().add(line); // } else { // Debug.error("DemoLayer: Drawing tool can't create OMLine"); // } // } else { // Debug.output("DemoLayer can't find a drawing tool"); // } // } // }); // box.add(button); // button = new JButton("Create Lat/Lon Circle"); // button.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent event) { // DrawingTool dt = getDrawingTool(); // GraphicAttributes ga = new GraphicAttributes(); // ga.setRenderType(OMGraphic.RENDERTYPE_LATLON); // if (dt != null) { // OMCircle circle = (OMCircle) // getDrawingTool().create("com.bbn.openmap.omGraphics.OMCircle", // ga, layer); // if (circle != null) { // getList().add(circle); // } else { // Debug.error("DemoLayer: Drawing tool can't create // OMCircle"); // } // } else { // Debug.output("DemoLayer can't find a drawing tool"); // } // } // }); // box.add(button); // button = new JButton("Create XY Circle"); // button.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent event) { // DrawingTool dt = getDrawingTool(); // GraphicAttributes ga = new GraphicAttributes(); // ga.setRenderType(OMGraphic.RENDERTYPE_XY); // if (dt != null) { // OMCircle circle = (OMCircle) // getDrawingTool().create("com.bbn.openmap.omGraphics.OMCircle", // ga, layer); // if (circle != null) { // getList().add(circle); // } else { // Debug.error("DemoLayer: Drawing tool can't create // OMCircle"); // } // } else { // Debug.output("DemoLayer can't find a drawing tool"); // } // } // }); // box.add(button); // button = new JButton("Create Offset Circle"); // button.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent event) { // DrawingTool dt = getDrawingTool(); // GraphicAttributes ga = new GraphicAttributes(); // ga.setRenderType(OMGraphic.RENDERTYPE_OFFSET); // ga.setFillPaint(Color.red); // if (dt != null) { // OMCircle circle = (OMCircle) // getDrawingTool().create("com.bbn.openmap.omGraphics.OMCircle", // ga, layer); // if (circle != null) { // getList().add(circle); // } else { // Debug.error("DemoLayer: Drawing tool can't create // OMCircle"); // } // } else { // Debug.output("DemoLayer can't find a drawing tool"); // } // } // }); // box.add(button); JButton button = new JButton("Create Containing Rectangle Filter"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { DrawingTool dt = getDrawingTool(); if (dt != null) { GraphicAttributes fga = getFilterGA(); fga.setFillPaint(new OMColor(0x0c0a0a0a)); OMRect rect = (OMRect) getDrawingTool().create("com.bbn.openmap.omGraphics.OMRect", fga, layer, false); if (rect != null) { rect.setAppObject(internalKey); } else { Debug.error("DemoLayer: Drawing tool can't create OMRect"); } } else { Debug.output("DemoLayer can't find a drawing tool"); } } }); box.add(button); button = new JButton("Create Containing Polygon Filter"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { DrawingTool dt = getDrawingTool(); if (dt != null) { GraphicAttributes fga = getFilterGA(); fga.setFillPaint(OMColor.clear); EditableOMPoly eomp = new EditableOMPoly(fga); eomp.setEnclosed(true); eomp.setShowGUI(false); dt.setBehaviorMask(OMDrawingTool.QUICK_CHANGE_BEHAVIOR_MASK); OMPoly poly = (OMPoly) getDrawingTool().edit(eomp, layer); if (poly != null) { poly.setIsPolygon(true); poly.setAppObject(internalKey); } else { Debug.error("DemoLayer: Drawing tool can't create OMPoly"); } } else { Debug.output("DemoLayer can't find a drawing tool"); } } }); box.add(button); button = new JButton("Create Excluding Rectangle Filter"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { DrawingTool dt = getDrawingTool(); if (dt != null) { GraphicAttributes fga = getFilterGA(); fga.setFillPaint(OMColor.clear);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -