本文整理汇总了Java中org.netbeans.api.visual.model.ObjectState类的典型用法代码示例。如果您正苦于以下问题:Java ObjectState类的具体用法?Java ObjectState怎么用?Java ObjectState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ObjectState类属于org.netbeans.api.visual.model包,在下文中一共展示了ObjectState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ListWidget
import org.netbeans.api.visual.model.ObjectState; //导入依赖的package包/类
/**
* Creates a list widget.
* @param scene the scene
*/
public ListWidget (Scene scene) {
super (scene);
LookFeel lookFeel = scene.getLookFeel ();
setOpaque (true);
setBackground (lookFeel.getBackground ());
setBorder (BorderFactory.createLineBorder ());
setLayout (LayoutFactory.createVerticalFlowLayout ());
header = new Widget (scene);
header.setLayout (LayoutFactory.createHorizontalFlowLayout (LayoutFactory.SerialAlignment.CENTER, 0));
header.addChild (imageWidget = new ImageWidget (scene));
header.addChild (labelWidget = new LabelWidget (scene));
addChild (header);
addChild (new SeparatorWidget (scene, SeparatorWidget.Orientation.HORIZONTAL));
setState (ObjectState.createNormal ());
}
示例2: updateUI
import org.netbeans.api.visual.model.ObjectState; //导入依赖的package包/类
public void updateUI (VMDConnectionWidget widget, ObjectState previousState, ObjectState state) {
if (state.isHovered ())
widget.setForeground (COLOR_HOVERED);
else if (state.isSelected ())
widget.setForeground (COLOR_SELECTED);
else if (state.isHighlighted ())
widget.setForeground (COLOR_HIGHLIGHTED);
else if (state.isFocused ())
widget.setForeground (COLOR_HOVERED);
else
widget.setForeground (COLOR_NORMAL);
if (state.isSelected ()) {
widget.setControlPointShape (PointShape.SQUARE_FILLED_SMALL);
widget.setEndPointShape (PointShape.SQUARE_FILLED_BIG);
} else {
widget.setControlPointShape (PointShape.NONE);
widget.setEndPointShape (POINT_SHAPE_IMAGE);
}
}
示例3: updateUI
import org.netbeans.api.visual.model.ObjectState; //导入依赖的package包/类
public void updateUI (VMDNodeWidget widget, ObjectState previousState, ObjectState state) {
if (! previousState.isSelected () && state.isSelected ())
widget.bringToFront ();
boolean hover = state.isHovered () || state.isFocused ();
widget.getHeader ().setOpaque (hover);
if (state.isSelected ())
widget.setBorder (BORDER60_SELECT);
else if (state.isHovered ())
widget.setBorder (BORDER60_HOVER);
else if (state.isFocused ())
widget.setBorder (BORDER60_HOVER);
else
widget.setBorder (BORDER60);
}
示例4: ListWidget
import org.netbeans.api.visual.model.ObjectState; //导入依赖的package包/类
/**
* Creates a list widget.
* @param scene the scene
*/
public ListWidget (Scene scene) {
super (scene);
GeomUtil.LOG.warning ("org.netbeans.api.visual.widget.general.ListWidget class is deprecated. Use org.netbeans.modules.visual.experimental.widget.general.ListWidget class instead. Since it is an experimental class outside of public-API packages, you have to set an implementation dependency on the org.netbeans.api.visual module."); // NOI18N
LookFeel lookFeel = scene.getLookFeel ();
setOpaque (true);
setBackground (lookFeel.getBackground ());
setBorder (BorderFactory.createLineBorder ());
setLayout (LayoutFactory.createVerticalFlowLayout ());
header = new Widget (scene);
header.setLayout (LayoutFactory.createHorizontalFlowLayout (LayoutFactory.SerialAlignment.CENTER, 0));
header.addChild (imageWidget = new ImageWidget (scene));
header.addChild (labelWidget = new LabelWidget (scene));
addChild (header);
addChild (new SeparatorWidget (scene, SeparatorWidget.Orientation.HORIZONTAL));
setState (ObjectState.createNormal ());
}
示例5: IconNodeWidget
import org.netbeans.api.visual.model.ObjectState; //导入依赖的package包/类
/**
* 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 ());
}
示例6: testRegisterWidgetTransfersState
import org.netbeans.api.visual.model.ObjectState; //导入依赖的package包/类
/**
* 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());
}
示例7: mouseClicked
import org.netbeans.api.visual.model.ObjectState; //导入依赖的package包/类
@Override
public final WidgetAction.State mouseClicked(Widget widget, WidgetAction.WidgetMouseEvent event) {
if (event.getButton() == MouseEvent.BUTTON1 && event.getClickCount() == 1) {
ObjectState widgetState = widget.getState();
boolean isFocused = widgetState.isObjectFocused();
ObjectState newWidgetState = widgetState.deriveObjectFocused(!isFocused);
unfocusAllWidgets(widget);
widget.setState(newWidgetState);
widget.revalidate();
String htmlDescription = getHtmlDescription();
if (htmlDescription != null) {
IPaletteActions paletteActions = ((ShedScene) widget.getScene()).getPaletteActions();
paletteActions.setHtmlDescription(htmlDescription);
}
return WidgetAction.State.CONSUMED;
}
return WidgetAction.State.REJECTED;
}
示例8: EdgeSwitchWidget
import org.netbeans.api.visual.model.ObjectState; //导入依赖的package包/类
public EdgeSwitchWidget(final CfgScene scene, NodeWidget nodeWidget, boolean output) {
super(scene);
this.scene = scene;
this.output = output;
this.nodeWidget = nodeWidget;
this.getActions().addAction(ActionFactory.createSelectAction(selectProvider));
TwoStateHoverProvider ts = new TsHover(this);
WidgetAction wa = ActionFactory.createHoverAction(ts);
this.hoverAction = wa;
this.getActions().addAction(wa);
scene.getActions().addAction(wa);
this.setToolTipText(TT_HIDE_EDGES);
this.setForeground(color_enabled);
this.setState(ObjectState.createNormal());
}
示例9: changeEdgeVisibility
import org.netbeans.api.visual.model.ObjectState; //导入依赖的package包/类
public void changeEdgeVisibility(boolean visible){
Collection<CfgEdge> edges = this.getEdges();
for(CfgEdge e: edges) {
EdgeWidget ew = (EdgeWidget) scene.findWidget(e);
if(visible != ew.isEdgeVisible()){
ew.setEdgeVisible(visible);
if(output){
scene.getInputSwitch(e.getTargetNode()).updateStatus();
} else {
scene.getOutputSwitch(e.getSourceNode()).updateStatus();
}
}
}
if(visible)
this.setToolTipText(TT_HIDE_EDGES);
else
this.setToolTipText(TT_SHOW_EDGES);
this.setForeground(color_enabled);
this.bringToBack();
ObjectState os = this.getState();
this.setState(os.deriveSelected(!visible));
}
示例10: updateStatus
import org.netbeans.api.visual.model.ObjectState; //导入依赖的package包/类
/**
* Update the status of the switch to the current state of the edges
* usually needed when the opposit switch changes the state
*/
private void updateStatus(){
Collection<CfgEdge> edges = this.getEdges();
boolean hiddenFound=false;
for(CfgEdge e: edges) {
EdgeWidget ew = (EdgeWidget) scene.findWidget(e);
if(!ew.isVisible()) {
hiddenFound=true;
break;
}
}
ObjectState os = this.getState();
if(os.isSelected() && !hiddenFound) {
this.setState(os.deriveSelected(false));
setToolTipText(TT_HIDE_EDGES);
} else if (!os.isSelected() && hiddenFound) {
this.setState(os.deriveSelected(true));
setToolTipText(TT_SHOW_EDGES);
}
this.revalidate();
}
示例11: notifyStateChanged
import org.netbeans.api.visual.model.ObjectState; //导入依赖的package包/类
@Override
public void notifyStateChanged(ObjectState oldState, ObjectState newState) {
setForeground (getLineColor());
if(newState.isHighlighted() && !oldState.isHighlighted()){
this.setStroke(previewStroke);
this.setVisible(true);
} else {
if(newState.isSelected()){
this.setStroke(selectedStroke);
} else {
this.setStroke(defaultStroke);
}
if(this.isEdgeVisible()){
this.setVisible(true);
} else {
this.setVisible(false);
}
}
}
示例12: notifyStateChanged
import org.netbeans.api.visual.model.ObjectState; //导入依赖的package包/类
@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();
}
示例13: notifyStateChanged
import org.netbeans.api.visual.model.ObjectState; //导入依赖的package包/类
@Override
protected void notifyStateChanged(ObjectState previousState, ObjectState state) {
super.notifyStateChanged(previousState, state);
if (previousState.isHovered() != state.isHovered()) {
if (state.isHovered()) {
this.setBorder(BorderFactory.createLineBorder(1, HOVER_FOREGROUND_COLOR));
} else {
this.setBorder(BorderFactory.createLineBorder(1, NORMAL_FOREGROUND_COLOR));
}
}
if (previousState.isSelected() != state.isSelected()) {
if (state.isSelected()) {
this.setFont(boldFont);
} else {
this.setFont(font);
}
}
}
示例14: paintWidget
import org.netbeans.api.visual.model.ObjectState; //导入依赖的package包/类
@Override
protected void paintWidget() {
Graphics2D g = getScene().getGraphics();
//g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
g.setColor(this.color);
ObjectState state = this.getState();
float width = 1.0f;
if (state.isHovered() || this.popupVisible) {
width = HOVER_STROKE_WIDTH;
}
Stroke oldStroke = g.getStroke();
g.setStroke(new BasicStroke(width));
for (Route r : routeList) {
g.drawLine(r.from.x, r.from.y, r.to.x, r.to.y);
}
g.setStroke(oldStroke);
}
示例15: notifyStateChanged
import org.netbeans.api.visual.model.ObjectState; //导入依赖的package包/类
@Override
public void notifyStateChanged(ObjectState previousState, ObjectState state) {
if (previousState.isHovered() != state.isHovered()) {
color = connection.getColor();
if (state.isHovered()) {
this.setStroke(BOLD_STROKE);
} else {
this.setStroke(NORMAL_STROKE);
}
if (state.isHovered()) {
this.setStroke(BOLD_STROKE);
} else {
this.setStroke(NORMAL_STROKE);
}
repaint();
}
super.notifyStateChanged(previousState, state);
}