org.netbeans.api.visual.widget.LayerWidget Java Examples

The following examples show how to use org.netbeans.api.visual.widget.LayerWidget. 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: ControlFlowScene.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public ControlFlowScene() {
    selection = new HashSet<BlockWidget>();

    this.getInputBindings().setZoomActionModifiers(0);
    this.setLayout(LayoutFactory.createAbsoluteLayout());

    mainLayer = new LayerWidget(this);
    this.addChild(mainLayer);

    edgeLayer = new LayerWidget(this);
    this.addChild(edgeLayer);

    selectLayer = new LayerWidget(this);
    this.addChild(selectLayer);

    this.getActions().addAction(hoverAction);
    this.getActions().addAction(selectAction);
    this.getActions().addAction(ActionFactory.createRectangularSelectAction(this, selectLayer, this));
    this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1));
}
 
Example #2
Source File: ControlFlowScene.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public ControlFlowScene() {
    selection = new HashSet<BlockWidget>();

    this.getInputBindings().setZoomActionModifiers(0);
    this.setLayout(LayoutFactory.createAbsoluteLayout());

    mainLayer = new LayerWidget(this);
    this.addChild(mainLayer);

    edgeLayer = new LayerWidget(this);
    this.addChild(edgeLayer);

    selectLayer = new LayerWidget(this);
    this.addChild(selectLayer);

    this.getActions().addAction(hoverAction);
    this.getActions().addAction(selectAction);
    this.getActions().addAction(ActionFactory.createRectangularSelectAction(this, selectLayer, this));
    this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1));
}
 
Example #3
Source File: ControlFlowScene.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public ControlFlowScene() {
    selection = new HashSet<BlockWidget>();

    this.getInputBindings().setZoomActionModifiers(0);
    this.setLayout(LayoutFactory.createAbsoluteLayout());

    mainLayer = new LayerWidget(this);
    this.addChild(mainLayer);

    edgeLayer = new LayerWidget(this);
    this.addChild(edgeLayer);

    selectLayer = new LayerWidget(this);
    this.addChild(selectLayer);

    this.getActions().addAction(hoverAction);
    this.getActions().addAction(selectAction);
    this.getActions().addAction(ActionFactory.createRectangularSelectAction(this, selectLayer, this));
    this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1));
}
 
Example #4
Source File: LayerWidget103528Test.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testLayerPreferredLocation () {
    Scene scene = new Scene ();

    scene.addChild (new LayerWidget (scene));

    LayerWidget layer = new LayerWidget (scene);
    layer.setPreferredLocation (new Point (100, 100));
    scene.addChild (layer);

    Widget widget = new Widget (scene);
    widget.setPreferredBounds (new Rectangle (-20, -10, 100, 50));
    widget.setOpaque (true);
    widget.setBackground (Color.RED);
    layer.addChild (widget);

    Color color = (Color) (new DefaultLookFeel()).getBackground();
    assertScene (scene, color, new Rectangle (80, 90, 100, 50));
}
 
Example #5
Source File: ControlFlowScene.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public ControlFlowScene() {
    selection = new HashSet<BlockWidget>();

    this.getInputBindings().setZoomActionModifiers(0);
    this.setLayout(LayoutFactory.createAbsoluteLayout());

    mainLayer = new LayerWidget(this);
    this.addChild(mainLayer);

    edgeLayer = new LayerWidget(this);
    this.addChild(edgeLayer);

    selectLayer = new LayerWidget(this);
    this.addChild(selectLayer);

    this.getActions().addAction(hoverAction);
    this.getActions().addAction(selectAction);
    this.getActions().addAction(ActionFactory.createRectangularSelectAction(this, selectLayer, this));
    this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1));
}
 
Example #6
Source File: OffscreenRenderingTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testOffscreenRendering () {
    Scene scene = new Scene ();

    LayerWidget layer = new LayerWidget (scene);
    layer.setPreferredBounds (new Rectangle (0, 0, 80, 80));
    scene.addChild (layer);

    LabelWidget widget = new LabelWidget (scene, "Hi");
    widget.setVerticalAlignment (LabelWidget.VerticalAlignment.CENTER);
    widget.setAlignment (LabelWidget.Alignment.CENTER);
    widget.setBorder (BorderFactory.createLineBorder ());
    widget.setPreferredLocation (new Point (20, 20));
    widget.setPreferredBounds (new Rectangle (0, 0, 40, 40));
    layer.addChild (widget);

    BufferedImage image = dumpSceneOffscreenRendering (scene);
    Color backgroundColor = (Color) (new DefaultLookFeel()).getBackground();
    Color foregroundColor = (new DefaultLookFeel()).getForeground();
    assertCleaness (testCleaness (image, backgroundColor, foregroundColor), image, null);

    assertScene (scene, backgroundColor, new Rectangle (19, 19, 42, 42));
}
 
Example #7
Source File: ControlFlowScene.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public ControlFlowScene() {
    selection = new HashSet<BlockWidget>();

    this.getInputBindings().setZoomActionModifiers(0);
    this.setLayout(LayoutFactory.createAbsoluteLayout());

    mainLayer = new LayerWidget(this);
    this.addChild(mainLayer);

    edgeLayer = new LayerWidget(this);
    this.addChild(edgeLayer);

    selectLayer = new LayerWidget(this);
    this.addChild(selectLayer);

    this.getActions().addAction(hoverAction);
    this.getActions().addAction(selectAction);
    this.getActions().addAction(ActionFactory.createRectangularSelectAction(this, selectLayer, this));
    this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1));
}
 
Example #8
Source File: ControlFlowScene.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public ControlFlowScene() {
    selection = new HashSet<BlockWidget>();

    this.getInputBindings().setZoomActionModifiers(0);
    this.setLayout(LayoutFactory.createAbsoluteLayout());

    mainLayer = new LayerWidget(this);
    this.addChild(mainLayer);

    edgeLayer = new LayerWidget(this);
    this.addChild(edgeLayer);

    selectLayer = new LayerWidget(this);
    this.addChild(selectLayer);

    this.getActions().addAction(hoverAction);
    this.getActions().addAction(selectAction);
    this.getActions().addAction(ActionFactory.createRectangularSelectAction(this, selectLayer, this));
    this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1));
}
 
Example #9
Source File: ControlFlowScene.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public ControlFlowScene() {
    selection = new HashSet<BlockWidget>();

    this.getInputBindings().setZoomActionModifiers(0);
    this.setLayout(LayoutFactory.createAbsoluteLayout());

    mainLayer = new LayerWidget(this);
    this.addChild(mainLayer);

    edgeLayer = new LayerWidget(this);
    this.addChild(edgeLayer);

    selectLayer = new LayerWidget(this);
    this.addChild(selectLayer);

    this.getActions().addAction(hoverAction);
    this.getActions().addAction(selectAction);
    this.getActions().addAction(ActionFactory.createRectangularSelectAction(this, selectLayer, this));
    this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1));
}
 
Example #10
Source File: ControlFlowScene.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public ControlFlowScene() {
    selection = new HashSet<BlockWidget>();

    this.getInputBindings().setZoomActionModifiers(0);
    this.setLayout(LayoutFactory.createAbsoluteLayout());

    mainLayer = new LayerWidget(this);
    this.addChild(mainLayer);

    edgeLayer = new LayerWidget(this);
    this.addChild(edgeLayer);

    selectLayer = new LayerWidget(this);
    this.addChild(selectLayer);

    this.getActions().addAction(hoverAction);
    this.getActions().addAction(selectAction);
    this.getActions().addAction(ActionFactory.createRectangularSelectAction(this, selectLayer, this));
    this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1));
}
 
Example #11
Source File: ScenePrinter.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static List<Widget> getAllNodeWidgets(Widget widget, List<Widget> widgetList) {
    if (widgetList == null) {
        widgetList = new ArrayList<Widget>();
    }

    if (widget instanceof LayerWidget && widget.getChildren().size() > 0) //widget has children
    {
        widgetList.addAll(widget.getChildren());

        for (Widget child : widget.getChildren()) {
            getAllNodeWidgets(child, widgetList);
        }
    }

    return widgetList;
}
 
Example #12
Source File: QBGraphScene.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public QBGraphScene(QueryBuilderGraphFrame qbGF) {
    qbGF._firstTableInserted = false;
    mainLayer = new LayerWidget(this);
    connectionLayer = new LayerWidget(this);
    addChild(mainLayer);
    addChild(connectionLayer);
    
    router = RouterFactory.createOrthogonalSearchRouter(mainLayer, connectionLayer);
    getActions().addAction(mouseHoverAction);
    // getActions().addAction(ActionFactory.createZoomAction());
    // ToDo: qbGF has been passed in only to support the menu; eventually, merge QBGF into this
    getActions().addAction(ActionFactory.createPopupMenuAction(qbGF));
}
 
Example #13
Source File: LabelOrientationTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static LabelWidget createLabel (LayerWidget layer, String label, int x, int y, LabelWidget.Orientation orientation, LabelWidget.Alignment alignment, LabelWidget.VerticalAlignment verticalAlignment) {
    LabelWidget widget = new LabelWidget (layer.getScene (), label);
    widget.setOpaque (true);
    widget.setBackground (Color.YELLOW);
    widget.setPreferredLocation (new Point (x, y));
    widget.setPreferredBounds (new Rectangle (-20, -30, 180, 180));
    widget.setOrientation (orientation);
    widget.setAlignment (alignment);
    widget.setVerticalAlignment (verticalAlignment);
    layer.addChild (widget);
    return widget;
}
 
Example #14
Source File: LabelOrientationTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testLabelOrientations () {
    Scene scene = new Scene ();
    LayerWidget layer = new LayerWidget (scene);
    scene.addChild(layer);
    layer.addChild (new Widget (scene));

    createLabel (layer, "N O R M A L", 100, 100, LabelWidget.Orientation.NORMAL, LabelWidget.Alignment.LEFT, LabelWidget.VerticalAlignment.BASELINE).setPreferredBounds (null);
    createLabel (layer, "R O T A T E 9 0", 100, 100, LabelWidget.Orientation.ROTATE_90, LabelWidget.Alignment.LEFT, LabelWidget.VerticalAlignment.BASELINE).setPreferredBounds (null);

    createLabel (layer, "NORMAL BASELINE", 200, 100, LabelWidget.Orientation.NORMAL, LabelWidget.Alignment.BASELINE, LabelWidget.VerticalAlignment.BASELINE);
    createLabel (layer, "ROTATE90 BASELINE", 200, 300, LabelWidget.Orientation.ROTATE_90, LabelWidget.Alignment.BASELINE, LabelWidget.VerticalAlignment.BASELINE);

    createLabel (layer, "NORMAL LEFT,TOP", 400, 100, LabelWidget.Orientation.NORMAL, LabelWidget.Alignment.LEFT, LabelWidget.VerticalAlignment.TOP);
    createLabel (layer, "ROTATE90 LEFT,TOP", 400, 300, LabelWidget.Orientation.ROTATE_90, LabelWidget.Alignment.LEFT, LabelWidget.VerticalAlignment.TOP);

    createLabel (layer, "NORMAL CENTER", 600, 100, LabelWidget.Orientation.NORMAL, LabelWidget.Alignment.CENTER, LabelWidget.VerticalAlignment.CENTER);
    createLabel (layer, "ROTATE90 CENTER", 600, 300, LabelWidget.Orientation.ROTATE_90, LabelWidget.Alignment.CENTER, LabelWidget.VerticalAlignment.CENTER);

    createLabel (layer, "NORMAL RIGHT,BOTTOM", 800, 100, LabelWidget.Orientation.NORMAL, LabelWidget.Alignment.RIGHT, LabelWidget.VerticalAlignment.BOTTOM);
    createLabel (layer, "ROTATE90 RIGHT,BOTTOM", 800, 300, LabelWidget.Orientation.ROTATE_90, LabelWidget.Alignment.RIGHT, LabelWidget.VerticalAlignment.BOTTOM);

    BufferedImage snapshot = takeOneTimeSnapshot (scene);
    BufferedImage clean = clearRegions (snapshot, Color.RED,
            new Rectangle (100, 80, 100, 30),
            new Rectangle (80, 0, 30, 110),

            new Rectangle (190, 90, 130, 30),
            new Rectangle (380, 70, 110, 30),
            new Rectangle (610, 150, 120, 30),
            new Rectangle (810, 230, 150, 30),

            new Rectangle (180, 270, 30, 130),
            new Rectangle (380, 270, 30, 160),
            new Rectangle (650, 290, 30, 150),
            new Rectangle (945, 275, 30, 190)

    );
    Color color = (Color) (new DefaultLookFeel()).getBackground();
    assertCleaness (testCleaness (clean, color, Color.YELLOW, Color.RED), snapshot, clean);
}
 
Example #15
Source File: BasicTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testShow () {
    Scene scene = new Scene ();
    
    LayerWidget mainLayer = new LayerWidget (scene);
    scene.addChild(mainLayer);
    
    Widget w1 = new Widget (scene);
    w1.setBorder (BorderFactory.createLineBorder ());
    w1.setPreferredLocation (new Point (100, 100));
    w1.setPreferredSize (new Dimension (40, 20));
    mainLayer.addChild(w1);
    
    Widget w2 = new Widget (scene);
    w2.setBorder (BorderFactory.createLineBorder ());
    w2.setPreferredLocation (new Point (200, 100));
    w2.setPreferredSize (new Dimension (40, 20));
    mainLayer.addChild(w2);
    
    LayerWidget connLayer = new LayerWidget (scene);
    scene.addChild(connLayer);
    
    ConnectionWidget conn = new ConnectionWidget(scene);
    conn.setSourceAnchor(AnchorFactory.createRectangularAnchor(w1));
    conn.setTargetAnchor(AnchorFactory.createRectangularAnchor(w2));
    connLayer.addChild(conn);
    
    Color color = (Color) (new DefaultLookFeel()).getBackground();
    assertScene (scene, color,
            new Rectangle (99, 99, 42, 22),
            new Rectangle (199, 99, 42, 22),
            new Rectangle (138, 108, 64, 4)
    );
}
 
Example #16
Source File: FlowLayoutWeightOverflow108052Test.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testFlowLayoutWeightOverflow () {
    Scene scene = new Scene ();
    LayerWidget layer = new LayerWidget (scene);
    layer.setMinimumSize (new Dimension (300, 200));
    scene.addChild (layer);

    Widget vbox = new Widget (scene);
    vbox.setBorder (BorderFactory.createLineBorder (1, Color.BLACK));
    vbox.setLayout (LayoutFactory.createVerticalFlowLayout (LayoutFactory.SerialAlignment.JUSTIFY, 0));
    layer.addChild (vbox);

    Widget hbox1 = new Widget (scene);
    hbox1.setBorder (BorderFactory.createLineBorder (1, Color.BLUE));
    hbox1.setLayout (LayoutFactory.createHorizontalFlowLayout ());
    vbox.addChild (hbox1);

    Widget item1 = new LabelWidget (scene, "Item1");
    item1.setBorder (BorderFactory.createLineBorder (1, Color.GREEN));
    hbox1.addChild (item1);

    Widget item2 = new LabelWidget (scene, "Item2");
    item2.setBorder (BorderFactory.createLineBorder (1, Color.YELLOW));
    hbox1.addChild (item2, 1000);

    Widget item3 = new LabelWidget (scene, "Item3");
    item3.setBorder (BorderFactory.createLineBorder (1, Color.RED));
    hbox1.addChild (item3);

    Widget hbox2 = new Widget (scene);
    hbox2.setBorder (BorderFactory.createLineBorder (1, Color.BLUE));
    hbox2.setPreferredSize (new Dimension (200, 20));
    vbox.addChild (hbox2);
    
    Color color = (Color) (new DefaultLookFeel()).getBackground();
    assertScene (scene, color, new Rectangle (-5, -5, 210, 100));
}
 
Example #17
Source File: NodeContextModel.java    From jeddict with Apache License 2.0 5 votes vote down vote up
private static WidgetAction[] getConnectActions(
        IModelerScene scene, 
        String connectionContextToolId,
        Function<EdgeWidgetInfo, IEdgeWidget> edgeWidgetFunction) {
    SceneConnectProvider connector = new SceneConnectProvider(connectionContextToolId, edgeWidgetFunction);
    LayerWidget layer = scene.getInterractionLayer();
    WidgetAction action = new ConnectAction(new ContextPaletteConnectDecorator(), layer, connector);
    WidgetAction[] retVal = new WidgetAction[]{action};
    return retVal;
}
 
Example #18
Source File: ModelGraphScene.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
public ModelGraphScene() {
    mainLayer = new LayerWidget (this);
    addChild(mainLayer);

    connectionLayer = new LayerWidget (this);
    addChild(connectionLayer);
}
 
Example #19
Source File: StringGraphScene.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
public StringGraphScene () {
    mainLayer = new LayerWidget (this);
    connectionLayer = new LayerWidget (this);
    addChild (mainLayer);
    addChild (connectionLayer);

    getActions ().addAction (mouseHoverAction);
}
 
Example #20
Source File: StringGraphScene.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
public LayerWidget getConnectionLayer () {
    return connectionLayer;
}
 
Example #21
Source File: DesignView.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new instance of GraphView.
 * @param service
 * @param implementationClass
 */
public DesignView(ProjectService service, FileObject implementationClass) {
    super(new BorderLayout());
    
    this.service = service;
    this.implementationClass = implementationClass;
    
    scene = new ObjectScene() {
        @Override
        /**
         * Use our own traversal policy
         */
        public Comparable<DesignerWidgetIdentityCode> getIdentityCode(Object object) {
            return new DesignerWidgetIdentityCode(scene,object);
        }
    };
    zoomer = new ZoomManager(scene);

    scene.getActions().addAction(ActionFactory.createCycleObjectSceneFocusAction());
    scene.setKeyEventProcessingType (EventProcessingType.FOCUSED_WIDGET_AND_ITS_PARENTS);

    mainLayer = new LayerWidget(scene);
    mainLayer.setPreferredLocation(new Point(0, 0));
    mainLayer.setLayout(LayoutFactory.createVerticalFlowLayout(
            LayoutFactory.SerialAlignment.JUSTIFY, 12));
    scene.addChild(mainLayer);
    
    mainWidget = new Widget(scene);
    mainWidget.setLayout(LayoutFactory.createVerticalFlowLayout(
            LayoutFactory.SerialAlignment.JUSTIFY, 12));
    
    headerWidget = new LabelWidget(scene);
    headerWidget.setFont(scene.getFont().deriveFont(Font.BOLD));
    headerWidget.setForeground(Color.GRAY);
    headerWidget.setBorder(BorderFactory.createEmptyBorder(6,28,0,0));
    mainWidget.addChild(headerWidget);
    
    separatorWidget = new SeparatorWidget(scene,
            SeparatorWidget.Orientation.HORIZONTAL);
    separatorWidget.setForeground(Color.ORANGE);
    mainWidget.addChild(separatorWidget);
    
    contentWidget = new Widget(scene);
    contentWidget.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20));
    contentWidget.setLayout(LayoutFactory.createVerticalFlowLayout(
            LayoutFactory.SerialAlignment.JUSTIFY, 16));
    mainWidget.addChild(contentWidget);
    
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER){
        /* (non-Javadoc)
         * @see java.awt.FlowLayout#layoutContainer(java.awt.Container)
         */
        @Override
        public void layoutContainer( Container target ) {
            super.layoutContainer(target);
            Component[] components = target.getComponents();
            double height = target.getSize().getHeight()/2;
            for (Component component : components) {
                Point location = component.getLocation();
                component.setLocation( (int)location.getX(), (int)height );
            }
        }
    });
    panel.add(new JLabel(NbBundle.getMessage( DesignView.class, "LBL_Wait")));
    add( panel,BorderLayout.CENTER);
    
    mainLayer.addChild(mainWidget);

    messageWidget = new Widget(scene);
    messageWidget.setLayout(LayoutFactory.createVerticalFlowLayout(
            LayoutFactory.SerialAlignment.JUSTIFY, 4));
    mainLayer.addChild(messageWidget);
    scene.addObject(messageLayerKey, messageWidget);
    
    initServiceModel();
}
 
Example #22
Source File: PageFlowScene.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public LayerWidget getConnectionLayer() {
    return connectionLayer;
}
 
Example #23
Source File: GraphLayoutListenerRemoval197502Test.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public LayerWidget getConnectionLayer() {
    return connectionLayer;
}
 
Example #24
Source File: QBGraphScene.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public LayerWidget getMainLayer() {
    return mainLayer;
}
 
Example #25
Source File: QBGraphScene.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public LayerWidget getConnectionLayer() {
    return connectionLayer;
}
 
Example #26
Source File: DiagramScene.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public DiagramScene(Action[] actions, DiagramViewModel model) {
    this.actions = actions;
    selectedWidgets = new ArrayList<FigureWidget>();
    content = new InstanceContent();
    lookup = new AbstractLookup(content);
    this.setCheckClipping(true);
    this.getInputBindings().setZoomActionModifiers(0);

    JComponent comp = this.createView();
    comp.setDoubleBuffered(true);
    comp.setBackground(Color.WHITE);
    comp.setOpaque(true);

    this.setBackground(Color.WHITE);
    this.setOpaque(true);
    scrollPane = new JScrollPane(comp);
    scrollPane.setBackground(Color.WHITE);
    scrollPane.getVerticalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT);
    scrollPane.getVerticalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT);
    scrollPane.getHorizontalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT);
    scrollPane.getHorizontalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT);
    scrollPane.getViewport().addChangeListener(scrollChangeListener);
    hoverAction = this.createWidgetHoverAction();

    blockLayer = new LayerWidget(this);
    this.addChild(blockLayer);

    startLayer = new LayerWidget(this);
    this.addChild(startLayer);
    // TODO: String startLabelString = "Loading graph with " + originalDiagram.getFigures().size() + " figures and " + originalDiagram.getConnections().size() + " connections...";
    String startLabelString = "";
    LabelWidget w = new LabelWidget(this, startLabelString);
    scrollChangeListener.register(w, new Point(10, 10));
    w.setAlignment(LabelWidget.Alignment.CENTER);
    startLabel = w;
    startLayer.addChild(w);

    mainLayer = new LayerWidget(this);
    this.addChild(mainLayer);

    topLeft = new Widget(this);
    topLeft.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE));
    this.addChild(topLeft);


    bottomRight = new Widget(this);
    bottomRight.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE));
    this.addChild(bottomRight);

    slotLayer = new LayerWidget(this);
    this.addChild(slotLayer);

    connectionLayer = new LayerWidget(this);
    this.addChild(connectionLayer);

    LayerWidget selectionLayer = new LayerWidget(this);
    this.addChild(selectionLayer);

    this.setLayout(LayoutFactory.createAbsoluteLayout());

    this.getActions().addAction(hoverAction);
    zoomAction = new BoundedZoomAction(1.1, false);
    zoomAction.setMaxFactor(ZOOM_MAX_FACTOR);
    zoomAction.setMinFactor(ZOOM_MIN_FACTOR);
    this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1));
    panAction = new ExtendedPanAction();
    this.getActions().addAction(panAction);
    this.getActions().addAction(ActionFactory.createPopupMenuAction(popupMenuProvider));

    LayerWidget selectLayer = new LayerWidget(this);
    this.addChild(selectLayer);
    this.getActions().addAction(ActionFactory.createRectangularSelectAction(rectangularSelectDecorator, selectLayer, rectangularSelectProvider));

    blockWidgets = new HashMap<InputBlock, BlockWidget>();

    boolean b = this.getUndoRedoEnabled();
    this.setUndoRedoEnabled(false);
    this.setNewModel(model);
    this.setUndoRedoEnabled(b);
}
 
Example #27
Source File: DiagramScene.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public DiagramScene(Action[] actions, Action[] actionsWithSelection, DiagramViewModel model) {

        this.actions = actions;
        this.actionsWithSelection = actionsWithSelection;

        content = new InstanceContent();
        lookup = new AbstractLookup(content);

        this.setCheckClipping(true);

        scrollPane = createScrollPane();

        hoverAction = createObjectHoverAction();

        // This panAction handles the event only when the left mouse button is
        // pressed without any modifier keys, otherwise it will not consume it
        // and the selection action (below) will handle the event
        panAction = new CustomizablePanAction(~0, MouseEvent.BUTTON1_DOWN_MASK);
        this.getActions().addAction(panAction);

        selectAction = createSelectAction();
        this.getActions().addAction(selectAction);

        blockLayer = new LayerWidget(this);
        this.addChild(blockLayer);

        connectionLayer = new LayerWidget(this);
        this.addChild(connectionLayer);

        mainLayer = new LayerWidget(this);
        this.addChild(mainLayer);

        topLeft = new Widget(this);
        topLeft.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE));
        this.addChild(topLeft);

        bottomRight = new Widget(this);
        bottomRight.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE));
        this.addChild(bottomRight);

        LayerWidget selectionLayer = new LayerWidget(this);
        this.addChild(selectionLayer);

        this.setLayout(LayoutFactory.createAbsoluteLayout());

        this.getInputBindings().setZoomActionModifiers(KeyEvent.CTRL_MASK);
        zoomAction = ActionFactory.createMouseCenteredZoomAction(1.2);
        this.getActions().addAction(zoomAction);
        this.getView().addMouseWheelListener(mouseWheelListener);
        this.getActions().addAction(ActionFactory.createPopupMenuAction(popupMenuProvider));

        this.getActions().addAction(ActionFactory.createWheelPanAction());

        LayerWidget selectLayer = new LayerWidget(this);
        this.addChild(selectLayer);
        this.getActions().addAction(ActionFactory.createRectangularSelectAction(rectangularSelectDecorator, selectLayer, rectangularSelectProvider));

        boolean b = this.getUndoRedoEnabled();
        this.setUndoRedoEnabled(false);
        this.setNewModel(model);
        this.setUndoRedoEnabled(b);
        this.addObjectSceneListener(selectionChangedListener, ObjectSceneEventType.OBJECT_SELECTION_CHANGED, ObjectSceneEventType.OBJECT_HIGHLIGHTING_CHANGED, ObjectSceneEventType.OBJECT_HOVER_CHANGED);
    }
 
Example #28
Source File: DiagramScene.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public DiagramScene(Action[] actions, DiagramViewModel model) {
    this.actions = actions;
    selectedWidgets = new ArrayList<FigureWidget>();
    content = new InstanceContent();
    lookup = new AbstractLookup(content);
    this.setCheckClipping(true);
    this.getInputBindings().setZoomActionModifiers(0);

    JComponent comp = this.createView();
    comp.setDoubleBuffered(true);
    comp.setBackground(Color.WHITE);
    comp.setOpaque(true);

    this.setBackground(Color.WHITE);
    this.setOpaque(true);
    scrollPane = new JScrollPane(comp);
    scrollPane.setBackground(Color.WHITE);
    scrollPane.getVerticalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT);
    scrollPane.getVerticalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT);
    scrollPane.getHorizontalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT);
    scrollPane.getHorizontalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT);
    scrollPane.getViewport().addChangeListener(scrollChangeListener);
    hoverAction = this.createWidgetHoverAction();

    blockLayer = new LayerWidget(this);
    this.addChild(blockLayer);

    startLayer = new LayerWidget(this);
    this.addChild(startLayer);
    // TODO: String startLabelString = "Loading graph with " + originalDiagram.getFigures().size() + " figures and " + originalDiagram.getConnections().size() + " connections...";
    String startLabelString = "";
    LabelWidget w = new LabelWidget(this, startLabelString);
    scrollChangeListener.register(w, new Point(10, 10));
    w.setAlignment(LabelWidget.Alignment.CENTER);
    startLabel = w;
    startLayer.addChild(w);

    mainLayer = new LayerWidget(this);
    this.addChild(mainLayer);

    topLeft = new Widget(this);
    topLeft.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE));
    this.addChild(topLeft);


    bottomRight = new Widget(this);
    bottomRight.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE));
    this.addChild(bottomRight);

    slotLayer = new LayerWidget(this);
    this.addChild(slotLayer);

    connectionLayer = new LayerWidget(this);
    this.addChild(connectionLayer);

    LayerWidget selectionLayer = new LayerWidget(this);
    this.addChild(selectionLayer);

    this.setLayout(LayoutFactory.createAbsoluteLayout());

    this.getActions().addAction(hoverAction);
    zoomAction = new BoundedZoomAction(1.1, false);
    zoomAction.setMaxFactor(ZOOM_MAX_FACTOR);
    zoomAction.setMinFactor(ZOOM_MIN_FACTOR);
    this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1));
    panAction = new ExtendedPanAction();
    this.getActions().addAction(panAction);
    this.getActions().addAction(ActionFactory.createPopupMenuAction(popupMenuProvider));

    LayerWidget selectLayer = new LayerWidget(this);
    this.addChild(selectLayer);
    this.getActions().addAction(ActionFactory.createRectangularSelectAction(rectangularSelectDecorator, selectLayer, rectangularSelectProvider));

    blockWidgets = new HashMap<InputBlock, BlockWidget>();

    boolean b = this.getUndoRedoEnabled();
    this.setUndoRedoEnabled(false);
    this.setNewModel(model);
    this.setUndoRedoEnabled(b);
}
 
Example #29
Source File: DiagramScene.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public DiagramScene(Action[] actions, DiagramViewModel model) {
    this.actions = actions;
    selectedWidgets = new ArrayList<FigureWidget>();
    content = new InstanceContent();
    lookup = new AbstractLookup(content);
    this.setCheckClipping(true);
    this.getInputBindings().setZoomActionModifiers(0);

    JComponent comp = this.createView();
    comp.setDoubleBuffered(true);
    comp.setBackground(Color.WHITE);
    comp.setOpaque(true);

    this.setBackground(Color.WHITE);
    this.setOpaque(true);
    scrollPane = new JScrollPane(comp);
    scrollPane.setBackground(Color.WHITE);
    scrollPane.getVerticalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT);
    scrollPane.getVerticalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT);
    scrollPane.getHorizontalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT);
    scrollPane.getHorizontalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT);
    scrollPane.getViewport().addChangeListener(scrollChangeListener);
    hoverAction = this.createWidgetHoverAction();

    blockLayer = new LayerWidget(this);
    this.addChild(blockLayer);

    startLayer = new LayerWidget(this);
    this.addChild(startLayer);
    // TODO: String startLabelString = "Loading graph with " + originalDiagram.getFigures().size() + " figures and " + originalDiagram.getConnections().size() + " connections...";
    String startLabelString = "";
    LabelWidget w = new LabelWidget(this, startLabelString);
    scrollChangeListener.register(w, new Point(10, 10));
    w.setAlignment(LabelWidget.Alignment.CENTER);
    startLabel = w;
    startLayer.addChild(w);

    mainLayer = new LayerWidget(this);
    this.addChild(mainLayer);

    topLeft = new Widget(this);
    topLeft.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE));
    this.addChild(topLeft);


    bottomRight = new Widget(this);
    bottomRight.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE));
    this.addChild(bottomRight);

    slotLayer = new LayerWidget(this);
    this.addChild(slotLayer);

    connectionLayer = new LayerWidget(this);
    this.addChild(connectionLayer);

    LayerWidget selectionLayer = new LayerWidget(this);
    this.addChild(selectionLayer);

    this.setLayout(LayoutFactory.createAbsoluteLayout());

    this.getActions().addAction(hoverAction);
    zoomAction = new BoundedZoomAction(1.1, false);
    zoomAction.setMaxFactor(ZOOM_MAX_FACTOR);
    zoomAction.setMinFactor(ZOOM_MIN_FACTOR);
    this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1));
    panAction = new ExtendedPanAction();
    this.getActions().addAction(panAction);
    this.getActions().addAction(ActionFactory.createPopupMenuAction(popupMenuProvider));

    LayerWidget selectLayer = new LayerWidget(this);
    this.addChild(selectLayer);
    this.getActions().addAction(ActionFactory.createRectangularSelectAction(rectangularSelectDecorator, selectLayer, rectangularSelectProvider));

    blockWidgets = new HashMap<InputBlock, BlockWidget>();

    boolean b = this.getUndoRedoEnabled();
    this.setUndoRedoEnabled(false);
    this.setNewModel(model);
    this.setUndoRedoEnabled(b);
}
 
Example #30
Source File: DiagramScene.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public DiagramScene(Action[] actions, DiagramViewModel model) {
    this.actions = actions;
    selectedWidgets = new ArrayList<FigureWidget>();
    content = new InstanceContent();
    lookup = new AbstractLookup(content);
    this.setCheckClipping(true);
    this.getInputBindings().setZoomActionModifiers(0);

    JComponent comp = this.createView();
    comp.setDoubleBuffered(true);
    comp.setBackground(Color.WHITE);
    comp.setOpaque(true);

    this.setBackground(Color.WHITE);
    this.setOpaque(true);
    scrollPane = new JScrollPane(comp);
    scrollPane.setBackground(Color.WHITE);
    scrollPane.getVerticalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT);
    scrollPane.getVerticalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT);
    scrollPane.getHorizontalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT);
    scrollPane.getHorizontalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT);
    scrollPane.getViewport().addChangeListener(scrollChangeListener);
    hoverAction = this.createWidgetHoverAction();

    blockLayer = new LayerWidget(this);
    this.addChild(blockLayer);

    startLayer = new LayerWidget(this);
    this.addChild(startLayer);
    // TODO: String startLabelString = "Loading graph with " + originalDiagram.getFigures().size() + " figures and " + originalDiagram.getConnections().size() + " connections...";
    String startLabelString = "";
    LabelWidget w = new LabelWidget(this, startLabelString);
    scrollChangeListener.register(w, new Point(10, 10));
    w.setAlignment(LabelWidget.Alignment.CENTER);
    startLabel = w;
    startLayer.addChild(w);

    mainLayer = new LayerWidget(this);
    this.addChild(mainLayer);

    topLeft = new Widget(this);
    topLeft.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE));
    this.addChild(topLeft);


    bottomRight = new Widget(this);
    bottomRight.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE));
    this.addChild(bottomRight);

    slotLayer = new LayerWidget(this);
    this.addChild(slotLayer);

    connectionLayer = new LayerWidget(this);
    this.addChild(connectionLayer);

    LayerWidget selectionLayer = new LayerWidget(this);
    this.addChild(selectionLayer);

    this.setLayout(LayoutFactory.createAbsoluteLayout());

    this.getActions().addAction(hoverAction);
    zoomAction = new BoundedZoomAction(1.1, false);
    zoomAction.setMaxFactor(ZOOM_MAX_FACTOR);
    zoomAction.setMinFactor(ZOOM_MIN_FACTOR);
    this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1));
    panAction = new ExtendedPanAction();
    this.getActions().addAction(panAction);
    this.getActions().addAction(ActionFactory.createPopupMenuAction(popupMenuProvider));

    LayerWidget selectLayer = new LayerWidget(this);
    this.addChild(selectLayer);
    this.getActions().addAction(ActionFactory.createRectangularSelectAction(rectangularSelectDecorator, selectLayer, rectangularSelectProvider));

    blockWidgets = new HashMap<InputBlock, BlockWidget>();

    boolean b = this.getUndoRedoEnabled();
    this.setUndoRedoEnabled(false);
    this.setNewModel(model);
    this.setUndoRedoEnabled(b);
}