Example usage for org.jfree.ui TextAnchor BASELINE_CENTER

List of usage examples for org.jfree.ui TextAnchor BASELINE_CENTER

Introduction

In this page you can find the example usage for org.jfree.ui TextAnchor BASELINE_CENTER.

Prototype

TextAnchor BASELINE_CENTER

To view the source code for org.jfree.ui TextAnchor BASELINE_CENTER.

Click Source Link

Document

Baseline/center.

Usage

From source file:com.bdb.weather.display.day.DayHumidityPane.java

@Override
protected void addAnnotations(XYPlot plot, SummaryRecord summaryRecord) {
    plot.clearAnnotations();/*from  ww  w  .j a v a  2s .  c o m*/

    if (summaryRecord == null)
        return;

    LocalDateTime highTime = summaryRecord.getMaxOutdoorHumidityTime();
    Humidity highHumidity = summaryRecord.getMaxOutdoorHumidity();
    LocalDateTime lowTime = summaryRecord.getMinOutdoorHumidityTime();
    Humidity lowHumidity = summaryRecord.getMinOutdoorHumidity();

    if (highTime == null || highHumidity == null || lowTime == null || lowHumidity == null)
        return;

    String highAnnotation = highHumidity.toString() + Humidity.Unit.RELATIVE_HUMIDITY + " "
            + DisplayConstants.formatTime(highTime.toLocalTime());
    String lowAnnotation = lowHumidity.toString() + Humidity.Unit.RELATIVE_HUMIDITY + " "
            + DisplayConstants.formatTime(lowTime.toLocalTime());

    XYTextAnnotation a = new XYTextAnnotation(highAnnotation, TimeUtils.localDateTimeToEpochMillis(highTime),
            highHumidity.get());
    a.setTextAnchor(TextAnchor.BASELINE_CENTER);
    plot.addAnnotation(a);

    a = new XYTextAnnotation(lowAnnotation, TimeUtils.localDateTimeToEpochMillis(lowTime), lowHumidity.get());
    a.setTextAnchor(TextAnchor.TOP_CENTER);
    plot.addAnnotation(a);
}

From source file:com.bdb.weather.display.day.DayPressurePane.java

@Override
protected void addAnnotations(XYPlot plot, SummaryRecord summaryRecord) {
    plot.getRenderer(0).removeAnnotations();
    plot.getRenderer(1).removeAnnotations();

    if (summaryRecord == null)
        return;/*from   ww w  .ja  v  a  2 s.  c  om*/

    LocalDateTime maxTime = summaryRecord.getMaxBaroPressureTime();
    Pressure maxBaroPressure = summaryRecord.getMaxBaroPressure();
    LocalDateTime minTime = summaryRecord.getMinBaroPressureTime();
    Pressure minBaroPressure = summaryRecord.getMinBaroPressure();

    //
    // Barometric pressure
    //
    String highAnnotation = maxBaroPressure.toString() + Pressure.getDefaultUnit() + " "
            + DisplayConstants.formatTime(maxTime.toLocalTime());
    String lowAnnotation = minBaroPressure.toString() + Pressure.getDefaultUnit() + " "
            + DisplayConstants.formatTime(minTime.toLocalTime());

    XYTextAnnotation a = new XYTextAnnotation(highAnnotation,
            (double) TimeUtils.localDateTimeToEpochMillis(maxTime), maxBaroPressure.get());
    a.setTextAnchor(TextAnchor.BASELINE_CENTER);

    plot.getRenderer(0).addAnnotation(a);

    TextAnchor anchor = TextAnchor.TOP_CENTER;

    if (minTime.getHour() <= 2)
        anchor = TextAnchor.TOP_LEFT;
    else if (minTime.getHour() >= 22)
        anchor = TextAnchor.TOP_RIGHT;

    a = new XYTextAnnotation(lowAnnotation, (double) TimeUtils.localDateTimeToEpochMillis(minTime),
            minBaroPressure.get());
    a.setTextAnchor(anchor);

    plot.getRenderer(0).addAnnotation(a);

    SolarRadiation maxSolarRadiation = summaryRecord.getMaxSolarRadiation();
    maxTime = summaryRecord.getMaxSolarRadiationTime();

    if (maxSolarRadiation != null) {
        highAnnotation = maxSolarRadiation.toString() + SolarRadiation.Unit.WATTS_PER_METER_SQUARED + " "
                + DisplayConstants.formatTime(maxTime.toLocalTime());
        a = new XYTextAnnotation(highAnnotation, (double) TimeUtils.localDateTimeToEpochMillis(maxTime),
                maxSolarRadiation.get());
        a.setTextAnchor(TextAnchor.BASELINE_CENTER);
        plot.getRenderer(1).addAnnotation(a);
    }
}

From source file:com.bdb.weather.display.day.DayWindPane.java

@Override
protected void addAnnotations(XYPlot plot, SummaryRecord summaryRecord) {
    plot.clearAnnotations();//from  w w  w  .j  ava  2  s.c  o m
    if (summaryRecord == null)
        return;

    LocalDateTime maxSpeedTime = summaryRecord.getMaxWindSpeedTime();
    if (maxSpeedTime != null) {
        double maxSpeed = summaryRecord.getMaxWindSpeed().get();

        String maxSpeedAnnotation = Speed.getDefaultFormatter().format(maxSpeed) + Speed.getDefaultUnit() + " "
                + DisplayConstants.formatTime(maxSpeedTime.toLocalTime());

        XYTextAnnotation a = new XYTextAnnotation(maxSpeedAnnotation,
                (double) TimeUtils.localDateTimeToEpochMillis(maxSpeedTime), maxSpeed);
        a.setTextAnchor(TextAnchor.BASELINE_CENTER);
        plot.addAnnotation(a);
    }
}

From source file:loansystem.visual.panel.StartPage.java

private void dibujarGrafico(DefaultCategoryDataset datos, int tipoGrafico, String titulo, String ejeX,
        String ejeY, PlotOrientation orientacion, JPanel contenedor) {
    JFreeChart grafica = null;//ww  w  .j  a  va 2s  . co m

    switch (tipoGrafico) {
    case BAR:
        grafica = ChartFactory.createBarChart3D(titulo, ejeX, ejeY, datos, orientacion, true, true, false);
        break;
    case LINE:

        break;

    case PIE:

        break;
    }

    grafica.getTitle().setPaint(Color.black);

    CategoryPlot p = grafica.getCategoryPlot();
    p.setRangeGridlinePaint(Color.black);

    CategoryItemRenderer renderer = ((CategoryPlot) grafica.getPlot()).getRenderer();
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);
    ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER);
    renderer.setBasePositiveItemLabelPosition(position);

    int style = Font.BOLD;
    Font font = new Font("Tahoma", style, 12);
    renderer.setItemLabelFont(font);

    ChartPanel panel = new ChartPanel(grafica);
    contenedor.add(panel);
    contenedor.revalidate();
    contenedor.repaint();
}

From source file:org.jgrasstools.gears.utils.chart.Scatter.java

public void addAnnotation(String text, double x) {
    XYPlot plot = (XYPlot) getChart().getPlot();
    Color color = new Color(0, 0, 0, 100);
    Marker updateMarker = new ValueMarker(x, color, new BasicStroke(2f));
    plot.addDomainMarker(updateMarker);/*  ww w  . ja va2s.  c o m*/
    if (text != null) {
        XYTextAnnotation updateLabel = new XYTextAnnotation(text, x, 0);
        updateLabel.setRotationAnchor(TextAnchor.BASELINE_CENTER);
        updateLabel.setTextAnchor(TextAnchor.BASELINE_CENTER);
        updateLabel.setRotationAngle(-3.14 / 2);
        updateLabel.setPaint(Color.black);
        plot.addAnnotation(updateLabel);
    }
    setShapeLinesVisibility(plot);
}

From source file:org.jfree.chart.demo.DrawStringDemo.java

private TextAnchor convertStringToAnchor(String s) {
    if (s.equals("TextAnchor.TOP_LEFT"))
        return TextAnchor.TOP_LEFT;
    if (s.equals("TextAnchor.TOP_CENTER"))
        return TextAnchor.TOP_CENTER;
    if (s.equals("TextAnchor.TOP_RIGHT"))
        return TextAnchor.TOP_RIGHT;
    if (s.equals("TextAnchor.CENTER_LEFT"))
        return TextAnchor.CENTER_LEFT;
    if (s.equals("TextAnchor.CENTER"))
        return TextAnchor.CENTER;
    if (s.equals("TextAnchor.CENTER_RIGHT"))
        return TextAnchor.CENTER_RIGHT;
    if (s.equals("TextAnchor.HALF_ASCENT_LEFT"))
        return TextAnchor.HALF_ASCENT_LEFT;
    if (s.equals("TextAnchor.HALF_ASCENT_CENTER"))
        return TextAnchor.HALF_ASCENT_CENTER;
    if (s.equals("TextAnchor.HALF_ASCENT_RIGHT"))
        return TextAnchor.HALF_ASCENT_RIGHT;
    if (s.equals("TextAnchor.BASELINE_LEFT"))
        return TextAnchor.BASELINE_LEFT;
    if (s.equals("TextAnchor.BASELINE_CENTER"))
        return TextAnchor.BASELINE_CENTER;
    if (s.equals("TextAnchor.BASELINE_RIGHT"))
        return TextAnchor.BASELINE_RIGHT;
    if (s.equals("TextAnchor.BOTTOM_LEFT"))
        return TextAnchor.BOTTOM_LEFT;
    if (s.equals("TextAnchor.BOTTOM_CENTER"))
        return TextAnchor.BOTTOM_CENTER;
    if (s.equals("TextAnchor.BOTTOM_RIGHT"))
        return TextAnchor.BOTTOM_RIGHT;
    else/* w w  w  . j  a va2  s .  c  om*/
        return null;
}

From source file:com.bdb.weather.display.day.DayTemperaturePane.java

@Override
public void addAnnotations(XYPlot plot, SummaryRecord summaryRecord) {
    plot.clearAnnotations();//from   www  .ja  v a 2 s  .  c  o m
    summary = summaryRecord;
    if (summaryRecord == null)
        return;

    LocalDateTime highTime = summaryRecord.getMaxOutdoorTempTime();
    Temperature outdoorHighTemp = summaryRecord.getMaxOutdoorTemp();
    LocalDateTime lowTime = summaryRecord.getMinOutdoorTempTime();
    Temperature outdoorLowTemp = summaryRecord.getMinOutdoorTemp();

    if (highTime == null || outdoorHighTemp == null || lowTime == null || outdoorLowTemp == null)
        return;

    String highAnnotation = outdoorHighTemp.toString() + " " + Temperature.getDefaultUnit() + " "
            + DisplayConstants.formatTime(highTime.toLocalTime());
    String lowAnnotation = outdoorLowTemp.toString() + " " + Temperature.getDefaultUnit() + " "
            + DisplayConstants.formatTime(lowTime.toLocalTime());

    XYTextAnnotation a = new XYTextAnnotation(highAnnotation,
            (double) TimeUtils.localDateTimeToEpochMillis(highTime), outdoorHighTemp.get());
    a.setTextAnchor(TextAnchor.BASELINE_CENTER);
    plot.addAnnotation(a);

    a = new XYTextAnnotation(lowAnnotation, TimeUtils.localDateTimeToEpochMillis(lowTime),
            outdoorLowTemp.get());
    a.setTextAnchor(TextAnchor.TOP_CENTER);
    plot.addAnnotation(a);

    highTime = summaryRecord.getMaxIndoorTempTime();
    Temperature indoorHighTemp = summaryRecord.getMaxIndoorTemp();
    lowTime = summaryRecord.getMinIndoorTempTime();
    Temperature indoorLowTemp = summaryRecord.getMinIndoorTemp();

    highAnnotation = indoorHighTemp.toString() + " " + Temperature.getDefaultUnit() + " "
            + DisplayConstants.formatTime(highTime.toLocalTime());
    lowAnnotation = indoorLowTemp + " " + Temperature.getDefaultUnit() + " "
            + DisplayConstants.formatTime(lowTime.toLocalTime());

    a = new XYTextAnnotation(highAnnotation, TimeUtils.localDateTimeToEpochMillis(highTime),
            indoorHighTemp.get());
    a.setTextAnchor(TextAnchor.BASELINE_CENTER);
    plot.addAnnotation(a);

    a = new XYTextAnnotation(lowAnnotation, TimeUtils.localDateTimeToEpochMillis(lowTime), indoorLowTemp.get());
    a.setTextAnchor(TextAnchor.TOP_CENTER);
    plot.addAnnotation(a);
}

From source file:forms.frDados.java

/**
 * Inicializa o grfico de velocidade./*from w w  w .  j  av  a 2 s  .c om*/
 */
private void initSatVelox() {
    dadosGraficoVelox.clear();

    veloxPlot = ChartFactory.createLineChart("Velocidade", "Hora", "Velocidade KM/h", dadosGraficoVelox,
            PlotOrientation.VERTICAL, false, true, false);

    veloxPlot.getTitle().setFont(Font.decode("arial-16"));
    veloxPlot.getTitle().setPadding(5, 20, 5, 20);
    veloxPlot.setPadding(new RectangleInsets(10, 10, 0, 10));

    ChartPanel cp = new ChartPanel(veloxPlot);
    cp.setBorder(LineBorder.createGrayLineBorder());

    LineAndShapeRenderer br = (LineAndShapeRenderer) veloxPlot.getCategoryPlot().getRenderer();

    br.setBaseItemLabelsVisible(true);
    br.setSeriesItemLabelFont(0, Font.decode("arial-12"));
    br.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    br.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));

    veloxPlot.getCategoryPlot().getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    //veloxPlot.getCategoryPlot().getRangeAxis().setRange(new Range(0,100), true,true);

    pnlChartSpeed.setLayout(new BorderLayout());
    pnlChartSpeed.add(cp, BorderLayout.CENTER);
}

From source file:forms.frDados.java

/**
 * Inicializa o grfico de intensidade de sinal dos satlites.
 *//*w  ww . j a  v  a2 s  .  c  om*/
private void initSatGrafico() {
    dadosGraficoSats.clear();
    plot = ChartFactory.createBarChart("Intensidade do sinal", "PRN", "SNR", dadosGraficoSats,
            PlotOrientation.VERTICAL, false, true, true);

    plot.getTitle().setFont(Font.decode("arial-16"));
    plot.getTitle().setPadding(5, 20, 5, 20);
    plot.setPadding(new RectangleInsets(10, 10, 0, 10));
    //plot.setBackgroundPaint(new Color(255,255,255,0));

    BarRenderer br = (BarRenderer) plot.getCategoryPlot().getRenderer();
    br.setSeriesPaint(0, Color.BLUE);
    br.setMaximumBarWidth(0.05);

    plot.getCategoryPlot().getRangeAxis().setRange(new Range(0, 50), true, true);
    br.setBaseItemLabelsVisible(true);
    br.setSeriesItemLabelFont(0, Font.decode("arial-12"));
    br.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    br.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));

    SpringLayout lm = new SpringLayout();
    ChartPanel cp = new ChartPanel(plot);
    cp.setBorder(LineBorder.createGrayLineBorder());

    lm.putConstraint(SpringLayout.EAST, pnlSatPlot, 10, SpringLayout.EAST, cp);
    lm.putConstraint(SpringLayout.WEST, cp, 10, SpringLayout.WEST, pnlSatPlot);
    lm.putConstraint(SpringLayout.SOUTH, pnlSatPlot, 10, SpringLayout.SOUTH, cp);
    lm.putConstraint(SpringLayout.NORTH, cp, 10, SpringLayout.NORTH, pnlSatPlot);

    pnlSatPlot.setLayout(lm);
    pnlSatPlot.add(cp);
}

From source file:org.jfree.demo.DrawStringDemo.java

/**
 * Converts a string to a corresponding {@link TextAnchor} instance.
 *
 * @param text  the text./*from   w  w  w .  jav a2s  .  c o m*/
 *
 * @return The anchor.
 */
private TextAnchor convertStringToAnchor(final String text) {

    if (text.equals("TextAnchor.TOP_LEFT")) {
        return TextAnchor.TOP_LEFT;
    } else if (text.equals("TextAnchor.TOP_CENTER")) {
        return TextAnchor.TOP_CENTER;
    } else if (text.equals("TextAnchor.TOP_RIGHT")) {
        return TextAnchor.TOP_RIGHT;
    } else if (text.equals("TextAnchor.CENTER_LEFT")) {
        return TextAnchor.CENTER_LEFT;
    } else if (text.equals("TextAnchor.CENTER")) {
        return TextAnchor.CENTER;
    } else if (text.equals("TextAnchor.CENTER_RIGHT")) {
        return TextAnchor.CENTER_RIGHT;
    } else if (text.equals("TextAnchor.HALF_ASCENT_LEFT")) {
        return TextAnchor.HALF_ASCENT_LEFT;
    } else if (text.equals("TextAnchor.HALF_ASCENT_CENTER")) {
        return TextAnchor.HALF_ASCENT_CENTER;
    } else if (text.equals("TextAnchor.HALF_ASCENT_RIGHT")) {
        return TextAnchor.HALF_ASCENT_RIGHT;
    } else if (text.equals("TextAnchor.BASELINE_LEFT")) {
        return TextAnchor.BASELINE_LEFT;
    } else if (text.equals("TextAnchor.BASELINE_CENTER")) {
        return TextAnchor.BASELINE_CENTER;
    } else if (text.equals("TextAnchor.BASELINE_RIGHT")) {
        return TextAnchor.BASELINE_RIGHT;
    } else if (text.equals("TextAnchor.BOTTOM_LEFT")) {
        return TextAnchor.BOTTOM_LEFT;
    } else if (text.equals("TextAnchor.BOTTOM_CENTER")) {
        return TextAnchor.BOTTOM_CENTER;
    } else if (text.equals("TextAnchor.BOTTOM_RIGHT")) {
        return TextAnchor.BOTTOM_RIGHT;
    } else {
        return null;
    }

}