es.ucm.fdi.gaia.jcolibri.extensions.visualization.infovisual.InfoVisual Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jCOLIBRI Show documentation
Show all versions of jCOLIBRI Show documentation
jCOLIBRI is a java framework for the development of Case-Based Reasoning systems.
/*
* @(#)InfoVisual.java 1.0 2005/03/14
*
*
* Institut d'Investigaci� en Intel�lig?ncia Artificial (IIIA)
*
*/
/*
*-----------------------------------------------------------------------------
*
* Copyright 2007 by the
* Institut d'Investigaci� en Intel�lig?ncia Artificial, CSIC, Catalonia, EU
* http://www.iiia.csic.es
*
* This file is part of InfoVisual Toolkit
*
* InfoVisual Toolkit is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* InfoVisual Toolkit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with iForecast; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*-----------------------------------------------------------------------------
*/
package es.ucm.fdi.gaia.jcolibri.extensions.visualization.infovisual;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import prefuse.util.ui.JValueSlider;
//-------------------------------------------------------------------
// *********************** The Class. *********************
//-------------------------------------------------------------------
/**
* Main InfoVisual application.
*
* @author IIIA-CSIC
* @version $Revision: 1.10 $ $Date: 2006/07/10 12:29:58 $
*
*/
public class InfoVisual extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
private final GraphLayout path;
//---------------------------------------------------------------
// CONSTRUCTORS of the Class.
//---------------------------------------------------------------
public InfoVisual (GraphLayout graph){
this(graph,true,true);
}
/**
* Main Class constructor.
*/
public InfoVisual (GraphLayout graph, boolean controlPanel, boolean exitOnClose){
path = graph;
// -- 6. launch the visualization -------------------------------------
if (controlPanel){
// Controls Panel (Right Frame)
JPanel fpanel = new JPanel();
// Controlling Expanding Distance
final JValueSlider slider = new JValueSlider("Distance", 0, 30, 1);
slider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
path.setDistance(slider.getValue().intValue());
}
});
slider.setPreferredSize(new Dimension(250,30));
slider.setMaximumSize(new Dimension(300,30));
Box cf = new Box(BoxLayout.Y_AXIS);
cf.add(slider);
cf.setBorder(BorderFactory.createTitledBorder("Connectivity Filter"));
//fpanel.add(cf);
// Controlling Spring Distance
final JValueSlider sslider = new JValueSlider("Length", 0, 200, 50);
sslider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
path.setSpringForce (sslider.getValue().floatValue());
}
});
sslider.setPreferredSize(new Dimension(250,30));
sslider.setMaximumSize(new Dimension(300,30));
Box sf = new Box(BoxLayout.Y_AXIS);
sf.add(sslider);
sf.setBorder(BorderFactory.createTitledBorder("Spring Force"));
fpanel.add(sf);
// JForcePanel ffpanel = new JForcePanel(fsim);
// fpanel.add(ffpanel);
fpanel.add(Box.createVerticalGlue());
// create a new JSplitPane to present the interface
JSplitPane split = new JSplitPane();
split.setLeftComponent(path);
split.setRightComponent(fpanel);
split.setOneTouchExpandable(true);
split.setContinuousLayout(false);
split.setDividerLocation(720);
this.add(split);
}else{
this.add(path,BorderLayout.CENTER);
}
// Activating the window
this.setTitle("jCOLIBRI Case base visualization tool");
this.setPreferredSize(new Dimension(1000,700));
// ensure application exits when window is closed
if (exitOnClose) this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
else
{
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
GraphLayout.vis.cancel("layout");
}
});
}
this.pack(); // layout components in window
this.setVisible(true); // show the window
}
//---------------------------------------------------------------
// METHODS of the Class.
//---------------------------------------------------------------
/**
* Main method to start the InfoVis Toolkit.
* @param args of the main method.
*/
public static void main (String args[]) {
CBGraph graph = new CBGraph();
graph.generateGraph();
new InfoVisual( new CaseBaseVis(graph), false, true);
// new InfoVisual( new CaseBaseVis("data/Zoology.xml"), false, true);
}
}//end 'InfoVisual' class.