Java Graphics Draw drawXMajorScaleTick(Graphics g, int x, int y)

Here you can find the source of drawXMajorScaleTick(Graphics g, int x, int y)

Description

Draws a major scale tick for the x-axis from (x, y) down using the graphics in the Graphics2D object g.

License

Open Source License

Parameter

Parameter Description
g <code>java.awt.Graphics</code> object to the graphics.
x int starting x-coordinate of the scale tick.
y int starting y-coordinate of the scale tick.

Declaration

private static void drawXMajorScaleTick(Graphics g, int x, int y) 

Method Source Code

//package com.java2s;
/**/*from   w w w.j av  a 2 s . com*/
 * PlotUtilities.java
 *
 *
 * Cytobank (TM) is server and client software for web-based management, analysis,
 * and sharing of flow cytometry data.
 *
 * Copyright (C) 2009 Cytobank, Inc. All rights reserved.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * Cytobank, Inc.
 * 659 Oak Grove Avenue #205
 * Menlo Park, CA 94025
 *
 * http://www.cytobank.org
 */

import java.awt.*;

public class Main {
    /**
     * The length of a major scale tick
     */
    private static final int MAJOR_TICK_LENGTH = 7;

    /**
     * <p>
     * Draws a major scale tick for the x-axis from (x, y) down using the
     * graphics in the <code>Graphics2D</code> object g.
     * </p>
     *
     * @param g
     * <code>java.awt.Graphics</code> object to the graphics.
     * @param x
     * int starting x-coordinate of the scale tick.
     * @param y
     * int starting y-coordinate of the scale tick.
     */
    private static void drawXMajorScaleTick(Graphics g, int x, int y) {
        drawScaleTick(g, x, y, false, MAJOR_TICK_LENGTH);
    }

    /**
     * <p>
     * Draws a scale tick of length length from (x, y) to the left if
     * horizontalP is true or down if horizontalP is false using the graphics in
     * the <code>Graphics2D</code> object g.
     * </p>
     *
     * @param g
     * <code>java.awt.Graphics</code> object to the graphics.
     * @param x
     * int starting x-coordinate of the scale tick.
     * @param y
     * int starting y-coordinate of the scale tick.
     * @param yAxisP
     * boolean flag indicating whether the scale tick is for the
     * y-axis.
     * @param length
     * int length of the scale tick.
     */
    private static void drawScaleTick(Graphics g, int x, int y,
            boolean yAxisP, int length) {
        if (g == null) {
            // If the graphics is null, then quit.
            return;
        }

        if (yAxisP) {
            // If the scale tick is for the y-axis, then draw a horizontal scale
            // tick extending to the left from (x, y).
            g.drawLine(x, y, x - length, y);
        } else {
            // Otherwise, the scale tick is for the x-axis, so draw a vertical
            // scale tick extending down from (x, y).
            g.drawLine(x, y, x, y + length);
        }
    }
}

Related

  1. drawTankISPip(Graphics2D g2d, int width, int height)
  2. drawTransparent(Graphics g, int x, int y, int width, int height)
  3. drawUp(Graphics g, int x, int y, int w, int h)
  4. drawWeightBox(Graphics2D g2d, int ycentre, int xcentre, int width)
  5. drawWinUpperLeft(Graphics g, int which, Color fill, int x, int y, int fmWidth, int fmHeight)
  6. fillVisible(final Graphics g, final JComponent c)
  7. fitToWidthAndHeight(Graphics2D g2, JComponent component, int width, int height)
  8. getGraphicsDevice(Component comp)
  9. getTranslatedGraphics(Graphics g, PageFormat pf, int pageIndex, Component component)