public class SwtGraphicContext extends Object implements GraphicContext
GraphicContext implementation using the SWT GC to draw on whatever
 you like.| Constructor and Description | 
|---|
SwtGraphicContext(org.eclipse.swt.graphics.GC delegate)
Constructor. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
Area | 
calculateTextSize(String text)
Calculates the size of the text. 
 | 
void | 
clip(Area rect)
Restricts which area of the context can be used to drawn on. 
 | 
SwtGraphicContext | 
delegate(org.eclipse.swt.graphics.GC newDelegate)
Sets the GC. 
 | 
void | 
dispose()
Disposes of the operating system resources associated with this resource. 
 | 
void | 
drawLine(double x1,
        double y1,
        double x2,
        double y2)
Draws a simple line between two points. 
 | 
void | 
drawPolyline(double[] x,
            double[] y)
Paints the outline of a polyline. 
 | 
void | 
drawText(double x,
        double y,
        String text)
Paints the text on a position. 
 | 
void | 
fillArc(double x,
       double y,
       double width,
       double height,
       double startAngle,
       double arcAngle)
Draws the outline of a circular or elliptical arc covering the specified rectangle. 
 | 
void | 
fillOval(double x,
        double y,
        double width,
        double height)
Paints a filled oval. 
 | 
void | 
fillPolygon(double[] x,
           double[] y)
Paints a filled polygon. 
 | 
void | 
fillRectangle(double x,
             double y,
             double width,
             double height)
Paints a filled rectangle. 
 | 
int | 
getColor()
Returns the color as ARGB int, e.g. 
 | 
org.eclipse.swt.graphics.GC | 
getDelegate()
Returns the GC. 
 | 
Font | 
getFont()
Returns the font as an enum with the font properties as hints for the actual font
 used by the GUI. 
 | 
void | 
scale(double x,
     double y)
Scales the drawing canvas with the factor. 
 | 
void | 
setColor(int colorAsInt)
Sets the color as ARGB int, e.g. 
 | 
void | 
setDelegate(org.eclipse.swt.graphics.GC delegate)
Sets the GC. 
 | 
void | 
setFont(Font fontAsEnum)
Sets the font as an enum with the font properties as hints for the actual font used
 by the GUI. 
 | 
void | 
translate(double x,
         double y)
Moves the drawing canvas's origin to the new coordinates. 
 | 
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdrawRectangle, drawRectangle, fillRectangle, scalepublic SwtGraphicContext(org.eclipse.swt.graphics.GC delegate)
delegate - the GC to draw on; cannot be nullpublic void setColor(int colorAsInt)
GraphicContext0xFFFF0000 and blue is
 0xFF0000FF.setColor in interface GraphicContextcolorAsInt - the colorpublic int getColor()
GraphicContext0xFFFF0000 and blue is
 0xFF0000FF.getColor in interface GraphicContextpublic void setFont(Font fontAsEnum)
GraphicContextsetFont in interface GraphicContextfontAsEnum - the fontpublic Font getFont()
GraphicContextgetFont in interface GraphicContextpublic Area calculateTextSize(String text)
GraphicContextcalculateTextSize in interface GraphicContextpublic void translate(double x,
                      double y)
GraphicContexttranslate in interface GraphicContextx - translate xy - translate ypublic void scale(double x,
                  double y)
GraphicContextscale in interface GraphicContextx - factor xy - factor ypublic void clip(Area rect)
GraphicContextnull to remove the restriction again.clip in interface GraphicContextrect - the clipping areapublic void drawLine(double x1,
                     double y1,
                     double x2,
                     double y2)
GraphicContextdrawLine in interface GraphicContextx1 - - start point xy1 - - start point yx2 - - end point xy2 - - end point ypublic void fillRectangle(double x,
                          double y,
                          double width,
                          double height)
GraphicContextfillRectangle in interface GraphicContextx - the rectangle's xy - the rectangle's ywidth - the rectangle's widthheight - the rectangle's heightpublic void drawPolyline(double[] x,
                         double[] y)
GraphicContextdrawPolyline in interface GraphicContextx - the polygon's x coordinatesy - the polygon's y coordinatesGraphicContext.fillPolygon(double[], double[])public void fillPolygon(double[] x,
                        double[] y)
GraphicContextfillPolygon in interface GraphicContextx - the polygon's x coordinatesy - the polygon's y coordinatesGraphicContext.drawPolyline(double[], double[])public void drawText(double x,
                     double y,
                     String text)
GraphicContextdrawText in interface GraphicContextx - the text's xy - the text's ypublic void fillOval(double x,
                     double y,
                     double width,
                     double height)
GraphicContextfillOval in interface GraphicContextx - the oval's xy - the oval's ywidth - the oval's widthheight - the oval's heightpublic void fillArc(double x,
                    double y,
                    double width,
                    double height,
                    double startAngle,
                    double arcAngle)
GraphicContext
 The resulting arc begins at startAngle and extends for
 arcAngle degrees, using the current color. Angles are interpreted such
 that 0 degrees is at the 3 o'clock position. A positive value indicates a
 counter-clockwise rotation while a negative value indicates a clockwise rotation.
 
 The center of the arc is the center of the rectangle whose origin is
 (x, y) and whose size is specified by the width and
 height arguments.
 
 The resulting arc covers an area width + 1 pixels wide by
 height + 1 pixels tall.
 
fillArc in interface GraphicContextx - the x coordinate of the upper-left corner of the arc to be drawn.y - the y coordinate of the upper-left corner of the arc to be drawn.width - the width of the arc to be drawn.height - the height of the arc to be drawn.startAngle - the beginning angle.arcAngle - the angular extent of the arc, relative to the start angle.public void dispose()
public org.eclipse.swt.graphics.GC getDelegate()
public SwtGraphicContext delegate(org.eclipse.swt.graphics.GC newDelegate)
newDelegate - the GC to draw on; cannot be nullpublic void setDelegate(org.eclipse.swt.graphics.GC delegate)
delegate - the GC to draw on; cannot be nullCopyright © 2020. All rights reserved.