Skip to content
Permalink
Browse files

fix: Default track color is a property of the panel

This addresses a static analysis warning, which also revealed that the default track color, although settable per Panel, was actually an application-wide setting. Removing the static field makes this a panel-specific setting again.
  • Loading branch information...
rhwood committed May 18, 2019
1 parent b436d39 commit 4b0c247707508bb7c52e91be58728ddabeb73863
@@ -9268,7 +9268,6 @@ public void setSidelineTrackWidth(int w) {
* @param color value to set the default track color to.
*/
public void setDefaultTrackColor(@Nonnull Color color) {
LayoutTrack.setDefaultTrackColor(color);
defaultTrackColor = color;
JmriColorChooser.addRecentColor(color);
}
@@ -70,17 +70,13 @@
//protected static double maxDashLength = 10;
protected boolean hidden = false;

// package-private
static Color defaultTrackColor = Color.black;

/**
* constructor method
*/
public LayoutTrack(@Nonnull String ident, @Nonnull Point2D c, @Nonnull LayoutEditor layoutEditor) {
this.ident = ident;
this.center = c;
this.layoutEditor = layoutEditor;
defaultTrackColor = layoutEditor.getDefaultTrackColorColor();
}

/**
@@ -138,10 +134,6 @@ public void setDecorations(Map<String, String> decorations) {
}
protected Map<String, String> decorations = null;

public static void setDefaultTrackColor(@Nullable Color color) {
defaultTrackColor = color;
}

protected Color getColorForTrackBlock(
@Nullable LayoutBlock layoutBlock, boolean forceBlockTrackColor) {
Color result = ColorUtil.CLEAR; // transparent
@@ -1108,7 +1108,7 @@ protected void draw1(Graphics2D g2, boolean isMain, boolean isBlock) {
Color color = g2.getColor();
// draw turntable circle - default track color, side track width
g2.setStroke(new BasicStroke(trackWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND));
g2.setColor(defaultTrackColor);
g2.setColor(layoutEditor.getDefaultTrackColorColor());
g2.draw(new Ellipse2D.Double(center.getX() - radius, center.getY() - radius, diameter, diameter));
g2.setStroke(stroke);
g2.setColor(color);
@@ -1123,7 +1123,7 @@ protected void draw1(Graphics2D g2, boolean isMain, boolean isBlock) {
}
if (isBlock) {
if (ts == null) {
g2.setColor(defaultTrackColor);
g2.setColor(layoutEditor.getDefaultTrackColorColor());
} else {
setColorForTrackBlock(g2, ts.getLayoutBlock());
}
@@ -1224,7 +1224,7 @@ protected void drawTurnoutControls(Graphics2D g2) {
@Override
protected void drawEditControls(Graphics2D g2) {
Point2D pt = getCoordsCenter();
g2.setColor(defaultTrackColor);
g2.setColor(layoutEditor.getDefaultTrackColorColor());
g2.draw(layoutEditor.trackControlCircleAt(pt));

for (int j = 0; j < getNumberRays(); j++) {
@@ -1537,7 +1537,7 @@ protected void highlightUnconnected(Graphics2D g2, int specificType) {

@Override
protected void drawEditControls(Graphics2D g2) {
g2.setColor(defaultTrackColor);
g2.setColor(layoutEditor.getDefaultTrackColorColor());
//TODO:uncomment this line g2.draw(layoutEditor.trackEditControlCircleAt(getCoordsCenter()));

if (getConnectA() == null) {
@@ -3094,6 +3094,7 @@ public boolean hasDecorations() {
*/
@Override
public void setDecorations(Map<String, String> decorations) {
Color defaultTrackColor = layoutEditor.getDefaultTrackColorColor();
super.setDecorations(decorations);
if (decorations != null) {
for (Map.Entry<String, String> entry : decorations.entrySet()) {

0 comments on commit 4b0c247

Please sign in to comment.
You can’t perform that action at this time.