edu.mit.csail.sdg.alloy4graph
Class Artist

java.lang.Object
  extended by edu.mit.csail.sdg.alloy4graph.Artist

public final class Artist
extends java.lang.Object

This class abstracts the drawing operations so that we can draw the graph using different frameworks such as Java2D or PDF.

Thread Safety: Can be called only by the AWT event thread.


Constructor Summary
Artist(java.awt.Graphics2D graphics2D)
          Construct an artist that acts as a wrapper around the given Graphics2D object.
Artist(OurPDFWriter pdfWriter)
          Construct an artist that acts as a wrapper around the given OurPDFWriter object.
 
Method Summary
 void draw(edu.mit.csail.sdg.alloy4graph.Curve curve)
          Draws the given curve.
 void draw(java.awt.Shape shape, boolean fillOrNot)
          Draws the outline of the given shape.
 void drawCircle(int radius)
          Draws a circle of the given radius, centered at (0,0)
 void drawLine(int x1, int y1, int x2, int y2)
          Draws a line from (x1,y1) to (x2,y2)
 void drawSmoothly(edu.mit.csail.sdg.alloy4graph.Curve curve)
          Draws the given curve smoothly (assuming the curve is monotonic vertically)
 void drawString(java.lang.String text, int x, int y)
          Draws the given string at (x,y)
 void fillCircle(int radius)
          Fills a circle of the given radius, centered at (0,0)
static java.awt.geom.Rectangle2D getBounds(boolean fontBoldness, java.lang.String string)
          Returns the bounding box when drawing the given string using the given font size and font boldness settings.
static int getMaxAscent()
          Returns the max ascent when drawing text using the given font size and font boldness settings.
static int getMaxAscentAndDescent()
          Returns the sum of the max ascent and max descent when drawing text using the given font size and font boldness settings.
 void set(DotStyle style, double scale)
          Modifies the given Graphics2D object to use the line style representing by this object.
 void setColor(java.awt.Color color)
          Changes the current color.
 void setFont(boolean fontBoldness)
          Changes the current font.
 void translate(int x, int y)
          Shifts the coordinate space by the given amount.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Artist

public Artist(java.awt.Graphics2D graphics2D)
Construct an artist that acts as a wrapper around the given Graphics2D object.


Artist

public Artist(OurPDFWriter pdfWriter)
Construct an artist that acts as a wrapper around the given OurPDFWriter object.

Method Detail

translate

public void translate(int x,
                      int y)
Shifts the coordinate space by the given amount.


drawCircle

public void drawCircle(int radius)
Draws a circle of the given radius, centered at (0,0)


fillCircle

public void fillCircle(int radius)
Fills a circle of the given radius, centered at (0,0)


drawLine

public void drawLine(int x1,
                     int y1,
                     int x2,
                     int y2)
Draws a line from (x1,y1) to (x2,y2)


setColor

public void setColor(java.awt.Color color)
Changes the current color.


drawSmoothly

public void drawSmoothly(edu.mit.csail.sdg.alloy4graph.Curve curve)
Draws the given curve smoothly (assuming the curve is monotonic vertically)


draw

public void draw(edu.mit.csail.sdg.alloy4graph.Curve curve)
Draws the given curve.


draw

public void draw(java.awt.Shape shape,
                 boolean fillOrNot)
Draws the outline of the given shape.


set

public void set(DotStyle style,
                double scale)
Modifies the given Graphics2D object to use the line style representing by this object.

NOTE: as a special guarantee, if gr2d==null, then this method returns immediately without doing anything.

NOTE: just like the typical AWT and Swing methods, this method can be called only by the AWT event dispatching thread.


setFont

public void setFont(boolean fontBoldness)
Changes the current font.


drawString

public void drawString(java.lang.String text,
                       int x,
                       int y)
Draws the given string at (x,y)


getMaxAscent

public static int getMaxAscent()
Returns the max ascent when drawing text using the given font size and font boldness settings.


getMaxAscentAndDescent

public static int getMaxAscentAndDescent()
Returns the sum of the max ascent and max descent when drawing text using the given font size and font boldness settings.


getBounds

public static java.awt.geom.Rectangle2D getBounds(boolean fontBoldness,
                                                  java.lang.String string)
Returns the bounding box when drawing the given string using the given font size and font boldness settings.