org.formaria.editor.project.pages
Class ComponentSizer

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.formaria.editor.project.pages.ComponentSizer
All Implemented Interfaces:
java.awt.event.FocusListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener

public class ComponentSizer
extends javax.swing.JComponent
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.FocusListener

Provides a set of grab handles to visually manipulate a component. In response to grabbing one of the handles the component is resize or moved as needed.

Copyright (c) Formaria Ltd., 1998-2003

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
 
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
ComponentSizer(EditorProject project, PagePanel cpp)
           
 
Method Summary
 void adjustBounds(java.awt.Rectangle r)
          Adjust this component and its children so that the specified rectangle is highlighted and force any listeneing components to update themselves
 void focusGained(java.awt.event.FocusEvent e)
           
 void focusLost(java.awt.event.FocusEvent e)
           
 Page getPage()
          Get the page that owns this componet
protected  PageDesigner getPageHolder()
           
 PageResource getPageResource()
          Get the screen with which the highlighted component is associated.
 java.awt.Dimension getStartSize()
          Get the size at the start of the manipulation
 java.awt.Component getTarget()
          Return the monitored component
 void highlightComponent(GuidePane owner, PageResource page, java.awt.Component comp)
          Add this Sizer component to the container so that the specified component appears to be selected
 boolean isEnabled()
           
 boolean isFocusable()
           
 boolean isIncluded()
          Is the component included?
 boolean isLocked()
          Is the component locked?
 boolean isRepeated()
          Is the component repeated?
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
          Dynamically resize the component in response to mouse drags.
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void paintComponent(java.awt.Graphics g)
           
 void processMousePressed(java.awt.event.MouseEvent e, boolean forwardEvent)
           
 void remove()
          Remove the sizer from the parent and hide
 void repositionSizer()
          Updates the sizer to match the component
 void repositionTarget()
          Updates the targets position to match that of the sizer
 void resetStartSize()
          Reset the start size to that of this sizer
 void rightButtonClicked(java.awt.event.MouseEvent evt)
           
 void setBounds(java.awt.Rectangle r)
          Adjust this component and its children so that the specified rectangle is highlighted
 void setDragNewComponent(boolean start)
           
 void setLocked(boolean state)
          Set the locked state of this component
 void setSizerListener(SizerListener sListener)
          Add a listener for the size changes
 
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, paintChildren, 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, 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, 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
 

Constructor Detail

ComponentSizer

public ComponentSizer(EditorProject project,
                      PagePanel cpp)
Method Detail

paintComponent

public void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

setSizerListener

public void setSizerListener(SizerListener sListener)
Add a listener for the size changes

Parameters:
sListener -

highlightComponent

public void highlightComponent(GuidePane owner,
                               PageResource page,
                               java.awt.Component comp)
Add this Sizer component to the container so that the specified component appears to be selected

Parameters:
comp - the selected component

remove

public void remove()
Remove the sizer from the parent and hide


isLocked

public boolean isLocked()
Is the component locked?

Returns:
true if the component is locked

isIncluded

public boolean isIncluded()
Is the component included?

Returns:
true if the component is included

isRepeated

public boolean isRepeated()
Is the component repeated?

Returns:
true if the component is repeated

setLocked

public void setLocked(boolean state)
Set the locked state of this component

Parameters:
true - to lock the component

getTarget

public java.awt.Component getTarget()
Return the monitored component

Returns:

getPageResource

public PageResource getPageResource()
Get the screen with which the highlighted component is associated.

Returns:
the screen that owns the highlighted control

getStartSize

public java.awt.Dimension getStartSize()
Get the size at the start of the manipulation

Returns:
the size

resetStartSize

public void resetStartSize()
Reset the start size to that of this sizer


adjustBounds

public void adjustBounds(java.awt.Rectangle r)
Adjust this component and its children so that the specified rectangle is highlighted and force any listeneing components to update themselves

Parameters:
r - the new size

repositionTarget

public void repositionTarget()
Updates the targets position to match that of the sizer


repositionSizer

public void repositionSizer()
Updates the sizer to match the component


setBounds

public void setBounds(java.awt.Rectangle r)
Adjust this component and its children so that the specified rectangle is highlighted

Overrides:
setBounds in class java.awt.Component
Parameters:
r - the new size

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

processMousePressed

public void processMousePressed(java.awt.event.MouseEvent e,
                                boolean forwardEvent)

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

rightButtonClicked

public void rightButtonClicked(java.awt.event.MouseEvent evt)

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Dynamically resize the component in response to mouse drags.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Parameters:
e -

getPage

public Page getPage()
Get the page that owns this componet

Returns:

getPageHolder

protected PageDesigner getPageHolder()

focusGained

public void focusGained(java.awt.event.FocusEvent e)
Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost(java.awt.event.FocusEvent e)
Specified by:
focusLost in interface java.awt.event.FocusListener

isFocusable

public boolean isFocusable()
Overrides:
isFocusable in class java.awt.Component

isEnabled

public boolean isEnabled()
Overrides:
isEnabled in class java.awt.Component

setDragNewComponent

public void setDragNewComponent(boolean start)