TPTP 4.2.0 Platform Project
Internal API Specification

org.eclipse.tptp.platform.report.igc.svg.internal
Class SVGGC

java.lang.Object
  extended byorg.eclipse.tptp.platform.report.igc.svg.internal.SVGGC
All Implemented Interfaces:
IGC

public class SVGGC
extends java.lang.Object
implements IGC

Test for SVG implementation on IGC.... Special feature added on SVG: - fillRect(int,int,int,int) and fillRect(Rect) support GradientBrush. Note: SVG use clockwise angle whereas IGC uses counter-clockwise angle !.


Field Summary
protected  IBrush brush_
           
protected  int fill_
           
protected  IFont font_
           
protected  org.eclipse.tptp.platform.report.igc.svg.internal.SVGGC.GCDirect gd_
           
protected  int gradient_number_
           
protected  IPen pen_
           
protected  int stroke_
           
protected  int stroke_opacity_
           
protected  int stroke_width_
           
protected  int strokedasharray_
           
 
Fields inherited from interface org.eclipse.tptp.platform.report.igc.internal.IGC
C_INFO_BACKGROUND, C_INFO_FOREGROUND, C_LIST_BACKGROUND, C_LIST_FOREGROUND, C_LIST_SELECTION_BACKGROUND, C_LIST_SELECTION_TEXT, C_TITLE_BACKGROUND, C_TITLE_BACKGROUND_GRADIENT, C_TITLE_FOREGROUND, C_TITLE_INACTIVE_BACKGROUND, C_TITLE_INACTIVE_BACKGROUND_GRADIENT, C_TITLE_INACTIVE_FOREGROUND, C_WIDGET_BACKGROUND, C_WIDGET_BORDER, C_WIDGET_DARK_SHADOW, C_WIDGET_FOREGROUND, C_WIDGET_HIGHLIGHT_SHADOW, C_WIDGET_LIGHT_SHADOW, C_WIDGET_NORMAL_SHADOW
 
Constructor Summary
SVGGC(java.io.OutputStream output, int w, int h)
          Builds a new SVG GC
 
Method Summary
 void begin()
          starts a drawing session
 void drawArc(int xc, int yc, double _r1_angle, int r1, int r2, double _start_angle, double _arc_length)
          draw an oriented arc defined by start angle and length (>0 means counter-clockwise in the sense (1,0)>(0,1)).
 void drawCircle(int cx, int cy, int radius)
          Draw a circle of radius and centered at (cx,cy) using current brush or color.
 void drawEllipse(int xc, int yc, double _r1_angle, int r1, int r2)
          Draw an oriented ellipse, not necessary coordinate aligned one.
 void drawFocus(int x, int y, int w, int h)
          Not implemented in SVG do nothing
 void drawFocus(IRect rect)
          Draw the focus with rectangle object.
 void drawHLine(int x1, int x2, int y)
           
 void drawImage(IImage image, int x, int y)
          draw image at given location
 void drawImage(IImage image, int srcX, int srcY, int srcW, int srcH)
          draw image resized to a rectangle
 void drawImage(IImage image, int srcX, int srcY, int srcW, int srcH, int dstX, int dstY, int dstW, int dstH)
          draw part of image resized to a rectangle
 void drawLine(int x1, int y1, int x2, int y2)
          Draw a line using current pen. points are expressed in pixel coordinates
 void drawOval(int x, int y, int w, int h)
          Draw using current brush or color the oval defined inside given rectangle.
 void drawPath(IPath path)
          Supported path: IPolygon.
 void drawPoint(int x, int y)
          Draw pixel at location (x,y) using current brush
 void drawPoly(IPolygon poly)
          draw the polygon using current brush or color.
 void drawRect(int x, int y, int w, int h)
          Draw the outline of rectangle using current pen.
 void drawRect(IRect r)
          Draw the outline of rectangle using current pen.
 void drawText(java.lang.String text, int x, int y)
          Draw text at given location, x,y is the upper left corner.
 void drawText(java.lang.String text, int x, int y, double angle)
          Draw rotated text at given location (uppper left corner).
 void drawVLine(int x, int y1, int y2)
           
 void end()
          terminates a drawing session
 void fillArc(int xc, int yc, double _r1_angle, int r1, int r2, double _start_angle, double _arc_length)
          fill an oriented arc defined by start angle and length (>0 means counter-clockwise in the sense (1,0)>(0,1)).
 void fillCircle(int cx, int cy, int radius)
          Fill circle using current brush or color
 void fillEllipse(int xc, int yc, double _r1_angle, int r1, int r2)
          Fill an oriented ellipse, not necessary coordinate aligned one.
 void fillOval(int x, int y, int w, int h)
          Fill using current brush or color the oval defined inside given rectangle.
 void fillPoly(IPolygon poly)
          fill the polygon using current brush or color.
 void fillRect(int x, int y, int w, int h)
          Fill rectangle including outline using current brush (@see IRect for rectangle definition).
 void fillRect(IRect r)
          Fill rectangle including outline using current brush
 void fillShape(IShape shape)
          Supported shapes: IRect, Oval.
 IBrush getBrush()
           
 IShape getClipping()
           
 IFont getFont()
           
 IFontMetrics getFontMetrics()
           
 IGCDirect getIGCDirect()
           
 java.io.OutputStream getOutputStream()
           
 IPen getPen()
           
 int getPoint(int x, int y)
           
 int getSystemColor(int id)
          Return system color for given id.
 IBrush setBrush(IBrush _brush)
          Support: -SolidBrush.
 IShape setClipping(IShape s)
          Change current clipping area, and return previous one.
 IFont setFont(IFont font)
          Change current font and return previous one (can be null)
 void setOutputStream(java.io.OutputStream os_)
           
 IPen setPen(IPen _pen)
          Supports LineStylePen, but extract only color for it.
protected  void svg2Coord(int x1, int y1, int x2, int y2, java.lang.StringBuffer b)
           
protected  void svgColor(int rgba, java.lang.StringBuffer b)
           
protected  void svgCoord(int x, int y, java.lang.StringBuffer b)
           
protected  void svgEllipse(int cx, int cy, int rx, int ry, java.lang.StringBuffer b)
           
protected  void svgFill(java.lang.StringBuffer b)
           
protected  void svgFont(java.lang.StringBuffer b)
           
protected  java.lang.String svgGradient(FullGradientBrush b, int x1, int y1, int x2, int y2)
           
protected  java.lang.String svgGradient(GradientBrush b, int x1, int y1, int x2, int y2)
           
protected  void svgPoints(int[] x, int[] y, java.lang.StringBuffer b)
           
protected  void svgRect(int x, int y, int w, int h, int rx, int ry, java.lang.StringBuffer b)
           
protected  void svgStroke(java.lang.StringBuffer b)
           
protected  void svgWrite(java.lang.String string)
          Generates a String into the stream format.
 ISize textExtent(java.lang.String text)
           
 ISize textExtent(java.lang.String text, double angle)
           
 IPolygon textExtent(java.lang.String text, int x, int y, double angle)
           
protected  void Unsupported(java.lang.String what)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

brush_

protected IBrush brush_

pen_

protected IPen pen_

font_

protected IFont font_

fill_

protected int fill_

stroke_

protected int stroke_

strokedasharray_

protected int strokedasharray_

stroke_width_

protected int stroke_width_

stroke_opacity_

protected int stroke_opacity_

gradient_number_

protected int gradient_number_

gd_

protected org.eclipse.tptp.platform.report.igc.svg.internal.SVGGC.GCDirect gd_
Constructor Detail

SVGGC

public SVGGC(java.io.OutputStream output,
             int w,
             int h)
Builds a new SVG GC

Method Detail

getIGCDirect

public IGCDirect getIGCDirect()
Specified by:
getIGCDirect in interface IGC
Returns:
IGCDirect interface used by this IGC.

getSystemColor

public int getSystemColor(int id)
Description copied from interface: IGC
Return system color for given id.
Note: for constant color as white,red,... use RGBA class instead.

Specified by:
getSystemColor in interface IGC
Parameters:
id - identifiant of system color, see C_xxx constants
Returns:
rgba color defined in system for given id.
See Also:
class.

begin

public void begin()
starts a drawing session


end

public void end()
terminates a drawing session


getBrush

public IBrush getBrush()
Specified by:
getBrush in interface IGC
Returns:
current brush, or null if no brush are used

setBrush

public IBrush setBrush(IBrush _brush)
Support: -SolidBrush. -GradientBrush for fillRect

Specified by:
setBrush in interface IGC
See Also:
IGC.setBrush(org.eclipse.tptp.platform.report.igc.internal.IBrush)

getPen

public IPen getPen()
Specified by:
getPen in interface IGC
Returns:
curren pen, or null is no pen are used

getPoint

public int getPoint(int x,
                    int y)
Specified by:
getPoint in interface IGC
Parameters:
x - coordinate of point to get color.
y - coorindate of point to get color.
Returns:
current pixel color (RGBA) at (x,y), 0 if requested point is outside.

setPen

public IPen setPen(IPen _pen)
Supports LineStylePen, but extract only color for it.

Specified by:
setPen in interface IGC
See Also:
IGC.setPen(org.eclipse.tptp.platform.report.igc.internal.IPen)

getFont

public IFont getFont()
Specified by:
getFont in interface IGC
Returns:
current font used by drawText.

setFont

public IFont setFont(IFont font)
Description copied from interface: IGC
Change current font and return previous one (can be null)

Specified by:
setFont in interface IGC

drawHLine

public void drawHLine(int x1,
                      int x2,
                      int y)

drawVLine

public void drawVLine(int x,
                      int y1,
                      int y2)

drawLine

public void drawLine(int x1,
                     int y1,
                     int x2,
                     int y2)
Description copied from interface: IGC
Draw a line using current pen. points are expressed in pixel coordinates

Specified by:
drawLine in interface IGC

drawPoint

public void drawPoint(int x,
                      int y)
Description copied from interface: IGC
Draw pixel at location (x,y) using current brush

Specified by:
drawPoint in interface IGC

drawCircle

public void drawCircle(int cx,
                       int cy,
                       int radius)
Description copied from interface: IGC
Draw a circle of radius and centered at (cx,cy) using current brush or color.

Specified by:
drawCircle in interface IGC

fillCircle

public void fillCircle(int cx,
                       int cy,
                       int radius)
Description copied from interface: IGC
Fill circle using current brush or color

Specified by:
fillCircle in interface IGC

drawOval

public void drawOval(int x,
                     int y,
                     int w,
                     int h)
Description copied from interface: IGC
Draw using current brush or color the oval defined inside given rectangle.

Specified by:
drawOval in interface IGC

fillOval

public void fillOval(int x,
                     int y,
                     int w,
                     int h)
Description copied from interface: IGC
Fill using current brush or color the oval defined inside given rectangle.

Specified by:
fillOval in interface IGC

drawArc

public void drawArc(int xc,
                    int yc,
                    double _r1_angle,
                    int r1,
                    int r2,
                    double _start_angle,
                    double _arc_length)
Description copied from interface: IGC
draw an oriented arc defined by start angle and length (>0 means counter-clockwise in the sense (1,0)>(0,1)).

Specified by:
drawArc in interface IGC
Parameters:
xc - X center of the ellipse.
yc - Y center of the ellipse.
_r1_angle - angle of main radius (r1) from X coordinate axis.
r1 - main radius
r2 - secondary radius (90 degree from r1)
_start_angle - start angle of arc 0 is 3 O'clock position
_arc_length - arc length from start angle >0 for counter-clockwise, 2*PI for full ellipse.

fillArc

public void fillArc(int xc,
                    int yc,
                    double _r1_angle,
                    int r1,
                    int r2,
                    double _start_angle,
                    double _arc_length)
Description copied from interface: IGC
fill an oriented arc defined by start angle and length (>0 means counter-clockwise in the sense (1,0)>(0,1)). Fill include the center of ellipse.

Specified by:
fillArc in interface IGC
Parameters:
xc - X center of the ellipse.
yc - Y center of the ellipse.
_r1_angle - angle of main radius (r1) from X coordinate axis.
r1 - main radius
r2 - secondary radius (90 degree from r1)
_start_angle - start angle (radian) of arc 0 is 3 O'clock position
_arc_length - arc length (radian) from start angle >0 for counter-clockwise, 2*PI for full ellipse.

drawEllipse

public void drawEllipse(int xc,
                        int yc,
                        double _r1_angle,
                        int r1,
                        int r2)
Description copied from interface: IGC
Draw an oriented ellipse, not necessary coordinate aligned one.

Specified by:
drawEllipse in interface IGC
Parameters:
xc - X center of the ellipse.
yc - Y center of the ellipse.
_r1_angle - angle of main radius (r1) from X coordinate axis.
r1 - main radius
r2 - secondary radius (90 degree from r1)

fillEllipse

public void fillEllipse(int xc,
                        int yc,
                        double _r1_angle,
                        int r1,
                        int r2)
Description copied from interface: IGC
Fill an oriented ellipse, not necessary coordinate aligned one.

Specified by:
fillEllipse in interface IGC
Parameters:
xc - X center of the ellipse.
yc - Y center of the ellipse.
_r1_angle - angle (radian) of main radius (r1) from X coordinate axis.
r1 - main radius
r2 - secondary radius (90 degree from r1)

fillRect

public void fillRect(int x,
                     int y,
                     int w,
                     int h)
Description copied from interface: IGC
Fill rectangle including outline using current brush (@see IRect for rectangle definition).

Specified by:
fillRect in interface IGC

drawRect

public void drawRect(int x,
                     int y,
                     int w,
                     int h)
Description copied from interface: IGC
Draw the outline of rectangle using current pen.

Specified by:
drawRect in interface IGC

fillRect

public void fillRect(IRect r)
Description copied from interface: IGC
Fill rectangle including outline using current brush

Specified by:
fillRect in interface IGC

drawRect

public void drawRect(IRect r)
Description copied from interface: IGC
Draw the outline of rectangle using current pen.

Specified by:
drawRect in interface IGC

drawImage

public void drawImage(IImage image,
                      int x,
                      int y)
Description copied from interface: IGC
draw image at given location

Specified by:
drawImage in interface IGC

drawImage

public void drawImage(IImage image,
                      int srcX,
                      int srcY,
                      int srcW,
                      int srcH,
                      int dstX,
                      int dstY,
                      int dstW,
                      int dstH)
Description copied from interface: IGC
draw part of image resized to a rectangle

Specified by:
drawImage in interface IGC

drawImage

public void drawImage(IImage image,
                      int srcX,
                      int srcY,
                      int srcW,
                      int srcH)
Description copied from interface: IGC
draw image resized to a rectangle

Specified by:
drawImage in interface IGC

drawPoly

public void drawPoly(IPolygon poly)
Description copied from interface: IGC
draw the polygon using current brush or color.

Specified by:
drawPoly in interface IGC

fillPoly

public void fillPoly(IPolygon poly)
Description copied from interface: IGC
fill the polygon using current brush or color.

Specified by:
fillPoly in interface IGC

drawText

public void drawText(java.lang.String text,
                     int x,
                     int y)
Draw text at given location, x,y is the upper left corner. if not transparent, background of text is filled using current brush.

Specified by:
drawText in interface IGC

drawText

public void drawText(java.lang.String text,
                     int x,
                     int y,
                     double angle)
Draw rotated text at given location (uppper left corner). if not transparent, background of text is filled using current brush.

Specified by:
drawText in interface IGC

drawFocus

public void drawFocus(int x,
                      int y,
                      int w,
                      int h)
Not implemented in SVG do nothing

Specified by:
drawFocus in interface IGC

drawFocus

public void drawFocus(IRect rect)
Draw the focus with rectangle object. Call drawFocus(x,y,w,h)

Specified by:
drawFocus in interface IGC
See Also:
drawFocus(int, int, int, int)

getFontMetrics

public IFontMetrics getFontMetrics()
Specified by:
getFontMetrics in interface IGC
Returns:
current font metrics

textExtent

public IPolygon textExtent(java.lang.String text,
                           int x,
                           int y,
                           double angle)
Specified by:
textExtent in interface IGC
Returns:
rotated text bounding polygon in pixels, using given angle (radian). null is rotation is not supported. (x,y) is where text will be drawn, (top left corner of text before rotation). By convention, first point must be top-left corner of text (x,y), second one is top right corner, third is bottom right and last one if bottom left corner, more points can be returned, but only the fourth first are mandatory. If you want to get size of rotated text, use IPolygon.getBounds();

textExtent

public ISize textExtent(java.lang.String text)
Specified by:
textExtent in interface IGC
Returns:
size of text bounding box in pixels

textExtent

public ISize textExtent(java.lang.String text,
                        double angle)
Specified by:
textExtent in interface IGC
Returns:
size of rotated text using given angle (in radian), or null if rotation is not supported.

getClipping

public IShape getClipping()
Specified by:
getClipping in interface IGC
Returns:
current clipping area, null if none

setClipping

public IShape setClipping(IShape s)
Description copied from interface: IGC
Change current clipping area, and return previous one.

Specified by:
setClipping in interface IGC

fillShape

public void fillShape(IShape shape)
Supported shapes: IRect, Oval.

Specified by:
fillShape in interface IGC

drawPath

public void drawPath(IPath path)
Supported path: IPolygon.

Specified by:
drawPath in interface IGC

Unsupported

protected void Unsupported(java.lang.String what)

svgWrite

protected void svgWrite(java.lang.String string)
Generates a String into the stream format.


svgColor

protected void svgColor(int rgba,
                        java.lang.StringBuffer b)

svgFill

protected void svgFill(java.lang.StringBuffer b)

svgStroke

protected void svgStroke(java.lang.StringBuffer b)

svgFont

protected void svgFont(java.lang.StringBuffer b)

svgGradient

protected java.lang.String svgGradient(GradientBrush b,
                                       int x1,
                                       int y1,
                                       int x2,
                                       int y2)

svgGradient

protected java.lang.String svgGradient(FullGradientBrush b,
                                       int x1,
                                       int y1,
                                       int x2,
                                       int y2)

svgCoord

protected void svgCoord(int x,
                        int y,
                        java.lang.StringBuffer b)

svg2Coord

protected void svg2Coord(int x1,
                         int y1,
                         int x2,
                         int y2,
                         java.lang.StringBuffer b)

svgRect

protected void svgRect(int x,
                       int y,
                       int w,
                       int h,
                       int rx,
                       int ry,
                       java.lang.StringBuffer b)

svgEllipse

protected void svgEllipse(int cx,
                          int cy,
                          int rx,
                          int ry,
                          java.lang.StringBuffer b)

svgPoints

protected void svgPoints(int[] x,
                         int[] y,
                         java.lang.StringBuffer b)

getOutputStream

public java.io.OutputStream getOutputStream()

setOutputStream

public void setOutputStream(java.io.OutputStream os_)

TPTP 4.2.0 Platform Project
Internal API Specification