Reimplement ColoredBackground in JDiagram
parent
8cebc3644c
commit
b6b1770ce5
|
@ -7,6 +7,7 @@ import java.awt.Dimension;
|
|||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.util.List;
|
||||
import java.awt.MouseInfo;
|
||||
import java.awt.Point;
|
||||
import java.awt.Toolkit;
|
||||
|
@ -28,6 +29,7 @@ import javax.swing.event.ChangeEvent;
|
|||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import org.hwo.ui.diagram.CirclePlotPainter;
|
||||
import org.hwo.ui.diagram.ColoredBackground;
|
||||
import org.hwo.ui.diagram.DiagramListener;
|
||||
import org.hwo.ui.diagram.DiagramViewEvent;
|
||||
import org.hwo.ui.diagram.LinePlotPainter;
|
||||
|
@ -117,6 +119,7 @@ public class JDiagram extends JComponent implements PlotProviderListener, Bounde
|
|||
private double abzissSpacing;
|
||||
private boolean pointsEnabled;
|
||||
|
||||
private LinkedList<ColoredBackground> coloredBackgrounds = new LinkedList<>();
|
||||
|
||||
public JDiagram(){
|
||||
setMinimumSize(new Dimension(80, 80));
|
||||
|
@ -479,12 +482,22 @@ public class JDiagram extends JComponent implements PlotProviderListener, Bounde
|
|||
if (autoScale)
|
||||
this.autoscale();
|
||||
|
||||
for (ColoredBackground bg: coloredBackgrounds){
|
||||
Point2D pmin = mapDiagramToMouse(new Point2D.Double(0, bg.getMin()));
|
||||
Point2D pmax = mapDiagramToMouse(new Point2D.Double(0, bg.getMax()));
|
||||
|
||||
g.setColor(bg.getColor());
|
||||
g.fillRect(0, (int)pmax.getY(), getWidth(), (int)(pmax.getY() - pmin.getX()));
|
||||
}
|
||||
|
||||
paintOrdinates ((Graphics2D) g);
|
||||
paintAbszisse ((Graphics2D) g);
|
||||
paintGraphs ((Graphics2D) g);
|
||||
}
|
||||
if(mousePos != null)
|
||||
paintMouseCrosshair((Graphics2D) g);
|
||||
|
||||
if(mousePos != null) {
|
||||
paintMouseCrosshair((Graphics2D) g);
|
||||
}
|
||||
}
|
||||
|
||||
public double[] getordinateLabelHints(int ordinate){
|
||||
|
@ -926,4 +939,7 @@ public class JDiagram extends JComponent implements PlotProviderListener, Bounde
|
|||
this.changeListeners.remove(x);
|
||||
}
|
||||
|
||||
public List<ColoredBackground> getColoredBackgrounds() {
|
||||
return coloredBackgrounds;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue