cds.gui
Class CIcon

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended bycds.gui.CIcon
All Implemented Interfaces:
javax.swing.Icon, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

class CIcon
extends javax.swing.JComponent
implements javax.swing.Icon

Class defining the icon to add to the tabs. This icon is made of several squares


Nested Class Summary
 
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
private  int betweenCursor
           
static int BOTTOM_CURSOR
           
private  java.awt.Color[] col
           
private static int cursorWidth
           
static int LEFT_CURSOR
           
static int NO_CURSOR
           
private  java.awt.Rectangle rectIcon
           
static int RIGHT_CURSOR
           
private static int size
           
static int TOP_CURSOR
           
private  int x
           
private  int y
           
 
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
CIcon(java.awt.Color[] col)
          Constructor.
 
Method Summary
 boolean contains(int x, int y)
          returns true if the coordinates x,y are inside the icon
private  void drawCursor(java.awt.Graphics g, int placement, java.awt.Rectangle r, int betweenCursor)
           
 int getIconHeight()
           
 int getIconWidth()
           
 int inSquare(int x, int y)
          returns the square number in which the cursor position is.
 void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
          Paint the icon
 void setBetweenCursor(int pos)
          Sets the type of the 'between cursor'
 void setColor(java.awt.Color[] c)
           
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, 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, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, 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, 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, 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, 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

NO_CURSOR

public static final int NO_CURSOR
See Also:
Constant Field Values

LEFT_CURSOR

public static final int LEFT_CURSOR
See Also:
Constant Field Values

RIGHT_CURSOR

public static final int RIGHT_CURSOR
See Also:
Constant Field Values

TOP_CURSOR

public static final int TOP_CURSOR
See Also:
Constant Field Values

BOTTOM_CURSOR

public static final int BOTTOM_CURSOR
See Also:
Constant Field Values

size

private static final int size
See Also:
Constant Field Values

cursorWidth

private static final int cursorWidth
See Also:
Constant Field Values

col

private java.awt.Color[] col

x

private int x

y

private int y

rectIcon

private java.awt.Rectangle rectIcon

betweenCursor

private int betweenCursor
Constructor Detail

CIcon

public CIcon(java.awt.Color[] col)
Constructor. The array specify the number and the color of the squares

Parameters:
col - color of the icon
Method Detail

getIconHeight

public int getIconHeight()
Specified by:
getIconHeight in interface javax.swing.Icon

getIconWidth

public int getIconWidth()
Specified by:
getIconWidth in interface javax.swing.Icon

setColor

public void setColor(java.awt.Color[] c)

paintIcon

public void paintIcon(java.awt.Component c,
                      java.awt.Graphics g,
                      int x,
                      int y)
Paint the icon

Specified by:
paintIcon in interface javax.swing.Icon
Parameters:
c - the TabbedPane component. it allows also to get the rectangle defining the tab
g - the Graphics object to draw on the TabbedPane
x - X position of the icon
y - Y position of the icon

drawCursor

private void drawCursor(java.awt.Graphics g,
                        int placement,
                        java.awt.Rectangle r,
                        int betweenCursor)

setBetweenCursor

public void setBetweenCursor(int pos)
Sets the type of the 'between cursor'

Parameters:
pos - LEFT_CURSOR, RIGHT_CURSOR, or NO_CURSOR

contains

public boolean contains(int x,
                        int y)
returns true if the coordinates x,y are inside the icon

Parameters:
x - x coordinate to check
y - y coordonate to check
Returns:
true if the point is in the icon, false otherwise

inSquare

public int inSquare(int x,
                    int y)
returns the square number in which the cursor position is. It is assumed that the cursor is in the icon (not tested again)

Parameters:
x - x position of the cursor
y - y position of the cursor (not used)
Returns:
the index of the square (beginning at 0)