Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

edu.stanford.genetics.treeview
Class DragGridPanel  view DragGridPanel download DragGridPanel.java

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byedu.stanford.genetics.treeview.DragGridPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ComponentListener, java.awt.event.ContainerListener, java.util.EventListener, java.awt.event.FocusListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable

public class DragGridPanel
extends javax.swing.JPanel
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.ComponentListener, java.awt.event.FocusListener, java.awt.event.ContainerListener

A Panel which is divided into a rectangular grid which the user can change. Components may be added to the grid, and may take up any rectangular set of cells within the grid. The user may drag the borders between the components to change the relative sizes of the cells, and thus the sizes of the components.


Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
(package private)  boolean adjustable
          Set to true if user is allowed to adjust sizes.
(package private)  int bheight
          Height of the draggable borders between Components.
(package private)  int bwidth
          Width of the draggable borders between Components.
(package private)  int coldrag
          column divider being dragged by mouse, or 0.
(package private)  java.awt.Component[][] components
          The components, organised in a grid.
(package private) static int crossHairCursor
          Cross-hair cursor
(package private)  int currentCursor
          current cursor type.
(package private)  int curscol
          column divider which cursor is over.
(package private)  int cursrow
          row divider which cursor is over.
(package private)  DragBar dragBar
           
(package private)  int focusheight
          Height of the focus rectangle round each control.
(package private)  int focuswidth
          Width of the focus rectangle round each control.
(package private) static int handCursor
          Hand cursor
(package private) static int leftRightCursor
          Left-right cursor
(package private)  int minheight
          Minimum height of a component.
(package private)  int minwidth
          Minimum width of a component.
(package private)  java.awt.Cursor originalCursor
          original cursor type.
(package private)  boolean resize
           
(package private)  int rowdrag
          row divider being dragged by mouse, or 0.
(package private) static boolean trace
           
(package private) static int upDownCursor
          Up-down cursor
(package private) static RCSVersion version
           
(package private)  int[] xpos
          The x positions of the dividing lines between cells.
(package private)  float[] xsizes
          The relative sizes of the cell columns.
(package private)  int[] ypos
          The y positions of the dividing lines between cells.
(package private)  float[] ysizes
          The relative sizes of the cell rows.
 
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.Container
 
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
DragGridPanel(int x, int y)
          Constructor.
 
Method Summary
 void addComponent(java.awt.Component comp, int x, int y, int width, int height)
          Add a component to occupy a rectangle of cells.
 void addComponent(java.awt.Component component, java.awt.Rectangle rectangle)
          Adds a component to the DragGridPanel
private  void addFocusListenerRecursively(java.awt.Component c)
          added by alok 9/12/2001
 void componentAdded(java.awt.event.ContainerEvent e)
          added by alok 9/12/2001
 void componentHidden(java.awt.event.ComponentEvent e)
          This method is called when the component is hidden.
 void componentMoved(java.awt.event.ComponentEvent e)
          This method is called when the component is moved.
 void componentRemoved(java.awt.event.ContainerEvent e)
          added by alok 9/12/2001
 void componentResized(java.awt.event.ComponentEvent e)
          Called when this container gets resized.
 void componentShown(java.awt.event.ComponentEvent e)
          This method is called when the component is made visible.
private  void debug(java.lang.String s)
           
private  void debug(java.lang.String s, java.lang.Object o)
           
 void doLayout()
          Recompute cell sizes from proportional sizes, and resize components.
private  boolean dragging()
           
private  void drawFocus(java.awt.Graphics g, int x, int y)
           
 void focusGained(java.awt.event.FocusEvent e)
          draws focus rectangle, added by alok 9/12/2001
 void focusLost(java.awt.event.FocusEvent e)
          This method is invoked when a component loses the keyboard focus.
 int getBorderHeight()
          BorderHeight - height of the draggable borders between Components.
 int getBorderWidth()
          BorderWidth - width of the draggable borders between Components.
 int getFocusHeight()
          FocusHeight - height of the focus rectangle round each control.
 int getFocusWidth()
          FocusWidth - width of the focus rectangle round each control.
 float[] getHeights()
          Get the proportional heights of each row.
 int getMinimumHeight()
          MinimumHeight - minimum height of a component.
 int getMinimumWidth()
          MinimumWidth - minimum width of a component.
 java.awt.Dimension getPreferredSize()
          added by alok 10/9/2001
 float[] getWidths()
          Get the proportional widths of each column.
 boolean isAdjustable()
          Adjustable - true if use is allowed to drag borders to change cell sizes.
 void mouseClicked(java.awt.event.MouseEvent e)
          This method is called when the mouse is clicked (pressed and released in short succession) on a component.
 void mouseDragged(java.awt.event.MouseEvent e)
          If a border is selected, change it's position.
 void mouseEntered(java.awt.event.MouseEvent e)
          This method is called when the mouse enters a component.
 void mouseExited(java.awt.event.MouseEvent e)
          This method is called when the mouse exits a component.
 void mouseMoved(java.awt.event.MouseEvent e)
          Change the mouse cursor if over a draggable border.
 void mousePressed(java.awt.event.MouseEvent e)
          Select a border to drag.
 void mouseReleased(java.awt.event.MouseEvent e)
          Stop dragging a border.
private  boolean onDragBorder(int x, int y)
          Work out if the mouse cursor is over a draggable border.
 void paintComponent(java.awt.Graphics g)
          Standard paint routine.
 void removeComponent(java.awt.Component comp)
          Remove a component.
private  void removeFocusListenerRecursively(java.awt.Component c)
          added by alok 9/12/2001
(package private)  void resizeComponents()
          Resize components into new grid.
 void setAdjustable(boolean on)
          Adjustable - true if use is allowed to drag borders to change cell sizes.
 void setBorderHeight(int height)
          BorderHeight - height of the draggable borders between Components.
 void setBorderWidth(int width)
          BorderWidth - width of the draggable borders between Components.
private  void setCursor(int newcursor)
          Switch cursor to indicate user can drag a border.
 void setFocusHeight(int height)
          FocusHeight - height of the focus rectangle round each control.
 void setFocusWidth(int width)
          FocusWidth - width of the focus rectangle round each control.
 void setHeights(float[] heights)
          Set the proportional heights of each row.
 void setMinimumHeight(int height)
          MinimumHeight - minimum height of a component.
 void setMinimumWidth(int width)
          MinimumWidth - minimum width of a component.
 void setWidths(float[] widths)
          Set the proportional widths of each column.
 java.lang.String toString()
          Standard toString returns "DragGridPanel[x][y]" and Panel info.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, 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, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, 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, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

version

static RCSVersion version

resize

boolean resize

adjustable

boolean adjustable
Set to true if user is allowed to adjust sizes.


bwidth

int bwidth
Width of the draggable borders between Components.


bheight

int bheight
Height of the draggable borders between Components.


minwidth

int minwidth
Minimum width of a component.


minheight

int minheight
Minimum height of a component.


focuswidth

int focuswidth
Width of the focus rectangle round each control.


focusheight

int focusheight
Height of the focus rectangle round each control.


components

java.awt.Component[][] components
The components, organised in a grid. If a component takes up more than one cell, it is placed in all the array positions it occupies.


xpos

int[] xpos
The x positions of the dividing lines between cells. xpos[0] is always 0, and xpos[no of columns] is the width of the Panel.


ypos

int[] ypos
The y positions of the dividing lines between cells. ypos[0] is always 0, and ypos[no of rows] is the height of the Panel.


xsizes

float[] xsizes
The relative sizes of the cell columns. Add up to 1.


ysizes

float[] ysizes
The relative sizes of the cell rows. Add up to 1.


coldrag

int coldrag
column divider being dragged by mouse, or 0.


rowdrag

int rowdrag
row divider being dragged by mouse, or 0.


curscol

int curscol
column divider which cursor is over.


cursrow

int cursrow
row divider which cursor is over.


originalCursor

java.awt.Cursor originalCursor
original cursor type.


currentCursor

int currentCursor
current cursor type.


leftRightCursor

static final int leftRightCursor
Left-right cursor

See Also:
Constant Field Values

upDownCursor

static final int upDownCursor
Up-down cursor

See Also:
Constant Field Values

crossHairCursor

static final int crossHairCursor
Cross-hair cursor

See Also:
Constant Field Values

handCursor

static final int handCursor
Hand cursor

See Also:
Constant Field Values

trace

static final boolean trace
See Also:
Constant Field Values

dragBar

DragBar dragBar
Constructor Detail

DragGridPanel

public DragGridPanel(int x,
                     int y)
Constructor.

Method Detail

isAdjustable

public boolean isAdjustable()
Adjustable - true if use is allowed to drag borders to change cell sizes.


setAdjustable

public void setAdjustable(boolean on)
Adjustable - true if use is allowed to drag borders to change cell sizes.


getBorderWidth

public int getBorderWidth()
BorderWidth - width of the draggable borders between Components.


setBorderWidth

public void setBorderWidth(int width)
BorderWidth - width of the draggable borders between Components.


getBorderHeight

public int getBorderHeight()
BorderHeight - height of the draggable borders between Components.


setBorderHeight

public void setBorderHeight(int height)
BorderHeight - height of the draggable borders between Components.


getMinimumWidth

public int getMinimumWidth()
MinimumWidth - minimum width of a component.


setMinimumWidth

public void setMinimumWidth(int width)
MinimumWidth - minimum width of a component.


getMinimumHeight

public int getMinimumHeight()
MinimumHeight - minimum height of a component.


setMinimumHeight

public void setMinimumHeight(int height)
MinimumHeight - minimum height of a component.


getFocusWidth

public int getFocusWidth()
FocusWidth - width of the focus rectangle round each control.


setFocusWidth

public void setFocusWidth(int width)
FocusWidth - width of the focus rectangle round each control.


getFocusHeight

public int getFocusHeight()
FocusHeight - height of the focus rectangle round each control.


setFocusHeight

public void setFocusHeight(int height)
FocusHeight - height of the focus rectangle round each control.


setWidths

public void setWidths(float[] widths)
Set the proportional widths of each column.


getWidths

public float[] getWidths()
Get the proportional widths of each column.


setHeights

public void setHeights(float[] heights)
Set the proportional heights of each row.


getHeights

public float[] getHeights()
Get the proportional heights of each row.


addComponent

public void addComponent(java.awt.Component component,
                         java.awt.Rectangle rectangle)
Adds a component to the DragGridPanel


addComponent

public void addComponent(java.awt.Component comp,
                         int x,
                         int y,
                         int width,
                         int height)
Add a component to occupy a rectangle of cells.


removeComponent

public void removeComponent(java.awt.Component comp)
Remove a component. Other components will use up the vacated cell(s) if possible.


getPreferredSize

public java.awt.Dimension getPreferredSize()
added by alok 10/9/2001


addFocusListenerRecursively

private void addFocusListenerRecursively(java.awt.Component c)
added by alok 9/12/2001


removeFocusListenerRecursively

private void removeFocusListenerRecursively(java.awt.Component c)
added by alok 9/12/2001


componentAdded

public void componentAdded(java.awt.event.ContainerEvent e)
added by alok 9/12/2001

Specified by:
componentAdded in interface java.awt.event.ContainerListener

componentRemoved

public void componentRemoved(java.awt.event.ContainerEvent e)
added by alok 9/12/2001

Specified by:
componentRemoved in interface java.awt.event.ContainerListener

doLayout

public void doLayout()
Recompute cell sizes from proportional sizes, and resize components.


paintComponent

public void paintComponent(java.awt.Graphics g)
Standard paint routine.


focusGained

public void focusGained(java.awt.event.FocusEvent e)
draws focus rectangle, added by alok 9/12/2001

Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost(java.awt.event.FocusEvent e)
Description copied from interface: java.awt.event.FocusListener
This method is invoked when a component loses the keyboard focus.

Specified by:
focusLost in interface java.awt.event.FocusListener

drawFocus

private void drawFocus(java.awt.Graphics g,
                       int x,
                       int y)

toString

public java.lang.String toString()
Standard toString returns "DragGridPanel[x][y]" and Panel info.


mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Change the mouse cursor if over a draggable border.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Select a border to drag.

Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Stop dragging a border.

Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Description copied from interface: java.awt.event.MouseListener
This method is called when the mouse is clicked (pressed and released in short succession) on a component.

Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Description copied from interface: java.awt.event.MouseListener
This method is called when the mouse enters a component.

Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Description copied from interface: java.awt.event.MouseListener
This method is called when the mouse exits a component.

Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
If a border is selected, change it's position.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

componentResized

public void componentResized(java.awt.event.ComponentEvent e)
Called when this container gets resized.

Specified by:
componentResized in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
Description copied from interface: java.awt.event.ComponentListener
This method is called when the component is moved.

Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentShown

public void componentShown(java.awt.event.ComponentEvent e)
Description copied from interface: java.awt.event.ComponentListener
This method is called when the component is made visible.

Specified by:
componentShown in interface java.awt.event.ComponentListener

componentHidden

public void componentHidden(java.awt.event.ComponentEvent e)
Description copied from interface: java.awt.event.ComponentListener
This method is called when the component is hidden.

Specified by:
componentHidden in interface java.awt.event.ComponentListener

resizeComponents

void resizeComponents()
Resize components into new grid.


onDragBorder

private boolean onDragBorder(int x,
                             int y)
Work out if the mouse cursor is over a draggable border. Only called if DragGridPanel is adjustable. Sets cursor shape, curscol and cursrow appropriately.


setCursor

private void setCursor(int newcursor)
Switch cursor to indicate user can drag a border. Only called if new cursor is different to current one.


dragging

private boolean dragging()

debug

private void debug(java.lang.String s,
                   java.lang.Object o)

debug

private void debug(java.lang.String s)