org.eclipse.draw2d.Layer Java Examples

The following examples show how to use org.eclipse.draw2d.Layer. 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: 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 #2
Source File: XYContainerController.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public XYContainerController ( final SymbolController controller, final XYContainer element, final BasicViewElementFactory factory ) throws Exception
{
    this.figure = new Layer ();
    this.figure.setOpaque ( false );

    this.figure.setLayoutManager ( new XYLayout () );

    for ( final XYChild child : element.getChildren () )
    {
        final Controller elementController = factory.create ( controller, child.getElement () );
        final IFigure childFigure = elementController.getFigure ();

        final Rectangle rect = factory.create ( child.getPosition (), child.getDimension () );
        controller.addRawElement ( child.getName (), new XYChildController ( childFigure, rect ) );
        this.figure.add ( childFigure, rect );
    }

    controller.addElement ( element, this );
}
 
Example #3
Source File: BorderContainerController.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public BorderContainerController ( final SymbolController controller, final BorderContainer element, final BasicViewElementFactory factory ) throws Exception
{
    this.figure = new Layer ();
    this.figure.setOpaque ( false );

    this.figure.setLayoutManager ( this.layout = new BorderLayout () );

    this.layout.setHorizontalSpacing ( element.getHorizontalSpacing () );
    this.layout.setVerticalSpacing ( element.getVerticalSpacing () );

    for ( final BorderChild child : element.getChildren () )
    {
        final Controller elementController = factory.create ( controller, child.getElement () );
        final IFigure childFigure = elementController.getFigure ();

        controller.addRawElement ( child.getName (), new BorderChildController ( childFigure ) );

        this.figure.add ( childFigure, convert ( child.getAlignment () ) );
    }

    controller.addElement ( element, this );
}
 
Example #4
Source File: StackContainerController.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public StackContainerController ( final SymbolController controller, final StackContainer element, final BasicViewElementFactory factory ) throws Exception
{
    this.figure = new Layer ();
    this.figure.setOpaque ( false );

    this.figure.setLayoutManager ( this.layout = new StackLayout () );

    this.layout.setObserveVisibility ( true );

    for ( final Primitive child : element.getChildren () )
    {
        final Controller elementController = factory.create ( controller, child );
        final IFigure childFigure = elementController.getFigure ();

        controller.addRawElement ( child.getName (), elementController );

        this.figure.add ( childFigure );
    }

    controller.addElement ( element, this );
}
 
Example #5
Source File: BasicViewElementFactory.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public void createConnections ( final Layer layer, final SymbolController controller, final EList<Connection> connections )
{
    if ( connections == null )
    {
        return;
    }

    for ( final Connection connection : connections )
    {
        final Controller start = AdapterHelper.adapt ( controller.getElement ( connection.getStart () ), Controller.class );
        final Controller end = AdapterHelper.adapt ( controller.getElement ( connection.getEnd () ), Controller.class );

        if ( start != null && end != null )
        {
            final PolylineConnection c = new PolylineConnection ();
            c.setSourceAnchor ( new ChopboxAnchor ( start.getFigure () ) );
            c.setTargetAnchor ( new ChopboxAnchor ( end.getFigure () ) );
            c.setAntialias ( SWT.ON );
            layer.add ( c );
        }
    }
}
 
Example #6
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 #7
Source File: SymbolReferenceController.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
public SymbolReferenceController ( final SymbolController controller, final SymbolReference symbolReference, final BasicViewElementFactory factory, final ResourceManager manager, final FactoryContext factoryContext )
{
    if ( symbolReference.getZoom () != null )
    {
        this.figure = new org.eclipse.draw2d.ScalableLayeredPane ();
        ( (org.eclipse.draw2d.ScalableLayeredPane)this.figure ).setScale ( symbolReference.getZoom () );
    }
    else
    {
        this.figure = new LayeredPane ();
    }

    final Layer layer = new Layer ();
    layer.setLayoutManager ( new StackLayout () );

    layer.setOpaque ( false );
    this.figure.setOpaque ( false );

    this.figure.add ( layer );

    try
    {
        final SymbolLoader symbolLoader = factory.getRoot ();

        final Map<String, String> properties = new HashMap<String, String> ( convert ( symbolReference.getProperties () ) );
        createProperties ( controller, symbolReference, properties );

        final SymbolController childController = new SymbolController ( controller.getShell (), controller, symbolLoader, properties, controller.getScriptObjects (), factoryContext );

        final Symbol symbol = symbolLoader.loadSymbol ();
        final Controller elementController = factory.create ( childController, symbol.getRoot () );
        final IFigure rootFigure = elementController.getFigure ();
        layer.add ( rootFigure );

        final RGB color = org.eclipse.scada.vi.ui.draw2d.primitives.Helper.makeColor ( symbol.getBackgroundColor () );
        if ( color != null )
        {
            layer.setBackgroundColor ( manager.createColor ( color ) );
        }

        // register the symbol element controller
        controller.addElement ( symbolReference, elementController );
    }
    catch ( final Exception e )
    {
        logger.warn ( "Failed to create symbol", e ); //$NON-NLS-1$
        StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ), StatusManager.LOG );
        layer.add ( Helper.createErrorFigure ( e ) );
    }
}