net.sf.latexdraw.glib.views.Java2D.impl
Class LShapeView<S extends IShape>

java.lang.Object
  extended by net.sf.latexdraw.glib.views.AbstractView<S>
      extended by net.sf.latexdraw.glib.views.Java2D.impl.LShapeView<S>
All Implemented Interfaces:
IAbstractView, IViewShape, Pickable
Direct Known Subclasses:
LDotView, LFreeHandView, LGroupView, LModifiablePointsShapeView, LPictureView, LRectangularView, LStandardGridView, LTextView

abstract class LShapeView<S extends IShape>
extends AbstractView<S>
implements IViewShape

Defines a view of the LShape model.

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.

02/16/2008

Since:
3.0
Author:
Arnaud BLOUIN

Field Summary
protected  java.util.List<IViewArrow> arrows
          The view of the arrows of the shape.
protected  java.awt.geom.Rectangle2D border
          The border of the shape.
protected  java.awt.geom.Path2D path
          The Java2D path used to draw the shape.
 
Fields inherited from class net.sf.latexdraw.glib.views.AbstractView
shape
 
Constructor Summary
protected LShapeView(S model)
          Creates a view of the given model and initialises the Java2D view.
 
Method Summary
protected  IPoint beginRotation(java.awt.Graphics2D g)
          Begins the rotation by modifying the Graphics2D using the rotation angle.
 boolean contains(double x, double y)
          Tests if the given point is into the pickable object.
 boolean contains(IPoint pt)
          Allows to know if the point pt is in (or not) the shape.
protected  void endRotation(java.awt.Graphics2D g, IPoint translation)
          Ends the rotation of the view by modifying the Graphics2D using the rotation angle of the model of the view, and the given translation vector.
 void flush()
          Removes and flushes the used resources and temporary documents.
 java.awt.geom.Rectangle2D getBorder()
           
 java.awt.geom.Path2D getPath()
           
 Picker getPicker()
           
 java.awt.Shape getRotatedShape2D()
          This function creates the corresponding rotated Java shape using the shape model.
protected static java.awt.Shape getRotatedShape2D(double angle, java.awt.Shape shape, IPoint tlPoint, IPoint brPoint)
           
 java.awt.BasicStroke getStroke()
          Creates and returns a stroke corresponding to the current parameters of the shape model.
 double getStrokeThickness()
           
 boolean intersects(java.awt.geom.Rectangle2D rec)
           
 void paint(java.awt.Graphics2D g)
          Draws the shape within a Java2D graphics.
protected  void paintArrows(java.awt.Graphics2D g, boolean asShadow)
          Paints the arrows of the shape.
 void paintBorders(java.awt.Graphics2D g)
          Draws the borders of the shape within a Java2D graphics.
private  void paintBordersDouble(java.awt.Graphics2D g)
          Draws the double borders of the shape.
private  void paintBordersSimple(java.awt.Graphics2D g)
          Draws the simple border (not with double borders).
 void paintFilling(java.awt.Graphics2D g)
          Fills the shape within a Java2D graphics.
private  void paintHatchings2(java.awt.Graphics2D g, double angle, java.awt.geom.Rectangle2D clip)
          Paints the hatchings.
 void paintShadow(java.awt.Graphics2D g)
          Draws the shadow of the shape within a Java2D graphics.
 void paintShowPointsDots(java.awt.Graphics2D g)
          Paints the dots of the option 'show points'.
 void paintShowPointsLines(java.awt.Graphics2D g)
          Paints the lines of the option 'show points'.
 void update()
          Updates the view.
 void updateBorder()
          Update the border of the shape view.
protected abstract  void updateDblePathInside()
          Updates the borders of the double boundary when position is inside.
protected abstract  void updateDblePathMiddle()
          Updates the borders of the double boundary when position is middle.
protected abstract  void updateDblePathOutside()
          Updates the borders of the double boundary when position is outside.
protected abstract  void updateGeneralPathInside()
          Updates the borders of the shape as inside borders.
protected abstract  void updateGeneralPathMiddle()
          Updates the borders of the shape as middle borders.
protected abstract  void updateGeneralPathOutside()
          Updates the borders of the shape as outside borders.
 void updatePath()
          Updates the path of the shape.
protected  void updatePathArrows()
          Updates the path of the view of the arrows.
 
Methods inherited from class net.sf.latexdraw.glib.views.AbstractView
getShape
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.latexdraw.glib.views.IAbstractView
getShape
 

Field Detail

path

protected java.awt.geom.Path2D path
The Java2D path used to draw the shape.


arrows

protected java.util.List<IViewArrow> arrows
The view of the arrows of the shape.


border

protected java.awt.geom.Rectangle2D border
The border of the shape. This attribute must be used to compute 'intersects', 'contains' operations, etc. operations.

Constructor Detail

LShapeView

protected LShapeView(S model)
Creates a view of the given model and initialises the Java2D view.

Parameters:
model - The shape model.
Throws:
java.lang.IllegalArgumentException - If model is null.
Method Detail

getRotatedShape2D

protected static java.awt.Shape getRotatedShape2D(double angle,
                                                  java.awt.Shape shape,
                                                  IPoint tlPoint,
                                                  IPoint brPoint)

getRotatedShape2D

public java.awt.Shape getRotatedShape2D()
Description copied from interface: IViewShape
This function creates the corresponding rotated Java shape using the shape model.

Specified by:
getRotatedShape2D in interface IViewShape
Returns:
The rotated shape.

getPath

public java.awt.geom.Path2D getPath()
Specified by:
getPath in interface IViewShape
Returns:
The Java2D path of the view.

updateBorder

public void updateBorder()
Description copied from interface: IViewShape
Update the border of the shape view.

Specified by:
updateBorder in interface IViewShape

updateGeneralPathInside

protected abstract void updateGeneralPathInside()
Updates the borders of the shape as inside borders.

Since:
3.0

updateGeneralPathMiddle

protected abstract void updateGeneralPathMiddle()
Updates the borders of the shape as middle borders.

Since:
3.0

updateGeneralPathOutside

protected abstract void updateGeneralPathOutside()
Updates the borders of the shape as outside borders.

Since:
3.0

updatePath

public void updatePath()
Description copied from interface: IViewShape
Updates the path of the shape.

Specified by:
updatePath in interface IViewShape

updatePathArrows

protected void updatePathArrows()
Updates the path of the view of the arrows.


updateDblePathOutside

protected abstract void updateDblePathOutside()
Updates the borders of the double boundary when position is outside.

Since:
3.0

updateDblePathInside

protected abstract void updateDblePathInside()
Updates the borders of the double boundary when position is inside.

Since:
3.0

updateDblePathMiddle

protected abstract void updateDblePathMiddle()
Updates the borders of the double boundary when position is middle.

Since:
3.0

update

public void update()
Description copied from interface: IAbstractView
Updates the view.

Specified by:
update in interface IAbstractView

paintFilling

public void paintFilling(java.awt.Graphics2D g)
Description copied from interface: IViewShape
Fills the shape within a Java2D graphics.

Specified by:
paintFilling in interface IViewShape
Parameters:
g - The graphics where the shape must be drawn.

contains

public boolean contains(double x,
                        double y)
Description copied from interface: Pickable
Tests if the given point is into the pickable object.

Specified by:
contains in interface IViewShape
Specified by:
contains in interface Pickable
Parameters:
x - The x-coordinate of the point to test.
y - The y-coordinate of the point to test.
Returns:
True if the given point is into the pickable object.

contains

public boolean contains(IPoint pt)
Description copied from interface: IViewShape
Allows to know if the point pt is in (or not) the shape.

Specified by:
contains in interface IViewShape
Parameters:
pt - The point.
Returns:
True if the point is in the shape.

intersects

public boolean intersects(java.awt.geom.Rectangle2D rec)
Specified by:
intersects in interface IViewShape
Parameters:
rec - The rectangle used to check the intersection.
Returns:
True if the given rectangle intersects the view.

paint

public void paint(java.awt.Graphics2D g)
Description copied from interface: IViewShape
Draws the shape within a Java2D graphics.

Specified by:
paint in interface IViewShape
Parameters:
g - The graphics where the shape must be drawn.

paintArrows

protected void paintArrows(java.awt.Graphics2D g,
                           boolean asShadow)
Paints the arrows of the shape.

Since:
3.0

paintBorders

public void paintBorders(java.awt.Graphics2D g)
Description copied from interface: IViewShape
Draws the borders of the shape within a Java2D graphics.

Specified by:
paintBorders in interface IViewShape
Parameters:
g - The graphics where the shape must be drawn.

paintBordersDouble

private void paintBordersDouble(java.awt.Graphics2D g)
Draws the double borders of the shape.

Parameters:
g - The graphics to print into.
Since:
3.0

paintBordersSimple

private void paintBordersSimple(java.awt.Graphics2D g)
Draws the simple border (not with double borders).

Parameters:
g - The graphics to print into.
Since:
3.0

paintShadow

public void paintShadow(java.awt.Graphics2D g)
Description copied from interface: IViewShape
Draws the shadow of the shape within a Java2D graphics.

Specified by:
paintShadow in interface IViewShape
Parameters:
g - The graphics where the shape must be drawn.

paintShowPointsLines

public void paintShowPointsLines(java.awt.Graphics2D g)
Description copied from interface: IViewShape
Paints the lines of the option 'show points'.

Specified by:
paintShowPointsLines in interface IViewShape
Parameters:
g - The graphics.

paintShowPointsDots

public void paintShowPointsDots(java.awt.Graphics2D g)
Description copied from interface: IViewShape
Paints the dots of the option 'show points'.

Specified by:
paintShowPointsDots in interface IViewShape
Parameters:
g - The graphics.

paintHatchings2

private void paintHatchings2(java.awt.Graphics2D g,
                             double angle,
                             java.awt.geom.Rectangle2D clip)
Paints the hatchings.

Parameters:
g - The graphics to paint.
angle - The angle of the hatchings (in radian).
clip - The clip box.

getStroke

public java.awt.BasicStroke getStroke()
Description copied from interface: IViewShape
Creates and returns a stroke corresponding to the current parameters of the shape model.

Specified by:
getStroke in interface IViewShape
Returns:
The stroke based on the thickness, the double borders and so on, of the shape. Returns null if the line style is NONE.

getStrokeThickness

public double getStrokeThickness()
Returns:
The thickness of the stroke; The difference with shape.getThickness is that the double borders and their size are took in account.
Since:
3.0

beginRotation

protected IPoint beginRotation(java.awt.Graphics2D g)
Begins the rotation by modifying the Graphics2D using the rotation angle.

Parameters:
g - The graphics to modify to draw rotated views.
Returns:
The transition vector used to place the rotated view to its original location. The rotation was made as the origin point, so as translation is needed to place the view at the centre of the view. This point will be used to end the rotation. Returns null if g is null or if the rotation angle is equal to 0.
Since:
3.0

endRotation

protected void endRotation(java.awt.Graphics2D g,
                           IPoint translation)
Ends the rotation of the view by modifying the Graphics2D using the rotation angle of the model of the view, and the given translation vector.

Parameters:
g - The graphics to un-rotate.
translation - This translation vector is given by function beginRotation. It is used to translate the graphics at the initial position.
Since:
3.0

getBorder

public java.awt.geom.Rectangle2D getBorder()
Specified by:
getBorder in interface IViewShape
Returns:
The border of the view.

getPicker

public Picker getPicker()
Specified by:
getPicker in interface Pickable
Returns:
The picker object that contains the pickable object.

flush

public void flush()
Description copied from interface: IViewShape
Removes and flushes the used resources and temporary documents.

Specified by:
flush in interface IViewShape