se.liu.ida.critiquer.gui
Class TimeView

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by se.liu.ida.critiquer.gui.TimeView
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Comparable<ActivityUpdateListener>, EventListener, Accessible, DatasetChangeListener, ActivityUpdateListener, TimeLineRenderingListener, View

public class TimeView
extends JPanel
implements View, DatasetChangeListener, TimeLineRenderingListener, ActivityUpdateListener

This class presents the time view. It is a bit special since the constraints are notified by the TimeLinePlot and not the view itself. That's because we want to interact with the timeline and therefore it's easier if the input coordinate system is the same as the one used by the activity areas. The constraints are therefore only given the graphics context of the chart area when they display their information.

Interaction in this view goes as follows:

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  ConstraintComponent critiqueComponent
           
 
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
TimeView()
           
 
Method Summary
 void activityCreated(Activity activity)
          The activity has just been created
 void activityRemoved(Activity a)
          The activity was just removed
 void activityUpdated(Activity a)
          The activity has undergone major changes, refresh all information dependent on it.
 int compareTo(ActivityUpdateListener o)
          Put this one after all other update listeners so all changes have taken place when changing the time lines
 void datasetChanged(DatasetChangeEvent event)
           
 Rectangle2D getActivityArea(Activity activity)
          A view should render activities as either components or as Java 2D Shapes.
 HashMap<Activity,Rectangle2D> getActivityAreas()
           
 ChartPanel getChartPane()
           
 JPanel getConstraintPanel()
          All views should let constraints show information as components in a special panel
 Calendar getCurrentTime()
          Retrieves the current time as set by the slider
 ArrayList<Activity> getEvaluationActivities()
          One may select only a set of activities in the Time View for which time charts should be drawn.
 Rectangle2D getTimeChartArea()
           
 JPanel getTimePanel()
           
 void initSimulation()
           
 Calendar locationToDate(double x)
           
<T> void
paramAdded(Activity activity, Parameter<T> p)
          A parameter has been added
<T> void
paramChanged(Activity activity, Parameter<T> p)
          Recalculate the time chart based on when parameters change.
 void setCurrentTime(Double currentTime)
          Adjust the time according to the parameter, which is converted into a date by the plot
 void updateActivityArea(Comparable key, Rectangle2D bar)
           
 void updateView(Graphics2D g2)
           
 
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, getWidth, getVisibleRect, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, 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, 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

critiqueComponent

protected ConstraintComponent critiqueComponent
Constructor Detail

TimeView

public TimeView()
Method Detail

getConstraintPanel

public JPanel getConstraintPanel()
Description copied from interface: View
All views should let constraints show information as components in a special panel

Specified by:
getConstraintPanel in interface View
Returns:
the panel where the constraints may render components that display some critiquing information

updateView

public void updateView(Graphics2D g2)
Specified by:
updateView in interface View

initSimulation

public void initSimulation()

activityUpdated

public void activityUpdated(Activity a)
Description copied from interface: ActivityUpdateListener
The activity has undergone major changes, refresh all information dependent on it.

Specified by:
activityUpdated in interface ActivityUpdateListener
Parameters:
a - The activity to set.

getEvaluationActivities

public ArrayList<Activity> getEvaluationActivities()
One may select only a set of activities in the Time View for which time charts should be drawn.

Specified by:
getEvaluationActivities in interface View

datasetChanged

public void datasetChanged(DatasetChangeEvent event)
Specified by:
datasetChanged in interface DatasetChangeListener

activityCreated

public void activityCreated(Activity activity)
Description copied from interface: ActivityUpdateListener
The activity has just been created

Specified by:
activityCreated in interface ActivityUpdateListener

paramAdded

public <T> void paramAdded(Activity activity,
                           Parameter<T> p)
Description copied from interface: ActivityUpdateListener
A parameter has been added

Specified by:
paramAdded in interface ActivityUpdateListener

paramChanged

public <T> void paramChanged(Activity activity,
                             Parameter<T> p)
Recalculate the time chart based on when parameters change. This need only be done when parameters affecting the time of the mission are changed, but we are not so fussy about that. Await all pending activity updates before activating this, but do not block execution doing so. This so that we are ensured that the new time chart reflects a consistent state among the activities.

Specified by:
paramChanged in interface ActivityUpdateListener

activityRemoved

public void activityRemoved(Activity a)
Description copied from interface: ActivityUpdateListener
The activity was just removed

Specified by:
activityRemoved in interface ActivityUpdateListener

getCurrentTime

public Calendar getCurrentTime()
Retrieves the current time as set by the slider

See Also:
TimeLinePlot.getCurrentTime()

setCurrentTime

public void setCurrentTime(Double currentTime)
Adjust the time according to the parameter, which is converted into a date by the plot

See Also:
TimeLinePlot.setCurrentTime(java.lang.Double)

getTimeChartArea

public Rectangle2D getTimeChartArea()

locationToDate

public Calendar locationToDate(double x)

getChartPane

public ChartPanel getChartPane()
Returns:
Returns the chartPane.

getTimePanel

public JPanel getTimePanel()
Returns:
Returns the timePanel.

getActivityAreas

public HashMap<Activity,Rectangle2D> getActivityAreas()

updateActivityArea

public void updateActivityArea(Comparable key,
                               Rectangle2D bar)
Specified by:
updateActivityArea in interface TimeLineRenderingListener

getActivityArea

public Rectangle2D getActivityArea(Activity activity)
Description copied from interface: View
A view should render activities as either components or as Java 2D Shapes. We only use rectangles currently. If the view does not support an operation it may throw an "UnsupportedOperationException"

Specified by:
getActivityArea in interface View

compareTo

public int compareTo(ActivityUpdateListener o)
Put this one after all other update listeners so all changes have taken place when changing the time lines

Specified by:
compareTo in interface Comparable<ActivityUpdateListener>
See Also:
java.lang.Comparable#compareTo(T)