Java Doc for DrawString.java in  » Science » jcm1-source » edu » hws » jcm » draw » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Science » jcm1 source » edu.hws.jcm.draw 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   edu.hws.jcm.draw.Drawable
      edu.hws.jcm.draw.DrawString

DrawString
public class DrawString extends Drawable implements Computable(Code)
A DrawString object displays a string, possibly multi-line, in a DisplayCanvas, inside the rectangular region of a CoordinateRect. The location of the string can be specified in two ways. First, by giving the coordinates of a reference point together with a constant that says how the string is positioned with respect to that reference point. The coordintes are given as Value objects and the values are interepreted in the coordinate system of the CoordinateRect. The positioning object is one of the constants TOP_LEFT, TOP_CENTER, ..., BOTTOM_RIGHT defined in this class. This says where the REFERENCE POINT is -- at the top left of the string, at the top center, etc.

The second way to specify the position of the string is to set the reference point coordinates to null. In that case, the postioning constant gives the location of the STRING in the CorrdinateRect. A value of TOP_LEFT says that the string is in the top left corner of the rect, etc.

An array of Value objects can be specified to be displayed in the string. Their values are substituted for #'s in the string. (A double # in the string, however, is displayed as a literal single #.)

It is possible to set the color, font and justification of the string.

A DisplayString implements the Computable interface, so it can be added to a Controller. The values of the Value objects used by the string are recomputed only when its compute() method is called.



Field Summary
final public static  intCENTER
     For specifying justification of lines in multiline strings.
final public static  intLEFT
     For specifying justification of lines in multiline strings.
final public static  intRIGHT
     For specifying justification of lines in multiline strings.
final public static  intTOP_LEFTTOP_CENTERTOP_RIGHTCENTER_LEFTCENTER_CENTERCENTER_RIGHTBOTTOM_LEFTBOTTOM_CENTERBOTTOM_RIGHT
    
protected  ColorbackgroundColor
    
protected  StringbaseString
     String, possibly with \n and #'s.
protected  booleanclamp
     If true, the string is clamped to lie within the CoordinateRect.
protected  Colorcolor
     Color of string.
protected  Fontfont
     Font for drawing string.
protected  ColorframeColor
     If frameWidth is greate than zero, then a frame is drawn around the string in this color.
protected  intframeWidth
     If frameWidth is greater than zero, then a frame of this width is drawn around the string in the color given by frameColor.
protected  intjustification
     Left, right, or center justification of lines in the text.
protected  intnumSize
     Maximum number of characters desired in numbers; actual number might actually be larger.
protected  intoffset
     If absolute positioning is used, then this gives a gap between the string and edge of rect.
protected  intposition
    
protected  String[]strings
     The actual lines to draw, derived from baseString.
protected  Value[]values
     Values to be substituted for #'s in the baseString.
protected  ValuexPosyPos
     xy-coords for drawing the string.

Constructor Summary
public  DrawString()
     Create a DrawString object that initially has no string to draw.
public  DrawString(String str)
     Create a DrawString for drawing a black string in the top left corner of the coordinate rect.
Parameters:
  str - The string to draw, which can contain \n's to indicate line breaks.
public  DrawString(String str, int pos)
     Create a DrawString for drawing a black string in the position specified.
Parameters:
  str - The string to draw, which can contain \n's to indicate line breaks.
public  DrawString(String str, int pos, Value[] values)
     Create a DrawString for drawing a black string in the specified position. The number of #'s in the string should match values.length.
public  DrawString(String str, int pos, Value xPos, Value yPos, Value[] values)
     Create a string that is displayed at the reference point (xPos,yPos); The positioning constant, pos, gives the positioning relative to this point, if xPos or yPos is non-null.
Parameters:
  str - The string to draw, which can contain \n's to indicate line breaks and #'s to be replaced by numeric values.

Method Summary
public  voidcompute()
     The compute method sets up the array of strings that is actually displayed.
public  voiddraw(Graphics g, boolean coordsChanged)
     Draws the string.
public  ColorgetBackgroundColor()
     Get the color that is used to fill a rectangle on which the string is drawn.
public  booleangetClamp()
     Returns true if the string is set to be clamped to lie within the CoordinateRect.
public  ColorgetColor()
     Get the non-null color that is used for drawing the string.
public  FontgetFont()
     Return the font that is used for drawing the string.
public  ColorgetFrameColor()
     Get the color that is used to draw a frame around the string.
public  intgetFrameWidth()
     Get the width, in pixels, of the frame that is drawn around the string.
public  intgetJustification()
     Get the justification that is used for a multiple-line string.
public  intgetNumSize()
     Return the desired maximum number of characters in displayed numbers.
public  intgetOffset()
     Get the distance of the bounding box of the string from the reference point where it is drawn.
public  intgetPositioning()
     Return the positioning, as set by setPositioning().
public  StringgetString()
    
public  Value[]getValues()
     Return the array of values that are substituted for #'s in the string.
public  ValuegetXPos()
     Return the Value object that gives the x-coordinate of the reference point of this string.
public  ValuegetYPos()
     Return the Value object that gives the y-coordinate of the reference point of this string.point of this string.
public  voidsetBackgroundColor(Color color)
     Set the color that is used to fill a rectangle on which the string is drawn.
public  voidsetClamp(boolean clamp)
     Set the "clamp" property of the DrawString.
public  voidsetColor(Color c)
     Set the color for the string.
public  voidsetFont(Font f)
     Set the font that is used for drawing this string.
public  voidsetFrameColor(Color color)
     Set the color that is used to draw a frame around the string.
public  voidsetFrameWidth(int width)
     Set the width, in pixels, of a frame to draw around the string.
public  voidsetJustification(int j)
     Set the justification to be used if there are multiple lins in the string.
public  voidsetNumSize(int size)
     Set the desired maximum number of characters in displayed numbers. Actual size might be larger.
public  voidsetOffset(int b)
     Set the distance of the bounding box of the string from the reference point where it is drawn.
public  voidsetPositioning(int pos)
     Set the positioning of the string.
public  voidsetReferencePoint(Value x, Value y)
     Set the values of the (x,y) coordinates of the reference point for the stirng.
public  voidsetString(String str)
     Set the string that is displayed.
public  voidsetValues(Value[] v)
     Set the Values that are substituted for (single) #'s in the string. If the array of Values is null, then no substitution is done.

Field Detail
CENTER
final public static int CENTER(Code)
For specifying justification of lines in multiline strings. (But can also be used as a synonym for CENTER_CENTER to specify the position of the string).



LEFT
final public static int LEFT(Code)
For specifying justification of lines in multiline strings. (But can also be used as a synonym for TOP_LEFT to specify the position of the string).



RIGHT
final public static int RIGHT(Code)
For specifying justification of lines in multiline strings. (But can also be used as a synonym for TOP_RIGHT to specify the position of the string).



TOP_LEFTTOP_CENTERTOP_RIGHTCENTER_LEFTCENTER_CENTERCENTER_RIGHTBOTTOM_LEFTBOTTOM_CENTERBOTTOM_RIGHT
final public static int TOP_LEFTTOP_CENTERTOP_RIGHTCENTER_LEFTCENTER_CENTERCENTER_RIGHTBOTTOM_LEFTBOTTOM_CENTERBOTTOM_RIGHT(Code)
Specify string location in rect



backgroundColor
protected Color backgroundColor(Code)
If backgroundColor is non-null, then a rectangle of this color is filled as a background for the string;



baseString
protected String baseString(Code)
String, possibly with \n and #'s. This is used as a base to get the actual string that is drawn.



clamp
protected boolean clamp(Code)
If true, the string is clamped to lie within the CoordinateRect.



color
protected Color color(Code)
Color of string. If null, black is used as the default.



font
protected Font font(Code)
Font for drawing string. If null, get font from graphics context.



frameColor
protected Color frameColor(Code)
If frameWidth is greate than zero, then a frame is drawn around the string in this color. If the value is null, then the color will be the same as the color of the string.



frameWidth
protected int frameWidth(Code)
If frameWidth is greater than zero, then a frame of this width is drawn around the string in the color given by frameColor.



justification
protected int justification(Code)
Left, right, or center justification of lines in the text.



numSize
protected int numSize(Code)
Maximum number of characters desired in numbers; actual number might actually be larger.



offset
protected int offset(Code)
If absolute positioning is used, then this gives a gap between the string and edge of rect. For relative positioning, this gives an offset from the value of xPos yPos.



position
protected int position(Code)
one of the constants defined in this class for specifying position



strings
protected String[] strings(Code)
The actual lines to draw, derived from baseString.



values
protected Value[] values(Code)
Values to be substituted for #'s in the baseString.



xPosyPos
protected Value xPosyPos(Code)
xy-coords for drawing the string. If non-null then relative positioning is used. If null, then positioning is absolute.




Constructor Detail
DrawString
public DrawString()(Code)
Create a DrawString object that initially has no string to draw.



DrawString
public DrawString(String str)(Code)
Create a DrawString for drawing a black string in the top left corner of the coordinate rect.
Parameters:
  str - The string to draw, which can contain \n's to indicate line breaks.



DrawString
public DrawString(String str, int pos)(Code)
Create a DrawString for drawing a black string in the position specified.
Parameters:
  str - The string to draw, which can contain \n's to indicate line breaks.
Parameters:
  pos - The positioning of the string in the coordinate rect. One of the positioning constants such as TOP_LEFT or BOTTOM_RIGHT.



DrawString
public DrawString(String str, int pos, Value[] values)(Code)
Create a DrawString for drawing a black string in the specified position. The number of #'s in the string should match values.length. The values are computed and substituted for the #'s.
Parameters:
  str - The string to draw, which can contain \n's to indicate line breaks and #'s to be replaced by numeric values.
Parameters:
  pos - The positioning of the string in the coordinate rect. One of the positioning constants such as TOP_LEFT or BOTTOM_RIGHT.
Parameters:
  values - Value objects associated with #'s in the string.



DrawString
public DrawString(String str, int pos, Value xPos, Value yPos, Value[] values)(Code)
Create a string that is displayed at the reference point (xPos,yPos); The positioning constant, pos, gives the positioning relative to this point, if xPos or yPos is non-null.
Parameters:
  str - The string to draw, which can contain \n's to indicate line breaks and #'s to be replaced by numeric values.
Parameters:
  pos - The positioning of the string. One of the positioning constants such as TOP_LEFT or BOTTOM_RIGHT.If xPos or yPos is non-nul, this is interpreted relative to their values.
Parameters:
  xPos - x-coordinate relative to which the string is drawn (or null for absolute hoizontal positioning).
Parameters:
  yPos - y-coordinate relative to which the string is drawn (or null for absolute vertical positioning).
Parameters:
  values - Value objects associated with #'s in the string.




Method Detail
compute
public void compute()(Code)
The compute method sets up the array of strings that is actually displayed. This is required by the Computable interface and is usually called by a Controller rather than directly.



draw
public void draw(Graphics g, boolean coordsChanged)(Code)
Draws the string.



getBackgroundColor
public Color getBackgroundColor()(Code)
Get the color that is used to fill a rectangle on which the string is drawn. Null indicates that no rectangle is filled so the stuff in back of the string shows though. The default value is null.



getClamp
public boolean getClamp()(Code)
Returns true if the string is set to be clamped to lie within the CoordinateRect.



getColor
public Color getColor()(Code)
Get the non-null color that is used for drawing the string.



getFont
public Font getFont()(Code)
Return the font that is used for drawing the string. If the return value is null, then the font is taken from the Graphics context.



getFrameColor
public Color getFrameColor()(Code)
Get the color that is used to draw a frame around the string. This is only done if the frameWidth property is greater than zero. If the value is null, the frame is the same color as the string.



getFrameWidth
public int getFrameWidth()(Code)
Get the width, in pixels, of the frame that is drawn around the string. The default width is zero. The largest possible value is 25.



getJustification
public int getJustification()(Code)
Get the justification that is used for a multiple-line string. The value is one of the constants DrawString.LEFT, DrawString.RIGHT, or DrawString.CENTER



getNumSize
public int getNumSize()(Code)
Return the desired maximum number of characters in displayed numbers.



getOffset
public int getOffset()(Code)
Get the distance of the bounding box of the string from the reference point where it is drawn.



getPositioning
public int getPositioning()(Code)
Return the positioning, as set by setPositioning().



getString
public String getString()(Code)
Get a copy of the display string (with \n's #'s, not with substitued values.)



getValues
public Value[] getValues()(Code)
Return the array of values that are substituted for #'s in the string.



getXPos
public Value getXPos()(Code)
Return the Value object that gives the x-coordinate of the reference point of this string.



getYPos
public Value getYPos()(Code)
Return the Value object that gives the y-coordinate of the reference point of this string.point of this string.



setBackgroundColor
public void setBackgroundColor(Color color)(Code)
Set the color that is used to fill a rectangle on which the string is drawn. If the value is null, no rectangle is filled and the string just overlays whatever is in back of it on the canvas.



setClamp
public void setClamp(boolean clamp)(Code)
Set the "clamp" property of the DrawString. If set to true, the string will be clamped to lie entirely within the CoordinateRect (unless it doens't fit -- then it can stick out on the right and bottom). The default value is true.



setColor
public void setColor(Color c)(Code)
Set the color for the string. If c is null, Color.black is used.



setFont
public void setFont(Font f)(Code)
Set the font that is used for drawing this string. If f is null, then the font is obtained from the Graphics context in which the string is drawn.



setFrameColor
public void setFrameColor(Color color)(Code)
Set the color that is used to draw a frame around the string. This is only done if the frameWidth property is greater than zero. If the value is null, the frame is the same color as the string.



setFrameWidth
public void setFrameWidth(int width)(Code)
Set the width, in pixels, of a frame to draw around the string. If the value is zero, no frame is drawn. The default value is zero. The the value is clamped to the range 0 to 25.



setJustification
public void setJustification(int j)(Code)
Set the justification to be used if there are multiple lins in the string. Possible value are DrawString.LEFT, DrawString.RIGHT, and DrawString.CENTER.



setNumSize
public void setNumSize(int size)(Code)
Set the desired maximum number of characters in displayed numbers. Actual size might be larger. Value is clamped to the range 6 to 25.



setOffset
public void setOffset(int b)(Code)
Set the distance of the bounding box of the string from the reference point where it is drawn. The default value is 3.



setPositioning
public void setPositioning(int pos)(Code)
Set the positioning of the string. The parameter should be one of the positioning contstants defined in this class, such as TOP_LEFT. (If it is not, TOP_LEFT is used by default.)



setReferencePoint
public void setReferencePoint(Value x, Value y)(Code)
Set the values of the (x,y) coordinates of the reference point for the stirng. If a value is null, absolute positioning is used. If a value is undefined, the string is not drawn.



setString
public void setString(String str)(Code)
Set the string that is displayed. Note that it can include '\n' to represent a line break, and it can contain #'s which will be replaced by computed values.



setValues
public void setValues(Value[] v)(Code)
Set the Values that are substituted for (single) #'s in the string. If the array of Values is null, then no substitution is done. The length of the array should match the number of #'s, but it is not an error if they do not match. Extra values will be ignored; extra #'s will be shown as "undefined".



Fields inherited from edu.hws.jcm.draw.Drawable
protected DisplayCanvas canvas(Code)(Java Doc)
protected CoordinateRect coords(Code)(Java Doc)

Methods inherited from edu.hws.jcm.draw.Drawable
abstract public void draw(Graphics g, boolean coordsChanged)(Code)(Java Doc)
public boolean getVisible()(Code)(Java Doc)
public void needsRedraw()(Code)(Java Doc)
protected void setOwnerData(DisplayCanvas canvas, CoordinateRect coords)(Code)(Java Doc)
public void setVisible(boolean show)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.