|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
edu.hawaii.ics.yucheng.GraphBox
class GraphBox
A component that displays a graph and possibly a solution.
Nested Class Summary | |
---|---|
(package private) class |
GraphBox.Delegate
A class that shows information about the loaded graph through a popup window. |
private static class |
GraphBox.Theme
A collection of colors, fonts, and strokes. |
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
javax.swing.JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
private static int |
MAX_DISPLAYED_EDGES
The maximum number of edges displayed. |
private java.awt.Dimension |
myCachedSize
|
(package private) Graph |
myGraph
The displayed graph. |
private javax.swing.JLabel |
myHelpIcon
|
private float |
myMaxWeight
|
private float |
myMinWeight
|
(package private) GraphSolution |
mySolution
The displayed graph solution. |
private javax.swing.JLabel |
myStatusLabel
|
private java.awt.Dimension |
myVertexSize
|
private java.util.ArrayList<java.awt.Point> |
myXY
|
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
GraphBox()
Initializes a new instance of the class. |
Method Summary | |
---|---|
private void |
computeVertexLocations()
Computes the drawing information based on the assigned graph. |
private static void |
drawCentered(java.awt.Component component,
java.awt.Graphics g,
java.lang.String text)
Draws text centered in a component. |
private static void |
drawCentered(java.awt.Graphics g,
java.lang.String text,
int x,
int y)
Draws text centered at a location. |
private static java.lang.String |
formatWeight(float weight)
Formats the weight value as text. |
private java.awt.Color |
getScaledColor(float weight)
Returns a color based on a weight. |
private java.awt.Color |
getScaledColorByPercent(float percent)
Returns a color based on a percentage. |
void |
paint(java.awt.Graphics g)
Paints the component. |
private void |
paintBorder(java.awt.Graphics2D g)
Draws a border around the component. |
private void |
paintEdges(java.awt.Graphics2D g)
Draws the edges. |
private void |
paintNoGraph(java.awt.Graphics2D g)
Draws the component when no graph is loaded. |
private void |
paintScale(java.awt.Graphics2D g)
Draws the scale. |
private void |
paintVertices(java.awt.Graphics2D g)
Draws the vertices. |
void |
reset()
Resets the graph. |
void |
setBounds(java.awt.Rectangle r)
Moves and resizes this component to conform to the new bounding rectangle r. |
void |
setGraph(Graph g)
Sets the graph to display. |
void |
setSolution(GraphSolution solution)
Sets the solution. |
private static java.awt.Graphics2D |
startAntialiasing(java.awt.Graphics g)
Updates the graphics object to use antialiasing. |
private void |
updateInformationArea()
Sets the information area. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final int MAX_DISPLAYED_EDGES
private java.awt.Dimension myCachedSize
Graph myGraph
private final javax.swing.JLabel myHelpIcon
private float myMaxWeight
private float myMinWeight
GraphSolution mySolution
private final javax.swing.JLabel myStatusLabel
private java.awt.Dimension myVertexSize
private final java.util.ArrayList<java.awt.Point> myXY
Constructor Detail |
---|
public GraphBox()
Method Detail |
---|
private static void drawCentered(java.awt.Component component, java.awt.Graphics g, java.lang.String text)
component
- The component.g
- The graphics object.text
- The text.private static void drawCentered(java.awt.Graphics g, java.lang.String text, int x, int y)
g
- The graphics object.text
- The text.x
- The horizontal location.y
- The vertical location.private static java.lang.String formatWeight(float weight)
weight
- The weight.
private static java.awt.Graphics2D startAntialiasing(java.awt.Graphics g)
g
- The graphics object.
private void computeVertexLocations()
private java.awt.Color getScaledColor(float weight)
weight
- The weight.
private java.awt.Color getScaledColorByPercent(float percent)
percent
- The percentage.
public void paint(java.awt.Graphics g)
paint
in class javax.swing.JComponent
g
- The graphics object.private void paintBorder(java.awt.Graphics2D g)
g
- The graphics object.private void paintEdges(java.awt.Graphics2D g)
g
- The graphics object.private void paintNoGraph(java.awt.Graphics2D g)
g
- The graphics object.private void paintScale(java.awt.Graphics2D g)
g
- The graphics object.private void paintVertices(java.awt.Graphics2D g)
g
- The graphics object.public void reset()
public void setBounds(java.awt.Rectangle r)
setBounds
in class java.awt.Component
r
- the new bounding rectangle for this componentpublic void setGraph(Graph g)
g
- The graph.public void setSolution(GraphSolution solution)
solution
- private void updateInformationArea()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |