Package adapter

Class HexagonAdapter

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<Shape>, Movable

    public class HexagonAdapter
    extends SurfaceShape
    Class that is adapter for hexagon.jar library (Hexagon class).
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private hexagon.Hexagon hexagon  
      private static long serialVersionUID  
    • Constructor Summary

      Constructors 
      Constructor Description
      HexagonAdapter​(hexagon.Hexagon hexagon)  
    • Field Detail

      • hexagon

        private hexagon.Hexagon hexagon
    • Constructor Detail

      • HexagonAdapter

        public HexagonAdapter​(hexagon.Hexagon hexagon)
    • Method Detail

      • draw

        public void draw​(java.awt.Graphics graphics)
        Draw hexagon and check if it is selected, to mark and draw selected state too.
        Specified by:
        draw in class Shape
        Parameters:
        Graphics - {@docRoot#Graphics}
      • equals

        public boolean equals​(java.lang.Object obj)
        Determine if two hexagons are equal depend on their x and y coordinates and radius length.
        Overrides:
        equals in class java.lang.Object
      • compareTo

        public int compareTo​(Shape hex)
        Compares two hexagons depend on their radius.
      • toString

        public java.lang.String toString()
        Print hexagon values.
        Overrides:
        toString in class java.lang.Object
      • moveTo

        public void moveTo​(int x,
                           int y)
        Move hexagon to given place.
        Parameters:
        x - X coordinate of place to move.
        y - Y coordinate of place to move.
      • selected

        public void selected​(java.awt.Graphics graphics)
        Implemented in draw(Graphics).
        Specified by:
        selected in class Shape
        Parameters:
        Graphics - {@docRoot#Graphics}
      • containsClick

        public boolean containsClick​(int xCoordinate,
                                     int yCoordinate)
        Check if hexagon is clicked.
        Specified by:
        containsClick in class Shape
        Parameters:
        X - coordinate of click.
        Y - coordinate of click.
        Returns:
        boolean Indicate if hexagon contains click.
      • clone

        public HexagonAdapter clone()
        Make new instance of this class.
        Overrides:
        clone in class java.lang.Object
        Returns:
        HexagonAdapter New instance of this class.
      • fillUpShape

        public void fillUpShape​(java.awt.Graphics shapeForFillUp)
        Implemented in draw(Graphics).
        Specified by:
        fillUpShape in class SurfaceShape
        Parameters:
        Graphics - {@docRoot#Graphics}
      • isSelected

        public boolean isSelected()
        Overrides:
        isSelected in class Shape
      • setSelected

        public void setSelected​(boolean selected)
        Overrides:
        setSelected in class Shape
      • getColor

        public java.awt.Color getColor()
        Overrides:
        getColor in class Shape
      • setColor

        public void setColor​(java.awt.Color color)
        Overrides:
        setColor in class Shape
      • getR

        public int getR()
      • setR

        public void setR​(int r)
      • getXcoordinate

        public int getXcoordinate()
      • getYcoordinate

        public int getYcoordinate()