Example usage for org.jfree.chart.axis Axis isTickMarksVisible

List of usage examples for org.jfree.chart.axis Axis isTickMarksVisible

Introduction

In this page you can find the example usage for org.jfree.chart.axis Axis isTickMarksVisible.

Prototype

public boolean isTickMarksVisible() 

Source Link

Document

Returns the flag that indicates whether or not the tick marks are showing.

Usage

From source file:org.openfaces.component.chart.impl.helpers.AxisUtil.java

public static void setupAxisPresentation(String label, Axis axis, FakeAxisStyle axisStyle) {
    StyleObjectModel model = axisStyle.getStyleObjectModel();
    StyleBorderModel border = model.getBorder();
    if (border != null) {
        if (border.getColor() != null) {
            axis.setAxisLinePaint(border.getColor());
        }//from  w ww  .  java2s .  c  om

        if (!border.isNone()) {
            axis.setAxisLineVisible(true);
            axis.setAxisLineStroke(PropertiesConverter.toStroke(border));
            axis.setTickMarkPaint(border.getColor());
            axis.setTickMarksVisible(true);
            if (!axis.isTickMarksVisible())
                axis.setTickMarksVisible(false);
        }

        if (border.getStyle().equalsIgnoreCase("none")) {
            axis.setAxisLineVisible(false);
            axis.setTickMarksVisible(false);
            if (axis.isTickMarksVisible())
                axis.setTickMarksVisible(true);
        }

    }

    axis.setTickLabelsVisible(axisStyle.isTickLabelsVisible());

    if (axisStyle.isLabelVisible() && label != null) {
        axis.setLabel(label);
        axis.setLabelPaint(model.getColor());
        axis.setLabelFont(CSSUtil.getFont(model));
    }

    if (axisStyle.isTickLabelsVisible()) {
        axis.setTickLabelsVisible(true);
        axis.setTickLabelPaint(model.getColor());
        axis.setTickLabelFont(CSSUtil.getFont(model));
    } else {
        axis.setTickLabelsVisible(false);
    }

    Double tickInterval = axisStyle.getTickInterval();
    if (tickInterval != null && tickInterval != 0 && axis instanceof NumberAxis) {
        NumberAxis numberAxis = (NumberAxis) axis;
        if (tickInterval > 0) {
            NumberTickUnit tickUnit = new NumberTickUnit(tickInterval);
            numberAxis.setTickUnit(tickUnit);
        } else if (tickInterval == -1) {
            TickUnitSource tickUnits = NumberAxis.createIntegerTickUnits();
            numberAxis.setStandardTickUnits(tickUnits);
        } else {
            throw new FacesException("tickInterval must be a positive number for a fixed tick interval, "
                    + "or -1 for automatic integer tick selection: " + tickInterval);
        }

        numberAxis.setMinorTickMarksVisible(true);
        numberAxis.setMinorTickCount(2);
        numberAxis.setMinorTickMarkOutsideLength(3);
        numberAxis.setMinorTickMarkInsideLength(3);
        numberAxis.setTickMarkInsideLength(5);
        numberAxis.setTickMarkOutsideLength(5);
    }

    axis.setTickMarkInsideLength(axisStyle.getTickInsideLength());
    axis.setTickMarkOutsideLength(axisStyle.getTickOutsideLength());
    if (axisStyle.getMinorTicksVisible()) {
        axis.setMinorTickMarksVisible(true);
        if (axis instanceof ValueAxis)
            ((ValueAxis) axis).setMinorTickCount(axisStyle.getMinorTickCount() + 1);
        axis.setMinorTickMarkInsideLength(axisStyle.getMinorTickInsideLength());
        axis.setMinorTickMarkOutsideLength(axisStyle.getMinorTickOutsideLength());
    } else {
        axis.setMinorTickMarksVisible(false);
    }
}

From source file:daylightchart.options.chart.AxisOptions.java

/**
 * Gets the properties of the specified axis to match the properties
 * defined on this panel./*from w  w  w  .j  a  va  2 s  . co m*/
 *
 * @param axis
 *        the axis.
 */
void getAxisProperties(final Axis axis) {
    label = axis.getLabel();
    labelFont = axis.getLabelFont();
    labelPaint = axis.getLabelPaint();
    labelInsets = axis.getLabelInsets();
    //
    tickMarksVisible = axis.isTickMarksVisible();
    tickLabelsVisible = axis.isTickLabelsVisible();
    tickLabelFont = axis.getTickLabelFont();
    tickLabelPaint = axis.getTickLabelPaint();
    tickLabelInsets = axis.getTickLabelInsets();
}

From source file:com.bdaum.zoom.report.internal.wizards.ReportComponent.java

private static void saveAxisProperties(Axis axis, String prefix, Map<String, Object> properties) {
    properties.put(prefix + AXISLABEL, axis.getLabel());
    properties.put(prefix + AXISLABELFONT, axis.getLabelFont());
    properties.put(prefix + AXISLABELPAINT, axis.getLabelPaint());
    properties.put(prefix + TICKMARKSVISIBLE, axis.isTickMarksVisible());
    properties.put(prefix + TICKLABELSVISIBLE, axis.isTickLabelsVisible());
    properties.put(prefix + TICKLABELFONT, axis.getTickLabelFont());
    properties.put(prefix + TICKLABELPAINT, axis.getLabelPaint());
}

From source file:ch.zhaw.simulation.diagram.charteditor.DefaultAxisEditor.java

/**
 * Standard constructor: builds a panel for displaying/editing the
 * properties of the specified axis.//  w  w  w .  java  2s .c  om
 * 
 * @param axis
 *            the axis whose properties are to be displayed/edited in the
 *            panel.
 */
public DefaultAxisEditor(Axis axis) {
    this.labelFont = axis.getLabelFont();
    this.labelPaintSample = new PaintSample(axis.getLabelPaint());
    this.tickLabelFont = axis.getTickLabelFont();
    this.tickLabelPaintSample = new PaintSample(axis.getTickLabelPaint());

    // Insets values
    this.tickLabelInsets = axis.getTickLabelInsets();
    this.labelInsets = axis.getLabelInsets();

    setLayout(new BorderLayout());

    JPanel general = new JPanel(new BorderLayout());
    general.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
            localizationResources.getString("General")));

    JPanel interior = new JPanel(new LCBLayout(5));
    interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    interior.add(new JLabel(localizationResources.getString("Label")));
    this.label = new JTextField(axis.getLabel());
    interior.add(this.label);
    interior.add(new JPanel());

    interior.add(new JLabel(localizationResources.getString("Font")));
    this.labelFontField = new FontDisplayField(this.labelFont);
    interior.add(this.labelFontField);
    JButton b = new JButton(localizationResources.getString("Select..."));
    b.setActionCommand("SelectLabelFont");
    b.addActionListener(this);
    interior.add(b);

    interior.add(new JLabel(localizationResources.getString("Paint")));
    interior.add(this.labelPaintSample);
    b = new JButton(localizationResources.getString("Select..."));
    b.setActionCommand("SelectLabelPaint");
    b.addActionListener(this);
    interior.add(b);

    general.add(interior);

    add(general, BorderLayout.NORTH);

    this.slot1 = new JPanel(new BorderLayout());

    JPanel other = new JPanel(new BorderLayout());
    other.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
            localizationResources.getString("Other")));

    this.otherTabs = new JTabbedPane();
    this.otherTabs.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));

    JPanel ticks = new JPanel(new LCBLayout(3));
    ticks.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    this.showTickLabelsCheckBox = new JCheckBox(localizationResources.getString("Show_tick_labels"),
            axis.isTickLabelsVisible());
    ticks.add(this.showTickLabelsCheckBox);
    ticks.add(new JPanel());
    ticks.add(new JPanel());

    ticks.add(new JLabel(localizationResources.getString("Tick_label_font")));
    this.tickLabelFontField = new FontDisplayField(this.tickLabelFont);
    ticks.add(this.tickLabelFontField);
    b = new JButton(localizationResources.getString("Select..."));
    b.setActionCommand("SelectTickLabelFont");
    b.addActionListener(this);
    ticks.add(b);

    this.showTickMarksCheckBox = new JCheckBox(localizationResources.getString("Show_tick_marks"),
            axis.isTickMarksVisible());
    ticks.add(this.showTickMarksCheckBox);
    ticks.add(new JPanel());
    ticks.add(new JPanel());

    this.otherTabs.add(localizationResources.getString("Ticks"), ticks);

    other.add(this.otherTabs);

    this.slot1.add(other);

    this.slot2 = new JPanel(new BorderLayout());
    this.slot2.add(this.slot1, BorderLayout.NORTH);
    add(this.slot2);

}

From source file:org.jfree.experimental.chart.swt.editor.SWTAxisEditor.java

/**
 * Standard constructor: builds a composite for displaying/editing 
 * the properties of the specified axis.
 *
 * @param parent The parent composite./*w  w w .  j  a  va 2s.com*/
 * @param style The SWT style of the SwtAxisEditor.
 * @param axis  the axis whose properties are to be displayed/edited  
 *              in the composite.
 */
public SWTAxisEditor(Composite parent, int style, Axis axis) {
    super(parent, style);
    this.labelFont = SWTUtils.toSwtFontData(getDisplay(), axis.getLabelFont(), true);
    this.labelPaintColor = SWTUtils.toSwtColor(getDisplay(), axis.getLabelPaint());
    this.tickLabelFont = SWTUtils.toSwtFontData(getDisplay(), axis.getTickLabelFont(), true);
    this.tickLabelPaintColor = SWTUtils.toSwtColor(getDisplay(), axis.getTickLabelPaint());

    FillLayout layout = new FillLayout(SWT.VERTICAL);
    layout.marginHeight = layout.marginWidth = 4;
    this.setLayout(layout);
    Group general = new Group(this, SWT.NONE);
    general.setLayout(new GridLayout(3, false));
    general.setText(localizationResources.getString("General"));
    // row 1
    new Label(general, SWT.NONE).setText(localizationResources.getString("Label"));
    this.label = new Text(general, SWT.BORDER);
    if (axis.getLabel() != null) {
        this.label.setText(axis.getLabel());
    }
    this.label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    new Label(general, SWT.NONE).setText(""); //empty cell
    // row 2
    new Label(general, SWT.NONE).setText(localizationResources.getString("Font"));
    this.labelFontField = new Text(general, SWT.BORDER);
    this.labelFontField.setText(this.labelFont.toString());
    this.labelFontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    Button selectFontButton = new Button(general, SWT.PUSH);
    selectFontButton.setText(localizationResources.getString("Select..."));
    selectFontButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the color-change dialog
            FontDialog dlg = new FontDialog(getShell());
            dlg.setText(localizationResources.getString("Font_Selection"));
            dlg.setFontList(new FontData[] { SWTAxisEditor.this.labelFont });
            if (dlg.open() != null) {
                // Dispose of any fonts we have created
                if (SWTAxisEditor.this.font != null) {
                    SWTAxisEditor.this.font.dispose();
                }
                // Create the new font and set it into the title 
                // label
                SWTAxisEditor.this.font = new Font(getShell().getDisplay(), dlg.getFontList());
                //label.setFont( font );
                SWTAxisEditor.this.labelFontField.setText(SWTAxisEditor.this.font.getFontData()[0].toString());
                SWTAxisEditor.this.labelFont = SWTAxisEditor.this.font.getFontData()[0];
            }
        }
    });
    // row 3
    new Label(general, SWT.NONE).setText(localizationResources.getString("Paint"));
    // Use a colored text field to show the color
    final SWTPaintCanvas colorCanvas = new SWTPaintCanvas(general, SWT.NONE, this.labelPaintColor);
    GridData canvasGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    canvasGridData.heightHint = 20;
    colorCanvas.setLayoutData(canvasGridData);
    Button selectColorButton = new Button(general, SWT.PUSH);
    selectColorButton.setText(localizationResources.getString("Select..."));
    selectColorButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the color-change dialog
            ColorDialog dlg = new ColorDialog(getShell());
            dlg.setText(localizationResources.getString("Title_Color"));
            dlg.setRGB(SWTAxisEditor.this.labelPaintColor.getRGB());
            RGB rgb = dlg.open();
            if (rgb != null) {
                // create the new color and set it to the 
                // SwtPaintCanvas
                SWTAxisEditor.this.labelPaintColor = new Color(getDisplay(), rgb);
                colorCanvas.setColor(SWTAxisEditor.this.labelPaintColor);
            }
        }
    });
    Group other = new Group(this, SWT.NONE);
    FillLayout tabLayout = new FillLayout();
    tabLayout.marginHeight = tabLayout.marginWidth = 4;
    other.setLayout(tabLayout);
    other.setText(localizationResources.getString("Other"));

    this.otherTabs = new TabFolder(other, SWT.NONE);
    TabItem item1 = new TabItem(this.otherTabs, SWT.NONE);
    item1.setText(" " + localizationResources.getString("Ticks") + " ");
    Composite ticks = new Composite(this.otherTabs, SWT.NONE);
    ticks.setLayout(new GridLayout(3, false));
    this.showTickLabelsCheckBox = new Button(ticks, SWT.CHECK);
    this.showTickLabelsCheckBox.setText(localizationResources.getString("Show_tick_labels"));
    this.showTickLabelsCheckBox.setSelection(axis.isTickLabelsVisible());
    this.showTickLabelsCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    new Label(ticks, SWT.NONE).setText(localizationResources.getString("Tick_label_font"));
    this.tickLabelFontField = new Text(ticks, SWT.BORDER);
    this.tickLabelFontField.setText(this.tickLabelFont.toString());
    //tickLabelFontField.setFont(SwtUtils.toSwtFontData(getDisplay(), 
    // axis.getTickLabelFont()));
    this.tickLabelFontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    Button selectTickLabelFontButton = new Button(ticks, SWT.PUSH);
    selectTickLabelFontButton.setText(localizationResources.getString("Select..."));
    selectTickLabelFontButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the font-change dialog
            FontDialog dlg = new FontDialog(getShell());
            dlg.setText(localizationResources.getString("Font_Selection"));
            dlg.setFontList(new FontData[] { SWTAxisEditor.this.tickLabelFont });
            if (dlg.open() != null) {
                // Dispose of any fonts we have created
                if (SWTAxisEditor.this.font != null) {
                    SWTAxisEditor.this.font.dispose();
                }
                // Create the new font and set it into the title 
                // label
                SWTAxisEditor.this.font = new Font(getShell().getDisplay(), dlg.getFontList());
                //tickLabelFontField.setFont(font);
                SWTAxisEditor.this.tickLabelFontField
                        .setText(SWTAxisEditor.this.font.getFontData()[0].toString());
                SWTAxisEditor.this.tickLabelFont = SWTAxisEditor.this.font.getFontData()[0];
            }
        }
    });
    this.showTickMarksCheckBox = new Button(ticks, SWT.CHECK);
    this.showTickMarksCheckBox.setText(localizationResources.getString("Show_tick_marks"));
    this.showTickMarksCheckBox.setSelection(axis.isTickMarksVisible());
    this.showTickMarksCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    item1.setControl(ticks);
}

From source file:com.rcp.wbw.demo.editor.SWTAxisEditor.java

/**
 * Standard constructor: builds a composite for displaying/editing
 * the properties of the specified axis.
 * //from  w w  w .ja  v  a 2s.c o m
 * @param parent
 *            The parent composite.
 * @param style
 *            The SWT style of the SwtAxisEditor.
 * @param axis
 *            the axis whose properties are to be displayed/edited
 *            in the composite.
 */
public SWTAxisEditor(Composite parent, int style, Axis axis) {
    super(parent, style);
    this.labelFont = SWTUtils.toSwtFontData(getDisplay(), axis.getLabelFont(), true);
    this.labelPaintColor = SWTUtils.toSwtColor(getDisplay(), axis.getLabelPaint());
    this.tickLabelFont = SWTUtils.toSwtFontData(getDisplay(), axis.getTickLabelFont(), true);
    this.tickLabelPaintColor = SWTUtils.toSwtColor(getDisplay(), axis.getTickLabelPaint());

    FillLayout layout = new FillLayout(SWT.VERTICAL);
    layout.marginHeight = layout.marginWidth = 4;
    setLayout(layout);
    Group general = new Group(this, SWT.NONE);
    general.setLayout(new GridLayout(3, false));
    general.setText(localizationResources.getString("General"));
    // row 1
    new Label(general, SWT.NONE).setText(localizationResources.getString("Label"));
    this.label = new Text(general, SWT.BORDER);
    if (axis.getLabel() != null) {
        this.label.setText(axis.getLabel());
    }
    this.label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    new Label(general, SWT.NONE).setText(""); // empty cell
    // row 2
    new Label(general, SWT.NONE).setText(localizationResources.getString("Font"));
    this.labelFontField = new Text(general, SWT.BORDER);
    this.labelFontField.setText(this.labelFont.toString());
    this.labelFontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    Button selectFontButton = new Button(general, SWT.PUSH);
    selectFontButton.setText(localizationResources.getString("Select..."));
    selectFontButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the color-change dialog
            FontDialog dlg = new FontDialog(getShell());
            dlg.setText(localizationResources.getString("Font_Selection"));
            dlg.setFontList(new FontData[] { SWTAxisEditor.this.labelFont });
            if (dlg.open() != null) {
                // Dispose of any fonts we have created
                if (SWTAxisEditor.this.font != null) {
                    SWTAxisEditor.this.font.dispose();
                }
                // Create the new font and set it into the title
                // label
                SWTAxisEditor.this.font = new Font(getShell().getDisplay(), dlg.getFontList());
                // label.setFont(font);
                SWTAxisEditor.this.labelFontField.setText(SWTAxisEditor.this.font.getFontData()[0].toString());
                SWTAxisEditor.this.labelFont = SWTAxisEditor.this.font.getFontData()[0];
            }
        }
    });
    // row 3
    new Label(general, SWT.NONE).setText(localizationResources.getString("Paint"));
    // Use a colored text field to show the color
    final SWTPaintCanvas colorCanvas = new SWTPaintCanvas(general, SWT.NONE, this.labelPaintColor);
    GridData canvasGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    canvasGridData.heightHint = 20;
    colorCanvas.setLayoutData(canvasGridData);
    Button selectColorButton = new Button(general, SWT.PUSH);
    selectColorButton.setText(localizationResources.getString("Select..."));
    selectColorButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the color-change dialog
            ColorDialog dlg = new ColorDialog(getShell());
            dlg.setText(localizationResources.getString("Title_Color"));
            dlg.setRGB(SWTAxisEditor.this.labelPaintColor.getRGB());
            RGB rgb = dlg.open();
            if (rgb != null) {
                // create the new color and set it to the
                // SwtPaintCanvas
                SWTAxisEditor.this.labelPaintColor = new Color(getDisplay(), rgb);
                colorCanvas.setColor(SWTAxisEditor.this.labelPaintColor);
            }
        }
    });
    Group other = new Group(this, SWT.NONE);
    FillLayout tabLayout = new FillLayout();
    tabLayout.marginHeight = tabLayout.marginWidth = 4;
    other.setLayout(tabLayout);
    other.setText(localizationResources.getString("Other"));

    this.otherTabs = new TabFolder(other, SWT.NONE);
    TabItem item1 = new TabItem(this.otherTabs, SWT.NONE);
    item1.setText(" " + localizationResources.getString("Ticks") + " ");
    Composite ticks = new Composite(this.otherTabs, SWT.NONE);
    ticks.setLayout(new GridLayout(3, false));
    this.showTickLabelsCheckBox = new Button(ticks, SWT.CHECK);
    this.showTickLabelsCheckBox.setText(localizationResources.getString("Show_tick_labels"));
    this.showTickLabelsCheckBox.setSelection(axis.isTickLabelsVisible());
    this.showTickLabelsCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    new Label(ticks, SWT.NONE).setText(localizationResources.getString("Tick_label_font"));
    this.tickLabelFontField = new Text(ticks, SWT.BORDER);
    this.tickLabelFontField.setText(this.tickLabelFont.toString());
    // tickLabelFontField.setFont(SwtUtils.toSwtFontData(getDisplay(),
    // axis.getTickLabelFont()));
    this.tickLabelFontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    Button selectTickLabelFontButton = new Button(ticks, SWT.PUSH);
    selectTickLabelFontButton.setText(localizationResources.getString("Select..."));
    selectTickLabelFontButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the font-change dialog
            FontDialog dlg = new FontDialog(getShell());
            dlg.setText(localizationResources.getString("Font_Selection"));
            dlg.setFontList(new FontData[] { SWTAxisEditor.this.tickLabelFont });
            if (dlg.open() != null) {
                // Dispose of any fonts we have created
                if (SWTAxisEditor.this.font != null) {
                    SWTAxisEditor.this.font.dispose();
                }
                // Create the new font and set it into the title
                // label
                SWTAxisEditor.this.font = new Font(getShell().getDisplay(), dlg.getFontList());
                // tickLabelFontField.setFont(font);
                SWTAxisEditor.this.tickLabelFontField
                        .setText(SWTAxisEditor.this.font.getFontData()[0].toString());
                SWTAxisEditor.this.tickLabelFont = SWTAxisEditor.this.font.getFontData()[0];
            }
        }
    });
    this.showTickMarksCheckBox = new Button(ticks, SWT.CHECK);
    this.showTickMarksCheckBox.setText(localizationResources.getString("Show_tick_marks"));
    this.showTickMarksCheckBox.setSelection(axis.isTickMarksVisible());
    this.showTickMarksCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    item1.setControl(ticks);
}