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

The following examples show how to use org.eclipse.draw2d.IFigure#setSize() . 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: FunnyStyleSupport.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
public void createFooter() {
    final IFigure footer = new Figure();
    final BorderLayout footerLayout = new BorderLayout();
    footer.setLayoutManager(footerLayout);
    footer.setBorder(new MarginBorder(new Insets(0, 0, 0, 0)));

    final IFigure footer1 = new Figure();
    footer1.setSize(-1, 1);
    footer1.setBackgroundColor(ColorConstants.black);
    footer1.setOpaque(true);
    footer.add(footer1, BorderLayout.TOP);

    final IFigure footer2 = new Figure();
    footer2.setSize(-1, 6);
    footer.add(footer2, BorderLayout.BOTTOM);

    getTableFigure().add(footer, BorderLayout.BOTTOM);
}
 
Example 2
Source File: FunnyStyleSupport.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void createFooter() {
	IFigure footer = new Figure();
	BorderLayout footerLayout = new BorderLayout();
	footer.setLayoutManager(footerLayout);
	footer.setBorder(new MarginBorder(new Insets(0, 0, 0, 0)));

	IFigure footer1 = new Figure();
	footer1.setSize(-1, 1);
	footer1.setBackgroundColor(ColorConstants.black);
	footer1.setOpaque(true);
	footer.add(footer1, BorderLayout.TOP);

	IFigure footer2 = new Figure();
	footer2.setSize(-1, 6);
	footer.add(footer2, BorderLayout.BOTTOM);

	this.getTableFigure().add(footer, BorderLayout.BOTTOM);
}
 
Example 3
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 4
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 5
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 6
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 7
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 8
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 9
Source File: FunnyStyleSupport.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void createFooter() {
    final IFigure footer = new Figure();
    final BorderLayout footerLayout = new BorderLayout();
    footer.setLayoutManager(footerLayout);
    footer.setBorder(new MarginBorder(new Insets(0, 2, 0, 2)));

    final IFigure footer1 = new Figure();
    footer1.setSize(-1, 10);
    footer1.setBackgroundColor(Resources.VERY_LIGHT_GRAY);
    footer1.setOpaque(true);

    footer.add(footer1, BorderLayout.TOP);

    final IFigure footer2 = new Figure();
    footer2.setSize(-1, 7);

    footer.add(footer2, BorderLayout.BOTTOM);

    getTableFigure().add(footer, BorderLayout.BOTTOM);
}
 
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 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 11
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 12
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 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: 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 15
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 16
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 17
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 18
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 19
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 20
Source File: ChartReportItemUIImpl.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public final void updateFigure( final ExtendedItemHandle eih, final IFigure ifg )
{
	try
	{
		eih.loadExtendedElement( );
		// UPDATE THE MODEL
		eih.getReportItem( ).setHandle( eih );

		ChartReportItemUIUtil.refreshBackground( eih,
				(ReportElementFigure) ifg );

		// USE THE SWT DISPLAY SERVER TO CONVERT POINTS TO PIXELS
		final IDisplayServer idsSWT = ChartUIUtil.getDisplayServer( );
		final int dpi = idsSWT.getDpiResolution( );
		
		eih.loadExtendedElement( );
		// UPDATE THE MODEL
		final ChartReportItemImpl iri = (ChartReportItemImpl) eih.getReportItem( );
		final DesignerRepresentation dr = (DesignerRepresentation)iri.getDesignerRepresentation( );
		// Resizes chart to fit container via async execution. The flag
		// needFitContainer makes sure it's executed only once.
		if ( dr.needFitContainer )
		{
			dr.needFitContainer = false;
			Display.getCurrent( ).asyncExec( new Runnable( ) {

				@Override
				public void run( )
				{
					resizeToFitContainer( eih, ifg, dpi );
				}
			} );
		}
		eih.getReportItem( ).setHandle( eih );

		ChartReportItemUIUtil.refreshBackground( eih,
				(ReportElementFigure) ifg );

		Bounds bounds = ChartItemUtil.computeChartBounds( eih, dpi );
		if ( bounds == null )
		{
			return;
		}
		
		final double dHeightInPixels = ( dpi * bounds.getHeight( ) ) / 72d;
		final double dWidthInPixels = ( dpi * bounds.getWidth( ) ) / 72d;			

		// UPDATE THE FIGURE
		( (DesignerRepresentation) ifg ).setDirty( true );
		
		Dimension newSize = ifg.getBounds( ).getCopy( ).getSize( );
		if ( dWidthInPixels >= 0 )
		{
			newSize.width = (int) dWidthInPixels;
		}
		if ( dHeightInPixels >= 0 )
		{
			newSize.height = (int) dHeightInPixels;
		}
		ifg.setSize( newSize );
	}
	catch ( BirtException ex )
	{
		logger.log( ex );
	}
}