コード例 #1
0
  public static void movepositions(
      final SWTGefBot bot,
      SWTBotGefEditor gmfEditor,
      final String sourcelane,
      final String destlane,
      final String element,
      final int j,
      final int i) {

    final SWTBotEditor botEditor = bot.activeEditor();
    gmfEditor = bot.gefEditor(botEditor.getTitle());

    final SWTBotGefEditPart lane2 = gmfEditor.getEditPart(sourcelane);
    lane2.parent().select().resize(PositionConstants.NORTH, 100, 150);

    // compute target destination
    final SWTBotGefEditPart lane3 = gmfEditor.getEditPart(destlane);

    // move step2 to lane2

    final SWTBotGefEditPart ele = gmfEditor.getEditPart(element).parent();
    ele.select();

    // move step2 to lane2

    SWTBotGefEditPart step = gmfEditor.getEditPart(element).parent();
    step.select();

    IFigure figure = ((GraphicalEditPart) step.part()).getFigure();
    final Rectangle dest = figure.getBounds().getCopy();
    figure.translateToAbsolute(dest);

    gmfEditor.drag(step, dest.x + j, dest.y + i);

    step = gmfEditor.getEditPart(element).parent();
    step.select();
    figure = ((GraphicalEditPart) step.part()).getFigure();
    final Rectangle targetdest = figure.getBounds().getCopy();
    figure.translateToAbsolute(targetdest);

    Assert.assertTrue("Move has failed", !targetdest.equals(dest));

    bot.waitUntil(
        new ICondition() {
          @Override
          public boolean test() throws Exception {
            return getPartRecursively(lane3.parent(), element) != null;
          }

          @Override
          public void init(final SWTBot bot) {}

          @Override
          public String getFailureMessage() {
            System.out.println(element + "is not in sourcelane");
            return "element is not in sourcelane (unable to move the step)";
          }
        });
  }
コード例 #2
0
ファイル: EllipseBorder.java プロジェクト: ReEng/sdm-commons
  @Override
  public void paintBorder(IFigure figure, Graphics graphics, Insets insets) {
    Rectangle rect = getPaintRectangle(figure, insets);
    int width = figure.getBounds().width;
    int height = figure.getBounds().height;

    int x = rect.x + (int) Math.floor(this.getWidth() / 2.0);
    int y = rect.y + (int) Math.floor(this.getWidth() / 2.0);
    graphics.drawOval(x, y, width - this.getWidth(), height - this.getWidth());
  }
  public void figureMoved(IFigure figure) {
    Rectangle bounds = figure.getBounds();

    if (relativeToParent) {
      bounds = Rectangle.SINGLETON.setBounds(bounds); // copy
      Rectangle parentBounds = figure.getParent().getBounds();
      bounds.translate(-parentBounds.x, -parentBounds.y);
    }

    Point loc = element.getLocation();
    if (loc == null || loc.x != bounds.x || loc.y != bounds.y) {
      Point newLocation = new Point(bounds.x, bounds.y);
      if (element instanceof FormElementGroup) {
        FormElementGroupPropertySource formElementGroupPropertySource =
            new FormElementGroupPropertySource((FormElementGroup) element, form);
        formElementGroupPropertySource.setLocation(newLocation);
      } else {
        element.setLocation(newLocation);
      }
    }
    Dimension dim = element.getSize();
    if (dim == null || dim.width != bounds.width || dim.height != bounds.height) {
      Dimension newSize = new Dimension(bounds.width, bounds.height);
      if (element instanceof FormElementGroup) {
        FormElementGroupPropertySource formElementGroupPropertySource =
            new FormElementGroupPropertySource((FormElementGroup) element, null);
        formElementGroupPropertySource.setSize(newSize);
      } else {
        element.setSize(newSize);
      }
    }
  }
コード例 #4
0
  protected void paintConnections(Graphics graphics) {
    // paint composite connections
    graphics.setForegroundColor(FigurePrefs.relationsColor);
    IFigure compositeFigure = getContentPane(0);
    if (compositeFigure.isVisible()) {
      int compositeChildrenNumber = compositeFigure.getChildren().size();
      if (compositeChildrenNumber == 0) return;
      Point mainToggleLocation =
          isRightToLeft() ? mainToggle.getBounds().getLeft() : mainToggle.getBounds().getRight();
      //			translateToRelative(mainToggleLocation);
      Point[] childs = new Point[compositeChildrenNumber];
      for (int i = 0; i < compositeChildrenNumber; i++) {
        IFigure compositeChild = (IFigure) compositeFigure.getChildren().get(i);

        // calculate target point position
        Point targetLocation;
        if (compositeChild instanceof INodeFigure)
          targetLocation = ((INodeFigure) compositeChild).getTargetAnchor(0).getLocation(null);
        else {
          Rectangle compositeChildBounds = compositeChild.getBounds();
          targetLocation =
              isRightToLeft() ? compositeChildBounds.getRight() : compositeChildBounds.getLeft();
          compositeChild.translateToAbsolute(targetLocation);
        }
        translateToRelative(targetLocation);
        childs[i] = targetLocation;
      }
      DrawUtils.drawHorizontalTree(graphics, mainToggleLocation, DrawUtils.SPACING / 2, childs);
    }
  }
コード例 #5
0
 private void refreshLabelBounds(IFigure figure, GraphLabel label) {
   Rectangle figureBounds = figure.getBounds();
   if (figureBounds.width * figureBounds.height > 0) {
     label.setText(label.getText()); // hack: resets label's size
     Dimension labelSize = label.getSize();
     labelSize.expand(-6, -4);
     Point anchorPoint = figure.getBounds().getBottomRight();
     anchorPoint.x -= labelSize.width / 2;
     anchorPoint.y -= labelSize.height / 2;
     Rectangle bounds = new Rectangle(anchorPoint, labelSize);
     label.setBounds(bounds);
     label.getParent().setConstraint(label, bounds);
   } else {
     label.getParent().setConstraint(label, new Rectangle(figureBounds.x, figureBounds.y, 0, 0));
     label.setBounds(new Rectangle(figureBounds.x, figureBounds.y, 0, 0));
   }
 }
コード例 #6
0
ファイル: SliderViewer.java プロジェクト: gedaofeng/xmind3
 protected double calcNewPortionCanvas(int x, int y) {
   Rectangle r = slotFigure.getBounds();
   if (vertical) {
     return ((y - r.y) * 1.0d) / r.height;
   } else {
     return ((x - r.x) * 1.0d) / r.width;
   }
 }
コード例 #7
0
 protected Dimension calculatePreferredSize(IFigure container, int wHint, int hHint) {
   container.validate();
   List<IFigure> children = container.getChildren();
   Rectangle result = new Rectangle().setLocation(container.getClientArea().getLocation());
   for (IFigure c : children) result.union(c.getBounds());
   Insets ins = container.getInsets();
   result.resize(ins.getWidth(), ins.getHeight());
   return result.getSize();
 }
コード例 #8
0
 /**
  * @see org.eclipse.draw2d.Border#paint(org.eclipse.draw2d.IFigure, org.eclipse.draw2d.Graphics,
  *     org.eclipse.draw2d.geometry.Insets)
  */
 public void paint(IFigure figure, Graphics graphics, Insets insets) {
   graphics.setForegroundColor(ColorConstants.buttonDarker);
   if (horizontal) {
     graphics.drawLine(
         figure.getBounds().getTopLeft(),
         figure
             .getBounds()
             .getBottomLeft()
             .translate(new org.eclipse.draw2d.geometry.Point(0, -4)));
   } else {
     graphics.drawLine(
         figure.getBounds().getTopLeft(),
         figure
             .getBounds()
             .getTopRight()
             .translate(new org.eclipse.draw2d.geometry.Point(-4, 0)));
   }
 }
コード例 #9
0
 public Point getChildLocation(GraphicalEditPart parentEditPart) {
   IFigure f =
       ((LifelineEditPart) parentEditPart)
           .getPrimaryShape()
           .getFigureLifelineDotLineFigure();
   Rectangle b = f.getBounds().getCopy();
   f.translateToAbsolute(b);
   return b.getCenter().getCopy().translate(0, 50);
 }
コード例 #10
0
  // We override reveal to show the Handles of the selected EditPart when
  // scrolling
  public void reveal(EditPart part) {
    // In some case, the editor control is not created, but get the sync selection event.
    // Fix this problem temporary.
    if (getFigureCanvas() == null || getFigureCanvas().isDisposed()) {
      return;
    }

    Viewport port = getFigureCanvas().getViewport();
    IFigure target = ((GraphicalEditPart) part).getFigure();

    Rectangle exposeRegion = target.getBounds().getCopy();

    // Get the primary editpolicy
    EditPolicy policy = part.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);

    // If the policy let us access the handles, proceed, otherwise
    // default to original behaviour
    if (!(policy instanceof ISelectionHandlesEditPolicy)) {
      super.reveal(part);
      return;
    }

    // First translate exposeRegion to the root level
    target = target.getParent();
    while (target != null && target != port) {
      target.translateToParent(exposeRegion);
      target = target.getParent();
    }

    // Merge selection handles if any to the exposeRegion
    List handles = ((ISelectionHandlesEditPolicy) policy).getHandles();
    for (Iterator iter = handles.iterator(); iter.hasNext(); ) {
      AbstractHandle handle = (AbstractHandle) iter.next();

      Locator locator = handle.getLocator();
      locator.relocate(handle);
      exposeRegion.union(handle.getBounds().getCopy());
    }

    exposeRegion.getExpanded(5, 5);

    Dimension viewportSize = port.getClientArea().getSize();

    Point topLeft = exposeRegion.getTopLeft();
    Point bottomRight = exposeRegion.getBottomRight().translate(viewportSize.getNegated());
    Point finalLocation = new Point();
    if (viewportSize.width < exposeRegion.width)
      finalLocation.x = Math.min(bottomRight.x, Math.max(topLeft.x, port.getViewLocation().x));
    else finalLocation.x = Math.min(topLeft.x, Math.max(bottomRight.x, port.getViewLocation().x));

    if (viewportSize.height < exposeRegion.height)
      finalLocation.y = Math.min(bottomRight.y, Math.max(topLeft.y, port.getViewLocation().y));
    else finalLocation.y = Math.min(topLeft.y, Math.max(bottomRight.y, port.getViewLocation().y));

    getFigureCanvas().scrollSmoothTo(finalLocation.x, finalLocation.y);
  }
コード例 #11
0
 /**
  * Export an image to SVG file format.
  *
  * @param file
  * @param rootFigure
  * @throws IOException
  */
 public void exportToSVG(File file, IFigure rootFigure) throws IOException {
   Rectangle bounds = rootFigure.getBounds();
   GraphicsSVG graphics =
       GraphicsSVG.getInstance(bounds.getTranslated(bounds.getLocation().negate()));
   graphics.translate(bounds.getLocation().negate());
   rootFigure.paint(graphics);
   // graphics.getSVGGraphics2D().stream(new BufferedWriter(new OutputStreamWriter(new
   // FileOutputStream(file))));
   // FIXME: SVG export is not working any more due to API restrictions of GMF
 }
コード例 #12
0
 @Override
 public void paint(IFigure figure, Graphics graphics, Insets insets) {
   super.paint(figure, graphics, insets);
   Rectangle bounds = figure.getBounds();
   if (image != null) {
     int x = bounds.x;
     int y = bounds.y;
     graphics.drawImage(image, x, y);
   }
 }
コード例 #13
0
  /**
   * Gets the width of an Item. This depends upon whether the Item is compacted or not.
   *
   * @param item The item to get the width for
   * @param index The index of the Item
   * @param nbItems The number of items
   * @param itemFont The Font of the item
   * @return int The Width of the Item
   */
  protected int getItemWidth(Widget item, int index, int nbItems, Font itemFont) {
    if (body != null) {
      IFigure bf = (IFigure) body.getChildren().get(index);
      return bf.getBounds().width;
    }

    Rectangle rect = getParent().getBounds();
    // -6 to add a little empty space at the end of the figure
    return (rect.width - 6) / nbItems;
  }
コード例 #14
0
  private int getColumnIndex(DirectEditRequest editRequest) {
    ZoomManager zoomManager =
        ((ScalableFreeformRootEditPart) this.getHost().getRoot()).getZoomManager();
    double zoom = zoomManager.getZoom();

    IFigure figure = ((TableViewEditPart) this.getHost()).getFigure();

    int center = (int) (figure.getBounds().y + (figure.getBounds().height / 2) * zoom);

    int index = 0;

    if (editRequest.getLocation().y >= center) {
      TableView newTableView = (TableView) this.getHost().getModel();

      index = newTableView.getColumns().size();
    }

    return index;
  }
コード例 #15
0
 /**
  * Returns the bounds which holds all the points in this polyline connection. Returns any
  * previously existing bounds, else calculates by unioning all the children's dimensions.
  *
  * @return the bounds
  */
 public Rectangle getBounds() {
   if (bounds == null) {
     super.getBounds();
     for (int i = 0; i < getChildren().size(); i++) {
       IFigure child = (IFigure) getChildren().get(i);
       bounds.union(child.getBounds());
     }
   }
   return bounds;
 }
コード例 #16
0
 @Override
 public Rectangle getBounds() {
   IFigure partFigure = this.editPart.getFigure();
   final org.eclipse.draw2d.geometry.Rectangle bounds = partFigure.getBounds().getCopy();
   partFigure.translateToAbsolute(bounds);
   Point viewerOrigin = this.diagramEditor.getGraphicalViewer().getControl().getLocation();
   viewerOrigin = this.diagramEditor.getGraphicalViewer().getControl().toDisplay(viewerOrigin);
   bounds.x += viewerOrigin.x;
   bounds.y += viewerOrigin.y;
   return new Rectangle(bounds.x, bounds.y, bounds.width, 20);
 }
コード例 #17
0
 public void setBoundsForOverlapComputation(IGraphicalEditPart ep, Rectangle result) {
   if (ep.resolveSemanticElement() instanceof FlowElement) {
     IFigure fig = ((IGraphicalEditPart) ep).getContentPane();
     result.setBounds(fig.getBounds());
     fig.translateToAbsolute(result);
     return;
   } else {
     result.setBounds(ep.getFigure().getBounds());
     ep.getFigure().translateToAbsolute(result);
   }
 }
コード例 #18
0
 public static int getMinimumWidth(IFigure figure) {
   if (figure instanceof FlowPage) {
     FlowPage fp = (FlowPage) figure;
     TextFlow tf = (TextFlow) fp.getChildren().get(0);
     List<?> fragments = tf.getFragments();
     int width = getLongestFragment(fragments) + figure.getBorder().getInsets(figure).getWidth();
     return width;
   } else {
     return figure.getBounds().width;
   }
 }
コード例 #19
0
ファイル: ColumnLayout.java プロジェクト: debabratahazra/DS
  /**
   * Lays out the figure.
   *
   * @param container The container to layout
   */
  public void layout(IFigure container) {
    List children = container.getChildren();
    IWidgetFigure header = (IWidgetFigure) children.get(COLUMN_HEADER_INDEX);
    IWidgetFigure body = (IWidgetFigure) children.get(COLUMN_BODY_INDEX);

    // Calculate the size and position of each figure
    Rectangle cb = container.getBounds();

    calculateSizes(header, body, cb);
    calculatePositions(header, body);
  }
コード例 #20
0
  @Override
  public Image stereotypeIconToDisplay() {

    // retrieve the first stereotype in the list of displayed stereotype

    // String firstStereotypeName = tokenizer.nextToken();
    EList<Stereotype> stereotype_list = getUMLElement().getAppliedStereotypes();
    if (stereotype_list.size() != 0) {
      Stereotype stereotype = stereotype_list.get(0);
      if (stereotype.getName().equals("DataFlowPort")
          || stereotype.getName().equals("ServicePort")) {
        Image icon = Activator.getIconElement(getUMLElement(), stereotype, false);

        IFigure portView = getHostFigure();
        IFigure parentView = portView.getParent().getParent();

        Rectangle parentBounds = parentView.getBounds();
        Rectangle portBounds = portView.getBounds();

        if (portBounds.x() <= parentBounds.x()) {
          // left
          return icon;
        } else if (portBounds.x() >= (parentBounds.right() - portBounds.width())) {
          // right
          return new Image(icon.getDevice(), RotationHelper.rotateImage(icon, 180));
        } else if (portBounds.y() <= parentBounds.y()) {
          // top
          return new Image(icon.getDevice(), RotationHelper.rotateImage(icon, 90));
        } else if (portBounds.y() >= parentBounds.bottom() - portBounds.height()) {
          // bottom
          return new Image(icon.getDevice(), RotationHelper.rotateImage(icon, -90));
        } else {
          return null;
        }
      }
      return Activator.getIconElement(getUMLElement(), stereotype, false);
    }
    return null;
  }
コード例 #21
0
 /*
  * public void addChild() {
  * List<EditPart> listchildren = this.getChildren();
  * if(!listchildren.isEmpty()) {
  * int size = listchildren.size();
  * EditPart childEditPart = listchildren.get(0);
  * this.addChild(childEditPart, size);
  * listchildren = this.getChildren();
  * size = listchildren.size();
  * System.out.printf("Size of ListChildren %d\n", size);
  *
  * }
  * }
  */
 @Override
 protected boolean removeFixedChild(EditPart childEditPart) {
   if (childEditPart instanceof MessageNameEditPart) {
     if (childEditPart instanceof MessageNameEditPart) {
       IFigure childFigureBefore = ((GraphicalEditPart) childEditPart).getFigure();
       getPrimaryShape().remove(((MessageNameEditPart) childEditPart).getFigure());
       IFigure childFigure = ((GraphicalEditPart) childEditPart).getFigure();
       if (childFigure.getParent() == null) {
         childFigure.setParent(this.getPrimaryShape());
       }
       if (childFigure.getBounds() == new Rectangle(0, 0, 0, 0)) {
         // System.out.println("The bound have changed!!!! ");
         childFigure.setBounds(childFigureBefore.getBounds());
       }
     }
     return true;
   }
   if (childEditPart instanceof AppliedStereotypeMessageEditPart) {
     return true;
   }
   return false;
 }
コード例 #22
0
  /**
   * First scroll the source and target FigureCanvases as needed to ensure the source and target
   * IFigures are showing. Then move the mouse over the source IFigure and drag and drop it on to
   * the target IFigure
   *
   * @since 3.8.0
   * @param ui - driver for ui generated input
   * @param sourceCanvas - the FigureCanvas containing the source IFigure
   * @param source - the IFigure to be dragged and dropped
   * @param targetCanvas - the FigureCanvas containing the target IFigure
   * @param target - the IFigure on which to drop the source
   */
  public void dragAndDrop(
      IUIContext ui,
      FigureCanvas sourceCanvas,
      IFigure source,
      FigureCanvas targetCanvas,
      IFigure target) {
    TestCase.assertNotNull(sourceCanvas);
    TestCase.assertNotNull(source);
    TestCase.assertNotNull(targetCanvas);
    TestCase.assertNotNull(target);

    // first scroll the source and target canvases
    // as necessary to show the figures
    FigureTester figureTester = new FigureTester();
    figureTester.scrollForClick(sourceCanvas, source);
    figureTester.scrollForClick(targetCanvas, target);

    // compute the source screen location
    Rectangle sourceRect = source.getBounds().getCopy();
    source.translateToAbsolute(sourceRect);

    // compute the target screen location
    Rectangle targetRect = source.getBounds().getCopy();
    target.translateToAbsolute(targetRect);

    try {
      // move the mouse over the source
      ui.mouseMove(new XYLocator(sourceRect.x, sourceRect.y));

      // drag and drop on the target
      ui.dragTo(new XYLocator(targetRect.x, targetRect.y));
    }
    // SHOULD NEVER HAPPEN BECAUSE WE'RE USING THE XYLOCATOR
    catch (WidgetSearchException ex) {
      Draw2DActivator.logException(ex);
      TestCase.fail(ex.getLocalizedMessage());
    }
  }
コード例 #23
0
        public void figureMoved(IFigure source) {

          Rectangle newBounds = source.getBounds().getCopy();

          if (algorithm.updateObstacle((Rectangle) figuresToBounds.get(source), newBounds)) {
            queueSomeRouting();
            isDirty = true;
          }

          // Skip labels as routing obstacles
          if (!(source instanceof TransparentLabel)) {
            figuresToBounds.put(source, newBounds);
          }
        }
コード例 #24
0
  public InlineTextInputDialog(final IGraphicalEditPart graphicalEditPart, final String value) {
    super(graphicalEditPart.getViewer().getControl().getShell());
    final IFigure theFigure = graphicalEditPart.getFigure();

    final org.eclipse.draw2d.geometry.Rectangle r = theFigure.getBounds().getCopy();
    theFigure.translateToAbsolute(r);

    final Control theCanvas = graphicalEditPart.getViewer().getControl();
    labelBounds =
        theCanvas.getDisplay().map(theCanvas, null, new Rectangle(r.x, r.y, r.width, r.height));

    this.value = value;
    setShellStyle(SWT.NO_TRIM | SWT.APPLICATION_MODAL);
  }
コード例 #25
0
 void removeChild(IFigure child) {
   if (connectionToPaths == null) {
     return;
   }
   Rectangle bounds = child.getBounds().getCopy();
   boolean change = false;
   algorithm.removeObstacle(bounds);
   figuresToBounds.remove(child);
   child.removeFigureListener(figureListener);
   if (change) {
     isDirty = true;
     queueSomeRouting();
   }
 }
コード例 #26
0
 public static int getMinimumHeight(IFigure figure) {
   int height = figure.getBounds().height;
   if (figure instanceof FlowPage) {
     FlowPage fp = (FlowPage) figure;
     TextFlow tf = (TextFlow) fp.getChildren().get(0);
     Dimension textExtents = TextUtilities.INSTANCE.getTextExtents(tf.getText(), tf.getFont());
     List<?> fragments = tf.getFragments();
     if (fragments.size() != 0) {
       height = fragments.size() * textExtents.height;
       // include border padding
       height = height + figure.getBorder().getInsets(figure).getHeight();
     }
   }
   return height;
 }
コード例 #27
0
  public static void increaseLaneHeight(final SWTBotGefEditor editor, final String laneName) {
    final SWTBotGefEditPart lanePart = editor.getEditPart(laneName).parent();
    lanePart.select();

    final IGraphicalEditPart graphicalEditPart = (IGraphicalEditPart) lanePart.part();
    final UpdateSizePoolSelectionEditPolicy addPoolSizeElementEditPolicy =
        (UpdateSizePoolSelectionEditPolicy)
            graphicalEditPart.getEditPolicy(
                UpdateSizePoolSelectionEditPolicy.UPDATE_POOL_SIZE_SELECTION_FEEDBACK_ROLE);

    final IFigure toolbarFigure =
        addPoolSizeElementEditPolicy.getFigure(UpdateSizePoolSelectionEditPolicy.ADD_BOTTOM);
    final Point location = toolbarFigure.getBounds().getCenter().getCopy();
    toolbarFigure.translateToAbsolute(location);
    editor.click(location.x, location.y);
  }
コード例 #28
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.birt.report.designer.internal.ui.editors.schematic.tools.
   * TableDragGuideTracker#getMarqueeSelectionRectangle()
   */
  protected Rectangle getMarqueeSelectionRectangle() {
    IFigure figure = getCrosstabTableEditPart().getFigure();
    Insets insets = figure.getInsets();

    int value = getLocation().x - getStartLocation().x;
    value = getTrueValueAbsolute(value);

    Point p = getStartLocation().getCopy();
    figure.translateToAbsolute(p);
    figure.translateToRelative(p);
    Rectangle bounds = figure.getBounds().getCopy();
    figure.translateToAbsolute(bounds);

    return new Rectangle(
        value + p.x, bounds.y + insets.top, 2, bounds.height - (insets.top + insets.bottom));
  }
コード例 #29
0
 @Override
 public void relocate(IFigure target) {
   Rectangle bounds = target.getBounds().getCopy();
   Point location = null;
   if (parent instanceof ConnectorEditPart) {
     ConnectorEditPart connectorPart = (ConnectorEditPart) parent;
     PointList points = getPoints(connectorPart.getConnectionFigure());
     location = getPointForEnd(points);
   } else {
     // if the parent is any other edit part
     // use the bounds center
     location = parent.getFigure().getBounds().getCenter();
   }
   if (lastLocation == null) {
     lastLocation = location;
   }
   Dimension delta = location.getDifference(lastLocation);
   bounds.translate(delta.width, delta.height);
   lastLocation = location.getCopy();
   // if the current width is 0 then the
   // user has never set the width, calculate it
   // here using a maximum number of 400
   boolean cropWidth = false;
   if (bounds.width == 0) {
     Dimension preferred = target.getPreferredSize();
     bounds.width = preferred.width;
     bounds.width = Math.min(400, bounds.width);
     cropWidth = true;
   }
   if (bounds.width < target.getBorder().getInsets(target).getWidth()) {
     // do not allow resizing to zero
     bounds.width = target.getBorder().getInsets(target).getWidth();
   }
   // we must set the bounds to allow recalculation
   // of text height (wrapping)
   target.setBounds(bounds);
   target.validate();
   // adjust height to account for word wrapping
   bounds.height = getMinimumHeight(target);
   if (cropWidth) {
     // crop the width here, as this is not a user set
     // width and otherwise if near 400 may leave extra
     // slack
     bounds.width = getMinimumWidth(target);
   }
   target.setBounds(bounds);
 }
コード例 #30
0
  void addChild(IFigure child) {
    if (connectionToPaths == null) {
      return;
    }
    if (figuresToBounds.containsKey(child)) {
      return;
    }
    Rectangle bounds = child.getBounds().getCopy();

    // Skip labels as routing obstacles
    if (!(child instanceof TransparentLabel)) {
      algorithm.addObstacle(bounds);
      figuresToBounds.put(child, bounds);
      child.addFigureListener(figureListener);
      isDirty = true;
    }
  }