jfig.commands
Class JCreateImageCommand

java.lang.Object
  extended byjfig.commands.Command
      extended byjfig.commands.JCreateImageCommand
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, java.awt.event.ItemListener, java.awt.event.WindowListener

public class JCreateImageCommand
extends Command
implements java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.event.WindowListener

command to create an embedded image object.

JCreateImageCommand allows the user to create a FIG image object. Note that the FigImage class relies on the Java AWT image classes. Therefore, not all image formats supported by xfig can be displayed. Currently, XBM, GIF, PNG, and JPEG images work on all platforms, TIFF, and EPS/Postscript usually are not supported.

The image file/URL/resource name and the initial aspect ratio settings are specified interactively using the CreateImageDialog window. To process the events generated by the CreateImageDialog, this class implements both the ActionListener and the ItemListener interface.

See Also:
FigImage, JCreateImageDialog

Field Summary
protected  FigAttribs attribs
           
protected static javax.swing.JFileChooser fileChooser
           
protected  java.lang.String filename
           
protected static java.awt.Frame frame
           
protected  java.awt.Image image
           
protected  FigObject imageObject
           
protected  JCreateImageDialog imageOptionsDialog
           
protected  int n_points
           
protected  java.awt.Point P1
           
protected  java.awt.Point P2
           
 
Fields inherited from class jfig.commands.Command
editor, objectCanvas, ready
 
Constructor Summary
JCreateImageCommand(FigBasicEditor editor, FigCanvas objectCanvas)
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
          actionPerformed: handle callbacks from the imageOptionsDialog (Cancel, LoadImage, OK).
 void execute()
          execute the current editor command
 java.lang.String getDescription()
          one-line description of this command
 FigObject[] getModifiedObjects()
          return an array-wrapped reference to the embedded image object created by this command.
 void itemStateChanged(java.awt.event.ItemEvent evt)
          itemStateChanged: handle callbacks from the imageOptionsDialog, when the user changed the image aspect ratio settings.
 void mousePressed(FigCanvasEvent evt)
          mousePressed: collect the corner points of the new image object
 void setFrame(java.awt.Frame f)
          setFrame: specify a visible AWT frame as a parent for the image options dialog window.
 java.lang.String toString()
          return a (possibly verbose) description of this Command object
 void undo()
          undo this command
 void windowActivated(java.awt.event.WindowEvent dummy)
           
 void windowClosed(java.awt.event.WindowEvent dummy)
           
 void windowClosing(java.awt.event.WindowEvent we)
          handle the "close" window decoration button on imageOptionsDialog: cancel
 void windowDeactivated(java.awt.event.WindowEvent dummy)
           
 void windowDeiconified(java.awt.event.WindowEvent dummy)
           
 void windowIconified(java.awt.event.WindowEvent dummy)
           
 void windowOpened(java.awt.event.WindowEvent dummy)
           
 
Methods inherited from class jfig.commands.Command
cancel, isReady, message, notifyEditor, statusMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

n_points

protected int n_points

imageObject

protected FigObject imageObject

attribs

protected FigAttribs attribs

image

protected java.awt.Image image

P1

protected java.awt.Point P1

P2

protected java.awt.Point P2

filename

protected java.lang.String filename

imageOptionsDialog

protected JCreateImageDialog imageOptionsDialog

fileChooser

protected static javax.swing.JFileChooser fileChooser

frame

protected static java.awt.Frame frame
Constructor Detail

JCreateImageCommand

public JCreateImageCommand(FigBasicEditor editor,
                           FigCanvas objectCanvas)
Method Detail

getModifiedObjects

public FigObject[] getModifiedObjects()
return an array-wrapped reference to the embedded image object created by this command. The image object reference may be null.

Overrides:
getModifiedObjects in class Command

setFrame

public void setFrame(java.awt.Frame f)
setFrame: specify a visible AWT frame as a parent for the image options dialog window. Typically, your editor should register its Frame here.

If no Frame was registered by calling setFrame(), JCreateImageCommand will create a dummy Frame when necessary.


execute

public void execute()
Description copied from class: Command
execute the current editor command

This method is empty for class Command.

Overrides:
execute in class Command

undo

public void undo()
Description copied from class: Command
undo this command

Try to undo this command as far as possible. Don't try to undo() a command that has never been execute()d before. This method is empty for class Command.

Overrides:
undo in class Command

mousePressed

public void mousePressed(FigCanvasEvent evt)
mousePressed: collect the corner points of the new image object

This method first waits for two mouse-clicks, to specify the coordinates (opposite corners) of the new image object. Then, the imageOptionsDialog is created and shown, to specify the image source file/URL/resource and the image aspect ratio.

Overrides:
mousePressed in class Command

windowClosing

public void windowClosing(java.awt.event.WindowEvent we)
handle the "close" window decoration button on imageOptionsDialog: cancel

Specified by:
windowClosing in interface java.awt.event.WindowListener

windowOpened

public void windowOpened(java.awt.event.WindowEvent dummy)
Specified by:
windowOpened in interface java.awt.event.WindowListener

windowClosed

public void windowClosed(java.awt.event.WindowEvent dummy)
Specified by:
windowClosed in interface java.awt.event.WindowListener

windowIconified

public void windowIconified(java.awt.event.WindowEvent dummy)
Specified by:
windowIconified in interface java.awt.event.WindowListener

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent dummy)
Specified by:
windowDeiconified in interface java.awt.event.WindowListener

windowActivated

public void windowActivated(java.awt.event.WindowEvent dummy)
Specified by:
windowActivated in interface java.awt.event.WindowListener

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent dummy)
Specified by:
windowDeactivated in interface java.awt.event.WindowListener

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
actionPerformed: handle callbacks from the imageOptionsDialog (Cancel, LoadImage, OK).

Specified by:
actionPerformed in interface java.awt.event.ActionListener

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent evt)
itemStateChanged: handle callbacks from the imageOptionsDialog, when the user changed the image aspect ratio settings.

Specified by:
itemStateChanged in interface java.awt.event.ItemListener

getDescription

public java.lang.String getDescription()
Description copied from class: Command
one-line description of this command

return a one-line desription of this command, e.g. to label the undo/redo buttons, if any

Overrides:
getDescription in class Command

toString

public java.lang.String toString()
Description copied from class: Command
return a (possibly verbose) description of this Command object

Overrides:
toString in class Command