Module ij
Package ij.text

Class TextPanel

java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Panel
ij.text.TextPanel
All Implemented Interfaces:
java.awt.datatransfer.ClipboardOwner, java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, java.util.EventListener, javax.accessibility.Accessible

public class TextPanel
extends java.awt.Panel
implements java.awt.event.AdjustmentListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.KeyListener, java.awt.datatransfer.ClipboardOwner, java.awt.event.ActionListener, java.awt.event.MouseWheelListener, java.lang.Runnable
This is an unlimited size text panel with tab-delimited, labeled and resizable columns. It is based on the hGrid class at http://www.lynx.ch/contacts/~/thomasm/Grid/index.html.
See Also:
Serialized Form
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.awt.Panel

    java.awt.Panel.AccessibleAWTPanel

    Nested classes/interfaces inherited from class java.awt.Container

    java.awt.Container.AccessibleAWTContainer

    Nested classes/interfaces inherited from class java.awt.Component

    java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
  • Field Summary

    Fields inherited from class java.awt.Component

    accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT

    Fields inherited from interface java.awt.image.ImageObserver

    ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
  • Constructor Summary

    Constructors 
    Constructor Description
    TextPanel()
    Constructs a new TextPanel.
    TextPanel​(java.lang.String title)
    Constructs a new TextPanel.
  • Method Summary

    Modifier and Type Method Description
    void actionPerformed​(java.awt.event.ActionEvent e)  
    void addKeyListener​(java.awt.event.KeyListener listener)
    Unused keyPressed and keyTyped events will be passed to 'listener'.
    void addMouseListener​(java.awt.event.MouseListener listener)  
    void adjustmentValueChanged​(java.awt.event.AdjustmentEvent e)  
    void append​(java.lang.String text)
    Adds one or more lines to the end of this TextPanel.
    void append​(java.util.ArrayList list)
    Adds strings contained in an ArrayList to the end of this TextPanel.
    void appendLine​(java.lang.String text)
    Adds a single line to the end of this TextPanel.
    void appendWithoutUpdate​(java.lang.String data)
    Adds a single line to the end of this TextPanel without updating the display.
    void clear()
    Deletes all the lines.
    void clearSelection()
    Deletes the selected lines.
    int copySelection()
    Copies the current selection to the system clipboard.
    void doClear()
    Implements the Clear command.
    java.lang.String getColumnHeadings()
    Returns the column headings as a tab-delimited string.
    java.lang.String getLine​(int index)
    Returns the specified line as a string.
    int getLineCount()
    Returns the number of lines of text in this TextPanel.
    ResultsTable getOrCreateResultsTable()
    Returns the ResultsTable associated with this TextPanel, or attempts to create one and returns the created table.
    ResultsTable getResultsTable()
    Returns the ResultsTable associated with this TextPanel, or null.
    int getSelectionEnd()
    Returns the index of the last selected line, or -1 if there is no slection.
    int getSelectionStart()
    Returns the index of the first selected line, or -1 if there is no slection.
    java.lang.String getText()
    Returns all the text as a string.
    void keyPressed​(java.awt.event.KeyEvent e)  
    void keyReleased​(java.awt.event.KeyEvent e)  
    void keyTyped​(java.awt.event.KeyEvent e)  
    void lostOwnership​(java.awt.datatransfer.Clipboard clip, java.awt.datatransfer.Transferable cont)  
    void mouseClicked​(java.awt.event.MouseEvent e)  
    void mouseDragged​(java.awt.event.MouseEvent e)  
    void mouseEntered​(java.awt.event.MouseEvent e)  
    void mouseExited​(java.awt.event.MouseEvent e)  
    void mouseMoved​(java.awt.event.MouseEvent e)  
    void mousePressed​(java.awt.event.MouseEvent e)  
    void mouseReleased​(java.awt.event.MouseEvent e)  
    void mouseWheelMoved​(java.awt.event.MouseWheelEvent event)  
    void resetSelection()
    Clears the selection, if any.
    int rowIndex​(int y)
    Converts a y coordinate in pixels into a row index.
    void run()
    For better performance, open double-clicked files on separate thread instead of on event dispatch thread.
    void save​(java.io.PrintWriter pw)
    Writes all the text in this TextPanel to a file.
    boolean saveAs​(java.lang.String path)
    Saves the text in this TextPanel to a file.
    void scrollToTop()  
    void selectAll()
    Selects all the lines in this TextPanel.
    void setColumnHeadings​(java.lang.String labels)
    Clears this TextPanel and sets the column headings to those in the tab-delimited 'headings' String.
    void setFont​(java.awt.Font font, boolean antialiased)  
    void setLine​(int index, java.lang.String s)
    Replaces the contents of the specified line, where 'index' must be greater than or equal to zero and less than the value returned by getLineCount().
    void setResultsTable​(ResultsTable rt)
    Sets the ResultsTable associated with this TextPanel.
    void setSelection​(int startLine, int endLine)
    Creates a selection and insures that it is visible.
    void setTitle​(java.lang.String title)  
    void updateColumnHeadings​(java.lang.String labels)  
    void updateDisplay()  

    Methods inherited from class java.awt.Panel

    addNotify, getAccessibleContext

    Methods inherited from class java.awt.Container

    add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, isValidateRoot, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTree

    Methods inherited from class java.awt.Component

    action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • TextPanel

      public TextPanel()
      Constructs a new TextPanel.
    • TextPanel

      public TextPanel​(java.lang.String title)
      Constructs a new TextPanel.
  • Method Details

    • setColumnHeadings

      public void setColumnHeadings​(java.lang.String labels)
      Clears this TextPanel and sets the column headings to those in the tab-delimited 'headings' String. Set 'headings' to "" to use a single column with no headings.
    • getColumnHeadings

      public java.lang.String getColumnHeadings()
      Returns the column headings as a tab-delimited string.
    • updateColumnHeadings

      public void updateColumnHeadings​(java.lang.String labels)
    • setFont

      public void setFont​(java.awt.Font font, boolean antialiased)
    • appendLine

      public void appendLine​(java.lang.String text)
      Adds a single line to the end of this TextPanel.
    • append

      public void append​(java.lang.String text)
      Adds one or more lines to the end of this TextPanel.
    • append

      public void append​(java.util.ArrayList list)
      Adds strings contained in an ArrayList to the end of this TextPanel.
    • appendWithoutUpdate

      public void appendWithoutUpdate​(java.lang.String data)
      Adds a single line to the end of this TextPanel without updating the display.
    • updateDisplay

      public void updateDisplay()
    • adjustmentValueChanged

      public void adjustmentValueChanged​(java.awt.event.AdjustmentEvent e)
      Specified by:
      adjustmentValueChanged in interface java.awt.event.AdjustmentListener
    • mousePressed

      public void mousePressed​(java.awt.event.MouseEvent e)
      Specified by:
      mousePressed in interface java.awt.event.MouseListener
    • run

      public void run()
      For better performance, open double-clicked files on separate thread instead of on event dispatch thread.
      Specified by:
      run in interface java.lang.Runnable
    • mouseExited

      public void mouseExited​(java.awt.event.MouseEvent e)
      Specified by:
      mouseExited in interface java.awt.event.MouseListener
    • mouseMoved

      public void mouseMoved​(java.awt.event.MouseEvent e)
      Specified by:
      mouseMoved in interface java.awt.event.MouseMotionListener
    • mouseDragged

      public void mouseDragged​(java.awt.event.MouseEvent e)
      Specified by:
      mouseDragged in interface java.awt.event.MouseMotionListener
    • mouseReleased

      public void mouseReleased​(java.awt.event.MouseEvent e)
      Specified by:
      mouseReleased in interface java.awt.event.MouseListener
    • mouseClicked

      public void mouseClicked​(java.awt.event.MouseEvent e)
      Specified by:
      mouseClicked in interface java.awt.event.MouseListener
    • mouseEntered

      public void mouseEntered​(java.awt.event.MouseEvent e)
      Specified by:
      mouseEntered in interface java.awt.event.MouseListener
    • mouseWheelMoved

      public void mouseWheelMoved​(java.awt.event.MouseWheelEvent event)
      Specified by:
      mouseWheelMoved in interface java.awt.event.MouseWheelListener
    • addKeyListener

      public void addKeyListener​(java.awt.event.KeyListener listener)
      Unused keyPressed and keyTyped events will be passed to 'listener'.
      Overrides:
      addKeyListener in class java.awt.Component
    • addMouseListener

      public void addMouseListener​(java.awt.event.MouseListener listener)
      Overrides:
      addMouseListener in class java.awt.Component
    • keyPressed

      public void keyPressed​(java.awt.event.KeyEvent e)
      Specified by:
      keyPressed in interface java.awt.event.KeyListener
    • keyReleased

      public void keyReleased​(java.awt.event.KeyEvent e)
      Specified by:
      keyReleased in interface java.awt.event.KeyListener
    • keyTyped

      public void keyTyped​(java.awt.event.KeyEvent e)
      Specified by:
      keyTyped in interface java.awt.event.KeyListener
    • actionPerformed

      public void actionPerformed​(java.awt.event.ActionEvent e)
      Specified by:
      actionPerformed in interface java.awt.event.ActionListener
    • lostOwnership

      public void lostOwnership​(java.awt.datatransfer.Clipboard clip, java.awt.datatransfer.Transferable cont)
      Specified by:
      lostOwnership in interface java.awt.datatransfer.ClipboardOwner
    • rowIndex

      public int rowIndex​(int y)
      Converts a y coordinate in pixels into a row index.
    • copySelection

      public int copySelection()
      Copies the current selection to the system clipboard. Returns the number of characters copied.
    • doClear

      public void doClear()
      Implements the Clear command.
    • clearSelection

      public void clearSelection()
      Deletes the selected lines.
    • clear

      public void clear()
      Deletes all the lines.
    • selectAll

      public void selectAll()
      Selects all the lines in this TextPanel.
    • resetSelection

      public void resetSelection()
      Clears the selection, if any.
    • setSelection

      public void setSelection​(int startLine, int endLine)
      Creates a selection and insures that it is visible.
    • save

      public void save​(java.io.PrintWriter pw)
      Writes all the text in this TextPanel to a file.
    • saveAs

      public boolean saveAs​(java.lang.String path)
      Saves the text in this TextPanel to a file. Set 'path' to "" to display a "save as" dialog. Returns 'false' if the user cancels the dialog.
    • getText

      public java.lang.String getText()
      Returns all the text as a string.
    • setTitle

      public void setTitle​(java.lang.String title)
    • getLineCount

      public int getLineCount()
      Returns the number of lines of text in this TextPanel.
    • getLine

      public java.lang.String getLine​(int index)
      Returns the specified line as a string. The argument must be greater than or equal to zero and less than the value returned by getLineCount().
    • setLine

      public void setLine​(int index, java.lang.String s)
      Replaces the contents of the specified line, where 'index' must be greater than or equal to zero and less than the value returned by getLineCount().
    • getSelectionStart

      public int getSelectionStart()
      Returns the index of the first selected line, or -1 if there is no slection.
    • getSelectionEnd

      public int getSelectionEnd()
      Returns the index of the last selected line, or -1 if there is no slection.
    • setResultsTable

      public void setResultsTable​(ResultsTable rt)
      Sets the ResultsTable associated with this TextPanel.
    • getResultsTable

      public ResultsTable getResultsTable()
      Returns the ResultsTable associated with this TextPanel, or null.
    • getOrCreateResultsTable

      public ResultsTable getOrCreateResultsTable()
      Returns the ResultsTable associated with this TextPanel, or attempts to create one and returns the created table.
    • scrollToTop

      public void scrollToTop()