Class Graphics2DDisplay

  • All Implemented Interfaces:
    OutputDisplay
    Direct Known Subclasses:
    ImageOutputDisplay

    public class Graphics2DDisplay
    extends Object
    implements OutputDisplay
    An output display implementation that shows the areas on a Graphics2D device.
    Author:
    burgetr
    • Constructor Detail

      • Graphics2DDisplay

        public Graphics2DDisplay​(Graphics2D g)
    • Method Detail

      • setGraphics

        public void setGraphics​(Graphics2D g)
      • drawPage

        public void drawPage​(Page page)
        Description copied from interface: OutputDisplay
        Draws the complete page including all the boxes.
        Specified by:
        drawPage in interface OutputDisplay
        Parameters:
        page - The page to draw.
      • drawPage

        public void drawPage​(Page page,
                             boolean bitmap)
        Description copied from interface: OutputDisplay
        Draws the complete page by drawing all the boxes or a bitmap screenshot.
        Specified by:
        drawPage in interface OutputDisplay
        Parameters:
        page - The page to draw.
        bitmap - Use bitmap page screen shot if available.
      • drawBox

        public void drawBox​(Box box)
        Description copied from interface: OutputDisplay
        Draws the box contents on the page depending on the box type. This does not automatically draw the child boxes.
        Specified by:
        drawBox in interface OutputDisplay
        Parameters:
        box - The box do draw.
      • drawExtent

        public void drawExtent​(Box box)
        Description copied from interface: OutputDisplay
        Draws the box bounds at the output display.
        Specified by:
        drawExtent in interface OutputDisplay
        Parameters:
        box - The box to be displayed
      • drawExtent

        public void drawExtent​(Area area)
        Description copied from interface: OutputDisplay
        Draws the area bounds at the output display.
        Specified by:
        drawExtent in interface OutputDisplay
        Parameters:
        area - The area to be displayed
      • drawRectangle

        public void drawRectangle​(Rectangular rect,
                                  Color color)
        Description copied from interface: OutputDisplay
        Draws the given rectangle with the specified color.
        Specified by:
        drawRectangle in interface OutputDisplay
        Parameters:
        rect - the rectangle to be drawn
        color - the drawing color
      • drawConnection

        public void drawConnection​(ContentRect a1,
                                   ContentRect a2,
                                   Color color)
        Description copied from interface: OutputDisplay
        Draws a connection between two content rectangles.
        Specified by:
        drawConnection in interface OutputDisplay
        Parameters:
        a1 - The first content rectangle
        a2 - The second content rectangle
        color - Connection color
      • colorizeByTags

        public void colorizeByTags​(ContentRect rect,
                                   Set<Tag> s)
        Description copied from interface: OutputDisplay
        Draws the colorized are bounds. The color is defined by the tags. Multiple colors should be used when there are multiple tags (e.g. splitting the area bounds to several parts). The output display should assign different colors to different tags; the exact implementation of the color mapping depends on the OutputDisplay implementation. The area is not displayed when the tag set is empty.
        Specified by:
        colorizeByTags in interface OutputDisplay
        Parameters:
        rect - The area to be displayed
        s - A set of tags used for generating the area colors
      • clearArea

        public void clearArea​(int x,
                              int y,
                              int width,
                              int height)
        Description copied from interface: OutputDisplay
        Clears the given area of the display.
        Specified by:
        clearArea in interface OutputDisplay
        Parameters:
        x - the area X coordinate
        y - the area Y coordinate
        width - the area width
        height - the area height
      • colorizeByClass

        public void colorizeByClass​(ContentRect rect,
                                    String cname)
        Description copied from interface: OutputDisplay
        Draws the colorized are bounds. The color is defined by a string. The output display should assign different colors to different strings; the exact implementation of the color mapping depends on the OutputDisplay implementation. The area is not displayed when class name is empty.
        Specified by:
        colorizeByClass in interface OutputDisplay
        Parameters:
        rect - The area to be displayed
        cname - The class name used for generating the colors.
      • setupGraphics

        protected void setupGraphics()
        Configures the graphics context for drawing the boxes. This method is normally called from drawPage(Page) before the actual drawing starts.
      • stringColor

        protected Color stringColor​(String cname)