public class FigureViewDelegate extends Object implements FigureViewManager, FigureObserver
Details:
An FigureViewDelegate
provides generic figure drawing and mouse support to a InteractiveFigureView
, thus allowing the InteractiveFigureView
to become a view of the figure.
The features offered in this class are generic and useful for implementing figure views in any GUI platform, including AWT, Swing, and SWT.
To access platform-
Any UI component that implements InteractiveFigureView
can become a view of a Figure
by creating a private, concrete instance of this class and decorating it with the desired public methods (read up on the "decorator design pattern," if necessary).
Minimally, only the original widget's paint requests need to be forwarded to this class.
A FigureViewDelegate
can render its figure in any translation, scale, or rotation.
Methods provided in this class make it possible to change the view's orientation at any time.
A FigureViewDelegate
also maintains a registry of com.sharkysoft.fig.core.event.FigMouseListener
s, sending them FigMouseEvent
s whenever applicable mouse events occur.
Modifier and Type | Field and Description |
---|---|
protected Figure |
mFigure
Details:
mFigure is the figure being displayed in the widget. |
protected FigureTransform |
mTransform
Figure transform.
|
protected FigureView |
mWidget
UI component displaying figure.
|
Constructor and Description |
---|
FigureViewDelegate(FigureView iCanvas,
FigureTransform iTransform) |
Modifier and Type | Method and Description |
---|---|
void |
doodleAdded(Figure iFigure,
Doodle iShape)
Doodle was added to figure.
|
void |
doodleChanged(Figure iFigure,
Doodle iDoodle)
Doodle has changed.
|
void |
doodleRemoved(Figure iFigure,
Doodle iDoodle)
Doodle was removed from figure.
|
DetailLevel |
getDetailLevel()
Returns current detail level.
|
Figure |
getFigure()
Returns figure in view.
|
FigureTransform |
getTransform()
Returns transform manager.
|
void |
paint(Graphics2D iG)
Draws figure.
|
void |
setDetailLevel(DetailLevel iDetailLevel)
Sets detail level.
|
void |
setFigure(Figure iFigure)
No summary entered.
|
protected final FigureView mWidget
Details:
mWidget
is the UI component employing this view.
In other words, it is the object decorating this instance.
protected Figure mFigure
Details:
mFigure
is the figure being displayed in the widget.
protected final FigureTransform mTransform
Details:
mTransform
is the transform associated with this view.
The transform controls the position, scale, and rotation at which the figure is viewed (rendered).
public FigureViewDelegate(FigureView iCanvas, FigureTransform iTransform)
public Figure getFigure()
FigureViewManager
Details: This method returns the current figure displayed in the view.
getFigure
in interface FigureViewManager
public void setFigure(Figure iFigure)
Details:
setFigure
sets the figure that this view will render.
To set this view to "no figure," set ipFigure
to null
.
setFigure
in interface FigureViewManager
iFigure
- public DetailLevel getDetailLevel()
FigureViewManager
getDetailLevel
in interface FigureViewManager
public void setDetailLevel(DetailLevel iDetailLevel)
FigureViewManager
Details: This method updates the current detail level to the provided value. The view will redraw the figure if necessary.
setDetailLevel
in interface FigureViewManager
iDetailLevel
- the new detail levelpublic FigureTransform getTransform()
FigureViewManager
Details: This method returns the view's transform manager. The instance returned can be used to query or alter the view's transform.
getTransform
in interface FigureViewManager
public void paint(Graphics2D iG)
Details:
paint
draws the figure using the given graphics context.
Before drawing, the current transform associated with this view is added to the graphics context's original transform.
Before returning, however, the graphics context's original transform is restored.
Other graphics context settings, such as pen colors and strokes, may also be altered as the figure is being rendered. These other settings will not necessarily be restored. If this presents a problem, create a copy of the original graphics context and offer the copy as the parameter to this method. Then, dispose the copy after this method returns.
paint
in interface FigureViewManager
iG
- the graphics contextpublic void doodleChanged(Figure iFigure, Doodle iDoodle)
FigureObserver
Details:
doodleChanged
notifies this listener that the given doodle has changed, and that the view should redraw the area covered by it.
doodleChanged
in interface FigureObserver
iFigure
- figure whose doodle changediDoodle
- doodle that changedpublic void doodleAdded(Figure iFigure, Doodle iShape)
FigureObserver
Details:
doodleAdded
notifies this listener that a doodle has been added to the figure.
This callback will always be followed by a call to FigureObserver.doodleChanged(Figure, Doodle)
, so it is not usually critical to respond to this message.
doodleAdded
in interface FigureObserver
iFigure
- affected figureiShape
- added doodlepublic void doodleRemoved(Figure iFigure, Doodle iDoodle)
FigureObserver
Details:
doodleRemoved
notifies this listener that a doodle was removed from the figure.
This callback will always be followed by a call to FigureObserver.doodleChanged(Figure, Doodle)
, so it is not critical to respond to this message.
doodleRemoved
in interface FigureObserver
iFigure
- affected figureiDoodle
- removed doodleCopyright © 2013. All Rights Reserved.