Package doodlepad
Class Shape
java.lang.Object
doodlepad.Shape
Abstract base class for all graphical shape objects
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Interface used by methods that assign mouse event handlers given a method reference as a parameter.static interface
Interface used by methods that assign selection event handlers given a method reference as a parameter. -
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Boolean indicating if this shape can be dragged.protected boolean
Flag indicating if this Shape should receive eventsprotected Color
The fill color to be used to draw this Shape.protected boolean
Flag to determine if Shape should be filled.protected Font
The Font to use to render the textprotected String
protected int
protected int
protected double
The height of the Shape's bounding box.protected Layer
The Layer on which this Shape is to be drawnprotected boolean
Flag to indicate if this Shape can be selected.protected boolean
Flag to indicate if this Shape is currently selectedprotected ShapeMouseListener
Inner class used to handle Shape mouse events.protected Color
The stroke color to be used to draw this Shape.protected boolean
Flag to determine if Shape should be stroked.protected double
The width of the stroke used to draw this Shape.protected String
The String to be displayed over a Shapeprotected Color
Color to use to render the textprotected AffineTransform
The current affine transform to be used when drawing this Shapeprotected boolean
Flag to determine if Shape should be drawn.protected double
The width of the Shape's bounding box.protected double
The x-coordinate of the upper left-hand coordinate of the Shape's bounding box.protected double
The y-coordinate of the upper left-hand coordinate of the Shape's bounding box. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(double x, double y) Returns true if this shape contains the given pointboolean
Returns true if this shape contains the given pointabstract void
draw
(Graphics2D g) Draw the shape.protected void
Draw the text over a ShapegetArea()
Get a rectangular Area object that surrounds the ShapeReturn the current center point of the shape as a Point object.boolean
Determine if the Shape is set so that it can be draggedboolean
Return setting that indicates if the Shape object will receive events that are implementable by overriding methodsint
Get the fill color alpha componentint
Get the fill color blue componentGet fill color that currently used to fill the shape when drawnboolean
Get flag indicating whether or not Shape should be filled.int
Get the fill color green componentint
Get the fill color red componentReturn the Font family name for this Rectangle object.int
Return the font size for this Text object.int
Return the Font style code for this Rectangle object.double
Get the Shape's heightgetLayer()
Return the Layer on which this Shape existsReturn the current location of the shape as a Point object.getPad()
A utility method that returns this Shape's Pad instanceGet the coordinates of the Shape location in the Pad coordinate systemboolean
Determine if the Shape is set so that it can be selectedboolean
Return selected state of this Shape.getSize()
Return the current Shape size as a Dimension objectint
Get the stroke color alpha componentint
Get the stroke color blue componentGet the current Shape stroke color.boolean
Get flag indicating whether or not Shape should be stroked.int
Get the stroke color green componentint
Get the stroke color red componentdouble
Get the current stroke width for this Shape.getText()
Return the Rectangle object StringClone the Shape\'s current AffineTransform.boolean
Get visible status of Shapedouble
getWidth()
Get the Shape's widthGet the coordinates of the Shape location in the window coordinate systemdouble
getX()
Get x-coordinate of Shapedouble
getY()
Get y-coordinate of Shapeboolean
intersects
(Shape shp) Determine if the current Shape intersects with the shp Shape parametervoid
move
(double dx, double dy) Move the Shape by the amounts specified in the x and y-directionsvoid
onMouseClicked
(double x, double y, int button) Handle mouse clicked Shape events.void
onMouseDoubleClicked
(double x, double y, int button) Handle mouse double-clicked Shape events.void
onMouseDragged
(double x, double y, int button) Handle mouse dragged Shape events.void
onMouseEntered
(double x, double y, int button) Handle mouse entered Shape events.void
onMouseExited
(double x, double y, int button) Handle mouse exited Shape events.void
onMouseMoved
(double x, double y, int button) Handle mouse moved Shape events.void
onMousePressed
(double x, double y, int button) Handle mouse pressed Shape events.void
onMouseReleased
(double x, double y, int button) Handle mouse released Shape events.void
onSelectionChanged
(boolean sel) React to change in selection state by overridingprotected void
repaint()
Utility method to trigger a repaint of the entire Pad.void
reset()
Resets the shape to have no transformation.void
rotate
(double angle) Add a rotation angle to Shape transform.void
rotate
(double angle, double cx, double cy) Add a rotation angle to Shape transform.void
scale
(double factor) Add a scale factor to Shape transform.void
scale
(double xFactor, double yFactor) Add a scale factor to Shape transform.void
scale
(double factor, double cx, double cy) Add a scale factor to Shape transform.void
scale
(double xFactor, double yFactor, double cx, double cy) Add a scale factor to Shape transform.void
setCenter
(double cx, double cy) Set the Shape position so that the center is at the given coordinates.void
Set the Shape position so that the center is at the given Point.void
setDraggable
(boolean drag) Set the flag that indicates if the shape can be dragged.void
setEventsEnabled
(boolean enabled) Set the boolean indicating whether or not the Shape will receive events that can be handled by overriding event methodsvoid
setFillColor
(double gray) Set the gray scale fill color with which to draw the shape.void
setFillColor
(double red, double green, double blue) Set the fill color with which to draw the shapevoid
setFillColor
(double red, double green, double blue, double alpha) Set the fill color with which to fill the shapevoid
setFillColor
(Color color) Set the fill color by passing a Color objectvoid
setFilled
(boolean filled) Set flag indicating whether or not Shape should be filled.void
setFontFamily
(String fontFamily) Update the Font family for the text of this Rectangle object.void
setFontSize
(int fontSize) Update the Font size for this Rectangle object.void
setFontStyle
(int fontStyle) Update the Font style for this Rectangle object.void
setHeight
(double height) Set a new Shape height.void
setLocation
(double x, double y) Set the current location of the shape and redraw it.void
setLocation
(Point p) Set the current location of the shape and redraw it.void
Assign an onMouseClicked event handler using a method reference.void
Assign an onMouseDoubleClicked event handler using a method reference.void
Assign an onMouseDragged event handler using a method reference.void
Assign an onMouseEntered event handler using a method reference.void
Assign an onMouseExited event handler using a method reference.void
Assign an onMouseMoved event handler using a method reference.void
Assign an onMousePressed event handler using a method reference.void
Assign an onMouseReleased event handler using a method reference.void
Set the Pad location of the Shapevoid
setSelectable
(boolean select) Set the flag that indicates if the shape can be selectedvoid
setSelected
(boolean sel) Set the selected state of the Shapevoid
Assign a selectionChanged event handler using a method reference.void
setSize
(double width, double height) Reset the size of the Shape and trigger a repaintvoid
Reset the size of the Shape and trigger a repaintvoid
setStrokeColor
(double gray) Set the gray scale stroke color with which to draw the shape.void
setStrokeColor
(double red, double green, double blue) Set the current Shape stroke color.void
setStrokeColor
(double red, double green, double blue, double alpha) Set the fill color with which to stroke the shapevoid
setStrokeColor
(Color clr) Set the stroke color of the Shapevoid
setStroked
(boolean stroked) Set flag indicating whether or not Shape should be stroked.void
setStrokeWidth
(double width) Set the stroke width for this Shape.void
Set the Rectangle textvoid
setTextColor
(double gray) Set the gray scale text color with which to draw the shape.void
setTextColor
(double red, double green, double blue) Set the text colorvoid
setTextColor
(double red, double green, double blue, double alpha) Set the text colorvoid
setTextColor
(Color color) Set the text color by passing a Color objectvoid
setTransform
(AffineTransform transform) Set a new AffineTransform for the Shape.void
setVisible
(boolean visible) Set visible status of Shapevoid
setWidth
(double width) Set a new Shape width.void
Set the window location of the Shapevoid
setX
(double x) Set x-coordinate of Shapevoid
setY
(double y) Set y-coordinate of Shapevoid
toBack()
Move this shape to the beginning of the draw listvoid
toFront()
Move this shape to the end of the draw listtoString()
Generate a representation of the Shape object.double[]
toWindowCoords
(double x, double y) Convert transformed Shape coordinates to window coordinates returns as a new Point object.toWindowCoords
(Point pt) Convert transformed Shape coordinates in a Point object to window coordinates returned as a new Point object.void
translate
(double deltaX, double deltaY) Add a translate to Shape transform.
-
Field Details
-
layer
The Layer on which this Shape is to be drawn -
x
protected double xThe x-coordinate of the upper left-hand coordinate of the Shape's bounding box. -
y
protected double yThe y-coordinate of the upper left-hand coordinate of the Shape's bounding box. -
width
protected double widthThe width of the Shape's bounding box. -
height
protected double heightThe height of the Shape's bounding box. -
transform
The current affine transform to be used when drawing this Shape -
fillColor
The fill color to be used to draw this Shape. -
strokeColor
The stroke color to be used to draw this Shape. -
strokeWidth
protected double strokeWidthThe width of the stroke used to draw this Shape. -
visible
protected boolean visibleFlag to determine if Shape should be drawn. -
filled
protected boolean filledFlag to determine if Shape should be filled. -
stroked
protected boolean strokedFlag to determine if Shape should be stroked. -
text
The String to be displayed over a Shape -
fontSize
protected int fontSize -
fontStyle
protected int fontStyle -
fontFamily
-
font
The Font to use to render the text -
textFillColor
Color to use to render the text -
eventsEnabled
protected boolean eventsEnabledFlag indicating if this Shape should receive events -
selected
protected boolean selectedFlag to indicate if this Shape is currently selected -
selectable
protected boolean selectableFlag to indicate if this Shape can be selected. -
draggable
protected boolean draggableBoolean indicating if this shape can be dragged. -
shapeListener
Inner class used to handle Shape mouse events.
-
-
Constructor Details
-
Shape
Constructor for Shape object. Optional Pad object parameter.- Parameters:
x
- Shape x-coordinatey
- Shape y-coordinatewidth
- Shape widthheight
- Shape heightlayer
- Layer object to add Shape to, or null if not to add Shape to a Layer
-
-
Method Details
-
getPad
A utility method that returns this Shape's Pad instance- Returns:
- The current Pad singleton object.
-
getFilled
public boolean getFilled()Get flag indicating whether or not Shape should be filled.- Returns:
- Boolean indicating whether or not Shape should be filled.
-
setFilled
public void setFilled(boolean filled) Set flag indicating whether or not Shape should be filled.- Parameters:
filled
- true if Shape to be filled when drawn.
-
getFillColor
Get fill color that currently used to fill the shape when drawn- Returns:
- The current fill color object
-
getFillRed
public int getFillRed()Get the fill color red component- Returns:
- The current fill color red component
-
getFillBlue
public int getFillBlue()Get the fill color blue component- Returns:
- The current fill color blue component
-
getFillGreen
public int getFillGreen()Get the fill color green component- Returns:
- The current fill color green component
-
getFillAlpha
public int getFillAlpha()Get the fill color alpha component- Returns:
- The current fill color alpha component
-
setFillColor
public void setFillColor(double gray) Set the gray scale fill color with which to draw the shape.- Parameters:
gray
- the gray scale value in the range [0, 255]
-
setFillColor
public void setFillColor(double red, double green, double blue) Set the fill color with which to draw the shape- Parameters:
red
- the red component of the color [0, 255]green
- the green component of the color [0, 255]blue
- the blue component of the color [0, 255]
-
setFillColor
public void setFillColor(double red, double green, double blue, double alpha) Set the fill color with which to fill the shape- Parameters:
red
- the red component of the color [0, 255]green
- the green component of the color [0, 255]blue
- the blue component of the color [0, 255]alpha
- the color transparency [0, 255]
-
setFillColor
Set the fill color by passing a Color object- Parameters:
color
- the Color to be used for fill
-
getStroked
public boolean getStroked()Get flag indicating whether or not Shape should be stroked.- Returns:
- boolean indicating whether Shape is stroked
-
setStroked
public void setStroked(boolean stroked) Set flag indicating whether or not Shape should be stroked.- Parameters:
stroked
- true if Shape to be stroked when drawn.
-
getStrokeColor
Get the current Shape stroke color.- Returns:
- Current Shape stroke color.
-
getStrokeRed
public int getStrokeRed()Get the stroke color red component- Returns:
- The current stroke color red component
-
getStrokeBlue
public int getStrokeBlue()Get the stroke color blue component- Returns:
- The current stroke color blue component
-
getStrokeGreen
public int getStrokeGreen()Get the stroke color green component- Returns:
- The current stroke color green component
-
getStrokeAlpha
public int getStrokeAlpha()Get the stroke color alpha component- Returns:
- The current stroke color alpha component
-
setStrokeColor
public void setStrokeColor(double gray) Set the gray scale stroke color with which to draw the shape.- Parameters:
gray
- the gray scale value in the range [0, 255]
-
setStrokeColor
public void setStrokeColor(double red, double green, double blue) Set the current Shape stroke color.- Parameters:
red
- the red component of the stroke color [0, 255]green
- the green component of the stroke color [0, 255]blue
- the blue component of the stroke color [0, 255]
-
setStrokeColor
public void setStrokeColor(double red, double green, double blue, double alpha) Set the fill color with which to stroke the shape- Parameters:
red
- the red component of the color [0, 255]green
- the green component of the color [0, 255]blue
- the blue component of the color [0, 255]alpha
- the color transparency [0, 255]
-
setStrokeColor
Set the stroke color of the Shape- Parameters:
clr
- the Color object to be used as the stroke color
-
getStrokeWidth
public double getStrokeWidth()Get the current stroke width for this Shape.- Returns:
- A float value for the current stroke width.
-
setStrokeWidth
public void setStrokeWidth(double width) Set the stroke width for this Shape.- Parameters:
width
- The stroke width value to set.
-
setText
Set the Rectangle text- Parameters:
text
- The internal text as a String
-
getText
Return the Rectangle object String- Returns:
- The text of the object as a String
-
setTextColor
public void setTextColor(double gray) Set the gray scale text color with which to draw the shape.- Parameters:
gray
- the gray scale value in the range [0, 255]
-
setTextColor
public void setTextColor(double red, double green, double blue) Set the text color- Parameters:
red
- the red component of the color [0, 255]green
- the green component of the color [0, 255]blue
- the blue component of the color [0, 255]
-
setTextColor
public void setTextColor(double red, double green, double blue, double alpha) Set the text color- Parameters:
red
- the red component of the color [0, 255]green
- the green component of the color [0, 255]blue
- the blue component of the color [0, 255]alpha
- the color transparency [0, 255]
-
setTextColor
Set the text color by passing a Color object- Parameters:
color
- the Color to be used for fill
-
setFontFamily
Update the Font family for the text of this Rectangle object.- Parameters:
fontFamily
- The Font family name (ex. "Arial")
-
getFontFamily
Return the Font family name for this Rectangle object.- Returns:
- The Font family name String
-
setFontStyle
public void setFontStyle(int fontStyle) Update the Font style for this Rectangle object.- Parameters:
fontStyle
- The font style code (ex. 0 (Font.PLAIN), 1 (Font.BOLD), 2 (Font.ITALIC))
-
getFontStyle
public int getFontStyle()Return the Font style code for this Rectangle object.- Returns:
- The Font style code
-
setFontSize
public void setFontSize(int fontSize) Update the Font size for this Rectangle object.- Parameters:
fontSize
- The font size (ex. 10)
-
getFontSize
public int getFontSize()Return the font size for this Text object.- Returns:
- the font size.
-
setLocation
public void setLocation(double x, double y) Set the current location of the shape and redraw it.- Parameters:
x
- the x-value of the positiony
- the y-value of the position
-
setLocation
Set the current location of the shape and redraw it.- Parameters:
p
- a Point object containing the coordinates of the new location
-
setPadLocation
Set the Pad location of the Shape- Parameters:
p
- The point indicating Pad coordinates
-
setWindowLocation
Set the window location of the Shape- Parameters:
p
- The point indicating window coordinates
-
getLocation
Return the current location of the shape as a Point object.- Returns:
- A Point object representing the current upper left corner of the Shape's bounding box.
-
getPadLocation
Get the coordinates of the Shape location in the Pad coordinate system- Returns:
- A Point object holding Pad coordinates of the current Shape location
-
getWindowLocation
Get the coordinates of the Shape location in the window coordinate system- Returns:
- A Point object holding window coordinates of the current Shape location
-
setCenter
public void setCenter(double cx, double cy) Set the Shape position so that the center is at the given coordinates.- Parameters:
cx
- the x-value of the positioncy
- the y-value of the position
-
setCenter
Set the Shape position so that the center is at the given Point.- Parameters:
c
- the Point object indicating the center coordinates
-
getCenter
Return the current center point of the shape as a Point object.- Returns:
- A Point object representing the current center point of the Shape's bounding box.
-
getX
public double getX()Get x-coordinate of Shape- Returns:
- The Shape's x-coordinate
-
getY
public double getY()Get y-coordinate of Shape- Returns:
- The Shape's y-coordinate
-
setX
public void setX(double x) Set x-coordinate of Shape- Parameters:
x
- x-coordinate value
-
setY
public void setY(double y) Set y-coordinate of Shape- Parameters:
y
- y-coordinate value
-
move
public void move(double dx, double dy) Move the Shape by the amounts specified in the x and y-directions- Parameters:
dx
- Amount to move in the x-direction (pixels)dy
- Amount to move in the y-direction (pixels)
-
setSize
public void setSize(double width, double height) Reset the size of the Shape and trigger a repaint- Parameters:
width
- new widthheight
- new height
-
setSize
Reset the size of the Shape and trigger a repaint- Parameters:
d
- Dimension containing Shape size
-
getSize
Return the current Shape size as a Dimension object- Returns:
- A Dimension object holding the Shape width and height
-
getWidth
public double getWidth()Get the Shape's width- Returns:
- A double that is the Shape's current width
-
setWidth
public void setWidth(double width) Set a new Shape width.- Parameters:
width
- A double value that is the new Shape width.
-
getHeight
public double getHeight()Get the Shape's height- Returns:
- A double that is the Shape's current height
-
setHeight
public void setHeight(double height) Set a new Shape height.- Parameters:
height
- A double value that is the new Shape height.
-
setEventsEnabled
public void setEventsEnabled(boolean enabled) Set the boolean indicating whether or not the Shape will receive events that can be handled by overriding event methods- Parameters:
enabled
- Boolean indicating if this Shape should receive events.
-
getEventsEnabled
public boolean getEventsEnabled()Return setting that indicates if the Shape object will receive events that are implementable by overriding methods- Returns:
- boolean indicating whether Shape receives events
-
setVisible
public void setVisible(boolean visible) Set visible status of Shape- Parameters:
visible
- Boolean indicating whether or not the Shape should be drawn.
-
getVisible
public boolean getVisible()Get visible status of Shape- Returns:
- true if the Shape is currently marked to be visible.
-
setSelected
public void setSelected(boolean sel) Set the selected state of the Shape- Parameters:
sel
- Boolean indicating if the Shapes should be selected
-
getSelected
public boolean getSelected()Return selected state of this Shape.- Returns:
- Boolean indicating the selected state of the Shape.
-
setSelectable
public void setSelectable(boolean select) Set the flag that indicates if the shape can be selected- Parameters:
select
- a boolean value (true/false) to assign to the flag
-
getSelectable
public boolean getSelectable()Determine if the Shape is set so that it can be selected- Returns:
- true if the Shape can be selected
-
setDraggable
public void setDraggable(boolean drag) Set the flag that indicates if the shape can be dragged. If true, then also set selectable to true. Shapes cannot be dragged unless they can be selected.- Parameters:
drag
- a boolean value (true/false) to assign to the flag
-
getDraggable
public boolean getDraggable()Determine if the Shape is set so that it can be dragged- Returns:
- true if the Shape can be dragged
-
toFront
public void toFront()Move this shape to the end of the draw list -
toBack
public void toBack()Move this shape to the beginning of the draw list -
toString
Generate a representation of the Shape object. -
contains
public boolean contains(double x, double y) Returns true if this shape contains the given point- Parameters:
x
- The x-coordinate of the point to testy
- The y-coordinate of the point to test- Returns:
- true if the Shape contains the given point.
-
contains
Returns true if this shape contains the given point- Parameters:
p
- a Point object containing the coordinates to be tested- Returns:
- true if the Shape contains the given point.
-
getArea
Get a rectangular Area object that surrounds the Shape- Returns:
- Rectangular Area object
-
getLayer
Return the Layer on which this Shape exists- Returns:
- Layer holding this Shape
-
intersects
Determine if the current Shape intersects with the shp Shape parameter- Parameters:
shp
- The Shape with which to test intersection- Returns:
- true if the intersection is not empty
-
repaint
protected void repaint()Utility method to trigger a repaint of the entire Pad. -
setMouseClickedHandler
Assign an onMouseClicked event handler using a method reference.- Parameters:
handler
- Method reference to an event handler
-
setMouseDoubleClickedHandler
Assign an onMouseDoubleClicked event handler using a method reference.- Parameters:
handler
- Method reference to an event handler
-
setMouseDraggedHandler
Assign an onMouseDragged event handler using a method reference.- Parameters:
handler
- Method reference to an event handler
-
setMouseEnteredHandler
Assign an onMouseEntered event handler using a method reference.- Parameters:
handler
- Method reference to an event handler
-
setMouseExitedHandler
Assign an onMouseExited event handler using a method reference.- Parameters:
handler
- Method reference to an event handler
-
setMouseMovedHandler
Assign an onMouseMoved event handler using a method reference.- Parameters:
handler
- Method reference to an event handler
-
setMousePressedHandler
Assign an onMousePressed event handler using a method reference.- Parameters:
handler
- Method reference to an event handler
-
setMouseReleasedHandler
Assign an onMouseReleased event handler using a method reference.- Parameters:
handler
- Method reference to an event handler
-
setSelectionChangedHandler
Assign a selectionChanged event handler using a method reference.- Parameters:
handler
- Method reference to an event handler
-
onMousePressed
public void onMousePressed(double x, double y, int button) Handle mouse pressed Shape events. Override in subclasses to implement.- Parameters:
x
- x-position of the mouse when event occurredy
- y-position of the mouse when event occurredbutton
- Integer indicating button pressed during event.
-
onMouseReleased
public void onMouseReleased(double x, double y, int button) Handle mouse released Shape events. Override in subclasses to implement.- Parameters:
x
- x-position of the mouse when event occurredy
- y-position of the mouse when event occurredbutton
- Integer indicating button pressed during event.
-
onMouseClicked
public void onMouseClicked(double x, double y, int button) Handle mouse clicked Shape events. Override in subclasses to implement.- Parameters:
x
- x-position of the mouse when event occurredy
- y-position of the mouse when event occurredbutton
- Integer indicating button pressed during event.
-
onMouseDoubleClicked
public void onMouseDoubleClicked(double x, double y, int button) Handle mouse double-clicked Shape events. Override in subclasses to implement.- Parameters:
x
- x-position of the mouse when event occurredy
- y-position of the mouse when event occurredbutton
- Integer indicating button pressed during event.
-
onMouseMoved
public void onMouseMoved(double x, double y, int button) Handle mouse moved Shape events. Override in subclasses to implement.- Parameters:
x
- x-position of the mouse when event occurredy
- y-position of the mouse when event occurredbutton
- Integer indicating button pressed during event.
-
onMouseDragged
public void onMouseDragged(double x, double y, int button) Handle mouse dragged Shape events. Override in subclasses to implement.- Parameters:
x
- x-position of the mouse when event occurredy
- y-position of the mouse when event occurredbutton
- Integer indicating button pressed during event.
-
onMouseEntered
public void onMouseEntered(double x, double y, int button) Handle mouse entered Shape events. Override in subclasses to implement.- Parameters:
x
- x-position of the mouse when event occurredy
- y-position of the mouse when event occurredbutton
- Integer indicating button pressed during event.
-
onMouseExited
public void onMouseExited(double x, double y, int button) Handle mouse exited Shape events. Override in subclasses to implement.- Parameters:
x
- x-position of the mouse when event occurredy
- y-position of the mouse when event occurredbutton
- Integer indicating button pressed during event.
-
onSelectionChanged
public void onSelectionChanged(boolean sel) React to change in selection state by overriding- Parameters:
sel
- Boolean indicating new selection state of Shape.
-
rotate
public void rotate(double angle) Add a rotation angle to Shape transform.- Parameters:
angle
- Adds the rotation angle to the current transform (degrees)
-
rotate
public void rotate(double angle, double cx, double cy) Add a rotation angle to Shape transform.- Parameters:
angle
- Adds the rotation angle to the current transform (degrees)cx
- x-coordinate of point about which rotation occurscy
- y-coordinate of point about which rotation occurs
-
translate
public void translate(double deltaX, double deltaY) Add a translate to Shape transform.- Parameters:
deltaX
- Translate shape in the x-direction by deltaXdeltaY
- Translate shape in the y-direction by deltaY
-
scale
public void scale(double factor) Add a scale factor to Shape transform.- Parameters:
factor
- Scale the shape by a scale factor
-
scale
public void scale(double factor, double cx, double cy) Add a scale factor to Shape transform.- Parameters:
factor
- Scale the shape by a scale factorcx
- x-coordinate of point about which scaling occurscy
- y-coordinate of point about which scaling occurs
-
scale
public void scale(double xFactor, double yFactor) Add a scale factor to Shape transform.- Parameters:
xFactor
- Scale the shape in the x-direction by a xFactoryFactor
- Scale the shape in the y-direction by a yFactor
-
scale
public void scale(double xFactor, double yFactor, double cx, double cy) Add a scale factor to Shape transform.- Parameters:
xFactor
- Scale the shape in the x-direction by a xFactoryFactor
- Scale the shape in the y-direction by a yFactorcx
- x-coordinate of point about which scaling occurscy
- y-coordinate of point about which scaling occurs
-
reset
public void reset()Resets the shape to have no transformation. -
getTransform
Clone the Shape\'s current AffineTransform.- Returns:
- The cloned AffineTransform.
-
setTransform
Set a new AffineTransform for the Shape.- Parameters:
transform
- The new transform.
-
toWindowCoords
public double[] toWindowCoords(double x, double y) Convert transformed Shape coordinates to window coordinates returns as a new Point object. This method is useful for converting transformed coordinates received from a Shape mouse event method back to original window coordinates.- Parameters:
x
- Transformed x-coordinatey
- Transformed y-coordinate- Returns:
- A Point object containing the transformed coordinates
-
toWindowCoords
Convert transformed Shape coordinates in a Point object to window coordinates returned as a new Point object. This method is useful for converting transformed coordinates received from a Shape mouse event method back to original window coordinates.- Parameters:
pt
- A Point object- Returns:
- A new Point object containing the transformed coordinates
-
drawText
Draw the text over a Shape- Parameters:
g
- The Graphics2D on which to draw the hit region
-
draw
Draw the shape. Abstract method to be overridden in subclasses.- Parameters:
g
- The Graphics2D object on which to draw.
-