Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

exptree.utilities
Class imageGenerator  view imageGenerator download imageGenerator.java

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byexptree.utilities.imageGenerator
All Implemented Interfaces:
java.lang.Cloneable, java.awt.image.ImageObserver, java.awt.MenuContainer, java.lang.Runnable, java.io.Serializable

public class imageGenerator
extends javax.swing.JComponent
implements java.lang.Runnable, java.lang.Cloneable

Generates an image based on expressionTrees. Currently, this supports images in the RGB and HSB colorspaces, and therefore takes 3 expressionTrees. The image generation takes place in a thread, and does not begin until the startIt() method is called.

Version:
1.1 08/19/2000

Nested Class Summary
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  javax.swing.event.ChangeEvent changeEvent
           
(package private)  java.awt.image.ColorModel colorModel
           
(package private)  exptree.expressionTree[] expressions
          The actual expressionTrees that describe the image.
(package private)  boolean finished
           
protected  javax.swing.event.ChangeEvent finishedEvent
           
protected  javax.swing.event.EventListenerList finishedListenerList
           
(package private)  java.awt.image.BufferedImage image
          Stores the generated image.
(package private)  int imageHeight
          The image's imageWidth and imageHeight.
(package private)  int imageWidth
          The image's imageWidth and imageHeight.
protected  javax.swing.event.EventListenerList listenerList
           
(package private)  double magnification
           
private static double map_height
           
private static double PI_OVER_TWO
           
(package private)  myComponents.myProgressMonitor pm
           
(package private)  java.awt.image.WritableRaster raster
           
(package private)  settings.globalSettings settings
          Local copy of the settings package.
(package private)  java.lang.Thread theThread
           
(package private)  boolean threadKeepRunning
           
(package private)  exptree.variable[] variables
          The set of variables retrieved from the variablePackage.
(package private)  variablePackage vp
           
(package private)  double x_translation
           
(package private)  double y_translation
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
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
imageGenerator(settings.globalSettings s, imageGeneratorParams params, myComponents.myProgressMonitor myPM, java.awt.Dimension D)
          Class constuctor.
 
Method Summary
 void addChangeListener(javax.swing.event.ChangeListener l)
          Adds a ChangeListener to the image.
 void addFinishedListener(javax.swing.event.ChangeListener l)
          Adds a ChangeListener to the image.
protected  java.lang.Object clone()
          This method may be called to create a new copy of the Object.
protected  void fireFinished()
          Notify all listeners that have registered interest for notification on this event type.
protected  void fireStateChanged()
          Notify all listeners that have registered interest for notification on this event type.
 imageGenerator getClone()
           
 java.awt.image.BufferedImage getImage()
           
 imageGeneratorParams getImageGeneratorParams()
           
 java.awt.Dimension getSize(java.awt.Dimension rv)
          Get the component's size.
private  java.awt.image.BufferedImage initImage(int width, int height)
           
 boolean isFinished()
           
(package private) static double map(double a)
           
 void paint(java.awt.Graphics g)
          Paint the component.
 void removeChangeListener(javax.swing.event.ChangeListener l)
          Removes a ChangeListener from the button.
 void removeFinishedListener(javax.swing.event.ChangeListener l)
          Removes a ChangeListener from the button.
 void run()
          Thread which actually generates the image.
 void setImageSize(int w, int h)
           
 void setPreferredSize(java.awt.Dimension d)
          Sets the component's preferred size, as well as the size of the image to generate.
 void setProgressMonitor(myComponents.myProgressMonitor p)
           
 void setSize(java.awt.Dimension d)
          Sets the component's size, as well as the size of the image to generate.
 void setSize(int w, int h)
          Sets the component's size, as well as the size of the image to generate.
 void startIt()
           
 void stop()
           
 java.lang.String toString()
          Returns a string representation of this component.
 void update(java.awt.Graphics g)
          Call paint(java.awt.Graphics) 55 .
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, 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, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, 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, 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, processMouseEvent, 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, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

image

java.awt.image.BufferedImage image
Stores the generated image.


settings

settings.globalSettings settings
Local copy of the settings package.


variables

exptree.variable[] variables
The set of variables retrieved from the variablePackage.


vp

variablePackage vp

expressions

exptree.expressionTree[] expressions
The actual expressionTrees that describe the image.


imageWidth

int imageWidth
The image's imageWidth and imageHeight.


imageHeight

int imageHeight
The image's imageWidth and imageHeight.


theThread

java.lang.Thread theThread

threadKeepRunning

boolean threadKeepRunning

colorModel

java.awt.image.ColorModel colorModel

raster

java.awt.image.WritableRaster raster

finished

boolean finished

magnification

double magnification

x_translation

double x_translation

y_translation

double y_translation

pm

transient myComponents.myProgressMonitor pm

changeEvent

protected transient javax.swing.event.ChangeEvent changeEvent

listenerList

protected javax.swing.event.EventListenerList listenerList

finishedEvent

protected transient javax.swing.event.ChangeEvent finishedEvent

finishedListenerList

protected javax.swing.event.EventListenerList finishedListenerList

map_height

private static final double map_height

PI_OVER_TWO

private static final double PI_OVER_TWO
See Also:
Constant Field Values
Constructor Detail

imageGenerator

public imageGenerator(settings.globalSettings s,
                      imageGeneratorParams params,
                      myComponents.myProgressMonitor myPM,
                      java.awt.Dimension D)
Class constuctor.

Method Detail

setProgressMonitor

public void setProgressMonitor(myComponents.myProgressMonitor p)

setSize

public void setSize(int w,
                    int h)
Sets the component's size, as well as the size of the image to generate.


setSize

public void setSize(java.awt.Dimension d)
Sets the component's size, as well as the size of the image to generate.


setPreferredSize

public void setPreferredSize(java.awt.Dimension d)
Sets the component's preferred size, as well as the size of the image to generate.


setImageSize

public void setImageSize(int w,
                         int h)

startIt

public void startIt()

run

public void run()
Thread which actually generates the image.

Specified by:
run in interface java.lang.Runnable

stop

public void stop()

paint

public void paint(java.awt.Graphics g)
Description copied from class: javax.swing.JComponent

Paint the component. This is a delicate process, and should only be called from the repaint thread, under control of the javax.swing.RepaintManager. Client code should usually call Component.repaint()>Component.repaint() 55 to trigger painting.

The body of the paint call involves calling JComponent.paintComponent(java.awt.Graphics)>JComponent.paintComponent(java.awt.Graphics) 55 , JComponent.paintBorder(java.awt.Graphics)>JComponent.paintBorder(java.awt.Graphics) 55 , and JComponent.paintChildren(java.awt.Graphics)>JComponent.paintChildren(java.awt.Graphics) 55 in order. If you want to customize painting behavior, you should override one of these methods rather than paint.

For more details on the painting sequence, see this article.


update

public void update(java.awt.Graphics g)
Description copied from class: javax.swing.JComponent
Call JComponent.paint(java.awt.Graphics)>JComponent.paint(java.awt.Graphics) 55 .


getImage

public java.awt.image.BufferedImage getImage()

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener l)
Adds a ChangeListener to the image.


removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener l)
Removes a ChangeListener from the button.


fireStateChanged

protected void fireStateChanged()
Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.


addFinishedListener

public void addFinishedListener(javax.swing.event.ChangeListener l)
Adds a ChangeListener to the image.


removeFinishedListener

public void removeFinishedListener(javax.swing.event.ChangeListener l)
Removes a ChangeListener from the button.


fireFinished

protected void fireFinished()
Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.


clone

protected java.lang.Object clone()
Description copied from class: java.lang.Object
This method may be called to create a new copy of the Object. The typical behavior is as follows:
  • o == o.clone() is false
  • o.getClass() == o.clone().getClass() is true
  • o.equals(o) is true

However, these are not strict requirements, and may be violated if necessary. Of the three requirements, the last is the most commonly violated, particularly if the subclass does not override Object.equals(Object)>Object.equals(Object) 55 .

If the Object you call clone() on does not implement java.lang.Cloneable (which is a placeholder interface), then a CloneNotSupportedException is thrown. Notice that Object does not implement Cloneable; this method exists as a convenience for subclasses that do.

Object's implementation of clone allocates space for the new Object using the correct class, without calling any constructors, and then fills in all of the new field values with the old field values. Thus, it is a shallow copy. However, subclasses are permitted to make a deep copy.

All array types implement Cloneable, and override this method as follows (it should never fail):

 public Object clone()
 {
   try
     {
       super.clone();
     }
   catch (CloneNotSupportedException e)
     {
       throw new InternalError(e.getMessage());
     }
 }
 


getClone

public imageGenerator getClone()

initImage

private java.awt.image.BufferedImage initImage(int width,
                                               int height)

isFinished

public boolean isFinished()

getImageGeneratorParams

public imageGeneratorParams getImageGeneratorParams()

toString

public java.lang.String toString()
Description copied from class: java.awt.Component
Returns a string representation of this component. This is implemented as getClass().getName() + '[' + paramString() + ']'.


map

static double map(double a)

getSize

public java.awt.Dimension getSize(java.awt.Dimension rv)
Description copied from class: javax.swing.JComponent
Get the component's size. The passed-in java.awt.Dimension value will be used as the return value, if possible.