|
From: <be...@us...> - 2006-10-23 21:05:58
|
Revision: 48
http://svn.sourceforge.net/jtreemap/?rev=48&view=rev
Author: benoitx
Date: 2006-10-23 14:05:30 -0700 (Mon, 23 Oct 2006)
Log Message:
-----------
Moved remotely
Added Paths:
-----------
trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitBySlice.java
Removed Paths:
-------------
trunk/JTreeMap/src/main/java/org/jense/swing/jtreemap/SplitBySlice.java
Copied: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitBySlice.java (from rev 47, trunk/JTreeMap/src/main/java/org/jense/swing/jtreemap/SplitBySlice.java)
===================================================================
--- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitBySlice.java (rev 0)
+++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/SplitBySlice.java 2006-10-23 21:05:30 UTC (rev 48)
@@ -0,0 +1,111 @@
+/*
+ * Created on 3 nov. 2005
+ */
+package org.jense.swing.jtreemap;
+
+import java.util.Vector;
+
+/**
+ * Split the treemap by slice
+ *
+ * @author Laurent DUTHEIL
+ */
+public class SplitBySlice extends SplitStrategy {
+
+ /**
+ * Calculate the dimension of the elements of the Vector.
+ *
+ * @param x0 x-coordinate
+ * @param y0 y-coordinate
+ * @param w0 width
+ * @param h0 height
+ * @param v elements to split in the dimensions before
+ * @param sumWeight sum of the weights
+ */
+ public static void splitInSlice(int x0, int y0, int w0, int h0,
+ Vector<TreeMapNode> v, double sumWeight) {
+ int offset = 0;
+ boolean vertical = h0 > w0;
+
+ for (TreeMapNode node : v) {
+ if (vertical) {
+ node.setX(x0);
+ node.setWidth(w0);
+ node.setY(y0 + offset);
+ node.setHeight((int) Math.round(h0 * node.getWeight() / sumWeight));
+ offset = offset + node.getHeight();
+ } else {
+ node.setX(x0 + offset);
+ node.setWidth((int) Math.round(w0 * node.getWeight() / sumWeight));
+ node.setY(y0);
+ node.setHeight(h0);
+ offset = offset + node.getWidth();
+ }
+ }
+
+ // Because of the Math.round(), we adjust the last element to fit the
+ // correctly the JTreeMap
+ if (!v.isEmpty()) {
+ TreeMapNode node = v.lastElement();
+ if (vertical && h0 != offset) {
+ node.setHeight(node.getHeight() - offset + h0);
+ } else if (!vertical && w0 != offset) {
+ node.setWidth(node.getWidth() - offset + w0);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jense.swing.jtreemap.SplitStrategy#splitElements(java.util.Vector,
+ * java.util.Vector, java.util.Vector)
+ */
+ @Override
+ public void splitElements(Vector<TreeMapNode> v, Vector<TreeMapNode> v1,
+ Vector<TreeMapNode> v2) {
+ // ignore
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jense.swing.jtreemap.SplitStrategy#calculatePositionsRec(int, int,
+ * int, int, double, java.util.Vector)
+ */
+ @Override
+ protected void calculatePositionsRec(int x0, int y0, int w0, int h0,
+ double weight0, Vector<TreeMapNode> v) {
+
+ SplitBySlice.splitInSlice(x0, y0, w0, h0, v, weight0);
+
+ for (TreeMapNode node : v) {
+ if (node.isLeaf()) {
+ node.setX(node.getX() + TreeMapNode.getBorder());
+ node.setY(node.getY() + TreeMapNode.getBorder());
+ node.setHeight(node.getHeight() - TreeMapNode.getBorder());
+ node.setWidth(node.getWidth() - TreeMapNode.getBorder());
+ } else {
+ // if this is not a leaf, calculation for the children
+ if (TreeMapNode.getBorder() > 1) {
+ TreeMapNode.setBorder(TreeMapNode.getBorder() - 2);
+ calculatePositionsRec(node.getX() + 2, node.getY() + 2, node
+ .getWidth() - 2, node.getHeight() - 2, node.getWeight(), node
+ .getChildren());
+ TreeMapNode.setBorder(TreeMapNode.getBorder() + 2);
+ } else if (TreeMapNode.getBorder() == 1) {
+ TreeMapNode.setBorder(0);
+ calculatePositionsRec(node.getX() + 1, node.getY() + 1, node
+ .getWidth() - 1, node.getHeight() - 1, node.getWeight(), node
+ .getChildren());
+ TreeMapNode.setBorder(1);
+ } else {
+ calculatePositionsRec(node.getX(), node.getY(), node.getWidth(), node
+ .getHeight(), node.getWeight(), node.getChildren());
+ }
+ }
+ }
+
+ }
+}
Deleted: trunk/JTreeMap/src/main/java/org/jense/swing/jtreemap/SplitBySlice.java
===================================================================
--- trunk/JTreeMap/src/main/java/org/jense/swing/jtreemap/SplitBySlice.java 2006-10-23 21:02:36 UTC (rev 47)
+++ trunk/JTreeMap/src/main/java/org/jense/swing/jtreemap/SplitBySlice.java 2006-10-23 21:05:30 UTC (rev 48)
@@ -1,111 +0,0 @@
-/*
- * Created on 3 nov. 2005
- */
-package org.jense.swing.jtreemap;
-
-import java.util.Vector;
-
-/**
- * Split the treemap by slice
- *
- * @author Laurent DUTHEIL
- */
-public class SplitBySlice extends SplitStrategy {
-
- /**
- * Calculate the dimension of the elements of the Vector.
- *
- * @param x0 x-coordinate
- * @param y0 y-coordinate
- * @param w0 width
- * @param h0 height
- * @param v elements to split in the dimensions before
- * @param sumWeight sum of the weights
- */
- public static void splitInSlice(int x0, int y0, int w0, int h0,
- Vector<TreeMapNode> v, double sumWeight) {
- int offset = 0;
- boolean vertical = h0 > w0;
-
- for (TreeMapNode node : v) {
- if (vertical) {
- node.setX(x0);
- node.setWidth(w0);
- node.setY(y0 + offset);
- node.setHeight((int) Math.round(h0 * node.getWeight() / sumWeight));
- offset = offset + node.getHeight();
- } else {
- node.setX(x0 + offset);
- node.setWidth((int) Math.round(w0 * node.getWeight() / sumWeight));
- node.setY(y0);
- node.setHeight(h0);
- offset = offset + node.getWidth();
- }
- }
-
- // Because of the Math.round(), we adjust the last element to fit the
- // correctly the JTreeMap
- if (!v.isEmpty()) {
- TreeMapNode node = v.lastElement();
- if (vertical && h0 != offset) {
- node.setHeight(node.getHeight() - offset + h0);
- } else if (!vertical && w0 != offset) {
- node.setWidth(node.getWidth() - offset + w0);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.jense.swing.jtreemap.SplitStrategy#splitElements(java.util.Vector,
- * java.util.Vector, java.util.Vector)
- */
- @Override
- public void splitElements(Vector<TreeMapNode> v, Vector<TreeMapNode> v1,
- Vector<TreeMapNode> v2) {
- // ignore
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.jense.swing.jtreemap.SplitStrategy#calculatePositionsRec(int, int,
- * int, int, double, java.util.Vector)
- */
- @Override
- protected void calculatePositionsRec(int x0, int y0, int w0, int h0,
- double weight0, Vector<TreeMapNode> v) {
-
- SplitBySlice.splitInSlice(x0, y0, w0, h0, v, weight0);
-
- for (TreeMapNode node : v) {
- if (node.isLeaf()) {
- node.setX(node.getX() + TreeMapNode.getBorder());
- node.setY(node.getY() + TreeMapNode.getBorder());
- node.setHeight(node.getHeight() - TreeMapNode.getBorder());
- node.setWidth(node.getWidth() - TreeMapNode.getBorder());
- } else {
- // if this is not a leaf, calculation for the children
- if (TreeMapNode.getBorder() > 1) {
- TreeMapNode.setBorder(TreeMapNode.getBorder() - 2);
- calculatePositionsRec(node.getX() + 2, node.getY() + 2, node
- .getWidth() - 2, node.getHeight() - 2, node.getWeight(), node
- .getChildren());
- TreeMapNode.setBorder(TreeMapNode.getBorder() + 2);
- } else if (TreeMapNode.getBorder() == 1) {
- TreeMapNode.setBorder(0);
- calculatePositionsRec(node.getX() + 1, node.getY() + 1, node
- .getWidth() - 1, node.getHeight() - 1, node.getWeight(), node
- .getChildren());
- TreeMapNode.setBorder(1);
- } else {
- calculatePositionsRec(node.getX(), node.getY(), node.getWidth(), node
- .getHeight(), node.getWeight(), node.getChildren());
- }
- }
- }
-
- }
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|