public ImageLayer( String name, BufferedImage img, LocationType topLeft, LocationType bottomRight) { this.name = name; this.topLeft = new LocationType(topLeft); this.image = img; this.zoom = topLeft.getOffsetFrom(bottomRight)[0] / img.getHeight(); }
@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++; } }
private DataDiscretizer parseLog(String entity) { DataDiscretizer dd = new DataDiscretizer(10); IMraLog parser = logSource.getLog(messageName); IMraLog stateParser = logSource.getLog("EstimatedState"); if (parser == null || stateParser == null) { return dd; } IMCMessage entry = parser.nextLogEntry(); IMCMessage stateEntry = stateParser.nextLogEntry(); LocationType ref = IMCUtils.getLocation(stateEntry).convertToAbsoluteLatLonDepth(); entityList.clear(); entityList.add("ALL"); while (entry != null) { parser.advance(1); entry = parser.getCurrentEntry(); if (entry != null) { String entName = logSource.getEntityName(entry.getSrc(), entry.getSrcEnt()); if (!entityList.contains(entName)) entityList.add(entName); if (!entity.equalsIgnoreCase("ALL") && !entName.equalsIgnoreCase(entity)) continue; stateEntry = stateParser.getEntryAtOrAfter(parser.currentTimeMillis()); LocationType loc = new LocationType(); loc.setLatitudeRads(stateEntry.getDouble("lat")); loc.setLongitudeRads(stateEntry.getDouble("lon")); loc.translatePosition( stateEntry.getDouble("x"), stateEntry.getDouble("y"), stateEntry.getDouble("z")); double[] offsets = loc.getOffsetFrom(ref); double[] vals = new double[4]; vals[0] = Double.NaN; if (stateEntry != null) { vals[0] = entry.getDouble(varName); dd.addPoint(offsets[1], -offsets[0], vals); } } } entCombo.setModel(new DefaultComboBoxModel<>(entityList)); return dd; }
private void drawPath( Graphics2D g, double scaleX, double scaleY, double minX, double minY, double timeStep) { g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setTransform(new AffineTransform()); g.setColor(new Color(0, 0, 0, 10)); // IMraLog stateParser = logSource.getLog("EstimatedState"); // IMCMessage stateEntry; LsfIterator<EstimatedState> iterator = logSource.getLsfIndex().getIterator(EstimatedState.class); if (timeStep > 0) iterator = logSource.getLsfIndex().getIterator(EstimatedState.class, (long) (timeStep * 1000)); Point2D lastPt = null; EstimatedState state = iterator.next(); if (state == null) { NeptusLog.pub().error("No estimatedstate messages in the log"); return; } LocationType ref = IMCUtils.getLocation(state).convertToAbsoluteLatLonDepth(); LinkedHashMap<Integer, Point2D> lastStates = new LinkedHashMap<>(); while (state != null) { LocationType loc = IMCUtils.getLocation(state).convertToAbsoluteLatLonDepth(); double[] offsets = loc.getOffsetFrom(ref); Point2D pt = new Point2D.Double((offsets[1] - minY) * scaleY, (-minX - offsets[0]) * scaleX); if (timeStep == 0) g.setColor(new Color(0, 0, 0, 20)); else g.setColor(Color.black); lastPt = lastStates.get(state.getSrc()); if (lastPt != null && pt != null) g.draw(new Line2D.Double(lastPt, pt)); lastStates.put(state.getSrc(), pt); state = iterator.next(); } }