Package jpicedt.ui

Class PEDrawingBoard

  • All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

    public class PEDrawingBoard
    extends javax.swing.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

      Nested Classes 
      Modifier and Type Class Description
      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

        javax.swing.JPanel.AccessibleJPanel
      • 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

      • Fields inherited from class javax.swing.JComponent

        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

        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
      PEDrawingBoard​(int untitledIndex, double zoom, PageFormat pageFormat, Grid grid, ContentType contentType)
      create a new empty drawing board with a (localized) "untitled" title
      PEDrawingBoard​(int untitledIndex, java.util.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 jpicedt.graphic.PageFormat for details) - key = PECanvas.KEY_CONTENT_TYPE, value = path of ContentType class (e.g.
      PEDrawingBoard​(java.lang.String path, double zoom, PageFormat pageFormat, Grid grid, ContentType contentType, Parser parser)
      create a new drawing board pre-loaded from the given path ; set title from this path.
      PEDrawingBoard​(java.lang.String path, java.util.Properties preferences, Parser parser)
      create a new drawing board pre-loaded from the given path ; set title from this path.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      PECanvas getCanvas()  
      PopupMenuFactory getPopupMenuFactory()  
      PEScrollPane getScrollPane()  
      PEDrawingBoard.StatusBar getStatusBar()
      Return the status bar
      java.lang.String getTitle()  
      void insert​(java.lang.String path, Parser parser)
      Insert new content from the given path into this board's drawing
      boolean isDirty()  
      boolean isSaved()  
      void load​(java.lang.String path, Parser parser)
      Load this board's content from the given path
      void reload​(Parser 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​(java.lang.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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, 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, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, 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 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
        Parameters:
        untitledIndex - index appended to "untitled", e.g. "Untitled 2"
        Since:
        jPicEdt
      • PEDrawingBoard

        public PEDrawingBoard​(java.lang.String path,
                              double zoom,
                              PageFormat pageFormat,
                              Grid grid,
                              ContentType contentType,
                              Parser parser)
        create a new drawing board pre-loaded from the given path ; set title from this path.
        Since:
        jPicEdt
      • PEDrawingBoard

        public PEDrawingBoard​(int untitledIndex,
                              java.util.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 jpicedt.graphic.PageFormat for details) - key = PECanvas.KEY_CONTENT_TYPE, value = path of ContentType class (e.g. "jpicedt.format.latex.ContentType") - key = PECanvas.KEY_UNDOABLE_STEPS, value = nb of undoable events to remember suitable for instanciation by Class.forName("xxx").newInstance(). "preferences" is also used to init the ContentType, if non-null.
        Parameters:
        untitledIndex - index appended to "untitled", e.g. "Untitled 2"
        Since:
        jPicEdt
      • PEDrawingBoard

        public PEDrawingBoard​(java.lang.String path,
                              java.util.Properties preferences,
                              Parser 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 : - key = PECanvas.KEY_ZOOM, value = a double - key = PageFormat.KEY_PAGE_FORMAT (see jpicedt.graphic.PageFormat for details) - 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.
        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()
      • isSaved

        public boolean isSaved()
        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()
        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 java.lang.String getTitle()
        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​(java.lang.String fileName,
                         boolean selectionOnly)
                  throws java.io.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:
        java.io.IOException
      • load

        public void load​(java.lang.String path,
                         Parser parser)
        Load this board's content from the given path
        Since:
        jPicEdt
      • insert

        public void insert​(java.lang.String path,
                           Parser parser)
        Insert new content from the given path into this board's drawing
        Since:
        jPicEdt
      • reload

        public void reload​(Parser 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
        Since:
        jPicEdt