|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
cz.psika.numerist.DiagramCanvas
public class DiagramCanvas
Diagram drawing component.
Diagram is created in connection with the Entry
object.
It is observable as every object implementing Item
interface.
Implicit constructor is used to create empty diagrams.
Drawing diagrams here is quite fast and should be usable
on very slow machines (<200 MHz) too. Nevertheless many graphic optimizations
could be done. Drawing diagrams for entries with quite large source strings
could evoke disappearing of diagram(s) inside small window.
Please resize window in this case, diagram should show up.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
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 | |
---|---|
protected int |
activeRectangle
Rectangle over which mouse pointer is situated. |
protected static double |
ARROW_TRIANGLE_ANGLE
Default arrow angle. |
protected java.awt.geom.GeneralPath |
arrowhead
Path for drawing arrowheads. |
protected java.awt.BasicStroke |
arrowLineStroke
Line strokes. |
protected static java.awt.Color |
BACKGROUND_COLOR
|
protected static java.awt.Color |
BORDER_COLOR
|
protected static java.awt.Color |
CIRCLE_COLOR
|
protected static java.awt.Color[] |
circleColors
Blue circle colors, outer circles are going to be brighter. |
protected java.awt.BasicStroke |
circleLineStroke
Line strokes. |
protected java.awt.geom.Rectangle2D[] |
circleRects
Dynamic rectangles which bound circles. |
protected static int |
colLines
|
protected java.awt.Dimension |
currentSize
Current dimension. |
static java.awt.Dimension |
DEFAULT_DIMENSION
Default dimension of canvas. |
protected java.awt.BasicStroke |
diagonalLineStroke
Line strokes. |
protected java.awt.Image |
dImage
Caching image. |
protected boolean |
empty
Empty diagram flag. |
protected Entry |
entry
Source entry. |
protected static java.awt.Color |
HIGHLIGHT_GRID_CELL_COLOR
|
protected static java.awt.Color |
HIGHLIGHT_LINE_COLOR
|
protected static int |
innerDiagonalLines
|
protected static java.awt.Color |
INVISIBLE_COLOR
|
protected boolean |
isThumbnail
Flag to distinguish thumbnail and full diagram. |
protected static int |
MAX_NUMBER_OF_CIRCLE_COLORS
|
static int |
NO_RECTANGLE_ACTIVE
Mouse pointer is not over some rectangle. |
protected static boolean |
NO_TOGGLE_BORDER
Suppress border toggle. |
protected java.awt.Color[] |
numberColors
Colors for numbers loaded from style or default colors. |
protected java.util.Set<ItemObserver> |
observers
Diagram observers. |
protected static int |
outerDiagonalLine
|
protected boolean |
paintError
Painting error. |
protected static java.awt.Color |
PLACE_BACKGROUND_COLOR
|
protected java.awt.geom.Rectangle2D[] |
rects
Rectangle parts of diagram. |
protected static int |
rowLines
|
protected Style |
style
Cache for current entry's style. |
protected java.awt.geom.Line2D |
tmpLine
Reusable graphic line. |
protected static boolean |
TOGGLE_BORDER
Change of border required. |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
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 | |
---|---|
protected |
DiagramCanvas()
Implicit constructor used by child class to create empty diagrams. |
|
DiagramCanvas(Entry entry,
java.awt.Dimension size,
boolean setThumbnail)
Constructor of diagram. |
Method Summary | |
---|---|
void |
addObserver(ItemObserver observer)
Observing diagrams not used for now. |
java.lang.Object |
clone()
Cloning the diagram. |
Memento |
createMemento()
Create history object. |
void |
deleteObserver(ItemObserver observer)
Observing diagrams not used for now. |
protected void |
drawArrows(java.awt.Graphics2D g)
Painting arrows. |
protected void |
drawArrowsIf(java.awt.Graphics2D g,
int pos1,
int pos2,
int angle)
Drawing lines with arrow(s). |
protected void |
drawCircles(java.awt.Graphics2D g)
Drawing circles. |
protected void |
drawGrid(java.awt.Graphics2D g)
Draws grid lines. |
protected void |
drawNumbers(java.awt.Graphics2D g)
Draw all numbers/digits. |
boolean |
equals(java.lang.Object other)
Diagrams are equal when their Entry instances are the same
or their unique identifiers are the same. |
Entry |
fetchEntry()
Fetch entry of this diagram. |
void |
forceRepaint()
Force repainting of component by deleting offscreen image buffer. |
Entry |
getEntry()
Get diagram entry. |
protected void |
initRects()
Initialize all rectangles used for rendering numbers, circles and arrowheads. |
boolean |
isCopy()
Some diagram could be made as copy of the other one. |
boolean |
isEmpty()
Find whether this diagram is the empty diagram. |
boolean |
isThumbnail()
Check type of diagram. |
void |
notifyObservers(Constants.ItemEvents event)
Observing diagrams not used for now. |
void |
paintComponent(java.awt.Graphics g)
Painting diagram. |
void |
refresh()
Refresh diagram, hide some dynamic effects temporarily. |
void |
setBorder(boolean toggle)
Set border for component or toggle border type. |
void |
setEntry(Entry newEntry)
Set entry. |
void |
setMemento(Memento memento)
Set state of this object to previously saved status. |
void |
setNewSize(java.awt.Dimension newSize)
Resizing of diagram. |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printComponent, printChildren, 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, updateUI |
Methods inherited from class java.awt.Container |
---|
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, setLayout, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, 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, hide, checkImage, checkImage, 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, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.awt.Dimension currentSize
protected Entry entry
protected Style style
protected static final double ARROW_TRIANGLE_ANGLE
protected static final java.awt.Color BACKGROUND_COLOR
protected static final java.awt.Color CIRCLE_COLOR
protected static final java.awt.Color PLACE_BACKGROUND_COLOR
protected static final int MAX_NUMBER_OF_CIRCLE_COLORS
protected static final java.awt.Color BORDER_COLOR
protected static final java.awt.Color HIGHLIGHT_GRID_CELL_COLOR
protected static final java.awt.Color HIGHLIGHT_LINE_COLOR
protected static final java.awt.Color INVISIBLE_COLOR
public static final java.awt.Dimension DEFAULT_DIMENSION
protected static final int rowLines
protected static final int colLines
protected static final int innerDiagonalLines
protected static final int outerDiagonalLine
protected java.awt.Color[] numberColors
protected static final java.awt.Color[] circleColors
protected java.awt.BasicStroke circleLineStroke
protected java.awt.BasicStroke arrowLineStroke
protected java.awt.BasicStroke diagonalLineStroke
protected java.awt.geom.Rectangle2D[] rects
protected java.awt.geom.Rectangle2D[] circleRects
protected java.awt.geom.GeneralPath arrowhead
protected java.awt.geom.Line2D tmpLine
protected java.awt.Image dImage
protected boolean paintError
protected final boolean isThumbnail
protected static final boolean TOGGLE_BORDER
protected static final boolean NO_TOGGLE_BORDER
protected java.util.Set<ItemObserver> observers
public static final int NO_RECTANGLE_ACTIVE
protected int activeRectangle
protected final boolean empty
Constructor Detail |
---|
protected DiagramCanvas()
public DiagramCanvas(Entry entry, java.awt.Dimension size, boolean setThumbnail)
entry
- source entrysize
- specified dimension of requested diagramsetThumbnail
- thumbnail of full diagram behaviourMethod Detail |
---|
public void setEntry(Entry newEntry)
newEntry
- entry to set
java.lang.IllegalArgumentException
- when called for empty diagramspublic Entry getEntry()
public void setNewSize(java.awt.Dimension newSize)
newSize
- new diagram dimensionpublic boolean isCopy()
true
if this diagram is copy of another oneEntry.isCopy()
public void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
g
- Graphics
objectpublic void forceRepaint()
protected void drawGrid(java.awt.Graphics2D g)
g
- Graphics2D
objectprotected void drawNumbers(java.awt.Graphics2D g)
g
- Graphics2D
objectprotected void drawCircles(java.awt.Graphics2D g)
g
- Graphics2D
object
java.lang.IllegalStateException
- if entry not validprotected void drawArrows(java.awt.Graphics2D g)
g
- graphic contextdrawArrowsIf(java.awt.Graphics2D, int, int, int)
protected void drawArrowsIf(java.awt.Graphics2D g, int pos1, int pos2, int angle)
drawArrows()
method should be rewritten
to be more readable and maybe a bit quicker. There are some things
which should be removed and made more clear. But I dont have
much motivation to do it, because it runs quite fast for now.
g
- graphic contextpos1
- position of first rectanglepos2
- position of second rectangleangle
- angle of arrowhead and line from first rectangle's point of viewpublic void setBorder(boolean toggle)
toggle
- change border stylepublic void refresh()
public boolean isEmpty()
EmptyDiagramCanvas
instance must return true
herepublic boolean isThumbnail()
true
when this diagram is thumbnailpublic Entry fetchEntry()
fetchEntry
in interface Item
public Memento createMemento()
createMemento
in interface History
DiagramCanvasMemento
object representing history status of this instanceDiagramCanvasMemento.DiagramCanvasMemento(Entry entry)
public void setMemento(Memento memento)
setMemento
in interface History
memento
- DiagramCanvasMemento
object representing history status of this instanceDiagramCanvasMemento.fetchEntry()
public boolean equals(java.lang.Object other)
Entry
instances are the same
or their unique identifiers are the same.
equals
in class java.lang.Object
other
- other DiagramCanvas
instance
true
if diagrams are the samepublic java.lang.Object clone()
clone
in class java.lang.Object
DiagramCanvas
instanceprotected void initRects()
paintComponent
repeatedly.
public void addObserver(ItemObserver observer)
addObserver
in interface ItemObservable
observer
- an observer to attachpublic void deleteObserver(ItemObserver observer)
deleteObserver
in interface ItemObservable
observer
- to removepublic void notifyObservers(Constants.ItemEvents event)
notifyObservers
in interface ItemObservable
event
- type of event to notify all registered observers
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |