Skip to content
Snippets Groups Projects
Commit 8d82fc49 authored by tcarver's avatar tcarver
Browse files

allow graph lines to have a line size of zero to be able to hide them

parent 4d284913
No related branches found
No related tags found
No related merge requests found
...@@ -767,6 +767,8 @@ public class BasePlot extends Plot ...@@ -767,6 +767,8 @@ public class BasePlot extends Plot
if(i < lines.length) if(i < lines.length)
{ {
g.setColor(lines[i].getLineColour()); g.setColor(lines[i].getLineColour());
if(lines[i].getStroke() == null)
continue;
((Graphics2D)g).setStroke(lines[i].getStroke()); ((Graphics2D)g).setStroke(lines[i].getStroke());
} }
else else
......
...@@ -67,7 +67,7 @@ public class LineAttributes ...@@ -67,7 +67,7 @@ public class LineAttributes
private BasicStroke stroke; private BasicStroke stroke;
private static float dotDash[] = {10.f, 5.f, 3.f, 5.f}; private static float dotDash[] = {10.f, 5.f, 3.f, 5.f};
private static float dash[] = {10.f}; private static float dash[] = {5.f};
private static BasicStroke style1 = private static BasicStroke style1 =
new BasicStroke(1.f); new BasicStroke(1.f);
...@@ -131,6 +131,8 @@ public class LineAttributes ...@@ -131,6 +131,8 @@ public class LineAttributes
*/ */
private static int getStyleIndex(BasicStroke stroke) private static int getStyleIndex(BasicStroke stroke)
{ {
if(stroke == null)
stroke = style1;
float myDash[] = stroke.getDashArray(); float myDash[] = stroke.getDashArray();
if(myDash != null && if(myDash != null &&
myDash.length == dotDash.length) myDash.length == dotDash.length)
...@@ -304,8 +306,13 @@ public class LineAttributes ...@@ -304,8 +306,13 @@ public class LineAttributes
panel.add(butt, c); panel.add(butt, c);
// line style // line style
final JSlider slider = new JSlider(1, 10, final int lineWidth;
(int)lines[colourNumber].getStroke().getLineWidth()); if(lines[colourNumber].getStroke() == null)
lineWidth = 0;
else
lineWidth = (int)lines[colourNumber].getStroke().getLineWidth();
final JSlider slider = new JSlider(0, 10, lineWidth);
Integer index[] = new Integer[STROKES.length]; Integer index[] = new Integer[STROKES.length];
for(int j=0; j<index.length; j++) for(int j=0; j<index.length; j++)
index[j] = j; index[j] = j;
...@@ -331,6 +338,8 @@ public class LineAttributes ...@@ -331,6 +338,8 @@ public class LineAttributes
{ {
public void stateChanged(ChangeEvent e) public void stateChanged(ChangeEvent e)
{ {
thislines[colourNumber].setStroke(
STROKES[lineStyle.getSelectedIndex()]);
setLineSize(plot, slider, thislines, colourNumber); setLineSize(plot, slider, thislines, colourNumber);
} }
}); });
...@@ -369,11 +378,16 @@ public class LineAttributes ...@@ -369,11 +378,16 @@ public class LineAttributes
private static void setLineSize(Plot plot, JSlider slider, private static void setLineSize(Plot plot, JSlider slider,
LineAttributes[] thislines, int number) LineAttributes[] thislines, int number)
{ {
BasicStroke oldStroke = thislines[number].getStroke(); if(slider.getValue() == 0.f)
BasicStroke newStroke = new BasicStroke(slider.getValue(), thislines[number].setStroke(null);
else
{
BasicStroke oldStroke = thislines[number].getStroke();
BasicStroke newStroke = new BasicStroke(slider.getValue(),
BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER,
1.f, oldStroke.getDashArray(), 0.f); 1.f, oldStroke.getDashArray(), 0.f);
thislines[number].setStroke(newStroke); thislines[number].setStroke(newStroke);
}
plot.repaint(); plot.repaint();
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment