Package org.eclipse.draw2d

Examples of org.eclipse.draw2d.Polyline


public class SVGPolylinePart extends ElementRecordPart {

  @Override
  protected IFigure createFigure() {
    Polyline figure = new Polyline();

    SVGPolylineRecord record = (SVGPolylineRecord) getElementRecord();
    figure.setPoints(record.getPoints().getCopy());

    XYLayout layout = new XYLayout();
    figure.setLayoutManager(layout);
    figure.setForegroundColor(new Color(null, 0, 0, 0));

    return figure;
  }
View Full Code Here


    return figure;
  }

  @Override
  protected void refreshVisuals() {
    Polyline line = (Polyline) getFigure();
    SVGPolylineRecord record = (SVGPolylineRecord) getElementRecord();
    line.setPoints(record.getPoints());

    super.refreshVisuals();

    // hack because selection handle does not update
    if (getViewer().getSelectedEditParts().contains(this)
View Full Code Here

        LOW_HEIGHT - 2 * inset));
    return ellipse;
  }

  private static Polyline getPencilIconFigure() {
    Polyline line = new Polyline();
    int[] rawPoints = { 11, 3, 6, 3, 6, 4, 3, 4, 3, 5, 2, 5, 1, 6, 1, 8, 2,
        8, 2, 9, 3, 9, 4, 9, 5, 8, 7, 8, 7, 7, 8, 7, 8, 6, 13, 6, 14,
        7, 14, 10, 13, 10, 13, 11, 9, 11, 9, 12, 7, 12 };
    PointList points = new PointList(rawPoints);
    line.setPoints(points);
    line.setForegroundColor(black);
    return line;
  }
View Full Code Here

   * @return a polyline figure, already being initialized to the feedback
   *         layer
   */
  protected AbstractPointListShape getPolylineFeedback() {
    if (shape == null) {
      shape = new Polyline();
      shape.setForegroundColor(ColorConstants.black);
      addFeedback(shape);
    }
    return shape;
  }
View Full Code Here

  /**
   * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
   */
  @Override
  protected IFigure createFigure() {
    final Polyline polyline = new Polyline();
    polyline.setForegroundColor(Display.getDefault().getSystemColor(SWT.COLOR_CYAN));
    polyline.setLineWidth(5);
    polyline.setLineStyle(SWT.LINE_SOLID);
    polyline.setBackgroundColor(Display.getDefault().getSystemColor(SWT.COLOR_RED));
    for (final MapNodeRef ref : ((MapObjectNodes) getModel()).getObject().getNodes()) {
      final MapNode node = ref.getNode();
      final Point p = getCoordinateSystem().toPoint(node.getPosition());
      polyline.addPoint(p);
    }
    polyline.setPreferredSize(polyline.getBounds().width, polyline.getBounds().height);
    return polyline;
  }
View Full Code Here

      refreshVisuals();
    }
  }

  protected void refreshFigure() {
    final Polyline polyline = (Polyline) getFigure();
    polyline.removeAllPoints();
    for (final MapNodeRef ref : ((MapObjectNodes) getModel()).getObject().getNodes()) {
      final MapNode node = ref.getNode();
      final Point p = getCoordinateSystem().toPoint(node.getPosition());
      polyline.addPoint(p);
    }
    polyline.setPreferredSize(polyline.getBounds().width, polyline.getBounds().height);
  }
View Full Code Here

      if (event instanceof MoveEvent) {
        _matched=true;
        Tortoise _tortoise = ((MoveEvent)event).getTortoise();
        boolean _isPaint = _tortoise.isPaint();
        if (_isPaint) {
          final Polyline line = new Polyline();
          Tortoise _tortoise_1 = ((MoveEvent)event).getTortoise();
          Color _lineColor = _tortoise_1.getLineColor();
          line.setForegroundColor(_lineColor);
          Tortoise _tortoise_2 = ((MoveEvent)event).getTortoise();
          int _lineWidth = _tortoise_2.getLineWidth();
          line.setLineWidth(_lineWidth);
          Point _oldPosition = ((MoveEvent)event).getOldPosition();
          Point _oldPosition_1 = ((MoveEvent)event).getOldPosition();
          line.setEndpoints(_oldPosition, _oldPosition_1);
          Point _oldPosition_2 = ((MoveEvent)event).getOldPosition();
          Tortoise _tortoise_3 = ((MoveEvent)event).getTortoise();
          Point _position = _tortoise_3.getPosition();
          Tortoise _tortoise_4 = ((MoveEvent)event).getTortoise();
          int _delay = _tortoise_4.getDelay();
View Full Code Here

   *
   * @return a Polyline figure
   */
  protected Polyline getLineFeedback() {
    if (insertionLine == null) {
      insertionLine = new Polyline();
      insertionLine.setLineWidth(2);
      if (getHost() instanceof ShapeEditPart) {
        ShapeEditPart shapeEditPart = (ShapeEditPart)getHost();
        DiagramResourceCache resourceCache = shapeEditPart.getNodeEditPart().getCastedModel().getDiagramModel().getResourceCache();
        insertionLine.setForegroundColor(resourceCache.getOutlineColor());
View Full Code Here

   * Shows an insertion line if there is one or more current children.
   */
  protected void showLayoutTargetFeedback(Request request) {
    if (getHost().getChildren().size() == 0)
      return;
    Polyline fb = getLineFeedback();
    Transposer transposer = new Transposer();
    transposer.setEnabled(!isLayoutHorizontal(request));

    boolean before = true;
    int epIndex = getFeedbackIndexFor(request);
    Rectangle r = null;
    if (epIndex == -1) {
      before = false;
      epIndex = getHost().getChildren().size() - 1;
      EditPart editPart = (EditPart) getHost().getChildren().get(epIndex);
      r = transposer.t(getAbsoluteBounds((GraphicalEditPart) editPart));
    } else {
      EditPart editPart = (EditPart) getHost().getChildren().get(epIndex);
      r = transposer.t(getAbsoluteBounds((GraphicalEditPart) editPart));
      Point p = transposer.t(getLocationFromRequest(request));
      if (p.x <= r.x + (r.width / 2))
        before = true;
      else {
        /*
         * We are not to the left of this Figure, so the emphasis line
         * needs to be to the right of the previous Figure, which must
         * be on the previous row.
         */
        before = false;
        epIndex--;
        editPart = (EditPart) getHost().getChildren().get(epIndex);
        r = transposer
            .t(getAbsoluteBounds((GraphicalEditPart) editPart));
      }
    }
    int x = Integer.MIN_VALUE;
    if (before) {
      /*
       * Want the line to be halfway between the end of the previous and
       * the beginning of this one. If at the beginning of a line, then
       * start halfway between the left edge of the parent and the
       * beginning of the box, but no more than 5 pixels (it would be too
       * far and be confusing otherwise).
       */
      if (epIndex > 0) {
        // Need to determine if a line break.
        Rectangle boxPrev = transposer
            .t(getAbsoluteBounds((GraphicalEditPart) getHost()
                .getChildren().get(epIndex - 1)));
        int prevRight = boxPrev.right();
        if (prevRight < r.x) {
          // Not a line break
          x = prevRight + (r.x - prevRight) / 2;
        } else if (prevRight == r.x) {
          x = prevRight + 1;
        }
      }
      if (x == Integer.MIN_VALUE) {
        // It is a line break.
        Rectangle parentBox = transposer
            .t(getAbsoluteBounds((GraphicalEditPart) getHost()));
        x = r.x - 5;
        if (x < parentBox.x)
          x = parentBox.x + (r.x - parentBox.x) / 2;
      }
    } else {
      /*
       * We only have before==false if we are at the end of a line, so go
       * halfway between the right edge and the right edge of the parent,
       * but no more than 5 pixels.
       */
      Rectangle parentBox = transposer
          .t(getAbsoluteBounds((GraphicalEditPart) getHost()));
      int rRight = r.x + r.width;
      int pRight = parentBox.x + parentBox.width;
      x = rRight + 5;
      if (x > pRight)
        x = rRight + (pRight - rRight) / 2;
    }
    Point p1 = new Point(x, r.y);
    p1 = transposer.t(p1);
    fb.translateToRelative(p1);
    Point p2 = new Point(x, r.y + r.height);
    p2 = transposer.t(p2);
    fb.translateToRelative(p2);
    fb.setPoint(p1, 0);
    fb.setPoint(p2, 1);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.draw2d.Polyline

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.