java-org.hwo.ui/src/org/hwo/ui/JDiagram.java

84 lines
1.6 KiB
Java
Raw Normal View History

2015-06-24 23:32:14 +02:00
package org.hwo.ui;
2016-04-28 16:29:16 +02:00
import java.awt.Color;
2015-06-24 23:32:14 +02:00
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JComponent;
import javax.swing.JPanel;
import org.hwo.ui.diagram.Diagram;
public class JDiagram extends JPanel {
private Diagram diagram;
public JDiagram(){
setMinimumSize(new Dimension(80, 80));
2016-04-28 16:29:16 +02:00
getDiagram();
2015-06-24 23:32:14 +02:00
diagram.setFont( getFont() );
}
@Override
public void paint(Graphics g) {
this.diagram.plot((Graphics2D)g, this.getWidth(), this.getHeight());
}
public Diagram getDiagram() {
2016-04-28 16:29:16 +02:00
if (diagram==null)
diagram = new Diagram();
2015-06-24 23:32:14 +02:00
return diagram;
}
public void setDiagram(Diagram diagram) {
this.diagram = diagram;
}
public int getNumLabels(){
return this.diagram.getNumLabels();
}
public void setNumLabels(int nLabels){
this.diagram.setNumLabels(nLabels);
}
public String getLabelFormatSpec(){
return this.diagram.getLabelFormatSpec();
}
public void setLabelFormatSpec(String spec){
this.diagram.setLabelFormatSpec(spec);
}
@Override
public Font getFont() {
return super.getFont();
}
@Override
public void setFont(Font font) {
if (diagram != null)
diagram.setFont(font);
super.setFont(font);
}
2016-04-28 16:29:16 +02:00
@Override
public Color getBackground() {
return getDiagram().getBackground();
}
@Override
public void setBackground(Color bg) {
getDiagram().setBackground(bg);
repaint();
}
@Override
public void setForeground(Color fg) {
getDiagram().setForeground(fg);
repaint();
}
@Override
public Color getForeground() {
return getDiagram().getForeground();
}
2015-06-24 23:32:14 +02:00
}