Klasse BarChart


public class BarChart extends VisualizationElement
Represents a bar chart to visualize sort algorithms.
  • Felddetails

    • START_X_POS

      private static final int START_X_POS
      Siehe auch:
    • values

      private Vector<BarChartElement> values
    • width

      private int width
    • height

      private int height
    • startYPos

      private int startYPos
  • Konstruktordetails

    • BarChart

      public BarChart(Vector<BarChartElement> values, int width, int heigth)
      Creates a new BarChart.
      Parameter:
      values - Vector with values to show as bars in the BarChart.
      width - Width of the BarChart.
      heigth - Height of the BarChart.
    • BarChart

      public BarChart(BarChartElement[] values, int width, int heigth)
      Creates a new BarChart.
      Parameter:
      values - Array with values to show as bars in the BarChart.
      width - Width of the BarChart.
      heigth - Height of the BarChart.
  • Methodendetails

    • draw

      public void draw(Graphics g)
      Beschreibung aus Klasse kopiert: VisualizationElement
      Draws the visualization element.
      Angegeben von:
      draw in Klasse VisualizationElement
      Parameter:
      g - The Graphics object to draw the element to the DrawArea.
    • calculateBarHeight

      private int calculateBarHeight(BarChartElement barChartElement)
      Calculates the height of the bar dependent of the height and value. Ensures that no bar is drawn downwards if the window is resized.
      Parameter:
      barChartElement - The BarChartElement the height is calculated for.
      Gibt zurück:
      Returns how high the bar should be drawn.
    • setValues

      public void setValues(Vector<BarChartElement> values)
      Parameter:
      values - the values to set
    • getValues

      public Vector<BarChartElement> getValues()
      Gibt zurück:
      the values
    • setWidth

      public void setWidth(int width)
      Parameter:
      width - the width to set
    • getWidth

      public int getWidth()
      Gibt zurück:
      the width
    • setHeight

      public void setHeight(int height)
      Parameter:
      height - the height to set
    • getHeight

      public int getHeight()
      Gibt zurück:
      the height