|
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.splitElements(v, v1, v2);
weight1 = this.sumWeight(v1);
weight2 = this.sumWeight(v2);
- int w1, w2, h1, h2;
- int x2, y2;
+ int w1;
+ int w2;
+ int h1;
+ int h2;
+ int x2;
+ int y2;
// if width is greater than height, we split the width
if (w0 > h0) {
w1 = (int) (w0 * weight1 / weight0);
@@ -163,4 +169,43 @@
}
+ protected void workOutWeight(final Vector<TreeMapNode> v1, final Vector<TreeMapNode> v2, final Vector<TreeMapNode> vClone,
+ final double sumWeight) {
+ double memWeight = 0.0;
+ double elemWeight = 0.0;
+ 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);
+ }
+ }
+ }
}
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/TreeMapNode.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/TreeMapNode.java 2006-10-24 11:38:30 UTC (rev 65)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/TreeMapNode.java 2006-10-24 15:37:27 UTC (rev 66)
@@ -97,25 +97,25 @@
* get the active leaf.<BR>
* null if the passed position is not in this tree.
*
- * @param x
+ * @param xParam
* x-coordinate
- * @param y
+ * @param yParam
* y-coordinate
* @return active leaf
*/
- public TreeMapNode getActiveLeaf(final int x, final int y) {
+ public TreeMapNode getActiveLeaf(final int xParam, final int yParam) {
if (this.isLeaf()) {
- if ((x >= this.getX()) && (x <= this.getX() + this.getWidth()) && (y >= this.getY())
- && (y <= this.getY() + this.getHeight())) {
+ if ((xParam >= this.getX()) && (xParam <= this.getX() + this.getWidth()) && (yParam >= this.getY())
+ && (yParam <= this.getY() + this.getHeight())) {
return this;
}
} else {
for (final Enumeration e = this.children(); e.hasMoreElements();) {
final TreeMapNode node = (TreeMapNode) (e.nextElement());
- if ((x >= node.getX()) && (x <= node.getX() + node.getWidth()) && (y >= node.getY())
- && (y <= node.getY() + node.getHeight())) {
- return node.getActiveLeaf(x, y);
+ if ((xParam >= node.getX()) && (xParam <= node.getX() + node.getWidth()) && (yParam >= node.getY())
+ && (yParam <= node.getY() + node.getHeight())) {
+ return node.getActiveLeaf(xParam, yParam);
}
}
}
@@ -126,18 +126,18 @@
* get the first child which fits the position.<BR>
* null if the passed position is not in this tree.
*
- * @param x
+ * @param xParam
* x-coordinate
- * @param y
+ * @param yParam
* y-coordinate
* @return the first child which fits the position.
*/
- public TreeMapNode getChild(final int x, final int y) {
+ public TreeMapNode getChild(final int xParam, final int yParam) {
if (!this.isLeaf()) {
for (final Enumeration e = this.children(); e.hasMoreElements();) {
final TreeMapNode node = (TreeMapNode) (e.nextElement());
- if ((x >= node.getX()) && (x <= node.getX() + node.getWidth()) && (y >= node.getY())
- && (y <= node.getY() + node.getHeight())) {
+ if ((xParam >= node.getX()) && (xParam <= node.getX() + node.getWidth()) && (yParam >= node.getY())
+ && (yParam <= node.getY() + node.getHeight())) {
return node;
}
}
@@ -240,20 +240,20 @@
/**
* set the position and the size.
*
- * @param x
+ * @param xParam
* x-coordinate
- * @param y
+ * @param yParam
* y-coordinate
- * @param width
+ * @param widthParam
* the new width
- * @param height
+ * @param heightParam
* the new height
*/
- public void setDimension(final int x, final int y, final int width, final int height) {
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
+ public void setDimension(final int xParam, final int yParam, final int widthParam, final int heightParam) {
+ this.x = xParam;
+ this.y = yParam;
+ this.width = widthParam;
+ this.height = heightParam;
}
/**
@@ -279,27 +279,27 @@
/**
* set the position.
*
- * @param x
+ * @param xParam
* x-coordinate
- * @param y
+ * @param yParam
* y-coordinate
*/
- public void setPosition(final int x, final int y) {
- this.x = x;
- this.y = y;
+ public void setPosition(final int xParam, final int yParam) {
+ this.x = xParam;
+ this.y = yParam;
}
/**
* set size.
*
- * @param width
+ * @param widthParam
* the new width
- * @param height
+ * @param heightParam
* the new height
*/
- public void setSize(final int width, final int height) {
- this.width = width;
- this.height = height;
+ public void setSize(final int widthParam, final int heightParam) {
+ this.width = widthParam;
+ this.height = heightParam;
}
/**
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/TreeMapNodeBuilder.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/TreeMapNodeBuilder.java 2006-10-24 11:38:30 UTC (rev 65)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/TreeMapNodeBuilder.java 2006-10-24 15:37:27 UTC (rev 66)
@@ -13,6 +13,7 @@
*
*/
private static final long serialVersionUID = -1340499387405510692L;
+
private TreeMapNode root;
/**
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/UniqueColorProvider.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/UniqueColorProvider.java 2006-10-24 11:38:30 UTC (rev 65)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/UniqueColorProvider.java 2006-10-24 15:37:27 UTC (rev 66)
@@ -22,7 +22,7 @@
*/
private static final long serialVersionUID = -7571926934516139432L;
- private final static Color defaultColor = new Color(153, 153, 51);
+ private static final Color DEFAULT_COLOR = new Color(153, 153, 51);
private Color color;
@@ -32,7 +32,7 @@
* Constructor.
*/
public UniqueColorProvider() {
- this.color = defaultColor;
+ this.color = DEFAULT_COLOR;
}
/**
@@ -74,6 +74,14 @@
* @author Laurent Dutheil
*/
private static class Legend extends JPanel {
+ private static final int LEGEND_Y_POS = 20;
+
+ private static final int LEGEND_X_POS = 20;
+
+ private static final int LEGEND_HEIGHT = 40;
+
+ private static final int LEGEND_WIDTH = 100;
+
private static final long serialVersionUID = -8046211081305644785L;
private static final String TEXT = "Unique Color Provider";
@@ -82,14 +90,14 @@
* Constructor.
*/
public Legend() {
- this.setPreferredSize(new java.awt.Dimension(100, 40));
+ this.setPreferredSize(new java.awt.Dimension(LEGEND_WIDTH, LEGEND_HEIGHT));
}
@Override
public void paint(final Graphics g) {
g.setColor(Color.black);
- g.drawString(Legend.TEXT, 20, 20);
+ g.drawString(Legend.TEXT, LEGEND_X_POS, LEGEND_Y_POS);
}
}
}
Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/Value.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/Value.java 2006-10-24 11:38:30 UTC (rev 65)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/Value.java 2006-10-24 15:37:27 UTC (rev 66)
@@ -9,6 +9,9 @@
*/
public abstract class Value implements Comparable, Serializable {
+ private static final int SHIFT = 32;
+ private static final int PRIME = 31;
+
/**
* get the double value.
*
@@ -41,11 +44,10 @@
@Override
public int hashCode() {
- final int PRIME = 31;
int result = super.hashCode();
long temp;
temp = Double.doubleToLongBits(getValue());
- result = PRIME * result + (int) (temp ^ (temp >>> 32));
+ result = PRIME * result + (int) (temp ^ (temp >>> SHIFT));
return result;
}
Added: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/ValuePercent.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/ValuePercent.java (rev 0)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/ValuePercent.java 2006-10-24 15:37:27 UTC (rev 66)
@@ -0,0 +1,66 @@
+package net.sf.jtreemap.swing;
+
+import java.text.NumberFormat;
+
+
+/**
+ * class who can display the values of elements of a JTreeMap with pourcent
+ *
+ * @author Laurent Dutheil
+ */
+
+public class ValuePercent extends Value {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1087258219010392928L;
+
+ private double value;
+
+ private NumberFormat nf;
+
+ /**
+ * Constructor of ValuePercent
+ */
+ public ValuePercent() {
+ this.nf = NumberFormat.getInstance();
+ this.nf.setMaximumFractionDigits(2);
+ this.nf.setMinimumFractionDigits(2);
+ this.nf.setMinimumIntegerDigits(1);
+ }
+
+ /**
+ * Constructor of ValuePercent
+ *
+ * @param value
+ * double value
+ */
+ public ValuePercent(final double value) {
+ this();
+ this.value = value;
+ }
+
+ @Override
+ public void setValue(final double d) {
+ this.value = d;
+ }
+
+ @Override
+ public void setLabel(final String stLibelle) {
+ // ignore
+ }
+
+ @Override
+ public double getValue() {
+ return this.value;
+ }
+
+ @Override
+ public String getLabel() {
+ if (this.value >= 0) {
+ return "+" + this.nf.format(this.value) + " %";
+ }
+ return this.nf.format(this.value) + " %";
+ }
+
+}
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-10-24 11:38:30 UTC (rev 65)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/BuilderTM3.java 2006-10-24 15:37:27 UTC (rev 66)
@@ -56,11 +56,11 @@
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("MM/dd/yyyy");
- private static final LinkedList<String> fieldNames = new LinkedList<String>();
+ private static final LinkedList<String> FIELD_NAMES = new LinkedList<String>();
- private static final LinkedList<String> fieldTypes = new LinkedList<String>();
+ private static final LinkedList<String> FIELD_TYPES = new LinkedList<String>();
- private static final HashMap<TreeMapNode, HashMap<String, Object>> values = new HashMap<TreeMapNode, HashMap<String, Object>>();
+ private static final HashMap<TreeMapNode, HashMap<String, Object>> VALUES = new HashMap<TreeMapNode, HashMap<String, Object>>();
private TreeMapNodeBuilder builder;
@@ -81,10 +81,10 @@
*/
public String[] getNumberFields() {
final TreeSet<String> result = new TreeSet<String>();
- for (int i = 0; i < fieldNames.size(); i++) {
- final String type = fieldTypes.get(i);
+ for (int i = 0; i < FIELD_NAMES.size(); i++) {
+ final String type = FIELD_TYPES.get(i);
if (INTEGER.equals(type) || FLOAT.equals(type)) {
- result.add(fieldNames.get(i));
+ result.add(FIELD_NAMES.get(i));
}
}
return result.toArray(new String[1]);
@@ -100,19 +100,19 @@
}
/**
- * Set the values of all the JTreeMapNode with the values of the fieldName.
+ * Set the VALUES of all the JTreeMapNode with the VALUES of the fieldName.
*
* @param fieldName
- * name of the field to set the values
+ * name of the field to set the VALUES
*/
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;
@@ -126,19 +126,19 @@
}
/**
- * Set the weights of all the JTreeMapNode with the values of the fieldName.
+ * Set the weights of all the JTreeMapNode with the VALUES of the fieldName.
*
* @param fieldName
* name of the field to set the weights
*/
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;
@@ -155,7 +155,7 @@
* @param st
* StringTokenizer which contains the hierarchy path
* @param mapNodeValues
- * HashMap with fields and their values
+ * HashMap with fields and their VALUES
*/
private void createNodes(final StringTokenizer st, final HashMap<String, Object> mapNodeValues) {
// read the hierarchy path
@@ -188,8 +188,8 @@
// 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);
+ // each leaf is associated to their VALUES
+ VALUES.put(leaf, mapNodeValues);
}
/**
@@ -205,32 +205,32 @@
// read the field names
line = in.readLine();
StringTokenizer st = new StringTokenizer(line, "\t");
- fieldNames.clear();
+ FIELD_NAMES.clear();
while (st.hasMoreTokens()) {
- fieldNames.add(st.nextToken());
+ FIELD_NAMES.add(st.nextToken());
}
// read the field types
line = in.readLine();
st = new StringTokenizer(line, "\t");
- fieldTypes.clear();
+ FIELD_TYPES.clear();
while (st.hasMoreTokens()) {
- fieldTypes.add(st.nextToken());
+ FIELD_TYPES.add(st.nextToken());
}
- // read the values
- values.clear();
+ // read the VALUES
+ VALUES.clear();
while ((line = in.readLine()) != null) {
st = new StringTokenizer(line, "\t");
final HashMap<String, Object> mapNodeValues = new HashMap<String, Object>();
- // the values are formated
- for (int i = 0; i < fieldNames.size(); i++) {
+ // the VALUES are formated
+ for (int i = 0; i < FIELD_NAMES.size(); i++) {
Object value;
- if (FLOAT.equals(fieldTypes.get(i))) {
+ if (FLOAT.equals(FIELD_TYPES.get(i))) {
value = new Double(Double.parseDouble(st.nextToken()));
- } else if (INTEGER.equals(fieldTypes.get(i))) {
+ } else if (INTEGER.equals(FIELD_TYPES.get(i))) {
value = new Integer(Integer.parseInt(st.nextToken()));
- } else if (DATE.equals(fieldTypes.get(i))) {
+ } else if (DATE.equals(FIELD_TYPES.get(i))) {
try {
value = DATE_FORMAT.parse(st.nextToken());
} catch (final ParseException e) {
@@ -239,7 +239,7 @@
} else {
value = st.nextToken();
}
- mapNodeValues.put(fieldNames.get(i), value);
+ mapNodeValues.put(FIELD_NAMES.get(i), value);
}
// if we have not the path (the node names of parents)
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-10-24 11:38:30 UTC (rev 65)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/BuilderXML.java 2006-10-24 15:37:27 UTC (rev 66)
@@ -11,6 +11,7 @@
import net.sf.jtreemap.swing.TreeMapNode;
import net.sf.jtreemap.swing.TreeMapNodeBuilder;
import net.sf.jtreemap.swing.Value;
+import net.sf.jtreemap.swing.ValuePercent;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -90,12 +91,10 @@
final double weight = Double.valueOf(weightString).doubleValue();
this.builder.buildLeaf(label, weight, value, tmn);
-
}
}
}
-
}
private void parse(final String stFileName) throws ParseException {
@@ -115,7 +114,5 @@
} catch (final IOException e) {
throw new ParseException("The file don't correspond to the TreeMap.dtd (" + e.getMessage() + ")", 0);
}
-
}
-
}
Added: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/DemoUtil.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/DemoUtil.java (rev 0)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/DemoUtil.java 2006-10-24 15:37:27 UTC (rev 66)
@@ -0,0 +1,163 @@
+/**
+ *
+ */
+package net.sf.jtreemap.swing.example;
+
+import net.sf.jtreemap.swing.TreeMapNode;
+import net.sf.jtreemap.swing.TreeMapNodeBuilder;
+import net.sf.jtreemap.swing.Value;
+import net.sf.jtreemap.swing.ValuePercent;
+
+/**
+ * @author xhensevb
+ *
+ */
+public final class DemoUtil {
+ private DemoUtil() {
+ }
+
+ /**
+ * This method build a default TreeMap root. <BR>
+ * This methode may be replaced by one who get the root from a servlet or a
+ * jdbc client or something else...
+ *
+ * @return the root of the TreeMap.
+ */
+ public static TreeMapNode buildDemoRoot() {
+ final TreeMapNodeBuilder builder = new TreeMapNodeBuilder();
+
+ final TreeMapNode rootNode = builder.buildBranch("Root", null);
+ final TreeMapNode tmn1 = builder.buildBranch("branch1", rootNode);
+ final TreeMapNode tmn11 = builder.buildBranch("branch11", tmn1);
+ Value value = new ValuePercent(0.45);
+ builder.buildLeaf("leaf111", 1.0, value, tmn11);
+ value = new ValuePercent(-5.0);
+ builder.buildLeaf("leaf112", 2.0, value, tmn11);
+ value = new ValuePercent(2.0);
+ builder.buildLeaf("leaf113", 0.5, value, tmn11);
+ value = new ValuePercent(2.0);
+ builder.buildLeaf("leaf114", 3.0, value, tmn11);
+ value = new ValuePercent(-5.0);
+ builder.buildLeaf("leaf115", 0.25, value, tmn11);
+ final TreeMapNode tmn12 = builder.buildBranch("branch12", tmn1);
+ value = new ValuePercent(1.0);
+ builder.buildLeaf("leaf121", 1.0, value, tmn12);
+ value = new ValuePercent(5.0);
+ builder.buildLeaf("leaf122", 2.0, value, tmn12);
+ value = new ValuePercent(2.0);
+ builder.buildLeaf("leaf123", 0.5, value, tmn12);
+ value = new ValuePercent(-2.0);
+ builder.buildLeaf("leaf124", 3.0, value, tmn12);
+ value = new ValuePercent(0.0);
+ builder.buildLeaf("leaf125", 0.25, value, tmn12);
+ final TreeMapNode tmn13 = builder.buildBranch("branch13", tmn1);
+ value = new ValuePercent(1.0);
+ builder.buildLeaf("leaf131", 1.0, value, tmn13);
+ value = new ValuePercent(5.0);
+ builder.buildLeaf("leaf132", 2.0, value, tmn13);
+ value = new ValuePercent(2.0);
+ builder.buildLeaf("leaf133", 0.5, value, tmn13);
+ value = new ValuePercent(2.0);
+ builder.buildLeaf("leaf134", 3.0, value, tmn13);
+ value = new ValuePercent(2.0);
+ builder.buildLeaf("leaf14", 3.0, value, tmn1);
+ value = new ValuePercent(-5.0);
+ builder.buildLeaf("leaf15", 2.0, value, tmn1);
+ final TreeMapNode tmn2 = builder.buildBranch("branch2", rootNode);
+ final TreeMapNode tmn21 = builder.buildBranch("branch21", tmn2);
+ value = new ValuePercent(-1.0);
+ builder.buildLeaf("leaf211", 1.0, value, tmn21);
+ value = new ValuePercent(-5.0);
+ builder.buildLeaf("leaf212", 2.0, value, tmn21);
+ value = new ValuePercent(2.0);
+ builder.buildLeaf("leaf213", 0.5, value, tmn21);
+ value = new ValuePercent(2.0);
+ builder.buildLeaf("leaf214", 3.0, value, tmn21);
+ value = new ValuePercent(5.0);
+ builder.buildLeaf("leaf215", 0.25, value, tmn21);
+ final TreeMapNode tmn22 = builder.buildBranch("branch22", tmn2);
+ value = new ValuePercent(1.0);
+ builder.buildLeaf("leaf221", 1.0, value, tmn22);
+ value = new ValuePercent(5.0);
+ builder.buildLeaf("leaf222", 2.0, value, tmn22);
+ value = new ValuePercent(2.0);
+ builder.buildLeaf("leaf223", 0.5, value, tmn22);
+ value = new ValuePercent(2.0);
+ builder.buildLeaf("leaf224", 3.0, value, tmn22);
+ final TreeMapNode tmn3 = builder.buildBranch("branch3", rootNode);
+ final TreeMapNode tmn31 = builder.buildBranch("branch31", tmn3);
+ value = new ValuePercent(-1.0);
+ builder.buildLeaf("leaf311", 1.0, value, tmn31);
+ value = new ValuePercent(-5.0);
+ builder.buildLeaf("leaf312", 2.0, value, tmn31);
+ value = new ValuePercent(-2.0);
+ builder.buildLeaf("leaf313", 0.5, value, tmn31);
+ value = new ValuePercent(-2.0);
+ builder.buildLeaf("leaf314", 3.0, value, tmn31);
+ value = new ValuePercent(-5.0);
+ builder.buildLeaf("leaf315", 0.25, value, tmn31);
+ final TreeMapNode tmn32 = builder.buildBranch("branch32", tmn3);
+ value = new ValuePercent(-1.0);
+ builder.buildLeaf("leaf321", 1.0, value, tmn32);
+ value = new ValuePercent(-5.0);
+ builder.buildLeaf("leaf322", 2.0, value, tmn32);
+ value = new ValuePercent(0.0);
+ builder.buildLeaf("leaf323", 0.5, value, tmn32);
+ value = new ValuePercent(2.0);
+ builder.buildLeaf("leaf324", 3.0, value, tmn32);
+ value = new ValuePercent(-5.0);
+ builder.buildLeaf("leaf325", 0.25, value, tmn32);
+ final TreeMapNode tmn33 = builder.buildBranch("branch33", tmn3);
+ value = new ValuePercent(-1.0);
+ builder.buildLeaf("leaf331", 1.0, value, tmn33);
+ value = new ValuePercent(5.0);
+ builder.buildLeaf("leaf332", 2.0, value, tmn33);
+ value = new ValuePercent(2.0);
+ builder.buildLeaf("leaf333", 0.5, value, tmn33);
+ value = new ValuePercent(-2.0);
+ builder.buildLeaf("leaf334", 3.0, value, tmn33);
+ final TreeMapNode tmn34 = builder.buildBranch("branch34", tmn3);
+ value = new ValuePercent(-1.0);
+ builder.buildLeaf("leaf341", 1.0, value, tmn34);
+ value = new ValuePercent(5.0);
+ builder.buildLeaf("leaf342", 2.0, value, tmn34);
+ value = new ValuePercent(-2.0);
+ builder.buildLeaf("leaf343", 0.5, value, tmn34);
+ final TreeMapNode tmn4 = builder.buildBranch("branch4", rootNode);
+ final TreeMapNode tmn41 = builder.buildBranch("branch41", tmn4);
+ value = new ValuePercent(1.0);
+ builder.buildLeaf("leaf411", 1.0, value, tmn41);
+ value = new ValuePercent(5.0);
+ builder.buildLeaf("leaf412", 2.0, value, tmn41);
+ value = new ValuePercent(2.0);
+ builder.buildLeaf("leaf413", 0.5, value, tmn41);
+ value = new ValuePercent(2.0);
+ builder.buildLeaf("leaf414", 3.0, value, tmn41);
+ value = new ValuePercent(-5.0);
+ builder.buildLeaf("leaf415", 0.25, value, tmn41);
+ final TreeMapNode tmn42 = builder.buildBranch("branch42", tmn4);
+ value = new ValuePercent(1.0);
+ builder.buildLeaf("leaf421", 1.0, value, tmn42);
+ value = new ValuePercent(5.0);
+ builder.buildLeaf("leaf422", 2.0, value, tmn42);
+ value = new ValuePercent(2.0);
+ builder.buildLeaf("leaf423", 0.5, value, tmn42);
+ value = new ValuePercent(2.0);
+ builder.buildLeaf("leaf424", 3.0, value, tmn42);
+ value = new ValuePercent(-5.0);
+ builder.buildLeaf("leaf425", 0.25, value, tmn42);
+ final TreeMapNode tmn43 = builder.buildBranch("branch43", tmn4);
+ value = new ValuePercent(1.0);
+ builder.buildLeaf("leaf431", 1.0, value, tmn43);
+ value = new ValuePercent(-5.0);
+ builder.buildLeaf("leaf432", 2.0, value, tmn43);
+ value = new ValuePercent(2.0);
+ builder.buildLeaf("leaf433", 0.5, value, tmn43);
+ value = new ValuePercent(0.0);
+ builder.buildLeaf("leaf434", 3.0, value, tmn43);
+ value = new ValuePercent(0.0);
+ builder.buildLeaf("leaf5", 5.0, value, rootNode);
+
+ return builder.getRoot();
+ }
+}
Deleted: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/HSBTreeMapColorProvider.java
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/HSBTreeMapColorProvider.java 2006-10-24 11:38:30 UTC (rev 65)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/example/HSBTreeMapColorProvider.java 2006-10-24 15:37:27 UTC (rev 66)
@@ -1,391 +0,0 @@
-/*
- * HSBTreeMapColorProvider.java Created on Feb 17, 2006
- */
-package net.sf.jtreemap.swing.example;
-
-import java.awt.Color;
-import java.awt.Graphics;
-import java.util.Enumeration;
-
-import javax.swing.JPanel;
-
-import net.sf.jtreemap.swing.ColorProvider;
-import net.sf.jtreemap.swing.DefaultValue;
-import net.sf.jtreemap.swing.JTreeMap;
-import net.sf.jtreemap.swing.TreeMapNode;
-import net.sf.jtreemap.swing.Value;
-
-/**
- * An HSB color space color provider for JTreeMap. Uses a specified function to
- * map the values onto the HSB color space. The default is a linear function,
- * but in my experience one of the logarithmic ones works best for this color
- * space.
- *
- * @author Andy Adamczak
- */
-public class HSBTreeMapColorProvider extends ColorProvider {
- /**
- *
- */
- private static final long serialVersionUID = 5009655580804320847L;
- /**
- * @author Andy Adamczak
- */
- public enum ColorDistributionTypes {
- /**
- *
- */
- Linear,
- /**
- *
- */
- Log,
- /**
- *
- */
- Exp,
- /**
- *
- */
- SquareRoot,
- /**
- *
- */
- CubicRoot
- }
-
- /**
- * @param treeMap
- * @param color
- */
- public HSBTreeMapColorProvider(final JTreeMap treeMap, final Color color)
- {
- this(treeMap, ColorDistributionTypes.Linear, color, color);
- }
-
- /**
- * @param treeMap
- * @param colorDistribution
- * @param color
- */
- public HSBTre...
[truncated message content] |