Beispiel #1
0
 /**
  * Popup a dialog asking the user for the name of the saved ViewManager. If provided, add a new
  * TwoFacedObject to the list of saved ViewManagers and write the list to disk.
  *
  * @param vm The view manager to save
  */
 protected void saveViewManagerState(ViewManager vm) {
   try {
     String name = ((vm instanceof MapViewManager) ? "Map View" : "View");
     name = GuiUtils.getInput(null, "Name for saved view: ", name);
     if (name == null) {
       return;
     }
     ViewState viewState = vm.doMakeViewState();
     viewState.setName(name);
     getVMState().add(viewState);
     writeVMState();
   } catch (Exception exc) {
     logException("Saving view state", exc);
   }
 }
Beispiel #2
0
  /**
   * Instantiates (if needed) and returns the list of {@link TwoFacedObject}s that is the set of
   * saved viewpoints
   *
   * @return List that holds the viewpoints
   */
  public List getVMState() {
    if (viewpoints == null) {
      List tmp = new ArrayList();
      XmlResourceCollection rc =
          getResourceManager().getXmlResources(getResourceManager().RSC_VIEWPOINTS);

      for (int i = 0; i < rc.size(); i++) {
        String contents = rc.read(i);
        if (contents == null) {
          continue;
        }
        try {
          List resources = (List) getIdv().getEncoderForRead().toObject(contents);
          tmp.addAll(resources);
          boolean local = rc.isWritable(i);
          for (Object o : resources) {
            if (o instanceof ViewState) {
              ((ViewState) o).setIsLocal(local);
            }
          }
        } catch (Exception exc) {
          logException("Creating VM list", exc);
        }
      }
      viewpoints = tmp;
    }
    return viewpoints;
  }
Beispiel #3
0
  protected void draw(Graphics g, boolean hilited) {
    ViewState view = ViewState.getInstance();
    int offsetX = view.getRx();
    int offsetY = view.getRy();

    int posX = getRx() - offsetX;
    int posY = getRy() - offsetY;
    int rwidth = getRwidth();
    int rheight = getRheight();

    double Rscale = view.getScale();
    boolean zoom = (Rscale < 1.0) && view.isZoomOnHilited() && view.isHilitedObject(this);
    if (zoom) {
      rwidth /= Rscale;
      rheight /= Rscale;
      posX -= (rwidth - getRwidth()) / 2;
      posY -= (rheight - getRheight()) / 2;
      if (view.getRx() < 0) posX = posX < 0 ? 2 : posX;
      if (view.getRy() < 0) posY = posY <= 0 ? 2 : posY;
      Rscale = 1.0;
    }

    if (hilited) g.setColor(Constants.HILITE_COLOR);
    else g.setColor(getVisibleColor());

    // double scale = view.getScale();

    posX = startVertex.getRx() - offsetX;
    posY = startVertex.getRy() - offsetY;

    int posX2 = endVertex.getRx() - offsetX;
    int posY2 = endVertex.getRy() - offsetY;

    int t;
    if (posX > posX2) {
      t = posX;
      posX = posX2;
      posX2 = t;
    }
    if (posY > posY2) {
      t = posY;
      posY = posY2;
      posY2 = t;
    }

    if ((dashed) && ((posX != posX2) || (posY != posY2))) {
      int curX = posX;
      while (curX <= posX2) {
        int curX2 = curX + Constants.DASHED_LINE_DENSITY;

        if (curX2 > posX2) curX2 = posX2;

        g.drawLine(curX, posY, curX2, posY);
        g.drawLine(curX, posY2, curX2, posY2);

        curX += 2 * Constants.DASHED_LINE_DENSITY;
      }

      int curY = posY;
      while (curY <= posY2) {
        int curY2 = curY + Constants.DASHED_LINE_DENSITY;

        if (curY2 > posY2) curY2 = posY2;

        g.drawLine(posX, curY, posX, curY2);
        g.drawLine(posX2, curY, posX2, curY2);

        curY += 2 * Constants.DASHED_LINE_DENSITY;
      }
    } else g.drawRect(posX, posY, posX2 - posX, posY2 - posY);
  }