http://www.jpicedt.org

jpicedt.ui
Class PEDrawingBoard

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by jpicedt.ui.PEDrawingBoard
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class PEDrawingBoard
extends JPanel

A drawing board based on jpicedt.graphic.PECanvas, with an embeded scrollpane, and some I/O facilities (saving and loading) which PECanvas doesn't have.
There are two accessors two retrieve the embedded canvas and scrollpane.

Since:
jPicEdt
Author:
Sylvain Reynal
See Also:
Serialized Form

Nested Class Summary
 class PEDrawingBoard.GridZoomToolBar
          A toolbar that allows the user to change the grid and zoom properties
 class PEDrawingBoard.StatusBar
          jpicedt's Status Bar
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
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
PEDrawingBoard(int untitledIndex, double zoom, PageFormat pageFormat, Grid grid, ContentType contentType)
          Create a new empty drawing board with a (localized) "untitled" title
author: Sylvain Reynal
PEDrawingBoard(int untitledIndex, Properties preferences)
          Create a new empty drawing board with a (localized) "untitled" title Init zoom, pageFormat, contentType and undoableLimit from the given Properties, using: key = PECanvas.KEY_ZOOM, value = a double key = PageFormat.KEY_PAGE_FORMAT (see PageFormat for details) key = PECanvas.KEY_CONTENT_TYPE, value = path of ContentType class (e.g.
PEDrawingBoard(String path, double zoom, PageFormat pageFormat, Grid grid, ContentType contentType, ExtractionParsing parser)
          Create a new drawing board pre-loaded from the given path ; set title from this path.
PEDrawingBoard(String path, Properties preferences, ExtractionParsing parser)
          Create a new drawing board pre-loaded from the given path ; set title from this path.
 
Method Summary
 PECanvas getCanvas()
          
author: Sylvain Reynal
 PopupMenuFactory getPopupMenuFactory()
           
 PEScrollPane getScrollPane()
          
author: Sylvain Reynal
 PEDrawingBoard.StatusBar getStatusBar()
          Return the status bar
 String getTitle()
          
author: Sylvain Reynal
 void insert(String path, ExtractionParsing parser, PicPoint insertionPoint)
          Insert new content from the given path into this board's drawing
author: Sylvain Reynal
 boolean isDirty()
          
author: Sylvain Reynal
 boolean isSaved()
          
author: Sylvain Reynal
 void load(String path, ExtractionParsing parser)
          Load this board's content from the given path
author: Sylvain Reynal
 void reload(ExtractionParsing parser)
          Reload the content of this board from its current file name if applicable ; do nothing otherwise.
 boolean save(boolean alwaysPrompt)
          Save drawing content to disk.
 void save(String fileName, boolean selectionOnly)
          Save drawing or selection content the given file.
 boolean saveFragment()
          Save the selection content to the "fragment directory" on disk, prompting user for a file name
 void setDirty(boolean dirty)
          Mark this board as being dirty.
 void setPopupMenuFactory(PopupMenuFactory factory)
          Set the PopupMenuFactory that produces JPopupMenu when a popup-trigger mouse event occurs on the board.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, 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
 
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, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
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, hide, 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, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PEDrawingBoard

public PEDrawingBoard(int untitledIndex,
                      double zoom,
                      PageFormat pageFormat,
                      Grid grid,
                      ContentType contentType)
Create a new empty drawing board with a (localized) "untitled" title
author: Sylvain Reynal

Parameters:
untitledIndex - index appended to "untitled", e.g. "Untitled 2"
Since:
jPicEdt

PEDrawingBoard

public PEDrawingBoard(String path,
                      double zoom,
                      PageFormat pageFormat,
                      Grid grid,
                      ContentType contentType,
                      ExtractionParsing parser)
Create a new drawing board pre-loaded from the given path ; set title from this path.
author: Sylvain Reynal

Since:
jPicEdt

PEDrawingBoard

public PEDrawingBoard(int untitledIndex,
                      Properties preferences)

Create a new empty drawing board with a (localized) "untitled" title Init zoom, pageFormat, contentType and undoableLimit from the given Properties, using:


author: Sylvain Reynal

Parameters:
untitledIndex - index appended to "untitled", e.g. "Untitled 2"
Since:
jPicEdt

PEDrawingBoard

public PEDrawingBoard(String path,
                      Properties preferences,
                      ExtractionParsing parser)
Create a new drawing board pre-loaded from the given path ; set title from this path. Init zoom, pageFormat and contentType from the given Properties, using:
  1. key = PECanvas.KEY_ZOOM, value = a double
  2. key = PageFormat.KEY_PAGE_FORMAT (see jpicedt.graphic.PageFormat for details)
  3. key = PECanvas.KEY_CONTENT_TYPE, value = path of ContentType class (e.g. "jpicedt.format.latex.ContentType") suitable for instanciation by Class.forName("xxx").newInstance(). "preferences" is also used to init the ContentType, if non-null.

    1. author: Sylvain Reynal

      Since:
      jPicEdt
Method Detail

setPopupMenuFactory

public void setPopupMenuFactory(PopupMenuFactory factory)
Set the PopupMenuFactory that produces JPopupMenu when a popup-trigger mouse event occurs on the board.


getPopupMenuFactory

public PopupMenuFactory getPopupMenuFactory()
Returns:
the PopupMenuFactory that produces JPopupMenu when a popup-trigger mouse event occurs on the board.

getCanvas

public PECanvas getCanvas()

author: Sylvain Reynal


getScrollPane

public PEScrollPane getScrollPane()

author: Sylvain Reynal


isSaved

public boolean isSaved()

author: Sylvain Reynal

Returns:
Whether this board has been already saved to disk (even if it's been modified since then) This is just a convenience to know if a file path is attached to this board or not.

isDirty

public boolean isDirty()

author: Sylvain Reynal

Returns:
whether this board has been modified since the last time it was saved or created

This signal that this board need to be saved during "save", "save all",... actions.


setDirty

public void setDirty(boolean dirty)
Mark this board as being dirty.


getTitle

public String getTitle()

author: Sylvain Reynal

Returns:
This board's title, e.g. used as the title of the hosting frame.
Since:
jPicEdt

save

public boolean save(boolean alwaysPrompt)
Save drawing content to disk.

If alwaysPrompt is false, save to disk using the current title; prompt user if it's null, ie this board has never been saved.
If alwaysPrompt is true, prompt user for a file name (aka "Save as…") in any case.

Returns:
false if operation was cancelled by user or an I/O error occured

saveFragment

public boolean saveFragment()
Save the selection content to the "fragment directory" on disk, prompting user for a file name

Returns:
false if operation was cancelled by user or I/O error occured

save

public void save(String fileName,
                 boolean selectionOnly)
          throws IOException
Save drawing or selection content the given file.

Parameters:
fileName - name of file to save content to
selectionOnly - whether to save the content of the selection or that of the whole the drawing
Throws:
IOException

load

public void load(String path,
                 ExtractionParsing parser)
Load this board's content from the given path
author: Sylvain Reynal

Since:
jPicEdt

insert

public void insert(String path,
                   ExtractionParsing parser,
                   PicPoint insertionPoint)
Insert new content from the given path into this board's drawing
author: Sylvain Reynal

Since:
jPicEdt

reload

public void reload(ExtractionParsing parser)
Reload the content of this board from its current file name if applicable ; do nothing otherwise. [pending] should raise an exception in the latter case
author: Sylvain Reynal

Since:
jPicEdt

getStatusBar

public PEDrawingBoard.StatusBar getStatusBar()
Return the status bar


http://www.jpicedt.org

Submit a bug : syd@jpicedt.org