|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Canvas | +--quicktime.app.display.QTCanvas
A specialized canvas which supplies access to the native graphics environment and offers expanded functionality to control its viewing or display size. The QTCanvas object can display any object which implements the Drawable interface. This Drawable object is set as the drawing client of the QTCanvas object.
The resize and alignment flags determine how the QTCanvas object acts when it has its setSize or setBounds method called. These flags allow the application to control or restrict the viewing size of a QTCanvas - generally desirable as the QuickTime client of a QTCanvas is constructed to be viewed in a particular best size or react in a desired manner when resized. The resize flags comments discuss the typically appropriate usage. If the kAnySize flag is used the QTCanvas will be resized as any other java.awt.Component.
The size of the QTCanvas and its Drawable client are kept synchronized. The actual size of the QTCanvas is determined by the size of its Drawable client when it is set (which becomes its "best" viewing size), the resize and alignement flag settings, and the size of the QTCanvas' java.awt.Container parent. The client, the resize and alignment flags determine how a QTCanvas reacts to a setBounds or setSize call - any resize flag other than the kAnySize flag will result in the QTCanvas' actual size being arbitrated with the best viewing size of its client. Thus in many cases the calls to setSize and setBounds on a QTCanvas object are requests and may not result in the QTCanvas actually being resized to that requested size.
When a QTCanvas' client is set the size of the client's current size is used by the QTCanvas to indicate that this is that client's best viewing size. By default (and an application can change this) this will also become the preferred size of the QTCanvas. This size is cached by the QTCanvas and used when it is responding to resize requests from its parent Container (for instance, the user resizes the window the QTCanvas is in).
If an application changes the size of the client after it has been set - for instance a Movie client is edited and the viewing area of the movie is now different - then the application must inform the QTCanvas that the client's best size is changed, before resizing the QTCanvas itself. This ensures that the QTCanvas will resize and redraw the client correctly, avoiding unwanted scaling of the client:
// application changes the actual display size of a Movie through // adding a video track to a movie that only had a sound track // this means that the movie client has now a best size that // that is different when it was originally set as the client of this QTCanvas myQTCanvas.clientChanged (r.getWidth(), r.getHeight()); myQTCanvas.invalidate(); //resize the QTCanvas' parent container so that the changed viewing conditions of the //client will be seen. //pack() is appropriate, as is getParent().setSize(), or getParent().setBounds() //The application could also just validate the parent if the parent should not change size
Once the application has notified the canvas that the client's best viewing size has changed the QTCanvas will correctly respond to the any new sizes that are given to it by it parent's layout manager or resizing actions.
In most interactions between a QTCanvas and its client this explicit resizing of the client is not required as all of the Drawable clients are able to scale themselves appropriately to a different display size. It is only required when the client's size itself has changed.
Drawable
, Serialized FormInner classes inherited from class java.awt.Canvas |
java.awt.Canvas.AccessibleAWTCanvas |
Inner classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent |
Field Summary | |
static int |
kAspectResize
Use this flag if the client can be resized to any size which preserves the initial aspect ratio. |
static int |
kFreeResize
Use this flag if the client can be resized to any size >= the minimum and <= the maximum. |
static int |
kHorizontalResize
Use this flag to allow the client's horizontal aspect to be any size, but the vertical axis will be the intial size of smaller. |
static int |
kInitialSize
Use this flag if the client should revert to its initially specified size. |
static int |
kInitialSizeNoResize
Use this flag specify that the client cannot be resized |
static int |
kIntegralResize
Use this flag if the client should maintain the aspect size of its original dimensions but grow bigger by integral increments (2x, 3x, 4x, etc.) |
static int |
kPerformanceResize
Use this flag if the client can be resized to any size which is a factor of 2 of the initial size. |
static int |
kVerticalResize
Use this flag to allow the client's vertical aspect to be any size, but the horizontal axis will be the intial size of smaller. |
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 | |
QTCanvas()
Constructor for creating a client-less QTCanvas. |
|
QTCanvas(int resizeFlag,
float xAlignment,
float yAlignment)
Constructor for creating a client-less QTCanvas. |
Method Summary | |
void |
addNotify()
We use this method to notify an existing client that its NativeGraphics environment may have changed and it should recheck its status |
void |
addQTClientListener(java.awt.event.ComponentListener e)
A ComponentListener and ComponentEvent are used to listen to these types of events that occur to the QTCanvas' client - ie. |
void |
clientChanged(java.awt.Dimension bestSize)
This method is used by an appliction to notify a QTCanvas that the best size of its' current client has changed. |
void |
clientChanged(int bestWidth,
int bestHeight)
This method is used by an appliction to notify a QTCanvas that the best size of its' current client has changed. |
protected void |
finalize()
|
float |
getAlignmentX()
Returns the current setting of the x position alignment being used. |
float |
getAlignmentY()
Returns the current setting of the y position alignment being used. |
java.awt.Dimension |
getBestSize()
Returns the best size of the client, the size of the client when it was set to this QTCanvas, or the size if the appliction notified the QTCanvas that the clien't best size was changed. |
Drawable |
getClient()
Returns the Drawable object currently associated with this QTCanvas. |
java.awt.Dimension |
getMaximumSize()
Returns the maximum acceptable size of this QTCanvas object. |
java.awt.Dimension |
getMinimumSize()
Returns the minimum acceptable size of this QTCanvas object. |
NativeGraphics |
getNativeGraphics()
Returns the NativeGrapics object that represents the Graphics Port that corresponds to the display space taken up by the QTCanvas. |
java.awt.Point |
getNGLocation()
Returns the coordinates of a component relative to the NativeGrapics window it is currently placed within. |
QDGraphics |
getPort()
This method will return a QTJava object, QDGraphics, which is a reference to the native graphics drawing environment being used by this QTCanvas object. |
java.awt.Dimension |
getPreferredSize()
Returns the preferred size of the QTCanvas object. |
int |
getResizeFlag()
Returns the current setting of the resize flag being used. |
void |
paint(java.awt.Graphics g)
Override the standard paint method. |
void |
removeClient()
Removes the client from the canvas. |
void |
removeNotify()
Overridden to notify the client associated with this QTCanvas that it no longer has a grafport to draw to and should stop all graphics operations. |
void |
removeQTClientListener(java.awt.event.ComponentListener e)
Remove a previously registered ComponentListener that is listening to events that occur with the QTCanvas' QTDrawable client. |
void |
reshape(int x,
int y,
int width,
int height)
Deprecated. As of JDK version 1.1, replaced by setBounds(int, int, int, int) . |
void |
setAlignment(float xAlignment,
float yAlignment)
Set the alignment position values. |
void |
setAlignmentX(float x)
|
void |
setAlignmentY(float y)
|
void |
setBounds(int x,
int y,
int width,
int height)
Resizes and/or moves the QTCanvas object as well as the associated Drawable object to the parameters specified. |
void |
setClient(Drawable client,
boolean layoutFlag)
Associates a new client, a Drawable object, with this QTCanvas. |
void |
setClient(Drawable client,
QDRect initialBounds)
Associates a new client, a Drawable object, with this QTCanvas. |
void |
setMaximumSize(java.awt.Dimension maxSize)
Set the minimum size of the QTCanvas. |
void |
setMaximumSize(int width,
int height)
Set the maximum size of the canvas. |
void |
setMinimumSize(java.awt.Dimension minSize)
Set the minimum size of the QTCanvas. |
void |
setMinimumSize(int width,
int height)
Set the minimum size of the canvas. |
void |
setPreferredSize(java.awt.Dimension prefSize)
Sets the preferred size of the QTCanvas object. |
void |
setPreferredSize(int width,
int height)
Sets the preferred size of the QTCanvas object. |
void |
setResizeFlag(int rFlag)
Reset the resize flag and re-layout the component. |
void |
setSize(java.awt.Dimension dim)
Resizes the QTCanvas object to the specified parameters. |
void |
setSize(int width,
int height)
Resizes the QTCanvas object, as well as the associated Drawable object. |
void |
setVisible(boolean b)
Sets the visible state of the Canvas. |
java.lang.String |
toString()
Print information about this object. |
QDPoint |
translatePoint(int x,
int y)
An incoming point (typically from some kind of MouseEvent) is in coordinates that have their origin set at the local coordinate system of the canvas. |
void |
update(java.awt.Graphics g)
We override the update method to call our paint method as the background colour repaint is not valid for a QTCanvas object. |
Methods inherited from class java.awt.Canvas |
getAccessibleContext |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, resize, resize, setBackground, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, show, show, size, transferFocus, validate |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int kIntegralResize
public static final int kInitialSize
public static final int kFreeResize
public static final int kAspectResize
public static final int kPerformanceResize
public static final int kHorizontalResize
public static final int kVerticalResize
public static final int kInitialSizeNoResize
Constructor Detail |
public QTCanvas()
public QTCanvas(int resizeFlag, float xAlignment, float yAlignment)
resizeFlag
- the resize control settingxAlignment
- a value between 0 and 1 that sets the position of the drawable client within the
space that AWT will give to the canvas when layed out. 0 means left, 1 means right, 0.5 means centre.yAlignment
- a value between 0 and 1 that sets the position of the drawable client within the
space that AWT will give to the canvas when layed out. 0 means top, 1 means bottom, 0.5 means centre.Method Detail |
public final QDGraphics getPort() throws QTUnknownOSException, NativeGraphicsException
QTUnknownOSException
- if the current operating system is unknown to QuickTimequicktime.NativeGraphicsException
- if there was a problem initialising the NativeGraphics environmentpublic final java.awt.Point getNGLocation() throws QTUnknownOSException, NativeGraphicsException
public final NativeGraphics getNativeGraphics()
public final QDPoint translatePoint(int x, int y) throws QTUnknownOSException, NativeGraphicsException
x
- the x locationy
- the y locationpublic final void removeClient()
public void setClient(Drawable client, boolean layoutFlag) throws QTException
The size of the client when this method is called is used to ascertain the best size for viewing this client's media.
This method can throw a number of exceptions:
QTUnknownOSException the application is trying to run on a platform that is not supported by QuickTime
NativeGraphicsException the native graphics environment is not initialised
QTException or subclass - there was a problem within QuickTime itself in dealing with this client
client
- a Drawable object - if null the method will remove the clientlayoutFlag
- if true java.awt will re-layout the canvas, if false the client will fit
into the existing state (display size, etc) of the canvas, disregarding any resize that might
have occured to honour the layout flag setting with respect to the different size of the new client.public void setClient(Drawable client, QDRect initialBounds) throws QTException
This method can throw a number of exceptions:
QTUnknownOSException the application is trying to run on a platform that is not supported by QuickTime
NativeGraphicsException the native graphics environment is not initialised
QTException or subclass - there was a problem within QuickTime itself in dealing with this client
client
- a Drawable object - if null the method will remove the clientinitialBounds
- the best size of the clientpublic final Drawable getClient()
public void setAlignment(float xAlignment, float yAlignment)
Alignment Positioning works like this:
xAlignment
- a float between 0.0 and 1.0 representing the x position alignmentyAlignment
- a float between 0.0 and 1.0 representing the y position alignmentpublic final void setAlignmentX(float x)
setAlignment
public final void setAlignmentY(float y)
setAlignment
public float getAlignmentX()
getAlignmentX
in class java.awt.Component
public float getAlignmentY()
getAlignmentY
in class java.awt.Component
public void setResizeFlag(int rFlag)
rFlag
- the new value for the resizeFlagpublic int getResizeFlag()
public void setMinimumSize(java.awt.Dimension minSize)
minSize
- a Dimension objectpublic void setMinimumSize(int width, int height)
width
- the minimum widthheight
- the minimum heightpublic java.awt.Dimension getMinimumSize()
getMinimumSize
in class java.awt.Component
public java.awt.Dimension getBestSize()
clientChanged
public void clientChanged(java.awt.Dimension bestSize)
An application only needs to call this if the display characteristics of the client have been changed. For instance, the client is a movie and some of the visual tracks of this movie have been disabled, or a new video track was added. Thus the movie itself has changed its best size and the application must use this method to notify the QTCanvas that the client's best size has changed.
This will not effect the display area of the QTCanvas, the application should invalidate the QTCanvas and re-layout the parent container to have this change take effect. getBestSize() returns this newly notified size.
In the normal operation of a QTCanvas and its client there is no need for an application to use this method.
bestSize
- the client's new best width and heightpublic void clientChanged(int bestWidth, int bestHeight)
An application only needs to call this if the display characteristics of the client have been changed. For instance, the client is a movie and some of the visual tracks of this movie have been disabled, or a new video track was added. Thus the movie itself has changed its best size and the application must use this method to notify the QTCanvas that the client's best size has changed.
This will not effect the display area of the QTCanvas, the application should invalidate the QTCanvas and re-layout the parent container to have this change take effect. getBestSize() returns this newly notified size.
In the normal operation of a QTCanvas and its client there is no need for an application to use this method.
bestWidth
- the client's new best widthbestHeight
- the client's new actual heightpublic java.awt.Dimension getPreferredSize()
getPreferredSize
in class java.awt.Component
public void setPreferredSize(java.awt.Dimension prefSize)
public void setPreferredSize(int width, int height)
width
- the minimum widthheight
- the minimum heightpublic void setMaximumSize(java.awt.Dimension maxSize)
maxSize
- a Dimension objectpublic void setMaximumSize(int width, int height)
width
- the minimum widthheight
- the minimum heightpublic java.awt.Dimension getMaximumSize()
getMaximumSize
in class java.awt.Component
public void setSize(java.awt.Dimension dim)
setSize
in class java.awt.Component
dim
- a Dimension object with the new width and heightpublic void setSize(int width, int height)
setSize
in class java.awt.Component
width
- the width, in pixels, to make this componentheight
- the height, in pixels, to make this componentpublic final void reshape(int x, int y, int width, int height)
setBounds(int, int, int, int)
.
reshape
in class java.awt.Component
public final void setBounds(int x, int y, int width, int height)
setBounds
in class java.awt.Component
x
- the x coordinate, in pixels, relative to the parent of this
componenty
- the y coordinate, in pixels, relative to the parent of this
componentwidth
- the width, in pixels, to make this componentheight
- the height, in pixels, to make this componentpublic void paint(java.awt.Graphics g)
paint
in class java.awt.Canvas
public void update(java.awt.Graphics g)
update
in class java.awt.Component
public void setVisible(boolean b)
setVisible
in class java.awt.Component
b
- if true canvas is visible, if false then its notpublic void addQTClientListener(java.awt.event.ComponentListener e)
e
- the ComponentListenerpublic void removeQTClientListener(java.awt.event.ComponentListener e)
e
- the ComponentListeneraddQTClientListener
public void addNotify()
addNotify
in class java.awt.Canvas
public void removeNotify()
removeNotify
in class java.awt.Component
public java.lang.String toString()
toString
in class java.awt.Component
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |