|
From: <eki...@us...> - 2006-11-06 20:06:17
|
Revision: 96
http://svn.sourceforge.net/jtreemap/?rev=96&view=rev
Author: ekingulen
Date: 2006-11-06 12:05:53 -0800 (Mon, 06 Nov 2006)
Log Message:
-----------
- checkstyle etc fixes.
Modified Paths:
--------------
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/JTreeMap.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/BuilderTM3.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/BuilderXML.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/JTreeMapAppletExample.java
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/JTreeMap.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/JTreeMap.java 2006-11-06 17:24:15 UTC (rev 95)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/JTreeMap.java 2006-11-06 20:05:53 UTC (rev 96)
@@ -48,6 +48,7 @@
import javax.swing.JTree;
import javax.swing.ToolTipManager;
import javax.swing.border.Border;
+import javax.swing.tree.TreePath;
/**
* JComponent who represents each element of a tree in a rectangle of more or
@@ -83,7 +84,7 @@
* The optional tree representation of the hierarchical data.
*/
private JTree treeView;
-
+
// active leaf
private TreeMapNode activeLeaf = null;
@@ -118,7 +119,7 @@
public JTreeMap(final TreeMapNode root) {
this(root, new SplitSquarified());
}
-
+
/**
* Constructor of JTreeMap. <BR>
* The chosen strategy is SplitSquarified. <BR>
@@ -129,9 +130,9 @@
* @param root the root of the tree to display
* @param treeView The tree representation of the hierarchical data.
*/
- public JTreeMap(final TreeMapNode root, JTree treeView) {
- this(root, new SplitSquarified());
- this.treeView = treeView;
+ public JTreeMap(final TreeMapNode root, final JTree treeView) {
+ this(root, new SplitSquarified());
+ this.treeView = treeView;
}
/**
@@ -582,23 +583,34 @@
* @author Ekin Gulen
*/
protected class HandleMouseClick extends MouseAdapter {
-
- @Override
- public void mouseClicked(MouseEvent e) {
- if (e.getClickCount() >= 2) {
- final TreeMapNode t = getDisplayedRoot().getChild(e.getX(), e.getY());
- if ( t != null && !t.isLeaf()) {
-// treeView.setSelectionPath(new TreePath(t.getPath()));
- zoom(t);
- } else {
-// treeView.setSelectionPath(new TreePath(((TreeMapNode)getDisplayedRoot().getParent()).getPath()));
- zoom((TreeMapNode)getDisplayedRoot().getParent());
- }
- repaint();
- }
- }
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ if (e.getClickCount() >= 2) {
+ final TreeMapNode t = getDisplayedRoot().getChild(e.getX(), e.getY());
+ if ( t != null && !t.isLeaf()) {
+ if (treeView == null) {
+ zoom(t);
+ } else {
+ zoom(t);
+ // dont know why below does not work so for now leave it commented out
+ // treeView.setSelectionPath(new TreePath(t.getPath()));
+ }
+
+ } else {
+ if (treeView == null) {
+ zoom((TreeMapNode)getDisplayedRoot().getParent());
+ } else {
+ zoom((TreeMapNode)getDisplayedRoot().getParent());
+ // dont know why below does not work so for now leave it commented out
+ //treeView.setSelectionPath(new TreePath(((TreeMapNode)getDisplayedRoot().getParent()).getPath()));
+ }
+ }
+ repaint();
+ }
+ }
}
-
+
/**
* Class who zoom and unzoom the JTreeMap.
*
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/BuilderTM3.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/BuilderTM3.java 2006-11-06 17:24:15 UTC (rev 95)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/BuilderTM3.java 2006-11-06 20:05:53 UTC (rev 96)
@@ -50,6 +50,8 @@
import net.sf.jtreemap.swing.TreeMapNode;
import net.sf.jtreemap.swing.TreeMapNodeBuilder;
+
+
/**
* Parse a TM3 file to build the tree. <BR>
* See <a href=http://www.cs.umd.edu/hcil/treemap/doc4.1/create_TM3_file.html>
@@ -89,7 +91,7 @@
private static final LinkedList<String> FIELD_TYPES = new LinkedList<String>();
- private final HashMap<TreeMapNode, HashMap<String, Object>> VALUES = new HashMap<TreeMapNode, HashMap<String, Object>>();
+ private final HashMap<TreeMapNode, HashMap<String, Object>> values = new HashMap<TreeMapNode, HashMap<String, Object>>();
private TreeMapNodeBuilder builder;
@@ -113,10 +115,10 @@
* @throws IOException
*/
public BuilderTM3(final BufferedReader reader) throws IOException {
- this.builder = new TreeMapNodeBuilder();
- parse(reader);
+ this.builder = new TreeMapNodeBuilder();
+ parse(reader);
}
-
+
/**
* @return the number fields (ie INTEGER and FLOAT)
*/
@@ -148,12 +150,12 @@
*/
public void setValues(final String fieldName) {
if ("".equals(fieldName)) {
- for (final TreeMapNode node : VALUES.keySet()) {
+ for (final TreeMapNode node : values.keySet()) {
node.setValue(new DefaultValue(0));
}
} else {
- for (final TreeMapNode node : VALUES.keySet()) {
- final HashMap<String, Object> mapNodeValues = VALUES.get(node);
+ for (final TreeMapNode node : values.keySet()) {
+ final HashMap<String, Object> mapNodeValues = values.get(node);
final Object value = mapNodeValues.get(fieldName);
if (value instanceof Number) {
final Number number = (Number) value;
@@ -174,12 +176,12 @@
*/
public void setWeights(final String fieldName) {
if ("".equals(fieldName)) {
- for (final TreeMapNode node : VALUES.keySet()) {
+ for (final TreeMapNode node : values.keySet()) {
node.setWeight(1);
}
} else {
- for (final TreeMapNode node : VALUES.keySet()) {
- final HashMap<String, Object> mapNodeValues = VALUES.get(node);
+ for (final TreeMapNode node : values.keySet()) {
+ final HashMap<String, Object> mapNodeValues = values.get(node);
final Object value = mapNodeValues.get(fieldName);
if (value instanceof Number) {
final Number number = (Number) value;
@@ -230,7 +232,7 @@
// create the leaf
final TreeMapNode leaf = this.builder.buildLeaf(hierarchyPath.getLast(), 1, new DefaultValue(), node);
// each leaf is associated to their VALUES
- VALUES.put(leaf, mapNodeValues);
+ values.put(leaf, mapNodeValues);
}
/**
@@ -257,7 +259,7 @@
}
// read the VALUES
- VALUES.clear();
+ values.clear();
while ((line = reader.readLine()) != null) {
st = new StringTokenizer(line, "\t");
final HashMap<String, Object> mapNodeValues = new HashMap<String, Object>();
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/BuilderXML.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/BuilderXML.java 2006-11-06 17:24:15 UTC (rev 95)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/BuilderXML.java 2006-11-06 20:05:53 UTC (rev 96)
@@ -95,10 +95,10 @@
* if the file don't correspond to the TreeMap.dtd
*/
public BuilderXML(final File stFile) throws ParseException {
- this.builder = new TreeMapNodeBuilder();
- parse(stFile);
+ this.builder = new TreeMapNodeBuilder();
+ parse(stFile);
}
-
+
/**
* Constructor
*
@@ -108,10 +108,10 @@
* if the file don't correspond to the TreeMap.dtd
*/
public BuilderXML(final InputStream stream) throws ParseException {
- this.builder = new TreeMapNodeBuilder();
- parse(stream);
+ this.builder = new TreeMapNodeBuilder();
+ parse(stream);
}
-
+
/**
* get the build root
*
@@ -174,25 +174,25 @@
throw new ParseException("The file don't correspond to the TreeMap.dtd (" + e.getMessage() + ")", 0);
}
}
-
+
private void parse(final InputStream stream) throws ParseException {
- try {
- final DocumentBuilderFactory fabrique = DocumentBuilderFactory.newInstance();
-
- final DocumentBuilder constructeur = fabrique.newDocumentBuilder();
- this.document = constructeur.parse(stream);
-
- final Element root = this.document.getDocumentElement();
-
- build(root, null);
- } catch (final ParserConfigurationException e) {
- throw new ParseException("The file don't correspond to the TreeMap.dtd (" + e.getMessage() + ")", 0);
- } catch (final SAXException e) {
- throw new ParseException("The file don't correspond to the TreeMap.dtd (" + e.getMessage() + ")", 0);
- } catch (final IOException e) {
- e.printStackTrace();
- throw new ParseException("The file don't correspond to the TreeMap.dtd (" + e.getMessage() + ")", 0);
- }
+ try {
+ final DocumentBuilderFactory fabrique = DocumentBuilderFactory.newInstance();
+
+ final DocumentBuilder constructeur = fabrique.newDocumentBuilder();
+ this.document = constructeur.parse(stream);
+
+ final Element root = this.document.getDocumentElement();
+
+ build(root, null);
+ } catch (final ParserConfigurationException e) {
+ throw new ParseException("The file don't correspond to the TreeMap.dtd (" + e.getMessage() + ")", 0);
+ } catch (final SAXException e) {
+ throw new ParseException("The file don't correspond to the TreeMap.dtd (" + e.getMessage() + ")", 0);
+ } catch (final IOException e) {
+ e.printStackTrace();
+ throw new ParseException("The file don't correspond to the TreeMap.dtd (" + e.getMessage() + ")", 0);
+ }
}
}
/*
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/JTreeMapAppletExample.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/JTreeMapAppletExample.java 2006-11-06 17:24:15 UTC (rev 95)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/JTreeMapAppletExample.java 2006-11-06 20:05:53 UTC (rev 96)
@@ -69,17 +69,17 @@
* @author Laurent Dutheil
*/
public class JTreeMapAppletExample extends JApplet {
-
- private static final double CONSTRAINT_WEIGHTX = 0.5;
-
+
+ private static final double CONSTRAINT_WEIGHTX = 0.5;
+
private static final String XML = "xml";
- private static final String TM3 = "tm3";
+ private static final String TM3 = "tm3";
-// private static final int APPLET_HEIGHT = 400;
-//
-// private static final int APPLET_WIDTH = 600;
+// private static final int APPLET_HEIGHT = 400;
+// private static final int APPLET_WIDTH = 600;
+
private static final int DEFAULT_FONT_SIZE = 16;
private static final long serialVersionUID = -8376357344981512167L;
@@ -87,7 +87,7 @@
private JTreeMap jTreeMap;
private javax.swing.JPanel jContentPane = null;
-
+
private JComboBox cmbValue;
private JComboBox cmbWeight;
@@ -96,8 +96,8 @@
private BuilderTM3 builderTM3;
- private boolean showTM3CTonf;
-
+ private boolean showTM3CTonf;
+
/**
* This is the default constructor
*/
@@ -124,30 +124,30 @@
builderTM3 = new BuilderTM3(createReader(dataFile));
root = builderTM3.getRoot();
if (showTM3CTonf) {
- setTM3Fields();
- panelTM3.setVisible(true);
+ setTM3Fields();
+ panelTM3.setVisible(true);
}
} catch (final IOException e) {
- root = handleException(e);
+ root = handleException(e);
}
} else if(XML.equalsIgnoreCase(dataFileType)) {
try {
- URL url = new URL(getCodeBase() + dataFile);
- URLConnection connection = url.openConnection();
+ URL url = new URL(getCodeBase() + dataFile);
+ URLConnection connection = url.openConnection();
final BuilderXML bXml = new BuilderXML(connection.getInputStream());
root = bXml.getRoot();
} catch (final ParseException e) {
- root = handleException(e);
+ root = handleException(e);
} catch (MalformedURLException e) {
- root = handleException(e);
- } catch (IOException e) {
- root = handleException(e);
- }
+ root = handleException(e);
+ } catch (IOException e) {
+ root = handleException(e);
+ }
} else {
- root = DemoUtil.buildDemoRoot();
+ root = DemoUtil.buildDemoRoot();
}
-
+
this.jTreeMap = new JTreeMap(root, new SplitBySortedWeight());
this.jTreeMap.setFont(new Font(null, Font.BOLD, DEFAULT_FONT_SIZE));
this.jTreeMap.setColorProvider(new RedGreenColorProvider(this.jTreeMap));
@@ -158,25 +158,24 @@
getJContentPane().add(this.jTreeMap, BorderLayout.CENTER);
}
- /**
- * @param dataFile
- * @return
- * @throws MalformedURLException
- * @throws IOException
- */
- private BufferedReader createReader(String dataFile) throws MalformedURLException, IOException {
- URL url = new URL(getCodeBase() + dataFile);
- URLConnection connection = url.openConnection();
- BufferedReader reader = new BufferedReader(
- new InputStreamReader(connection.getInputStream()));
- return reader;
- }
+ /**
+ * @param dataFile
+ * @return
+ * @throws IOException
+ */
+ private BufferedReader createReader(String dataFile) throws IOException {
+ URL url = new URL(getCodeBase() + dataFile);
+ URLConnection connection = url.openConnection();
+ BufferedReader reader = new BufferedReader(
+ new InputStreamReader(connection.getInputStream()));
+ return reader;
+ }
- private TreeMapNode handleException(final Exception e) {
- e.printStackTrace();
- JOptionPane.showMessageDialog(this, e.getMessage(), "File error", JOptionPane.ERROR_MESSAGE);
- return DemoUtil.buildDemoRoot();
- }
+ private TreeMapNode handleException(final Exception e) {
+ e.printStackTrace();
+ JOptionPane.showMessageDialog(this, e.getMessage(), "File error", JOptionPane.ERROR_MESSAGE);
+ return DemoUtil.buildDemoRoot();
+ }
/**
* Add a pane to choose the weight and the value for TM3 file
@@ -235,8 +234,8 @@
final JComboBox cmb = (JComboBox) e.getSource();
final String field = (String) cmb.getSelectedItem();
JTreeMapAppletExample.this.builderTM3.setValues(field);
-// createColorProviders();
-// updateLegendPanel();
+// createColorProviders();
+// updateLegendPanel();
JTreeMapAppletExample.this.repaint();
}
});
@@ -264,13 +263,13 @@
*/
@Override
public void init() {
- // Width and height params are mandatory for an applet/object element in html
- // and should be defined via html.
- // this.setSize(APPLET_WIDTH, APPLET_HEIGHT);
+ // Width and height params are mandatory for an applet/object element in html
+ // and should be defined via html.
+ // this.setSize(APPLET_WIDTH, APPLET_HEIGHT);
this.setContentPane(getJContentPane());
showTM3CTonf = "true".equalsIgnoreCase(getParameter("showTM3Conf"));
- if (showTM3CTonf) {
- addPanelEast(getJContentPane());
+ if (showTM3CTonf) {
+ addPanelEast(getJContentPane());
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|