JLogView_.utils
Class LGDrawingStylesUtils

java.lang.Object
  extended by JLogView_.utils.LGDrawingStylesUtils

public class LGDrawingStylesUtils
extends java.lang.Object

LGDrawingStyleUtils is a class that contains all sorts of useful static methods. It is static so that you can call the methods from anywhere without having to instantiate the object. All the methods are to do with the personalisation of drawing, colours, line styles, symbols for data points. Saving and loading personalised styles.


Field Summary
static float[][] available_strokes
          This is the fixed set of 8 available line styles (aka strokes), the personalised styles just mix and match within 8 colours, 8 strokes and 8 symbols
static java.awt.Color[] colours_available
          This is the fixed set of 8 available colours, the personalised styles just mix and match within 8 colours, 8 strokes and 8 symbols
 
Constructor Summary
LGDrawingStylesUtils()
           
 
Method Summary
static void drawSymbol(java.awt.Graphics2D g, int symbstyle, int x, int y, int size)
          This methods draw the requested symbol on a graphics context, with the specified size in pixels and at the given coordinates (in pixels as well).
static java.awt.BasicStroke getBasicStroke(int i)
          This methods gives the array representing the line style (aka stroke) of the personalised drawing style at the given index.
static java.awt.Color getColour(int i)
          This methods gives the Color object representing the colour of the personalised drawing style at the given index
static java.awt.Color getColour(java.lang.String colname)
          given a colour name, this methods returns the appropriate Color object that correspond to it
static int getColourIndex(java.awt.Color c)
          Given a Color object this methods tells you at which index in the array of the 8 available colours this colour is.
static int getColourIndex(int ind)
          Given an index from the array of personalised colours, this methods tells you which index in the array of the 8 available colours this colour corresponds to.
static int getNStyles()
          This methods tells how many personalised drawing styles there are.
static float[] getStroke(int i)
          This methods gives the array representing the line style (aka stroke) of the personalised drawing style at the given index.
static int getStrokeIndex(int ind)
          Given an index from the array of personalised strokes, this methods tells you which index in the array of the 8 available strokes this stroke corresponds to.
static int getStrokeWidth(int i)
          This methods gives the line width in pixels representing the line style (aka stroke) of the drawing style at the given index
static int getSymbol(int i)
          This methods gives the type (between 0 and 7) of symbol used for the personalised drawing style at the given index.
static int getSymbolSize(int i)
          This methods gives the size of symbol used for the personalised drawing style at the given index.
static void loadDrawingStyles()
          This methods initialises the personalised drawing styles.
static void saveDrawingStyles()
          This methods saves the personalised drawing styles in an file called 'JLogView_.prefs' situated in $CCP4I_TOP/JLogView_ all details are saved in this file as binary information for two reasons,1) it is much smaller, 2) user can not mess it up
static void setDrawingParameters(java.awt.Color[] cols, float[][] lines, int[] widths, int[] symbs, int[] sizes)
          This methods sets all the parameteres of the personalised drawing styles.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

colours_available

public static java.awt.Color[] colours_available
This is the fixed set of 8 available colours, the personalised styles just mix and match within 8 colours, 8 strokes and 8 symbols


available_strokes

public static float[][] available_strokes
This is the fixed set of 8 available line styles (aka strokes), the personalised styles just mix and match within 8 colours, 8 strokes and 8 symbols

Constructor Detail

LGDrawingStylesUtils

public LGDrawingStylesUtils()
Method Detail

setDrawingParameters

public static void setDrawingParameters(java.awt.Color[] cols,
                                        float[][] lines,
                                        int[] widths,
                                        int[] symbs,
                                        int[] sizes)
This methods sets all the parameteres of the personalised drawing styles.

Parameters:
cols - an array of Color, representing the colour for each drawing style
lines - an 2-dimension array of float, each entry is an array representing the line pattern for each drawing style
widths - an array of integer giving the line width in pixels of each drawing style
symbs - an array of integer giving the symbol type for each drawing style.
sizes - an array of integer giving the symbol size in pixels for each drawing style.
See Also:
Color

getNStyles

public static int getNStyles()
This methods tells how many personalised drawing styles there are. NB: this is never less than 8.

Returns:
the number of personalised drawing styles.

getColourIndex

public static int getColourIndex(int ind)
Given an index from the array of personalised colours, this methods tells you which index in the array of the 8 available colours this colour corresponds to.

Parameters:
ind - an integer representing the index in the personalised colour array.
Returns:
the index of the personalised colour in the array of available colour.

getColourIndex

public static int getColourIndex(java.awt.Color c)
Given a Color object this methods tells you at which index in the array of the 8 available colours this colour is.

Parameters:
c - a Color object.
Returns:
the index of c in the array of available colour.
See Also:
Color

getStrokeIndex

public static int getStrokeIndex(int ind)
Given an index from the array of personalised strokes, this methods tells you which index in the array of the 8 available strokes this stroke corresponds to.

Parameters:
ind - an integer representing the index in the personalised stroke array.
Returns:
the index of the personalised stroke in the array of available strokes.

getColour

public static java.awt.Color getColour(int i)
This methods gives the Color object representing the colour of the personalised drawing style at the given index

Parameters:
i - the index of the personalised drawing style
Returns:
a Color object representing that personalised colour
See Also:
Color

getStroke

public static float[] getStroke(int i)
This methods gives the array representing the line style (aka stroke) of the personalised drawing style at the given index.

Parameters:
i - the index of the personalised drawing style
Returns:
a an array of float representing the line pattern of this stroke

getStrokeWidth

public static int getStrokeWidth(int i)
This methods gives the line width in pixels representing the line style (aka stroke) of the drawing style at the given index

Parameters:
i - the index of the personalised drawing style
Returns:
the width in pixels of this stroke

getSymbol

public static int getSymbol(int i)
This methods gives the type (between 0 and 7) of symbol used for the personalised drawing style at the given index.

Parameters:
i - the index of the personalised drawing style
Returns:
the type, an integer between 0 and 7, of this symbol

getSymbolSize

public static int getSymbolSize(int i)
This methods gives the size of symbol used for the personalised drawing style at the given index.

Parameters:
i - the index of the personalised drawing style
Returns:
the size in pixels of this symbol

getBasicStroke

public static java.awt.BasicStroke getBasicStroke(int i)
This methods gives the array representing the line style (aka stroke) of the personalised drawing style at the given index.

Parameters:
i - the index of the personalised drawing style
Returns:
a an array of float representing the line pattern of this stroke

getColour

public static java.awt.Color getColour(java.lang.String colname)
given a colour name, this methods returns the appropriate Color object that correspond to it

Parameters:
colname - a String representing the colour name
Returns:
the Color object representing that colour
See Also:
Color

drawSymbol

public static void drawSymbol(java.awt.Graphics2D g,
                              int symbstyle,
                              int x,
                              int y,
                              int size)
This methods draw the requested symbol on a graphics context, with the specified size in pixels and at the given coordinates (in pixels as well). the different symbol types are as follow.

loadDrawingStyles

public static void loadDrawingStyles()
This methods initialises the personalised drawing styles. It firstly looks for an existing saved file containing the informations of personalised styles or load default parameters if this file do not exist.


saveDrawingStyles

public static void saveDrawingStyles()
This methods saves the personalised drawing styles in an file called 'JLogView_.prefs' situated in $CCP4I_TOP/JLogView_ all details are saved in this file as binary information for two reasons,1) it is much smaller, 2) user can not mess it up