net.sf.latexdraw.glib.views.Java2D.impl
Class LTextView

java.lang.Object
  extended by net.sf.latexdraw.glib.views.AbstractView<S>
      extended by net.sf.latexdraw.glib.views.Java2D.impl.LShapeView<IText>
          extended by net.sf.latexdraw.glib.views.Java2D.impl.LTextView
All Implemented Interfaces:
IAbstractView, IViewShape, IViewText, ToolTipable, Pickable

 class LTextView
extends LShapeView<IText>
implements IViewText

Defines a view of the IText 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.

05/23/2010

Since:
3.0
Author:
Arnaud BLOUIN

Field Summary
static java.awt.Font FONT
           
static java.awt.FontMetrics FONT_METRICS
           
protected  java.awt.Image image
          The picture.
private  java.awt.Color lastColour
          Used to detect if the last version of the text is different from the view.
private  java.lang.String lastText
          Used to detect if the last version of the text is different from the view.
private  IText.TextPosition lastTextPos
          Used to detect if the last version of the text is different from the view.
protected  java.lang.String log
          The log of the compilation.
private  java.lang.String pathPic
          The path of the files: for instance on Unix is can be /tmp/latexdraw180980 (without any extension).
protected static double SCALE_IMAGE
          A ratio used to create bigger thumbnails to improve the quality of the displayed image.
 
Fields inherited from class net.sf.latexdraw.glib.views.Java2D.impl.LShapeView
arrows, border, path
 
Fields inherited from class net.sf.latexdraw.glib.views.AbstractView
shape
 
Constructor Summary
protected LTextView(IText model)
          Creates and initialises a text view.
 
Method Summary
 boolean contains(double x, double y)
          Tests if the given point is into the pickable object.
private  java.awt.Image createImage()
           
private  boolean execute(java.lang.String[] cmd)
          Executes a given command and returns the log.
protected  void finalize()
           
 void flush()
          Removes and flushes the used resources and temporary documents.
protected  void flushPictures()
          Flushes the pictures of the text and all the related resources.
 java.awt.Image getImage()
           
 java.lang.String getLaTeXDocument()
           
 java.lang.String getLatexErrorMessageFromLog()
           
private  IPoint getTextPositionImage()
           
private  IPoint getTextPositionText()
           
 java.lang.String getToolTip()
           
 boolean intersects(java.awt.geom.Rectangle2D rec)
           
 boolean isToolTipVisible(double x, double y)
          Tests if a tooltip can be displayed.
 void paint(java.awt.Graphics2D g)
          Draws the shape within a Java2D graphics.
 void update()
          Updates the view.
 void updateBorder()
          Update the border of the shape view.
protected  void updateDblePathInside()
          Updates the borders of the double boundary when position is inside.
protected  void updateDblePathMiddle()
          Updates the borders of the double boundary when position is middle.
protected  void updateDblePathOutside()
          Updates the borders of the double boundary when position is outside.
protected  void updateGeneralPathInside()
          Updates the borders of the shape as inside borders.
protected  void updateGeneralPathMiddle()
          Updates the borders of the shape as middle borders.
protected  void updateGeneralPathOutside()
          Updates the borders of the shape as outside borders.
 void updateImage()
          Updates the image.
 
Methods inherited from class net.sf.latexdraw.glib.views.Java2D.impl.LShapeView
beginRotation, contains, endRotation, getBorder, getPath, getPicker, getRotatedShape2D, getRotatedShape2D, getStroke, getStrokeThickness, paintArrows, paintBorders, paintFilling, paintShadow, paintShowPointsDots, paintShowPointsLines, updatePath, updatePathArrows
 
Methods inherited from class net.sf.latexdraw.glib.views.AbstractView
getShape
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.latexdraw.glib.views.Java2D.interfaces.IViewShape
contains, getBorder, getPath, getRotatedShape2D, getStroke, paintBorders, paintFilling, paintShadow, paintShowPointsDots, paintShowPointsLines, updatePath
 
Methods inherited from interface net.sf.latexdraw.glib.views.IAbstractView
getShape
 
Methods inherited from interface org.malai.picking.Pickable
getPicker
 

Field Detail

image

protected java.awt.Image image
The picture.


log

protected java.lang.String log
The log of the compilation.


pathPic

private java.lang.String pathPic
The path of the files: for instance on Unix is can be /tmp/latexdraw180980 (without any extension).


lastText

private java.lang.String lastText
Used to detect if the last version of the text is different from the view. It helps to update the picture.


lastColour

private java.awt.Color lastColour
Used to detect if the last version of the text is different from the view. It helps to update the picture.


lastTextPos

private IText.TextPosition lastTextPos
Used to detect if the last version of the text is different from the view. It helps to update the picture.


FONT

public static final java.awt.Font FONT

FONT_METRICS

public static final java.awt.FontMetrics FONT_METRICS

SCALE_IMAGE

protected static final double SCALE_IMAGE
A ratio used to create bigger thumbnails to improve the quality of the displayed image.

See Also:
Constant Field Values
Constructor Detail

LTextView

protected LTextView(IText model)
Creates and initialises a text view.

Parameters:
model - The model to view.
Throws:
java.lang.IllegalArgumentException - If the given model is null.
Since:
3.0
Method Detail

update

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

Specified by:
update in interface IAbstractView
Overrides:
update in class LShapeView<IText>

finalize

protected void finalize()
Overrides:
finalize in class java.lang.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
Overrides:
flush in class LShapeView<IText>

flushPictures

protected void flushPictures()
Flushes the pictures of the text and all the related resources.

Since:
3.0

updateImage

public void updateImage()
Description copied from interface: IViewText
Updates the image.

Specified by:
updateImage in interface IViewText

getImage

public java.awt.Image getImage()
Specified by:
getImage in interface IViewText
Returns:
the image.

createImage

private java.awt.Image createImage()
Returns:
The LaTeX compiled picture of the text or null.
Since:
3.0

getLatexErrorMessageFromLog

public java.lang.String getLatexErrorMessageFromLog()
Specified by:
getLatexErrorMessageFromLog in interface IViewText
Returns:
The precise latex error messages that the latex compilation produced.

execute

private boolean execute(java.lang.String[] cmd)
Executes a given command and returns the log.

Parameters:
cmd - The command to execute.
Returns:
True if the command exit normally.
Since:
3.0

getLaTeXDocument

public java.lang.String getLaTeXDocument()
Specified by:
getLaTeXDocument in interface IViewText
Returns:
The LaTeX document that will be compiled in order to get the picture of the text.

intersects

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

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
Overrides:
contains in class LShapeView<IText>
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.

getTextPositionImage

private IPoint getTextPositionImage()

getTextPositionText

private IPoint getTextPositionText()

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
Overrides:
paint in class LShapeView<IText>
Parameters:
g - The graphics where the shape must be drawn.

updateBorder

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

Specified by:
updateBorder in interface IViewShape
Overrides:
updateBorder in class LShapeView<IText>

updateDblePathInside

protected void updateDblePathInside()
Description copied from class: LShapeView
Updates the borders of the double boundary when position is inside.

Specified by:
updateDblePathInside in class LShapeView<IText>

updateDblePathMiddle

protected void updateDblePathMiddle()
Description copied from class: LShapeView
Updates the borders of the double boundary when position is middle.

Specified by:
updateDblePathMiddle in class LShapeView<IText>

updateDblePathOutside

protected void updateDblePathOutside()
Description copied from class: LShapeView
Updates the borders of the double boundary when position is outside.

Specified by:
updateDblePathOutside in class LShapeView<IText>

updateGeneralPathInside

protected void updateGeneralPathInside()
Description copied from class: LShapeView
Updates the borders of the shape as inside borders.

Specified by:
updateGeneralPathInside in class LShapeView<IText>

updateGeneralPathMiddle

protected void updateGeneralPathMiddle()
Description copied from class: LShapeView
Updates the borders of the shape as middle borders.

Specified by:
updateGeneralPathMiddle in class LShapeView<IText>

updateGeneralPathOutside

protected void updateGeneralPathOutside()
Description copied from class: LShapeView
Updates the borders of the shape as outside borders.

Specified by:
updateGeneralPathOutside in class LShapeView<IText>

isToolTipVisible

public boolean isToolTipVisible(double x,
                                double y)
Description copied from interface: ToolTipable
Tests if a tooltip can be displayed. The coordinates can be used to test if the current pointer position points onto the tooltipable object.

Specified by:
isToolTipVisible in interface ToolTipable
Parameters:
x - The X-coordinate to test.
y - The Y-coordinate to test.
Returns:
True if a tooltip can be displayed.

getToolTip

public java.lang.String getToolTip()
Specified by:
getToolTip in interface ToolTipable
Returns:
The tooltip to display.