Ejemplo n.º 1
0
  private String getDescr(Fig f) {
    if (f == null) {
      return null;
    }
    String className = f.getClass().getName();
    StringBuffer descr = new StringBuffer(className.substring(className.lastIndexOf(".") + 1));
    //        descr.append(" - paints=").append(f.getPaintCount());
    //        descr.append(" - damages=").append(f.getDamageCount());
    descr.append(
        " - bounds=[" + f.getX() + "," + f.getY() + "," + f.getWidth() + "," + f.getHeight() + "]");
    if (!f.isVisible()) {
      descr.append(" - INVISIBLE");
    }
    if (f.isFilled()) {
      descr.append(" - FILLED");
    }
    descr.append(
        " - fill=["
            + f.getFillColor().getRed()
            + ","
            + f.getFillColor().getGreen()
            + ","
            + f.getFillColor().getBlue()
            + "]");
    if (f.getOwner() != null) {
      descr.append(" - owner=").append(f.getOwner());
    }
    if (f instanceof FigText) {
      descr.append(" \"").append(((FigText) f).getText()).append("\"");
    }

    descr.append(" - lay=").append(toString(f.getLayer()));
    descr.append(" - grp=").append(toString(f.getGroup()));
    return descr.toString();
  }
Ejemplo n.º 2
0
  /**
   * Handle a refresh of the style panel after the fig has moved.
   *
   * <p><em>Warning</em>. There is a circular trap here. Editing the boundary box will also trigger
   * a refresh, and so we reset the boundary box, which causes funny behaviour (the cursor keeps
   * jumping to the end of the text).
   *
   * <p>The solution is to not reset the boundary box field if the boundaries have not changed.
   *
   * <p>
   */
  public void refresh() {
    Fig target = getPanelTarget();
    if (target instanceof FigEdgeModelElement) {
      hasEditableBoundingBox(false);
    } else {
      hasEditableBoundingBox(true);
    }
    if (target == null) return;

    // The boundary box as held in the target fig, and as listed in
    // the
    // boundary box style field (null if we don't have anything
    // valid)

    Rectangle figBounds = target.getBounds();
    Rectangle styleBounds = parseBBox();

    // Only reset the text if the two are not the same (i.e the fig
    // has
    // moved, rather than we've just edited the text, when
    // setTargetBBox()
    // will have made them the same). Note that styleBounds could
    // be null,
    // so we do the test this way round.

    if (!(figBounds.equals(styleBounds))) {
      bboxField.setText(
          figBounds.x + "," + figBounds.y + "," + figBounds.width + "," + figBounds.height);
    }

    // Change the fill colour

    if (target.getFilled()) {
      Color c = target.getFillColor();
      fillField.setSelectedItem(c);
      if (c != null && !fillField.getSelectedItem().equals(c)) {
        fillField.insertItemAt(c, fillField.getItemCount() - 1);
        fillField.setSelectedItem(c);
      }
    } else {
      fillField.setSelectedIndex(0);
    }

    // Change the line colour

    if (target.getLineWidth() > 0) {
      Color c = target.getLineColor();
      lineField.setSelectedItem(c);
      if (c != null && !lineField.getSelectedItem().equals(c)) {
        lineField.insertItemAt(c, lineField.getItemCount() - 1);
        lineField.setSelectedItem(c);
      }
    } else {
      lineField.setSelectedIndex(0);
    }
  }
Ejemplo n.º 3
0
 /*
  * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
  */
 public void itemStateChanged(ItemEvent e) {
   Object src = e.getSource();
   Fig target = getPanelTarget();
   if (e.getStateChange() == ItemEvent.SELECTED && target != null) {
     if (src == fillField) {
       if (e.getItem() == CUSTOM_ITEM) {
         handleCustomColor(fillField, "Custom Fill Color", target.getFillColor());
       }
       setTargetFill();
     } else if (src == lineField) {
       if (e.getItem() == CUSTOM_ITEM) {
         handleCustomColor(lineField, "Custom Line Color", target.getLineColor());
       }
       setTargetLine();
     }
   }
 }