Package prezoom.model.GObject
Class GObject
- java.lang.Object
-
- prezoom.model.GObject.GObject
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
GImage,GLine,GOval,GRectangle,GText
public abstract class GObject extends Object implements Serializable
The base class for all graphical objects- Author:
- Zhijie Lan
create date: 2020/11/1
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ShapedrawShapethe actual shape object that shows on the canvasprivate GAttributeManagergAttributeManagerthe manager to manage the state of this object
-
Constructor Summary
Constructors Modifier Constructor Description protectedGObject(Double x, Double y, Color col, Boolean filled, Integer lineWidth, Double width, Double height, Double x2, Double y2, Boolean visible, String fontName, Integer fontStyle, Double fontSize, String textString)the constructor will call theGAttributeManagerto manage all the attributes
-
Method Summary
Modifier and Type Method Description abstract voiddraw(Graphics2D g)generate the shape to drawprotected voiddrawing(Graphics2D g)General function to draw all kinds of shapes useGAttributes.getColor()as color.GAttributeManagergetAttributeManager()Get the attribute manager of this objectGAttributesIgetCurrentAttributes()Get the attributes for the current statePoint2D[]getResizePoints()get the position of the diagonal points to draw the resize pointsbooleaninShape(double mx, double my)Whether the given position is in this object
-
-
-
Field Detail
-
gAttributeManager
private final GAttributeManager gAttributeManager
the manager to manage the state of this object
-
drawShape
protected Shape drawShape
the actual shape object that shows on the canvas
-
-
Constructor Detail
-
GObject
protected GObject(Double x, Double y, Color col, Boolean filled, Integer lineWidth, Double width, Double height, Double x2, Double y2, Boolean visible, String fontName, Integer fontStyle, Double fontSize, String textString)
the constructor will call theGAttributeManagerto manage all the attributes- Parameters:
x- location, xy- location, ycol- paint colorfilled- whether filledlineWidth- width of lineswidth- width of the object, if applicableheight- height of the object, if applicablex2- x2 of the object, if applicabley2- y2 of the object, if applicablevisible- whether visiblefontName- font namefontSize- font sizefontStyle- plain, bold, or italictextString- the text content
-
-
Method Detail
-
draw
public abstract void draw(Graphics2D g)
generate the shape to draw- Parameters:
g- the Graphics to paint
-
drawing
protected void drawing(Graphics2D g)
General function to draw all kinds of shapes useGAttributes.getColor()as color. useGAttributes.getFilled()to depend whether callingGraphics2D.fill(Shape)orGraphics2D.draw(Shape). useGAttributes.getWidth()to set the line style- Parameters:
g- the Graphics to paint
-
inShape
public boolean inShape(double mx, double my)Whether the given position is in this object- Parameters:
mx- xmy- y- Returns:
- True if in the object
-
getAttributeManager
public GAttributeManager getAttributeManager()
Get the attribute manager of this object- Returns:
- the attribute manager
-
getCurrentAttributes
public GAttributesI getCurrentAttributes()
Get the attributes for the current state- Returns:
- current attributes
-
getResizePoints
public Point2D[] getResizePoints()
get the position of the diagonal points to draw the resize points- Returns:
- diagonal points
-
-