net.sf.jaxodraw.io
Class JaxoPreview

java.lang.Object
  extended by net.sf.jaxodraw.io.JaxoPreview
All Implemented Interfaces:
java.lang.Cloneable

public class JaxoPreview
extends java.lang.Object
implements java.lang.Cloneable

Responsible for viewing, like the results of an export. In general, one has to create temporary files that are opened with a default application and deleted after the program terminates. For postscript preview, it is mandatory to specify a default application in the preferences, the LaTeX preview may be done with Java's internal JEditorPane.

Since:
2.0

Field Summary
static java.lang.String USER_DIR
          The user's home directory.
 
Constructor Summary
JaxoPreview(java.awt.Component parentc)
          Constructor.
 
Method Summary
 void browseURL(java.net.URL u)
          Show a window displaying the given URL, allowing the user to browse.
 void browseURLInternally(java.net.URL u)
          Show a window displaying the URL (typically HTML), allowing the user to browse.
 boolean canShowPostscript()
          Is it possible to show postscript files?
 JaxoPreview copy()
          Returns a copy (clone) of this preview.
 java.awt.Component getParentComponent()
          Parent component to use for window owners.
 java.lang.String getTitle()
          Title to be used for internally opened Windows.
 void setParentComponent(java.awt.Component value)
          Sets the parent component.
 void setTitle(java.lang.String value)
          Sets the title of this dialog.
 void showComponent(java.awt.Component c)
          Show a window displaying the component.
 void showComponent(java.awt.Component c, javax.swing.JFrame frame)
          Display a component in a given frame.
 void showMessageForPostscriptViewer()
          Show a message that the user cannot view postscript files.
 void showPostscript(java.io.File f)
          Show the postscript file 'f', or a message that it cannot be shown.
 void showText(java.lang.String text, java.lang.String fileName)
          Show a window displaying the text file.
 void showText(java.lang.String text, java.lang.String fileName, javax.swing.JFrame frame)
          Show a window displaying the text file.
 void showTextInternally(java.lang.String text)
          Show a window displaying the text file.
 void showTextInternally(java.lang.String text, javax.swing.JFrame frame)
          Display a text file in a given frame.
 void showURLInternally(java.net.URL u)
          Show a window displaying the URL (typically HTML), not allowing the user to browse.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USER_DIR

public static final java.lang.String USER_DIR
The user's home directory.

Constructor Detail

JaxoPreview

public JaxoPreview(java.awt.Component parentc)
Constructor.

Parameters:
parentc - Component whose Window to use a parent for dialogs.
Method Detail

getParentComponent

public final java.awt.Component getParentComponent()
Parent component to use for window owners.

Returns:
The parent component.

setParentComponent

public void setParentComponent(java.awt.Component value)
Sets the parent component.

Parameters:
value - The parent component.

copy

public JaxoPreview copy()
Returns a copy (clone) of this preview.

Returns:
A clone of this preview.

getTitle

public final java.lang.String getTitle()
Title to be used for internally opened Windows. By default, JaxoInfo.VERSION.

Returns:
The title of the dialog.

setTitle

public void setTitle(java.lang.String value)
Sets the title of this dialog.

Parameters:
value - The title.

showComponent

public void showComponent(java.awt.Component c)
Show a window displaying the component.

Parameters:
c - The component to show.

showComponent

public void showComponent(java.awt.Component c,
                          javax.swing.JFrame frame)
Display a component in a given frame. Any contents of the frame's ContentPane are removed.

Parameters:
c - The component to show.
frame - The frame to show the Component in.

showText

public void showText(java.lang.String text,
                     java.lang.String fileName)
              throws java.io.IOException
Show a window displaying the text file. If there is an external editor, use that.

Parameters:
text - the text to show.
fileName - The name of the temporary file that is created when the external editor is used. It is created in the user home dir.
Throws:
java.io.IOException - when there is a problem writing the temporary file when the external editor is used.

showText

public void showText(java.lang.String text,
                     java.lang.String fileName,
                     javax.swing.JFrame frame)
              throws java.io.IOException
Show a window displaying the text file. If there is an external editor, use that.

Parameters:
text - the text to show.
fileName - The name of the temporary file that is created when the external editor is used. It is created in the user home dir.
frame - the frame to show the component in.
Throws:
java.io.IOException - when there is a problem writing the temporary file when the external editor is used.

showTextInternally

public void showTextInternally(java.lang.String text)
Show a window displaying the text file. Always use the internal editor (JEditorPane).

Parameters:
text - The text.

showTextInternally

public void showTextInternally(java.lang.String text,
                               javax.swing.JFrame frame)
Display a text file in a given frame. Always use an internal editor (JEditorPane). Any contents of the frame's ContentPane are removed.

Parameters:
text - The text.
frame - the frame to show the component in.

browseURL

public void browseURL(java.net.URL u)
Show a window displaying the given URL, allowing the user to browse. Use an external editor if available, otherwise the internal editor (JEditorPane).

Parameters:
u - The URL to display.

showURLInternally

public void showURLInternally(java.net.URL u)
Show a window displaying the URL (typically HTML), not allowing the user to browse.

Parameters:
u - The URL to display.

browseURLInternally

public void browseURLInternally(java.net.URL u)
Show a window displaying the URL (typically HTML), allowing the user to browse.

Parameters:
u - The URL to display.

canShowPostscript

public boolean canShowPostscript()
Is it possible to show postscript files?

Returns:
True if a postscript viewer has been specified in the preferences.

showMessageForPostscriptViewer

public void showMessageForPostscriptViewer()
Show a message that the user cannot view postscript files.

See Also:
canShowPostscript()

showPostscript

public void showPostscript(java.io.File f)
Show the postscript file 'f', or a message that it cannot be shown.

Parameters:
f - The ps file to show.
See Also:
canShowPostscript(), showMessageForPostscriptViewer()


Licensed under GPL. For more information, see http://jaxodraw.sourceforge.net/license.html or the LICENSE file in the jaxodraw distribution.