Class Box

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.awt.Color background
      The background color of the whole box.
      protected java.util.LinkedList<Box> children
      List of child boxes
      static boolean DEBUG  
      protected float depth
      The depth of this box, i.e.
      protected Box elderParent  
      protected java.awt.Color foreground
      The foreground color of the whole box.
      protected float height
      The height of this box, i.e.
      protected java.awt.Color markForDEBUG  
      protected Box parent  
      protected float shift
      The shift amount: the meaning depends on the particular kind of box (up, down, left, right)
      protected int type  
      protected float width
      The width of this box, i.e.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Box()
      Creates an empty box (no children) with all dimensions set to 0 and no foreground and background color set (default values will be used: null)
      protected Box​(java.awt.Color fg, java.awt.Color bg)
      Creates an empty box (no children) with all dimensions set to 0 and sets the foreground and background color of the box.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int pos, Box b)
      Inserts the given box at the given position in the list of child boxes.
      void add​(Box b)
      Inserts the given box at the end of the list of child boxes.
      abstract void draw​(java.awt.Graphics2D g2, float x, float y)
      Paints this box at the given coordinates using the given graphics context.
      protected void drawDebug​(java.awt.Graphics2D g2, float x, float y)  
      protected void drawDebug​(java.awt.Graphics2D g2, float x, float y, boolean showDepth)  
      protected void endDraw​(java.awt.Graphics2D g2)
      Restores the previous color setting.
      float getDepth()
      Get the depth of this box.
      Box getElderParent()  
      float getHeight()
      Get the height of this box.
      abstract int getLastFontId()
      Get the id of the font that will be used the last when this box will be painted.
      Box getParent()  
      float getShift()
      Get the shift amount for this box.
      float getWidth()
      Get the width of this box.
      void negWidth()  
      void setDepth​(float d)
      Set the depth for this box.
      void setElderParent​(Box elderParent)  
      void setHeight​(float h)
      Set the height for this box.
      void setParent​(Box parent)  
      void setShift​(float s)
      Set the shift amount for this box.
      void setWidth​(float w)
      Set the width for this box.
      protected void startDraw​(java.awt.Graphics2D g2, float x, float y)
      Stores the old color setting, draws the background of the box (if not null) and sets the foreground color (if not null).
      • Methods inherited from class java.lang.Object

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

      • DEBUG

        public static boolean DEBUG
      • foreground

        protected java.awt.Color foreground
        The foreground color of the whole box. Child boxes can override this color. If it's null and it has a parent box, the foreground color of the parent will be used. If it has no parent, the foreground color of the component on which it will be painted, will be used.
      • background

        protected java.awt.Color background
        The background color of the whole box. Child boxes can paint a background on top of this background. If it's null, no background will be painted.
      • width

        protected float width
        The width of this box, i.e. the value that will be used for further calculations.
      • height

        protected float height
        The height of this box, i.e. the value that will be used for further calculations.
      • depth

        protected float depth
        The depth of this box, i.e. the value that will be used for further calculations.
      • shift

        protected float shift
        The shift amount: the meaning depends on the particular kind of box (up, down, left, right)
      • type

        protected int type
      • children

        protected java.util.LinkedList<Box> children
        List of child boxes
      • parent

        protected Box parent
      • elderParent

        protected Box elderParent
      • markForDEBUG

        protected java.awt.Color markForDEBUG
    • Constructor Detail

      • Box

        protected Box()
        Creates an empty box (no children) with all dimensions set to 0 and no foreground and background color set (default values will be used: null)
      • Box

        protected Box​(java.awt.Color fg,
                      java.awt.Color bg)
        Creates an empty box (no children) with all dimensions set to 0 and sets the foreground and background color of the box.
        Parameters:
        fg - the foreground color
        bg - the background color
    • Method Detail

      • add

        public void add​(Box b)
        Inserts the given box at the end of the list of child boxes.
        Parameters:
        b - the box to be inserted
      • add

        public void add​(int pos,
                        Box b)
        Inserts the given box at the given position in the list of child boxes.
        Parameters:
        pos - the position at which to insert the given box
        b - the box to be inserted
      • setParent

        public void setParent​(Box parent)
      • getParent

        public Box getParent()
      • setElderParent

        public void setElderParent​(Box elderParent)
      • getElderParent

        public Box getElderParent()
      • getWidth

        public float getWidth()
        Get the width of this box.
        Returns:
        the width of this box
      • negWidth

        public void negWidth()
      • getHeight

        public float getHeight()
        Get the height of this box.
        Returns:
        the height of this box
      • getDepth

        public float getDepth()
        Get the depth of this box.
        Returns:
        the depth of this box
      • getShift

        public float getShift()
        Get the shift amount for this box.
        Returns:
        the shift amount
      • setWidth

        public void setWidth​(float w)
        Set the width for this box.
        Parameters:
        w - the width
      • setDepth

        public void setDepth​(float d)
        Set the depth for this box.
        Parameters:
        d - the depth
      • setHeight

        public void setHeight​(float h)
        Set the height for this box.
        Parameters:
        h - the height
      • setShift

        public void setShift​(float s)
        Set the shift amount for this box.
        Parameters:
        s - the shift amount
      • draw

        public abstract void draw​(java.awt.Graphics2D g2,
                                  float x,
                                  float y)
        Paints this box at the given coordinates using the given graphics context.
        Parameters:
        g2 - the graphics (2D) context to use for painting
        x - the x-coordinate
        y - the y-coordinate
      • getLastFontId

        public abstract int getLastFontId()
        Get the id of the font that will be used the last when this box will be painted.
        Returns:
        the id of the last font that will be used.
      • startDraw

        protected void startDraw​(java.awt.Graphics2D g2,
                                 float x,
                                 float y)
        Stores the old color setting, draws the background of the box (if not null) and sets the foreground color (if not null).
        Parameters:
        g2 - the graphics (2D) context
        x - the x-coordinate
        y - the y-coordinate
      • drawDebug

        protected void drawDebug​(java.awt.Graphics2D g2,
                                 float x,
                                 float y,
                                 boolean showDepth)
      • drawDebug

        protected void drawDebug​(java.awt.Graphics2D g2,
                                 float x,
                                 float y)
      • endDraw

        protected void endDraw​(java.awt.Graphics2D g2)
        Restores the previous color setting.
        Parameters:
        g2 - the graphics (2D) context