org.eclipse.draw2d.Figure Java Examples

The following examples show how to use org.eclipse.draw2d.Figure. 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: TableCellEditPart.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void activate( )
{
	if ( handles == null )
	{
		handles = getHandleList( );
	}
	// IFigure layer = getLayer( CrosstabTableEditPart.CELL_HANDLE_LAYER );
	IFigure layer = getLayer( LayerConstants.HANDLE_LAYER );
	int size = handles.size( );
	for ( int i = 0; i < size; i++ )
	{
		Figure handle = (Figure) handles.get( i );
		layer.add( handle );
	}
	super.activate( );
}
 
Example #2
Source File: SimpleStyleSupport.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void initTitleBar(final Figure top) {
    final ToolbarLayout topLayout = new ToolbarLayout();

    topLayout.setMinorAlignment(OrderedLayout.ALIGN_TOPLEFT);
    topLayout.setStretchMinorAxis(true);
    top.setLayoutManager(topLayout);

    nameLabel = new Label();
    nameLabel.setBorder(new MarginBorder(new Insets(5, 20, 5, 20)));
    top.add(nameLabel);

    final Figure separater = new Figure();
    separater.setSize(-1, 1);
    separater.setBackgroundColor(getTextColor());
    separater.setOpaque(true);

    top.add(separater);
}
 
Example #3
Source File: HexagonalGridEditPart.java    From ice with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates the root Figure for the Grid. This is a FreeformLayer that
 * contains a grid of labels and CellFigures.
 */
@Override
protected IFigure createFigure() {

	// Initialize the root figure. We use a FreeformLayer. FIXME - This was
	// in a few tutorials. We should find some links to explain why this is
	// important.
	Figure rootFigure = new FreeformLayer();
	rootFigure.setBackgroundColor(ColorConstants.white);
	rootFigure.setOpaque(true);

	// Set the layout of the root figure to our custom layout.
	Grid grid = ((Grid) getModel());
	HexagonalGridLayout layout = new HexagonalGridLayout(grid.rows,
			grid.columns);
	rootFigure.setLayoutManager(layout);

	// Get the layout's hexagonal PointList.
	hexagonPoints = layout.getPoints();

	return rootFigure;
}
 
Example #4
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 #5
Source File: MultipleLayout.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void layout( IFigure container )
{
	List list = container.getChildren( );
	for ( int i = 0; i < list.size( ); i++ )
	{
		Figure child = (Figure)list.get( i );
		Dimension dim = child.getPreferredSize();
		Rectangle bounds = new Rectangle(container.getClientArea( ).x ,container.getClientArea( ).y,dim.width, dim.height);
		if (!child.getBounds( ).equals( bounds ))
		{
			child.setBounds( bounds );
			//container.getBounds( ).width = bounds.width;
		}
	}
	
}
 
Example #6
Source File: EditorDragGuidePolicy.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void adjustLocation( )
{
	if (infoLabel == null)
	{
		return;
	}
	Rectangle rect = infoLabel.getBounds( ).getCopy();
	Dimension dim = getDistance(  );
	Point p = ((Figure)infoLabel).getLocation( ).getCopy( );
	if (dim.width < rect.width)
	{
		p.x = p.x - (rect.width - dim.width);
	}
	
	if (dim.height < rect.height + DISTANCE)
	{
		p.y = p.y + (rect.height + DISTANCE - dim.height);
	}
	
	infoLabel.setLocation( p );
}
 
Example #7
Source File: SimpleStyleSupport.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
public void initTitleBar(Figure top) {
    final ToolbarLayout topLayout = new ToolbarLayout();

    topLayout.setMinorAlignment(ToolbarLayout.ALIGN_TOPLEFT);
    topLayout.setStretchMinorAxis(true);
    top.setLayoutManager(topLayout);

    this.nameLabel = new Label();
    nameLabel.setBorder(new MarginBorder(new Insets(5, 20, 5, 20)));
    top.add(nameLabel);

    final Figure separater = new Figure();
    separater.setSize(-1, 1);
    separater.setBackgroundColor(getTextColor());
    separater.setOpaque(true);

    top.add(separater);
}
 
Example #8
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 #9
Source File: CrosstabCellEditPart.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void activate( )
{
	if ( handles == null )
	{
		handles = getHandleList( );
	}
	// IFigure layer = getLayer( CrosstabTableEditPart.CELL_HANDLE_LAYER );
	IFigure layer = getLayer( LayerConstants.HANDLE_LAYER );
	int size = handles.size( );
	for ( int i = 0; i < size; i++ )
	{
		Figure handle = (Figure) handles.get( i );
		layer.add( handle );
	}
	super.activate( );
}
 
Example #10
Source File: CrosstabFirstCellEditPart.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected IFigure createFigure( )
{
	Figure figure = new FirstCellFigure();
	
	contentPane = new Figure();
	ReportFlowLayout rflayout = new ReportFlowLayout( )
	{
		public void layout( IFigure parent )
		{
			super.layout( parent );
		}
	};
	contentPane.setLayoutManager( rflayout );
	contentPane.setOpaque( false );
	
	figure.add( contentPane );
	
	controlFigure = new ControlFigure(this, new NothingLocator());
	
	figure.add( controlFigure );
	
	return figure;
}
 
Example #11
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 #12
Source File: FirstCellLayout.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected Dimension calculateMinimumSize( IFigure container, int wHint, int hHint )
{
	if ( wHint > -1 )
		wHint = Math.max( 0, wHint - container.getInsets( ).getWidth( ) );
	if ( hHint > -1 )
		hHint = Math.max( 0, hHint - container.getInsets( ).getHeight( ) );
	
	List list = container.getChildren( );
	//Rectangle rect = container.getClientArea( );
	Dimension retValue = new Dimension();
	Rectangle contraint = getChildContraint( container );
	for (int i=0; i<list.size( ); i++)
	{
		Figure child = (Figure)list.get( i );
		Dimension min = child.getMinimumSize( (wHint-contraint.width) > 0?wHint-contraint.width:-1  , hHint );
		retValue.width = retValue.width + min.width;
		retValue.height = Math.max( retValue.height,min.height);
	}	
	retValue.width += container.getInsets( ).getWidth( );
	retValue.height += container.getInsets( ).getHeight( );
	//retValue.union( getBorderPreferredSize( container ) );
	return retValue;
}
 
Example #13
Source File: FunnyStyleSupport.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void createColumnArea(final IFigure columns) {
    initColumnArea(columns);

    columns.setBorder(new MarginBorder(0, 0, 0, 0));
    columns.setBackgroundColor(ColorConstants.white);
    columns.setOpaque(true);

    final Figure centerFigure = new Figure();
    centerFigure.setLayoutManager(new BorderLayout());
    centerFigure.setBorder(new MarginBorder(new Insets(0, 2, 0, 2)));

    centerFigure.add(columns, BorderLayout.CENTER);
    getTableFigure().add(centerFigure, BorderLayout.CENTER);
}
 
Example #14
Source File: FirstCellLayout.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void layout( IFigure container )
{
	List list = container.getChildren( );
	Rectangle rect = container.getClientArea( );
	Rectangle contraint = getChildContraint( container );
	
	
	for (int i=0; i<list.size( ); i++)
	{
		Figure child = (Figure)list.get( i );
		if (constraints.get( child ) == null)
		{
			child.setBounds( new Rectangle(rect.x, rect.y, rect.width-contraint.width, rect.height ));
		}
		else
		{
			child.setBounds( new Rectangle(rect.x+rect.width-contraint.width, rect.y, contraint.width, rect.height ));
		}
	}
}
 
Example #15
Source File: MultipleGuideHandle.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Calculate the size.
 * 
 * @return
 */
protected Dimension calculateIndicatorDimension( )
{
	Dimension retValue = new Dimension( );
	List children = getChildren( );
	for ( int i = 0; i < children.size( ); i++ )
	{
		Figure figure = (Figure) children.get( i );
		if ( figure instanceof ShowSourceFigure )
		{
			continue;
		}
		// retValue = retValue.union( figure.getSize( ) );
		retValue.width = retValue.width + figure.getSize( ).width;
		retValue.height = Math.max( retValue.height,
				figure.getSize( ).height );
	}

	return retValue;
}
 
Example #16
Source File: CustomMainPaletteViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createDefaultRoot() {
	setRootEditPart(new SimpleRootEditPart(){
		@Override
		protected IFigure createFigure() {
			Figure figure = new Figure();
			figure.setLayoutManager(new StackLayout());
			return figure;
		}
	});
}
 
Example #17
Source File: ActivityNameCursorMouseMotionListener.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void mouseEntered(MouseEvent me) {
    final Figure source = (Figure) me.getSource();
    if (editPart.getSelected() == EditPart.SELECTED_PRIMARY) {
        source.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_IBEAM));
    } else {
        source.setCursor(Pics.getOpenedHandCursor());
    }

}
 
Example #18
Source File: CubeEditPart.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected IFigure createFigure( )
{
	Figure f = new FreeformLayer( );
	f.setLayoutManager( new FreeformLayout( ) );
	f.setBorder( new MarginBorder( 5 ) );
	return f;
}
 
Example #19
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 #20
Source File: ActivityNameCursorMouseMotionListener.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void mouseHover(MouseEvent me) {
    final Figure source = (Figure) me.getSource();
    if (editPart.getSelected() == EditPart.SELECTED_PRIMARY) {
        source.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_IBEAM));
    } else {
        source.setCursor(Pics.getOpenedHandCursor());
    }
}
 
Example #21
Source File: CrosstabTableEditPart.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the top-most set of layers on the given layered pane.
 * 
 * @param layeredPane
 *            the parent for the created layers
 */
protected void createLayers( LayeredPane layeredPane )
{
	Figure figure = new FreeformLayer( );
	figure.setOpaque( false );
	layeredPane.add( figure, CELL_HANDLE_LAYER );
	layeredPane.add( getPrintableLayers( ), PRINTABLE_LAYERS );
	layeredPane.add( new FreeformLayer( ), HANDLE_LAYER );
	layeredPane.add( new GuideLayer( ), GUIDE_LAYER );
}
 
Example #22
Source File: BPMNShapeFactory.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private PolylineConnection createConnectorFigure(Edge bonitaEdge) {
    Bounds sourceLocation = getBPMNShapeBounds(modelExporter.getEObjectID(bonitaEdge.getSource()));
    Bounds targetLocation = getBPMNShapeBounds(modelExporter.getEObjectID(bonitaEdge.getTarget()));

    PolylineConnection conn = new PolylineConnection();
    AbstractRouter router = new CustomRectilinearRouter();
    conn.setConnectionRouter(router);
    final List<RelativeBendpoint> pointList = ((RelativeBendpoints) bonitaEdge.getBendpoints()).getPoints();
    List<org.eclipse.draw2d.RelativeBendpoint> figureConstraint = new ArrayList<>();
    for (int i = 0; i < pointList.size(); i++) {
        RelativeBendpoint relativeBendpoint = (RelativeBendpoint) pointList.get(i);
        IFigure sourceFigure = new Figure();
        sourceFigure.setBounds(toRectangle(sourceLocation));
        IFigure targetFigure = new Figure();
        targetFigure.setBounds(toRectangle(targetLocation));
        conn.setSourceAnchor(new CustomAnchor(sourceFigure));
        conn.setTargetAnchor(new CustomAnchor(targetFigure));
        org.eclipse.draw2d.RelativeBendpoint rbp = new org.eclipse.draw2d.RelativeBendpoint(conn);
        rbp.setRelativeDimensions(
                new Dimension(relativeBendpoint.getSourceX(), relativeBendpoint.getSourceY()),
                new Dimension(relativeBendpoint.getTargetX(), relativeBendpoint.getTargetY()));
        if (pointList.size() == 1) {
            rbp.setWeight(0.5f);
        } else {
            rbp.setWeight(i / ((float) pointList.size() - 1));
        }
        figureConstraint.add(rbp);
    }
    conn.setRoutingConstraint(figureConstraint);
    router.route(conn);
    return conn;
}
 
Example #23
Source File: FunnyStyleSupport.java    From erflute with Apache License 2.0 5 votes vote down vote up
@Override
public void initTitleBar(Figure top) {
    top.setLayoutManager(new BorderLayout());

    final FlowLayout layout = new FlowLayout();
    layout.setStretchMinorAxis(true);
    final Figure title = new Figure();
    top.add(title, BorderLayout.TOP);
    title.setLayoutManager(layout);

    title.setBorder(new MarginBorder(new Insets(2, 2, 2, 2)));

    final ImageFigure image = new ImageFigure();
    image.setBorder(new MarginBorder(new Insets(0, 0, 0, 0)));
    image.setImage(Activator.getImage(getTableFigure().getImageKey()));
    title.add(image);

    this.nameLabel = new Label();
    nameLabel.setBorder(new MarginBorder(new Insets(0, 0, 0, 20)));
    title.add(nameLabel);

    final Figure separater = new Figure();
    separater.setSize(-1, 1);
    separater.setBackgroundColor(ColorConstants.black);
    separater.setOpaque(true);

    top.add(separater, BorderLayout.BOTTOM);
}
 
Example #24
Source File: ListBandControlFigure.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public Dimension getPreferredSize( int wHint, int hHint )
{
	// return CONTROL_SIZE;//88, 19
	Dimension dimension = new Dimension( 0, CONTROL_SIZE.height );
	List list = getChildren( );
	for ( int i = 0; i < list.size( ); i++ )
	{
		Figure figure = (Figure) list.get( i );
		dimension.width = dimension.width + figure.getSize( ).width;
	}
	return dimension;
	// return super.getPreferredSize( wHint, hHint );
}
 
Example #25
Source File: ImageTest.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
private static void main() throws FileNotFoundException {
    try {
        shell.setSize(100, 100);

        final LightweightSystem lws = new LightweightSystem(shell);

        final IFigure panel = new Figure();
        panel.setLayoutManager(new ToolbarLayout());

        initialize(panel);

        lws.setContents(panel);

        shell.open();

        final Display display = Display.getDefault();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }

    } finally {
        if (image != null) {
            image.dispose();
        }
    }
}
 
Example #26
Source File: FrameStyleSupport.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void initTitleBar(final Figure top) {
    titleBarBorder = (TitleBarBorder) border.getInnerBorder();
    titleBarBorder.setTextAlignment(PositionConstants.CENTER);
    titleBarBorder.setPadding(new Insets(5, 20, 5, 20));
}
 
Example #27
Source File: ReportFigureUtilities.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public static Figure createToolTipFigure( String toolTipText,
		String direction, String textAlign )
{
	if ( toolTipText == null )
	{
		return null;
	}

	LabelFigure tooltip = new LabelFigure( );

	// bidi_hcg start
	if ( DesignChoiceConstants.BIDI_DIRECTION_RTL.equals( direction ) )
	{
		tooltip.setDirection( direction );
	}
	else if ( DesignChoiceConstants.BIDI_DIRECTION_LTR.equals( direction ) )
	{
		tooltip.setDirection( direction );
	}

	tooltip.setTextAlign( textAlign );
	// bidi_hcg end

	tooltip.setText( toolTipText );
	tooltip.setBorder( new MarginBorder( 0, 2, 0, 2 ) );

	return tooltip;
}
 
Example #28
Source File: AbstractStyleSupport.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
@Override
public void createTitleBar() {
    final Figure top = new Figure();
    tableFigure.add(top, BorderLayout.TOP);

    initTitleBar(top);
}
 
Example #29
Source File: FunnyStyleSupport.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void initTitleBar(final Figure top) {
    top.setLayoutManager(new BorderLayout());

    final Figure title = new Figure();
    top.add(title, BorderLayout.TOP);
    final FlowLayout titleLayout = new FlowLayout();
    titleLayout.setMinorAlignment(OrderedLayout.ALIGN_CENTER);
    title.setLayoutManager(titleLayout);

    final ImageFigure image = new ImageFigure();
    image.setBorder(new MarginBorder(new Insets(5, 10, 5, 2)));
    image.setImage(ERDiagramActivator.getImage(getTableFigure().getImageKey()));
    title.add(image);

    nameLabel = new Label();
    nameLabel.setBorder(new MarginBorder(new Insets(5, 0, 5, 20)));
    title.add(nameLabel);

    final Figure separater = new Figure();
    separater.setSize(-1, 1);
    separater.setBackgroundColor(ColorConstants.black);
    separater.setOpaque(true);

    top.add(separater, BorderLayout.BOTTOM);
}
 
Example #30
Source File: RailroadView.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void createPartControl(Composite parent) {
	canvas = new FigureCanvas(parent, SWT.V_SCROLL | SWT.H_SCROLL);
	rootFigure = new Figure();
	rootFigure.addMouseListener(selectionProvider);
	rootFigure.setLayoutManager(new StackLayout());
	rootFigure.setVisible(true);
	canvas.setContents(rootFigure);
	getSite().setSelectionProvider(selectionProvider);
	createActions();
}