Class HTMLGraphics2D


  • public class HTMLGraphics2D
    extends Graphics2D
    HTMLGraphics.java.

    Copyright (c) 2003-2020 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information www.simulation.tudelft.nl. The source code and binary code of this software is proprietary information of Delft University of Technology.
    Author:
    Alexander Verbraeck
    • Constructor Detail

      • HTMLGraphics2D

        public HTMLGraphics2D()
    • Method Detail

      • clearCommand

        public void clearCommand()
        Clear the commands and put the start tag in.
      • closeAndGetCommands

        public String closeAndGetCommands()
        Close the commands and put the end tag in.
        Returns:
        the current set of commands
      • addDraw

        protected void addDraw​(String drawCommand,
                               Object... params)
        Add a draw command.
        Parameters:
        drawCommand - String; the tag for the draw command
        params - Object...; the params for the draw command
      • addAffineTransform

        protected void addAffineTransform()
        add AffineTransform to the command.
      • addColor

        protected void addColor​(Color c)
        add Color to the command.
        Parameters:
        c - Color; the color
      • addFontData

        protected void addFontData()
        add font data to the command, font-name, font-size, bold/italic/plain.
      • addTransformFill

        protected void addTransformFill​(String fillCommand,
                                        Object... params)
        Add fill command, transform.m11(h-scale), transform.m12(h-skew), transform.m21(v-skew), transform.m22(v-scale), transform.dx(h-translate), transform.dy(v-translate), color.r, color.g, color.b, color.alpha, color.transparency, params...
        Parameters:
        fillCommand - String; the tag to use
        params - Object...; the params to send
      • addTransformDraw

        protected void addTransformDraw​(String drawCommand,
                                        Object... params)
        Add command, transform.m11(h-scale), transform.m12(h-skew), transform.m21(v-skew), transform.m22(v-scale), transform.dx(h-translate), transform.dy(v-translate), linecolor.r, linecolor.g, linecolor.b, linecolor.alpha, linecolor.transparency, line-width, params...
        Parameters:
        drawCommand - String; the tag to use
        params - Object...; the params
      • addTransformPathFloat

        protected void addTransformPathFloat​(Path2D.Float path,
                                             boolean fill)
        Add a path2D to the command. In case of fill:
        FILL, transform.m11(h-scale), transform.m12(h-skew), transform.m21(v-skew), transform.m22(v-scale), transform.dx(h-translate), transform.dy(v-translate), fillcolor.r, fillcolor.g, fillcolor.b, fillcolor.alpha, fillcolor.transparency, winding_rule[WIND_EVEN_ODD/WIND_NON_ZERO], COMMAND, coords, COMMAND, coords, ...
        In case of draw:
        DRAW, transform.m11(h-scale), transform.m12(h-skew), transform.m21(v-skew), transform.m22(v-scale), transform.dx(h-translate), transform.dy(v-translate), strokecolor.r, strokecolor.g, strokecolor.b, strokecolor.alpha, strokecolor.transparency, line_width, COMMAND, coords, COMMAND, coords, ...
        where command can be one of the following:
        - CLOSE, followed by no coordinates
        - CUBICTO, followed by 3 coordinates (6 numbers)
        - LINETO, followed by 1 coordinate (2 numbers)
        - MOVETO, followed by 1 coordinate (2 numbers)
        - QUADTO, followed by 2 coordinates (4 numbers)
        Parameters:
        path - Path2D.Float; the path to draw
        fill - boolean;
      • addTransformPathDouble

        protected void addTransformPathDouble​(Path2D.Double path,
                                              boolean fill)
        Add a path2D to the command. In case of fill:
        FILL, transform.m11(h-scale), transform.m12(h-skew), transform.m21(v-skew), transform.m22(v-scale), transform.dx(h-translate), transform.dy(v-translate), fillcolor.r, fillcolor.g, fillcolor.b, fillcolor.alpha, fillcolor.transparency, winding_rule[WIND_EVEN_ODD/WIND_NON_ZERO], COMMAND, coords, COMMAND, coords, ...
        In case of draw:
        DRAW, transform.m11(h-scale), transform.m12(h-skew), transform.m21(v-skew), transform.m22(v-scale), transform.dx(h-translate), transform.dy(v-translate), strokecolor.r, strokecolor.g, strokecolor.b, strokecolor.alpha, strokecolor.transparency, line_width, COMMAND, coords, COMMAND, coords, ...
        where command can be one of the following:
        - CLOSE, followed by no coordinates
        - CUBICTO, followed by 3 coordinates (6 numbers)
        - LINETO, followed by 1 coordinate (2 numbers)
        - MOVETO, followed by 1 coordinate (2 numbers)
        - QUADTO, followed by 2 coordinates (4 numbers)
        Parameters:
        path - Path2D.Double; the path to draw
        fill - boolean;
      • addTransformText

        protected void addTransformText​(String drawCommand,
                                        Object... params)
        Add string, 0=command, 1=transform.m11(h-scale), 2=transform.m12(h-skew), 3=transform.m21(v-skew), 4=transform.m22(v-scale), 5=transform.dx(h-translate), 6=transform.dy(v-translate), 7=color.r, 8=color.g, 9=color.b, 10=color.alpha, 11=color.transparency, 12=fontname, 13=fontsize, 14=fontstyle(normal/italic/bold), 15=x, 16=y, 17=text.
        Parameters:
        drawCommand - String; the tag to use
        params - Object...; the params
      • drawFillShape

        protected void drawFillShape​(Shape shape,
                                     boolean fill)
        Draw or fill a shape.
        Parameters:
        shape - Shape; the shape
        fill - boolean; filled or not
      • translate

        public void translate​(int x,
                              int y)
        Specified by:
        translate in class Graphics2D
      • translate

        public void translate​(double tx,
                              double ty)
        Specified by:
        translate in class Graphics2D
      • rotate

        public void rotate​(double theta)
        Specified by:
        rotate in class Graphics2D
      • rotate

        public void rotate​(double theta,
                           double x,
                           double y)
        Specified by:
        rotate in class Graphics2D
      • scale

        public void scale​(double sx,
                          double sy)
        Specified by:
        scale in class Graphics2D
      • shear

        public void shear​(double shx,
                          double shy)
        Specified by:
        shear in class Graphics2D
      • clipRect

        public void clipRect​(int x,
                             int y,
                             int width,
                             int height)
        Specified by:
        clipRect in class Graphics
      • setClip

        public void setClip​(int x,
                            int y,
                            int width,
                            int height)
        Specified by:
        setClip in class Graphics
      • copyArea

        public void copyArea​(int x,
                             int y,
                             int width,
                             int height,
                             int dx,
                             int dy)
        Specified by:
        copyArea in class Graphics
      • drawLine

        public void drawLine​(int x1,
                             int y1,
                             int x2,
                             int y2)
        Specified by:
        drawLine in class Graphics
      • fillRect

        public void fillRect​(int x,
                             int y,
                             int width,
                             int height)
        Specified by:
        fillRect in class Graphics
      • clearRect

        public void clearRect​(int x,
                              int y,
                              int width,
                              int height)
        Specified by:
        clearRect in class Graphics
      • drawRoundRect

        public void drawRoundRect​(int x,
                                  int y,
                                  int width,
                                  int height,
                                  int arcWidth,
                                  int arcHeight)
        Specified by:
        drawRoundRect in class Graphics
      • fillRoundRect

        public void fillRoundRect​(int x,
                                  int y,
                                  int width,
                                  int height,
                                  int arcWidth,
                                  int arcHeight)
        Specified by:
        fillRoundRect in class Graphics
      • drawOval

        public void drawOval​(int x,
                             int y,
                             int width,
                             int height)
        Specified by:
        drawOval in class Graphics
      • fillOval

        public void fillOval​(int x,
                             int y,
                             int width,
                             int height)
        Specified by:
        fillOval in class Graphics
      • drawArc

        public void drawArc​(int x,
                            int y,
                            int width,
                            int height,
                            int startAngle,
                            int arcAngle)
        Specified by:
        drawArc in class Graphics
      • fillArc

        public void fillArc​(int x,
                            int y,
                            int width,
                            int height,
                            int startAngle,
                            int arcAngle)
        Specified by:
        fillArc in class Graphics
      • drawPolyline

        public void drawPolyline​(int[] xPoints,
                                 int[] yPoints,
                                 int nPoints)
        Specified by:
        drawPolyline in class Graphics
      • drawPolygon

        public void drawPolygon​(int[] xPoints,
                                int[] yPoints,
                                int nPoints)
        Specified by:
        drawPolygon in class Graphics
      • fillPolygon

        public void fillPolygon​(int[] xPoints,
                                int[] yPoints,
                                int nPoints)
        Specified by:
        fillPolygon in class Graphics
      • drawImage

        public boolean drawImage​(Image img,
                                 int dx1,
                                 int dy1,
                                 int dx2,
                                 int dy2,
                                 int sx1,
                                 int sy1,
                                 int sx2,
                                 int sy2,
                                 ImageObserver observer)
        Specified by:
        drawImage in class Graphics
      • drawImage

        public boolean drawImage​(Image img,
                                 int dx1,
                                 int dy1,
                                 int dx2,
                                 int dy2,
                                 int sx1,
                                 int sy1,
                                 int sx2,
                                 int sy2,
                                 Color bgcolor,
                                 ImageObserver observer)
        Specified by:
        drawImage in class Graphics
      • dispose

        public void dispose()
        Specified by:
        dispose in class Graphics