1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602
|
package grid;
import composantGraphique.JGraphFoldingManager;
import grid.classPanel;
import frameWork.MyMarqueeHandler;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.tree.DefaultMutableTreeNode;
// importations
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.JButton;
import java.util.List;
import java.io.*;
import org.jdom.*;
import org.jdom.output.*;
import java.util.Locale;
import java.lang.*;
import java.awt.*;
import java.beans.*;
import java.net.*;
import java.util.*;
import javax.swing.*;
import javax.swing.ImageIcon.*;
import javax.swing.JButton.*;
import java.io.File;
import javax.swing.JTextArea;
import javax.swing.JSplitPane;
import java.awt.Dimension;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import javax.imageio.ImageIO;
import javax.jws.soap.SOAPBinding.Style;
import javax.swing.event.UndoableEditEvent;
import javax.swing.table.DefaultTableModel;
import javax.swing.tree.DefaultMutableTreeNode;
import org.jdom.input.SAXBuilder;
import org.jgraph.JGraph;
import org.jgraph.event.GraphSelectionEvent;
import org.jgraph.event.GraphSelectionListener;
import org.jgraph.graph.AttributeMap;
import org.jgraph.graph.BasicMarqueeHandler;
import org.jgraph.graph.CellView;
import org.jgraph.graph.DefaultCellViewFactory;
import org.jgraph.graph.DefaultEdge;
import org.jgraph.graph.DefaultGraphCell;
import org.jgraph.graph.DefaultGraphModel;
import org.jgraph.graph.DefaultPort;
import org.jgraph.graph.EdgeView;
import org.jgraph.graph.GraphCell;
import org.jgraph.graph.GraphConstants;
import org.jgraph.graph.GraphUndoManager;
import org.jgraph.graph.ParentMap;
import org.jgraph.graph.PortView;
import org.jgraph.graph.VertexView;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.JApplet;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JToolBar;
import javax.swing.border.TitledBorder;
import org.jgraph.graph.GraphUndoManager;
public class monApplet extends javax.swing.JApplet implements ActionListener ,
GraphSelectionListener,KeyListener {
private JPanel panelNorth;
private JToolBar toolBar1;
private JToolBar toolBar2;
private JButton bouttonOpen =null;
private JButton bouttonSupp=null;
private JTextPane TextDecsription;
private JPanel PanelDescription;
private JPanel PanelDessin;
private JPanel PanelPrincipale;
private JButton bouttonSend=null;
private JButton bouttonXml=null;
private JToolBar toolBar11=null;
private JTextField textSearch=null;
private JButton bouttonSearch=null;
private JToolBar toolBar10=null;
private JButton bouttonend=null;
private JButton bouttonStart=null;
private JButton bouttonJoin=null;
private JButton bouttonFork=null;
private JButton bouttonDecision=null;
private JButton bouttonCircle=null;
private JButton bouttonRoundedRect=null;
private JButton bouttonRect=null;
private JButton bouttonSpline=null;
private JButton bouttonEdge=null;
private JToolBar toolBar9;
private JButton bouttonEdit=null;
private JButton bouttonToGif=null;
private JButton bouttonHelp=null;
private JToolBar toolBar8;
private JButton bouttonSelect=null;
private JToolBar toolBar7=null;
private JButton bouttonNormal=null;
private JButton bouttonUnderLine=null;
private JButton bouttonItalic=null;
private JButton bouttonBold=null;
private JButton bouttonRedo=null;
private JToolBar toolBar6;
private JButton bouttonUnGroup=null;
private JButton bouttonGoup=null;
private JButton bouttonToBack=null;
private JButton bouttonToFront=null;
private JToolBar toolBar5;
private JButton bouttonZoomOut=null;
private JButton bouttonZoomIn=null;
private JButton bouttonZoomActual=null;
private JToolBar toolBar4;
private JButton bouttonPaste=null;
private JButton bouttonCopy=null;
private JButton bouttonCut=null;
private JButton bouttonUndo=null;
private JToolBar toolBar3;
private JButton bouttonPrint=null;
private JButton bouttonSaveAll=null;
private JButton bouttonSave=null;
private JButton bouttonDiag=null;
private JButton bouttonNouv=null;
public static JFileChooser filechooser;
public static int nbreOngletOuvert =0;
public classPanel classPanel= new classPanel();
static GraphUndoManager undoManager ;
{
//Set Look & Feel
try {
javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch(Exception e) {
e.printStackTrace();
}
}
/**
* Auto-generated main method to display this
* JApplet inside a new JFrame.
*/
public static void main(String[] args) {
JFrame frame = new JFrame();
monApplet inst = new monApplet();
frame.getContentPane().add(inst);
((JComponent)frame.getContentPane()).setPreferredSize(inst.getSize());
frame.pack();
frame.setVisible(true);
}
public monApplet() {
super();
initGUI();
}
private void initGUI() {
try {
getContentPane().setLayout(null);
this.setSize(889, 406);
{
panelNorth = new JPanel();
getContentPane().add(panelNorth);
panelNorth.setBounds(7, 7, 805, 91);
panelNorth.setLayout(null);
{
toolBar1 = new JToolBar();
panelNorth.add(toolBar1);
toolBar1.setBounds(14, 7, 70, 28);
{
bouttonNouv = new JButton();
toolBar1.add(bouttonNouv);
bouttonNouv.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/newdocument.gif")));
bouttonNouv.addActionListener(this);
}
{
bouttonDiag = new JButton();
toolBar1.add(bouttonDiag);
bouttonDiag.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/newdiagram.gif")));
bouttonDiag.addActionListener(this);
}
}
{
toolBar2 = new JToolBar();
panelNorth.add(toolBar2);
toolBar2.setBounds(91, 7, 119, 28);
{
bouttonOpen = new JButton(); // to open an old diagram , it already exist
toolBar2.add(bouttonOpen);
bouttonOpen.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/open.gif")));
bouttonOpen.addActionListener(this);
}
{
bouttonSave = new JButton(); // to save my diagram
toolBar2.add(bouttonSave);
bouttonSave.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/save.gif")));
bouttonSave.addActionListener(this);
}
{
bouttonSaveAll = new JButton(); // if i am openning many onglet , i save all my diagrams in one time
toolBar2.add(bouttonSaveAll);
bouttonSaveAll.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/saveall.gif")));
bouttonSaveAll.addActionListener(this);
}
{
bouttonPrint = new JButton(); // to print my draw
toolBar2.add(bouttonPrint);
bouttonPrint.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/print.gif")));
bouttonPrint.addActionListener(this);
}
}
{
toolBar3 = new JToolBar();
panelNorth.add(toolBar3);
toolBar3.setBounds(231, 7, 147, 28);
{
bouttonUndo = new JButton(); // undo button
toolBar3.add(bouttonUndo);
bouttonUndo.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/undo.gif")));
bouttonUndo.addActionListener(this);
}
{
bouttonRedo = new JButton(); // redo button
toolBar3.add(bouttonRedo);
bouttonRedo.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/redo_1.gif")));
bouttonRedo.addActionListener(this);
}
{
bouttonCut = new JButton(); // cut
toolBar3.add(bouttonCut);
bouttonCut.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/cut.gif")));
bouttonCut.addActionListener(this);
}
{
bouttonCopy = new JButton(); // copy
toolBar3.add(bouttonCopy);
bouttonCopy.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/copy.gif")));
bouttonCopy.addActionListener(this);
}
{
bouttonPaste = new JButton(); // paste
toolBar3.add(bouttonPaste);
bouttonPaste.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/paste.gif")));
bouttonPaste.addActionListener(this);
}
}
{
toolBar4 = new JToolBar();
panelNorth.add(toolBar4);
toolBar4.setBounds(392, 7, 91, 28);
{
bouttonZoomActual = new JButton(); // zoom 1:1
toolBar4.add(bouttonZoomActual);
bouttonZoomActual.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/zoomactual.gif")));
bouttonZoomActual.addActionListener(this);
}
{
bouttonZoomIn = new JButton();
toolBar4.add(bouttonZoomIn);
bouttonZoomIn.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/zoomin.gif")));
}
{
bouttonZoomOut = new JButton();
toolBar4.add(bouttonZoomOut);
bouttonZoomOut.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/zoomout.gif")));
}
}
{
toolBar5 = new JToolBar();
panelNorth.add(toolBar5);
toolBar5.setBounds(518, 7, 105, 28);
{
bouttonToFront = new JButton();
toolBar5.add(bouttonToFront);
bouttonToFront.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/tofront.gif")));
}
{
bouttonToBack = new JButton();
toolBar5.add(bouttonToBack);
bouttonToBack.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/toback.gif")));
}
{
bouttonGoup = new JButton();
toolBar5.add(bouttonGoup);
bouttonGoup.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/group.gif")));
}
{
bouttonUnGroup = new JButton();
toolBar5.add(bouttonUnGroup);
bouttonUnGroup.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/ungroup.gif")));
}
}
{
toolBar6 = new JToolBar();
panelNorth.add(toolBar6);
toolBar6.setBounds(644, 7, 119, 28);
{
bouttonBold = new JButton();
toolBar6.add(bouttonBold);
bouttonBold.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/bold.gif")));
}
{
bouttonItalic = new JButton();
toolBar6.add(bouttonItalic);
bouttonItalic.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/italic.gif")));
}
{
bouttonUnderLine = new JButton();
toolBar6.add(bouttonUnderLine);
bouttonUnderLine.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/underline.gif")));
}
{
bouttonNormal = new JButton();
toolBar6.add(bouttonNormal);
bouttonNormal.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/plain.gif")));
}
}
{
toolBar7 = new JToolBar();
panelNorth.add(toolBar7);
toolBar7.setBounds(7, 56, 77, 28);
{
bouttonSelect = new JButton();
toolBar7.add(bouttonSelect);
bouttonSelect.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/select.gif")));
}
{
bouttonSupp = new JButton();
toolBar7.add(bouttonSupp);
bouttonSupp.setIcon(new ImageIcon(getClass().getClassLoader().getResource("Icones Stage/supp.gif")));
bouttonSupp.setPreferredSize(new java.awt.Dimension(31, 25));
}
}
{
toolBar8 = new JToolBar();
panelNorth.add(toolBar8);
toolBar8.setBounds(105, 56, 91, 28);
{
bouttonHelp = new JButton();
toolBar8.add(bouttonHelp);
bouttonHelp.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/help16.gif")));
}
{
bouttonToGif = new JButton(); // to convert my draw to a gif file ?
toolBar8.add(bouttonToGif);
bouttonToGif.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/gif.gif")));
}
{
bouttonEdit = new JButton(); // to edit the name of my shapes and give the sens example in activity
toolBar8.add(bouttonEdit);
bouttonEdit.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/edit.gif")));
bouttonEdit.addActionListener(this);
}
}
{
toolBar9 = new JToolBar();
panelNorth.add(toolBar9);
toolBar9.setBounds(203, 56, 273, 28);
{
bouttonEdge = new JButton(); // my Edge
toolBar9.add(bouttonEdge);
bouttonEdge.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/edge.gif")));
bouttonedge.addActionListener(this);
}
{
bouttonSpline = new JButton();
toolBar9.add(bouttonSpline);
bouttonSpline.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/orthogonal.gif")));
bouttonSpline.addActionListener(this);
}
{
bouttonRect = new JButton(); // activity
toolBar9.add(bouttonRect);
bouttonRect.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/rectangle.gif")));
bouttonRect.addActionListener(this);
}
{
bouttonRoundedRect = new JButton(); // activity 2
toolBar9.add(bouttonRoundedRect);
bouttonRoundedRect.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/rounded.gif")));
bouttonRoundedRect.addActionListener(this);
}
{
bouttonCircle = new JButton(); // circle
toolBar9.add(bouttonCircle);
bouttonCircle.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/circle.gif")));
bouttonCircle.addActionListener(this);
}
{
bouttonDecision = new JButton(); // decision == if (condition)
toolBar9.add(bouttonDecision);
bouttonDecision.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/decision.gif")));
bouttonDecision.addActionListener(this);
}
{
bouttonFork = new JButton(); // fork
toolBar9.add(bouttonFork);
bouttonFork.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/fork.gif")));
bouttonFork.addActionListener(this);
}
{
bouttonJoin = new JButton(); // join
toolBar9.add(bouttonJoin);
bouttonJoin.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/join.gif")));
bouttonJoin.addActionListener(this);
}
{
bouttonStart = new JButton();
toolBar9.add(bouttonStart);
bouttonStart.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/initialstate.gif")));
bouttonStart.addActionListener(this);
}
{
bouttonend = new JButton();
toolBar9.add(bouttonend);
bouttonend.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/finalstate.gif")));
bouttonend.addActionListener(this);
}
}
{
toolBar10 = new JToolBar();
panelNorth.add(toolBar10);
toolBar10.setBounds(490, 56, 154, 28);
{
bouttonSearch = new JButton();// search
toolBar10.add(bouttonSearch);
bouttonSearch.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/search.gif")));
bouttonSearch.addActionListener(this);
}
{
textSearch = new JTextField();
toolBar10.add(textSearch);
}
}
{
toolBar11 = new JToolBar();
panelNorth.add(toolBar11);
toolBar11.setBounds(679, 56, 84, 28);
{
bouttonXml = new JButton();
toolBar11.add(bouttonXml);
bouttonXml.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/xml.gif")));
}
{
bouttonSend = new JButton();
toolBar11.add(bouttonSend);
bouttonSend.setIcon(new ImageIcon(getClass()
.getClassLoader().getResource(
"Icones Stage/connecton.gif")));
}
}
}
{
PanelPrincipale = new JPanel();
getContentPane().add(PanelPrincipale);
PanelPrincipale.setBounds(21, 105, 826, 273);
PanelPrincipale.setLayout(null);
{
PanelDessin = new JPanel();
PanelPrincipale.add(PanelDessin);
PanelDessin.setBounds(21, 21, 490, 252);
PanelDessin.setBorder(BorderFactory.createTitledBorder(null, "Panneau de dessin", TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma",0,11), new java.awt.Color(128,0,128)));
}
{
PanelDescription = new JPanel();
PanelPrincipale.add(PanelDescription);
PanelDescription.setBounds(532, 28, 308, 238);
PanelDescription.setBorder(BorderFactory.createTitledBorder(null, "Description", TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma",0,11), new java.awt.Color(128,0,128)));
PanelDescription.setLayout(null);
{
TextDecsription = new JTextPane();
PanelDescription.add(TextDecsription);
TextDecsription.setBounds(21, 28, 273, 189);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void actionPerformed(ActionEvent evt)
{
Object source = evt.getSource();
if(source == bouttonNouv)
{
toolBar1.setVisible(true);
}
if(source == bouttonStart)
{
!!!!
}
}
} |
Partager