Class Convex2DGraph

All Implemented Interfaces:
MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class Convex2DGraph extends JabaGraph implements MouseListener, MouseMotionListener
This class draws all the part of the graph
Author:
Carlo Gimondi, modified by Sebastiano Spicuglia
See Also:
  • Constructor Details

    • Convex2DGraph

      public Convex2DGraph(JabaModel data, JabaController mainWin)
      Initialize the object from the vector where all the points are sored
      Parameters:
      data - the Jaba model to show
      mainWin - the Jaba controller
  • Method Details

    • paint

      public void paint(Graphics g)
      Overrides:
      paint in class JabaGraph
    • drawSelectLine

      public void drawSelectLine(Graphics2D g, DPoint p1, DPoint p2)
      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
    • 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
    • drawArea

      public void drawArea(Graphics2D g, Vector<Point2D> allConvex, Color color)
      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
      color - The color of the area
    • fillArea

      public void fillArea(Graphics2D g, Vector<Point2D> allConvex, Color color)
    • drawMaskedOffRectangle

      public void drawMaskedOffRectangle(Graphics2D g, Point2D point, Color color)
    • 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
    • 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
    • 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
    • mouseMoved

      public void mouseMoved(MouseEvent e)
      Specified by:
      mouseMoved in interface MouseMotionListener
    • mousePressed

      public void mousePressed(MouseEvent e)
      Specified by:
      mousePressed in interface MouseListener
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      Specified by:
      mouseReleased in interface MouseListener
    • mouseDragged

      public void mouseDragged(MouseEvent e)
      Specified by:
      mouseDragged in interface MouseMotionListener
    • mouseEntered

      public void mouseEntered(MouseEvent e)
      Specified by:
      mouseEntered in interface MouseListener
    • mouseExited

      public void mouseExited(MouseEvent e)
      Specified by:
      mouseExited in interface MouseListener
    • mouseClicked

      public void mouseClicked(MouseEvent ev)
      Specified by:
      mouseClicked in interface MouseListener
    • showAllLabels

      public void showAllLabels(boolean b)