renderable
Class Comment

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 renderable.Comment
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class Comment
extends javax.swing.JPanel

Comment stores and displays user-generated text that can be edited by the user. Comments begin in “editable” state. Comments are associated with a parent source of type JComponent. It should "tag" along with that component. Note, however, that this feature should be ensured by the parent source. The parent source can guarantee this by invoking the methods setPosition, translatePosition, and setParent when appropriate. text : String //the text stored in this Comment and edited by the user

See Also:
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
(package private) static int DEFAULT_HEIGHT
           
(package private) static int DEFAULT_WIDTH
           
(package private) static int FONT_SIZE
           
(package private) static int MINIMUM_HEIGHT
           
(package private) static int MINIMUM_WIDTH
           
 
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
Comment(java.lang.String initText, CommentSource source, java.awt.Color borderColor, double zoom)
          Constructs a Comment with belonging to source, with text of initText, and initial zoom The comment's borders will have the color borderColor.
 
Method Summary
 void delete()
          Handle the removal of this comment from its comment source
 CommentArrow getArrow()
          access to the comment arrow object
(package private)  java.awt.Color getBackgroundColor()
          Returns the comment background color
(package private)  java.awt.Color getBorderColor()
          Returns the borderColor of this comment
(package private)  CommentLabel getCommentLabel()
          returns the commentLabel for this comment
 int getCommentLabelWidth()
          Returns the width of the comment label for this comment
(package private)  CommentSource getCommentSource()
          returns the CommentSource for this comment
(package private)  int getMargin()
           
(package private)  int getMyHeight()
           
(package private)  int getMyWidth()
           
 java.lang.String getSaveString()
          Returns the save String for this comment.
 java.lang.String getText()
           
 boolean isConstrainComment()
          returns whether this comment should be constrained to its parent's bounds
(package private)  boolean isPressed()
           
(package private)  boolean isResizing()
           
static Comment loadComment(org.w3c.dom.NodeList commentChildren, RenderableBlock rb)
          Loads the comment from a NodeList of comment parts
static void main(java.lang.String[] args)
          Test application for comment.
 void paint(java.awt.Graphics g)
          overrides javax.Swing.JPanel.paint()
 void reformComment()
          Recalculate the shape of this comment
 void setConstrainComment(boolean constrainComment)
          sets whether this comment should be constrained to its parent's bounds
 void setLocation(int x, int y)
          moves this to a new position at (x,y) but not outside of its parent Container
 void setLocation(java.awt.Point p)
          moves this to a new position at (x,y) but not outside of its parent Container
(package private)  void setMargin(int margin)
           
(package private)  void setMyHeight(int height)
           
(package private)  void setMyWidth(int width)
           
 void setParent(java.awt.Container newparent)
          Moves this comment from it's old parent Container to a new Container.
 void setParent(java.awt.Container newparent, java.lang.Object constraints)
          Moves this comment from it's old parent Container to a new Container with given constrain.
(package private)  void setPressed(boolean pressed)
           
(package private)  void setResizing(boolean resizing)
           
 void setText(java.lang.String text)
           
 void setVisible(boolean b)
          Over rides the standard setVisible to make sure the arrow's visibility is also set.
 void setZoomLevel(double newZoom)
          Set a new zoom level, changes font size, label size, location, shape of comment, and arrow for this comment
 void showOnTop()
          Bumps the comment to top of ZOrder of parent if parent exists
 java.lang.String toString()
          String representation of this
 void translatePosition(int dx, int dy)
           
 void update()
          Updates the comment and commentLabel
 void update(boolean visibleState)
          Sets the active state of the commentLabel and updates the comment and commentLabel
 
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, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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, 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, 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, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FONT_SIZE

static int FONT_SIZE

MINIMUM_WIDTH

static int MINIMUM_WIDTH

MINIMUM_HEIGHT

static int MINIMUM_HEIGHT

DEFAULT_WIDTH

static int DEFAULT_WIDTH

DEFAULT_HEIGHT

static int DEFAULT_HEIGHT
Constructor Detail

Comment

public Comment(java.lang.String initText,
               CommentSource source,
               java.awt.Color borderColor,
               double zoom)
Constructs a Comment with belonging to source, with text of initText, and initial zoom The comment's borders will have the color borderColor. Note that initializing a comment only constructs all of the necessary structures. To graphically display a comment, the implementor must then add the comment using the proper Swing methods OR through the convenience method Comment.setParent()

Parameters:
initText, - initial text of comment
source, - where the comment is linked to.
borderColor - the color that the border of the comment should be
zoom - initial zoom
Method Detail

delete

public void delete()
Handle the removal of this comment from its comment source


getCommentSource

CommentSource getCommentSource()
returns the CommentSource for this comment

Returns:

getCommentLabel

CommentLabel getCommentLabel()
returns the commentLabel for this comment

Returns:

getCommentLabelWidth

public int getCommentLabelWidth()
Returns the width of the comment label for this comment

Returns:

update

public void update()
Updates the comment and commentLabel


update

public void update(boolean visibleState)
Sets the active state of the commentLabel and updates the comment and commentLabel

Parameters:
visibleState -

setZoomLevel

public void setZoomLevel(double newZoom)
Set a new zoom level, changes font size, label size, location, shape of comment, and arrow for this comment

Parameters:
newZoom -

reformComment

public void reformComment()
Recalculate the shape of this comment


getSaveString

public java.lang.String getSaveString()
Returns the save String for this comment.

Returns:

loadComment

public static Comment loadComment(org.w3c.dom.NodeList commentChildren,
                                  RenderableBlock rb)
Loads the comment from a NodeList of comment parts

Parameters:
commentChildren -
rb -
Returns:

paint

public void paint(java.awt.Graphics g)
overrides javax.Swing.JPanel.paint()

Overrides:
paint in class javax.swing.JComponent

getText

public java.lang.String getText()
Returns:
this.text.trim()

setText

public void setText(java.lang.String text)
Parameters:
text -

setLocation

public void setLocation(int x,
                        int y)
moves this to a new position at (x,y) but not outside of its parent Container

Overrides:
setLocation in class java.awt.Component

setLocation

public void setLocation(java.awt.Point p)
moves this to a new position at (x,y) but not outside of its parent Container

Overrides:
setLocation in class java.awt.Component

translatePosition

public void translatePosition(int dx,
                              int dy)
Parameters:
dx -
dy -

setParent

public void setParent(java.awt.Container newparent)
Moves this comment from it's old parent Container to a new Container. Removal and addition applies only if the Containers are non-null

Parameters:
newparent -

setVisible

public void setVisible(boolean b)
Over rides the standard setVisible to make sure the arrow's visibility is also set.

Overrides:
setVisible in class javax.swing.JComponent

setParent

public void setParent(java.awt.Container newparent,
                      java.lang.Object constraints)
Moves this comment from it's old parent Container to a new Container with given constrain.

Parameters:
newparent -

toString

public java.lang.String toString()
String representation of this

Overrides:
toString in class java.awt.Component

showOnTop

public void showOnTop()
Bumps the comment to top of ZOrder of parent if parent exists


getBackgroundColor

java.awt.Color getBackgroundColor()
Returns the comment background color

Returns:

getBorderColor

java.awt.Color getBorderColor()
Returns the borderColor of this comment

Returns:

getArrow

public CommentArrow getArrow()
access to the comment arrow object

Returns:

getMyWidth

int getMyWidth()
Returns:
the width

setMyWidth

void setMyWidth(int width)
Parameters:
width - the width to set

getMyHeight

int getMyHeight()
Returns:
the height

setMyHeight

void setMyHeight(int height)
Parameters:
height - the height to set

getMargin

int getMargin()
Returns:
the margin

setMargin

void setMargin(int margin)
Parameters:
margin - the margin to set

main

public static void main(java.lang.String[] args)
Test application for comment.

Parameters:
args -

isPressed

boolean isPressed()
Returns:
the pressed true, if this comment has been pressed

setPressed

void setPressed(boolean pressed)
Parameters:
pressed - true if this comment has been pressed

isResizing

boolean isResizing()
Returns:
the resizing, true if this comment is being resized

setResizing

void setResizing(boolean resizing)
Parameters:
resizing - true if this comment is being resized

isConstrainComment

public boolean isConstrainComment()
returns whether this comment should be constrained to its parent's bounds

Returns:
the constrainComment

setConstrainComment

public void setConstrainComment(boolean constrainComment)
sets whether this comment should be constrained to its parent's bounds

Parameters:
constrainComment - the constrainComment to set