org.formaria.swing
Class Shape

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.formaria.swing.Shape
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, ShapeGenerator

public class Shape
extends javax.swing.JComponent
implements ShapeGenerator

Draws a simple shape

Copyright (c) Formaria Ltd., 2008, This software is licensed under the GNU Public License (GPL), please see license.txt for more details. If you make commercial use of this software you must purchase a commercial license from formaria.

$Revision: 1.12 $

See Also:
Serialized Form

Nested Class Summary
 
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 BOLD_HORIZONTAL
          A bold horizontal line
static int BOLD_VERTICAL
          A bold vertical line
static int DIAMOND
          An outline diamond
static int ELLIPSE
          An ellipse outline
static int EXTRABOLD_HORIZONTAL
          An extra bold horizontal line
static int EXTRABOLD_VERTICAL
          An extra bold vertical line
static int LEFT_TOP_LINE
          A line from the top left to the bottom right
protected  int mode
          the drawing / shape mode
static int NORMAL_HORIZONTAL
          A vertical line
static int NORMAL_VERTICAL
          A vertical line
static int ORTHO_LINE
          A vertical or horizontal line
static int RECTANGLE
          A rectangle shape
static int RIGHT_TOP_LINE
          A line from the top right to the bottom left
static int SOLID_DIAMOND
          A filled diamond
static int SOLID_ELLIPSE
          A filled ellipse
static int THIN_HORIZONTAL
          A thin horizontal line
static int THIN_VERTICAL
          A thin vertical line
static int USER
          A user defined shape drawn in outline
static int USER_FILL
          A user defined shape, filled
static int USER_FILL_DRAW
          A user defined shape drawn and filled
protected  java.awt.Shape userShape
          The user defined shape
 
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
Shape()
          Constructor for a new Shape
 
Method Summary
 int getMode()
          Get shape identifier.
 java.awt.Shape getShape()
          Get a shape
 boolean isSelected()
           
 void paintChildren(java.awt.Graphics g)
          Paint the child components, this method just consumes the call without doing anything
 void paintComponent(java.awt.Graphics g)
          Fills the shape with the background color
 void setMode(int shapeId)
          Get shape identifier.
 void setSelected(boolean selected)
           
 void setShape(java.awt.Shape s, boolean fill)
          Set a user defiend shape.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, 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, updateUI
 
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, 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, 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, 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

mode

protected int mode
the drawing / shape mode


RECTANGLE

public static final int RECTANGLE
A rectangle shape

See Also:
Constant Field Values

ORTHO_LINE

public static final int ORTHO_LINE
A vertical or horizontal line

See Also:
Constant Field Values

EXTRABOLD_HORIZONTAL

public static final int EXTRABOLD_HORIZONTAL
An extra bold horizontal line

See Also:
Constant Field Values

BOLD_HORIZONTAL

public static final int BOLD_HORIZONTAL
A bold horizontal line

See Also:
Constant Field Values

NORMAL_HORIZONTAL

public static final int NORMAL_HORIZONTAL
A vertical line

See Also:
Constant Field Values

THIN_HORIZONTAL

public static final int THIN_HORIZONTAL
A thin horizontal line

See Also:
Constant Field Values

EXTRABOLD_VERTICAL

public static final int EXTRABOLD_VERTICAL
An extra bold vertical line

See Also:
Constant Field Values

BOLD_VERTICAL

public static final int BOLD_VERTICAL
A bold vertical line

See Also:
Constant Field Values

NORMAL_VERTICAL

public static final int NORMAL_VERTICAL
A vertical line

See Also:
Constant Field Values

THIN_VERTICAL

public static final int THIN_VERTICAL
A thin vertical line

See Also:
Constant Field Values

RIGHT_TOP_LINE

public static final int RIGHT_TOP_LINE
A line from the top right to the bottom left

See Also:
Constant Field Values

LEFT_TOP_LINE

public static final int LEFT_TOP_LINE
A line from the top left to the bottom right

See Also:
Constant Field Values

ELLIPSE

public static final int ELLIPSE
An ellipse outline

See Also:
Constant Field Values

SOLID_ELLIPSE

public static final int SOLID_ELLIPSE
A filled ellipse

See Also:
Constant Field Values

SOLID_DIAMOND

public static final int SOLID_DIAMOND
A filled diamond

See Also:
Constant Field Values

DIAMOND

public static final int DIAMOND
An outline diamond

See Also:
Constant Field Values

USER

public static final int USER
A user defined shape drawn in outline

See Also:
Constant Field Values

USER_FILL

public static final int USER_FILL
A user defined shape, filled

See Also:
Constant Field Values

USER_FILL_DRAW

public static final int USER_FILL_DRAW
A user defined shape drawn and filled

See Also:
Constant Field Values

userShape

protected java.awt.Shape userShape
The user defined shape

Constructor Detail

Shape

public Shape()
Constructor for a new Shape

Method Detail

paintComponent

public void paintComponent(java.awt.Graphics g)
Fills the shape with the background color

Overrides:
paintComponent in class javax.swing.JComponent
Parameters:
g - the graphics context

paintChildren

public void paintChildren(java.awt.Graphics g)
Paint the child components, this method just consumes the call without doing anything

Overrides:
paintChildren in class javax.swing.JComponent
Parameters:
g - the graphics context

setMode

public void setMode(int shapeId)
Get shape identifier. The ID is an enumerated constant

Parameters:
shapeId - the new shape ID.

getMode

public int getMode()
Get shape identifier.

Returns:
the enumerated constant for this shape

getShape

public java.awt.Shape getShape()
Get a shape

Specified by:
getShape in interface ShapeGenerator
Returns:
the generated shape

setShape

public void setShape(java.awt.Shape s,
                     boolean fill)
Set a user defiend shape. The shapoe should define a close area is the mode is set for filling

Parameters:
s - the user shape
fill - true to fill the shape

setSelected

public void setSelected(boolean selected)
Parameters:
selected - the selected to set

isSelected

public boolean isSelected()
Returns:
the selected