public class PresentationElement extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
PresentationElement.ArrayElementInfo
Interface for data related to array elements in the viewer.
|
static interface |
PresentationElement.ArrayInfo
Interface for data related to the optional array in the viewer.
|
static interface |
PresentationElement.FieldInfo
Interface for data related to fields of interest in the viewer.
|
Modifier and Type | Field and Description |
---|---|
static int |
ADT_GENERAL
Array display type indicating non-array.
|
static int |
ADT_OBJECT
Array display type indicating object array.
|
static int |
ADT_PRIMITIVE
Array display type indicating primitive array.
|
static int |
ARRAY_SEL
Selection flag indicating that the entire array is selected.
|
static int |
CONTAINER_ITEM
Item constant indicating the container node.
|
static int |
EMBEDDED
Configure flag indicating that value nodes should be shown embedded in
their container nodes as opposed to being linked.
|
static int |
FI_ERROR
FieldInfo type constant indicating that there was an error retrieving
the field value.
|
static int |
FI_OBJECT
FieldInfo type constant indicating an object field.
|
static int |
FI_PRIMITIVE
FieldInfo type constant indicating a primitive field.
|
static int |
HASH_ARRAY_ELEMENT
Configure flag indicating that the element is a hash array element.
|
static int |
NO_ITEM
Item constant indicating no item.
|
static int |
NO_SEL
Selection flag indicating no selection.
|
static int |
NODE_LABELS
Configure flag indicating that nodes will be labeled.
|
static int |
REVERSED
Configure flag indicating that the orientation will be reversed.
|
static int |
ROUND
Configure flag indicating that nodes should be round as opposed to
square.
|
static int |
SIMPLE
Configure flag indicating that a less cluttered display should be
used.
|
static int |
TREE
Configure flag indicating that the element will be used in a tree
structure as opposed to a list.
|
static int |
UP
Configure flag indicating that the list in which this element is used
will be bottom-to-top.
|
static int |
VALUES_ARE_OBJECTS
Configure flag indicating that values in the structure are objects as
opposed to primitives.
|
static int |
VERTICAL
Configure flag indicating that the orientation will be vertical.
|
Constructor and Description |
---|
PresentationElement() |
Modifier and Type | Method and Description |
---|---|
boolean |
arrayHandleContainsPoint(int x,
int y)
Determines if an array handle contains a point.
|
void |
configure(Graphics g,
String[] rowLabels,
int numLinksIn,
int numValuesIn,
List<? extends PresentationElement.FieldInfo> fieldInfo,
PresentationElement.ArrayInfo arrayData,
int labelSpaceIn,
int markerSpaceIn,
int flags,
int valueTextWidth)
Configures the display.
|
int |
getArrayAreaHeight()
Gets the height of the area used to display an array-like structure as
an addition to the rest of the view.
|
int |
getArrayAreaWidth()
Gets the width necessary to display all array items.
|
int |
getArrayElementContainingPoint(int x,
int y)
Determines which array element index contains a point.
|
int |
getArrowHeadWidth()
Gets half the width of an arrow head.
|
int |
getArrowLength()
Gets the length of a container-to-value arrow.
|
int |
getBorder()
Gets the size of border between text and node edge, also used for other
separations.
|
int |
getEdge()
Gets the width used for most lines.
|
int |
getElementHeight()
Gets the height of an element.
|
int |
getElementWidth()
Gets the width of an element.
|
double |
getFieldArrowYPos()
Gets the y position for field pointers.
|
int |
getFieldContainingPoint(int x,
int y)
Determines which field box contains a point.
|
int |
getFieldNodeHeight()
Gets the height of the nodes used to display fields.
|
int |
getFieldsAreaHeight()
Gets the height of the area used to display fields.
|
int |
getFieldsWidth()
Gets the width necessary to display all fields.
|
int |
getFieldTextYPos()
Gets the baseline position of the fields text.
|
int |
getFontHeight()
Gets the font height.
|
Point |
getIndexMarkPos(Rectangle elementRect)
Gets the index marker position for horizontal orientation.
|
int |
getItemContainingPoint(Rectangle elementRect,
boolean[] valueIsNull,
int x,
int y)
Gets the element item containing a point.
|
int |
getItemContainingPoint(Rectangle elementRect,
boolean valueIsNull,
int x,
int y)
Gets the element item containing a point.
|
int |
getLabelRightOffset()
Gets the right offset of the structure labels.
|
Point2D.Double |
getLeftLinkSource(Rectangle elementRect)
Gets the left link attachment point.
|
double |
getLinkGap()
Gets a length for separating edges.
|
int |
getMargin()
Gets the margin used to separate elements.
|
Rectangle |
getNodeRect(Rectangle elementRect)
Gets the bounding rectangle for the container node.
|
RectangularShape |
getNodeShape(Rectangle elementRect)
Gets a shape for the container node.
|
RectangularShape |
getObjectNodeShape(Rectangle elementRect,
int objectIndex)
Gets a shape for the value node.
|
int |
getPointerLen()
Gets half the index pointer height.
|
Point2D.Double |
getRightLinkSource(Rectangle elementRect) |
int |
getSquareLength()
Gets the edge length of a reference square.
|
Rectangle2D.Double |
getSquareRect(Rectangle elementRect,
int objectIndex) |
int |
getSquareSpace()
Gets the space for a launch square.
|
int |
getThinEdge()
Gets the width used for thin lines.
|
Rectangle |
getValueNodeRect(Rectangle elementRect,
int objectIndex)
Gets the bounding rectangle for a value node.
|
boolean |
noLabels()
Determines if there are no structure labels.
|
void |
paintArray(Graphics2D g,
Color nodeBg,
Color objColor,
int selIndex,
Color selColor)
Paints array data at the top of the view.
|
void |
paintElement(Graphics2D g,
Rectangle elementRect,
Color nodeBg,
Color[] valueColor,
Color selColor,
boolean selectedIn,
boolean[] valueSelected,
boolean[] valueIsNull,
String[] text,
Color[] textColor,
boolean[] linkIsNull,
String nodeLabel,
List<IndexItem> markers,
int markerLabelWidth)
Paints the element.
|
void |
paintElement(Graphics2D g,
Rectangle elementRect,
Color nodeBg,
Color valueColor,
Color selColor,
boolean selected,
boolean valueSelected,
boolean valueIsNull,
String text,
Color textColor,
boolean[] linkIsNull,
String nodeLabel,
List<IndexItem> markers,
int markerLabelWidth)
Paints the element.
|
double[] |
paintFields(Graphics2D g,
List<? extends PresentationElement.FieldInfo> fieldInfo,
Color objColor,
Color primitiveColor,
int selIndex,
Color selColor)
Paints the fields data at the top of the view.
|
void |
paintHashArrayElement(Graphics2D g,
Rectangle elementRect,
Color nodeBg,
Color selColor,
boolean selected,
boolean valueIsNull,
String nodeLabel,
Rectangle rawTargetRect,
Rectangle targetRect)
Paints an array node and arrow to target.
|
void |
paintSelectedNodeBorder(Graphics2D g,
Rectangle elementRect,
Color selColor)
Paints the selection border on a node.
|
void |
paintSquare(Graphics2D g,
Color color,
double x,
double y,
boolean isNull)
Paints a launch square.
|
public static final int NODE_LABELS
public static final int VERTICAL
public static final int TREE
public static final int VALUES_ARE_OBJECTS
public static final int SIMPLE
public static final int EMBEDDED
public static final int ROUND
public static final int UP
public static final int HASH_ARRAY_ELEMENT
public static final int REVERSED
public static final int CONTAINER_ITEM
public static final int NO_ITEM
public static final int FI_OBJECT
public static final int FI_PRIMITIVE
public static final int FI_ERROR
public static final int ADT_OBJECT
public static final int ADT_PRIMITIVE
public static final int ADT_GENERAL
public static final int NO_SEL
public static final int ARRAY_SEL
public boolean arrayHandleContainsPoint(int x, int y)
x
- x position of point of interest.y
- y position of point of interest.public void configure(Graphics g, String[] rowLabels, int numLinksIn, int numValuesIn, List<? extends PresentationElement.FieldInfo> fieldInfo, PresentationElement.ArrayInfo arrayData, int labelSpaceIn, int markerSpaceIn, int flags, int valueTextWidth)
g
- appropriate graphics object for the view.rowLabels
- labels that will go beside each structure, or null if
there are none. Room will be reserved for the largest of these.numLinksIn
- number of links in a node. Currently this must be zero
(for arrays and the like), one, or two.numValuesIn
- number of values that will be associated with each
node. This must be greater than zero.fieldInfo
- data for fields that will be displayed, or null if none
will be displayed.arrayData
- data for an array-like structure that will be displayed
with the view, or null if no such structure should be displayed.labelSpaceIn
- space needed below the node for text, such as array
or list indices. For a vertical display, this would be the horizontal
space needed, for a horizontal display it would be the vertical space
needed.markerSpaceIn
- space needed below the node and label for a marker,
such as an array index indicator. For a vertical display, this would be
the horizontal space needed, for a horizontal display it would be the
vertical space needed. If this is non-zero, space for a marker will also
be added.flags
- layout flags. A combination of NODE_LABELS
,
VERTICAL
, REVERSED
, TREE
, UP
,
VALUES_ARE_OBJECTS
, SIMPLE
, EMBEDDED
, and
ROUND
.valueTextWidth
- desired width of value text area in units of '0'
characters * 10, or, if the HASH_ARRAY_ELEMENT flag is used, the element
width in pixels.public int getArrayAreaHeight()
public int getArrayAreaWidth()
public int getArrayElementContainingPoint(int x, int y)
x
- x position of point of interest.y
- y position of point of interest.public int getArrowHeadWidth()
public int getArrowLength()
public int getBorder()
public int getEdge()
public int getElementHeight()
public int getElementWidth()
public double getFieldArrowYPos()
public int getFieldContainingPoint(int x, int y)
x
- x position of point of interest.y
- y position of point of interest.public int getFieldNodeHeight()
public int getFieldsAreaHeight()
public int getFieldsWidth()
public int getFieldTextYPos()
public int getFontHeight()
public Point getIndexMarkPos(Rectangle elementRect)
elementRect
- the element rectangle.public int getItemContainingPoint(Rectangle elementRect, boolean valueIsNull, int x, int y)
elementRect
- bounds of the element.valueIsNull
- true if the element value is null, false otherwise.x
- x coordinate of point of interest.y
- y coordinate of point of interest.CONTAINER_ITEM
if the container node contains the point, or
NO_ITEM
if no node contains the point.public int getItemContainingPoint(Rectangle elementRect, boolean[] valueIsNull, int x, int y)
elementRect
- bounds of the element.valueIsNull
- array of booleans that are true for each value if null
and false otherwise.x
- x coordinate of point of interest.y
- y coordinate of point of interest.CONTAINER_ITEM
if the container node contains the point, or
NO_ITEM
if no node contains the point.public int getLabelRightOffset()
public Point2D.Double getLeftLinkSource(Rectangle elementRect)
elementRect
- boundary rectangle for the element.public double getLinkGap()
public int getMargin()
public Rectangle getNodeRect(Rectangle elementRect)
elementRect
- bounds of the element.public RectangularShape getNodeShape(Rectangle elementRect)
elementRect
- bounds of the element.public RectangularShape getObjectNodeShape(Rectangle elementRect, int objectIndex)
elementRect
- bounds of the element.objectIndex
- index of the value node.public int getPointerLen()
public Point2D.Double getRightLinkSource(Rectangle elementRect)
public int getSquareLength()
public Rectangle2D.Double getSquareRect(Rectangle elementRect, int objectIndex)
public int getSquareSpace()
public int getThinEdge()
public Rectangle getValueNodeRect(Rectangle elementRect, int objectIndex)
elementRect
- bounds of the element.objectIndex
- index of the value node.public boolean noLabels()
public void paintArray(Graphics2D g, Color nodeBg, Color objColor, int selIndex, Color selColor)
public void paintElement(Graphics2D g, Rectangle elementRect, Color nodeBg, Color valueColor, Color selColor, boolean selected, boolean valueSelected, boolean valueIsNull, String text, Color textColor, boolean[] linkIsNull, String nodeLabel, List<IndexItem> markers, int markerLabelWidth)
g
- the graphics on which to paint.elementRect
- the element bounds.nodeBg
- the node background color.valueColor
- the value color.selColor
- the selection color.selected
- true if the node is selected, false if it is not.valueSelected
- true if the value is selected, false if it is not.valueIsNull
- true if the value is null, false if it is not.text
- the value text.textColor
- the color to use for the value text.linkIsNull
- for each link, true if the link target is null, false
otherwise.nodeLabel
- label text, or null if no label should be displayed.markers
- the markers.markerLabelWidth
- maximum marker label text, width for horizontally
oriented elements. This is ignored if the orientation is vertical or if
markerLabelText
is null.public void paintElement(Graphics2D g, Rectangle elementRect, Color nodeBg, Color[] valueColor, Color selColor, boolean selectedIn, boolean[] valueSelected, boolean[] valueIsNull, String[] text, Color[] textColor, boolean[] linkIsNull, String nodeLabel, List<IndexItem> markers, int markerLabelWidth)
g
- the graphics on which to paint.elementRect
- the element bounds.nodeBg
- the node background color.valueColor
- the color for each value.selColor
- the node selection color.selectedIn
- true if the node is selected, false otherwise.valueSelected
- for each value, true if it is selected and false if
it is not.valueIsNull
- true if the node value is null, false otherwise.text
- the text for each value.textColor
- the color for the text of each value.linkIsNull
- for each link, true if the link target is null, false
otherwise.nodeLabel
- label text, or null if no label should be displayed.markers
- the markers.markerLabelWidth
- maximum marker label text, width for horizontally
oriented elements. This is ignored if the orientation is vertical or if
markerLabelText
is null.public double[] paintFields(Graphics2D g, List<? extends PresentationElement.FieldInfo> fieldInfo, Color objColor, Color primitiveColor, int selIndex, Color selColor)
g
- graphics object used for rendering.fieldInfo
- data for the fields to be displayed.objColor
- color for fields with Object type.primitiveColor
- color for fields with primitive type.selIndex
- index of selected field, or -1 if no fields are selected.selColor
- color used to outline selected fields.public void paintHashArrayElement(Graphics2D g, Rectangle elementRect, Color nodeBg, Color selColor, boolean selected, boolean valueIsNull, String nodeLabel, Rectangle rawTargetRect, Rectangle targetRect)
g
- the graphics used to render the node.elementRect
- element bounds for the node element.nodeBg
- the node background color.selColor
- the node selection color.selected
- true if the node is selected, false otherwise.valueIsNull
- true if the node value is null, false otherwise.nodeLabel
- the node label.rawTargetRect
- non-animation target node bounds, or if the value is
null, what those bounds would be if there were a target.targetRect
- the target node bounds. This is ignored if
valueIsNull
is true.public void paintSelectedNodeBorder(Graphics2D g, Rectangle elementRect, Color selColor)
g
- graphics on which the selected node border will be rendered.elementRect
- element bounds rectangle.selColor
- selection border color.public void paintSquare(Graphics2D g, Color color, double x, double y, boolean isNull)
g
- the graphics on which to paint.color
- the launch square color.x
- the launch square center x position.y
- the launch square center y position.isNull
- true if the launch is for a null pointer, false
otherwise.