Author: jfuerth
Date: Tue Apr 7 14:24:15 2009
New Revision: 2976
Modified:
trunk/src/ca/sqlpower/architect/swingui/BasicRelationshipUI.java
trunk/src/ca/sqlpower/architect/swingui/IERelationshipUI.java
trunk/src/ca/sqlpower/architect/swingui/Relationship.java
Log:
Fix for "relationship lines appear to vanish when selected." (This issue
was reported on the forum by bronius).
Now we use SQL Power Orange for selected relations that can't be darkened.
We also changed the column highlight to match, so it's now more obvious
what the column highlight means in this context.
With additional suggestions from Giulio, we now also double the line
thickness when a relationship is selected, since colour alone can be
ambiguous.
Modified: trunk/src/ca/sqlpower/architect/swingui/BasicRelationshipUI.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/BasicRelationshipUI.java
(original)
+++ trunk/src/ca/sqlpower/architect/swingui/BasicRelationshipUI.java Tue
Apr 7 14:24:15 2009
@@ -37,6 +37,8 @@
import org.apache.log4j.Logger;
+import ca.sqlpower.swingui.ColourScheme;
+
/**
* The BasicRelationshipUI is responsible for drawing the lines
* between tables. Subclasses decorate the ends of the lines.
@@ -68,9 +70,16 @@
*/
protected transient GeneralPath containmentPath;
- protected BasicStroke nonIdStroke = new BasicStroke(1.0f);
- protected BasicStroke idStroke = new BasicStroke(1.0f);
-
+ /**
+ * The stroke width to use when the relationship is selected.
+ */
+ protected float nonSelectedStrokeWidth = 1f;
+
+ /**
+ * The stroke width to use when the relationship is not selected.
+ */
+ protected float selectedStrokeWidth = 2f;
+
/**
* Points within radius pixels of this relationship's visible path
* are considered to be contained within this component.
@@ -248,15 +257,11 @@
path = new GeneralPath(containmentPath);
}
- // if the relationship line is selected and the darker color
- // is the same, then set it to default selected color
- // (204,204,255)
-
if (!r.isSelected()) {
g2.setColor(r.getForegroundColor());
} else {
if(r.getForegroundColor().darker().equals(r.getForegroundColor())) {
- g2.setColor(new Color(204,204,255));
+ g2.setColor(ColourScheme.SQLPOWER_ORANGE);
} else {
g2.setColor(r.getForegroundColor().darker());
}
@@ -273,8 +278,9 @@
g2.draw(path);
if (logger.isDebugEnabled()) logger.debug("Drew path
"+path);
- g2.setStroke(oldStroke);
+ g2.setStroke(new BasicStroke(getStrokeWidth()));
paintTerminations(g2, start, end, orientation);
+ g2.setStroke(oldStroke);
} finally {
g2.translate(c.getX(), c.getY()); // playpen coordinate
space
}
@@ -595,12 +601,30 @@
return relationship;
}
+ /**
+ * Returns the stroke thickness that should be used, based on the
+ * relationship component's current state (for example, whether or not
it's
+ * selected).
+ * <p>
+ * If you just want to know what stroke to use, don't call this
method; use
+ * {...@link #getIdentifyingStroke()} or {...@link
#getNonIdentifyingStroke()}.
+ *
+ * @return The correct stroke thickness to use.
+ */
+ protected float getStrokeWidth() {
+ if (relationship.isSelected()) {
+ return selectedStrokeWidth;
+ } else {
+ return nonSelectedStrokeWidth;
+ }
+ }
+
public Stroke getIdentifyingStroke() {
- return idStroke;
+ return new BasicStroke(getStrokeWidth());
}
public Stroke getNonIdentifyingStroke() {
- return nonIdStroke;
+ return new BasicStroke(getStrokeWidth());
}
/**
Modified: trunk/src/ca/sqlpower/architect/swingui/IERelationshipUI.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/IERelationshipUI.java
(original)
+++ trunk/src/ca/sqlpower/architect/swingui/IERelationshipUI.java Tue Apr
7 14:24:15 2009
@@ -34,13 +34,6 @@
logger.debug("Creating new IERelationshipUI for "+c);
return new IERelationshipUI();
}
-
- public IERelationshipUI() {
- idStroke = new BasicStroke(1.0f);
- nonIdStroke = new BasicStroke(
- 1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL,
- 1.0f, new float[] {15.0f, 4.0f}, 0.0f);
- }
/**
* Paints relationship line terminations based on the IE diagram
@@ -168,10 +161,12 @@
}
public Stroke getIdentifyingStroke() {
- return idStroke;
+ return new BasicStroke(getStrokeWidth());
}
public Stroke getNonIdentifyingStroke() {
- return nonIdStroke;
+ return new BasicStroke(
+ getStrokeWidth(), BasicStroke.CAP_BUTT,
BasicStroke.JOIN_BEVEL,
+ 1.0f, new float[] {15.0f, 4.0f}, 0.0f);
}
}
Modified: trunk/src/ca/sqlpower/architect/swingui/Relationship.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/Relationship.java (original)
+++ trunk/src/ca/sqlpower/architect/swingui/Relationship.java Tue Apr 7
14:24:15 2009
@@ -72,7 +72,7 @@
/**
* The colour to highlight related columns with when this relationship is
selected.
*/
- private Color columnHighlightColour = Color.red;
+ private Color columnHighlightColour = ColourScheme.SQLPOWER_ORANGE;
/**
* This constructor is only for making a copy of an existing
relationship component.