Java Doc for DrawGeometric.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.DrawGeometric

All known Subclasses:   edu.hws.jcm.draw.Crosshair,  edu.hws.jcm.draw.TangentLine,
DrawGeometric
public class DrawGeometric extends Drawable implements Computable(Code)
A DrawGeometric object is a geometic figure such as a line or rectangle that can be drawn in a CoordinateRect. The data for the object always consists of four numbers, which are interpreted differenetly depending on the object. These numbers can be specified as Value objects. A DrawGeometric is a Computable, and the Values will be re-computed when its compute() method is called. It should be added to a Controller that can respond to any changes in the data that define the Values. If one of the Value objects has an undefined value, nothing will be drawn.

The type of object is given as one of the constants defined in this class: LINE_ABSOLUTE, OVAL_RELATIVE, CROSS, and so on. In the descriptions of these constants, x1, x2, y1, and y2 refer to the values of Value objects that provide data for the DrawGeomentric while h and v refer to int's that can be specified in place of x2 and y2 for certain types of figures. For those figures, h or v is used if x2 or y2, respectively, is null.
author:
   David Eck



Field Summary
final public static  intCROSS
     Specifies a cross centered on the point (x1,y1).
final public static  intINFINITE_LINE_ABSOLUTE
     Specifies a line that extends through the points (x1,y1) and (x2,y2) and beyond.
final public static  intINFINITE_LINE_RELATIVE
     Specifies an infinite line through (x1,y1) and (x1+x2,y1+y2), or through (x1,y1) and (x1+h,y1+v) if x2,y2 are null.
final public static  intLINE_ABSOLUTE
     Specifies a line segment from (x1,y1) to (x2,y2).
final public static  intLINE_CENTERED
     Specifies a line segment centered on (x1,y1).
final public static  intLINE_RELATIVE
     Specifies a line segment from (x1,y1) to (x1+x2,y1+y2), or to (x1+h,y1+v) if x2,y2 are null. (Note that h,v are given in terms of pixels while x1,x2,y1,y2 are given in terms of the CoordinateRect.
final public static  intOVAL_ABSOLUTE
     Specifies an oval that just fits in the rectangle with corners at (x1,y1) and (x2,y2).
final public static  intOVAL_CENTERED
     Specifies an oval that just fits inside the rect specified by RECT_CENTERED.
final public static  intOVAL_RELATIVE
     Specifies an oval that just fits inside the rect specified by RECT_RELATIVE.
final public static  intRECT_ABSOLUTE
     Specifies a rectangle with corners at (x1,y1) and (x2,y2).
final public static  intRECT_CENTERED
     Specifies a Rectangle centered on (x1,y1).
final public static  intRECT_RELATIVE
     Specifies a rectangle with one corner at (x1,y1), and with width given by x2, or h if if x2 is null, and with height given by y2, or by v if y2 is null.
protected  doublea
     Value of x1.
protected  doubleb
     Value of y1.
protected  doublec
     Value of x2.
protected  Colorcolor
     Color of the shappe.
protected  doubled
     Value of y2.
protected  ColorfillColor
     Rects and ovals are filled with this color, if it is non-null.
protected  inth
     Integer that gives horizontal pixel offset from x1.
protected  intlineWidth
     The width, in pixels, of lines, including the outlines of rects and ovals.
protected  intshape
    
protected  intv
     Integer that gives vertical pixel offset fromy1.
protected  Valuex1
     One of the Value objects that determine the shape that is drawn.
protected  Valuex2
     One of the Value objects that determine the shape that is drawn. The shape is specified by two points, (x1,y1) and (x2,y2). x2 must be non-null for the "ABSOLUTE" shapes.
protected  Valuey1
     One of the Value objects that determine the shape that is drawn.
protected  Valuey2
     One of the Value objects that determine the shape that is drawn. The shape is specified by two points, (x1,y1) and (x2,y2). y2 must be non-null for the "ABSOLUTE" shapes.

Constructor Summary
public  DrawGeometric()
     Create a DrawGeometric object.
public  DrawGeometric(int shape, Value x1, Value y1, Value x2, Value y2)
     Create a DrawGeometric with the specified shape and values for x1,x2,y1,y2 Any of the shapes makes sense in this context.
public  DrawGeometric(int shape, Value x1, Value y1, int h, int v)
     Create a DrawGeometric with a specified shape and values.

Method Summary
public  voidcompute()
     Recompute the values that define the size/postion of the DrawGeometric.
public  voiddraw(Graphics g, boolean coordsChanged)
     Do the drawing.
public  ColorgetColor()
     Get the non-null color that is used for drawing the shape.
public  ColorgetFillColor()
     Get the color that is used for filling ovals and rects.
public  intgetH()
     Get the horizontal offset from (x1,y1).
public  intgetLineWidth()
     Get the width, in pixels, of lines that are drawn.
public  intgetV()
     Get the vertical offset from (x1,y1).
public  ValuegetX1()
     Get the value that gives the x-coordinate of the first point that determines the shape.
public  ValuegetX2()
     Get the value that gives the x-coordinate of the second point that determines the shape.
public  ValuegetY1()
     Get the value that gives the y-coordinate of the first point that determines the shape.
public  ValuegetY2()
     Get the value that gives the y-coordinate of the second point that determines the shape.
public  voidsetColor(Color c)
     Set the color that is used for drawing the shape.
public  voidsetFillColor(Color c)
     Set the color that is used for filling ovals and rects.
public  voidsetH(int x)
     Set the integer that gives the horizontal offset from (x1,y1).
public  voidsetLineWidth(int width)
     Set the width, in pixels, of lines that are drawn.
public  voidsetPoints(Value x1, Value y1, Value x2, Value y2)
     Set the Value objects that specify the two points that determine the shape.
public  voidsetPoints(Value x1, Value y1, int h, int v)
     Set the values that specify a point (x1,y1) and an offset (h,v) from that point. This only makes sense for RELATIVE shapes.
public  voidsetShape(int shape)
     Set the shape, which should be given as one of the shape constants such as LINE_ABSOLUTE or CROSS.
public  voidsetV(int y)
     Set the integer that gives the vertical offset from (x1,y1).
public  voidsetX1(Value x)
     Set the value that gives the x-coordinate of the first point that determines the shape.
public  voidsetX2(Value x)
     Set the value that gives the x-coordinate of the second point that determines the shape.
public  voidsetY1(Value y)
     Set the value that gives the y-coordinate of the first point that determines the shape.
public  voidsetY2(Value y)
     Set the value that gives the y-coordinate of the second point that determines the shape.

Field Detail
CROSS
final public static int CROSS(Code)
Specifies a cross centered on the point (x1,y1). Its arms extend horizontally by a distance of x2, or h, in each direction. Its vertical arms extend y2, or v, in each direction.



INFINITE_LINE_ABSOLUTE
final public static int INFINITE_LINE_ABSOLUTE(Code)
Specifies a line that extends through the points (x1,y1) and (x2,y2) and beyond.



INFINITE_LINE_RELATIVE
final public static int INFINITE_LINE_RELATIVE(Code)
Specifies an infinite line through (x1,y1) and (x1+x2,y1+y2), or through (x1,y1) and (x1+h,y1+v) if x2,y2 are null.



LINE_ABSOLUTE
final public static int LINE_ABSOLUTE(Code)
Specifies a line segment from (x1,y1) to (x2,y2).



LINE_CENTERED
final public static int LINE_CENTERED(Code)
Specifies a line segment centered on (x1,y1). The amount it extends in each direction is given by x2,y2 or by h,v



LINE_RELATIVE
final public static int LINE_RELATIVE(Code)
Specifies a line segment from (x1,y1) to (x1+x2,y1+y2), or to (x1+h,y1+v) if x2,y2 are null. (Note that h,v are given in terms of pixels while x1,x2,y1,y2 are given in terms of the CoordinateRect. If you use h,v, you get a line of a fixed size and direction.)



OVAL_ABSOLUTE
final public static int OVAL_ABSOLUTE(Code)
Specifies an oval that just fits in the rectangle with corners at (x1,y1) and (x2,y2).



OVAL_CENTERED
final public static int OVAL_CENTERED(Code)
Specifies an oval that just fits inside the rect specified by RECT_CENTERED.



OVAL_RELATIVE
final public static int OVAL_RELATIVE(Code)
Specifies an oval that just fits inside the rect specified by RECT_RELATIVE.



RECT_ABSOLUTE
final public static int RECT_ABSOLUTE(Code)
Specifies a rectangle with corners at (x1,y1) and (x2,y2).



RECT_CENTERED
final public static int RECT_CENTERED(Code)
Specifies a Rectangle centered on (x1,y1). The amount it extends in each direction is given by x2,y2 or by h,v. (Thus, x2 or h is the HALF-width and y2 or v is the HALF-height.)



RECT_RELATIVE
final public static int RECT_RELATIVE(Code)
Specifies a rectangle with one corner at (x1,y1), and with width given by x2, or h if if x2 is null, and with height given by y2, or by v if y2 is null.



a
protected double a(Code)
Value of x1. This is re-computed when the compute() method is called.



b
protected double b(Code)
Value of y1. This is re-computed when the compute() method is called.



c
protected double c(Code)
Value of x2. This is re-computed when the compute() method is called.



color
protected Color color(Code)
Color of the shappe. Color will be black if this is null. For shapes that have "insides", such as rects, this is the color of the outline.



d
protected double d(Code)
Value of y2. This is re-computed when the compute() method is called.



fillColor
protected Color fillColor(Code)
Rects and ovals are filled with this color, if it is non-null. If this is null, only the outline of the shape is drawn.



h
protected int h(Code)
Integer that gives horizontal pixel offset from x1. This is only used if x2 is null.



lineWidth
protected int lineWidth(Code)
The width, in pixels, of lines, including the outlines of rects and ovals. It is restricted to being an integer in the range from 0 to 10. A value of 0 means that lines won't be drawn at all; this would only be useful for a filled shape that has a colored interior.



shape
protected int shape(Code)
One of the constants such as OVAL_CENTERED, specifying the shape to be drawn



v
protected int v(Code)
Integer that gives vertical pixel offset fromy1. This is only used if y2 is null.



x1
protected Value x1(Code)
One of the Value objects that determine the shape that is drawn. The shape is specified by two points, (x1,y1) and (x2,y2). x1 must be non-null.



x2
protected Value x2(Code)
One of the Value objects that determine the shape that is drawn. The shape is specified by two points, (x1,y1) and (x2,y2). x2 must be non-null for the "ABSOLUTE" shapes. (If not, they revert to "RELATIVE" shapes and use h,v as the offset values.)



y1
protected Value y1(Code)
One of the Value objects that determine the shape that is drawn. The shape is specified by two points, (x1,y1) and (x2,y2). y1 must be non-null.



y2
protected Value y2(Code)
One of the Value objects that determine the shape that is drawn. The shape is specified by two points, (x1,y1) and (x2,y2). y2 must be non-null for the "ABSOLUTE" shapes. (If not, they revert to "RELATIVE" shapes and use h,v as the offset values.)




Constructor Detail
DrawGeometric
public DrawGeometric()(Code)
Create a DrawGeometric object. By default, it is a LINE_ABSOLUTE. However, nothing will be drawn as long as x1,y1,x2,y2 are null.



DrawGeometric
public DrawGeometric(int shape, Value x1, Value y1, Value x2, Value y2)(Code)
Create a DrawGeometric with the specified shape and values for x1,x2,y1,y2 Any of the shapes makes sense in this context.
Parameters:
  shape - One of the shape constants such as LINE_ABSOLUTE or RECT_RELATIVE.



DrawGeometric
public DrawGeometric(int shape, Value x1, Value y1, int h, int v)(Code)
Create a DrawGeometric with a specified shape and values. The last two parameters give pixel offsets from x1,y1. The "ABSOLUTE" shapes don't make sense in this context. (They will be treated as the corresponding "RELATIVE" shapes.)
Parameters:
  shape - One of the "RELATIVE" or "CENTERED" shape constants such as LINE_RELATIVE or OVAL_CENTERED or CROSS.




Method Detail
compute
public void compute()(Code)
Recompute the values that define the size/postion of the DrawGeometric. This is ordinarily only called by a Controller.



draw
public void draw(Graphics g, boolean coordsChanged)(Code)
Do the drawing. This is not meant to be called directly.



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



getFillColor
public Color getFillColor()(Code)
Get the color that is used for filling ovals and rects. If null, no fill is done.



getH
public int getH()(Code)
Get the horizontal offset from (x1,y1).



getLineWidth
public int getLineWidth()(Code)
Get the width, in pixels, of lines that are drawn. This is also used for outlines of rects and ovals.



getV
public int getV()(Code)
Get the vertical offset from (x1,y1).



getX1
public Value getX1()(Code)
Get the value that gives the x-coordinate of the first point that determines the shape.



getX2
public Value getX2()(Code)
Get the value that gives the x-coordinate of the second point that determines the shape.



getY1
public Value getY1()(Code)
Get the value that gives the y-coordinate of the first point that determines the shape.



getY2
public Value getY2()(Code)
Get the value that gives the y-coordinate of the second point that determines the shape.



setColor
public void setColor(Color c)(Code)
Set the color that is used for drawing the shape. If the color is null, black is used. For shapes that have interiors, such as rects, this is only the color of the outline of the shaape.



setFillColor
public void setFillColor(Color c)(Code)
Set the color that is used for filling ovals and rects. If the color is null, only the outline of the shape is drawn.



setH
public void setH(int x)(Code)
Set the integer that gives the horizontal offset from (x1,y1). This only makes sense for RELATIVE shapes. This method also sets x2 to null, since the h value is only used when x2 is null.



setLineWidth
public void setLineWidth(int width)(Code)
Set the width, in pixels, of lines that are drawn. This is also used for outlines of rects and ovals.



setPoints
public void setPoints(Value x1, Value y1, Value x2, Value y2)(Code)
Set the Value objects that specify the two points that determine the shape. The first two parameters, x1 and y1, must be non-null.



setPoints
public void setPoints(Value x1, Value y1, int h, int v)(Code)
Set the values that specify a point (x1,y1) and an offset (h,v) from that point. This only makes sense for RELATIVE shapes. The Value objects x1 and y1 must be non-null



setShape
public void setShape(int shape)(Code)
Set the shape, which should be given as one of the shape constants such as LINE_ABSOLUTE or CROSS.



setV
public void setV(int y)(Code)
Set the integer that gives the vertical offset from (x1,y1). This only makes sense for RELATIVE shapes. This method also sets y2 to null, since the v value is only used when y2 is null.



setX1
public void setX1(Value x)(Code)
Set the value that gives the x-coordinate of the first point that determines the shape. This must be non-null, or nothing will be drawn.



setX2
public void setX2(Value x)(Code)
Set the value that gives the x-coordinate of the second point that determines the shape. If this is null, then the value of h is used instead.



setY1
public void setY1(Value y)(Code)
Set the value that gives the y-coordinate of the first point that determines the shape. This must be non-null, or nothing will be drawn.



setY2
public void setY2(Value y)(Code)
Set the value that gives the y-coordinate of the second point that determines the shape. If this is null, then the value of v is used instead.



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.