Author: kono
Date: 2011-10-10 14:42:27 -0700 (Mon, 10 Oct 2011)
New Revision: 27117
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/ObjectPlacerGraphic.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/ColorIcon.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/CustomGraphicsIcon.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/FontFaceIcon.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/NodeIcon.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/ObjectPositionIcon.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/StrokeIcon.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/TextIcon.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/VisualPropertyIcon.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/FlagAndSelectionHandler.java
Log:
fixes #416 Icon sizes and icon alignments are fixed.
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/ObjectPlacerGraphic.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/ObjectPlacerGraphic.java
2011-10-10 21:40:27 UTC (rev 27116)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/ObjectPlacerGraphic.java
2011-10-10 21:42:27 UTC (rev 27117)
@@ -120,8 +120,7 @@
* @param fullDetail
* whether or not to render at full detail or not
*/
- public ObjectPlacerGraphic(final Integer windowSize,
- boolean fullDetail, final String objectName) {
+ public ObjectPlacerGraphic(final Integer windowSize, boolean
fullDetail, final String objectName) {
super();
this.p = new ObjectPositionImpl();
@@ -189,8 +188,7 @@
public void paint(Graphics gin) {
final Graphics2D g = (Graphics2D) gin;
- g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
+ g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
// calculate the font
if (labelLen <= 0) {
@@ -232,14 +230,12 @@
for (int i = 0; i < npoints.length; i++)
for (int j = 0; j < npoints.length; j++) {
g.setColor(transparentMagenta);
- g.fillOval(npoints[i] - (gd / 2),
npoints[j] - (gd / 2),
- gd, gd);
+ g.fillOval(npoints[i] - (gd / 2),
npoints[j] - (gd / 2), gd, gd);
if ((i == bestNodeX) && (j ==
bestNodeY) && !beenDragged)
g.setColor(Color.yellow);
else
g.setColor(Color.black);
- g.fillOval(npoints[i] - (dot / 2),
npoints[j] - (dot / 2),
- dot, dot);
+ g.fillOval(npoints[i] - (dot / 2),
npoints[j] - (dot / 2), dot, dot);
}
}
@@ -248,53 +244,40 @@
g.fillRect(xOffset + xPos, yOffset + yPos, lx, ly);
g.setColor(Color.red);
- g.drawLine(xOffset + xPos, yOffset + yPos, xOffset + xPos + lx,
yOffset
- + yPos);
- g.drawLine(xOffset + xPos + lx, yOffset + yPos, xOffset + xPos
+ lx,
- yOffset + yPos + ly);
- g.drawLine(xOffset + xPos + lx, yOffset + yPos + ly, xOffset +
xPos,
- yOffset + yPos + ly);
- g.drawLine(xOffset + xPos, yOffset + yPos + ly, xOffset + xPos,
yOffset
- + yPos);
+ g.drawLine(xOffset + xPos, yOffset + yPos, xOffset + xPos + lx,
yOffset + yPos);
+ g.drawLine(xOffset + xPos + lx, yOffset + yPos, xOffset + xPos
+ lx, yOffset + yPos + ly);
+ g.drawLine(xOffset + xPos + lx, yOffset + yPos + ly, xOffset +
xPos, yOffset + yPos + ly);
+ g.drawLine(xOffset + xPos, yOffset + yPos + ly, xOffset + xPos,
yOffset + yPos);
// draw the string in the justified location
if (renderDetail) {
int vspace = (ly - ascent - ascent) / 3;
if (justify == JUSTIFY_LEFT) {
- g.drawString(objectLabel, xOffset + xPos +
detailStrokeWidth, yOffset
- + yPos + vspace + ascent);
- g.drawString(click, xOffset + xPos +
detailStrokeWidth, yOffset
- + yPos + (2 * (vspace +
ascent)));
+ g.drawString(objectLabel, xOffset + xPos +
detailStrokeWidth, yOffset + yPos + vspace + ascent);
+ g.drawString(click, xOffset + xPos +
detailStrokeWidth, yOffset + yPos + (2 * (vspace + ascent)));
} else if (justify == JUSTIFY_RIGHT) {
- g.drawString(objectLabel, xOffset + xPos + (lx
- labelLen), yOffset
- + yPos + vspace + ascent);
+ g.drawString(objectLabel, xOffset + xPos + (lx
- labelLen), yOffset + yPos + vspace + ascent);
;
- g.drawString(click, xOffset + xPos + (lx -
clickLen), yOffset
- + yPos + (2 * (vspace +
ascent)));
+ g.drawString(click, xOffset + xPos + (lx -
clickLen), yOffset + yPos + (2 * (vspace + ascent)));
} else { // center
- g.drawString(objectLabel, (xOffset + xPos +
((lx - labelLen) / 2))
- - detailStrokeWidth, yOffset +
yPos + vspace + ascent);
- g.drawString(click, (xOffset + xPos + ((lx -
clickLen) / 2))
- - detailStrokeWidth, yOffset +
yPos
+ g.drawString(objectLabel, (xOffset + xPos +
((lx - labelLen) / 2)) - detailStrokeWidth, yOffset + yPos
+ + vspace + ascent);
+ g.drawString(click, (xOffset + xPos + ((lx -
clickLen) / 2)) - detailStrokeWidth, yOffset + yPos
+ (2 * (vspace + ascent)));
}
} else {
g.setColor(Color.gray);
if (justify == JUSTIFY_LEFT)
- g.drawLine(xOffset + xPos + lowStrokeWidth,
yOffset + yPos
- + (ly / 2), xOffset + xPos +
(lx / 3), yOffset + yPos
- + (ly / 2));
+ g.drawLine(xOffset + xPos + lowStrokeWidth,
yOffset + yPos + (ly / 2), xOffset + xPos + (lx / 3),
+ yOffset + yPos + (ly / 2));
else if (justify == JUSTIFY_RIGHT)
- g.drawLine(xOffset + xPos + ((2 * lx) / 3),
yOffset + yPos
- + (ly / 2), xOffset + xPos +
lx, yOffset + yPos
- + (ly / 2));
+ g.drawLine(xOffset + xPos + ((2 * lx) / 3),
yOffset + yPos + (ly / 2), xOffset + xPos + lx, yOffset
+ + yPos + (ly / 2));
else
- g.drawLine(xOffset + xPos + (lx / 3),
- yOffset + yPos + (ly / 2),
- (xOffset + xPos + ((2 * lx) /
3)) - lowStrokeWidth,
- yOffset + yPos + (ly / 2));
+ g.drawLine(xOffset + xPos + (lx / 3), yOffset +
yPos + (ly / 2), (xOffset + xPos + ((2 * lx) / 3))
+ - lowStrokeWidth, yOffset +
yPos + (ly / 2));
}
if (renderDetail) {
@@ -306,9 +289,8 @@
if ((i == bestLabelX) && (j ==
bestLabelY) && !beenDragged)
g.setColor(Color.yellow);
- g.fillOval((xPos + xOffset +
lxpoints[i]) - (dot / 2),
- (yPos + yOffset +
lypoints[j]) - (dot / 2), dot,
- dot);
+ g.fillOval((xPos + xOffset +
lxpoints[i]) - (dot / 2), (yPos + yOffset + lypoints[j]) - (dot / 2),
+ dot, dot);
if ((i == bestLabelX) && (j ==
bestLabelY))
g.setColor(Color.black);
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/ColorIcon.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/ColorIcon.java
2011-10-10 21:40:27 UTC (rev 27116)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/ColorIcon.java
2011-10-10 21:42:27 UTC (rev 27117)
@@ -1,18 +1,16 @@
package org.cytoscape.ding.icon;
-import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
-import java.awt.Stroke;
public class ColorIcon extends VisualPropertyIcon<Color> {
private static final long serialVersionUID = 5636448639330547200L;
- private static final Stroke BORDER = new BasicStroke(1.0f);
+ private static final float ARC_RATIO = 0.35f;
public ColorIcon(final Color value, final int width, final int height,
final String name) {
super(value, width, height, name);
@@ -24,12 +22,9 @@
// Turn AA on
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
+ Float arc = width * ARC_RATIO;
g2d.setColor(value);
- g2d.fillRect(x+leftPad, y+bottomPad, width, height);
- g2d.setColor(color);
- g2d.setStroke(BORDER);
- g2d.drawRect(x+leftPad, y+bottomPad, width, height);
-
+ g2d.fillRoundRect(x+leftPad, y, width, height, arc.intValue(),
arc.intValue());
}
}
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/CustomGraphicsIcon.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/CustomGraphicsIcon.java
2011-10-10 21:40:27 UTC (rev 27116)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/CustomGraphicsIcon.java
2011-10-10 21:42:27 UTC (rev 27117)
@@ -23,9 +23,7 @@
// AA on
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
- g2d.translate(0, bottomPad);
- g2d.drawImage(getImage(), 0, (c.getHeight() - height) / 2,
width, height, c);
- g2d.translate(0, -bottomPad);
+ g2d.drawImage(getImage(), leftPad, (c.getHeight() - height) /
2, width, height, c);
}
}
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/FontFaceIcon.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/FontFaceIcon.java
2011-10-10 21:40:27 UTC (rev 27116)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/FontFaceIcon.java
2011-10-10 21:42:27 UTC (rev 27117)
@@ -15,14 +15,15 @@
private static final long serialVersionUID = 4629615986711780878L;
- private static final String TEXT = "ABC";
+ private static final String TEXT = "A";
+
private static final Color FONT_COLOR = Color.DARK_GRAY;
private final Font font;
public FontFaceIcon(Font value, int width, int height, String name) {
super(value, width, height, name);
- font = new Font(value.getFamily(), value.getStyle(), width - 2);
+ font = new Font(value.getFamily(), value.getStyle(), height);
}
@Override
@@ -32,16 +33,11 @@
g2d.setColor(FONT_COLOR);
// AA on
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
- g2d.translate(leftPad, bottomPad);
-
g2d.setFont(font);
+ g2d.drawString(TEXT, x+leftPad+5, y+(c.getHeight()/2));
- g2d.drawString(TEXT, 20, (height + 40) / 2);
-
- g2d.translate(-leftPad, -bottomPad);
g2d.setFont(originalFont);
}
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/NodeIcon.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/NodeIcon.java
2011-10-10 21:40:27 UTC (rev 27116)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/NodeIcon.java
2011-10-10 21:42:27 UTC (rev 27117)
@@ -116,10 +116,7 @@
// AA on
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
- g2d.translate(0, bottomPad);
- newShape = value;
-
af.setToTranslation(leftPad, (c.getHeight() -
newShape.getBounds2D().getHeight()) / 2);
newShape = af.createTransformedShape(newShape);
@@ -127,7 +124,6 @@
g2d.setStroke(new BasicStroke(2.0f));
g2d.draw(newShape);
- g2d.translate(0, -bottomPad);
}
/**
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/ObjectPositionIcon.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/ObjectPositionIcon.java
2011-10-10 21:40:27 UTC (rev 27116)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/ObjectPositionIcon.java
2011-10-10 21:42:27 UTC (rev 27117)
@@ -1,5 +1,6 @@
package org.cytoscape.ding.icon;
+import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
@@ -13,23 +14,33 @@
private static final long serialVersionUID = 6852491198236306710L;
private Graphics2D g2d;
+ private static final float ARC_RATIO = 0.35f;
+
+ private static final Color BACK = new Color(0x1f, 0x1f, 0x1f, 150);
public ObjectPositionIcon(final ObjectPosition value, int width, int
height, String name) {
super(value, width, height, name);
}
-
-
+
@Override public void paintIcon(Component c, Graphics g, int x, int y) {
g2d = (Graphics2D) g;
// AA on
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
+ // Transform to fit to the component
+ g2d.translate((x+leftPad), y);
+ Float arc = width * ARC_RATIO;
+ g2d.setColor(BACK);
+ g2d.fillRoundRect(0, 0, width, height, arc.intValue(),
arc.intValue());
final ObjectPlacerGraphic lp = new ObjectPlacerGraphic(width,
false, "Label");
lp.setObjectPosition(value);
lp.applyPosition();
lp.paint(g2d);
+
+ // Transform to fit to the component
+ g2d.translate(-(x+leftPad), -y);
}
}
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/StrokeIcon.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/StrokeIcon.java
2011-10-10 21:40:27 UTC (rev 27116)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/StrokeIcon.java
2011-10-10 21:42:27 UTC (rev 27117)
@@ -70,45 +70,39 @@
super(stroke, width, height, name);
}
- /**
- * DOCUMENT ME!
- *
- * @param c DOCUMENT ME!
- * @param g DOCUMENT ME!
- * @param x DOCUMENT ME!
- * @param y DOCUMENT ME!
- */
+
@Override public void paintIcon(Component c, Graphics g, int x, int y) {
g2d = (Graphics2D) g;
g2d.setColor(color);
// AA on
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
- g2d.translate(leftPad, bottomPad);
+ //g2d.translate(leftPad, bottomPad);
g2d.setStroke(value);
- g2d.draw(new Line2D.Double(20, (height + 20) / 2, width*2,
(height + 20) / 2));
+ final int yPosition = (height + 20) / 2;
+ g2d.draw(new Line2D.Double(leftPad, yPosition, width*1.5,
yPosition));
- /*
- * Superimpose text if text object is not empty.
- */
- if (superimposedText != null) {
-
- if (textColor == null) {
- g2d.setColor(Color.DARK_GRAY);
- } else
- g2d.setColor(textColor);
-
- if (textFont == null) {
- g2d.setFont(new Font("SansSerif", Font.BOLD,
24));
- } else {
- g2d.setFont(textFont);
- }
-
- g2d.drawString(superimposedText, 20, (height + 40) / 2);
- }
-
- g2d.translate(-leftPad, -bottomPad);
- g2d.setFont(new Font("SansSerif", Font.BOLD, 14));
+// /*
+// * Superimpose text if text object is not empty.
+// */
+// if (superimposedText != null) {
+//
+// if (textColor == null) {
+// g2d.setColor(Color.DARK_GRAY);
+// } else
+// g2d.setColor(textColor);
+//
+// if (textFont == null) {
+// g2d.setFont(new Font("SansSerif", Font.BOLD,
24));
+// } else {
+// g2d.setFont(textFont);
+// }
+//
+// g2d.drawString(superimposedText, 20, (height + 40) / 2);
+// }
+//
+// //g2d.translate(-leftPad, -bottomPad);
+// g2d.setFont(new Font("SansSerif", Font.BOLD, 14));
}
/**
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/TextIcon.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/TextIcon.java
2011-10-10 21:40:27 UTC (rev 27116)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/TextIcon.java
2011-10-10 21:42:27 UTC (rev 27117)
@@ -9,13 +9,12 @@
public class TextIcon extends VisualPropertyIcon<Object> {
private static final long serialVersionUID = -4217147694751380332L;
-
- private static final Font font = new Font("SansSerif", Font.BOLD, 18);
- public TextIcon(final Object value, final int width, final int height,
- final String name) {
+ private static final int FONT_SIZE = 20;
+ private static final Font FONT = new Font("SansSerif", Font.BOLD,
FONT_SIZE);
+
+ public TextIcon(final Object value, final int width, final int height,
final String name) {
super(value, width, height, name);
- this.leftPad = 15;
}
@Override
@@ -23,16 +22,17 @@
final Graphics2D g2d = (Graphics2D) g;
// Turn AA on
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
final Font original = g2d.getFont();
+
if (value != null) {
g2d.setColor(color);
- g2d.setFont(font);
- g2d.drawString(value.toString(), leftPad, height/2+7);
+ g2d.setFont(FONT);
+ final int cHeight = c.getHeight();
+ g2d.drawString(value.toString(), x+leftPad+5, y +
(cHeight/2) - 5);
}
-
+
g2d.setFont(original);
}
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/VisualPropertyIcon.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/VisualPropertyIcon.java
2011-10-10 21:40:27 UTC (rev 27116)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/VisualPropertyIcon.java
2011-10-10 21:42:27 UTC (rev 27117)
@@ -66,7 +66,7 @@
final protected T value;
final protected String name;
- protected int leftPad = 0;
+ protected int leftPad = 20;
protected int bottomPad = 0;
/**
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/FlagAndSelectionHandler.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/FlagAndSelectionHandler.java
2011-10-10 21:40:27 UTC (rev 27116)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/FlagAndSelectionHandler.java
2011-10-10 21:42:27 UTC (rev 27117)
@@ -144,8 +144,11 @@
if (nodesOrEdges.isEmpty())
return;
+
for (final CyTableEntry nodeOrEdge : nodesOrEdges)
nodeOrEdge.getCyRow().set(CyNetwork.SELECTED, selected);
+
+ System.out.println("@Selection END!");
}
/**
--
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.