|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.rosuda.javaGD.GDInterface
public class GDInterface
CGInterface
defines an interface (and provides a simple implementation) between the JavaGD R device and the Java code. Any back-end that desires to display R graphics in Java can subclass this class are provide its name to JavaGD package via JAVAGD_CLASS_NAME environment variable. The default implementation handles most callbacks, but subclasses should override at least gdOpen(double, double)
to create an instance of GDContainer
c
which will be used for all subsequent drawing.
external API: those methods are called via JNI from the GD C code
public void gdOpen(int devNr, double w, double h); public void gdActivate(); public void gdCircle(double x, double y, double r); public void gdClip(double x0, double x1, double y0, double y1); public void gdClose(); public void gdDeactivate(); public void gdFlush(boolean flush); public void gdHold(); public double[] gdLocator(); public void gdLine(double x1, double y1, double x2, double y2); public double[] gdMetricInfo(int ch); public void gdMode(int mode); public void gdNewPage(int deviceNumber); public void gdPath(int npoly, int[] nper, double[] x, double[] y, int mode); public void gdPolygon(int n, double[] x, double[] y); public void gdPolyline(int n, double[] x, double[] y); public void gdRaster(byte img[], int img_w, int img_h, double x, double y, double w, double h, double rot, boolean interpolate); public void gdRect(double x0, double y0, double x1, double y1); public double[] gdSize(); public double gdStrWidth(String str); public void gdText(double x, double y, String str, double rot, double hadj);
GDC - manipulation of the current graphics state
public void gdcSetColor(int cc); public void gdcSetFill(int cc); public void gdcSetLine(double lwd, int lty); public void gdcSetFont(double cex, double ps, double lineheight, int fontface, String fontfamily);
Field Summary | |
---|---|
boolean |
active
flag indicating whether this device is active (current) in R |
GDContainer |
c
container that will receive all drawing methods. |
boolean |
holding
flag indicating whether hold is in progress |
LocatorSync |
ls
synchronization object for locator calls |
boolean |
open
flag indicating whether this device has currently an open instance |
Constructor Summary | |
---|---|
GDInterface()
|
Method Summary | |
---|---|
void |
executeDevOff()
close the device in R associted with this instance |
void |
gdActivate()
the device became active (current) |
void |
gdCircle(double x,
double y,
double r)
draw a circle |
void |
gdClip(double x0,
double x1,
double y0,
double y1)
clip drawing to the specified region |
void |
gdClose()
close the display |
void |
gdcSetColor(int cc)
set drawing color |
void |
gdcSetFill(int cc)
set fill color |
void |
gdcSetFont(double cex,
double ps,
double lineheight,
int fontface,
java.lang.String fontfamily)
set current font |
void |
gdcSetLine(double lwd,
int lty)
set line width and type |
void |
gdDeactivate()
the device became inactive (i.e. another device is now current) |
void |
gdFlush(boolean flush)
hold/flush |
void |
gdHold()
(unimplemented - this call is now obsolete in R) |
void |
gdLine(double x1,
double y1,
double x2,
double y2)
draw a line |
double[] |
gdLocator()
invoke the locator |
double[] |
gdMetricInfo(int ch)
retrieve font metrics info for the given unicode character |
void |
gdMode(int mode)
R signalled a mode change |
void |
gdNewPage()
create a new, blank page (old API, not used anymore) |
void |
gdNewPage(int devNr)
create a new, blank page |
void |
gdOpen(double w,
double h)
requests a new device of the specified size |
void |
gdPath(int npoly,
int[] nper,
double[] x,
double[] y,
boolean winding)
create multi-polygon path |
void |
gdPolygon(int n,
double[] x,
double[] y)
|
void |
gdPolyline(int n,
double[] x,
double[] y)
|
void |
gdRaster(byte[] img,
int img_w,
int img_h,
double x,
double y,
double w,
double h,
double rot,
boolean interpolate)
|
void |
gdRect(double x0,
double y0,
double x1,
double y1)
|
double[] |
gdSize()
retrieve the current size of the device |
double |
gdStrWidth(java.lang.String str)
retrieve width of the given text when drawn in the current font |
void |
gdText(double x,
double y,
java.lang.String str,
double rot,
double hadj)
draw text |
int |
getDeviceNumber()
returns the device number |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public boolean active
public boolean open
public boolean holding
public GDContainer c
gdOpen(double, double)
method.
public LocatorSync ls
Constructor Detail |
---|
public GDInterface()
Method Detail |
---|
public void gdOpen(double w, double h)
w
- width of the deviceh
- height of the devicepublic void gdActivate()
public void gdCircle(double x, double y, double r)
x
- x coordinate of the centery
- y coordinate of the centerr
- radiuspublic void gdClip(double x0, double x1, double y0, double y1)
x0
- left coordinatex1
- right coordinatey0
- top coordinatey1
- bottom coordinatepublic void gdClose()
public void gdDeactivate()
public void gdHold()
public void gdFlush(boolean flush)
flush
- if false
then the device started holding and no
updates should be shown on screen, if true
then the device should
flush right away and resume normal operation after than. Note that
the flush must either be synchronous, or it must be guaranteed that
shown content will be identical to the state up till now, otherwise
the device will break animations.public double[] gdLocator()
null
is cancelledpublic void gdLine(double x1, double y1, double x2, double y2)
x1
- x coordinate of the originy1
- y coordinate of the originx2
- x coordinate of the endy2
- y coordinate of the endpublic double[] gdMetricInfo(int ch)
ch
- character (encoding may depend on the font type)
public void gdMode(int mode)
mode
- mode as signalled by R (currently 0=R stopped drawing, 1=R started drawing, 2=graphical input exists)public void gdNewPage()
public void gdNewPage(int devNr)
devNr
- device number assigned to this device by Rpublic void gdPath(int npoly, int[] nper, double[] x, double[] y, boolean winding)
winding:
- use winding rule (true) or odd-even rule (false)public void gdPolygon(int n, double[] x, double[] y)
public void gdPolyline(int n, double[] x, double[] y)
public void gdRect(double x0, double y0, double x1, double y1)
public void gdRaster(byte[] img, int img_w, int img_h, double x, double y, double w, double h, double rot, boolean interpolate)
public double[] gdSize()
public double gdStrWidth(java.lang.String str)
str
- text
public void gdText(double x, double y, java.lang.String str, double rot, double hadj)
x
- x coordinate of the originy
- y coordinate of the originstr
- text to drawrot
- rotation (in degrees)hadj
- horizontal adjustment with respect to the text size (0=left-aligned wrt origin, 0.5=centered, 1=right-aligned wrt origin)public void gdcSetColor(int cc)
cc
- colorpublic void gdcSetFill(int cc)
cc
- colorpublic void gdcSetLine(double lwd, int lty)
lwd
- line width (see lwd
parameter in R)lty
- line type (see lty
parameter in R)public void gdcSetFont(double cex, double ps, double lineheight, int fontface, java.lang.String fontfamily)
cex
- character expansion (see cex
parameter in R)ps
- point size (see ps
parameter in R - for all practical purposes the requested font size in points is cex * ps
)lineheight
- line heightfontface
- font face (see font
parameter in R: 1=plain, 2=bold, 3=italic, 4=bold-italic, 5=symbol)fontfamily
- font family (see family
parameter in R)public int getDeviceNumber()
public void executeDevOff()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |