uk.ac.starlink.ast.grf
Class GrfEscape

java.lang.Object
  extended by uk.ac.starlink.ast.grf.GrfEscape

public class GrfEscape
extends Object

Represents a Grf escape sequence. Each GrfEscape instance has a type code and an associated integer value. The meaning of the sequence is determined by the type code, and sometimes the value integer. The known escape codes are defined as static final integer members of this class - the definitions below document the textual meaning of these and what, if anything, the value means.

This class also contains static methods for locating escape sequences and global control of how AST handles them in text strings.

Author:
Mark Taylor (Starlink)
See Also:
Grf.cap(int, int)

Field Summary
static int GRF__ESBAC
          Code for a backwards space before drawing the next characters.
static int GRF__ESCOL
          Code for a change in colour.
static int GRF__ESFON
          Code for a change in font.
static int GRF__ESGAP
          Code for a horizontal gap before drawing the next characters.
static int GRF__ESPER
          Code for a literal percent sign.
static int GRF__ESPOP
          Code for popping the current graphics attribute values from the stack.
static int GRF__ESPSH
          Code for pushing the current graphics attribute values onto the stack.
static int GRF__ESSIZ
          Code for a change in character size.
static int GRF__ESSTY
          Code for a change in style.
static int GRF__ESSUB
          Code for subscripted text.
static int GRF__ESSUP
          Code for superscripted text.
static int GRF__ESWID
          Code for a change in character width.
 
Constructor Summary
GrfEscape(int code, int value)
          Constructs a new escape object.
 
Method Summary
 boolean equals(Object o)
           
static Object[] findEscapes(String text)
          Parses a string into a set of blocks each representing text or an escape code.
 int getCode()
          Returns the symbolic graphics code representing the type of this escape object.
static boolean getEscapes()
          Indicates whether escape sequences will be stripped out of strings returned by AstObject methods.
 String getText()
          Returns the textual representation of this escape sequence.
 int getValue()
          Returns the integer value associated with this escape object.
 int hashCode()
           
static void setEscapes(boolean escapes)
          Determines whether escape sequences should be stripped out of strings returned by AstObject methods.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

GRF__ESPER

public static final int GRF__ESPER
Code for a literal percent sign.

value is ignored.

Textual representation is "%%".


GRF__ESSUP

public static final int GRF__ESSUP
Code for superscripted text.

value gives the distance from the base-line of "normal" text to the base-line of the superscripted text, scaled so a value of 100 corresponds to the height of normal text. A value of -1 means draw subsequent characters with the normal baseline.

Textual representation is "%^value+", or "%^+" for value=-1.


GRF__ESSUB

public static final int GRF__ESSUB
Code for subscripted text.

value gives the distance from the base-line of "normal" text to the base-line of the subscripted text, scaled so that a value of 100 corresponds to the height of normal text. A value of -1 means draw subsequent characters with the normal baseline.

Textual representation is "%vvalue+", or "%v+" for value=-1.


GRF__ESGAP

public static final int GRF__ESGAP
Code for a horizontal gap before drawing the next characters.

value gives the size of the movement, scaled so that a value of 100 corresponds to the height(?) of normal text.

Textual representation is "%>value+".


GRF__ESBAC

public static final int GRF__ESBAC
Code for a backwards space before drawing the next characters.

value gives the size of the movement, scaled so that a value of 100 corresponds to the height(?) of normal text.

Textual representation is "%<value+".


GRF__ESSIZ

public static final int GRF__ESSIZ
Code for a change in character size.

value gives the new size as a fraction of "normal" size, scaled so a value of 100 corresponds to 1.0. A value of -1 means draw subsequent characters at the normal size.

Textual representation is "%svalue+", or "%s+" for value=-1.


GRF__ESWID

public static final int GRF__ESWID
Code for a change in character width.

value gives the new width as a fraction of "normal" width, scaled so a value of 100 corresponds to 1.0. A value of -1 means draw subsequent characters at the normal width.

Textual representation is "%wvalue+", or "%w+" for value=-1.


GRF__ESFON

public static final int GRF__ESFON
Code for a change in font.

value gives the new font value. A value of -1 means reset the font attribute to its normal value.

Textual representation is "%fvalue+", or "%f+" for value=-1.


GRF__ESCOL

public static final int GRF__ESCOL
Code for a change in colour.

value gives the new colour value. A value of -1 means reset the font attribute to its normal value.

Textual representation is "%cvalue+", or "%c+" for value=-1.


GRF__ESSTY

public static final int GRF__ESSTY
Code for a change in style.

value gives the new style value. A value of -1 means reset the styel attribute to its normal value.

Textual representation is "%tvalue+", or "%t+" for value=-1.


GRF__ESPOP

public static final int GRF__ESPOP
Code for popping the current graphics attribute values from the stack.

value is ignored.

Textual representation is "%-".


GRF__ESPSH

public static final int GRF__ESPSH
Code for pushing the current graphics attribute values onto the stack.

value is ignored.

Textual representation is "%+".

Constructor Detail

GrfEscape

public GrfEscape(int code,
                 int value)
Constructs a new escape object.

Parameters:
code - symbolic graphics code (one of the GRF__ES* constants)
value - associated numeric value (meaning is dependent on the value of code)
Method Detail

getCode

public int getCode()
Returns the symbolic graphics code representing the type of this escape object.

Returns:
one of the GRF__* values

getValue

public int getValue()
Returns the integer value associated with this escape object.

Returns:
value (meaning is dependent on code).

getText

public String getText()
Returns the textual representation of this escape sequence. This starts with a "%" sign.

Returns:
text string for this escape sequence

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

setEscapes

public static void setEscapes(boolean escapes)
Determines whether escape sequences should be stripped out of strings returned by AstObject methods. Plot defines a set of escape sequences which can be included within a text string to control the appearance of substrings in the text. It is usually inappropriate for object methods to return strings containing such escape sequences when called by application code. For instance, an application which displays the value of the Title attribute of a Frame usually does not want the displayed string to include escape sequences which a human would have difficulty interpreting. Therefore the default behaviour is to strip out such escape sequences when called by application code.

Parameters:
escapes - true iff you want get* methods to include escape sequences
See Also:
Plot.setEscape(boolean)

getEscapes

public static boolean getEscapes()
Indicates whether escape sequences will be stripped out of strings returned by AstObject methods. Plot defines a set of escape sequences which can be included within a text string to constrol the appearance of substrings in the text. It is usually inappropriate for object methods to return strings containing such escape sequences when called by application code. For instance, an application which displays the value of the Title attribute of a Frame usually does not want the displayed string to include escape sequences which a human would have difficulty interpreting. Therefore the default behaviour is to strip out such escape sequences when called by application code.

Returns:
true iff get* methods will include escape sequences
See Also:
Plot.setEscape(boolean)

findEscapes

public static Object[] findEscapes(String text)
Parses a string into a set of blocks each representing text or an escape code. The returned value is an array of objects each element of which is either a GrfEscape or a String.

Parameters:
text - string to analyse
Returns:
array of GrfEscape and String objects representing the parsed value of text


Copyright © 2017 Central Laboratory of the Research Councils. All Rights Reserved.