ConForM.CoopnTools.CoKer.Visual
Class GraphicalPicture

java.lang.Object
  |
  +--ConForM.CoopnTools.CoKer.Visual.GraphicalPicture
All Implemented Interfaces:
GraphicalVisualRenderable, GraphicalVisualRenderableGroup, javax.swing.undo.StateEditable
Direct Known Subclasses:
CoopnClassModel, CoopnEnrichmentGraph, CoopnObjectModel, ScenarioGraph

public abstract class GraphicalPicture
extends java.lang.Object
implements javax.swing.undo.StateEditable, GraphicalVisualRenderableGroup

Graphical Visual Picture. A picture represents a model with an aspect. A picture has all information needed by a garphical visual to work. In addition, a picture is a renderable group; it is a kind of top-level container for the elements. This class is an abstract class; however, the methods of renderable are implemented. Coordinates of elements are given in the so-called logical space, i.e. without zooming, and distances expressed in logical coordinates, like in Aspects (1 inch = 81,92 logical units). When drawing itself, a component may be obliged to transform its coordinates in the so-called PHYSICAL space; this transformation is actually a simple affine transformation (a multiplication by an integer constant and an offset).


Fields inherited from interface javax.swing.undo.StateEditable
RCSID
 
Constructor Summary
GraphicalPicture()
           
 
Method Summary
 void actionOnMultipleClick(java.awt.event.MouseEvent e, java.awt.Point location, GraphicalVisualEditor editor)
          Multiple click callback.
 void addComponent(GraphicalVisualElement component)
          Add a component.
 java.awt.Rectangle boundingBox()
          Get the bounding box.
 void componentChanged(GraphicalVisualElement component)
          Notification of the modification of a component BoundingBox.
 GraphicalVisualElement[] components()
          Get the contained elements.
 void deselect()
          Deselect the element, along with its label and information field.
abstract  void dispose()
          Leave a picture.
 void export(GraphicalExporter g)
          Exporting method.
abstract  java.lang.String name()
          Get the name of the picture.
abstract  GraphicalPicture open(java.lang.String aspectName)
          Open the picture using a specified aspect name.
abstract  boolean openPossible()
          Look if the picture is able to perform an open.
abstract  PackageMgr packageMgr()
          Get the package manager used to access the package of the model associated to this picture.
abstract  java.lang.String packageName()
          Get the name of the package of the model associated to this picture; may be null iff no package.
 void paint(java.awt.Graphics2D g, boolean selected)
          Painting method.
 GraphicalVisualRenderable pointedElement(java.awt.Point p)
          Look if the renderable contains a point.
 void print(java.awt.Graphics2D g)
          Printing method.
 void removeComponent(GraphicalVisualElement component)
          Remove a component.
 GraphicalPicture reOpen()
          Re-open the picture using its default aspect name.
abstract  boolean reOpenPossible()
          Look if the picture is able to perform a re-open.
 void restoreState(java.util.Hashtable state)
          Restore the state, by delegating this op to the elements.
 boolean save()
          Save the aspect of the picture, under the current aspect name
abstract  boolean saveAs(java.lang.String aspectName)
          Save the aspect of the picture, as a particular aspect name.
 void saveAspect()
          Start a save process.
 void saveAspectAs(java.lang.String aspectName)
          Save the aspect of the renderable as a specified name.
 boolean saveAspectAsPossible()
          look if this renderable is able to save itself as a specified name.
 boolean saveAspectPossible()
          look if this renderable is able to save itself.
abstract  boolean saveAsPossible()
          Look if the picture is able to save its aspect under a specified name.
abstract  boolean savePossible()
          Look if the picture is able to save its aspect.
 void selectElement()
          Select the element.
 void selectInfo()
          Select the information field of the element.
 void selectLabel()
          Select the label of the element.
 void setEditables(GraphicalVisualElement[] components)
          Set the components of the picture
abstract  javax.swing.Action[] specificAction()
          Get the specific actions to put in the tool bar.
abstract  javax.swing.JMenuItem[] specificEditMenu()
          Get the specific edit menu.
abstract  javax.swing.JMenuItem[] specificFileMenu()
          Get the specific file menu.
abstract  javax.swing.JMenuItem[] specificHelpMenu()
          Get the specific help menu.
abstract  javax.swing.JMenu[] specificMenu()
          Get the specific menus.
 javax.swing.KeyStroke specificPictureAcceleratorKey()
          Specific menu item accelerator.
 javax.swing.KeyStroke specificPictureAcceleratorKey2()
          Second specific menu item accelerator.
 javax.swing.JMenuItem[] specificPopup()
          Get the specific items of the popup menu of this renderable.
abstract  javax.swing.JMenuItem[] specificViewMenu()
          Get the specific view menu.
 void storeState(java.util.Hashtable state)
          Store the state, by delegating this op to the elements.
abstract  java.lang.String title()
          Get the title of the graph.
abstract  void use()
          Uses a picture.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphicalPicture

public GraphicalPicture()
Method Detail

use

public abstract void use()
Uses a picture.

dispose

public abstract void dispose()
Leave a picture. This method release the resources used by the picture, if it is not used any more.

packageName

public abstract java.lang.String packageName()
Get the name of the package of the model associated to this picture; may be null iff no package.

packageMgr

public abstract PackageMgr packageMgr()
Get the package manager used to access the package of the model associated to this picture.

reOpenPossible

public abstract boolean reOpenPossible()
Look if the picture is able to perform a re-open.
Returns:
true iff reOpen is possible

reOpen

public GraphicalPicture reOpen()
Re-open the picture using its default aspect name.
Returns:
a new picture, reflecting the same model, or null if the operation fails.

openPossible

public abstract boolean openPossible()
Look if the picture is able to perform an open.
Returns:
true iff open is possible

open

public abstract GraphicalPicture open(java.lang.String aspectName)
Open the picture using a specified aspect name.
Parameters:
aspectName - the name of the aspect to use; a NULL value means the default aspect name
Returns:
a new picture, reflecting the same model, or null if the operation fails.

savePossible

public abstract boolean savePossible()
Look if the picture is able to save its aspect.
Returns:
true iff save is possible

save

public boolean save()
Save the aspect of the picture, under the current aspect name
Returns:
true iff the save succeeded. The save is considered as successful even if no save was performed because a default aspect name was asked and no default aspect name exists.

saveAsPossible

public abstract boolean saveAsPossible()
Look if the picture is able to save its aspect under a specified name.
Returns:
true iff saveAs is possible

saveAs

public abstract boolean saveAs(java.lang.String aspectName)
Save the aspect of the picture, as a particular aspect name.
Parameters:
aspectName - the name of the aspect to use; a NULL value means the current aspect name.
Returns:
true iff the save succeeded. The save is considered as successful even if no save was performed because a default aspect name was asked and no default aspect name exists.

title

public abstract java.lang.String title()
Get the title of the graph.
Returns:
the title of the graph.

name

public abstract java.lang.String name()
Get the name of the picture.
Returns:
the name of the picture.

specificPictureAcceleratorKey

public final javax.swing.KeyStroke specificPictureAcceleratorKey()
Specific menu item accelerator. The specific menu items of the picture should not define keyboard accelerators, to prevent conflicts with the graphical visual accelerators. The exception is the keystroke returned by this method and by specificPictureAcceleratorKey2(), free to be used by the picture as an accelerator.

specificPictureAcceleratorKey2

public final javax.swing.KeyStroke specificPictureAcceleratorKey2()
Second specific menu item accelerator. The specific menu items of the picture should not define keyboard accelerators, to prevent conflicts with the graphical visual accelerators. The exception is the keystroke returned by this method and by specificPictureAcceleratorKey(), free to be used by the picture as an accelerator.

specificFileMenu

public abstract javax.swing.JMenuItem[] specificFileMenu()
Get the specific file menu.
Returns:
the specific file menu. Any element member of the interface GraphicalVisualEditoredMenuItem has its editor set by the editor associated to this renderable.

specificEditMenu

public abstract javax.swing.JMenuItem[] specificEditMenu()
Get the specific edit menu.
Returns:
the specific edit menu. Any element member of the interface GraphicalVisualEditoredMenuItem has its editor set by the editor associated to this renderable.

specificViewMenu

public abstract javax.swing.JMenuItem[] specificViewMenu()
Get the specific view menu.
Returns:
the specific view menu. Any element member of the interface GraphicalVisualEditoredMenuItem has its editor set by the editor associated to this renderable.

specificHelpMenu

public abstract javax.swing.JMenuItem[] specificHelpMenu()
Get the specific help menu.
Returns:
the specific help menu. Any element member of the interface GraphicalVisualEditoredMenuItem has its editor set by the editor associated to this renderable.

specificMenu

public abstract javax.swing.JMenu[] specificMenu()
Get the specific menus.
Returns:
the specific menus. Any element member of the interface GraphicalVisualEditoredMenuItem has its editor set by the editor associated to this renderable.

specificAction

public abstract javax.swing.Action[] specificAction()
Get the specific actions to put in the tool bar.
Returns:
the specific action. Any element member of the interface GraphicalVisualEditoredMenuItem has its editor set by the editor associated to this renderable.

addComponent

public void addComponent(GraphicalVisualElement component)
Add a component.
Specified by:
addComponent in interface GraphicalVisualRenderableGroup

removeComponent

public void removeComponent(GraphicalVisualElement component)
Remove a component.
Specified by:
removeComponent in interface GraphicalVisualRenderableGroup

setEditables

public void setEditables(GraphicalVisualElement[] components)
Set the components of the picture
Parameters:
components - the components of the picture; cannot be null

components

public GraphicalVisualElement[] components()
Get the contained elements.
Specified by:
components in interface GraphicalVisualRenderableGroup
Returns:
an array, possibly empty, of the contained elements. Never null.

storeState

public void storeState(java.util.Hashtable state)
Store the state, by delegating this op to the elements.
Specified by:
storeState in interface javax.swing.undo.StateEditable

restoreState

public void restoreState(java.util.Hashtable state)
Restore the state, by delegating this op to the elements.
Specified by:
restoreState in interface javax.swing.undo.StateEditable

selectElement

public void selectElement()
Select the element.
Specified by:
selectElement in interface GraphicalVisualRenderable

selectLabel

public void selectLabel()
Select the label of the element.
Specified by:
selectLabel in interface GraphicalVisualRenderable

selectInfo

public void selectInfo()
Select the information field of the element.
Specified by:
selectInfo in interface GraphicalVisualRenderable

deselect

public void deselect()
Deselect the element, along with its label and information field.
Specified by:
deselect in interface GraphicalVisualRenderable

saveAspectPossible

public boolean saveAspectPossible()
look if this renderable is able to save itself. If true, such an object is able to contact the correct aspect manager for saving its aspect.
Specified by:
saveAspectPossible in interface GraphicalVisualRenderable
Returns:
true iff this renderable is able to save itself.

saveAspect

public void saveAspect()
Start a save process.
Specified by:
saveAspect in interface GraphicalVisualRenderable

saveAspectAsPossible

public boolean saveAspectAsPossible()
look if this renderable is able to save itself as a specified name. If true, such an object is able to changes its aspect name, and to contact the correct aspect manager for saving its aspect under that name.
Specified by:
saveAspectAsPossible in interface GraphicalVisualRenderable
Returns:
true iff this renderable is able to save itself.

saveAspectAs

public void saveAspectAs(java.lang.String aspectName)
Save the aspect of the renderable as a specified name. When receiving this event, the renderable must adopt its new aspect name, and try to save its aspect under that name.
Specified by:
saveAspectAs in interface GraphicalVisualRenderable
Parameters:
aspectName - the new aspect name to use

componentChanged

public void componentChanged(GraphicalVisualElement component)
Notification of the modification of a component BoundingBox.
Specified by:
componentChanged in interface GraphicalVisualRenderableGroup

boundingBox

public java.awt.Rectangle boundingBox()
Get the bounding box. The bounding box is the total rectangle containing the renderable, its label and its information field.
Specified by:
boundingBox in interface GraphicalVisualRenderable
Returns:
the bounding box of the element, as a rectangle in the logical coordinate space.

pointedElement

public GraphicalVisualRenderable pointedElement(java.awt.Point p)
Look if the renderable contains a point. If the renderable has components, this routine should return the most accurate component in which this point is "inside".
Specified by:
pointedElement in interface GraphicalVisualRenderable
Parameters:
point - the point in logicial coordinates; cannot be null
Returns:
null if the point is not contained in this renderable, the identifier of the smallest included renderable containing the point else.

specificPopup

public javax.swing.JMenuItem[] specificPopup()
Get the specific items of the popup menu of this renderable.
Specified by:
specificPopup in interface GraphicalVisualRenderable
Returns:
an array of GraphicalVisualMenuItem. A null value or an empty array mean that the renderable as no specific popup elements.

actionOnMultipleClick

public void actionOnMultipleClick(java.awt.event.MouseEvent e,
                                  java.awt.Point location,
                                  GraphicalVisualEditor editor)
Multiple click callback. This routine is called by the graphical visual when it detects a multiple click on this renderable.
Specified by:
actionOnMultipleClick in interface GraphicalVisualRenderable
Parameters:
e - the mouse event
location - the location of the event, in logical space
editor - the assicated editor

paint

public void paint(java.awt.Graphics2D g,
                  boolean selected)
Painting method. This routine is called when the renderable must paint itself inside the graphics. The renderable paint either its selected parts or its un-selected parts on the graphics. The renderable draws on the graphics in logical coordinates. It is the responsability of the caller to initialise this Graphics2D object with the correct affine transformation for getting the physical space.
Specified by:
paint in interface GraphicalVisualRenderable
Parameters:
g - the graphics 2D; cannot be null
selected - if true, the renderable paints only its selected parts on the graphics; if false, the renderable paints only its unselected part on the graphics

print

public void print(java.awt.Graphics2D g)
Printing method. This routine is called when the renderable must paint itself inside the graphics. The renderable draws inside the graphics in logical coordinates. It is the responsability of the caller to initialise this Graphics2D object with the correct affine transformation for getting the physical space.
Specified by:
print in interface GraphicalVisualRenderable
Parameters:
g - the graphics 2D; cannot be null

export

public void export(GraphicalExporter g)
Exporting method. This routine is called when the renderable must export itself through a graphical exporter.
Specified by:
export in interface GraphicalVisualRenderable
Parameters:
g - the graphical exporter; cannot be null
See Also:
GraphicalExporter