Package org.swtchart

Examples of org.swtchart.IAxis


        setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
        getTitle().setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
        getLegend().setVisible(false);

        // x axis
        IAxis xAxis = getAxisSet().getXAxis(0);
        xAxis.getTitle().setVisible(false);
        xAxis.getTick().setVisible(false);
        xAxis.getGrid().setStyle(LineStyle.NONE);

        String[] categories = new String[dates.size()];
        for (int ii = 0; ii < categories.length; ii++)
            categories[ii] = dates.get(ii).toString(ISODateTimeFormat.date());
        xAxis.setCategorySeries(categories);
        xAxis.enableCategory(true);

        // y axis
        IAxis yAxis = getAxisSet().getYAxis(0);
        yAxis.getTitle().setVisible(false);
        yAxis.getTick().setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
        yAxis.setPosition(Position.Secondary);

        ((IPlotArea) getPlotArea()).addCustomPaintListener(new ICustomPaintListener()
        {
            @Override
            public void paintControl(PaintEvent e)
View Full Code Here


        return toolTip;
    }

    private void paintTimeGrid(PaintEvent e)
    {
        IAxis xAxis = getAxisSet().getXAxis(0);
        Range range = xAxis.getRange();

        final DateMidnight start = dates.get(0);
        final DateMidnight end = dates.get(dates.size() - 1);

        int totalDays = Days.daysBetween(start, end).getDays() + 1;

        DateMidnight current = start.plusYears(1).withMonthOfYear(1).withDayOfMonth(1);
        while (current.isBefore(end))
        {
            int days = Days.daysBetween(start, current).getDays();
            int y = xAxis.getPixelCoordinate((double) days * range.upper / (double) totalDays);
            e.gc.drawLine(y, 0, y, e.height);
            e.gc.drawText(String.valueOf(current.getYear()), y + 5, 5);

            current = current.plusYears(1);
        }
View Full Code Here

        setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
        getTitle().setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
        getLegend().setVisible(false);

        // x axis
        IAxis xAxis = getAxisSet().getXAxis(0);
        xAxis.getTitle().setVisible(false);
        xAxis.getTick().setVisible(false);
        xAxis.getGrid().setStyle(LineStyle.NONE);

        // y axis
        IAxis yAxis = getAxisSet().getYAxis(0);
        yAxis.getTitle().setVisible(false);
        yAxis.getTick().setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
        yAxis.setPosition(Position.Secondary);

        ((IPlotArea) getPlotArea()).addCustomPaintListener(new ICustomPaintListener()
        {
            @Override
            public void paintControl(PaintEvent e)
View Full Code Here

        return toolTip;
    }

    private void paintTimeGrid(PaintEvent e)
    {
        IAxis xAxis = getAxisSet().getXAxis(0);
        Range range = xAxis.getRange();
        Date upper = new Date((long) range.upper);

        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date((long) range.lower));
        cal.add(Calendar.YEAR, 1);
        cal.set(Calendar.MONTH, Calendar.JANUARY);
        cal.set(Calendar.DAY_OF_MONTH, 1);

        while (cal.getTimeInMillis() < upper.getTime())
        {
            int y = xAxis.getPixelCoordinate((double) cal.getTimeInMillis());
            e.gc.drawLine(y, 0, y, e.height);
            e.gc.drawText(String.valueOf(cal.get(Calendar.YEAR)), y + 5, 5);

            cal.add(Calendar.YEAR, 1);
        }
View Full Code Here

    private void paintMarkerLines(PaintEvent e)
    {
        if (markerLines.isEmpty())
            return;

        IAxis xAxis = getAxisSet().getXAxis(0);

        int labelExtentX = 0;
        int labelStackY = 0;

        for (MarkerLine marker : markerLines)
        {
            int x = xAxis.getPixelCoordinate((double) marker.date.getTime());

            Point textExtent = e.gc.textExtent(marker.label);
            boolean flip = x + 5 + textExtent.x > e.width;
            int textX = flip ? x - 5 - textExtent.x : x + 5;
            labelStackY = labelExtentX > textX ? labelStackY + textExtent.y : 0;
View Full Code Here

TOP

Related Classes of org.swtchart.IAxis

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.