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

The following examples show how to use org.netbeans.api.visual.widget.LabelWidget#setLabel() . 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: DB_VMDGraph.java    From BART with MIT License 6 votes vote down vote up
private void createAttribute(String table , Attribute attribute)   {
    VMDPinWidget attributeWidget = (VMDPinWidget)scene.addPin(table,table+attribute.getName());
    attributeWidget.setPinName(attribute.getName());
    attributeWidget.setToolTipText("Double click for View Table data");
    attributeWidget.setLayout(LayoutFactory.createHorizontalFlowLayout(
                                LayoutFactory.SerialAlignment.JUSTIFY, 7));
    
    LabelWidget type = new LabelWidget(scene);
    type.setForeground(Color.GRAY);
    type.setLabel(attribute.getType());
    attributeWidget.addChild(type);
    
    for(Key k : db.getKeys(table))   {
        for(AttributeRef attr : k.getAttributes())   {
            if(attr.getName().equals(attribute.getName()) && k.isPrimaryKey())   {
                LabelWidget pk = new LabelWidget(scene);
                pk.setForeground(Color.BLUE);
                pk.setLabel(" PK");
                attributeWidget.addChild(pk);    
            }
        }
    }
}
 
Example 2
Source File: FigureWidget.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void paintWidget() {
    if (firstTime) {
        firstTime = false;
        for (LabelWidget w : labelWidgets) {
            String cur = w.getLabel();
            Graphics graphics = this.getGraphics();
            if (graphics.getFontMetrics().stringWidth(cur) > figure.getWidth()) {
                w.setLabel(shortenString(cur));
            }
        }
    }
    super.paintWidget();
}
 
Example 3
Source File: FigureWidget.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void paintWidget() {
    if (firstTime) {
        firstTime = false;
        for (LabelWidget w : labelWidgets) {
            String cur = w.getLabel();
            Graphics graphics = this.getGraphics();
            if (graphics.getFontMetrics().stringWidth(cur) > figure.getWidth()) {
                w.setLabel(shortenString(cur));
            }
        }
    }
    super.paintWidget();
}
 
Example 4
Source File: FigureWidget.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void paintWidget() {
    if (firstTime) {
        firstTime = false;
        for (LabelWidget w : labelWidgets) {
            String cur = w.getLabel();
            Graphics graphics = this.getGraphics();
            if (graphics.getFontMetrics().stringWidth(cur) > figure.getWidth()) {
                w.setLabel(shortenString(cur));
            }
        }
    }
    super.paintWidget();
}
 
Example 5
Source File: FigureWidget.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void paintWidget() {
    if (firstTime) {
        firstTime = false;
        for (LabelWidget w : labelWidgets) {
            String cur = w.getLabel();
            Graphics graphics = this.getGraphics();
            if (graphics.getFontMetrics().stringWidth(cur) > figure.getWidth()) {
                w.setLabel(shortenString(cur));
            }
        }
    }
    super.paintWidget();
}
 
Example 6
Source File: FigureWidget.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void paintWidget() {
    if (firstTime) {
        firstTime = false;
        for (LabelWidget w : labelWidgets) {
            String cur = w.getLabel();
            Graphics graphics = this.getGraphics();
            if (graphics.getFontMetrics().stringWidth(cur) > figure.getWidth()) {
                w.setLabel(shortenString(cur));
            }
        }
    }
    super.paintWidget();
}
 
Example 7
Source File: FigureWidget.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void paintWidget() {
    if (firstTime) {
        firstTime = false;
        for (LabelWidget w : labelWidgets) {
            String cur = w.getLabel();
            Graphics graphics = this.getGraphics();
            if (graphics.getFontMetrics().stringWidth(cur) > figure.getWidth()) {
                w.setLabel(shortenString(cur));
            }
        }
    }
    super.paintWidget();
}
 
Example 8
Source File: FigureWidget.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void paintWidget() {
    if (firstTime) {
        firstTime = false;
        for (LabelWidget w : labelWidgets) {
            String cur = w.getLabel();
            Graphics graphics = this.getGraphics();
            if (graphics.getFontMetrics().stringWidth(cur) > figure.getWidth()) {
                w.setLabel(shortenString(cur));
            }
        }
    }
    super.paintWidget();
}
 
Example 9
Source File: AbegoTreeLayoutForNetbeansDemo.java    From treelayout with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected Widget attachNodeWidget(String n) {
	LabelWidget w = new LabelWidget(this);
	w.setLabel(" " + n + " ");
	mainLayer.addChild(w);
	return w;
}
 
Example 10
Source File: NodeWidget.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Messages("ACT_FixVersionConflict=Fix Version Conflict...")
private void initContent (DependencyGraphScene scene, GraphNodeImplementation impl, Icon icon) {
    contentW = new LevelOfDetailsWidget(scene, 0.05, 0.1, Double.MAX_VALUE, Double.MAX_VALUE);
    contentW.setBorder(BorderFactory.createLineBorder(10));
    contentW.setLayout(LayoutFactory.createVerticalFlowLayout(LayoutFactory.SerialAlignment.JUSTIFY, 1));

    //Artifact name (with optional project icon on the left)
    nodeW = new IconNodeWidget(scene, TextOrientation.RIGHT_CENTER);
    nodeW.setLabel(node.getImpl().getQualifiedName() + "  ");

    if (null != icon) {
        nodeW.setImage(ImageUtilities.icon2Image(icon));
    }

    nodeW.getLabelWidget().setUseGlyphVector(true);

    if (node.isRoot()) {
        Font defF = scene.getDefaultFont();
        nodeW.getLabelWidget().setFont(defF.deriveFont(Font.BOLD, defF.getSize() + 3f));
    }
    contentW.addChild(nodeW);
    
    if(getDependencyGraphScene().supportsVersions()) {
        Widget versionDetW = new LevelOfDetailsWidget(scene, 0.5, 0.7, Double.MAX_VALUE, Double.MAX_VALUE);
        versionDetW.setLayout(LayoutFactory.createHorizontalFlowLayout(LayoutFactory.SerialAlignment.CENTER, 2));
        contentW.addChild(versionDetW);
        versionW = new LabelWidget(scene);
        versionW.setLabel(scene.getVersion(node.getImpl()));
        versionW.setUseGlyphVector(true);
        int mngState = node.getManagedState();
        if (mngState != GraphNode.UNMANAGED) { 
             lockW = new ImageWidget(scene,
                    mngState == GraphNode.MANAGED ? ImageUtilities.loadImage(LOCK_ICON) : ImageUtilities.loadImage(LOCK_BROKEN_ICON));
        }
        versionDetW.addChild(versionW);
        if (lockW != null) {
            versionDetW.addChild(lockW);
        }
    }

    // fix hint
    if (fixConflictAction != null) {
        Widget rootW = new Widget(scene);
        rootW.setLayout(LayoutFactory.createOverlayLayout());
        fixHintW = new ImageWidget(scene, ImageUtilities.loadImage(BULB_ICON));
        fixHintW.setVisible(false);
        fixHintW.setToolTipText(ACT_FixVersionConflict());
        fixHintW.getActions().addAction(sceneHoverActionAction);
        fixHintW.getActions().addAction(fixConflictAction);
        Widget panelW = new Widget(scene);
        panelW.setLayout(LayoutFactory.createVerticalFlowLayout(LayoutFactory.SerialAlignment.LEFT_TOP, 0));
        panelW.setBorder(BorderFactory.createEmptyBorder(0, 3));
        panelW.addChild(fixHintW);
        rootW.addChild(panelW);
        rootW.addChild(contentW);
        addChild(rootW);
    } else {
        addChild(contentW);
    }

}