public class DiffView extends JScrollPane
PrintStream
for use with
ProcessUtils.exec(java.io.File, PrintStream, PrintStream, String...)
. It
can also show links that might update the view by calling an
ActionListener
. Otherwise, this class is pretty dumb.JScrollPane.AccessibleJScrollPane, JScrollPane.ScrollBar
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
protected static String |
ACTION_ATTRIBUTE |
protected int |
adds |
protected static int |
BIG_FONT_SIZE |
protected SimpleAttributeSet |
bigBold |
protected SimpleAttributeSet |
bold |
protected StyledDocument |
document |
protected static String |
FONT |
protected static int |
FONT_SIZE |
protected SimpleAttributeSet |
green |
protected Cursor |
handCursor |
protected boolean |
inHeader |
protected SimpleAttributeSet |
italic |
protected SimpleAttributeSet |
normal |
protected Cursor |
normalCursor |
protected JPanel |
panel |
protected SimpleAttributeSet |
red |
protected int |
removes |
protected JTextPane |
textPane |
columnHeader, horizontalScrollBar, horizontalScrollBarPolicy, lowerLeft, lowerRight, rowHeader, upperLeft, upperRight, verticalScrollBar, verticalScrollBarPolicy, viewport
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
COLUMN_HEADER, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_POLICY, LOWER_LEADING_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_TRAILING_CORNER, ROW_HEADER, UPPER_LEADING_CORNER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, UPPER_TRAILING_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
DiffView()
Create a colorized diff view.
|
Modifier and Type | Method and Description |
---|---|
static SimpleAttributeSet |
getActionStyle(ActionListener action)
Generate an attribute set for links.
|
int |
getAdds()
Get the number of added lines.
|
int |
getChanges()
Get the number of added or removed lines.
|
protected Document |
getDocument()
Access the underlying document.
|
PrintStream |
getPrintStream()
Construct a
PrintStream adapter to this view. |
int |
getRemoves()
Get the number of removed lines.
|
static SimpleAttributeSet |
getStyle(Color color,
boolean italic,
boolean bold,
String fontName,
int fontSize)
Create an attribute set for stylish text.
|
void |
green(int position,
String text)
Insert some green text.
|
void |
green(String text)
Add some green text.
|
void |
link(String text,
ActionListener action)
Add a link.
|
static void |
main(String[] args)
A main method for testing.
|
void |
normal(String text)
Add some plain text.
|
void |
println(String line)
Colorize one line of output.
|
void |
red(int position,
String text)
Insert some red text.
|
void |
red(String text)
Add some red text.
|
void |
styled(int position,
String text,
AttributeSet set)
Insert some stylish text.
|
void |
styled(String text,
AttributeSet set)
Add stylish text.
|
void |
warn(String warning)
Add some warnings.
|
createHorizontalScrollBar, createVerticalScrollBar, createViewport, getAccessibleContext, getColumnHeader, getCorner, getHorizontalScrollBar, getHorizontalScrollBarPolicy, getRowHeader, getUI, getUIClassID, getVerticalScrollBar, getVerticalScrollBarPolicy, getViewport, getViewportBorder, getViewportBorderBounds, isValidateRoot, isWheelScrollingEnabled, paramString, setColumnHeader, setColumnHeaderView, setComponentOrientation, setCorner, setHorizontalScrollBar, setHorizontalScrollBarPolicy, setLayout, setRowHeader, setRowHeaderView, setUI, setVerticalScrollBar, setVerticalScrollBarPolicy, setViewport, setViewportBorder, setViewportView, setWheelScrollingEnabled, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
protected static final String ACTION_ATTRIBUTE
protected static final String FONT
protected static final int FONT_SIZE
protected static final int BIG_FONT_SIZE
protected JPanel panel
protected JTextPane textPane
protected Cursor normalCursor
protected Cursor handCursor
protected SimpleAttributeSet normal
protected SimpleAttributeSet bigBold
protected SimpleAttributeSet bold
protected SimpleAttributeSet italic
protected SimpleAttributeSet red
protected SimpleAttributeSet green
protected StyledDocument document
protected int adds
protected int removes
protected boolean inHeader
public static SimpleAttributeSet getStyle(Color color, boolean italic, boolean bold, String fontName, int fontSize)
color
- the coloritalic
- whether the text should be slantedbold
- whether the text should be boldfontName
- the name of the font to usefontSize
- the font size to usepublic void styled(String text, AttributeSet set)
text
- the text to addset
- the formatting attributespublic void styled(int position, String text, AttributeSet set)
position
- the position where to insert the texttext
- the text to insertset
- the formatting attributespublic void normal(String text)
text
- the text to addpublic void warn(String warning)
warning
- the text to addpublic void red(String text)
text
- the text to addpublic void green(String text)
text
- the text to addpublic void red(int position, String text)
text
- the text to insertpublic void green(int position, String text)
text
- the text to insertpublic static SimpleAttributeSet getActionStyle(ActionListener action)
action
- the action to performpublic void link(String text, ActionListener action)
text
- the label of the linkaction
- the action to perform when the link is clickedpublic int getAdds()
public int getRemoves()
public int getChanges()
public void println(String line)
line
- the linepublic PrintStream getPrintStream()
PrintStream
adapter to this view.protected Document getDocument()
public static void main(String[] args)
args
- the command lineCopyright © 2014–2022 ImageJ. All rights reserved.