Пример #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;
  }
Пример #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();
  }
Пример #3
0
  public void revalidatePosition() {
    startVertex.revalidatePosition();
    endVertex.revalidatePosition();

    double rscale = getRscale();

    setRx((int) (getX() * rscale));
    setRy((int) (getY() * rscale));
  }
Пример #4
0
  protected void validate() {
    startVertex.validate();
    endVertex.validate();

    revalidatePosition();

    double rscale = getRscale();

    setRwidth((int) (getWidth() * rscale));
    setRheight((int) (getHeight() * rscale));
  }
Пример #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;
  }
Пример #6
0
 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);
 }
Пример #7
0
 public void snapToGrid() {
   startVertex.snapToGrid();
   endVertex.snapToGrid();
 }
Пример #8
0
 public int getHeight() {
   return Math.abs(startVertex.getY() - endVertex.getY());
 }
Пример #9
0
 public int getWidth() {
   return Math.abs(startVertex.getX() - endVertex.getX());
 }
Пример #10
0
 /* (non-Javadoc)
  * @see com.cosylab.vdct.graphics.objects.VisibleObject#getY()
  */
 public int getY() {
   return Math.min(startVertex.getY(), endVertex.getY());
 }
Пример #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;
  }
Пример #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);
  }
Пример #13
0
  public boolean checkMove(int dx, int dy) {
    if (startVertex.checkMove(dx, dy) && endVertex.checkMove(dx, dy)) return true;

    return false;
  }
Пример #14
0
 public void refresh() {
   opis.setText(v.getInfo());
 }