Java Code Examples for org.eclipse.draw2d.IFigure#setLocation()

The following examples show how to use org.eclipse.draw2d.IFigure#setLocation() . 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: UpdateSizeLaneSelectionEditPolicy.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void showSelectionForAddBottom() {
    if(sourceFigure == null){
        if(laneEditPart == null){
            laneEditPart = findLaneEditPart(getHost());
            if(laneEditPart == null) {
                return ;
            }
        }
        sourceFigure = laneEditPart.getFigure() ;
    }
    final Rectangle ref = sourceFigure.getBounds().getCopy();
    FiguresHelper.translateToAbsolute(sourceFigure, ref);
    final IFigure f = new ImageFigure(Pics.getImage(PicsConstants.plusBlack));
    f.setSize(20, 20);
    f.setLocation(ref.getBottom().translate(0, 1));
    f.addMouseListener(new MouseListenerForSpan(UpdateSizeLaneSelectionEditPolicy.ADD_BOTTOM));
    layer.add(f);
    figures.add(f);

}
 
Example 2
Source File: UpdateSizeLaneSelectionEditPolicy.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void showSelectionForRemoveBottom() {
    if(sourceFigure == null){
        if(laneEditPart == null){
            laneEditPart = findLaneEditPart(getHost());
            if(laneEditPart == null) {
                return ;
            }
        }
        sourceFigure = laneEditPart.getFigure() ;
    }
    final Rectangle ref = sourceFigure.getBounds().getCopy();
    FiguresHelper.translateToAbsolute(sourceFigure, ref);
    final IFigure f = new ImageFigure(Pics.getImage(PicsConstants.minusBlack));
    f.setSize(20, 20);
    f.setLocation(ref.getBottom().translate(0, -20));
    f.addMouseListener(new MouseListenerForSpan(UpdateSizeLaneSelectionEditPolicy.REMOVE_BOTTOM));
    layer.add(f);
    figures.add(f);

}
 
Example 3
Source File: UpdateSizePoolSelectionEditPolicy.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void showSelectionForAddRight(double zoom) {
    if(sourceFigure == null){
        if(poolEditPart == null){
            poolEditPart = findPoolEditPart(getHost());
            if(poolEditPart == null) {
                return ;
            }
        }
        sourceFigure = poolEditPart.getFigure() ;
    }
    Rectangle ref = sourceFigure.getBounds();
    IFigure f = new ImageFigure(Pics.getImage(PicsConstants.plusBlack));
    f.setSize(20, 20);
    f.setLocation(ref.getRight().getCopy().translate(10, -20));
    f.getBounds().performScale(zoom) ;
    f.addMouseListener(new MouseListenerForSpan(UpdateSizePoolSelectionEditPolicy.ADD_RIGHT));
    layer.add(f);
    figures.put(UpdateSizePoolSelectionEditPolicy.ADD_RIGHT,f);

}
 
Example 4
Source File: UpdateSizePoolSelectionEditPolicy.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void showSelectionForAddBottom(double zoom) {
    if(sourceFigure == null){
        if(poolEditPart == null){
            poolEditPart = findPoolEditPart(getHost());
            if(poolEditPart == null) {
                return ;
            }
        }
        sourceFigure = poolEditPart.getFigure() ;
    }
    Rectangle ref = sourceFigure.getBounds();
    IFigure f = new ImageFigure(Pics.getImage(PicsConstants.plusBlack));
    f.setSize(20, 20);
    f.setLocation(ref.getBottom().getCopy().translate(20, 0));
    f.addMouseListener(new MouseListenerForSpan(UpdateSizePoolSelectionEditPolicy.ADD_BOTTOM));
    f.getBounds().performScale(zoom);
    layer.add(f);
    figures.put(UpdateSizePoolSelectionEditPolicy.ADD_BOTTOM,f);

}
 
Example 5
Source File: UpdateSizePoolSelectionEditPolicy.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void showSelectionForRemoveBottom(double zoom) {
    if(sourceFigure == null){
        if(poolEditPart == null){
            poolEditPart = findPoolEditPart(getHost());
            if(poolEditPart == null) {
                return ;
            }
        }
        sourceFigure = poolEditPart.getFigure() ;
    }
    Rectangle ref = sourceFigure.getBounds();
    IFigure f = new ImageFigure(Pics.getImage(PicsConstants.minusBlack));
    f.setSize(20, 20);
    f.setLocation(ref.getBottom().getCopy().translate(20, -20));
    f.getBounds().performScale(zoom);
    f.addMouseListener(new MouseListenerForSpan(UpdateSizePoolSelectionEditPolicy.REMOVE_BOTTOM));
    layer.add(f);
    figures.put(UpdateSizePoolSelectionEditPolicy.REMOVE_BOTTOM,f);

}
 
Example 6
Source File: UpdateSizePoolSelectionEditPolicy.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 
 */
private void showSelectionForRemoveRight(double zoom) {
    if(sourceFigure == null){
        if(poolEditPart == null){
            poolEditPart = findPoolEditPart(getHost());
            if(poolEditPart == null) {
                return ;
            }
        }
        sourceFigure = poolEditPart.getFigure() ;
    }
    Rectangle ref = sourceFigure.getBounds();
    IFigure f = new ImageFigure(Pics.getImage(PicsConstants.minusBlack));
    f.setSize(20, 20);
    f.setLocation(ref.getLeft().getCopy().translate(-25, -10));

    f.addMouseListener(new MouseListenerForSpan(UpdateSizePoolSelectionEditPolicy.REMOVE_RIGHT));
    f.getBounds().performScale(zoom);
    layer.add(f);
    figures.put(UpdateSizePoolSelectionEditPolicy.REMOVE_RIGHT,f);

}
 
Example 7
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 8
Source File: UpdateSizeLaneSelectionEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void showSelectionForAddRight(final double zoom) {
    final IFigure poolFigure = getPoolEditPart().getFigure();
    final Rectangle ref = poolFigure.getBounds();
    final IFigure f = new ImageFigure(Pics.getImage(PicsConstants.plusBlack));
    f.setSize(20, 20);
    f.setLocation(ref.getRight().translate(10, -20));
    f.getBounds().performScale(zoom) ;
    f.addMouseListener(new MouseListenerForSpan(UpdateSizePoolSelectionEditPolicy.ADD_RIGHT));
    layer.add(f);
    figures.add(f);

}
 
Example 9
Source File: SlideMenuBarFigure.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void addToMenu(IFigure menuEntry){
	
	elements.add(menuEntry);
	
	for(IFigure elem : elements){
		elem.setSize(new Dimension(getSize().width/elements.size(),getSize().height));
		if(elements.indexOf(elem) >0){
			elem.setLocation(new Point(getBounds().getTopLeft().x+elem.getSize().width,getBounds().getTopLeft().y));
		}else{
			elem.setLocation(new Point(getBounds().getTopLeft().x,getBounds().getTopLeft().y));
		}
		this.add(elem);
	}

}
 
Example 10
Source File: DropDownMenuFigure.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void paintElements(){
	if (elements != null) {
		for(Pair<IFigure, MouseListener> pair : elements){
			IFigure elem = pair.getFirst();
			if (elem != null && !(elem instanceof Polyline)) {
				elem.setSize(new Dimension(20,20));
				elem.setLocation(new Point(location.x +elem.getSize().width*elements.indexOf(pair),location.y+20/*+elem.getSize().height*elements.indexOf(elem)*/));
				elem.setVisible(false);
				layer.add(elem);
				addElementsToShow(elem);
			}
		}
	}
}
 
Example 11
Source File: SubprocessCollapseHandle.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void relocate(IFigure target) {
	Rectangle theBounds = getOwnerFigure().getParent().getBounds().getCopy();          
	getOwnerFigure().translateToAbsolute(theBounds);
	target.translateToRelative(theBounds);
	Point loc = theBounds.getBottom(); 
	double zoom = zoomManager.getZoom() ;
	loc.translate(Math.round((float)zoom*-5), Math.round((float)zoom*-20)) ;
	target.setLocation(loc);            
}
 
Example 12
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 13
Source File: SwitchPoolSelectionEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 
 */
private void showSelectionForAddTop() {
	if (!isOnTop()) {

		IFigure f = new ImageFigure(Pics.getImage(PicsConstants.arrowUp));
		f.setParent(getHostFigure());
		f.setSize(20, 20);



		sourceFigure = getHostFigure() ;

		Rectangle bounds = sourceFigure.getBounds().getCopy();
		//get the absolute coordinate of bounds
		sourceFigure.translateToAbsolute(bounds);
		IFigure parentFigure = sourceFigure.getParent();
		while( parentFigure != null  ) {
			if(parentFigure instanceof Viewport) {
				Viewport viewport = (Viewport)parentFigure;
				bounds.translate(
						viewport.getHorizontalRangeModel().getValue(),
						viewport.getVerticalRangeModel().getValue());
				parentFigure = parentFigure.getParent();
			}
			else {
				parentFigure = parentFigure.getParent();
			}
		}

		f.setLocation(new Point(bounds.getTopLeft().x,bounds.getTop().y-20));
		f.addMouseListener(new MouseListenerForSpan(AbstractSwitchLaneSelectionEditPolicy.ADD_TOP));
		layer.add(f);
		figures.add(f);
	}
}
 
Example 14
Source File: SwitchPoolSelectionEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 
 */
private void showSelectionForAddBottom() {
	if (!isOnBottom()) {

		IFigure f = new ImageFigure(Pics.getImage(PicsConstants.arrowDown));
		f.setSize(20, 20);

		sourceFigure = getHostFigure() ;

		Rectangle bounds = sourceFigure.getBounds().getCopy();
		//get the absolute coordinate of bounds
		sourceFigure.translateToAbsolute(bounds);
		IFigure parentFigure = sourceFigure.getParent();
		while( parentFigure != null  ) {
			if(parentFigure instanceof Viewport) {
				Viewport viewport = (Viewport)parentFigure;
				bounds.translate(
						viewport.getHorizontalRangeModel().getValue(),
						viewport.getVerticalRangeModel().getValue());
				parentFigure = parentFigure.getParent();
			}
			else {
				parentFigure = parentFigure.getParent();
			}
		}

		f.setLocation(new Point(bounds.getBottomLeft().x,bounds.getBottom().y));

		f.addMouseListener(new MouseListenerForSpan(AbstractSwitchLaneSelectionEditPolicy.ADD_BOTTOM));
		layer.add(f);
		figures.add(f);
	}
}
 
Example 15
Source File: AbstractSwitchLaneSelectionEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param zoom 
 * 
 */
private void showSelectionForAddTop(double zoom) {
	if (!isOnTop()) {

		IFigure f = new ImageFigure(Pics.getImage(PicsConstants.arrowUp));
		f.setParent(getHostFigure());
		f.setSize(20, 20);



		sourceFigure = getHostFigure() ;

		Rectangle bounds = sourceFigure.getBounds().getCopy();
		//get the absolute coordinate of bounds
		sourceFigure.translateToAbsolute(bounds);
		IFigure parentFigure = sourceFigure.getParent();
		while( parentFigure != null  ) {
			if(parentFigure instanceof Viewport) {
				Viewport viewport = (Viewport)parentFigure;
				bounds.translate(
						viewport.getHorizontalRangeModel().getValue(),
						viewport.getVerticalRangeModel().getValue());
				parentFigure = parentFigure.getParent();
			}
			else {
				parentFigure = parentFigure.getParent();
			}
		}


		Point location = new Point(bounds.getTopLeft().x+20,bounds.getTopLeft().y-20) ;

		f.setLocation(location);
		f.addMouseListener(new MouseListenerForSpan(AbstractSwitchLaneSelectionEditPolicy.ADD_TOP));
		getLayer(LayerConstants.HANDLE_LAYER).add(f);
		figures.add(f);
	}
}
 
Example 16
Source File: AbstractSwitchLaneSelectionEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param zoom 
 * 
 */
private void showSelectionForAddBottom(double zoom) {
	if (!isOnBottom()) {

		IFigure f = new ImageFigure(Pics.getImage(PicsConstants.arrowDown));
		f.setSize(20, 20);

		sourceFigure = getHostFigure() ;

		Rectangle bounds = sourceFigure.getBounds().getCopy();
		//get the absolute coordinate of bounds
		sourceFigure.translateToAbsolute(bounds);
		IFigure parentFigure = sourceFigure.getParent();
		while( parentFigure != null  ) {
			if(parentFigure instanceof Viewport) {
				Viewport viewport = (Viewport)parentFigure;
				bounds.translate(
						viewport.getHorizontalRangeModel().getValue(),
						viewport.getVerticalRangeModel().getValue());
				parentFigure = parentFigure.getParent();
			}
			else {
				parentFigure = parentFigure.getParent();
			}
		}

		Point location =new Point(bounds.getBottomLeft().x+20,bounds.getBottomLeft().y) ; 

		f.setLocation(location);

		f.addMouseListener(new MouseListenerForSpan(AbstractSwitchLaneSelectionEditPolicy.ADD_BOTTOM));
		getLayer(LayerConstants.HANDLE_LAYER).add(f);
		figures.add(f);
	}
}
 
Example 17
Source File: UpdateSizeLaneSelectionEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void showSelectionForRemoveRight(final double zoom) {
    final IFigure poolFigure = getPoolEditPart().getFigure();
    final Rectangle ref = poolFigure.getBounds();
    final IFigure f = new ImageFigure(Pics.getImage(PicsConstants.minusBlack));
    f.setSize(20, 20);
    f.setLocation(ref.getLeft().translate(-25, -10));

    f.addMouseListener(new MouseListenerForSpan(UpdateSizePoolSelectionEditPolicy.REMOVE_RIGHT));
    f.getBounds().performScale(zoom);
    layer.add(f);
    figures.add(f);
}