Example usage for java.awt Color LIGHT_GRAY

List of usage examples for java.awt Color LIGHT_GRAY

Introduction

In this page you can find the example usage for java.awt Color LIGHT_GRAY.

Prototype

Color LIGHT_GRAY

To view the source code for java.awt Color LIGHT_GRAY.

Click Source Link

Document

The color light gray.

Usage

From source file:net.sf.dynamicreports.test.jasper.chart.WaterfallBarChartTest.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(1);/* www .j  a v a2 s. c o  m*/

    JFreeChart chart = getChart("summary.chart1", 0);
    CategoryPlot categoryPlot = chart.getCategoryPlot();
    Assert.assertEquals("renderer", WaterfallBarRenderer.class, categoryPlot.getRenderer().getClass());
    Assert.assertTrue("show labels", categoryPlot.getRenderer().getBaseItemLabelsVisible());
    Assert.assertFalse("show tick labels", categoryPlot.getDomainAxis().isTickMarksVisible());
    Assert.assertFalse("show tick marks", categoryPlot.getDomainAxis().isTickLabelsVisible());

    chart = getChart("summary.chart2", 0);
    Axis axis = chart.getCategoryPlot().getDomainAxis();
    Assert.assertEquals("category label", "category", axis.getLabel());
    Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    CategoryLabelPosition labelPosition = chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositions()
            .getLabelPosition(RectangleEdge.LEFT);
    Assert.assertEquals("plot label rotation", (45d / 180) * Math.PI, labelPosition.getAngle());
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());

    chart = getChart("summary.chart3", 0);
    axis = chart.getCategoryPlot().getRangeAxis();
    Assert.assertEquals("value label", "value", axis.getLabel());
    Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10));
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
    Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound());
    Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound());
}

From source file:com.github.fabioticconi.roguelite.systems.BootstrapSystem.java

@Override
protected void processSystem() {
    // this must be only run once
    setEnabled(false);// w  ww . j  a  va  2 s . c  o  m

    int x;
    int y;

    // add player
    int id = world.create();
    EntityEdit edit = world.edit(id);

    // load the player's data
    try {
        loadBody("data/creatures/player.yaml", edit);
    } catch (final IOException e) {
        e.printStackTrace();
        System.exit(1);
    }

    edit.create(Player.class);
    x = Options.MAP_SIZE_X / 2;
    y = Options.MAP_SIZE_Y / 2;
    edit.create(Position.class).set(x, y);
    edit.create(Sprite.class).set('@', Color.WHITE);
    grid.set(x, y, id);
    pManager.setPlayer(world.getEntity(id), "player");
    System.out.println("setPlayer");
    edit.create(Speed.class).value = 0f; // FIXME to remove later, only for debug

    // add a herd of buffalos
    int groupId = sGroup.createGroup();
    IntSet group = sGroup.getGroup(groupId);
    for (int i = 0; i < 5; i++) {
        id = world.create();
        edit = world.edit(id);

        try {
            loadBody("data/creatures/buffalo.yaml", edit);
        } catch (final IOException e) {
            e.printStackTrace();
            System.exit(1);
        }

        final AI ai = new AI(r.nextFloat() * AISystem.BASE_TICKTIME + 1.0f);
        ai.behaviours.add(world.getSystem(FleeBehaviour.class));
        ai.behaviours.add(world.getSystem(GrazeBehaviour.class));
        ai.behaviours.add(world.getSystem(FlockBehaviour.class));
        ai.behaviours.add(world.getSystem(WanderBehaviour.class));
        edit.add(ai);
        x = (Options.MAP_SIZE_X / 2) + r.nextInt(10) - 5;
        y = (Options.MAP_SIZE_Y / 2) + r.nextInt(10) - 5;
        edit.create(Position.class).set(x, y);
        edit.create(Group.class).groupId = groupId;
        group.add(id);
        edit.create(Alertness.class).value = 0.0f;
        edit.create(Sprite.class).set('b', Util.BROWN);

        grid.set(x, y, id);
    }

    // add small, independent rabbits/hares
    for (int i = 0; i < 3; i++) {
        id = world.create();
        edit = world.edit(id);

        try {
            loadBody("data/creatures/rabbit.yaml", edit);
        } catch (final IOException e) {
            e.printStackTrace();
            System.exit(1);
        }

        final AI ai = new AI(r.nextFloat() * AISystem.BASE_TICKTIME + 1.0f);
        ai.behaviours.add(world.getSystem(FleeBehaviour.class));
        ai.behaviours.add(world.getSystem(GrazeBehaviour.class));
        ai.behaviours.add(world.getSystem(WanderBehaviour.class));
        edit.add(ai);
        x = (Options.MAP_SIZE_X / 2) + r.nextInt(10) - 5;
        y = (Options.MAP_SIZE_Y / 2) + r.nextInt(10) - 5;
        edit.create(Position.class).set(x, y);
        edit.create(Alertness.class).value = 0.0f;
        edit.create(Sprite.class).set('r', Color.LIGHT_GRAY);

        grid.set(x, y, id);
    }

    // add a pack of wolves
    groupId = sGroup.createGroup();
    group = sGroup.getGroup(groupId);
    for (int i = 0; i < 5; i++) {
        id = world.create();
        edit = world.edit(id);

        try {
            loadBody("data/creatures/wolf.yaml", edit);
        } catch (final IOException e) {
            e.printStackTrace();
            System.exit(1);
        }

        final AI ai = new AI(r.nextFloat() * AISystem.BASE_TICKTIME + 1.0f);
        ai.behaviours.add(world.getSystem(ChaseBehaviour.class));
        ai.behaviours.add(world.getSystem(FlockBehaviour.class));
        ai.behaviours.add(world.getSystem(WanderBehaviour.class));
        edit.add(ai);
        x = (Options.MAP_SIZE_X / 2) + r.nextInt(10) - 5;
        y = (Options.MAP_SIZE_Y / 2) + r.nextInt(10) - 5;
        edit.create(Position.class).set(x, y);
        edit.create(Group.class).groupId = groupId;
        group.add(id);
        edit.create(Alertness.class).value = 0.0f;
        edit.create(Sprite.class).set('w', Color.DARK_GRAY);

        grid.set(x, y, id);
    }

    // add solitary pumas
    for (int i = 0; i < 3; i++) {
        id = world.create();
        edit = world.edit(id);

        try {
            loadBody("data/creatures/puma.yaml", edit);
        } catch (final IOException e) {
            e.printStackTrace();
            System.exit(1);
        }

        final AI ai = new AI(r.nextFloat() * AISystem.BASE_TICKTIME + 1.0f);
        ai.behaviours.add(world.getSystem(ChaseBehaviour.class));
        ai.behaviours.add(world.getSystem(WanderBehaviour.class));
        edit.add(ai);
        x = (Options.MAP_SIZE_X / 2) + r.nextInt(10) - 5;
        y = (Options.MAP_SIZE_Y / 2) + r.nextInt(10) - 5;
        edit.create(Position.class).set(x, y);
        edit.create(Alertness.class).value = 0.0f;
        edit.create(Sprite.class).set('p', Util.BROWN.darker());

        grid.set(x, y, id);
    }

    // add random trees?
    for (x = 0; x < Options.MAP_SIZE_X; x++) {
        for (y = 0; y < Options.MAP_SIZE_Y; y++) {
            final Cell cell = map.get(x, y);

            if ((cell.equals(Cell.GRASS) && r.nextGaussian() > 3f)
                    || (cell.equals(Cell.HILL_GRASS) && r.nextGaussian() > 2f)
                    || (cell.equals(Cell.HILL) && r.nextGaussian() > 3f)) {
                id = world.create();
                edit = world.edit(id);

                edit.create(Position.class).set(x, y);
                edit.create(Sprite.class).set('T', Color.GREEN.brighter());
                edit.create(Obstacle.class);

                // FIXME: we should only need one or the other to determine if obstacle.
                // ie, the map should be able to get the Obstacle component from the SingleGrid
                // to determine if the cell is obstructed or not.

                grid.set(x, y, id);
                map.setObstacle(x, y);
            }
        }
    }

    System.out.println("Bootstrap done");
}

From source file:net.sf.dynamicreports.test.jasper.chart.StackedBar3DChartTest.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(1);/*from   www .  j av  a 2 s  .  com*/

    JFreeChart chart = getChart("summary.chart1", 0);
    CategoryPlot categoryPlot = chart.getCategoryPlot();
    Assert.assertEquals("renderer", StackedBarRenderer3D.class, categoryPlot.getRenderer().getClass());
    BarRenderer3D renderer = (BarRenderer3D) categoryPlot.getRenderer();
    Assert.assertTrue("show labels", renderer.getBaseItemLabelsVisible());
    Assert.assertEquals("x offset", 2d, renderer.getXOffset());
    Assert.assertEquals("y offset", 3d, renderer.getYOffset());

    chart = getChart("summary.chart2", 0);
    Axis axis = chart.getCategoryPlot().getDomainAxis();
    Assert.assertEquals("category label", "category", axis.getLabel());
    Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    CategoryLabelPosition labelPosition = chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositions()
            .getLabelPosition(RectangleEdge.LEFT);
    Assert.assertEquals("plot label rotation", (45d / 180) * Math.PI, labelPosition.getAngle());
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());

    chart = getChart("summary.chart3", 0);
    axis = chart.getCategoryPlot().getRangeAxis();
    Assert.assertEquals("value label", "value", axis.getLabel());
    Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10));
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
    Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound());
    Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound());
}

From source file:au.edu.uwa.csse.plot.Clustering.java

private void setUpView(Graph graph) throws IOException {

    //Create a simple layout frame
    //specify the Fruchterman-Rheingold layout algorithm
    final AggregateLayout<Integer, Number> layout = new AggregateLayout<Integer, Number>(
            new FRLayout<Integer, Number>(graph));

    vv = new VisualizationViewer<Integer, Number>(layout);
    vv.setBackground(Color.white);
    vv.setVertexToolTipTransformer(Plot.vertexLabelTransformer);
    //Tell the renderer to use our own customized color rendering
    vv.getRenderContext()/* www .  ja v  a2 s .  c  o  m*/
            .setVertexFillPaintTransformer(MapTransformer.<Integer, Paint>getInstance(vertexPaints));
    vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Integer, Paint>() {
        public Paint transform(Integer v) {
            if (vv.getPickedVertexState().isPicked(v)) {
                return Color.cyan;
            } else {
                return Color.BLACK;
            }
        }
    });

    vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints));

    vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() {
        protected final Stroke THIN = new BasicStroke(1);
        protected final Stroke THICK = new BasicStroke(2);

        public Stroke transform(Number e) {
            Paint c = edgePaints.get(e);
            if (c == Color.LIGHT_GRAY)
                return THIN;
            else
                return THICK;
        }
    });

    //add restart button
    JButton scramble = new JButton("Restart");
    scramble.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Layout layout = vv.getGraphLayout();
            layout.initialize();
            Relaxer relaxer = vv.getModel().getRelaxer();
            if (relaxer != null) {
                relaxer.stop();
                relaxer.prerelax();
                relaxer.relax();
            }
        }

    });

    DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
    vv.setGraphMouse(gm);

    final JToggleButton groupVertices = new JToggleButton("Group Clusters");

    //Create slider to adjust the number of edges to remove when clustering
    final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL);
    edgeBetweennessSlider.setBackground(Color.WHITE);
    edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50));
    edgeBetweennessSlider.setPaintTicks(true);
    edgeBetweennessSlider.setMaximum(graph.getEdgeCount());
    edgeBetweennessSlider.setMinimum(0);
    edgeBetweennessSlider.setValue(0);
    edgeBetweennessSlider.setMajorTickSpacing(10);
    edgeBetweennessSlider.setPaintLabels(true);
    edgeBetweennessSlider.setPaintTicks(true);

    //      edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black));
    //TO DO: edgeBetweennessSlider.add(new JLabel("Node Size (PageRank With Priors):"));
    //I also want the slider value to appear
    final JPanel eastControls = new JPanel();
    eastControls.setOpaque(true);
    eastControls.setLayout(new BoxLayout(eastControls, BoxLayout.Y_AXIS));
    eastControls.add(Box.createVerticalGlue());
    eastControls.add(edgeBetweennessSlider);

    final String COMMANDSTRING = "Edges removed for clusters: ";
    final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue();

    final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize);
    eastControls.setBorder(sliderBorder);
    //eastControls.add(eastSize);
    eastControls.add(Box.createVerticalGlue());

    groupVertices.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors,
                    e.getStateChange() == ItemEvent.SELECTED);
            vv.repaint();
        }
    });

    clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected());

    edgeBetweennessSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();
            if (!source.getValueIsAdjusting()) {
                int numEdgesToRemove = source.getValue();
                clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected());
                sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue());
                eastControls.repaint();
                vv.validate();
                vv.repaint();
            }
        }
    });

    Container content = getContentPane();
    content.add(new GraphZoomScrollPane(vv));
    JPanel south = new JPanel();
    JPanel grid = new JPanel(new GridLayout(2, 1));
    grid.add(scramble);
    grid.add(groupVertices);
    south.add(grid);
    south.add(eastControls);
    JPanel p = new JPanel();
    p.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    p.add(gm.getModeComboBox());
    south.add(p);
    content.add(south, BorderLayout.SOUTH);
}

From source file:ecg.ecgshow.ECGShowUI.java

private void createECGData(long timeZone) {
    ECGData = new JPanel(new GridLayout(LEAD_COUNT, 1));
    dateAxises = new DateAxis[LEAD_COUNT];
    ECGSeries = new TimeSeries[LEAD_COUNT * 2];
    for (int i = 0; i < LEAD_COUNT; i++) {
        TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); //XYDataset  TimeSeriesCollection
        ECGSeries[i] = new TimeSeries("?" + (i + 1));
        ECGSeries[i].setMaximumItemCount(500);
        ECGSeries[i + LEAD_COUNT] = new TimeSeries("");
        ECGSeries[i + LEAD_COUNT].setMaximumItemAge(timeZone);
        ECGSeries[i + LEAD_COUNT].setMaximumItemCount(2);

        timeseriescollection.addSeries(ECGSeries[i]);
        timeseriescollection.addSeries(ECGSeries[i + LEAD_COUNT]);

        //DateAxis dateaxis = new DateAxis("Time");
        dateAxises[i] = new DateAxis("");
        dateAxises[i].setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016)));
        dateAxises[i].setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018)));
        dateAxises[i].setTickLabelsVisible(true);
        dateAxises[i].setVisible(false);

        //NumberAxis numberaxis = new NumberAxis("ecg");
        NumberAxis numberaxis = new NumberAxis("ecg");
        numberaxis.setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016)));
        numberaxis.setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018)));
        numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        numberaxis.setVisible(false);/*  w w  w .ja va  2  s .c o  m*/
        numberaxis.setLowerBound(1500D);
        numberaxis.setUpperBound(3000D);

        XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
        xylineandshaperenderer.setSeriesPaint(0, Color.GREEN); //
        xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(2));
        xylineandshaperenderer.setSeriesPaint(1, Color.LIGHT_GRAY); //
        xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(5));

        XYPlot xyplot = new XYPlot(timeseriescollection, dateAxises[i], numberaxis, xylineandshaperenderer);
        xyplot.setBackgroundPaint(Color.LIGHT_GRAY);
        xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY);
        xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY);
        xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
        xyplot.setBackgroundPaint(Color.BLACK);

        JFreeChart jfreechart = new JFreeChart(xyplot);
        jfreechart.setBackgroundPaint(new Color(237, 237, 237));//?
        jfreechart.getLegend().setVisible(false);

        ChartPanel chartpanel = new ChartPanel(jfreechart, (int) (WIDTH * 46 / 100), (int) (HEIGHT * 17 / 100),
                0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, true, false, false);

        chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0) //??0
                , BorderFactory.createEmptyBorder() //????
        ));
        chartpanel.setMouseZoomable(false); //?
        ECGData.add(chartpanel);
    }
}

From source file:co.udea.edu.proyectointegrador.gr11.parqueaderoapp.domain.stadistics.graphics.implement.Grafica.java

@Override
public JFreeChart createXYLineChartToHoursOfDay(List<HoraDelDiaEstadistica> horasDelDia) {
    //Se obtiene el conjunto de datos
    XYDataset dataset = createDataForHoursOfDay(horasDelDia);

    JFreeChart chart = ChartFactory.createXYLineChart(TITLE_OF_XY_CHART, //Titulo del grafico
            DOMAIN_AXIS_LABEL_HOUR, //Nombre del Rango
            RANGE_AXIS_LABEL, //Nombre del dominio
            dataset, //conjunto de datos
            PlotOrientation.VERTICAL, //Orientacion del grafico
            true, //incluir leyendas
            true, false);/*from  w  w w . j  a  v a  2 s  . co  m*/

    //Se pinta el fondo de blanco
    chart.setBackgroundPaint(Color.WHITE);

    //Se pintan el fondo del grafico de gris y las lineas de blanco
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.WHITE);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    plot.setRenderer(renderer);
    plot.setNoDataMessage(NO_DATA_TO_DISPLAY);

    //Se configura para que solo muestre nmeros enteros en el rango
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    //Se configura para que solo muestre nmeros enteros en el dominio
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return chart;
}

From source file:net.sf.dynamicreports.test.jasper.chart.GroupedStackedBarChartTest.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(1);/*  www .ja  va 2s  .  com*/

    JFreeChart chart = getChart("summary.chart1", 0);
    CategoryPlot categoryPlot = chart.getCategoryPlot();
    Assert.assertEquals("renderer", GroupedStackedBarRenderer.class, categoryPlot.getRenderer().getClass());
    Assert.assertTrue("show labels", categoryPlot.getRenderer().getBaseItemLabelsVisible());
    Assert.assertFalse("show tick labels", categoryPlot.getDomainAxis().isTickLabelsVisible());
    Assert.assertFalse("show tick marks", categoryPlot.getDomainAxis().isTickMarksVisible());

    chart = getChart("summary.chart2", 0);
    Axis axis = chart.getCategoryPlot().getDomainAxis();
    Assert.assertEquals("category label", "category", axis.getLabel());
    Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    CategoryLabelPosition labelPosition = chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositions()
            .getLabelPosition(RectangleEdge.LEFT);
    Assert.assertEquals("plot label rotation", (45d / 180) * Math.PI, labelPosition.getAngle());
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());

    chart = getChart("summary.chart3", 0);
    axis = chart.getCategoryPlot().getRangeAxis();
    Assert.assertEquals("value label", "value", axis.getLabel());
    Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10));
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
    Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound());
    Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound());
}

From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.interactivepiechartfilters.JfreeDivaPieChartFilter.java

private void updateLabelsAndValues(Set<Integer> dsIndexes, boolean reset) {
    ;//from   w w  w.  ja v  a 2 s  .com
    if (dsIndexes == null || dsIndexes.isEmpty()) {
        this.labels = new String[inuseDsIndexesMap.size()];
        this.values = new int[inuseDsIndexesMap.size()];
        int x = 0;
        int notAvailableIndex = -1;
        for (String str : inuseDsIndexesMap.keySet()) {
            if (str.equalsIgnoreCase("Not Available")) {
                notAvailableIndex = x;
            }
            labels[x] = str;
            values[x] = inuseDsIndexesMap.get(str).size();
            valuesMap.put(labels[x], values[x] + "");

            x++;
        }
        if (notAvailableIndex != -1) {
            labels[notAvailableIndex] = labels[labels.length - 1];
            labels[labels.length - 1] = "Not Available";
            int notAvaiValue = values[notAvailableIndex];
            values[notAvailableIndex] = values[values.length - 1];
            values[values.length - 1] = notAvaiValue;
            defaultColors[labels.length - 1] = Color.LIGHT_GRAY;
        }

    } else {
        //            availableDsIds.addAll(dsIndexes);
        Map<String, List<Integer>> filteredDssMap = new HashMap<String, List<Integer>>();
        Map<String, Integer> filteredDsIndexesMap = new HashMap<String, Integer>();
        for (int y : dsIndexes) {
            for (String key : dsIndexesMap.keySet()) {
                if (dsIndexesMap.get(key).contains(y)) {
                    if (!filteredDsIndexesMap.containsKey(key)) {
                        filteredDsIndexesMap.put(key, 0);
                        filteredDssMap.put(key, new ArrayList<Integer>());
                    }
                    int val = filteredDsIndexesMap.get(key);
                    val++;
                    List<Integer> dsIds = filteredDssMap.get(key);
                    dsIds.add(y);
                    filteredDsIndexesMap.put(key, val);
                    filteredDssMap.put(key, dsIds);
                }
            }

        }

        this.labels = new String[filteredDsIndexesMap.size()];
        this.values = new int[filteredDsIndexesMap.size()];
        int x = 0;
        int notAvailableIndex = -1;

        for (String str : filteredDsIndexesMap.keySet()) {
            if (str.equalsIgnoreCase("Not Available")) {
                notAvailableIndex = x;
            }
            labels[x] = str;
            values[x] = filteredDsIndexesMap.get(str);
            valuesMap.put(labels[x], values[x] + "");
            x++;
        }
        if (notAvailableIndex != -1) {
            labels[notAvailableIndex] = labels[labels.length - 1];
            labels[labels.length - 1] = "Not Available";
            int notAvaiValue = values[notAvailableIndex];
            values[notAvailableIndex] = values[values.length - 1];
            values[values.length - 1] = notAvaiValue;
        }
        if (reset) {
            inuseDsIndexesMap = filteredDssMap;
        }

    }

}

From source file:net.sf.dynamicreports.test.jasper.chart.LayeredBarChartTest.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(1);//from   w  w w. j av a2s.co m

    JFreeChart chart = getChart("summary.chart1", 0);
    CategoryPlot categoryPlot = chart.getCategoryPlot();
    Assert.assertEquals("renderer", LayeredBarRenderer.class, categoryPlot.getRenderer().getClass());
    Assert.assertTrue("show labels", categoryPlot.getRenderer().getBaseItemLabelsVisible());
    Assert.assertFalse("show tick labels", categoryPlot.getDomainAxis().isTickMarksVisible());
    Assert.assertFalse("show tick marks", categoryPlot.getDomainAxis().isTickLabelsVisible());

    chart = getChart("summary.chart2", 0);
    Axis axis = chart.getCategoryPlot().getDomainAxis();
    Assert.assertEquals("category label", "category", axis.getLabel());
    Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    CategoryLabelPosition labelPosition = chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositions()
            .getLabelPosition(RectangleEdge.LEFT);
    Assert.assertEquals("plot label rotation", (45d / 180) * Math.PI, labelPosition.getAngle());
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());

    chart = getChart("summary.chart3", 0);
    axis = chart.getCategoryPlot().getRangeAxis();
    Assert.assertEquals("value label", "value", axis.getLabel());
    Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10));
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
    Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound());
    Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound());
}

From source file:net.sf.maltcms.chromaui.foldChangeViewer.tasks.FoldChangeViewLoaderWorker.java

@Override
public void run() {
    ProgressHandle handle = ProgressHandleFactory.createHandle("Creating fold change plot");
    try {/* w  w w.j  av  a  2  s . c  om*/
        handle.setDisplayName("Loading fold change elements");//+new File(this.files.getResourceLocation()).getName());
        handle.start(5);
        handle.progress("Reading settings", 1);
        RTUnit rtAxisUnit = RTUnit.valueOf(sp.getProperty("rtAxisUnit", "SECONDS"));
        handle.progress("Retrieving data", 2);
        XYShapeRenderer renderer = new XYShapeRenderer() {

            @Override
            protected Paint getPaint(XYDataset dataset, int series, int item) {
                double x = dataset.getXValue(series, item);
                double y = dataset.getYValue(series, item);
                if (Math.abs(x) < 1.0) {
                    Paint p = super.getPaint(dataset, series, item);
                    if (p instanceof Color) {
                        Color color = (Color) p;
                        float[] values = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(),
                                new float[3]);
                        Color hsb = new Color(
                                Color.HSBtoRGB(values[0], (float) Math.max(0.1, values[1] - 0.9), values[2]));
                        return new Color(hsb.getRed(), hsb.getGreen(), hsb.getBlue(), 64);
                    }
                }
                return super.getPaint(dataset, series, item);
            }

        };
        renderer.setAutoPopulateSeriesFillPaint(true);
        renderer.setAutoPopulateSeriesOutlinePaint(true);
        renderer.setBaseCreateEntities(true);
        handle.progress("Building plot", 3);
        XYPlot plot = new XYPlot(dataset, new NumberAxis("log2 fold change"), new NumberAxis("-log10 p-value"),
                renderer);
        BasicStroke dashed = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 5.0f,
                new float[] { 5.0f }, 0.0f);
        ValueMarker marker = new ValueMarker(-Math.log10(0.05), Color.RED, dashed);
        marker.setLabel("p-value=0.05");
        marker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT);
        marker.setLabelOffset(new RectangleInsets(UnitType.ABSOLUTE, 0, 50, 10, 0));
        marker.setLabelOffsetType(LengthAdjustmentType.EXPAND);
        marker.setLabelPaint(Color.LIGHT_GRAY);
        plot.addRangeMarker(marker);

        Font font1 = new Font("SansSerif", Font.PLAIN, 12);
        SelectionAwareXYTooltipGenerator tooltipGenerator = cvtc.getLookup()
                .lookup(SelectionAwareXYTooltipGenerator.class);
        if (tooltipGenerator == null) {
            tooltipGenerator = new SelectionAwareXYTooltipGenerator(tooltipGenerator) {
                @Override
                public String createSelectionAwareTooltip(XYDataset xyd, int i, int i1) {
                    FoldChangeDataset dataset = (FoldChangeDataset) xyd;
                    FoldChangeElement fce = dataset.getNamedElementProvider().get(i).get(i1);
                    StringBuilder sb = new StringBuilder();
                    sb.append("<html>");
                    sb.append(fce.getPeakGroup().getMajorityDisplayName());
                    sb.append("<br>");
                    sb.append("log2 fold change=");
                    sb.append(fce.getFoldChange());
                    sb.append("<br>");
                    sb.append("p-value=");
                    sb.append(Math.pow(10, -fce.getPvalue()));
                    sb.append("</html>");
                    return sb.toString();
                }
            };
        }
        tooltipGenerator.setXYToolTipGenerator(new XYToolTipGenerator() {
            @Override
            public String generateToolTip(XYDataset xyd, int i, int i1) {
                Comparable comp = xyd.getSeriesKey(i);
                double x = xyd.getXValue(i, i1);
                double y = xyd.getYValue(i, i1);
                StringBuilder sb = new StringBuilder();
                sb.append("<html>");
                sb.append(comp);
                sb.append("<br>");
                sb.append("log2 fold change=");
                sb.append(x);
                sb.append("<br>");
                sb.append("p-value=");
                sb.append(sb.append(Math.pow(10, -y)));
                sb.append("</html>");
                return sb.toString();
            }
        });
        plot.getRenderer().setBaseToolTipGenerator(tooltipGenerator);
        handle.progress("Configuring plot", 4);
        configurePlot(plot, rtAxisUnit);
        final FoldChangeViewPanel cmhp = cvtc.getLookup().lookup(FoldChangeViewPanel.class);
        Range domainRange = null;
        Range valueRange = null;
        if (cmhp != null) {
            XYPlot xyplot = cmhp.getPlot();
            if (xyplot != null) {
                ValueAxis domain = xyplot.getDomainAxis();
                domainRange = domain.getRange();
                ValueAxis range = xyplot.getRangeAxis();
                valueRange = range.getRange();
            }
        }

        if (domainRange != null) {
            plot.getDomainAxis().setRange(domainRange);
        }
        if (valueRange != null) {
            Logger.getLogger(getClass().getName()).info("Setting previous value range!");
        }
        handle.progress("Adding plot to panel", 5);
        final XYPlot targetPlot = plot;
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                final FoldChangeViewPanel cmhp = cvtc.getLookup().lookup(FoldChangeViewPanel.class);
                cmhp.setPlot(targetPlot);
                cvtc.requestActive();
            }
        });
    } finally {
        handle.finish();
    }
}