SimpleGraphics Class Documentation

Embed Size (px)

Citation preview

  • 7/25/2019 SimpleGraphics Class Documentation

    1/4

    Editor class

    Editor()

    Creates an Editor object with default title, background, width and height.

    void setHeight(int height)

    Sets the height of the editor window.

    void setWidth(int width)

    Set the width of the editor window.

    void setBackgroundImage(String imageFile)

    Sets the background of the editor window to the image contained in imageFile.

    void add(element)

    Adds the given element to be displayed in the editor window.

    Text class

    Text(String text, int x, int y)

    Creates a Text object representing text to be displayed at position (x, y).

    Text(Text textObject)

    Creates a Text object which is a copy of textObject.

    void setFont(String font_name, int font_style, int font_size)

    Sets the font to be used to display the text.

    Description: Possible values for font_style:

    1 = Bold

    2 = Italic

    3 = Bold and Italic

    Any other value = Plain

    void setColor(int red, int green, int blue)

    Sets the color to be used to display the text. The range of each value for RGB is 0 to 255.

    void translate(int d_x, int d_y)

    Relocates the Text object by d_x units along the X-axis and d_y units along the Y-axis.

    (positive value for x/y to the right/downward, negative value for x/y- to the left / upward)

  • 7/25/2019 SimpleGraphics Class Documentation

    2/4

    Line class

    Line(int x1,int y1, int x2, int y2)

    Creates a Line object representing a line with endpoints (x1,y1) and (x2,y2).

    Line(Line lineObject)Creates a Line object which is a copy of lineObject.

    void setColor(int red, int green, int blue)

    Sets the color to be used to display the line. The range of each value for RGB is 0 to 255.

    void translate(int d_x, int d_y)

    Relocates the Line object by d_x units along the X-axis and d_y units along the Y-axis.

    (positive value for x/y to the right/downward, negative value for x/y- to the left / upward)

    Rectangle class

    Rectangle(int x, int y , int width , int height)

    Creates a Rectangle object representing a rectangle shape given the upper-left corner (x,y), width

    and height

    Rectangle(Rectangle rectObject)

    Creates a Rectangle object which is a copy of rectObject

    Void setHollow(bool status)

    Sets the hollow status of the shape. If the hollow status is true, the shape displayed is unfilled

    i.e. only its border is displayed. Otherwise, the shape displayed is filled.

    By default, the hollow status of a newly created Rectangle object is true.

    void setColor(int red, int green, int blue)

    Sets the color to be used to display the rectangle. The range of each value for RGB is 0 to 255.

    void translate(int d_x, int d_y)

    Relocates the Rectangle object by d_x units along the X-axis and d_y units along the Y-axis.

    (positive value for x/y to the right/downward, negative value for x/y- to the left / upward)

  • 7/25/2019 SimpleGraphics Class Documentation

    3/4

    Oval class

    Oval(int x, int y, int width, int height)

    Creates an Oval object representing an oval shape given the upper-left corner (x,y), width

    and height of its bounding rectangle.Oval(Oval ovalObject)

    Creates a Oval object which is a copy of ovalObject.

    Void setHollow(bool status)

    Sets the hollow status of the shape. If the hollow status is true, the shape displayed is unfilled

    i.e. only its border is displayed. Otherwise, the shape displayed is filled.

    By default, the hollow status of a newly created Rectangle object is true.

    void setColor(int red, int green, int blue)Sets the color to be used to display the oval. The range of each value for RGB is 0 to 255.

    void translate(int d_x, int d_y)

    Relocates the Oval object by d_x units along the X-axis and d_y units along the Y-axis.

    (positive value for x/y to the right/downward, negative value for x/y- to the left / upward)

    Polygon class

    Polygon(int numPoints)Creates a Polygon object representing a closed polygonal shape consisting of n vertices.

    An example of a polygon containing 5 vertices

    Polygon(Polygon polygonObject)

    Creates a Polygon object which is a copy of polygonObject.

    void setVertex(int idx, int x, int y)

    Sets the X and Y coordinates of the idx-th vertex of the polygon to x and y respectively

    The index of the vertex whose value must be between 0 and numVerts-1 where numVerts isthe number of vertices of the polygon.

    void setHollow(bool status)

    Sets the hollow status of the shape. If the hollow status is true, the shape displayed is unfilled

    i.e. only its border is displayed. Otherwise, the shape displayed is filled.

    By default, the hollow status of a newly created Rectangle object is true.

  • 7/25/2019 SimpleGraphics Class Documentation

    4/4

    void setColor(int red, int green, int blue)

    Sets the color to be used to display the polygon. The range of each value for RGB is 0 to 255.

    void translate(int d_x, int d_y)

    Relocates the Polygon object by d_x units along the X-axis and d_y units along the Y-axis.

    (positive value for x/y to the right/downward, negative value for x/y- to the left / upward)

    Group class

    Group()

    Creates an Group object representing an empty group of elements.Group(Group groupObject)

    Creates a Group object which is a copy of groupObject.

    void add(element)

    Adds the given element to the group

    void translate(int d_x, int d_y)

    Relocates the Group object by d_x units along the X-axis and d_y units along the Y-axis.

    (positive value for x/y to the right/downward, negative value for x/y- to the left / upward)