com.jfimagine.jfgraph.shape.union
Class JFPage

java.lang.Object
  |
  +--com.jfimagine.jfgraph.shape.base.AbstractObject
        |
        +--com.jfimagine.jfgraph.shape.union.JFPage
All Implemented Interfaces:
java.lang.Cloneable

public class JFPage
extends AbstractObject

JFPage class. A page is a cad page, for multi-views of a cad graph design.

Version:
$Revision: 1.1 $
Author:
CookieMaker

Field Summary
static java.lang.String XML_DISABLEPORTSNAPPING
          A XML string tag represents if disable or enable port snapping
static java.lang.String XML_HIDEPORTS
          A XML string tag represents if hide or show ports
static java.lang.String XML_JFDRAW
          A XML string tag represents a JFDraw xml file
static java.lang.String XML_PAGE
          A XML string tag represents a Page
static java.lang.String XML_SCALEUNIT
          A XML string tag represents a scale unit
static java.lang.String XML_SCALEVALUE
          A XML string tag represents a scale value
static java.lang.String XML_SCREENUNIT
          A XML string tag represents a screen unit
 
Fields inherited from class com.jfimagine.jfgraph.shape.base.AbstractObject
m_lastError, XML_OBJECTID, XML_OBJECTTYPE
 
Constructor Summary
JFPage()
          Constructor for Page
 
Method Summary
 void addLayer(JFLayer layer)
          Add a new layer to this page.
protected  void appendChildToDOM(Element element, JFVersion version)
          Append necessary xml child for current element, this method will be called internally by toDOM.
 int bindPorts(JFPoint mousePos)
          bind ports at a specified point.
 void bringToFront(java.util.List objList)
          Send a sub-collection of object list in current layer to back.
 void clearAccessTimes()
          Clear access times, Clear all objects access times of current layer.
 java.lang.Object clone()
          Creates a new object of the same class and with the same contents as this object.
protected  AbstractObject cloneMe()
          Creates a new AbstractObject of the same class and with the same contents as this object.
 void draw(java.awt.Graphics g, boolean isXorMode)
          Draw current page on graphic canvas.
 boolean equals(java.lang.Object obj)
          Determines whether or not two objects are equal.
protected  void extractChildFromDOM(Element element, JFVersion version)
          Extract needed xml child from current element, this method will be called internally by fromDOM.
 boolean finishLoadingImages(java.awt.Component canvas)
          for loading an image, we need to call this finish loading image method to completely create a new image.
 java.lang.String getAuthor()
          Get the author of this page.
 Rect getBounds()
          Get the bounds of this page.
 CanvasFormat getCanvasFormat()
          Get canvas format.
 JFLayer getCurrentLayer()
          Get the current layer.
 int getCurrentLayerIndex()
          Get the current layer index.
 JFLayer getLayer(int index)
          Get a specified layer by index.
 JFLayer getLayerByObjectId(int objectId)
          Get a specified layer by object id.
 java.util.List getLayerItemList()
          Get layer items as check items, it's used to be modified by layer setup.
 ObjectList getLayerList()
          Get the shape list.
 JFPageFormat getPageFormat()
          Get page format.
 java.lang.String getProducer()
          Get the producer of this page.
 int getScaleUnit()
          Get the scale unit, a scale unit is something like << 1cm = 100 * [scaleUnit] >>
 double getScaleValue()
          Get the scale value, a scale value is something like << 1cm = [scaleValue] * km >>
 int getScreenUnit()
          Get the screen unit, a screen unit is something like << 1 * [screenUnit] = 1000 * meter >> We only allowed CM or INch for current screen unit.
 java.lang.String getVersion()
          Get the version of this page.
 AbstractObject groupShapes(java.util.List objList)
          Group a selection to one JFGroup object.
 int hashCode()
          Returns the hashcode for this Object.
 void insertLayer(JFLayer layer, int index)
          Insert a new layer to this page.
 boolean isDisablePortSnapping()
          if assigned disable port snapping.
 boolean isHidePorts()
          if assigned hidding ports .
 boolean isModified()
          if this page is modified.
 boolean loadFromBinary(java.lang.String fileName, java.awt.Component c)
          Load this page from a binary file.
 void loadFromStream(JFReader stream, boolean skipHead, JFVersion version)
          Load object data from a binary stream
 boolean loadFromXML(java.lang.String fileName, java.awt.Component c)
          Load this page from an XML file.
 boolean loadFromXMLString(java.lang.String xmlString, java.awt.Component c)
          Load this page from an XML string.Attention: this xml string is already an xml document, but not the file name of an xml file.
 void newPage()
          clear all data in this page, to create a complete new page.
 AbstractObject pickBy(java.awt.Graphics g, JFPoint pnt)
          pick up shape object by a position point.
 ObjectList pickBy(java.awt.Graphics g, Rect rect)
          pick up shape object by a rectangle.
 Port portIntersects(JFPoint pnt, AbstractObject avoidParent)
          Get which port of current shape that intersects with point pnt.
 java.util.List portIntersectsList(JFPoint pnt)
          Get a ports list of alls hapes that intersects with point pnt.
 void removeLayer(int index)
          Remove a specified layer.
 void removeLayerByObjectId(int objectId)
          Remove a specified layer.
 void restoreLayerItemList(java.util.List itemList)
          Restore layer items as item backuped in itemList.
 boolean saveToBinary(java.lang.String fileName)
          Save this page to a binary file.
 void saveToStream(JFWriter stream, JFVersion version)
          Save this object to a binary stream
 boolean saveToXML(java.lang.String fileName)
          Save this page to an XML file.
 java.lang.String saveToXMLString()
          Save this page to an XML string.
 void sendToBack(java.util.List objList)
          Send a sub-collection of object list in current layer to back.
 void setAuthor(java.lang.String author)
          Set the author of this page.
 void setCurrentLayerIndex(int layerIndex)
          Set the current layer index.
 void setDefaultLayerIndex()
          Consider the default visible layer, then set current layer index on it.
 void setDisablePortSnapping(boolean disable)
          set if hide or show ports.
 void setHidePorts(boolean hide)
          set if hide or show ports.
 void setIsMetric(boolean isMetric)
          set scale as metric or english measurement.
 void setLayerItemList(java.util.List itemList, java.util.List removedItemList)
          Set new layer items
 void setModified(boolean modified)
          set if this page is modified or unmodified(when save/load).
 void setScaleUnit(int unit)
          Set the scale unit
 void setScaleValue(double scale)
          Set the scale value
 void setScreenUnit(int unit)
          Set the screen unit We only allowed CM or INch for current screen unit.
 void setShowDesign(boolean showDesign)
          set if show or hide current object's design info
 void setValue(AbstractObject obj)
          Set value by a new object.
 void setZoomScale(double zoomScale)
          set zoom scale
 java.lang.String toString()
          Convert this object to String
 int unbindPorts(JFPoint mousePos)
          unbind ports at a specified point.
 java.util.List ungroupShapes(java.util.List objList)
          Ungroup a selection to individual objects.
 
Methods inherited from class com.jfimagine.jfgraph.shape.base.AbstractObject
fromDOM, getLastError, getMaxObjectId, getObjectId, getObjectType, getXMLTag, getZoomScale, isShowDesign, setLastError, setObjectId, setObjectType, setXMLTag, toDOM
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

XML_JFDRAW

public static final java.lang.String XML_JFDRAW
A XML string tag represents a JFDraw xml file

See Also:
Constant Field Values

XML_PAGE

public static final java.lang.String XML_PAGE
A XML string tag represents a Page

See Also:
Constant Field Values

XML_HIDEPORTS

public static final java.lang.String XML_HIDEPORTS
A XML string tag represents if hide or show ports

See Also:
Constant Field Values

XML_DISABLEPORTSNAPPING

public static final java.lang.String XML_DISABLEPORTSNAPPING
A XML string tag represents if disable or enable port snapping

See Also:
Constant Field Values

XML_SCALEVALUE

public static final java.lang.String XML_SCALEVALUE
A XML string tag represents a scale value

See Also:
Constant Field Values

XML_SCALEUNIT

public static final java.lang.String XML_SCALEUNIT
A XML string tag represents a scale unit

See Also:
Constant Field Values

XML_SCREENUNIT

public static final java.lang.String XML_SCREENUNIT
A XML string tag represents a screen unit

See Also:
Constant Field Values
Constructor Detail

JFPage

public JFPage()
Constructor for Page

Method Detail

newPage

public void newPage()
clear all data in this page, to create a complete new page.


getVersion

public java.lang.String getVersion()
Get the version of this page.

Returns:
The version.

getProducer

public java.lang.String getProducer()
Get the producer of this page.

Returns:
The producer.

getAuthor

public java.lang.String getAuthor()
Get the author of this page.

Returns:
The author.

setAuthor

public void setAuthor(java.lang.String author)
Set the author of this page.

Parameters:
author - A new author.

isModified

public boolean isModified()
if this page is modified.


setModified

public void setModified(boolean modified)
set if this page is modified or unmodified(when save/load).


isHidePorts

public boolean isHidePorts()
if assigned hidding ports .


setHidePorts

public void setHidePorts(boolean hide)
set if hide or show ports.


isDisablePortSnapping

public boolean isDisablePortSnapping()
if assigned disable port snapping.


setDisablePortSnapping

public void setDisablePortSnapping(boolean disable)
set if hide or show ports.


getScaleValue

public double getScaleValue()
Get the scale value, a scale value is something like << 1cm = [scaleValue] * km >>

Returns:
the scale value.

setScaleValue

public void setScaleValue(double scale)
Set the scale value

Parameters:
scale - A new scale value

getScaleUnit

public int getScaleUnit()
Get the scale unit, a scale unit is something like << 1cm = 100 * [scaleUnit] >>

Returns:
the scale unit.

setScaleUnit

public void setScaleUnit(int unit)
Set the scale unit

Parameters:
unit - A new scale unit

getScreenUnit

public int getScreenUnit()
Get the screen unit, a screen unit is something like << 1 * [screenUnit] = 1000 * meter >> We only allowed CM or INch for current screen unit.

Returns:
the screen unit.

setScreenUnit

public void setScreenUnit(int unit)
Set the screen unit We only allowed CM or INch for current screen unit.

Parameters:
unit - A new screen unit

setIsMetric

public void setIsMetric(boolean isMetric)
set scale as metric or english measurement. if the scale units has been modified before, and a scaleUnit is different as a screenUnit, there would be no effects with this method.

Parameters:
isMetric - True if is metric, false english.

getLayerList

public ObjectList getLayerList()
Get the shape list.

Returns:
The shape list.

getPageFormat

public JFPageFormat getPageFormat()
Get page format.

Returns:
The page format.

getCanvasFormat

public CanvasFormat getCanvasFormat()
Get canvas format.

Returns:
The canvas format.

getBounds

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

Returns:
The bounds rectangle.

getCurrentLayer

public JFLayer getCurrentLayer()
Get the current layer.

Returns:
The current layer.

getCurrentLayerIndex

public int getCurrentLayerIndex()
Get the current layer index.

Returns:
The current layer index.

setCurrentLayerIndex

public void setCurrentLayerIndex(int layerIndex)
Set the current layer index.


setDefaultLayerIndex

public void setDefaultLayerIndex()
Consider the default visible layer, then set current layer index on it.


setValue

public void setValue(AbstractObject obj)
Set value by a new object.

Overrides:
setValue in class AbstractObject

draw

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

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

setShowDesign

public void setShowDesign(boolean showDesign)
set if show or hide current object's design info

Overrides:
setShowDesign in class AbstractObject

pickBy

public AbstractObject pickBy(java.awt.Graphics g,
                             JFPoint pnt)
pick up shape object by a position point.

Parameters:
g - A graphics context used to pick some graphics sensitive shapes(e.g. label)
pnt - A JFPoint that intersect or contained in an AbstractObject.

pickBy

public ObjectList pickBy(java.awt.Graphics g,
                         Rect rect)
pick up shape object by a rectangle.

Parameters:
g - A graphics context used to pick some graphics sensitive shapes(e.g. label)
rect - A Rect that intersects or contains one or move AbstractObjects.

portIntersects

public Port portIntersects(JFPoint pnt,
                           AbstractObject avoidParent)
Get which port of current shape that intersects with point pnt.

Parameters:
pnt - A JFPoint used to test intersection.
avoidParent - A specified avoided parent to avoid connected to self.
Returns:
A port of current shape.

portIntersectsList

public java.util.List portIntersectsList(JFPoint pnt)
Get a ports list of alls hapes that intersects with point pnt.

Parameters:
pnt - A JFPoint used to test intersection.
Returns:
A port list.

groupShapes

public AbstractObject groupShapes(java.util.List objList)
Group a selection to one JFGroup object.

Parameters:
objList - a sub collection of this object list.
Returns:
A group object.

ungroupShapes

public java.util.List ungroupShapes(java.util.List objList)
Ungroup a selection to individual objects.

Parameters:
objList - a collection of grouped objects.
Returns:
An individual objects list.

clearAccessTimes

public void clearAccessTimes()
Clear access times, Clear all objects access times of current layer.


setZoomScale

public void setZoomScale(double zoomScale)
set zoom scale

Overrides:
setZoomScale in class AbstractObject
Parameters:
zoomScale - A new zoom scale.

bindPorts

public int bindPorts(JFPoint mousePos)
bind ports at a specified point.

Parameters:
mousePos - Current mouse position.
Returns:
number of ports bound.

unbindPorts

public int unbindPorts(JFPoint mousePos)
unbind ports at a specified point.

Parameters:
mousePos - Current mouse position.
Returns:
number of ports unbound.

sendToBack

public void sendToBack(java.util.List objList)
Send a sub-collection of object list in current layer to back.


bringToFront

public void bringToFront(java.util.List objList)
Send a sub-collection of object list in current layer to back.


insertLayer

public void insertLayer(JFLayer layer,
                        int index)
Insert a new layer to this page.

Parameters:
layer - A new layer
index - A index position for insertion.

addLayer

public void addLayer(JFLayer layer)
Add a new layer to this page.

Parameters:
layer - A new layer

getLayer

public JFLayer getLayer(int index)
Get a specified layer by index.

Parameters:
index - The index of a layer.

getLayerByObjectId

public JFLayer getLayerByObjectId(int objectId)
Get a specified layer by object id.

Parameters:
objectId - The object id of a layer.

removeLayer

public void removeLayer(int index)
Remove a specified layer.

Parameters:
index - The index of a layer.

removeLayerByObjectId

public void removeLayerByObjectId(int objectId)
Remove a specified layer.


getLayerItemList

public java.util.List getLayerItemList()
Get layer items as check items, it's used to be modified by layer setup.

Returns:
A checkItem List.

restoreLayerItemList

public void restoreLayerItemList(java.util.List itemList)
Restore layer items as item backuped in itemList.

Parameters:
itemList - A layer items list backuped.

setLayerItemList

public void setLayerItemList(java.util.List itemList,
                             java.util.List removedItemList)
Set new layer items

Parameters:
itemList - item list that is modified
removedItemList - item list that is removed.

toString

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

Overrides:
toString in class AbstractObject
Returns:
An string represents the content of the object

cloneMe

protected AbstractObject cloneMe()
                          throws java.lang.CloneNotSupportedException
Creates a new AbstractObject of the same class and with the same contents as this object. This method implements the method defined in AbstractObject.

Specified by:
cloneMe in class AbstractObject
Returns:
A clone of this class.
java.lang.CloneNotSupportedException

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Creates a new object of the same class and with the same contents as this object.

Overrides:
clone in class AbstractObject
Returns:
A clone of this instance.
java.lang.CloneNotSupportedException

hashCode

public int hashCode()
Returns the hashcode for this Object.

Overrides:
hashCode in class AbstractObject
Returns:
hash code for this Point2D.

equals

public boolean equals(java.lang.Object obj)
Determines whether or not two objects are equal.

Overrides:
equals in class AbstractObject
Parameters:
obj - an object to be compared with this object
Returns:
true if the object to be compared is an instance of Port and has the same values; false otherwise.

saveToXML

public boolean saveToXML(java.lang.String fileName)
Save this page to an XML file.

Parameters:
fileName - A file name.

saveToXMLString

public java.lang.String saveToXMLString()
Save this page to an XML string.

Returns:
Not null if successfully return a XML string document, null otherwise.

appendChildToDOM

protected void appendChildToDOM(Element element,
                                JFVersion version)
Append necessary xml child for current element, this method will be called internally by toDOM.

Overrides:
appendChildToDOM in class AbstractObject
Parameters:
version - A file version notification so this object can obey the rules to save data.
element - A XML element to append child xml nodes

loadFromXML

public boolean loadFromXML(java.lang.String fileName,
                           java.awt.Component c)
Load this page from an XML file.

Parameters:
fileName - A file name.
c - A component used to help loading some special objects, e.g. image.

loadFromXMLString

public boolean loadFromXMLString(java.lang.String xmlString,
                                 java.awt.Component c)
Load this page from an XML string.Attention: this xml string is already an xml document, but not the file name of an xml file.

Parameters:
xmlString - An xml string.
c - A component used to help loading some special objects, e.g. image.

extractChildFromDOM

protected void extractChildFromDOM(Element element,
                                   JFVersion version)
Extract needed xml child from current element, this method will be called internally by fromDOM.

Overrides:
extractChildFromDOM in class AbstractObject
Parameters:
element - An element used to extract needed xml child
version - A file version notification so this object can obey the rules to fetch data.

saveToBinary

public boolean saveToBinary(java.lang.String fileName)
Save this page to a binary file.

Parameters:
fileName - A file name.

saveToStream

public void saveToStream(JFWriter stream,
                         JFVersion version)
                  throws java.io.IOException
Save this object to a binary stream

Overrides:
saveToStream in class AbstractObject
Parameters:
stream - An binary output stream
version - A file version notification so this object can obey the rules to save data.
Throws:
java.io.IOException

loadFromBinary

public boolean loadFromBinary(java.lang.String fileName,
                              java.awt.Component c)
Load this page from a binary file.

Parameters:
fileName - A file name.
c - A component used to help loading some special objects, e.g. image.

loadFromStream

public void loadFromStream(JFReader stream,
                           boolean skipHead,
                           JFVersion version)
                    throws java.io.IOException
Load object data from a binary stream

Overrides:
loadFromStream in class AbstractObject
Parameters:
stream - An binary input stream
skipHead - Skip head 'TYPE' check, an shape object should always has its own shape-type stored, if this shape-type has already been readed, this loadFromStream should/could not read the type anymore.
version - A file version notification so this object can obey the rules to fetch data.
Throws:
java.io.IOException

finishLoadingImages

public boolean finishLoadingImages(java.awt.Component canvas)
for loading an image, we need to call this finish loading image method to completely create a new image.

Parameters:
canvas - A component for creating an image object.


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