|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectchordDiagrams.DiagramDrawer
public class DiagramDrawer
This class provides graphical representations of diagrams (draws diagrams to a bitmap), and provides means to draw collections of diagrams and saving them to files.
Field Summary | |
---|---|
(package private) java.awt.BasicStroke |
dashedStroke
Dashed stroke for drawing |
(package private) int |
dspace
Spacing between diagrams |
(package private) java.awt.Graphics2D |
g2
Graphics object to draw on the image |
(package private) java.awt.image.BufferedImage |
image
Data structure to store image |
(package private) int |
numcols
Number of columns on the contact sheet |
(package private) int |
numrows
Number of rows on the contact sheet |
(package private) int |
r
circle radius |
(package private) java.awt.BasicStroke |
solidStroke
|
(package private) int |
space
spacing between circles |
Constructor Summary | |
---|---|
DiagramDrawer(int r,
int space)
Creates a diagram drawer instance |
|
DiagramDrawer(int r,
int space,
int numrows,
int numcols,
int dspace)
Creates a diagram drawer instance |
Method Summary | |
---|---|
void |
clearImage()
Blanks the image |
java.lang.String |
coefToString(double c)
Returns number as a string, with 1 being empty string and -1 being "-". |
int |
diagHeight(diagram g)
Returns the height of the diagram, in pixels |
int |
diagWidth(diagram g)
Returns the width of the diagram, in pixels |
void |
DrawAndSave(diagram g,
java.lang.String filename)
Draws and saves a diagram |
void |
DrawAndSave(java.util.HashMap<java.lang.String,diagram> hm,
java.lang.Iterable keySet,
java.lang.String name)
Draws and saves a subset of a collection of diagrams The filenames are formed using the pattern "name_n-k_#.png", where # stays for index in the list |
void |
drawChord(diagram g,
int i,
int off_x,
int off_y)
Draws straight chord in the diagram g emanating from endpoint t |
void |
drawCircles(int k,
int off_x,
int off_y)
Draws k properly spaced circles |
void |
drawCurvedChord(diagram g,
int i,
int off_x,
int off_y)
Draws curved chord in the diagram g emanating from endpoint t |
void |
drawCurvedInnerChord(diagram g,
int i,
int off_x,
int off_y)
Draws curved inner chord in the diagram g emanating from endpoint t (inner = not between links) |
void |
drawDiagram(diagram g,
int off_x,
int off_y,
boolean drawframe)
Draws a diagram on the image. |
void |
drawDot(diagram g,
int t,
int off_x,
int off_y)
Draws a dot that represents an endpoint on a diagram |
void |
DrawRelation(Relation relation,
java.util.ArrayList<java.lang.String> keySet,
java.util.HashMap<java.lang.String,diagram> diags,
int off_x,
int off_y)
Draws a relation on the image canvas |
java.awt.geom.Point2D |
getCircleCenter(diagram g,
int t,
int off_x,
int off_y)
Gets the center of the circle that represents the ring t |
private int |
getOffX(int i,
int dw)
Gets X offset of the diagram on the contact sheet |
private int |
getOffY(int i,
int dh)
Gets Y offset of the diagram on the contact sheet |
java.awt.geom.Point2D |
getPoint(diagram g,
int t,
int off_x,
int off_y)
Takes an index of a chord endpoint and produces a point |
void |
initImage(int dw,
int dh)
Initializes image and the graphics object and blanks the image |
int |
relationDiagramHeight(Relation relation,
java.util.ArrayList<java.lang.String> keySet,
java.util.HashMap<java.lang.String,diagram> diags)
Returns the relation depiction height |
int |
relationDiagramWidth(Relation relation,
java.util.ArrayList<java.lang.String> keySet,
java.util.HashMap<java.lang.String,diagram> diags)
Returns the relation depiction width |
void |
Save(java.lang.String filename)
Saves the diagram to a file |
void |
setFontByMinHeight(java.lang.Double pixelheight)
Sets font for the graphics 2D object to match the specified pixelheight The font will have the smallest point size that will result in font pixel height exceeding pixelheight parameter |
void |
setFontByWidth(java.lang.String S,
double pixelwidth,
double pixelheight)
Sets font for the graphics 2D object so that a string has length not exceeding pixel width and height The font size is largest value so that the string width does not exceed the set pixelwidth/pixelheight |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
java.awt.image.BufferedImage image
java.awt.Graphics2D g2
int r
int space
int numrows
int numcols
int dspace
java.awt.BasicStroke dashedStroke
java.awt.BasicStroke solidStroke
Constructor Detail |
---|
public DiagramDrawer(int r, int space, int numrows, int numcols, int dspace)
r
- diagram radiusspace
- spacing on the sides and between diagramsnumrows
- number of rows on contact sheetnumcols
- number of columns on contact sheetdspace
- spacing between diagramspublic DiagramDrawer(int r, int space)
r
- diagram radiusspace
- spacing on the sides and between diagramsMethod Detail |
---|
public void initImage(int dw, int dh)
w
- diagram widthh
- diagram heightpublic void clearImage()
public void drawCircles(int k, int off_x, int off_y)
k
- number of circlesoffset_x
- X coordinate of the leftmost circle (UL corner)offset_y
- Y coordinate of the leftmost circle (UL corner)public int diagWidth(diagram g)
g
- the diagram
public int diagHeight(diagram g)
g
- the diagram
public void drawDiagram(diagram g, int off_x, int off_y, boolean drawframe)
g
- the diagram to drawoff_x
- x offsetoff_y
- y offsetdrawframe
- draw frame around diagram ?public void drawChord(diagram g, int i, int off_x, int off_y)
g
- the diagramt
- endpoint indexoff_x
- X offsetoff_y
- Y offsetpublic void drawCurvedChord(diagram g, int i, int off_x, int off_y)
g
- t
- public void drawCurvedInnerChord(diagram g, int i, int off_x, int off_y)
g
- t
- public java.awt.geom.Point2D getCircleCenter(diagram g, int t, int off_x, int off_y)
t
- index of the link
public java.awt.geom.Point2D getPoint(diagram g, int t, int off_x, int off_y)
g
- the diagram that contains the pointt
- index of the pointoff_x
- X offsetoff_y
- Y offset
public void drawDot(diagram g, int t, int off_x, int off_y)
g
- the diagramt
- endpoint indexpublic void Save(java.lang.String filename)
filename
- The name of the file to save the diagram to (without extension, just the name)
Saves to PNG.public void DrawAndSave(diagram g, java.lang.String filename)
g
- the diagram to be savedfilename
- public void DrawAndSave(java.util.HashMap<java.lang.String,diagram> hm, java.lang.Iterable keySet, java.lang.String name)
hm
- hashmap with the diagramskeySet
- keys for the diagrams to draw and savename
- base for the filenameprivate int getOffX(int i, int dw)
i
- number of the diagramdw
- width of the diagram
private int getOffY(int i, int dh)
i
- number of the diagramdh
- height of the diagram
public int relationDiagramWidth(Relation relation, java.util.ArrayList<java.lang.String> keySet, java.util.HashMap<java.lang.String,diagram> diags)
relation
- the Arraylist that stores relationdiags
- data structure with diagrams diagram
public java.lang.String coefToString(double c)
c
- coefficient
public int relationDiagramHeight(Relation relation, java.util.ArrayList<java.lang.String> keySet, java.util.HashMap<java.lang.String,diagram> diags)
relation
- the Arraylist that stores relationdiags
- data structure with diagrams diagram
public void setFontByMinHeight(java.lang.Double pixelheight)
pixelheight
- desired heightpublic void DrawRelation(Relation relation, java.util.ArrayList<java.lang.String> keySet, java.util.HashMap<java.lang.String,diagram> diags, int off_x, int off_y)
relation
- the relation to draw - an arraylist of relation entrieskeySet
- data structure with keys; indices in the relation must correspond to entries in keySetdiags
- data structure with diagramsoff_x
- x offsetoff_y
- y offsetpublic void setFontByWidth(java.lang.String S, double pixelwidth, double pixelheight)
S
- the string you want to fit in pixelwidthpixelwidth
- desired string pixel width
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |