com.sun.electric.tool.user.ui
Class TextWindow

java.lang.Object
  extended by com.sun.electric.tool.user.ui.TextWindow
All Implemented Interfaces:
WindowContent

public class TextWindow
extends java.lang.Object
implements WindowContent

This class defines a text window for displaying text cells.


Constructor Summary
TextWindow(Cell cell, WindowFrame wf)
          Factory method to create a new TextWindow with a given cell, in a given WindowFrame.
 
Method Summary
static void addTextRedoListener(java.beans.PropertyChangeListener l)
           
static void addTextUndoListener(java.beans.PropertyChangeListener l)
           
 void bottomScrollChanged(int value)
           
 void centerCursor()
          Method to shift the window so that the current cursor location becomes the center.
 java.lang.String[] convertToStrings()
          Method to convert the document in this window to an array of strings.
 void fillScreen()
          Method to pan and zoom the screen so that the entire cell is displayed.
 boolean findNextText(boolean reverse)
          Method to find the next occurrence of a string.
 void finished()
          Method to get rid of this EditWindow.
 void focusOnHighlighted()
           
 void fullRepaint()
           
 Cell getCell()
          Method to return the cell that is shown in this window.
 Highlighter getHighlighter()
          Get the Highlighter for this window
 int getLineCount()
          Method to return the number of lines of text in this TextWindow.
 javax.swing.JPanel getPanel()
          Method to return the top-level JPanel for this TextWindow.
 java.awt.image.BufferedImage getPrintImage(ElectricPrinter ep)
          Method to print window using offscreen canvas.
 void goToLineNumber(int lineNumber)
          Method to select a line number in this TextWindow.
 boolean initializePrinting(ElectricPrinter ep, java.awt.print.PageFormat pageFormat)
          Method to intialize for printing.
 void initTextSearch(java.lang.String search, boolean caseSensitive, boolean regExp, java.util.Set<TextUtils.WhatToSearch> whatToSearch, boolean highlightedOnly)
          Method to initialize for a new text search.
 java.util.List<javax.swing.tree.MutableTreeNode> loadExplorerTrees()
           
 void paint(java.awt.Graphics g)
          Method to repaint this TextWindow.
 void panXOrY(int direction, double[] panningAmounts, int ticks)
          Method to pan along X or Y according to fixed amount of ticks
static void readTextCell()
          Method to read a text disk file into this TextWindow.
 void readTextCell(java.lang.String fileName)
           
 void redo()
          Method to redo changes to text in this TextWindow.
static void removeTextRedoListener(java.beans.PropertyChangeListener l)
           
static void removeTextUndoListener(java.beans.PropertyChangeListener l)
           
 void repaint()
           
 void replaceAllText(java.lang.String replace)
          Method to replace all selected text.
 void replaceText(java.lang.String replace)
          Method to replace the text that was just selected with findNextText().
 void rightScrollChanged(int value)
           
 void setCell(Cell cell, VarContext context, WindowFrame.DisplayAttributes displayAttributes)
          Method to set the cell that is shown in the window to "cell".
 void setCursor(java.awt.Cursor cursor)
          Method relevant for waveform windows where the drawing panel is not given by getPanel()
 void setWindowTitle()
          Method to set the window title.
 void undo()
          Method to undo changes to text in this TextWindow.
 void updateFontInformation()
          Method to update the font information in this window.
static void updateText(Cell cell)
          Method to update text for a cell (if it is being displayed).
 void writeImage(ElectricPrinter ep, java.lang.String filePath)
          Method to export directly PNG file
static void writeTextCell()
          Method to save this TextWindow to a disk file.
 boolean writeTextCell(java.lang.String fileName)
          Method to write text cell into a file
 void zoomInContents()
           
 void zoomOutContents()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextWindow

public TextWindow(Cell cell,
                  WindowFrame wf)
Factory method to create a new TextWindow with a given cell, in a given WindowFrame.

Parameters:
cell - the cell in this TextWindow.
wf - the WindowFrame that this TextWindow lives in.
Method Detail

setCursor

public void setCursor(java.awt.Cursor cursor)
Description copied from interface: WindowContent
Method relevant for waveform windows where the drawing panel is not given by getPanel()

Specified by:
setCursor in interface WindowContent
Parameters:
cursor - the cursor to display

addTextUndoListener

public static void addTextUndoListener(java.beans.PropertyChangeListener l)

addTextRedoListener

public static void addTextRedoListener(java.beans.PropertyChangeListener l)

removeTextUndoListener

public static void removeTextUndoListener(java.beans.PropertyChangeListener l)

removeTextRedoListener

public static void removeTextRedoListener(java.beans.PropertyChangeListener l)

undo

public void undo()
Method to undo changes to text in this TextWindow.


redo

public void redo()
Method to redo changes to text in this TextWindow.


paint

public void paint(java.awt.Graphics g)
Method to repaint this TextWindow.


updateFontInformation

public void updateFontInformation()
Method to update the font information in this window.


loadExplorerTrees

public java.util.List<javax.swing.tree.MutableTreeNode> loadExplorerTrees()
Specified by:
loadExplorerTrees in interface WindowContent

getPanel

public javax.swing.JPanel getPanel()
Method to return the top-level JPanel for this TextWindow.

Specified by:
getPanel in interface WindowContent
Returns:
the top-level JPanel for this TextWindow.

finished

public void finished()
Method to get rid of this EditWindow. Called by WindowFrame when that windowFrame gets closed.

Specified by:
finished in interface WindowContent

setWindowTitle

public void setWindowTitle()
Method to set the window title.

Specified by:
setWindowTitle in interface WindowContent

getCell

public Cell getCell()
Method to return the cell that is shown in this window.

Specified by:
getCell in interface WindowContent
Returns:
the cell that is shown in this window.

getHighlighter

public Highlighter getHighlighter()
Description copied from interface: WindowContent
Get the Highlighter for this window

Specified by:
getHighlighter in interface WindowContent

setCell

public void setCell(Cell cell,
                    VarContext context,
                    WindowFrame.DisplayAttributes displayAttributes)
Method to set the cell that is shown in the window to "cell".

Specified by:
setCell in interface WindowContent

readTextCell

public static void readTextCell()
Method to read a text disk file into this TextWindow.


readTextCell

public void readTextCell(java.lang.String fileName)

writeTextCell

public static void writeTextCell()
Method to save this TextWindow to a disk file.


writeTextCell

public boolean writeTextCell(java.lang.String fileName)
Method to write text cell into a file

Parameters:
fileName -
Returns:
true if no errors were found

goToLineNumber

public void goToLineNumber(int lineNumber)
Method to select a line number in this TextWindow.

Parameters:
lineNumber - the line to select (1-based).

updateText

public static void updateText(Cell cell)
Method to update text for a cell (if it is being displayed). This is called when the text for a cell has been changed by some other part of the system, and should be redisplayed where appropriate.

Parameters:
cell - the Cell whose text changed.

getLineCount

public int getLineCount()
Method to return the number of lines of text in this TextWindow.

Returns:
the number of lines of text in this TextWindow.

convertToStrings

public java.lang.String[] convertToStrings()
Method to convert the document in this window to an array of strings.

Returns:
an array of strings with the current text.

rightScrollChanged

public void rightScrollChanged(int value)
Specified by:
rightScrollChanged in interface WindowContent

bottomScrollChanged

public void bottomScrollChanged(int value)
Specified by:
bottomScrollChanged in interface WindowContent

repaint

public void repaint()
Specified by:
repaint in interface WindowContent

fullRepaint

public void fullRepaint()
Specified by:
fullRepaint in interface WindowContent

fillScreen

public void fillScreen()
Method to pan and zoom the screen so that the entire cell is displayed.

Specified by:
fillScreen in interface WindowContent

zoomOutContents

public void zoomOutContents()
Specified by:
zoomOutContents in interface WindowContent

zoomInContents

public void zoomInContents()
Specified by:
zoomInContents in interface WindowContent

focusOnHighlighted

public void focusOnHighlighted()
Specified by:
focusOnHighlighted in interface WindowContent

initTextSearch

public void initTextSearch(java.lang.String search,
                           boolean caseSensitive,
                           boolean regExp,
                           java.util.Set<TextUtils.WhatToSearch> whatToSearch,
                           boolean highlightedOnly)
Method to initialize for a new text search.

Specified by:
initTextSearch in interface WindowContent
Parameters:
search - the string to locate.
caseSensitive - true to match only where the case is the same.
regExp - true if the search string is a regular expression.
whatToSearch - a collection of text types to consider.
highlightedOnly - true to search only in the highlighted area.

findNextText

public boolean findNextText(boolean reverse)
Method to find the next occurrence of a string.

Specified by:
findNextText in interface WindowContent
Parameters:
reverse - true to find in the reverse direction.
Returns:
true if something was found.

replaceText

public void replaceText(java.lang.String replace)
Method to replace the text that was just selected with findNextText().

Specified by:
replaceText in interface WindowContent
Parameters:
replace - the new text to replace.

replaceAllText

public void replaceAllText(java.lang.String replace)
Method to replace all selected text.

Specified by:
replaceAllText in interface WindowContent
Parameters:
replace - the new text to replace everywhere.

writeImage

public void writeImage(ElectricPrinter ep,
                       java.lang.String filePath)
Method to export directly PNG file

Specified by:
writeImage in interface WindowContent
Parameters:
ep - printable object.
filePath -

initializePrinting

public boolean initializePrinting(ElectricPrinter ep,
                                  java.awt.print.PageFormat pageFormat)
Method to intialize for printing.

Specified by:
initializePrinting in interface WindowContent
Parameters:
ep - the ElectricPrinter object.
pageFormat - information about the print job.
Returns:
Always true.

getPrintImage

public java.awt.image.BufferedImage getPrintImage(ElectricPrinter ep)
Method to print window using offscreen canvas.

Specified by:
getPrintImage in interface WindowContent
Parameters:
ep - printable object.
Returns:
the image to print (null on error).

panXOrY

public void panXOrY(int direction,
                    double[] panningAmounts,
                    int ticks)
Method to pan along X or Y according to fixed amount of ticks

Specified by:
panXOrY in interface WindowContent
Parameters:
direction -
panningAmounts -
ticks -

centerCursor

public void centerCursor()
Method to shift the window so that the current cursor location becomes the center.

Specified by:
centerCursor in interface WindowContent