org.netbeans.api.visual.widget.LabelWidget Java Examples
The following examples show how to use
org.netbeans.api.visual.widget.LabelWidget.
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: PageFlowScene.java From netbeans with Apache License 2.0 | 6 votes |
public void setText(Widget widget, String newName) { if (newName.equals("")) { return; } NavigationCaseEdge caseNode = (NavigationCaseEdge) findObject(widget.getParentWidget()); String oldName = caseNode.getName(); if (caseNode.canRename()) { //Pin pin = getEdgeSource(caseNode); //caseNode.setName(pin, newName); caseNode.setName(newName); } ((LabelWidget) widget).setLabel(newName); }
Example #2
Source File: FigureWidget.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@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: ObjectSceneLazyTest.java From netbeans with Apache License 2.0 | 6 votes |
/** * Checks that lazy object will maintain the state even if * a widget is registered */ public void testRegisterWidgetTransfersState() throws Exception { Object item = new String("lazyItem"); scene.setSelectedObjects(Collections.singleton(item)); scene.setHighlightedObjects(Collections.singleton(item)); scene.setHoveredObject(item); scene.setFocusedObject(item); Widget w = new LabelWidget(scene); scene.addObject(item, w); ObjectState s = scene.getObjectState(item); assertTrue(s.isSelected()); assertTrue(s.isHighlighted()); assertTrue(s.isHovered()); assertTrue(s.isFocused()); ObjectState ws = w.getState(); assertTrue(ws.isSelected()); assertTrue(ws.isHighlighted()); assertTrue(ws.isHovered()); assertTrue(ws.isFocused()); }
Example #4
Source File: OffscreenRenderingTest.java From netbeans with Apache License 2.0 | 6 votes |
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 #5
Source File: IconNodeWidget.java From netbeans with Apache License 2.0 | 6 votes |
/** * 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 #6
Source File: PageFlowScene.java From netbeans with Apache License 2.0 | 6 votes |
public void setText(Widget widget, String text) { Page pageNode = (Page) findObject(nodeWidget); if (pageNode.canRename() && !text.equals(pageNode.getName())) { //Explicitly declared oldName and newName for ease of reading. String oldName = pageNode.getDisplayName(); String newName; pageNode.setName(text); newName = pageNode.getDisplayName(); // if( oldName != newName ) { // renamePin(pageNode, oldName + "pin", newName + "pin"); // } if (widget instanceof LabelWidget) { ((LabelWidget) widget).setLabel(newName); } else if (widget instanceof VMDNodeWidget) { ((VMDNodeWidget) widget).getNodeNameWidget().setLabel(newName); } validate(); } }
Example #7
Source File: Utils.java From netbeans with Apache License 2.0 | 6 votes |
public TestScene() { addChild(mainLayer); addChild(connectionLayer); addChild(interractionLayer); getActions().addAction(createAction); //mainLayer.addChild(new LabelWidget(this, "Click on background to create a node. Drag a node to create a connection.")); // do not change label nor location because it is hard coded in test cases //addNode("Label 0").setPreferredLocation(new Point(100, 100)); Widget label0Widget = addNode("Label 0"); label0Widget.setPreferredLocation(new Point(100, 100)); label0Widget.getActions().addAction(ActionFactory.createPopupMenuAction(new MyPopupProvider())); label0Widget.getActions().addAction(new LabelAction()); Widget label1Widget = addNode("Label 1"); label1Widget.setPreferredLocation(new Point(300, 100)); LabelWidget movableWidget = new LabelWidget(this, "Movable Widget"); movableWidget.setPreferredLocation(new Point(100, 150)); movableWidget.getActions().addAction(moveAction); addChild(movableWidget); }
Example #8
Source File: DB_VMDGraph.java From BART with MIT License | 6 votes |
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 #9
Source File: RuleScene.java From jlibs with Apache License 2.0 | 6 votes |
@Override protected Widget attachEdgeWidget(Edge edge){ EdgeWidget connection = new EdgeWidget(this); connection.setStroke(Util.STROKE_2); connection.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED); LabelWidget label = createEdgeLabel(edge); connection.setConstraint(label, LayoutFactory.ConnectionWidgetLayoutAlignment.TOP_CENTER, 0.5f); connection.addChild(label); connections.addChild(connection); connection.setRouter(router); connection.highLight(false); connection.getActions().addAction(hoverAction); connection.getActions().addAction(editAction); connection.getActions().addAction(edgePopupAction); return connection; }
Example #10
Source File: OutputWidget.java From netbeans with Apache License 2.0 | 6 votes |
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 #11
Source File: TableWidget.java From netbeans with Apache License 2.0 | 6 votes |
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 #12
Source File: FigureWidget.java From hottub with GNU General Public License v2.0 | 5 votes |
@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 #13
Source File: PageFlowScene.java From netbeans with Apache License 2.0 | 5 votes |
public void renameEdgeWidget(NavigationCaseEdge edge, String newName, String oldName) { VMDConnectionWidget edgeWidget = (VMDConnectionWidget) findWidget(edge); List<Widget> widgets = edgeWidget.getChildren(); for (Widget widget : widgets) { if (widget instanceof LabelWidget && ((LabelWidget) widget).getLabel().equals(oldName)) { ((LabelWidget) widget).setLabel(newName); return; } } }
Example #14
Source File: ConnectionWrapperLayout.java From netbeans with Apache License 2.0 | 5 votes |
private static final void resetLabelConstraint(ConnectionWidget connectionWidget, LabelWidget label) { assert connectionWidget != null; if (label != null) { connectionWidget.removeConstraint(label); connectionWidget.removeChild(label); Anchor sourceAnchor = connectionWidget.getSourceAnchor(); Entry sourceAnchorEntry = connectionWidget.getSourceAnchorEntry(); assert sourceAnchor != null; assert sourceAnchorEntry != null; if (sourceAnchor != null && sourceAnchorEntry != null) { EnumSet<Anchor.Direction> directions = sourceAnchor.compute(sourceAnchorEntry).getDirections(); if (directions.contains(Anchor.Direction.TOP)) { label.setOrientation(LabelWidget.Orientation.ROTATE_90); connectionWidget.setConstraint(label, LayoutFactory.ConnectionWidgetLayoutAlignment.TOP_RIGHT, 10); } else if (directions.contains(Anchor.Direction.BOTTOM)) { label.setOrientation(LabelWidget.Orientation.ROTATE_90); connectionWidget.setConstraint(label, LayoutFactory.ConnectionWidgetLayoutAlignment.BOTTOM_RIGHT, 10); } else if (directions.contains(Anchor.Direction.RIGHT)) { connectionWidget.setConstraint(label, LayoutFactory.ConnectionWidgetLayoutAlignment.TOP_RIGHT, 10); label.setOrientation(LabelWidget.Orientation.NORMAL); } else { connectionWidget.setConstraint(label, LayoutFactory.ConnectionWidgetLayoutAlignment.TOP_LEFT, 10); label.setOrientation(LabelWidget.Orientation.NORMAL); } } else { LogRecord record = new LogRecord(Level.FINE, "Problems Reseting Label Constraint"); record.setSourceClassName("ConnectionWrapperLayout"); record.setSourceMethodName("resetLabelConstraint"); record.setParameters(new Object[]{connectionWidget, label, new Date()}); LOGGER.log(record); connectionWidget.setConstraint(label, LayoutFactory.ConnectionWidgetLayoutAlignment.TOP_LEFT, 10); label.setOrientation(LabelWidget.Orientation.NORMAL); } connectionWidget.addChild(label); } }
Example #15
Source File: ParametersWidget.java From netbeans with Apache License 2.0 | 5 votes |
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 #16
Source File: FigureWidget.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@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 #17
Source File: FigureWidget.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@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 #18
Source File: FigureWidget.java From hottub with GNU General Public License v2.0 | 5 votes |
@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 #19
Source File: FaultsWidget.java From netbeans with Apache License 2.0 | 5 votes |
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 #20
Source File: FigureWidget.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@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 #21
Source File: FigureWidget.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@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 #22
Source File: FigureWidget.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@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 #23
Source File: FigureWidget.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@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 #24
Source File: AbegoTreeLayoutForNetbeansDemo.java From treelayout with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected Widget attachNodeWidget(String n) { LabelWidget w = new LabelWidget(this); w.setLabel(" " + n + " "); mainLayer.addChild(w); return w; }
Example #25
Source File: DBColorScheme.java From jeddict with Apache License 2.0 | 5 votes |
@Override public void installUI(IPinSeperatorWidget label) { label.setOpaque(true); label.setBackground(PIN_SEPERATOR_WIDGET_BACKGROUND); label.setForeground(PIN_SEPERATOR_WIDGET_FOREGROUND); Font fontPinCategory = label.getScene().getDefaultFont().deriveFont(9.5f); label.setFont(fontPinCategory); label.setAlignment(LabelWidget.Alignment.CENTER); label.setCheckClipping(true); }
Example #26
Source File: RuleScene.java From jlibs with Apache License 2.0 | 5 votes |
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 #27
Source File: ModelGraphScene.java From opensim-gui with Apache License 2.0 | 5 votes |
protected Widget attachNodeWidget (String node) { LabelWidget label = new LabelWidget (this, node); label.setBorder (BORDER_4); label.getActions ().addAction (moveAction); mainLayer.addChild (label); return label; }
Example #28
Source File: topologyEditorTopComponent.java From opensim-gui with Apache License 2.0 | 5 votes |
public void edit(Widget widget) { if (widget != null) { //widget.setBackground (new Color (52, 124, 150)); //widget.setForeground (Color.RED); if (widget instanceof LabelWidget){ LabelWidget selected = ((LabelWidget)widget); Body b = OpenSimDB.getInstance().getCurrentModel().getBodySet().get(selected.getLabel()); ViewDB.getInstance().replaceSelectedObject(b); } else sceneGraphLayout.invokeLayoutImmediately (); } }
Example #29
Source File: GraphColorScheme.java From Llunatic with GNU General Public License v3.0 | 5 votes |
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 #30
Source File: ObjectSceneLazyTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testRegularRemoveObject() throws Exception { Object item = new String("lazyItem"); scene.setSelectedObjects(Collections.singleton(item)); scene.setHighlightedObjects(Collections.singleton(item)); scene.setHoveredObject(item); scene.setFocusedObject(item); Widget w = new LabelWidget(scene); scene.addObject(item, w); ObjectState s = scene.getObjectState(item); assertTrue(s.isSelected()); assertTrue(s.isHighlighted()); assertTrue(s.isHovered()); assertTrue(s.isFocused()); SceneAdapter ad = new SceneAdapter(item); scene.addObjectSceneListener(ad, ObjectSceneEventType.values()); scene.removeObject(item); assertEquals(0, ad.added); assertEquals(1, ad.removed); assertEquals(1, ad.focusChanged); assertEquals(1, ad.highlightChanged); assertEquals(1, ad.hoverChanged); assertEquals(1, ad.selChanged); assertEquals(4, ad.stateChanged); assertNull(scene.getHoveredObject()); assertNull(scene.getFocusedObject()); assertTrue(scene.getSelectedObjects().isEmpty()); assertTrue(scene.getHighlightedObjects().isEmpty()); }