ca.sqlpower.architect.swingui
Class PlayPenComponent

java.lang.Object
  extended by ca.sqlpower.architect.swingui.PlayPenComponent
All Implemented Interfaces:
Selectable
Direct Known Subclasses:
ContainerPane, Relationship, UsageComponent

public abstract class PlayPenComponent
extends java.lang.Object
implements Selectable

PlayPenComponent is the base class for a component that can live in the playpen's content pane.


Field Summary
protected  java.awt.Color backgroundColor
           
protected  boolean componentPreviouslySelected
           
protected  java.awt.Color foregroundColor
           
protected  boolean selected
          A selected component is one that the user has clicked on.
 
Constructor Summary
protected PlayPenComponent(PlayPenContentPane parent)
           
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Adds a property change listener to the existing list.
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener l)
          Adds a property change listener for a specific property.
 void addSelectionListener(SelectionListener l)
           
 boolean contains(java.awt.Point p)
           
 void firePropertyChange(java.beans.PropertyChangeEvent e)
           
protected  void firePropertyChange(java.lang.String propName, java.lang.Object oldValue, java.lang.Object newValue)
          Notifies property change listeners of a property change event.
protected  void fireSelectionEvent(SelectionEvent e)
           
 java.awt.Color getBackgroundColor()
           
 java.awt.Rectangle getBounds()
          Returns a copy of this component's bounding rectangle.
 java.awt.Rectangle getBounds(java.awt.Rectangle r)
          Sets the given rectangle to be identical to this component's bounding box.
 java.awt.Font getFont()
           
 java.awt.FontMetrics getFontMetrics(java.awt.Font f)
           
 java.awt.font.FontRenderContext getFontRenderContext()
           
 java.awt.Color getForegroundColor()
           
 int getHeight()
           
 java.awt.Insets getInsets()
           
 java.awt.Point getLocation()
           
 java.awt.Point getLocation(java.awt.Point p)
          Copies this component's location into the given point object.
abstract  java.lang.Object getModel()
           
abstract  java.lang.String getName()
          Returns the user-visible name for this component--often the same as getModel().getName(), but this depends entirely on the subclass's idea of what in the model constitutes its name.
 PlayPenContentPane getParent()
           
 PlayPen getPlayPen()
           
 javax.swing.JPopupMenu getPopup()
          Returns a component specific popup menu.
 java.awt.Point getPreferredLocation()
          The revalidate() call uses this to determine the component's correct location.
 java.awt.Dimension getPreferredSize()
           
 java.awt.Dimension getSize()
           
 java.lang.String getToolTipText()
           
 PlayPenComponentUI getUI()
           
 int getWidth()
           
 int getX()
           
 int getY()
           
abstract  void handleMouseEvent(java.awt.event.MouseEvent evt)
          Performs the component specific actions for the given MouseEvent.
 boolean isOpaque()
           
 boolean isSelected()
          See selected.
 void paint(java.awt.Graphics2D g2)
           
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Removes a specific property change listener from the existing list.
 void removeSelectionListener(SelectionListener l)
           
 void repaint()
          Forwards to repaint(Rectangle).
 void repaint(long tm, int x, int y, int width, int height)
          Tells the owning PlayPen to repaint the given region.
 void repaint(java.awt.Rectangle r)
          Forwards to repaint(long,int,int,int,int).
 void revalidate()
          Translates this request into a call to PlayPen.repaint(Rectangle).
 void setBackgroundColor(java.awt.Color c)
           
 void setBounds(int x, int y, int width, int height)
          See setBoundsImpl.
protected  void setBoundsImpl(int x, int y, int width, int height)
          Updates the bounds of this component, then issues a repaint to the PlayPen which covers the old bounds of this component.
 void setForegroundColor(java.awt.Color c)
           
 void setInsets(java.awt.Insets insets)
           
 void setLocation(int x, int y)
          Updates the on-screen location of this component.
 void setLocation(java.awt.Point point)
          Updates the on-screen location of this component.
 void setOpaque(boolean opaque)
           
 void setSelected(boolean isSelected, int multiSelectType)
          Tells this component it is selected or deselected.
 void setSize(java.awt.Dimension size)
           
 void setToolTipText(java.lang.String toolTipText)
           
 void setUI(PlayPenComponentUI ui)
           
 void showPopup(java.awt.Point p)
          Shows the component's popup menu on the PlayPen that owns this component because it doesn't work to show it on this component, which is not really part of the swing hierarchy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

backgroundColor

protected java.awt.Color backgroundColor

foregroundColor

protected java.awt.Color foregroundColor

selected

protected boolean selected
A selected component is one that the user has clicked on. It will appear more prominently than non-selected ContainerPane, and its status as selected makes it the target of actions that are invoked on the playpen.


componentPreviouslySelected

protected boolean componentPreviouslySelected
Constructor Detail

PlayPenComponent

protected PlayPenComponent(PlayPenContentPane parent)
Method Detail

getPlayPen

public PlayPen getPlayPen()

getUI

public PlayPenComponentUI getUI()

setUI

public void setUI(PlayPenComponentUI ui)

showPopup

public void showPopup(java.awt.Point p)
Shows the component's popup menu on the PlayPen that owns this component because it doesn't work to show it on this component, which is not really part of the swing hierarchy. Only executed if the component has a popup menu, see getPopup().

Parameters:
p - the point (relative to this component's top-left corner) to show it at.

getPopup

public javax.swing.JPopupMenu getPopup()
Returns a component specific popup menu. Defaulted here to null so components that have popup menus must override this class.


revalidate

public void revalidate()
Translates this request into a call to PlayPen.repaint(Rectangle). That will eventually cause a call to PlayPen.paint(). Painting a TablePane causes it to re-evaluate its preferred size, which is what validation is really all about.


setBoundsImpl

protected void setBoundsImpl(int x,
                             int y,
                             int width,
                             int height)
Updates the bounds of this component, then issues a repaint to the PlayPen which covers the old bounds of this component. This will allow newly-exposed sections of the PlayPen to draw themselves in case this setBounds call is shrinking this component. Also ensures the new bounds do not remain left of or above the (0,0) point by normalizing the play pen.

All methods that affect the bounds rectangle should do so by calling this method.


setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
See setBoundsImpl.


getBounds

public java.awt.Rectangle getBounds()
Returns a copy of this component's bounding rectangle.


getBounds

public java.awt.Rectangle getBounds(java.awt.Rectangle r)
Sets the given rectangle to be identical to this component's bounding box.

Parameters:
r - An existing rectangle. If null, this method creates a new rectangle for you.
Returns:
r if r was not null; a new rectangle otherwise.

getSize

public java.awt.Dimension getSize()

getPreferredLocation

public java.awt.Point getPreferredLocation()
The revalidate() call uses this to determine the component's correct location. This implementation just returns the current location. Override it if you need to be moved during validation.


getLocation

public java.awt.Point getLocation()

getLocation

public java.awt.Point getLocation(java.awt.Point p)
Copies this component's location into the given point object.

Parameters:
p - A point that this method will modify. If you pass in null, this method will create a new point for you.
Returns:
p if p was not null; a new point otherwise.

setLocation

public void setLocation(java.awt.Point point)
Updates the on-screen location of this component. If you try to move this component to a negative co-ordinate, it will automatically be normalized (along with everything else in the playpen) to non-negative coordinates.


setLocation

public void setLocation(int x,
                        int y)
Updates the on-screen location of this component. If you try to move this component to a negative co-ordinate, it will automatically be normalized (along with everything else in the playpen) to non-negative coordinates.


setSize

public void setSize(java.awt.Dimension size)

repaint

public void repaint()
Forwards to repaint(Rectangle).


repaint

public void repaint(java.awt.Rectangle r)
Forwards to repaint(long,int,int,int,int).


getName

public abstract java.lang.String getName()
Returns the user-visible name for this component--often the same as getModel().getName(), but this depends entirely on the subclass's idea of what in the model constitutes its name.


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a property change listener to the existing list.


addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener l)
Adds a property change listener for a specific property.


removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes a specific property change listener from the existing list.


firePropertyChange

protected void firePropertyChange(java.lang.String propName,
                                  java.lang.Object oldValue,
                                  java.lang.Object newValue)
Notifies property change listeners of a property change event.


firePropertyChange

public void firePropertyChange(java.beans.PropertyChangeEvent e)
See Also:
PlayPenComponent.firePropertyChange()

getX

public int getX()

getY

public int getY()

getWidth

public int getWidth()

getHeight

public int getHeight()

getInsets

public java.awt.Insets getInsets()

setInsets

public void setInsets(java.awt.Insets insets)

repaint

public void repaint(long tm,
                    int x,
                    int y,
                    int width,
                    int height)
Tells the owning PlayPen to repaint the given region. The rectangle is manipulated (zoomed) into screen coordinates.


isOpaque

public boolean isOpaque()

setOpaque

public void setOpaque(boolean opaque)

getBackgroundColor

public java.awt.Color getBackgroundColor()

setBackgroundColor

public void setBackgroundColor(java.awt.Color c)

getForegroundColor

public java.awt.Color getForegroundColor()

setForegroundColor

public void setForegroundColor(java.awt.Color c)

getToolTipText

public java.lang.String getToolTipText()

setToolTipText

public void setToolTipText(java.lang.String toolTipText)

getFont

public java.awt.Font getFont()

getFontMetrics

public java.awt.FontMetrics getFontMetrics(java.awt.Font f)

getFontRenderContext

public java.awt.font.FontRenderContext getFontRenderContext()

contains

public boolean contains(java.awt.Point p)

paint

public void paint(java.awt.Graphics2D g2)

getPreferredSize

public java.awt.Dimension getPreferredSize()

getModel

public abstract java.lang.Object getModel()

getParent

public PlayPenContentPane getParent()

handleMouseEvent

public abstract void handleMouseEvent(java.awt.event.MouseEvent evt)
Performs the component specific actions for the given MouseEvent.


addSelectionListener

public final void addSelectionListener(SelectionListener l)
Specified by:
addSelectionListener in interface Selectable

removeSelectionListener

public final void removeSelectionListener(SelectionListener l)
Specified by:
removeSelectionListener in interface Selectable

fireSelectionEvent

protected final void fireSelectionEvent(SelectionEvent e)

isSelected

public boolean isSelected()
See selected.

Specified by:
isSelected in interface Selectable

setSelected

public void setSelected(boolean isSelected,
                        int multiSelectType)
Tells this component it is selected or deselected. If isSelected is different from the current selection state for this component, a SelectionEvent will be fired to all selection listeners.

See selected.

Specified by:
setSelected in interface Selectable
Parameters:
isSelected - The new selection state for this component
multiSelectType - One of the type codes from SelectionEvent.


Copyright © 2003-2007 SQL Power Group Inc. www.sqlpower.ca