Example usage for org.jfree.chart.plot ValueMarker setAlpha

List of usage examples for org.jfree.chart.plot ValueMarker setAlpha

Introduction

In this page you can find the example usage for org.jfree.chart.plot ValueMarker setAlpha.

Prototype

public void setAlpha(float alpha) 

Source Link

Document

Sets the alpha transparency that should be used when drawing the marker, and sends a MarkerChangeEvent to all registered listeners.

Usage

From source file:eu.udig.tools.jgrass.profile.ProfileView.java

public void addStopLine(double x) {

    DecimalFormat formatter = new DecimalFormat("0.0");
    // add a category marker
    ValueMarker marker = new ValueMarker(x, Color.red, new BasicStroke(1.0f));
    marker.setAlpha(0.6f);
    marker.setLabel(formatter.format(x));
    marker.setLabelFont(new Font("Dialog", Font.PLAIN, 8));
    marker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
    marker.setLabelOffset(new RectangleInsets(2, 5, 2, 5));
    plot.addDomainMarker(marker, Layer.BACKGROUND);
    markers.add(marker);/*from   ww w . jav a 2  s. c  o m*/
}

From source file:ec.ui.view.AutoCorrelationsView.java

protected void onDataChange() {
    chartPanel.getChart().setTitle(ACKind.Normal == kind ? "Autocorrelations" : "Partial autocorrelations");
    NumberAxis domainAxis = (NumberAxis) chartPanel.getChart().getXYPlot().getDomainAxis();
    domainAxis.setRange(0, length);//from w  w w  .j a  v a  2s .c  o  m
    domainAxis.setTickUnit(new NumberTickUnit(length / 6));

    if (ac == DEFAULT_AUTO_CORRELATIONS) {
        chartPanel.getChart().getXYPlot().setDataset(Charts.emptyXYDataset());
    } else {
        ac.setCorrectedForMean(meanCorrection);
        ac.setKMax(length);

        double[] vals = ACKind.Normal == kind ? ac.getAC() : ac.getPAC();
        XYSeries series = new XYSeries("");
        for (int i = 0; i < vals.length; ++i) {
            series.add(i + 1, vals[i]);
        }

        XYPlot plot = chartPanel.getChart().getXYPlot();
        plot.clearRangeMarkers();
        plot.setDataset(new XYBarDataset(new XYSeriesCollection(series), 1));

        double z = 2.0d / Math
                .sqrt(ac.getUnderlyingData().getDataCount() - ac.getUnderlyingData().getMissingValuesCount());
        for (double o : new double[] { z, -z }) {
            ValueMarker marker = new ValueMarker(o);
            marker.setStroke(MARKER_STROKE);
            marker.setAlpha(MARKER_ALPHA);
            plot.addRangeMarker(marker);
        }

        onColorSchemeChange();
    }
}

From source file:grafix.graficos.eixos.Eixo.java

private void incluirEixoX(XYPlot plot) {
    if (Controle.getConfiguracoesUsuario().isExibeEixoX()) {
        ValueMarker mx = new ValueMarker(0);
        mx.setPaint(Color.BLACK);
        mx.setStroke(new BasicStroke(.9f));
        mx.setAlpha(1.0f);
        plot.addRangeMarker(mx);//from www  .j  av  a 2s  .co m
    }
}

From source file:grafix.graficos.eixos.Eixo.java

protected ValueMarker gerarRangeMarker(final MarcaGrafica m) {
    ValueMarker vm = new ValueMarker(m.getValor());
    vm.setLabelOffsetType(LengthAdjustmentType.EXPAND);
    vm.setPaint(m.getCor());/*from   w w w .jav  a  2s .c o  m*/
    vm.setStroke(new BasicStroke(.5f));
    vm.setAlpha(0.9f);
    vm.setLabel(m.getTag());
    vm.setLabelFont(new Font("SansSerif", Font.PLAIN, 11));
    vm.setLabelPaint(m.getCor());
    vm.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    vm.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
    return vm;
}

From source file:ec.ui.view.MarginView.java

private void addDateMarkers() {
    XYPlot plot = chartPanel.getChart().getXYPlot();
    if (data.markers != null) {
        for (Date o : data.markers) {
            ValueMarker marker = new ValueMarker(new Day(o).getFirstMillisecond());
            marker.setStroke(DATE_MARKER_STROKE);
            marker.setAlpha(DATE_MARKER_ALPHA);
            plot.addDomainMarker(marker, Layer.FOREGROUND);
        }/*from  ww w  .ja  va 2  s . co  m*/
    }
}

From source file:ec.ui.view.StabilityView.java

private void configureAxis(XYPlot plot) {
    int nb = graphs_.size();
    List<String> names = new ArrayList<>();
    for (Map.Entry<Bornes, Graphs> entry : graphs_.entrySet()) {
        names.add(entry.getValue().label_);
    }//from  w ww. j  ava 2 s  .c  o  m

    NumberAxis xAxis = new NumberAxis();
    xAxis.setTickLabelPaint(Color.GRAY);
    xAxis.setTickUnit(new StabilityTickUnit(names));
    xAxis.setRange(-0.5, nb - 0.5);
    plot.setDomainAxis(xAxis);
    plot.setDomainGridlinesVisible(false);
    NumberAxis yaxis = new NumberAxis();
    rescaleAxis(yaxis);
    plot.setRangeAxis(yaxis);

    for (int i = 0; i < nb; i++) {
        ValueMarker marker = new ValueMarker(i + 0.5);
        marker.setStroke(MARKER_STROKE);
        marker.setPaint(MARKER_PAINT);
        marker.setAlpha(MARKER_ALPHA);
        plot.addDomainMarker(marker);
    }
}

From source file:be.nbb.demetra.dfm.output.simulation.RealTimePerspGraphView.java

private void configureAxis(XYPlot plot, int start, int end) {
    int nb = graphs_.size();
    List<String> names = new ArrayList<>();
    for (int i = start; i <= end; i++) {
        names.add(periods.get(i).toString());
    }//from  www .  j  a  va 2s.co m

    NumberAxis xAxis = new NumberAxis();
    xAxis.setTickLabelPaint(Color.GRAY);
    xAxis.setTickUnit(new MyTickUnit(names));
    xAxis.setRange(-0.5, nb - 0.5);
    xAxis.setVerticalTickLabels(true);
    plot.setDomainAxis(xAxis);
    plot.setDomainGridlinesVisible(false);
    NumberAxis yaxis = new NumberAxis();
    rescaleAxis(yaxis);
    yaxis.configure();
    plot.setRangeAxis(yaxis);

    for (int i = 0; i < nb; i++) {
        ValueMarker marker = new ValueMarker(i + 0.5);
        marker.setStroke(MARKER_STROKE);
        marker.setPaint(MARKER_PAINT);
        marker.setAlpha(MARKER_ALPHA);
        plot.addDomainMarker(marker);
    }
}

From source file:net.praqma.jenkins.memorymap.MemoryMapBuildAction.java

public void doDrawMemoryMapUsageGraph(StaplerRequest req, StaplerResponse rsp) throws IOException {
    DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> dataset = new DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel>();

    String members = req.getParameter("categories");
    String graphTitle = req.getParameter("title");

    int w = Integer.parseInt(req.getParameter("width"));
    int h = Integer.parseInt(req.getParameter("height"));

    List<String> memberList = Arrays.asList(members.split(","));
    List<List<String>> memberLists = new ArrayList<List<String>>();

    for (String s : memberList) {
        memberLists.add(Arrays.asList(s.split(" ")));
    }/*from  w w  w.j  a  va2s.co  m*/

    List<ValueMarker> markers = new ArrayList<ValueMarker>();

    double max = Double.MIN_VALUE;
    Set<String> drawnMarker = new HashSet<String>();

    String scale = getRecorder().scale;

    for (MemoryMapBuildAction membuild = this; membuild != null; membuild = membuild.getPreviousAction()) {
        ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel(membuild.build);
        MemoryMapConfigMemory result = membuild.getMemoryMapConfig();
        MemoryMapConfigMemory resultBlacklist = new MemoryMapConfigMemory();
        for (List<String> list : memberLists) {
            double value = 0.0d;
            double maxx = 0.0d;
            String labelName = "";
            for (MemoryMapConfigMemoryItem res : result) {
                if (list.contains(res.getName()) && !resultBlacklist.contains(res)) {
                    resultBlacklist.add(res);
                    if (labelName.equals("")) {
                        labelName = res.getName();
                    } else {
                        labelName = String.format("%s+%s", labelName, res.getName());
                    }

                    if (getRecorder().getShowBytesOnGraph()) {
                        maxx = maxx + HexUtils.byteCount(res.getLength(), getRecorder().getWordSize(), scale);
                        value = value + HexUtils.byteCount(res.getUsed(), getRecorder().getWordSize(), scale);
                    } else {
                        maxx = maxx + HexUtils.wordCount(res.getLength(), getRecorder().getWordSize(), scale);
                        value = value + HexUtils.wordCount(res.getUsed(), getRecorder().getWordSize(), scale);
                    }
                } else {
                }

                if (maxx > max) {
                    max = maxx;
                }
                if (value > max) {
                    max = value;
                }
            }
            if (!labelName.equals("")) {
                dataset.add(value, labelName, label);
            }

            boolean makeMarker = true;
            for (ValueMarker vm : markers) {
                if (maxx == vm.getValue() && !vm.getLabel().contains(labelName) && !labelName.equals("")) {
                    drawnMarker.add(vm.getLabel().replace("(MAX) - ", "") + " - " + labelName);
                    String s = vm.getLabel().replace("(MAX) - ", "");

                    vm.setLabel(String.format("%s - %s", vm.getLabel(), labelName));
                    //this is the size of chars used for setting the offset right
                    double i = vm.getLabel().length() * labelOffset + 40;
                    vm.setLabelOffset(new RectangleInsets(5, i, -20, 5));

                    makeMarker = false;
                }
            }

            if ((!labelName.equals("")) && (drawnMarker.add(labelName))) {
                if (makeMarker) {
                    ValueMarker vm = new ValueMarker((double) maxx, Color.BLACK,
                            new BasicStroke(1.2f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 1.0f,
                                    new float[] { 6.0f, 6.0f }, 0.0f));

                    vm.setLabel(String.format("(MAX) - %s", labelName));

                    double i = vm.getLabel().length() * labelOffset + 40;
                    vm.setLabelOffset(new RectangleInsets(5, i, -20, 5));
                    vm.setLabelAnchor(RectangleAnchor.TOP_LEFT);
                    vm.setPaint(Color.BLACK);
                    vm.setOutlinePaint(Color.BLACK);
                    vm.setAlpha(1.0f);
                    markers.add(vm);
                }
            }
        }
    }

    String s = "";
    if (scale.equalsIgnoreCase("kilo")) {
        s = "k";
    } else if (scale.equalsIgnoreCase("mega")) {
        s = "M";
    } else if (scale.equalsIgnoreCase("giga")) {
        s = "G";
    }

    String byteLegend = s + "Bytes";
    String wordLegend = s + "Words";

    String legend = getRecorder().getShowBytesOnGraph() ? byteLegend : wordLegend;

    JFreeChart chart = createPairedBarCharts(graphTitle, legend, max * 1.1d, 0d, dataset.build(), markers);

    chart.setBackgroundPaint(Color.WHITE);
    chart.getLegend().setPosition(RectangleEdge.BOTTOM);
    ChartUtil.generateGraph(req, rsp, chart, w, h);
}