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

CoordinateRect
public class CoordinateRect implements Tieable,Limits,Computable,InputObject(Code)
A CoordinateRect represents a rectagular region in the xy-plane, specified by values xmin,xmax,ymin,ymax. The conditions ymin < ymax and xmin < xmax are enforced. (Values are swapped if necessary, and if min==max, they are reset to -1 and +1. If any of the values are set to an infinite or NaN value, then the coordinate rect won't display anything except the message "Error: undefined limits".)

When the Rect is mapped onto the screen, there can be a gap of a specified number of pixels between the min,max values and the edges of the rectangle on the screen. If the gap is non-zero, then the actual range of coordinates on the rect is larger than the range from the specifed min to max. (This is done mainly so I could have axes that don't quite reach the edges of the rect.)

A CoordinateRect maintains a list of Drawable items. When the Rect's draw() method is called, it calls the draw() method of each of the Drawable items it contains. When its compute() method is called, it calls the compute() method of any Drawable that is a Computable. When its checkInput() method is called, it calls the checkInput() method of any Drawable that is an InputObject.

A CoordinateRect represents a rectangular region in a DisplayCanvas. It has a reference to that Canvas, which is set automatically when it is added to the canvas. If the size, range, or gap on the CoordinateRect change, it will ask the Canvas to redraw the area it occupies.

The values of xmin, xmax, ymin, ymax are exported as Value objects, which can be used elsewhere in your program. The Value objects can be obtained by calling getValueObject(). If you do this, you should add the objects that depend on those values to a Controller and register the Controller to listen for changes from this CoordinateRect by calling the CoordinateRect.setOnChange(Controller) method.



Field Summary
final public static  intXMAX
     A constant for use with the getValueObject() method to specify which Value is to be returned.
final public static  intXMIN
     A constant for use with the getValueObject() method to specify which Value is to be returned.
final public static  intYMAX
     A constant for use with the getValueObject() method to specify which Value is to be returned.
final public static  intYMIN
     A constant for use with the getValueObject() method to specify which Value is to be returned.
protected  booleanchanged
     Set to true when one of the limits or the gap has changed.
protected  VectordrawItems
    
protected  ControlleronChange
     If non-null, this is the Controller that is notified when the limits change.
protected  TiesyncWith
     This contains other Limit objects with which the CoordinateRect is synchronizing.

Constructor Summary
public  CoordinateRect()
     Create a CoordinateRect with default limits: -5, 5, -5, 5.
public  CoordinateRect(double xmin, double xmax, double ymin, double ymax)
     Create a CoordinateRect with specified limits.

Method Summary
public synchronized  voidadd(Drawable d)
     Add a drawable item to the CoordinateRect.
 DraggablecheckDraggables(java.awt.event.MouseEvent evt)
     Check whether a mouse click (as specified in the MouseEvent parameter) is a click on a Draggable item that wants to be dragged.
public  voidcheckInput()
     When this is called, the CoordinateRect will call the checkInput method of any Drawable it contains that is also an InputObject.
public  voidclearRestoreBuffer()
     A CoordinateRect can store its current limits in a buffer.
public  voidcompute()
     When this is called, the CoordinateRect will call the compute method of any Drawable it contains that is also a Computable.
protected  voiddoDraw(Graphics g)
     Draw all the Drawable items.
public  voiddraw(Graphics g, int width, int height)
     Draw in rect with upperleft corner (0,0) and specified width,height.
public synchronized  voiddraw(Graphics g, int left, int top, int width, int height)
     Draw in specified rect.
public  double[]equalizeAxes()
     Reset limits, if necessary, so scales on the axes are the same. Only valid of the CoordinateRect has been drawn.
public  DrawablegetDrawable(int i)
     Get the i-th Drawable in this Rect, or null if i is less than zero or greater than or equal to the number of items.
public  intgetDrawableCount()
     Returns the number of Drawable items that are in this CoordinateRect.
public  intgetGap()
     Get the gap, in pixels, between the edges of the CoordinateRect and the limits specified by xmin, xmax, ymin, and ymax.
public  intgetHeight()
     Get the height in pixels of this CoordinateRect in the DisplayCanvas that contains it. (This is only valid when the CoordinateRect has actually been displayed.
public  intgetLeft()
     Get the left edge of this CoordinateRect in the DisplayCanvas that contains it. (This is only valid when the CoordinateRect has actually been displayed.
public  double[]getLimits()
     Get an array containing the limits on the CoordinateRect in the order xmin, xmax, ymin, ymax.
public  ControllergetOnChange()
     Get the controller that is notified when the limits on this CoordinateRect change.
public  doublegetPixelHeight()
     Return the height of one pixel in this coordinate system. (This is only valid when the CoordinateRect has actually been displayed.
public  doublegetPixelWidth()
     Return the width of one pixel in this coordinate system. (This is only valid when the CoordinateRect has actually been displayed.
public  longgetSerialNumber()
     Return the serial number of the CoordinateRect, which is incremented each time the limits change.
public  intgetTop()
     Get the top edge of this CoordinateRect in the DisplayCanvas that contains it. (This is only valid when the CoordinateRect has actually been displayed.
public  ValuegetValueObject(int which)
     Get a Value object representing one of the limits on this CoordinateRect.
public  intgetWidth()
     Get the width in pixels of this CoordinateRect in the DisplayCanvas that contains it. (This is only valid when the CoordinateRect has actually been displayed.
public  doublegetXmax()
     Get the maximum x-coordinate.
public  doublegetXmin()
     Get the mimimum x-coordinate.
public  doublegetYmax()
     Get the maximum x-coordinate.
public  doublegetYmin()
     Get the mimimum y-coordinate.
public  voidnotifyControllerOnChange(Controller c)
     Method required by InputObject interface; in this class, it calls the same method recursively on any input objects containted in this CoordinateRect.
public  doublepixelToX(int h)
     Convert a horizontal pixel coordinate into an x-coordinate. (This is only valid when the CoordinateRect has actually been displayed.
public  doublepixelToY(int y)
     Convert a vertical pixel coordinate into a y-coordinate. (This is only valid when the CoordinateRect has actually been displayed.
public synchronized  voidremove(Drawable d)
     Remove the given Drawable item, if present in this CoordinateRect.
public  double[]restore()
     A CoordinateRect can store its current limits in a buffer.
public  voidsetGap(int g)
     Set the gap.
public  voidsetLimits(double xmin, double xmax, double ymin, double ymax)
    
public  voidsetLimits(double[] d)
     Set the coordinate limits from array; extra elements in array are ignored.
public  voidsetOnChange(Controller c)
     Specify a controller to be notified when the limits on this CoordinateRect change.
 voidsetOwner(DisplayCanvas canvas)
     This is meant to be called only by the DisplayCanvas class, when this CoordinateRect is added to ta DisplayCanvas.
public  voidsetRestoreBuffer()
     Save current limits in buffer.
public  voidsetSyncWith(Tie tie)
     Set the Tie object that is used to synchronize this CoordinareRect with other objects.
public  voidsync(Tie tie, Tieable newest)
     Part of the Tieable interface.
public  intxToPixel(double x)
     Convert an x-coodinate into a horizontal pixel coordinate. (This is only valid when the CoordinateRect has actually been displayed.
public  intyToPixel(double y)
     Convert a y-coodinate into a vertical pixel coordinate. (This is only valid when the CoordinateRect has actually been displayed.
public  double[]zoomIn()
     Change limits to zoom in by a factor of 2.
public  double[]zoomInOnPixel(int x, int y)
     Change limits to zoom in by a factor of 2, centered on a specified point.
public  double[]zoomOut()
     Change limits to zoom out by a factor of 2.
public  double[]zoomOutFromPixel(int x, int y)
     Change limits to zoom out by a factor of 2, centered on a specified point.

Field Detail
XMAX
final public static int XMAX(Code)
A constant for use with the getValueObject() method to specify which Value is to be returned. XMAX specifies that the Value is the maximum x-coordinate on the CoordinateRect.



XMIN
final public static int XMIN(Code)
A constant for use with the getValueObject() method to specify which Value is to be returned. XMIN specifies that the Value is the minimum x-coordinate on the CoordinateRect.



YMAX
final public static int YMAX(Code)
A constant for use with the getValueObject() method to specify which Value is to be returned. YMAX specifies that the Value is the maximum y-coordinate on the CoordinateRect.



YMIN
final public static int YMIN(Code)
A constant for use with the getValueObject() method to specify which Value is to be returned. YMIN specifies that the Value is the minimum y-coordinate on the CoordinateRect.



changed
protected boolean changed(Code)
Set to true when one of the limits or the gap has changed.



drawItems
protected Vector drawItems(Code)
Drawable items contained in this CoordinateRect



onChange
protected Controller onChange(Code)
If non-null, this is the Controller that is notified when the limits change.



syncWith
protected Tie syncWith(Code)
This contains other Limit objects with which the CoordinateRect is synchronizing. This is ordinarily managed by a LimitControlPanel, so you don't have to worry about it. (However, you can also sync several CoordinateRects even in the absense of a LimitControlPanel. To do so, create the Tie that ties the CoordinateRect and pass it to the setSyncWith() method of each CoordinateRect. It is NOT necessary to add the Tie to a Controller. Synchronization is handled by the CoordinateRects themselves.




Constructor Detail
CoordinateRect
public CoordinateRect()(Code)
Create a CoordinateRect with default limits: -5, 5, -5, 5.



CoordinateRect
public CoordinateRect(double xmin, double xmax, double ymin, double ymax)(Code)
Create a CoordinateRect with specified limits.




Method Detail
add
public synchronized void add(Drawable d)(Code)
Add a drawable item to the CoordinateRect.



checkDraggables
Draggable checkDraggables(java.awt.event.MouseEvent evt)(Code)
Check whether a mouse click (as specified in the MouseEvent parameter) is a click on a Draggable item that wants to be dragged. If so, return that item. If not, return null. This is meant to be called only by DisplayCanvas.



checkInput
public void checkInput()(Code)
When this is called, the CoordinateRect will call the checkInput method of any Drawable it contains that is also an InputObject. This is ordinarly only called by a DisplayCanvas.



clearRestoreBuffer
public void clearRestoreBuffer()(Code)
A CoordinateRect can store its current limits in a buffer. This method clears that buffer.



compute
public void compute()(Code)
When this is called, the CoordinateRect will call the compute method of any Drawable it contains that is also a Computable. This is ordinarly only called by a DisplayCanvas.



doDraw
protected void doDraw(Graphics g)(Code)
Draw all the Drawable items. This is called by the draw() method and is not meant to be called directly. However, it might be overridden in a subclass.



draw
public void draw(Graphics g, int width, int height)(Code)
Draw in rect with upperleft corner (0,0) and specified width,height. This is not ordinarily called directly.



draw
public synchronized void draw(Graphics g, int left, int top, int width, int height)(Code)
Draw in specified rect. This is not ordinarily called directly.



equalizeAxes
public double[] equalizeAxes()(Code)
Reset limits, if necessary, so scales on the axes are the same. Only valid of the CoordinateRect has been drawn. an array with the new limits, or null if limits don't change.



getDrawable
public Drawable getDrawable(int i)(Code)
Get the i-th Drawable in this Rect, or null if i is less than zero or greater than or equal to the number of items.
Parameters:
  i - The number of the item to be returned, where the first item is number zero.



getDrawableCount
public int getDrawableCount()(Code)
Returns the number of Drawable items that are in this CoordinateRect.



getGap
public int getGap()(Code)
Get the gap, in pixels, between the edges of the CoordinateRect and the limits specified by xmin, xmax, ymin, and ymax.



getHeight
public int getHeight()(Code)
Get the height in pixels of this CoordinateRect in the DisplayCanvas that contains it. (This is only valid when the CoordinateRect has actually been displayed. It is meant mainly to be used by Drawables in this CoordinateRect.)



getLeft
public int getLeft()(Code)
Get the left edge of this CoordinateRect in the DisplayCanvas that contains it. (This is only valid when the CoordinateRect has actually been displayed. It is meant mainly to be used by Drawables in this CoordinateRect.)



getLimits
public double[] getLimits()(Code)
Get an array containing the limits on the CoordinateRect in the order xmin, xmax, ymin, ymax.



getOnChange
public Controller getOnChange()(Code)
Get the controller that is notified when the limits on this CoordinateRect change. This can be null.



getPixelHeight
public double getPixelHeight()(Code)
Return the height of one pixel in this coordinate system. (This is only valid when the CoordinateRect has actually been displayed. It is meant mainly to be used by Drawables in this CoordinateRect.)



getPixelWidth
public double getPixelWidth()(Code)
Return the width of one pixel in this coordinate system. (This is only valid when the CoordinateRect has actually been displayed. It is meant mainly to be used by Drawables in this CoordinateRect.)



getSerialNumber
public long getSerialNumber()(Code)
Return the serial number of the CoordinateRect, which is incremented each time the limits change. Part of the Tieable interface. Not meant to be called directly.



getTop
public int getTop()(Code)
Get the top edge of this CoordinateRect in the DisplayCanvas that contains it. (This is only valid when the CoordinateRect has actually been displayed. It is meant mainly to be used by Drawables in this CoordinateRect.)



getValueObject
public Value getValueObject(int which)(Code)
Get a Value object representing one of the limits on this CoordinateRect. The parameter should be one of the constants CoordinateRect.XMIN, CoordinateRect.XMAX, CoordinateRect.YMIN, or CoordinateRect.YMAX. (If not, it is treated the same as YMAX).



getWidth
public int getWidth()(Code)
Get the width in pixels of this CoordinateRect in the DisplayCanvas that contains it. (This is only valid when the CoordinateRect has actually been displayed. It is meant mainly to be used by Drawables in this CoordinateRect.)



getXmax
public double getXmax()(Code)
Get the maximum x-coordinate.



getXmin
public double getXmin()(Code)
Get the mimimum x-coordinate.



getYmax
public double getYmax()(Code)
Get the maximum x-coordinate.



getYmin
public double getYmin()(Code)
Get the mimimum y-coordinate.



notifyControllerOnChange
public void notifyControllerOnChange(Controller c)(Code)
Method required by InputObject interface; in this class, it calls the same method recursively on any input objects containted in this CoordinateRect. This is meant to be called by JCMPanel.gatherInputs().



pixelToX
public double pixelToX(int h)(Code)
Convert a horizontal pixel coordinate into an x-coordinate. (This is only valid when the CoordinateRect has actually been displayed. It is meant mainly to be used by Drawables in this CoordinateRect.)



pixelToY
public double pixelToY(int y)(Code)
Convert a vertical pixel coordinate into a y-coordinate. (This is only valid when the CoordinateRect has actually been displayed. It is meant mainly to be used by Drawables in this CoordinateRect.)



remove
public synchronized void remove(Drawable d)(Code)
Remove the given Drawable item, if present in this CoordinateRect.



restore
public double[] restore()(Code)
A CoordinateRect can store its current limits in a buffer. These limits can be restored by a call to this method. Only one level of save/restore is provided. If limits have not been saved, then nothing happens. The original limits on the CoordinateRect are saves automatically when the CoordinateRect is first created. an array containing new limits.



setGap
public void setGap(int g)(Code)
Set the gap. This is ignored if g is less than zero. This gap is the number of pixels between the edges of the CoordinateRect and the limits specified by xmin, xmax, ymin, and ymax. The default value is 5.



setLimits
public void setLimits(double xmin, double xmax, double ymin, double ymax)(Code)
Set the limits on the CoordinteRect
Parameters:
  xmin - the minimum x-coordinate on the CoordinateRect
Parameters:
  xmax - the maximum x-coordinate on the CoordinateRect
Parameters:
  ymin - the minimum y-coordinate on the CoordinateRect
Parameters:
  ymax - the maximum y-coordinate on the CoordinateRect



setLimits
public void setLimits(double[] d)(Code)
Set the coordinate limits from array; extra elements in array are ignored. This is ignored if the array is null or has fewer than 4 members. The order of values in the array is xmin, xmax, ymin, ymax.



setOnChange
public void setOnChange(Controller c)(Code)
Specify a controller to be notified when the limits on this CoordinateRect change.



setOwner
void setOwner(DisplayCanvas canvas)(Code)
This is meant to be called only by the DisplayCanvas class, when this CoordinateRect is added to ta DisplayCanvas.



setRestoreBuffer
public void setRestoreBuffer()(Code)
Save current limits in buffer. They can be restored later by a call to the restore() method. Only one level of save/restore is provided.



setSyncWith
public void setSyncWith(Tie tie)(Code)
Set the Tie object that is used to synchronize this CoordinareRect with other objects. This is ordinarily called by a LimitControlPanel, so you don't have to worry about it.



sync
public void sync(Tie tie, Tieable newest)(Code)
Part of the Tieable interface. Not meant to be called directly.



xToPixel
public int xToPixel(double x)(Code)
Convert an x-coodinate into a horizontal pixel coordinate. (This is only valid when the CoordinateRect has actually been displayed. It is meant mainly to be used by Drawables in this CoordinateRect.)



yToPixel
public int yToPixel(double y)(Code)
Convert a y-coodinate into a vertical pixel coordinate. (This is only valid when the CoordinateRect has actually been displayed. It is meant mainly to be used by Drawables in this CoordinateRect.)



zoomIn
public double[] zoomIn()(Code)
Change limits to zoom in by a factor of 2. A maximal zoom is enforced. The center of the rectangle does not move. an array of the new limits, or null if limits don't change.



zoomInOnPixel
public double[] zoomInOnPixel(int x, int y)(Code)
Change limits to zoom in by a factor of 2, centered on a specified point. A maximal zoom is enforced. The point does not move. Only valid when CoordinateRect is displayed in a rectangle on the screen.
Parameters:
  x - the horizontal pixel coordinate of the center point of the zoom
Parameters:
  y - the vertical pixel coordinate of the center point of the zoom an array of the new limits, or null if limits don't change.



zoomOut
public double[] zoomOut()(Code)
Change limits to zoom out by a factor of 2. A maximal zoom is enforced. The center of the rectangle does not move. an array of the new limits, or null if limits don't change.



zoomOutFromPixel
public double[] zoomOutFromPixel(int x, int y)(Code)
Change limits to zoom out by a factor of 2, centered on a specified point. A maximal zoom is enforced. The point (x,y) does not move. Valid only if CoordinateRect has been drawn.
Parameters:
  x - the horizontal pixel coordinate of the center point of the zoom
Parameters:
  y - the vertical pixel coordinate of the center point of the zoom an array of the new limits, or null if limits don't change.



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.