001/* 002 * @(#)InfoVisual.java 1.0 2005/03/14 003 * 004 * 005 * Institut d'Investigaci� en Intel�lig?ncia Artificial (IIIA) 006 * 007 */ 008 009/* 010 *----------------------------------------------------------------------------- 011 * 012 * Copyright 2007 by the 013 * Institut d'Investigaci� en Intel�lig?ncia Artificial, CSIC, Catalonia, EU 014 * http://www.iiia.csic.es 015 * 016 * This file is part of InfoVisual Toolkit 017 * 018 * InfoVisual Toolkit is free software; you can redistribute it and/or modify 019 * it under the terms of the GNU General Public License as published by 020 * the Free Software Foundation; either version 2 of the License, or 021 * (at your option) any later version. 022 * 023 * InfoVisual Toolkit is distributed in the hope that it will be useful, 024 * but WITHOUT ANY WARRANTY; without even the implied warranty of 025 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 026 * GNU General Public License for more details. 027 * 028 * You should have received a copy of the GNU General Public License 029 * along with iForecast; if not, write to the Free Software 030 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 031 * 032 *----------------------------------------------------------------------------- 033 */ 034 035package es.ucm.fdi.gaia.jcolibri.extensions.visualization.infovisual; 036 037 038import java.awt.BorderLayout; 039import java.awt.Dimension; 040import java.awt.event.WindowAdapter; 041import java.awt.event.WindowEvent; 042 043import javax.swing.BorderFactory; 044import javax.swing.Box; 045import javax.swing.BoxLayout; 046import javax.swing.JFrame; 047import javax.swing.JPanel; 048import javax.swing.JSplitPane; 049import javax.swing.event.ChangeEvent; 050import javax.swing.event.ChangeListener; 051 052import prefuse.util.ui.JValueSlider; 053 054//------------------------------------------------------------------- 055// *********************** The Class. ********************* 056//------------------------------------------------------------------- 057 058/** 059 * Main InfoVisual application. 060 * 061 * @author IIIA-CSIC 062 * @version $Revision: 1.10 $ $Date: 2006/07/10 12:29:58 $ 063 * 064 */ 065public class InfoVisual extends JFrame { 066 067 /** 068 * 069 */ 070 private static final long serialVersionUID = 1L; 071private final GraphLayout path; 072 073 //--------------------------------------------------------------- 074 // CONSTRUCTORS of the Class. 075 //--------------------------------------------------------------- 076 077 public InfoVisual (GraphLayout graph){ 078 this(graph,true,true); 079 } 080 081 /** 082 * Main Class constructor. 083 */ 084 085 public InfoVisual (GraphLayout graph, boolean controlPanel, boolean exitOnClose){ 086 087 path = graph; 088 089 // -- 6. launch the visualization ------------------------------------- 090 091 if (controlPanel){ 092 093 // Controls Panel (Right Frame) 094 JPanel fpanel = new JPanel(); 095 096 // Controlling Expanding Distance 097 final JValueSlider slider = new JValueSlider("Distance", 0, 30, 1); 098 slider.addChangeListener(new ChangeListener() { 099 public void stateChanged(ChangeEvent e) { 100 path.setDistance(slider.getValue().intValue()); 101 } 102 }); 103 slider.setPreferredSize(new Dimension(250,30)); 104 slider.setMaximumSize(new Dimension(300,30)); 105 106 Box cf = new Box(BoxLayout.Y_AXIS); 107 cf.add(slider); 108 cf.setBorder(BorderFactory.createTitledBorder("Connectivity Filter")); 109 //fpanel.add(cf); 110 111 // Controlling Spring Distance 112 final JValueSlider sslider = new JValueSlider("Length", 0, 200, 50); 113 sslider.addChangeListener(new ChangeListener() { 114 public void stateChanged(ChangeEvent e) { 115 path.setSpringForce (sslider.getValue().floatValue()); 116 } 117 }); 118 sslider.setPreferredSize(new Dimension(250,30)); 119 sslider.setMaximumSize(new Dimension(300,30)); 120 121 Box sf = new Box(BoxLayout.Y_AXIS); 122 sf.add(sslider); 123 sf.setBorder(BorderFactory.createTitledBorder("Spring Force")); 124 fpanel.add(sf); 125 126// JForcePanel ffpanel = new JForcePanel(fsim); 127// fpanel.add(ffpanel); 128 129 fpanel.add(Box.createVerticalGlue()); 130 131 // create a new JSplitPane to present the interface 132 JSplitPane split = new JSplitPane(); 133 split.setLeftComponent(path); 134 split.setRightComponent(fpanel); 135 split.setOneTouchExpandable(true); 136 split.setContinuousLayout(false); 137 split.setDividerLocation(720); 138 this.add(split); 139 }else{ 140 this.add(path,BorderLayout.CENTER); 141 } 142 143 // Activating the window 144 this.setTitle("jCOLIBRI Case base visualization tool"); 145 this.setPreferredSize(new Dimension(1000,700)); 146 // ensure application exits when window is closed 147 if (exitOnClose) this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 148 else 149 { 150 this.addWindowListener(new WindowAdapter(){ 151 public void windowClosing(WindowEvent e){ 152 GraphLayout.vis.cancel("layout"); 153 } 154 }); 155 } 156 this.pack(); // layout components in window 157 this.setVisible(true); // show the window 158 159 } 160 161 //--------------------------------------------------------------- 162 // METHODS of the Class. 163 //--------------------------------------------------------------- 164 165 /** 166 * Main method to start the InfoVis Toolkit. 167 * @param args of the main method. 168 */ 169 public static void main (String args[]) { 170 171 CBGraph graph = new CBGraph(); 172 graph.generateGraph(); 173 new InfoVisual( new CaseBaseVis(graph), false, true); 174// new InfoVisual( new CaseBaseVis("data/Zoology.xml"), false, true); 175 } 176 177}//end 'InfoVisual' class.