|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.nwoods.jgo.JGoObject
com.nwoods.jgo.JGoDrawable
com.nwoods.jgo.instruments.AbstractIndicator
An abstract class designed to visually represent a specific quantitative value.
AbstractIndicator provides a basis for indicators designed to interact with an implementation of GraduatedScale to indicate values that correspond to specific graphical points, determined by the GraduatedScale. However, it is possible to create an AbstractIndicator that does not rely on an instance of GraduatedScale, and the information needed to indicate specific values would be contained internally. This would be useful when the value system does not correspond to graphical points, such as a color scale system.
| Field Summary | |
static int |
ChangedActionEnabled
This is a JGoObject update subhint. |
static int |
ChangedQuantBase
This is a JGoObject update subhint. |
static int |
ChangedQuantized
This is a JGoObject update subhint. |
static int |
ChangedQuantUnit
This is a JGoObject update subhint. |
static int |
ChangedScale
This is a JGoObject update subhint. |
static int |
ChangedValue
This is a JGoObject update subhint. |
| Fields inherited from class com.nwoods.jgo.JGoObject |
Bottom, BottomCenter, BottomLeft, BottomMiddle, BottomRight, Center, CenterLeft, CenterRight, Changed4ResizeHandles, ChangedAutoRescale, ChangedBrush, ChangedDraggable, ChangedDragsNode, ChangedGeometry, ChangedGrabChildSelection, ChangedInitializing, ChangedPen, ChangedResizable, ChangedSelectable, ChangedUpdatePartner, ChangedVisible, ChangedZOrder, LastChangedHint, Left, LeftCenter, NoHandle, NoSpot, NumReservedHandles, RepaintAll, Right, RightCenter, SideLeft, SideRight, Top, TopCenter, TopLeft, TopMiddle, TopRight |
| Constructor Summary | |
protected |
AbstractIndicator()
The constructor changes the default JGoDrawable brush of Indicators to JGoBrush.red and makes it not Selectable. |
| Method Summary | |
void |
changeValue(JGoDocumentChangedEdit e,
boolean undo)
Handle undo and redo changes. |
protected void |
computePath(java.awt.geom.GeneralPath path)
Compute a GeneralPath used to paint this AbstractIndicator |
void |
copyNewValueForRedo(JGoDocumentChangedEdit e)
This method is called when a JGoDocumentChangedEdit is created for a JGoDocumentEvent.CHANGED event, when a JGoObject has been changed. |
JGoObject |
copyObject(JGoCopyEnvironment env)
Copy the field values and the internal data structures to avoid sharing references |
boolean |
doUncapturedMouseMove(int flags,
java.awt.Point dc,
java.awt.Point vc,
JGoView view)
Change the cursor to Cursors.Hand if the user can modify the value of this indicator interactively. |
void |
expandRectByPenWidth(java.awt.Rectangle rect)
Take into account the bounds of the GeneralPath. |
void |
generateSVGOutput(DomDoc svgDoc,
DomElement jGoElementGroup)
|
protected void |
geometryChange(java.awt.Rectangle old)
Whenever the size and/or position is changed, we need to recalculate the GeneralPath. |
JGoObject |
getPartner()
Sometimes it is convenient to be able to associate an object with another object, without any predetermined knowledge about the class. |
java.awt.geom.GeneralPath |
getPath()
|
double |
getQuantizeBase()
Gets the base value which is allowed when AbstractIndicator.Quantized is true. |
double |
getQuantizeUnit()
Gets the difference between two consecutive allowed values when AbstractIndicator.Quantized is true. |
GraduatedScale |
getScale()
Gets the scale with which the indicator is associated. |
double |
getValue()
Gets the value that will be indicated, relative to the associated GraduatedScale. |
double |
getValueForPoint(java.awt.Point dc)
This method is called by onActionAdjusted and onAction to get the proposed new value for the given mouse point. |
boolean |
isActionActivated()
Gets whether the object's Action is about to be invoked, normally by a mouse button being pressed. |
boolean |
isActionEnabled()
Gets whether the user can adjust the indicators value. |
boolean |
isQuantized()
Gets whether the indicator is forced to have discrete values. |
java.awt.geom.GeneralPath |
makePath()
Make sure that whenever we reconstruct the main GeneralPath for this shape, we call computePath. |
void |
onAction(JGoView view,
int modifiers,
java.awt.Point dc,
java.awt.Point vc)
This method is called by JGoView to perform the object's action, normally by a mouse button being released. |
void |
onActionAdjusted(JGoView view,
int modifiers,
java.awt.Point dc,
java.awt.Point vc,
int event)
This method is called by JGoView as the user is adjusting the object, normally by a mouse drag or move. |
void |
onActionCancelled(JGoView view)
Just restore the original value of this indicator, as remembered when this indicator was activated. |
void |
paint(java.awt.Graphics2D g,
JGoView view)
Paint this object to a view, using a GeneralPath determined by a call to computePath. |
double |
quantizeValue(double val)
A function used to ensure valid values within the quantized value system. |
protected void |
resetPath()
|
void |
setActionActivated(boolean value)
Sets whether the object's Action is about to be invoked, normally by a mouse button being pressed. |
void |
setActionEnabled(boolean value)
Sets whether the user can adjust the indicators value. |
void |
setPartner(JGoObject value)
Sometimes it is convenient to be able to associate an object with another object, without any predetermined knowledge about the class. |
void |
setQuantizeBase(double value)
Sets the base value which is allowed when AbstractIndicator.Quantized is true. |
void |
setQuantized(boolean value)
Sets whether the indicator is forced to have discrete values. |
void |
setQuantizeUnit(double value)
Sets the difference between two consecutive allowed values when AbstractIndicator.Quantized is true. |
void |
setScale(GraduatedScale value)
Sets the scale with which the indicator is associated. |
void |
setValue(double value)
Sets the value that will be indicated, relative to the associated GraduatedScale. |
DomNode |
SVGReadObject(DomDoc svgDoc,
JGoDocument jGoDoc,
DomElement svgElement,
DomElement jGoChildElement)
Read this object in from a DomDoc representing a Scalable Vector Graphics (SVG) XML document. |
void |
SVGUpdateReference(java.lang.String attr,
java.lang.Object referencedObject)
This method will be called to fill in object references. |
void |
SVGWriteObject(DomDoc svgDoc,
DomElement jGoElementGroup)
Write this object out to a DomDoc representing a Scalable Vector Graphics (SVG) XML document. |
double |
validValue(double val)
A function used to check the validity of the given value. |
| Methods inherited from class com.nwoods.jgo.JGoDrawable |
draw3DRect, draw3DRect, drawEllipse, drawEllipse, drawEllipse, drawLine, drawLine, drawPath, drawPolygon, drawPolygon, drawRect, drawRect, drawRect, drawRoundRect, drawRoundRect, getBrush, getNearestIntersectionPoint, getPen, setBrush, setPen, SVGAddPathArgs, SVGReadAttributes, SVGWriteAttributes |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int ChangedValue
public static final int ChangedScale
public static final int ChangedQuantized
public static final int ChangedQuantBase
public static final int ChangedQuantUnit
public static final int ChangedActionEnabled
| Constructor Detail |
protected AbstractIndicator()
| Method Detail |
public JGoObject copyObject(JGoCopyEnvironment env)
copyObject in class JGoDrawableenv - the environment for the copy operation - keeps track of copied objects.
public double getValue()
public void setValue(double value)
This calls validValue to make sure the new value is in the permitted range.
public GraduatedScale getScale()
public void setScale(GraduatedScale value)
public double validValue(double val)
val -
public boolean isQuantized()
public void setQuantized(boolean value)
Setting this property does not actually change the Value. If you want to make sure the Value is "quantized" correctly, you will need to set it explicitly.
public double getQuantizeBase()
public void setQuantizeBase(double value)
Setting this property does not actually change the Value. If you want to make sure the Value is "quantized" correctly, you will need to set it explicitly.
public double getQuantizeUnit()
public void setQuantizeUnit(double value)
Setting this property does not actually change the Value. If you want to make sure the Value is "quantized" correctly, you will need to set it explicitly.
public double quantizeValue(double val)
val -
public boolean isActionEnabled()
The default value is false.
isActionEnabled in interface JGoActionObjectpublic void setActionEnabled(boolean value)
setActionEnabled in interface JGoActionObjectvalue - public boolean isActionActivated()
This defaults to false.
isActionActivated in interface JGoActionObjectpublic void setActionActivated(boolean value)
A change to this state is considered transient, and does not invoke JGoObject.update.
setActionActivated in interface JGoActionObjectvalue -
public void onActionAdjusted(JGoView view,
int modifiers,
java.awt.Point dc,
java.awt.Point vc,
int event)
By default this just sets the Value according to the current input point. This will get called repeatedly as the user drags the mouse around. When calling setValue, this method temporarily sets SkipsUndoManager to true.
onActionAdjusted in interface JGoActionObjectview - the JGoView that the input event occurred inmodifiers - which keys are pressedvc - the current position of the mouse in view coordsdc - the current position of the mouse in doc coordsevent - one of JGoView.EventMouseDown, EventMouseMove, or EventMouseUp.
public void onAction(JGoView view,
int modifiers,
java.awt.Point dc,
java.awt.Point vc)
By default this starts a transaction, sets the Value according to the current input point, and then ends the transaction.
onAction in interface JGoActionObjectview - the JGoView that the input event occurred inmodifiers - which keys are pressedvc - the current position of the mouse in view coordsdc - the current position of the mouse in doc coordspublic void onActionCancelled(JGoView view)
onActionCancelled in interface JGoActionObjectview - the JGoView where the user is cancelling an actionpublic double getValueForPoint(java.awt.Point dc)
dc - a Point in document coordinates
public boolean doUncapturedMouseMove(int flags,
java.awt.Point dc,
java.awt.Point vc,
JGoView view)
doUncapturedMouseMove in class JGoObjectflags - the modifiers for this eventdc - the current mouse point in document coordinatesvc - the current mouse point in view coordinatesview - the JGoView
JGoView.doUncapturedMouseMove(int, java.awt.Point, java.awt.Point)public JGoObject getPartner()
JGoObjectBy default this returns null.
getPartner in class JGoObjectpublic void setPartner(JGoObject value)
JGoObjectBy default this is a no-op.
setPartner in class JGoObjectprotected void geometryChange(java.awt.Rectangle old)
geometryChange in class JGoObjectprotected void computePath(java.awt.geom.GeneralPath path)
path - a GeneralPath that should be modifiedpublic java.awt.geom.GeneralPath getPath()
protected void resetPath()
public java.awt.geom.GeneralPath makePath()
public void paint(java.awt.Graphics2D g,
JGoView view)
paint in class JGoObjectg - the graphics context on which to drawview - the view we're drawing inpublic void expandRectByPenWidth(java.awt.Rectangle rect)
expandRectByPenWidth in class JGoDrawablerect - the rectangle to be enlargedpublic void copyNewValueForRedo(JGoDocumentChangedEdit e)
JGoObjectJust as the previous/old value/state information is stored as one or both of an integer and an Object, the new value/state information may be stored as either or both of an integer or an Object.
The responsibility for copying rests with the document event listener rather than the code calling JGoObject.update for efficiency when there is no undo/redo manager.
copyNewValueForRedo in class JGoDrawable
public void changeValue(JGoDocumentChangedEdit e,
boolean undo)
changeValue in class JGoDrawablee - undo -
public void SVGWriteObject(DomDoc svgDoc,
DomElement jGoElementGroup)
JGoXMLSaveRestoreThis method will be called by com.nwoods.jgo.svg.DefaultDocument.SVGWriteDoc() for every JGoObject contained within a JGoDocument. The following example uses a JGoRectangle to illustrate the format of a generated SVG JGoObject:
<g>
<JGoClass class="com.nwoods.jgo.JGoRectangle"\>
<rect height="75" style="stroke:black;stroke-width:1;fill:rgb(255,0,0);" width="75" x="65" y="71"/>
<JGoClass class="com.nwoods.jgo.JGoDrawable" drawablebrush="jgoid1" drawablepen="jgoid2" embeddedpenbrush="false"/>
<JGoClass class="com.nwoods.jgo.JGoObject" obj_flags="1054"/>
</g>
Note that the entire JGoObject is enclosed in a group (<g>). Each subclass of the JGoObject is described by a <JGoClass> element, starting with the most specific class and moving to the more general. Each <JGoClass> element has a "class" attribute which defines the class name. Each <JGoClass> element may also have several other attributes which uniquely describe that state of that class. Following the <JGoClass> element, each class may also genereate any other elements that are required, including representations of contained objects and standard SVG elements such as the <rect> element shown in the above example. The generation of SVG elements in the output makes it possible for the output to be read by SVG viewers and other SVG aware applications. The information contained in the <JGoClass> elements allows us to accurately save and restore all the information in a particular JGoObject subclass.
If this class contains a reference to another object, call DomDoc.registerReferencingNode() to register that reference. This will cause the element representing the referenced object to be identified with a unique id attribute, and cause the element representing the referring object to have a user defined attribute containing a reference to that id. See DomDoc.registerReferencingNode() for more information.
Typically, an implementation of this method will generate a <JGoClass> element using the DomDoc.createJGoClassElement() method, adding whatever attributes are necessary to describe the class. It will then call its superclass so that the superclass can add its own <JGoClass> element and other information to jGoElementGroup within the DomDoc.
Refer to com.nwoods.jgo.examples.flower.ActivityNode.SVGWriteObject() and com.nwoods.jgo.examples.SimpleNode.SVGWriteObject() for examples using this method.
Refer to the file com.nwoods.jgo.svg\xsvg.dtd for a formal description of JGo extensions to the SVG document type.
SVGWriteObject in interface JGoXMLSaveRestoreSVGWriteObject in class JGoDrawable
public void generateSVGOutput(DomDoc svgDoc,
DomElement jGoElementGroup)
public DomNode SVGReadObject(DomDoc svgDoc,
JGoDocument jGoDoc,
DomElement svgElement,
DomElement jGoChildElement)
JGoXMLSaveRestoreThis method will be called by com.nwoods.jgo.svg.DefaultDocument.SVGReadDoc() for every <JGoClass> element encountered in a DomDoc. First, an object of the type specified by the class attribute will be created and then the SVGReadObject() method will be called on that newly created object. Refer to SVGWriteObject() for a description of the expected format of the SVG document.
This method may also be called by com.nwoods.jgo.svg.DefaultDocument.SVGReadDoc() when reading any SVG document, including those not generated by JGo and therefore not containing any <JGoClass> elements. In such cases, the DefaultDocument.SVGReadElement() method may be subclassed to examine the SVG element and cause the appropriate JGoObject to be created to represent that element and call SVGReadObject() on that newly created object. By default, standard JGoObjects such as JGoRectangles, JGoStrokes, etc will be created to represent these objects.
If this class contains a reference to another object, call DomDoc.registerReferencingObject() to register that reference. This will cause the JGoObject.SVGUpdateReference() to be called on the referencing object after all the objects have been created, passing in the object befing referenced. See DomDoc.registerReferencingObject() for more information.
Typically, an implementation of this method starts by verifying that the element being read is a <JGoClass> element (which will be true if jGoChildElement is not null). This will always be true unless you have subclassed the DefaultDocument.SVGReadElement() method as described above. It will then read the expected attributes of the <JGoClass> element (as written by SVGReadObject()), call SVGReadObject() on its superclass, and finally return the next element by calling svgElement.getNextSibling().
Refer to com.nwoods.jgo.examples.flower.ActivityNode.SVGReadObject() and com.nwoods.jgo.examples.SimpleNode.SVGReadObject() for examples using this method.
SVGReadObject in interface JGoXMLSaveRestoreSVGReadObject in class JGoDrawable
public void SVGUpdateReference(java.lang.String attr,
java.lang.Object referencedObject)
JGoObjectThis is called by com.nwoods.jgo.svg.DefaultDocument.SVGReadDoc() after all the objects have been created and if DomDoc.registerReferencingObject() has been previously called by SVGReadObject().
Typically, an implementation of this method will first call the superclass and then fill in the appropriate object reference based on the attr argument.
Refer to com.nwoods.jgo.examples.SimpleNode.SVGWriteObject() for an example using this method.
SVGUpdateReference in class JGoDrawable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||