|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.minueto.window.MinuetoPanel
public class MinuetoPanel
The MinuetoPanel class allows you to create a Panel which can be inserted
inside your Swing/AWT application. This panel is your main drawing surface (your canvas).
It is also a JPanel. This allows for easy swing integration by adding it like any other control.
The only difference is that you must pass the width and height for your canvas size first.
This class is also implements MinuetoWindow. As such, all the drawing
functionnality is provided as well.
If you were using the old version of this class, minimal changes should be needed: You just need to add it like a regular JPanel and calling enable is no longer needed. Just call setVisible(true).
When a MinuetoPanel is created, it is invisible. The setVisible
method must be used to show the window (make it visible).
Minueto draws to the screen using a double-buffering strategy. In other words,
there are two drawing surfaces : your window itself and an off screen surface.
All your drawing occurs on the off screen surface. The content of the off
screen buffer is drawn to the screen when the render method is invoked.
As Minueto does complex Graphical work, it isn't really meant to interact with Swing that nicely. While the MinuetoPanel takes care of actually allowing you to draw in an accelerated fashion while contained within Swing components. The Panel itself doesn't know about Swing. Therefore, it is drawn completely on top of any other swing component. Thus, windows or buttons that are in front of the MinuetoPanel will be drawn behind it.
MinuetoBaseWindow,
MinuetoWindow,
MinuetoImage,
Serialized Form| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
javax.swing.JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
java.awt.Component.BaselineResizeBehavior |
| Field Summary |
|---|
| Fields inherited from class javax.swing.JComponent |
|---|
TOOL_TIP_TEXT_KEY, 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 java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
MinuetoPanel(int width,
int height)
|
|
| Method Summary | |
|---|---|
void |
addFocusListener(java.awt.event.FocusListener arg0)
|
void |
addKeyListener(java.awt.event.KeyListener arg0)
|
void |
addMouseListener(java.awt.event.MouseListener arg0)
|
void |
addMouseMotionListener(java.awt.event.MouseMotionListener arg0)
|
void |
addMouseWheelListener(java.awt.event.MouseWheelListener arg0)
|
void |
clear()
Clears the contents of the Drawing Surface. |
void |
clear(MinuetoColor color)
Erases the contents from the Drawing Surface. |
void |
close()
Closing a MinuetoPanel doesn't really make too much sense. |
void |
draw(MinuetoImage image,
int x,
int y)
Draw another MinuetoImage on this MinuetoDrawingSurface (thus compositing them). |
void |
drawLine(MinuetoColor color,
int xStart,
int yStart,
int xStop,
int yStop)
Draw a line of the specified color from the start point to the end point. |
double |
getFrameRate()
Returns the number of frame renders per second. |
int |
getHeight()
Return the height of the image. |
int |
getPositionX()
Returns the top-left X screen location of the MinuetoWindow drawing surface |
int |
getPositionY()
Returns the top-left Y screen location of the MinuetoWindow drawing surface |
java.awt.Dimension |
getPreferredSize()
|
int |
getWidth()
Return the width of the image. |
boolean |
isClosed()
Returns if the MinuetoWindow is was closed. |
boolean |
isVisible()
Returns if the MinuetoWindow is visible or not. |
void |
paint(java.awt.Graphics arg0)
|
void |
registerFocusHandler(MinuetoFocusHandler handler,
MinuetoEventQueue queue)
Assign a focus handler to the MinuetoWindow to process
focus events. |
void |
registerKeyboardHandler(MinuetoKeyboardHandler handler,
MinuetoEventQueue queue)
Assign a keyboard handler to the MinuetoWindow to process
keyboard input. |
void |
registerMouseHandler(MinuetoMouseHandler handler,
MinuetoEventQueue queue)
Assign a mouse handler to the MinuetoWindow to process
mouse input. |
void |
registerMouseWheelHandler(MinuetoMouseWheelHandler handler,
MinuetoEventQueue queue)
Assign a mousewheel handler to the MinuetoWindow to process
mouse wheel input. |
void |
registerWindowHandler(MinuetoWindowHandler handler,
MinuetoEventQueue queue)
Assign a window handler to the MinuetoWindow to process
window input. |
void |
removeFocusListener(java.awt.event.FocusListener arg0)
|
void |
removeKeyListener(java.awt.event.KeyListener arg0)
|
void |
removeMouseListener(java.awt.event.MouseListener arg0)
|
void |
removeMouseMotionListener(java.awt.event.MouseMotionListener arg0)
|
void |
removeMouseWheelListener(java.awt.event.MouseWheelListener arg0)
|
void |
render()
Draws the content of the backbuffer onto the window. |
void |
save(java.lang.String filename)
Saves the content of the MinuetoDrawingSurface to a PNG file. |
void |
setCursorVisible(boolean value)
Shows or hides the mouse cursor. |
void |
setMaxFrameRate(double value)
Caps the number of frames which can be rendered (display) per second. |
void |
setPixel(int x,
int y,
MinuetoColor color)
Change the color of pxel at location X,y. |
void |
setSize(java.awt.Dimension dimension)
|
void |
setTitle(java.lang.String title)
Change the title of the window. |
void |
setVisible(boolean arg0)
Shows or hides the MinuetoWindow. |
void |
unregisterFocusHandler(MinuetoFocusHandler handler,
MinuetoEventQueue queue)
Removes a focus handler from the MinuetoWindow. |
void |
unregisterKeyboardHandler(MinuetoKeyboardHandler handler,
MinuetoEventQueue queue)
Removes a keyboard handler from the MinuetoWindow. |
void |
unregisterMouseHandler(MinuetoMouseHandler handler,
MinuetoEventQueue queue)
Removes a mouse handler from the MinuetoWindow. |
void |
unregisterMouseWheelHandler(MinuetoMouseWheelHandler handler,
MinuetoEventQueue queue)
Removes a mouse wheel handler from the MinuetoWindow. |
void |
unregisterWindowHandler(MinuetoWindowHandler handler,
MinuetoEventQueue queue)
Removes a window handler from the MinuetoWindow. |
void |
update(java.awt.Graphics arg0)
|
| Methods inherited from class javax.swing.JPanel |
|---|
getAccessibleContext, getUI, getUIClassID, setUI, updateUI |
| Methods inherited from class javax.swing.JComponent |
|---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, unregisterKeyboardAction |
| Methods inherited from class java.awt.Container |
|---|
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate |
| Methods inherited from class java.awt.Component |
|---|
action, add, addComponentListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public MinuetoPanel(int width,
int height)
| Method Detail |
|---|
public void clear()
MinuetoDrawingSurface
clear in interface MinuetoDrawingSurfacepublic void clear(MinuetoColor color)
MinuetoDrawingSurface
clear in interface MinuetoDrawingSurfacecolor - MinuetoColor of the cleared buffer.public void close()
close in interface MinuetoWindow
public void draw(MinuetoImage image,
int x,
int y)
MinuetoDrawingSurfaceMinuetoImage on this MinuetoDrawingSurface (thus compositing them).
draw in interface MinuetoDrawingSurfaceimage - MinuetoImage that we will draw on our image.x - int denoting where we should start drawing on the x axis.y - int denothing where we should start drawing on the y axis.
public void drawLine(MinuetoColor color,
int xStart,
int yStart,
int xStop,
int yStop)
MinuetoDrawingSurface
drawLine in interface MinuetoDrawingSurfacecolor - MinuetoColor denoting the color of the line.xStart - int denoting the X value of the start point.yStart - int denoting the Y value of the start point.xStop - int denoting the X value of the end point.yStop - int denoting the Y value of the end point.public double getFrameRate()
MinuetoWindow
getFrameRate in interface MinuetoWindowint denoting the number of frames drawn per second.public int getHeight()
MinuetoDrawingSurface
getHeight in interface MinuetoDrawingSurfacegetHeight in class javax.swing.JComponentint denoting the height of the image.public int getWidth()
MinuetoDrawingSurface
getWidth in interface MinuetoDrawingSurfacegetWidth in class javax.swing.JComponentint denoting the width of the image.
public void registerKeyboardHandler(MinuetoKeyboardHandler handler,
MinuetoEventQueue queue)
MinuetoWindowMinuetoWindow to process
keyboard input. An unlimited number of keyboard handlers can be registered
with a window, but too many handlers may slow the application (because
of the large number of events produced).
registerKeyboardHandler in interface MinuetoWindowhandler - MinuetoKeyboardHandler to register with the
MinuetoEventQueue.queue - MinuetoEventQueue that will store events..
public void registerMouseHandler(MinuetoMouseHandler handler,
MinuetoEventQueue queue)
MinuetoWindowMinuetoWindow to process
mouse input. An unlimited number of mouse handlers can be registered
with a window, but too many handlers may slow the application (because
of the large number of events produced).
registerMouseHandler in interface MinuetoWindowhandler - MinuetoMouseHandler to register with the
MinuetoWindow.queue - MinuetoEventQueue that will store events.
public void registerMouseWheelHandler(MinuetoMouseWheelHandler handler,
MinuetoEventQueue queue)
MinuetoWindowMinuetoWindow to process
mouse wheel input. An unlimited number of mouse wheel handlers can be registered
with a window, but too many handlers may slow the application (because
of the large number of events produced).
registerMouseWheelHandler in interface MinuetoWindowhandler - MinuetoMouseWheelHandler to register with the
MinuetoWindow.queue - MinuetoEventQueue that will store events.
public void registerWindowHandler(MinuetoWindowHandler handler,
MinuetoEventQueue queue)
MinuetoWindowMinuetoWindow to process
window input. An unlimited number of window handlers can be registered
with a window, but too many handlers may slow the application (because
of the large number of events produced).
registerWindowHandler in interface MinuetoWindowhandler - MinuetoWindowHandler to register with the
MinuetoWindow.queue - MinuetoEventQueue that will store events.
public void registerFocusHandler(MinuetoFocusHandler handler,
MinuetoEventQueue queue)
MinuetoWindowMinuetoWindow to process
focus events. An unlimited number of window handlers can be registered
with a window, but too many handlers may slow the application (because
of the large number of events produced).
registerFocusHandler in interface MinuetoWindowhandler - MinuetoFocusHandler to register with the
MinuetoWindow.queue - MinuetoEventQueue that will store events.public void render()
MinuetoWindow
render in interface MinuetoWindowpublic void setCursorVisible(boolean value)
MinuetoWindow
setCursorVisible in interface MinuetoWindowvalue - boolean denoting if the window should be visible or not.public void setMaxFrameRate(double value)
MinuetoWindow
setMaxFrameRate in interface MinuetoWindowvalue - double denoting the desired number of frames to
be displayed per second.public void setTitle(java.lang.String title)
MinuetoWindow
setTitle in interface MinuetoWindowtitle - String identifying the desired title of the screen.public boolean isVisible()
MinuetoWindow
isVisible in interface MinuetoWindowisVisible in class java.awt.Componentboolean if Window is visible or notpublic void setVisible(boolean arg0)
MinuetoWindow
setVisible in interface MinuetoWindowsetVisible in class javax.swing.JComponentarg0 - boolean denoting if the window should be visible or not.
public void unregisterKeyboardHandler(MinuetoKeyboardHandler handler,
MinuetoEventQueue queue)
MinuetoWindowMinuetoWindow. Note that
both the correct handler and queue must be given to unregister the handler.
unregisterKeyboardHandler in interface MinuetoWindowhandler - MinuetoKeyboardHandler to unregister with the
MinuetoWindow.queue - MinuetoEventQueue that stored the events.
public void unregisterMouseHandler(MinuetoMouseHandler handler,
MinuetoEventQueue queue)
MinuetoWindowMinuetoWindow. Note that
both the correct handler and queue must be given to unregister the handler.
unregisterMouseHandler in interface MinuetoWindowhandler - MinuetoMouseHandler to unregister with the
MinuetoWindow.queue - MinuetoEventQueue that stored the events.
public void unregisterMouseWheelHandler(MinuetoMouseWheelHandler handler,
MinuetoEventQueue queue)
MinuetoWindowMinuetoWindow. Note that
both the correct handler and queue must be given to unregister the handler.
unregisterMouseWheelHandler in interface MinuetoWindowhandler - MinuetoMouseWheelHandler to unregister with the
MinuetoWindow.queue - MinuetoEventQueue that stored the events.
public void unregisterWindowHandler(MinuetoWindowHandler handler,
MinuetoEventQueue queue)
MinuetoWindowMinuetoWindow. Note that
both the correct handler and queue must be given to unregister the handler.
unregisterWindowHandler in interface MinuetoWindowhandler - MinuetoWindowHandler to unregister with the
MinuetoWindow.queue - MinuetoEventQueue that stored the events.
public void unregisterFocusHandler(MinuetoFocusHandler handler,
MinuetoEventQueue queue)
MinuetoWindowMinuetoWindow. Note that
both the correct handler and queue must be given to unregister the handler.
unregisterFocusHandler in interface MinuetoWindowhandler - MinuetoFocusHandler to unregister with the
MinuetoWindow.queue - MinuetoEventQueue that stored the events.public void addFocusListener(java.awt.event.FocusListener arg0)
addFocusListener in class java.awt.Componentpublic void addKeyListener(java.awt.event.KeyListener arg0)
addKeyListener in class java.awt.Componentpublic void addMouseListener(java.awt.event.MouseListener arg0)
addMouseListener in class java.awt.Componentpublic void addMouseMotionListener(java.awt.event.MouseMotionListener arg0)
addMouseMotionListener in class java.awt.Componentpublic void addMouseWheelListener(java.awt.event.MouseWheelListener arg0)
addMouseWheelListener in class java.awt.Componentpublic void removeFocusListener(java.awt.event.FocusListener arg0)
removeFocusListener in class java.awt.Componentpublic void removeKeyListener(java.awt.event.KeyListener arg0)
removeKeyListener in class java.awt.Componentpublic void removeMouseListener(java.awt.event.MouseListener arg0)
removeMouseListener in class java.awt.Componentpublic void removeMouseMotionListener(java.awt.event.MouseMotionListener arg0)
removeMouseMotionListener in class java.awt.Componentpublic void removeMouseWheelListener(java.awt.event.MouseWheelListener arg0)
removeMouseWheelListener in class java.awt.Component
public void save(java.lang.String filename)
throws MinuetoFileException
MinuetoDrawingSurface
save in interface MinuetoDrawingSurfacefilename - String indicating the name of the PNG file.
MinuetoFileException
public void setPixel(int x,
int y,
MinuetoColor color)
MinuetoDrawingSurfaceThis uses the drawLine function to be faster than a direct raw data setPxel, though it should be used with caution as it is still slower than drawing a completed image to the drawing surface.
setPixel in interface MinuetoDrawingSurfacex - int denoting which pxel on the X axis should be colored.y - int denoting which pxel on the y axis should be colored.color - MinuetoColor denoting the new color for pxel x,y.public int getPositionX()
MinuetoWindow
getPositionX in interface MinuetoWindowint denoting the x position of the drawing surfacepublic int getPositionY()
MinuetoWindow
getPositionY in interface MinuetoWindowint denoting the y position of the drawing surfacepublic java.awt.Dimension getPreferredSize()
getPreferredSize in class javax.swing.JComponentpublic void setSize(java.awt.Dimension dimension)
setSize in class java.awt.Componentpublic void paint(java.awt.Graphics arg0)
paint in class javax.swing.JComponentpublic void update(java.awt.Graphics arg0)
update in class javax.swing.JComponentpublic boolean isClosed()
MinuetoWindow
isClosed in interface MinuetoWindowboolean if Window was closed or not
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||