net.sf.latexdraw.glib.models.impl
Class LShapeFactory

java.lang.Object
  extended by net.sf.latexdraw.glib.models.impl.LShapeFactory
All Implemented Interfaces:
IShapeFactory

public class LShapeFactory
extends java.lang.Object
implements IShapeFactory

This factory creates shapes.

This file is part of LaTeXDraw.
Copyright (c) 2005-2012 Arnaud BLOUIN

LaTeXDraw is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
LaTeXDraw is distributed without any warranty; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

04/02/2010

Since:
3.0
Version:
3.0
Author:
Arnaud BLOUIN

Constructor Summary
LShapeFactory()
          Creates the factory.
 
Method Summary
 IArc createArc(boolean isUniqueID)
          Creates a circled arc with a 1 radius.
 IArc createArc(IPoint tl, IPoint br, boolean uniqueID)
          Creates an arc.
 IArrow createArrow(IArrow arrow, IShape owner)
          Creates an arrow from an other arrow.
 IArrow createArrow(IShape owner)
          Creates an arrow.
 IAxes createAxes(boolean isUniqueID, IPoint pt)
          Creates axes with default values.
 IBezierCurve createBezierCurve(boolean isUniqueID)
          Creates a model with no point.
 IBezierCurve createBezierCurve(IPoint point, IPoint point2, boolean uniqueID)
          Creates a bezier curve with two points.
 ICircle createCircle(boolean isUniqueID)
           
 ICircle createCircle(IPoint pt, double radius, boolean isUniqueID)
          Creates a circle.
 ICircleArc createCircleArc(boolean isUniqueID)
          Creates a circled arc with a 1 radius.
 ICircleArc createCircleArc(IPoint tl, IPoint br, boolean uniqueID)
          Creates a circled arc.
 IDot createDot(IPoint pt, boolean isUniqueID)
           
 IDrawing createDrawing()
           
 IEllipse createEllipse(boolean isUniqueID)
           
 IEllipse createEllipse(IPoint tl, IPoint br, boolean isUniqueID)
          Creates an ellipse.
 IFreehand createFreeHand(IPoint pt, boolean uniqueID)
          Creates and initialises a freehand model.
 IGrid createGrid(boolean isUniqueID, IPoint pt)
          Creates a grid with a predefined point.
 IGroup createGroup(boolean uniqueID)
           
 ILine createLine(double x1, double y1, double x2, double y2)
          Constructs a line from the specified coordinates.
 ILine createLine(double b, IPoint p1)
          Creates a line by creating a second point with:
 ILine createLine(IPoint p1, IPoint p2)
          Constructs a line from the specified Point2D objects.
 IPicture createPicture(boolean isUniqueID, IPoint pt)
          Creates a picture and the corresponding EPS picture.
 IPoint createPoint()
           
 IPoint createPoint(double x, double y)
          Creates a Point2D with the specified coordinates.
 IPoint createPoint(IPoint pt)
          Creates a Point2D with the specified coordinates.
 IPoint createPoint(java.awt.Point pt)
          Creates a point from the java Point.
 IPolygon createPolygon(boolean uniqueID)
           
 IPolygon createPolygon(IPoint point, IPoint point2, boolean uniqueID)
          Creates a polygon with two points.
 IPolyline createPolyline(boolean uniqueID)
           
 IPolyline createPolyline(IPoint point, IPoint point2, boolean uniqueID)
          Creates a model with two points.
 IRectangle createRectangle(boolean uniqueID)
           
 IRectangle createRectangle(IPoint pos, double width, double height, boolean uniqueID)
          Creates a rectangle.
 IRectangle createRectangle(IPoint tl, IPoint br, boolean uniqueID)
          Creates a rectangle.
 IRhombus createRhombus(boolean isUniqueID)
           
 IRhombus createRhombus(IPoint centre, double width, double height, boolean uniqueID)
          Creates a rhombus.
 ISquare createSquare(boolean isUniqueID)
          Creates a square at position (0,0) which width equals 10.
 ISquare createSquare(IPoint pos, double width, boolean isUniqueID)
          Creates a square.
 IText createText(boolean isUniqueID)
          Create a text at position (0,0) which text is "text".
 IText createText(boolean isUniqueID, IPoint pt, java.lang.String text)
          Creates a text.
 ITriangle createTriangle(boolean isUniqueID)
           
 ITriangle createTriangle(IPoint pos, double width, double height, boolean uniqueID)
          Creates a triangle.
 IShape duplicate(IShape shape)
          Duplicates the given shape.
<T extends IShape>
T
newShape(java.lang.Class<T> shapeClass)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LShapeFactory

public LShapeFactory()
Creates the factory.

Since:
3.0
Method Detail

newShape

public <T extends IShape> T newShape(java.lang.Class<T> shapeClass)
Specified by:
newShape in interface IShapeFactory
Parameters:
shapeClass - The class of the shape to instantiated.
Returns:
A new instance of the class given as argument or null.

createDrawing

public IDrawing createDrawing()
Specified by:
createDrawing in interface IShapeFactory
Returns:
The created drawing.

createArrow

public IArrow createArrow(IArrow arrow,
                          IShape owner)
Description copied from interface: IShapeFactory
Creates an arrow from an other arrow.

Specified by:
createArrow in interface IShapeFactory
Parameters:
arrow - The arrow to copy.
owner - The shape that contains the arrow.
Returns:
The created arrow.

createArrow

public IArrow createArrow(IShape owner)
Description copied from interface: IShapeFactory
Creates an arrow.

Specified by:
createArrow in interface IShapeFactory
Parameters:
owner - The shape that contains the arrow.
Returns:
The created arrow.

createAxes

public IAxes createAxes(boolean isUniqueID,
                        IPoint pt)
Description copied from interface: IShapeFactory
Creates axes with default values.

Specified by:
createAxes in interface IShapeFactory
Parameters:
isUniqueID - True: the model will have a unique ID.
pt - The bottom left position of the axes.
Returns:
The created axes.

createDot

public IDot createDot(IPoint pt,
                      boolean isUniqueID)
Specified by:
createDot in interface IShapeFactory
Parameters:
pt - The centre of the dot.
isUniqueID - True: the shape will have a unique ID.
Returns:
The created dot.

createBezierCurve

public IBezierCurve createBezierCurve(boolean isUniqueID)
Description copied from interface: IShapeFactory
Creates a model with no point.

Specified by:
createBezierCurve in interface IShapeFactory
Parameters:
isUniqueID - True: the model will have a unique ID.
Returns:
The created bezier curve.

createBezierCurve

public IBezierCurve createBezierCurve(IPoint point,
                                      IPoint point2,
                                      boolean uniqueID)
Description copied from interface: IShapeFactory
Creates a bezier curve with two points.

Specified by:
createBezierCurve in interface IShapeFactory
Parameters:
point - The first point of the curve.
point2 - The second point of the curve.
uniqueID - uniqueID True: the model will have a unique ID.
Returns:
The created bezier curve.

createEllipse

public IEllipse createEllipse(IPoint tl,
                              IPoint br,
                              boolean isUniqueID)
Description copied from interface: IShapeFactory
Creates an ellipse.

Specified by:
createEllipse in interface IShapeFactory
Parameters:
tl - The top-left point of the ellipse.
br - The bottom-right point of the ellipse.
isUniqueID - True: the ellipse will have a unique ID.
Returns:
The created ellipse.

createEllipse

public IEllipse createEllipse(boolean isUniqueID)
Specified by:
createEllipse in interface IShapeFactory
Parameters:
isUniqueID - True: the ellipse will have a unique ID.
Returns:
The created ellipse.

createTriangle

public ITriangle createTriangle(IPoint pos,
                                double width,
                                double height,
                                boolean uniqueID)
Description copied from interface: IShapeFactory
Creates a triangle.

Specified by:
createTriangle in interface IShapeFactory
Parameters:
pos - The north-west point of the triangle.
width - The width of the triangle.
height - The height of the triangle.
uniqueID - True: the triangle will have a unique ID.
Returns:
The created triangle.

createTriangle

public ITriangle createTriangle(boolean isUniqueID)
Specified by:
createTriangle in interface IShapeFactory
Parameters:
isUniqueID - True: the shape will have a unique ID.
Returns:
The created triangle.

createRhombus

public IRhombus createRhombus(IPoint centre,
                              double width,
                              double height,
                              boolean uniqueID)
Description copied from interface: IShapeFactory
Creates a rhombus.

Specified by:
createRhombus in interface IShapeFactory
Parameters:
centre - The centre of the rhombus.
width - The width of the rhombus.
height - The height of the rhombus.
uniqueID - True: the rhombus will have a unique ID.
Returns:
The created rhombus.

createRhombus

public IRhombus createRhombus(boolean isUniqueID)
Specified by:
createRhombus in interface IShapeFactory
Parameters:
isUniqueID - True: the shape will have a unique ID.
Returns:
The created rhombus.

createPicture

public IPicture createPicture(boolean isUniqueID,
                              IPoint pt)
Description copied from interface: IShapeFactory
Creates a picture and the corresponding EPS picture.

Specified by:
createPicture in interface IShapeFactory
Parameters:
isUniqueID - True: the shape will have a unique ID.
pt - The position of the top-left point of the picture.
Returns:
The created picture.

createGrid

public IGrid createGrid(boolean isUniqueID,
                        IPoint pt)
Description copied from interface: IShapeFactory
Creates a grid with a predefined point.

Specified by:
createGrid in interface IShapeFactory
Parameters:
isUniqueID - True: the shape will have a unique ID.
pt - The position.
Returns:
The created grid.

createFreeHand

public IFreehand createFreeHand(IPoint pt,
                                boolean uniqueID)
Description copied from interface: IShapeFactory
Creates and initialises a freehand model.

Specified by:
createFreeHand in interface IShapeFactory
Parameters:
pt - The first point.
uniqueID - True: the model will have a unique ID.
Returns:
The created freehand shape.

createCircle

public ICircle createCircle(IPoint pt,
                            double radius,
                            boolean isUniqueID)
Description copied from interface: IShapeFactory
Creates a circle.

Specified by:
createCircle in interface IShapeFactory
Parameters:
pt - The centre of the circle.
radius - The radius.
isUniqueID - True: the model will have a unique ID.
Returns:
The created circle.

createCircle

public ICircle createCircle(boolean isUniqueID)
Specified by:
createCircle in interface IShapeFactory
Parameters:
isUniqueID - True: the circle will have a unique ID.
Returns:
The created circle.

createGroup

public IGroup createGroup(boolean uniqueID)
Specified by:
createGroup in interface IShapeFactory
Parameters:
uniqueID - True: the model will have a unique ID.
Returns:
The created group of shapes.

createLine

public ILine createLine(double x1,
                        double y1,
                        double x2,
                        double y2)
Description copied from interface: IShapeFactory
Constructs a line from the specified coordinates.

Specified by:
createLine in interface IShapeFactory
Parameters:
x1 - the X coordinate of the start point.
y1 - the Y coordinate of the start point.
x2 - the X coordinate of the end point.
y2 - the Y coordinate of the end point.
Returns:
The created line.

createLine

public ILine createLine(double b,
                        IPoint p1)
Description copied from interface: IShapeFactory
Creates a line by creating a second point with:

Specified by:
createLine in interface IShapeFactory
Parameters:
b - y = ax+ b
p1 - The first point.
Returns:
The created line.

createLine

public ILine createLine(IPoint p1,
                        IPoint p2)
Description copied from interface: IShapeFactory
Constructs a line from the specified Point2D objects.

Specified by:
createLine in interface IShapeFactory
Parameters:
p1 - the start Point2D of this line segment.
p2 - the end Point2D of this line segment.
Returns:
The created line.

createPoint

public IPoint createPoint()
Specified by:
createPoint in interface IShapeFactory
Returns:
The created point with coordinates (0, 0).

createPoint

public IPoint createPoint(double x,
                          double y)
Description copied from interface: IShapeFactory
Creates a Point2D with the specified coordinates.

Specified by:
createPoint in interface IShapeFactory
Parameters:
x - The X-coordinate to set.
y - The Y-coordinate to set.
Returns:
The created point.

createPoint

public IPoint createPoint(IPoint pt)
Description copied from interface: IShapeFactory
Creates a Point2D with the specified coordinates.

Specified by:
createPoint in interface IShapeFactory
Parameters:
pt - The IPoint, if null the default value (0,0) will be used.
Returns:
The created point.

createPolyline

public IPolyline createPolyline(boolean uniqueID)
Specified by:
createPolyline in interface IShapeFactory
Parameters:
uniqueID - True: the shape will have a unique ID.
Returns:
The created polyline

createPolyline

public IPolyline createPolyline(IPoint point,
                                IPoint point2,
                                boolean uniqueID)
Description copied from interface: IShapeFactory
Creates a model with two points.

Specified by:
createPolyline in interface IShapeFactory
Parameters:
point - The first point of the shape.
point2 - The second point of the shape.
uniqueID - True: the shape will have a unique ID.
Returns:
The created polyline.

createPolygon

public IPolygon createPolygon(boolean uniqueID)
Specified by:
createPolygon in interface IShapeFactory
Parameters:
uniqueID - True: the shape will have a unique ID.
Returns:
The created polygon

createPolygon

public IPolygon createPolygon(IPoint point,
                              IPoint point2,
                              boolean uniqueID)
Description copied from interface: IShapeFactory
Creates a polygon with two points.

Specified by:
createPolygon in interface IShapeFactory
Parameters:
point - The first point of the shape.
point2 - The second point of the shape.
uniqueID - True: the shape will have a unique ID.
Returns:
The created polygon.

createRectangle

public IRectangle createRectangle(boolean uniqueID)
Specified by:
createRectangle in interface IShapeFactory
Parameters:
uniqueID - True: the shape will have a unique ID.
Returns:
The created rectangle with position (0,0) and width=10 and height=10.

createRectangle

public IRectangle createRectangle(IPoint pos,
                                  double width,
                                  double height,
                                  boolean uniqueID)
Description copied from interface: IShapeFactory
Creates a rectangle.

Specified by:
createRectangle in interface IShapeFactory
Parameters:
pos - The north-west point of the rectangle.
width - The width of the rectangle.
height - The height of the rectangle.
uniqueID - True: the rectangle will have a unique ID.
Returns:
The created rectangle.

createRectangle

public IRectangle createRectangle(IPoint tl,
                                  IPoint br,
                                  boolean uniqueID)
Description copied from interface: IShapeFactory
Creates a rectangle.

Specified by:
createRectangle in interface IShapeFactory
Parameters:
tl - The top left point of the rectangle.
br - The bottom right point of the rectangle.
uniqueID - True: the rectangle will have a unique ID.
Returns:
The created rectangle.

createText

public IText createText(boolean isUniqueID)
Description copied from interface: IShapeFactory
Create a text at position (0,0) which text is "text".

Specified by:
createText in interface IShapeFactory
Parameters:
isUniqueID - True: the shape will have a unique ID.
Returns:
The created text.

createText

public IText createText(boolean isUniqueID,
                        IPoint pt,
                        java.lang.String text)
Description copied from interface: IShapeFactory
Creates a text.

Specified by:
createText in interface IShapeFactory
Parameters:
isUniqueID - True: the model will have a unique ID.
pt - The position of the text.
text - The text.
Returns:
The created text.

createSquare

public ISquare createSquare(boolean isUniqueID)
Description copied from interface: IShapeFactory
Creates a square at position (0,0) which width equals 10.

Specified by:
createSquare in interface IShapeFactory
Parameters:
isUniqueID - True: the shape will have a unique ID.
Returns:
The created square.

createSquare

public ISquare createSquare(IPoint pos,
                            double width,
                            boolean isUniqueID)
Description copied from interface: IShapeFactory
Creates a square.

Specified by:
createSquare in interface IShapeFactory
Parameters:
pos - The north-west point of the square.
width - The width of the square.
isUniqueID - True: the shape will have a unique ID.
Returns:
The created square.

createCircleArc

public ICircleArc createCircleArc(IPoint tl,
                                  IPoint br,
                                  boolean uniqueID)
Description copied from interface: IShapeFactory
Creates a circled arc.

Specified by:
createCircleArc in interface IShapeFactory
Parameters:
tl - The top left point of the circled arc.
br - The bottom right point of the circled arc.
uniqueID - True: the circled arc will have a unique ID.
Returns:
The created circled arc.

createCircleArc

public ICircleArc createCircleArc(boolean isUniqueID)
Description copied from interface: IShapeFactory
Creates a circled arc with a 1 radius.

Specified by:
createCircleArc in interface IShapeFactory
Parameters:
isUniqueID - True: the model will have a unique ID.
Returns:
The created circled arc.

createArc

public IArc createArc(IPoint tl,
                      IPoint br,
                      boolean uniqueID)
Description copied from interface: IShapeFactory
Creates an arc.

Specified by:
createArc in interface IShapeFactory
Parameters:
tl - The top left point of the arc.
br - The bottom right point of the arc.
uniqueID - True: the arc will have a unique ID.
Returns:
The created arc.

createArc

public IArc createArc(boolean isUniqueID)
Description copied from interface: IShapeFactory
Creates a circled arc with a 1 radius.

Specified by:
createArc in interface IShapeFactory
Parameters:
isUniqueID - True: the model will have a unique ID.
Returns:
The created arc.

duplicate

public IShape duplicate(IShape shape)
Description copied from interface: IShapeFactory
Duplicates the given shape.

Specified by:
duplicate in interface IShapeFactory
Parameters:
shape - The shape to duplicate
Returns:
The duplicated shape or null.

createPoint

public IPoint createPoint(java.awt.Point pt)
Description copied from interface: IShapeFactory
Creates a point from the java Point.

Specified by:
createPoint in interface IShapeFactory
Parameters:
pt - The java point.
Returns:
The created point or null.