Class PainterConvex2D

java.lang.Object
jaba.panels.PainterConvex2D

public class PainterConvex2D extends Object
This class draws all the part of the graph
Author:
Carlo Gimondi
  • Constructor Details

    • PainterConvex2D

      public PainterConvex2D(Vector<Point2D> allDominants, int height, int width)
      Initialize the object from the vector where all the points are sored
      Parameters:
      allDominants - The vector with all the points
      height - The height of the window
      width - The width of the window
  • Method Details

    • drawSelectLine

      public void drawSelectLine(Graphics2D g, DPoint p1, DPoint p2, Vector<Object> s3d, String[] classNames)
      Draw the selected line of the convex hull and the information about it
      Parameters:
      g - Graphic object
      p1 - The first point of the line
      p2 - The second point of the line
      s3d - Information aboute the classes
      classNames - The name of the classes
    • update

      public boolean update(int height, int width)
      If the height or the width are changed the parameters of the graph are update
      Parameters:
      height - The height of the window
      width - The width of the window
      Returns:
      true if somethig is change
    • axis

      public void axis(Graphics2D g, String[] className)
      It draws the axis of the graph
      Parameters:
      g - The graphic object
      className - The name of the classes
    • summary

      public void summary(Graphics2D g)
      It draws that explains the simbols on the graphic
      Parameters:
      g - The graphic object
    • twoPointRectangle

      public Polygon twoPointRectangle(int xP1, int yP1, int xP2, int yP2)
      Create a Polygon that is a rectangle draw between two point
      Parameters:
      xP1 - The x of the first point
      yP1 - The y of the first point
      xP2 - The x of the second point
      yP2 - The y of the second point
      Returns:
      The rectangle in a polygon object
    • drawPoint

      public void drawPoint(Graphics g, Vector<Point2D> points, Color c, int size)
      It draws the points contained in a vector. The coordinates of the point must be insered in a Point2D object
      Parameters:
      g - The graphic object
      points - The Vector who contains the points
      c - The color of the points
    • drawShadowPoint

      public void drawShadowPoint(Graphics2D g, Point p, Color c, int size)
      It draw a temporary point when a point is moved in another place
      Parameters:
      g - The graphic object
      p - The position of the point
      c - The color of the point
      size - The size of the point
    • getScale

      public double getScale()
      Return the scale factor
      Returns:
      the scale factor
    • drawArea

      public void drawArea(Graphics g, Vector<Point2D> allConvex, Vector<Point2D> allDominants, Color area, Color maskedoff)
      This function draw the area among the axis and the point of the convex hull
      Parameters:
      g - The graphic object
      allConvex - The vector with the points of the convex hull
      allDominants - The vector with the dominant points
      area - The filter area
      maskedoff - The vector with the masked-off points
    • pointLabel

      public void pointLabel(Graphics2D g, Vector<Point2D> points)
      Print a label over every point, if the point is select the label contain the coordinate too
      Parameters:
      g - The graphic object
      points - The vector with all points
    • drawDominantArrow

      public void drawDominantArrow(Graphics2D g, Vector<Point2D> dominant, Vector<Point2D> dominates)
      When is select a Dominat point is draw an arrow from the dominant
      Parameters:
      g - The graphic object
      dominant - The vector with the dominant points
      dominates - The vector with the dominates points
    • drawMousePosition

      public void drawMousePosition(Graphics2D g, Point dragPoint)
      This function traw a line near the coordinate of the mouse
      Parameters:
      g - The graphic object
      dragPoint - The position of the mouse
    • drawFiltArea

      public void drawFiltArea(Graphics2D g, Area filtArea)
      Draw a semi-trasparent area that is the filtered area
      Parameters:
      g - The graphic object
      filtArea - The filtered area
    • drawDragArea

      public void drawDragArea(Graphics2D g, Point dragPoint, Point beginPoint, Color c)
      Draw a semi-trasparet area
      Parameters:
      g - The graphic object
      dragPoint - The first point
      beginPoint - The second point
      c - The color of the area
    • insidePoint

      public Point insidePoint(Point p)
      Set the parameter point as the dragPoint. If the point in out of the graphich area it is resized
      Parameters:
      p - The point
    • getTrueX

      public double getTrueX(double XonScreen)
      Return the true x on the graph from the mouse position
      Parameters:
      XonScreen - The x of the point on screen
      Returns:
      The true x point
    • getTrueY

      public double getTrueY(double YonScreen)
      Return the true y on the graph from the mouse position
      Parameters:
      YonScreen - The y of the point on screen
      Returns:
      The true y point
    • getPointSize

      public int getPointSize()
      Return the size of the points on screen
      Returns:
      The size of the points
    • selectLine

      public boolean selectLine(DPoint p1, DPoint p2, Point point)
      Return true if the point is on a line between the first and the second point
      Parameters:
      p1 - The first point of the line
      p2 - The second point of the line
      point - The point that could be on the line
      Returns:
      True if the point is on a line between the first and the second point
    • theSame

      public boolean theSame(Point mousePoint, DPoint ifPoint, int more)
      If a generic point and a point on the screen are the same point
      Parameters:
      mousePoint - The point on screen
      ifPoint - A generic point
      Returns:
      If the point on screen and a generic point are the same