kcl.waterloo.annotation
Class GJAnnotation
- java.lang.Object
-
- kcl.waterloo.annotation.GJAnnotation
-
- All Implemented Interfaces:
- GJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>
- Direct Known Subclasses:
- GJAnnotation.ArrowAnnotation, GJAnnotation.LineAnnotation, GJAnnotation.ShapeAnnotation, GJAnnotation.TextAnnotation
public abstract class GJAnnotation extends java.lang.Object implements GJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>
GJAnnotation is an abstract class that provides concrete internal classes to annotate parentGraph containers and static factory methods to construct them. Annotations can be added to parentGraph containers by calling the container'saddmethod (in which case the position of the annotation will be set in the coordinate space of that container's View) or by calling theaddmethod of a parentGraph layer in the View of a container (in which case the position of the annotation will be set in that layer's coordinate space).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classGJAnnotation.ArrowAnnotationInternal class for arrow annotationsstatic classGJAnnotation.LineAnnotationInternal class for line annotationsstatic classGJAnnotation.ShapeAnnotationInternal class for shape annotationsstatic classGJAnnotation.TextAnnotationInternal class for text annotations
-
Constructor Summary
Constructors Constructor and Description GJAnnotation()Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static GJAnnotation.ArrowAnnotationcreateArrow(double x1, double y1, double x2, double y2, double szx, double szy)Static method to create a line between {x1,y1} and {x2,y2}.static GJAnnotation.ArrowAnnotationcreateArrow(double x1, double y1, double x2, double y2, double x3, double y3, double szx, double szy)static GJAnnotation.ShapeAnnotationcreateBox(double x, double y, double w, double h)Static method to create a rectangle where {X,Y} is the top left corner and w and h are the width and height.static GJAnnotation.ShapeAnnotationcreateEllipse(double x, double y, double w, double h)Static method to create an ellipse where {X,Y} is the top left corner and w and h are the width and height of the bounding rectangle.static GJAnnotation.LineAnnotationcreateLine(double x1, double y1, double x2, double y2)Static method to create a line between {x1,y1} and {x2,y2}.static GJAnnotation.LineAnnotationcreateLine(double x1, double y1, double x2, double y2, double x3, double y3)Static method to create a line between {x1,y1} and {x2,y2}.static GJAnnotation.ShapeAnnotationcreateShape(java.awt.Shape s)Creates an annotation using the specified object which should implement the {code Shape} interface.static GJAnnotation.TextAnnotationcreateText(double x, double y, java.lang.String s)GJMarkergetExtra()Returns the parentGraph reference for setting the coordinate system for this annotation.java.awt.PaintgetFill()java.awt.FontgetFont()java.awt.PaintgetLineColor()java.awt.StrokegetLineStroke()intgetLineTextPosition()GJMarkergetMarker()java.lang.StringgetName()GJGraphInterfacegetParentGraph()Returns the parentGraph reference for setting the coordinate system for this annotation.java.awt.geom.Path2DgetPath()Returns a clone of the Path2D object.java.lang.StringgetText()java.awt.PaintgetTextBackground()java.awt.PaintgetTextColor()doublegetXData()doublegetYData()voidpaintAnnotation(java.awt.Graphics2D g2, java.awt.geom.AffineTransform af)paintAnnotation method.voidremove()Removes the annotationvoidremove(java.lang.String name)Removes annotation(s) named by the stringvoidsetExtra(GJMarker p)Sets the Path2D object.voidsetFill(java.awt.Paint Fill)voidsetFont(java.awt.Font Font)voidsetLineColor(java.awt.Paint LineColor)voidsetLineStroke(java.awt.Stroke LineStroke)voidsetLineTextPosition(int pos)voidsetMarker(GJMarker Marker)voidsetName(java.lang.String Name)voidsetParentGraph(GJGraphInterface gr)setParentGraph method.voidsetPath(java.awt.geom.Path2D p)Sets the Path2D object.voidsetText(java.lang.String Text)voidsetTextBackground(java.awt.Paint textBackground)voidsetTextColor(java.awt.Paint TextColor)Sets the textColorvoidsetXData(double X)voidsetYData(double Y)
-
-
-
Method Detail
-
getPath
public java.awt.geom.Path2D getPath()
Returns a clone of the Path2D object.- Specified by:
getPathin interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Returns:
- the marker
-
setPath
public void setPath(java.awt.geom.Path2D p)
Sets the Path2D object.- Specified by:
setPathin interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Parameters:
p-
-
getParentGraph
public GJGraphInterface getParentGraph()
Returns the parentGraph reference for setting the coordinate system for this annotation.- Specified by:
getParentGraphin interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Returns:
- the plot
-
setExtra
public void setExtra(GJMarker p)
Sets the Path2D object.- Specified by:
setExtrain interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Parameters:
p-
-
getExtra
public GJMarker getExtra()
Returns the parentGraph reference for setting the coordinate system for this annotation.- Specified by:
getExtrain interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Returns:
- the plot
-
setParentGraph
public void setParentGraph(GJGraphInterface gr)
setParentGraph method. This is called when an annotation is added using theaddmethod of a parentGraph - which is recommended - so need not be called directly by the user.- Specified by:
setParentGraphin interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Parameters:
gr-
-
getLineStroke
public java.awt.Stroke getLineStroke()
- Specified by:
getLineStrokein interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Returns:
- the lineStroke
-
setLineStroke
public void setLineStroke(java.awt.Stroke LineStroke)
- Specified by:
setLineStrokein interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Parameters:
LineStroke- the LineStroke to set
-
getLineColor
public java.awt.Paint getLineColor()
- Specified by:
getLineColorin interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Returns:
- the lineColor
-
setLineColor
public void setLineColor(java.awt.Paint LineColor)
- Specified by:
setLineColorin interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Parameters:
LineColor- the LineColor to set
-
getFont
public java.awt.Font getFont()
- Specified by:
getFontin interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Returns:
- the Font
-
setFont
public void setFont(java.awt.Font Font)
- Specified by:
setFontin interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Parameters:
Font- the Font to set
-
getFill
public java.awt.Paint getFill()
- Specified by:
getFillin interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Returns:
- the fill
-
setFill
public void setFill(java.awt.Paint Fill)
- Specified by:
setFillin interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Parameters:
Fill- the Fill to set
-
getMarker
public GJMarker getMarker()
- Specified by:
getMarkerin interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Returns:
- the marker
-
setMarker
public void setMarker(GJMarker Marker)
- Specified by:
setMarkerin interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Parameters:
Marker- the Marker to set
-
getName
public java.lang.String getName()
- Specified by:
getNamein interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Returns:
- the name
-
setName
public void setName(java.lang.String Name)
- Specified by:
setNamein interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Parameters:
Name- the Name to set
-
getText
public java.lang.String getText()
- Specified by:
getTextin interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Returns:
- the text
-
setText
public void setText(java.lang.String Text)
- Specified by:
setTextin interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Parameters:
Text- the Text to set
-
getXData
public double getXData()
- Specified by:
getXDatain interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Returns:
- the X
-
setXData
public void setXData(double X)
- Specified by:
setXDatain interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Parameters:
X- the X to set
-
getYData
public double getYData()
- Specified by:
getYDatain interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Returns:
- the Y
-
setYData
public void setYData(double Y)
- Specified by:
setYDatain interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Parameters:
Y- the Y to set
-
getTextColor
public java.awt.Paint getTextColor()
- Specified by:
getTextColorin interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Returns:
- the textColor
-
setTextColor
public void setTextColor(java.awt.Paint TextColor)
Sets the textColor- Specified by:
setTextColorin interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Parameters:
TextColor- the TextColor to set
-
getLineTextPosition
public int getLineTextPosition()
- Returns:
- the lineTextPosition
-
setLineTextPosition
public void setLineTextPosition(int pos)
- Parameters:
pos- the lineTextPosition to set
-
remove
public void remove()
Description copied from interface:GJAnnotationInterfaceRemoves the annotation- Specified by:
removein interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>
-
remove
public void remove(java.lang.String name)
Description copied from interface:GJAnnotationInterfaceRemoves annotation(s) named by the string- Specified by:
removein interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Parameters:
name- the name of the annotation(s) to remove
-
paintAnnotation
public void paintAnnotation(java.awt.Graphics2D g2, java.awt.geom.AffineTransform af)paintAnnotation method. This has public scope to allow it to be called from the parentGraph container's paint methods. When using a standard Project Waterloo parentGraph container where annotations have been added using theaddmethod, this is done automatically.- Specified by:
paintAnnotationin interfaceGJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font>- Parameters:
g2- the graphics object to render toaf- an AffineTransform instance with scale and translate set to position this annotation correctly in the container using the parentGraph's coordinate system.
-
createLine
public static GJAnnotation.LineAnnotation createLine(double x1, double y1, double x2, double y2)
Static method to create a line between {x1,y1} and {x2,y2}.- Parameters:
x1-y1-x2-y2-- Returns:
- the the annotation
-
createArrow
public static GJAnnotation.ArrowAnnotation createArrow(double x1, double y1, double x2, double y2, double szx, double szy)
Static method to create a line between {x1,y1} and {x2,y2}.- Parameters:
x1-y1-x2-y2-szx-szy-- Returns:
- the annotation
-
createArrow
public static GJAnnotation.ArrowAnnotation createArrow(double x1, double y1, double x2, double y2, double x3, double y3, double szx, double szy)
- Parameters:
x1-y1-x2-y2-x3-y3-szx-szy-- Returns:
- the annotation
-
createLine
public static GJAnnotation.LineAnnotation createLine(double x1, double y1, double x2, double y2, double x3, double y3)
Static method to create a line between {x1,y1} and {x2,y2}.- Parameters:
x1-y1-x2-y2-x3-y3-- Returns:
- the LineAnnotation
-
createBox
public static GJAnnotation.ShapeAnnotation createBox(double x, double y, double w, double h)
Static method to create a rectangle where {X,Y} is the top left corner and w and h are the width and height.- Parameters:
x-y-w-h-- Returns:
- a GJAnnotation$ShapeAnnotation
-
createEllipse
public static GJAnnotation.ShapeAnnotation createEllipse(double x, double y, double w, double h)
Static method to create an ellipse where {X,Y} is the top left corner and w and h are the width and height of the bounding rectangle.- Parameters:
x-y-w-h-- Returns:
- a GJAnnotation$ShapeAnnotation
-
createShape
public static GJAnnotation.ShapeAnnotation createShape(java.awt.Shape s)
Creates an annotation using the specified object which should implement the {code Shape} interface.- Parameters:
s- a Shape.- Returns:
- a GJAnnotation$ShapeAnnotation
-
createText
public static GJAnnotation.TextAnnotation createText(double x, double y, java.lang.String s)
-
getTextBackground
public java.awt.Paint getTextBackground()
- Returns:
- the textBackground
-
setTextBackground
public void setTextBackground(java.awt.Paint textBackground)
- Parameters:
textBackground- the textBackground to set
-
-
DMelt 3.0 © DataMelt by jWork.ORG