cz.cuni.jagrlib.gui
Class ModuleGUI

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by cz.cuni.jagrlib.gui.ModuleGUI
All Implemented Interfaces:
Undo, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible
Direct Known Subclasses:
GroupGUI, ModuleGUIImproved

public abstract class ModuleGUI
extends javax.swing.JPanel
implements Undo

Abstract class that cares about visual representation of a module.

Since:
0.25
See Also:
ModuleGUI.java, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int ACTION_MODULE_MOVE
           
static int ACTION_MODULE_RESIZE
           
protected  InfoPlug actualPlug
          Actual plug.
protected  java.awt.Rectangle drawRegion
           
 InfoModule info
          Information about module.
protected  javax.swing.JPopupMenu jPopupMenuActions
           
static int minHeight
          Module height in minimization mode.
static int minWidth
          Module width in minimization mode.
static int MM_DEFAULT
          No special mouse action.
static int MM_MOVE
          Module move.
static int MM_PLUG
          Plug move.
static int MM_RESIZEE
          Module resize - direction E (horizontal).
static int MM_RESIZES
          Module resize - direction S (vertical).
static int MM_RESIZESE
          Module resize - direction SE (upper right corner).
protected  int modeMove
          Mode of mouse move or mouse procedure in action.
protected static int moduleHeight
          Initial module height.
protected static int moduleWidth
          Initial module width.
 java.awt.event.MouseAdapter mouseClick
           
 java.awt.event.MouseMotionAdapter mouseMove
           
protected  int oldMouseX
          Old mouse position (X-coordinate).
protected  int oldMouseY
          Old mouse position (Y-coordinate).
protected  java.awt.Point oldPosition
           
protected  java.awt.Dimension oldSize
           
 ActionsUndo undoReg
          Undo/Redo object.
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ModuleGUI()
          Default constructor.
 
Method Summary
 java.awt.Dimension getMaxBounds()
          Gets max axis of module.
static int getModuleHeight()
          Initial height of module.
static int getModuleHeight(int _paramCount)
          Get initial height of module with parametrs.
static int getModuleWidth()
          Initial width of module.
protected abstract  int getMouseMode(int mx, int my)
          Returns mouse's mode.
protected  InfoPlug getPlugAtPoint(int x, int y)
          Finds a plug at the given screen position [x,y].
 void moveModule(int nx, int ny)
          Moves the module.
protected  void newModuleGeometry(boolean resize)
          Reflect changes depending on module's geometry..
 void newPlug(InfoPlug _infoP)
          Adds new plug (initial orientation: South).
 void redo(ActionsUndoReg action)
          Redo last on-done action.
protected abstract  void removeModule()
          Deletes module.
protected  void resizePlug(PlugGUI p)
          Resizes the window (Plug has to adapt).
static void setModuleHeight(int _height)
          Set initial height of a module.
protected  void setModuleType()
          Sets plugs for the module.
static void setModuleWidth(int _width)
          Set initial width of a module.
protected abstract  void setParams()
          Sets parameters of the module.
 void setUndoObj(ActionsUndo _undo)
          Sets undo object for module and plugs.
protected  void this_ancestorRemoved(javax.swing.event.AncestorEvent e)
          Deleting of composition.
protected  void this_componentMoved(java.awt.event.ComponentEvent e)
          Module moved.
protected  void this_componentResized(java.awt.event.ComponentEvent e)
          Module was resized: Plugs' positions need to be recomputed.
protected  void this_mouseClicked(java.awt.event.MouseEvent e)
          Mouse click.
protected  void this_mouseDragged(java.awt.event.MouseEvent e)
          Mouse drag:
mode MM_MOVE - move module.
protected  void this_mouseMoved(java.awt.event.MouseEvent e)
          Mouse move:
mode MM_DEFAULT - sets cursor on normal cursor.
protected  void this_mousePressed(java.awt.event.MouseEvent e)
          Mouse pressed.
protected  void this_mouseReleased(java.awt.event.MouseEvent e)
          Mouse released.
 void undo(ActionsUndoReg action)
          Undo last action.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintComponent, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printComponent, printChildren, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, checkImage, checkImage, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

info

public InfoModule info
Information about module.


actualPlug

protected InfoPlug actualPlug
Actual plug.


oldMouseX

protected int oldMouseX
Old mouse position (X-coordinate).


oldMouseY

protected int oldMouseY
Old mouse position (Y-coordinate).


oldPosition

protected java.awt.Point oldPosition

oldSize

protected java.awt.Dimension oldSize

drawRegion

protected java.awt.Rectangle drawRegion

MM_DEFAULT

public static final int MM_DEFAULT
No special mouse action.

See Also:
Constant Field Values

MM_MOVE

public static final int MM_MOVE
Module move.

See Also:
Constant Field Values

MM_PLUG

public static final int MM_PLUG
Plug move.

See Also:
Constant Field Values

MM_RESIZEE

public static final int MM_RESIZEE
Module resize - direction E (horizontal).

See Also:
Constant Field Values

MM_RESIZES

public static final int MM_RESIZES
Module resize - direction S (vertical).

See Also:
Constant Field Values

MM_RESIZESE

public static final int MM_RESIZESE
Module resize - direction SE (upper right corner).

See Also:
Constant Field Values

modeMove

protected int modeMove
Mode of mouse move or mouse procedure in action.


moduleWidth

protected static int moduleWidth
Initial module width.


moduleHeight

protected static int moduleHeight
Initial module height.


minWidth

public static int minWidth
Module width in minimization mode.


minHeight

public static int minHeight
Module height in minimization mode.


undoReg

public ActionsUndo undoReg
Undo/Redo object.


ACTION_MODULE_MOVE

public static final int ACTION_MODULE_MOVE
See Also:
Constant Field Values

ACTION_MODULE_RESIZE

public static final int ACTION_MODULE_RESIZE
See Also:
Constant Field Values

jPopupMenuActions

protected javax.swing.JPopupMenu jPopupMenuActions

mouseClick

public java.awt.event.MouseAdapter mouseClick

mouseMove

public java.awt.event.MouseMotionAdapter mouseMove
Constructor Detail

ModuleGUI

public ModuleGUI()
Default constructor.

Method Detail

setModuleType

protected void setModuleType()
Sets plugs for the module.


getPlugAtPoint

protected InfoPlug getPlugAtPoint(int x,
                                  int y)
Finds a plug at the given screen position [x,y].

Parameters:
x - X-coordinate.
y - Y-coordinate.
Returns:
Plug's key or null.

setParams

protected abstract void setParams()
Sets parameters of the module.


newPlug

public void newPlug(InfoPlug _infoP)
Adds new plug (initial orientation: South).

Parameters:
_infoP - Information about plug.

getMouseMode

protected abstract int getMouseMode(int mx,
                                    int my)
Returns mouse's mode.

Parameters:
mx - X-coordinate of mouse.
my - Y-coordinate of mouse.
Returns:
Mouse mode.

removeModule

protected abstract void removeModule()
Deletes module.


resizePlug

protected void resizePlug(PlugGUI p)
Resizes the window (Plug has to adapt).


this_mouseDragged

protected void this_mouseDragged(java.awt.event.MouseEvent e)
Mouse drag:
mode MM_MOVE - move module.
mode MM_RESIZEE - resize East.
mode MM_RESIZES - resize South.
mode MM_RESIZESE - resize SouthEast.


this_mousePressed

protected void this_mousePressed(java.awt.event.MouseEvent e)
Mouse pressed.
left button - select/unselect module.
SHIFT + left button - select/unselect module.
it doesn't change selecting of others modules.


this_mouseReleased

protected void this_mouseReleased(java.awt.event.MouseEvent e)
Mouse released.


this_mouseClicked

protected void this_mouseClicked(java.awt.event.MouseEvent e)
Mouse click.


this_mouseMoved

protected void this_mouseMoved(java.awt.event.MouseEvent e)
Mouse move:
mode MM_DEFAULT - sets cursor on normal cursor.
mode MM_MOVE - sets cursor on move cursor.
mode MM_PLUG - sets cursor on hand cursor and sets ToolTip of Plug.
mode MM_RESIZEE - sets cursor on resizeE cursor.
mode MM_RESIZES - sets cursor on resizeS cursor.
mode MM_RESIZESE - sets cursor on resizeSE cursor.


newModuleGeometry

protected void newModuleGeometry(boolean resize)
Reflect changes depending on module's geometry..

Parameters:
resize - Module was resized? (resize its interior)

this_componentResized

protected void this_componentResized(java.awt.event.ComponentEvent e)
Module was resized: Plugs' positions need to be recomputed. Changes bound of work space.


this_componentMoved

protected void this_componentMoved(java.awt.event.ComponentEvent e)
Module moved. Changes bound of work space.


this_ancestorRemoved

protected void this_ancestorRemoved(javax.swing.event.AncestorEvent e)
Deleting of composition.


moveModule

public void moveModule(int nx,
                       int ny)
Moves the module.

Parameters:
nx - Relative x coordinate.
ny - Relative y coordainte.

getMaxBounds

public java.awt.Dimension getMaxBounds()
Gets max axis of module.

Returns:
(xmax, ymax).

undo

public void undo(ActionsUndoReg action)
Undo last action.

Specified by:
undo in interface Undo
Parameters:
action - do this action.

redo

public void redo(ActionsUndoReg action)
Redo last on-done action.

Specified by:
redo in interface Undo
Parameters:
action - do this action.

setUndoObj

public void setUndoObj(ActionsUndo _undo)
Sets undo object for module and plugs.

Parameters:
_undo - new ActionsUndo object.

getModuleWidth

public static int getModuleWidth()
Initial width of module.


getModuleHeight

public static int getModuleHeight()
Initial height of module.


getModuleHeight

public static int getModuleHeight(int _paramCount)
Get initial height of module with parametrs.

Parameters:
_paramCount - Number of parameters.
Returns:
Module height in pixels.

setModuleWidth

public static void setModuleWidth(int _width)
Set initial width of a module.

Parameters:
_width - new value for moduleWidth.

setModuleHeight

public static void setModuleHeight(int _height)
Set initial height of a module.

Parameters:
_height - new value for moduleHeight.