Exemple #1
0
  public Flexible copyToGroup(String group) {

    String newName;
    if (group.equals(nullString)) newName = Group.substractObjectName(getName());
    else newName = group + Constants.GROUP_SEPARATOR + Group.substractObjectName(getName());

    // object with new name already exists, add suffix ///!!!
    while (Group.getRoot().findObject(newName, true) != null)
      newName = StringUtils.incrementName(newName, Constants.COPY_SUFFIX);

    Box grBox =
        new Box(
            newName,
            null,
            startVertex.getX(),
            startVertex.getY(),
            endVertex.getX(),
            endVertex.getY());
    grBox.setColor(getColor());
    Group.getRoot().addSubObject(newName, grBox, true);

    // ViewState view = ViewState.getInstance();
    // grBox.move(20 - view.getRx(), 20 - view.getRy());

    unconditionalValidation();
    return grBox;
  }
Exemple #2
0
  public void destroy() {
    super.destroy();
    if (getParent() != null) getParent().removeObject(Group.substractObjectName(name));

    if (!startVertex.isDestroyed()) startVertex.destroy();

    if (!endVertex.isDestroyed()) endVertex.destroy();
  }
Exemple #3
0
  public void revalidatePosition() {
    startVertex.revalidatePosition();
    endVertex.revalidatePosition();

    double rscale = getRscale();

    setRx((int) (getX() * rscale));
    setRy((int) (getY() * rscale));
  }
Exemple #4
0
  protected void validate() {
    startVertex.validate();
    endVertex.validate();

    revalidatePosition();

    double rscale = getRscale();

    setRwidth((int) (getWidth() * rscale));
    setRheight((int) (getHeight() * rscale));
  }
Exemple #5
0
  public boolean move(int dx, int dy) {
    if (checkMove(dx, dy)) {
      startVertex.move(dx, dy);
      endVertex.move(dx, dy);

      revalidatePosition();

      return true;
    }

    return false;
  }
 public VertexInfoDialog(Vertex vertex) {
   v = vertex;
   setTitle("Vertex: " + v.getName());
   Container cp = getContentPane();
   JPanel p = new JPanel();
   p.setLayout(new GridLayout(1, 1));
   opis = new TextArea(v.getInfo());
   opis.setEditable(false);
   p.add(opis, new FlowLayout());
   cp.add(p);
   setSize(200, 300);
   setDefaultCloseOperation(DISPOSE_ON_CLOSE);
 }
Exemple #7
0
 public void snapToGrid() {
   startVertex.snapToGrid();
   endVertex.snapToGrid();
 }
Exemple #8
0
 public int getHeight() {
   return Math.abs(startVertex.getY() - endVertex.getY());
 }
Exemple #9
0
 public int getWidth() {
   return Math.abs(startVertex.getX() - endVertex.getX());
 }
Exemple #10
0
 /* (non-Javadoc)
  * @see com.cosylab.vdct.graphics.objects.VisibleObject#getY()
  */
 public int getY() {
   return Math.min(startVertex.getY(), endVertex.getY());
 }
Exemple #11
0
  /**
   * Returned value inicates change Creation date: (21.12.2000 22:21:12)
   *
   * @return com.cosylab.visible.objects.VisibleObject
   * @param x int
   * @param y int
   */
  public VisibleObject hiliteComponentsCheck(int x, int y) {

    if (startVertex.intersects(x, y) != null) return startVertex;
    if (endVertex.intersects(x, y) != null) return endVertex;
    return null;
  }
Exemple #12
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);
  }
Exemple #13
0
  public boolean checkMove(int dx, int dy) {
    if (startVertex.checkMove(dx, dy) && endVertex.checkMove(dx, dy)) return true;

    return false;
  }
 public void refresh() {
   opis.setText(v.getInfo());
 }