org.openbp.jaspira.gui.interaction
Class BasicDropRegion

java.lang.Object
  extended by org.openbp.jaspira.gui.interaction.BasicDropRegion
All Implemented Interfaces:
DragAwareRegion
Direct Known Subclasses:
BasicDragReactor, CircleDropRegion, ViewDropRegion

public class BasicDropRegion
extends java.lang.Object
implements DragAwareRegion

Basic implementation of DragAwareRegion. This implementation receives its parameters via the constructor. It can not be used for component elements that change dynamically during Dragging.

Author:
Stephan Moritz

Field Summary
protected  java.lang.Object id
          Name to identify this drop region to the drop client
protected  java.awt.Component origin
          Origin to which the coordinates are relative
protected  InteractionClient parent
          Drop client that this region belongs to
protected  java.lang.String toolTipText
          Text of the Tooltip that should be displayed for this region
 
Fields inherited from interface org.openbp.jaspira.gui.interaction.DragAwareRegion
COPY, COPY_OR_MOVE, MOVE, NONE
 
Constructor Summary
BasicDropRegion(java.lang.Object id, InteractionClient parent, java.awt.Component source)
          Component constructor.
BasicDropRegion(java.lang.Object id, InteractionClient parent, java.awt.geom.RectangularShape shape, java.awt.Component origin)
          Constructor for a rectangular region.
 
Method Summary
 boolean canImport()
          BasicDropRegion objects can always import.
 boolean dragEnter()
          Do nothing, return true.
 boolean dragExit()
          Do nothing, return true.
 void draw(java.awt.Graphics2D g)
          Draws the region with the given attributes.
 java.awt.Rectangle getBounds()
          Returns the bounding box of the region.
 CursorPrototype getCursor()
          Gets the cursor prototype that should be used for constructing a cursor if a drag over occurs.
 java.awt.Color getFrameColor()
          Gets the color of the frame of the region.
 java.lang.Object getId()
          Gets the name to identify this drop region to the drop client.
 java.awt.Component getOrigin()
          Gets the origin to which the coordinates are relative.
 java.awt.Shape getOverlay()
          Gets the overlay shape for this region.
 java.awt.Paint getPaint()
          Gets the fill paint for the region.
 InteractionClient getParent()
          Gets the drop client that this region belongs to.
 java.awt.geom.RectangularShape getShape()
          Gets the visible shape of the region.
 java.awt.Stroke getStroke()
          Gets the stroke for the frame.
 java.lang.String getToolTipText()
          Gets the text of the Tooltip that should be displayed for this region.
 boolean importData(java.awt.datatransfer.Transferable data, java.awt.Point p)
          Imports the dragged data into our parent.
 boolean reactsOn(int x, int y)
          Checks if the given coordinates are within the shapes region.
 void setCursor(CursorPrototype cursor)
          Sets the cursor prototype that should be used for constructing a cursor if a drag over occurs.
 void setFrameColor(java.awt.Color frameColor)
          Sets the color of the frame of the region.
 void setId(java.lang.Object id)
          Sets the name to identify this drop region to the drop client.
 void setOrigin(java.awt.Component origin)
          Sets the origin to which the coordinates are relative.
 void setOverlay(java.awt.Shape overlay)
          Sets the overlay shape for this region.
 void setPaint(java.awt.Paint paint)
          Sets the fill paint for the region.
 void setParent(InteractionClient parent)
          Sets the drop client that this region belongs to.
 void setShape(java.awt.geom.RectangularShape shape)
          Sets the visible shape of the region.
 void setStroke(java.awt.Stroke stroke)
          Sets the stroke for the frame.
 void setToolTipText(java.lang.String toolTipText)
          Sets the text of the Tooltip that should be displayed for this region.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

protected java.lang.Object id
Name to identify this drop region to the drop client


parent

protected InteractionClient parent
Drop client that this region belongs to


origin

protected java.awt.Component origin
Origin to which the coordinates are relative


toolTipText

protected java.lang.String toolTipText
Text of the Tooltip that should be displayed for this region

Constructor Detail

BasicDropRegion

public BasicDropRegion(java.lang.Object id,
                       InteractionClient parent,
                       java.awt.geom.RectangularShape shape,
                       java.awt.Component origin)
Constructor for a rectangular region.

Parameters:
id - Name to identify this drop region to the drop client
parent - Drop client that this region belongs to
shape - Shape to represent this region. Relative to drop client origin.
origin - Component to which th shape is relative to

BasicDropRegion

public BasicDropRegion(java.lang.Object id,
                       InteractionClient parent,
                       java.awt.Component source)
Component constructor.

Parameters:
id - Name to identify this drop region to the drop client
parent - Drop client that this region belongs to
source - Component that shall be covered by this region. The bounds region will equals the component's bounds.
Method Detail

importData

public boolean importData(java.awt.datatransfer.Transferable data,
                          java.awt.Point p)
Imports the dragged data into our parent.

Specified by:
importData in interface DragAwareRegion
Parameters:
data - Data to import
p - Import position in glass coordinates
Returns:
true If the data could be imported.
false Otherwise

canImport

public boolean canImport()
BasicDropRegion objects can always import.

Specified by:
canImport in interface DragAwareRegion

draw

public void draw(java.awt.Graphics2D g)
Draws the region with the given attributes.

Specified by:
draw in interface DragAwareRegion
Parameters:
g - Graphics context

getBounds

public java.awt.Rectangle getBounds()
Returns the bounding box of the region.

Specified by:
getBounds in interface DragAwareRegion
Returns:
The bounding box

reactsOn

public boolean reactsOn(int x,
                        int y)
Checks if the given coordinates are within the shapes region.

Specified by:
reactsOn in interface DragAwareRegion
Parameters:
x - Position in screen coordinates
y - Position in screen coordinates

dragEnter

public boolean dragEnter()
Do nothing, return true.

Specified by:
dragEnter in interface DragAwareRegion
Returns:
true If this event should be passed to other eglible targets
false To purge the event

dragExit

public boolean dragExit()
Do nothing, return true.

Specified by:
dragExit in interface DragAwareRegion
Returns:
true If this event should be passed to other eglible targets
false To purge the event

getId

public java.lang.Object getId()
Gets the name to identify this drop region to the drop client.


setId

public void setId(java.lang.Object id)
Sets the name to identify this drop region to the drop client.


getParent

public InteractionClient getParent()
Gets the drop client that this region belongs to.


setParent

public void setParent(InteractionClient parent)
Sets the drop client that this region belongs to.


getShape

public java.awt.geom.RectangularShape getShape()
Gets the visible shape of the region. Relative to drop client origin.


setShape

public void setShape(java.awt.geom.RectangularShape shape)
Sets the visible shape of the region. Relative to drop client origin.


getFrameColor

public java.awt.Color getFrameColor()
Gets the color of the frame of the region. May be null.


setFrameColor

public void setFrameColor(java.awt.Color frameColor)
Sets the color of the frame of the region. May be null.


getStroke

public java.awt.Stroke getStroke()
Gets the stroke for the frame. May be null.


setStroke

public void setStroke(java.awt.Stroke stroke)
Sets the stroke for the frame. May be null.


getPaint

public java.awt.Paint getPaint()
Gets the fill paint for the region.


setPaint

public void setPaint(java.awt.Paint paint)
Sets the fill paint for the region.


getCursor

public CursorPrototype getCursor()
Gets the cursor prototype that should be used for constructing a cursor if a drag over occurs.

Specified by:
getCursor in interface DragAwareRegion
Returns:
The drag cursor prototype or null

setCursor

public void setCursor(CursorPrototype cursor)
Sets the cursor prototype that should be used for constructing a cursor if a drag over occurs.


getOverlay

public java.awt.Shape getOverlay()
Gets the overlay shape for this region.

Specified by:
getOverlay in interface DragAwareRegion
Returns:
The overlay or null if no overlay should be shown

setOverlay

public void setOverlay(java.awt.Shape overlay)
Sets the overlay shape for this region.


getOrigin

public java.awt.Component getOrigin()
Gets the origin to which the coordinates are relative.


setOrigin

public void setOrigin(java.awt.Component origin)
Sets the origin to which the coordinates are relative.


getToolTipText

public java.lang.String getToolTipText()
Gets the text of the Tooltip that should be displayed for this region.

Specified by:
getToolTipText in interface DragAwareRegion
Returns:
The tool tip or null if no tool tip should be displayed

setToolTipText

public void setToolTipText(java.lang.String toolTipText)
Sets the text of the Tooltip that should be displayed for this region.



Copyright © 2011. All Rights Reserved.