Java Code Examples for org.eclipse.draw2d.Polyline#addPoint()

The following examples show how to use org.eclipse.draw2d.Polyline#addPoint() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TableLayout.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 2
Source File: TableLayout.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 3
Source File: TableLayout.java    From erflute with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 4
Source File: TableLayout.java    From erflute with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 5
Source File: MenuEventFigure.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void paintElements() {
    final RoundedRectangle background = new RoundedRectangle();
    background.setAlpha(50);
    background.setBackgroundColor(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY));
    background.setSize(new Dimension(4*20,figureList.size()*20));
    background.setLocation(new Point(parent.getBounds().getTopLeft().x,parent.getBounds().getTopLeft().y+40));
    background.setVisible(false);
    parent.add(background);
    addElementsToShow(background);
    if (figureList != null) {
        for(final List<IFigure> eventLists : figureList){
            for(final IFigure f : eventLists){
                f.setSize(new Dimension(20,20));
                f.setLocation(new Point(parent.getBounds().getTopLeft().x +f.getSize().width*eventLists.indexOf(f),parent.getBounds().getTopLeft().y+20*(figureList.indexOf(eventLists)+2)));
                f.setVisible(false);
                background.add(f);
                if(!(f instanceof RectangleFigure)){
                    addElementsToShow(f);
                }

            }
            if(figureList.indexOf(eventLists) != figureList.size()-1){
                final Polyline lineSeparator = new Polyline();
                lineSeparator.addPoint(new Point(parent.getBounds().getTopLeft().x ,parent.getBounds().getTopLeft().y+20+20*(figureList.indexOf(eventLists)+2)));
                lineSeparator.addPoint(new Point(parent.getBounds().getTopLeft().x + 80,parent.getBounds().getTopLeft().y+20+20*(figureList.indexOf(eventLists)+2)));
                lineSeparator.setAlpha(80);
                lineSeparator.setVisible(false);
                background.add(lineSeparator);
                addElementsToShow(lineSeparator);
            }
        }
    }
}
 
Example 6
Source File: DropDownMenuEventFigure.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void paintElements() {
	
	if (figureList != null) {
		for(List<IFigure> eventLists : figureList){
			Point parentTopLeft = parent.getBounds().getTopLeft();
			for(IFigure f : eventLists){
				f.setSize(new Dimension(20,20));
				f.setLocation(new Point(parentTopLeft.x +f.getSize().width*eventLists.indexOf(f),parentTopLeft.y+20*(figureList.indexOf(eventLists)+2)));
				f.setVisible(false);
				subMenuFigure.add(f);
				if(!(f instanceof RectangleFigure)){
					addElementsToShow(f);
				}
			
			}
			if(figureList.indexOf(eventLists) != figureList.size()-1){
				Polyline lineSeparator = new Polyline();
				lineSeparator.addPoint(new Point(parentTopLeft.x ,parentTopLeft.y+20+20*(figureList.indexOf(eventLists)+2)));
				lineSeparator.addPoint(new Point(parentTopLeft.x + 80,parentTopLeft.y+20+20*(figureList.indexOf(eventLists)+2)));
				lineSeparator.setAlpha(80);
				lineSeparator.setVisible(false);
				subMenuFigure.add(lineSeparator);
				addElementsToShow(lineSeparator);
			}
		}
	}
	isPaint = true ;
}
 
Example 7
Source File: TableLayout.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 8
Source File: TableLayout.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 9
Source File: RelationBendpointEditPolicy.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
/**
 * {@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);
    }

}
 
Example 10
Source File: RelationBendpointEditPolicy.java    From erflute with Apache License 2.0 4 votes vote down vote up
@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);
    }
}
 
Example 11
Source File: RelationBendpointEditPolicy.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
/**
 * {@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);
	}

}