http://www.jpicedt.org

jpicedt.graphic.model
Class PicText

java.lang.Object
  extended by jpicedt.graphic.model.AbstractElement
      extended by jpicedt.graphic.model.TextEditable
          extended by jpicedt.graphic.model.PicText
All Implemented Interfaces:
Element, NodeableElement, ActionFactory, CustomizerFactory

public class PicText
extends TextEditable
implements CustomizerFactory, NodeableElement

Textual elements, possibly surrounded by a box (currently, only rectangular, oval and circular shapes are supported). The box size is computed from the text size (ie aka LaTeX's \\framebox command with no width/height argument).

Since:
PicEdt 1.0
Version:
$Id: PicText.java,v 1.38 2013/03/27 07:01:13 vincentb1 Exp $
Author:
Sylvain Reynal

Nested Class Summary
static class PicText.FrameStyle
          An enum for allowed values for frame-box styles
static class PicText.HorAlign
          An enum for allowed values for horizontal text alignment
static class PicText.TextIcon
          An enum for the text display options TEXT_MODEIn this mode the value of text is used for display.
static class PicText.TextMode
          An enum for the different text-modes
 class PicText.TextNodeConnectionManager
           
static class PicText.VertAlign
          An enum for allowed values for vertical text alignment
 
Field Summary
protected  boolean areaSet
           
protected  double depth
           
protected  Shape frame
           
protected  double frameSep
           
protected  double height
           
protected  PicText.TextNodeConnectionManager nodeConnectionManager
           
protected  double nodeSep
           
protected  double width
          dimensions (in latex sense) of the latex box (this does not include frame)
 
Fields inherited from class jpicedt.graphic.model.TextEditable
FIRST_PT, LAST_PT, P_ANCHOR, ptAnchor, textString
 
Fields inherited from class jpicedt.graphic.model.AbstractElement
attributeSet, name, parent, view
 
Constructor Summary
PicText()
          Creates a PicText object with a default attribute set, and the following default values : empty string, no frame, bottom-left alignment.
PicText(PicAttributeSet set)
          Creates a PicText object with the following default values : empty string, frame and alignment according to the attribute set and anchor point at (0,0)
PicText(PicPoint ptA, PicAttributeSet set)
          Creates a PicText object with the following default values :
empty string, frame and alignment according to the attribute set
PicText(PicPoint ptA, String textString, PicAttributeSet set)
          Create a new PicText object with the whole bunch of parameters !
PicText(PicText text)
          cloning constructor
 
Method Summary
 PicText clone()
          Override Object.clone() method
 AbstractCustomizer createCustomizer()
          Return a Customizer for geometry editing
protected  void fireChangedUpdate(DrawingEvent.EventType eventType)
          Overriden in order to support forwarding to node connections.
 boolean getAreaMode()
           
 boolean getAreaSet()
           
 double getBaseLineY()
          Return y-coordinate of baseline
 double getBottomY()
          Return y-coordinate of bottom boundary of text only
 Rectangle2D getBoundingBox(Rectangle2D r)
          Returns the bounding box (i.e. the surrounding rectangle) in double precision Used e.g. to determine the arguments of a \\begin{picture} command.
 double getCenterX()
          Return x-coordinate of center of text only
 double getCenterY()
          Return y-coordinate of center of text only
 String getDefaultName()
          Return a string that represents this object's name
 double getDepth()
          Return the depth of text only
 double getFrameBaseLineY()
          Return y-coordinate of baseline
 double getFrameBottomY()
          Return y-coordinate of bottom boundary
 double getFrameCenterX()
          Return x-coordinate of center
 double getFrameCenterY()
          Return y-coordinate of center
 double getFrameDepth()
          Return the depth of the text including frame
 double getFrameHeight()
          Return the height of the text including frame
 double getFrameLeftX()
          Return x-coordinate of left boundary, including frame
 double getFrameRightX()
          Return x-coordinate of right boundary
 double getFrameTopY()
          Return y-coordinate of top boundary
 PicText.FrameStyle getFrameType()
          Set the frame type
 double getFrameWidth()
          Return the width of the text including frame
 double getHeight()
          Return the height of text only
 PicText.HorAlign getHorAlign()
          Return horizontal alignment (see constant fields above)
 double getLeftX()
          Return x-coordinate of left boundary of text only
 NodeConnectionManager getNodeConnectionManager()
           
 double getRightX()
          Return x-coordinate of right boundary of text only
 Shape getShapeOfFrame()
          Returns the frame that surrounds the text, ignoring rotation (the view will rotate it)
 boolean getTextMode()
          Return the textmode only
 double getTopY()
          Return y-coordinate of top boundary of text only
 PicText.VertAlign getVertAlign()
          Return vertical alignement (see static constant above)
 double getWidth()
          Return the width of text only
 boolean isFramed()
          Return TRUE if the box has to be drawn
 void mirror(PicPoint ptOrg, PicVector normalVector)
          Effectue une réflexion sur this relativement à l'axe défini par ptOrg et normalVector.
 void rotate(PicPoint ptOrg, double angle)
          Rotate this Element by the given angle along the given point
 void scale(double ptOrgX, double ptOrgY, double sx, double sy, UserConfirmationCache ucc)
          Scale this object by (sx,sy) using (ptOrgX,ptOrgY) as the origin.
 void setAreaMode(boolean b)
           
 void setCtrlPt(int index, PicPoint pt, EditPointConstraint constraint)
          Set the user-controlled point indexed by "index" to the given value, using the specified geometrical constraint.
 void setDimensions(double w, double h, double d)
          set the width, height, and depth (of the text box, without frame).
 void setFrameType(PicText.FrameStyle frameType)
          Set the type of frame to be put around the text.
 void setHorAlign(PicText.HorAlign horAlign)
          Set the horizontal alignment (see constant fields above)
 void setTextIcon(PicText.TextIcon textIcon)
           
 void setTextMode(boolean mode)
          Set the textmode and updates the text
 void setTextMode(PicText.TextMode textMode)
           
 void setVertAlign(PicText.VertAlign vertAlign)
          set the vertical alignement (see constant fields above)
 void shear(PicPoint ptOrg, double shx, double shy, UserConfirmationCache ucc)
          Shear this Element by the given params wrt to the given origin
 String toString()
          Returns a String representation of the attribute set for this AbstractElement
 void translate(double dx, double dy)
          Translate this Element by (dx,dy) ; this implementation translates the specification-points, then fires a changed-update event.
 void updateFrame()
          First computes frame dimensions (frameWidth, etc).
 
Methods inherited from class jpicedt.graphic.model.TextEditable
getCtrlPt, getCtrlPtSubset, getFirstPointIndex, getLastPointIndex, getText, getText, setAttribute, setText
 
Methods inherited from class jpicedt.graphic.model.AbstractElement
anchorPointsIterator, createActions, createShape, getAttribute, getAttributeSet, getDrawing, getName, getParent, getView, pullOutOfGroup, removeView, replaceBy, scale, scale, scale, setAttributeSet, setCtrlPt, setName, setParent, setViewFromFactory, shear, syncArrowGeometry
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jpicedt.graphic.model.Element
anchorPointsIterator, createShape, getAttribute, getAttributeSet, getCtrlPt, getCtrlPtSubset, getDrawing, getFirstPointIndex, getLastPointIndex, getName, getParent, getView, removeView, replaceBy, scale, scale, scale, setAttribute, setAttributeSet, setCtrlPt, setParent, setViewFromFactory, shear, syncArrowGeometry
 

Field Detail

width

protected double width
dimensions (in latex sense) of the latex box (this does not include frame)


height

protected double height

depth

protected double depth

areaSet

protected boolean areaSet

frame

protected Shape frame

frameSep

protected double frameSep

nodeSep

protected double nodeSep

nodeConnectionManager

protected PicText.TextNodeConnectionManager nodeConnectionManager
Constructor Detail

PicText

public PicText(PicPoint ptA,
               String textString,
               PicAttributeSet set)
Create a new PicText object with the whole bunch of parameters !

Parameters:
ptA - Anchor point (see setHorAlign() and setVertAlign() for details)
textString - the text content

PicText

public PicText(PicPoint ptA,
               PicAttributeSet set)
Creates a PicText object with the following default values :


PicText

public PicText(PicAttributeSet set)
Creates a PicText object with the following default values : and anchor point at (0,0)


PicText

public PicText()
Creates a PicText object with a default attribute set, and the following default values : and anchor point at (0,0)


PicText

public PicText(PicText text)
cloning constructor

Method Detail

clone

public PicText clone()
Override Object.clone() method

Specified by:
clone in interface Element
Specified by:
clone in class AbstractElement

getDefaultName

public String getDefaultName()
Return a string that represents this object's name

Specified by:
getDefaultName in class AbstractElement

getBoundingBox

public Rectangle2D getBoundingBox(Rectangle2D r)
Returns the bounding box (i.e. the surrounding rectangle) in double precision Used e.g. to determine the arguments of a \\begin{picture} command.

This implementation compute the bb from the smallest rectangle that encompasses all specification-points.

Specified by:
getBoundingBox in interface Element
Returns:
the bounding box (i.e. the surrounding rectangle) in double precision Used e.g. to determine the arguments of the \\begin{picture} command. If r is null, allocate a new rectangle and returns it. Otherwise the source rectangle is modified and returned for convenience. [todo:reynal] this really need to be improved : this method would probably better be moved to the attached view, since the latter knows exactly what the TRUE bounding box is.
Since:
PicEdt 1.0

setCtrlPt

public void setCtrlPt(int index,
                      PicPoint pt,
                      EditPointConstraint constraint)
Description copied from interface: Element
Set the user-controlled point indexed by "index" to the given value, using the specified geometrical constraint. Constraints depend on the particular concrete implementation, and may involve restricting movement along a particular direction, moving several points at once to preserve parallelism,…

Specified by:
setCtrlPt in interface Element
constraint - a geometry constraint, or null if no particular constraint is being imposed (aka default).

fireChangedUpdate

protected void fireChangedUpdate(DrawingEvent.EventType eventType)
Overriden in order to support forwarding to node connections.

Overrides:
fireChangedUpdate in class AbstractElement
Parameters:
eventType - the event type
Since:
jpicedt 1.4pre5

translate

public void translate(double dx,
                      double dy)
Translate this Element by (dx,dy) ; this implementation translates the specification-points, then fires a changed-update event.

Specified by:
translate in interface Element
Parameters:
dx - The X coordinate of translation vector
dy - The Y coordinate of translation vector
Since:
PicEdt 1.0

scale

public void scale(double ptOrgX,
                  double ptOrgY,
                  double sx,
                  double sy,
                  UserConfirmationCache ucc)
Scale this object by (sx,sy) using (ptOrgX,ptOrgY) as the origin. This implementation simply apply a scaling transform to all specification-points. Note that sx and sy may be negative. This method eventually fires a changed-update event.

Specified by:
scale in interface Element
ucc - une valeur UserConfirmationCache permettant de demander à l'utilisateur confirmation, de se souvenir de la dernière confirmation qu'il a donné, ou de ses préférences.

rotate

public void rotate(PicPoint ptOrg,
                   double angle)
Rotate this Element by the given angle along the given point

Specified by:
rotate in interface Element
Parameters:
angle - rotation angle in radians

mirror

public void mirror(PicPoint ptOrg,
                   PicVector normalVector)
Effectue une réflexion sur this relativement à l'axe défini par ptOrg et normalVector.

Specified by:
mirror in interface Element
Parameters:
ptOrg - le PicPoint par lequel passe l'axe de réflexion.
normalVector - le PicVector normal à l'axe de réflexion.

shear

public void shear(PicPoint ptOrg,
                  double shx,
                  double shy,
                  UserConfirmationCache ucc)
Shear this Element by the given params wrt to the given origin

Specified by:
shear in interface Element
ucc - une valeur UserConfirmationCache permettant de demander à l'utilisateur confirmation, de se souvenir de la dernière confirmation qu'il a donné, ou de ses préférences.

setTextMode

public void setTextMode(PicText.TextMode textMode)

setTextIcon

public void setTextIcon(PicText.TextIcon textIcon)

getHorAlign

public PicText.HorAlign getHorAlign()
Return horizontal alignment (see constant fields above)


setHorAlign

public void setHorAlign(PicText.HorAlign horAlign)
Set the horizontal alignment (see constant fields above)


getVertAlign

public PicText.VertAlign getVertAlign()
Return vertical alignement (see static constant above)


setVertAlign

public void setVertAlign(PicText.VertAlign vertAlign)
set the vertical alignement (see constant fields above)


isFramed

public boolean isFramed()
Return TRUE if the box has to be drawn


setFrameType

public void setFrameType(PicText.FrameStyle frameType)
Set the type of frame to be put around the text.


getFrameType

public PicText.FrameStyle getFrameType()
Set the frame type


getShapeOfFrame

public Shape getShapeOfFrame()
Returns the frame that surrounds the text, ignoring rotation (the view will rotate it)


updateFrame

public void updateFrame()
First computes frame dimensions (frameWidth, etc). Then computes the frame that surrounds the text, ignoring rotation (the view will rotate it)


getTextMode

public boolean getTextMode()
Return the textmode only


setTextMode

public void setTextMode(boolean mode)
Set the textmode and updates the text


setAreaMode

public void setAreaMode(boolean b)

getAreaSet

public boolean getAreaSet()

getAreaMode

public boolean getAreaMode()

getWidth

public double getWidth()
Return the width of text only


getHeight

public double getHeight()
Return the height of text only


getDepth

public double getDepth()
Return the depth of text only


getLeftX

public double getLeftX()
Return x-coordinate of left boundary of text only


getRightX

public double getRightX()
Return x-coordinate of right boundary of text only


getCenterX

public double getCenterX()
Return x-coordinate of center of text only


getBottomY

public double getBottomY()
Return y-coordinate of bottom boundary of text only


getTopY

public double getTopY()
Return y-coordinate of top boundary of text only


getBaseLineY

public double getBaseLineY()
Return y-coordinate of baseline


getCenterY

public double getCenterY()
Return y-coordinate of center of text only


getFrameWidth

public double getFrameWidth()
Return the width of the text including frame


getFrameHeight

public double getFrameHeight()
Return the height of the text including frame


getFrameDepth

public double getFrameDepth()
Return the depth of the text including frame


getFrameLeftX

public double getFrameLeftX()
Return x-coordinate of left boundary, including frame


getFrameRightX

public double getFrameRightX()
Return x-coordinate of right boundary


getFrameCenterX

public double getFrameCenterX()
Return x-coordinate of center


getFrameTopY

public double getFrameTopY()
Return y-coordinate of top boundary


getFrameBottomY

public double getFrameBottomY()
Return y-coordinate of bottom boundary


getFrameBaseLineY

public double getFrameBaseLineY()
Return y-coordinate of baseline


getFrameCenterY

public double getFrameCenterY()
Return y-coordinate of center


setDimensions

public void setDimensions(double w,
                          double h,
                          double d)
set the width, height, and depth (of the text box, without frame). Normally, are set by the view.


getNodeConnectionManager

public NodeConnectionManager getNodeConnectionManager()
Specified by:
getNodeConnectionManager in interface NodeableElement

toString

public String toString()
Description copied from class: AbstractElement
Returns a String representation of the attribute set for this AbstractElement

Overrides:
toString in class AbstractElement

createCustomizer

public AbstractCustomizer createCustomizer()
Return a Customizer for geometry editing

Specified by:
createCustomizer in interface CustomizerFactory

http://www.jpicedt.org

Submit a bug : syd@jpicedt.org