@Override public void mouseClicked(MouseEvent event, StateRenderer2D source) { if (event.getButton() == MouseEvent.BUTTON3) { JPopupMenu popup = new JPopupMenu(); popup .add("Generate plans locally") .addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { solve(); } }); popup .add("Clear polygon") .addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { pe = null; vertexCount = 0; } }); popup .add("Settings") .addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { PropertiesEditor.editProperties(AreaCoveragePlanner.this, getConsole(), true); } }); popup.show(source, event.getX(), event.getY()); } else if (pe == null) { LocationType l = source.getRealWorldLocation(event.getPoint()); pe = new PathElement( MapGroup.getMapGroupInstance(getConsole().getMission()), new MapType(), l); pe.setMyColor(Color.green.brighter()); pe.setShape(true); pe.setFinished(true); pe.setStroke(new BasicStroke(2.0f)); pe.addPoint(0, 0, 0, false); vertexCount = 1; } else { LocationType l = source.getRealWorldLocation(event.getPoint()); double[] offsets = l.getOffsetFrom(pe.getCenterLocation()); pe.addPoint(offsets[1], offsets[0], 0, false); vertexCount++; } }
@Override public void paint(Graphics2D g, StateRenderer2D renderer) { if ((System.currentTimeMillis() - lastStateMillis) > 2000) return; Point2D pt = renderer.getScreenPosition(simulatedState.getPosition()); g.translate(pt.getX(), pt.getY()); g.rotate(-renderer.getRotation() + simulatedState.getYaw() + Math.PI); g.setStroke(new BasicStroke(2f)); g.setColor(Color.cyan.darker().darker()); g.draw(path); g.setColor(Color.cyan.brighter().brighter()); g.fill(path); g.drawString("S", -4, -4); }
@Override public void paint(Graphics2D g2, StateRenderer2D renderer) { if (pe != null) { Graphics2D g = (Graphics2D) g2.create(); pe.paint(g, renderer, -renderer.getRotation()); g.dispose(); } }
@Override public void paint(Graphics2D g, StateRenderer2D renderer, double rotation) { Point2D pt = renderer.getScreenPosition(getCenterLocation()); g.translate(pt.getX(), pt.getY()); g.rotate(getYawRad() - renderer.getRotation()); double widthScaled = width * renderer.getZoom(); double lengthScaled = length * renderer.getZoom(); Rectangle2D.Double tmp = new Rectangle2D.Double(-widthScaled / 2, -lengthScaled / 2, widthScaled, lengthScaled); if (isSelected()) g.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue())); else g.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 100)); if (isFilled()) g.fill(tmp); g.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue())); g.draw(tmp); }
@Override public void paintOnMap(Graphics2D g2d, PlanElement planElement, StateRenderer2D renderer) { super.paintOnMap(g2d, planElement, renderer); g2d = (Graphics2D) g2d.create(); if (!isStartFromCurrentPosition()) { // x marks the spot... g2d.drawLine(-4, -4, 4, 4); g2d.drawLine(-4, 4, 4, -4); } double radius = this.getRadius() * renderer.getZoom(); if (isStartFromCurrentPosition()) g2d.setColor(new Color(255, 0, 0, 100)); else g2d.setColor(new Color(255, 255, 255, 100)); g2d.fill(new Ellipse2D.Double(-radius, -radius, radius * 2, radius * 2)); if (isStartFromCurrentPosition()) g2d.setColor(Color.RED); else g2d.setColor(Color.GREEN); g2d.draw(new Ellipse2D.Double(-radius, -radius, radius * 2, radius * 2)); g2d.setColor(new Color(255, 0, 0, 200)); for (double i = this.getRadius() - 2; i > 0; i = i - 2) { double r = i * renderer.getZoom(); g2d.draw(new Ellipse2D.Double(-r, -r, r * 2, r * 2)); } // g2d.rotate(Math.PI/2); g2d.translate(0, -14); g2d.setColor(Color.WHITE); g2d.setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); if (isStartFromCurrentPosition()) { g2d.drawLine(-5, 0, 5, 0); } else { int m = 1; if (getManeuverLocation().getAllZ() < getEndZ()) m = -1; g2d.drawLine(-5, m * -5, 5, m * -5); if (getManeuverLocation().getAllZ() < getEndZ() || getManeuverLocation().getAllZ() > getEndZ()) { g2d.drawLine(-5, m * 5, 0, 0); g2d.drawLine(5, m * 5, 0, 0); } else g2d.drawLine(-5, m * 5, 5, m * 5); } g2d.dispose(); }