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

The following examples show how to use org.netbeans.api.visual.widget.LabelWidget#setFont() . 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: IconNodeWidget.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an icon node widget with a specified orientation.
 * @param scene the scene
 * @param orientation the text orientation
 */
public IconNodeWidget (Scene scene, TextOrientation orientation) {
    super (scene);
    LookFeel lookFeel = getScene ().getLookFeel ();

    switch (orientation) {
        case BOTTOM_CENTER:
            setLayout (LayoutFactory.createVerticalFlowLayout (LayoutFactory.SerialAlignment.CENTER, - lookFeel.getMargin () + 1));
            break;
        case RIGHT_CENTER:
            setLayout (LayoutFactory.createHorizontalFlowLayout (LayoutFactory.SerialAlignment.CENTER, - lookFeel.getMargin () + 1));
            break;
    }

    imageWidget = new ImageWidget (scene);
    addChild (imageWidget);

    labelWidget = new LabelWidget (scene);
    labelWidget.setFont (scene.getDefaultFont ().deriveFont (14.0f));
    addChild (labelWidget);

    setState (ObjectState.createNormal ());
}
 
Example 2
Source File: FigureWidget.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void notifyStateChanged(ObjectState previousState, ObjectState state) {
    super.notifyStateChanged(previousState, state);

    Font font = this.figure.getDiagram().getFont();
    if (state.isSelected()) {
        font = this.figure.getDiagram().getBoldFont();
    }

    Color borderColor = Color.BLACK;
    Color innerBorderColor = getFigure().getColor();
    if (state.isHighlighted()) {
        innerBorderColor = borderColor = Color.BLUE;
    }

    middleWidget.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(borderColor, 1), BorderFactory.createLineBorder(innerBorderColor, 1)));
    for (LabelWidget labelWidget : labelWidgets) {
        labelWidget.setFont(font);
    }
    repaint();
}
 
Example 3
Source File: FigureWidget.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void notifyStateChanged(ObjectState previousState, ObjectState state) {
    super.notifyStateChanged(previousState, state);

    Color borderColor = Color.BLACK;
    int thickness = 1;
    boolean repaint = false;
    Font f = font;
    if (state.isSelected()) {
        thickness = 1;
        f = boldFont;
    }

    if (state.isHovered()) {
        borderColor = Color.BLUE;
    }

    if (state.isHovered() != previousState.isHovered()) {
        repaint = true;
    }

    if (state.isSelected() != previousState.isSelected()) {
        repaint = true;
    }

    if (repaint) {
        middleWidget.setBorder(BorderFactory.createLineBorder(borderColor, thickness));
        for (LabelWidget labelWidget : labelWidgets) {
            labelWidget.setFont(f);
        }
        repaint();
    }
}
 
Example 4
Source File: FigureWidget.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void notifyStateChanged(ObjectState previousState, ObjectState state) {
    super.notifyStateChanged(previousState, state);

    Color borderColor = Color.BLACK;
    int thickness = 1;
    boolean repaint = false;
    Font f = font;
    if (state.isSelected()) {
        thickness = 1;
        f = boldFont;
    }

    if (state.isHovered()) {
        borderColor = Color.BLUE;
    }

    if (state.isHovered() != previousState.isHovered()) {
        repaint = true;
    }

    if (state.isSelected() != previousState.isSelected()) {
        repaint = true;
    }

    if (repaint) {
        middleWidget.setBorder(BorderFactory.createLineBorder(borderColor, thickness));
        for (LabelWidget labelWidget : labelWidgets) {
            labelWidget.setFont(f);
        }
        repaint();
    }
}
 
Example 5
Source File: FigureWidget.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void notifyStateChanged(ObjectState previousState, ObjectState state) {
    super.notifyStateChanged(previousState, state);

    Color borderColor = Color.BLACK;
    int thickness = 1;
    boolean repaint = false;
    Font f = font;
    if (state.isSelected()) {
        thickness = 1;
        f = boldFont;
    }

    if (state.isHovered()) {
        borderColor = Color.BLUE;
    }

    if (state.isHovered() != previousState.isHovered()) {
        repaint = true;
    }

    if (state.isSelected() != previousState.isSelected()) {
        repaint = true;
    }

    if (repaint) {
        middleWidget.setBorder(BorderFactory.createLineBorder(borderColor, thickness));
        for (LabelWidget labelWidget : labelWidgets) {
            labelWidget.setFont(f);
        }
        repaint();
    }
}
 
Example 6
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 7
Source File: FigureWidget.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void notifyStateChanged(ObjectState previousState, ObjectState state) {
    super.notifyStateChanged(previousState, state);

    Color borderColor = Color.BLACK;
    int thickness = 1;
    boolean repaint = false;
    Font f = font;
    if (state.isSelected()) {
        thickness = 1;
        f = boldFont;
    }

    if (state.isHovered()) {
        borderColor = Color.BLUE;
    }

    if (state.isHovered() != previousState.isHovered()) {
        repaint = true;
    }

    if (state.isSelected() != previousState.isSelected()) {
        repaint = true;
    }

    if (repaint) {
        middleWidget.setBorder(BorderFactory.createLineBorder(borderColor, thickness));
        for (LabelWidget labelWidget : labelWidgets) {
            labelWidget.setFont(f);
        }
        repaint();
    }
}
 
Example 8
Source File: FigureWidget.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void notifyStateChanged(ObjectState previousState, ObjectState state) {
    super.notifyStateChanged(previousState, state);

    Color borderColor = Color.BLACK;
    int thickness = 1;
    boolean repaint = false;
    Font f = font;
    if (state.isSelected()) {
        thickness = 1;
        f = boldFont;
    }

    if (state.isHovered()) {
        borderColor = Color.BLUE;
    }

    if (state.isHovered() != previousState.isHovered()) {
        repaint = true;
    }

    if (state.isSelected() != previousState.isSelected()) {
        repaint = true;
    }

    if (repaint) {
        middleWidget.setBorder(BorderFactory.createLineBorder(borderColor, thickness));
        for (LabelWidget labelWidget : labelWidgets) {
            labelWidget.setFont(f);
        }
        repaint();
    }
}
 
Example 9
Source File: FigureWidget.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void notifyStateChanged(ObjectState previousState, ObjectState state) {
    super.notifyStateChanged(previousState, state);

    Color borderColor = Color.BLACK;
    int thickness = 1;
    boolean repaint = false;
    Font f = font;
    if (state.isSelected()) {
        thickness = 1;
        f = boldFont;
    }

    if (state.isHovered()) {
        borderColor = Color.BLUE;
    }

    if (state.isHovered() != previousState.isHovered()) {
        repaint = true;
    }

    if (state.isSelected() != previousState.isSelected()) {
        repaint = true;
    }

    if (repaint) {
        middleWidget.setBorder(BorderFactory.createLineBorder(borderColor, thickness));
        for (LabelWidget labelWidget : labelWidgets) {
            labelWidget.setFont(f);
        }
        repaint();
    }
}
 
Example 10
Source File: FigureWidget.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void notifyStateChanged(ObjectState previousState, ObjectState state) {
    super.notifyStateChanged(previousState, state);

    Color borderColor = Color.BLACK;
    int thickness = 1;
    boolean repaint = false;
    Font f = font;
    if (state.isSelected()) {
        thickness = 1;
        f = boldFont;
    }

    if (state.isHovered()) {
        borderColor = Color.BLUE;
    }

    if (state.isHovered() != previousState.isHovered()) {
        repaint = true;
    }

    if (state.isSelected() != previousState.isSelected()) {
        repaint = true;
    }

    if (repaint) {
        middleWidget.setBorder(BorderFactory.createLineBorder(borderColor, thickness));
        for (LabelWidget labelWidget : labelWidgets) {
            labelWidget.setFont(f);
        }
        repaint();
    }
}
 
Example 11
Source File: RuleScene.java    From jlibs with Apache License 2.0 5 votes vote down vote up
private LabelWidget createEdgeLabel(Edge edge){
    LabelWidget label = new LabelWidget(this, edge.toString());
    label.setFont(Util.FIXED_WIDTH_FONT);
    label.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 0));

    label.getActions().addAction(hoverAction);
    label.getActions().addAction(editAction);
    label.getActions().addAction(moveAction);
    label.getActions().addAction(edgePopupAction);
    return label;
}
 
Example 12
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 13
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();
}