Decorators - greipadmin/greip GitHub Wiki
Intoduction
Decorators are graphical components to visualize data or images. Decorators are used by Greip widgets (e.g. Picture, Tile). You can also use all decorators for your own widgets.
IDecorator
IDecorator is the interface that is used by controls to paint decorators. All decorators must implement this interface. The base implementation is AbstractDecorator
.
Methods
void doPaint(GC gc, int x, int y)
, paints the decorator to the specified GC.Point getSize()
, returns the size of the decorator
AbstractDecorator
AbstractDecorator is the base implementation of the IDecorator
interface. All decorator implementations are subclasses of this abstract class.
Constructors
AbstractDecorator(Control parent)
parent
the parent control to paint the decorator
Methods
void dispose()
, is called when the parent control is disposedDisplay getDisplay()
, returns the display of the parent controlControl getParent()
, returns the parent controlvoid redraw()
, force decorator paintig by redrawing the parent control
ImageDecorator
Paint an image to the parent control. Supports all image formats supported by ImageLoader
plus animated GIFs.
Methods
void loadImage(InputStream stream)
, loads an image from input streamvoid loadImage(String filename)
, loads an image from the filevoid setImage(Image image)
, sets an imagevoid scaleTo(final Point scaleTo)
, scales the image to the defined size
PercentageDecorator
Displays an percentage value as animated graphic.
Methods
void setCircleBackground(Color color)
, defines the circle background colorvoid setCircleForeground(Color color)
, defines the circle foreground colorvoid setCircleType(CircleType type)
, defines the type of the circlevoid setFont(final Font font)
, sets the text fontvoid setForeground(final Color color)
, sets the foreground (text) colorvoid setInnerDiameter(int innerDiameter)
, sets the inner diameter in pixelsvoid setMaxValue(int maxValue)
, sets the maximum number (equal to 100 percent)void setMinValue(int minValue)
, sets the minimum number (equal to zero percent)void setNumberFormat(NumberFormat format)
, sets the format for number formattingvoid setOuterDiameter(int outerDiameter)
, sets the outer diameter in pixelsvoid setShowAnimation(boolean animate)
, enables or disables the animationvoid setTreshholdColors(Map<Integer, Color> treshholdMap)
, defines color treshholdsvoid setUnit(String text)
, sets the unit textvoid setUnitAlignment(int alignment)
, sets the alignment of the unitvoid setUnitFont(Font font)
, sets the font to paint the unit textvoid setValue(int value)
, sets the displayed value
You can also use all related getters.
ShapeDecorator
Displays an absolute number value as animated graphic.
Methods
void setBackground(Color color)
, defines the shape colorvoid setCornerArc(int arcWidth, int arcHeight)
, defines how the corners of the figure should be rounded offvoid setFont(final Font font)
, sets the text fontvoid setForeground(final Color color)
, sets the foreground (text) colorvoid setLineWidth(int width)
, defines the line width with which the shape is drawnvoid setNumberFormat(NumberFormat format)
, sets the format for number formattingvoid setShapeSize(int width, int height)
, defines the size of the shapevoid setShowAnimation(boolean animate)
, enables or disables the animationvoid setTreshholdColors(Map<Integer, Color> treshholdMap)
, defines color treshholdsvoid setUnit(String text)
, sets the unit textvoid setUnitAlignment(int alignment)
, sets the alignment of the unitvoid setUnitFont(Font font)
, sets the font to paint the unit textvoid setValue(int value)
, sets the displayed value
You can also use all related getters.
Examples
- Sample1 shows the display of an animated GIF using the
ImageDecorator
. - Sample2 shows the use of an
ShapeDecorator
. The shape is configured as a circle. - Sample3 shows the use of an
ShapeDecorator
to display a formatted date. The shape is configured to paint a rectangle with rounded corners. - Sample4 shows the use of a
PercentageDecorator
.