|
Holger's Java API |
|||||||||
| 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
com.antelmann.image.JImagePanel
public class JImagePanel
a special panel for images that allows drag/drop as well as copy/paste.
This component fires PropertyChangeEvent objects with key 'image'
upon changing the image.
By default, the component is editable.
All image changes fire a property change event with key 'image'.
JComponent.setEnabled(boolean) is effectively the same as setEditable(boolean).
| Nested Class Summary |
|---|
| 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 |
|---|
| 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 java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
JImagePanel()
uses 200 x 200 as dimension |
|
JImagePanel(Dimension d)
|
|
JImagePanel(Image image)
takes height and width from the given image |
|
JImagePanel(Image image,
Dimension d)
|
|
JImagePanel(Image image,
Dimension d,
boolean enableDelete)
|
|
JImagePanel(Image image,
int width,
int height)
|
|
JImagePanel(int width,
int height)
|
|
| Method Summary | |
|---|---|
void |
addContextMenuFactory(Factory<JMenuItem> factory)
allows to register an additional context menu option by providing a factory that can conditionally return a JMenuItem. |
void |
clearContextMenuFactory()
|
protected JPopupMenu |
createContextMenu()
creates the pop-up menu that is enabled on the component. |
protected File |
createFileForDrop()
creates and returns a temp file with some generated name using 'unnamed_file' as a prefix |
protected void |
crop(Point cp,
Point dp)
|
Image |
getImage()
|
String |
getImageFileSaveFormat()
|
Filter<Image> |
getImageImportFilter()
|
Image |
getRelevantValue()
returns the relevant value for this instance at the time of calling |
Filter<URL> |
getUrlImportFilter()
|
protected boolean |
importTransferable(Transferable t)
|
boolean |
isCroppingEnabled()
|
boolean |
isEditable()
|
boolean |
isScaleUpToFit()
determines whether the image is to be scaled if it is smaller than the panel (false by default) |
protected boolean |
isSupported(DataFlavor[] flavors)
|
protected boolean |
isSupported(Transferable t)
|
protected void |
paintComponent(Graphics g)
|
protected void |
rotate(double degrees)
|
void |
setCroppingEnabled(boolean flag)
|
void |
setEditable(boolean flag)
|
void |
setImage(Image image)
fires a property change event with key 'image'. |
void |
setImageFile(File file)
simply calls the setImageURL(URL) method |
void |
setImageFileSaveFormat(String imageFileSaveFormat)
|
void |
setImageImportFilter(Filter<Image> imageFilter)
allows to set a filter that is applied when importing an image through either drag and drop or pasting |
void |
setImageProcessor(Processor<Image,? extends RuntimeException> imageProcessor)
allows to alter the image before it's set by setImage(Image) (for instance by scaling it) |
void |
setImageURL(URL url)
calls setImage(Image) on the InputStream read |
void |
setRelevantValue(Image image)
sets the relevant value for this instance with the given value |
void |
setScaleUpToFit(boolean scaleUpToFilt)
allows to specify whether the image is to be scaled if it is smaller than the panel |
void |
setUrlImportFilter(Filter<URL> urlImportFilter)
|
void |
showInSeparateFrame()
called from the popup menu when the image is to be shown in a separate frame |
protected Point |
toImagePoint(Point componentPoint)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public JImagePanel()
public JImagePanel(int width,
int height)
public JImagePanel(Dimension d)
public JImagePanel(Image image,
int width,
int height)
public JImagePanel(Image image)
public JImagePanel(Image image,
Dimension d)
public JImagePanel(Image image,
Dimension d,
boolean enableDelete)
| Method Detail |
|---|
public void addContextMenuFactory(Factory<JMenuItem> factory)
public void clearContextMenuFactory()
protected boolean isSupported(Transferable t)
protected boolean isSupported(DataFlavor[] flavors)
protected boolean importTransferable(Transferable t)
throws UnsupportedFlavorException,
IOException
UnsupportedFlavorException
IOExceptionpublic void setCroppingEnabled(boolean flag)
public boolean isCroppingEnabled()
protected void crop(Point cp,
Point dp)
protected Point toImagePoint(Point componentPoint)
protected void rotate(double degrees)
protected JPopupMenu createContextMenu()
protected File createFileForDrop()
throws IOException
IOExceptionpublic Filter<Image> getImageImportFilter()
public void setImageImportFilter(Filter<Image> imageFilter)
public Filter<URL> getUrlImportFilter()
public void setUrlImportFilter(Filter<URL> urlImportFilter)
public String getImageFileSaveFormat()
public void setImageFileSaveFormat(String imageFileSaveFormat)
public void setImageProcessor(Processor<Image,? extends RuntimeException> imageProcessor)
setImage(Image) (for instance by scaling it)
public void showInSeparateFrame()
public void setImageFile(File file)
throws IOException
setImageURL(URL) method
IOException
public void setImageURL(URL url)
throws IOException
setImage(Image) on the InputStream read
IOExceptionpublic void setImage(Image image)
public Image getImage()
public Image getRelevantValue()
ValueRetriever
getRelevantValue in interface ValueRetriever<Image>
public void setRelevantValue(Image image)
throws Exception
ValueSetter
setRelevantValue in interface ValueSetter<Image>Exceptionpublic boolean isScaleUpToFit()
public void setScaleUpToFit(boolean scaleUpToFilt)
protected void paintComponent(Graphics g)
paintComponent in class JComponentpublic boolean isEditable()
isEditable in interface EditableComponentpublic void setEditable(boolean flag)
setEditable in interface EditableComponent
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||