|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.tensegrity.graphics.device.AbstractDevice
com.tensegrity.graphics.device.SWTDeviceNonAWTDependent
This is a TEMPORARY version of the SWT-based implementation
of .
This class is intended to replace in a foreseeable futur the current Device
which is a simple wrapper around the AWTDevice.
SWTDevice
| Field Summary | |
static boolean |
USE_FONT_CACHING
Disable or enable font-caching. |
| Fields inherited from class com.tensegrity.graphics.device.AbstractDevice |
fontFormat, fontFormatData, paintFormat, paintFormatData, strokeFormat, strokeFormatData, visibleFont, visiblePaint, visibleStroke |
| Fields inherited from interface com.tensegrity.graphics.device.Device |
DRAW_FILL, DRAW_OUTLINE |
| Constructor Summary | |
protected |
SWTDeviceNonAWTDependent()
Default constructor. |
| Method Summary | |
void |
clearClip()
Clears the currently used clip rectangle. |
void |
clearRect(int x,
int y,
int width,
int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface. |
void |
clipRect(int x,
int y,
int width,
int height)
Intersects the current clip with the specified rectangle. |
static int[] |
convertIntArrays(int[] ptX,
int[] ptY,
int ptCount)
Utility method creating an array of alternating x and y values, with the x values contained into ptX and the y values in ptY.
|
static int[] |
convertIntArrays(int[] ptX,
int[] ptY,
int ptCount,
int xOffset,
int yOffset)
Utility method creating an array of alternating x and y values, with the x values contained into ptX and the y values in
ptY. |
static int[] |
convertIntArrays(int[] ptX,
int[] ptY,
int ptCount,
int xOffset,
int yOffset,
float scaleX,
float scaleY)
Utility method creating an array of alternating x and y values, with the x values contained into ptX and the y values in ptY.
|
void |
debugColor(int color)
Simple Debug utility method which prints out the Red, Green and Blue values of the passed color.
|
void |
dispose()
Disposes the internal image and GC buffer. |
void |
drawArc(int flags,
int arg0,
int arg1,
int arg2,
int arg3,
int startAngle,
int arcAngle)
Draws a circular or elliptical arc covering the specified rectangle. |
void |
drawLine(int arg0,
int arg1,
int arg2,
int arg3)
This method draws a line from the starting coordinate given by x1 and y1 to the ending coordinate given
by x2 and y2. |
void |
drawOval(int flags,
int arg0,
int arg1,
int arg2,
int arg3)
Draws an oval. |
void |
drawPolygon(int flags,
int[] ptX1,
int[] ptY1,
int ptCount)
This method draws a closed polygon. |
void |
drawPolyline(int[] ptX1,
int[] ptY1,
int ptCount)
This method draws a polyline. |
void |
drawRect(int flags,
int arg0,
int arg1,
int arg2,
int arg3)
This methods draws the rectangle defined by the given parameters. |
void |
drawRoundRect(int flags,
int x1,
int y1,
int width1,
int height1,
int arcWidth1,
int arcHeight1)
Draws a round-cornered rectangle using this graphic contexts currently set Stroke- and PaintFormat. |
void |
drawString(java.lang.String str,
int cx,
int cy)
Draws the text given by the specified string, using this graphics context's current font and color. |
protected void |
finalize()
This method is herein overridden in order to call the dispose()
method. |
Boundary |
getClipBounds()
Returns the bounding rectangle of the current clipping area. |
Boundary |
getClipBounds(Boundary boundary)
Returns the bounding rectangle of the current clipping area. |
Device |
getDevice(org.eclipse.swt.graphics.Device device,
org.eclipse.swt.graphics.GC gc,
int x,
int y,
int width,
int height)
This method creates, initializes and returns a new instance of this class. |
DeviceStatistics |
getDeviceStatistics()
Returns the device statistics or null if statistics
are disabled. |
Transform2D |
getTransform()
Returns a copy of the current AffineTransform in the
Device. |
boolean |
hitClip(int x,
int y,
int width,
int height)
Returns true if the specified rectangular area intersects
the bounding rectangle of the current clipping area. |
void |
initiate()
Initializes this Device.
|
boolean |
isAntialiasing()
Returns always false since Antialiasing is not supported
by the SWT device implementation. |
boolean |
isInhibitLT2RBFlip()
Warning: Inhibit LT2RB Flip is currently not supported by the SWT Device. |
boolean |
isInhibitYFlip()
Warning: Inhibit Y Flip is currently not supported by the SWT Device. |
boolean |
isPrinting()
ATTENTION: if we return the correct value, the text of Label2D is printed at the wrong place - therefore currently always false. |
static org.eclipse.swt.graphics.Font |
lookupSWTFont(org.eclipse.swt.graphics.Device device,
FontFormat fontformat)
Font creation/lookup method. |
static org.eclipse.swt.graphics.Font |
lookupSWTFont(org.eclipse.swt.graphics.Device device,
int size,
int weight,
java.lang.String family,
boolean italic)
Font creation/lookup method. |
void |
setAntialiasing(boolean antialiasing)
Ignored since Antialiasing is not supported by the SWT device implementation. |
void |
setClip(int x,
int y,
int width,
int height)
Sets the current clip to the rectangle specified by the given coordinates. |
void |
setClipBounds(Boundary boundary)
Sets the current clip to the rectangle specified by the given coordinates. |
void |
setFontFormat(FontFormat fontFormat)
Sets the FontFormat that will be used for all
subsequent text drawing operations. |
void |
setFontFormatData(java.lang.Object[] fontFormatData)
Because all formats get pooled, illustrators and users need an easy way to change them. |
void |
setInhibitLT2RBFlip(boolean inhibitLT2RBFlip)
Warning: This method is currently not implemented into the SWT Device. |
void |
setInhibitYFlip(boolean inhibitYFlip)
Warning: This method is currently not implemented into the SWT Device. |
void |
setIsPrinting(boolean isPrinting)
|
void |
setPaintFormat(PaintFormat paintFormat)
Sets the PaintFormat the Device should use
for filling areas. |
void |
setPaintFormatData(java.lang.Object[] paintFormatData)
Sets the PaintFormat rendering data the Device
should use for filling areas.
|
void |
setPaintMode()
Sets the paint mode of this graphics context to overwrite the destination with this graphics context's current color. |
void |
setStrokeFormat(StrokeFormat strokeFormat)
Sets the StrokeFormat the Device should use for
drawing lines or borders around rectangles and polygons. |
void |
setStrokeFormatData(java.lang.Object[] strokeFormatData)
Sets the StrokeFormat rendering data the Device
should use for drawing lines or borders around rectangles and polygons.
|
void |
setTransform(Transform2D xform)
Sets the Transform2D in the Device. |
void |
setXORMode(int xorAlternationColor)
Sets the paint mode of this graphics context to alternate between this graphics context's current color and the new specified color. |
void |
translate(int x,
int y)
This method translates the origin of this devise to the point given by x and y in the actual coordinate of this
device. |
| Methods inherited from class com.tensegrity.graphics.device.AbstractDevice |
getFontFormat, getPaintFormat, getStrokeFormat |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.tensegrity.graphics.device.Device |
getFontFormat, getPaintFormat, getStrokeFormat |
| Field Detail |
public static boolean USE_FONT_CACHING
| Constructor Detail |
protected SWTDeviceNonAWTDependent()
Default constructor. This is set to private in order to force the use of
the
public static method.
This constructor only initializes the internal
SWTDevice.getDevice(org.eclipse.swt.graphics.Device, GC, int, int, int, int).
DeviceStatistics
| Method Detail |
public Device getDevice(org.eclipse.swt.graphics.Device device,
org.eclipse.swt.graphics.GC gc,
int x,
int y,
int width,
int height)
This method creates, initializes and returns a new instance of this
class.
Please note that the method
is called in order to simplify clients code.
Also note that the AWTDevice.initiate() method
will not dispose the passed parameters and it is the caller's
responsability to ensure that the resources it allocated are disposed.
SWTDevice.dispose()
device - the "SWT" Device
associated to the returned SWTDevice.gc - the graphical context for the returned SWTDevicex - the on screen X position of the drawing areay - the on screen Y position of the drawing areawidth - the on screen width of the drawing areaheight - the on screen height of the drawing area
SWTDevice instancepublic void initiate()
DeviceDevice.
initiate in interface Devicepublic void dispose()
Device
since they were not explicitely created by this class but were passed to
getDevice(GC, org.eclipse.swt.graphics.Device)
dispose in interface DeviceDevice.dispose()public void setAntialiasing(boolean antialiasing)
setAntialiasing in interface Deviceantialiasing - true indicates that
anti-aliasing should be enabled, false disables it.Device.setAntialiasing(boolean)public boolean isAntialiasing()
false since Antialiasing is not supported
by the SWT device implementation.
isAntialiasing in interface Devicefalse.Device.isAntialiasing()public void setStrokeFormat(StrokeFormat strokeFormat)
DeviceStrokeFormat the Device should use for
drawing lines or borders around rectangles and polygons. When invoking
this method the StrokeFormat is used instead of the color
value the Device currently uses. If the Device
should use the current color value, this method has to be called with a
null parameter.
setStrokeFormat in interface DevicesetStrokeFormat in class AbstractDevicepublic void setStrokeFormatData(java.lang.Object[] strokeFormatData)
DeviceStrokeFormat rendering data the Device
should use for drawing lines or borders around rectangles and polygons.
When invoking this method the StrokeFormat is used instead of
the color value the Device currently uses. If the
Device should use the current color value, this method has
to be called with a null parameter.
The given array has to consist of three Integer objects.
The meaning of the value is defined by its position in the array. The
following list specifies the valid index positions:
setStrokeFormatData in interface DevicesetStrokeFormatData in class AbstractDeviceDevice.setStrokeFormatData(java.lang.Object[])public void setPaintFormat(PaintFormat paintFormat)
DevicePaintFormat the Device should use
for filling areas. If the current color should be used, this method
has to be called with a null parameter.
setPaintFormat in interface DevicesetPaintFormat in class AbstractDevicepublic void setPaintFormatData(java.lang.Object[] paintFormatData)
DevicePaintFormat rendering data the Device
should use for filling areas.
When invoking this method the PaintFormat is used instead of the
color value the Device> currently uses. If the
Device should use the current color value, this method has
to be called with a null parameter.
Overall eight values of the given array are estimated.
REVIEWJAVADOC: Device.java : what do you mean by "estimated"???
The meaning of each value is defined by its position in the array. The following
table specifies the valid index positions and object types:
| Index | Type |
|---|---|
RenderingData.VALUEINDEX_PAINT_STYLE |
Integer |
RenderingData.VALUEINDEX_PAINT_COLORBACK |
Integer |
RenderingData.VALUEINDEX_PAINT_COLORFORE |
Integer |
RenderingData.VALUEINDEX_PAINT_GRADIENTTYPE |
Integer |
RenderingData.VALUEINDEX_PAINT_PATTERNTYPE |
Integer |
RenderingData.VALUEINDEX_PAINT_TEXTURE |
Texture |
RenderingData.VALUEINDEX_PAINT_TRANSPARENCY |
Integer |
RenderingData.VALUEINDEX_PAINT_TRANSPARENT |
Boolean |
setPaintFormatData in interface DevicesetPaintFormatData in class AbstractDevicepublic final void setFontFormat(FontFormat fontFormat)
DeviceFontFormat that will be used for all
subsequent text drawing operations. When the default color and font
of the Device should be used, the method has to be called
with a null parameter.
setFontFormat in interface DevicesetFontFormat in class AbstractDevicepublic final void setFontFormatData(java.lang.Object[] fontFormatData)
DeviceFontFormat rendering data that will be used for all
subsequent text drawing operations. When the Device
should use the current color value and the default font of the
device, however, this method has to be called with a null parameter.
At this time, four values of the given array are estimated.
REVIEWJAVADOC: There is that word "estimated" again!!!
The meaning
of each value is defined by its position in the array. The following
list specifies the valid index positions and object types:
| Index | Type |
|---|---|
RenderingData.VALUEINDEX_FONT_SIZE |
Integer |
RenderingData.VALUEINDEX_FONT_WEIGHT |
Integer |
RenderingData.VALUEINDEX_FONT_FAMILY |
String |
RenderingData.VALUEINDEX_FONT_ITALIC |
Boolean |
setFontFormatData in interface DevicesetFontFormatData in class AbstractDevice
public void translate(int x,
int y)
Devicex and y in the actual coordinate of this
device. All coordinates in subsequent calls to drawing methods are
assumed to be relative to the new origin.
translate in interface Devicex - the x coordinate of the new originy - the y coordinate of the new originpublic Transform2D getTransform()
DeviceAffineTransform in the
Device.
getTransform in interface DeviceAffineTransform in the
Device.public void setTransform(Transform2D xform)
DeviceTransform2D in the Device.
setTransform in interface Devicexform - the Transform2D object to be used in the
rendering processpublic void setPaintMode()
Device
setPaintMode in interface Devicepublic void setXORMode(int xorAlternationColor)
Device
setXORMode in interface DevicexorAlternationColor - the XOR alternation color
public void setClip(int x,
int y,
int width,
int height)
Device
setClip in interface Devicex - the left coordinate of the new clip rectangley - the top coordinate of the new clip rectanglewidth - the extent of the new clip rectangle in x directionheight - the extent of the new clip rectangle in y direction
public void clipRect(int x,
int y,
int width,
int height)
Device
clipRect in interface Devicex - the x coordinate of the rectangle to intersect the clip withy - the y coordinate of the rectangle to intersect the clip withwidth - the width of the rectangle to intersect the clip withheight - the height of the rectangle to intersect the clip with
public boolean hitClip(int x,
int y,
int width,
int height)
Devicetrue if the specified rectangular area intersects
the bounding rectangle of the current clipping area. The coordinates in
the rectangle are relative to the coordinate system origin of this
graphics context.
hitClip in interface Devicex - the x coordinate of the rectangle to test against the clipy - the y coordinate of the rectangle to test against the clipwidth - the width of the rectangle to test against the clipheight - the height of the rectangle to test against the clip
true if the specified rectangular area intersects
the bounding rectangle of the current clipping area.public Boundary getClipBounds()
Device
getClipBounds in interface Devicepublic Boundary getClipBounds(Boundary boundary)
DeviceDevice.getClipBounds() in that an existing Boundary is
used instead of allocating a new one. This method refers to the user
clip, which is independent of the clipping associated with device bounds
and window visibility. If no clip has previously been set, or if the clip
has been cleared using setClip(null), this method returns
the specified Boundary.
getClipBounds in interface Deviceboundary - the rectangular boundary where the current clipping area
is copied to. Any current values in this rectangle are overwritten.
public void setClipBounds(Boundary boundary)
Device
setClipBounds in interface Deviceboundary - the new bounding rectangle to clip againstpublic void clearClip()
Device
clearClip in interface Device
public void drawLine(int arg0,
int arg1,
int arg2,
int arg3)
Devicex1 and y1 to the ending coordinate given
by x2 and y2.
drawLine in interface Devicearg0 - the starting coordinate x valuearg1 - the starting coordinate y valuearg2 - the ending coordinate x valuearg3 - the ending coordinate y value
public void drawRect(int flags,
int arg0,
int arg1,
int arg2,
int arg3)
Devicex and y. The right
coordinates are calculated by x + width and the bottom
coordinates are calculated by y + height.
drawRect in interface Deviceflags - bitwise combined flags that determine what to draw.arg0 - the left coordinate of the rectangle.arg1 - the top coordinate of the rectangle.arg2 - the extent in x direction.arg3 - the extent in y direction.
public void clearRect(int x,
int y,
int width,
int height)
Device
clearRect in interface Devicex - the x coordinate of the rectangle to be cleary - the y coordinate of the rectangle to be clearwidth - the width of the rectangle to be clearheight - the height of the rectangle to be clear
public void drawRoundRect(int flags,
int x1,
int y1,
int width1,
int height1,
int arcWidth1,
int arcHeight1)
DeviceStroke- and PaintFormat. The
left and right edges of the rectangle are at x and
x + width, respectively. The top and bottom edges of the
rectangle are at y and y + height.
drawRoundRect in interface Deviceflags - bitwise combined flags that determine what to drawx1 - the x coordinate of the rectangle to be drawny1 - the y coordinate of the rectangle to be drawnwidth1 - the width of the rectangle to be drawnheight1 - the height of the rectangle to be drawnarcWidth1 - the horizontal diameter of the arc at the four cornersarcHeight1 - the vertical diameter of the arc at the four corners
public void drawOval(int flags,
int arg0,
int arg1,
int arg2,
int arg3)
Device
drawOval in interface Deviceflags - bitwise combined flags that determine what to drawarg0 - the x coordinate of the upper left corner of the oval to be
drawnarg1 - the y coordinate of the upper left corner of the oval to be
drawnarg2 - the width of the oval to be drawnarg3 - the height of the oval to be drawn
public void drawArc(int flags,
int arg0,
int arg1,
int arg2,
int arg3,
int startAngle,
int arcAngle)
DevicestartAngle and extends for
arcAngle degrees, using the current color of the
Device. Angles are interpreted in such a manner that a
degree of 0 belongs to 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. The angles are specified relative to the non-square
extents of the bounding rectangle such that 45 degrees always falls
on the line from the center of the ellipse to the upper right corner
of the bounding rectangle. As a result, if the bounding rectangle is
noticeably longer in one axis than the other, the angles to the
start and end of the arc segment will be skewed farther along the
longer axis of the bounds.
drawArc in interface Deviceflags - bitwise combined flags that determine what to drawarg0 - the x coordinate of the upper-left corner of the arc to be
drawnarg1 - the y coordinate of the upper-left corner of the arc to be
drawnarg2 - the width of the arc to be drawnarg3 - the height of the arc to be drawnstartAngle - the beginning anglearcAngle - the angular extent of the arc, relative to the start
angle
public void drawPolyline(int[] ptX1,
int[] ptY1,
int ptCount)
Device
drawPolyline in interface DeviceptX1 - the x coordinates of the pointsptY1 - the y coordinates of the pointsptCount - the amount of points the polygon consist of
public void drawPolygon(int flags,
int[] ptX1,
int[] ptY1,
int ptCount)
Device
drawPolygon in interface Deviceflags - bitwise combined flags that determine what to drawptX1 - the x coordinates of the pointsptY1 - the y coordinates of the pointsptCount - the amount of points the polygon consist of
public void drawString(java.lang.String str,
int cx,
int cy)
Device
drawString in interface Devicestr - the string to be drawncx - the x coordinatecy - the y coordinatepublic void setIsPrinting(boolean isPrinting)
setIsPrinting in interface Devicepublic boolean isPrinting()
false.
isPrinting in interface Devicefalse.Device.isPrinting()public void setInhibitLT2RBFlip(boolean inhibitLT2RBFlip)
setInhibitLT2RBFlip in interface DeviceinhibitLT2RBFlip - true in order to Inhibit LT2RB Flip, false otherwise.Device.setInhibitLT2RBFlip(boolean)public boolean isInhibitLT2RBFlip()
isInhibitLT2RBFlip in interface Devicefalse.Device.isInhibitLT2RBFlip()public void setInhibitYFlip(boolean inhibitYFlip)
setInhibitYFlip in interface DeviceinhibitYFlip - true in order to Inhibit Y Flip, false otherwise.Device.setInhibitYFlip(boolean)public boolean isInhibitYFlip()
isInhibitYFlip in interface Devicefalse.Device.isInhibitYFlip()
protected void finalize()
throws java.lang.Throwable
dispose()
method. However one should not rely on this and instead ensure that the
dispose() method is automatically called.
java.lang.ThrowableObject.finalize()public void debugColor(int color)
Simple Debug utility method which prints out the Red, Green and Blue
values of the passed color.
color - the color (as int) to print out
public static int[] convertIntArrays(int[] ptX,
int[] ptY,
int ptCount)
Utility method creating an array of alternating x and y values, with the
x values contained into ptX and the y values in ptY.
The returned array of integers has a size of ptCount* 2.
ptX - array representing x values.ptY - array representing y values.ptCount - the size of ptX and ptY.
ptX and
ptY.
public static int[] convertIntArrays(int[] ptX,
int[] ptY,
int ptCount,
int xOffset,
int yOffset,
float scaleX,
float scaleY)
Utility method creating an array of alternating x and y values, with the
x values contained into ptX and the y values in ptY.
The returned array of integers has a size of ptCount* 2.
ptX - array representing x values.ptY - array representing y values.ptCount - the size of ptX and ptY.xOffset - an offset on the x-axis for (0,0)-based values.yOffset - an offset on the y-axis for (0,0)-based values.
ptX and
ptY.
public static int[] convertIntArrays(int[] ptX,
int[] ptY,
int ptCount,
int xOffset,
int yOffset)
Utility method creating an array of alternating x and y values, with the
x values contained into ptX and the y values in
ptY. The returned array of integers has a size of
ptCount* 2.
ptX - array representing x valuesptY - array representing y valuesptCount - the size of ptX and ptYxOffset - an offset on the x-axis for (0,0)-based valuesyOffset - an offset on the y-axis for (0,0)-based values
ptX and
ptY.public final DeviceStatistics getDeviceStatistics()
null if statistics
are disabled.
public static final org.eclipse.swt.graphics.Font lookupSWTFont(org.eclipse.swt.graphics.Device device,
FontFormat fontformat)
device - the SWT device. Can be null if there is a current device.fontformat - the fontformat to lookup or create.
public static final org.eclipse.swt.graphics.Font lookupSWTFont(org.eclipse.swt.graphics.Device device,
int size,
int weight,
java.lang.String family,
boolean italic)
device - the SWT device. Can be null if there is a current device.size - size of the font to lookup.weight - weight of the font to lookup.family - the font family.italic - whether the font is italic or plain.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||