vmm.fractals
Class Mandelbrot.MandelbrotView

java.lang.Object
  extended by vmm.core.View
      extended by vmm.fractals.Mandelbrot.MandelbrotView
All Implemented Interfaces:
java.util.EventListener, javax.swing.event.ChangeListener, Decorateable, Parameterizable
Enclosing class:
Mandelbrot

public class Mandelbrot.MandelbrotView
extends View

A View class suitable for viewing a Mandelbrot exhibit. The view for a Mandelbrot exhibit MUST be of this type. This class modifies the usual behavior of a View extensively to account for the fact that the basic data for a Mandelbrot exhibit is the bitmap on which the Mandelbrot is drawn. This view class has been rigged to make sure that this bitmap is not redrawn more often than necessary. For example, decorations are not drawn to the bitmap; instead, they are drawn over the bitmap each time the view is repainted.


Field Summary
static int SHOW_BOTH
           
static int SHOW_JULIA
           
static int SHOW_NONE
           
static int SHOW_ORBIT
           
 
Fields inherited from class vmm.core.View
backgroundCommands, buildAnimation, buildingImageForFilmstrip, currentGraphics, decorations, directOffscreenDrawing, fullOSI, needsRedraw, offscreenImageType, parameters, showAxesAction
 
Constructor Summary
Mandelbrot.MandelbrotView()
           
 
Method Summary
 void doZoom(double magnificationFactor)
          Zooms the display by a specified magnification factor.
 void drawOvalDirect(java.awt.Color c, int x, int y, int width, int height)
           
 void fillOvalDirect(java.awt.Color c, int x, int y, int width, int height)
           
 ActionList getActions()
          Generates a list of "Action commands" that can be applied to this View.
 MouseTask getDefaultMouseTask()
          Overridden to return a mouse task that will let the user drag the Julia set point.
 java.awt.image.BufferedImage getImage(boolean alwaysCopy)
          Has been overridden because the usual bitmap for this view does not contain the decorations.
 int getShowJuliaAndOrbit()
          Returns the value of the showJuliaAndOrbit property.
 java.lang.String getStatusText()
          This method is called by the display to determine what message to show in the status bar when this view is active.
 void parameterChanged(Parameter param, java.lang.Object oldValue, java.lang.Object newValue)
          Overridden to force a redraw of the Mandelbrot bitmap if it is the maximum iteration count that is changing.
 void render(java.awt.Graphics2D g, int width, int height)
          The render method has been modified to draw the mandelbrot set directly to the bitmap.
 void setFastDrawing(boolean fast, boolean redrawSynchronizedViews)
          Overridden to force a redraw of the Mandelbrot bitmap.
 void setShowJuliaAndOrbit(int showJuliaAndOrbit)
          Sets the value of the showJuliaAndOrbit property.
 void stateChanged(javax.swing.event.ChangeEvent evt)
          Overridden to force a redraw of the Mandelbrot bitmap if it is the transform that is changing.
 void takeExhibit(View view, boolean shareTransform)
          Has been overridden to copy the maximum iteration count, if the shareTransform parameter is true.
 
Methods inherited from class vmm.core.View
addDecoration, addExtraXML, addParameter, beginDrawToOffscreenImage, clearDecorations, clearOSI, createAxes, createOSI, doDraw, drawCurve, drawCurve, drawCurve, drawDot, drawLine, drawLine, drawLineDirect, drawPixel, drawPixel, drawPixelDirect, drawPixels, drawString, drawString, endDrawToOffscreenImage, fillRectDirect, finish, finishOSIDraw, forceRedraw, getActionsForViewAndExhibit, getAdditionalAnimations, getAdditionalAnimationsForViewAndExhibit, getAntialiased, getApplyGraphics2DTransform, getBackground, getColor, getDecorations, getDisplay, getExhibit, getFastDrawing, getForeground, getName, getParameterByName, getParameters, getPreserveAspect, getRequestedWindow, getSettingsCommands, getSettingsCommandsForViewAndExhibit, getShowAxes, getTitle, getTransform, getViewAndExhibitParameters, getViewCommands, getWindow, needsNewOSI, prepareOSIForDrawing, putOSI, readExtraXML, removeDecoration, removeParameter, setAntialiased, setApplyGraphics2DTransform, setBackground, setColor, setDisplay, setExhibit, setFastDrawing, setForeground, setName, setPreserveAspect, setShowAxes, setStrokeSizeMultiplier, setTransform, setWindow, setWindow
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHOW_JULIA

public static final int SHOW_JULIA
See Also:
Constant Field Values

SHOW_ORBIT

public static final int SHOW_ORBIT
See Also:
Constant Field Values

SHOW_BOTH

public static final int SHOW_BOTH
See Also:
Constant Field Values

SHOW_NONE

public static final int SHOW_NONE
See Also:
Constant Field Values
Constructor Detail

Mandelbrot.MandelbrotView

public Mandelbrot.MandelbrotView()
Method Detail

doZoom

public void doZoom(double magnificationFactor)
Zooms the display by a specified magnification factor. A magnification factor greater than 1 is a zoom in; a magnification factor less than 1 is a zoom out. The magnification factor must be greater than zero (this is not checked).


getShowJuliaAndOrbit

public int getShowJuliaAndOrbit()
Returns the value of the showJuliaAndOrbit property.

See Also:
setShowJuliaAndOrbit(int)

setShowJuliaAndOrbit

public void setShowJuliaAndOrbit(int showJuliaAndOrbit)
Sets the value of the showJuliaAndOrbit property. A Mandelbrot exhibit has an associated decoration that is capable of showing an outline of the Julia set and the zero orbit associated with some value of c. The showJuliaAndOrbit property of the view determines what is actually shown of this decoration in this view. The values are given by constants SHOW_NONE, SHOW_BOTH, SHOW_JUILA, and SHOW_ORBIT which are defined in this class.


getActions

public ActionList getActions()
Description copied from class: View
Generates a list of "Action commands" that can be applied to this View. The commands must implement the ActionItem interface and will generally belong to one of the classes AbstractActionVMM, ToggleAction, ActionRadioGroup, or ActionList. Null items represent separators. The idea is that the list items will be added to a menu or otherwise presented to the user so that the user can invoke the commands (with ActionList items representing submenus). Null values can occur in the list; they are meant to become separaters in the menu.

Subclasses that override this method should generally call super.getActionss() and add their commands to the list retured by that method. This top-level View class does not define any Action commands; the return value is an empty non-null ArrayList.

Overrides:
getActions in class View

getStatusText

public java.lang.String getStatusText()
Description copied from class: View
This method is called by the display to determine what message to show in the status bar when this view is active. This message is used when there is no animation or one-shot mouse task active and the default mouse task's getStatusText returns null. If the return value is null, then the title of the exhibit is used as the status string (or, if there is no exhibit, then the string "No Exhibit" is used (in the English version)).

Overrides:
getStatusText in class View
Returns:
returns null to use the default string.

setFastDrawing

public void setFastDrawing(boolean fast,
                           boolean redrawSynchronizedViews)
Overridden to force a redraw of the Mandelbrot bitmap.

Overrides:
setFastDrawing in class View
See Also:
View.setFastDrawing(boolean)

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent evt)
Overridden to force a redraw of the Mandelbrot bitmap if it is the transform that is changing.

Specified by:
stateChanged in interface javax.swing.event.ChangeListener
Overrides:
stateChanged in class View
See Also:
View.forceRedraw()

parameterChanged

public void parameterChanged(Parameter param,
                             java.lang.Object oldValue,
                             java.lang.Object newValue)
Overridden to force a redraw of the Mandelbrot bitmap if it is the maximum iteration count that is changing. (In fact, this is the only parameter defined for this class.)

Specified by:
parameterChanged in interface Parameterizable
Overrides:
parameterChanged in class View
Parameters:
param - The Parmeter whose value has been set.
oldValue - The previous value of the parameter.
newValue - The new, current value of the parameter. This is not necessarily guaranteed to be different from the old value (although it is for parameters definedin the VMM core).
See Also:
View.forceRedraw()

drawOvalDirect

public void drawOvalDirect(java.awt.Color c,
                           int x,
                           int y,
                           int width,
                           int height)

fillOvalDirect

public void fillOvalDirect(java.awt.Color c,
                           int x,
                           int y,
                           int width,
                           int height)

render

public void render(java.awt.Graphics2D g,
                   int width,
                   int height)
The render method has been modified to draw the mandelbrot set directly to the bitmap. The usual rendering is not used; in particular, the computeDrawData and doDraw methods of the Mandelbrot exhibit are not called.

Overrides:
render in class View
Parameters:
g - The graphics context where the Exhibit is to be drawn. It is assumed that the upper left corner of the drawing area has coordinates (0,0). The off-screen image is simply drawn in g, except that when no exhibit exists, it is filled with the background color.
width - The width, in pixels, of the drawing area where the exhibit is to be drawn.
height - The height, in pixels, of the drawing area where the exhibit is to be drawn.

getImage

public java.awt.image.BufferedImage getImage(boolean alwaysCopy)
Has been overridden because the usual bitmap for this view does not contain the decorations. A new BufferedImage is created that shows both the andelbrot set bitmap and the decorations.

Overrides:
getImage in class View
Parameters:
alwaysCopy - If this is false, it is possible that the image that is returned is the actual image that the View uses to store its content; this image will be modified whenever the view is redrawn. (alwaysCopy = true is used to get the frame for a filmstrip; alwaysCopy = false is used to get an image to save to a file)

takeExhibit

public void takeExhibit(View view,
                        boolean shareTransform)
Has been overridden to copy the maximum iteration count, if the shareTransform parameter is true. (Otherwise, if the view has been zoomed in a lot, the synchronized view might be entirely black.)

Overrides:
takeExhibit in class View
Parameters:
view - The view whose Exhibit is to be copied. After the method is called, both views will be drawing the same exhibit. If null, then the exhibit of this view will also be set to null.
shareTransform - If true, the two views will share the same Transform, so that changes made to the transform in one will also result in a change in the other.

getDefaultMouseTask

public MouseTask getDefaultMouseTask()
Overridden to return a mouse task that will let the user drag the Julia set point. If the user does not click near the start point, the mouse task behaves the same as a usual BasicMouseTask2D.

Overrides:
getDefaultMouseTask in class View
Returns:
The value returned in the top-level View class is a BasicMouseTask2D, which allows dragging and zooming of the 2D window.
See Also:
MouseTask