net.sf.latexdraw.instruments
Class Exporter

java.lang.Object
  extended by org.malai.instrument.Instrument
      extended by org.malai.instrument.WidgetInstrument
          extended by net.sf.latexdraw.instruments.Exporter
All Implemented Interfaces:
ActionHandler, Preferenciable, Modifiable, Reinitialisable, UndoHandler

public class Exporter
extends WidgetInstrument

This instrument exports a drawing in different formats.

This file is part of LaTeXDraw.
Copyright (c) 2005-2012 Arnaud BLOUIN

LaTeXDraw is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
LaTeXDraw is distributed without any warranty; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

05/23/2010

Since:
3.0
Author:
Arnaud BLOUIN

Field Summary
protected  ICanvas canvas
          The canvas that contains the shapes to export.
protected  java.lang.String defaultPackages
          The latex packages that the interactive system saves by default.
protected  IDrawing drawing
          The drawing that contains the shapes to export.
protected  MMenu exportMenu
          The export menu that contains all the export menu item.
protected  ExportDialog fileChooserExport
          The dialog box that allows to define where the drawing must be exported.
static java.lang.String LABEL_EXPORT_AS
          The label of the menu export as
static java.lang.String LABEL_EXPORT_BMP
          The label of the exportAsBMPFile item
static java.lang.String LABEL_EXPORT_JPG
          The label of the exportDrawMenu item
static java.lang.String LABEL_EXPORT_PNG
          The label of the exportAsPNGFile item
static java.lang.String LABEL_EXPORT_TRICKS
          The label of the exportCodeMenu item
protected  MMenuItem menuItemBMP
          The menu item that export as BMP picture.
protected  MMenuItem menuItemEPSLatex
          The menu item that export as PS (using latex) document.
protected  MMenuItem menuItemJPG
          The menu item that export as JPG picture.
protected  MMenuItem menuItemPDF
          The menu item that export as PDF document.
protected  MMenuItem menuItemPDFcrop
          The menu item that export as PDF (using pdfcrop) document.
protected  MMenuItem menuItemPNG
          The menu item that export as PNG picture.
protected  MMenuItem menuItemPST
          The menu item that export as PST code.
protected  java.lang.String pathExport
          The default location of the exports.
protected  MButton pdfButton
          The button used to export the drawing as a pdf document.
protected  javax.swing.JLabel statusBar
          The field where messages are displayed.
static java.lang.String TITLE_DIALOG_EXPORT
          The title of the dialog box used to export drawings.
 
Fields inherited from class org.malai.instrument.WidgetInstrument
composer
 
Fields inherited from class org.malai.instrument.Instrument
activated, eventables, links, modified
 
Constructor Summary
Exporter(UIComposer<?> composer, ICanvas canvas, IDrawing drawing, javax.swing.JLabel statusBar)
          Creates the instrument.
 
Method Summary
 java.lang.String getDefaultPackages()
           
protected  ExportDialog getExportDialog(Export.ExportFormat format)
           
 MMenu getExportMenu()
           
 java.lang.String getPathExport()
           
 MButton getPdfButton()
           
protected  void initialiseLinks()
          Initialises the links of the instrument.
protected  void initialiseWidgets()
          Initialises the widgets of the instrument.
 void load(boolean generalPreferences, java.lang.String nsURI, org.w3c.dom.Element root)
          Loads data save in an XML document.
 void onActionExecuted(Action action)
          Notifies the handler when the given action is executed.
 void reinit()
          Reinitialises the object.
 void save(boolean generalPreferences, java.lang.String nsURI, org.w3c.dom.Document document, org.w3c.dom.Element root)
          Saves the parameters of the instrument into an XML tag.
 void setActivated(boolean activated)
          Activates or deactivates the instrument.
 void setActivated(boolean activated, boolean hide)
          Activates or deactivates the instrument.
 void setDefaultPackages(java.lang.String defaultPackages)
           
 void setPackages(java.lang.String packages)
           
 void setPathExport(java.lang.String pathExport)
           
 
Methods inherited from class org.malai.instrument.WidgetInstrument
getComposer
 
Methods inherited from class org.malai.instrument.Instrument
addEventable, addLink, clearEvents, getLinks, getSizeLinks, hasLinks, interimFeedback, isActivated, isModified, onActionAborted, onActionAdded, onActionCancelled, onActionDone, onUndoableAdded, onUndoableRedo, onUndoableUndo, removeLink, setModified
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TITLE_DIALOG_EXPORT

public static final java.lang.String TITLE_DIALOG_EXPORT
The title of the dialog box used to export drawings.

See Also:
Constant Field Values

LABEL_EXPORT_BMP

public static final java.lang.String LABEL_EXPORT_BMP
The label of the exportAsBMPFile item


LABEL_EXPORT_PNG

public static final java.lang.String LABEL_EXPORT_PNG
The label of the exportAsPNGFile item


LABEL_EXPORT_TRICKS

public static final java.lang.String LABEL_EXPORT_TRICKS
The label of the exportCodeMenu item


LABEL_EXPORT_JPG

public static final java.lang.String LABEL_EXPORT_JPG
The label of the exportDrawMenu item


LABEL_EXPORT_AS

public static final java.lang.String LABEL_EXPORT_AS
The label of the menu export as


canvas

protected ICanvas canvas
The canvas that contains the shapes to export. The canvas is used instead of the drawing because to export as picture, we paint the views into a graphics.


drawing

protected IDrawing drawing
The drawing that contains the shapes to export.


pdfButton

protected MButton pdfButton
The button used to export the drawing as a pdf document.


exportMenu

protected MMenu exportMenu
The export menu that contains all the export menu item.


menuItemPST

protected MMenuItem menuItemPST
The menu item that export as PST code.


menuItemJPG

protected MMenuItem menuItemJPG
The menu item that export as JPG picture.


menuItemPNG

protected MMenuItem menuItemPNG
The menu item that export as PNG picture.


menuItemBMP

protected MMenuItem menuItemBMP
The menu item that export as BMP picture.


menuItemPDF

protected MMenuItem menuItemPDF
The menu item that export as PDF document.


menuItemEPSLatex

protected MMenuItem menuItemEPSLatex
The menu item that export as PS (using latex) document.


menuItemPDFcrop

protected MMenuItem menuItemPDFcrop
The menu item that export as PDF (using pdfcrop) document.


fileChooserExport

protected ExportDialog fileChooserExport
The dialog box that allows to define where the drawing must be exported.


pathExport

protected java.lang.String pathExport
The default location of the exports.


defaultPackages

protected java.lang.String defaultPackages
The latex packages that the interactive system saves by default. These packages should by set by the user and must be general, i.e. independent of any document.


statusBar

protected javax.swing.JLabel statusBar
The field where messages are displayed.

Constructor Detail

Exporter

public Exporter(UIComposer<?> composer,
                ICanvas canvas,
                IDrawing drawing,
                javax.swing.JLabel statusBar)
Creates the instrument.

Parameters:
composer - The composer that manages the widgets of the instrument.
canvas - The canvas that contains the views to export (for pictures).
drawing - The drawing that contains the shapes to export (for latex and code).
statusBar - The status bar where messages are displayed.
Throws:
java.lang.IllegalArgumentException - If one of the given arguments is null.
Since:
3.0
Method Detail

initialiseWidgets

protected void initialiseWidgets()
Description copied from class: WidgetInstrument
Initialises the widgets of the instrument.

Specified by:
initialiseWidgets in class WidgetInstrument

reinit

public void reinit()
Description copied from interface: Reinitialisable
Reinitialises the object.

Specified by:
reinit in interface Reinitialisable
Overrides:
reinit in class Instrument

load

public void load(boolean generalPreferences,
                 java.lang.String nsURI,
                 org.w3c.dom.Element root)
Description copied from interface: Preferenciable
Loads data save in an XML document.

Specified by:
load in interface Preferenciable
Overrides:
load in class Instrument
Parameters:
generalPreferences - True: this operation is called to load the general preferences of the interactive system. Otherwise, it is called to load a presentation in a document. This parameter is useful when different information must be loaded during a presentation backup or a general preferences backup.
nsURI - The namespace that must be added to tags corresponding to the instrument's parameters.
root - The meta data element.

save

public void save(boolean generalPreferences,
                 java.lang.String nsURI,
                 org.w3c.dom.Document document,
                 org.w3c.dom.Element root)
Description copied from interface: Preferenciable
Saves the parameters of the instrument into an XML tag.

Specified by:
save in interface Preferenciable
Overrides:
save in class Instrument
Parameters:
generalPreferences - True: this operation is called to save the general preferences of the interactive system. Otherwise, it is called to save a presentation in a document. This parameter is useful when different information must be saved during a presentation backup or a general preferences backup.
nsURI - The namespace that must be added to tags corresponding to the instrument's parameters.
document - The XML document.
root - The root element that will contains the instrument's parameters.

setActivated

public void setActivated(boolean activated,
                         boolean hide)
Description copied from class: WidgetInstrument
Activates or deactivates the instrument. This operation is related to Instrument.setActivated(boolean) but the difference is that is this opedeactivateration another parameter can be used to define is the widgets of the instrument must be hidden: in some cases, deactivating the instrument just implies disabling its widgets (but they are still visible); in some others cases, deactivating the instrument means hiding the widgets. Should be overridden to define the process of hiding the widgets.

Overrides:
setActivated in class WidgetInstrument
Parameters:
activated - True = activation.
hide - If true the widgets will be hidden. Only while deactivating the instrument.

setActivated

public void setActivated(boolean activated)
Description copied from class: Instrument
Activates or deactivates the instrument.

Overrides:
setActivated in class Instrument
Parameters:
activated - True = activation.

initialiseLinks

protected void initialiseLinks()
Description copied from class: Instrument
Initialises the links of the instrument.

Specified by:
initialiseLinks in class Instrument

getPdfButton

public MButton getPdfButton()
Returns:
The button used to export the drawing as a pdf document.
Since:
3.0

getExportMenu

public MMenu getExportMenu()
Returns:
The export menu that contains all the export menu item.
Since:
3.0

getExportDialog

protected ExportDialog getExportDialog(Export.ExportFormat format)
Parameters:
format - The format of the document to export.
Returns:
The export dialog to select a path.
Since:
3.0

onActionExecuted

public void onActionExecuted(Action action)
Description copied from interface: ActionHandler
Notifies the handler when the given action is executed.

Specified by:
onActionExecuted in interface ActionHandler
Overrides:
onActionExecuted in class Instrument
Parameters:
action - The executed action.

getDefaultPackages

public java.lang.String getDefaultPackages()
Returns:
The latex packages that the interactive system saves by default.
Since:
3.0

setDefaultPackages

public void setDefaultPackages(java.lang.String defaultPackages)
Parameters:
defaultPackages - The latex packages that the interactive system saves by default. These packages should by set by the user and must be general, i.e. independent of any document. Packages for a given document should by set using setPackages(String).
Since:
3.0

setPackages

public void setPackages(java.lang.String packages)
Parameters:
packages - The latex packages used when exporting using latex. These packages are defined for the current document but not for all documents. These general packages can be set using setDefaultPackages(String).
Since:
3.0

getPathExport

public java.lang.String getPathExport()
Returns:
The path where files are exported.
Since:
3.0

setPathExport

public void setPathExport(java.lang.String pathExport)
Parameters:
pathExport - The path where files are exported.
Since:
3.0