|
||||||||||
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.JGoText
JGoText displays a text string.
There are various properties to control the appearance of the text: FaceName, Size, Alignment, TextColor, BkColor, Transparent, Bold, Underline, StrikeThrough, Italic, Multiline, and Clipping.
There are also some properties that control the behavior: Editable, EditOnSingleClick, AutoResize, SelectBackground, and 2DScale.
The FaceName and Size properties control the font used to display the text. You can set these dynamically or in some of the constructors. For the other constructors, the default values for these properties is provided by the static methods getDefaultFontFaceName() and getDefaultFontSize().
The Alignment property governs whether the text is positioned on the left side, on the right side, or in the center of the bounding rectangle. For multiline text strings, this property applies to each line.
The TextColor and BkColor properties control the color of the glyphs and the color of the background. These default to black and white, respectively. If the Transparent property is true, the BkColor is not used because the background is not filled in at all. The default value for Transparent is false.
The Bold, Underline, Italic, and StrikeThrough properties are false, by default.
The Multiline property controls whether the text will be displayed in just one line or with potentially multiple lines. When the user edits a single line text string, the ENTER key finishes editing the value, whereas for Multiline objects it would just insert a newline into the string.
If this object is Editable, then clicking (or double-clicking, depending on the EditOnSingleClick property) will put the view in edit-text-in-place mode. It will create a JGoTextEdit in the view at the same position as the JGoText, and it will activate the JGoTextEdit so that an SWT Text Control is visible and has focus. User editing on single click only works when both the Editable and EditOnSingleClick properties are true, along with the Selectable property, because of the otherwise ambiguous nature of a single click.
The sizing of the JGoText instance, if not explicitly set by calling setBoundingRect() or setSize() or setHeight() or the like, is continually determined by the text string and the font size and other attributes, if isAutoResize() is true.
If the JGoText object is not Resizable, the text is not rescaled (by changing the point size) when the height (or width) of the text is changed. JGoText objects are not Resizable by default.
The SelectBackground property, when true, assumes the text's background is normally transparent. If the text is not resizable, we manifest the selection by making the text background opaque. When selection is lost, the background is made transparent again.
The Clipping property controls whether the text drawing is clipped by the bounding rectangle. This is normally useful only when Resizable is false, because then the text font size is not automatically changed to fit the line height. The default value is false, which permits faster display than when Clipping is turned on.
The AutoResize property controls whether to reset the bounding rectangle whenever the text object changes, such as a change to the text string, or to the font or size.
There is support for greeking, to speed up text object painting at small view scales. The paintGreek method is called by the paint method, and gets the opportunity to change the rendering method used depending on the view's scale. Two new static properties have been added to control the default greeking behavior.
We have added support for automatically wrapping text when the text is longer than the WrappingWidth property. Wrapping only occurs when isWrapping() and isMultiline() are both true.
JGoTextEdit
,
Serialized FormField Summary | |
static int |
ALIGN_CENTER
Align the text at the center |
static int |
ALIGN_LEFT
Align the text at the left side |
static int |
ALIGN_RIGHT
Align the text at the right side. |
static int |
Changed2DScale
a CHANGED event hint: changed whether the horizontal size can be used to control the resize |
static int |
ChangedAlignment
a CHANGED event hint: the alignment has changed |
static int |
ChangedAutoResize
a CHANGED event hint: changed whether it automatically resizes itself |
static int |
ChangedBetterPainting
a CHANGED event hint: changed whether the text should be drawn more carefully and accurately |
static int |
ChangedBkColor
a CHANGED event hint: the text background color has changed |
static int |
ChangedBold
a CHANGED event hint: the boldness has changed |
static int |
ChangedClipping
a CHANGED event hint: changed whether text is clipped by the bounding rectangle |
static int |
ChangedEditable
a CHANGED event hint: changed the user-editability of the text |
static int |
ChangedEditOnSingleClick
a CHANGED event hint: if editable, changed whether the text starts edit mode on a single or a double click |
static int |
ChangedFaceName
a CHANGED event hint: the font face name has changed |
static int |
ChangedFontSize
a CHANGED event hint: the font size has changed |
static int |
ChangedItalic
a CHANGED event hint: the italicization has changed |
static int |
ChangedMultiline
a CHANGED event hint: changed whether the text is only a single line or multiple lines |
static int |
ChangedSelectBackground
a CHANGED event hint: if editable, changed whether selection is shown using the text's transparency and background |
static int |
ChangedStrikeThrough
a CHANGED event hint: changed whether text is shown with a strike-through |
static int |
ChangedText
a CHANGED event hint: the text string has changed |
static int |
ChangedTextColor
a CHANGED event hint: the text color has changed |
static int |
ChangedTransparent
a CHANGED event hint: the transparency has changed |
static int |
ChangedUnderline
a CHANGED event hint: the underlinedness has changed |
static int |
ChangedWrapping
a CHANGED event hint: changed whether text is wrapped inside the bounding rectangle |
static int |
ChangedWrappingWidth
a CHANGED event hint: the wrapping width has changed |
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 | |
JGoText()
Create a text object with no text and no size. |
|
JGoText(org.eclipse.swt.graphics.Point location,
int fontSize,
java.lang.String text,
java.lang.String fontName,
boolean bold,
boolean underline,
boolean italic,
int alignment,
boolean multiline,
boolean editable)
Create a text object with the given attributes. |
|
JGoText(org.eclipse.swt.graphics.Point location,
java.lang.String text)
Create a left-aligned text object given an initial string value whose top-left point is the given location. |
|
JGoText(java.lang.String text)
Create a text object given an initial string value. |
Method Summary | |
void |
changeValue(JGoDocumentChangedEdit e,
boolean undo)
This method is called by the JGoDocumentChangedEdit.undo and redo methods to actually perform the property value change for a JGoObject. |
java.lang.String |
computeEdit(java.lang.String oldtext,
java.lang.String newtext)
Calculate a new string value for this object as a result of an edit. |
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)
Create a new instance of this object with the same field values. |
boolean |
doEdit(JGoView view,
java.lang.String oldtext,
java.lang.String newtext)
Called when a user tries to commit a text edit. |
void |
doEndEdit()
Programmatically end the editing of the text for the user. |
boolean |
doMouseClick(int modifiers,
org.eclipse.swt.graphics.Point dc,
org.eclipse.swt.graphics.Point vc,
JGoView view)
The default behavior on single click is to start editing in-place if the document isModifiable is true, if isEditable is true, and if isEditOnSingleClick is true. |
boolean |
doMouseDblClick(int modifiers,
org.eclipse.swt.graphics.Point dc,
org.eclipse.swt.graphics.Point vc,
JGoView view)
The default behavior on double click is to start editing in-place if the document isModifiable is true, if isEditable is true, and if isEditOnSingleClick is false. |
void |
doStartEdit(JGoView view,
org.eclipse.swt.graphics.Point vc)
Programmatically start the editing of the text for the user. |
void |
expandRectByPenWidth(org.eclipse.swt.graphics.Rectangle rect)
Account for any likely text drawn beyond the bounding rectangle because of nonlinear text scaling |
protected void |
gainedSelection(JGoSelection selection)
JGoText has different handles than most objects because the resizing is only supposed to depend on the height. |
protected void |
geometryChange(org.eclipse.swt.graphics.Rectangle prevRect)
Called when the geometry of the text bounding box is changed. |
int |
getAlignment()
Return how multiple lines will be aligned. |
org.eclipse.swt.graphics.RGB |
getBkColor()
Return the color of the background behind the text. |
static java.lang.String |
getDefaultFontFaceName()
Return the default font face name for JGoText constructors that do not take an explicit font face name argument. |
static int |
getDefaultFontSize()
Return the default font size for JGoText constructors that do not take an explicit font size argument. |
static double |
getDefaultPaintGreekScale()
Return the view scale at which this text object should paint something simpler than real text. |
static double |
getDefaultPaintNothingScale()
Return the view scale at which a text object should not paint anything. |
static int |
getDefaultWrappingWidth()
Return the default wrapping width for JGoText constructors. |
java.lang.String |
getFaceName()
Return the font face. |
int |
getFontSize()
Return how big the font is. |
org.eclipse.swt.graphics.Point |
getLocation(org.eclipse.swt.graphics.Point result)
Returns the TopLeft, TopMiddle or TopRight point, depending on the text alignment attribute |
java.lang.String |
getText()
Return the text that is currently being displayed. |
org.eclipse.swt.graphics.RGB |
getTextColor()
Return the color of the text. |
int |
getTextFlags()
Return the current state of this JGoText object's flags. |
int |
getWrappingWidth()
Return the maximum width for wrapped text. |
org.eclipse.swt.graphics.Rectangle |
handleResize(Graphics2D g,
JGoView view,
org.eclipse.swt.graphics.Rectangle prevRect,
org.eclipse.swt.graphics.Point newPoint,
int whichHandle,
int event,
int minWidth,
int minHeight)
If this JGoText object is resizable and if the font size is only dependent on the height of the bounding rectangle, we need to recalculate based on new height and whether there are multiple lines of text. |
boolean |
is2DScale()
Return whether resizing text heeds both dimensions, rather than just the height. |
boolean |
isAutoResize()
Return whether text's bounding rectangle is recomputed whenever the text string or any of the other visual attributes is changed. |
boolean |
isBetterPainting()
Return whether text is drawn more carefully. |
boolean |
isBold()
Return whether the text is bold. |
boolean |
isClipping()
Return whether text display is limited to the bounding rectangle. |
static boolean |
isDefaultBetterPainting()
Return the default setting for JGoText's BetterPainting property. |
boolean |
isEditable()
Return whether the text is editable by the end user. |
boolean |
isEditOnSingleClick()
Return whether a user's single click starts editing the text, assuming the text is editable at all. |
boolean |
isItalic()
Return whether the text is italic. |
boolean |
isMultiline()
Return whether the text can be shown on multiple lines. |
boolean |
isSelectBackground()
Return whether gainedSelection() uses the text's background color and the text's transparency to display the selection. |
boolean |
isStrikeThrough()
Return whether the text is shown with a strike-through. |
boolean |
isTransparent()
Return whether the text is transparent. |
boolean |
isUnderline()
Return whether the text is underlined. |
boolean |
isWrapping()
Return whether text is automatically wrapped to try to fit in the wrapping width. |
protected void |
lostSelection(JGoSelection selection)
If isSelectBackground() is true, we assume the text is normally transparent, and that the background color will be the selection or highlight color. |
void |
paint(Graphics2D g,
JGoView view)
Called to draw the text on the screen. |
boolean |
paintGreek(Graphics2D g,
JGoView view)
This method is called by paint to allow optimizing drawing a lot of objects at small scales. |
void |
set2DScale(boolean bFlag)
Change whether the resizing the text depends on both the width and the height, rather than just the height to determine the font size to use in displaying the string. |
void |
setAlignment(int align)
Set how multiple lines are aligned. |
void |
setAutoResize(boolean bFlag)
Control whether the bounding rectangle is changed whenever the text string or other visual attributes are changed. |
void |
setBetterPainting(boolean bFlag)
Control whether text is drawn slower and more carefully. |
void |
setBkColor(org.eclipse.swt.graphics.RGB color)
Set the color of the background behind the text. |
void |
setBold(boolean bFlag)
Change the boldness of the text. |
void |
setClipping(boolean bFlag)
Change whether the text is only drawn within the bounding rectangle. |
static void |
setDefaultBetterPainting(boolean b)
Change the default setting for the BetterPainting property for each new JGoText object. |
static void |
setDefaultFontFaceName(java.lang.String name)
Change the default font face to be used by JGoText constructors that do not take an explicit font face name argument. |
static void |
setDefaultFontSize(int size)
Change the default font size to be used by JGoText constructors that do not take an explicit font size argument. |
static void |
setDefaultPaintGreekScale(double s)
Change the scale at which text will paint very simply. |
static void |
setDefaultPaintNothingScale(double s)
Change the scale at which text will not paint. |
static void |
setDefaultWrappingWidth(int w)
Change the default text wrapping width to be used by JGoText constructors. |
void |
setEditable(boolean bFlag)
Change whether the text is editable by the end user. |
void |
setEditOnSingleClick(boolean bFlag)
If the text is editable, control whether the user can start editing with a double click or with a single click. |
void |
setFaceName(java.lang.String name)
Sets the font face. |
void |
setFontSize(int size)
Sets the font size to the size specified. |
void |
setItalic(boolean bFlag)
Change whether the text is italic. |
void |
setLocation(int x,
int y)
Sets a new position for the TopLeft, TopMiddle or TopRight point. |
void |
setMultiline(boolean bFlag)
Change whether the text is limited to a single line or may have multiple lines. |
void |
setSelectBackground(boolean bFlag)
If the text background is transparent and the text is not resizable, control whether gainedSelection() makes the background opaque and whether lostSelection() makes the background transparent again. |
void |
setSizeKeepingLocation(int w,
int h)
Sets a new size for this object while maintaining the same Location. |
void |
setStrikeThrough(boolean bFlag)
Change whether the text is shown with a strike-through. |
void |
setText(java.lang.String str)
Set the text to be displayed. |
void |
setTextColor(org.eclipse.swt.graphics.RGB color)
Set the color of the text. |
void |
setTextFlags(int f)
Each JGoText keeps a set of flags for programmatic use by classes outside of the JGo package. |
void |
setTransparent(boolean bFlag)
Set whether or not the text background is filled with the background color before drawing the text (opaque), or if only the text is drawn without hiding what's underneath the text (transparent). |
void |
setUnderline(boolean bFlag)
Change whether the text is underlined. |
void |
setWrapping(boolean bFlag)
Change whether longer text is broken into multiple lines to fit in the defined wrapping width of this object. |
void |
setWrappingWidth(int w)
Change the width at which text will wrap, if isMultiline() and isWrapping() are true. |
void |
SVGReadAttributes(DomElement svgElement)
This method will read attributes from standard SVG elements. |
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 |
SVGWriteAttributes(DomElement svgElement)
This method will add attributes to standard SVG elements. |
void |
SVGWriteObject(DomDoc svgDoc,
DomElement jGoElementGroup)
Write this object out to a DomDoc representing a Scalable Vector Graphics (SVG) XML document. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int ALIGN_LEFT
public static final int ALIGN_CENTER
public static final int ALIGN_RIGHT
public static final int ChangedText
public static final int ChangedAlignment
public static final int ChangedFontSize
public static final int ChangedFaceName
public static final int ChangedTextColor
public static final int ChangedBkColor
public static final int ChangedTransparent
public static final int ChangedBold
public static final int ChangedUnderline
public static final int ChangedItalic
public static final int ChangedMultiline
public static final int ChangedEditable
public static final int ChangedEditOnSingleClick
public static final int Changed2DScale
public static final int ChangedSelectBackground
public static final int ChangedClipping
public static final int ChangedStrikeThrough
public static final int ChangedAutoResize
public static final int ChangedWrapping
public static final int ChangedWrappingWidth
public static final int ChangedBetterPainting
Constructor Detail |
public JGoText()
public JGoText(java.lang.String text)
text
- the initial stringpublic JGoText(org.eclipse.swt.graphics.Point location, java.lang.String text)
location
- the top-left point for the text, in document coordinatestext
- the initial stringpublic JGoText(org.eclipse.swt.graphics.Point location, int fontSize, java.lang.String text, java.lang.String fontName, boolean bold, boolean underline, boolean italic, int alignment, boolean multiline, boolean editable)
location
- the top-left, top-middle, or top-right corner of the text,
depending on the alignmentfontSize
- the size of the font to usetext
- the text to displayfontName
- the name of the font face to usebold
- display in bold if trueunderline
- display underline if trueitalic
- display in italic if truealignment
- the type of alignmentmultiline
- display more than one line of text if trueeditable
- permit in-place editing of text if trueMethod Detail |
public JGoObject copyObject(JGoCopyEnvironment env)
copyObject
in class JGoObject
env
- the environment for the copy operation - keeps track of copied objects.
public void setText(java.lang.String str)
str
- the text string to be displayed.public java.lang.String getText()
public void setAlignment(int align)
This also controls the natural Location for the text object, even when only a single line.
align
- one of the above alignment typespublic int getAlignment()
public void setFontSize(int size)
size
- the size to set the font topublic int getFontSize()
public void setFaceName(java.lang.String name)
name
- the name of the font facepublic java.lang.String getFaceName()
public void setTextColor(org.eclipse.swt.graphics.RGB color)
color
- the color of the textpublic org.eclipse.swt.graphics.RGB getTextColor()
public void setBkColor(org.eclipse.swt.graphics.RGB color)
color
- the color of the backgroundpublic org.eclipse.swt.graphics.RGB getBkColor()
public final void setTextFlags(int f)
Setting the flags does not call update, because the need for update must be determined by the application and the flags being changed.
This property is now exclusively for the use of user-defined extension classes and applications. The flags that had been used by the implementation of JGoText has been moved to a different field. This is also independent of JGoObject's Flags property.
f
- a new set of flag bitspublic final int getTextFlags()
public void setTransparent(boolean bFlag)
bFlag
- true if transparent, false if opaquepublic boolean isTransparent()
public void setBold(boolean bFlag)
bFlag
- true if bold, false if normalpublic boolean isBold()
public void setUnderline(boolean bFlag)
bFlag
- true if underlined, false if normalpublic boolean isUnderline()
public void setStrikeThrough(boolean bFlag)
bFlag
- true if strike-through, false if normalpublic boolean isStrikeThrough()
public void setItalic(boolean bFlag)
bFlag
- true if italic, false if normalpublic boolean isItalic()
public void setMultiline(boolean bFlag)
bFlag
- true if multiple lines, false if only a single linepublic boolean isMultiline()
public void setEditable(boolean bFlag)
bFlag
- true if user may edit, false if notpublic boolean isEditable()
public void setEditOnSingleClick(boolean bFlag)
Note that the text object may not receive a single click event if it is a non-selectable part of an area. You can avoid this problem by overriding doMouseClick in the area. Look at most of the example node classes for how to do this.
bFlag
- true if user starts editing with single click, false if
a double click is requiredpublic boolean isEditOnSingleClick()
public void setSelectBackground(boolean bFlag)
bFlag
- true to show the background color when selectedpublic boolean isSelectBackground()
public void set2DScale(boolean bFlag)
This property is only used when the user interactively resizes this text object, or in other words, when isResizable() is true. This property is not used when this object's height or width changes programmatically.
bFlag
- true if resizing should use both dimensions.public boolean is2DScale()
By default, this value is false.
public void setClipping(boolean bFlag)
bFlag
- true if the text should not be drawn beyond the
bounding rectanglepublic boolean isClipping()
public void setAutoResize(boolean bFlag)
bFlag
- true if this should resize itself when the text changespublic boolean isAutoResize()
By default, this is true.
public void setBetterPainting(boolean bFlag)
bFlag
- true if slower but more accuratelypublic boolean isBetterPainting()
By default, this value is true, unless the Java Version is earlier than 1.2.2.
public void setWrapping(boolean bFlag)
bFlag
- public boolean isWrapping()
public void setWrappingWidth(int w)
w
- the new wrapping widthpublic int getWrappingWidth()
public void expandRectByPenWidth(org.eclipse.swt.graphics.Rectangle rect)
expandRectByPenWidth
in class JGoObject
rect
- the Rectangle to be modifiedpublic boolean paintGreek(Graphics2D g, JGoView view)
public void paint(Graphics2D g, JGoView view)
paint
in class JGoObject
g
- the graphics context on which to drawview
- the view we're drawing inprotected void gainedSelection(JGoSelection selection)
If isSelectBackground() is true, we assume the text is normally transparent, and that the background color will be the selection or highlight color. Selection is shown by just making the background visible instead of transparent.
If is2DScale() is true, the user can also resize by changing the width.
gainedSelection
in class JGoObject
selection
- the selection into which this object was addedprotected void lostSelection(JGoSelection selection)
lostSelection
in class JGoObject
selection
- the selection from which this object was removedpublic org.eclipse.swt.graphics.Rectangle handleResize(Graphics2D g, JGoView view, org.eclipse.swt.graphics.Rectangle prevRect, org.eclipse.swt.graphics.Point newPoint, int whichHandle, int event, int minWidth, int minHeight)
handleResize
in class JGoObject
g
- the graphics context to draw onview
- the view we're being resizing inprevRect
- the object's original bounding rectanglenewPoint
- the location of the new pointwhichHandle
- the handle number of the point being movedevent
- one of: JGoView.EventMouseUp, JGoView.EventMouseMove, JGoView.EventMouseDownminWidth
- the minimum width of the object (defaults to zero)minHeight
- the minimum height of the object (defaults to zero)protected void geometryChange(org.eclipse.swt.graphics.Rectangle prevRect)
geometryChange
in class JGoObject
prevRect
- the previous bounding rectanglepublic org.eclipse.swt.graphics.Point getLocation(org.eclipse.swt.graphics.Point result)
getLocation
in class JGoObject
result
- a Point that will be modified to have the object's natural
location in document coordinates; if result is null a Point will
be allocated
public void setLocation(int x, int y)
setLocation
in class JGoObject
x
- the new X position for the object's locationy
- the new Y position for the object's locationpublic void setSizeKeepingLocation(int w, int h)
setSizeKeepingLocation
in class JGoObject
w
- the new width for this object's bounding rectangleh
- the new height for this object's bounding rectanglepublic boolean doMouseClick(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc, JGoView view)
doMouseClick
in class JGoObject
modifiers
- which keys are pressed, etc.dc
- the document coordinates.vc
- the view coordinates.view
- the view itself
JGoView.doMouseDblClick(int, org.eclipse.swt.graphics.Point, org.eclipse.swt.graphics.Point)
public boolean doMouseDblClick(int modifiers, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc, JGoView view)
doMouseDblClick
in class JGoObject
modifiers
- which keys are pressed, etc.dc
- the document coordinates.vc
- the view coordinates.view
- the view itself
JGoView.doMouseDblClick(int, org.eclipse.swt.graphics.Point, org.eclipse.swt.graphics.Point)
public void doStartEdit(JGoView view, org.eclipse.swt.graphics.Point vc)
This is responsible for starting a transaction.
view
- the view in which the user will be editingvc
- the view coordinates where the user may have clickedpublic boolean doEdit(JGoView view, java.lang.String oldtext, java.lang.String newtext)
This actually sets the text string of this text object. You can override this method in order to validate any in-place text editing done by the user.
// do some validation--don't allow integers larger than 1000 public boolean doEdit(JGoView view, String oldtext, String newtext) { try { int i = Integer.parseInt(newtext); if (i > 1000) { view.doCancelMouse(); MessageBox dlg = new MessageBox(view.getShell(), SWT.ICON_ERROR | SWT.OK); dlg.setText("Label Validation"); dlg.setMessage(Integer.toString(i) + " is too big!"); dlg.open(); return false; } } catch (NumberFormatException ex) { // allow non-integers to pass validation } return super.doEdit(view, oldtext, newtext); }By default this just calls setText(computeEdit(oldtext, newtext)) and returns true.
view
- the JGoView that the user is editing inoldtext
- the old pre-edit string value of this text objectnewtext
- the proposed new string value for this text object
public java.lang.String computeEdit(java.lang.String oldtext, java.lang.String newtext)
This is called by doEdit, which is responsible for calling setText with the value returned by this method.
You can override this method in order to canonicalize the string values that the user enters.
oldtext
- the old pre-edit string value of this text objectnewtext
- the proposed new string value for this text object
public void doEndEdit()
This is responsible for firing a JGoViewEvent.OBJECT_EDITED event and for ending a transaction.
public void copyNewValueForRedo(JGoDocumentChangedEdit e)
JGoObject
Just 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 JGoObject
e
- the UndoableEdit that also remembers the kind of change and any
appropriate new state that should be copied inpublic void changeValue(JGoDocumentChangedEdit e, boolean undo)
JGoObject
You will want to override this method to handle changing the additional state of your object subclasses.
changeValue
in class JGoObject
e
- the UndoableEdit that also remembers the kind of change and any
appropriate old and new state for performing an undo or redoundo
- if true, this method should restore the old state/value, otherwise
this method should restore the new state/valuepublic static void setDefaultFontFaceName(java.lang.String name)
name
- the new font face namepublic static java.lang.String getDefaultFontFaceName()
public static void setDefaultFontSize(int size)
size
- the new font sizepublic static int getDefaultFontSize()
public static double getDefaultPaintNothingScale()
public static void setDefaultPaintNothingScale(double s)
public static double getDefaultPaintGreekScale()
public static void setDefaultPaintGreekScale(double s)
public static void setDefaultWrappingWidth(int w)
w
- the new default wrap widthpublic static int getDefaultWrappingWidth()
public static void setDefaultBetterPainting(boolean b)
public static boolean isDefaultBetterPainting()
public void SVGWriteObject(DomDoc svgDoc, DomElement jGoElementGroup)
JGoXMLSaveRestore
This 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 JGoXMLSaveRestore
SVGWriteObject
in class JGoObject
public DomNode SVGReadObject(DomDoc svgDoc, JGoDocument jGoDoc, DomElement svgElement, DomElement jGoChildElement)
JGoXMLSaveRestore
This 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 JGoXMLSaveRestore
SVGReadObject
in class JGoObject
public void SVGWriteAttributes(DomElement svgElement)
JGoObject
Call this method from SVGWriteObject() if standard SVG elements are generated by this class or if this class may be subclassed and it should contribute arguments to SVG elements. For example, the JGoDrawable class implements this method to add standard SVG attributes for stroke, fill, and width. The JGoRectangle class calls this method to add all appropriate attributes to the <rect> element it generates. It is not necessary to implement this method if this class does not contribute any attributes to standard SVG elements. It is not necessary to call this method from SVGWriteObject() if this class does not generate any standard SVG elements.
Typically, an implementation of this method will first call the superclass and then call DomElement.setAttribute() to add attributes for this class.
SVGWriteAttributes
in class JGoObject
svgElement
- the DomElement to which to add attributesJGoObject.SVGWriteObject(com.nwoods.jgo.DomDoc, com.nwoods.jgo.DomElement)
,
JGoObject.SVGReadObject(com.nwoods.jgo.DomDoc, com.nwoods.jgo.JGoDocument, com.nwoods.jgo.DomElement, com.nwoods.jgo.DomElement)
,
JGoObject.SVGWriteAttributes(com.nwoods.jgo.DomElement)
,
JGoObject.SVGReadAttributes(com.nwoods.jgo.DomElement)
,
JGoObject.SVGUpdateReference(java.lang.String, java.lang.Object)
,
DomDoc
,
DomNode
,
DomElement
,
DomText
public void SVGReadAttributes(DomElement svgElement)
JGoObject
Call this method from SVGReadObject() if standard SVG elements are being read by this class or if this class may be subclassed and it should read arguments from SVG elements. For example, the JGoDrawable class implements this method to read standard SVG attributes for stroke, fill, and width. The JGoRectangle class calls this method to read all appropriate attributes from the <rect> element it is reading. It is not necessary to implement this method if this class does not read any attributes from standard SVG elements. It is not necessary to call this method from SVGReadObject() if this class does not read any standard SVG elements.
Typically, an implementation of this method will first call the superclass and then call DomElement.getAttribute() to read the attributes for this class.
SVGReadAttributes
in class JGoObject
svgElement
- the DomElement from which to read attributesJGoObject.SVGWriteObject(com.nwoods.jgo.DomDoc, com.nwoods.jgo.DomElement)
,
JGoObject.SVGReadObject(com.nwoods.jgo.DomDoc, com.nwoods.jgo.JGoDocument, com.nwoods.jgo.DomElement, com.nwoods.jgo.DomElement)
,
JGoObject.SVGWriteAttributes(com.nwoods.jgo.DomElement)
,
JGoObject.SVGReadAttributes(com.nwoods.jgo.DomElement)
,
JGoObject.SVGUpdateReference(java.lang.String, java.lang.Object)
,
DomDoc
,
DomNode
,
DomElement
,
DomText
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |