ewe.graphics
Class Mosaic

java.lang.Object
  extended byewe.ui.ControlBase
      extended byewe.ui.Control
          extended byewe.ui.Container
              extended byewe.ui.Canvas
                  extended byewe.graphics.Mosaic
All Implemented Interfaces:
CellConstants, ControlConstants, EventListener, ImageRefresher, IScroll, ScrollClient, TimerProc, UIConstants
Direct Known Subclasses:
MosaicPanel

public class Mosaic
extends Canvas
implements ImageRefresher

A Mosaic is used to display multiple images, each of which may be able to move and or be animated. The Mosaic ensures that, should an image need to be refreshed due to being moved or changed, that an effecient screen refresh will be done.

Mosaic is also the base object for a MosaicPanel - which provides convenience methods to detect when the user presses/drags the pen/mouse on an image in the Mosaic.

MosaicPanel is also the base object for an InteractivePanel - which provides methods to move images when the user drags them with the pen/mouse and also to detect when one image is being dragged over another.


Field Summary
 Image backgroundImage
          Set this to be a backgroundImage.
protected  boolean firstSnap
           
 ImageList images
          These are the images in the Mosaic.
protected  boolean pauseSnapShots
           
 boolean quickDragging
          Set this true IF, while one image is being dragged no other images will change.
 
Fields inherited from class ewe.ui.Canvas
isFullScrollClient, origin, scrollPercent, virtualSize
 
Fields inherited from class ewe.ui.Container
closedFocus, cycleFocus, dontAutoScroll, dontFocusOnChildren
 
Fields inherited from class ewe.ui.Control
_debug, backGround, beforeRemoved, borderColor, borderStyle, borderWidth, children, columns, constraints, DoPaintMethod, dragging, dragResolution, dragTime, exitKeys, fieldTransfer, font, foreGround, haveNativePaint, height, holdDownPause, holdTick, hotKey, image, lastSelected, listeners, maxHeight, maxWidth, menuState, minHeight, minWidth, modifiers, MyClass, name, next, np, parent, penStatus, popupSound, popupSoundClip, preferredHeight, preferredWidth, prev, prompt, promptControl, rows, ss, standardBorder, standardEdge, startDragResolution, tags, tail, text, toolTip, width, x, y
 
Fields inherited from class ewe.ui.ControlBase
clipItems, clipObject, clipOwner, curPoint, currentPenEvent, debugControl, debugFlag, DidHoldDown, doubleBuffer, doubleClickTime, firstPress, globalDrawFlat, globalEditable, globalEnabled, globalPalmStyle, globalSmallControls, GotPenDown, PenIsOn, pressPoint, TAG_LAST_USER_DATA, TAG_USER_DATA, TAKE_FIRST_PRESS, unnamed, useNativeTextInput
 
Fields inherited from interface ewe.fx.ImageRefresher
KEEP_VISIBLE
 
Fields inherited from interface ewe.ui.IScroll
Higher, Horizontal, Lower, OPTION_INDICATOR_ONLY, PageHigher, PageLower, ScrollHigher, ScrollLower, TrackTo, Vertical
 
Fields inherited from interface ewe.ui.UIConstants
BDR_DOTTED, BDR_INNER, BDR_NOBORDER, BDR_OUTER, BDR_OUTLINE, BDR_RAISEDINNER, BDR_RAISEDOUTER, BDR_SUNKENINNER, BDR_SUNKENOUTER, BF_BOTTOM, BF_BOTTOMLEFT, BF_BOTTOMRIGHT, BF_BUTTON, BF_DIAGONAL, BF_DIAGONAL_ENDBOTTOMLEFT, BF_DIAGONAL_ENDBOTTOMRIGHT, BF_DIAGONAL_ENDTOPLEFT, BF_DIAGONAL_ENDTOPRIGHT, BF_EXACT, BF_FLAT, BF_LEFT, BF_MIDDLE, BF_MONO, BF_PALM, BF_RECT, BF_RIGHT, BF_SOFT, BF_SQUARE, BF_TOP, BF_TOPLEFT, BF_TOPRIGHT, EDGE_BUMP, EDGE_ETCHED, EDGE_RAISED, EDGE_SUNKEN
 
Fields inherited from interface ewe.ui.CellConstants
BORDER, BOTTOM, CELLFLAG, CELLMASK, CENTER, CONTROLMASK, DONTCHANGE, DONTFILL, DONTSTRETCH, EAST, FILL, FIXEDSIZE, GROW, HCENTER, HCONTRACT, HEXPAND, HFILL, HGROW, HSHRINK, HSTRETCH, INITIALLY_CLOSED, INITIALLY_MINIMIZED, INITIALLY_PREFERRED_SIZE, INSETS, LEFT, MAXIMUMSIZE, MINIMUMSIZE, NORTH, NORTHEAST, NORTHWEST, PREFERREDSIZE, RECT, RIGHT, SHRINK, SOUTH, SOUTHEAST, SOUTHWEST, SPAN, STRETCH, TEXTSIZE, TOP, VCENTER, VCONTRACT, VEXPAND, VFILL, VGROW, VSHRINK, VSTRETCH, WEST
 
Fields inherited from interface ewe.ui.ControlConstants
All, AlwaysEnabled, AlwaysRecalculateSizes, ByDeferredMouse, ByDeferredPen, ByFrameChange, ByKeyboard, ByMouse, ByPen, ByRequest, CalculatedSizes, Disabled, DisablePopupMenu, DisplayOnly, Down, DrawFlat, Flag, ForceResize, HasData, Invisible, KeepImage, KeepSIP, Left, MakeMenuAtLeastAsWide, Maximize, Minimize, MouseSensitive, NoFocus, NotAnEditor, NotEditable, PaintDataOnly, PaintOutsideOnly, PenTransparent, PreferredSizeOnly, Right, SendUpKeyEvents, SendUpPenEvents, ShowSIP, ShrinkToNothing, SmallControl, SpecialBackground, TakeControlEvents, TakesKeyFocus, Transparent, Up, WantDrag, WantHoldDown
 
Constructor Summary
Mosaic()
           
 
Method Summary
 void addImage(AniImage im)
          Add an image to the mosaic.
 void addToSnapShot(AniImage which)
          This is used for advanced refreshing with quickDragging.
 Image confirmImage(Image what)
           
 void doPaint(Graphics g, Rect area)
          The doPaint() method for the Control.
 void dropImage(AniImage which)
          This is used with quickDragging.
 void onSetOrigin()
           
 void paintMosaicBackground(Graphics g)
           
 void refresh()
          Repaint the entire mosaic.
 void refresh(AniImage image, Graphics gr)
          Refresh a particular image.
 void refresh(Graphics gr)
          Paint the entire mosaic to the graphics.
 void refresh(IImage image, int options)
          The default version of this method simpy repaints the control - however for controls which may display multiple images a better refresh scheme would be needed.
 void refresh(Rect area, Graphics gr)
          Refresh the mosaic.
 void refresh(Rect area, Graphics gr, boolean doingOneImage)
           
 void refreshChanged(Graphics gr)
          This refreshes all images marked as changed.
 boolean refreshOnScreen(AniImage movedImage)
          This method is used to refresh an Image that has been moved, but that you want to make sure remains fully visible, by scrolling the Mosaic if necessary.
 void removeFromSnapShot(AniImage which)
          This is used for advanced refreshing with quickDragging.
 void removeImage(AniImage im)
          Remove an image from the mosaic.
 void setAndSizeToBackgroundImage(Image img)
          This sets the backgroundImage AND sets the virtualSize to be the same size as the image.
 void setMovingImage(AniImage which)
          This is used with quickDragging.
 void takeSnapShot()
          This is used for advanced refreshing with quickDragging.
 
Methods inherited from class ewe.ui.Canvas
canGo, canScreenScroll, checkScrolls, doBorder, doScroll, fixOrigin, getActual, getBuffer, getCurrent, getDisplayedSize, getMySize, getPercent, getScrollablePanel, getScrollClient, getVisible, getVisibleArea, needScrollBar, onScroll, reduceClip, scroll, scroll, scrollToVisible, setOrigin, updateScrollServer
 
Methods inherited from class ewe.ui.Container
_paintChildren, add, addDirectly, containerHasFocus, dismantle, dismantle, doHotKey, findChild, focusFirst, focusFirst, focusOnContainer, focusOnData, getChildren, getChildrenBackwards, getFirstFocus, getNextKeyFocus, gotFocus, lostFocus, remove, removeAll, repaintDataNow, takeFocus, takePromptControl
 
Methods inherited from class ewe.ui.Control
acceptsData, activate, addListener, addTimer, amOnTopFrame, calculateSizes, calculateTextSize, cancelCut, cancelHoldDown, canEdit, chainDataChange, change, checkClipboardOperations, checkExitKey, checkMenu, checkMenuKey, checkModifiers, checkPenTransparent, clearTag, clipboardToString, clipboardTransfer, closeMenu, contains, contains, createGraphics, dataAccepted, dataBeingRemoved, dataDraggedOff, dataDraggedOver, dataDraggedOver, dataDroppedOn, dataTransferCancelled, deactivate, defaultTo, doAction, doActionKey, doBackground, doMenu, dontAcceptDrop, doPaintChildren, doPaintChildren, doPaintChildren, doPaintData, doPaintData, doShowMenu, dragged, exitEntry, fillBackground, formClosing, fromClipboard, fromField, fromField, getAllDescendants, getAllSubControls, getBackground, getClipboardMenu, getClipObject, getControlBuffer, getControlBuffer, getDataRect, getDataToCopy, getDataToDragAndDrop, getDim, getDisplayText, getDragAndDropContext, getFont, getFontMetrics, getFontMetrics, getForeground, getFrame, getFrameOrContainer, getGraphics, getImage, getLastSelected, getLocation, getMaximumSize, getMenu, getMinimumSize, getModifiers, getNext, getParent, getPasswordCharacter, getPosInFrame, getPosInParent, getPreferredSize, getPrompt, getPromptText, getRect, getRect, getServer, getSize, getSizes, getSubControls, getTag, getText, getToolTip, getWindow, hasModifier, hasPopupFormAttached, hasTag, inheritModifiers, isChildOf, isModal, isOnMe, isSomeonesHotKey, make, makeFrameTopMost, makeHot, menuIsActive, modify, modifyAll, modifyAll, notifyAction, notifyDataChange, notifyDataChange, notNative_doPaintChildren, oldButWorksDoPaintChildren, oldPaintChildren, oldPostEvent, onControlEvent, onEvent, onKeyEvent, onLabelPenEvent, onPaint, onPenEvent, paintBackground, paintChildren, penClicked, penDoubleClicked, penHeld, penPressed, penReleased, penRightReleased, popupBeep, popupMenuClosed, popupMenuEvent, popupMenuEvent, postEvent, recalculatePreferredSize, redisplay, removeListener, removeTimer, repaint, repaintNow, repaintNow, repaintNow, requestPaint, requestResizeTo, resetRect, resizeTo, restore, scrollAndRepaint, sendToListeners, set, setBorder, setCell, setClipObject, setControl, setCursor, setFixedSize, setFont, setHotKey, setHotKey, setLocation, setMaximumSize, setMenu, setMinimumSize, setPreferredSize, setPromptControl, setRect, setRect, setServer, setTag, setTags, setText, setTextSize, setToolTip, show, shown, standardOnKeyEvent, startDragAndDrop, startDragAndDrop, startDragging, stopDragging, takeData, takeFromClipboard, testDim, ticked, toClipboard, toField, toField, toString, toTextData, transferPenPress, transferPenPress, tryDragAndDrop, tryNext, tryStartMenu, updateData, willAcceptDrop, willShowFrame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode
 
Methods inherited from interface ewe.ui.ScrollClient
getServer, setServer
 

Field Detail

quickDragging

public boolean quickDragging
Set this true IF, while one image is being dragged no other images will change. It makes the updating of moving images somewhat more effecient.


images

public ImageList images
These are the images in the Mosaic. However don't add/remove from it directly. Use the addImage()/removeImage() methods instead.


backgroundImage

public Image backgroundImage
Set this to be a backgroundImage.


pauseSnapShots

protected boolean pauseSnapShots

firstSnap

protected boolean firstSnap
Constructor Detail

Mosaic

public Mosaic()
Method Detail

setAndSizeToBackgroundImage

public void setAndSizeToBackgroundImage(Image img)
This sets the backgroundImage AND sets the virtualSize to be the same size as the image. It does NOT set the preferredSize of the mosaic. You still have to set that yourself.


addImage

public void addImage(AniImage im)
Add an image to the mosaic.


removeImage

public void removeImage(AniImage im)
Remove an image from the mosaic.


paintMosaicBackground

public void paintMosaicBackground(Graphics g)

confirmImage

public Image confirmImage(Image what)

takeSnapShot

public void takeSnapShot()
This is used for advanced refreshing with quickDragging.


removeFromSnapShot

public void removeFromSnapShot(AniImage which)
This is used for advanced refreshing with quickDragging.


addToSnapShot

public void addToSnapShot(AniImage which)
This is used for advanced refreshing with quickDragging.


setMovingImage

public void setMovingImage(AniImage which)
This is used with quickDragging. Call this method to set the image that is moving.


dropImage

public void dropImage(AniImage which)
This is used with quickDragging. This tells the mosaic that the previously moving image is no longer moving.


refresh

public void refresh(Rect area,
                    Graphics gr)
Refresh the mosaic. If gr is null then a Graphics will be created. if area is null then the entire mosaic will be refreshed. Normally you will not call this method. Instead you will generally refresh just a single image.


refresh

public void refresh(Rect area,
                    Graphics gr,
                    boolean doingOneImage)

refreshChanged

public void refreshChanged(Graphics gr)
This refreshes all images marked as changed. If gr is null, then a new graphics will be created and used.


refresh

public void refresh(AniImage image,
                    Graphics gr)
Refresh a particular image. If gr is null then a new Graphics will be created and used.


refresh

public void refresh(Graphics gr)
Paint the entire mosaic to the graphics. If gr is null then a new Graphics will be created and used.


refresh

public void refresh()
Repaint the entire mosaic.


doPaint

public void doPaint(Graphics g,
                    Rect area)
The doPaint() method for the Control.

Overrides:
doPaint in class Control

onSetOrigin

public void onSetOrigin()
Overrides:
onSetOrigin in class Canvas

refreshOnScreen

public boolean refreshOnScreen(AniImage movedImage)
This method is used to refresh an Image that has been moved, but that you want to make sure remains fully visible, by scrolling the Mosaic if necessary. Note that this will only work correctly IF the virtualSize value has been set AND the image remains in the range (0,0) to (virtualSize.x-imageWidth,virtualSize.y-imageHeight).

This method will also update the scroll bars if there are any.

Parameters:
movedImage - The image that has been moved or changed in some way.
Returns:
true if a scroll was done, false if no scrolling occured.

refresh

public void refresh(IImage image,
                    int options)
Description copied from class: Control
The default version of this method simpy repaints the control - however for controls which may display multiple images a better refresh scheme would be needed.

Specified by:
refresh in interface ImageRefresher
Overrides:
refresh in class Control
Parameters:
image - the image to refresh.
options -
Returns: