java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
org.jempeg.empeg.logoedit.LogoEditPanel
- All Implemented Interfaces:
- java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
- public class LogoEditPanel
- extends javax.swing.JComponent
An implementation of a simple painting canvas
that supports drawing, paintbrush, floodfill,
color switching, brush sizes, text, and undo/redo.
| Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Fields inherited from class java.awt.Container |
|
|
Method Summary |
void |
click(int _x,
int _y)
|
void |
drag(int _x,
int _y)
|
void |
draw(int _x,
int _y)
|
protected void |
drawImage(java.awt.Image _fromImage,
java.awt.Graphics _toGraphics)
|
void |
fill(int _x,
int _y)
|
void |
finalize()
Called on an object by the Virtual Machine at most once,
at some point after the Object is determined unreachable
but before it is destroyed. |
protected void |
floodFill(int _x,
int _y,
int _newColor,
int[] _pixels)
|
java.awt.Image |
getImage()
|
int |
getImageHeight()
|
int |
getImageWidth()
|
long |
getModificationTime()
|
int |
getPaintState()
|
java.awt.Dimension |
getPreferredSize()
Get the component's preferred size. |
int |
getScale()
|
int |
getStrokeWidth()
|
java.awt.Font |
getTextFont()
|
void |
paint(int _x,
int _y)
|
protected void |
paint(int _x,
int _y,
int _state)
|
void |
paintComponent(java.awt.Graphics _g)
Paint the component's body. |
protected void |
paintText(java.awt.Graphics _g,
int _scale)
|
void |
release(int _x,
int _y)
|
void |
saveUndo()
|
void |
setColor(java.awt.Color _color)
|
void |
setImage(java.awt.Image _image)
|
void |
setPaintState(int _paintState)
|
void |
setScale(int _scale)
|
void |
setStrokeWidth(int _strokeWidth)
|
void |
setTextFont(java.awt.Font _textFont)
|
void |
undo()
|
| Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI |
| Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, 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, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, 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, 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, processMouseEvent, 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, transferFocusBackward, transferFocusUpCycle |
PAINTSTATE_DRAW
public static final int PAINTSTATE_DRAW
- See Also:
- Constant Field Values
PAINTSTATE_PAINT
public static final int PAINTSTATE_PAINT
- See Also:
- Constant Field Values
PAINTSTATE_FILL
public static final int PAINTSTATE_FILL
- See Also:
- Constant Field Values
PAINTSTATE_TEXT
public static final int PAINTSTATE_TEXT
- See Also:
- Constant Field Values
myImage
private java.awt.Image myImage
myImageGraphics
private java.awt.Graphics myImageGraphics
myUndoImage
private java.awt.Image myUndoImage
myUndoImageGraphics
private java.awt.Graphics myUndoImageGraphics
myWidth
private int myWidth
myHeight
private int myHeight
myScale
private int myScale
myStrokeWidth
private int myStrokeWidth
myPaintState
private int myPaintState
myColor
private java.awt.Color myColor
myModificationTime
private long myModificationTime
myTextBuffer
private java.lang.StringBuffer myTextBuffer
myTextFont
private java.awt.Font myTextFont
myTextX
private int myTextX
myTextY
private int myTextY
LogoEditPanel
public LogoEditPanel(int _width,
int _height)
paintComponent
public void paintComponent(java.awt.Graphics _g)
- Description copied from class:
javax.swing.JComponent
- Paint the component's body. This usually means calling ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)>
ComponentUI.update(java.awt.Graphics, javax.swing.JComponent) 55 on the JComponent.ui>JComponent.ui 55 property of the component, if
it is non-null. You may override this if you wish to
customize the component's body-painting behavior. The component's body
is painted first, before the border and children.
paintText
protected void paintText(java.awt.Graphics _g,
int _scale)
click
public void click(int _x,
int _y)
drag
public void drag(int _x,
int _y)
release
public void release(int _x,
int _y)
draw
public void draw(int _x,
int _y)
paint
public void paint(int _x,
int _y)
fill
public void fill(int _x,
int _y)
setPaintState
public void setPaintState(int _paintState)
getPaintState
public int getPaintState()
setTextFont
public void setTextFont(java.awt.Font _textFont)
getTextFont
public java.awt.Font getTextFont()
setScale
public void setScale(int _scale)
getScale
public int getScale()
setStrokeWidth
public void setStrokeWidth(int _strokeWidth)
getStrokeWidth
public int getStrokeWidth()
setColor
public void setColor(java.awt.Color _color)
getImage
public java.awt.Image getImage()
setImage
public void setImage(java.awt.Image _image)
getImageWidth
public int getImageWidth()
getImageHeight
public int getImageHeight()
getPreferredSize
public java.awt.Dimension getPreferredSize()
- Description copied from class:
javax.swing.JComponent
- Get the component's preferred size. If the JComponent.preferredSize>
JComponent.preferredSize 55
property has been explicitly set, it is returned. If the JComponent.preferredSize>JComponent.preferredSize 55 property has not been set but the JComponent.ui>JComponent.ui 55 property
has been, the result of ComponentUI.getPreferredSize(javax.swing.JComponent)>ComponentUI.getPreferredSize(javax.swing.JComponent) 55 is
returned. If neither property has been set, the result of Container.getPreferredSize()>Container.getPreferredSize() 55 is returned.
finalize
public void finalize()
- Description copied from class:
java.lang.Object
- Called on an object by the Virtual Machine at most once,
at some point after the Object is determined unreachable
but before it is destroyed. You would think that this
means it eventually is called on every Object, but this is
not necessarily the case. If execution terminates
abnormally, garbage collection does not always happen.
Thus you cannot rely on this method to always work.
For finer control over garbage collection, use references
from the
java.lang.ref package.
Virtual Machines are free to not call this method if
they can determine that it does nothing important; for
example, if your class extends Object and overrides
finalize to do simply super.finalize().
finalize() will be called by a java.lang.Thread that has no
locks on any Objects, and may be called concurrently.
There are no guarantees on the order in which multiple
objects are finalized. This means that finalize() is
usually unsuited for performing actions that must be
thread-safe, and that your implementation must be
use defensive programming if it is to always work.
If an Exception is thrown from finalize() during garbage
collection, it will be patently ignored and the Object will
still be destroyed.
It is allowed, although not typical, for user code to call
finalize() directly. User invocation does not affect whether
automatic invocation will occur. It is also permitted,
although not recommended, for a finalize() method to "revive"
an object by making it reachable from normal code again.
Unlike constructors, finalize() does not get called
for an object's superclass unless the implementation
specifically calls super.finalize().
The default implementation does nothing.
saveUndo
public void saveUndo()
undo
public void undo()
getModificationTime
public long getModificationTime()
paint
protected void paint(int _x,
int _y,
int _state)
drawImage
protected void drawImage(java.awt.Image _fromImage,
java.awt.Graphics _toGraphics)
floodFill
protected void floodFill(int _x,
int _y,
int _newColor,
int[] _pixels)