- Forward


Sampled Dynamic Visual Content
An Introduction with Examples in Java


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Introduction
Back SMYC Forward
  • Dynamic Visual Content:
    • Visual content that changes over time
    • It has been given a variety of different names over the years including movies, videos, films, animations, and marquees
  • Sampling Dynamic Visual Content:
    • Select a discrete set of points in time (called frames)
    • "Record" the action at each time
Sampling Dynamic Visual Content
Back SMYC Forward

An Illustration

dynamic-sampling
Some Observations
Back SMYC Forward
  • Each frame is thought of as a coherent whole
  • Each frame consists of static visual content
  • Each frame can be either sampled or described (and is completely independent of the time-based sampling)
"Quick Start"
Back SMYC Forward
  • Requirements:
    • The system must render a sequence of SimpleContent objects over time
  • To Satisfy this Requirement we Need:
    • An object that manages the collection of SimpleContent objects
    • A process that controls the rendering of the objects in the sequence
    • A GUI component that presents the SimpleContent objects
  • We Have Everything But:
    • An "enhanced" Visualization object to manage the collection of SimpleContent objects
"Quick Start" (cont.)
Back SMYC Forward
  • Alternative Ways to Add these Enhancements:
    • Add code to the Visualization and VisualizationView classes
    • Decorate the Visualization and VisualizationView classes
    • Specialize the Visualization and VisualizationView classes
  • Which is Best?
    • You tell me
"Quick Start" (cont.)
Back SMYC Forward
  • An Obvious Approach to Control the Rendering:
    • Write a loop that calls each SimpleContent object's render() method
  • The Problem:
    • No control over the amount of time each frame is visible
"Quick Start" (cont.)
Back SMYC Forward

Controlling the Timing of the Rendering Process

sampled-dynamics_design-overview
"Quick Start" (cont.)
Back SMYC Forward

Outline of a Screen Class

javaexamples/visual/dynamic/sampled/Screen.java (Fragment: skeleton)
 

Handling Metronome Ticks

javaexamples/visual/dynamic/sampled/Screen.java (Fragment: handleTick)
 
javaexamples/visual/dynamic/sampled/Screen.java (Fragment: advanceFrame)
 

Modifying Behavior in the Parent Class

javaexamples/visual/dynamic/sampled/Screen.java (Fragment: iterator)
 
"Quick Start" (cont.)
Back SMYC Forward

The Rendering Process

sampled-dynamics_sequence1
Double Buffering
Back SMYC Forward
  • A Problem:
    • Dynamic visual content has a tendency to "flicker" when pre-rendering, rendering, and post-rendering takes a "noticeable" abount of time
  • A Solution:
    • Don't have the rendering engine write directly to the screen (i.e., video memory).
    • Have it write to a background image.
Double Buffering (cont.)
Back SMYC Forward
javaexamples/visual/VisualizationView.java (Fragment: doublebuffer1)
 
javaexamples/visual/VisualizationView.java (Fragment: doublebuffer2)
 
javaexamples/visual/VisualizationView.java (Fragment: doublebuffer3)
 
Double Buffering (cont.)
Back SMYC Forward
  • In Java, all Swing components support double buffering
  • The approach used is not suitable for our purposes
  • Hence, we must use our own implementation and deactivate the default buffering
Operating on Multiple Frames
Back SMYC Forward
  • Straight Cut:
    • Frame n+1 is rendered in its entirety immediately after frame n
  • Transition:
    • An alternative way to "join" frames together
Operating on Multiple Frames (cont.)
Back SMYC Forward
  • Fade-In (or Fade-Up):
    • A progressive brightening
    • Most commonly, a "fade from black"
  • Fade-Out (or Fade-To):
    • A progressive darkening
    • Most commonly, a "fade to black"
Operating on Multiple Frames (cont.)
Back SMYC Forward

A Fade Class

javaexamples/visual/dynamic/sampled/Fade.java (Fragment: setDestinationPixels)
 

Pre-Rendering Phase

javaexamples/visual/dynamic/sampled/Fade.java (Fragment: preRendering)
 

Post-Rendering Phase

javaexamples/visual/dynamic/sampled/Fade.java (Fragment: postRendering)
 
Operating on Multiple Frames (cont.)
Back SMYC Forward
  • Dissolve:
    • Frame n fades out while framen+1 fades in
  • The Most Common Dissolve:
    • A fade-in without an intermediate solid background
Operating on Multiple Frames (cont.)
Back SMYC Forward

A Disolve Class

javaexamples/visual/dynamic/sampled/Dissolve.java
 
Operating on Multiple Frames (cont.)
Back SMYC Forward
  • Wipe:
    • A frame (or frames) is clipped to a series of (one or more) geometric shapes
  • Common Wipes:
    • Rectangle Wipe, Circle Wipe, Star Wipe
    • Line Wipe
    • Quivering, Venetian Blind
Operating on Multiple Frames (cont.)
Back SMYC Forward

A RectangleWipe Class

javaexamples/visual/dynamic/sampled/RectangleWipe.java (Fragment: calculateClip)
 

Pre-Rendering Phase

javaexamples/visual/dynamic/sampled/RectangleWipe.java (Fragment: preRendering)
 

Post-Rendering Phase

javaexamples/visual/dynamic/sampled/RectangleWipe.java (Fragment: postRendering)
 
Operating on Multiple Frames (cont.)
Back SMYC Forward

A LineWipe Class

javaexamples/visual/dynamic/sampled/LineWipe.java (Fragment: calculateClip)
 
Operating on Individual Frames
Back SMYC Forward
  • Superimposition:
    • A description of visual content that is to be added to an existing frame
  • Common Types:
    • "Text"
    • "Graphics"
Operating on Individual Frames (cont.)
Back SMYC Forward

An AbstractSuperimposition Class

javaexamples/visual/dynamic/sampled/AbstractSuperimposition.java
 
Operating on Individual Frames (cont.)
Back SMYC Forward

A TransformableContentSuperimposition Class

javaexamples/visual/dynamic/sampled/TransformableContentSuperimposition.java (Fragment: constructor)
 
javaexamples/visual/dynamic/sampled/TransformableContentSuperimposition.java (Fragment: postRendering)
 
Design of a Sampled Dynamic Content System
Back SMYC Forward
  • Requirements:
    • The system must support transitions (other than straight cuts) between frames of sampled dynamic content
    • The system must support the superimposition of static visual content on one or more frames of sampled dynamic content
  • Alternative Designs:
    • There are several to consider
Design of a Sampled Dynamic Content System (cont.)
Back SMYC Forward
sampled-dynamics_ops_design1
Design of a Sampled Dynamic Content System (cont.)
Back SMYC Forward
sampled-dynamics_ops_design2
Design of a Sampled Dynamic Content System (cont.)
Back SMYC Forward
sampled-dynamics_ops_design3
Design of a Sampled Dynamic Content System (cont.)
Back SMYC Forward
sampled-dynamics_ops
Design of a Sampled Dynamic Content System (cont.)
Back SMYC Forward

Common Requirements

javaexamples/visual/dynamic/sampled/FrameOp.java
 
Design (cont.)
Back SMYC Forward

Abstract Implementation

javaexamples/visual/dynamic/sampled/AbstractFrameOp.java
 
Implementation of the Design
Back SMYC Forward

The Screen Class

javaexamples/visual/dynamic/sampled/Screen.java (Fragment: transition1)
 
javaexamples/visual/dynamic/sampled/Screen.java (Fragment: superimposition1)
 
javaexamples/visual/dynamic/sampled/Screen.java (Fragment: transition3)
 
javaexamples/visual/dynamic/sampled/Screen.java (Fragment: transition4)
 
javaexamples/visual/dynamic/sampled/Screen.java (Fragment: superimposition3)
 
javaexamples/visual/dynamic/sampled/Screen.java (Fragment: superimposition4)
 
Implementation of the Design (cont.)
Back SMYC Forward

The ScreenRenderer Class

javaexamples/visual/dynamic/sampled/ScreenRenderer.java (Fragment: preRendering)
 
javaexamples/visual/dynamic/sampled/ScreenRenderer.java (Fragment: postRendering)
 
javaexamples/visual/dynamic/sampled/ScreenRenderer.java (Fragment: render)
 
There's Always More to Learn
Back -