javamorph
Class CFrame

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JLabel
                  extended by javamorph.CFrame
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants

public class CFrame
extends JLabel

Version:
1.1
Author:
claus.erhard.wimmer@googlemail.com
Program: JavaMorph V 1.1.
Class: CFrame.
License: GPLv2.
Description: JComponent to show either the left picture of the right one.
Hint: Paint operation also performed by the four decorators (a pattern).
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JLabel
JLabel.AccessibleJLabel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static Color BACKGROUND
          Background color of this component.
private  double[][] clip
          Polygon's smoothed clip matrix.
private  CMeshDecorator dmesh
          Decorator to draw & edit the morph mesh.
private  CPictureDecorator dpicture
          Decorator to draw & edit the picture as subject of this program.
private  CPolygonDecorator dpolygon
          Decorator to draw & edit the clip polygon.
private  CPopupMenuDecorator dpopup
          Decorator to provide the pop up menu.
static int EDIT_MESH
          Constant for pop up menu edit command: Edit the mesh.
static int EDIT_POLYGON
          Constant for pop up menu edit command: Edit the polygon.
private  File f_clip
          File to store a debug copy of the clip matrix.
private  BufferedImage image
          Picture itself.
private  Vector<Point> mesh
          Picture's mesh.
private  BufferedImage moffline
          Double buffer image to avoid flickering effects.
private  CMain parent
          Parent frame which lays out this component.
private  Vector<Point> polygon
          Picture's clip polygon points.
static Dimension PREF_SIZE
          Preferred paint size of this component.
private static long serialVersionUID
          Java API.
 
Fields inherited from class javax.swing.JLabel
labelFor
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
CFrame(CMain parent, Vector<Point> mesh, Vector<Point> polygon, BufferedImage image, double[][] clip, File f_mesh, File f_polygon, File f_clip)
          Constructor.
 
Method Summary
 void genClip()
           
 Rectangle getImageBounds()
          Return the position & the size of the drawn image within the component.
 CMain getParent()
          Obtain the instance of the application's main class.
 Dimension getPreferredSize()
          Java API.
 void initMesh()
          Delete content of mesh.
 void initPolygon()
          Delete polygon.
 void paint(Graphics g)
          Paint this component to the screen.
 int scaleMarkSize()
          Scale mark & cursor size simultan.
 void scalePoint(Point p)
          Scale a screen point to a picture point.
 void update(Graphics g)
          Java API.
 
Methods inherited from class javax.swing.JLabel
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, 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, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, 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, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Java API.

See Also:
Constant Field Values

PREF_SIZE

public static final Dimension PREF_SIZE
Preferred paint size of this component.


BACKGROUND

public static final Color BACKGROUND
Background color of this component.


EDIT_MESH

public static final int EDIT_MESH
Constant for pop up menu edit command: Edit the mesh.

See Also:
Constant Field Values

EDIT_POLYGON

public static final int EDIT_POLYGON
Constant for pop up menu edit command: Edit the polygon.

See Also:
Constant Field Values

parent

private CMain parent
Parent frame which lays out this component.


dmesh

private CMeshDecorator dmesh
Decorator to draw & edit the morph mesh.


dpicture

private CPictureDecorator dpicture
Decorator to draw & edit the picture as subject of this program.


dpolygon

private CPolygonDecorator dpolygon
Decorator to draw & edit the clip polygon.


dpopup

private CPopupMenuDecorator dpopup
Decorator to provide the pop up menu.


moffline

private BufferedImage moffline
Double buffer image to avoid flickering effects.


mesh

private Vector<Point> mesh
Picture's mesh.


polygon

private Vector<Point> polygon
Picture's clip polygon points.


image

private BufferedImage image
Picture itself.


clip

private double[][] clip
Polygon's smoothed clip matrix.


f_clip

private File f_clip
File to store a debug copy of the clip matrix.

Constructor Detail

CFrame

public CFrame(CMain parent,
              Vector<Point> mesh,
              Vector<Point> polygon,
              BufferedImage image,
              double[][] clip,
              File f_mesh,
              File f_polygon,
              File f_clip)
Constructor.

Parameters:
parent - Main JFrame.
mesh - Picture's mesh.
polygon - Clip polygon points.
image - Picture itself.
clip - Smoothed clip matrix.
f_mesh - File to store to mesh to.
f_polygon - File to store the polygon to.
f_clip - File to debug the smoothed clip matrix to.
Method Detail

paint

public void paint(Graphics g)
Paint this component to the screen. Call the decorators therefore.

Overrides:
paint in class JComponent

update

public void update(Graphics g)
Java API.

Overrides:
update in class JComponent

getPreferredSize

public Dimension getPreferredSize()
Java API. Constant used as return.

Overrides:
getPreferredSize in class JComponent

getImageBounds

public Rectangle getImageBounds()
Return the position & the size of the drawn image within the component.

Returns:
Bounds in screen pixel units relating to this component.

getParent

public CMain getParent()
Obtain the instance of the application's main class.

Overrides:
getParent in class Component

genClip

public void genClip()

scalePoint

public void scalePoint(Point p)
Scale a screen point to a picture point.

Parameters:
p - Point in screen resolution units.

scaleMarkSize

public int scaleMarkSize()
Scale mark & cursor size simultan. (Regression.)

Returns:
Mark size to be draw by scaling decorator.

initMesh

public void initMesh()
Delete content of mesh. Initialize matrix controlled by configuration_s number of rows & columns.


initPolygon

public void initPolygon()
Delete polygon. Initialize controlled by configuration's number of points.