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

The following examples show how to use org.eclipse.draw2d.Figure#add() . 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: RoundDetailsPart.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
private void createRoundArrow ( final Figure figure )
{
    final PolylineConnection c = new PolylineConnection ();
    c.setSourceAnchor ( new ChopboxAnchor ( this.sourceRect ) );
    c.setTargetAnchor ( new ChopboxAnchor ( this.targetRect ) );

    final PolygonDecoration dec = new PolygonDecoration ();
    dec.setTemplate ( PolygonDecoration.TRIANGLE_TIP );
    c.setTargetDecoration ( dec );

    final MidpointLocator typeLocator = new MidpointLocator ( c, 0 );
    typeLocator.setRelativePosition ( PositionConstants.NORTH );
    this.typeLabel = new Label ( "" ); //$NON-NLS-1$
    c.add ( this.typeLabel, typeLocator );

    figure.add ( c );
    this.roundConnection = c;
}
 
Example 2
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 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: 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 5
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 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 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 8
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 9
Source File: GenericLevelPresets.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected IFigure createMain ()
{
    final Figure baseFigure = new LayeredPane ();

    final Layer rootFigure = new Layer ();

    this.connLayer = new ConnectionLayer ();
    this.connLayer.setAntialias ( 1 );
    this.connLayer.setConnectionRouter ( ConnectionRouter.NULL );

    baseFigure.add ( this.connLayer );
    baseFigure.add ( rootFigure );

    rootFigure.setLayoutManager ( new BorderLayout () );
    rootFigure.setBackgroundColor ( ColorConstants.white );

    rootFigure.add ( createArrowFigure (), BorderLayout.RIGHT );
    rootFigure.add ( createEntryGrid ( this.connLayer ), BorderLayout.CENTER );

    return baseFigure;
}
 
Example 10
Source File: RoundDetailsPart.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected IFigure createMain ()
{
    final Figure rootFigure = new Figure ();

    rootFigure.setLayoutManager ( new GridLayout ( 3, true ) );

    rootFigure.add ( makeHeader (), new GridData ( GridData.BEGINNING, GridData.CENTER, true, false, 3, 1 ) );

    rootFigure.add ( createSourceValue (), new GridData ( GridData.CENTER, GridData.CENTER, true, true ) );
    rootFigure.add ( new Figure () );
    rootFigure.add ( createTargetValue (), new GridData ( GridData.CENTER, GridData.CENTER, true, true ) );

    rootFigure.add ( new Figure () );
    rootFigure.add ( createCommandPanel (), new GridData ( GridData.CENTER, GridData.CENTER, true, true ) );

    createRoundArrow ( rootFigure );

    return rootFigure;
}
 
Example 11
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 12
Source File: ManualOverride.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private Figure createRV ()
{
    final Figure rvFigure = new Figure ();
    rvFigure.setLayoutManager ( new BorderLayout () );
    final Label label = new Label ( Messages.ManualOverride_ResetValue_Label );
    label.setBorder ( new MarginBorder ( 10 ) );
    rvFigure.add ( label, BorderLayout.RIGHT );

    this.rvRect = new RoundedRectangle ();
    this.rvRect.setLayoutManager ( new BorderLayout () );
    this.rvValue = new Label ();
    this.rvRect.setBackgroundColor ( ColorConstants.lightGray );
    this.rvValue.setBorder ( new MarginBorder ( 10 ) );
    this.rvRect.add ( this.rvValue, BorderLayout.CENTER );

    this.rvRectBlinker = new StyleBlinker () {

        @Override
        public void update ( final CurrentStyle style )
        {
            ManualOverride.this.rvRect.setBackgroundColor ( style.background );
            ManualOverride.this.rvRect.setForegroundColor ( style.foreground );
            ManualOverride.this.rvRect.setFont ( style.font );
        }
    };
    this.rvRectStyler = new StateStyler ( this.rvRectBlinker );

    rvFigure.add ( this.rvRect, BorderLayout.CENTER );
    return rvFigure;
}
 
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: AbstractBaseDraw2DDetailsPart.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
protected IFigure createRoot ()
{
    this.rootFigure = createMain ();
    this.naFigure = createNaPanel ();

    final Figure baseFigure = new LayeredPane ();

    baseFigure.add ( this.rootFigure );
    baseFigure.add ( this.naFigure );

    return baseFigure;
}
 
Example 15
Source File: GenericLevelPresets.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private Triangle createTri ( final Figure figure, final String tag, final Object constraint, final int direction )
{
    final Triangle tri;
    tri = new Triangle ();
    tri.setDirection ( direction );
    tri.setBackgroundColor ( ColorConstants.black );
    tri.setSize ( TRI_DIMENSION );
    tri.setLineWidth ( 3 );
    tri.setCursor ( Display.getDefault ().getSystemCursor ( SWT.CURSOR_HAND ) );

    figure.add ( tri, constraint );

    activate ( tag, tri );
    return tri;
}
 
Example 16
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 17
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 18
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 19
Source File: GenericLevelPresets.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private void createConnection ( final Figure connLayer, final Label label, final Figure figure )
{
    final Connection c = new PolylineConnection ();
    c.setSourceAnchor ( new ChopboxAnchor ( label ) );
    c.setTargetAnchor ( new ChopboxAnchor ( figure ) );
    c.setConnectionRouter ( new BendpointConnectionRouter () );
    connLayer.add ( c );
}
 
Example 20
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;
}