public static void main(String[] args) { GuiUtils.setLookAndFeel(); OperationLimits limits = new OperationLimits(); limits.setMaxSpeed(100d); OperationLimitsPanel panel = new OperationLimitsPanel(new MissionType(), true); panel.setLimits(limits); GuiUtils.testFrame(panel); }
private void init() { final WaitPanel wait = new WaitPanel(); wait.start(); GuiUtils.setLookAndFeel(); t = new Thread() { public void run() { createMenuBar(); createRender(); Runnable r = new Runnable() { public void run() { setLayout(new BorderLayout()); add(menu, BorderLayout.NORTH); add(render, BorderLayout.CENTER); wait.stop(); } }; SwingUtilities.invokeLater(r); } }; // t.start(); createMenuBar(); createRender(); setLayout(new BorderLayout()); add(menu, BorderLayout.NORTH); add(render, BorderLayout.CENTER); wait.stop(); }
/** * This method initializes jDialog * * @return javax.swing.JDialog */ private JDialog getJDialog() { if (jDialog == null) { jDialog = new JDialog(); jDialog.setContentPane(getJContentPane()); jDialog.setTitle(title); jDialog.setSize(this.getWidth() + 5, this.getHeight() + 35); jDialog.setLayout(new BorderLayout()); jDialog.getContentPane().add(this, BorderLayout.CENTER); jDialog.setModal(true); jDialog.setAlwaysOnTop(true); GuiUtils.centerOnScreen(jDialog); jDialog.setResizable(false); jDialog.setAlwaysOnTop(true); jDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); jDialog.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { JOptionPane.showMessageDialog(jDialog, "You must enter a password!"); } }); // getJContentPane().paintImmediately(0, 0, 300, 300); jDialog.setIconImage(ImageUtils.getImage("images/neptus-icon.png")); jDialog.toFront(); jDialog.setFocusTraversalPolicy(new PasswordPanelFocusTraversalPolicy()); jDialog.setVisible(true); } return jDialog; }
/** * Shutdown. Stops the {@link #openNode} and {@link #messageProcessor} and clears the messages * queue. Calls the stopMsgProcessing on the vehicle comms. Then sends a {@link #MANAGER_STOP} * event. * * <p style="color='GREEN'">This one needs to be called if you override it. * * @return */ @Override public synchronized boolean stop() { boolean ret; try { if (!started) return true; // do nothing NeptusLog.pub().debug("Stopping comms"); if (timerThread != null) { timerThread.interrupt(); timerThread = null; } stopManagerComms(); if (messageProcessor != null) { messageProcessor.stopProcessing(); messageProcessor = null; msgQueue.clear(); infoQueue.clear(); } for (SystemCommBaseInfo<M, Mi, I> vic : commInfo.values()) { vic.stopMsgProcessing(); } sendManagerStatusChanged(MANAGER_STOP, ""); started = false; ret = true; } catch (Exception e) { GuiUtils.errorMessage(ConfigFetch.getSuperParentFrame(), e); NeptusLog.pub().error("CommBase Manager init error!", e); ret = false; } super.stop(); return ret; }
@Override public void sendMessage(IridiumMessage msg) throws Exception { VehicleType vt = VehiclesHolder.getVehicleWithImc(new ImcId16(msg.getDestination())); if (vt == null) { throw new Exception("Cannot send message to an unknown destination"); } IridiumArgs args = (IridiumArgs) vt.getProtocolsArgs().get("iridium"); if (askRockBlockPassword || rockBlockPassword == null || rockBlockUsername == null) { Pair<String, String> credentials = GuiUtils.askCredentials( ConfigFetch.getSuperParentFrame(), "Enter RockBlock Credentials", getRockBlockUsername(), getRockBlockPassword()); if (credentials == null) return; setRockBlockUsername(credentials.first()); setRockBlockPassword(credentials.second()); PluginUtils.saveProperties("conf/rockblock.props", this); askRockBlockPassword = false; } String result = sendToRockBlockHttp( args.getImei(), getRockBlockUsername(), getRockBlockPassword(), msg.serialize()); if (result != null) { if (!result.split(",")[0].equals("OK")) { throw new Exception("RockBlock server failed to deliver the message: '" + result + "'"); } } }
public static void main(String[] args) { Rhodamine3DToolbar toolbar = new Rhodamine3DToolbar(null); toolbar.createtoolBar(); GuiUtils.testFrame( toolbar, "Test toolbar: " + toolbar.getClass().getSimpleName(), ICON_SIZE + 25, ICON_SIZE * 3 + 500); }
@Override public Collection<IridiumMessage> pollMessages(Date timeSince) throws Exception { if (askGmailPassword || gmailPassword == null || gmailUsername == null) { Pair<String, String> credentials = GuiUtils.askCredentials( ConfigFetch.getSuperParentFrame(), "Enter Gmail Credentials", getGmailUsername(), getGmailPassword()); if (credentials == null) return null; setGmailUsername(credentials.first()); setGmailPassword(credentials.second()); PluginUtils.saveProperties("conf/rockblock.props", this); askGmailPassword = false; } Properties props = new Properties(); props.put("mail.store.protocol", "imaps"); ArrayList<IridiumMessage> messages = new ArrayList<>(); try { Session session = Session.getDefaultInstance(props, null); Store store = session.getStore("imaps"); store.connect("imap.gmail.com", getGmailUsername(), getGmailPassword()); Folder inbox = store.getFolder("Inbox"); inbox.open(Folder.READ_ONLY); int numMsgs = inbox.getMessageCount(); for (int i = numMsgs; i > 0; i--) { Message m = inbox.getMessage(i); if (m.getReceivedDate().before(timeSince)) { break; } else { MimeMultipart mime = (MimeMultipart) m.getContent(); for (int j = 0; j < mime.getCount(); j++) { BodyPart p = mime.getBodyPart(j); Matcher matcher = pattern.matcher(p.getContentType()); if (matcher.matches()) { InputStream stream = (InputStream) p.getContent(); byte[] data = IOUtils.toByteArray(stream); IridiumMessage msg = process(data, matcher.group(1)); if (msg != null) messages.add(msg); } } } } } catch (NoSuchProviderException ex) { ex.printStackTrace(); System.exit(1); } catch (MessagingException ex) { ex.printStackTrace(); System.exit(2); } return messages; }
private void printErrors(String[] errors) { String errorsString = "<html>" + I18n.text("The following errors were found") + ":<br>"; int i = 1; for (String error : errors) { errorsString = errorsString + "<br> " + (i++) + ") " + error; } errorsString = errorsString + "</html>"; GuiUtils.errorMessage( new JFrame(I18n.text("Error")), I18n.text("Invalid properties"), errorsString); }
public void selectFile() { final JFileChooser chooser = new JFileChooser(overlays.defaultDirectory); chooser.setFileFilter( GuiUtils.getCustomFileFilter(I18n.text("LSF log files"), new String[] {"lsf", "lsf.gz"})); chooser.setApproveButtonText(I18n.text("Open Log")); int option = chooser.showOpenDialog(overlays.getConsole()); if (option != JFileChooser.APPROVE_OPTION) return; else { Thread logLoading = new Thread( new Runnable() { @Override public void run() { final ProgressMonitor monitor = new ProgressMonitor( overlays.getConsole(), I18n.text("Opening LSF log"), I18n.text("Opening LSF log"), 0, 100); try { clearOverlays(); fileLabel.setText("loading..."); logFile = chooser.getSelectedFile(); LsfLogSource source = new LsfLogSource( chooser.getSelectedFile(), new LsfIndexListener() { @Override public void updateStatus(String messageToDisplay) { monitor.setNote(messageToDisplay); } }); logSource = source; loadOverlays(source); } catch (Exception e) { GuiUtils.errorMessage(overlays.getConsole(), e); } SwingUtilities.invokeLater( new Runnable() { @Override public void run() { fileLabel.setText(chooser.getSelectedFile().getParentFile().getName()); } }); monitor.close(); overlays.defaultDirectory = chooser.getSelectedFile().getParent(); } }); logLoading.start(); } }
private void drawLegend(Graphics2D g, ColorMap cmap, int var) { if (dd.maxVal == null) return; g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setTransform(new AffineTransform()); g.setColor(new Color(255, 255, 255, 100)); g.fillRoundRect(10, 10, 100, 170, 10, 10); ColorBar cb = new ColorBar(ColorBar.VERTICAL_ORIENTATION, cmap); cb.setSize(15, 80); g.setColor(Color.black); Font prev = g.getFont(); g.setFont(new Font("Helvetica", Font.BOLD, 14)); // g.drawString(varNames[var], 15, 25); g.setFont(prev); g.translate(15, 45); cb.paint(g); g.translate(-10, -15); try { g.drawString(GuiUtils.getNeptusDecimalFormat(2).format(dd.maxVal[var]), 28, 20); g.drawString( GuiUtils.getNeptusDecimalFormat(2).format((dd.maxVal[var] + dd.minVal[var]) / 2), 28, 60); g.drawString(GuiUtils.getNeptusDecimalFormat(2).format(dd.minVal[var]), 28, 100); } catch (Exception e) { NeptusLog.pub().error(e); e.printStackTrace(); } g.translate(10, 120); g.drawLine(0, -3, 0, 3); g.drawLine(0, 0, 90, 0); g.drawLine(90, -3, 90, 3); // double meters = scaleX * 90; g.drawString(GuiUtils.getNeptusDecimalFormat(2).format(90d / scaleX) + " m", 25, 15); }
public static void main(String[] args) { TranslationTableModel model = new TranslationTableModel(new File("conf/localization/pt")); JXTable table = new JXTable(model); table.setRowSelectionAllowed(true); JScrollPane scroll = new JScrollPane(table); GuiUtils.testFrame(scroll); Vector<Integer> searchResults = model.search("PLUGINNAME"); for (int i : searchResults) { table.getSelectionModel().addSelectionInterval(i, i); } }
public static void generateColorMap( Point2D[] points, Double[] vals, Graphics2D destination, double width, double height, int alpha, ColorMap colorMap, boolean drawPoints) { generateInterpolatedColorMap(points, vals, destination, width, height, alpha, colorMap); if (points.length == 0) return; double minX = points[0].getX(); double maxX = minX; double minY = points[0].getY(); double maxY = minY; for (int i = 0; i < points.length; i++) { if (points[i].getX() < minX) minX = points[i].getX(); else if (points[i].getX() > maxX) maxX = points[i].getX(); if (points[i].getY() < minY) minY = points[i].getY(); else if (points[i].getY() > maxY) maxY = points[i].getY(); } if (drawPoints) { Graphics2D g = destination; g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.black); double scaleX = (width) / (maxX - minX); double scaleY = (height) / (maxY - minY); for (int i = 0; i < points.length; i++) { double dx = (points[i].getX() - minX) * scaleX; double dy = (points[i].getY() - minY) * scaleY; g.translate(dx, dy); g.drawLine(-3, -3, 3, 3); g.drawLine(-3, 3, 3, -3); g.drawString("" + GuiUtils.getNeptusDecimalFormat(1).format(vals[i]), 10, 10); g.translate(-dx, -dy); } } }
public static void main(String[] args) { Location loc = new Location(41, -8); Location loc0 = new Location(loc); Location loc1 = new Location(loc); Location loc2 = new Location(loc); Location loc3 = new Location(loc); Location loc4 = new Location(loc); Location loc5 = new Location(loc); loc1.translate(15, 8.5, 0); loc2.translate(5, 10, 0); loc3.translate(10, 7, 0); loc4.translate(3, 5, 0); loc5.translate(00, 12, 20); Location[] locs = new Location[] {loc0, loc1, loc2}; Double[] values = new Double[] {0d, 600d, 340d}; BufferedImage img = new BufferedImage(800, 600, BufferedImage.TYPE_INT_ARGB); generateColorMap( locs, values, (Graphics2D) img.getGraphics(), (double) img.getWidth(), (double) img.getHeight(), 255, ColorMapFactory.createInvertedColorMap( (InterpolationColorMap) ColorMapFactory.createGrayScaleColorMap())); // generateColorMap(locs, values, (Graphics2D)img.getGraphics(), (double)img.getWidth(), // (double)img.getHeight(),255, ColorMapFactory.createJetColorMap()); JLabel lbl = new JLabel(new ImageIcon(img)); GuiUtils.testFrame(lbl); }
private void solve() { if (pe == null) { GuiUtils.errorMessage(getConsole(), "Coverage Plan Solver", "The polygon is not valid"); return; } double north, east, south, west; double[] bounds = pe.getBounds3d(); south = bounds[PathElement.SOUTH_COORD]; west = bounds[PathElement.WEST_COORD]; north = bounds[PathElement.NORTH_COORD]; east = bounds[PathElement.EAST_COORD]; CoverageCell[][] cells = new CoverageCell[(int) ((north - south) / grid) + 1][(int) ((east - west) / grid) + 1]; for (int i = 0; i < cells.length; i++) for (int j = 0; j < cells[i].length; j++) { cells[i][j] = new CoverageCell(); cells[i][j].i = i; cells[i][j].j = j; } int i = 0, j = 0; int desiredCells = 0; for (double n = south + grid / 2; n < north; n += grid) { j = 0; for (double e = west + grid / 2; e < east; e += grid) { LocationType lt = new LocationType(pe.getCenterLocation()); lt.translatePosition(n, e, 0); CoverageCell cell = cells[i][j]; cell.realWorldLoc = lt.getNewAbsoluteLatLonDepth(); if (pe.containsPoint(lt, null)) { cell.desired = true; desiredCells++; } cells[i][j] = cell; j++; } i++; } CoverageCell initialCell = null; i = 0; for (j = 0; j < cells[0].length - 1 && initialCell == null; j++) for (i = 0; i < cells.length && initialCell == null; i++) if (cells[i][j].desired) initialCell = cells[i][j]; if (initialCell == null) { GuiUtils.errorMessage("Polygon coverage", "Polygon area is invalid"); return; } CoverageCell current = initialCell; desiredCells--; int dir = -1; while (desiredCells > 0) { current.visited = true; current.active = false; if (dir == 1) { if (current.i < cells.length - 1 && cells[current.i + 1][current.j].desired == true && cells[current.i + 1][current.j].visited == false) { current.next = cells[current.i + 1][current.j]; cells[current.i + 1][current.j].previous = current; current = current.next; current.active = true; } else { dir = -1; if (current.j == cells[0].length - 1) break; while (!cells[current.i][current.j + 1].desired && i > 0 && current.previous != null) { current.active = false; current = current.previous; } if (i == 0) break; current.next = cells[current.i][current.j + 1]; cells[current.i][current.j + 1].previous = current; current = current.next; current.active = true; } } else { if (current.i > 0 && cells[current.i - 1][current.j].desired == true && cells[current.i - 1][current.j].visited == false) { current.next = cells[current.i - 1][current.j]; cells[current.i - 1][current.j].previous = current; current = current.next; current.active = true; } else { dir = 1; if (current.j == cells[0].length - 1) break; while (current.previous != null && !cells[current.i][current.j + 1].desired && i < cells.length) { current.active = false; current = current.previous; } if (i == cells.length) break; current.next = cells[current.i][current.j + 1]; cells[current.i][current.j + 1].previous = current; current = current.next; current.active = true; } } desiredCells--; } generatePlans(cells, initialCell); }
public static void main(String[] args) { MiGLayoutXmlPropertyEditor xp = new MiGLayoutXmlPropertyEditor(); GuiUtils.testFrame(xp.button); }
/** @param args */ public static void main(String[] args) { SymbolLabel symb1 = new SymbolLabel(); symb1.setSize(20, 50); JXPanel panel = new JXPanel(); panel.setLayout(new BorderLayout()); panel.add(symb1, BorderLayout.CENTER); GuiUtils.testFrame(panel); // try { Thread.sleep(2000); } catch (InterruptedException e) { } // symb1.toggleActive(); // symb1.repaint(); // // try { Thread.sleep(100); } catch (InterruptedException e) { } // symb1.toggleActive(); // symb1.repaint(); // // try { Thread.sleep(100); } catch (InterruptedException e) { } // symb1.toggleActive(); // symb1.repaint(); // // try { Thread.sleep(200); } catch (InterruptedException e) { } // symb1.toggleActive(); // symb1.repaint(); // // try { Thread.sleep(300); } catch (InterruptedException e) { } // symb1.toggleActive(); // symb1.repaint(); // // try { Thread.sleep(400); } catch (InterruptedException e) { } // symb1.toggleActive(); // symb1.repaint(); // // try { Thread.sleep(650); } catch (InterruptedException e) { } // symb1.toggleActive(); // symb1.repaint(); // // try { Thread.sleep(100); } catch (InterruptedException e) { } // symb1.toggleActive(); // symb1.repaint(); // // try { Thread.sleep(100); } catch (InterruptedException e) { } // symb1.toggleActive(); // symb1.repaint(); // // try { Thread.sleep(2000); } catch (InterruptedException e) { } // symb1.toggleActive(); // symb1.repaint(); // // try { Thread.sleep(300); } catch (InterruptedException e) { } // symb1.toggleActive(); // symb1.repaint(); // // try { Thread.sleep(400); } catch (InterruptedException e) { } // symb1.toggleActive(); // symb1.repaint(); // // try { Thread.sleep(10650); } catch (InterruptedException e) { } // symb1.toggleActive(); // symb1.repaint(); }
public OperationLimitsPanel(MissionType mt, boolean editArea) { this.mt = mt; setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); maxDepthCheck = new JCheckBox(I18n.text("Maximum Depth (m)")); minAltitudeCheck = new JCheckBox(I18n.text("Minimum Altitude (m)")); maxAltitudeCheck = new JCheckBox(I18n.text("Maximum Altitude (m)")); minSpeedCheck = new JCheckBox(I18n.text("Minimum Speed (m/s)")); maxSpeedCheck = new JCheckBox(I18n.text("Maximum Speed (m/s)")); areaCheck = new JCheckBox(I18n.text("Area Limits")); maxVRateCheck = new JCheckBox(I18n.text("Maximum Vertical Rate (m/s)")); maxDepthField = new JFormattedTextField(GuiUtils.getNeptusDecimalFormat(1) /*NumberFormat.getInstance()*/); maxAltitudeField = new JFormattedTextField(GuiUtils.getNeptusDecimalFormat(1) /*NumberFormat.getInstance()*/); minAltitudeField = new JFormattedTextField(GuiUtils.getNeptusDecimalFormat(1) /*NumberFormat.getInstance()*/); maxSpeedField = new JFormattedTextField(GuiUtils.getNeptusDecimalFormat(1) /*NumberFormat.getInstance()*/); minSpeedField = new JFormattedTextField(GuiUtils.getNeptusDecimalFormat(1) /*NumberFormat.getInstance()*/); maxVRateField = new JFormattedTextField(GuiUtils.getNeptusDecimalFormat(1) /*NumberFormat.getInstance()*/); JPanel tmp = new JPanel(new GridLayout(0, 2, 2, 10)); tmp.add(maxDepthCheck); tmp.add(maxDepthField); tmp.add(maxAltitudeCheck); tmp.add(maxAltitudeField); tmp.add(minAltitudeCheck); tmp.add(minAltitudeField); tmp.add(maxSpeedCheck); tmp.add(maxSpeedField); tmp.add(minSpeedCheck); tmp.add(minSpeedField); tmp.add(maxVRateCheck); tmp.add(maxVRateField); tmp.add(areaCheck); JButton b = new JButton(I18n.text("Select...")); b.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { RectangleEditor editor = new RectangleEditor(OperationLimitsPanel.this.mt); if (limits.getOpAreaLat() != null) { editor.pp = new ParallelepipedElement( MapGroup.getMapGroupInstance(OperationLimitsPanel.this.mt), null); editor.pp.setWidth(limits.getOpAreaWidth()); editor.pp.setLength(limits.getOpAreaLength()); editor.pp.setYawDeg(Math.toDegrees(limits.getOpRotationRads())); LocationType lt = new LocationType(); lt.setLatitudeDegs(limits.getOpAreaLat()); lt.setLongitudeDegs(limits.getOpAreaLon()); editor.pp.setCenterLocation(lt); editor.pp.setMyColor(Color.red); editor.btnOk.setEnabled(true); } ParallelepipedElement rectangle = editor.showDialog(OperationLimitsPanel.this); if (rectangle != null) { double lld[] = rectangle.getCenterLocation().getAbsoluteLatLonDepth(); limits.setOpAreaLat(lld[0]); limits.setOpAreaLon(lld[1]); limits.setOpAreaLength(rectangle.getLength()); limits.setOpAreaWidth(rectangle.getWidth()); limits.setOpRotationRads(rectangle.getYawRad()); } } }); tmp.add(b); if (!editArea) b.setEnabled(false); add(tmp); }
public static void main(String[] args) { ConfigFetch.initialize(); GuiUtils.setLookAndFeel(); GuiUtils.testFrame(new LogBook()); }
@SuppressWarnings("unchecked") public void openFile(File fx) { saveFile = null; File file; if (fx == null) file = showOpenImageDialog(); else file = fx; if (file != null) { if ("3ds".equalsIgnoreCase(FileUtil.getFileExtension(file))) { if (lobj != null) render.removeObj3D(lobj); Inspector3DS loader = new Inspector3DS(file.getAbsolutePath()); // constructor loader.parseIt(); // process the file TransformGroup theModel1 = loader.getModel(); // get the // resulting 3D NeptusLog.waste().info("Point to view window " + Util3D.getModelDim(theModel1)); lobj = new Obj3D(); lobj.setModel3D(theModel1); // lobj.setRoll(Math.PI/2); render.addObj3D(lobj); update3dFilesOpened(file); } else if ("wrl".equalsIgnoreCase(FileUtil.getFileExtension(file))) { /* * try { * * if (lobj != null) render.removeObj3D(lobj); * * String filename = file.getAbsolutePath(); VrmlLoader loader = * new VrmlLoader(); * * BufferedReader in = null; in = new BufferedReader(new * InputStreamReader(new FileInputStream(filename), "UTF8")); * * URL url = FileUtil.pathToURL(file.getParent()+"/"); * loader.setBaseUrl(url); * * Scene scene = loader.load(in); BranchGroup branch = * scene.getSceneGroup(); * * TransformGroup ret = new TransformGroup(); Enumeration<Group> * enume = branch.getAllChildren(); while * (enume.hasMoreElements()) { Group next = enume.nextElement(); * branch.removeChild(next); ret.addChild(next); } * lobj.setModel3D(ret); //lobj.setRoll(Math.PI / 2); * render.addObj3D(lobj); * * * } catch (Throwable e) { e.printStackTrace(); * GuiUtils.errorMessage(this, "Load", * "Error Loading WRL File"); * * } */ // -------------------------------------------------------- if (lobj != null) render.removeObj3D(lobj); Loader myFileLoader = null; // holds the file loader Scene myVRMLScene = null; // holds the loaded scene BranchGroup myVRMLModel = null; // BG of the VRML scene try { // create an instance of the Loader myFileLoader = new org.web3d.j3d.loaders.VRML97Loader(); myFileLoader.setBasePath(file.getParent()); myFileLoader.setFlags( myFileLoader.getFlags() | org.web3d.j3d.loaders.VRML97Loader.LOAD_BEHAVIOR_NODES); // Load the scene from your VRML97 file myVRMLScene = myFileLoader.load(file.getAbsolutePath()); // Obtain the root BranchGroup for the Scene myVRMLModel = myVRMLScene.getSceneGroup(); lobj = new Obj3D(); TransformGroup scene = new TransformGroup(); Enumeration<Node> enume = myVRMLModel.getAllChildren(); while (enume.hasMoreElements()) { Node next = enume.nextElement(); myVRMLModel.removeChild(next); scene.addChild(next); } lobj.setModel3D(scene); // lobj.setRoll(Math.PI / 2); render.addObj3D(lobj); /* * VrmlLoader f = new VrmlLoader(); Scene s = null; * BranchGroup myVRMLModel = null; //BG of the VRML scene * try { //f.setFlags(VrmlLoader.LOAD_ALL); s = * f.load(file.getAbsolutePath()); // Obtain the root * BranchGroup for the Scene myVRMLModel = * s.getSceneGroup(); lobj = new Obj3D(); TransformGroup * scene = new TransformGroup(); Enumeration<Group> enume = * myVRMLModel.getAllChildren(); while * (enume.hasMoreElements()) { Group next = * enume.nextElement(); myVRMLModel.removeChild(next); * scene.addChild(next); } lobj.setModel3D(scene); * //lobj.setRoll(Math.PI / 2); render.addObj3D(lobj); } * catch (FileNotFoundException e) { e.printStackTrace(); * GuiUtils.errorMessage(this, "Load", * "Error Loading WRL File"); } */ update3dFilesOpened(file); System.err.println("fez o load----------"); } catch (Exception e) { // in case there was a problem, print the stack out e.printStackTrace(); // we still need a model, even if we can't load the right // one, I use a color cube just in case GuiUtils.errorMessage(this, "Load", "Error Loading WRL File"); } } else if ("x3d".equalsIgnoreCase(FileUtil.getFileExtension(file)) || "x3dv".equalsIgnoreCase(FileUtil.getFileExtension(file))) { if (lobj != null) render.removeObj3D(lobj); Loader myFileLoader = null; // holds the file loader Scene myVRMLScene = null; // holds the loaded scene BranchGroup myVRMLModel = null; // BG of the VRML scene try { // create an instance of the Loader myFileLoader = new org.web3d.j3d.loaders.X3DLoader(); myFileLoader.setBasePath(file.getParent()); // myFileLoader.setFlags(org.web3d.j3d.loaders.X3DLoader.LOAD_ALL); // Load the scene from your VRML97 file myVRMLScene = myFileLoader.load(file.getAbsolutePath()); // Obtain the root BranchGroup for the Scene myVRMLModel = myVRMLScene.getSceneGroup(); lobj = new Obj3D(); TransformGroup scene = new TransformGroup(); Enumeration<Group> enume = myVRMLModel.getAllChildren(); while (enume.hasMoreElements()) { Group next = enume.nextElement(); myVRMLModel.removeChild(next); scene.addChild(next); } lobj.setModel3D(scene); // lobj.setRoll(Math.PI / 2); render.addObj3D(lobj); update3dFilesOpened(file); System.err.println("fez o load----------"); } catch (Exception e) { // in case there was a problem, print the stack out e.printStackTrace(); // we still need a model, even if we can't load the right // one, I use a color cube just in case GuiUtils.errorMessage(this, "Load", "Error Loading x3D File"); } } else if ("j3d".equalsIgnoreCase(FileUtil.getFileExtension(file))) { if (lobj != null) render.removeObj3D(lobj); BranchGroup bg = null; try { SceneGraphFileReader filer = new SceneGraphFileReader(file); bg = (filer.readAllBranchGraphs())[0]; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (bg == null) { NeptusLog.pub().error("Error loading vehicle model\n" + this); } TransformGroup scene = new TransformGroup(); Enumeration<Group> enume = bg.getAllChildren(); while (enume.hasMoreElements()) { Group next = enume.nextElement(); bg.removeChild(next); scene.addChild(next); } lobj = new Obj3D(); lobj.setModel3D(scene); // lobj.setRoll(Math.PI / 2); render.addObj3D(lobj); update3dFilesOpened(file); } else GuiUtils.errorMessage(this, "Load", "Invalid file type."); } }
void generatePlans(CoverageCell[][] mat, CoverageCell first) { Vector<String> selectedVehicles = new Vector<String>(); Vector<SystemsList> tmp = getConsole().getSubPanelsOfClass(SystemsList.class); selectedVehicles.addAll(tmp.get(0).getSelectedSystems(true)); Object planid; if (selectedVehicles.size() > 1) planid = JOptionPane.showInputDialog(getConsole(), "Enter desired plan prefix"); else planid = JOptionPane.showInputDialog(getConsole(), "Enter desired plan name"); MissionType mission = getConsole().getMission(); if (mission == null) { GuiUtils.errorMessage(getConsole(), "Coverage Plan Solver", "No mission has been set"); return; } if (selectedVehicles.size() <= 1) { CoverageCell current = first, next = current.next; PlanCreator creator = new PlanCreator(mission); creator.setLocation(first.realWorldLoc); // creator.addManeuver("Goto"); while (next != null) { if (next.j != current.j) { CoverageCell pivot = current; while (pivot.previous != null && pivot.previous.i == current.i) pivot = pivot.previous; creator.setLocation(pivot.realWorldLoc); creator.addManeuver("Goto"); creator.setLocation(next.realWorldLoc); creator.addManeuver("Goto"); } current = next; next = current.next; } PlanType plan = creator.getPlan(); plan.setId(planid.toString()); plan.setVehicle(getConsole().getMainSystem()); mission.addPlan(plan); mission.save(false); getConsole().updateMissionListeners(); } else { double distance = 0; CoverageCell current = first, next = current.next; distance += current.realWorldLoc.getDistanceInMeters(next.realWorldLoc); while (next != null) { if (next.j != current.j) { CoverageCell pivot = current; while (pivot.previous != null && pivot.previous.i == current.i) pivot = pivot.previous; } distance += current.realWorldLoc.getDistanceInMeters(next.realWorldLoc); current = next; next = current.next; } double distEach = distance / selectedVehicles.size(); current = first; next = current.next; PlanCreator creator = new PlanCreator(mission); creator.setLocation(current.realWorldLoc); distance = 0; int curIndex = 0; while (next != null) { if (next.j != current.j) { CoverageCell pivot = current; while (pivot.previous != null && pivot.previous.i == current.i) pivot = pivot.previous; creator.setLocation(pivot.realWorldLoc); creator.addManeuver("Goto"); distance += current.realWorldLoc.getDistanceInMeters(next.realWorldLoc); if (distance < distEach) { creator.setLocation(next.realWorldLoc); creator.addManeuver("Goto"); } } else distance += current.realWorldLoc.getDistanceInMeters(next.realWorldLoc); if (distance > distEach) { creator.setLocation(current.realWorldLoc); creator.addManeuver("Goto"); PlanType plan = creator.getPlan(); plan.setVehicle(selectedVehicles.get(curIndex)); plan.setId(planid + "_" + selectedVehicles.get(curIndex++)); mission.addPlan(plan); creator = new PlanCreator(mission); creator.setLocation(current.realWorldLoc); creator.addManeuver("Goto"); distance = 0; } current = next; next = current.next; } PlanType plan = creator.getPlan(); plan.setVehicle(selectedVehicles.get(curIndex)); plan.setId(planid + "_" + selectedVehicles.get(curIndex++)); mission.addPlan(plan); mission.save(false); getConsole().updateMissionListeners(); } }