databionics.esom.renderer.background
Class BackgroundTool

java.lang.Object
  extended by databionics.esom.tool.AbstractTool
      extended by databionics.esom.renderer.background.BackgroundTool
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.util.EventListener

public class BackgroundTool
extends AbstractTool
implements java.awt.event.MouseListener, java.awt.event.KeyListener

GUI-interface to manage the various backgrounds. Delivers a JPanel for the ControlPanel.


Field Summary
protected  javax.swing.JComboBox backgroundBox
          Drop down list to choose backgrounds
protected  java.util.ArrayList backgroundList
          A list containing the backgrounds.
protected  StringList backgroundNames
          A list containing the names oft the backgrounds.
protected  java.text.NumberFormat df
          Number format for parameters for some backgrounds.
protected static org.apache.log4j.Logger log
          interface to log4j system.
protected  LoadBMFileAction noBmCapture
          This Action will load a *.bm into if the Background is missing one.
protected  LoadLrnFileAction noLrnCapture
          This Action will load a *.lrn into if the Background is missing one.
protected  LoadWtsFileAction noWtsFileCapture
          This Action will load a *.wts file if the Background is missing one.
protected  javax.swing.JPanel pnlBackgroundChooser
          Panel containing the different GUI elements.
 
Fields inherited from class databionics.esom.tool.AbstractTool
application, bottomBar, bottomTab, btnClear, btnLoad, btnPaint, btnSave, clearItm, clickMode, controlButton, creatorPanel, dataTable, dataTableModel, displayPanel, dragMode, drawing, fileMenu, filename, gui, loader, loadItm, moveCallback, pnlControl, polygonMode, popMenu, removeItm, renderer, renderPanel, saveItm, toolBar, toolRenderer
 
Constructor Summary
BackgroundTool(boolean gui, Application application)
          Standard Constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Event handling for background GUI elements.
protected  java.lang.String fallback()
          If for any reason a Background might not work, this can be called as a fallback on the UMatrix.
 void findBackgrounds(java.lang.String dir, java.lang.String jar, java.lang.String pkg, java.lang.String sclass)
          Finds classes that render backgrounds from *.jar file.
 BackgroundRenderer getActualRenderer()
          workaround
 BackgroundRenderer getBackgroundByName(java.lang.String name)
          Get a Background by its name.
 java.lang.String getShortTitle()
           
 void init()
          Find backgrounds automatically.
 void initGui(RenderPanel renderPanel, BottomBar bottomBar)
          Let the tool know the references to relevant GUI elements.
 void initRenderer()
          Initialize the main renderer with the current settings.
 void keyPressed(java.awt.event.KeyEvent e)
          donothing.
 void keyReleased(java.awt.event.KeyEvent e)
          Event handling for edit fields.
 void keyTyped(java.awt.event.KeyEvent e)
          donothing.
 void mouseClicked(java.awt.event.MouseEvent e)
          donothing.
 void mouseEntered(java.awt.event.MouseEvent e)
          donothing.
 void mouseExited(java.awt.event.MouseEvent e)
          donothing.
 void mousePressed(java.awt.event.MouseEvent e)
          donothing.
 void mouseReleased(java.awt.event.MouseEvent e)
          Event handling for the sliders.
 void reset()
          Reset the Cache of all Backgrounds.
 void setLoader(ToolLoader loader)
           
 void setUmxLoaded(boolean umx)
          Set the flag if a height matrix (*.umx) but no Grid (*.wts) is loaded.
protected  boolean showBackground(java.lang.String name)
           
 void update()
          Updates the GUI elements dependent on the flag umxLoaded.
 
Methods inherited from class databionics.esom.tool.AbstractTool
callback, getApplication, getBottomTab, getCallback, getControlButton, getCreatorPanel, getDataTable, getDataTableModel, getDisplayPanel, getFileMenu, getFilename, getLoader, getMessage, getMoveCallback, getPnlControl, getPopMenu, getRenderer, getToolBar, getToolRenderer, isClickMode, isDragMode, isDrawing, isGui, isPolygonMode, moveSelection, reAreas, reColorize, reDraw, reFore, reMask, rePostFore, rePreFore, reRender, reTile, reZoom, select, setApplication, setBottomTab, setCallback, setClickMode, setControlButton, setCreatorPanel, setCtrlAccelerator, setDataTable, setDataTableModel, setDisplayPanel, setDragMode, setDrawing, setFilename, setMoveCallback, setPolygonMode, setRenderer, setToolBar
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.log4j.Logger log
interface to log4j system.


backgroundList

protected java.util.ArrayList backgroundList
A list containing the backgrounds. Filled automatically.


backgroundNames

protected StringList backgroundNames
A list containing the names oft the backgrounds. Filled automatically. The name is the prefix of the class name, e.g. UMatrix for UMatrixRenderer.


backgroundBox

protected javax.swing.JComboBox backgroundBox
Drop down list to choose backgrounds


df

protected java.text.NumberFormat df
Number format for parameters for some backgrounds.


noLrnCapture

protected LoadLrnFileAction noLrnCapture
This Action will load a *.lrn into if the Background is missing one.


noBmCapture

protected LoadBMFileAction noBmCapture
This Action will load a *.bm into if the Background is missing one.


noWtsFileCapture

protected LoadWtsFileAction noWtsFileCapture
This Action will load a *.wts file if the Background is missing one.


pnlBackgroundChooser

protected javax.swing.JPanel pnlBackgroundChooser
Panel containing the different GUI elements.

Constructor Detail

BackgroundTool

public BackgroundTool(boolean gui,
                      Application application)
Standard Constructor. Initialises the actions to load missing files. Sets up the the layout to control the background.

Parameters:
gui - flag whether the tool is used from the GUI
application - reference to the running application
Method Detail

findBackgrounds

public void findBackgrounds(java.lang.String dir,
                            java.lang.String jar,
                            java.lang.String pkg,
                            java.lang.String sclass)
Finds classes that render backgrounds from *.jar file.

Parameters:
dir - directory to look in.
jar - jar to look for.
pkg - package to look in.
sclass - superclass to find subclasses of.

fallback

protected java.lang.String fallback()
If for any reason a Background might not work, this can be called as a fallback on the UMatrix.

Returns:
"UMatrix" a string. not really neccessary.

initGui

public void initGui(RenderPanel renderPanel,
                    BottomBar bottomBar)
Let the tool know the references to relevant GUI elements. Calls super() and registers a MouseListener at the ControlPanel.

Overrides:
initGui in class AbstractTool
Parameters:
controlPanel - ControlPanel
renderPanel - RenderPanel
bottomBar - BottomBar
See Also:
databionics.esom.tool.AbstractTool#initGui(databionics.esom.gui.ControlPanel, databionics.esom.gui.RenderPanel, databionics.esom.gui.BottomBar)

initRenderer

public void initRenderer()
Initialize the main renderer with the current settings.


init

public void init()
Find backgrounds automatically.

Specified by:
init in class AbstractTool

reset

public void reset()
Reset the Cache of all Backgrounds.

Specified by:
reset in class AbstractTool

update

public void update()
Updates the GUI elements dependent on the flag umxLoaded.

Overrides:
update in class AbstractTool

getBackgroundByName

public BackgroundRenderer getBackgroundByName(java.lang.String name)
Get a Background by its name. The name is the prefix of the class name, e.g. UMatrix for UMatrixRenderer.

Parameters:
name - the name of the background.
Returns:
the background if found otherwise null.

showBackground

protected boolean showBackground(java.lang.String name)

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Event handling for background GUI elements.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Overrides:
actionPerformed in class AbstractTool
Parameters:
e - an ActionEvent

getActualRenderer

public BackgroundRenderer getActualRenderer()
workaround


mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
donothing.

Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
donothing.

Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
donothing.

Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
donothing.

Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Event handling for the sliders.

Specified by:
mouseReleased in interface java.awt.event.MouseListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
donothing.

Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Event handling for edit fields.

Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
donothing.

Specified by:
keyTyped in interface java.awt.event.KeyListener

setUmxLoaded

public void setUmxLoaded(boolean umx)
Set the flag if a height matrix (*.umx) but no Grid (*.wts) is loaded.

Parameters:
umx -

getShortTitle

public java.lang.String getShortTitle()
Specified by:
getShortTitle in class AbstractTool

setLoader

public void setLoader(ToolLoader loader)
Overrides:
setLoader in class AbstractTool
Parameters:
loader - The loader to set.


Copyright © 2005-2006 Databionics Research Group. All Rights Reserved.