|
miSim | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Panel | +--misim.editor.TextPanel
The text panel implements an uneditable display of text from a file. It uses a parser to break each line into tokens which are drawn in appropriate styles.
Inner classes inherited from class java.awt.Panel |
java.awt.Panel.AccessibleAWTPanel |
Inner classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
Inner classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent |
Field Summary | |
protected LogListener |
logging
The log listener for informing the user of events |
Fields inherited from class java.awt.Component |
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 | |
TextPanel(TextFile file,
EditorPrefs prefs,
LogListener logging)
Note that the creator must not use the loglistener to notify error events, as this text panel may be the view onto the log itself. |
Method Summary | |
void |
addItemListener(java.awt.event.ItemListener itemListener)
Add an item listener to this panel, which will receive select events if the selectLine flag is set and a new line is selected |
void |
adjustmentValueChanged(java.awt.event.AdjustmentEvent aev)
Respond to any scrollbar adjustment events. |
void |
append(java.lang.String text)
Append text to the file |
boolean |
checkBoundaries(CursorPos newCursor)
Make sure that the given cursor position is onscreen. |
void |
copySelection()
Copy the currently selected text to the clipboard. |
void |
drawCursor(boolean show)
Draw the cursor, or remove it as appropriate. |
void |
drawLine(int lineNum,
java.awt.Graphics gr)
Draw the givwen line number onscreen in the appropriate position. |
void |
focusGained(java.awt.event.FocusEvent evt)
|
void |
focusLost(java.awt.event.FocusEvent evt)
|
TextFile |
getFile()
Return the file that this text panel refers to. |
java.lang.String |
getPanelName()
Return the panelname |
int |
getSelectedLine()
Return the currently selected line. |
java.lang.Object[] |
getSelectedObjects()
Return the currently selected line, if selectLine is true and a line is selected |
java.lang.String |
getTitle()
Return the title for this editor panel |
void |
gotoFirstError(boolean getFocus)
Goto the first error in the file. |
void |
gotoLine(int lineNumber,
boolean highlight)
Move the cursor to the given line and display it. |
boolean |
hasSelection()
Check to see if there is currently a selection that may be copied to the clipboard. |
void |
keyPressed(java.awt.event.KeyEvent ke)
|
void |
keyReleased(java.awt.event.KeyEvent ke)
|
void |
keyTyped(java.awt.event.KeyEvent ke)
|
void |
mouseClicked(java.awt.event.MouseEvent e)
|
void |
mouseDragged(java.awt.event.MouseEvent e)
Respond to a mouse dragged event. |
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)
Respond to a mouse click. |
void |
mouseReleased(java.awt.event.MouseEvent e)
|
void |
moveCursor(CursorPos newCursor,
boolean isShifted,
boolean redraw)
Process a new position for the cursor. |
void |
paint(java.awt.Graphics g)
|
protected void |
processControlKey(java.awt.event.KeyEvent ke)
Handle a control key press - specifically, the copy event. |
protected boolean |
processKey(int keyCode,
java.awt.event.KeyEvent ke,
CursorPos newCursor,
boolean redraw)
|
void |
redrawText(java.awt.Graphics g)
|
void |
refresh()
Redraw the text panel |
void |
removeItemListener(java.awt.event.ItemListener itemListener)
Remove an item listener from this panel. |
void |
requestFocus()
When the panel requests focus, pass it onto the canvas |
void |
run()
========================================================================= Thread handler for displaying cursor |
void |
selectLine(boolean selectLine)
Set whether the current cursor position selects the entire line (and extended selections are therefore not supported), or not. |
void |
setCursor(boolean enabled)
Set the cursor to be hidden or displayed |
void |
setTitle(java.lang.String title)
Set the title for this editor panel |
void |
showErrors(boolean showErrors)
Set whether errors should be shown or not |
void |
updateScrollbars()
Update the scrollbars to reflect the current file size and the position of the view on that file. |
Methods inherited from class java.awt.Panel |
addNotify, getAccessibleContext |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected LogListener logging
Constructor Detail |
public TextPanel(TextFile file, EditorPrefs prefs, LogListener logging) throws java.io.IOException
Method Detail |
public java.lang.String getPanelName()
public java.lang.String getTitle()
public void setTitle(java.lang.String title)
title
- The new title for this editor panelpublic void addItemListener(java.awt.event.ItemListener itemListener)
addItemListener
in interface java.awt.ItemSelectable
itemListener
- The ItemListener to addpublic void removeItemListener(java.awt.event.ItemListener itemListener)
removeItemListener
in interface java.awt.ItemSelectable
itemListener
- The ItemListener to removepublic java.lang.Object[] getSelectedObjects()
getSelectedObjects
in interface java.awt.ItemSelectable
public void setCursor(boolean enabled)
enabled
- If true, the cursor is displayedpublic void showErrors(boolean showErrors)
showErrors
- If true, errors are indicatedpublic void selectLine(boolean selectLine)
selectLine
- If true, select the entire linepublic TextFile getFile()
public void refresh()
public boolean hasSelection()
public void append(java.lang.String text)
text
- The String to append to the end of this filepublic void gotoLine(int lineNumber, boolean highlight)
lineNumber
- The line to displayhighlight
- If true, highlight the linepublic void gotoFirstError(boolean getFocus)
public int getSelectedLine()
public void paint(java.awt.Graphics g)
paint
in class java.awt.Container
public void redrawText(java.awt.Graphics g)
public void drawLine(int lineNum, java.awt.Graphics gr)
lineNum
- The line number to be drawnpublic void drawCursor(boolean show)
show
- If true, draw the cursor, else remove itpublic boolean checkBoundaries(CursorPos newCursor)
newCursor
- The cursor position to checkpublic void updateScrollbars()
public void adjustmentValueChanged(java.awt.event.AdjustmentEvent aev)
adjustmentValueChanged
in interface java.awt.event.AdjustmentListener
aev
- The Adjustment Event that occurred.public void requestFocus()
requestFocus
in class java.awt.Component
public void focusGained(java.awt.event.FocusEvent evt)
focusGained
in interface java.awt.event.FocusListener
public void focusLost(java.awt.event.FocusEvent evt)
focusLost
in interface java.awt.event.FocusListener
public void keyPressed(java.awt.event.KeyEvent ke)
keyPressed
in interface java.awt.event.KeyListener
public void keyReleased(java.awt.event.KeyEvent ke)
keyReleased
in interface java.awt.event.KeyListener
public void keyTyped(java.awt.event.KeyEvent ke)
keyTyped
in interface java.awt.event.KeyListener
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
e
- The mouse event to respond topublic void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
e
- The MouseEvent that we must respond topublic void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public void copySelection()
protected boolean processKey(int keyCode, java.awt.event.KeyEvent ke, CursorPos newCursor, boolean redraw)
protected void processControlKey(java.awt.event.KeyEvent ke)
aChar
- - the character that has been pressedpublic void moveCursor(CursorPos newCursor, boolean isShifted, boolean redraw)
newRow
- The new row for the cursornewCol
- The new column for the cursorisShifted
- If this is a 'shifted' movement - ie. it extends the current selectionredraw
- If true, always redraw the entire panel, otherwise on draw the necessary areaspublic void run()
run
in interface java.lang.Runnable
|
miSim | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |