Package Shapes

Class MyRoundedRectangle

java.lang.Object
Shapes.MyShape
Shapes.MyBoundedShape
Shapes.MyRoundedRectangle

public class MyRoundedRectangle
extends MyBoundedShape
a rounded rectangle that draws rectangle width rounded corners
Author:
Itay Finci
  • Field Summary

    Fields 
    Modifier and Type Field Description
    (package private) int roundnessPercentage  

    Fields inherited from class Shapes.MyShape

    color, origin, stroke, target, thickness
  • Constructor Summary

    Constructors 
    Constructor Description
    MyRoundedRectangle​(java.awt.Point origin, java.awt.Point target, java.awt.Color color, boolean filled, int roundnessPercentage, int thickness)
    makes a new rounded rectangle
  • Method Summary

    Modifier and Type Method Description
    void draw​(java.awt.Graphics g)
    shapes will implement this method to be drawn
    private int lengthPercentage​(int length)
    finds the arc length based on the length and the roundness percentage

    Methods inherited from class Shapes.MyBoundedShape

    calculateHeight, calculateWidth, findStart, isFilled

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • MyRoundedRectangle

      public MyRoundedRectangle​(java.awt.Point origin, java.awt.Point target, java.awt.Color color, boolean filled, int roundnessPercentage, int thickness)
      makes a new rounded rectangle
      Parameters:
      origin - the point which the rectangle starts in
      target - the point which the rectangle ends in
      color - the color of the rectangle
      filled - if the rectangle is filled or not
      roundnessPercentage - the percentage of the width and height that turns into the arc- between 0 to 100
      thickness - the line thickness
  • Method Details

    • draw

      public void draw​(java.awt.Graphics g)
      Description copied from class: MyShape
      shapes will implement this method to be drawn
      Specified by:
      draw in class MyShape
      Parameters:
      g - the graphics manager
    • lengthPercentage

      private int lengthPercentage​(int length)
      finds the arc length based on the length and the roundness percentage
      Parameters:
      length - the width/ height that need to be calculated
      Returns:
      the width/ height of the arc