Exemplo n.º 1
0
    /** ok, the importer has now finished, we can tidy up now */
    public final void doFinished() {
      // also have a pass through to set the stepper in any narratives
      // try to set the pointer to the TimeStepper in the narratives, if there are any
      Session newSession = _theApplication.getCurrentSession();
      if (newSession != null) {
        Layers theData = newSession.getData();
        Debrief.GUI.Views.PlainView pv = newSession.getCurrentView();
        if (pv instanceof Debrief.GUI.Views.AnalysisView) {
          int len = theData.size();
          for (int i = 0; i < len; i++) {
            Layer ly = theData.elementAt(i);
            if (ly instanceof Debrief.Wrappers.NarrativeWrapper) {
              @SuppressWarnings("unused")
              Debrief.Wrappers.NarrativeWrapper nw = (Debrief.Wrappers.NarrativeWrapper) ly;
            } // whether this is a narrative
          } // through the layers
        } // whether this is an analysis view
      } // if we managed to create a session

      // put the filename into the MRU
      Debrief.GUI.Frames.Application.addToMru(_theFile.getPath());

      // and restore the application cursor
      _theApplication.restoreCursor();
    }
Exemplo n.º 2
0
  /**
   * process this list of file
   *
   * @param files the list of files
   */
  public final void FilesReceived(final java.util.Vector<File> files) {
    // get our layers object
    // Layers newLayers = new Layers();
    final Layers newLayers = _theSession.getData();

    _theParent.setCursor(java.awt.Cursor.WAIT_CURSOR);

    java.io.File[] theFiles = new java.io.File[] {null};
    theFiles = (java.io.File[]) files.toArray(theFiles);

    // ok, go for it!
    final MWC.Utilities.ReaderWriter.ImportManager.BaseImportCaller caller =
        new MWC.Utilities.ReaderWriter.ImportManager.BaseImportCaller(theFiles, newLayers) {
          // handle the completion of each file
          public void fileFinished(final java.io.File fName, final Layers newData) {}

          // handle completion of the full import process
          public void allFilesFinished(final java.io.File[] fNames, final Layers newData) {
            // _theSession.getData().addThis(newData);

            _theSession.getData().fireExtended();

            // and get the plot to redraw

            // create a deferred event, to run immediately all of this madness is
            // over.
            // with these events inlined, the plot itself wasn't actaully getting.
            // Putting
            // them into invokeLater triggers the refresh after the current
            // processing is complete
            javax.swing.SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    _theChart.rescale();
                    _theChart.update();
                  }
                });

            // and clear the busy flag
            _theParent.restoreCursor();
          }
        };

    // ok, get going!
    caller.start();
  }
Exemplo n.º 3
0
  /** <code>buildTheInterface</code> puts the bits together */
  protected final void buildTheInterface() {

    // we've had to do this here, so that we know we've foudn the chart
    addTools();

    // retrieve the tools for this interface
    final Enumeration<MenuItemInfo> iter = getTools();

    while (iter.hasMoreElements()) {
      final MenuItemInfo thisItem = iter.nextElement();

      addThisTool(thisItem);
    }

    // setup our double-click editor
    // and add our dbl click listener
    getChart().addCursorDblClickedListener(new DblClickEdit(getProperties()));

    // create our right click editor, and add it's helpers
    final RightClickEdit rc = new RightClickEdit(getProperties());
    rc.addMenuCreator(new MWC.Algorithms.Editors.ProjectionEditPopupMenuAdaptor());
    rc.addMenuCreator(new MWC.GUI.LayerManager.EditLayersPopupMenuAdaptor());
    rc.addMenuCreator(new MWC.GUI.Canvas.EditCanvasPopupMenuAdaptor(getChart().getCanvas()));

    _toteAdapter = new Debrief.GUI.Tote.RightClickEditToteAdaptor(_theTote);
    rc.addPlottableMenuCreator(_toteAdapter, _theProperties);

    // keep local reference to the right-clicker, to overcome a memory leak
    _rightClicker =
        new RightClickCutCopyAdaptor(_theSession.getClipboard(), _theSession.getUndoBuffer());
    rc.addPlottableMenuCreator(_rightClicker, _theProperties);
    rc.addPlottableMenuCreator(
        new RightClickPasteAdaptor(_theSession.getClipboard()), _theProperties);

    // we also want to try to give these properties to the layers object, so
    // that it can be edited
    // properly by the right-clicking in the Layer Manager
    _theSession.getData().setEditor(rc);

    // and add our right-click editor
    getChart().addRightClickListener(rc);
  }
Exemplo n.º 4
0
  /** build the list of tools necessary for this type of view */
  private void addTools() {

    _theTools.addElement(
        new MenuItemInfo(
            "File", null, "Save", new SavePlotXML(_theParent, _theSession), null, ' '));
    _theTools.addElement(
        new MenuItemInfo(
            "File", null, "Save As", new SavePlotAsXML(_theParent, _theSession), null, ' '));
    _theTools.addElement(
        new MenuItemInfo(
            "File",
            null,
            "Save WMF",
            new WriteMetafile(_theParent, _theChart, _theSession.getData()),
            null,
            ' '));
    // _theTools.addElement(new MenuItemInfo(null, "Copy to clipboard", new
    // WriteClipboard(_theParent, _theChart, _theSession.getData()), null,
    // ' '));
    _theTools.addElement(
        new MenuItemInfo(
            "File", null, "Import", new ImportData2(_theParent, null, _theSession), null, ' '));
    _theTools.addElement(
        new MenuItemInfo(
            "File",
            null,
            "Import Range",
            new ImportRangeData(_theParent, _theProperties, _theSession.getData()),
            null,
            'G'));

    // NOTE: wrap this next creator, in case we haven't got the right files
    // avaialble
    try {
      _theTools.addElement(
          new MenuItemInfo(
              "File",
              null,
              "Record to video",
              new ShowVideo(_theParent, _theProperties, _theChart.getPanel()),
              null,
              ' '));
    } catch (java.lang.NoClassDefFoundError e) {
      System.err.println("Record to video not provided, JMF classes not found");
      // e.printStackTrace();
    }

    _theTools.addElement(
        new MenuItemInfo("View", null, "Repaint", new Repaint(_theParent, _theChart), null, 'R'));

    // ////////////////////////
    // second row
    // ////////////////////////

    // _theTools.addElement(new MenuItemInfo(null, "Print Chart", new
    // PrintChart(_theParent, _theChart), null, 'f'));
    _theTools.addElement(
        new MenuItemInfo("View", null, "Fit", new FitToWin(_theParent, _theChart), null, 'f'));
    _theTools.addElement(
        new MenuItemInfo("View", "Drag", "Pan", new Pan(_theChart, _theParent, null), null, 'P'));
    _theTools.addElement(
        new MenuItemInfo(
            "View",
            "Drag",
            "Rng Brg",
            new RangeBearing(_theChart, _theParent, getStatusBar()),
            null,
            'B'));
    _theTools.addElement(
        new MenuItemInfo("View", "Drag", "Zoom", new ZoomIn(_theChart, _theParent), null, 'I'));
    _theTools.addElement(
        new MenuItemInfo(
            "View",
            null,
            "Zoom Out",
            new ZoomOut(_theParent, _theChart),
            new java.awt.MenuShortcut(java.awt.event.KeyEvent.VK_SUBTRACT),
            'O'));

    // //////////////////////////////////////////////////////////
    // now the decorations
    // //////////////////////////////////////////////////////////
    // find the decorations layer
    final Layer decs = _theSession.getData().findLayer(Layers.CHART_FEATURES);
    _theTools.addElement(
        new MenuItemInfo(
            Layers.CHART_FEATURES,
            null,
            "Create Scale",
            new CreateScale(_theParent, _theProperties, decs, _theSession.getData(), _theChart),
            null,
            ' '));

    _theTools.addElement(
        new MenuItemInfo(
            Layers.CHART_FEATURES,
            null,
            "Create Grid",
            new CreateGrid(_theParent, _theProperties, decs, _theSession.getData(), _theChart),
            null,
            ' '));
    _theTools.addElement(
        new MenuItemInfo(
            Layers.CHART_FEATURES,
            null,
            "Create Local Grid",
            new CreateLocalGrid(_theParent, _theProperties, decs, _theSession.getData(), _theChart),
            null,
            ' '));

    _theTools.addElement(
        new MenuItemInfo(
            Layers.CHART_FEATURES,
            null,
            "Create Coast",
            new CreateCoast(_theParent, _theProperties, decs, _theSession.getData(), _theChart),
            null,
            ' '));
    // let's not read in the VPF reference layer, since we can't get OpenMap
    // code to read
    // it in from the jar file.
    /*
     * _theTools.addElement(new MenuItemInfo(Layers.CHART_FEATURES, null,
     * "Create VPF Coast", new CreateVPFCoast(_theParent, _theProperties, decs,
     * _theChart),null, ' ' ));
     */
    _theTools.addElement(
        new MenuItemInfo(
            Layers.CHART_FEATURES,
            null,
            "Create VPF Layers",
            new CreateVPFLayers(_theParent, _theProperties, decs, _theSession.getData(), _theChart),
            null,
            ' '));
    _theTools.addElement(
        new MenuItemInfo(
            Layers.CHART_FEATURES,
            null,
            "Create ETOPO Bathy",
            new CreateTOPO(_theParent, _theProperties, _theSession.getData(), _theChart),
            null,
            ' '));
    _theTools.addElement(
        new MenuItemInfo(
            Layers.CHART_FEATURES,
            null,
            "Create Buoy Pattern",
            new Debrief.Tools.Palette.BuoyPatterns.CreateBuoyPattern(
                _theParent,
                _theProperties,
                _theSession.getData(),
                _theChart,
                "Buoy Pattern",
                "images/buoy.gif"),
            null,
            ' '));
    // //////////////////////////////////////////////////////////
    // now the shape creators
    // //////////////////////////////////////////////////////////

    _theTools.addElement(
        new MenuItemInfo(
            "Drawing",
            null,
            "Create Label",
            new CreateLabel(
                _theParent,
                _theProperties,
                _theSession.getData(),
                _theChart,
                "Label",
                "images/label.gif"),
            null,
            ' '));
    _theTools.addElement(
        new MenuItemInfo(
            "Drawing",
            null,
            "Create Ellipse",
            new CreateShape(
                _theParent,
                _theProperties,
                _theSession.getData(),
                _theChart,
                "Ellipse",
                "images/ellipse.gif") {
              protected ShapeWrapper getShape(final WorldLocation centre) {
                return new ShapeWrapper(
                    "new ellipse",
                    new EllipseShape(
                        centre,
                        0,
                        new WorldDistance(0, WorldDistance.DEGS),
                        new WorldDistance(0, WorldDistance.DEGS)),
                    java.awt.Color.red,
                    null);
              }
            },
            null,
            ' '));
    // rectangle
    _theTools.addElement(
        new MenuItemInfo(
            "Drawing",
            null,
            "Create Rectangle",
            new CreateShape(
                _theParent,
                _theProperties,
                _theSession.getData(),
                _theChart,
                "Rectangle",
                "images/rectangle.gif") {
              protected ShapeWrapper getShape(final WorldLocation centre) {
                return new ShapeWrapper(
                    "new rectangle",
                    new RectangleShape(
                        centre,
                        centre.add(
                            new WorldVector(MWC.Algorithms.Conversions.Degs2Rads(45), 0.05, 0))),
                    java.awt.Color.red,
                    null);
              }
            },
            null,
            ' '));

    // arc
    _theTools.addElement(
        new MenuItemInfo(
            "Drawing",
            null,
            "Create arc",
            new CreateShape(
                _theParent,
                _theProperties,
                _theSession.getData(),
                _theChart,
                "Arc",
                "images/arc.gif") {
              protected ShapeWrapper getShape(final WorldLocation centre) {
                return new ShapeWrapper(
                    "new arc",
                    new ArcShape(
                        centre, new WorldDistance(4000, WorldDistance.YARDS), 135, 90, true, false),
                    java.awt.Color.red,
                    null);
              }
            },
            null,
            ' ')); // circle
    _theTools.addElement(
        new MenuItemInfo(
            "Drawing",
            null,
            "Create circle",
            new CreateShape(
                _theParent,
                _theProperties,
                _theSession.getData(),
                _theChart,
                "Circle",
                "images/circle.gif") {
              protected ShapeWrapper getShape(final WorldLocation centre) {
                return new ShapeWrapper(
                    "new circle", new CircleShape(centre, 4000), java.awt.Color.red, null);
              }
            },
            null,
            ' '));
    // line
    _theTools.addElement(
        new MenuItemInfo(
            "Drawing",
            null,
            "Create line",
            new CreateShape(
                _theParent,
                _theProperties,
                _theSession.getData(),
                _theChart,
                "Line",
                "images/line.gif") {
              protected ShapeWrapper getShape(final WorldLocation centre) {
                return new ShapeWrapper(
                    "new line",
                    new LineShape(
                        centre,
                        centre.add(
                            new WorldVector(MWC.Algorithms.Conversions.Degs2Rads(45.0), 0.05, 0))),
                    java.awt.Color.red,
                    null);
              }
            },
            null,
            ' '));

    // line
    _theTools.addElement(
        new MenuItemInfo(
            "Drawing",
            null,
            "Create polygon",
            new CreateShape(
                _theParent,
                _theProperties,
                _theSession.getData(),
                _theChart,
                "Polygon",
                "images/polygon.gif") {
              protected ShapeWrapper getShape(final WorldLocation centre) {
                return new ShapeWrapper("new polygon", null, java.awt.Color.red, null);
              }
            },
            null,
            ' '));
  }