net.kolls.railworld.edit
Class EditCanvas

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by net.kolls.railworld.RailCanvas
              extended by net.kolls.railworld.edit.EditCanvas
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class EditCanvas
extends RailCanvas

A canvas for editing segments. Does not support having trains.

Author:
Steve Kollmansberger
See Also:
Serialized Form

Nested Class Summary
static class EditCanvas.Tool
          The available tools in the edit canvas.
 
Nested classes/interfaces inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 boolean displaySEP
          Should edit points be displayed?
 boolean justSaved
          Still as it was when loaded or saved?
 EditCanvas.Tool selectedTool
          One of the TOOL_* constants.
 javax.swing.JPanel seppanel
          The edit panel provided by the currently selected edit point.
 javax.swing.undo.UndoManager undos
          Allows calls to undo and redo for edits.
 
Fields inherited from class net.kolls.railworld.RailCanvas
la, minisource, miniv, mx, my, orig_src, vx, vy, zoom
 
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
EditCanvas(java.awt.image.BufferedImage s, RailSegment[] lines, MiniViewer mini)
          Construct an edit canvas with a given source image, some segments, and a mini viewer.
 
Method Summary
 void addUndo(javax.swing.undo.UndoableEdit ue)
          Add an undo to the sequence; if a segment creation is in progress, the undo is added to that undo group.
 void doMiniPaint(java.awt.Graphics2D ofg)
          Given the graphics context of the mini image, paint it.
protected  void doPaint(java.awt.Graphics2D ofg, int hvx, int hvy, boolean detailed)
          Paint the main image.
 void leftDrag(java.awt.event.MouseEvent e)
          Called if the left mouse button is held and dragged.
 void leftPress(java.awt.event.MouseEvent e)
          Called if the left mouse button is pressed
 void leftRelease(java.awt.event.MouseEvent e)
          Called if the left mouse button is released
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void recomp()
          Recompute all segment details
 void showEdit()
          Show the edit panel for the selected segment.
 void xymove(int dx, int dy)
          Move the previous selected segment a given amount.
 
Methods inherited from class net.kolls.railworld.RailCanvas
angle, areaSize, draw, drawCanvas, drawOutlineFont, getCenterPoint, getVXY, leftMove, lineAngle, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, stop, submitCenterCoords, submitCoords, trackLength, transform, transform
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, paint, update
 
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, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, 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, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

selectedTool

public EditCanvas.Tool selectedTool
One of the TOOL_* constants.


undos

public javax.swing.undo.UndoManager undos
Allows calls to undo and redo for edits.


justSaved

public boolean justSaved
Still as it was when loaded or saved?


displaySEP

public boolean displaySEP
Should edit points be displayed?


seppanel

public javax.swing.JPanel seppanel
The edit panel provided by the currently selected edit point.

Constructor Detail

EditCanvas

public EditCanvas(java.awt.image.BufferedImage s,
                  RailSegment[] lines,
                  MiniViewer mini)
Construct an edit canvas with a given source image, some segments, and a mini viewer.

Parameters:
s - Source BufferedImage
lines - Array of RailSegments
mini - MiniViewer to use.
Method Detail

recomp

public void recomp()
Description copied from class: RailCanvas
Recompute all segment details

Overrides:
recomp in class RailCanvas

xymove

public void xymove(int dx,
                   int dy)
Move the previous selected segment a given amount. Used for arrow keys.

Parameters:
dx -
dy -

addUndo

public void addUndo(javax.swing.undo.UndoableEdit ue)
Add an undo to the sequence; if a segment creation is in progress, the undo is added to that undo group.

Parameters:
ue - The undo to add

doMiniPaint

public void doMiniPaint(java.awt.Graphics2D ofg)
Description copied from class: RailCanvas
Given the graphics context of the mini image, paint it.

Specified by:
doMiniPaint in class RailCanvas
Parameters:
ofg - A Graphics2D context for the mini image.

doPaint

protected void doPaint(java.awt.Graphics2D ofg,
                       int hvx,
                       int hvy,
                       boolean detailed)
Description copied from class: RailCanvas
Paint the main image.

Specified by:
doPaint in class RailCanvas
Parameters:
ofg - A Graphics2D context for the main image.
hvx - The vy coordinate to use
hvy - The vx coordinate to use
detailed - Should expensive items also be drawn?

leftDrag

public void leftDrag(java.awt.event.MouseEvent e)
Description copied from class: RailCanvas
Called if the left mouse button is held and dragged.

Overrides:
leftDrag in class RailCanvas
Parameters:
e - The mouse event generated

leftRelease

public void leftRelease(java.awt.event.MouseEvent e)
Description copied from class: RailCanvas
Called if the left mouse button is released

Overrides:
leftRelease in class RailCanvas
Parameters:
e - The mouse event generated

showEdit

public void showEdit()
Show the edit panel for the selected segment.


leftPress

public void leftPress(java.awt.event.MouseEvent e)
Description copied from class: RailCanvas
Called if the left mouse button is pressed

Overrides:
leftPress in class RailCanvas
Parameters:
e - The mouse event generated

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener
Overrides:
mouseClicked in class RailCanvas