utility
Class NightPlanner

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by utility.NightPlanner
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class NightPlanner
extends java.awt.Canvas

See Also:
Serialized Form

Nested Class Summary
 class NightPlanner.BarInfo
           
 
Field Summary
 java.awt.Color badBar
           
 int barHeight
           
 NightPlanner.BarInfo[] barInfos
           
 double binPerMin
           
 NightPlanner.BarInfo currentBar
           
 int dragPos
           
 boolean editMode
           
 java.awt.FontMetrics fm
           
 java.awt.Color goodBar
           
 int height
           
 boolean isFirstDraw
           
 boolean loquacious
           
 int nightLength
           
 java.awt.Color noTimeBar
           
 int numBars
           
 int numFilts
           
 java.awt.Dimension osD
           
 java.awt.Graphics osG
           
 java.awt.Image osImg
           
 long possibleLoops
           
 NightPlanner.BarInfo[] saveBars
           
 java.awt.Font sfont
           
 int smargin
           
 int textheight
           
 Sixty theStart
           
 int tmargin
           
 boolean tryReorder
           
 java.awt.Color unusedBar
           
 java.awt.Color whoopsBar
           
 int width
           
 
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
NightPlanner()
           
 
Method Summary
 boolean addNextBar(java.lang.String[] night, NightPlanner.BarInfo bar)
          add a bar to the night as far left as possible.
 int amountOutsideRange(NightPlanner.BarInfo bar, int min, int max)
          sees how much of a bar is currently outside a given range
 boolean betterToSwap(NightPlanner.BarInfo bar1, NightPlanner.BarInfo bar2)
          determines if swapping frees up space
 boolean canMove(java.lang.String[] night, NightPlanner.BarInfo bar)
          sees if moving will create enough space
 boolean canPush(java.lang.String[] night, NightPlanner.BarInfo bar)
          sees if pushing will create enough space
 boolean canReorder(java.lang.String[] night, NightPlanner.BarInfo bar)
          sees if reordering bars can free up enough space
 boolean canSwap(java.lang.String[] night, NightPlanner.BarInfo bar)
          sees if swapping will create enough space
 void cloneArray(java.lang.Object[] a1, java.lang.Object[] a2)
          fills the elements of one array (a1) with another (a2).
static void fill(java.lang.String[] night, NightPlanner.BarInfo bar, int index)
          adds a bar to the night centered at index
 int gainedByPushing(java.lang.String[] night, NightPlanner.BarInfo bar, boolean pushForward, int errorReturn, java.util.Vector pushList, int limit)
          sees how much you can gain by pushing another bar forward or backward
 java.util.Vector getAllBars(java.lang.String[] night)
          gets all the bars on a night
 java.util.Vector getAllOverlappingBars(java.util.Vector allBars, NightPlanner.BarInfo bar2, java.util.Vector barList)
          finds all bars that in some way connect to a given bar through overlap including bar
 NightPlanner.BarInfo getBar(java.lang.String name)
          gets a bar given its name
 int getBarOverlap(NightPlanner.BarInfo bar1, NightPlanner.BarInfo bar2)
          gets the ammount of overlap of two bars
 java.util.Vector getPossibleNextBars(java.util.Vector bars, int leftMostOpen)
          gets the bars that can go before all the other bars
 void getSwapList(java.util.Vector swapList, NightPlanner.BarInfo bar, java.util.Vector excludeBars)
          finds which bars in the list (excluding excludeBar) can be swapped with bar.
static boolean isBlocked(java.lang.String[] night, NightPlanner.BarInfo bar, int index)
          sees if there is free space to add a bar centered at index
 void joinTwoVectors(java.util.Vector vec1, java.util.Vector vec2)
          adds the elements of the second Vector to the first
 void move(java.lang.String[] night, NightPlanner.BarInfo bar)
          tries moving bar to free space
 void paint(java.awt.Graphics g)
           
 void plan()
          tries to organize the bars efficiently using as many as possible w/o overlap
 boolean probInNight(java.lang.String[] night)
          tests for problems in night[]
 void processMouseEvent(java.awt.event.MouseEvent e)
          handles mouse clicks - mouseDown
 void processMouseMotionEvent(java.awt.event.MouseEvent e)
          handles mouse clicks - mouseDrag
 void push(java.lang.String[] night, java.util.Vector pushList, boolean pushForward, int dist)
          finds all the seems between the bars and tries to push them out to make room for the next bar.
 java.lang.String[] refillNight(java.lang.String[] night)
          clears the night and adds everything again
 boolean reorder(java.lang.String[] night, java.util.Vector remainingBars, int leftMostOpen)
          tries reordering bars to free up more space
 void restore()
          restores the last saved bar state
 void save()
          saves the current bar state
 void setUpBars(java.util.Vector candNames, java.util.Vector riseTimes, java.util.Vector setTimes, java.util.Vector expTimes, double nightBegin, double nightEnd, int slewTime, int readoutTime, Sixty theStart)
           
 void swap(java.lang.String[] night, NightPlanner.BarInfo bar)
          tries swapping neighboring bars to free up more space
 void update(java.awt.Graphics g)
           
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, dispatchEvent, doLayout, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

osImg

public java.awt.Image osImg

osG

public java.awt.Graphics osG

isFirstDraw

public boolean isFirstDraw

osD

public java.awt.Dimension osD

height

public int height

width

public int width

tmargin

public int tmargin

smargin

public int smargin

nightLength

public int nightLength

barHeight

public int barHeight

numBars

public int numBars

goodBar

public java.awt.Color goodBar

badBar

public java.awt.Color badBar

unusedBar

public java.awt.Color unusedBar

whoopsBar

public java.awt.Color whoopsBar

noTimeBar

public java.awt.Color noTimeBar

barInfos

public NightPlanner.BarInfo[] barInfos

currentBar

public NightPlanner.BarInfo currentBar

sfont

public java.awt.Font sfont

fm

public java.awt.FontMetrics fm

textheight

public int textheight

saveBars

public NightPlanner.BarInfo[] saveBars

editMode

public boolean editMode

dragPos

public int dragPos

tryReorder

public boolean tryReorder

loquacious

public boolean loquacious

possibleLoops

public long possibleLoops

numFilts

public int numFilts

binPerMin

public double binPerMin

theStart

public Sixty theStart
Constructor Detail

NightPlanner

public NightPlanner()
Method Detail

setUpBars

public void setUpBars(java.util.Vector candNames,
                      java.util.Vector riseTimes,
                      java.util.Vector setTimes,
                      java.util.Vector expTimes,
                      double nightBegin,
                      double nightEnd,
                      int slewTime,
                      int readoutTime,
                      Sixty theStart)

plan

public void plan()
tries to organize the bars efficiently using as many as possible w/o overlap


canMove

public boolean canMove(java.lang.String[] night,
                       NightPlanner.BarInfo bar)
sees if moving will create enough space


move

public void move(java.lang.String[] night,
                 NightPlanner.BarInfo bar)
tries moving bar to free space


canPush

public boolean canPush(java.lang.String[] night,
                       NightPlanner.BarInfo bar)
sees if pushing will create enough space


gainedByPushing

public int gainedByPushing(java.lang.String[] night,
                           NightPlanner.BarInfo bar,
                           boolean pushForward,
                           int errorReturn,
                           java.util.Vector pushList,
                           int limit)
sees how much you can gain by pushing another bar forward or backward


push

public void push(java.lang.String[] night,
                 java.util.Vector pushList,
                 boolean pushForward,
                 int dist)
finds all the seems between the bars and tries to push them out to make room for the next bar.


canSwap

public boolean canSwap(java.lang.String[] night,
                       NightPlanner.BarInfo bar)
sees if swapping will create enough space


swap

public void swap(java.lang.String[] night,
                 NightPlanner.BarInfo bar)
tries swapping neighboring bars to free up more space


getAllBars

public java.util.Vector getAllBars(java.lang.String[] night)
gets all the bars on a night


refillNight

public java.lang.String[] refillNight(java.lang.String[] night)
clears the night and adds everything again


getPossibleNextBars

public java.util.Vector getPossibleNextBars(java.util.Vector bars,
                                            int leftMostOpen)
gets the bars that can go before all the other bars


cloneArray

public void cloneArray(java.lang.Object[] a1,
                       java.lang.Object[] a2)
fills the elements of one array (a1) with another (a2).


canReorder

public boolean canReorder(java.lang.String[] night,
                          NightPlanner.BarInfo bar)
sees if reordering bars can free up enough space


reorder

public boolean reorder(java.lang.String[] night,
                       java.util.Vector remainingBars,
                       int leftMostOpen)
tries reordering bars to free up more space


addNextBar

public boolean addNextBar(java.lang.String[] night,
                          NightPlanner.BarInfo bar)
add a bar to the night as far left as possible.


getAllOverlappingBars

public java.util.Vector getAllOverlappingBars(java.util.Vector allBars,
                                              NightPlanner.BarInfo bar2,
                                              java.util.Vector barList)
finds all bars that in some way connect to a given bar through overlap including bar


joinTwoVectors

public void joinTwoVectors(java.util.Vector vec1,
                           java.util.Vector vec2)
adds the elements of the second Vector to the first


getSwapList

public void getSwapList(java.util.Vector swapList,
                        NightPlanner.BarInfo bar,
                        java.util.Vector excludeBars)
finds which bars in the list (excluding excludeBar) can be swapped with bar.


getBarOverlap

public int getBarOverlap(NightPlanner.BarInfo bar1,
                         NightPlanner.BarInfo bar2)
gets the ammount of overlap of two bars


betterToSwap

public boolean betterToSwap(NightPlanner.BarInfo bar1,
                            NightPlanner.BarInfo bar2)
determines if swapping frees up space


amountOutsideRange

public int amountOutsideRange(NightPlanner.BarInfo bar,
                              int min,
                              int max)
sees how much of a bar is currently outside a given range


getBar

public NightPlanner.BarInfo getBar(java.lang.String name)
gets a bar given its name


isBlocked

public static boolean isBlocked(java.lang.String[] night,
                                NightPlanner.BarInfo bar,
                                int index)
sees if there is free space to add a bar centered at index


fill

public static void fill(java.lang.String[] night,
                        NightPlanner.BarInfo bar,
                        int index)
adds a bar to the night centered at index


probInNight

public boolean probInNight(java.lang.String[] night)
tests for problems in night[]


processMouseEvent

public void processMouseEvent(java.awt.event.MouseEvent e)
handles mouse clicks - mouseDown

Overrides:
processMouseEvent in class java.awt.Component

processMouseMotionEvent

public void processMouseMotionEvent(java.awt.event.MouseEvent e)
handles mouse clicks - mouseDrag

Overrides:
processMouseMotionEvent in class java.awt.Component

update

public void update(java.awt.Graphics g)
Overrides:
update in class java.awt.Canvas

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class java.awt.Canvas

save

public void save()
saves the current bar state


restore

public void restore()
restores the last saved bar state