|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLabel
verinec.gui.core.NwComponent
public abstract class NwComponent
Base class for every network component of the GUI.
The class itself provides several functionalities. Common methodes are directly implemented in this class: moving and scaling the component as well as creating the icon.
Moving is implemented as follows: all setBounds, setLocation and the moveComponent methods are
redirected to setBounds(int, int, int, int).
This method prevents moving a component out of the window area.
Components having attached children should overwrite that method to move
their children with them.
| Nested Class Summary | |
|---|---|
(package private) class |
NwComponent.Mouse
Handling of mouse clicks on nodes: select/unselect and context menue with right click. |
| Nested classes/interfaces inherited from class javax.swing.JLabel |
|---|
JLabel.AccessibleJLabel |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
protected ImageIcon |
componentIcon
Gui element |
protected ImageIcon |
componentIconNeg
Gui element |
protected Element |
config
The XML element defining this component. |
private static int |
defaultSize
Default size in pixel of a component when the view is 100%. |
protected DrawPanel |
drawPanel
The panel this component is located in. |
protected VerinecStudio |
gui
Reference to the main application. |
private MouseListener |
mouse
|
private JPopupMenu |
popup
Gui element |
protected Point |
pos
The position can get negative, although we want the component to always apear on screen. |
private static Random |
random
Random number generator for id's. |
protected boolean |
selection
Gui element |
protected int |
type
The network type of this component. |
| Fields inherited from class javax.swing.JLabel |
|---|
labelFor |
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface javax.swing.SwingConstants |
|---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
protected |
NwComponent(Element config,
Point position,
float factor,
String iconPath,
VerinecStudio gui,
int type)
Initializes the size, position and the coordination of the component. |
| Method Summary | |
|---|---|
void |
addContextMenu(Action a)
Add an action to the context menu. |
void |
addContextMenuSeparator()
Adds a separator to the context menu. |
boolean |
changeIcon(String iconPath)
Changes the icon of the component. |
void |
delete()
Deletes the node and removes the subtree in the parents XML-Element. |
int |
getAbsX()
Return the real x position, not the screen position. |
int |
getAbsY()
Return the real y position, not the screen position. |
Element |
getConfig()
Returns the XML element of the object. |
static int |
getDefaultSize()
Returns the default size of the component. |
protected abstract Element |
getLayoutChild(Element config)
Extract the node gui information child from the configuration, add a default if necessary. |
protected static long |
getRandomId()
Get a positive random number to be used as id. |
int |
getType()
Get the network type of this component. |
void |
initialize()
Reset the component to initial state, that is remove all foreign listeners and menue entries. |
boolean |
isSelected()
Returns the selection state of the object. |
private boolean |
loadIcon(String iconPath)
Loads an icon for this component. |
void |
moveComponent(int dx,
int dy)
Moves the component to the new coordinates. |
void |
resizeComponent(float factor)
Resizes the component to the new size. |
static void |
resizeDefaultSize(float factor)
Scale the default size of a component. |
void |
setBounds(int x,
int y,
int w,
int h)
Set the position and size of the component on the panel. |
void |
setBounds(Rectangle r)
Set the position of the component. |
void |
setLocation(int x,
int y)
Set the position of the component. |
void |
setLocation(Point p)
Set the position of the component. |
void |
setSelected(boolean value)
Changes whether the node is currently selected or not. |
protected void |
showIcon(boolean inverted)
Load the icon if there is one. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private MouseListener mouse
protected Element config
protected DrawPanel drawPanel
protected VerinecStudio gui
protected int type
NetworkTypes.
protected Point pos
private JPopupMenu popup
protected ImageIcon componentIcon
protected ImageIcon componentIconNeg
private static Random random
protected boolean selection
private static int defaultSize
| Constructor Detail |
|---|
protected NwComponent(Element config,
Point position,
float factor,
String iconPath,
VerinecStudio gui,
int type)
config - The config element of the component.position - The top left corner point of the component. Will be ignored if the configuration contains layout information.factor - A ratio to the default size.iconPath - The location where the icon can be found or null for no icon.gui - The main application.type - The netowrk type id or 0 if node component.| Method Detail |
|---|
public void initialize()
public void addContextMenu(Action a)
a - The action to add.public void addContextMenuSeparator()
public int getType()
NetworkTypespublic static void resizeDefaultSize(float factor)
factor - the resize factor.public static int getDefaultSize()
public void setLocation(int x,
int y)
setLocation in class Componentx - Top left corner x coordinatey - Top left corner y coordinatepublic void setLocation(Point p)
setBounds(int, int, int, int).
setLocation in class Componentp - Top left corner.
public void setBounds(int x,
int y,
int w,
int h)
Prevents placing anything into the negative area of the pane, which
would make it unreachable.
Takes care of scaling the icon if width or height changes.
If a component needs to do anything when its moved, overwrite this method, but do not forget to call super.setBounds at some place.
setBounds in class Componentx - Top left corner x coordinatey - Top left corner y coordinatew - With of componenth - Height of componentpublic void setBounds(Rectangle r)
setBounds(int, int, int, int).
setBounds in class Componentr - Area of the component.public int getAbsX()
public int getAbsY()
protected abstract Element getLayoutChild(Element config)
config - The network xml object.
public void moveComponent(int dx,
int dy)
setBounds(int, int, int, int) internally to actually
move the icon on the panel.
dx - horizontal translation.dy - vertical translation.public void resizeComponent(float factor)
factor - the resize factor for the icon.public final void setSelected(boolean value)
value - the new selection state.public final boolean isSelected()
public final Element getConfig()
public void delete()
private boolean loadIcon(String iconPath)
iconPath - the path of the new icon.
public boolean changeIcon(String iconPath)
iconPath - the path of the new icon.
protected final void showIcon(boolean inverted)
componentIconNeg, otherwise the normal one componentIcon.
inverted - protected static long getRandomId()
|
Copyright © 2005 Verinec, DIUF | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||