EDU.utwente.CoCompose.lang
Class Composite

java.lang.Object
  extended byEDU.auburn.VGJ.graph.Node
      extended byEDU.utwente.CoCompose.lang.AbstractConcept
          extended byEDU.utwente.CoCompose.lang.ConstrainedConcept
              extended byEDU.utwente.CoCompose.lang.Composite
All Implemented Interfaces:
java.lang.Cloneable, java.awt.image.ImageObserver, UniqueRealm
Direct Known Subclasses:
CompositeType

public class Composite
extends ConstrainedConcept
implements UniqueRealm

The CoCompose design language primitive Composite.

Version:
0.1.22, 12 August 2004
Author:
Dennis Wagelaar

Field Summary
protected static java.lang.String DefaultLabelPos
          Default label position.
protected static int DefaultShape
          Default Composite shape (rectangle).
 
Fields inherited from class EDU.utwente.CoCompose.lang.AbstractConcept
changeListeners, DEFAULT_EDGE_COLOR, DEFAULT_FILL_COLOR, DEFAULT_FONT_COLOR, DEFAULT_SELECT_COLOR, defaultLabel_, FONT_SIZE, realm_
 
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
Composite()
          Constructs a Composite.
 
Method Summary
 void accept(ModelVisitor visitor)
          Accepts a ModelVisitor.
 void addImplementation(ImplementationGenerator implementation)
          Adds an implementation generator for this composite.
 void addPartConcept(CompositePartConcept concept)
          Adds a CompositePartConcept to this Composite and saves position offset.
 void addSolution(SolutionPattern solution)
          Adds a solution pattern for this composite.
 void checkCompleteness()
          Checks the completeness of the composite using default rules and the specific CompletenessConstraint, if it exists.
 void copyAttributes(Composite fromComposite)
          Copies attributes from fromComposite to self.
 void copyTypeAttributes(Composite fromComposite)
          Copies attributes from fromComposite to self.
 void draw(java.awt.Component comp, java.awt.Graphics graphics, Matrix44 transform, int quality)
          Draws the Composite on a component.
protected  void drawIcon(java.awt.Graphics graphics, int x, int y, double scale)
          Draws the icon of the composite, if any.
 javax.swing.ImageIcon getIcon()
          Gets the composite type icon.
 java.util.Enumeration getImplementations()
          Gets the implementation generators for this composite.
 java.util.Enumeration getImplementations(java.lang.String language)
          Gets the implementation generators for this composite given the language.
 CompositePartConcept getPartConcept(java.lang.String name)
          Gets a CompositePartConcept in this composite by name.
 java.util.Enumeration getPartConcepts()
          Gets an enumeration of all the CompositePartConcepts in this composite.
 PublishedConcept getPublishedConcept(java.lang.String name)
          Gets a published concept in this composite by name.
 java.util.Enumeration getPublishedConcepts()
          Gets an enumeration of all the published concepts in this composite.
 CompositeRole getRole(java.lang.String name)
          Gets a role in this composite by name.
 java.util.Enumeration getRoles()
          Gets an enumeration of all the roles in this composite.
 boolean getShowIconOnly()
          Gets show icon only attribute.
 java.util.Enumeration getSolutions()
          Gets the solution patterns for this composite.
 java.lang.String getType()
          Gets type attribute.
 UniqueRealm getTypeUniqueRealm()
          Gets the type uniqueness realm.
 boolean hasImplementations(java.lang.String language)
          Checks if there are implementation generators for this composite in the given language.
 boolean hasPartConcept(CompositePartConcept concept)
          Checks whether this composite has the given CompositePartConcept.
 boolean hasSolutions()
          Checks whether this composite has solution patterns.
 java.lang.String imagePS()
          Gets the Postscript representation for the type image.
protected  void implementationsToXML(org.xml.sax.helpers.DefaultHandler handler)
          Create XML from the implementation generators using a SAX DefaultHandler.
 void insertImplementation(ImplementationGenerator implementation, int index)
          Inserts an implementation generator for this composite on a given index.
 void insertSolution(SolutionPattern solution, int index)
          Inserts a solution pattern for this composite on a given index.
 boolean isDependent()
          Checks whether this composite depends on other composites through using their published concepts.
 boolean isUnique(java.lang.String value)
          Checks whether the given value is unique within the realm.
protected  void publishedToXML(org.xml.sax.helpers.DefaultHandler handler)
          Create XML from the published concepts using a SAX DefaultHandler.
 void register(java.lang.String value)
          Registers a new value in the realm.
 void removeImplementation(ImplementationGenerator implementation)
          Removes an implementation generator for this composite.
 void removePartConcept(CompositePartConcept concept)
          Removes a CompositePartConcept from this Composite.
 void removeSolution(SolutionPattern solution)
          Removes a solution pattern for this composite.
 void restoreOffsets()
          Restores the offset coordinates from all roles relative to this composite.
protected  void rolesToXML(org.xml.sax.helpers.DefaultHandler handler)
          Create XML from the composite roles using a SAX DefaultHandler.
 void saveOffsets()
          Saves the offset coordinates from all roles and published concepts relative to this composite.
 void scale(double scalex, double scaley, double scalez)
          Scales the size of the Composite.
 void setDefaults()
          Sets the defaults for this composite.
 void setIcon(javax.swing.ImageIcon icon)
          Sets the composite type icon.
 void setLabel()
          Sets the label using the object attributes.
 void setSelected(boolean selected)
          Sets this composite as selected or unselected.
 void setShowIconOnly(boolean showIconOnly)
          Sets show icon only attribute.
 void setType(java.lang.String type_in)
          Sets type attribute.
 void setTypeUniqueRealm(UniqueRealm realm)
          Sets the type uniqueness realm.
protected  void solutionsToXML(org.xml.sax.helpers.DefaultHandler handler)
          Create XML from the solution patterns 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 toPSimage(Matrix44 transform)
          Create the PostScript invocation for the image.
 void toXML(org.xml.sax.helpers.DefaultHandler handler)
          Create XML from this object using a SAX DefaultHandler.
 void unRegister(java.lang.String value)
          Unregisters a value from the realm.
 void updateAttributes(Composite fromComposite)
          Updates attributes from fromComposite to self.
protected  void updateLangImplTable()
          Updates the language => implementations lookup table.
 
Methods inherited from class EDU.utwente.CoCompose.lang.ConstrainedConcept
checkConstraint, checkCorrectness, copyAttributes, getCompletenessConstraint, getCorrectnessConstraint, setCompletenessConstraint, setCorrectnessConstraint, updateAttributes
 
Methods inherited from class EDU.utwente.CoCompose.lang.AbstractConcept
addPropertyChangeListener, alignToGrid, alignToGrid, commentsToXML, copyAttributes, drawLabel, drawSelected, drawShape, endXML, getComments, getCopiedFrom, getDefaultFillColor, getDrawBounds, getEdgeColor, getFillColor, getFirstCopiedFrom, getFontColor, getInstantiatedBy, getLastCopiedFrom, getModel, getName, getPartOf, getPublicName, getSelectColor, getSpecification, getSpecificationLang, getTargetLanguage, getUniqueRealm, gmlToXML, isCopiedFrom, notifyListeners, notifyNameChange, notifyRemovedFromModel, removePropertyChangeListener, scaleBounds, setComments, setEdgeColor, setFillColor, setFontColor, setId, setInstantiatedBy, setModel, setName, setPartOf, setPosition, setPosition, setPosition, setPosition, setSelectColor, setSpecification, setSpecificationLang, setUniqueRealm, slide, specToXML, toPS, toString, unRegister
 
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, searchNextChild, setBoundingBox, setBoundingBox, setBoundingBox, setBoundingBox, setChild, setContext, setDefaultLabel, setGMLvalues, setGroup, setImage, setImageSource, setImageType, setLabel, setLabelPosition, setShape, setTemp, setToolkit, toPSimage
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface EDU.utwente.CoCompose.util.UniqueRealm
getName
 

Field Detail

DefaultShape

protected static final int DefaultShape
Default Composite shape (rectangle).

See Also:
Constant Field Values

DefaultLabelPos

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

See Also:
Constant Field Values
Constructor Detail

Composite

public Composite()
Constructs a Composite.

Method Detail

drawIcon

protected void drawIcon(java.awt.Graphics graphics,
                        int x,
                        int y,
                        double scale)
Draws the icon of the composite, if any.

Parameters:
graphics - The graphics context.
x - The transformed X coordinate.
y - The transformed Y coordinate.
scale - The drawing scale.

rolesToXML

protected void rolesToXML(org.xml.sax.helpers.DefaultHandler handler)
                   throws org.xml.sax.SAXException
Create XML from the composite roles using a SAX DefaultHandler.

Parameters:
handler - The SAX DefaultHandler.
Throws:
org.xml.sax.SAXException - if an XML handler error occurs.

publishedToXML

protected void publishedToXML(org.xml.sax.helpers.DefaultHandler handler)
                       throws org.xml.sax.SAXException
Create XML from the published concepts using a SAX DefaultHandler.

Parameters:
handler - The SAX DefaultHandler.
Throws:
org.xml.sax.SAXException - if an XML handler error occurs.

solutionsToXML

protected void solutionsToXML(org.xml.sax.helpers.DefaultHandler handler)
                       throws org.xml.sax.SAXException
Create XML from the solution patterns using a SAX DefaultHandler.

Parameters:
handler - The SAX DefaultHandler.
Throws:
org.xml.sax.SAXException - if an XML handler error occurs.

implementationsToXML

protected void implementationsToXML(org.xml.sax.helpers.DefaultHandler handler)
                             throws org.xml.sax.SAXException
Create XML from the implementation generators 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.

Overrides:
startXML in class ConstrainedConcept
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.

updateLangImplTable

protected void updateLangImplTable()
Updates the language => implementations lookup table.


setDefaults

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

Overrides:
setDefaults in class AbstractConcept

setLabel

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

Overrides:
setLabel in class AbstractConcept

setTypeUniqueRealm

public void setTypeUniqueRealm(UniqueRealm realm)
Sets the type uniqueness realm.

Parameters:
realm - The uniqueness realm for type identifiers.

getTypeUniqueRealm

public UniqueRealm getTypeUniqueRealm()
Gets the type uniqueness realm.

Returns:
The uniqueness realm for type identifiers.

getType

public java.lang.String getType()
Gets type attribute.

Returns:
The type attribute.

setType

public void setType(java.lang.String type_in)
             throws CoComposeException
Sets type attribute.

Parameters:
type_in - The new type.
Throws:
CoComposeException - if the type is not a valid identifier.

setIcon

public void setIcon(javax.swing.ImageIcon icon)
Sets the composite type icon.

Parameters:
icon - the composite type icon.

getIcon

public javax.swing.ImageIcon getIcon()
Gets the composite type icon.

Returns:
the composite type icon.

setShowIconOnly

public void setShowIconOnly(boolean showIconOnly)
Sets show icon only attribute.

Parameters:
showIconOnly - Whether or not to show only the composite icon.

getShowIconOnly

public boolean getShowIconOnly()
Gets show icon only attribute.

Returns:
Whether or not to show only the composite icon.

addPartConcept

public void addPartConcept(CompositePartConcept concept)
Adds a CompositePartConcept to this Composite and saves position offset.

Parameters:
concept - The CompositePartConcept to be added.

removePartConcept

public void removePartConcept(CompositePartConcept concept)
Removes a CompositePartConcept from this Composite.

Parameters:
concept - The CompositePartConcept to be removed.

getPartConcepts

public java.util.Enumeration getPartConcepts()
Gets an enumeration of all the CompositePartConcepts in this composite.

Returns:
An Enumeration of the composite part concepts.

hasPartConcept

public boolean hasPartConcept(CompositePartConcept concept)
Checks whether this composite has the given CompositePartConcept.

Parameters:
concept - The composite part concept to check for.
Returns:
True if and only if the composite contains the composite part concept.

getPartConcept

public CompositePartConcept getPartConcept(java.lang.String name)
Gets a CompositePartConcept in this composite by name.

Parameters:
name - The CompositePartConcept name.
Returns:
The CompositePartConcept.

getRole

public CompositeRole getRole(java.lang.String name)
Gets a role in this composite by name.

Parameters:
name - The composite role name.
Returns:
The role.

getRoles

public java.util.Enumeration getRoles()
Gets an enumeration of all the roles in this composite.

Returns:
An Enumeration of the roles.

getPublishedConcepts

public java.util.Enumeration getPublishedConcepts()
Gets an enumeration of all the published concepts in this composite.

Returns:
An Enumeration of the published concepts.

getPublishedConcept

public PublishedConcept getPublishedConcept(java.lang.String name)
Gets a published concept in this composite by name.

Parameters:
name - The published concept name.
Returns:
The published concept.

setSelected

public void setSelected(boolean selected)
Sets this composite as selected or unselected. Sets roles selection as well.

Overrides:
setSelected in class Node
Parameters:
selected - When true, sets this composite as selected, otherwise unselected.

addSolution

public void addSolution(SolutionPattern solution)
Adds a solution pattern for this composite.

Parameters:
solution - The solution pattern to add.

insertSolution

public void insertSolution(SolutionPattern solution,
                           int index)
Inserts a solution pattern for this composite on a given index.

Parameters:
solution - The solution pattern to insert.
index - The index on which to insert the solution pattern.

removeSolution

public void removeSolution(SolutionPattern solution)
Removes a solution pattern for this composite.

Parameters:
solution - The solution pattern to remove.

getSolutions

public java.util.Enumeration getSolutions()
Gets the solution patterns for this composite.

Returns:
The solution patterns for this composite.

hasSolutions

public boolean hasSolutions()
Checks whether this composite has solution patterns.

Returns:
True if it has solution patterns.

addImplementation

public void addImplementation(ImplementationGenerator implementation)
Adds an implementation generator for this composite.

Parameters:
implementation - The implementation generator to add.

insertImplementation

public void insertImplementation(ImplementationGenerator implementation,
                                 int index)
Inserts an implementation generator for this composite on a given index.

Parameters:
implementation - The implementation generator to insert.
index - The index on which to insert the implementation generator.

removeImplementation

public void removeImplementation(ImplementationGenerator implementation)
Removes an implementation generator for this composite.

Parameters:
implementation - The implementation generator to remove.

getImplementations

public java.util.Enumeration getImplementations()
Gets the implementation generators for this composite.

Returns:
The implementation generators for this composite.

getImplementations

public java.util.Enumeration getImplementations(java.lang.String language)
Gets the implementation generators for this composite given the language.

Parameters:
language - The language in which the implementation generators should be expressed.
Returns:
The implementation generators in the given language for this composite.

hasImplementations

public boolean hasImplementations(java.lang.String language)
Checks if there are implementation generators for this composite in the given language.

Parameters:
language - The language in which the implementation generators should be expressed.
Returns:
True if there are implementations generators.

saveOffsets

public void saveOffsets()
Saves the offset coordinates from all roles and published concepts relative to this composite.


restoreOffsets

public void restoreOffsets()
Restores the offset coordinates from all roles relative to this composite.


copyAttributes

public void copyAttributes(Composite fromComposite)
                    throws CoComposeException
Copies attributes from fromComposite to self.

Parameters:
fromComposite - The Composite to copy the attributes from.
Throws:
CoComposeException - if the copy could not be made.

copyTypeAttributes

public void copyTypeAttributes(Composite fromComposite)
                        throws CoComposeException
Copies attributes from fromComposite to self. Copies type-sepcific attributes only and resets the name and public names of published concepts.

Parameters:
fromComposite - The Composite to copy the attributes from.
Throws:
CoComposeException - if the copy could not be made.

updateAttributes

public void updateAttributes(Composite fromComposite)
                      throws CoComposeException
Updates attributes from fromComposite to self. Assumes this composite is already in use within a model and only needs the attributes copied, which are specific for its type.

Parameters:
fromComposite - The Composite to copy the attributes from.
Throws:
CoComposeException - if the copy could not be made.

scale

public void scale(double scalex,
                  double scaley,
                  double scalez)
Scales the size of the Composite. Also enforces boundary check on the composite part concepts.

Overrides:
scale in class Node
Parameters:
scalex - The X axis scale multiplier.
scaley - The Y axis scale multiplier.
scalez - The Z axis scale multiplier.

draw

public void draw(java.awt.Component comp,
                 java.awt.Graphics graphics,
                 Matrix44 transform,
                 int quality)
Draws the Composite on a component.

Overrides:
draw in class AbstractConcept
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.

Overrides:
toXML in class AbstractConcept
Parameters:
handler - The SAX DefaultHandler.
Throws:
org.xml.sax.SAXException - if an XML handler error occurs.

checkCompleteness

public void checkCompleteness()
                       throws CoComposeException
Checks the completeness of the composite using default rules and the specific CompletenessConstraint, if it exists.

Overrides:
checkCompleteness in class ConstrainedConcept
Throws:
CoComposeException - if the composite is not completely specified.

isUnique

public boolean isUnique(java.lang.String value)
Checks whether the given value is unique within the realm.

Specified by:
isUnique in interface UniqueRealm
Parameters:
value - The value to check.
Returns:
True if and only if the value is unique within the realm.

register

public void register(java.lang.String value)
Registers a new value in the realm.

Specified by:
register in interface UniqueRealm
Parameters:
value - The value to register.

unRegister

public void unRegister(java.lang.String value)
Unregisters a value from the realm.

Specified by:
unRegister in interface UniqueRealm
Parameters:
value - The value to unregister.

imagePS

public java.lang.String imagePS()
Gets the Postscript representation for the type image.

Returns:
The Postscript representation.

toPSimage

public java.lang.String toPSimage(Matrix44 transform)
Create the PostScript invocation for the image.

Parameters:
transform - The coordinate transformation matrix.
Returns:
The postscript representation.

accept

public void accept(ModelVisitor visitor)
            throws CoComposeException
Accepts a ModelVisitor.

Overrides:
accept in class ConstrainedConcept
Parameters:
visitor - The visitor object to accept.
Throws:
CoComposeException - if visiting operation failed.

isDependent

public boolean isDependent()
Checks whether this composite depends on other composites through using their published concepts.

Returns:
true - if the composite has dependencies.