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

The following examples show how to use org.eclipse.draw2d.IFigure#addMouseListener() . 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: 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 8
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);
}
 
Example 9
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 10
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 11
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 12
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);
	}
}