com.aspose.page

Class Device

  • Direct Known Subclasses:
    DeviceXps, ImageDevice, PdfDevice


    public abstract class Device
    extends Object

    This class encapsulates rendering of document to abstract device. Rendering of the document is performed page by page.

    • Field Detail

      • VERSION

        public static String VERSION

        Current device version.

    • Constructor Detail

      • Device

        public Device(Dimension pageSize)

        Creates the new instance of Device with a size of a page.

        Parameters:
        pageSize - Page size.
    • Method Detail

      • renew

        public void renew()

        Reset device to initial state for whole document. Used for reseting output stream.

      • setSaveOptions

        public void setSaveOptions(SaveOptions options)

        Specifies options for managing rendering process.

        Parameters:
        options - Options for managing rendering process.
      • getProperties

        public UserProperties getProperties()

        Gets device properties including metadata.

        Returns:
        Device properties.
      • setProperties

        public void setProperties(UserProperties props)

        Specifies device properties including metadata.

        Parameters:
        props - Device properties.
      • getProperty

        public String getProperty(String key)

        Gets a value of string property.

        Parameters:
        key - The name of property.
        Returns:
        The property value.
      • getPropertyColor

        public Color getPropertyColor(String key)

        Gets a value of color property.

        Parameters:
        key - The name of property.
        Returns:
        The property value.
      • getPropertyRectangle

        public Rectangle getPropertyRectangle(String key)

        Gets a value of rectangle property.

        Parameters:
        key - The name of property.
        Returns:
        The property value.
      • getPropertyMargins

        public Insets getPropertyMargins(String key)

        Gets a value of margins property.

        Parameters:
        key - The name of property.
        Returns:
        The property value.
      • getPropertySize

        public Dimension getPropertySize(String key)

        Gets a value of size property.

        Parameters:
        key - The name of property.
        Returns:
        The property value.
      • getPropertyInt

        public int getPropertyInt(String key)

        Gets a value of integer property.

        Parameters:
        key - The name of property.
        Returns:
        The property value.
      • getPropertyDouble

        public double getPropertyDouble(String key)

        Gets a value of double property.

        Parameters:
        key - The name of property.
        Returns:
        The property value.
      • isProperty

        public boolean isProperty(String key)

        Gets a value of boolean property.

        Parameters:
        key - The name of property.
        Returns:
        The property value.
      • getCreator

        public String getCreator()

        Gets creator of resulting device output.

        Returns:
        A creator value.
      • setCreator

        public void setCreator(String creator)

        Specifies creator of resulting device output.

        Parameters:
        creator - A creator value.
      • getSize

        public Dimension getSize()

        Gets a size of the page.

        Returns:
        Size of page.
      • setSize

        public void setSize(Dimension size)

        Specifies size of page.

        Parameters:
        size - Size of page.
      • isDirectRGB

        public boolean isDirectRGB()

        Indicates whether device uses direct RGB mode, that is RGB.

        Returns:
        True if direct RGB mode and false otherwise, that is BGR.
      • getBackground

        public Color getBackground()

        Gets current background of the page.

        Returns:
        Current background of the page
      • setBackground

        public void setBackground(Color background)

        Specifies current background of the page.

        Parameters:
        background - A background of the page.
      • getOpacity

        public float getOpacity()

        Gets current opacity.

        Returns:
        Current opacity.
      • setOpacity

        public void setOpacity(float opacity)

        Specifies opacity.

        Parameters:
        opacity - An opacity.
      • getStroke

        public Stroke getStroke()

        Gets current stroke.

        Returns:
        Current stroke.
      • setStroke

        public void setStroke(Stroke stroke)

        Specifies a stroke.

        Parameters:
        stroke - A stroke.
      • getPaint

        public Paint getPaint()

        Gets current paint.

        Returns:
        Current paint.
      • setPaint

        public void setPaint(Paint paint)

        Specifies a paint.

        Parameters:
        paint - A paint.
      • getOpacityMask

        public Paint getOpacityMask()

        Gets current opacity mask.

        Returns:
        Current opacity mask.
      • setOpacityMask

        public void setOpacityMask(Paint opacityMask)

        Specifies a opacity mask.

        Parameters:
        opacityMask - A opacity mask.
      • getFont

        public ITrFont getFont()

        Gets current font.

        Returns:
        Current font.
      • setFont

        public void setFont(ITrFont font)

        Specifies a font.

        Parameters:
        font - A font.
      • getCharTM

        public AffineTransform getCharTM()

        Gets current characters transform.

        Returns:
        Current characters transform.
      • setCharTM

        public void setCharTM(AffineTransform charTM)

        Specifies characters transform.

        Parameters:
        charTM - Сharacters transform.
      • getTextRenderingMode

        public TextRenderingMode getTextRenderingMode()

        Gets current text rendering mode.

        Returns:
        Current text rendering mode.
      • setTextRenderingMode

        public void setTextRenderingMode(TextRenderingMode textRenderingMode)

        Specifies text rendering mode.

        Parameters:
        textRenderingMode - Text rendering mode.
      • getTextStrokeWidth

        public float getTextStrokeWidth()

        Gets current text stroke width.

        Returns:
        Current text stroke width.
      • setTextStrokeWidth

        public void setTextStrokeWidth(float textStrokeWidth)

        Specifies text stroke width.

        Parameters:
        textStrokeWidth - Text stroke width.
      • create

        public Device create()

        Creates a copy of this device.

        Returns:
        Copy of this device.
      • setTransform

        public void setTransform(AffineTransform transform)

        Specifies current transform.

        Parameters:
        transform - A transform..
      • getTransform

        public AffineTransform getTransform()

        Gets current transform.

        Returns:
        Current transform.
      • transform

        public void transform(AffineTransform transform)

        Transforms the current transformation matrix. Calls writeTransform(Transform).

        Parameters:
        transform - Transform to be applied.
      • translate

        public void translate(double x,
                              double y)

        Translates the current transformation matrix. Calls writeTransform(Transform).

        Parameters:
        x - Translation in X axis.
        y - Translation in Y axis.
      • rotate

        public void rotate(double theta)

        Rotate the current transformation matrix. Calls writeTransform(Transform). Rotating with a positive angle theta rotates points on the positive x axis toward the positive y axis.

        Parameters:
        theta - Angle in radians over which to rotate.
      • rotate

        public void rotate(double theta,
                           double x,
                           double y)

        Rotate the current transformation matrix around a point.

        Parameters:
        theta - An angle of rotation in radians.
        x - X coordinate of point.
        y - Y coordinate of point.
      • scale

        public void scale(double x,
                          double y)

        Scales the current transformation matrix. Calls writeTransform(Transform).

        Parameters:
        x - A scale in X axis.
        y - A scale in Y axis.
      • shear

        public void shear(double shx,
                          double shy)

        Shears the current transformation matrix. Calls writeTransform(Transform).

        Parameters:
        shx - A shear in X axis.
        shy - A shear in Y axis.
      • initClip

        public void initClip()

        Initializes clip of the device.

      • setClip

        public void setClip(Shape clipPath)

        Specifies the clip of the device.

        Parameters:
        clipPath - A clipping path.
      • draw

        public void draw(Shape path)

        Draws a path.

        Parameters:
        path - A path to be drawn.
      • fill

        public void fill(Shape path)

        Fills a path.

        Parameters:
        path - A path to be filled.
      • drawString

        public void drawString(String str,
                               float x,
                               float y)

        Draws a string at given point.

        Parameters:
        str - A string to be drawn.
        x - X coordinate of point.
        y - Y coordinate of point.
      • drawImage

        public void drawImage(BufferedImage image,
                              AffineTransform transform,
                              Color bkg)

        Draws an image with assigned transform and background.

        Parameters:
        image - An image to be drawn.
        transform - A transform.
        bkg - A background color.
      • startDocument

        public void startDocument()

        Makes necessary preparation of device before start rendering of document.

      • endDocument

        public void endDocument()

        Makes necessary preparation of device after the document has been rendered.

      • dispose

        public void dispose()

        Disposes the device.

      • reset

        public void reset()

        Reset the device to initial state for a page.

      • writeComment

        public void writeComment(String comment)

        Writes a comment.

        Parameters:
        comment - A comment to be written.
      • toString

        public String toString()

        Returns the name of device type.

        Overrides:
        toString in class Object
        Returns:
        Type name.
      • drawArc

        public void drawArc(float x,
                            float y,
                            float width,
                            float height,
                            float startAngle,
                            float arcAngle)

        Draws an arc.

        Parameters:
        x - X coordinate of center of the arc.
        y - Y coordinate of center of the arc.
        width - A width of circumscribed rectangle.
        height - A height of circumscribed rectangle.
        startAngle - A start angle of the arc.
        arcAngle - An angle of the arc.
      • drawLine

        public void drawLine(float x1,
                             float y1,
                             float x2,
                             float y2)

        Draws a line segment.

        Parameters:
        x1 - X coordinate of the beginning of segment.
        y1 - Y coordinate of the beginning of segment.
        x2 - X coordinate of the end of segment.
        y2 - Y coordinate of the end of segment.
      • drawOval

        public void drawOval(float x,
                             float y,
                             float width,
                             float height)

        Draws an oval.

        Parameters:
        x - X coordinate of center of the oval.
        y - Y coordinate of center of the oval.
        width - A width of circumscribed rectangle.
        height - A height of circumscribed rectangle.
      • drawPolyline

        public void drawPolyline(int[] xPoints,
                                 int[] yPoints,
                                 int nPoints)

        Draws a polyline.

        Parameters:
        xPoints - X coordinates of points.
        yPoints - Y coordinate of points.
        nPoints - The number of points.
      • drawPolyline

        public void drawPolyline(float[] xPoints,
                                 float[] yPoints,
                                 int nPoints)

        Draws a polyline.

        Parameters:
        xPoints - X coordinates of points.
        yPoints - Y coordinate of points.
        nPoints - The number of points.
      • drawPolygon

        public void drawPolygon(int[] xPoints,
                                int[] yPoints,
                                int nPoints)

        Draws a polygon.

        Parameters:
        xPoints - X coordinates of points.
        yPoints - Y coordinate of points.
        nPoints - The number of points.
      • drawPolygon

        public void drawPolygon(float[] xPoints,
                                float[] yPoints,
                                int nPoints)

        Draws a polygon.

        Parameters:
        xPoints - X coordinates of points.
        yPoints - Y coordinate of points.
        nPoints - The number of points.
      • drawRect

        public void drawRect(float x,
                             float y,
                             float width,
                             float height)

        Draws a rectangle.

        Parameters:
        x - X coordinate of upper left corner of the rectangle.
        y - Y coordinate of upper left corner of the rectangle.
        width - A width of the rectangle.
        height - A height of the rectangle.
      • drawRoundRect

        public void drawRoundRect(float x,
                                  float y,
                                  float width,
                                  float height,
                                  float arcWidth,
                                  float arcHeight)

        Draws a round rectangle.

        Parameters:
        x - X coordinate of upper left corner of the rectangle.
        y - Y coordinate of upper left corner of the rectangle.
        width - A width of the rectangle.
        height - A height of the rectangle.
        arcWidth - A width of circumscribed rectangle of the arc that rounds an angle of the rectangle.
        arcHeight - A height of circumscribed rectangle of the arc that rounds an angle of the rectangle.
      • fillArc

        public void fillArc(float x,
                            float y,
                            float width,
                            float height,
                            float startAngle,
                            float arcAngle)

        Fills an arc.

        Parameters:
        x - X coordinate of center of the arc.
        y - Y coordinate of center of the arc.
        width - A width of circumscribed rectangle.
        height - A height of circumscribed rectangle.
        startAngle - A start angle of the arc.
        arcAngle - An angle of the arc.
      • fillOval

        public void fillOval(float x,
                             float y,
                             float width,
                             float height)

        Fills an oval.

        Parameters:
        x - X coordinate of center of the oval.
        y - Y coordinate of center of the oval.
        width - A width of circumscribed rectangle.
        height - A height of circumscribed rectangle.
      • fillPolygon

        public void fillPolygon(int[] xPoints,
                                int[] yPoints,
                                int nPoints)

        Fills a polygon.

        Parameters:
        xPoints - X coordinates of points.
        yPoints - Y coordinate of points.
        nPoints - The number of points.
      • fillPolygon

        public void fillPolygon(float[] xPoints,
                                float[] yPoints,
                                int nPoints)

        Fills a polygon.

        Parameters:
        xPoints - X coordinates of points.
        yPoints - Y coordinate of points.
        nPoints - The number of points.
      • fillRect

        public void fillRect(float x,
                             float y,
                             float width,
                             float height)

        Fills a rectangle.

        Parameters:
        x - X coordinate of upper left corner of the rectangle.
        y - Y coordinate of upper left corner of the rectangle.
        width - A width of the rectangle.
        height - A height of the rectangle.
      • fillRoundRect

        public void fillRoundRect(float x,
                                  float y,
                                  float width,
                                  float height,
                                  float arcWidth,
                                  float arcHeight)

        Draws a round rectangle.

        Parameters:
        x - X coordinate of upper left corner of the rectangle.
        y - Y coordinate of upper left corner of the rectangle.
        width - A width of the rectangle.
        height - A height of the rectangle.
        arcWidth - A width of circumscribed rectangle of the arc that rounds an angle of the rectangle.
        arcHeight - A height of circumscribed rectangle of the arc that rounds an angle of the rectangle.
      • writeString

        public void writeString(ITrFont font,
                                String str)

        Writes out string with specified font.

        Parameters:
        font - Specified font.
        str - The string.
      • isLicensed

        public boolean isLicensed()

        Indicates whether this instance of Aspose.Page library is licensed.

        Returns:
        If true the library is licensed.