Java Code Examples for org.eclipse.draw2d.Figure#setLayoutManager()

The following examples show how to use org.eclipse.draw2d.Figure#setLayoutManager() . 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: 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 2
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 3
Source File: ProcessFigure.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void createHeader() {
	Figure top = new Figure();
	GridLayout topLayout = new GridLayout(3, false);
	topLayout.horizontalSpacing = 0;
	topLayout.verticalSpacing = 0;
	topLayout.marginHeight = 0;
	topLayout.marginWidth = 0;
	top.setLayoutManager(topLayout);
	leftExpander = new ProcessExpander(node, Side.INPUT);
	rightExpander = new ProcessExpander(node, Side.OUTPUT);
	top.add(leftExpander, new GridData(SWT.LEFT, SWT.CENTER, false, false));
	top.add(new Label(node.getName()), new GridData(SWT.FILL, SWT.FILL, true, false));
	top.add(rightExpander, new GridData(SWT.RIGHT, SWT.CENTER, false, false));
	add(top, new GridData(SWT.FILL, SWT.FILL, true, false));
	GridData dummyGridData = new GridData(SWT.FILL, SWT.FILL, true, false);
	dummyGridData.heightHint = TEXT_HEIGHT + 3 * MARGIN_HEIGHT;
	add(new Figure(), dummyGridData);
}
 
Example 4
Source File: ImageTest.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
private static Figure createContents() {
	Figure contents = new Figure();
	XYLayout layout = new XYLayout();
	contents.setLayoutManager(layout);

	Button button = new Button("Hello World");
	layout.setConstraint(button, new Rectangle(0, 0, -1, -1));
	contents.add(button);

	button.addActionListener(new ActionListener() {

		public void actionPerformed(ActionEvent actionevent) {
			setBrightness();
		}
	});

	String path = "C:\\Users\\Public\\Pictures\\Sample Pictures\\Oryx Antelope.jpg";
	image = new Image(Display.getDefault(), path);
	imageFigure = new ImageFigure(image);

	layout.setConstraint(imageFigure, new Rectangle(0, 30, -1, -1));

	contents.add(imageFigure);

	return contents;
}
 
Example 5
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 6
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 7
Source File: FunnyStyleSupport.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void createColumnArea(IFigure columns) {
	this.initColumnArea(columns);

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

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

	centerFigure.add(columns, BorderLayout.CENTER);
	this.getTableFigure().add(centerFigure, BorderLayout.CENTER);
}
 
Example 8
Source File: SimpleStyleSupport.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void initTitleBar(Figure top) {
	ToolbarLayout topLayout = new ToolbarLayout();

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

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

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

	top.add(separater);
}
 
Example 9
Source File: FunnyStyleSupport.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void initTitleBar(Figure top) {
	top.setLayoutManager(new BorderLayout());

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

	if (new BigDecimal("1.5").equals(getSettings().getTitleFontEm())) {
		title.setBorder(new MarginBorder(new Insets(2, 2, 2, 2)));
	} else {
		title.setBorder(new MarginBorder(new Insets(4, 4, 4, 4)));
	}

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

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

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

	top.add(separater, BorderLayout.BOTTOM);
}
 
Example 10
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 11
Source File: FunnyStyleSupport.java    From erflute with Apache License 2.0 5 votes vote down vote up
@Override
public void createColumnArea(IFigure columns) {
    initColumnArea(columns);

    columns.setBorder(new MarginBorder(new Insets(1, 0, 1, 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 12
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 13
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 14
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();
}
 
Example 15
Source File: AbstractBaseDraw2DDetailsPart.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private IFigure createNaPanel ()
{
    final Figure naPanel = new Figure ();

    final BorderLayout layout = new BorderLayout ();
    naPanel.setLayoutManager ( layout );

    final Label label = new Label ();
    label.setText ( Messages.AbstractBaseDraw2DDetailsPart_Label_NotAvail_Text );
    naPanel.add ( label, BorderLayout.CENTER );

    return naPanel;
}
 
Example 16
Source File: GenericLevelPresets.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private IFigure createEntryGrid ( final Figure connLayer )
{
    final Figure figure = new Figure ();
    figure.setLayoutManager ( new GridLayout ( 1, false ) );

    figure.add ( this.presetCeil = new Label ( "" ), new GridData ( GridData.CENTER, GridData.FILL, true, true ) ); //$NON-NLS-1$
    figure.add ( this.presetHH = new Label ( "" ), new GridData ( GridData.CENTER, GridData.FILL, true, true ) ); //$NON-NLS-1$
    figure.add ( this.presetH = new Label ( "" ), new GridData ( GridData.CENTER, GridData.FILL, true, true ) ); //$NON-NLS-1$

    figure.add ( this.currentLabel = new Label ( "" ), new GridData ( GridData.CENTER, GridData.FILL, true, true ) ); //$NON-NLS-1$

    figure.add ( this.presetL = new Label ( "" ), new GridData ( GridData.CENTER, GridData.FILL, true, true ) ); //$NON-NLS-1$
    figure.add ( this.presetLL = new Label ( "" ), new GridData ( GridData.CENTER, GridData.FILL, true, true ) ); //$NON-NLS-1$
    figure.add ( this.presetFloor = new Label ( "" ), new GridData ( GridData.CENTER, GridData.FILL, true, true ) ); //$NON-NLS-1$

    createConnection ( connLayer, this.presetCeil, this.rectCeil );
    createConnection ( connLayer, this.presetHH, this.triHH );
    createConnection ( connLayer, this.presetH, this.triH );
    createConnection ( connLayer, this.presetL, this.triL );
    createConnection ( connLayer, this.presetLL, this.triLL );
    createConnection ( connLayer, this.presetFloor, this.rectFloor );

    this.blinkerCeil = new LevelBlinker ( this.rectCeil );
    this.blinkerHH = new LevelBlinker ( this.triHH );
    this.blinkerH = new LevelBlinker ( this.triH );
    this.blinkerL = new LevelBlinker ( this.triL );
    this.blinkerLL = new LevelBlinker ( this.triLL );
    this.blinkerFloor = new LevelBlinker ( this.rectFloor );

    this.stylerCeil = new StateStyler ( this.blinkerCeil );
    this.stylerHH = new StateStyler ( this.blinkerHH );
    this.stylerH = new StateStyler ( this.blinkerH );
    this.stylerL = new StateStyler ( this.blinkerL );
    this.stylerLL = new StateStyler ( this.blinkerLL );
    this.stylerFloor = new StateStyler ( this.blinkerFloor );

    return figure;
}
 
Example 17
Source File: StateFigureCompartmentEditPart.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected IFigure createFigure() {
	figure = new Figure();
	figure.setLayoutManager(new StateFigureCompartmentLayout(getAlignment()));
	return figure;
}
 
Example 18
Source File: ManualOverride.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IFigure createMain ()
{
    final LayeredPane root = new LayeredPane ();

    final Layer figureLayer = new Layer ();
    figureLayer.setLayoutManager ( new FlowLayout () );

    final ConnectionLayer connectionLayer = new ConnectionLayer ();
    connectionLayer.setAntialias ( SWT.ON );

    final Figure figure = new Figure ();
    figureLayer.add ( figure );

    final GridLayout gridLayout = new GridLayout ( 3, true );
    gridLayout.horizontalSpacing = 50;
    gridLayout.verticalSpacing = 50;
    figure.setLayoutManager ( gridLayout );

    final Figure rpvFigure = createRPV ();
    final Figure pvFigure = createPV ();
    final Figure rmvFigure = createRMV ();
    final Figure mvFigure = createMV ();
    final Figure rvFigure = createRV ();

    figure.add ( rpvFigure, new GridData ( GridData.CENTER, GridData.CENTER, true, true, 1, 1 ) );
    figure.add ( pvFigure, new GridData ( GridData.CENTER, GridData.CENTER, true, true, 1, 2 ) );
    figure.add ( rvFigure, new GridData ( GridData.CENTER, GridData.CENTER, true, true, 1, 3 ) );

    figure.add ( rmvFigure, new GridData ( GridData.CENTER, GridData.CENTER, true, true, 1, 1 ) );

    figure.add ( mvFigure, new GridData ( GridData.CENTER, GridData.CENTER, true, true, 1, 1 ) );
    figure.add ( new Figure (), new GridData ( GridData.CENTER, GridData.CENTER, true, true, 1, 1 ) ); // placeholder

    connectionLayer.add ( this.p2rConnection = createConnection ( this.pvRect, this.rvRect ) );
    connectionLayer.add ( this.m2rConnection = createConnection ( this.mvRect, this.rvRect ) );

    connectionLayer.add ( this.rp2pConnection = createConnection ( this.rpvRect, this.pvRect ) );
    connectionLayer.add ( this.rm2pConnection = createConnection ( this.rmvRect, this.pvRect ) );

    root.add ( figureLayer );
    root.add ( connectionLayer );

    return root;
}
 
Example 19
Source File: AbstractWidgetTest.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @return the test bench figure on which the widget will placed on.
 */
private Figure getTestBench() {
	final Figure result = new TestBench();
	result.setLayoutManager(new StackLayout());
	return result;
}
 
Example 20
Source File: CircularGridEditPart.java    From ice with Eclipse Public License 1.0 4 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() {
		// FIXME - We may be able to use one of these methods to force
		// anti-aliasing. This would avoid having to override the paint
		// behavior of child Figures.
		// @Override
		// protected void paintClientArea(Graphics graphics) {
		// logger.info("paintClientArea");
		// graphics.setAntialias(SWT.ON);
		// super.paintClientArea(graphics);
		// }
		// @Override
		// protected void paintFigure(Graphics graphics) {
		// logger.info("paintFigure");
		// graphics.setAntialias(SWT.ON);
		// super.paintFigure(graphics);
		// }
		// @Override
		// protected void paintChildren(Graphics graphics) {
		// logger.info("paintChildren");
		// graphics.setAntialias(SWT.ON);
		// super.paintChildren(graphics);
		// }
	};
	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);

	// We want the left and right sides of the circular cells to touch.
	layout.setRotated(true);

	// For the circular layout, we don't want the borders of the circular
	// cells to overlap.
	layout.setHorizontalSpacing(5);
	layout.setVerticalSpacing(5);
	// FIXME - The above spacings need to be more easily accessible!

	return rootFigure;
}