Package org.jfree.chart.renderer

Examples of org.jfree.chart.renderer.LookupPaintScale


    /**
     * Some checks for the default constructor.
     */
    public void testConstructor1() {
        LookupPaintScale s = new LookupPaintScale();
        assertEquals(0.0, s.getLowerBound(), EPSILON);
        assertEquals(1.0, s.getUpperBound(), EPSILON);
    }
View Full Code Here


    /**
     * Some checks for the other constructor.
     */
    public void testConstructor2() {
        LookupPaintScale s = new LookupPaintScale(1.0, 2.0, Color.red);
        assertEquals(1.0, s.getLowerBound(), EPSILON);
        assertEquals(2.0, s.getUpperBound(), EPSILON);
        assertEquals(Color.red, s.getDefaultPaint());
    }
View Full Code Here

    /**
     * Some general checks for the lookup table.
     */
    public void testGeneral() {

        LookupPaintScale s = new LookupPaintScale(0.0, 100.0, Color.black);
        assertEquals(Color.black, s.getPaint(-1.0));
        assertEquals(Color.black, s.getPaint(0.0));
        assertEquals(Color.black, s.getPaint(50.0));
        assertEquals(Color.black, s.getPaint(100.0));
        assertEquals(Color.black, s.getPaint(101.0));

        s.add(50.0, Color.blue);
        assertEquals(Color.black, s.getPaint(-1.0));
        assertEquals(Color.black, s.getPaint(0.0));
        assertEquals(Color.blue, s.getPaint(50.0));
        assertEquals(Color.blue, s.getPaint(100.0));
        assertEquals(Color.black, s.getPaint(101.0));

        s.add(50.0, Color.red);
        assertEquals(Color.black, s.getPaint(-1.0));
        assertEquals(Color.black, s.getPaint(0.0));
        assertEquals(Color.red, s.getPaint(50.0));
        assertEquals(Color.red, s.getPaint(100.0));
        assertEquals(Color.black, s.getPaint(101.0));

        s.add(25.0, Color.green);
        assertEquals(Color.black, s.getPaint(-1.0));
        assertEquals(Color.black, s.getPaint(0.0));
        assertEquals(Color.green, s.getPaint(25.0));
        assertEquals(Color.red, s.getPaint(50.0));
        assertEquals(Color.red, s.getPaint(100.0));
        assertEquals(Color.black, s.getPaint(101.0));

        s.add(75.0, Color.yellow);
        assertEquals(Color.black, s.getPaint(-1.0));
        assertEquals(Color.black, s.getPaint(0.0));
        assertEquals(Color.green, s.getPaint(25.0));
        assertEquals(Color.red, s.getPaint(50.0));
        assertEquals(Color.yellow, s.getPaint(75.0));
        assertEquals(Color.yellow, s.getPaint(100.0));
        assertEquals(Color.black, s.getPaint(101.0));
    }
View Full Code Here

       yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
       
        Color outboundCol = new Color(Integer.decode(outboundColor).intValue());
       
        //Sets the graph paint scale and the legend paintscale
        LookupPaintScale paintScale = new LookupPaintScale(zvalues[0], (new Double(zrangeMax)).doubleValue(),outboundCol);
        LookupPaintScale legendPaintScale = new LookupPaintScale(0.5, 0.5+zvalues.length, outboundCol);
       
        for (int ke=0; ke<=(zvalues.length-1) ; ke++){
          Double key =(new Double(zvalues[ke]));
          Color temp =(Color)colorRangeMap.get(key);
          paintScale.add(zvalues[ke],temp);
          legendPaintScale.add(0.5+ke, temp);
        }    
        //Configures the renderer
        XYBlockRenderer renderer = new XYBlockRenderer();
        renderer.setPaintScale(paintScale);
        double blockHeight =  (new Double(blockH)).doubleValue();
        double blockWidth =  (new Double(blockW)).doubleValue();
        renderer.setBlockWidth(blockWidth);
        renderer.setBlockHeight(blockHeight);
       
        //configures the plot with title, subtitle, axis ecc.
        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
        plot.setBackgroundPaint(Color.white);
        plot.setDomainGridlinePaint(Color.black);
        plot.setRangeGridlinePaint(Color.black);
        plot.setDomainCrosshairPaint(Color.black);
       
        plot.setForegroundAlpha(0.66f);
        plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
        JFreeChart chart = new JFreeChart(plot);
        TextTitle title =setStyleTitle(name, styleTitle);
        chart.setTitle(title);
        if(subName!= null && !subName.equals("")){
      TextTitle subTitle =setStyleTitle(subName, styleSubTitle);
      chart.addSubtitle(subTitle);
    }
        chart.removeLegend();
        chart.setBackgroundPaint(Color.white);
       
        //Sets legend labels
        SymbolAxis scaleAxis = new SymbolAxis(null,legendLabels);
        scaleAxis.setRange(0.5, 0.5+zvalues.length);
        scaleAxis.setPlot(new PiePlot());
        scaleAxis.setGridBandsVisible(false);
        scaleAxis.setLabel(zLabel);
        //scaleAxis.setLabelAngle(3.14/2);
        scaleAxis.setLabelFont(addLabelsStyle.getFont());
        scaleAxis.setLabelPaint(addLabelsStyle.getColor());
     
        //draws legend as chart subtitle
        PaintScaleLegend psl = new PaintScaleLegend(legendPaintScale, scaleAxis);
        psl.setAxisOffset(2.0);
        psl.setPosition(RectangleEdge.RIGHT);
        psl.setMargin(new RectangleInsets(5, 1, 5, 1));       
        chart.addSubtitle(psl);
       
        if(yLabels!=null){
          //Sets y legend labels
          LookupPaintScale legendPaintScale2 = new LookupPaintScale(0, (yLabels.length-1), Color.white);
         
          for (int ke=0; ke<yLabels.length ; ke++){
            Color temp =Color.white;
            legendPaintScale2.add(1+ke, temp);
          }
         
          SymbolAxis scaleAxis2 = new SymbolAxis(null,yLabels);
          scaleAxis2.setRange(0, (yLabels.length-1));
          scaleAxis2.setPlot(new PiePlot());
View Full Code Here

      renderer.addAnnotation(xyAnnotation);
    }

    logger.debug("Annotation set");

    LookupPaintScale paintScale = new LookupPaintScale(0.5, ranges.size()+0.5, color);
    String[] labels=new String[ranges.size()+1];
    labels[0]="";

    // ******************** SCALE ****************************
    for (Iterator iterator = ranges.iterator(); iterator.hasNext();) {
      RangeBlocks range = (RangeBlocks) iterator.next();
      Integer index=patternRangeIndex.get(range.getPattern());
      Color color=range.getColor();
      if(color!=null){
        //Paint colorTransparent=new Color(color.getRed(), color.getGreen(), color.getBlue(), 50);     
        Paint colorTransparent=null;
        if(addTransparency==true){
          colorTransparent=new Color(color.getRed(), color.getGreen(), color.getBlue(),50);     
        }
        else{
          colorTransparent=new Color(color.getRed(), color.getGreen(), color.getBlue());               
        }
        paintScale.add(index+0.5, colorTransparent);
      }
      //String insertLabel="            "+range.getLabel();
      String insertLabel=range.getLabel();     
      labels[index+1]=insertLabel;
    }
View Full Code Here

    /**
     * Creates a new <code>XYShapeRenderer</code> instance with default
     * attributes.
     */
    public XYShapeRenderer() {
        this.paintScale = new LookupPaintScale();
        this.useFillPaint = false;
        this.drawOutlines = false;
        this.useOutlinePaint = true;
        this.guideLinesVisible = false;
        this.guideLinePaint = Color.darkGray;
View Full Code Here

     * Creates a new <code>XYBlockRenderer</code> instance with default
     * attributes.
     */
    public XYBlockRenderer() {
        updateOffsets();
        this.paintScale = new LookupPaintScale();
    }
View Full Code Here

     * Creates a new <code>XYBlockRenderer</code> instance with default
     * attributes.
     */
    public XYBlockRenderer() {
        updateOffsets();
        this.paintScale = new LookupPaintScale();
    }
View Full Code Here

   
    /**
     * A test for the equals() method.
     */
    public void testEquals() {
        LookupPaintScale g1 = new LookupPaintScale();
        LookupPaintScale g2 = new LookupPaintScale();
        assertTrue(g1.equals(g2));
        assertTrue(g2.equals(g1));
       
        g1 = new LookupPaintScale(1.0, 2.0, Color.red);
        assertFalse(g1.equals(g2));
        g2 = new LookupPaintScale(1.0, 2.0, Color.red);
        assertTrue(g1.equals(g2));
       
        g1.add(new Double(1.5), new GradientPaint(1.0f, 2.0f, Color.red, 3.0f,
                4.0f, Color.blue));
        assertFalse(g1.equals(g2));
        g2.add(new Double(1.5), new GradientPaint(1.0f, 2.0f, Color.red, 3.0f,
                4.0f, Color.blue));
        assertTrue(g1.equals(g2));
    }
View Full Code Here

   
    /**
     * Confirm that cloning works.
     */
    public void testCloning() {
        LookupPaintScale g1 = new LookupPaintScale();
        LookupPaintScale g2 = null;
        try {
            g2 = (LookupPaintScale) g1.clone();
        }
        catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        assertTrue(g1 != g2);
        assertTrue(g1.getClass() == g2.getClass());
        assertTrue(g1.equals(g2));
       
        // check independence
        g1.add(new Double(0.5), Color.red);
        assertFalse(g1.equals(g2));
        g2.add(new Double(0.5), Color.red);
        assertTrue(g1.equals(g2));
       
        // try with gradient paint
        g1 = new LookupPaintScale(1.0, 2.0, new GradientPaint(1.0f, 2.0f,
                Color.red, 3.0f, 4.0f, Color.green));
        g1.add(new Double(1.5), new GradientPaint(1.0f, 2.0f, Color.red, 3.0f,
                4.0f, Color.blue));
        g2 = null;
        try {
            g2 = (LookupPaintScale) g1.clone();
        }
        catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        assertTrue(g1 != g2);
        assertTrue(g1.getClass() == g2.getClass());
        assertTrue(g1.equals(g2));
    }
View Full Code Here

TOP

Related Classes of org.jfree.chart.renderer.LookupPaintScale

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.