Java Code Examples for org.netbeans.api.visual.widget.LabelWidget#setAlignment()

The following examples show how to use org.netbeans.api.visual.widget.LabelWidget#setAlignment() . 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: 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 2
Source File: OutputWidget.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void createContent() {
    headerLabelWidget = new ImageLabelWidget(getScene(), getIcon(), getTitle());
    headerLabelWidget.setLabelFont(getScene().getFont().deriveFont(Font.BOLD));
    getHeaderWidget().addChild(new Widget(getScene()),5);
    getHeaderWidget().addChild(headerLabelWidget);
    getHeaderWidget().addChild(new Widget(getScene()),4);
    
    buttons = new Widget(getScene());
    buttons.setLayout(LayoutFactory.createHorizontalFlowLayout(
            LayoutFactory.SerialAlignment.CENTER, 8));
    buttons.addChild(getExpanderWidget());
    getHeaderWidget().addChild(buttons);
    
    LabelWidget returnWidget = new LabelWidget(getScene(), method.isOneWay()?
        NbBundle.getMessage(OperationWidget.class, "LBL_ReturnTypeNone"):
        NbBundle.getMessage(OperationWidget.class, "LBL_ReturnType", method.getResult().getResultType()));
    returnWidget.setAlignment(LabelWidget.Alignment.CENTER);
    getContentWidget().addChild(returnWidget);
    
}
 
Example 3
Source File: TableWidget.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void createTableHeader() {
    Scene scene = getScene();
    int noCols = model.getColumnCount();
    Widget headerWidget = new RowWidget(scene,noCols,null);
    addChild(headerWidget);
    
    for (int i = 0; i<noCols;i++) {
        LabelWidget columnHeader = new LabelWidget(scene, model.getColumnName(i));
        if(i!=0) {
            columnHeader.setBorder(new LineBorder(0, 1, 0, 0, BORDER_COLOR));
        }
        columnHeader.setAlignment(LabelWidget.Alignment.CENTER);
        columnHeader.setBackground(HEADER_COLOR);
        columnHeader.setOpaque(true);
        headerWidget.addChild(columnHeader);
    }
}
 
Example 4
Source File: VMDOriginalColorScheme.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static Widget createPinCategoryWidgetCore (VMDNodeWidget widget, String categoryDisplayName, boolean changeFont) {
    Scene scene = widget.getScene ();
    LabelWidget label = new LabelWidget (scene, categoryDisplayName);
    label.setOpaque (true);
    label.setBackground (BORDER_CATEGORY_BACKGROUND);
    label.setForeground (Color.GRAY);
    if (changeFont) {
        Font fontPinCategory = scene.getDefaultFont ().deriveFont (10.0f);
        label.setFont (fontPinCategory);
    }
    label.setAlignment (LabelWidget.Alignment.CENTER);
    label.setCheckClipping (true);
    return label;
}
 
Example 5
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 6
Source File: OutputWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Widget getComponentWidget() {
    if(tabComponent==null) {
        tabComponent = createContentWidget();
        LabelWidget returnWidget = new LabelWidget(getScene(), method.isOneWay()?
            NbBundle.getMessage(OperationWidget.class, "LBL_ReturnTypeNone"):
            NbBundle.getMessage(OperationWidget.class, "LBL_ReturnType", method.getResult().getResultType()));
        returnWidget.setAlignment(LabelWidget.Alignment.CENTER);
        tabComponent.addChild(returnWidget);
    }
    return tabComponent;
}
 
Example 7
Source File: FaultsWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void populateContentWidget(Widget parentWidget) {
    if(model.getRowCount()>0) {
        faultTable = new TableWidget(getScene(),model);
        parentWidget.addChild(faultTable);
    } else {
        LabelWidget noFaults = new LabelWidget(getScene(),
                NbBundle.getMessage(OperationWidget.class, "LBL_FaultsNone"));
        noFaults.setAlignment(LabelWidget.Alignment.CENTER);
        parentWidget.addChild(noFaults);
    }
}
 
Example 8
Source File: ParametersWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void populateContentWidget(Widget parentWidget) {
    if(model.getRowCount()>0) {
        parameterTable = new TableWidget(getScene(),model);
        parentWidget.addChild(parameterTable);
    } else {
        LabelWidget noParamsWidget = new LabelWidget(getScene(),
                NbBundle.getMessage(OperationWidget.class, "LBL_InputNone"));
        noParamsWidget.setAlignment(LabelWidget.Alignment.CENTER);
        parentWidget.addChild(noParamsWidget);
    }
}
 
Example 9
Source File: GraphColorScheme.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
static Widget createPinCategoryWidgetCore(VMDNodeWidget widget, String categoryDisplayName, boolean changeFont) {
    Scene scene = widget.getScene();
    LabelWidget label = new LabelWidget(scene, categoryDisplayName);
    label.setOpaque(true);
    label.setBackground(BORDER_CATEGORY_BACKGROUND);
    label.setForeground(Color.GRAY);
    if (changeFont) {
        Font fontPinCategory = scene.getDefaultFont().deriveFont(10.0f);
        label.setFont(fontPinCategory);
    }
    label.setAlignment(LabelWidget.Alignment.CENTER);
    label.setCheckClipping(true);
    return label;
}
 
Example 10
Source File: DiagramScene.java    From TencentKona-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);
}
 
Example 11
Source File: DiagramScene.java    From jdk8u60 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 12
Source File: DiagramScene.java    From openjdk-jdk8u 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 13
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 14
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 15
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 16
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);
}