~ubuntu-branches/ubuntu/wily/weka/wily

« back to all changes in this revision

Viewing changes to src/main/java/weka/gui/treevisualizer/TreeVisualizer.java

  • Committer: Bazaar Package Importer
  • Author(s): tony mancill
  • Date: 2011-08-05 22:40:50 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20110805224050-a01vkwst9epdi4sw
Tags: 3.6.5-1
* Team upload.
* New upstream version (Closes: #632082, #598400)
* Bump Standards-Version to 3.9.2 (no changes required).
* Freshen jar.patch; remove java_cup.patch (incorporated upstream)
* Add README.source to document process of obtaining .png resources.
* Add myself to Uploaders.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
package weka.gui.treevisualizer;
24
24
 
25
25
import weka.core.Instances;
 
26
import weka.core.Utils;
26
27
import weka.gui.visualize.PrintablePanel;
27
28
import weka.gui.visualize.VisualizePanel;
 
29
import weka.gui.visualize.VisualizeUtils;
28
30
 
29
31
import java.awt.Color;
30
32
import java.awt.Container;
32
34
import java.awt.Font;
33
35
import java.awt.FontMetrics;
34
36
import java.awt.Graphics;
 
37
import java.awt.Graphics2D;
35
38
import java.awt.event.ActionEvent;
36
39
import java.awt.event.ActionListener;
37
40
import java.awt.event.ItemEvent;
42
45
import java.io.FileReader;
43
46
import java.io.IOException;
44
47
import java.io.StringReader;
 
48
import java.util.Properties;
45
49
 
46
50
import javax.swing.BorderFactory;
47
51
import javax.swing.ButtonGroup;
83
87
 * Select Auto Scale to set the tree to it's optimal display size.
84
88
 *
85
89
 * @author Malcolm Ware (mfw4@cs.waikato.ac.nz)
86
 
 * @version $Revision: 4725 $
 
90
 * @version $Revision: 7059 $
87
91
 */
88
92
public class TreeVisualizer
89
93
  extends PrintablePanel
92
96
  /** for serialization */
93
97
  private static final long serialVersionUID = -8668637962504080749L;
94
98
 
 
99
  /** the props file. */
 
100
  public final static String PROPERTIES_FILE = "weka/gui/treevisualizer/TreeVisualizer.props";
 
101
  
95
102
  /** The placement algorithm for the Node structure. */
96
103
  private NodePlace m_placer;  
97
104
 
161
168
  /** An option on the win_menu */
162
169
  private JMenuItem m_autoScale;
163
170
 
164
 
  /** A ub group on the win_menu */
 
171
  /** A sub group on the win_menu */
165
172
  private JMenu m_selectFont;
166
173
 
167
174
  /** A grouping for the font choices */
249
256
  private JDialog m_searchWin;
250
257
  private JRadioButton m_caseSen;
251
258
 
 
259
  /** the font color. */
 
260
  protected Color m_FontColor = null;
 
261
 
 
262
  /** the background color. */
 
263
  protected Color m_BackgroundColor = null;
 
264
 
 
265
  /** the node color. */
 
266
  protected Color m_NodeColor = null;
 
267
 
 
268
  /** the line color. */
 
269
  protected Color m_LineColor = null;
 
270
 
 
271
  /** the color of the zoombox. */
 
272
  protected Color m_ZoomBoxColor = null;
 
273
 
 
274
  /** the XOR color of the zoombox. */
 
275
  protected Color m_ZoomBoxXORColor = null;
 
276
  
 
277
  /** whether to show the border or not. */
 
278
  protected boolean m_ShowBorder = true;
 
279
  
252
280
  ///////////////////
253
281
 
254
282
  //this is the event fireing stuff
264
292
   */
265
293
  public TreeVisualizer(TreeDisplayListener tdl, String dot, NodePlace p) {
266
294
    super();
 
295
 
 
296
    initialize();
267
297
    
268
298
    //generate the node structure in here
269
 
    setBorder(BorderFactory.createTitledBorder("Tree View")); 
 
299
    if (m_ShowBorder)
 
300
      setBorder(BorderFactory.createTitledBorder(Messages.getInstance().getString("TreeVisualizer_BorderFactoryCreateTitledBorder_Text_First"))); 
270
301
    m_listener = tdl;
271
302
 
272
303
    TreeBuild builder = new TreeBuild();
312
343
 
313
344
 
314
345
    m_winMenu = new JPopupMenu();
315
 
    m_topN = new JMenuItem("Center on Top Node");           //note to change 
 
346
    m_topN = new JMenuItem(Messages.getInstance().getString("TreeVisualizer_TopN_JMenuItem_Text_First"));           //note to change 
316
347
    //language change this line
317
 
    m_topN.setActionCommand("Center on Top Node");          //but not this one,
 
348
    m_topN.setActionCommand(Messages.getInstance().getString("TreeVisualizer_TopN_JMenuItem_SetActionCommand_Text_First"));          //but not this one,
318
349
    //same for all menu items
319
 
    m_fitToScreen = new JMenuItem("Fit to Screen");
320
 
    m_fitToScreen.setActionCommand("Fit to Screen");
 
350
    m_fitToScreen = new JMenuItem(Messages.getInstance().getString("TreeVisualizer_FitToScreen_JMenuItem_Text_First"));
 
351
    m_fitToScreen.setActionCommand(Messages.getInstance().getString("TreeVisualizer_FitToScreen_JMenuItem_SetActionCommand_Text_First"));
321
352
    //unhide = new JMenuItem("Unhide all Nodes");
322
 
    m_selectFont = new JMenu("Select Font");
323
 
    m_selectFont.setActionCommand("Select Font");
324
 
    m_autoScale = new JMenuItem("Auto Scale");
325
 
    m_autoScale.setActionCommand("Auto Scale");
 
353
    m_selectFont = new JMenu(Messages.getInstance().getString("TreeVisualizer_SelectFont_JMenu_Text_First"));
 
354
    m_selectFont.setActionCommand(Messages.getInstance().getString("TreeVisualizer_SelectFont_JMenu_SetActionCommand_Text_First"));
 
355
    m_autoScale = new JMenuItem(Messages.getInstance().getString("TreeVisualizer_AutoScale_JMenuItem_Text_First"));
 
356
    m_autoScale.setActionCommand(Messages.getInstance().getString("TreeVisualizer_AutoScale_JMenuItem_SetActionCommand_Text_First"));
326
357
    m_selectFontGroup = new ButtonGroup();
327
358
    
328
 
    m_accept = new JMenuItem("Accept The Tree");
329
 
    m_accept.setActionCommand("Accept The Tree");
 
359
    m_accept = new JMenuItem(Messages.getInstance().getString("TreeVisualizer_Accept_JMenuItem_Text_First"));
 
360
    m_accept.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Accept_JMenuItem_SetActionCommand_Text_First"));
330
361
    
331
362
    m_winMenu.add(m_topN);
332
363
    m_winMenu.addSeparator();
333
364
    m_winMenu.add(m_fitToScreen);
334
365
    m_winMenu.add(m_autoScale);
335
 
    m_winMenu.addSeparator();
 
366
    //m_winMenu.addSeparator();
336
367
    //m_winMenu.add(unhide);
337
368
    m_winMenu.addSeparator();
338
369
    m_winMenu.add(m_selectFont);
339
 
    m_winMenu.addSeparator();
340
370
 
341
371
    if (m_listener != null) {
 
372
      m_winMenu.addSeparator();
342
373
      m_winMenu.add(m_accept);
343
374
    }
344
375
    
348
379
    m_autoScale.addActionListener(this);
349
380
    m_accept.addActionListener(this);
350
381
        
351
 
    m_size24 = new JRadioButtonMenuItem("Size 24",false);//,select_font_group);
352
 
    m_size22 = new JRadioButtonMenuItem("Size 22",false);//,select_font_group);
353
 
    m_size20 = new JRadioButtonMenuItem("Size 20",false);//,select_font_group);
354
 
    m_size18 = new JRadioButtonMenuItem("Size 18",false);//,select_font_group);
355
 
    m_size16 = new JRadioButtonMenuItem("Size 16",false);//,select_font_group);
356
 
    m_size14 = new JRadioButtonMenuItem("Size 14",false);//,select_font_group);
357
 
    m_size12 = new JRadioButtonMenuItem("Size 12",true);//,select_font_group);
358
 
    m_size10 = new JRadioButtonMenuItem("Size 10",false);//,select_font_group);
359
 
    m_size8 = new JRadioButtonMenuItem("Size 8",false);//,select_font_group);
360
 
    m_size6 = new JRadioButtonMenuItem("Size 6",false);//,select_font_group);
361
 
    m_size4 = new JRadioButtonMenuItem("Size 4",false);//,select_font_group);
362
 
    m_size2 = new JRadioButtonMenuItem("Size 2",false);//,select_font_group);
363
 
    m_size1 = new JRadioButtonMenuItem("Size 1",false);//,select_font_group);
 
382
    m_size24 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_Size24_Text_First"),false);//,select_font_group);
 
383
    m_size22 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_Size22_Text_First"),false);//,select_font_group);
 
384
    m_size20 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_Size20_Text_First"),false);//,select_font_group);
 
385
    m_size18 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_Size18_Text_First"),false);//,select_font_group);
 
386
    m_size16 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_Size16_Text_First"),false);//,select_font_group);
 
387
    m_size14 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_Size14_Text_First"),false);//,select_font_group);
 
388
    m_size12 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_Size12_Text_First"),true);//,select_font_group);
 
389
    m_size10 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_Size10_Text_First"),false);//,select_font_group);
 
390
    m_size8 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_Size8_Text_First"),false);//,select_font_group);
 
391
    m_size6 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_Size6_Text_First"),false);//,select_font_group);
 
392
    m_size4 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_Size4_Text_First"),false);//,select_font_group);
 
393
    m_size2 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_Size2_Text_First"),false);//,select_font_group);
 
394
    m_size1 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_Size1_Text_First"),false);//,select_font_group);
364
395
 
365
 
    m_size24.setActionCommand("Size 24");//,select_font_group);
366
 
    m_size22.setActionCommand("Size 22");//,select_font_group);
367
 
    m_size20.setActionCommand("Size 20");//,select_font_group);
368
 
    m_size18.setActionCommand("Size 18");//,select_font_group);
369
 
    m_size16.setActionCommand("Size 16");//,select_font_group);
370
 
    m_size14.setActionCommand("Size 14");//,select_font_group);
371
 
    m_size12.setActionCommand("Size 12");//,select_font_group);
372
 
    m_size10.setActionCommand("Size 10");//,select_font_group);
373
 
    m_size8.setActionCommand("Size 8");//,select_font_group);
374
 
    m_size6.setActionCommand("Size 6");//,select_font_group);
375
 
    m_size4.setActionCommand("Size 4");//,select_font_group);
376
 
    m_size2.setActionCommand("Size 2");//,select_font_group);
377
 
    m_size1.setActionCommand("Size 1");//,select_font_group);
 
396
    m_size24.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size24_Text_First"));//,select_font_group);
 
397
    m_size22.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size22_Text_First"));//,select_font_group);
 
398
    m_size20.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size20_Text_First"));//,select_font_group);
 
399
    m_size18.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size18_Text_First"));//,select_font_group);
 
400
    m_size16.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size16_Text_First"));//,select_font_group);
 
401
    m_size14.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size14_Text_First"));//,select_font_group);
 
402
    m_size12.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size12_Text_First"));//,select_font_group);
 
403
    m_size10.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size10_Text_First"));//,select_font_group);
 
404
    m_size8.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size8_Text_First"));//,select_font_group);
 
405
    m_size6.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size6_Text_First"));//,select_font_group);
 
406
    m_size4.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size4_Text_First"));//,select_font_group);
 
407
    m_size2.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size2_Text_First"));//,select_font_group);
 
408
    m_size1.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size1_Text_First"));//,select_font_group);
378
409
    
379
410
    
380
411
    m_selectFontGroup.add(m_size24);
446
477
 
447
478
    m_nodeMenu = new JPopupMenu();
448
479
    /* A visualize choice for the node, may not be available. */
449
 
    m_visualise = new JMenuItem("Visualize The Node");
450
 
    m_visualise.setActionCommand("Visualize The Node");
 
480
    m_visualise = new JMenuItem(Messages.getInstance().getString("TreeVisualizer_Visualise_JMenuItem_Text_First"));
 
481
    m_visualise.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Visualise_JMenuItem_SetActionCommand_Text_First"));
451
482
    m_visualise.addActionListener(this);
452
483
    m_nodeMenu.add(m_visualise);
453
484
   
454
485
    if (m_listener != null) {
455
 
      m_remChildren = new JMenuItem("Remove Child Nodes");
456
 
      m_remChildren.setActionCommand("Remove Child Nodes");
 
486
      m_remChildren = new JMenuItem(Messages.getInstance().getString("TreeVisualizer_RemChildren_JMenuItem_Text_First"));
 
487
      m_remChildren.setActionCommand(Messages.getInstance().getString("TreeVisualizer_RemChildren_JMenuItem_SetActionCommand_Text_First"));
457
488
      m_remChildren.addActionListener(this);
458
489
      m_nodeMenu.add(m_remChildren);
459
490
      
460
491
      
461
 
      m_classifyChild = new JMenuItem("Use Classifier...");
462
 
      m_classifyChild.setActionCommand("classify_child");
 
492
      m_classifyChild = new JMenuItem(Messages.getInstance().getString("TreeVisualizer_ClassifyChild_JMenuItem_Text_First"));
 
493
      m_classifyChild.setActionCommand(Messages.getInstance().getString("TreeVisualizer_ClassifyChild_JMenuItem_SetActionCommand_Text_First"));
463
494
      m_classifyChild.addActionListener(this);
464
495
      m_nodeMenu.add(m_classifyChild);
465
496
      
490
521
   */  
491
522
  public TreeVisualizer(TreeDisplayListener tdl, Node n, NodePlace p) {
492
523
    super();
 
524
 
 
525
    initialize();
493
526
    
494
527
    //if the size needs to be automatically alocated I will do it here
495
 
    setBorder(BorderFactory.createTitledBorder("Tree View")); 
 
528
    if (m_ShowBorder)
 
529
      setBorder(BorderFactory.createTitledBorder(Messages.getInstance().getString("TreeVisualizer_BorderFactoryCreateTitledBorder_Text_Second"))); 
496
530
    m_listener = tdl;
497
531
    m_topNode = n;
498
532
    m_placer = p;
525
559
    m_newMousePos = new Dimension(0, 0);
526
560
    m_frameLimiter = new Timer(120, this);
527
561
 
528
 
 
529
 
 
530
 
 
531
 
 
532
562
    m_winMenu = new JPopupMenu();
533
 
    m_topN = new JMenuItem("Center on Top Node");           //note to change 
 
563
    m_topN = new JMenuItem(Messages.getInstance().getString("TreeVisualizer_TopN_JMenuItem_Text_Second"));           //note to change 
534
564
    //language change this line
535
 
    m_topN.setActionCommand("Center on Top Node");          //but not this 
 
565
    m_topN.setActionCommand(Messages.getInstance().getString("TreeVisualizer_TopN_JMenuItem_SetActionCommand_Text_Second"));          //but not this 
536
566
    //one, same for all menu items
537
 
    m_fitToScreen = new JMenuItem("Fit to Screen");
538
 
    m_fitToScreen.setActionCommand("Fit to Screen");
 
567
    m_fitToScreen = new JMenuItem(Messages.getInstance().getString("TreeVisualizer_FitToScreen_JMenuItem_Text_Second"));
 
568
    m_fitToScreen.setActionCommand(Messages.getInstance().getString("TreeVisualizer_FitToScreen_JMenuItem_SetActionCommand_Text_Second"));
539
569
    //unhide = new JMenuItem("Unhide all Nodes");
540
 
    m_selectFont = new JMenu("Select Font");
541
 
    m_selectFont.setActionCommand("Select Font");
542
 
    m_autoScale = new JMenuItem("Auto Scale");
543
 
    m_autoScale.setActionCommand("Auto Scale");
 
570
    m_selectFont = new JMenu(Messages.getInstance().getString("TreeVisualizer_SelectFont_JMenu_Text_Second"));
 
571
    m_selectFont.setActionCommand(Messages.getInstance().getString("TreeVisualizer_SelectFont_JMenu_SetActionCommand_Text_Second"));
 
572
    m_autoScale = new JMenuItem(Messages.getInstance().getString("TreeVisualizer_AutoScale_JMenuItem_Text_Second"));
 
573
    m_autoScale.setActionCommand(Messages.getInstance().getString("TreeVisualizer_AutoScale_JMenuItem_SetActionCommand_Text_Second"));
544
574
    m_selectFontGroup = new ButtonGroup();
545
575
    
546
 
    m_accept = new JMenuItem("Accept The Tree");
547
 
    m_accept.setActionCommand("Accept The Tree");
 
576
    m_accept = new JMenuItem(Messages.getInstance().getString("TreeVisualizer_Accept_JMenuItem_Text_Second"));
 
577
    m_accept.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Accept_JMenuItem_SetActionCommand_Text_Second"));
548
578
    
549
579
    m_winMenu.add(m_topN);
550
580
    m_winMenu.addSeparator();
566
596
    m_autoScale.addActionListener(this);
567
597
    m_accept.addActionListener(this);
568
598
        
569
 
    m_size24 = new JRadioButtonMenuItem("Size 24",false);//,select_font_group);
570
 
    m_size22 = new JRadioButtonMenuItem("Size 22",false);//,select_font_group);
571
 
    m_size20 = new JRadioButtonMenuItem("Size 20",false);//,select_font_group);
572
 
    m_size18 = new JRadioButtonMenuItem("Size 18",false);//,select_font_group);
573
 
    m_size16 = new JRadioButtonMenuItem("Size 16",false);//,select_font_group);
574
 
    m_size14 = new JRadioButtonMenuItem("Size 14",false);//,select_font_group);
575
 
    m_size12 = new JRadioButtonMenuItem("Size 12",true);//,select_font_group);
576
 
    m_size10 = new JRadioButtonMenuItem("Size 10",false);//,select_font_group);
577
 
    m_size8 = new JRadioButtonMenuItem("Size 8",false);//,select_font_group);
578
 
    m_size6 = new JRadioButtonMenuItem("Size 6",false);//,select_font_group);
579
 
    m_size4 = new JRadioButtonMenuItem("Size 4",false);//,select_font_group);
580
 
    m_size2 = new JRadioButtonMenuItem("Size 2",false);//,select_font_group);
581
 
    m_size1 = new JRadioButtonMenuItem("Size 1",false);//,select_font_group);
 
599
    m_size24 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size24_JRadioButtonMenuItem_Size24_Text_Second"),false);//,select_font_group);
 
600
    m_size22 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size24_JRadioButtonMenuItem_Size22_Text_Second"),false);//,select_font_group);
 
601
    m_size20 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size24_JRadioButtonMenuItem_Size20_Text_Second"),false);//,select_font_group);
 
602
    m_size18 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size24_JRadioButtonMenuItem_Size18_Text_Second"),false);//,select_font_group);
 
603
    m_size16 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size24_JRadioButtonMenuItem_Size16_Text_Second"),false);//,select_font_group);
 
604
    m_size14 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size24_JRadioButtonMenuItem_Size14_Text_Second"),false);//,select_font_group);
 
605
    m_size12 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size24_JRadioButtonMenuItem_Size12_Text_Second"),true);//,select_font_group);
 
606
    m_size10 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size24_JRadioButtonMenuItem_Size10_Text_Second"),false);//,select_font_group);
 
607
    m_size8 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size24_JRadioButtonMenuItem_Size8_Text_Second"),false);//,select_font_group);
 
608
    m_size6 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size24_JRadioButtonMenuItem_Size6_Text_Second"),false);//,select_font_group);
 
609
    m_size4 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size24_JRadioButtonMenuItem_Size4_Text_Second"),false);//,select_font_group);
 
610
    m_size2 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size24_JRadioButtonMenuItem_Size2_Text_Second"),false);//,select_font_group);
 
611
    m_size1 = new JRadioButtonMenuItem(Messages.getInstance().getString("TreeVisualizer_Size24_JRadioButtonMenuItem_Size1_Text_Second"),false);//,select_font_group);
582
612
 
583
 
    m_size24.setActionCommand("Size 24");//,select_font_group);
584
 
    m_size22.setActionCommand("Size 22");//,select_font_group);
585
 
    m_size20.setActionCommand("Size 20");//,select_font_group);
586
 
    m_size18.setActionCommand("Size 18");//,select_font_group);
587
 
    m_size16.setActionCommand("Size 16");//,select_font_group);
588
 
    m_size14.setActionCommand("Size 14");//,select_font_group);
589
 
    m_size12.setActionCommand("Size 12");//,select_font_group);
590
 
    m_size10.setActionCommand("Size 10");//,select_font_group);
591
 
    m_size8.setActionCommand("Size 8");//,select_font_group);
592
 
    m_size6.setActionCommand("Size 6");//,select_font_group);
593
 
    m_size4.setActionCommand("Size 4");//,select_font_group);
594
 
    m_size2.setActionCommand("Size 2");//,select_font_group);
595
 
    m_size1.setActionCommand("Size 1");//,select_font_group);
 
613
    m_size24.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size24_Text_Second"));//,select_font_group);
 
614
    m_size22.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size22_Text_Second"));//,select_font_group);
 
615
    m_size20.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size20_Text_Second"));//,select_font_group);
 
616
    m_size18.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size18_Text_Second"));//,select_font_group);
 
617
    m_size16.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size16_Text_Second"));//,select_font_group);
 
618
    m_size14.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size14_Text_Second"));//,select_font_group);
 
619
    m_size12.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size12_Text_Second"));//,select_font_group);
 
620
    m_size10.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size10_Text_Second"));//,select_font_group);
 
621
    m_size8.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size8_Text_Second"));//,select_font_group);
 
622
    m_size6.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size6_Text_Second"));//,select_font_group);
 
623
    m_size4.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size4_Text_Second"));//,select_font_group);
 
624
    m_size2.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size2_Text_Second"));//,select_font_group);
 
625
    m_size1.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Size1_JRadioButtonMenuItem_SetActionCommand_Size1_Text_Second"));//,select_font_group);
596
626
 
597
627
 
598
628
 
673
703
 
674
704
    m_nodeMenu = new JPopupMenu();
675
705
    /* A visualize choice for the node, may not be available. */
676
 
    m_visualise = new JMenuItem("Visualize The Node");
677
 
    m_visualise.setActionCommand("Visualize The Node");
 
706
    m_visualise = new JMenuItem(Messages.getInstance().getString("TreeVisualizer_Visualise_JMenuItem_Text_Second"));
 
707
    m_visualise.setActionCommand(Messages.getInstance().getString("TreeVisualizer_Visualise_JMenuItem_SetActionCommand_Text_Second"));
678
708
    m_visualise.addActionListener(this);
679
709
    m_nodeMenu.add(m_visualise);
680
710
 
681
711
    if (m_listener != null) {
682
 
      m_remChildren = new JMenuItem("Remove Child Nodes");
683
 
      m_remChildren.setActionCommand("Remove Child Nodes");
 
712
      m_remChildren = new JMenuItem(Messages.getInstance().getString("TreeVisualizer_RemChildren_JMenuItem_Text_Second"));
 
713
      m_remChildren.setActionCommand(Messages.getInstance().getString("TreeVisualizer_RemChildren_JMenuItem_SetActionCommand_Text_Second"));
684
714
      m_remChildren.addActionListener(this);
685
715
      m_nodeMenu.add(m_remChildren);
686
716
      
687
 
      m_classifyChild = new JMenuItem("Use Classifier...");
688
 
      m_classifyChild.setActionCommand("classify_child");
 
717
      m_classifyChild = new JMenuItem(Messages.getInstance().getString("TreeVisualizer_ClassifyChild_JMenuItem_Text_Second"));
 
718
      m_classifyChild.setActionCommand(Messages.getInstance().getString("TreeVisualizer_ClassifyChild_JMenuItem_SetActionCommand_Text_Second"));
689
719
      m_classifyChild.addActionListener(this);
690
720
      m_nodeMenu.add(m_classifyChild);
691
721
      
692
 
      m_sendInstances = new JMenuItem("Add Instances To Viewer");
693
 
      m_sendInstances.setActionCommand("send_instances");
 
722
      m_sendInstances = new JMenuItem(Messages.getInstance().getString("TreeVisualizer_SendInstances_JMenuItem_Text"));
 
723
      m_sendInstances.setActionCommand(Messages.getInstance().getString("TreeVisualizer_SendInstances_JMenuItem_SetActionCommand_Text"));
694
724
      m_sendInstances.addActionListener(this);
695
725
      m_nodeMenu.add(m_sendInstances);
696
726
      
713
743
  }
714
744
 
715
745
  /**
 
746
   * Processes the color string. Returns null if empty.
 
747
   * 
 
748
   * @param colorStr    the string to process
 
749
   * @return            the processed color or null
 
750
   */
 
751
  protected Color getColor(String colorStr) {
 
752
    Color       result;
 
753
    
 
754
    result = null;
 
755
    
 
756
    if ((colorStr != null) && (colorStr.length() > 0))
 
757
      result = VisualizeUtils.processColour(colorStr, result);
 
758
    
 
759
    return result;
 
760
  }
 
761
  
 
762
  /**
 
763
   * Performs some initialization.
 
764
   */
 
765
  protected void initialize() {
 
766
    Properties  props;
 
767
    
 
768
    try {
 
769
      props = Utils.readProperties(PROPERTIES_FILE);
 
770
    }
 
771
    catch (Exception e) {
 
772
      e.printStackTrace();
 
773
      props = new Properties();
 
774
    }
 
775
    
 
776
    m_FontColor       = getColor(props.getProperty("FontColor", ""));
 
777
    m_BackgroundColor = getColor(props.getProperty("BackgroundColor", ""));
 
778
    m_NodeColor       = getColor(props.getProperty("NodeColor", ""));
 
779
    m_LineColor       = getColor(props.getProperty("LineColor", ""));
 
780
    m_ZoomBoxColor    = getColor(props.getProperty("ZoomBoxColor", ""));
 
781
    m_ZoomBoxXORColor = getColor(props.getProperty("ZoomBoxXORColor", ""));
 
782
    m_ShowBorder      = Boolean.parseBoolean(props.getProperty("ShowBorder", "true"));
 
783
  }
 
784
 
 
785
  /**
716
786
   * Fits the tree to the current screen size. Call this after
717
787
   * window has been created to get the entrire tree to be in view
718
788
   * upon launch.
793
863
        animateScaling(m_nViewPos, m_nViewSize, m_scaling);
794
864
      }
795
865
    }
796
 
    else if (e.getActionCommand().equals("Fit to Screen")) {
 
866
    else if (e.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ActionPerformed_FitToScreen_Text"))) {
797
867
      
798
868
      Dimension np = new Dimension();
799
869
      Dimension ns = new Dimension();
803
873
      animateScaling(np, ns, 10);
804
874
      
805
875
    }
806
 
    else if (e.getActionCommand().equals("Center on Top Node")) {
 
876
    else if (e.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ActionPerformed_CenterOnTopNode_Text"))) {
807
877
      
808
878
      int tpx = (int)(m_topNode.getCenter() * m_viewSize.width);   //calculate
809
879
      //the top nodes postion but don't adjust for where 
817
887
      animateScaling(np, m_viewSize, 10);
818
888
      
819
889
    }
820
 
    else if (e.getActionCommand().equals("Auto Scale")) {
 
890
    else if (e.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ActionPerformed_AutoScale_Text"))) {
821
891
      autoScale();  //this will figure the best scale value 
822
892
      //keep the focus on the middle of the screen and call animate
823
893
    }
824
 
    else if (e.getActionCommand().equals("Visualize The Node")) {
 
894
    else if (e.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ActionPerformed_VisualizeTheNode_Text"))) {
825
895
      //send the node data to the visualizer 
826
896
      if (m_focusNode >= 0) {
827
897
        Instances inst;
834
904
          nf.setVisible(true);
835
905
        }
836
906
        else {
837
 
          JOptionPane.showMessageDialog(this, "Sorry, there is no " + 
838
 
                                        "available Instances data for " +
839
 
                                        "this Node.", "Sorry!",
 
907
          JOptionPane.showMessageDialog(this, Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_First"), 
 
908
                          Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_Second"),
840
909
                                        JOptionPane.WARNING_MESSAGE); 
841
910
        }
842
911
      }
843
912
      else {
844
 
        JOptionPane.showMessageDialog(this, "Error, there is no " + 
845
 
                                      "selected Node to perform " +
846
 
                                      "this operation on.", "Error!",
 
913
        JOptionPane.showMessageDialog(this, Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_Third"), 
 
914
                        Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_Fourth"),
847
915
                                      JOptionPane.ERROR_MESSAGE); 
848
916
      }
849
917
    }
850
 
    else if (e.getActionCommand().equals("Create Child Nodes")) {
 
918
    else if (e.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ActionPerformed_CreateChildNodes_Text"))) {
851
919
      if (m_focusNode >= 0) {
852
920
        if (m_listener != null) {
853
921
          //then send message to the listener
856
924
             m_nodes[m_focusNode].m_node.getRefer()));
857
925
        }
858
926
        else {
859
 
          JOptionPane.showMessageDialog(this, "Sorry, there is no " + 
860
 
                                        "available Decision Tree to " +
861
 
                                        "perform this operation on.",
862
 
                                        "Sorry!", 
 
927
          JOptionPane.showMessageDialog(this, Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_Sixth"),
 
928
                                        Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_Seventh"), 
863
929
                                        JOptionPane.WARNING_MESSAGE);
864
930
        }
865
931
      }
866
932
      else {
867
 
        JOptionPane.showMessageDialog(this, "Error, there is no " +
868
 
                                      "selected Node to perform this " +
869
 
                                      "operation on.", "Error!",
 
933
        JOptionPane.showMessageDialog(this, Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_Eighth"), 
 
934
                        Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_Eighth"),
870
935
                                      JOptionPane.ERROR_MESSAGE);
871
936
      }
872
937
    }
873
 
    else if (e.getActionCommand().equals("Remove Child Nodes")) {
 
938
    else if (e.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ActionPerformed_RemoveChildNodes_Text"))) {
874
939
      if (m_focusNode >= 0) {
875
940
        if (m_listener != null) {
876
941
          //then send message to the listener
879
944
                             m_nodes[m_focusNode].m_node.getRefer()));
880
945
        }
881
946
        else {
882
 
          JOptionPane.showMessageDialog(this, "Sorry, there is no " + 
883
 
                                        "available Decsion Tree to " +
884
 
                                        "perform this operation on.",
885
 
                                        "Sorry!", 
 
947
          JOptionPane.showMessageDialog(this, Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_Nineth"),
 
948
                                        Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_Tenth"), 
886
949
                                        JOptionPane.WARNING_MESSAGE);
887
950
        }
888
951
      }
889
952
      else {
890
 
        JOptionPane.showMessageDialog(this, "Error, there is no " +
891
 
                                      "selected Node to perform this " +
892
 
                                      "operation on.", "Error!",
 
953
        JOptionPane.showMessageDialog(this, Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_Eleventh"), 
 
954
                        Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_Twelveth"),
893
955
                                      JOptionPane.ERROR_MESSAGE);
894
956
      }
895
957
    }
896
 
    else if (e.getActionCommand().equals("classify_child")) {
 
958
    else if (e.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ActionPerformed_Classify_Child_Text"))) {
897
959
      if (m_focusNode >= 0) {
898
960
        if (m_listener != null) {
899
961
          //then send message to the listener
902
964
             m_nodes[m_focusNode].m_node.getRefer()));
903
965
        }
904
966
        else {
905
 
          JOptionPane.showMessageDialog(this, "Sorry, there is no " + 
906
 
                                        "available Decsion Tree to " +
907
 
                                        "perform this operation on.",
908
 
                                        "Sorry!", 
 
967
          JOptionPane.showMessageDialog(this, Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_Thirteenth"),
 
968
                                        Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_Fourteenth"), 
909
969
                                        JOptionPane.WARNING_MESSAGE);
910
970
        }
911
971
      }
912
972
      else {
913
 
        JOptionPane.showMessageDialog(this, "Error, there is no " +
914
 
                                      "selected Node to perform this " +
915
 
                                      "operation on.", "Error!",
 
973
        JOptionPane.showMessageDialog(this, Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_Fifteenth"),
 
974
                        "                       " + Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_Sixteenth"),
916
975
                                      JOptionPane.ERROR_MESSAGE);
917
976
      }
918
977
    }
919
 
    else if (e.getActionCommand().equals("send_instances")) {
 
978
    else if (e.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ActionPerformed_Send_Instances_Text"))) {
920
979
      if (m_focusNode >= 0) {
921
980
        if (m_listener != null) {
922
981
          //then send message to the listener
925
984
             m_nodes[m_focusNode].m_node.getRefer()));
926
985
        }
927
986
        else {
928
 
          JOptionPane.showMessageDialog(this, "Sorry, there is no " + 
929
 
                                        "available Decsion Tree to " +
930
 
                                        "perform this operation on.",
931
 
                                        "Sorry!", 
 
987
          JOptionPane.showMessageDialog(this, Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_Seventeenth"),
 
988
                                        Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_Eighteenth"), 
932
989
                                        JOptionPane.WARNING_MESSAGE);
933
990
        }
934
991
      }
935
992
      else {
936
 
        JOptionPane.showMessageDialog(this, "Error, there is no " +
937
 
                                      "selected Node to perform this " +
938
 
                                      "operation on.", "Error!",
 
993
        JOptionPane.showMessageDialog(this, Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_Nineteenth"), 
 
994
                        Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_Twentyth"),
939
995
                                      JOptionPane.ERROR_MESSAGE);
940
996
      }
941
997
    }
942
 
    else if (e.getActionCommand().equals("Accept The Tree")) {
 
998
    else if (e.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ActionPerformed_AcceptTheTree_Text"))) {
943
999
      if (m_listener != null) {
944
1000
        //then send message to the listener saying that the tree is done
945
1001
        m_listener.userCommand(new TreeDisplayEvent(TreeDisplayEvent.ACCEPT,
946
1002
                                                  null));
947
1003
      }
948
1004
      else {
949
 
        JOptionPane.showMessageDialog(this, "Sorry, there is no " +
950
 
                                      "available Decision Tree to " +
951
 
                                      "perform this operation on.",
952
 
                                      "Sorry!", 
 
1005
        JOptionPane.showMessageDialog(this, Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_TwentyFirst"),
 
1006
                                      Messages.getInstance().getString("TreeVisualizer_ActionPerformed_JOptionPaneShowMessageDialog_Text_TwentySecond"), 
953
1007
                                      JOptionPane.WARNING_MESSAGE);
954
1008
      }
955
1009
    }
963
1017
  public void itemStateChanged(ItemEvent e)
964
1018
  {
965
1019
    JRadioButtonMenuItem c = (JRadioButtonMenuItem)e.getSource();
966
 
    if (c.getActionCommand().equals("Size 24")) {
 
1020
    if (c.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ItemStateChanged_GetActionCommand_Size24_Text"))) {
967
1021
      changeFontSize(24);
968
1022
    }
969
 
    else if (c.getActionCommand().equals("Size 22")) {
 
1023
    else if (c.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ItemStateChanged_GetActionCommand_Size22_Text"))) {
970
1024
      changeFontSize(22);
971
1025
    }
972
 
    else if (c.getActionCommand().equals("Size 20")) {
 
1026
    else if (c.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ItemStateChanged_GetActionCommand_Size20_Text"))) {
973
1027
      changeFontSize(20);
974
1028
    }
975
 
    else if (c.getActionCommand().equals("Size 18")) {
 
1029
    else if (c.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ItemStateChanged_GetActionCommand_Size18_Text"))) {
976
1030
      changeFontSize(18);
977
1031
    } 
978
 
    else if (c.getActionCommand().equals("Size 16")) {
 
1032
    else if (c.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ItemStateChanged_GetActionCommand_Size16_Text"))) {
979
1033
      changeFontSize(16);
980
1034
    }
981
 
    else if (c.getActionCommand().equals("Size 14")) {
 
1035
    else if (c.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ItemStateChanged_GetActionCommand_Size14_Text"))) {
982
1036
      changeFontSize(14);
983
1037
    }
984
 
    else if (c.getActionCommand().equals("Size 12")) {
 
1038
    else if (c.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ItemStateChanged_GetActionCommand_Size12_Text"))) {
985
1039
      changeFontSize(12);
986
1040
    }
987
 
    else if (c.getActionCommand().equals("Size 10")) {
 
1041
    else if (c.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ItemStateChanged_GetActionCommand_Size10_Text"))) {
988
1042
      changeFontSize(10);
989
1043
    }
990
 
    else if (c.getActionCommand().equals("Size 8")) {
 
1044
    else if (c.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ItemStateChanged_GetActionCommand_Size8_Text"))) {
991
1045
      changeFontSize(8);
992
1046
    }
993
 
    else if (c.getActionCommand().equals("Size 6")) {
 
1047
    else if (c.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ItemStateChanged_GetActionCommand_Size6_Text"))) {
994
1048
      changeFontSize(6);
995
1049
    }
996
 
    else if (c.getActionCommand().equals("Size 4")) {
 
1050
    else if (c.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ItemStateChanged_GetActionCommand_Size4_Text"))) {
997
1051
      changeFontSize(4);
998
1052
    }
999
 
    else if (c.getActionCommand().equals("Size 2")) {
 
1053
    else if (c.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ItemStateChanged_GetActionCommand_Size2_Text"))) {
1000
1054
      changeFontSize(2);
1001
1055
    }
1002
 
    else if (c.getActionCommand().equals("Size 1")) {
 
1056
    else if (c.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ItemStateChanged_GetActionCommand_Size1_Text"))) {
1003
1057
      changeFontSize(1);
1004
1058
    }
1005
 
    else if (c.getActionCommand().equals("Hide Descendants")) {
 
1059
    else if (c.getActionCommand().equals(Messages.getInstance().getString("TreeVisualizer_ItemStateChanged_GetActionCommand_HideDescendants_Text"))) {
1006
1060
      //focus_node.setCVisible(!c.isSelected());
1007
1061
      //no longer used...
1008
1062
    }
1039
1093
      if (m_focusNode != -1) {
1040
1094
        if (m_listener != null) {
1041
1095
          //then set this to be the selected node for editing
1042
 
          actionPerformed(new ActionEvent(this, 32000, "Create Child Nodes"));
 
1096
          actionPerformed(new ActionEvent(this, 32000, Messages.getInstance().getString("TreeVisualizer_ItemStateChanged_GetActionCommand_ActionPerformed_Text_First")));
1043
1097
          
1044
1098
        }
1045
1099
        else {
1046
1100
          //then open a visualize to display this nodes instances if possible
1047
 
          actionPerformed(new ActionEvent(this, 32000, "Visualize The Node"));
 
1101
          actionPerformed(new ActionEvent(this, 32000, Messages.getInstance().getString("TreeVisualizer_ItemStateChanged_GetActionCommand_ActionPerformed_Text_Second")));
1048
1102
        }
1049
1103
      }
1050
1104
    }
1077
1131
        m_mouseState = 3;
1078
1132
        
1079
1133
        Graphics g = getGraphics();
1080
 
        g.setColor(Color.black);
1081
 
        g.setXORMode(Color.white);
 
1134
        if (m_ZoomBoxColor == null)
 
1135
          g.setColor(Color.black);
 
1136
        else
 
1137
          g.setColor(m_ZoomBoxColor);
 
1138
        if (m_ZoomBoxXORColor == null)
 
1139
          g.setXORMode(Color.white);
 
1140
        else
 
1141
          g.setXORMode(m_ZoomBoxXORColor);
1082
1142
        g.drawRect(m_oldMousePos.width, m_oldMousePos.height,
1083
1143
                   m_newMousePos.width - m_oldMousePos.width, 
1084
1144
                   m_newMousePos.height - m_oldMousePos.height);
1152
1212
      //then zoom in
1153
1213
      m_mouseState = 0;
1154
1214
      Graphics g = getGraphics();
1155
 
      g.setColor(Color.black);
1156
 
      g.setXORMode(Color.white);
 
1215
      if (m_ZoomBoxColor == null)
 
1216
        g.setColor(Color.black);
 
1217
      else
 
1218
        g.setColor(m_ZoomBoxColor);
 
1219
      if (m_ZoomBoxXORColor == null)
 
1220
        g.setXORMode(Color.white);
 
1221
      else
 
1222
        g.setXORMode(m_ZoomBoxXORColor);
1157
1223
      g.drawRect(m_oldMousePos.width, m_oldMousePos.height, 
1158
1224
                 m_newMousePos.width - m_oldMousePos.width, 
1159
1225
                 m_newMousePos.height - m_oldMousePos.height);
1267
1333
      //then zoom box being created
1268
1334
      //redraw the zoom box
1269
1335
      Graphics g = getGraphics();
1270
 
      g.setColor(Color.black);
1271
 
      g.setXORMode(Color.white);
 
1336
      if (m_ZoomBoxColor == null)
 
1337
        g.setColor(Color.black);
 
1338
      else
 
1339
        g.setColor(m_ZoomBoxColor);
 
1340
      if (m_ZoomBoxXORColor == null)
 
1341
        g.setXORMode(Color.white);
 
1342
      else
 
1343
        g.setXORMode(m_ZoomBoxXORColor);
1272
1344
      g.drawRect(m_oldMousePos.width, m_oldMousePos.height,
1273
1345
                 m_newMousePos.width - m_oldMousePos.width, 
1274
1346
                 m_newMousePos.height - m_oldMousePos.height);
1334
1406
   * @param g the drawing surface.
1335
1407
   */
1336
1408
  public void paintComponent(Graphics g) {
1337
 
    //System.out.println(nodes[0].top + "this is seriously pissing me off");
 
1409
    Color oldBackground = ((Graphics2D) g).getBackground();
 
1410
    if (m_BackgroundColor != null)
 
1411
      ((Graphics2D) g).setBackground(m_BackgroundColor);
1338
1412
    g.clearRect(0, 0, getSize().width, getSize().height);
 
1413
    ((Graphics2D) g).setBackground(oldBackground);
1339
1414
    g.setClip(3, 7, getWidth() - 6, getHeight() - 10);
1340
1415
    painter(g);
1341
1416
    g.setClip(0, 0, getWidth(), getHeight());
1462
1537
    if (m_highlightNode >= 0 && m_highlightNode < m_numNodes) {
1463
1538
      //then draw outline
1464
1539
      if (m_nodes[m_highlightNode].m_quad == 18) {
1465
 
        Color acol = m_nodes[m_highlightNode].m_node.getColor();
 
1540
        Color acol;
 
1541
        if (m_NodeColor == null)
 
1542
          acol = m_nodes[m_highlightNode].m_node.getColor();
 
1543
        else
 
1544
          acol = m_NodeColor;
1466
1545
        g.setColor(new Color((acol.getRed() + 125) % 256, 
1467
1546
                             (acol.getGreen() + 125) % 256, 
1468
1547
                             (acol.getBlue() + 125) % 256));
1516
1595
  private void drawNode(int n, Graphics g) {
1517
1596
    //this will draw a node and then print text on it
1518
1597
    
1519
 
    g.setColor(m_nodes[n].m_node.getColor());
 
1598
    if (m_NodeColor == null)
 
1599
      g.setColor(m_nodes[n].m_node.getColor());
 
1600
    else
 
1601
      g.setColor(m_NodeColor);
1520
1602
    g.setPaintMode();
1521
1603
    calcScreenCoords(n);
1522
1604
    int x = m_nodes[n].m_center - m_nodes[n].m_side;
1553
1635
    calcScreenCoords(c);
1554
1636
    calcScreenCoords(p);
1555
1637
    
1556
 
    g.setColor(Color.black);
 
1638
    if (m_LineColor == null)
 
1639
      g.setColor(Color.black);
 
1640
    else
 
1641
      g.setColor(m_LineColor);
1557
1642
    g.setPaintMode();
1558
1643
    
1559
1644
    if (m_currentFont.getSize() < 2) {
1623
1708
    //this function will take in the rectangle that the text should be 
1624
1709
    //drawn in as well as the subscript
1625
1710
    //for either the edge or node and a boolean variable to tell which
 
1711
    
 
1712
    // backup color
 
1713
    Color oldColor = g.getColor();
1626
1714
 
1627
1715
    g.setPaintMode();
1628
 
    g.setColor(Color.black);
 
1716
    if (m_FontColor == null)
 
1717
      g.setColor(Color.black);
 
1718
    else
 
1719
      g.setColor(m_FontColor);
1629
1720
    String st;
1630
1721
    if (e_or_n) {
1631
1722
      //then paint for edge
1645
1736
                     y1 + (noa + 1) * m_fontSize.getHeight()); 
1646
1737
      }
1647
1738
    }
 
1739
    
 
1740
    // restore color
 
1741
    g.setColor(oldColor);
1648
1742
  }
1649
1743
  
1650
1744
  /**
1825
1919
    //I will have to use a global variable since I am doing it proportionally
1826
1920
 
1827
1921
    if (frames == 0) {
1828
 
      System.out.println("the timer didn't end in time");
 
1922
      System.out.println(Messages.getInstance().getString("TreeVisualizer_AnimateScaling_Text"));
1829
1923
      m_scaling = 0;
1830
1924
    }
1831
1925
    else {
2073
2167
   * @param args first argument should be the name of a file that contains
2074
2168
   * a tree discription in dot format.
2075
2169
   */
2076
 
  public static void main(String[] args)
2077
 
  {
2078
 
    try
2079
 
      {
2080
 
        weka.core.logging.Logger.log(weka.core.logging.Logger.Level.INFO, "Logging started");
2081
 
        //put in the random data generator right here
2082
 
        // this call with import java.lang gives me between 0 and 1 Math.random
2083
 
        TreeBuild builder = new TreeBuild();
2084
 
        Node top = null;
2085
 
        NodePlace arrange = new PlaceNode2();
2086
 
        //top = builder.create(new StringReader("digraph atree { top [label=\"the top\"] a [label=\"the first node\"] b [label=\"the second nodes\"] c [label=\"comes off of first\"] top->a top->b b->c }"));
2087
 
        top = builder.create(new FileReader(args[0]));
2088
 
    
2089
 
        int num = top.getCount(top,0);
2090
 
        //System.out.println("counter counted " + num + " nodes");
2091
 
        //System.out.println("there are " + num + " nodes");
2092
 
        TreeVisualizer a = new TreeVisualizer(null, top, arrange);
2093
 
        a.setSize(800 ,600);
2094
 
        //a.setTree(top);
2095
 
        JFrame f;
2096
 
        f = new JFrame();
2097
 
        //a.addMouseMotionListener(a);
2098
 
        //a.addMouseListener(a);
2099
 
        //f.add(a);
2100
 
        Container contentPane = f.getContentPane();
2101
 
        contentPane.add(a);
2102
 
   f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
2103
 
        f.setSize(800,600);
2104
 
        f.setVisible(true);
2105
 
        //f.
2106
 
        //find_prop(top);
2107
 
        //a.setTree(top,arrange);//,(num + 1000), num / 2 + 1000);
2108
 
      }
2109
 
    catch(IOException e){}
 
2170
  public static void main(String[] args) {
 
2171
    try {
 
2172
      weka.core.logging.Logger.log(weka.core.logging.Logger.Level.INFO, Messages.getInstance().getString("TreeVisualizer_Main_Logger_Text"));
 
2173
      //put in the random data generator right here
 
2174
      // this call with import java.lang gives me between 0 and 1 Math.random
 
2175
      TreeBuild builder = new TreeBuild();
 
2176
      Node top = null;
 
2177
      NodePlace arrange = new PlaceNode2();
 
2178
      //top = builder.create(new StringReader("digraph atree { top [label=\"the top\"] a [label=\"the first node\"] b [label=\"the second nodes\"] c [label=\"comes off of first\"] top->a top->b b->c }"));
 
2179
      top = builder.create(new FileReader(args[0]));
 
2180
 
 
2181
      int num = top.getCount(top,0);
 
2182
      //System.out.println("counter counted " + num + " nodes");
 
2183
      //System.out.println("there are " + num + " nodes");
 
2184
      TreeVisualizer a = new TreeVisualizer(null, top, arrange);
 
2185
      a.setSize(800 ,600);
 
2186
      //a.setTree(top);
 
2187
      JFrame f;
 
2188
      f = new JFrame();
 
2189
      //a.addMouseMotionListener(a);
 
2190
      //a.addMouseListener(a);
 
2191
      //f.add(a);
 
2192
      Container contentPane = f.getContentPane();
 
2193
      contentPane.add(a);
 
2194
      f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
 
2195
      f.setSize(800,600);
 
2196
      f.setVisible(true);
 
2197
      //f.
 
2198
      //find_prop(top);
 
2199
      //a.setTree(top,arrange);//,(num + 1000), num / 2 + 1000);
 
2200
    }
 
2201
    catch(IOException e) {
 
2202
      // ignored
 
2203
    }
2110
2204
  }
2111
2205
}
2112
 
 
2113
 
 
2114
 
 
2115
 
 
2116
 
 
2117
 
 
2118
 
 
2119
 
 
2120
 
 
2121
 
 
2122
 
 
2123