org.vectomatic.common.model
Class DrawingModel

java.lang.Object
  extended by org.vectomatic.common.model.DrawingModel

public class DrawingModel
extends Object

Class to represent a drawing. Contains the collection of shapes in the drawing stored in a linked list.


Nested Class Summary
protected  class DrawingModel.AscendingIterator
           
protected static class DrawingModel.AscendingNodeComparator
           
protected  class DrawingModel.DescendingIterator
           
protected static class DrawingModel.DescendingNodeComparator
           
protected  class DrawingModel.Node
           
 
Field Summary
protected  DrawingModel.AscendingIterator _ascIterator
          Linked list forward traversal (back to front)
protected  DrawingModel.DescendingIterator _descIterator
          Linked list reverse traversal (front to back)
protected  List<IDrawingModelListener> _drawingModelListeners
           
protected  DrawingModel.Node _head
          Shape linked list head node
protected  Set<Shape> _shapeSet
          Temporary set used for ordering computations
protected  Map<Shape,DrawingModel.Node> _shapeToNode
          A Map to retrieve the linked list node which contains a shape.
protected  DrawingModel.Node _tail
          Shape linked list tail node
protected static Comparator<DrawingModel.Node> ORDER_ASCENDING
          To sort Node based on their depth in ascending order
protected static Comparator<DrawingModel.Node> ORDER_DESCENDING
          To sort Node based on their depth in descending order
 
Constructor Summary
DrawingModel()
           
 
Method Summary
 void addDrawingModelListener(IDrawingModelListener listener)
           
 void addShape(Shape shape)
           
 List<Float> bringForward(List<Shape> shapes)
           
 List<Float> bringToFront(List<Shape> shapes)
           
 boolean canBringForward(List<Shape> shapes)
           
 boolean canBringToFront(List<Shape> shapes)
           
 boolean canSendBackward(List<Shape> shapes)
           
 boolean canSendToBack(List<Shape> shapes)
           
 void clear()
           
 boolean contains(Shape shape)
           
 int count()
           
 void fireModelHasChanged()
           
 void fromShapeArray(Shape[] shapeArray)
           
 Iterator<Shape> iterator()
           
 void removeDrawingModelListener(IDrawingModelListener listener)
           
 void removeShape(Shape shape)
           
 void reorder(List<Shape> shapes, List<Float> orders)
           
 Iterator<Shape> reverseIterator()
           
 List<Float> sendBackward(List<Shape> shapes)
           
 List<Float> sendToBack(List<Shape> shapes)
           
protected  DrawingModel.Node[] toNodeArray(List<Shape> shapes)
           
 Shape[] toShapeArray()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_drawingModelListeners

protected List<IDrawingModelListener> _drawingModelListeners

_head

protected DrawingModel.Node _head
Shape linked list head node


_tail

protected DrawingModel.Node _tail
Shape linked list tail node


_shapeToNode

protected Map<Shape,DrawingModel.Node> _shapeToNode
A Map to retrieve the linked list node which contains a shape.


_ascIterator

protected DrawingModel.AscendingIterator _ascIterator
Linked list forward traversal (back to front)


_descIterator

protected DrawingModel.DescendingIterator _descIterator
Linked list reverse traversal (front to back)


ORDER_ASCENDING

protected static final Comparator<DrawingModel.Node> ORDER_ASCENDING
To sort Node based on their depth in ascending order


ORDER_DESCENDING

protected static final Comparator<DrawingModel.Node> ORDER_DESCENDING
To sort Node based on their depth in descending order


_shapeSet

protected Set<Shape> _shapeSet
Temporary set used for ordering computations

Constructor Detail

DrawingModel

public DrawingModel()
Method Detail

addDrawingModelListener

public void addDrawingModelListener(IDrawingModelListener listener)

removeDrawingModelListener

public void removeDrawingModelListener(IDrawingModelListener listener)

fireModelHasChanged

public void fireModelHasChanged()

addShape

public void addShape(Shape shape)

removeShape

public void removeShape(Shape shape)

clear

public void clear()

reorder

public void reorder(List<Shape> shapes,
                    List<Float> orders)

count

public int count()

iterator

public Iterator<Shape> iterator()

reverseIterator

public Iterator<Shape> reverseIterator()

toNodeArray

protected DrawingModel.Node[] toNodeArray(List<Shape> shapes)

canBringToFront

public boolean canBringToFront(List<Shape> shapes)

canSendToBack

public boolean canSendToBack(List<Shape> shapes)

canBringForward

public boolean canBringForward(List<Shape> shapes)

canSendBackward

public boolean canSendBackward(List<Shape> shapes)

bringToFront

public List<Float> bringToFront(List<Shape> shapes)

sendToBack

public List<Float> sendToBack(List<Shape> shapes)

bringForward

public List<Float> bringForward(List<Shape> shapes)

sendBackward

public List<Float> sendBackward(List<Shape> shapes)

contains

public boolean contains(Shape shape)

toShapeArray

public Shape[] toShapeArray()

fromShapeArray

public void fromShapeArray(Shape[] shapeArray)


Copyright © 2010. All Rights Reserved.