|
From: <be...@us...> - 2006-10-24 11:38:59
|
Revision: 65
http://svn.sourceforge.net/jtreemap/?rev=65&view=rev
Author: benoitx
Date: 2006-10-24 04:38:30 -0700 (Tue, 24 Oct 2006)
Log Message:
-----------
Sorted most of issues raised by FindBugs, down to 1.
Modified Paths:
--------------
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/ColorProvider.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTip.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTipBuilder.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultValue.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/IToolTipBuilder.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/JTreeMap.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitByNumber.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitBySlice.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitBySortedWeight.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitByWeight.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitSquarified.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitStrategy.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/TreeMapNode.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/TreeMapNodeBuilder.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/UniqueColorProvider.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/Value.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/HSBTreeMapColorProvider.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/JTreeMapAppletExample.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/JTreeMapExample.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/RandomColorProvider.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/RedGreenColorProvider.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/ValuePercent.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/ZoomPopupMenu.java
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/ColorProvider.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/ColorProvider.java 2006-10-24 10:28:55 UTC (rev 64)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/ColorProvider.java 2006-10-24 11:38:30 UTC (rev 65)
@@ -1,30 +1,33 @@
package net.sf.jtreemap.swing;
-import javax.swing.JPanel;
import java.awt.Color;
+import java.io.Serializable;
+import javax.swing.JPanel;
+
/**
* Abstract class with the methods who attribute color to the elements of
* JTreeMap.
- *
+ *
* @author Laurent DUTHEIL
*/
-public abstract class ColorProvider {
+public abstract class ColorProvider implements Serializable {
- /**
- * get the associated color to the value.
- *
- *@param value double value
- *@return the associated color to the value
- */
- public abstract Color getColor(Value value);
+ /**
+ * get the associated color to the value.
+ *
+ * @param value
+ * double value
+ * @return the associated color to the value
+ */
+ public abstract Color getColor(Value value);
- /**
- * get a legend JPanel.
- *
- *@return a legend JPanel
- */
- public abstract JPanel getLegendPanel();
+ /**
+ * get a legend JPanel.
+ *
+ * @return a legend JPanel
+ */
+ public abstract JPanel getLegendPanel();
}
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTip.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTip.java 2006-10-24 10:28:55 UTC (rev 64)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTip.java 2006-10-24 11:38:30 UTC (rev 65)
@@ -12,47 +12,48 @@
/**
* Default ToolTip for the jTreeMap.
- *
+ *
* @author Laurent DUTHEIL
*/
public class DefaultToolTip extends JToolTip {
- private static final long serialVersionUID = -2492627777999093973L;
- private JTreeMap jTreeMap;
- private Font labelFont;
- private Font valueFont;
+ private static final long serialVersionUID = -2492627777999093973L;
- /**
- * Constructor.
- *
- * @param jTreeMap the jTreeMap who display the tooltip
- */
- public DefaultToolTip(JTreeMap jTreeMap) {
- this.jTreeMap = jTreeMap;
- this.labelFont = new Font("Default", Font.BOLD, 14);
- this.valueFont = new Font("Default", Font.PLAIN, 10);
+ private JTreeMap jTreeMap;
- int width = 160;
- int height = getFontMetrics(this.labelFont).getHeight()
- + getFontMetrics(this.valueFont).getHeight();
+ private Font labelFont;
- Dimension size = new Dimension(width, height);
- this.setSize(size);
- this.setPreferredSize(size);
- }
+ private Font valueFont;
- @Override
- public void paint(Graphics g) {
- if (this.jTreeMap.getActiveLeaf() != null) {
- g.setColor(Color.lightGray);
- g.fill3DRect(0, 0, this.getWidth(), this.getHeight(), true);
- g.setColor(Color.black);
- g.setFont(this.labelFont);
- g.drawString(this.jTreeMap.getActiveLeaf().getLabel(), 5, g
- .getFontMetrics(this.labelFont).getAscent());
- g.setFont(this.valueFont);
- g.drawString(this.jTreeMap.getActiveLeaf().getLabelValue(), 5, this
- .getHeight() - 5);
+ /**
+ * Constructor.
+ *
+ * @param jTreeMap
+ * the jTreeMap who display the tooltip
+ */
+ public DefaultToolTip(final JTreeMap jTreeMap) {
+ this.jTreeMap = jTreeMap;
+ this.labelFont = new Font("Default", Font.BOLD, 14);
+ this.valueFont = new Font("Default", Font.PLAIN, 10);
+
+ final int width = 160;
+ final int height = getFontMetrics(this.labelFont).getHeight() + getFontMetrics(this.valueFont).getHeight();
+
+ final Dimension size = new Dimension(width, height);
+ this.setSize(size);
+ this.setPreferredSize(size);
}
- }
+ @Override
+ public void paint(final Graphics g) {
+ if (this.jTreeMap.getActiveLeaf() != null) {
+ g.setColor(Color.lightGray);
+ g.fill3DRect(0, 0, this.getWidth(), this.getHeight(), true);
+ g.setColor(Color.black);
+ g.setFont(this.labelFont);
+ g.drawString(this.jTreeMap.getActiveLeaf().getLabel(), 5, g.getFontMetrics(this.labelFont).getAscent());
+ g.setFont(this.valueFont);
+ g.drawString(this.jTreeMap.getActiveLeaf().getLabelValue(), 5, this.getHeight() - 5);
+ }
+ }
+
}
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTipBuilder.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTipBuilder.java 2006-10-24 10:28:55 UTC (rev 64)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTipBuilder.java 2006-10-24 11:38:30 UTC (rev 65)
@@ -3,35 +3,46 @@
*/
package net.sf.jtreemap.swing;
+import java.io.Serializable;
+
import javax.swing.JToolTip;
/**
* Default class to build the DefaultToolTip displayed by the JTreeMap.<BR>
- *
+ *
* @see net.sf.jtreemap.swing.DefaultToolTip
* @author Laurent DUTHEIL
- *
+ *
*/
-public class DefaultToolTipBuilder implements IToolTipBuilder {
- private static JToolTip instance = null;
- private JTreeMap jTreeMap;
+public class DefaultToolTipBuilder implements IToolTipBuilder, Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -1646772942428571187L;
- /**
- * Constructor.
- *
- * @param jTreeMap the linked JTreeMap
- */
- public DefaultToolTipBuilder(JTreeMap jTreeMap) {
- this.jTreeMap = jTreeMap;
- }
+ private static JToolTip instance = null;
- /* (non-Javadoc)
- * @see net.sf.jtreemap.swing.IToolTipBuilder#getToolTip()
- */
- public JToolTip getToolTip() {
- if (instance == null) {
- instance = new DefaultToolTip(this.jTreeMap);
+ private JTreeMap jTreeMap;
+
+ /**
+ * Constructor.
+ *
+ * @param jTreeMap
+ * the linked JTreeMap
+ */
+ public DefaultToolTipBuilder(final JTreeMap jTreeMap) {
+ this.jTreeMap = jTreeMap;
}
- return instance;
- }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.jtreemap.swing.IToolTipBuilder#getToolTip()
+ */
+ public JToolTip getToolTip() {
+ if (instance == null) {
+ instance = new DefaultToolTip(this.jTreeMap);
+ }
+ return instance;
+ }
}
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultValue.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultValue.java 2006-10-24 10:28:55 UTC (rev 64)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultValue.java 2006-10-24 11:38:30 UTC (rev 65)
@@ -6,67 +6,72 @@
/**
* Default Value <BR>
* The getLabel() method returns the "" + getValue()
- *
+ *
* @author Laurent DUTHEIL
*/
public class DefaultValue extends Value {
- private double value;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 367321198951855282L;
+ private double value;
- /**
- * Constructor.
- */
- public DefaultValue() {
- //nothing to do
- }
+ /**
+ * Constructor.
+ */
+ public DefaultValue() {
+ // nothing to do
+ }
- /**
- * Constructor.
- *
- * @param value double value
- */
- public DefaultValue(double value) {
- this.value = value;
- }
+ /**
+ * Constructor.
+ *
+ * @param value
+ * double value
+ */
+ public DefaultValue(final double value) {
+ this.value = value;
+ }
- /*
- * (non-Javadoc)
- *
- * @see net.sf.jtreemap.swing.Value#getValue()
- */
- @Override
- public double getValue() {
- return this.value;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.jtreemap.swing.Value#getValue()
+ */
+ @Override
+ public double getValue() {
+ return this.value;
+ }
- /*
- * (non-Javadoc)
- *
- * @see net.sf.jtreemap.swing.Value#getLabel()
- */
- @Override
- public String getLabel() {
- return "" + this.value;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.jtreemap.swing.Value#getLabel()
+ */
+ @Override
+ public String getLabel() {
+ return "" + this.value;
+ }
- /*
- * (non-Javadoc)
- *
- * @see net.sf.jtreemap.swing.Value#setValue(double)
- */
- @Override
- public void setValue(double value) {
- this.value = value;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.jtreemap.swing.Value#setValue(double)
+ */
+ @Override
+ public void setValue(final double value) {
+ this.value = value;
+ }
- /*
- * (non-Javadoc)
- *
- * @see net.sf.jtreemap.swing.Value#setLabel(java.lang.String)
- */
- @Override
- public void setLabel(String newLabel) {
- // ignore
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.jtreemap.swing.Value#setLabel(java.lang.String)
+ */
+ @Override
+ public void setLabel(final String newLabel) {
+ // ignore
- }
+ }
}
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/IToolTipBuilder.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/IToolTipBuilder.java 2006-10-24 10:28:55 UTC (rev 64)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/IToolTipBuilder.java 2006-10-24 11:38:30 UTC (rev 65)
@@ -8,18 +8,17 @@
/**
* Interface used to build your own JToolTip for the jTreeMap.
- *
+ *
* @see net.sf.jtreemap.swing.JTreeMap#setToolTipBuilder(IToolTipBuilder)
* @author Laurent DUTHEIL
*/
public interface IToolTipBuilder {
- /**
- * Return the instance of the JToolTip.<BR>
- * Override this method to build your own JToolTip
- *
- * @return the instance of the JToolTip
- */
- public abstract JToolTip getToolTip();
-
+ /**
+ * Return the instance of the JToolTip.<BR>
+ * Override this method to build your own JToolTip
+ *
+ * @return the instance of the JToolTip
+ */
+ JToolTip getToolTip();
}
\ No newline at end of file
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/JTreeMap.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/JTreeMap.java 2006-10-24 10:28:55 UTC (rev 64)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/JTreeMap.java 2006-10-24 11:38:30 UTC (rev 65)
@@ -1,13 +1,14 @@
package net.sf.jtreemap.swing;
-import java.util.Enumeration;
import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Point;
+import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
-import java.awt.event.MouseEvent;
+import java.io.Serializable;
+import java.util.Enumeration;
import javax.swing.JComponent;
import javax.swing.JToolTip;
@@ -27,555 +28,587 @@
* <p>
* So, in a JTreeMap, you can see the size and the value of an element in a
* tree.
- *
+ *
* @see net.sf.jtreemap.swing.TreeMapNode
* @author Laurent Dutheil
*/
public class JTreeMap extends JComponent {
- private static final long serialVersionUID = 7255952672238300249L;
- private static final Color transparencyColor = new Color(204, 204, 204, 128);
- // active leaf
- private TreeMapNode activeLeaf = null;
- // color provider
- private ColorProvider colorProvider = null;
- // displayed root
- private TreeMapNode displayedRoot = null;
- // root of the tree
- private TreeMapNode root = null;
- // divide strategy
- private SplitStrategy strategy = null;
- // tooltip builder
- private IToolTipBuilder toolTipBuilder;
- // zoom
- private Zoom zoom;
+ private static final long serialVersionUID = 7255952672238300249L;
- /**
- * Constructor of JTreeMap. <BR>
- * The chosen strategy is SplitSquarified. <BR>
- * The chosen color provider is UniqueColorProvider.
- *
- * @see SplitSquarified
- * @see UniqueColorProvider
- * @param root the root of the tree to display
- */
- public JTreeMap(TreeMapNode root) {
- this(root, new SplitSquarified());
- }
+ private static final Color transparencyColor = new Color(204, 204, 204, 128);
- /**
- * Constructor of JTreeMap. <BR>
- * The chosen color provider is UniqueColorProvider.
- *
- * @see UniqueColorProvider
- * @param root the root of the tree to display
- * @param strategy the split strategy
- */
- public JTreeMap(TreeMapNode root, SplitStrategy strategy) {
- // ToolTips appears without delay and stay as long as possible
- ToolTipManager ttm = ToolTipManager.sharedInstance();
- ttm.setInitialDelay(0);
- ttm.setReshowDelay(0);
- ttm.setDismissDelay(100000);
- ttm.setEnabled(true);
- ttm.setLightWeightPopupEnabled(true);
- this.setToolTipText("");
+ // active leaf
+ private TreeMapNode activeLeaf = null;
- // the default DefaultToolTipBuilder
- this.toolTipBuilder = new DefaultToolTipBuilder(this);
+ // color provider
+ private ColorProvider colorProvider = null;
- this.zoom = new Zoom();
+ // displayed root
+ private TreeMapNode displayedRoot = null;
- this.setRoot(root);
- this.setStrategy(strategy);
- this.setColorProvider(new UniqueColorProvider());
+ // root of the tree
+ private TreeMapNode root = null;
- this.addMouseMotionListener(new HandleMouseMotion());
- }
+ // divide strategy
+ private SplitStrategy strategy = null;
- /**
- * calculate the postitions for the displayed root. <BR>
- * The positions of the root must be calculated first.
- */
- public void calculatePositions() {
- if (this.getStrategy() != null && this.displayedRoot != null) {
- this.getStrategy().calculatePositions(this.displayedRoot);
- }
- }
+ // tooltip builder
+ private IToolTipBuilder toolTipBuilder;
- @Override
- public JToolTip createToolTip() {
- return this.toolTipBuilder.getToolTip();
- }
+ // zoom
+ private Zoom zoom;
- /**
- * draw the item.
- *
- * @param g Graphics where you have to draw
- * @param item item to draw
- */
- protected void draw(Graphics g, TreeMapNode item) {
- if (item.isLeaf()) {
- g.setColor(this.colorProvider.getColor(item.getValue()));
- g.fillRect(item.getX(), item.getY(), item.getWidth(), item.getHeight());
- } else {
- for (Enumeration e = item.children(); e.hasMoreElements();) {
- draw(g, (TreeMapNode) (e.nextElement()));
- }
+ /**
+ * Constructor of JTreeMap. <BR>
+ * The chosen strategy is SplitSquarified. <BR>
+ * The chosen color provider is UniqueColorProvider.
+ *
+ * @see SplitSquarified
+ * @see UniqueColorProvider
+ * @param root
+ * the root of the tree to display
+ */
+ public JTreeMap(final TreeMapNode root) {
+ this(root, new SplitSquarified());
}
- }
- /**
- * write the label in the middle of the item. <BR>
- * You have first to define the font of the Graphics. <BR>
- * You may override this method to change the position or the color of the
- * label.
- *
- * @param g Graphics where you have to draw
- * @param item TreeMapNode to draw
- */
- protected void drawLabel(Graphics g, TreeMapNode item) {
- FontMetrics fm = g.getFontMetrics(g.getFont());
- // if the height of the item is high enough
- if (fm.getHeight() < item.getHeight() - 2) {
- String label = item.getLabel();
+ /**
+ * Constructor of JTreeMap. <BR>
+ * The chosen color provider is UniqueColorProvider.
+ *
+ * @see UniqueColorProvider
+ * @param root
+ * the root of the tree to display
+ * @param strategy
+ * the split strategy
+ */
+ public JTreeMap(final TreeMapNode root, final SplitStrategy strategy) {
+ // ToolTips appears without delay and stay as long as possible
+ final ToolTipManager ttm = ToolTipManager.sharedInstance();
+ ttm.setInitialDelay(0);
+ ttm.setReshowDelay(0);
+ ttm.setDismissDelay(100000);
+ ttm.setEnabled(true);
+ ttm.setLightWeightPopupEnabled(true);
+ this.setToolTipText("");
- int y = (item.getHeight() + fm.getAscent() - fm.getDescent()) / 2;
- int stringWidth = fm.stringWidth(label);
- // the width of the label depends on the font :
- // if the width of the label is larger than the item
- if (item.getWidth() - 5 <= stringWidth) {
- // We have to truncate the label
- // number of chars who can be writen in the item
- int nbChar = (label.length() * item.getWidth()) / stringWidth;
- if (nbChar > 3) {
- // and add "..." at the end
- label = label.substring(0, nbChar - 3) + "...";
- } else {
- // if it is not enough large, we display nothing
- label = "";
- }
- }
- int x = (item.getWidth() - fm.stringWidth(label)) / 2;
+ // the default DefaultToolTipBuilder
+ this.toolTipBuilder = new DefaultToolTipBuilder(this);
- // background in black
- g.setColor(Color.black);
- g.drawString(label, item.getX() + x + 1, item.getY() + y + 1);
- g.drawString(label, item.getX() + x - 1, item.getY() + y + 1);
- g.drawString(label, item.getX() + x + 1, item.getY() + y - 1);
- g.drawString(label, item.getX() + x - 1, item.getY() + y - 1);
- g.drawString(label, item.getX() + x + 1, item.getY() + y);
- g.drawString(label, item.getX() + x - 1, item.getY() + y);
- g.drawString(label, item.getX() + x, item.getY() + y + 1);
- g.drawString(label, item.getX() + x, item.getY() + y - 1);
- // label in white
- g.setColor(Color.white);
- g.drawString(label, item.getX() + x, item.getY() + y);
+ this.zoom = new Zoom();
+
+ this.setRoot(root);
+ this.setStrategy(strategy);
+ this.setColorProvider(new UniqueColorProvider());
+
+ this.addMouseMotionListener(new HandleMouseMotion());
}
- }
- /**
- * Draw all the labels to draw. <BR>
- * You may override this method to draw the labels you want. <BR>
- * For exemples, all the leaves, or all the first level children, or all of
- * them...
- *
- * @param g Graphics where you have to draw
- * @param item TreeMapNode to draw
- */
- protected void drawLabels(Graphics g, TreeMapNode item) {
- // add the labels (level -1)
- g.setFont(this.getFont());
- if (this.displayedRoot.isLeaf()) {
- drawLabel(g, this.displayedRoot);
- } else {
- for (Enumeration e = this.displayedRoot.children(); e.hasMoreElements();) {
- drawLabel(g, (TreeMapNode) (e.nextElement()));
- }
+ /**
+ * calculate the postitions for the displayed root. <BR>
+ * The positions of the root must be calculated first.
+ */
+ public void calculatePositions() {
+ if (this.getStrategy() != null && this.displayedRoot != null) {
+ this.getStrategy().calculatePositions(this.displayedRoot);
+ }
}
- /* uncomment to add the labels of the lowered levels (up to depth > 2) */
- // int depth = item.getLevel() - this.displayedRoot.getLevel();
- // float newSize = Math.max(20, this.getFont().getSize2D());
- // java.awt.Font labelFont = this.getFont().deriveFont(java.awt.Font.BOLD,
- // newSize - 3 * depth);
- // g.setFont(labelFont);
- // if (depth > 2) {
- // drawLabel(g, item);
- // return;
- // }
- // if (item.isLeaf()) {
- // drawLabel(g, item);
- // } else {
- // for (Enumeration e = item.children(); e.hasMoreElements();) {
- // drawLabels(g, (TreeMapNode) (e.nextElement()));
- // }
- // }
- }
+ @Override
+ public JToolTip createToolTip() {
+ return this.toolTipBuilder.getToolTip();
+ }
- /**
- * get the active leaf (the one under the mouse).
- *
- * @return Returns the activeLeaf.
- */
- public TreeMapNode getActiveLeaf() {
- return this.activeLeaf;
- }
+ /**
+ * draw the item.
+ *
+ * @param g
+ * Graphics where you have to draw
+ * @param item
+ * item to draw
+ */
+ protected void draw(final Graphics g, final TreeMapNode item) {
+ if (item.isLeaf()) {
+ g.setColor(this.colorProvider.getColor(item.getValue()));
+ g.fillRect(item.getX(), item.getY(), item.getWidth(), item.getHeight());
+ } else {
+ for (final Enumeration e = item.children(); e.hasMoreElements();) {
+ draw(g, (TreeMapNode) (e.nextElement()));
+ }
+ }
+ }
- /**
- * get the ColorProvider.
- *
- * @return the ColorProvider
- */
- public ColorProvider getColorProvider() {
- return this.colorProvider;
- }
+ /**
+ * write the label in the middle of the item. <BR>
+ * You have first to define the font of the Graphics. <BR>
+ * You may override this method to change the position or the color of the
+ * label.
+ *
+ * @param g
+ * Graphics where you have to draw
+ * @param item
+ * TreeMapNode to draw
+ */
+ protected void drawLabel(final Graphics g, final TreeMapNode item) {
+ final FontMetrics fm = g.getFontMetrics(g.getFont());
+ // if the height of the item is high enough
+ if (fm.getHeight() < item.getHeight() - 2) {
+ String label = item.getLabel();
- /**
- * get the displayed root.
- * <p>
- * This may be not the root of the jTreeMap. After a zoom, the displayed root
- * can be the root of an under-tree.
- * </p>
- *
- * @return the displayed root
- */
- public TreeMapNode getDisplayedRoot() {
- return this.displayedRoot;
- }
+ final int y = (item.getHeight() + fm.getAscent() - fm.getDescent()) / 2;
+ final int stringWidth = fm.stringWidth(label);
+ // the width of the label depends on the font :
+ // if the width of the label is larger than the item
+ if (item.getWidth() - 5 <= stringWidth) {
+ // We have to truncate the label
+ // number of chars who can be writen in the item
+ final int nbChar = (label.length() * item.getWidth()) / stringWidth;
+ if (nbChar > 3) {
+ // and add "..." at the end
+ label = label.substring(0, nbChar - 3) + "...";
+ } else {
+ // if it is not enough large, we display nothing
+ label = "";
+ }
+ }
+ final int x = (item.getWidth() - fm.stringWidth(label)) / 2;
- /**
- * get the root.
- *
- * @return the root
- */
- public TreeMapNode getRoot() {
- return this.root;
- }
+ // background in black
+ g.setColor(Color.black);
+ g.drawString(label, item.getX() + x + 1, item.getY() + y + 1);
+ g.drawString(label, item.getX() + x - 1, item.getY() + y + 1);
+ g.drawString(label, item.getX() + x + 1, item.getY() + y - 1);
+ g.drawString(label, item.getX() + x - 1, item.getY() + y - 1);
+ g.drawString(label, item.getX() + x + 1, item.getY() + y);
+ g.drawString(label, item.getX() + x - 1, item.getY() + y);
+ g.drawString(label, item.getX() + x, item.getY() + y + 1);
+ g.drawString(label, item.getX() + x, item.getY() + y - 1);
+ // label in white
+ g.setColor(Color.white);
+ g.drawString(label, item.getX() + x, item.getY() + y);
+ }
+ }
- /**
- * get the SplitStrategy.
- *
- * @return the SplitStrategy
- */
- public SplitStrategy getStrategy() {
- return this.strategy;
- }
+ /**
+ * Draw all the labels to draw. <BR>
+ * You may override this method to draw the labels you want. <BR>
+ * For exemples, all the leaves, or all the first level children, or all of
+ * them...
+ *
+ * @param g
+ * Graphics where you have to draw
+ * @param item
+ * TreeMapNode to draw
+ */
+ protected void drawLabels(final Graphics g, final TreeMapNode item) {
+ // add the labels (level -1)
+ g.setFont(this.getFont());
+ if (this.displayedRoot.isLeaf()) {
+ drawLabel(g, this.displayedRoot);
+ } else {
+ for (final Enumeration e = this.displayedRoot.children(); e.hasMoreElements();) {
+ drawLabel(g, (TreeMapNode) (e.nextElement()));
+ }
+ }
- @Override
- public Point getToolTipLocation(MouseEvent event) {
- int posX;
- int posY;
- JToolTip toolTip = this.createToolTip();
- int XMax = this.displayedRoot.getX() + this.displayedRoot.getWidth();
- int YMin = this.displayedRoot.getY();
- if (this.activeLeaf != null) {
- if (this.activeLeaf.getWidth() >= toolTip.getWidth() + 8
- && this.activeLeaf.getHeight() >= toolTip.getHeight() + 8) {
- posX = this.activeLeaf.getX() + 4;
- posY = this.activeLeaf.getY() + 4;
- } else {
- posX = this.activeLeaf.getX() + this.activeLeaf.getWidth() + 4;
- posY = this.activeLeaf.getY() - toolTip.getHeight() - 4;
- }
+ /* uncomment to add the labels of the lowered levels (up to depth > 2) */
+ // int depth = item.getLevel() - this.displayedRoot.getLevel();
+ // float newSize = Math.max(20, this.getFont().getSize2D());
+ // java.awt.Font labelFont =
+ // this.getFont().deriveFont(java.awt.Font.BOLD,
+ // newSize - 3 * depth);
+ // g.setFont(labelFont);
+ // if (depth > 2) {
+ // drawLabel(g, item);
+ // return;
+ // }
+ // if (item.isLeaf()) {
+ // drawLabel(g, item);
+ // } else {
+ // for (Enumeration e = item.children(); e.hasMoreElements();) {
+ // drawLabels(g, (TreeMapNode) (e.nextElement()));
+ // }
+ // }
+ }
- if (posY < YMin + 4) {
- posY = YMin + 4;
- }
- if ((posX + toolTip.getWidth() > XMax - 4)
- && (this.activeLeaf.getX() >= toolTip.getWidth() + 4)) {
- posX = this.activeLeaf.getX() - 4 - toolTip.getWidth();
- }
-
- return new Point(posX, posY);
+ /**
+ * get the active leaf (the one under the mouse).
+ *
+ * @return Returns the activeLeaf.
+ */
+ public TreeMapNode getActiveLeaf() {
+ return this.activeLeaf;
}
- return null;
- }
- /*
- * (non-Javadoc)
- *
- * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
- */
- @Override
- protected void paintComponent(Graphics g) {
- super.paintComponent(g);
- int width = getSize().width;
- int height = getSize().height;
- Insets insets = getInsets();
-
- int border = TreeMapNode.getBorder();
- this.root.setDimension(this.root.getX(), this.root.getY(), width - border
- - insets.left - insets.right, height - border - insets.top
- - insets.bottom);
-
- if (!this.root.equals( this.displayedRoot )) {
- this.displayedRoot.setDimension(this.displayedRoot.getX(), this.displayedRoot.getY(), width - border
- - insets.left - insets.right, height - border - insets.top
- - insets.bottom);
+ /**
+ * get the ColorProvider.
+ *
+ * @return the ColorProvider
+ */
+ public ColorProvider getColorProvider() {
+ return this.colorProvider;
}
- this.calculatePositions();
-
- if (this.displayedRoot.children().hasMoreElements()) {
- // the background
- g.setColor(this.getBackground());
- g.fillRect(this.displayedRoot.getX(), this.displayedRoot.getY(),
- this.displayedRoot.getWidth() + border, this.displayedRoot
- .getHeight()
- + border);
- // the ...
[truncated message content] |
|
From: <be...@us...> - 2006-10-24 15:37:49
|
Revision: 66
http://svn.sourceforge.net/jtreemap/?rev=66&view=rev
Author: benoitx
Date: 2006-10-24 08:37:27 -0700 (Tue, 24 Oct 2006)
Log Message:
-----------
Worked on checkstyle issues.
Modified Paths:
--------------
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTip.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultValue.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/JTreeMap.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitBySortedWeight.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitByWeight.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitSquarified.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitStrategy.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/TreeMapNode.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/TreeMapNodeBuilder.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/UniqueColorProvider.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/Value.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
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/JTreeMapExample.java
Added Paths:
-----------
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/ValuePercent.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/DemoUtil.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/package.html
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/package.html
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/provider/
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/provider/HSBTreeMapColorProvider.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/provider/RandomColorProvider.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/provider/RedGreenColorProvider.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/provider/ZoomPopupMenu.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/provider/package.html
Removed Paths:
-------------
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/HSBTreeMapColorProvider.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/RandomColorProvider.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/RedGreenColorProvider.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/ValuePercent.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/ZoomPopupMenu.java
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTip.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTip.java 2006-10-24 11:38:30 UTC (rev 65)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTip.java 2006-10-24 15:37:27 UTC (rev 66)
@@ -16,6 +16,12 @@
* @author Laurent DUTHEIL
*/
public class DefaultToolTip extends JToolTip {
+ private static final int TOOLTIP_OFFSET = 5;
+
+ private static final int DEFAULT_VALUE_SIZE = 10;
+
+ private static final int DEFAULT_LABEL_SIZE = 14;
+
private static final long serialVersionUID = -2492627777999093973L;
private JTreeMap jTreeMap;
@@ -32,8 +38,8 @@
*/
public DefaultToolTip(final JTreeMap jTreeMap) {
this.jTreeMap = jTreeMap;
- this.labelFont = new Font("Default", Font.BOLD, 14);
- this.valueFont = new Font("Default", Font.PLAIN, 10);
+ this.labelFont = new Font("Default", Font.BOLD, DEFAULT_LABEL_SIZE);
+ this.valueFont = new Font("Default", Font.PLAIN, DEFAULT_VALUE_SIZE);
final int width = 160;
final int height = getFontMetrics(this.labelFont).getHeight() + getFontMetrics(this.valueFont).getHeight();
@@ -50,9 +56,9 @@
g.fill3DRect(0, 0, this.getWidth(), this.getHeight(), true);
g.setColor(Color.black);
g.setFont(this.labelFont);
- g.drawString(this.jTreeMap.getActiveLeaf().getLabel(), 5, g.getFontMetrics(this.labelFont).getAscent());
+ g.drawString(this.jTreeMap.getActiveLeaf().getLabel(), TOOLTIP_OFFSET, g.getFontMetrics(this.labelFont).getAscent());
g.setFont(this.valueFont);
- g.drawString(this.jTreeMap.getActiveLeaf().getLabelValue(), 5, this.getHeight() - 5);
+ g.drawString(this.jTreeMap.getActiveLeaf().getLabelValue(), TOOLTIP_OFFSET, this.getHeight() - TOOLTIP_OFFSET);
}
}
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultValue.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultValue.java 2006-10-24 11:38:30 UTC (rev 65)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultValue.java 2006-10-24 15:37:27 UTC (rev 66)
@@ -14,6 +14,7 @@
*
*/
private static final long serialVersionUID = 367321198951855282L;
+
private double value;
/**
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/JTreeMap.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/JTreeMap.java 2006-10-24 11:38:30 UTC (rev 65)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/JTreeMap.java 2006-10-24 15:37:27 UTC (rev 66)
@@ -33,9 +33,17 @@
* @author Laurent Dutheil
*/
public class JTreeMap extends JComponent {
+ private static final int BORDER_FOR_FONT = 5;
+
+ private static final int MAX_NUM_CHAR = 3;
+
+ private static final int INSET = 4;
+
+ private static final int DISMISS_DELAY_MS = 100000;
+
private static final long serialVersionUID = 7255952672238300249L;
- private static final Color transparencyColor = new Color(204, 204, 204, 128);
+ private static final Color TRANSPARENCY_COLOR = new Color(204, 204, 204, 128);
// active leaf
private TreeMapNode activeLeaf = null;
@@ -87,21 +95,21 @@
final ToolTipManager ttm = ToolTipManager.sharedInstance();
ttm.setInitialDelay(0);
ttm.setReshowDelay(0);
- ttm.setDismissDelay(100000);
+ ttm.setDismissDelay(DISMISS_DELAY_MS);
ttm.setEnabled(true);
ttm.setLightWeightPopupEnabled(true);
- this.setToolTipText("");
+ setToolTipText("");
// the default DefaultToolTipBuilder
- this.toolTipBuilder = new DefaultToolTipBuilder(this);
+ toolTipBuilder = new DefaultToolTipBuilder(this);
- this.zoom = new Zoom();
+ zoom = new Zoom();
- this.setRoot(root);
- this.setStrategy(strategy);
- this.setColorProvider(new UniqueColorProvider());
+ setRoot(root);
+ setStrategy(strategy);
+ setColorProvider(new UniqueColorProvider());
- this.addMouseMotionListener(new HandleMouseMotion());
+ addMouseMotionListener(new HandleMouseMotion());
}
/**
@@ -109,14 +117,14 @@
* The positions of the root must be calculated first.
*/
public void calculatePositions() {
- if (this.getStrategy() != null && this.displayedRoot != null) {
- this.getStrategy().calculatePositions(this.displayedRoot);
+ if (this.getStrategy() != null && displayedRoot != null) {
+ getStrategy().calculatePositions(this.displayedRoot);
}
}
@Override
public JToolTip createToolTip() {
- return this.toolTipBuilder.getToolTip();
+ return toolTipBuilder.getToolTip();
}
/**
@@ -159,13 +167,13 @@
final int stringWidth = fm.stringWidth(label);
// the width of the label depends on the font :
// if the width of the label is larger than the item
- if (item.getWidth() - 5 <= stringWidth) {
+ if (item.getWidth() - BORDER_FOR_FONT <= stringWidth) {
// We have to truncate the label
// number of chars who can be writen in the item
final int nbChar = (label.length() * item.getWidth()) / stringWidth;
- if (nbChar > 3) {
+ if (nbChar > MAX_NUM_CHAR) {
// and add "..." at the end
- label = label.substring(0, nbChar - 3) + "...";
+ label = label.substring(0, nbChar - MAX_NUM_CHAR) + "...";
} else {
// if it is not enough large, we display nothing
label = "";
@@ -204,18 +212,18 @@
// add the labels (level -1)
g.setFont(this.getFont());
if (this.displayedRoot.isLeaf()) {
- drawLabel(g, this.displayedRoot);
+ drawLabel(g, displayedRoot);
} else {
- for (final Enumeration e = this.displayedRoot.children(); e.hasMoreElements();) {
+ for (final Enumeration e = displayedRoot.children(); e.hasMoreElements();) {
drawLabel(g, (TreeMapNode) (e.nextElement()));
}
}
/* uncomment to add the labels of the lowered levels (up to depth > 2) */
- // int depth = item.getLevel() - this.displayedRoot.getLevel();
- // float newSize = Math.max(20, this.getFont().getSize2D());
+ // int depth = item.getLevel() - displayedRoot.getLevel();
+ // float newSize = Math.max(20, getFont().getSize2D());
// java.awt.Font labelFont =
- // this.getFont().deriveFont(java.awt.Font.BOLD,
+ // getFont().deriveFont(java.awt.Font.BOLD,
// newSize - 3 * depth);
// g.setFont(labelFont);
// if (depth > 2) {
@@ -237,7 +245,7 @@
* @return Returns the activeLeaf.
*/
public TreeMapNode getActiveLeaf() {
- return this.activeLeaf;
+ return activeLeaf;
}
/**
@@ -246,7 +254,7 @@
* @return the ColorProvider
*/
public ColorProvider getColorProvider() {
- return this.colorProvider;
+ return colorProvider;
}
/**
@@ -259,7 +267,7 @@
* @return the displayed root
*/
public TreeMapNode getDisplayedRoot() {
- return this.displayedRoot;
+ return displayedRoot;
}
/**
@@ -268,7 +276,7 @@
* @return the root
*/
public TreeMapNode getRoot() {
- return this.root;
+ return root;
}
/**
@@ -277,30 +285,31 @@
* @return the SplitStrategy
*/
public SplitStrategy getStrategy() {
- return this.strategy;
+ return strategy;
}
@Override
public Point getToolTipLocation(final MouseEvent event) {
int posX;
int posY;
- final JToolTip toolTip = this.createToolTip();
- final int XMax = this.displayedRoot.getX() + this.displayedRoot.getWidth();
- final int YMin = this.displayedRoot.getY();
+ final JToolTip toolTip = createToolTip();
+ final int xMax = displayedRoot.getX() + displayedRoot.getWidth();
+ final int yMin = displayedRoot.getY();
if (this.activeLeaf != null) {
- if (this.activeLeaf.getWidth() >= toolTip.getWidth() + 8 && this.activeLeaf.getHeight() >= toolTip.getHeight() + 8) {
- posX = this.activeLeaf.getX() + 4;
- posY = this.activeLeaf.getY() + 4;
+ if (this.activeLeaf.getWidth() >= toolTip.getWidth() + 2 * INSET
+ && activeLeaf.getHeight() >= toolTip.getHeight() + 2 * INSET) {
+ posX = activeLeaf.getX() + INSET;
+ posY = activeLeaf.getY() + INSET;
} else {
- posX = this.activeLeaf.getX() + this.activeLeaf.getWidth() + 4;
- posY = this.activeLeaf.getY() - toolTip.getHeight() - 4;
+ posX = activeLeaf.getX() + activeLeaf.getWidth() + INSET;
+ posY = activeLeaf.getY() - toolTip.getHeight() - INSET;
}
- if (posY < YMin + 4) {
- posY = YMin + 4;
+ if (posY < yMin + INSET) {
+ posY = yMin + INSET;
}
- if ((posX + toolTip.getWidth() > XMax - 4) && (this.activeLeaf.getX() >= toolTip.getWidth() + 4)) {
- posX = this.activeLeaf.getX() - 4 - toolTip.getWidth();
+ if ((posX + toolTip.getWidth() > xMax - INSET) && (this.activeLeaf.getX() >= toolTip.getWidth() + INSET)) {
+ posX = activeLeaf.getX() - INSET - toolTip.getWidth();
}
return new Point(posX, posY);
@@ -321,29 +330,30 @@
final Insets insets = getInsets();
final int border = TreeMapNode.getBorder();
- this.root.setDimension(this.root.getX(), this.root.getY(), width - border - insets.left - insets.right, height - border
+ root.setDimension(this.root.getX(), root.getY(), width - border - insets.left - insets.right, height - border
- insets.top - insets.bottom);
if (!this.root.equals(this.displayedRoot)) {
- this.displayedRoot.setDimension(this.displayedRoot.getX(), this.displayedRoot.getY(), width - border - insets.left
+ displayedRoot.setDimension(this.displayedRoot.getX(), displayedRoot.getY(), width - border - insets.left
- insets.right, height - border - insets.top - insets.bottom);
}
- this.calculatePositions();
+ calculatePositions();
if (this.displayedRoot.children().hasMoreElements()) {
// the background
g.setColor(this.getBackground());
- g.fillRect(this.displayedRoot.getX(), this.displayedRoot.getY(), this.displayedRoot.getWidth() + border,
- this.displayedRoot.getHeight() + border);
+ g.fillRect(this.displayedRoot.getX(), displayedRoot.getY(), displayedRoot.getWidth() + border, displayedRoot
+ .getHeight()
+ + border);
// the JTreeMapExample
- draw(g, this.displayedRoot);
+ draw(g, displayedRoot);
// reveal the active leaf
if (this.activeLeaf != null) {
- reveal(g, this.activeLeaf);
+ reveal(g, activeLeaf);
}
// the labels
- drawLabels(g, this.displayedRoot);
+ drawLabels(g, displayedRoot);
}
}
@@ -358,7 +368,7 @@
*/
protected void reveal(final Graphics g, final TreeMapNode item) {
if (item.isLeaf()) {
- g.setColor(transparencyColor);
+ g.setColor(TRANSPARENCY_COLOR);
g.fillRect(item.getX(), item.getY(), item.getWidth(), item.getHeight());
}
}
@@ -371,7 +381,7 @@
*/
public void setActiveLeaf(final TreeMapNode newActiveLeaf) {
if (newActiveLeaf == null || newActiveLeaf.isLeaf()) {
- this.activeLeaf = newActiveLeaf;
+ activeLeaf = newActiveLeaf;
}
}
@@ -384,17 +394,17 @@
public void setBorder(final Border border) {
// Substract the previous border insets
Insets insets = getInsets();
- this.displayedRoot.setDimension(this.displayedRoot.getX() - insets.left, this.displayedRoot.getY() - insets.top,
- this.displayedRoot.getWidth() + insets.left + insets.right, this.displayedRoot.getHeight() + insets.top
- + insets.bottom);
+ displayedRoot.setDimension(this.displayedRoot.getX() - insets.left, displayedRoot.getY() - insets.top, displayedRoot
+ .getWidth()
+ + insets.left + insets.right, displayedRoot.getHeight() + insets.top + insets.bottom);
super.setBorder(border);
// Add the new border insets
insets = getInsets();
- this.displayedRoot.setDimension(this.displayedRoot.getX() + insets.left, this.displayedRoot.getY() + insets.top,
- this.displayedRoot.getWidth() - insets.left - insets.right, this.displayedRoot.getHeight() - insets.top
- - insets.bottom);
+ displayedRoot.setDimension(this.displayedRoot.getX() + insets.left, displayedRoot.getY() + insets.top, displayedRoot
+ .getWidth()
+ - insets.left - insets.right, displayedRoot.getHeight() - insets.top - insets.bottom);
}
/**
@@ -404,7 +414,7 @@
* the new ColorPorvider
*/
public void setColorProvider(final ColorProvider newColorProvider) {
- this.colorProvider = newColorProvider;
+ colorProvider = newColorProvider;
}
/**
@@ -418,7 +428,7 @@
* new DiplayedRoot
*/
public void setDisplayedRoot(final TreeMapNode newDisplayedRoot) {
- this.displayedRoot = newDisplayedRoot;
+ displayedRoot = newDisplayedRoot;
}
/**
@@ -428,11 +438,11 @@
* the new root to set
*/
public void setRoot(final TreeMapNode newRoot) {
- this.root = newRoot;
+ root = newRoot;
final Insets insets = getInsets();
- this.root.setX(insets.left);
- this.root.setY(insets.top);
- this.setDisplayedRoot(this.root);
+ root.setX(insets.left);
+ root.setY(insets.top);
+ setDisplayedRoot(this.root);
}
@@ -443,7 +453,7 @@
* the new strategy to set
*/
public void setStrategy(final SplitStrategy newStrat) {
- this.strategy = newStrat;
+ strategy = newStrat;
}
/**
@@ -464,14 +474,14 @@
* true if you want to keep proportions, else false
*/
public void setZoomKeepProportion(final boolean keepProportion) {
- this.zoom.setKeepProportion(keepProportion);
+ zoom.setKeepProportion(keepProportion);
}
/**
* Undo the zoom to display the root.
*/
public void unzoom() {
- this.zoom.undo();
+ zoom.undo();
}
/**
@@ -484,7 +494,7 @@
// undo the last zoom
unzoom();
- this.zoom.execute(dest);
+ zoom.execute(dest);
}
/**
@@ -530,7 +540,7 @@
* Constructor
*/
public Zoom() {
- this.enable = true;
+ enable = true;
}
/**
@@ -547,7 +557,7 @@
JTreeMap.this.setDisplayedRoot(dest);
- this.enable = false;
+ enable = false;
}
}
@@ -555,7 +565,7 @@
* @return Returns the keepProportion.
*/
public boolean isKeepProportion() {
- return this.keepProportion;
+ return keepProportion;
}
/**
@@ -605,10 +615,8 @@
public void undo() {
if (!this.enable) {
JTreeMap.this.setDisplayedRoot(JTreeMap.this.getRoot());
- this.enable = true;
+ enable = true;
}
}
-
}
-
}
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitBySortedWeight.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitBySortedWeight.java 2006-10-24 11:38:30 UTC (rev 65)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitBySortedWeight.java 2006-10-24 15:37:27 UTC (rev 66)
@@ -1,6 +1,5 @@
package net.sf.jtreemap.swing;
-import java.util.Iterator;
import java.util.Vector;
/**
@@ -25,46 +24,11 @@
@Override
public void splitElements(final Vector<TreeMapNode> v, final Vector<TreeMapNode> v1, final Vector<TreeMapNode> v2) {
final Vector<TreeMapNode> vClone = new Vector<TreeMapNode>(v);
- double memWeight = 0.0;
final double sumWeight = sumWeight(v);
- double elemWeight = 0.0;
sortVector(vClone);
- for (final Iterator<TreeMapNode> i = vClone.iterator(); i.hasNext();) {
- TreeMapNode tmn = i.next();
- elemWeight = tmn.getWeight();
- // if adding the current element pass the middle of total weight
- if (memWeight + elemWeight >= sumWeight / 2) {
- // we look at the finest split (the nearest of the middle of
- // weight)
- if (((sumWeight / 2) - memWeight) > ((memWeight + elemWeight) - (sumWeight / 2))) {
- // if it is after the add, we add the element to the first
- // Vector
- memWeight += elemWeight;
- v1.addElement(tmn);
- } else {
- // we must have at least 1 element in the first vector
- if (v1.isEmpty()) {
- v1.addElement(tmn);
- } else {
- // if it is before the add, we add the element to the
- // second Vector
- v2.addElement(tmn);
- }
- }
- // then we fill the second Vector qith the rest of elements
- while (i.hasNext()) {
- tmn = i.next();
- v2.addElement(tmn);
- }
- } else {
- // we add in the first vector while we don't reach the middle of
- // weight
- memWeight += elemWeight;
- v1.addElement(tmn);
- }
- }
+ workOutWeight(v1, v2, vClone, sumWeight);
}
}
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitByWeight.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitByWeight.java 2006-10-24 11:38:30 UTC (rev 65)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitByWeight.java 2006-10-24 15:37:27 UTC (rev 66)
@@ -1,6 +1,5 @@
package net.sf.jtreemap.swing;
-import java.util.Iterator;
import java.util.Vector;
/**
@@ -18,44 +17,29 @@
@Override
public void splitElements(final Vector<TreeMapNode> v, final Vector<TreeMapNode> v1, final Vector<TreeMapNode> v2) {
- double memWeight = 0.0;
final double sumWeight = sumWeight(v);
- double elemWeight = 0.0;
- for (final Iterator<TreeMapNode> i = v.iterator(); i.hasNext();) {
- TreeMapNode tmn = i.next();
- elemWeight = tmn.getWeight();
- // if adding the current element pass the middle of total weight
- if (memWeight + elemWeight >= sumWeight / 2) {
- // we look at the finest split (the nearest of the middle of
- // weight)
- if (((sumWeight / 2) - memWeight) > ((memWeight + elemWeight) - (sumWeight / 2))) {
- // if it is after the add, we add the element to the first
- // Vector
- memWeight += elemWeight;
- v1.addElement(tmn);
- } else {
- // we must have at least 1 element in the first vector
- if (v1.isEmpty()) {
- v1.addElement(tmn);
- } else {
- // if it is before the add, we add the element to the
- // second Vector
- v2.addElement(tmn);
- }
- }
- // then we fill the second Vector qith the rest of elements
- while (i.hasNext()) {
- tmn = i.next();
- v2.addElement(tmn);
- }
- } else {
- // we add in the first vector while we don't reach the middle of
- // weight
- memWeight += elemWeight;
- v1.addElement(tmn);
- }
- }
+ workOutWeight(v, v1, v2, sumWeight);
}
+ /*
+ * private double workoutWeight(final Vector<TreeMapNode> v, final Vector<TreeMapNode>
+ * v1, final Vector<TreeMapNode> v2, double memWeight, final double
+ * sumWeight) { double elemWeight; for (final Iterator<TreeMapNode> i =
+ * v.iterator(); i.hasNext();) { TreeMapNode tmn = i.next(); elemWeight =
+ * tmn.getWeight(); // if adding the current element pass the middle of
+ * total weight if (memWeight + elemWeight >= sumWeight / 2) { // we look at
+ * the finest split (the nearest of the middle of // weight) if (((sumWeight /
+ * 2) - memWeight) > ((memWeight + elemWeight) - (sumWeight / 2))) { // if
+ * it is after the add, we add the element to the first // Vector memWeight +=
+ * elemWeight; v1.addElement(tmn); } else { // we must have at least 1
+ * element in the first vector if (v1.isEmpty()) { v1.addElement(tmn); }
+ * else { // if it is before the add, we add the element to the // second
+ * Vector v2.addElement(tmn); } } // then we fill the second Vector qith the
+ * rest of elements while (i.hasNext()) { tmn = i.next();
+ * v2.addElement(tmn); } } else { // we add in the first vector while we
+ * don't reach the middle of // weight memWeight += elemWeight;
+ * v1.addElement(tmn); } } return memWeight; }
+ *
+ */
}
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitSquarified.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitSquarified.java 2006-10-24 11:38:30 UTC (rev 65)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitSquarified.java 2006-10-24 15:37:27 UTC (rev 66)
@@ -16,12 +16,26 @@
*/
private static final long serialVersionUID = 1711898915283018450L;
- private int w1, h1;
+ private int w1;
- private int x, y, w, h;
+ private int h1;
- private int x2, y2, w2, h2;
+ private int x;
+ private int y;
+
+ private int w;
+
+ private int h;
+
+ private int x2;
+
+ private int y2;
+
+ private int w2;
+
+ private int h2;
+
@Override
public void splitElements(final Vector<TreeMapNode> v, final Vector<TreeMapNode> v1, final Vector<TreeMapNode> v2) {
int mid = 0;
@@ -106,13 +120,13 @@
splitElements(vClone, v1, v2);
// before the recurence, we have to "save" the values for the 2nd
// Vector
- final int x2 = this.x2;
- final int y2 = this.y2;
- final int w2 = this.w2;
- final int h2 = this.h2;
+ final int prevX2 = this.x2;
+ final int prevY2 = this.y2;
+ final int prevW2 = this.w2;
+ final int prevH2 = this.h2;
SplitBySlice.splitInSlice(x0, y0, this.w1, this.h1, v1, sumWeight(v1));
calculateChildren(v1);
- calculatePositionsRec(x2, y2, w2, h2, sumWeight(v2), v2);
+ calculatePositionsRec(prevX2, prevY2, prevW2, prevH2, sumWeight(v2), v2);
}
}
@@ -133,16 +147,16 @@
if (node.isLeaf()) {
node.setX(node.getX() + TreeMapNode.getBorder());
node.setY(node.getY() + TreeMapNode.getBorder());
- int w = node.getWidth() - TreeMapNode.getBorder();
- if (w < 0) {
- w = 0;
+ int width = node.getWidth() - TreeMapNode.getBorder();
+ if (width < 0) {
+ width = 0;
}
- int h = node.getHeight() - TreeMapNode.getBorder();
- if (h < 0) {
- h = 0;
+ int height = node.getHeight() - TreeMapNode.getBorder();
+ if (height < 0) {
+ height = 0;
}
- node.setHeight(h);
- node.setWidth(w);
+ node.setHeight(height);
+ node.setWidth(width);
} else {
// if this is not a leaf, calculation for the children
int bSub;
@@ -154,17 +168,17 @@
bSub = 0;
}
- int w = node.getWidth() - bSub;
- if (w < 0) {
- w = 0;
+ int width = node.getWidth() - bSub;
+ if (width < 0) {
+ width = 0;
}
- int h = node.getHeight() - bSub;
- if (h < 0) {
- h = 0;
+ int height = node.getHeight() - bSub;
+ if (height < 0) {
+ height = 0;
}
TreeMapNode.setBorder(TreeMapNode.getBorder() - bSub);
- calculatePositionsRec(node.getX() + bSub, node.getY() + bSub, w, h, node.getWeight(), node.getChildren());
+ calculatePositionsRec(node.getX() + bSub, node.getY() + bSub, width, height, node.getWeight(), node.getChildren());
TreeMapNode.setBorder(TreeMapNode.getBorder() + bSub);
}
@@ -172,11 +186,11 @@
}
private double normAspect(final double big, final double small, final double a, final double b) {
- final double x = aspect(big, small, a, b);
- if (x < 1) {
- return 1 / x;
+ final double xCalc = aspect(big, small, a, b);
+ if (xCalc < 1) {
+ return 1 / xCalc;
}
- return x;
+ return xCalc;
}
}
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitStrategy.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitStrategy.java 2006-10-24 11:38:30 UTC (rev 65)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitStrategy.java 2006-10-24 15:37:27 UTC (rev 66)
@@ -1,6 +1,7 @@
package net.sf.jtreemap.swing;
import java.io.Serializable;
+import java.util.Iterator;
import java.util.Vector;
/**
@@ -112,13 +113,18 @@
// we split the Vector according to the selected strategy
final Vector<TreeMapNode> v1 = new Vector<TreeMapNode>();
final Vector<TreeMapNode> v2 = new Vector<TreeMapNode>();
- double weight1, weight2; // poids des 2 vecteurs
+ double weight1;
+ double weight2; // poids des 2 vecteurs
this.splitElem...
[truncated message content] |
|
From: <be...@us...> - 2006-10-24 16:42:00
|
Revision: 71
http://svn.sourceforge.net/jtreemap/?rev=71&view=rev
Author: benoitx
Date: 2006-10-24 09:41:47 -0700 (Tue, 24 Oct 2006)
Log Message:
-----------
Moved remotely
Added Paths:
-----------
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/provider/icons/
Removed Paths:
-------------
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/icons/
Copied: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/provider/icons (from rev 70, trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/icons)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <be...@us...> - 2006-10-24 22:19:35
|
Revision: 74
http://svn.sourceforge.net/jtreemap/?rev=74&view=rev
Author: benoitx
Date: 2006-10-24 15:19:05 -0700 (Tue, 24 Oct 2006)
Log Message:
-----------
Added Header & Footer
Modified Paths:
--------------
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/ColorProvider.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTip.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTipBuilder.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultValue.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/IToolTipBuilder.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/JTreeMap.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitByNumber.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitBySlice.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitBySortedWeight.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitByWeight.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitSquarified.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitStrategy.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/TreeMapNode.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/TreeMapNodeBuilder.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/UniqueColorProvider.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/Value.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/ValuePercent.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/DemoUtil.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/JTreeMapAppletExample.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/JTreeMapExample.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/provider/HSBTreeMapColorProvider.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/provider/RandomColorProvider.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/provider/RedGreenColorProvider.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/provider/ZoomPopupMenu.java
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/ColorProvider.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/ColorProvider.java 2006-10-24 19:51:07 UTC (rev 73)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/ColorProvider.java 2006-10-24 22:19:05 UTC (rev 74)
@@ -1,5 +1,5 @@
/*
- * ObjectLab, http://www.objectlab.co.uk/open is sponsoring the ObjectLab Kit.
+ * ObjectLab, http://www.objectlab.co.uk/open is supporting JTreeMap.
*
* Based in London, we are world leaders in the design and development
* of bespoke applications for the securities financing markets.
@@ -62,3 +62,19 @@
*/
public abstract JPanel getLegendPanel();
}
+/*
+ * ObjectLab is supporing JTreeMap
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *
+ * <a href="http://www.objectlab.co.uk/open">Click here to learn more about us</a>
+ * ___ _ _ _ _ _
+ * / _ \| |__ (_) ___ ___| |_| | __ _| |__
+ * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
+ * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
+ * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
+ * |__/
+ *
+ * www.ObjectLab.co.uk
+ */
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTip.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTip.java 2006-10-24 19:51:07 UTC (rev 73)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTip.java 2006-10-24 22:19:05 UTC (rev 74)
@@ -1,5 +1,34 @@
/*
- * Created on 28 sept. 2005
+ * ObjectLab, http://www.objectlab.co.uk/open is supporting JTreeMap.
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *
+ * <a href="http://www.objectlab.co.uk/open">Click here to learn more</a>
+ * ___ _ _ _ _ _
+ * / _ \| |__ (_) ___ ___| |_| | __ _| |__
+ * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
+ * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
+ * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
+ * |__/
+ *
+ * www.ObjectLab.co.uk
+ *
+ * $Id$
+ *
+ * Copyright 2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
*/
package net.sf.jtreemap.swing;
@@ -61,5 +90,20 @@
g.drawString(this.jTreeMap.getActiveLeaf().getLabelValue(), TOOLTIP_OFFSET, this.getHeight() - TOOLTIP_OFFSET);
}
}
-
}
+/*
+ * ObjectLab is supporing JTreeMap
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *
+ * <a href="http://www.objectlab.co.uk/open">Click here to learn more about us</a>
+ * ___ _ _ _ _ _
+ * / _ \| |__ (_) ___ ___| |_| | __ _| |__
+ * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
+ * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
+ * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
+ * |__/
+ *
+ * www.ObjectLab.co.uk
+ */
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTipBuilder.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTipBuilder.java 2006-10-24 19:51:07 UTC (rev 73)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTipBuilder.java 2006-10-24 22:19:05 UTC (rev 74)
@@ -1,5 +1,34 @@
-/**
+/*
+ * ObjectLab, http://www.objectlab.co.uk/open is supporting JTreeMap.
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *
+ * <a href="http://www.objectlab.co.uk/open">Click here to learn more</a>
+ * ___ _ _ _ _ _
+ * / _ \| |__ (_) ___ ___| |_| | __ _| |__
+ * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
+ * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
+ * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
+ * |__/
*
+ * www.ObjectLab.co.uk
+ *
+ * $Id$
+ *
+ * Copyright 2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
*/
package net.sf.jtreemap.swing;
@@ -46,3 +75,19 @@
return instance;
}
}
+/*
+ * ObjectLab is supporing JTreeMap
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *
+ * <a href="http://www.objectlab.co.uk/open">Click here to learn more about us</a>
+ * ___ _ _ _ _ _
+ * / _ \| |__ (_) ___ ___| |_| | __ _| |__
+ * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
+ * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
+ * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
+ * |__/
+ *
+ * www.ObjectLab.co.uk
+ */
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultValue.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultValue.java 2006-10-24 19:51:07 UTC (rev 73)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultValue.java 2006-10-24 22:19:05 UTC (rev 74)
@@ -1,5 +1,34 @@
/*
- * Created on 10 oct. 2005
+ * ObjectLab, http://www.objectlab.co.uk/open is supporting JTreeMap.
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *
+ * <a href="http://www.objectlab.co.uk/open">Click here to learn more</a>
+ * ___ _ _ _ _ _
+ * / _ \| |__ (_) ___ ___| |_| | __ _| |__
+ * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
+ * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
+ * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
+ * |__/
+ *
+ * www.ObjectLab.co.uk
+ *
+ * $Id$
+ *
+ * Copyright 2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
*/
package net.sf.jtreemap.swing;
@@ -74,5 +103,20 @@
// ignore
}
-
}
+/*
+ * ObjectLab is supporing JTreeMap
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *
+ * <a href="http://www.objectlab.co.uk/open">Click here to learn more about us</a>
+ * ___ _ _ _ _ _
+ * / _ \| |__ (_) ___ ___| |_| | __ _| |__
+ * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
+ * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
+ * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
+ * |__/
+ *
+ * www.ObjectLab.co.uk
+ */
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/IToolTipBuilder.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/IToolTipBuilder.java 2006-10-24 19:51:07 UTC (rev 73)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/IToolTipBuilder.java 2006-10-24 22:19:05 UTC (rev 74)
@@ -1,6 +1,34 @@
/*
- * Created on 6 mars 2006
+ * ObjectLab, http://www.objectlab.co.uk/open is supporting JTreeMap.
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *
+ * <a href="http://www.objectlab.co.uk/open">Click here to learn more</a>
+ * ___ _ _ _ _ _
+ * / _ \| |__ (_) ___ ___| |_| | __ _| |__
+ * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
+ * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
+ * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
+ * |__/
*
+ * www.ObjectLab.co.uk
+ *
+ * $Id$
+ *
+ * Copyright 2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
*/
package net.sf.jtreemap.swing;
@@ -21,4 +49,20 @@
* @return the instance of the JToolTip
*/
JToolTip getToolTip();
-}
\ No newline at end of file
+}
+/*
+ * ObjectLab is supporing JTreeMap
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *
+ * <a href="http://www.objectlab.co.uk/open">Click here to learn more about us</a>
+ * ___ _ _ _ _ _
+ * / _ \| |__ (_) ___ ___| |_| | __ _| |__
+ * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
+ * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
+ * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
+ * |__/
+ *
+ * www.ObjectLab.co.uk
+ */
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/JTreeMap.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/JTreeMap.java 2006-10-24 19:51:07 UTC (rev 73)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/JTreeMap.java 2006-10-24 22:19:05 UTC (rev 74)
@@ -1,3 +1,35 @@
+/*
+ * ObjectLab, http://www.objectlab.co.uk/open is supporting JTreeMap.
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *
+ * <a href="http://www.objectlab.co.uk/open">Click here to learn more</a>
+ * ___ _ _ _ _ _
+ * / _ \| |__ (_) ___ ___| |_| | __ _| |__
+ * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
+ * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
+ * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
+ * |__/
+ *
+ * www.ObjectLab.co.uk
+ *
+ * $Id$
+ *
+ * Copyright 2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package net.sf.jtreemap.swing;
import java.awt.Color;
@@ -620,3 +652,19 @@
}
}
}
+/*
+ * ObjectLab is supporing JTreeMap
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *
+ * <a href="http://www.objectlab.co.uk/open">Click here to learn more about us</a>
+ * ___ _ _ _ _ _
+ * / _ \| |__ (_) ___ ___| |_| | __ _| |__
+ * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
+ * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
+ * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
+ * |__/
+ *
+ * www.ObjectLab.co.uk
+ */
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitByNumber.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitByNumber.java 2006-10-24 19:51:07 UTC (rev 73)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitByNumber.java 2006-10-24 22:19:05 UTC (rev 74)
@@ -1,3 +1,35 @@
+/*
+ * ObjectLab, http://www.objectlab.co.uk/open is supporting JTreeMap.
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *
+ * <a href="http://www.objectlab.co.uk/open">Click here to learn more</a>
+ * ___ _ _ _ _ _
+ * / _ \| |__ (_) ___ ___| |_| | __ _| |__
+ * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
+ * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
+ * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
+ * |__/
+ *
+ * www.ObjectLab.co.uk
+ *
+ * $Id$
+ *
+ * Copyright 2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package net.sf.jtreemap.swing;
import java.util.Vector;
@@ -42,5 +74,20 @@
}
return weight;
}
-
}
+/*
+ * ObjectLab is supporing JTreeMap
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *
+ * <a href="http://www.objectlab.co.uk/open">Click here to learn more about us</a>
+ * ___ _ _ _ _ _
+ * / _ \| |__ (_) ___ ___| |_| | __ _| |__
+ * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
+ * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
+ * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
+ * |__/
+ *
+ * www.ObjectLab.co.uk
+ */
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitBySlice.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitBySlice.java 2006-10-24 19:51:07 UTC (rev 73)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitBySlice.java 2006-10-24 22:19:05 UTC (rev 74)
@@ -1,5 +1,34 @@
/*
- * Created on 3 nov. 2005
+ * ObjectLab, http://www.objectlab.co.uk/open is supporting JTreeMap.
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *
+ * <a href="http://www.objectlab.co.uk/open">Click here to learn more</a>
+ * ___ _ _ _ _ _
+ * / _ \| |__ (_) ___ ___| |_| | __ _| |__
+ * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
+ * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
+ * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
+ * |__/
+ *
+ * www.ObjectLab.co.uk
+ *
+ * $Id$
+ *
+ * Copyright 2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
*/
package net.sf.jtreemap.swing;
@@ -117,3 +146,19 @@
}
}
+/*
+ * ObjectLab is supporing JTreeMap
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *
+ * <a href="http://www.objectlab.co.uk/open">Click here to learn more about us</a>
+ * ___ _ _ _ _ _
+ * / _ \| |__ (_) ___ ___| |_| | __ _| |__
+ * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
+ * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
+ * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
+ * |__/
+ *
+ * www.ObjectLab.co.uk
+ */
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitBySortedWeight.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitBySortedWeight.java 2006-10-24 19:51:07 UTC (rev 73)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitBySortedWeight.java 2006-10-24 22:19:05 UTC (rev 74)
@@ -1,3 +1,35 @@
+/*
+ * ObjectLab, http://www.objectlab.co.uk/open is supporting JTreeMap.
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *
+ * <a href="http://www.objectlab.co.uk/open">Click here to learn more</a>
+ * ___ _ _ _ _ _
+ * / _ \| |__ (_) ___ ___| |_| | __ _| |__
+ * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
+ * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
+ * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
+ * |__/
+ *
+ * www.ObjectLab.co.uk
+ *
+ * $Id$
+ *
+ * Copyright 2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package net.sf.jtreemap.swing;
import java.util.Vector;
@@ -30,5 +62,20 @@
workOutWeight(v1, v2, vClone, sumWeight);
}
-
}
+/*
+ * ObjectLab is supporing JTreeMap
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *
+ * <a href="http://www.objectlab.co.uk/open">Click here to learn more about us</a>
+ * ___ _ _ _ _ _
+ * / _ \| |__ (_) ___ ___| |_| | __ _| |__
+ * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
+ * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
+ * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
+ * |__/
+ *
+ * www.ObjectLab.co.uk
+ */
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitByWeight.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitByWeight.java 2006-10-24 19:51:07 UTC (rev 73)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitByWeight.java 2006-10-24 22:19:05 UTC (rev 74)
@@ -1,3 +1,35 @@
+/*
+ * ObjectLab, http://www.objectlab.co.uk/open is supporting JTreeMap.
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *
+ * <a href="http://www.objectlab.co.uk/open">Click here to learn more</a>
+ * ___ _ _ _ _ _
+ * / _ \| |__ (_) ___ ___| |_| | __ _| |__
+ * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
+ * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
+ * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
+ * |__/
+ *
+ * www.ObjectLab.co.uk
+ *
+ * $Id$
+ *
+ * Copyright 2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package net.sf.jtreemap.swing;
import java.util.Vector;
@@ -21,25 +53,20 @@
workOutWeight(v, v1, v2, sumWeight);
}
-
- /*
- * private double workoutWeight(final Vector<TreeMapNode> v, final Vector<TreeMapNode>
- * v1, final Vector<TreeMapNode> v2, double memWeight, final double
- * sumWeight) { double elemWeight; for (final Iterator<TreeMapNode> i =
- * v.iterator(); i.hasNext();) { TreeMapNode tmn = i.next(); elemWeight =
- * tmn.getWeight(); // if adding the current element pass the middle of
- * total weight if (memWeight + elemWeight >= sumWeight / 2) { // we look at
- * the finest split (the nearest of the middle of // weight) if (((sumWeight /
- * 2) - memWeight) > ((memWeight + elemWeight) - (sumWeight / 2))) { // if
- * it is after the add, we add the element to the first // Vector memWeight +=
- * elemWeight; v1.addElement(tmn); } else { // we must have at least 1
- * element in the first vector if (v1.isEmpty()) { v1.addElement(tmn); }
- * else { // if it is before the add, we add the element to the // second
- * Vector v2.addElement(tmn); } } // then we fill the second Vector qith the
- * rest of elements while (i.hasNext()) { tmn = i.next();
- * v2.addElement(tmn); } } else { // we add in the first vector while we
- * don't reach the middle of // weight memWeight += elemWeight;
- * v1.addElement(tmn); } } return memWeight; }
- *
- */
}
+/*
+ * ObjectLab is supporing JTreeMap
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *
+ * <a href="http://www.objectlab.co.uk/open">Click here to learn more about us</a>
+ * ___ _ _ _ _ _
+ * / _ \| |__ (_) ___ ___| |_| | __ _| |__
+ * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
+ * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
+ * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
+ * |__/
+ *
+ * www.ObjectLab.co.uk
+ */
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitSquarified.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitSquarified.java 2006-10-24 19:51:07 UTC (rev 73)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitSquarified.java 2006-10-24 22:19:05 UTC (rev 74)
@@ -1,5 +1,34 @@
/*
- * Created on 3 nov. 2005
+ * ObjectLab, http://www.objectlab.co.uk/open is supporting JTreeMap.
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *
+ * <a href="http://www.objectlab.co.uk/open">Click here to learn more</a>
+ * ___ _ _ _ _ _
+ * / _ \| |__ (_) ___ ___| |_| | __ _| |__
+ * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
+ * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
+ * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
+ * |__/
+ *
+ * www.ObjectLab.co.uk
+ *
+ * $Id$
+ *
+ * Copyright 2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
*/
package net.sf.jtreemap.swing;
@@ -192,5 +221,20 @@
}
return xCalc;
}
-
}
+/*
+ * ObjectLab is supporing JTreeMap
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *
+ * <a href="http://www.objectlab.co.uk/open">Click here to learn more about us</a>
+ * ___ _ _ _ _ _
+ * / _ \| |__ (_) ___ ___| |_| | __ _| |__
+ * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
+ * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
+ * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
+ * |__/
+ *
+ * www.ObjectLab.co.uk
+ */
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitStrategy.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitStrategy.java 2006-10-24 19:51:07 UTC (rev 73)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitStrategy.java 2006-10-24 22:19:05 UTC (rev 74)
@@ -1,3 +1,35 @@
+/*
+ * ObjectLab, http://www.objectlab.co.uk/open is supporting JTreeMap.
+ *
+ * Based in London, we are world leaders in the design and development
+ * of bespoke applications for the securities financing markets.
+ *...
[truncated message content] |
|
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.
|
|
From: <eki...@us...> - 2006-12-12 22:41:53
|
Revision: 118
http://svn.sourceforge.net/jtreemap/?rev=118&view=rev
Author: ekingulen
Date: 2006-12-12 14:41:48 -0800 (Tue, 12 Dec 2006)
Log Message:
-----------
- applet reload issue fixed.
Modified Paths:
--------------
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTip.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/JTreeMap.java
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/JTreeMapAppletExample.java
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTip.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTip.java 2006-12-12 12:56:53 UTC (rev 117)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultToolTip.java 2006-12-12 22:41:48 UTC (rev 118)
@@ -36,7 +36,6 @@
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
-import java.awt.Graphics2D;
import javax.swing.JToolTip;
@@ -91,7 +90,7 @@
@Override
public void paint(final Graphics g) {
if (this.jTreeMap.getActiveLeaf() != null) {
- Graphics2D g2D = (Graphics2D) g;
+ Graphics g2D = (Graphics) g;
g2D.setColor(Color.YELLOW);
g2D.fill3DRect(0, 0, this.getWidth(), this.getHeight(), true);
g2D.setColor(Color.black);
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/JTreeMap.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/JTreeMap.java 2006-12-12 12:56:53 UTC (rev 117)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/JTreeMap.java 2006-12-12 22:41:48 UTC (rev 118)
@@ -585,12 +585,6 @@
setActiveLeaf(t);
repaint();
}
- if (t != null) {
- setToolTipText(t.getLabel() + " " + t.getValue().getValue());
-// setToolTipText(t.getLabel() + " " + t.getValue().getValue() + ", Weight = " + t.getWeight());
- } else {
- setToolTipText(null);
- }
}
}
}
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-12-12 12:56:53 UTC (rev 117)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/JTreeMapAppletExample.java 2006-12-12 22:41:48 UTC (rev 118)
@@ -126,14 +126,23 @@
super();
}
- /*
- * (non-Javadoc)
+ /**
*
- * @see java.applet.Applet#start()
*/
- @Override
- public void start() {
- super.start();
+ private void initGUI() {
+ // 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"));
+ showTree = "true".equalsIgnoreCase(getParameter("viewTree"));
+ showWeight = "true".equalsIgnoreCase(getParameter("showWeight"));
+ weightPrefix = getParameter("weightPrefix");
+ valuePrefix = getParameter("valuePrefix");
+ if (showTM3CTonf) {
+ addPanelEast(getJContentPane());
+ }
+
final String dataFile = getParameter("dataFile");
final String dataFileType = getParameter("dataFileType");
TreeMapNode root = null;
@@ -340,18 +349,7 @@
*/
@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);
- this.setContentPane(getJContentPane());
- showTM3CTonf = "true".equalsIgnoreCase(getParameter("showTM3Conf"));
- showTree = "true".equalsIgnoreCase(getParameter("viewTree"));
- showWeight = "true".equalsIgnoreCase(getParameter("showWeight"));
- weightPrefix = getParameter("weightPrefix");
- valuePrefix = getParameter("valuePrefix");
- if (showTM3CTonf) {
- addPanelEast(getJContentPane());
- }
+ initGUI();
}
/**
@@ -369,9 +367,12 @@
}
@Override
- public void stop() {
- jTreeMap.createToolTip().setVisible(false);
+ public void destroy() {
+ super.destroy();
+ this.jContentPane.removeAll();
}
+
+
}
/*
* ObjectLab is supporing JTreeMap
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|