gcspy.interpreter
Class Stream

java.lang.Object
  extended by gcspy.interpreter.Stream

public class Stream
extends java.lang.Object

Represents a stream

Author:
Tony Printezis

Field Summary
static int BYTE_TYPE
          Data type is byte
static int INT_TYPE
          Data type is int
static int PAINT_STYLE_PLAIN
          Plain paint style
static int PAINT_STYLE_ZERO
          Present zeor values specially (by showing them as light frames)
static int PRESENTATION_ENUM
          Select presentation from enumNames
static int PRESENTATION_MAX_VAR
          Maximum value calclated by iterating over the stream
static int PRESENTATION_PERCENT
          Present as a percentage of a fixed maximum
static int PRESENTATION_PERCENT_VAR
          Present as a percentage but use the value of the corresponding tile in stream maxStreamIndex for its maximum
static int PRESENTATION_PLAIN
          Present a tiles as is
static int PRESENTATION_PLUS
          Present a tile as maximum+ if its value exceeds the maximum for the stream
static int SHORT_TYPE
          Data type is short
 
Constructor Summary
Stream()
           
Stream(java.lang.String name, int dataType, int minValue, int maxValue, int zeroValue, int defaultValue, java.lang.String stringPre, java.lang.String stringPost, int presentation, int paintStyle, int maxStreamIndex, java.awt.Color color, java.lang.String[] enumNames)
          Create a new stream
Stream(java.lang.String name, int dataType, int minValue, int maxValue, int zeroValue, int defaultValue, java.lang.String stringPre, java.lang.String stringPost, int presentation, int paintStyle, int maxStreamIndex, java.awt.Color color, java.lang.String[] enumNames, int tileNum)
          Create a new stream
 
Method Summary
 int adjustValue(int val)
          Adjust a tile value according to the stream's presentation style.
 void calcMaxIfNecessary()
          Calculate the maximum value found in this stream if its presentation style is PRESENTATION_MAX_VAR
 void deserialise(BufferedInput input)
          Deserialise the stream
 void dump()
           
 DataAccessor getAccessor()
          Get the data accessor for this stream
 byte[] getByteData()
          Get the data for this stream (assumed to be bytes)
 java.awt.Color getColor()
          Get the colour used for this stream
 java.lang.Object getData()
          Get the data for this stream
 int getDataType()
          Get the type of this stream
 int getDefaultValue()
          Get the default value for this stream
 int[] getIntData()
          Get the data for this stream (assumed to be ints)
 int getMaxValue()
          Get the maximum value for this stream
 int getMaxValue(int i)
          Get the maximum value for a tile (neede for the PRESENTATION_PERCENT_VAR style.
 int getMinValue()
          Get the minimum value for this stream
 java.lang.String getName()
          Get the name of this stream
 int getPaintStyle()
          Get the paint style for this stream
 java.lang.String getPrefix()
          Get the the prefix string for tiles in this stream (e.g.
 int getPresentation()
          Get the presentation style for this stream
 short[] getShortData()
          Get the data for this stream (assumed to be shorts)
 java.lang.String getSuffix()
          Get the suffix string for tiles in this stream (e.g.
 int[] getSummary()
          Get the summary value(s) for this stream
 int getZeroValue()
          Get the zero value for this stream
 boolean isOverflow(int val)
          Does a tile value zero exceed the maximum
 boolean isZero(int val)
          Is a tile value zero
 java.lang.String presentData(int i)
          Present a tile value as a string
 java.lang.String presentDataSmall(int val)
          Present a tile value as a short string
 java.lang.String presentFullSummary(java.lang.String prefix1, java.lang.String prefix2)
          Present a full summary
 void reset()
          Reset the data values to their defaults
 void serialise(BufferedOutput output)
          Serialise the stream
 void setByteData(byte[] bData)
          Set the data for this stream as a byte array
 void setData(int len)
          Create the array for this stream's the data according to the stream's dataType>/code>
 void setData(java.lang.Object data)
          Set the data for this stream according to the stream's dataType>/code>
 void setID(int id)
          Set the ID for this stream
 void setIntData(int[] iData)
          Set the data for this stream as an int array
 void setShortData(short[] sData)
          Set the data for this stream as a short array
 void setSpace(Space space)
          Set the space for this stream
 void setSummary(int[] summary)
          Set the summary values for this stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRESENTATION_PLAIN

public static final int PRESENTATION_PLAIN
Present a tiles as is

See Also:
Constant Field Values

PRESENTATION_PLUS

public static final int PRESENTATION_PLUS
Present a tile as maximum+ if its value exceeds the maximum for the stream

See Also:
Constant Field Values

PRESENTATION_MAX_VAR

public static final int PRESENTATION_MAX_VAR
Maximum value calclated by iterating over the stream

See Also:
Constant Field Values

PRESENTATION_PERCENT

public static final int PRESENTATION_PERCENT
Present as a percentage of a fixed maximum

See Also:
Constant Field Values

PRESENTATION_PERCENT_VAR

public static final int PRESENTATION_PERCENT_VAR
Present as a percentage but use the value of the corresponding tile in stream maxStreamIndex for its maximum

See Also:
Constant Field Values

PRESENTATION_ENUM

public static final int PRESENTATION_ENUM
Select presentation from enumNames

See Also:
Constant Field Values

PAINT_STYLE_PLAIN

public static final int PAINT_STYLE_PLAIN
Plain paint style

See Also:
Constant Field Values

PAINT_STYLE_ZERO

public static final int PAINT_STYLE_ZERO
Present zeor values specially (by showing them as light frames)

See Also:
Constant Field Values

BYTE_TYPE

public static final int BYTE_TYPE
Data type is byte

See Also:
Constant Field Values

SHORT_TYPE

public static final int SHORT_TYPE
Data type is short

See Also:
Constant Field Values

INT_TYPE

public static final int INT_TYPE
Data type is int

See Also:
Constant Field Values
Constructor Detail

Stream

public Stream()

Stream

public Stream(java.lang.String name,
              int dataType,
              int minValue,
              int maxValue,
              int zeroValue,
              int defaultValue,
              java.lang.String stringPre,
              java.lang.String stringPost,
              int presentation,
              int paintStyle,
              int maxStreamIndex,
              java.awt.Color color,
              java.lang.String[] enumNames,
              int tileNum)
Create a new stream

Parameters:
name - Its name
dataType - Its data type (one of BYTE_TYPE, SHORT_TYPE, INT_TYPE)
minValue - The minimum value for the stream
maxValue - The maximum value for the stream
zeroValue - The zero value for the stream
defaultValue - The default value for the stream
stringPre - Text to prefix tile values in string representations
stringPost - Text to prefix tile values in string representations
presentation - The presentation style (see PRESENTATION_*)
paintStyle - The presentation style ( (one of PAINT_STYLE_PLAIN or PAINT_STYLE_ZERO)
maxStreamIndex - The ID of the stream to use as a maximum if the presentation style is PRESENTATION_PERCENT_VAR.
color - The tile colour
enumNames - A list of name to use if the presentation style is PRESENTATION_ENUM.
tileNum - The number of tiles in the stream

Stream

public Stream(java.lang.String name,
              int dataType,
              int minValue,
              int maxValue,
              int zeroValue,
              int defaultValue,
              java.lang.String stringPre,
              java.lang.String stringPost,
              int presentation,
              int paintStyle,
              int maxStreamIndex,
              java.awt.Color color,
              java.lang.String[] enumNames)
Create a new stream

Parameters:
name - Its name
dataType - Its data type (one of BYTE_TYPE, SHORT_TYPE, INT_TYPE)
minValue - The minimum value for the stream
maxValue - The maximum value for the stream
zeroValue - The zero value for the stream
defaultValue - The default value for the stream
stringPre - Text to prefix tile values in string representations
stringPost - Text to prefix tile values in string representations
presentation - The presentation style (see PRESENTATION_*)
paintStyle - The presentation style ( (one of PAINT_STYLE_PLAIN or PAINT_STYLE_ZERO)
maxStreamIndex - The ID of the stream to use as a maximum if the presentation style is PRESENTATION_PERCENT_VAR.
color - The tile colour
enumNames - A list of name to use if the presentation style is PRESENTATION_ENUM.
Method Detail

setSpace

public void setSpace(Space space)
Set the space for this stream

Parameters:
space - the space

setID

public void setID(int id)
Set the ID for this stream

Parameters:
id - the ID

setByteData

public void setByteData(byte[] bData)
Set the data for this stream as a byte array

Parameters:
bData - the data

setShortData

public void setShortData(short[] sData)
Set the data for this stream as a short array

Parameters:
sData - the data

setIntData

public void setIntData(int[] iData)
Set the data for this stream as an int array

Parameters:
iData - the data

setData

public void setData(java.lang.Object data)
Set the data for this stream according to the stream's dataType>/code>

Parameters:
data - the data

setData

public void setData(int len)
Create the array for this stream's the data according to the stream's dataType>/code>

Parameters:
len - The lenght of the data

setSummary

public void setSummary(int[] summary)
Set the summary values for this stream

Parameters:
summary - The summary values

getName

public java.lang.String getName()
Get the name of this stream

Returns:
the name of this stream

getDataType

public int getDataType()
Get the type of this stream

Returns:
this stream's data type (byte, short or int)

getMinValue

public int getMinValue()
Get the minimum value for this stream

Returns:
the minimum value for this stream

getMaxValue

public int getMaxValue()
Get the maximum value for this stream

Returns:
the maximum value for this stream

getZeroValue

public int getZeroValue()
Get the zero value for this stream

Returns:
the zero value for this stream

getDefaultValue

public int getDefaultValue()
Get the default value for this stream

Returns:
the default value for this stream

getPresentation

public int getPresentation()
Get the presentation style for this stream

Returns:
the presentation style for this stream

getPaintStyle

public int getPaintStyle()
Get the paint style for this stream

Returns:
the paint style for this stream

getColor

public java.awt.Color getColor()
Get the colour used for this stream

Returns:
the tile colour for this stream

getByteData

public byte[] getByteData()
Get the data for this stream (assumed to be bytes)

Returns:
the data as a byte array for this stream

getShortData

public short[] getShortData()
Get the data for this stream (assumed to be shorts)

Returns:
the data as a short array for this stream

getIntData

public int[] getIntData()
Get the data for this stream (assumed to be ints)

Returns:
the data as an int array for this stream

getData

public java.lang.Object getData()
Get the data for this stream

Returns:
the data as an array of appropriate type for this stream

getSummary

public int[] getSummary()
Get the summary value(s) for this stream

Returns:
the summary values for this stream

getAccessor

public DataAccessor getAccessor()
Get the data accessor for this stream

Returns:
the data accessor for this stream

getPrefix

public java.lang.String getPrefix()
Get the the prefix string for tiles in this stream (e.g. used in the block info view)

Returns:
the prefix

getSuffix

public java.lang.String getSuffix()
Get the suffix string for tiles in this stream (e.g. used in the block info view)

Returns:
the suffix

calcMaxIfNecessary

public void calcMaxIfNecessary()
Calculate the maximum value found in this stream if its presentation style is PRESENTATION_MAX_VAR


getMaxValue

public int getMaxValue(int i)
Get the maximum value for a tile (neede for the PRESENTATION_PERCENT_VAR style.

Parameters:
i - The tile's index
Returns:
Its maximum value

reset

public void reset()
Reset the data values to their defaults


adjustValue

public int adjustValue(int val)
Adjust a tile value according to the stream's presentation style. Note: should not really call this for PERCENT_VAR

Parameters:
val - The tile value
Returns:
The adjusted value or BAD_PRESENTATION_PERCENT if the style is PRESENTATION_PERCENT_VAR or BAD_PRESENTATION if the style is bad.

isZero

public boolean isZero(int val)
Is a tile value zero

Parameters:
val - The tile value
Returns:
true if it is zero

isOverflow

public boolean isOverflow(int val)
Does a tile value zero exceed the maximum

Parameters:
val - The tile value
Returns:
true if it exceeds the maximum

presentDataSmall

public java.lang.String presentDataSmall(int val)
Present a tile value as a short string

Parameters:
val - The value
Returns:
It's string representation

presentData

public java.lang.String presentData(int i)
Present a tile value as a string

Parameters:
i - The tiel index
Returns:
It's string representation

presentFullSummary

public java.lang.String presentFullSummary(java.lang.String prefix1,
                                           java.lang.String prefix2)
Present a full summary

Parameters:
prefix1 - A string to prefix the summary
prefix2 - A string to prefix the summary if the style is PRESENTATION_ENUM
Returns:
the full summary as a string

serialise

public void serialise(BufferedOutput output)
Serialise the stream

Parameters:
output - The BufferedOutput to use

deserialise

public void deserialise(BufferedInput input)
Deserialise the stream

Parameters:
input - The BufferedInput to use

dump

public void dump()