|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Panel | +--java.applet.Applet | +--javax.swing.JApplet | +--SpreadSheetApplet.SpreadSheet
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.
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 |
|
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 |
public static int defaultHeight
public static int defaultWidht
private static final java.lang.String allowedLocation
private javax.swing.JButton bBold
private javax.swing.JButton bItalic
private javax.swing.JButton bUnderline
private javax.swing.JButton bLeft
private javax.swing.JButton bCenter
private javax.swing.JButton bRight
private javax.swing.JButton bFusion
private javax.swing.JButton bUndo
private javax.swing.JButton bRedo
private javax.swing.JButton bBorder
private javax.swing.JButton bDebug
private javax.swing.JComboBox cbStyle
private javax.swing.JComboBox cbSize
private javax.swing.JComboBox cbFont
private javax.swing.JComboBox cbTextCol
private javax.swing.JComboBox cbBackCol
private SpreadSheetApplet.CellInterf[][] cellGrid
private javax.swing.JPanel cellPanel
private java.util.Vector subTableList
private java.awt.Point tlSelectedCell
private java.awt.Point brSelectedCell
private SpreadSheetApplet.Cell firstCell
private SpreadSheet.UndoHandler undoHandler
private java.lang.String[][] styles
private final java.lang.String styleDelim
private final java.lang.String valueDelim
private final java.lang.String[] styleDefaut
private java.lang.String[] tableStyle
Constructor Detail |
public SpreadSheet()
Method Detail |
public void init()
public void newSpreadSheet(int nbRows, int nbCols)
nbRows,
- nbCols : nombre de ligne, nombre de colonnesLe programme doit être correctement initialisé: la barre d'outils
et le panneau d'affichage doivent être présents
public java.lang.String exportToHTML()
Le programme doit être correctement initialisé: le panneau
d'affichage doit être présent et contenir des cellules
public void importFromHTML(java.lang.String html)
Le programme doit être correctement initialisé: le panneau
d'affichage doit être présent et contenir des cellules
ce tableau est la représentation de html, tous les éléments
sont initialisés et l'affichage est mis à jour
private void importCell(java.lang.String cellLine, int rowNbr, int colNbr, int width, int height, int deepness)
private void importSubTable(java.lang.String tableLine, int rowNbr, int colNbr, int row, int col, int width, int height, int deepness)
SpreadSheetApplet.Cell getCell(java.awt.Point p)
Point
- p: p.x > 0, p.y > 0SpreadSheetApplet.Cell getCell(int i, int j)
int
- i, int j: i > 0, j > 0void addRowHeight(int row, int size)
int
- row: row > 0 : ligne à modifierint
- size: size > 0 : la hauteur à rajouter à la lignela ligne row a une hauteur augmentée de size
private javax.swing.JToolBar createToolBar()
styles[][] doit être initialisé
tous les éléments de la barre d'outils sont créés et initialisés,
avec leur ActionListener.
private SpreadSheet.MouseAction createCellArray(int sizeX, int sizeY)
- cellGrid est rempli de nouvelles cellules de taille (1,1)
- nouveau undoHandler et subTableList
- la sélection est initialisée en (1,1)
private void updateToolBar()
- la toolbar doit exister
- firstCell doit exister
- undoHandler doit exister
cbFont, cbSize, cbBackCol et cbTextCol sont mis à jour en fonction
de firstCell
private void redrawCellPanel()
cellGrid doit être créée et remplie d'objet BorderButton ou Cell
cellPanel est recréé et l'affichage est rafraichi
private java.lang.String exportSubTable(SpreadSheetApplet.CellArray ca, int width, int height, int deepness)
CellArray
- ca : sous-tableau à exporter
int width, height : taille en pixel du cellPanelprivate java.lang.String getRGB(java.awt.Color col)
Color
- col: la couleur à convertirprivate java.lang.String getValue(java.lang.String value, java.lang.String str)
String
- value: le texte dont il faut trouver la valeurString
- str: texte dans lequel il faut chercherprivate boolean arrayContains(java.lang.Object[] arr, java.lang.Object o)
Object[]
- arr: tableau dans lequel il faut chercherObject
- o: objet à chercher dans arrprivate void setCellStyle(SpreadSheetApplet.Cell cell)
Cell
- cell: cellules à modifiercell a le même style que cbStyle
private void fusionCells(java.awt.Point tlC, java.awt.Point brC)
Point
- tlC, brC: tlC > (0,0) et brC > (0,0)toutes les cellules comprises entre tlC et brC sont remplacées
par des cellules de type TYPE_EMPTY pointant vers tlC
private boolean createSubTable(java.awt.Point tl, java.awt.Point br)
Point
- tl, br: tl > (0,0) et br > (0,0)le tableau contient un sous-tableau de tl à tc si compatibilité
private void removeSubTable(SpreadSheetApplet.CellArray ca)
CellArray
- ca: le sous-tableau à supprimerle tableau ca a été supprimé du tableur
private void setColSize(int col, int size)
int
- col: col > 0 : colonne à modifierint
- size: size > 0 : taille de la colonnela colonne col a une largeur size
private void setRowSize(int row, int size)
int
- row: row > 0 : ligne à modifierint
- size: size > 0 : taille de la lignela ligne row a une hauteur size
private void updateCellHeight()
la hauteur des cases est modifiée si nécessaire
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |