java-gnome version 4.0.19

org.gnome.rsvg
Class Handle

Object
  extended by org.freedesktop.bindings.Pointer
      extended by org.freedesktop.bindings.Proxy
          extended by org.gnome.glib.Object
              extended by org.gnome.rsvg.Handle

public class Handle
extends Object

Handle to an SVG image in memory. This class allows you to load an SVG image from a file on disk or from memory.

Once you have the Handle you can render it to Cairo directly with Context's showHandle(),

 Rsvg.init();
 ...
 
 graphic = new Handle("Tiger.svg");
 cr.showHandle(graphic);
 

Since:
4.0.18
Author:
Andrew Cowie

Constructor Summary
Handle()
           
Handle(String filename)
          Construct a handle to an SVG image sourced from the given filename.
 
Method Summary
 void close()
          Indicate you have finished loading data into the Handle.
 DimensionData getDimensions()
          Get the size of the SVG image represented by this Handle.
 DimensionData getDimensionsSub(String id)
          Get the size of a named sub-element of the SVG image represented by this Handle.
 double getDPIX()
          Get the horizontal resolution of this graphic.
 double getDPIY()
          Get the vertical resolution of this graphic.
 void write(byte[] data)
          Write data into this Handle.
 
Methods inherited from class org.freedesktop.bindings.Pointer
toString
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Handle

public Handle()

Handle

public Handle(String filename)
       throws FileNotFoundException
Construct a handle to an SVG image sourced from the given filename.

Throws:
FileNotFoundException
Since:
4.0.15
Method Detail

close

public void close()
           throws IOException
Indicate you have finished loading data into the Handle.

This method is the compliment of the write() method, and should be called when you have passed in all the data for the image you are loading.

Throws:
IOException
Since:
Unstable

getDimensions

public DimensionData getDimensions()
Get the size of the SVG image represented by this Handle.

Since:
4.0.18

getDimensionsSub

public DimensionData getDimensionsSub(String id)
Get the size of a named sub-element of the SVG image represented by this Handle.

You can pass null to get the size of the entire graphic.

Since:
4.0.18

getDPIX

public double getDPIX()
Get the horizontal resolution of this graphic.

Resolution and SVG is a bit of a weird topic. The default unts in an SVG file are "pixels", px as defined in the CSS specification, and the default resolution turns out to be 90 pixels per inch. So unless the program writing the graphic you are loading has gone to extraordinary lengths, the value of this property will be 90.0 regardless of the user space units in use inside the graphic.

Under ordinary circumstances it will be the same as the vertical resolution so you probably don't have to query both.

Since:
4.0.18

getDPIY

public double getDPIY()
Get the vertical resolution of this graphic. See getDPIX() for details.

Since:
4.0.18

write

public void write(byte[] data)
           throws IOException
Write data into this Handle.

Throws:
IOException - if there is a problem loading the data
Since:
Unstable


java-gnome