Author: kono
Date: 2011-03-28 18:50:07 -0700 (Mon, 28 Mar 2011)
New Revision: 24605
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/AbstractContinuousMappingEditor.java
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/C2DMappingEditor.java
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/ContinuousMappingEditorPanel.java
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/CyGradientTrackRenderer.java
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/DiscreteTrackRenderer.java
Log:
Fixed IconRenderers. Some of them are still broken.
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/AbstractContinuousMappingEditor.java
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/AbstractContinuousMappingEditor.java
2011-03-29 01:49:44 UTC (rev 24604)
+++
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/AbstractContinuousMappingEditor.java
2011-03-29 01:50:07 UTC (rev 24605)
@@ -20,7 +20,8 @@
public abstract class AbstractContinuousMappingEditor<K extends Number, V>
extends AbstractPropertyEditor {
- private static final Dimension MIN_SIZE = new Dimension(650, 400);
+ private static final Dimension DEF_SIZE = new Dimension(650, 400);
+ private static final Dimension MIN_SIZE = new Dimension(400, 200);
protected ContinuousMapping<K, V> mapping;
protected ContinuousMappingEditorPanel<K, V> editorPanel;
@@ -61,7 +62,8 @@
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.getContentPane().add(editorPanel,
BorderLayout.CENTER);
- dialog.setPreferredSize(MIN_SIZE);
+ dialog.setPreferredSize(DEF_SIZE);
+ dialog.setMinimumSize(MIN_SIZE);
dialog.pack();
}
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/C2DMappingEditor.java
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/C2DMappingEditor.java
2011-03-29 01:49:44 UTC (rev 24604)
+++
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/C2DMappingEditor.java
2011-03-29 01:50:07 UTC (rev 24605)
@@ -284,7 +284,7 @@
updateMap();
slider.setTrackRenderer(new
DiscreteTrackRenderer<Number, V>(
- mapping, below, above,
tracer));
+ mapping, below, above,
tracer, appManager.getCurrentRenderingEngine()));
slider.repaint();
// Update network
@@ -328,7 +328,7 @@
*/
TriangleThumbRenderer thumbRend = new
TriangleThumbRenderer(slider);
DiscreteTrackRenderer<Number, V> dRend = new
DiscreteTrackRenderer<Number, V>(
- mapping, below, above, tracer);
+ mapping, below, above, tracer,
appManager.getCurrentRenderingEngine());
slider.setThumbRenderer(thumbRend);
slider.setTrackRenderer(dRend);
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/ContinuousMappingEditorPanel.java
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/ContinuousMappingEditorPanel.java
2011-03-29 01:49:44 UTC (rev 24604)
+++
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/ContinuousMappingEditorPanel.java
2011-03-29 01:50:07 UTC (rev 24605)
@@ -76,6 +76,8 @@
private static final long serialVersionUID = 2077889066171872186L;
private static final Logger logger =
LoggerFactory.getLogger(ContinuousMappingEditorPanel.class);
+
+ protected static final Color BACKGROUND = Color.WHITE;
protected static final String BELOW_VALUE_CHANGED =
"BELOW_VALUE_CHANGED";
protected static final String ABOVE_VALUE_CHANGED =
"ABOVE_VALUE_CHANGED";
@@ -182,6 +184,8 @@
mainPanel.setSize(650, 800);
mainPanel.setMinimumSize(new Dimension(650, 800));
mainPanel.setPreferredSize(new Dimension(650, 800));
+ mainPanel.setBackground(BACKGROUND);
+ this.setBackground(BACKGROUND);
abovePanel = new BelowAndAbovePanel(Color.yellow, false,
mapping);
abovePanel.setName("abovePanel");
@@ -247,7 +251,6 @@
}
});
- // New in 2.6
minMaxButton.setText("Min/Max");
minMaxButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
minMaxButton.addActionListener(new
java.awt.event.ActionListener() {
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/CyGradientTrackRenderer.java
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/CyGradientTrackRenderer.java
2011-03-29 01:49:44 UTC (rev 24604)
+++
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/CyGradientTrackRenderer.java
2011-03-29 01:50:07 UTC (rev 24605)
@@ -71,6 +71,9 @@
// Preset fonts
private static final Font SMALL_FONT = new Font("SansSerif", Font.BOLD,
16);
private static final Font TITLE_FONT = new Font("SansSerif", Font.BOLD,
12);
+
+ // Width of the slider
+ private static final int THUMB_WIDTH = 12;
private int trackHeight = 40;
@@ -119,20 +122,19 @@
}
protected void paintComponent(Graphics gfx) {
- Graphics2D g = (Graphics2D) gfx;
+ final Graphics2D g = (Graphics2D) gfx;
// Turn AA on
- g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
+ g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
double minValue = tracer.getMin(type);
double maxValue = tracer.getMax(type);
double range = tracer.getRange(type);
// calculate the track area
- int thumb_width = 12;
- int track_width = slider.getWidth() - thumb_width;
- g.translate(thumb_width / 2, 12);
+
+ int track_width = slider.getWidth() - THUMB_WIDTH;
+ g.translate(THUMB_WIDTH / 2, 12);
// get the list of colors
List<Thumb<Color>> stops = slider.getModel().getSortedThumbs();
@@ -251,7 +253,7 @@
// draw a border
g.draw(rect);
- g.translate(-thumb_width / 2, -12);
+ g.translate(-THUMB_WIDTH / 2, -12);
}
private static void drawGradient(Graphics2D g, Point2D start, Point2D
end,
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/DiscreteTrackRenderer.java
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/DiscreteTrackRenderer.java
2011-03-29 01:49:44 UTC (rev 24604)
+++
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/DiscreteTrackRenderer.java
2011-03-29 01:50:07 UTC (rev 24605)
@@ -31,11 +31,12 @@
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
+ */
package org.cytoscape.view.vizmap.gui.internal.editor.mappingeditor;
import java.awt.BasicStroke;
import java.awt.Color;
+import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
@@ -44,127 +45,119 @@
import java.awt.geom.Point2D;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
+import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
+import org.cytoscape.model.CyNetwork;
import org.cytoscape.view.model.DiscreteRange;
import org.cytoscape.view.model.Range;
import org.cytoscape.view.model.VisualProperty;
+import org.cytoscape.view.presentation.RenderingEngine;
import org.cytoscape.view.vizmap.mappings.ContinuousMapping;
import org.cytoscape.view.vizmap.mappings.ContinuousMappingPoint;
import org.jdesktop.swingx.JXMultiThumbSlider;
import org.jdesktop.swingx.multislider.Thumb;
-/**
- *
- * @param T type of discrete values mapped here.
- * This is a discrete values such as node shape, arrow head, etc.
- *
- * @author $author$
- */
-public class DiscreteTrackRenderer<K, V> extends JComponent implements
VizMapTrackRenderer {
+public class DiscreteTrackRenderer<K, V> extends JComponent implements
+ VizMapTrackRenderer {
+
private final static long serialVersionUID = 1213748837182053L;
- /*
- * Constants for diagram.
- */
- private final Font TITLE_FONT = new Font("SansSerif", Font.BOLD, 12);
- //TODO: store default icon size somewhere
+
+ private static final Font TITLE_FONT = new Font("SansSerif", Font.BOLD,
12);
+ private static final Font TRACK_FONT = new Font("SansSerif",
Font.PLAIN, 10);
+ private static final Color BACKGROUND_COLOR = new Color(0x00, 0x68,
0x8B, 70);
+
+ private static final Dimension MIN_SIZE = new Dimension(200, 100);
private static final int ICON_SIZE = 32;
-// private static final int ICON_SIZE =
VisualPropertyIcon.DEFAULT_ICON_SIZE;
- private int SMALL_ICON_SIZE = 20;
- private static final Color ICON_COLOR = new Color(10, 100, 255, 200);
- private static int TRACK_HEIGHT = 70;
private static final int THUMB_WIDTH = 12;
private static final int V_PADDING = 20;
- private static int ARROW_BAR_Y_POSITION = TRACK_HEIGHT + 50;
-// private double valueRange;
-// private double minValue;
-// private double maxValue;
+ private int smallIconSize = 20;
+ private int trackHeight = 70;
+ private int arrowBarYPosition = trackHeight + 50;
+
+ private final String title;
+
private V below;
private V above;
- private VisualProperty<V> type;
- private String title;
+ private VisualProperty<V> vp;
+ private final Set<V> values;
- // Mainly for Icons
-// private List<Icon> rangeObjects;
- private V lastObject;
-
- // HTML document fot tooltip text.
private List<String> rangeTooltips;
private JXMultiThumbSlider<V> slider;
-
+
private final EditorValueRangeTracer tracer;
- private final Set<V> values;
-
+ private final Map<V, Icon> iconMap;
+
/**
- * Create new track renderer for numbers-discrete value mappings.
*
* @param mapping
* @param below
* @param above
+ * @param tracer
+ * @param engine
*/
- public DiscreteTrackRenderer(final ContinuousMapping<K, V> mapping,
final V below, final V above, final EditorValueRangeTracer tracer) {
+ public DiscreteTrackRenderer(final ContinuousMapping<K, V> mapping,
+ final V below, final V above, final
EditorValueRangeTracer tracer,
+ final RenderingEngine<CyNetwork> engine) {
- if(mapping == null)
+ if (mapping == null)
throw new NullPointerException("Mapping is null.");
- if(tracer == null)
+ if (tracer == null)
throw new NullPointerException("Tracer is null.");
-
+ if (engine == null)
+ throw new NullPointerException("Rendering engine is
null.");
+
this.below = below;
this.above = above;
this.tracer = tracer;
- this.type = mapping.getVisualProperty();
- Range<V> rangeObject = type.getRange();
- if(!rangeObject.isDiscrete())
+ this.vp = mapping.getVisualProperty();
+ final Range<V> rangeObject = vp.getRange();
+ if (!rangeObject.isDiscrete())
throw new IllegalArgumentException("Range type should
be discrete.");
+
+ this.values = ((DiscreteRange<V>) rangeObject).values();
+ // create map of icons. Key is V value.
+ this.iconMap = new HashMap<V, Icon>();
+ for (V value : values)
+ iconMap.put(value, engine.createIcon(vp, value,
ICON_SIZE, ICON_SIZE));
- this.values = ((DiscreteRange<V>)rangeObject).values();
this.title = mapping.getMappingAttributeName();
-
-
- this.setBackground(Color.white);
- this.setForeground(Color.white);
+ this.setBackground(BACKGROUND_COLOR);
+ this.setMinimumSize(MIN_SIZE);
}
-
- /**
- * DOCUMENT ME!
- *
- * @param g DOCUMENT ME!
- */
- public void paint(Graphics g) {
+
+ @Override public void paint(Graphics g) {
super.paint(g);
paintComponent(g);
}
- /**
- * Java2D code to draw track component.
- */
- protected void paintComponent(Graphics gfx) {
- TRACK_HEIGHT = slider.getHeight() - 100;
- ARROW_BAR_Y_POSITION = TRACK_HEIGHT + 50;
-
+
+ @Override protected void paintComponent(Graphics gfx) {
// Turn AA on
- Graphics2D g = (Graphics2D) gfx;
+ final Graphics2D g = (Graphics2D) gfx;
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
+
+ trackHeight = slider.getHeight() - 100;
+ arrowBarYPosition = trackHeight + 50;
- int track_width = slider.getWidth() - THUMB_WIDTH;
-
+ final int trackWidth = slider.getWidth() - THUMB_WIDTH;
g.translate(THUMB_WIDTH / 2, 12);
- double minValue = tracer.getMin(type);
- double maxValue = tracer.getMax(type);
- double valueRange = tracer.getRange(type);
-
- // get the list of tumbs
+ final double minValue = tracer.getMin(vp);
+ final double maxValue = tracer.getMax(vp);
+ final double valueRange = tracer.getRange(vp);
final List<Thumb<V>> stops =
slider.getModel().getSortedThumbs();
final int numPoints = stops.size();
@@ -172,173 +165,155 @@
final float[] fractions = new float[numPoints];
final Object[] objectValues = new Object[numPoints];
- /*
- * Find min, max, and ranges
- */
int i = 0;
-
for (Thumb<V> thumb : stops) {
objectValues[i] = thumb.getObject();
fractions[i] = thumb.getPosition();
i++;
}
- /*
- * Draw arrow bar
- */
- g.setStroke(new BasicStroke(1.0f));
- g.setColor(Color.black);
- g.drawLine(0, ARROW_BAR_Y_POSITION, track_width,
ARROW_BAR_Y_POSITION);
+ // Draw arrow
+ g.setStroke(STROKE1);
+ g.setColor(BORDER_COLOR);
+ g.drawLine(0, arrowBarYPosition, trackWidth, arrowBarYPosition);
- Polygon arrow = new Polygon();
- arrow.addPoint(track_width, ARROW_BAR_Y_POSITION);
- arrow.addPoint(track_width - 20, ARROW_BAR_Y_POSITION - 8);
- arrow.addPoint(track_width - 20, ARROW_BAR_Y_POSITION);
+ final Polygon arrow = new Polygon();
+ arrow.addPoint(trackWidth, arrowBarYPosition);
+ arrow.addPoint(trackWidth - 20, arrowBarYPosition - 8);
+ arrow.addPoint(trackWidth - 20, arrowBarYPosition);
g.fill(arrow);
g.setColor(Color.gray);
- g.drawLine(0, ARROW_BAR_Y_POSITION, 15, ARROW_BAR_Y_POSITION -
30);
- g.drawLine(15, ARROW_BAR_Y_POSITION - 30, 25,
ARROW_BAR_Y_POSITION - 30);
+ g.drawLine(0, arrowBarYPosition, 15, arrowBarYPosition - 30);
+ g.drawLine(15, arrowBarYPosition - 30, 25, arrowBarYPosition -
30);
g.setFont(SMALL_FONT);
- g.drawString("Min=" + minValue, 28, ARROW_BAR_Y_POSITION - 25);
+ g.drawString("Min=" + minValue, 28, arrowBarYPosition - 25);
- g.drawLine(track_width, ARROW_BAR_Y_POSITION, track_width - 15,
ARROW_BAR_Y_POSITION + 30);
- g.drawLine(track_width - 15, ARROW_BAR_Y_POSITION + 30,
track_width - 25,
- ARROW_BAR_Y_POSITION + 30);
+ g.drawLine(trackWidth, arrowBarYPosition, trackWidth - 15,
+ arrowBarYPosition + 30);
+ g.drawLine(trackWidth - 15, arrowBarYPosition + 30, trackWidth
- 25,
+ arrowBarYPosition + 30);
final String maxStr = "Max=" + maxValue;
- int strWidth =
SwingUtilities.computeStringWidth(g.getFontMetrics(), maxStr);
- g.drawString(maxStr, track_width - strWidth - 26,
ARROW_BAR_Y_POSITION + 35);
+ int strWidth =
SwingUtilities.computeStringWidth(g.getFontMetrics(),
+ maxStr);
+ g.drawString(maxStr, trackWidth - strWidth - 26,
+ arrowBarYPosition + 35);
- g.setFont(SMALL_FONT);
g.setColor(Color.black);
strWidth =
SwingUtilities.computeStringWidth(g.getFontMetrics(), title);
- g.drawString(title, (track_width / 2) - (strWidth / 2),
ARROW_BAR_Y_POSITION + 35);
+ g.drawString(title, (trackWidth / 2) - (strWidth / 2),
+ arrowBarYPosition + 35);
- /*
- * If no points, just draw empty box.
- */
if (numPoints == 0) {
g.setColor(BORDER_COLOR);
g.setStroke(new BasicStroke(1.5f));
- g.drawRect(0, 5, track_width, TRACK_HEIGHT);
+ g.drawRect(0, 5, trackWidth, trackHeight);
return;
}
+ g.setStroke(STROKE1);
- g.setStroke(new BasicStroke(1.0f));
+ // Fill background
+ g.setColor(BACKGROUND_COLOR);
+ g.fillRect(0, 5, trackWidth, trackHeight);
- /*
- * Fill background
- */
- g.setColor(Color.white);
- g.fillRect(0, 5, track_width, TRACK_HEIGHT);
-
-// rangeObjects = buildIconArray(stops.size() + 1);
-
int newX = 0;
+ final Point2D p1 = new Point2D.Float(0, 5);
+ final Point2D p2 = new Point2D.Float(0, 5);
- Point2D p1 = new Point2D.Float(0, 5);
- Point2D p2 = new Point2D.Float(0, 5);
-
int iconLocX;
int iconLocY;
- /*
- * Draw separators and icons
- */
+ // Draw Icons
for (i = 0; i < stops.size(); i++) {
- newX = (int) (track_width * (fractions[i] / 100));
+ newX = (int) (trackWidth * (fractions[i] / 100));
p2.setLocation(newX, 5);
g.setColor(Color.black);
g.setStroke(STROKE1);
- g.drawLine(newX, 5, newX, TRACK_HEIGHT + 4);
+ g.drawLine(newX, 5, newX, trackHeight + 4);
g.setColor(Color.DARK_GRAY);
- g.setFont(new Font("SansSerif", Font.BOLD, 10));
+ g.setFont(TRACK_FONT);
- final Float curPositionValue = ((Number)
(((fractions[i] / 100) * valueRange)
- + minValue)).floatValue();
+ final Float curPositionValue = ((Number)
(((fractions[i] / 100) * valueRange) + minValue))
+ .floatValue();
final String valueString = String.format("%.5f",
curPositionValue);
int flipLimit = 90;
- int borderVal = track_width - newX;
+ int borderVal = trackWidth - newX;
if (((i % 2) == 0) && (flipLimit < borderVal)) {
- g.drawLine(newX, ARROW_BAR_Y_POSITION, newX +
20, ARROW_BAR_Y_POSITION - 15);
- g.drawLine(newX + 20, ARROW_BAR_Y_POSITION -
15, newX + 30,
- ARROW_BAR_Y_POSITION - 15);
+ g.drawLine(newX, arrowBarYPosition, newX + 20,
+ arrowBarYPosition - 15);
+ g.drawLine(newX + 20, arrowBarYPosition - 15,
newX + 30,
+ arrowBarYPosition - 15);
g.setColor(Color.black);
- g.drawString(valueString, newX + 33,
ARROW_BAR_Y_POSITION - 11);
+ g.drawString(valueString, newX + 33,
arrowBarYPosition - 11);
} else if (((i % 2) == 1) && (flipLimit < borderVal)) {
- g.drawLine(newX, ARROW_BAR_Y_POSITION, newX +
20, ARROW_BAR_Y_POSITION + 15);
- g.drawLine(newX + 20, ARROW_BAR_Y_POSITION +
15, newX + 30,
- ARROW_BAR_Y_POSITION + 15);
+ g.drawLine(newX, arrowBarYPosition, newX + 20,
+ arrowBarYPosition + 15);
+ g.drawLine(newX + 20, arrowBarYPosition + 15,
newX + 30,
+ arrowBarYPosition + 15);
g.setColor(Color.black);
- g.drawString(valueString, newX + 33,
ARROW_BAR_Y_POSITION + 19);
+ g.drawString(valueString, newX + 33,
arrowBarYPosition + 19);
} else if (((i % 2) == 0) && (flipLimit >= borderVal)) {
- g.drawLine(newX, ARROW_BAR_Y_POSITION, newX -
20, ARROW_BAR_Y_POSITION - 15);
- g.drawLine(newX - 20, ARROW_BAR_Y_POSITION -
15, newX - 30,
- ARROW_BAR_Y_POSITION - 15);
+ g.drawLine(newX, arrowBarYPosition, newX - 20,
+ arrowBarYPosition - 15);
+ g.drawLine(newX - 20, arrowBarYPosition - 15,
newX - 30,
+ arrowBarYPosition - 15);
g.setColor(Color.black);
- g.drawString(valueString, newX - 90,
ARROW_BAR_Y_POSITION - 11);
+ g.drawString(valueString, newX - 90,
arrowBarYPosition - 11);
} else {
- g.drawLine(newX, ARROW_BAR_Y_POSITION, newX -
20, ARROW_BAR_Y_POSITION + 15);
- g.drawLine(newX - 20, ARROW_BAR_Y_POSITION +
15, newX - 30,
- ARROW_BAR_Y_POSITION + 15);
+ g.drawLine(newX, arrowBarYPosition, newX - 20,
+ arrowBarYPosition + 15);
+ g.drawLine(newX - 20, arrowBarYPosition + 15,
newX - 30,
+ arrowBarYPosition + 15);
g.setColor(Color.black);
- g.drawString(valueString, newX - 90,
ARROW_BAR_Y_POSITION + 19);
+ g.drawString(valueString, newX - 90,
arrowBarYPosition + 19);
}
g.setColor(Color.black);
- g.fillOval(newX - 3, ARROW_BAR_Y_POSITION - 3, 6, 6);
+ g.fillOval(newX - 3, arrowBarYPosition - 3, 6, 6);
iconLocX = newX - (((newX - (int) p1.getX()) / 2) +
(ICON_SIZE / 2));
- iconLocY = ((TRACK_HEIGHT) / 2) - (ICON_SIZE / 2) + 5;
+ iconLocY = ((trackHeight) / 2 + 5);
- // TODO: is this necessary?
-// if (ICON_SIZE < (newX - p1.getX()))
-// g.drawImage(((ImageIcon)
rangeObjects.get(i)).getImage(), iconLocX, iconLocY, this);
-
- if (i == 0) {
- //drawIcon(below, g, iconLocX, iconLocY,
ICON_SIZE);
- g.drawString(below.toString(), iconLocX,
iconLocY);
- } else {
- //drawIcon(objectValues[i], g, iconLocX,
iconLocY, ICON_SIZE);
- g.drawString(objectValues[i].toString(),
iconLocX, iconLocY);
- }
+ if (i == 0)
+ drawIcon(below, g, iconLocX, iconLocY);
+ else
+ drawIcon((V) objectValues[i], g, iconLocX,
iconLocY);
p1.setLocation(p2);
}
- /*
- * Draw last region (above region)
- */
- p2.setLocation(track_width, 5);
+ // Draw last region (above region)
+ p2.setLocation(trackWidth, 5);
- iconLocX = track_width - (((track_width - (int) p1.getX()) / 2)
+ (ICON_SIZE / 2));
- iconLocY = ((TRACK_HEIGHT) / 2) - (ICON_SIZE / 2) + 5;
- //g.drawImage(((ImageIcon) rangeObjects.get(i)).getImage(),
iconLocX, iconLocY, this);
- g.drawString(above.toString(), iconLocX, iconLocY);
- //drawIcon(above, g, iconLocX, iconLocY, ICON_SIZE);
+ iconLocX = trackWidth
+ - (((trackWidth - (int) p1.getX()) / 2) +
(ICON_SIZE / 2));
+ iconLocY = ((trackHeight) / 2 + 5);
+
+ drawIcon(above, g, iconLocX, iconLocY);
/*
* Finally, draw border line (rectangle)
*/
g.setColor(BORDER_COLOR);
g.setStroke(new BasicStroke(1.5f));
- g.drawRect(0, 5, track_width, TRACK_HEIGHT);
+ g.drawRect(0, 5, trackWidth, trackHeight);
g.translate(-THUMB_WIDTH / 2, -12);
}
/**
* DOCUMENT ME!
- *
- * @param slider DOCUMENT ME!
- *
+ *
+ * @param slider
+ * DOCUMENT ME!
+ *
* @return DOCUMENT ME!
*/
@SuppressWarnings("unchecked")
@@ -354,10 +329,12 @@
/**
* DOCUMENT ME!
- *
- * @param x DOCUMENT ME!
- * @param y DOCUMENT ME!
- *
+ *
+ * @param x
+ * DOCUMENT ME!
+ * @param y
+ * DOCUMENT ME!
+ *
* @return DOCUMENT ME!
*/
public String getToolTipForCurrentLocation(int x, int y) {
@@ -371,7 +348,8 @@
for (Thumb<V> thumb : stops) {
newX = (int) (slider.getWidth() * (thumb.getPosition()
/ 100));
- if ((oldX <= x) && (x <= newX) && (V_PADDING < y) && (y
< (V_PADDING + TRACK_HEIGHT)))
+ if ((oldX <= x) && (x <= newX) && (V_PADDING < y)
+ && (y < (V_PADDING + trackHeight)))
return "This is region " + i;
i++;
@@ -379,41 +357,19 @@
}
if ((oldX <= x) && (x <= slider.getWidth()) && (V_PADDING < y)
- && (y < (V_PADDING + TRACK_HEIGHT)))
- return "Last Area: " + oldX + " - " + slider.getWidth()
+ " (x, y) = " + x + ", " + y;
+ && (y < (V_PADDING + trackHeight)))
+ return "Last Area: " + oldX + " - " + slider.getWidth()
+ + " (x, y) = " + x + ", " + y;
return null;
}
- /**
- * DOCUMENT ME!
- *
- * @param x DOCUMENT ME!
- * @param y DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
-// public Object getObjectInRange(int x, int y) {
-// final int range = getRangeID(x, y);
-//
-// if (range == -1)
-// return null;
-//
-// if (range == 0) {
-// return null;
-// } else if (range == slider.getModel().getThumbCount()) {
-// }
-//
-// return rangeObjects.get(getRangeID(x, y));
-// }
/*
* Get region id.
- *
+ *
+ * +------------------------------------------- | 0 | 1 | 2 | ...
* +-------------------------------------------
- * | 0 | 1 | 2 | ...
- * +-------------------------------------------
- *
*/
protected int getRangeID(int x, int y) {
int oldX = 0;
@@ -427,14 +383,15 @@
thumb = stops.get(i);
newX = (int) (slider.getWidth() * (thumb.getPosition()
/ 100));
- if ((oldX <= x) && (x <= newX) && (V_PADDING < y) && (y
< (V_PADDING + TRACK_HEIGHT)))
+ if ((oldX <= x) && (x <= newX) && (V_PADDING < y)
+ && (y < (V_PADDING + trackHeight)))
return i;
oldX = newX + 1;
}
if ((oldX <= x) && (x <= slider.getWidth()) && (V_PADDING < y)
- && (y < (V_PADDING + TRACK_HEIGHT)))
+ && (y < (V_PADDING + trackHeight)))
return i;
// Invalid range
@@ -443,30 +400,31 @@
/**
* DOCUMENT ME!
- *
- * @param iconWidth DOCUMENT ME!
- * @param iconHeight DOCUMENT ME!
- * @param mapping DOCUMENT ME!
- *
+ *
+ * @param iconWidth
+ * DOCUMENT ME!
+ * @param iconHeight
+ * DOCUMENT ME!
+ * @param mapping
+ * DOCUMENT ME!
+ *
* @return DOCUMENT ME!
*/
public ImageIcon getTrackGraphicIcon(int iconWidth, int iconHeight,
- ContinuousMapping<K, V>
mapping) {
- final BufferedImage bi = new BufferedImage(iconWidth,
iconHeight, BufferedImage.TYPE_INT_RGB);
+ ContinuousMapping<K, V> mapping) {
+ final BufferedImage bi = new BufferedImage(iconWidth,
iconHeight,
+ BufferedImage.TYPE_INT_RGB);
final Graphics2D g2 = bi.createGraphics();
// Turn Anti-alias on
- g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
final int leftSpace = 2;
int trackHeight = iconHeight - 15;
int trackWidth = iconWidth - leftSpace - 5;
g2.setBackground(Color.white);
-
- /*
- * Draw background
- */
g2.setColor(Color.white);
g2.fillRect(0, 0, iconWidth, iconHeight);
g2.setStroke(new BasicStroke(1.0f));
@@ -499,315 +457,344 @@
objValues[2] = points.get(0).getRange().greaterValue;
} else {
// "Above" value
- objValues[objValues.length - 1] =
points.get(points.size() - 1).getRange().greaterValue;
+ objValues[objValues.length - 1] =
points.get(points.size() - 1)
+ .getRange().greaterValue;
for (int i = 0; i < pointCount; i++)
objValues[i + 1] =
points.get(i).getRange().equalValue;
}
- //List<ImageIcon> iconList = buildIconArray(objValues);
+ // List<ImageIcon> iconList = buildIconArray(objValues);
final Point2D start = new Point2D.Float(10, 0);
final Point2D end = new Point2D.Float(trackWidth, trackHeight);
- // int i=1;
- //
- // g2.setFont(new Font("SansSerif", Font.BOLD, 9));
- // int strWidth;
- // for(ContinuousMappingPoint point: points) {
- // String p =
Double.toString(point.getValue());
- // g2.setColor(Color.black);
- // strWidth =
SwingUtilities.computeStringWidth(g2.getFontMetrics(), p);
- // g2.drawString(p, fractions[i]*iconWidth
- strWidth/2, iconHeight -7);
- // i++;
- // }
+ // int i=1;
+ //
+ // g2.setFont(new Font("SansSerif", Font.BOLD, 9));
+ // int strWidth;
+ // for(ContinuousMappingPoint point: points) {
+ // String p = Double.toString(point.getValue());
+ // g2.setColor(Color.black);
+ // strWidth =
SwingUtilities.computeStringWidth(g2.getFontMetrics(), p);
+ // g2.drawString(p, fractions[i]*iconWidth - strWidth/2,
iconHeight -7);
+ // i++;
+ // }
return new ImageIcon(bi);
}
-// private List<Icon> buildIconArray(int size) {
+// private List<Icon> buildIconArray(final int size) {
// final List<Icon> icons = new ArrayList<Icon>();
-//
-// Map iconMap = NodeShape.getIconSet();
+// final Map<V, Icon> iconMap = new HashMap<V, Icon>();
//
-// Object[] keys = iconMap.keySet().toArray();
+// for (V value : values)
+// iconMap.put(value, engine.createIcon(vp, value, size,
size));
//
+// final Object[] keys = iconMap.keySet().toArray();
+//
// for (int i = 0; i < size; i++)
// icons.add((ImageIcon) iconMap.get(keys[i]));
//
// return icons;
// }
-// private Shape getIcon(Object key) {
-// final BufferedImage image = new BufferedImage(40, 40,
BufferedImage.TYPE_INT_RGB);
-//
-// final Graphics2D gfx = image.createGraphics();
-// Map icons = type.getVisualProperty().getIconSet();
-// JLabel label = new JLabel();
-// label.setIcon((Icon) icons.get(key));
-// label.setText("test1");
-// gfx.setBackground(Color.white);
-// gfx.setColor(Color.red);
-// gfx.drawString("Test1", 0, 0);
-//
-// // label.paint(gfx);
-// return ((VisualPropertyIcon) icons.get(key)).getShape();
-// }
+ // private Shape getIcon(Object key) {
+ // final BufferedImage image = new BufferedImage(40, 40,
+ // BufferedImage.TYPE_INT_RGB);
+ //
+ // final Graphics2D gfx = image.createGraphics();
+ // Map icons = type.getVisualProperty().getIconSet();
+ // JLabel label = new JLabel();
+ // label.setIcon((Icon) icons.get(key));
+ // label.setText("test1");
+ // gfx.setBackground(Color.white);
+ // gfx.setColor(Color.red);
+ // gfx.drawString("Test1", 0, 0);
+ //
+ // // label.paint(gfx);
+ // return ((VisualPropertyIcon) icons.get(key)).getShape();
+ // }
-// /*
-// * Draw icon object based on the given data type.
-// */
-// private void drawIcon(Object key, Graphics2D g, int x, int y, final int
size) {
-// g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
-// g.translate(x, y);
-// g.setColor(ICON_COLOR);
-// g.setStroke(STROKE2);
-//
-//
-// // TODO: Move this to somewhere more appropreate!
-// if(type.equals(NODE_SHAPE)) {
-//
-//
-// final VisualPropertyIcon icon =
(VisualPropertyIcon) type.getIconSet().get(key);
-// icon.setIconHeight(size);
-// icon.setIconWidth(size);
-// g.fill(icon.getShape());
-//
-// } else if(type.equals(EDGE_SRCARROW_SHAPE) ||
-// type.equals(EDGE_TGTARROW_SHAPE)) {
-//
-// final VisualPropertyIcon arrowIcon =
((VisualPropertyIcon) type.getIconSet().get(key));
-// if(arrowIcon == null) {
-// return;
-// }
-// final int newSize = size;
-// arrowIcon.setIconHeight(newSize);
-//
arrowIcon.setIconWidth(((Number)(newSize*2.5)).intValue());
-//
-// g.translate(-newSize, 0);
-// arrowIcon.paintIcon(this, g, x, y);
-// g.translate(newSize, 0);
-//
-// } else if(type.equals(NODE_FONT_FACE) ||
type.equals(EDGE_FONT_FACE)) {
-//
-// final Font font = (Font) key;
-// final String fontName = font.getFontName();
-// g.setFont(new Font(fontName, font.getStyle(),
size));
-// g.drawString("A", 0, size);
-//
-// final int smallFontSize = ((Number) (size *
0.25)).intValue();
-// g.setFont(new Font(fontName, font.getStyle(),
smallFontSize));
-//
-// int stringWidth =
SwingUtilities.computeStringWidth(g.getFontMetrics(), fontName);
-// g.drawString(fontName, (size / 2) -
(stringWidth / 2), size + smallFontSize + 2);
-//
-// } else if(type.equals(NODE_LINE_STYLE) ||
type.equals(EDGE_LINE_STYLE)) {
-//
-// final Stroke stroke = ((LineStyle)
key).getStroke(2.0f);
-// final int newSize2 = (int) (size * 1.5);
-// g.translate(0, -size * 0.25);
-// g.setColor(Color.DARK_GRAY);
-// g.drawRect(0, 0, size, newSize2);
-// g.setStroke(stroke);
-// g.setColor(ICON_COLOR);
-// g.drawLine(size - 1, 1, 1, newSize2 - 1);
-// g.translate(0, size * 0.25);
-//
-//
-//
-//// TODO
-//// case NODE_LABEL_POSITION:
-////
-//// final LabelPlacerGraphic lp = new
LabelPlacerGraphic((LabelPosition) key,
-////
(int) (size * 1.5), false);
-//// lp.paint(g);
-////
-//// break;
-// } else if ( type.equals(NODE_LABEL) ||
-// type.equals(NODE_TOOLTIP) ||
-// type.equals(EDGE_LABEL) ||
-// type.equals(EDGE_TOOLTIP) ) {
-// if(key != null) {
-// g.drawString(key.toString(), 0,
g.getFont().getSize()*2);
-// }
-// }
-//
-// g.translate(-x, -y);
-// }
+ /*
+ * Draw icon object based on the given data type.
+ */
+ private void drawIcon(V key, Graphics2D g, int x, int y) {
+ if(key == null)
+ return;
+
+ g.translate(x, y);
+ final Icon icon = iconMap.get(key);
+ if(icon != null)
+ icon.paintIcon(this, g, x, y);
+
+ g.translate(-x, -y);
+
+ // // TODO: Move this to somewhere more appropreate!
+ // if(type.equals(NODE_SHAPE)) {
+ //
+ //
+// final VisualPropertyIcon icon = (VisualPropertyIcon)
+// type.getIconSet().get(key);
+// icon.setIconHeight(size);
+// icon.setIconWidth(size);
+// g.fill(icon.getShape());
+ //
+ // } else if(type.equals(EDGE_SRCARROW_SHAPE) ||
+ // type.equals(EDGE_TGTARROW_SHAPE)) {
+ //
+ // final VisualPropertyIcon arrowIcon = ((VisualPropertyIcon)
+ // type.getIconSet().get(key));
+ // if(arrowIcon == null) {
+ // return;
+ // }
+ // final int newSize = size;
+ // arrowIcon.setIconHeight(newSize);
+ // arrowIcon.setIconWidth(((Number)(newSize*2.5)).intValue());
+ //
+ // g.translate(-newSize, 0);
+ // arrowIcon.paintIcon(this, g, x, y);
+ // g.translate(newSize, 0);
+ //
+ // } else if(type.equals(NODE_FONT_FACE) ||
type.equals(EDGE_FONT_FACE))
+ // {
+ //
+ // final Font font = (Font) key;
+ // final String fontName = font.getFontName();
+ // g.setFont(new Font(fontName, font.getStyle(), size));
+ // g.drawString("A", 0, size);
+ //
+ // final int smallFontSize = ((Number) (size *
0.25)).intValue();
+ // g.setFont(new Font(fontName, font.getStyle(),
smallFontSize));
+ //
+ // int stringWidth =
+ // SwingUtilities.computeStringWidth(g.getFontMetrics(),
+ // fontName);
+ // g.drawString(fontName, (size / 2) - (stringWidth / 2), size +
+ // smallFontSize + 2);
+ //
+ // } else if(type.equals(NODE_LINE_STYLE) ||
+ // type.equals(EDGE_LINE_STYLE)) {
+ //
+ // final Stroke stroke = ((LineStyle) key).getStroke(2.0f);
+ // final int newSize2 = (int) (size * 1.5);
+ // g.translate(0, -size * 0.25);
+ // g.setColor(Color.DARK_GRAY);
+ // g.drawRect(0, 0, size, newSize2);
+ // g.setStroke(stroke);
+ // g.setColor(ICON_COLOR);
+ // g.drawLine(size - 1, 1, 1, newSize2 - 1);
+ // g.translate(0, size * 0.25);
+ //
+ //
+ //
+ // // TODO
+ // // case NODE_LABEL_POSITION:
+ // //
+ // // final LabelPlacerGraphic lp = new
+ // LabelPlacerGraphic((LabelPosition)
+ // key,
+ // // (int) (size * 1.5), false);
+ // // lp.paint(g);
+ // //
+ // // break;
+ // } else if ( type.equals(NODE_LABEL) ||
+ // type.equals(NODE_TOOLTIP) ||
+ // type.equals(EDGE_LABEL) ||
+ // type.equals(EDGE_TOOLTIP) ) {
+ // if(key != null) {
+ // g.drawString(key.toString(), 0, g.getFont().getSize()*2);
+ // }
+ // }
-// /**
-// * DOCUMENT ME!
-// *
-// * @param iconWidth DOCUMENT ME!
-// * @param iconHeight DOCUMENT ME!
-// *
-// * @return DOCUMENT ME!
-// */
-// public ImageIcon getTrackGraphicIcon(int iconWidth, int iconHeight) {
-// return drawIcon(iconWidth, iconHeight, false);
-// }
-//
-// public ImageIcon getLegend(int iconWidth, int iconHeight) {
-// return drawIcon(iconWidth, iconHeight, true);
-// }
-//
-// private ImageIcon drawIcon(int iconWidth, int iconHeight, boolean
detail) {
-// if (slider == null) {
-// return null;
-// }
-//
-// final BufferedImage bi = new BufferedImage(iconWidth,
iconHeight, BufferedImage.TYPE_INT_RGB);
-// final Graphics2D g = bi.createGraphics();
-//
-// // Turn AA on.
-// g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
-//
-// // Fill background
-// g.setColor(Color.white);
-// g.fillRect(0, 0, iconWidth, iconHeight);
-//
-// double minValue = tracer.getMin(type);
-// double maxValue = tracer.getMax(type);
-// double valueRange = tracer.getRange(type);
-//
-// int track_width = iconWidth;
-// int trackHeight = iconHeight - 8;
-// if(detail) {
-// trackHeight = iconHeight - 30;
-// SMALL_ICON_SIZE = (int) (trackHeight * 0.5);
-// } else {
-// trackHeight = iconHeight - 8;
-// }
-//
-// // get the list of tumbs
-// List<Thumb<V>> stops = slider.getModel().getSortedThumbs();
-//
-// int numPoints = stops.size();
-//
-// // set up the data for the gradient
-// float[] fractions = new float[numPoints];
-// Object[] objectValues = new Object[numPoints];
-//
-// /*
-// * Find min, max, and ranges
-// */
-// int i = 0;
-//
-// for (Thumb<V> thumb : stops) {
-// objectValues[i] = thumb.getObject();
-// fractions[i] = thumb.getPosition();
-// i++;
-// }
-//
-// /*
-// * If no points, just draw empty box.
-// */
-// if (numPoints == 0) {
-// g.setColor(BORDER_COLOR);
-// g.setStroke(new BasicStroke(1.0f));
-// g.drawRect(0, 0, track_width - 3, trackHeight);
-//
-// return new ImageIcon(bi);
-// }
-//
-// //TODO: fix this!
+
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param iconWidth
+ * DOCUMENT ME!
+ * @param iconHeight
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public ImageIcon getTrackGraphicIcon(int iconWidth, int iconHeight) {
+ return createIcon(iconWidth, iconHeight, false);
+ }
+
+ public ImageIcon getLegend(int iconWidth, int iconHeight) {
+ return createIcon(iconWidth, iconHeight, true);
+ }
+
+ private ImageIcon createIcon(int iconWidth, int iconHeight, boolean
detail) {
+ if (slider == null) {
+ return null;
+ }
+
+ final BufferedImage bi = new BufferedImage(iconWidth,
iconHeight,
+ BufferedImage.TYPE_INT_RGB);
+ final Graphics2D g = bi.createGraphics();
+
+ // Turn AA on.
+ g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+
+ // Fill background
+ g.setColor(Color.white);
+ g.fillRect(0, 0, iconWidth, iconHeight);
+
+ double minValue = tracer.getMin(vp);
+ double maxValue = tracer.getMax(vp);
+ double valueRange = tracer.getRange(vp);
+
+ int track_width = iconWidth;
+ int trackHeight = iconHeight - 8;
+ if (detail) {
+ trackHeight = iconHeight - 30;
+ smallIconSize = (int) (trackHeight * 0.5);
+ } else {
+ trackHeight = iconHeight - 8;
+ }
+
+ // get the list of tumbs
+ List<Thumb<V>> stops = slider.getModel().getSortedThumbs();
+
+ int numPoints = stops.size();
+
+ // set up the data for the gradient
+ float[] fractions = new float[numPoints];
+ Object[] objectValues = new Object[numPoints];
+
+ /*
+ * Find min, max, and ranges
+ */
+ int i = 0;
+
+ for (Thumb<V> thumb : stops) {
+ objectValues[i] = thumb.getObject();
+ fractions[i] = thumb.getPosition();
+ i++;
+ }
+
+ /*
+ * If no points, just draw empty box.
+ */
+ if (numPoints == 0) {
+ g.setColor(BORDER_COLOR);
+ g.setStroke(new BasicStroke(1.0f));
+ g.drawRect(0, 0, track_width - 3, trackHeight);
+
+ return new ImageIcon(bi);
+ }
+
// rangeObjects = buildIconArray(stops.size() + 1);
-//
-// int newX = 0;
-//
-// Point2D p1 = new Point2D.Float(0, 5);
-// Point2D p2 = new Point2D.Float(0, 5);
-//
-// int iconLocX;
-// int iconLocY;
-//
-// /*
-// * Draw separators and icons
-// */
-// for (i = 0; i < stops.size(); i++) {
-// newX = (int) (track_width * (fractions[i] / 100));
-//
-// p2.setLocation(newX, 0);
-// iconLocX = newX - (((newX - (int) p1.getX()) / 2) +
(SMALL_ICON_SIZE / 2));
-// iconLocY = ((trackHeight) / 2) - (SMALL_ICON_SIZE / 2);
-//
-// if (i == 0) {
-// drawIcon(below, g, iconLocX, iconLocY,
SMALL_ICON_SIZE);
-// } else {
-// drawIcon(objectValues[i], g, iconLocX,
iconLocY, SMALL_ICON_SIZE);
-// }
-//
-// g.setColor(Color.DARK_GRAY);
-// g.setStroke(STROKE1);
-// g.drawLine(newX, 0, newX, trackHeight);
-//
-// p1.setLocation(p2);
-// }
-//
-// /*
-// * Draw last region (above region)
-// */
-// p2.setLocation(track_width, 0);
-//
-// iconLocX = track_width - (((track_width - (int) p1.getX()) / 2)
+ (SMALL_ICON_SIZE / 2));
-// iconLocY = ((trackHeight) / 2) - (SMALL_ICON_SIZE / 2);
-// drawIcon(above, g, iconLocX, iconLocY, SMALL_ICON_SIZE);
-//
-// /*
-// * Finally, draw border line (rectangle)
-// */
-// g.setColor(BORDER_COLOR);
-// g.setStroke(new BasicStroke(1.0f));
-// g.drawRect(0, 0, track_width - 3, trackHeight);
-//
-//
-// g.setFont(new Font("SansSerif", Font.BOLD, 9));
-//
-// final String minStr = String.format("%.2f", minValue);
-// final String maxStr = String.format("%.2f", maxValue);
-// int strWidth;
-// g.setColor(Color.black);
-// if(detail) {
-// String fNum = null;
-// for(int j=0; j<fractions.length; j++) {
-// fNum = String.format("%.2f",
((fractions[j]/100)*valueRange) + minValue);
-// strWidth =
SwingUtilities.computeStringWidth(g.getFontMetrics(), fNum);
-// g.drawString(fNum,
(fractions[j]/100)*iconWidth-strWidth/2, iconHeight-20);
-// }
-//
-// g.drawString(minStr, 0, iconHeight);
-// strWidth =
SwingUtilities.computeStringWidth(g.getFontMetrics(), maxStr);
-// g.drawString(maxStr, iconWidth - strWidth - 2,
iconHeight);
-//
-// g.setFont(TITLE_FONT);
-//
-// final int titleWidth =
SwingUtilities.computeStringWidth(g.getFontMetrics(), title);
-// g.setColor(Color.black);
-// g.drawString(title, (iconWidth / 2) - (titleWidth / 2),
-// iconHeight-5);
-// Polygon p = new Polygon();
-// p.addPoint(iconWidth,iconHeight-9);
-// p.addPoint(iconWidth-15,iconHeight-15 );
-// p.addPoint(iconWidth-15,iconHeight-9 );
-// g.fillPolygon(p);
-// g.drawLine(0, iconHeight-9, (iconWidth / 2) -
(titleWidth / 2)-3, iconHeight-9);
-// g.drawLine((iconWidth / 2) + (titleWidth / 2)+3,
iconHeight-9, iconWidth, iconHeight-9);
-//
-// } else {
-// g.drawString(minStr, 0, iconHeight);
-// strWidth =
SwingUtilities.computeStringWidth(g.getFontMetrics(), maxStr);
-// g.drawString(maxStr, iconWidth - strWidth - 2,
iconHeight);
-// }
-//
-// return new ImageIcon(bi);
-// }
-
+ int newX = 0;
+
+ Point2D p1 = new Point2D.Float(0, 5);
+ Point2D p2 = new Point2D.Float(0, 5);
+
+ int iconLocX;
+ int iconLocY;
+
+ /*
+ * Draw separators and icons
+ */
+ for (i = 0; i < stops.size(); i++) {
+ newX = (int) (track_width * (fractions[i] / 100));
+
+ p2.setLocation(newX, 0);
+ iconLocX = newX
+ - (((newX - (int) p1.getX()) / 2) +
(smallIconSize / 2));
+ iconLocY = ((trackHeight) / 2) - (smallIconSize / 2);
+
+ if (i == 0) {
+ drawIcon(below, g, iconLocX, iconLocY);
+ } else {
+ drawIcon((V) objectValues[i], g, iconLocX,
iconLocY);
+ }
+
+ g.setColor(Color.DARK_GRAY);
+ g.setStroke(STROKE1);
+ g.drawLine(newX, 0, newX, trackHeight);
+
+ p1.setLocation(p2);
+ }
+
+ /*
+ * Draw last region (above region)
+ */
+ p2.setLocation(track_width, 0);
+
+ iconLocX = track_width
+ - (((track_width - (int) p1.getX()) / 2) +
(smallIconSize / 2));
+ iconLocY = ((trackHeight) / 2) - (smallIconSize / 2);
+ drawIcon(above, g, iconLocX, iconLocY);
+
+ /*
+ * Finally, draw border line (rectangle)
+ */
+ g.setColor(BORDER_COLOR);
+ g.setStroke(new BasicStroke(1.0f));
+ g.drawRect(0, 0, track_width - 3, trackHeight);
+
+ g.setFont(new Font("SansSerif", Font.BOLD, 9));
+
+ final String minStr = String.format("%.2f", minValue);
+ final String maxStr = String.format("%.2f", maxValue);
+ int strWidth;
+ g.setColor(Color.black);
+ if (detail) {
+ String fNum = null;
+ for (int j = 0; j < fractions.length; j++) {
+ fNum = String.format("%.2f",
+ ((fractions[j] / 100) *
valueRange) + minValue);
+ strWidth = SwingUtilities.computeStringWidth(
+ g.getFontMetrics(), fNum);
+ g.drawString(fNum, (fractions[j] / 100) *
iconWidth - strWidth
+ / 2, iconHeight - 20);
+ }
+
+ g.drawString(minStr, 0, iconHeight);
+ strWidth =
SwingUtilities.computeStringWidth(g.getFontMetrics(),
+ maxStr);
+ g.drawString(maxStr, iconWidth - strWidth - 2,
iconHeight);
+
+ g.setFont(TITLE_FONT);
+
+ final int titleWidth =
SwingUtilities.computeStringWidth(
+ g.getFontMetrics(), title);
+ g.setColor(Color.black);
+ g.drawString(title, (iconWidth / 2) - (titleWidth / 2),
+ iconHeight - 5);
+ Polygon p = new Polygon();
+ p.addPoint(iconWidth, iconHeight - 9);
+ p.addPoint(iconWidth - 15, iconHeight - 15);
+ p.addPoint(iconWidth - 15, iconHeight - 9);
+ g.fillPolygon(p);
+ g.drawLine(0, iconHeight - 9, (iconWidth / 2) -
(titleWidth / 2)
+ - 3, iconHeight - 9);
+ g.drawLine((iconWidth / 2) + (titleWidth / 2) + 3,
iconHeight - 9,
+ iconWidth, iconHeight - 9);
+
+ } else {
+ g.drawString(minStr, 0, iconHeight);
+ strWidth =
SwingUtilities.computeStringWidth(g.getFontMetrics(),
+ maxStr);
+ g.drawString(maxStr, iconWidth - strWidth - 2,
iconHeight);
+ }
+
+ return new ImageIcon(bi);
+ }
+
public Double getSelectedThumbValue() {
- final double minValue = tracer.getMin(type);
- final double valueRange = tracer.getRange(type);
-
- final float position =
slider.getModel().getThumbAt(slider.getSelectedIndex()).getPosition();
+ final double minValue = tracer.getMin(vp);
+ final double valueRange = tracer.getRange(vp);
+ final float position = slider.getModel()
+
.getThumbAt(slider.getSelectedIndex()).getPosition();
+
return (((position / 100) * valueRange) + minValue);
}
-
+
}
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.