Java 类org.jfree.chart.plot.dial.DialBackground 实例源码

项目:mars-sim    文件:TemperatureDial.java   
public JFreeChart createStandardDialChart(String s, String s1, ValueDataset valuedataset, double d, double d1, double d2, int i) {
    DialPlot dialplot = new DialPlot();
    dialplot.setDataset(valuedataset);
    dialplot.setDialFrame(new StandardDialFrame());
    dialplot.setBackground(new DialBackground());
    DialTextAnnotation dialtextannotation = new DialTextAnnotation(s1);
    dialtextannotation.setFont(new Font("Dialog", 1, 14));
    dialtextannotation.setRadius(0.69999999999999996D);
    dialplot.addLayer(dialtextannotation);
    DialValueIndicator dialvalueindicator = new DialValueIndicator(0);
    dialplot.addLayer(dialvalueindicator);
    StandardDialScale standarddialscale = new StandardDialScale(d, d1, -120D, -300D, 10D, 4);
    standarddialscale.setMajorTickIncrement(d2);
    standarddialscale.setMinorTickCount(i);
    standarddialscale.setTickRadius(0.88D);
    standarddialscale.setTickLabelOffset(0.14999999999999999D);
    standarddialscale.setTickLabelFont(new Font("Dialog", 0, 14));
    dialplot.addScale(0, standarddialscale);
    dialplot.addPointer(new org.jfree.chart.plot.dial.DialPointer.Pin());
    DialCap dialcap = new DialCap();
    dialplot.setCap(dialcap);
    return new JFreeChart(s, dialplot);
}
项目:astor    文件:DialPlotTests.java   
/**
 * Check the notification event mechanism for the dial background.
 */
public void testBackgroundListener() {
    DialPlot p = new DialPlot();
    DialBackground b1 = new DialBackground(Color.red);
    p.setBackground(b1);
    p.addChangeListener(this);
    this.lastEvent = null;
    b1.setPaint(Color.blue);
    assertNotNull(this.lastEvent);

    DialBackground b2 = new DialBackground(Color.green);
    p.setBackground(b2);
    this.lastEvent = null;
    b1.setPaint(Color.red);
    assertNull(this.lastEvent);
    b2.setPaint(Color.red);
    assertNotNull(this.lastEvent);
}
项目:astor    文件:DialPlotTests.java   
/**
 * Check the notification event mechanism for a layer.
 */
public void testLayerListener() {
    DialPlot p = new DialPlot();
    DialBackground b1 = new DialBackground(Color.red);
    p.addLayer(b1);
    p.addChangeListener(this);
    this.lastEvent = null;
    b1.setPaint(Color.blue);
    assertNotNull(this.lastEvent);

    DialBackground b2 = new DialBackground(Color.green);
    p.addLayer(b2);
    this.lastEvent = null;
    b1.setPaint(Color.red);
    assertNotNull(this.lastEvent);
    b2.setPaint(Color.green);
    assertNotNull(this.lastEvent);

    p.removeLayer(b2);
    this.lastEvent = null;
    b2.setPaint(Color.red);
    assertNull(this.lastEvent);
}
项目:mars-sim    文件:TemperatureDial.java   
public TemperaturePanel() {
    super(new BorderLayout());
    dataset = new DefaultValueDataset(currentT);
    JFreeChart jfreechart = createStandardDialChart("", "Temperature", dataset, -120D, 20D, 10D, 4);
    DialPlot dialplot = (DialPlot)jfreechart.getPlot();
    StandardDialRange standarddialrange = new StandardDialRange(-20D, 20D, Color.blue);
    standarddialrange.setInnerRadius(0.52000000000000002D);
    standarddialrange.setOuterRadius(0.55000000000000004D);
    dialplot.addLayer(standarddialrange);
    StandardDialRange standarddialrange1 = new StandardDialRange(-60D, -20D, Color.orange);
    standarddialrange1.setInnerRadius(0.52000000000000002D);
    standarddialrange1.setOuterRadius(0.55000000000000004D);
    dialplot.addLayer(standarddialrange1);
    StandardDialRange standarddialrange2 = new StandardDialRange(-120D, -60D, Color.red);
    standarddialrange2.setInnerRadius(0.52000000000000002D);
    standarddialrange2.setOuterRadius(0.55000000000000004D);
    dialplot.addLayer(standarddialrange2);
    GradientPaint gradientpaint = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(170, 170, 220));
    DialBackground dialbackground = new DialBackground(gradientpaint);
    dialbackground.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    dialplot.setBackground(dialbackground);
    dialplot.removePointer(0);
    org.jfree.chart.plot.dial.DialPointer.Pointer pointer = new org.jfree.chart.plot.dial.DialPointer.Pointer();
    pointer.setFillPaint(Color.yellow);
    dialplot.addPointer(pointer);
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    //chartpanel.setPreferredSize(new Dimension(200, 200));
    //chartpanel.setSize(200, 200);
    chartpanel.setMinimumDrawHeight(150);
    chartpanel.setMaximumDrawHeight(150);
    chartpanel.setMaximumDrawWidth(150);
    chartpanel.setMinimumDrawWidth(150);
    //slider = new JSlider(-120, 20);
    //slider.setMajorTickSpacing(10);
    //slider.setPaintLabels(true);
    //slider.addChangeListener(this);
    add(chartpanel);
    //add(slider, "South");
}
项目:astor    文件:DialBackgroundTests.java   
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    DialBackground b1 = new DialBackground();
    DialBackground b2 = new DialBackground();
    assertTrue(b1.equals(b2));

    // paint
    b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f,
            Color.yellow));
    assertFalse(b1.equals(b2));
    b2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f,
            Color.yellow));
    assertTrue(b1.equals(b2));

    // gradient paint transformer
    b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(
            GradientPaintTransformType.CENTER_VERTICAL));
    assertFalse(b1.equals(b2));
    b2.setGradientPaintTransformer(new StandardGradientPaintTransformer(
            GradientPaintTransformType.CENTER_VERTICAL));
    assertTrue(b1.equals(b2));

    // check an inherited attribute
    b1.setVisible(false);
    assertFalse(b1.equals(b2));
    b2.setVisible(false);
    assertTrue(b1.equals(b2));

}
项目:astor    文件:DialBackgroundTests.java   
/**
 * Two objects that are equal are required to return the same hashCode.
 */
public void testHashCode() {
    DialBackground b1 = new DialBackground(Color.red);
    DialBackground b2 = new DialBackground(Color.red);
    assertTrue(b1.equals(b2));
    int h1 = b1.hashCode();
    int h2 = b2.hashCode();
    assertEquals(h1, h2);
}
项目:bamboobsc    文件:CommonMeterChartAction.java   
private void fillChart(String title, float value, int lowerBound, int upperBound) throws Exception {
    DefaultValueDataset dataset = new DefaultValueDataset();

    dataset.setValue(value);

    DialPlot plot = new DialPlot();
    plot.setView(0.0d, 0.0d, 1.0d, 1.0d);
    plot.setDataset(0, dataset);

    StandardDialFrame frame = new StandardDialFrame();
    plot.setDialFrame(frame);
    DialBackground dialBackground = new DialBackground();
    dialBackground.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    plot.setBackground(dialBackground);
    DialTextAnnotation textAnnotation = new DialTextAnnotation( title );
    textAnnotation.setRadius(0.555555555555555555D);
    plot.addLayer(textAnnotation);

    DialValueIndicator valueIndicator = new DialValueIndicator(0);
    plot.addLayer(valueIndicator);

    StandardDialScale scale1 = new StandardDialScale();
    scale1.setLowerBound( lowerBound );
    scale1.setUpperBound( upperBound );
    scale1.setStartAngle( -140 ); // -120
    scale1.setExtent( -260D ); // -300D 
    scale1.setTickRadius(0.88D);
    scale1.setTickLabelOffset(0.14999999999999999D); 
    scale1.setTickLabelFont(new Font("", Font.TRUETYPE_FONT, 14)); 
    plot.addScale(0, scale1);

    StandardDialRange standarddialrange0 = new StandardDialRange( lowerBound, (upperBound*0.6), Color.red);
    standarddialrange0.setInnerRadius(0.52000000000000002D);
    standarddialrange0.setOuterRadius(0.55000000000000004D);
    plot.addLayer(standarddialrange0);

    StandardDialRange standarddialrange1 = new StandardDialRange( (upperBound*0.6), (upperBound*0.8), Color.orange);
    standarddialrange1.setInnerRadius(0.52000000000000002D);
    standarddialrange1.setOuterRadius(0.55000000000000004D);
    plot.addLayer(standarddialrange1);

    StandardDialRange standarddialrange2 = new StandardDialRange( (upperBound*0.8), upperBound, Color.green);
    standarddialrange2.setInnerRadius(0.52000000000000002D);
    standarddialrange2.setOuterRadius(0.55000000000000004D);
    plot.addLayer(standarddialrange2);

    Pointer pointer = new Pointer(0); 
    pointer.setFillPaint(new Color(144, 196, 246));
    plot.addPointer(pointer);
    plot.mapDatasetToScale(0, 0);
    DialCap dialcap = new DialCap();
    dialcap.setRadius(0.0700000000000001D);
    plot.setCap(dialcap);

    this.chart = new JFreeChart(plot);
    //this.chart.setBackgroundPaint(new Color(234, 244, 253));
    this.chart.setBackgroundPaint( Color.white );
}
项目:astor    文件:DialPlotTests.java   
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    DialPlot p1 = new DialPlot();
    DialPlot p2 = new DialPlot();
    assertTrue(p1.equals(p2));

    // background
    p1.setBackground(new DialBackground(Color.green));
    assertFalse(p1.equals(p2));
    p2.setBackground(new DialBackground(Color.green));
    assertTrue(p1.equals(p2));

    p1.setBackground(null);
    assertFalse(p1.equals(p2));
    p2.setBackground(null);
    assertTrue(p1.equals(p2));

    // dial cap
    DialCap cap1 = new DialCap();
    cap1.setFillPaint(Color.red);
    p1.setCap(cap1);
    assertFalse(p1.equals(p2));
    DialCap cap2 = new DialCap();
    cap2.setFillPaint(Color.red);
    p2.setCap(cap2);
    assertTrue(p1.equals(p2));

    p1.setCap(null);
    assertFalse(p1.equals(p2));
    p2.setCap(null);
    assertTrue(p1.equals(p2));

    // frame
    StandardDialFrame f1 = new StandardDialFrame();
    f1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f,
            4.0f, Color.white));
    p1.setDialFrame(f1);
    assertFalse(p1.equals(p2));
    StandardDialFrame f2 = new StandardDialFrame();
    f2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f,
            4.0f, Color.white));
    p2.setDialFrame(f2);
    assertTrue(p1.equals(p2));

    // view
    p1.setView(0.2, 0.0, 0.8, 1.0);
    assertFalse(p1.equals(p2));
    p2.setView(0.2, 0.0, 0.8, 1.0);
    assertTrue(p1.equals(p2));

    // layer
    p1.addLayer(new StandardDialScale());
    assertFalse(p1.equals(p2));
    p2.addLayer(new StandardDialScale());
    assertTrue(p1.equals(p2));
}