GeoSoft API

no.geosoft.cc.graphics
Class GStyle

Object
  extended byGStyle
All Implemented Interfaces:
Cloneable

public class GStyle
extends Object
implements Cloneable

Graphics object apparence properties.

GStyle can be set on GObject, GSegment and GPositionals (GText, GImage, GComponent). It is optional, and when unset the style of the parent component is applied. This is also the case for the individual properties of the GStyle.

Example:

   // Define a style with foreground and background color set
   GStyle style1 = new GStyle();
   style1.setForegroundColor (Color.RED);
   style1.setBackgroundColor (Color.BLUE);

   // Create an object and apply style1.
   // It will have foreground color RED and background color BLUE
   GObject object1 = new GObject();
   object1.setStyle (style1);

   // Create a sub object without style. style1 is inherited from parent
   // It will have foreground color RED and background color BLUE
   GObject object2 = new GObject();
   object1.add (object2);

   // Define new style with foreground color set
   GStyle style2 = new GStyle()
   style2.setForegroundColor (Color.YELLOW);

   // Create a sub object and apply style2.
   // It will have foreground color YELLOW and background color BLUE
   GObject object3 = new GObject();
   object3.setStyle (style2);
   object1.add (object3);
 

Author:
GeoSoft

Field Summary
static int FILL_10
           
static int FILL_25
           
static int FILL_50
           
static int FILL_75
           
static int FILL_DIAGONAL
           
static int FILL_HORIZONTAL
           
static int FILL_NONE
           
static int FILL_SOLID
           
static int FILL_VERTICAL
           
static int LINESTYLE_DASHDOT
           
static int LINESTYLE_DASHED
           
static int LINESTYLE_DOTTED
           
static int LINESTYLE_INVISIBLE
           
static int LINESTYLE_SOLID
           
 
Constructor Summary
GStyle()
          Create a new style object.
 
Method Summary
 Object clone()
          Create a new style object based on this.
 Color getBackgroundColor()
          Return current background color of this style.
 int getCapStyle()
          Return current line end cap style of this style.
 BufferedImage getFillPattern()
          Return current fill pattern.
 Font getFont()
          Return current font of this style.
 Color getForegroundColor()
          Return the current foreground color of this style.
 int getJoinStyle()
          Return current join style of this style.
 float[] getLineStyle()
          Return current line style of this style.
 int getLineWidth()
          Return current line width of this style.
 boolean isAntialiased()
          Return current antialiasing setting of this style.
 void setAntialiased(boolean isAntialiased)
          Set antialising flag of this style.
 void setBackgroundColor(Color backgroundColor)
          Set background color.
 void setCapStyle(int capStyle)
          Set line end cap style of this style.
 void setFillPattern(BufferedImage image)
          Set image as fill pattern.
 void setFillPattern(int fillType)
          Set predefined fill pattern of this style.
 void setFillPattern(int width, int height, int[] data)
          Set custom fill pattern of this style.
 void setFillPattern(String fileName)
          Set image as fill pattern.
 void setFont(Font font)
          Set font of this style.
 void setForegroundColor(Color foregroundColor)
          Set foreground color of this style.
 void setGradient(Color color1, Color color2)
          TODO: This code is experimental and should not yet be used.
 void setJoinStyle(int joinStyle)
          Set line end join style of this style.
 void setLineStyle(float[] dashPattern)
          Set custom line style.
 void setLineStyle(int lineStyle)
          Set predefined line style of this style.
 void setLineWidth(int lineWidth)
          Set line width.
 void unsetAntialias()
          Unset antialias flag.
 void unsetBackgroundColor()
          Unset background color.
 void unsetCapStyle()
          Unset cap style of this style.
 void unsetFillPattern()
          Unset fill pattern.
 void unsetFont()
          Unset font of this style.
 void unsetForegroundColor()
          Unset foreground color of this style.
 void unsetGradient()
           
 void unsetJoinStyle()
          Unset join style of this style.
 void unsetLineStyle()
          Unset line style.
 void unsetLineWidth()
          Unset line width.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LINESTYLE_SOLID

public static final int LINESTYLE_SOLID
See Also:
Constant Field Values

LINESTYLE_DASHED

public static final int LINESTYLE_DASHED
See Also:
Constant Field Values

LINESTYLE_DOTTED

public static final int LINESTYLE_DOTTED
See Also:
Constant Field Values

LINESTYLE_DASHDOT

public static final int LINESTYLE_DASHDOT
See Also:
Constant Field Values

LINESTYLE_INVISIBLE

public static final int LINESTYLE_INVISIBLE
See Also:
Constant Field Values

FILL_NONE

public static final int FILL_NONE
See Also:
Constant Field Values

FILL_SOLID

public static final int FILL_SOLID
See Also:
Constant Field Values

FILL_10

public static final int FILL_10
See Also:
Constant Field Values

FILL_25

public static final int FILL_25
See Also:
Constant Field Values

FILL_50

public static final int FILL_50
See Also:
Constant Field Values

FILL_75

public static final int FILL_75
See Also:
Constant Field Values

FILL_HORIZONTAL

public static final int FILL_HORIZONTAL
See Also:
Constant Field Values

FILL_VERTICAL

public static final int FILL_VERTICAL
See Also:
Constant Field Values

FILL_DIAGONAL

public static final int FILL_DIAGONAL
See Also:
Constant Field Values
Constructor Detail

GStyle

public GStyle()
Create a new style object. The style is initially empty, individual settings are only valid if explicitly set.

Method Detail

clone

public Object clone()
Create a new style object based on this.

Returns:
Clone of this style object.

setForegroundColor

public void setForegroundColor(Color foregroundColor)
Set foreground color of this style.

Parameters:
foregroundColor - New foreground color.

unsetForegroundColor

public void unsetForegroundColor()
Unset foreground color of this style.


getForegroundColor

public Color getForegroundColor()
Return the current foreground color of this style. The element is not in use if it is invalid.

Returns:
Current foreground color.

setBackgroundColor

public void setBackgroundColor(Color backgroundColor)
Set background color.

Parameters:
backgroundColor - New background color.

unsetBackgroundColor

public void unsetBackgroundColor()
Unset background color.


getBackgroundColor

public Color getBackgroundColor()
Return current background color of this style. The element is not in use if it is invalid.

Returns:
Current background color of this style.

setLineWidth

public void setLineWidth(int lineWidth)
Set line width.

Parameters:
lineWidth - New line width.

unsetLineWidth

public void unsetLineWidth()
Unset line width.


getLineWidth

public int getLineWidth()
Return current line width of this style. The element is not in use if it is invalid.

Returns:
Current line width of this style.

setFont

public void setFont(Font font)
Set font of this style.

Parameters:
font - New font.

unsetFont

public void unsetFont()
Unset font of this style.


getFont

public Font getFont()
Return current font of this style. The element is not in use if it is invalid.

Returns:
Current font of this style.

setCapStyle

public void setCapStyle(int capStyle)
Set line end cap style of this style. One of BasicStroke.CAP_ROUND (default), BasicStroke.CAP_BUTT, or BasicStroke.CAP_SQUARE.

Parameters:
capStyle - New line end cap style.

unsetCapStyle

public void unsetCapStyle()
Unset cap style of this style.


getCapStyle

public int getCapStyle()
Return current line end cap style of this style. The element is not in use if it is invalid.

Returns:
Current line end cap style of this style.

setJoinStyle

public void setJoinStyle(int joinStyle)
Set line end join style of this style. One of BasicStroke.JOIN_BEVEL, BasicStroke.JOIN_MITTER or BasicStroke.JOIN_ROUND (default).

Parameters:
joinStyle - New join style.

unsetJoinStyle

public void unsetJoinStyle()
Unset join style of this style.


getJoinStyle

public int getJoinStyle()
Return current join style of this style. The element is not in use if it is invalid.

Returns:
Current join style of this style.

setAntialiased

public void setAntialiased(boolean isAntialiased)
Set antialising flag of this style.

Parameters:
isAntialiased - Antialiasing on (true) or off (false) (default).

unsetAntialias

public void unsetAntialias()
Unset antialias flag.


isAntialiased

public boolean isAntialiased()
Return current antialiasing setting of this style. The element is not in use if it is invalid.

Returns:
True if antialiasing on, false otherwise.

setGradient

public void setGradient(Color color1,
                        Color color2)
TODO: This code is experimental and should not yet be used.

Parameters:
color1 -
color2 -

unsetGradient

public void unsetGradient()

setFillPattern

public void setFillPattern(int fillType)
Set predefined fill pattern of this style.

Parameters:
fillType - New fill pattern.

setFillPattern

public void setFillPattern(int width,
                           int height,
                           int[] data)
Set custom fill pattern of this style.

Parameters:
width - Tile width.
height - Tile height.
data - Pattern data (0s and 1s indicating set/unset).

setFillPattern

public void setFillPattern(BufferedImage image)
Set image as fill pattern.

Parameters:
image - Image to use as fill pattern.

setFillPattern

public void setFillPattern(String fileName)
Set image as fill pattern. TODO: Cache the file name and create the image lazy

Parameters:
fileName - File name of image.

unsetFillPattern

public void unsetFillPattern()
Unset fill pattern.


getFillPattern

public BufferedImage getFillPattern()
Return current fill pattern.

Returns:
Current fill pattern.

setLineStyle

public void setLineStyle(float[] dashPattern)
Set custom line style. Dash pattern consists of and array of leg lengths of line on and line off respectively.

Parameters:
dashPattern - New dash pattern.

setLineStyle

public void setLineStyle(int lineStyle)
Set predefined line style of this style.

Parameters:
lineStyle - New line style.

unsetLineStyle

public void unsetLineStyle()
Unset line style.


getLineStyle

public float[] getLineStyle()
Return current line style of this style. The element is not in use if it is invalid.

Returns:
Current line style of this style.

GeoSoft API

Copyright © 2004 - Geotechnical Software Services     geosoft.no