Example usage for org.jfree.ui RectangleAnchor TOP_RIGHT

List of usage examples for org.jfree.ui RectangleAnchor TOP_RIGHT

Introduction

In this page you can find the example usage for org.jfree.ui RectangleAnchor TOP_RIGHT.

Prototype

RectangleAnchor TOP_RIGHT

To view the source code for org.jfree.ui RectangleAnchor TOP_RIGHT.

Click Source Link

Document

Top-Right.

Usage

From source file:lu.lippmann.cdb.ext.hydviga.ui.GapsUIUtil.java

public static ChartPanel buildGapChartPanel(final Instances dataSet, final int dateIdx, final Attribute attr,
        final int gapsize, final int position) throws Exception {
    Instances filteredDs = WekaDataProcessingUtil.buildFilteredByAttributesDataSet(dataSet,
            new int[] { attr.index(), dateIdx });
    filteredDs = WekaDataProcessingUtil.buildFilteredDataSet(filteredDs, 0, filteredDs.numAttributes() - 1,
            Math.max(0, position - GapsUtil.VALUES_BEFORE_AND_AFTER_RATIO * gapsize),
            Math.min(position + gapsize + GapsUtil.VALUES_BEFORE_AND_AFTER_RATIO * gapsize,
                    filteredDs.numInstances() - 1));

    final ChartPanel cp = TimeSeriesChartUtil.buildChartPanelForAllAttributes(filteredDs, false,
            WekaDataStatsUtil.getFirstDateAttributeIdx(filteredDs), null);

    final XYPlot xyp = (XYPlot) cp.getChart().getPlot();
    xyp.getDomainAxis().setLabel("");
    xyp.getRangeAxis().setLabel("");

    final Marker gapBeginMarker = new ValueMarker(dataSet.instance(Math.max(0, position - 1)).value(dateIdx));
    gapBeginMarker.setPaint(Color.RED);
    gapBeginMarker.setLabel("Gap begin");
    gapBeginMarker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    gapBeginMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
    cp.getChart().getXYPlot().addDomainMarker(gapBeginMarker);

    final Marker gapEndMarker = new ValueMarker(
            dataSet.instance(Math.min(dataSet.numInstances() - 1, position + gapsize)).value(dateIdx));
    gapEndMarker.setPaint(Color.RED);
    gapEndMarker.setLabel("Gap end");
    gapEndMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    gapEndMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
    cp.getChart().getXYPlot().addDomainMarker(gapEndMarker);

    addExportPopupMenu(filteredDs, cp);//from   w w w  .ja v a 2s.c  o  m

    return cp;
}

From source file:org.codehaus.mojo.chronos.chart.ChartUtil.java

/**
 * Generate a {@link ValueMarker}./*w ww  .  ja  v a 2  s.  c o  m*/
 */
private static ValueMarker addValueMarker(String text, double x, boolean domain) {
    ValueMarker marker = new ValueMarker(x);
    marker.setPaint(Color.GRAY);
    marker.setLabel(text);
    if (domain) {
        marker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
        marker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
    } else {
        marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
        marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    }
    return marker;
}

From source file:org.altusmetrum.altosuilib_2.AltosUIMarker.java

public void add(AltosUIDataPoint dataPoint) {
    try {/*from w w w.j  a  v a 2s  .  c  o m*/
        int id = dataPoint.id(fetch);
        if (id < 0)
            return;
        if (id == last_id)
            return;
        ValueMarker marker = new ValueMarker(dataPoint.x());
        marker.setLabel(dataPoint.id_name(fetch));
        marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
        marker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
        marker.setPaint(color);
        if (enabled)
            plot.addDomainMarker(marker);
        markers.add(marker);
        last_id = id;
    } catch (AltosUIDataMissing m) {
    }
}

From source file:com.googlecode.logVisualizer.chart.StatDevelopmentLineChart.java

@Override
protected ChartPanel createChartPanel() {
    final ChartPanel panel = super.createChartPanel();
    final XYPlot plot = (XYPlot) panel.getChart().getPlot();

    for (final DayChange dc : getLogData().getDayChanges()) {
        final ValueMarker day = new ValueMarker(dc.getTurnNumber());
        day.setLabel("Day " + dc.getDayNumber());
        day.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
        day.setLabelTextAnchor(TextAnchor.TOP_LEFT);
        day.setStroke(new BasicStroke(2));
        day.setPaint(new Color(175, 175, 255));
        plot.addDomainMarker(day);//from   www. j a va2 s .  co  m
    }

    return panel;
}

From source file:fr.crnan.videso3d.trajectography.Track2DView.java

public Track2DView(VidesoTrack track) {
    if (track instanceof LPLNTrack) {
        XYSeries dataset = new XYSeries(track.getName());
        List<ValueMarker> markers = new LinkedList<ValueMarker>();
        double distance = 0;
        LPLNTrackPoint last = null;//from ww  w.  jav a2s  . c  o  m
        for (LPLNTrackPoint p : ((LPLNTrack) track).getTrackPoints()) {
            if (last != null) {
                distance += Position.ellipsoidalDistance(last.getPosition(), p.getPosition(),
                        Earth.WGS84_EQUATORIAL_RADIUS, Earth.WGS84_POLAR_RADIUS) / LatLonCautra.NM;
            }
            dataset.add(distance, p.getElevation() / 30.48);
            ValueMarker marker = new ValueMarker(distance);
            marker.setLabel(p.getName());
            marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
            marker.setLabelTextAnchor(TextAnchor.TOP_CENTER);
            markers.add(marker);
            last = p;
        }
        JFreeChart chart = ChartFactory.createXYLineChart("Coupe 2D", "NM", "FL",
                new XYSeriesCollection(dataset), PlotOrientation.VERTICAL, false, false, false);
        for (ValueMarker m : markers) {
            chart.getXYPlot().addDomainMarker(m);
        }
        //ajout des secteurs AIP avec des XYPolygonAnnotation
        Collection<Object> secteurs;
        AIPController controller = (AIPController) DatasManager.getController(DatasManager.Type.AIP);
        secteurs = controller.getObjects(AIP.CTL);
        for (int i = 0; i <= 600; i += 10) {
            last = null;
            Secteur3D lastSecteur = null;
            double lastBoundary = 0.0;
            for (LPLNTrackPoint point : ((LPLNTrack) track).getTrackPoints()) {
                Position p = new Position(point.getPosition(), i * 30.48);
                //calcul du secteur contenant le point en cours
                Iterator<Object> iterator = secteurs.iterator();
                boolean contain = false;
                Secteur3D secteur = null;
                while (iterator.hasNext() && !contain) {
                    Secteur3D temp = (Secteur3D) iterator.next();
                    if (temp.contains(p)) {
                        contain = true;
                        secteur = temp;
                    }
                }

                //si premier point, on enregistre simplement le secteur trouv
                if (last == null) {
                    lastSecteur = secteur;
                } else {
                    if (lastSecteur != secteur) {
                        //si le secteur a chang, on dessine le secteur prcdent
                        //sauf si ce dernier n'existait pas
                        if (lastSecteur != null) {
                            //dans ce cas, on calcule le point d'intersection entre le secteur et le segment form par les deux points
                            //lastSecteur != null => last !=null
                            Set<Point2D> intersects = lastSecteur
                                    .getIntersections(new Line2D.Double(last.getLatitude(), last.getLongitude(),
                                            p.getLatitude().degrees, p.getLongitude().degrees), true);
                            if (!intersects.isEmpty()) {
                                Point2D intersect = intersects.iterator().next();
                                distance = Position.ellipsoidalDistance(
                                        new LatLonCautra(intersect.getX(), intersect.getY()),
                                        last.getPosition(), Earth.WGS84_EQUATORIAL_RADIUS,
                                        Earth.WGS84_POLAR_RADIUS) / LatLonCautra.NM;
                                //et ajout de l'annotation
                                XYPolygonAnnotation annotation = new XYPolygonAnnotation(
                                        new double[] { lastBoundary, i, lastBoundary + distance, i,
                                                lastBoundary + distance, i + 10, lastBoundary, i + 10 });
                                chart.getXYPlot().addAnnotation(annotation);
                                lastBoundary += distance;
                            }
                        }
                        lastSecteur = secteur;
                    }
                }
                last = point;
            }
        }
        //espace en haut pour les marqueurs
        chart.getXYPlot().getRangeAxis().setUpperMargin(0.05);
        ChartPanel chartPanel = new ChartPanel(chart);
        this.setContentPane(chartPanel);
        this.pack();
    }
}

From source file:lisong_mechlab.view.graphs.DpsGraph.java

JFreeChart makechart() {
    JFreeChart chart = ChartFactory.createStackedXYAreaChart("Max DPS over range for " + loadout, "range [m]",
            "damage / second", getSeries(), PlotOrientation.VERTICAL, true, true, false);
    chart.getPlot().setDrawingSupplier(colours);

    chart.getLegend().setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.getLegend().setVerticalAlignment(VerticalAlignment.TOP);

    LegendTitle legendTitle = chart.getLegend();
    XYTitleAnnotation titleAnnotation = new XYTitleAnnotation(0.98, 0.98, legendTitle,
            RectangleAnchor.TOP_RIGHT);
    titleAnnotation.setMaxWidth(0.4);/*from  www  .ja v  a 2 s.c o m*/
    ((XYPlot) (chart.getPlot())).addAnnotation(titleAnnotation);
    chart.removeLegend();

    return chart;
}

From source file:storybook.ui.chart.jfreechart.ChartUtil.java

public static Marker getAverageMarker(double paramDouble) {
    ValueMarker localValueMarker = new ValueMarker(paramDouble, Color.red, new BasicStroke(0.3F));
    localValueMarker.setLabel(I18N.getMsg("msg.common.average"));
    localValueMarker.setLabelFont(new Font("SansSerif", 2, 11));
    localValueMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    localValueMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    return localValueMarker;
}

From source file:lisong_mechlab.view.graphs.SustainedDpsGraph.java

JFreeChart makechart() {
    JFreeChart chart = ChartFactory.createStackedXYAreaChart("Max Sustained DPS over range for " + loadout,
            "range [m]", "damage / second", getSeries(), PlotOrientation.VERTICAL, true, true, false);
    chart.getPlot().setDrawingSupplier(colours);

    chart.getLegend().setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.getLegend().setVerticalAlignment(VerticalAlignment.TOP);

    LegendTitle legendTitle = chart.getLegend();
    XYTitleAnnotation titleAnnotation = new XYTitleAnnotation(0.98, 0.98, legendTitle,
            RectangleAnchor.TOP_RIGHT);
    titleAnnotation.setMaxWidth(0.4);/*from  w  ww.  j  a va  2 s  .  c  o  m*/
    ((XYPlot) (chart.getPlot())).addAnnotation(titleAnnotation);
    chart.removeLegend();

    return chart;
}

From source file:y.graphs.ChartHelperELF.java

private static JFreeChart createChart(final TimeSeriesCollection dataset, Date from, Date to, Config config,
        ArrayList<ConfigSerie> series) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart(Config.getResource("MsgTitleMagGraph"),
            Config.getResource("TitleDate"), Config.getResource("MsgTitleMagGraphYAxis"), dataset, true, // include legend
            true, // tooltips
            false // urls
    );/*from ww w . j av  a  2  s  .c  o  m*/

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    LegendTitle lt = new LegendTitle(plot);
    lt.setItemFont(new Font("Dialog", Font.PLAIN, 12));
    lt.setBackgroundPaint(Color.white);
    lt.setFrame(new BlockBorder(Color.white));
    lt.setVerticalAlignment(VerticalAlignment.CENTER);
    XYTitleAnnotation ta = new XYTitleAnnotation(config.getLegendX(), config.getLegendY(), lt,
            RectangleAnchor.TOP_RIGHT);
    ta.setMaxWidth(config.getLegendSize());
    plot.addAnnotation(ta);
    chart.removeLegend();

    plot.setBackgroundPaint(config.getColorBackgroundELF());
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    final Stroke lineStroke = new BasicStroke((float) config.getLineWidthELF());

    for (int si = 0; si < series.size(); si++) {
        final ConfigSerie cs = series.get(si);
        renderer.setSeriesLinesVisible(si, cs.isDrawLine());

        final float size = cs.getShapeSize();
        renderer.setSeriesShapesVisible(si, size > 0);
        if (size > 0)
            renderer.setSeriesShape(si, ShapeUtilities.createRegularCross(size, size));

        renderer.setSeriesStroke(si, lineStroke);
        //            renderer.setSeriesOutlineStroke(si, lineStroke);
        renderer.setSeriesPaint(si, cs.getColor());
    }
    plot.setRenderer(renderer);

    // x axis
    final DateAxis rangeAxis = (DateAxis) plot.getDomainAxis();
    //        rangeAxis.setStandardTickUnits(DateAxis.createStandardDateTickUnits()); // Returns a collection of standard date tick units that uses the default time zone. This collection will be used by default, but you are free to create your own collection if you want to
    rangeAxis.setAutoRange(true);
    //        rangeAxis.setRange(from, to);
    rangeAxis.setLowerMargin(0.01);
    rangeAxis.setUpperMargin(0.01);

    {
        final Font axisFont = config.getAxisFont();
        if (axisFont != null) {
            rangeAxis.setLabelFont(axisFont);
            plot.getRangeAxis().setLabelFont(axisFont);
        }
    }

    final String xaxisFmt = config.getAxisFormat();

    if (xaxisFmt == null || xaxisFmt.isEmpty()) {
        double diffInDays = (to.getTime() - from.getTime()) / (1000.0 * 60.0 * 60.0 * 24.0);
        if (diffInDays < 2)
            rangeAxis.setDateFormatOverride(
                    new SimpleDateFormat(Config.DEFAULT_TIMEFMT, DateFormatSymbols.getInstance()));
        else
            rangeAxis.setDateFormatOverride(
                    new SimpleDateFormat(Config.DEFAULT_SHORTTIMEFMT, DateFormatSymbols.getInstance()));
    } else
        rangeAxis.setDateFormatOverride(new SimpleDateFormat(xaxisFmt, DateFormatSymbols.getInstance()));

    final ValueAxis domain = plot.getRangeAxis();
    if (config.getForceYmin() != 0 || config.getForceYmax() != 0)
        domain.setRange(ElfValue.valueIntToDouble(config.getForceYmin()),
                ElfValue.valueIntToDouble(config.getForceYmax()));

    // title
    final Font titleFont = config.getTitleFont();
    if (titleFont != null)
        chart.getTitle().setFont(titleFont);

    return chart;
}

From source file:y.graphs.ChartHelperSRB.java

private static JFreeChart createChart(final TimeSeriesCollection dataset, Date from, Date to, Config config,
        ArrayList<ConfigSerie> series) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart(Config.getResource("MsgTitleSrbGraph"),
            Config.getResource("TitleDate"), Config.getResource("MsgTitleSrbGraphYAxis"), dataset, true, // include legend
            true, // tooltips
            false // urls
    );// w w w .j a va 2s  . c om

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    LegendTitle lt = new LegendTitle(plot);
    lt.setItemFont(new Font("Dialog", Font.PLAIN, 12));
    lt.setBackgroundPaint(Color.white);
    lt.setFrame(new BlockBorder(Color.white));
    lt.setVerticalAlignment(VerticalAlignment.CENTER);
    XYTitleAnnotation ta = new XYTitleAnnotation(config.getLegendX(), config.getLegendY(), lt,
            RectangleAnchor.TOP_RIGHT);
    ta.setMaxWidth(config.getLegendSize());
    plot.addAnnotation(ta);
    chart.removeLegend();

    plot.setBackgroundPaint(config.getColorBackgroundSRB());
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    final Stroke lineStroke = new BasicStroke((float) config.getLineWidthSRB());

    for (int si = 0; si < series.size(); si++) {
        final ConfigSerie cs = series.get(si);
        renderer.setSeriesLinesVisible(si, cs.isDrawLine());

        final float size = cs.getShapeSize();
        renderer.setSeriesShapesVisible(si, size > 0);
        if (size > 0)
            renderer.setSeriesShape(si, ShapeUtilities.createRegularCross(size, size));

        renderer.setSeriesStroke(si, lineStroke);
        //          renderer.setSeriesOutlineStroke(si, lineStroke);
        renderer.setSeriesPaint(si, cs.getColor());
    }
    plot.setRenderer(renderer);

    // x axis
    final DateAxis rangeAxis = (DateAxis) plot.getDomainAxis();
    //      rangeAxis.setStandardTickUnits(DateAxis.createStandardDateTickUnits()); // Returns a collection of standard date tick units that uses the default time zone. This collection will be used by default, but you are free to create your own collection if you want to
    rangeAxis.setAutoRange(true);
    //        rangeAxis.setRange(from, to);
    rangeAxis.setLowerMargin(0.01);
    rangeAxis.setUpperMargin(0.01);

    {
        final Font axisFont = config.getAxisFont();
        if (axisFont != null) {
            rangeAxis.setLabelFont(axisFont);
            plot.getRangeAxis().setLabelFont(axisFont);
        }
    }

    final String xaxisFmt = config.getAxisFormat();

    if (xaxisFmt == null || xaxisFmt.isEmpty()) {
        double diffInDays = (to.getTime() - from.getTime()) / (1000.0 * 60.0 * 60.0 * 24.0);
        if (diffInDays < 2)
            rangeAxis.setDateFormatOverride(
                    new SimpleDateFormat(Config.DEFAULT_TIMEFMT, DateFormatSymbols.getInstance()));
        else
            rangeAxis.setDateFormatOverride(
                    new SimpleDateFormat(Config.DEFAULT_SHORTTIMEFMT, DateFormatSymbols.getInstance()));
    } else
        rangeAxis.setDateFormatOverride(new SimpleDateFormat(xaxisFmt, DateFormatSymbols.getInstance()));

    final ValueAxis domain = plot.getRangeAxis();
    if (config.getForceYmin() != 0 || config.getForceYmax() != 0)
        domain.setRange(ElfValue.valueIntToDouble(config.getForceYmin()),
                ElfValue.valueIntToDouble(config.getForceYmax()));

    // title
    final Font titleFont = config.getTitleFont();
    if (titleFont != null)
        chart.getTitle().setFont(titleFont);

    return chart;
}