1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
/*
* (non-Javadoc)
* @see math.xyploter.data.view.CurvesView#draw(java.awt.Graphics2D, java.awt.geom.Rectangle2D, math.xyploter.axis.Axis, math.xyploter.axis.Axis, math.number.ValueReader)
*/
@Override
public void draw(final Graphics2D g2, final Rectangle2D parentBounds, final Axis xAxis, final Axis yAxis, final ValueReader reader) {
try {
if (drawThread != null && drawThread.isAlive()) {
drawThread.interrupt();
drawThread.join(); // wait before continue
}
Runnable r = new Runnable() {
public void run() {
for (V view:MainCurveViews.this) {
if (Thread.currentThread().isInterrupted()) {
break;
}
view.draw(g2, parentBounds, xAxis, yAxis, reader);
}
};
};
drawThread = new Thread(r);
drawThread.setDaemon(true); // allows not stopping the JVM close method
//drawThread.setPriority(Thread.MIN_PRIORITY);
drawThread.start();
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
catch(java.util.ConcurrentModificationException e) {
System.out.println("MainCurveViews.draw() error:ConcurrentModificationException");
}
} |
Partager