Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.nwoods.jgo
Class JGoEllipse

    java.lang.Object
      com.nwoods.jgo.JGoObject
          com.nwoods.jgo.JGoDrawable
              com.nwoods.jgo.JGoEllipse

All Implemented Interfaces:
  JGoXMLSaveRestore, java.io.Serializable

public class JGoEllipse
extends JGoDrawable

Represents an ellipse object in a JGoView. The ellipse is defined by the rectangle which encloses it. An ellipse can be a circle if the rectangle is a square.

See Also:
  Serialized Form

Field Summary

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
`JGoEllipse()` Create an ellipse with no dimensions.
`JGoEllipse(java.awt.Point location, java.awt.Dimension size)` Create an ellipse with the given location and size.
`JGoEllipse(java.awt.Rectangle rect)` Create an ellipse with the given bounding rectangle

Method Summary
`JGoObject` | `copyObject(JGoCopyEnvironment env)` Create a new instance of this object with the same field values.
`static boolean` | `getNearestIntersectionPoint(int left, int top, int width, int height, int px, int py, int cx, int cy, java.awt.Point result)` Compute the point along the edge of an ellipse that is closest to a given point on a straight line from that point to another given point.
`static boolean` | `getNearestIntersectionPoint(int left, int top, int width, int height, int px, int py, java.awt.Point R)` Compute the point along the edge of an ellipse that is closest to a given point on a straight line from that point to the center of that ellipse specified by the given bounds.
`boolean` | `getNearestIntersectionPoint(int px, int py, int cx, int cy, java.awt.Point result)` Consider the pen width in determining the nearest intersection point.
`boolean` | `isPointInObj(java.awt.Point pnt)` Instead of just checking the bounding rectangle, this sees if the given point is actually in the ellipse.
`void` | `paint(java.awt.Graphics2D g, JGoView view)` Draw the ellipse on the screen.
`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 com.nwoods.jgo.JGoDrawable
`changeValue, copyNewValueForRedo, draw3DRect, draw3DRect, drawEllipse, drawEllipse, drawEllipse, drawLine, drawLine, drawPath, drawPolygon, drawPolygon, drawRect, drawRect, drawRect, drawRoundRect, drawRoundRect, expandRectByPenWidth, getBrush, getPen, setBrush, setPen, SVGAddPathArgs, SVGUpdateReference`

Methods inherited from class com.nwoods.jgo.JGoObject
`canView, computeBoundingRect, computeMove, computeResize, copy, copyObjectDelayed, copyOldValueForUndo, copyRect, doMouseClick, doMouseDblClick, doUncapturedMouseMove, findCommonParent, foredate, gainedSelection, geometryChange, geometryChangeChild, getBoundingRect, getDocument, getDraggingObject, getFlags, getHeight, getLayer, getLeft, getLocation, getLocation, getParent, getParentJGoNode, getParentNode, getPartner, getRectangleSpotLocation, getSize, getSize, getSpotLocation, getSpotLocation, getToolTipText, getTop, getTopLeft, getTopLeft, getTopLevelObject, getView, getWidth, growRect, handleMove, handleResize, hideSelectionHandles, is4ResizeHandles, isAutoRescale, isBoundingRectInvalid, isChildOf, isDraggable, isDragsNode, isInitializing, isResizable, isSelectable, isSkipsUndoManager, isSuspendChildUpdates, isSuspendUpdates, isTopLevel, isUpdatePartner, isVisible, lostSelection, ownerChange, partnerUpdate, pick, redirectSelection, remove, set4ResizeHandles, setAutoRescale, setBoundingRect, setBoundingRect, setBoundingRect, setBoundingRectForce, setBoundingRectForce, setBoundingRectInvalid, setBoundsRect, setDraggable, setDragsNode, setFlags, setHeight, setInitializing, setLeft, setLocation, setLocation, setLocationOffset, setLocationOffset, setParent, setPartner, setRectangleSpotLocation, setResizable, setSelectable, setSize, setSize, setSizeKeepingLocation, setSkipsUndoManager, setSpotLocation, setSpotLocation, setSpotLocation, setSpotLocationOffset, setSuspendChildUpdates, setSuspendUpdates, setTop, setTopLeft, setTopLeft, setUpdatePartner, setVisible, setWidth, showSelectionHandles, spotOpposite, update, update`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### JGoEllipse

    public JGoEllipse()

  Create an ellipse with no dimensions.

### JGoEllipse

    public JGoEllipse(java.awt.Rectangle rect)

  Create an ellipse with the given bounding rectangle

Parameters:
  `rect` - the bounding rectangle.

### JGoEllipse

    public JGoEllipse(java.awt.Point location,
                      java.awt.Dimension size)

  Create an ellipse with the given location and size.

Parameters:
  `location` - the location of the ellipse.
  `size` - the size of the ellipse.

Method Detail

### copyObject

    public JGoObject copyObject(JGoCopyEnvironment env)

  Create a new instance of this object with the same field values.

  Overrides:
    `copyObject` in class `JGoDrawable`
  Parameters:
    `env` - the environment for the copy operation - keeps track of copied objects.

### SVGWriteObject

    public void SVGWriteObject(DomDoc svgDoc,
                               DomElement jGoElementGroup)

  Description copied from interface: `JGoXMLSaveRestore`
  Write this object out to a DomDoc representing a Scalable Vector Graphics (SVG) XML document.

  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.

  Specified by:
    `SVGWriteObject` in interface `JGoXMLSaveRestore`
  Overrides:
    `SVGWriteObject` in class `JGoDrawable`

### SVGReadObject

    public DomNode SVGReadObject(DomDoc svgDoc,
                                 JGoDocument jGoDoc,
                                 DomElement svgElement,
                                 DomElement jGoChildElement)

  Description copied from interface: `JGoXMLSaveRestore`
  Read this object in from a DomDoc representing a Scalable Vector Graphics (SVG) XML document.

  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.

  Specified by:
    `SVGReadObject` in interface `JGoXMLSaveRestore`
  Overrides:
    `SVGReadObject` in class `JGoDrawable`

### SVGWriteAttributes

    public void SVGWriteAttributes(DomElement svgElement)

  Description copied from class: `JGoObject`
  This method will add attributes to standard SVG elements.

  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.

  Overrides:
    `SVGWriteAttributes` in class `JGoDrawable`

### SVGReadAttributes

    public void SVGReadAttributes(DomElement svgElement)

  Description copied from class: `JGoObject`
  This method will read attributes from standard SVG elements.

  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.

  Overrides:
    `SVGReadAttributes` in class `JGoDrawable`

### paint

    public void paint(java.awt.Graphics2D g,
                      JGoView view)

  Draw the ellipse on the screen.

  Overrides:
    `paint` in class `JGoObject`
  Parameters:
    `g` - the graphics context on which to draw.
    `view` - the view we're drawing in

### isPointInObj

    public boolean isPointInObj(java.awt.Point pnt)

  Instead of just checking the bounding rectangle, this sees if the given point is actually in the ellipse. Any pen width is ignored.

  Overrides:
    `isPointInObj` in class `JGoObject`
  Parameters:
    `pnt` - the point to check
  Returns:
    true if pnt is in this object

### getNearestIntersectionPoint

    public static boolean getNearestIntersectionPoint(int left,
                                                      int top,
                                                      int width,
                                                      int height,
                                                      int px,
                                                      int py,
                                                      java.awt.Point R)

  Compute the point along the edge of an ellipse that is closest to a given point on a straight line from that point to the center of that ellipse specified by the given bounds.

  Parameters:
    `left` - the left bounds of an ellipse
    `top` - the top bounds of an ellipse
    `width` - the width of an ellipse
    `height` - the height of an ellipse
    `px` - the X coordinate of a point that specifies a line to the center
    `py` - the Y coordinate of a point that specifies a line to the center
    `R` - a Point that is modified (must not be null)
  Returns:
    true

### getNearestIntersectionPoint

    public static boolean getNearestIntersectionPoint(int left,
                                                      int top,
                                                      int width,
                                                      int height,
                                                      int px,
                                                      int py,
                                                      int cx,
                                                      int cy,
                                                      java.awt.Point result)

  Compute the point along the edge of an ellipse that is closest to a given point on a straight line from that point to another given point.

  We modify the given result Point to hold the point that is closest to (px,py). (cx,cy) is typically the center of the ellipse.

  Parameters:
    `left` - the left bounds of a rectangle
    `top` - the top bounds of a rectangle
    `width` - the width of a rectangle
    `height` - the height of a rectangle
    `px` - the X coordinate of a point that starts a line
    `py` - the Y coordinate of a point that starts a line
    `cx` - the X coordinate of a point that specifies the other end of the line
    `cy` - the Y coordinate of a point that specifies the other end of the line
    `result` - a Point that is modified (must not be null)
  Returns:
    whether the line from (px,py) to (cx,cy) intersects the rectangle

### getNearestIntersectionPoint

    public boolean getNearestIntersectionPoint(int px,
                                               int py,
                                               int cx,
                                               int cy,
                                               java.awt.Point result)

  Description copied from class: `JGoDrawable`
  Consider the pen width in determining the nearest intersection point.

  Overrides:
    `getNearestIntersectionPoint` in class `JGoDrawable`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD