SpreadSheetApplet
Class SpreadSheet

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--javax.swing.JApplet
                                |
                                +--SpreadSheetApplet.SpreadSheet

public class SpreadSheet
extends javax.swing.JApplet

Classe SpreadSheet, classe principale réalisant un tableur en applet Java, le tableur contient une barre d'outils et un ensemble de cellules. Ce programme permet de générer du code HTML à partir du tableau et de l'importer.

Version:
0.9 - beta
Author:
Denis Di Filippantonio for Dynasite
See Also:
Serialized Form

Inner Class Summary
private  class SpreadSheet.ArrayStateEdit
          Classe interne gérant le undo-redo de fusion de cellules, leur redimensionnement et les sous-tableaux.
private  class SpreadSheet.BorderAction
          Classe interne gérant les actions sur les boutons des marges et jouant le role de mouselistener pour le redimensionnement des colonnes et des lignes
private  class SpreadSheet.CellPanel
          Classe implementant le cellPanel, il s'agit d'un JPanel auquel on a rajouté le tracage de la zone sélectionée par l'utilisateur et le tracage de tous les sous-tableaux.
private  class SpreadSheet.ColoredCell
          Gestion de l'affichage des options dans la combobox du choix de la couleur de fond des cases.
private  class SpreadSheet.ColoredText
          Gestion de l'affichage des options dans la combobox du choix de la couleur de texte.
private  class SpreadSheet.KeyAction
          Classe interne gérant les actions sur les touches du clavier.
private  class SpreadSheet.MouseAction
          Classe interne gérant les actions de la souris sur les cellules du tableur.
private  class SpreadSheet.ToolBarAction
          Classe interne gérant les actions sur les boutons de la ToolBar.
private  class SpreadSheet.UndoHandler
          UndoManager qui permet aussi de maintenir à jour les boutons bUndo et bRedo en fonction de canUndo() et canRedo().
 
Field Summary
private static java.lang.String allowedLocation
          URL à partir de laquelle le programme peut être exécuté (URL du programme même, pas de la page HTML !
private  javax.swing.JButton bBold
           
private  javax.swing.JButton bBorder
           
private  javax.swing.JButton bCenter
           
private  javax.swing.JButton bDebug
           
private  javax.swing.JButton bFusion
           
private  javax.swing.JButton bItalic
           
private  javax.swing.JButton bLeft
           
private  javax.swing.JButton bRedo
           
private  javax.swing.JButton bRight
           
private  java.awt.Point brSelectedCell
           
private  javax.swing.JButton bUnderline
           
private  javax.swing.JButton bUndo
           
private  javax.swing.JComboBox cbBackCol
           
private  javax.swing.JComboBox cbFont
           
private  javax.swing.JComboBox cbSize
           
private  javax.swing.JComboBox cbStyle
           
private  javax.swing.JComboBox cbTextCol
           
private  SpreadSheetApplet.CellInterf[][] cellGrid
           
private  javax.swing.JPanel cellPanel
           
static int defaultHeight
          Hauteur par défaut du tableau (sans la marge)
static int defaultWidht
          Largeur par défaut du tableau (sans la marge)
private  SpreadSheetApplet.Cell firstCell
           
private  java.lang.String[] styleDefaut
           
private  java.lang.String styleDelim
           
private  java.lang.String[][] styles
          Gestion des styles passés en paramètres à l'applet.
private  java.util.Vector subTableList
           
private  java.lang.String[] tableStyle
           
private  java.awt.Point tlSelectedCell
           
private  SpreadSheet.UndoHandler undoHandler
           
private  java.lang.String valueDelim
           
 
Fields inherited from class javax.swing.JApplet
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.applet.Applet
accessibleContext, serialVersionUID, stub
 
Fields inherited from class java.awt.Panel
base, nameCounter, serialVersionUID
 
Fields inherited from class java.awt.Container
component, containerListener, containerSerializedDataVersion, dbg, descendantsCount, dispatcher, focusCycleRoot, focusTraversalPolicy, INCLUDE_SELF, layoutMgr, listeningBoundsChildren, listeningChildren, maxSize, ncomponents, printing, printingThreads, SEARCH_HEAVYWEIGHTS, serialVersionUID
 
Fields inherited from class java.awt.Component
accessibleContext, actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, bufferStrategy, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dbg, dropTarget, enabled, eventMask, FOCUS_TRAVERSABLE_DEFAULT, FOCUS_TRAVERSABLE_SET, FOCUS_TRAVERSABLE_UNKNOWN, focusable, focusListener, focusListenerK, focusTraversalKeyPropertyNames, focusTraversalKeys, focusTraversalKeysEnabled, font, foreground, graphicsConfig, height, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, ignoreRepaint, incRate, inputMethodListener, inputMethodListenerK, isFocusTraversableOverridden, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, mouseWheelListener, mouseWheelListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, privateKey, RIGHT_ALIGNMENT, serialVersionUID, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowClosingException, windowFocusListenerK, windowListenerK, windowStateListenerK, x, y
 
Constructor Summary
SpreadSheet()
           
 
Method Summary
(package private)  void addRowHeight(int row, int size)
          Modification de la hauteur d'une ligne entière du tableau.
private  boolean arrayContains(java.lang.Object[] arr, java.lang.Object o)
          Vérifie si un objet o se trouve dans un tableau d'objet arr.
private  SpreadSheet.MouseAction createCellArray(int sizeX, int sizeY)
          Création de l'ensemble des cellules et disposition dans la matrice cellGrid.
private  boolean createSubTable(java.awt.Point tl, java.awt.Point br)
          Création d'un sous-tableau allant de la position tl à la position br.
private  javax.swing.JToolBar createToolBar()
          Création de la barre d'outils.
private  java.lang.String exportSubTable(SpreadSheetApplet.CellArray ca, int width, int height, int deepness)
          Convertion du sous-tableau en format HTML (sous forme de table dans une cellule).
 java.lang.String exportToHTML()
          Convertion du tableau en format HTML (sous forme de table).
private  void fusionCells(java.awt.Point tlC, java.awt.Point brC)
          Fusion de toutes les cellules comprises entre tlC et brC, elles sont toutes (tlC comprise) remplacées par une "EmptyCell" pointant vers la position tlC.
(package private)  SpreadSheetApplet.Cell getCell(int i, int j)
          Renvoit la cellule correspondant à la (i,j).
(package private)  SpreadSheetApplet.Cell getCell(java.awt.Point p)
          Renvoit la cellule correspondant à la coordonée p.
private  java.lang.String getRGB(java.awt.Color col)
          Convertit un objet Color en code RGB à utiliser en HTML
private  java.lang.String getValue(java.lang.String value, java.lang.String str)
          Trouve la valeur de value dans le texte str, ce doit être de la forme "value=qlqc".
private  void importCell(java.lang.String cellLine, int rowNbr, int colNbr, int width, int height, int deepness)
           
 void importFromHTML(java.lang.String html)
          Importation d'un tableau à partir d'un string au format HTML (sous forme de table).
private  void importSubTable(java.lang.String tableLine, int rowNbr, int colNbr, int row, int col, int width, int height, int deepness)
           
 void init()
          Méthode d'initialisation de l'applet.
 void newSpreadSheet(int nbRows, int nbCols)
          Création d'un nouveau tableau.
private  void redrawCellPanel()
          Recréé tout le panneau d'affichage cellPanel à partir des éléments contenus dans la matrice cellGrid.
private  void removeSubTable(SpreadSheetApplet.CellArray ca)
          Suppresion du sous-tableau ca.
private  void setCellStyle(SpreadSheetApplet.Cell cell)
          Mofifie le style d'une case en fonction de la sélection du style de la Toolbar (cbStyle).
private  void setColSize(int col, int size)
          Modification de la largeur d'une colonne entière du tableau.
private  void setRowSize(int row, int size)
          Modification de la hauteur d'une ligne entière du tableau.
private  void updateCellHeight()
          Met à jour la taille des cases pour qu'on puisse voir tout le contenu de chaque case.
private  void updateToolBar()
          Mise à jour des comboBox de la ToolBar en fonction de firstCell.
 
Methods inherited from class javax.swing.JApplet
addImpl, createRootPane, createRootPaneException, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.applet.Applet
destroy, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, readObject, resize, resize, setStub, showStatus, start, stop
 
Methods inherited from class java.awt.Panel
, addNotify, constructComponentName
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, adjustDecendantsOnParent, adjustDescendants, adjustListeningChildren, applyComponentOrientation, areFocusTraversalKeysSet, checkGD, clearCurrentFocusCycleRootOnHide, clearMostRecentFocusOwnerOnHide, containsFocus, countComponents, countHierarchyMembers, createChildHierarchyEvents, createHierarchyEvents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, findComponentAt, findTraversalRoot, getAccessibleAt, getAccessibleChild, getAccessibleChildrenCount, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getContainerListeners, getDropTargetEventTarget, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMouseEventTarget, getMouseEventTarget, getMouseEventTargetImpl, getPreferredSize, initializeFocusTraversalKeys, initIDs, insets, invalidate, invalidateTree, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, lightweightPaint, lightweightPrint, list, list, locate, minimumSize, nextFocusHelper, numListening, paint, paintComponents, paintHeavyweightComponents, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, print, printComponents, printHeavyweightComponents, processContainerEvent, processEvent, proxyEnableEvents, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setZOrder, transferFocusBackward, transferFocusDownCycle, validate, validateTree, writeObject
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, adjustListeningChildrenOnParent, areInputMethodsEnabled, autoProcessMouseWheel, autoTransferFocus, bounds, checkImage, checkImage, checkWindowClosingException, coalesceEvents, contains, contains, createBufferStrategy, createBufferStrategy, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, dispatchMouseWheelToAncestor, doAutoTransfer, enable, enable, enableEvents, enableInputMethods, eventTypeEnabled, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleIndexInParent, getAccessibleStateSet, getBackground, getBounds, getBounds, getBufferStrategy, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys_NoIDCheck, getFocusTraversalKeysEnabled, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusable, isFocusOwner, isFocusTraversable, isFocusTraversableOverridden, isFontSet, isForegroundSet, isLightweight, isOpaque, isRecursivelyVisible, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusHelper, requestFocusInWindow, requestFocusInWindow, resetGC, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys_NoIDCheck, setFocusTraversalKeysEnabled, setForeground, setGCFromPeer, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle, updateCursorImmediately
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

defaultHeight

public static int defaultHeight


defaultWidht

public static int defaultWidht


allowedLocation

private static final java.lang.String allowedLocation


bBold

private javax.swing.JButton bBold


bItalic

private javax.swing.JButton bItalic


bUnderline

private javax.swing.JButton bUnderline


bLeft

private javax.swing.JButton bLeft


bCenter

private javax.swing.JButton bCenter


bRight

private javax.swing.JButton bRight


bFusion

private javax.swing.JButton bFusion


bUndo

private javax.swing.JButton bUndo


bRedo

private javax.swing.JButton bRedo


bBorder

private javax.swing.JButton bBorder


bDebug

private javax.swing.JButton bDebug


cbStyle

private javax.swing.JComboBox cbStyle


cbSize

private javax.swing.JComboBox cbSize


cbFont

private javax.swing.JComboBox cbFont


cbTextCol

private javax.swing.JComboBox cbTextCol


cbBackCol

private javax.swing.JComboBox cbBackCol


cellGrid

private SpreadSheetApplet.CellInterf[][] cellGrid


cellPanel

private javax.swing.JPanel cellPanel


subTableList

private java.util.Vector subTableList


tlSelectedCell

private java.awt.Point tlSelectedCell


brSelectedCell

private java.awt.Point brSelectedCell


firstCell

private SpreadSheetApplet.Cell firstCell


undoHandler

private SpreadSheet.UndoHandler undoHandler


styles

private java.lang.String[][] styles


styleDelim

private final java.lang.String styleDelim


valueDelim

private final java.lang.String valueDelim


styleDefaut

private final java.lang.String[] styleDefaut


tableStyle

private java.lang.String[] tableStyle

Constructor Detail

SpreadSheet

public SpreadSheet()

Method Detail

init

public void init()


newSpreadSheet

public void newSpreadSheet(int nbRows,
                           int nbCols)


exportToHTML

public java.lang.String exportToHTML()


importFromHTML

public void importFromHTML(java.lang.String html)


importCell

private void importCell(java.lang.String cellLine,
                        int rowNbr,
                        int colNbr,
                        int width,
                        int height,
                        int deepness)


importSubTable

private void importSubTable(java.lang.String tableLine,
                            int rowNbr,
                            int colNbr,
                            int row,
                            int col,
                            int width,
                            int height,
                            int deepness)


getCell

SpreadSheetApplet.Cell getCell(java.awt.Point p)


getCell

SpreadSheetApplet.Cell getCell(int i,
                               int j)


addRowHeight

void addRowHeight(int row,
                  int size)


createToolBar

private javax.swing.JToolBar createToolBar()


createCellArray

private SpreadSheet.MouseAction createCellArray(int sizeX,
                                                int sizeY)


updateToolBar

private void updateToolBar()


redrawCellPanel

private void redrawCellPanel()


exportSubTable

private java.lang.String exportSubTable(SpreadSheetApplet.CellArray ca,
                                        int width,
                                        int height,
                                        int deepness)


getRGB

private java.lang.String getRGB(java.awt.Color col)


getValue

private java.lang.String getValue(java.lang.String value,
                                  java.lang.String str)


arrayContains

private boolean arrayContains(java.lang.Object[] arr,
                              java.lang.Object o)


setCellStyle

private void setCellStyle(SpreadSheetApplet.Cell cell)


fusionCells

private void fusionCells(java.awt.Point tlC,
                         java.awt.Point brC)


createSubTable

private boolean createSubTable(java.awt.Point tl,
                               java.awt.Point br)


removeSubTable

private void removeSubTable(SpreadSheetApplet.CellArray ca)


setColSize

private void setColSize(int col,
                        int size)


setRowSize

private void setRowSize(int row,
                        int size)


updateCellHeight

private void updateCellHeight()