EDU.utwente.CoCompose.lang
Class AbstractConcept

java.lang.Object
  |
  +--EDU.auburn.VGJ.graph.Node
        |
        +--EDU.utwente.CoCompose.lang.AbstractConcept
All Implemented Interfaces:
java.lang.Cloneable, java.awt.image.ImageObserver
Direct Known Subclasses:
Concept, ConstrainedConcept, SolutionRole

public abstract class AbstractConcept
extends Node

The abstract base class for CoCompose design language primitives.

Version:
0.1.18, 22 November 2003
Author:
Dennis Wagelaar

Field Summary
protected  java.util.Set changeListeners
          Change listeners (observers).
protected static java.awt.Color DEFAULT_EDGE_COLOR
          Default edge/link color.
protected static java.awt.Color DEFAULT_FILL_COLOR
          Default shape filling color.
protected static java.awt.Color DEFAULT_FONT_COLOR
          Default font color.
protected static java.awt.Color DEFAULT_SELECT_COLOR
          Default selection rectangle color.
protected  java.lang.String defaultLabel_
          The default label displayed in the model when no name is set.
protected static java.lang.String DefaultLabelPos
          Default label position.
protected static int DefaultShape
          Default shape (oval).
static int FONT_SIZE
          Font size (fixed).
protected  UniqueRealm realm_
          The realm in which identifiers must be unique.
 
Fields inherited from class EDU.auburn.VGJ.graph.Node
BELOW, CENTER, data, data_, defaultDataTypes_, defaults, depth_, groupActive_, groupbox_, groupNode_, groupNodeId_, grouppos_, haveId_, height_, id_, IN, inActiveGroup_, index_, isDummy_, isGroup_, label_, oldbox_, oldpos_, OVAL, RECTANGLE, shapeNames, width_, x_, y_, z_
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
AbstractConcept()
          Constructs a Concept.
 
Method Summary
 void accept(ModelVisitor visitor)
          Accepts a ModelVisitor.
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Adds a PropertyChangeListener (observer) to the list of listeners.
protected  void alignToGrid(DPoint new_position)
          Aligns new coordinates to the grid, if needed.
protected  void alignToGrid(DPoint3 new_position)
          Aligns new coordinates to the grid, if needed.
protected  void commentsToXML(org.xml.sax.helpers.DefaultHandler handler)
          Create XML from the comments attribute using a SAX DefaultHandler.
 void copyAttributes(AbstractConcept fromConcept)
          Copies attributes from fromConcept to self.
 void draw(java.awt.Component comp, java.awt.Graphics graphics, Matrix44 transform, int quality)
          Draws the Concept on a component.
protected  void drawLabel(java.awt.Graphics graphics, int x, int y, double h)
          Draws the label of the concept.
protected  void drawSelected(java.awt.Graphics graphics, DPoint3 position, double scale)
          Draws the selection artifacts of the concept.
protected  void drawShape(java.awt.Graphics graphics, int x, int y, double w, double h)
          Draws the shape of the concept.
protected  void endXML(org.xml.sax.helpers.DefaultHandler handler, java.lang.String element)
          Create XML end from this object using a SAX DefaultHandler and element name.
 java.lang.String getComments()
          Gets comments attribute.
 AbstractConcept getCopiedFrom()
          Gets the AbstractConcept from which this one is copied, if any.
 java.awt.Color getDefaultFillColor()
          Gets default fill color, depending on whether this concept is already part of a role concept or not.
 void getDrawBounds(java.awt.Graphics graphics, Matrix44 transform, DPoint width, DPoint height)
          Get the drawing bounds (including label).
 java.awt.Color getEdgeColor()
          Gets the edge color for drawing.
 java.awt.Color getFillColor()
          Gets the filling color for drawing.
 java.awt.Color getFontColor()
          Gets the font color for drawing.
 AbstractConcept getInstantiatedBy()
          When instantiated from a solution pattern role part, returns what concept instantiated the role part.
 Model getModel()
          Gets the model this concept is part of.
 java.lang.String getName()
          Gets name attribute.
 SolutionRole getPartOf()
          Gets the solution role representing the role part this concept is part of.
 java.lang.String getPublicName()
          Gets the public name attribute, which is the same as the name attribute.
 java.awt.Color getSelectColor()
          Gets the selection artifact color for drawing.
 java.lang.String getSpecification()
          Gets specification attribute.
 java.lang.String getSpecificationLang()
          Gets specification language attribute.
 java.lang.String getTargetLanguage()
          Gets target language to translate the concept to.
 UniqueRealm getUniqueRealm()
          Gets the uniqueness realm.
protected  void gmlToXML(org.xml.sax.helpers.DefaultHandler handler)
          Create XML from the GML data using a SAX DefaultHandler.
protected  void notifyListeners(java.beans.PropertyChangeEvent evt)
          Notifies the PropertyChangeListeners of a PropertyChangeEvent.
protected  void notifyNameChange(java.lang.String oldName, java.lang.String newName)
          Notfies the PropertyChangeListeners of a name change.
protected  void notifyRemovedFromModel()
          Notfies the PropertyChangeListeners that we are removed from this model.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Removes a PropertyChangeListener (observer) from the list of listeners.
protected  void scaleBounds(java.awt.Graphics graphics, double scale)
          Scale the bounds of a Concept if label is put inside.
 void setComments(java.lang.String comments_in)
          Sets comments attribute.
 void setDefaults()
          Sets the defaults for this concept.
 void setEdgeColor(java.awt.Color edgeColor)
          Sets the edge color for drawing.
 void setFillColor(java.awt.Color fillColor)
          Sets the filling color for drawing.
 void setFontColor(java.awt.Color fontColor)
          Sets the font color for drawing.
 void setId(int id)
          Sets Id and initial label as well.
 void setInstantiatedBy(AbstractConcept instantiatedBy)
          Sets what concept instantiated the role part to which this belongs.
 void setLabel()
          Sets the label using the object attributes.
 void setModel(Model model)
          Sets the model this concept is part of.
 void setName(java.lang.String name_in)
          Sets name attribute - sets label as well.
 void setPartOf(SolutionRole role)
          Sets the solution role representing the role part this concept is part of.
 void setPosition(double new_x, double new_y)
          Sets a new position in the model.
 void setPosition(double new_x, double new_y, double new_z)
          Sets a new position in the model.
 void setPosition(DPoint new_position)
          Sets a new position in the model.
 void setPosition(DPoint3 new_position)
          Sets a new position in the model.
 void setSelectColor(java.awt.Color selectColor)
          Sets the selection artifact color for drawing.
 void setSpecification(java.lang.String specification_in)
          Sets specification attribute.
 void setSpecificationLang(java.lang.String specificationLang_in)
          Sets specification language attribute.
 void setUniqueRealm(UniqueRealm realm)
          Sets the uniqueness realm.
 void slide(Matrix44 moveTransform, Matrix44 viewTransform, int xoffs, int yoffs)
          Moves to a new position in the model.
protected  void specToXML(org.xml.sax.helpers.DefaultHandler handler)
          Create XML from the specification attribute using a SAX DefaultHandler.
protected  void startXML(org.xml.sax.helpers.DefaultHandler handler, java.lang.String element, org.xml.sax.helpers.AttributesImpl atts)
          Create XML start from this object using a SAX DefaultHandler, element name and given attributes.
 java.lang.String toPS(Matrix44 transform)
          Generate Postscript code for the node.
 java.lang.String toString()
           
 void toXML(org.xml.sax.helpers.DefaultHandler handler)
          Create XML from this object using a SAX DefaultHandler.
 void unRegister()
          Unregisters all identifiers from the realm.
 
Methods inherited from class EDU.auburn.VGJ.graph.Node
clearChild, clone, copyAttributes, firstChild, getBoundingBox, getBoundingBox3, getChildren, getDefaultLabel, getDrawBounds_, getId, getIdObject, getImage, getImagePixels, getImageSource, getImageType, getIndex, getLabel, getLabelPosition, getPosition, getPosition3, getSelected, getShape, getTemp, getVisibleGroupRoot, groupActive, hasChild, hasChild, imagePS, imageUpdate, inGroup, intersectWithLineTo, isGroup, isVisible, nextChild, numberOfChildren, PSnum_, psString_, saveState, scale, searchNextChild, setBoundingBox, setBoundingBox, setBoundingBox, setBoundingBox, setChild, setContext, setDefaultLabel, setGMLvalues, setGroup, setImage, setImageSource, setImageType, setLabel, setLabelPosition, setSelected, setShape, setTemp, setToolkit, toPSimage
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_EDGE_COLOR

protected static final java.awt.Color DEFAULT_EDGE_COLOR
Default edge/link color.

DEFAULT_FONT_COLOR

protected static final java.awt.Color DEFAULT_FONT_COLOR
Default font color.

DEFAULT_SELECT_COLOR

protected static final java.awt.Color DEFAULT_SELECT_COLOR
Default selection rectangle color.

DEFAULT_FILL_COLOR

protected static final java.awt.Color DEFAULT_FILL_COLOR
Default shape filling color.

DefaultShape

protected static final int DefaultShape
Default shape (oval).

DefaultLabelPos

protected static final java.lang.String DefaultLabelPos
Default label position.

FONT_SIZE

public static final int FONT_SIZE
Font size (fixed).

realm_

protected UniqueRealm realm_
The realm in which identifiers must be unique.

defaultLabel_

protected java.lang.String defaultLabel_
The default label displayed in the model when no name is set.

changeListeners

protected java.util.Set changeListeners
Change listeners (observers).
Constructor Detail

AbstractConcept

public AbstractConcept()
Constructs a Concept.
Method Detail

gmlToXML

protected void gmlToXML(org.xml.sax.helpers.DefaultHandler handler)
                 throws org.xml.sax.SAXException
Create XML from the GML data using a SAX DefaultHandler.
Parameters:
handler - The SAX DefaultHandler.
Throws:
org.xml.sax.SAXException - if an XML handler error occurs.

commentsToXML

protected void commentsToXML(org.xml.sax.helpers.DefaultHandler handler)
                      throws org.xml.sax.SAXException
Create XML from the comments attribute using a SAX DefaultHandler.
Parameters:
handler - The SAX DefaultHandler.
Throws:
org.xml.sax.SAXException - if an XML handler error occurs.

specToXML

protected void specToXML(org.xml.sax.helpers.DefaultHandler handler)
                  throws org.xml.sax.SAXException
Create XML from the specification attribute using a SAX DefaultHandler.
Parameters:
handler - The SAX DefaultHandler.
Throws:
org.xml.sax.SAXException - if an XML handler error occurs.

startXML

protected void startXML(org.xml.sax.helpers.DefaultHandler handler,
                        java.lang.String element,
                        org.xml.sax.helpers.AttributesImpl atts)
                 throws org.xml.sax.SAXException
Create XML start from this object using a SAX DefaultHandler, element name and given attributes.
Parameters:
handler - The SAX DefaultHandler.
element - The XML element name.
atts - The XML element attributes.
Throws:
org.xml.sax.SAXException - if an XML handler error occurs.

endXML

protected void endXML(org.xml.sax.helpers.DefaultHandler handler,
                      java.lang.String element)
               throws org.xml.sax.SAXException
Create XML end from this object using a SAX DefaultHandler and element name.
Parameters:
handler - The SAX DefaultHandler.
element - The XML element name.
atts - The XML element attributes.
Throws:
org.xml.sax.SAXException - if an XML handler error occurs.

scaleBounds

protected void scaleBounds(java.awt.Graphics graphics,
                           double scale)
Scale the bounds of a Concept if label is put inside.
Parameters:
graphics - The graphics context.
scale - The drawing scale.

drawShape

protected void drawShape(java.awt.Graphics graphics,
                         int x,
                         int y,
                         double w,
                         double h)
Draws the shape of the concept.
Parameters:
graphics - The graphics context.
x - The transformed X coordinate.
y - The transformed Y coordinate.
w - The width.
h - The height.

drawLabel

protected void drawLabel(java.awt.Graphics graphics,
                         int x,
                         int y,
                         double h)
Draws the label of the concept.
Parameters:
graphics - The graphics context.
x - The transformed X coordinate.
y - The transformed Y coordinate.
h - The height of the concept shape.

drawSelected

protected void drawSelected(java.awt.Graphics graphics,
                            DPoint3 position,
                            double scale)
Draws the selection artifacts of the concept.
Parameters:
graphics - The graphics context.
position - The transformed coordinates.
scale - The drawing scale.

alignToGrid

protected void alignToGrid(DPoint new_position)
Aligns new coordinates to the grid, if needed.
Parameters:
new_position - The new coordinates.

alignToGrid

protected void alignToGrid(DPoint3 new_position)
Aligns new coordinates to the grid, if needed.
Parameters:
new_position - The new coordinates.

notifyListeners

protected void notifyListeners(java.beans.PropertyChangeEvent evt)
Notifies the PropertyChangeListeners of a PropertyChangeEvent.
Parameters:
evt - The PropertyChangeEvent to send.

notifyNameChange

protected void notifyNameChange(java.lang.String oldName,
                                java.lang.String newName)
Notfies the PropertyChangeListeners of a name change.
Parameters:
oldName - The old name property value.
newName - The new name property value.

notifyRemovedFromModel

protected void notifyRemovedFromModel()
Notfies the PropertyChangeListeners that we are removed from this model.

setDefaults

public void setDefaults()
Sets the defaults for this concept.

setPosition

public void setPosition(double new_x,
                        double new_y)
Sets a new position in the model.
Overrides:
setPosition in class Node
Parameters:
new_x - The new X coordinate.
new_y - The new Y coordinate.

setPosition

public void setPosition(DPoint new_position)
Sets a new position in the model.
Overrides:
setPosition in class Node
Parameters:
new_position - The new coordinates.

setPosition

public void setPosition(double new_x,
                        double new_y,
                        double new_z)
Sets a new position in the model.
Overrides:
setPosition in class Node
Parameters:
new_x - The new X coordinate.
new_y - The new Y coordinate.
new_z - The new Z coordinate.

setPosition

public void setPosition(DPoint3 new_position)
Sets a new position in the model.
Overrides:
setPosition in class Node
Parameters:
new_position - The new coordinates.

slide

public void slide(Matrix44 moveTransform,
                  Matrix44 viewTransform,
                  int xoffs,
                  int yoffs)
Moves to a new position in the model.
Overrides:
slide in class Node
Parameters:
moveTransform - Move transformation matrix - see Node class.
viewTransform - View transformation matrix - see Node class.
xoffs - X offset - see Node class.
yoffs - Y offset - see Node class.

setUniqueRealm

public void setUniqueRealm(UniqueRealm realm)
Sets the uniqueness realm.
Parameters:
realm - The uniqueness realm for identifiers.

getUniqueRealm

public UniqueRealm getUniqueRealm()
Gets the uniqueness realm.
Returns:
The uniqueness realm for identifiers.

setLabel

public void setLabel()
Sets the label using the object attributes.

setModel

public void setModel(Model model)
Sets the model this concept is part of.
Parameters:
model - The model this concept is part of.

getModel

public Model getModel()
Gets the model this concept is part of.
Returns:
The model this concept is part of.

getDefaultFillColor

public java.awt.Color getDefaultFillColor()
Gets default fill color, depending on whether this concept is already part of a role concept or not.
Returns:
The default fill color.

setFillColor

public void setFillColor(java.awt.Color fillColor)
Sets the filling color for drawing.
Parameters:
fillColor - The color.

getFillColor

public java.awt.Color getFillColor()
Gets the filling color for drawing.
Returns:
The filling color for drawing.

setEdgeColor

public void setEdgeColor(java.awt.Color edgeColor)
Sets the edge color for drawing.
Parameters:
edgeColor - The color.

getEdgeColor

public java.awt.Color getEdgeColor()
Gets the edge color for drawing.
Returns:
The edge color for drawing.

setFontColor

public void setFontColor(java.awt.Color fontColor)
Sets the font color for drawing.
Parameters:
fontColor - The color.

getFontColor

public java.awt.Color getFontColor()
Gets the font color for drawing.
Returns:
The font color for drawing.

setSelectColor

public void setSelectColor(java.awt.Color selectColor)
Sets the selection artifact color for drawing.
Parameters:
selectColor - The color.

getSelectColor

public java.awt.Color getSelectColor()
Gets the selection artifact color for drawing.
Returns:
The select color for drawing.

setId

public void setId(int id)
Sets Id and initial label as well.
Overrides:
setId in class Node
Parameters:
id - Node identifier.

getName

public java.lang.String getName()
Gets name attribute.
Returns:
The name attribute.

getPublicName

public java.lang.String getPublicName()
Gets the public name attribute, which is the same as the name attribute.
Returns:
The public name attribute.

setName

public void setName(java.lang.String name_in)
             throws CoComposeException
Sets name attribute - sets label as well.
Parameters:
name_in - The new name.
Throws:
CoComposeException - if the name is not a valid unique identifier.

getComments

public java.lang.String getComments()
Gets comments attribute.
Returns:
The comments attribute.

setComments

public void setComments(java.lang.String comments_in)
Sets comments attribute.
Parameters:
comments_in - The new comments.

getSpecification

public java.lang.String getSpecification()
Gets specification attribute.
Returns:
The specification attribute.

setSpecification

public void setSpecification(java.lang.String specification_in)
Sets specification attribute.
Parameters:
specification_in - The new specification.

getSpecificationLang

public java.lang.String getSpecificationLang()
Gets specification language attribute.
Returns:
The specification language attribute.

setSpecificationLang

public void setSpecificationLang(java.lang.String specificationLang_in)
Sets specification language attribute.
Parameters:
specificationLang_in - The new specification language.

getCopiedFrom

public AbstractConcept getCopiedFrom()
Gets the AbstractConcept from which this one is copied, if any.
Returns:
the AbstractConcept from which this one is copied, if any, null otherwise.

setPartOf

public void setPartOf(SolutionRole role)
Sets the solution role representing the role part this concept is part of.
Parameters:
role - The solution role this concept is part of.

getPartOf

public SolutionRole getPartOf()
Gets the solution role representing the role part this concept is part of.
Returns:
The solution role this concept is part of.

copyAttributes

public void copyAttributes(AbstractConcept fromConcept)
Copies attributes from fromConcept to self.
Parameters:
fromConcept - The Concept to copy the attributes from.

draw

public void draw(java.awt.Component comp,
                 java.awt.Graphics graphics,
                 Matrix44 transform,
                 int quality)
Draws the Concept on a component.
Overrides:
draw in class Node
Parameters:
comp - The component to draw upon.
graphics - The graphics context.
transform - The coordinate transformation matrix.
quality - The drawing quality.

toXML

public void toXML(org.xml.sax.helpers.DefaultHandler handler)
           throws org.xml.sax.SAXException
Create XML from this object using a SAX DefaultHandler.
Parameters:
handler - The SAX DefaultHandler.
Throws:
org.xml.sax.SAXException - if an XML handler error occurs.

unRegister

public void unRegister()
Unregisters all identifiers from the realm.

toPS

public java.lang.String toPS(Matrix44 transform)
Generate Postscript code for the node.
Overrides:
toPS in class Node
Parameters:
transform - The coordinate transformation matrix (3D -> 2D).
Returns:
The Postscript representation.

getDrawBounds

public void getDrawBounds(java.awt.Graphics graphics,
                          Matrix44 transform,
                          DPoint width,
                          DPoint height)
Get the drawing bounds (including label).
Parameters:
graphics - The graphics context to measure for.
transform - The coordinate transformation matrix.
width - The variable to store the width.
height - The variable to store the height.

getTargetLanguage

public java.lang.String getTargetLanguage()
Gets target language to translate the concept to. Retrieved from model.
Returns:
The target language.

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a PropertyChangeListener (observer) to the list of listeners.
Parameters:
l - The PropertyChangeListener to add.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes a PropertyChangeListener (observer) from the list of listeners.
Parameters:
l - The PropertyChangeListener to remove.

accept

public void accept(ModelVisitor visitor)
            throws CoComposeException
Accepts a ModelVisitor.
Parameters:
visitor - The visitor object to accept.
Throws:
CoComposeException - if visiting operation failed.

getInstantiatedBy

public AbstractConcept getInstantiatedBy()
When instantiated from a solution pattern role part, returns what concept instantiated the role part. Otherwise returns null. Note that this is a volatile property and won't be saved with a model.
Returns:
The concept that instantiated this or null.

setInstantiatedBy

public void setInstantiatedBy(AbstractConcept instantiatedBy)
Sets what concept instantiated the role part to which this belongs. Note that this is a volatile property and won't be saved with a model.
Parameters:
instantiatedBy - The concept that instantiated this.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()