Java 类org.eclipse.draw2d.Polyline 实例源码

项目:NEXCORE-UML-Modeler    文件:InteractionUseEditPart.java   
/**
 * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
 */
@Override
protected void refreshVisuals() {
    try {
        super.refreshVisuals();

        NotationNode notationNode = (NotationNode) getModel();
        Polyline line = (Polyline) this.getFigure();
        line.removeAllPoints();
        line.addPoint(new Point(notationNode.getX(), notationNode.getY()));
        line.addPoint(new Point(notationNode.getX(), notationNode.getY() + notationNode.getHeight()));

        Rectangle bounds = new Rectangle(notationNode.getX(),
            notationNode.getY(),
            notationNode.getWidth(),
            notationNode.getHeight());
        ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), bounds);
    } catch (Exception e) {
        Log.error(UMLMessage.MESSAGE_INTERACTION_USE_EDIT_PART_REFRESH_VISUALS_ERROR + e);
    }
}
项目:seg.jUCMNav    文件:TimerFigure.java   
/**
 * Creates a filled circle containing an L like segment to simulate a clock.
 * 
 * @see seg.jUCMNav.figures.PathNodeFigure#createFigure()
 */
protected void createFigure() {
    ellipse = new Ellipse();
    // we're making it larger than the empty point.
    ellipse.setBounds(new Rectangle(preferredSize.width / 8, preferredSize.height / 8, DEFAULT_WIDTH * 3 / 4, DEFAULT_HEIGHT * 3 / 4));
    ellipse.setAntialias(GeneralPreferencePage.getAntialiasingPref());
    poly = new Polyline();
    poly.addPoint(new Point(DEFAULT_WIDTH / 2, preferredSize.height / 8));
    poly.addPoint(new Point(DEFAULT_WIDTH / 2, DEFAULT_HEIGHT / 2));
    poly.addPoint(new Point(preferredSize.width * 7 / 8, DEFAULT_HEIGHT / 2));
    poly.setAntialias(GeneralPreferencePage.getAntialiasingPref());
    ellipse.add(poly);
    ellipse.setLineWidth(2);
    ellipse.setAntialias(GeneralPreferencePage.getAntialiasingPref());
    poly.setLineWidth(2);

    add(ellipse);

}
项目:ermasterr    文件:TableLayout.java   
@SuppressWarnings("unchecked")
private void addVerticalSeparator(final IFigure figure, final Rectangle rect) {
    final Polyline separator = new Polyline();
    separator.setLineWidth(separatorWidth);
    separator.addPoint(new Point(rect.x, rect.y));
    separator.addPoint(new Point(rect.x, rect.y + rect.height));

    figure.getChildren().add(separator);
    separator.setParent(figure);

    separators.add(separator);
}
项目:ermasterr    文件:TableLayout.java   
@SuppressWarnings("unchecked")
private void addHorizontalSeparator(final IFigure figure, final Rectangle rect) {
    final Polyline separator = new Polyline();
    separator.setLineWidth(separatorWidth);
    separator.addPoint(new Point(rect.x, rect.y));
    separator.addPoint(new Point(rect.x + rect.width, rect.y));
    figure.getChildren().add(separator);
    separator.setParent(figure);

    separators.add(separator);
}
项目:ermaster-k    文件:TableLayout.java   
@SuppressWarnings("unchecked")
private void addVerticalSeparator(IFigure figure, Rectangle rect) {
    Polyline separator = new Polyline();
    separator.setLineWidth(separatorWidth);
    separator.addPoint(new Point(rect.x, rect.y));
    separator.addPoint(new Point(rect.x, rect.y + rect.height));

    figure.getChildren().add(separator);
    separator.setParent(figure);

    this.separators.add(separator);
}
项目:ermaster-k    文件:TableLayout.java   
@SuppressWarnings("unchecked")
private void addHorizontalSeparator(IFigure figure, Rectangle rect) {
    Polyline separator = new Polyline();
    separator.setLineWidth(separatorWidth);
    separator.addPoint(new Point(rect.x, rect.y));
    separator.addPoint(new Point(rect.x + rect.width, rect.y));
    figure.getChildren().add(separator);
    separator.setParent(figure);

    this.separators.add(separator);
}
项目:NEXCORE-UML-Modeler    文件:InteractionUseEditPart.java   
/**
 * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
 */
@Override
protected IFigure createFigure() {
    NotationNode notationNode = (NotationNode) getModel();
    Polyline line = new Polyline();
    line.setOpaque(false);
    line.addPoint(new Point(notationNode.getX(), notationNode.getY()));
    line.addPoint(new Point(notationNode.getX(), notationNode.getY() + 100));
    line.setLineWidth(2);
    line.setForegroundColor(UiCorePlugin.getDefault().getColor(IConstantColorRegistry.DimGray));
    line.setLineStyle(Graphics.LINE_DASH);
    return line;
}
项目:NEXCORE-UML-Modeler    文件:InteractionOperandFigure.java   
/**
 * createContents
 *   void
 */
private void createContents() {

    setLayoutManager(new InteractionOperandLayout());

    operandUnderBoundary = new Polyline();
    operandUnderBoundary.setFill(true);
    operandUnderBoundary.setOpaque(true);
    operandUnderBoundary.setLineWidth(1);
    operandUnderBoundary.setLineStyle(Graphics.LINE_DASH);
    operandUnderBoundary.setForegroundColor(UiCorePlugin.getDefault().getColor(IConstantColorRegistry.DimGray));
    this.add(operandUnderBoundary);
}
项目:erflute    文件:TableLayout.java   
private List<IFigure> getChildren(IFigure parent) {
    final List<IFigure> children = new ArrayList<>();

    for (@SuppressWarnings("unchecked")
    final Iterator<Polyline> iter = parent.getChildren().iterator(); iter.hasNext();) {
        final IFigure child = iter.next();

        if (!separators.contains(child)) {
            children.add(child);
        }
    }

    return children;
}
项目:erflute    文件:TableLayout.java   
@SuppressWarnings("unchecked")
private List<IFigure> clearSeparator(IFigure parent) {
    for (final Iterator<Polyline> iter = parent.getChildren().iterator(); iter.hasNext();) {
        final IFigure child = iter.next();

        if (separators.contains(child)) {
            iter.remove();
        }
    }

    separators.clear();

    return parent.getChildren();
}
项目:erflute    文件:TableLayout.java   
@SuppressWarnings("unchecked")
private void addVerticalSeparator(IFigure figure, Rectangle rect) {
    final Polyline separator = new Polyline();
    separator.setLineWidth(separatorWidth);
    separator.addPoint(new Point(rect.x, rect.y));
    separator.addPoint(new Point(rect.x, rect.y + rect.height));

    figure.getChildren().add(separator);
    separator.setParent(figure);

    separators.add(separator);
}
项目:erflute    文件:TableLayout.java   
@SuppressWarnings("unchecked")
private void addHorizontalSeparator(IFigure figure, Rectangle rect) {
    final Polyline separator = new Polyline();
    separator.setLineWidth(separatorWidth);
    separator.addPoint(new Point(rect.x, rect.y));
    separator.addPoint(new Point(rect.x + rect.width, rect.y));
    figure.getChildren().add(separator);
    separator.setParent(figure);

    separators.add(separator);
}
项目:OpenSPIFe    文件:TemporalNodeMoveEditPolicy.java   
private Polyline getStartFigure(Rectangle bounds) {
    IPlanModifier modifier = PlanModifierMember.get(getViewer().getPlan()).getModifier();
    if (startFigure != null || !(modifier instanceof ConstrainedPlanModifier)) {
        return null;
    }
    startFigure = getTemporalBoundFigure(Timepoint.START, bounds);
    return startFigure;
}
项目:OpenSPIFe    文件:TemporalNodeMoveEditPolicy.java   
private Polyline getEndFigure(Rectangle bounds) {
    IPlanModifier modifier = PlanModifierMember.get(getViewer().getPlan()).getModifier();
    if (endFigure != null || !(modifier instanceof ConstrainedPlanModifier)) {
        return null;
    }
    endFigure = getTemporalBoundFigure(Timepoint.END, bounds);
    return endFigure;
}
项目:OpenSPIFe    文件:LinePlotDataSelectionEditPolicy.java   
@Override
protected void showSelection() {
    Polyline line = (Polyline)getHostFigure();
    IFigure p = line.getParent();
    p.remove(line);
    p.add(line);
    line.setLineWidth(3);
}
项目:ermaster-nhit    文件:TableLayout.java   
@SuppressWarnings("unchecked")
private void addVerticalSeparator(IFigure figure, Rectangle rect) {
    Polyline separator = new Polyline();
    separator.setLineWidth(separatorWidth);
    separator.addPoint(new Point(rect.x, rect.y));
    separator.addPoint(new Point(rect.x, rect.y + rect.height));

    figure.getChildren().add(separator);
    separator.setParent(figure);

    this.separators.add(separator);
}
项目:ermaster-nhit    文件:TableLayout.java   
@SuppressWarnings("unchecked")
private void addHorizontalSeparator(IFigure figure, Rectangle rect) {
    Polyline separator = new Polyline();
    separator.setLineWidth(separatorWidth);
    separator.addPoint(new Point(rect.x, rect.y));
    separator.addPoint(new Point(rect.x + rect.width, rect.y));
    figure.getChildren().add(separator);
    separator.setParent(figure);

    this.separators.add(separator);
}
项目:birt    文件:ReportFlowLayoutEditPolicy.java   
protected void setTargetFeedbackPoints( Point p1, Point p2 )
{
    Transposer transposer = new Transposer( );
    transposer.setEnabled( !isHorizontal( ) );

    Rectangle parentBox = transposer.t( getAbsoluteClientBounds( (GraphicalEditPart) getHost( ) ) );
    Polyline fb = getLineFeedback( );
    if ( p2.y >= parentBox.bottom( ) && parentBox.bottom( ) - p1.y < 10 )
    {
        p2.y = p1.y;

        List list = ( (GraphicalEditPart) getHost( ) ).getChildren( );
        int size = list.size( );
        if ( size == 0 )
        {
            p2.x = p1.x + Math.min( 30, parentBox.width );
        }
        else
        {
            GraphicalEditPart last = (GraphicalEditPart) list.get( size - 1 );
            Rectangle rect = getAbsoluteBounds( last );
            p2.x = p1.x + Math.min( rect.width - 8, parentBox.width );
        }
    }
    else if ( p2.y >= parentBox.bottom( ) )
    {
        p2.y = parentBox.bottom( );
    }
    fb.translateToRelative( p1 );

    fb.translateToRelative( p2 );

    fb.setPoint( p1, 0 );
    fb.setPoint( p2, 1 );
}
项目:seg.jUCMNav    文件:EndPointFigure.java   
/**
 * A simple line, as wide as the bounds.
 * 
 * @see seg.jUCMNav.figures.PathNodeFigure#createFigure()
 */
protected void createFigure() {
    mainFigure = new Polygon();
    edges = new PointList();

    int barWidth = 6 / 2;

    edges.addPoint(DEFAULT_WIDTH / 2 - barWidth, 1);
    edges.addPoint(DEFAULT_WIDTH / 2 - barWidth, DEFAULT_HEIGHT-1);

    edges.addPoint(DEFAULT_WIDTH / 2 + barWidth, DEFAULT_HEIGHT-1);
    edges.addPoint(DEFAULT_WIDTH / 2 + barWidth, 1);
    edges.addPoint(DEFAULT_WIDTH / 2 - barWidth, 1);

    mainFigure.setLineWidth(2);
    mainFigure.setPoints(edges);
    mainFigure.setAntialias(GeneralPreferencePage.getAntialiasingPref());
    mainFigure.setForegroundColor(ColorManager.GRAY);
    mainFigure.setBackgroundColor(ColorManager.LINE);
    mainFigure.setFill(true);

    add(mainFigure);

    line = new Polyline();
    linePts = new PointList();
    linePts.addPoint(new Point(DEFAULT_WIDTH / 2 - barWidth+1, 0));
    linePts.addPoint(new Point(DEFAULT_WIDTH / 2 + barWidth-1, DEFAULT_HEIGHT - 1));
    line.setPoints(linePts);
    line.setLineWidth(2);
    line.setAntialias(GeneralPreferencePage.getAntialiasingPref());
    line.setForegroundColor(ColorManager.WHITE);

    add(line);
}
项目:seg.jUCMNav    文件:TimeoutPathFigure.java   
/**
 * Is a Z like figure determined by the three static constants, WIDTH, HEIGHT and DELTA
 * 
 */
protected void createFigure() {
    poly = new Polyline();
    poly.setLineWidth(3);
    poly.addPoint(getInitial());
    poly.addPoint(new Point(-WIDTH / 2, HEIGHT / 2));
    poly.addPoint(new Point(WIDTH / 2, -HEIGHT / 2));
    poly.addPoint(new Point(WIDTH / 2, -DELTA));
    poly.setAntialias(GeneralPreferencePage.getAntialiasingPref());

    add(poly);
}
项目:seg.jUCMNav    文件:FailurePointFigure.java   
public void setColor(Color bg) {
    super.setColor(bg);

    for (Iterator i = rects.iterator(); i.hasNext();) {
        Polyline l = (Polyline) i.next();
        l.setBackgroundColor(bg);
    }
}
项目:seg.jUCMNav    文件:FailurePointFigure.java   
public void rotate(double angle) {
    // make it always point towards bottom
    if (Math.cos(angle)>0)
        angle -= Math.PI;

    Transform t = new Transform();
    t.setRotation(angle);

    Point center = new Point(getPreferredSize().width / 2, getPreferredSize().height / 2);

    for (int j = 0; j < lines.size(); j++) {
        PointList points = (PointList) lines.get(j);
        Polyline line = (Polyline) rects.get(j);

        PointList newPoints = new PointList();
        for (int i = 0; i < points.size(); i++) {
            Point newPoint = t.getTransformed(new Point(points.getPoint(i).x - center.x, points.getPoint(i).y - center.y));
            //Point pt = new Point(newPoint.x - center.x, newPoint.y - center.y);

            newPoints.addPoint(newPoint);
        }

        newPoints.translate(center.x, center.y);

        line.setPoints(newPoints);
    }

    ((EllipseAnchor)outgoingAnchor).ancestorMoved(this);
}
项目:seg.jUCMNav    文件:AnythingFigure.java   
public void rotate(double angle) {
    Point center = new Point(getPreferredSize().width / 2, getPreferredSize().height / 2);

    for (int i = 0; i < pointList.size(); i++) {
        PointList newEdges = TransformationHelper.rotatePoints(angle, (PointList)pointList.get(i), center);

        ((Polyline)lines.get(i)).setPoints(newEdges);
    }
}
项目:seg.jUCMNav    文件:AnythingFigure.java   
@Override
public void setHover(boolean hover) {
    int width = 3;

    if(hover)
        width = 4;

    for (int i = 0; i < lines.size(); i++) {
        Polyline line = (Polyline)lines.get(i);
        line.setLineWidth(width);
    }
}
项目:bdf2    文件:TransitionLabelLocator.java   
public TransitionLabelLocator(String text, Point offset, Polyline polyline) {
    this.text = text;
    this.offset = offset;
    this.polyline = polyline;
}
项目:bdf2    文件:TransitionLabelLocator.java   
public Polyline getPolyline() {
    return polyline;
}
项目:bdf2    文件:TransitionLabelLocator.java   
public void setPolyline(Polyline polyline) {
    this.polyline = polyline;
}
项目:ermasterr    文件:RelationBendpointEditPolicy.java   
/**
 * {@inheritDoc}
 */
@Override
protected void showMoveBendpointFeedback(final BendpointRequest bendpointrequest) {
    final Relation relation = (Relation) getHost().getModel();
    final RelationEditPart editPart = (RelationEditPart) getHost();

    if (relation.getSource() == relation.getTarget()) {
        if (bendpointrequest.getIndex() != 1) {
            return;
        }
        final Point point = bendpointrequest.getLocation();
        getConnection().translateToRelative(point);
        final Bendpoint rate = getRate(point);
        rate.setRelative(true);

        final float rateX = (100f - (rate.getX() / 2)) / 100;
        final float rateY = (100f - (rate.getY() / 2)) / 100;

        final ERTableEditPart tableEditPart = (ERTableEditPart) editPart.getSource();
        final Rectangle bounds = tableEditPart.getFigure().getBounds();

        final Rectangle rect = new Rectangle();
        rect.x = (int) (bounds.x + (bounds.width * rateX));
        rect.y = (int) (bounds.y + (bounds.height * rateY));
        rect.width = bounds.width * rate.getX() / 100;
        rect.height = bounds.height * rate.getY() / 100;

        relation.setSourceLocationp(100, (int) (100 * rateY));

        relation.setTargetLocationp((int) (100 * rateX), 100);

        final LayerManager manager = (LayerManager) tableEditPart.getRoot();
        final IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER);
        getFeedbackLayer().setBounds(layer.getBounds());

        final List children = getFeedbackLayer().getChildren();
        children.clear();
        getFeedbackLayer().repaint();

        final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager();
        final double zoom = zoomManager.getZoom();

        final Polyline feedbackFigure = new Polyline();
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom)));
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) ((rect.y + rect.height) * zoom)));
        feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) ((rect.y + rect.height) * zoom)));
        feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) (rect.y * zoom)));
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom)));

        feedbackFigure.setLineStyle(SWT.LINE_DASH);

        feedbackFigure.translateToRelative(feedbackFigure.getLocation());

        addFeedback(feedbackFigure);

    } else {
        super.showMoveBendpointFeedback(bendpointrequest);
    }

}
项目:ermaster-k    文件:RelationBendpointEditPolicy.java   
/**
 * {@inheritDoc}
 */
@Override
protected void showMoveBendpointFeedback(BendpointRequest bendpointrequest) {
    Relation relation = (Relation) getHost().getModel();
    RelationEditPart editPart = (RelationEditPart) this.getHost();

    Category currentCategory = getDiagram().getCurrentCategory();

    if (relation.getSource() == relation.getTarget()) {
        if (bendpointrequest.getIndex() != 1) {
            return;
        }
        Point point = bendpointrequest.getLocation();
        this.getConnection().translateToRelative(point);
        Bendpoint rate = this.getRate(point);
        rate.setRelative(true);

        float rateX = (100f - (rate.getX() / 2)) / 100;
        float rateY = (100f - (rate.getY() / 2)) / 100;

        ERTableEditPart tableEditPart = (ERTableEditPart) editPart
                .getSource();
        Rectangle bounds = tableEditPart.getFigure().getBounds();

        Rectangle rect = new Rectangle();
        rect.x = (int) (bounds.x + (bounds.width * rateX));
        rect.y = (int) (bounds.y + (bounds.height * rateY));
        rect.width = (int) (bounds.width * rate.getX() / 100);
        rect.height = (int) (bounds.height * rate.getY() / 100);

        relation.setSourceLocationp(currentCategory, 100, (int) (100 * rateY));

        relation.setTargetLocationp(currentCategory, (int) (100 * rateX), 100);

        LayerManager manager = (LayerManager) tableEditPart.getRoot();
        IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER);
        this.getFeedbackLayer().setBounds(layer.getBounds());

        List children = this.getFeedbackLayer().getChildren();
        children.clear();
        this.getFeedbackLayer().repaint();

        ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this
                .getHost().getRoot()).getZoomManager();
        double zoom = zoomManager.getZoom();

        Polyline feedbackFigure = new Polyline();
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom),
                (int) (rect.y * zoom)));
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom),
                (int) ((rect.y + rect.height) * zoom)));
        feedbackFigure.addPoint(new Point(
                (int) ((rect.x + rect.width) * zoom),
                (int) ((rect.y + rect.height) * zoom)));
        feedbackFigure
                .addPoint(new Point((int) ((rect.x + rect.width) * zoom),
                        (int) (rect.y * zoom)));
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom),
                (int) (rect.y * zoom)));

        feedbackFigure.setLineStyle(SWT.LINE_DASH);

        feedbackFigure.translateToRelative(feedbackFigure.getLocation());

        this.addFeedback(feedbackFigure);

    } else {
        super.showMoveBendpointFeedback(bendpointrequest);
    }

}
项目:erflute    文件:RelationBendpointEditPolicy.java   
@Override
protected void showMoveBendpointFeedback(BendpointRequest bendpointrequest) {
    final Relationship relation = (Relationship) getHost().getModel();
    final RelationEditPart editPart = (RelationEditPart) getHost();

    if (relation.getSourceWalker() == relation.getTargetWalker()) {
        if (bendpointrequest.getIndex() != 1) {
            return;
        }
        final Point point = bendpointrequest.getLocation();
        getConnection().translateToRelative(point);
        final Bendpoint rate = getRate(point);
        rate.setRelative(true);

        final float rateX = (100f - (rate.getX() / 2)) / 100;
        final float rateY = (100f - (rate.getY() / 2)) / 100;

        final ERTableEditPart tableEditPart = (ERTableEditPart) editPart.getSource();
        final Rectangle bounds = tableEditPart.getFigure().getBounds();

        final Rectangle rect = new Rectangle();
        rect.x = (int) (bounds.x + (bounds.width * rateX));
        rect.y = (int) (bounds.y + (bounds.height * rateY));
        rect.width = (int) (bounds.width * rate.getX() / 100);
        rect.height = (int) (bounds.height * rate.getY() / 100);

        relation.setSourceLocationp(100, (int) (100 * rateY));

        relation.setTargetLocationp((int) (100 * rateX), 100);

        final LayerManager manager = (LayerManager) tableEditPart.getRoot();
        final IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER);
        getFeedbackLayer().setBounds(layer.getBounds());

        final List<?> children = getFeedbackLayer().getChildren();
        children.clear();
        getFeedbackLayer().repaint();

        final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager();
        final double zoom = zoomManager.getZoom();

        final Polyline feedbackFigure = new Polyline();
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom)));
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) ((rect.y + rect.height) * zoom)));
        feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) ((rect.y + rect.height) * zoom)));
        feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) (rect.y * zoom)));
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom)));

        feedbackFigure.setLineStyle(SWT.LINE_DASH);

        feedbackFigure.translateToRelative(feedbackFigure.getLocation());

        addFeedback(feedbackFigure);

    } else {
        super.showMoveBendpointFeedback(bendpointrequest);
    }
}
项目:OpenSPIFe    文件:TemporalNodeMoveEditPolicy.java   
private Polyline getTemporalBoundFigure(Timepoint timepoint, Rectangle bounds) {
    Date boundDate = getTimepointBound(timepoint);
    if (boundDate == null) {
        // no constraint on this side, no figure needed
        return null;
    }
    // time -> px conversion
    int x = getViewer().getPage().getScreenPosition(boundDate);
    // local to global coordinate transform
    x += getHostFigure().getParent().getBounds().x;
    Polyline figure = new Polyline() {
        @Override
        public void paintFigure(Graphics graphics) {
            graphics.setLineWidth(2);
            super.paintFigure(graphics);
            graphics.fillPolygon(this.getPoints());
        }
    };
    switch(timepoint) {
        case START:
            figure.setForegroundColor(ColorConstants.red);
            figure.setBackgroundColor(ColorConstants.red);
            break;
        case END:
            figure.setForegroundColor(ColorConstants.green);
            figure.setBackgroundColor(ColorConstants.green);
            break;
    }

    int y = bounds.y + 1;
    int w = bounds.height/4;
    int h = bounds.height - 2;

    figure.addPoint(new Point(x, y));
    figure.addPoint(new Point(x, y + h/4));
    switch(timepoint) {
        case START: figure.addPoint(new Point(x - w, y + h/2)); break;
        case END: figure.addPoint(new Point(x + w, y + h/2)); break;
    }
    figure.addPoint(new Point(x, y + 3*h/4));
    figure.addPoint(new Point(x, y + h));
    figure.addPoint(new Point(x, y));
    IFigure parentFigure = ((AbstractGraphicalEditPart)getHost().getParent()).getFigure();
    if (parentFigure.getBounds().contains(figure.getBounds())) {
        addFeedback(figure);
    } else {
        figure = null;
    }
    return figure;
}
项目:OpenSPIFe    文件:LinePlotDataSelectionEditPolicy.java   
@Override
protected void hideSelection() {
    ((Polyline)getHostFigure()).setLineWidth(2);
}
项目:ermaster-nhit    文件:RelationBendpointEditPolicy.java   
/**
 * {@inheritDoc}
 */
@Override
protected void showMoveBendpointFeedback(BendpointRequest bendpointrequest) {
    Relation relation = (Relation) getHost().getModel();
    RelationEditPart editPart = (RelationEditPart) this.getHost();

    if (relation.getSource() == relation.getTarget()) {
        if (bendpointrequest.getIndex() != 1) {
            return;
        }
        Point point = bendpointrequest.getLocation();
        this.getConnection().translateToRelative(point);
        Bendpoint rate = this.getRate(point);
        rate.setRelative(true);

        float rateX = (100f - (rate.getX() / 2)) / 100;
        float rateY = (100f - (rate.getY() / 2)) / 100;

        ERTableEditPart tableEditPart = (ERTableEditPart) editPart
                .getSource();
        Rectangle bounds = tableEditPart.getFigure().getBounds();

        Rectangle rect = new Rectangle();
        rect.x = (int) (bounds.x + (bounds.width * rateX));
        rect.y = (int) (bounds.y + (bounds.height * rateY));
        rect.width = (int) (bounds.width * rate.getX() / 100);
        rect.height = (int) (bounds.height * rate.getY() / 100);

        relation.setSourceLocationp(100, (int) (100 * rateY));

        relation.setTargetLocationp((int) (100 * rateX), 100);

        LayerManager manager = (LayerManager) tableEditPart.getRoot();
        IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER);
        this.getFeedbackLayer().setBounds(layer.getBounds());

        List children = this.getFeedbackLayer().getChildren();
        children.clear();
        this.getFeedbackLayer().repaint();

        ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this
                .getHost().getRoot()).getZoomManager();
        double zoom = zoomManager.getZoom();

        Polyline feedbackFigure = new Polyline();
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom),
                (int) (rect.y * zoom)));
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom),
                (int) ((rect.y + rect.height) * zoom)));
        feedbackFigure.addPoint(new Point(
                (int) ((rect.x + rect.width) * zoom),
                (int) ((rect.y + rect.height) * zoom)));
        feedbackFigure
                .addPoint(new Point((int) ((rect.x + rect.width) * zoom),
                        (int) (rect.y * zoom)));
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom),
                (int) (rect.y * zoom)));

        feedbackFigure.setLineStyle(SWT.LINE_DASH);

        feedbackFigure.translateToRelative(feedbackFigure.getLocation());

        this.addFeedback(feedbackFigure);

    } else {
        super.showMoveBendpointFeedback(bendpointrequest);
    }

}
项目:seg.jUCMNav    文件:StartPointFigure.java   
/**
 * An ellipse that fills 2/3 of the area.
 * 
 * @see seg.jUCMNav.figures.PathNodeFigure#createFigure()
 */
protected void createFigure() {

    int width = preferredSize.width;
    int height = preferredSize.height;

    ellipse = new Ellipse();
    ellipse.setBounds(new Rectangle(13, 13, 16, 16));
    ellipse.setBackgroundColor(ColorManager.LINE);
    ellipse.setAntialias(GeneralPreferencePage.getAntialiasingPref());


    add(ellipse);

    // create the text inside the main figure
    flowPage = new FlowPage();
    stubTypeText = new TextFlow();
    stubTypeText.setLayoutManager(new SimpleTextLayout(stubTypeText));
    // TODO CONCERNS: should use default font?
    stubTypeText.setFont(new Font(null, "Verdana", 12, SWT.BOLD)); //$NON-NLS-1$
    stubTypeText.setText("F"); //$NON-NLS-1$
    stubTypeText.setForegroundColor(ColorManager.WHITE);
    flowPage.add(stubTypeText);
    // TODO CONCERNS: depends on font size!
    flowPage.setBounds(new Rectangle(16, 12, 20, 20));
    flowPage.setVisible(false);

    add(flowPage);

    // The lightning for an abort failure point
    PointList pts = new PointList();
    pts.addPoint(23, 27);
    pts.addPoint(27, 33);
    pts.addPoint(20, 32);
    pts.addPoint(28, 42);
    pts.addPoint(28, 37);
    pts.addPoint(28, 42);
    pts.addPoint(23, 41);

    lightning = new Polyline();
    lightning.setLineWidth(2);
    lightning.setAntialias(GeneralPreferencePage.getAntialiasingPref());
    lightning.setPoints(pts);
    lightning.setVisible(false);

    add(lightning);

    bar = new Polyline();
    bar.addPoint(new Point(15, 15));
    bar.addPoint(new Point(27, 27));
    bar.setLineWidth(3);
    bar.setVisible(false);
    bar.setForegroundColor(ColorManager.WHITE);

    add(bar);
}
项目:seg.jUCMNav    文件:FailurePointFigure.java   
@Override
protected void createFigure() {
    int width = getPreferredSize().width;
    int height = getPreferredSize().height;

    lines = new Vector();
    rects = new Vector();

    rect1 = new Polyline();
    line1 = new PointList();
    line1.addPoint(new Point((width - 20) / 2, 18));
    line1.addPoint(new Point((width - 20) / 2 + 20, 18));
    rect1.setPoints(line1);
    rect1.setBackgroundColor(ColorManager.BLACK);
    rect1.setLineWidth(2);
    rect1.setAntialias(GeneralPreferencePage.getAntialiasingPref());
    lines.add(line1);
    rects.add(rect1);
    add(rect1);

    rect2 = new Polyline();
    line2 = new PointList();
    line2.addPoint(new Point((width - 14) / 2, 13));
    line2.addPoint(new Point((width - 14) / 2 + 14, 13));
    rect2.setPoints(line2);
    rect2.setBackgroundColor(ColorManager.BLACK);
    rect2.setLineWidth(2);
    rect2.setAntialias(GeneralPreferencePage.getAntialiasingPref());
    lines.add(line2);
    rects.add(rect2);
    add(rect2);

    rect3 = new Polyline();
    line3 = new PointList();
    line3.addPoint(new Point((width - 8) / 2, 8));
    line3.addPoint(new Point((width - 8) / 2 + 8, 8));
    rect3.setPoints(line3);
    rect3.setBackgroundColor(ColorManager.BLACK);
    rect3.setLineWidth(2);
    rect3.setAntialias(GeneralPreferencePage.getAntialiasingPref());
    lines.add(line3);
    rects.add(rect3);
    add(rect3);
}
项目:OnionUmlVisualization    文件:OnionRelationshipFigure.java   
private void makeShapes(RelationshipType relationshipType){

    List<Point2D.Float> points = new ArrayList<Point2D.Float>();
    mFillColor = ColorConstants.black;
    boolean isLineDashed = false;

    // construct points as percentages inside canvas
    switch(relationshipType){
        case AGGREGATION:
        case HYPER_AGGREGATION:
            mFillColor = ColorConstants.white;
        case COMPOSITION:
        case HYPER_COMPOSITION:
            points.add(new Point2D.Float(0.5f, 0.05f));
            points.add(new Point2D.Float(0.3f, 0.3f));
            points.add(new Point2D.Float(0.5f, 0.55f));
            points.add(new Point2D.Float(0.7f, 0.3f));
            break;
        case DEPENDENCY:
        case HYPER_DEPENDENCY:
            isLineDashed = true;
        case DIRECTEDASSOCIATION:
        case HYPER_DIRECTEDASSOCIATION:
            points.add(new Point2D.Float(0.5f, 0.05f));
            points.add(new Point2D.Float(0.2f, 0.3f));
            points.add(new Point2D.Float(0.5f, 0.05f));
            points.add(new Point2D.Float(0.8f, 0.3f));
            break;
        case REALIZATION:
        case HYPER_REALIZATION:
            isLineDashed = true;
        case GENERALIZATION:
        case HYPER_GENERALIZATION:
            mFillColor = ColorConstants.white;
            points.add(new Point2D.Float(0.5f, 0.1f));
            points.add(new Point2D.Float(0.25f, 0.4f));
            points.add(new Point2D.Float(0.75f, 0.4f));
            break;
        case ASSOCIATION:
        case HYPER_ASSOCIATION:
            // no head
            break;
        default:
            throw new RuntimeException("Relationship type not supported.");
    }

    // scale polygon to fit in the canvas
    if(points.size() > 0){
        mPolygon = new PointList();
        for(int i=0; i < points.size(); ++i){
            Point2D.Float p = points.get(i);
            mPolygon.addPoint(new Point((int) (p.x * CANVAS.width()),
                    (int) (p.y * CANVAS.height())));
        }
    }
    else{
        mPolygon = null;
    }
    mLinePoints = new PointList();
    mLinePoints.addPoint((int) (0.5f * CANVAS.width()), (int) (0.05f * CANVAS.height()));
    mLinePoints.addPoint((int) (0.5f * CANVAS.width()), (int) (0.95f * CANVAS.height()));
    mLine = new Polyline();
    mLine.setPoints(mLinePoints);
    if(isLineDashed){
        mLine.setLineDash(LINE_DASH);
        mLine.setLineStyle(SWT.LINE_DASH);
    }
    else{
        mLine.setLineStyle(SWT.LINE_SOLID);
    }
}
项目:NEXCORE-UML-Modeler    文件:LineFigure.java   
/**
 * getLine
 *  
 * @return Polyline
 */
public Polyline getLine() {
    return line;
}