com.jfimagine.jfdraw.draw
Class Selection

java.lang.Object
  |
  +--com.jfimagine.jfdraw.draw.Selection

public class Selection
extends java.lang.Object

Selection class. Used as a collection if user 'picked-up' some shapes.

Version:
$Revision: 1.1 $
Author:
CookieMaker

Constructor Summary
Selection(DrawCanvas drawCanvas)
          Constructor for ObjectList
 
Method Summary
 int add(AbstractObject obj)
          Add a new object at the end of the list.
 int add(java.util.List objList)
          Add an object list at the end of the list.
 Port addPort(double x, double y)
          Add a new port to this selection.
 void alignObjects(int ALIGNMENTTYPE)
          Align all the shapes in this list.
 void clear()
          Clear all objects in list.
 boolean contains(AbstractObject obj)
          If this selection has already contains such an object.
 void dragLabel(double lastx, double lasty, double newx, double newy, java.awt.Graphics g)
          Drag current label.
 void dragNode(double x, double y, java.awt.Graphics g)
          Drag current node and draw its relational lines.
 void draw(java.awt.Graphics g, boolean isXorMode)
          Draw current object on graphic canvas.
 void drawPicked(java.awt.Graphics g, boolean ifRotate)
          Draw picked state of current object on graphic canvas.
 void finishDragNode(double x, double y, java.awt.Graphics g)
          finish dragging current node and draw its relational lines.
 double flipObjects()
          Flip objects of current selection.
 Arrow getArrow()
          Get all the arrow format of objects in this selection.
 Rect getBounds()
          Get the bounds of this selection.
 Rect getBounds(boolean avoidUnrotatable)
          Get the bounds of this selection.
 Node getDraggingNode()
          get current dragging node of current shape.
 FillFormat getFillFormat()
          Get all the fill format of objects in this selection.
 AbstractShape getFirstObj()
          get first object in selection.
 FontFormat getFontFormat()
          Get all the font format of objects in this selection.
 JFPoint getLastPoint()
          Get last point.
 LineFormat getLineFormat()
          Get all the line format of objects in this selection.
 ObjectList getList()
          Get an objectList encapsulates shape Objects
 Label getMoveLabel()
          get current moving label of current shape.
 JFPoint getMovePos(double oldx, double oldy, double newx, double newy)
          Get a move offset(x,y) from source position to destination position.
 JFPoint getOriginalCenter()
          Get original center.
 JFPoint getOriginalPoint()
          Get original point.
 boolean hasQuadrant()
          if current selection has quadrant
 AbstractObject intersects(JFPoint pnt)
          Get which shape in the selection that intersects with point pnt.
 boolean isDraggingPortAlso()
          When dragging node of current shape, if a relational port is also dragged.
 Label labelIntersects(java.awt.Graphics g, JFPoint pnt)
          Get internal label of one shape in the selection that intersects with point pnt.
 double mirrorObjects()
          Mirror objects of current selection.
 boolean modifyLabel(java.awt.Container c, JFOperationManager manager)
          Modify label string of one object.
 void moveBy(double x, double y)
          Move current selection by a new offset.
 void moveRelationalPorts()
          Move all the relational ports of this selection.
 void moveTo(double x, double y, java.awt.Graphics g)
          Move current selection at a new position
 Node nodeIntersects(JFPoint pnt, int usage)
          Get which node of one shape in the selection that intersects with point pnt.
 Port pickPort(double x, double y)
          Pick a port that is on the selection, according to the current x,y position
 void remove(AbstractObject obj)
          Remove an object in object list.
 boolean removePort(Port port)
          Remove a port from this selection.
 void rotateObjects(double x, double y, java.awt.Graphics g)
          Rotate current objects by moving a rotating point.
 void setArrow(Arrow arrow)
          Set all the arrow format of object in this selection.
 void setDraggingNode(Node draggingNode)
          set current dragging node of current shape.
 void setFillFormat(FillFormat fillFormat)
          Set the fill format of objects in this selection.
 void setFontFormat(FontFormat fontFormat)
          Set the font format of objects in this selection.
 void setLastPoint(JFPoint pnt)
          Set last point.
 void setLineFormat(LineFormat lineFormat)
          Set the line format of objects in this selection.
 void setMoveLabel(Label moveLabel)
          set current moving label of current shape.
 void setOriginalPoint()
          Set original center point by currently selected objects.
 void setOriginalPoint(JFPoint pnt)
          Set original point.
 int size()
          Get the number of AbstractObject in list.
 java.lang.String toString()
          Convert this list to String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Selection

public Selection(DrawCanvas drawCanvas)
Constructor for ObjectList

Method Detail

getList

public ObjectList getList()
Get an objectList encapsulates shape Objects

Returns:
An object list.

contains

public boolean contains(AbstractObject obj)
If this selection has already contains such an object.

Parameters:
obj - A new AbstractObject.
Returns:
If obj is already inside the selection, then return true,otherwise false.

add

public int add(AbstractObject obj)
Add a new object at the end of the list.

Parameters:
obj - A new AbstractObject.
Returns:
The index the object located in the list.

add

public int add(java.util.List objList)
Add an object list at the end of the list.

Parameters:
objList - A new AbstractObject list.
Returns:
The number of added.

remove

public void remove(AbstractObject obj)
Remove an object in object list.

Parameters:
obj - An object to be removed.

clear

public void clear()
Clear all objects in list.


size

public int size()
Get the number of AbstractObject in list.

Returns:
The number of AbstractObject.

getBounds

public Rect getBounds()
Get the bounds of this selection.

Returns:
The bounds rectangle of current selection.

getBounds

public Rect getBounds(boolean avoidUnrotatable)
Get the bounds of this selection.

Parameters:
avoidUnrotatable - To avoid caculating the bounds of unrotatable objects.
Returns:
The bounds rectangle of current selection.

getOriginalPoint

public JFPoint getOriginalPoint()
Get original point.

Returns:
An original point.

getOriginalCenter

public JFPoint getOriginalCenter()
Get original center.

Returns:
An original center point.

setOriginalPoint

public void setOriginalPoint()
Set original center point by currently selected objects.


setOriginalPoint

public void setOriginalPoint(JFPoint pnt)
Set original point.

Parameters:
pnt - A new original point.

getLastPoint

public JFPoint getLastPoint()
Get last point.

Returns:
An last point.

setLastPoint

public void setLastPoint(JFPoint pnt)
Set last point.

Parameters:
pnt - A new last point.

getDraggingNode

public Node getDraggingNode()
get current dragging node of current shape.

Returns:
Current dragging node.

setDraggingNode

public void setDraggingNode(Node draggingNode)
set current dragging node of current shape.

Parameters:
draggingNode - A new dragging node of current shape.

getMoveLabel

public Label getMoveLabel()
get current moving label of current shape.

Returns:
Current moving label.

setMoveLabel

public void setMoveLabel(Label moveLabel)
set current moving label of current shape.

Parameters:
moveLabel - Current moving label.

isDraggingPortAlso

public boolean isDraggingPortAlso()
When dragging node of current shape, if a relational port is also dragged.


addPort

public Port addPort(double x,
                    double y)
Add a new port to this selection.


pickPort

public Port pickPort(double x,
                     double y)
Pick a port that is on the selection, according to the current x,y position


removePort

public boolean removePort(Port port)
Remove a port from this selection.

Parameters:
port - A port to be removed.

getArrow

public Arrow getArrow()
Get all the arrow format of objects in this selection.

Returns:
The arrow format.

setArrow

public void setArrow(Arrow arrow)
Set all the arrow format of object in this selection.

Parameters:
arrow - A new arrow format object.

getLineFormat

public LineFormat getLineFormat()
Get all the line format of objects in this selection.

Returns:
The line format.

setLineFormat

public void setLineFormat(LineFormat lineFormat)
Set the line format of objects in this selection.

Parameters:
lineFormat - A new line format.

getFillFormat

public FillFormat getFillFormat()
Get all the fill format of objects in this selection.

Returns:
The fill format.

setFillFormat

public void setFillFormat(FillFormat fillFormat)
Set the fill format of objects in this selection.

Parameters:
fillFormat - A new fill format.

getFontFormat

public FontFormat getFontFormat()
Get all the font format of objects in this selection.

Returns:
The font format.

setFontFormat

public void setFontFormat(FontFormat fontFormat)
Set the font format of objects in this selection.

Parameters:
fontFormat - A new font format.

flipObjects

public double flipObjects()
Flip objects of current selection. We make a up-down flip here.

Returns:
the flip baseY coordinate.

mirrorObjects

public double mirrorObjects()
Mirror objects of current selection. We make a left-right mirror here.

Returns:
the mirror baseX coordinate.

moveBy

public void moveBy(double x,
                   double y)
Move current selection by a new offset.


getMovePos

public JFPoint getMovePos(double oldx,
                          double oldy,
                          double newx,
                          double newy)
Get a move offset(x,y) from source position to destination position.

Returns:
The move offset point.

moveTo

public void moveTo(double x,
                   double y,
                   java.awt.Graphics g)
Move current selection at a new position

Parameters:
g - Graphics context to draw selections.

getFirstObj

public AbstractShape getFirstObj()
get first object in selection.


labelIntersects

public Label labelIntersects(java.awt.Graphics g,
                             JFPoint pnt)
Get internal label of one shape in the selection that intersects with point pnt.

Parameters:
pnt - A JFPoint used to test intersection.
g - A graphics text used necessary in label intersection operation.
Returns:
Internal label of current shape.

dragLabel

public void dragLabel(double lastx,
                      double lasty,
                      double newx,
                      double newy,
                      java.awt.Graphics g)
Drag current label.

Parameters:
g - Graphics context to draw selections.

nodeIntersects

public Node nodeIntersects(JFPoint pnt,
                           int usage)
Get which node of one shape in the selection that intersects with point pnt.

Parameters:
pnt - A JFPoint used to test intersection.
usage - Purpose to get a node intersected, e.g. move or rotate.
Returns:
A node of current shape.

intersects

public AbstractObject intersects(JFPoint pnt)
Get which shape in the selection that intersects with point pnt.

Parameters:
pnt - A JFPoint used to test intersection.
Returns:
A shape in the selection that intersects with the point.

dragNode

public void dragNode(double x,
                     double y,
                     java.awt.Graphics g)
Drag current node and draw its relational lines.

Parameters:
g - Graphics context to draw selections.

rotateObjects

public void rotateObjects(double x,
                          double y,
                          java.awt.Graphics g)
Rotate current objects by moving a rotating point.

Parameters:
g - Graphics context to draw selections.

alignObjects

public void alignObjects(int ALIGNMENTTYPE)
Align all the shapes in this list.


finishDragNode

public void finishDragNode(double x,
                           double y,
                           java.awt.Graphics g)
finish dragging current node and draw its relational lines.

Parameters:
g - Graphics context to draw selections.

moveRelationalPorts

public void moveRelationalPorts()
Move all the relational ports of this selection.


modifyLabel

public boolean modifyLabel(java.awt.Container c,
                           JFOperationManager manager)
Modify label string of one object.

Parameters:
c - A container that used to place modifier objects.
manager - An opeation manager used to register the text's change.
Returns:
true if label changed, false otherwise.

toString

public java.lang.String toString()
Convert this list to String

Overrides:
toString in class java.lang.Object
Returns:
An string represents the content of current list

draw

public void draw(java.awt.Graphics g,
                 boolean isXorMode)
Draw current object on graphic canvas.

Parameters:
g - A graphic canvas.
isXorMode - If is in xor mode now.

drawPicked

public void drawPicked(java.awt.Graphics g,
                       boolean ifRotate)
Draw picked state of current object on graphic canvas.

Parameters:
g - A graphic canvas.
ifRotate - If user's operation or other actions force objects to be rotated.

hasQuadrant

public boolean hasQuadrant()
if current selection has quadrant



Copyright 2004 ~ 2005 JingFei International Cooperation LTD. All Rights Reserved.