de.jaret.util.swing
Class GraphicsHelper

java.lang.Object
  extended by de.jaret.util.swing.GraphicsHelper

public class GraphicsHelper
extends Object

A simple class containing several static methods for convenient painting with a grpahics object.

Version:
$Id: GraphicsHelper.java 881 2009-09-22 21:25:47Z kliem $
Author:
Peter Kliem

Constructor Summary
GraphicsHelper()
           
 
Method Summary
static void drawArrowLine(Graphics g, int x1, int y1, int x2, int y2, int dist, boolean arrowLeft, boolean arrowRight)
           
static void drawArrowLineVertical(Graphics g, int x1, int y1, int x2, int y2, int dist, int height, boolean arrowUp, boolean arrowDown)
           
static void drawStringCentered(Graphics graphics, String string, int x, int y)
           
static void drawStringCentered(Graphics graphics, String string, int left, int right, int y)
           
static void drawStringCentered(Graphics graphics, String string, Rectangle area)
           
static void drawStringCenteredPoint(Graphics graphics, String string, int x, int y)
           
static void drawStringCenteredVCenter(Graphics graphics, String string, int left, int right, int yCenter)
           
static void drawStringLeftAlignedVCenter(Graphics graphics, String string, int x, int y)
           
static void drawStringRightAlignedVCenter(Graphics graphics, String string, int x, int y)
           
static void drawStringRightAlignedVTop(Graphics graphics, String string, int x, int yTop)
           
static void drawStringVCentered(Graphics graphics, String string, int x, int upperY, int lowerY)
          Draw a string vertically centered between upper and lower y left aligned to x.
static void drawStringVertical(Graphics graphics, String string, int x, int y)
          Draw a String vertical.
static int getStringDrawingHeight(Graphics graphics, String string)
           
static int getStringDrawingWidth(Graphics graphics, String string)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphicsHelper

public GraphicsHelper()
Method Detail

drawStringCentered

public static void drawStringCentered(Graphics graphics,
                                      String string,
                                      int left,
                                      int right,
                                      int y)

drawStringCenteredVCenter

public static void drawStringCenteredVCenter(Graphics graphics,
                                             String string,
                                             int left,
                                             int right,
                                             int yCenter)

drawStringRightAlignedVCenter

public static void drawStringRightAlignedVCenter(Graphics graphics,
                                                 String string,
                                                 int x,
                                                 int y)

drawStringLeftAlignedVCenter

public static void drawStringLeftAlignedVCenter(Graphics graphics,
                                                String string,
                                                int x,
                                                int y)

drawStringCentered

public static void drawStringCentered(Graphics graphics,
                                      String string,
                                      int x,
                                      int y)
Parameters:
graphics - graphics to use
string - string to render
x - center x
y - basey

drawStringCenteredPoint

public static void drawStringCenteredPoint(Graphics graphics,
                                           String string,
                                           int x,
                                           int y)

drawStringCentered

public static void drawStringCentered(Graphics graphics,
                                      String string,
                                      Rectangle area)

getStringDrawingWidth

public static int getStringDrawingWidth(Graphics graphics,
                                        String string)

getStringDrawingHeight

public static int getStringDrawingHeight(Graphics graphics,
                                         String string)

drawStringRightAlignedVTop

public static void drawStringRightAlignedVTop(Graphics graphics,
                                              String string,
                                              int x,
                                              int yTop)

drawStringVCentered

public static void drawStringVCentered(Graphics graphics,
                                       String string,
                                       int x,
                                       int upperY,
                                       int lowerY)
Draw a string vertically centered between upper and lower y left aligned to x.

Parameters:
graphics - Graphics to paint with
label - label to draw
x - left x
upperY - upper y bound
lowerY - lower y bound

drawArrowLine

public static void drawArrowLine(Graphics g,
                                 int x1,
                                 int y1,
                                 int x2,
                                 int y2,
                                 int dist,
                                 boolean arrowLeft,
                                 boolean arrowRight)

drawArrowLineVertical

public static void drawArrowLineVertical(Graphics g,
                                         int x1,
                                         int y1,
                                         int x2,
                                         int y2,
                                         int dist,
                                         int height,
                                         boolean arrowUp,
                                         boolean arrowDown)

drawStringVertical

public static void drawStringVertical(Graphics graphics,
                                      String string,
                                      int x,
                                      int y)
Draw a String vertical. This method might be quite costly since it uses an image to buffer.

Parameters:
graphics - graphics to paint with
string - string to to draw
x - upper left x
y - upper left y


Copyright © 2013. All Rights Reserved.