org.eclipse.draw2d.IFigure Java Examples

The following examples show how to use org.eclipse.draw2d.IFigure. 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: ListFigure.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Marks dirty flag on all children with the specified container.
 * 
 * @param container
 *            the container to mark.
 * @param flag
 *            the flag to mark.
 */
public void markDirtyTree( IFigure container, boolean flag )
{
	if ( container instanceof ListFigure )
	{
		( (ListFigure) container ).markDirty( flag );
	}

	Collection children = container.getChildren( );

	for ( Iterator iterator = children.iterator( ); iterator.hasNext( ); )
	{
		Object child = iterator.next( );

		if ( child instanceof IFigure )
		{
			markDirtyTree( (IFigure) child, flag );
		}
	}
}
 
Example #2
Source File: XtextDirectEditManager.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
protected void hookListeners() {
	super.hookListeners();

	// TODO: This gets around the problem of the cell editor not growing big
	// enough when in autosize mode because it doesn't listen to textflow
	// size changes. The superclass should be modified to not assume we want
	// to listen to the editpart's figure.
	ILabelDelegate label = (ILabelDelegate) getEditPart().getAdapter(ILabelDelegate.class);
	if (label != null && getEditPart().getFigure() instanceof WrappingLabel) {

		textFigureListener = new AncestorListener.Stub() {

			public void ancestorMoved(IFigure ancestor) {
				getLocator().relocate(getCellEditor());
			}
		};
		((IFigure) ((WrappingLabel) getEditPart().getFigure()).getTextFigure().getChildren().get(0))
				.addAncestorListener(textFigureListener);
	}
}
 
Example #3
Source File: GridContainerController.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public GridContainerController ( final SymbolController controller, final GridContainer element, final BasicViewElementFactory factory ) throws Exception
{
    this.figure = new Figure ();

    final GridLayout gridLayout = new GridLayout ( element.getColumns (), element.isEqualWidth () );
    gridLayout.horizontalSpacing = element.getHorizontalSpacing ();
    gridLayout.verticalSpacing = element.getVerticalSpacing ();
    gridLayout.marginHeight = element.getMarginHeight ();
    gridLayout.marginWidth = element.getMarginWidth ();

    this.figure.setLayoutManager ( gridLayout );

    for ( final GridChild child : element.getChildren () )
    {
        final Controller elementController = factory.create ( controller, child.getElement () );
        final IFigure childFigure = elementController.getFigure ();
        this.figure.add ( childFigure, convert ( child ) );
    }

    controller.addElement ( element, this );
}
 
Example #4
Source File: StartTimerEventLabelEditPart.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @generated
*/
protected void setLabelTextHelper(IFigure figure, String text) {
	EObject obj = resolveSemanticElement();
	if (obj != null && obj instanceof ThrowLinkEvent) {
		if (((ThrowLinkEvent) obj).getTo() != null) {
			text = ((ThrowLinkEvent) obj).getTo().getName();
			if (text == null) {
				text = "";
			}
		} else {
			text = "";
		}
	}
	if (figure instanceof WrappingLabel) {
		((WrappingLabel) figure).setText(text);
	} else {
		((Label) figure).setText(text);
	}
}
 
Example #5
Source File: BoundaryTimerEventLabelEditPart.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @generated
*/
protected void setLabelTextHelper(IFigure figure, String text) {
	EObject obj = resolveSemanticElement();
	if (obj != null && obj instanceof ThrowLinkEvent) {
		if (((ThrowLinkEvent) obj).getTo() != null) {
			text = ((ThrowLinkEvent) obj).getTo().getName();
			if (text == null) {
				text = "";
			}
		} else {
			text = "";
		}
	}
	if (figure instanceof WrappingLabel) {
		((WrappingLabel) figure).setText(text);
	} else {
		((Label) figure).setText(text);
	}
}
 
Example #6
Source File: RoundedRectangleBorder.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void paint(IFigure figure, Graphics graphics, Insets insets) {
	tempRect.setBounds(getPaintRectangle(figure, insets));
	if ((getWidth() % 2) == 1) {
		tempRect.width--;
		tempRect.height--;
	}
	tempRect.shrink(getWidth() / 2, getWidth() / 2);

	graphics.setLineWidth(getWidth());
	graphics.setLineStyle(getStyle());
	if (getColor() != null)
		graphics.setForegroundColor(getColor());

	graphics.drawRoundRectangle(tempRect, fArcWidth, fArcHeight);
}
 
Example #7
Source File: WrappableToolbarLayout.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public void layout(IFigure container) {
	Rectangle clientArea = container.getClientArea();
	int w = 0;
	int h = 0;
	int maxH = 0;
	for (Object child : container.getChildren()) {
		IFigure figure = (IFigure) child;
		Dimension preferSize = figure.getPreferredSize();
		if (w + preferSize.width < clientArea.width) {
			figure.setBounds(
					new Rectangle(clientArea.x + w, clientArea.y + h, preferSize.width, preferSize.height));
			w += preferSize.width;
			if (maxH < preferSize.height) {
				maxH = preferSize.height;
			}
		} else {
			h += maxH;
			w = 0;
			figure.setBounds(
					new Rectangle(clientArea.x + w, clientArea.y + h, preferSize.width, preferSize.height));
			w = preferSize.width;
			maxH = preferSize.height;
		}
	}

}
 
Example #8
Source File: ListBandHandle.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void relocate( IFigure target )
{
	Rectangle bounds;
	if ( getReference( ) instanceof ListBandFigure )
	{
		ListBandFigure parent = (ListBandFigure) getReference( );
		Figure content = (Figure) parent.getContent( );
		bounds = content.getBounds( ).getCopy( );
	}
	else
	{
		bounds = getReference( ).getBounds( ).getCopy( );
	}

	getReference( ).translateToAbsolute( bounds );
	target.translateToRelative( bounds );

	bounds.translate( 1, 1 );
	bounds.resize( -1, -1 );

	target.setBounds( bounds );
}
 
Example #9
Source File: DeferredGraphicalViewer.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @see GraphicalViewer#findHandleAt(org.eclipse.draw2d.geometry.Point)
 */
public Handle findHandleAt( Point p )
{
	LayerManager layermanager = (LayerManager) getEditPartRegistry( ).get( LayerManager.ID );
	if ( layermanager == null )
		return null;
	List list = new ArrayList( 3 );
	// list.add(layermanager.getLayer(LayerConstants.PRIMARY_LAYER));
	list.add( layermanager.getLayer( LayerConstants.CONNECTION_LAYER ) );
	list.add( layermanager.getLayer( LayerConstants.FEEDBACK_LAYER ) );
	IFigure handle = getLightweightSystem( ).getRootFigure( )
			.findFigureAtExcluding( p.x, p.y, list );
	if ( handle instanceof Handle )
		return (Handle) handle;
	return null;
}
 
Example #10
Source File: PoolEditPart.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected boolean addFixedChild(EditPart childEditPart) {
	if (childEditPart instanceof PoolNameEditPart) {
		((PoolNameEditPart) childEditPart).setLabel(getPrimaryShape().getFigurePoolNameFigure());
		if (VISUAL_ID != 3007 && VISUAL_ID != 2007 && VISUAL_ID != 3015 && VISUAL_ID != 3058) {
			getPrimaryShape().getFigurePoolNameFigure()
					.addMouseMotionListener(new ActivityNameCursorMouseMotionListener(this));
		}
		return true;
	}
	if (childEditPart instanceof PoolPoolCompartmentEditPart) {
		IFigure pane = getPrimaryShape().getFigurePoolContainerFigure();
		setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way 
		pane.add(((PoolPoolCompartmentEditPart) childEditPart).getFigure());
		return true;
	}

	return false;
}
 
Example #11
Source File: IntermediateCatchTimerEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public IFigure getContentPane() {
	if (contentPane != null) {
		return contentPane;
	}
	return super.getContentPane();
}
 
Example #12
Source File: NonInterruptingBoundaryTimerEvent2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* Creates figure for this edit part.
* 
* Body of this method does not depend on settings in generation model
* so you may safely remove <i>generated</i> tag and modify it.
* 
* @generated
*/
protected NodeFigure createMainFigure() {
	NodeFigure figure = createNodePlate();
	figure.setLayoutManager(new StackLayout());
	IFigure shape = createNodeShape();
	figure.add(shape);
	contentPane = setupContentPane(shape);
	return figure;
}
 
Example #13
Source File: ThrowLinkEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public IFigure getContentPane() {
	if (contentPane != null) {
		return contentPane;
	}
	return super.getContentPane();
}
 
Example #14
Source File: FixedBendpointEditPolicy.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
private void routeInResponseToBoxDrag(ChangeBoundsRequest request) {
	if (connectionStart) {
		IFigure figure = getHostFigure();
		originalBounds = getHostFigure().getBounds().getCopy();
		figure.translateToAbsolute(originalBounds);
		originalBounds.translate(request.getMoveDelta().getNegated()).resize(request.getSizeDelta().getNegated());
		router.initBoxDrag(originalBounds, getSourceConnections(request), getTargetConnections(request));
		connectionStart = false;
	}
	router.updateBoxDrag(request.getTransformedRectangle(originalBounds));
}
 
Example #15
Source File: CustomPoolCompartmentEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public IFigure createFigure() {
    final ShapeCompartmentFigure scf = new CustomShapeCompartmentFigure(getCompartmentName(), getMapMode());
    scf.getContentPane().setLayoutManager(getLayoutManager());
    scf.getContentPane().addLayoutListener(LayoutAnimator.getDefault());
    scf.setTitleVisibility(false);
    return scf;
}
 
Example #16
Source File: SubProcessEventLabel2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected String getLabelTextHelper(IFigure figure) {
	if (figure instanceof WrappingLabel) {
		return ((WrappingLabel) figure).getText();
	} else if (figure instanceof Label) {
		return ((Label) figure).getText();
	} else {
		return getLabelDelegate().getText();
	}
}
 
Example #17
Source File: AdjustIdentityAnchorCommand.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
private PrecisionPoint computeNewAnchor(PrecisionPoint currentAnchorPoint, EditPart editPart) {

		double scale = getScale(editPart);
		IFigure figure = ((IGraphicalEditPart) editPart).getFigure();
		Rectangle bounds = figure.getBounds();
		if (figure instanceof HandleBounds) {
			bounds = ((HandleBounds) figure).getHandleBounds();
		}

		Point currentRelativePoint = getAnchorRelativePoint(currentAnchorPoint, bounds);

		if (futureSize != null && delta != null) {
			// In case of border node, the real location is computed earlier
			// (according to BorderItemLocator). The corresponding futureSize
			// and delta are used instead of the request data.
			return new PrecisionPoint(((double) (currentRelativePoint.x - delta.x)) / futureSize.width,
					((double) (currentRelativePoint.y - delta.y)) / futureSize.height);
		} else {

			double logicalWidthDelta = request.getSizeDelta().width / scale;
			double logicalHeightDelta = request.getSizeDelta().height / scale;

			int direction = request.getResizeDirection();

			double newRelativeX = computeNewXRelativeLocation(direction, currentRelativePoint, logicalWidthDelta);
			double newRelativeY = computeNewYRelativeLocation(direction, currentRelativePoint, logicalHeightDelta);

			return new PrecisionPoint(newRelativeX / (bounds.width() + logicalWidthDelta),
					newRelativeY / (bounds.height() + logicalHeightDelta));
		}
	}
 
Example #18
Source File: NonInterruptingBoundaryTimerEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* Creates figure for this edit part.
* 
* Body of this method does not depend on settings in generation model
* so you may safely remove <i>generated</i> tag and modify it.
* 
* @generated
*/
protected NodeFigure createMainFigure() {
	NodeFigure figure = createNodePlate();
	figure.setLayoutManager(new StackLayout());
	IFigure shape = createNodeShape();
	figure.add(shape);
	contentPane = setupContentPane(shape);
	return figure;
}
 
Example #19
Source File: StartTimerEvent2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* Default implementation treats passed figure as content pane.
* Respects layout one may have set for generated figure.
* @param nodeShape instance of generated figure class
* @generated
*/
protected IFigure setupContentPane(IFigure nodeShape) {
	if (VISUAL_ID != 3007 && VISUAL_ID != 2007) {
		getPrimaryShape().addMouseMotionListener(new ActivityCursorMouseMotionListener());
	}
	return nodeShape; // use nodeShape itself as contentPane
}
 
Example #20
Source File: Animation.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
static void recordFinalState(IFigure child) {
	if (child instanceof Connection) {
		recordFinalState((Connection) child);
		return;
	}
	Rectangle rect2 = child.getBounds().getCopy();
	Rectangle rect1 = (Rectangle) initialStates.get(child);
	if (rect1.isEmpty()) {
		rect1.x = rect2.x;
		rect1.y = rect2.y;
		rect1.width = rect2.width;
	}
	finalStates.put(child, rect2);
}
 
Example #21
Source File: IntermediateCatchMessageEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
	if (borderItemEditPart instanceof IntermediateCatchMessageEventLabelEditPart) {
		BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
		locator.setBorderItemOffset(new Dimension(-20, -20));
		borderItemContainer.add(borderItemEditPart.getFigure(), locator);
	} else {
		super.addBorderItem(borderItemContainer, borderItemEditPart);
	}
}
 
Example #22
Source File: CustomPaletteEditPartFactory.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected EditPart createMainPaletteEditPart(EditPart parentEditPart,
		Object model) {
	return new SliderPaletteEditPart((PaletteRoot) model){
		@Override
		public IFigure createFigure() {
			Figure figure = new Figure();
			figure.setOpaque(true);
			figure.setForegroundColor(ColorConstants.listForeground);
			figure.setBackgroundColor(ColorConstants.white);
			return figure;
		}
	};
}
 
Example #23
Source File: HierarchyColumnEditPart.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected IFigure createFigure( )
{
	ColumnFigure columnFigure = null;
	columnFigure = new ColumnFigure( );
	FlowLayout layout = new FlowLayout( );
	layout.setMinorSpacing( 2 );
	columnFigure.setLayoutManager( layout );
	columnFigure.setOpaque( true );
	String name = OlapUtil.getDataFieldDisplayName( getColumn( ) );
	label = new Label( name );
	columnFigure.add( label );
	return columnFigure;
}
 
Example #24
Source File: ServiceTaskLabelEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected Image getLabelIconHelper(IFigure figure) {
	if (figure instanceof WrappingLabel) {
		return ((WrappingLabel) figure).getIcon();
	} else if (figure instanceof Label) {
		return ((Label) figure).getIcon();
	} else {
		return getLabelDelegate().getIcon(0);
	}
}
 
Example #25
Source File: Task2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* Creates figure for this edit part.
* 
* Body of this method does not depend on settings in generation model
* so you may safely remove <i>generated</i> tag and modify it.
* 
* @generated
*/
protected NodeFigure createMainFigure() {
	NodeFigure figure = createNodePlate();
	figure.setLayoutManager(new StackLayout());
	IFigure shape = createNodeShape();
	figure.add(shape);
	contentPane = setupContentPane(shape);
	return figure;
}
 
Example #26
Source File: InclusiveGatewayEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
	if (borderItemEditPart instanceof InclusiveGatewayLabelEditPart) {
		BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
		locator.setBorderItemOffset(new Dimension(-20, -20));
		borderItemContainer.add(borderItemEditPart.getFigure(), locator);
	} else {
		super.addBorderItem(borderItemContainer, borderItemEditPart);
	}
}
 
Example #27
Source File: EndEvent2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* Creates figure for this edit part.
* 
* Body of this method does not depend on settings in generation model
* so you may safely remove <i>generated</i> tag and modify it.
* 
* @generated
*/
protected NodeFigure createMainFigure() {
	NodeFigure figure = createNodePlate();
	figure.setLayoutManager(new StackLayout());
	IFigure shape = createNodeShape();
	figure.add(shape);
	contentPane = setupContentPane(shape);
	return figure;
}
 
Example #28
Source File: StartTimerEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public IFigure getContentPane() {
	if (contentPane != null) {
		return contentPane;
	}
	return super.getContentPane();
}
 
Example #29
Source File: LaneEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public IFigure getContentPane() {
	if (contentPane != null) {
		return contentPane;
	}
	return super.getContentPane();
}
 
Example #30
Source File: TreeMapper.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @return a newly created figure to alert the end-user of an inconsistency in the widget
 */
private IFigure createWarningFigure() {
	Image image = Display.getDefault().getSystemImage(SWT.ICON_WARNING);
	ImageFigure res = new ImageFigure(image);
	res.setPreferredSize(10, 10);
	Label label = new Label(Messages.widgetInconsistency);
	res.setToolTip(label);
	return res;
}