JHotDraw 7.5.1

org.jhotdraw.samples.svg
Class SVGCreateFromFileTool

java.lang.Object
  extended by org.jhotdraw.beans.AbstractBean
      extended by org.jhotdraw.draw.tool.AbstractTool
          extended by org.jhotdraw.draw.tool.CreationTool
              extended by org.jhotdraw.samples.svg.SVGCreateFromFileTool
All Implemented Interfaces:
java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, Tool

public class SVGCreateFromFileTool
extends CreationTool

A tool to create new figures from an input file. If the file holds a bitmap image, this tool creates a SVGImageFigure. If the file holds a SVG or a SVGZ image, ths tool creates a SVGGroupFigure.

Immediately, after the ImageTool has been activated, it opens a JFileChooser, letting the user specify a file. The the user then performs the following mouse gesture:

  1. Press the mouse button and drag the mouse over the DrawingView. This defines the bounds of the created Figure.

Version:
$Id: SVGCreateFromFileTool.java 641 2010-01-23 12:53:28Z rawcoder $
Author:
Werner Randelshofer
See Also:
Serialized Form

Field Summary
protected  javax.swing.JFileChooser fileChooser
           
protected  java.awt.FileDialog fileDialog
           
protected  CompositeFigure groupPrototype
           
protected  ImageHolderFigure imagePrototype
           
protected  boolean useFileDialog
           
protected  java.lang.Thread workerThread
           
 
Fields inherited from class org.jhotdraw.draw.tool.CreationTool
createdFigure, minimalSize, minimalSizeTreshold, presentationName, prototype, prototypeAttributes
 
Fields inherited from class org.jhotdraw.draw.tool.AbstractTool
anchor, editor, isWorking, listenerList
 
Fields inherited from class org.jhotdraw.beans.AbstractBean
propertySupport
 
Constructor Summary
SVGCreateFromFileTool(ImageHolderFigure imagePrototype, CompositeFigure groupPrototype)
          Creates a new instance.
SVGCreateFromFileTool(ImageHolderFigure imagePrototype, CompositeFigure groupPrototype, java.util.Map<AttributeKey,java.lang.Object> attributes)
          Creates a new instance.
 
Method Summary
 void activate(DrawingEditor editor)
          Activates the tool for the given editor.
protected  Figure createFigure()
           
 boolean isUseFileDialog()
           
 void setUseFileDialog(boolean newValue)
           
 
Methods inherited from class org.jhotdraw.draw.tool.CreationTool
creationFinished, deactivate, getAddedFigure, getCreatedFigure, getPrototype, isToolDoneAfterCreation, mouseDragged, mousePressed, mouseReleased, setToolDoneAfterCreation, updateCursor
 
Methods inherited from class org.jhotdraw.draw.tool.AbstractTool
addToolListener, addUndoableEditListener, constrainPoint, constrainPoint, createActionMap, createInputMap, draw, editCopy, editCut, editDelete, editDuplicate, editPaste, fireAreaInvalidated, fireAreaInvalidated, fireBoundsInvalidated, fireToolDone, fireToolStarted, getActionMap, getDrawing, getEditor, getInputMap, getToolTipText, getView, isActive, keyPressed, keyReleased, keyTyped, maybeFireBoundsInvalidated, mouseClicked, mouseEntered, mouseExited, mouseMoved, removeToolListener, removeUndoableEditListener, setActionMap, setInputMap, supportsHandleInteraction, viewToDrawing
 
Methods inherited from class org.jhotdraw.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, clone, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fileDialog

protected java.awt.FileDialog fileDialog

fileChooser

protected javax.swing.JFileChooser fileChooser

workerThread

protected java.lang.Thread workerThread

groupPrototype

protected CompositeFigure groupPrototype

imagePrototype

protected ImageHolderFigure imagePrototype

useFileDialog

protected boolean useFileDialog
Constructor Detail

SVGCreateFromFileTool

public SVGCreateFromFileTool(ImageHolderFigure imagePrototype,
                             CompositeFigure groupPrototype)
Creates a new instance.


SVGCreateFromFileTool

public SVGCreateFromFileTool(ImageHolderFigure imagePrototype,
                             CompositeFigure groupPrototype,
                             java.util.Map<AttributeKey,java.lang.Object> attributes)
Creates a new instance.

Method Detail

setUseFileDialog

public void setUseFileDialog(boolean newValue)

isUseFileDialog

public boolean isUseFileDialog()

activate

public void activate(DrawingEditor editor)
Description copied from interface: Tool
Activates the tool for the given editor. This method is called whenever the user switches to this tool.

Specified by:
activate in interface Tool
Overrides:
activate in class CreationTool

createFigure

protected Figure createFigure()
Overrides:
createFigure in class CreationTool

Copyright 1996-2010 (c) by the authors and contributors of the JHotDraw project.
Some rights reserved.