[latexdraw] 66/147: * new upstream release 2.0.1
Stuart Prescott
stuart at debian.org
Thu Nov 24 23:53:32 UTC 2016
This is an automated email from the git hooks/post-receive script.
stuart pushed a commit to branch master
in repository latexdraw.
commit 6eee2ccd22f304c251b2a0a150504c866c56dd4f
Author: Stuart Prescott <stuart at debian.org>
Date: Thu Apr 23 22:43:11 2009 +0000
* new upstream release 2.0.1
---
debian/README.Debian-source | 28 +-
lang/de/dialogFrames.properties | 1 +
lang/en-US/dialogFrames.properties | 1 +
lang/en/dialogFrames.properties | 1 +
lang/es/dialogFrames.properties | 1 +
lang/fr/dialogFrames.properties | 1 +
latexDraw/figures/Draw.java | 4228 +++++++++---------
latexDraw/figures/Figure.java | 163 +-
latexDraw/generators/svg/LShapeSVGGenerator.java | 198 +-
latexDraw/generators/svg/LTextSVGGenerator.java | 13 +-
.../pstricks/LaTeXDrawPSTricksParserActions.java | 3337 +++++++-------
.../parsers/svg/elements/SVGPatternElement.java | 1 +
latexDraw/ui/DrawContainer.java | 42 +-
latexDraw/ui/LaTeXDrawFrame.java | 4 +-
latexDraw/ui/dialog/AbstractParametersFrame.java | 4580 ++++++++++----------
latexDraw/util/LaTeXDrawNamespace.java | 1 +
release_note.txt | 1244 +++---
17 files changed, 7085 insertions(+), 6759 deletions(-)
diff --git a/debian/README.Debian-source b/debian/README.Debian-source
index df7de45..34ee1d7 100644
--- a/debian/README.Debian-source
+++ b/debian/README.Debian-source
@@ -2,33 +2,33 @@
Repackaging of original source for latexdraw
---------------------------------------------------------------------
-latexdraw version 2.0.0+2.
+latexdraw version 2.0.1+1.
-Downloaded file: LaTeXDraw2.0.0_src.zip
+Downloaded file: LaTeXDraw2.0.1_src.zip
From: sourceforge.net
-Path: ../tarballs/LaTeXDraw2.0.0_src.zip
+Path: ../LaTeXDraw2.0.1_src.zip
-$ md5sum --binary LaTeXDraw2.0.0_src.zip
-5bfe3a4afbb94fc6ce91e09b1f2bbfcc *LaTeXDraw2.0.0_src.zip
+$ md5sum --binary LaTeXDraw2.0.1_src.zip
+997bda67e6be8fc0c9a9aa53823260fd *LaTeXDraw2.0.1_src.zip
The following commands were used to repackage the original source (the
'touch' commands ensure that the md5sum of the archives stays the same):
-$ mkdir latexdraw-2.0.0+2.orig
+$ unzip -qq -d . LaTeXDraw2.0.1_src.zip
-$ unzip -qq -d latexdraw-2.0.0+2.orig LaTeXDraw2.0.0_src.zip
+$ mv LaTeXDraw2.0.1_src latexdraw-2.0.1+1.orig
-$ touch -t 199001010000.00 latexdraw-2.0.0+2.orig
+$ touch -t 199001010000.00 latexdraw-2.0.1+1.orig
-$ tar cf latexdraw_2.0.0+2.orig.tar --owner 0 --group 0 --numeric-owner --exclude=bin --exclude=doc --exclude=lib --exclude=src?lib --exclude=*.class --exclude=*.jar latexdraw-2.0.0+2.orig
+$ tar cf latexdraw_2.0.1+1.orig.tar --owner 0 --group 0 --numeric-owner --exclude=bin --exclude=doc --exclude=lib --exclude=src?lib --exclude=*.class --exclude=*.jar latexdraw-2.0.1+1.orig
-$ touch -t 199001010000.00 latexdraw_2.0.0+2.orig.tar
+$ touch -t 199001010000.00 latexdraw_2.0.1+1.orig.tar
-$ gzip -9 latexdraw_2.0.0+2.orig.tar
+$ gzip -9 latexdraw_2.0.1+1.orig.tar
-$ md5sum --binary latexdraw_2.0.0+2.orig.tar.gz
-a1fce0010c9a2476ee0c175388099396 *latexdraw_2.0.0+2.orig.tar.gz
+$ md5sum --binary latexdraw_2.0.1+1.orig.tar.gz
+0c8021d95523d7c4b1448bc9f77bad79 *latexdraw_2.0.1+1.orig.tar.gz
- -- Stuart Prescott <stuart+debian at nanonanonano.net> Thu, 23 Apr 2009 21:45:15 +0100
+ -- Stuart Prescott <stuart+debian at nanonanonano.net> Thu, 23 Apr 2009 23:01:26 +0100
---------------------------------------------------------------------
diff --git a/lang/de/dialogFrames.properties b/lang/de/dialogFrames.properties
index 3e0f009..c57521f 100644
--- a/lang/de/dialogFrames.properties
+++ b/lang/de/dialogFrames.properties
@@ -116,3 +116,4 @@ ParametersTriangleFrame.1=Basis Zentrum Y-Koordinaten:
ParamsBC.0=Alle bewegen
ParamsBC.1=Punkte und zugeh\u00F6rige Kontrollpunkte gleichzeitig verschieben.
ParamsGrid.0=Beschriftungen
+ExportDialog.0=Compression
diff --git a/lang/en-US/dialogFrames.properties b/lang/en-US/dialogFrames.properties
index d59e8b4..decf1bd 100644
--- a/lang/en-US/dialogFrames.properties
+++ b/lang/en-US/dialogFrames.properties
@@ -116,3 +116,4 @@ ParametersTriangleFrame.1=Base center Y-coord:
ParamsBC.0=Move all
ParamsBC.1=If unchecked, when you move a point, its control points are moved too.
ParamsGrid.0=Labels
+ExportDialog.0=Compression
diff --git a/lang/en/dialogFrames.properties b/lang/en/dialogFrames.properties
index ec9ad63..5c32dca 100644
--- a/lang/en/dialogFrames.properties
+++ b/lang/en/dialogFrames.properties
@@ -116,3 +116,4 @@ ParametersTriangleFrame.1=Base centre Y-coord:
ParamsBC.0=Move all
ParamsBC.1=If unchecked, when you move a point, its control points are moved too.
ParamsGrid.0=Labels
+ExportDialog.0=Compression
diff --git a/lang/es/dialogFrames.properties b/lang/es/dialogFrames.properties
index 2396579..ae0deee 100644
--- a/lang/es/dialogFrames.properties
+++ b/lang/es/dialogFrames.properties
@@ -116,3 +116,4 @@ ParametersTriangleFrame.1=Centro de base coord-Y:
ParamsBC.0=Move all
ParamsBC.1=If unchecked, when you move a point, its control points are moved too.
ParamsGrid.0=Etiquetas
+ExportDialog.0=Compression
diff --git a/lang/fr/dialogFrames.properties b/lang/fr/dialogFrames.properties
index ce83f40..85f979f 100644
--- a/lang/fr/dialogFrames.properties
+++ b/lang/fr/dialogFrames.properties
@@ -116,3 +116,4 @@ ParametersTriangleFrame.1=Coord Y centre base :
ParamsBC.0=Tout bouger
ParamsBC.1=Si non s\u00E9lectionn\u00E9, le mouvement d'un point provoque le mouvement de son point de contr\u00F4le.
ParamsGrid.0=Etiquettes
+ExportDialog.0=Compression
diff --git a/latexDraw/figures/Draw.java b/latexDraw/figures/Draw.java
index 2f866db..d079466 100644
--- a/latexDraw/figures/Draw.java
+++ b/latexDraw/figures/Draw.java
@@ -1,2104 +1,2124 @@
-package latexDraw.figures;
-
-
-import java.awt.Color;
-import java.awt.Graphics2D;
-import java.awt.Point;
-import java.awt.Shape;
-import java.awt.geom.Rectangle2D;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.util.LinkedList;
-import java.util.Vector;
-
-import latexDraw.psTricks.PSTricksConstants;
-import latexDraw.ui.LaTeXDrawFrame;
-import latexDraw.ui.components.MagneticGrid;
-import latexDraw.util.LaTeXDrawPoint2D;
-
-/**
- * This file is part of LaTeXDraw<br>
- * Copyright (c) 2005-2008 Arnaud BLOUIN<br>
- *<br>
- * 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
- * any later version.<br>
- *<br>
- * 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.<br>
- *<br>
- * 01/20/06<br>
- * @author Arnaud BLOUIN<br>
- * @version 2.0.0<br>
- */
-public class Draw extends Figure
-{
- private static final long serialVersionUID = 1L;
-
- /** All the figures which constitute the drawing. */
- protected Vector<Figure> figures;
-
- /** Defines the borders of the draw without taking account of the thickness of the figures. */
- protected LaTeXDrawRectangle minBorders;
-
- /** True: the figures of the drawing must be drawn (and the method get code get there code. */
- protected boolean drawFigures;
-
- /** The point is useful to rotate the selection. */
- protected transient LaTeXDrawPoint2D formerGravityC = null;
-
- /** The value by default of the attribute drawFigure */
- public static final boolean DEFAULT_DRAWFIGURE = false;
-
-
-
-
- /**
- * The constructor by default.
- */
- public Draw(boolean drawFigures, boolean increaseMeter)
- {
- this(null, drawFigures, increaseMeter);
- }
-
-
-
- public Draw(Vector<Figure> figs, boolean drawFigures, boolean increaseMeter, boolean cloneFigures)
- {
- super(increaseMeter);
-
- canHaveShadow = true;
- isResizable = true;
- isBordersMovable = true;
- isDashableOrDotable = true;
- isDoubleBoundaryable = true;
- this.drawFigures = drawFigures;
- canBeFilled = true;
- isCustomizable = true;
- isThicknessable = true;
-
- initializeBorders();
- figures = new Vector<Figure>();
-
- if(figs!=null)
- if(cloneFigures)
- {
- for(Figure f : figs)
- if(f!=null)
- try { addFigure((Figure)f.clone()); }
- catch(CloneNotSupportedException e) { e.printStackTrace(); }
- }
- else
- for(Figure f : figs)
- if(f!=null)
- addFigure(f);
-
- shape = createShape2D();
- }
-
-
-
- public Draw(Vector<Figure> figs, boolean drawFigures, boolean increaseMeter)
- {
- this(figs, drawFigures, increaseMeter, false);
- }
-
-
-
-
- /**
- * Initialise the minBorders and the borders (colour, style, ...).
- */
- protected void initializeBorders()
- {
- if(minBorders==null)
- minBorders = new LaTeXDrawRectangle(false);
-
- if(borders==null)
- borders = new LaTeXDrawRectangle(false);
-
- borders.setLinesColor(Color.gray);
- borders.setLineStyle(PSTricksConstants.LINE_DASHED_STYLE);
- }
-
-
-
-
-
- /**
- * Allows to add a figure to the drawing.
- * @param f The figure to add.
- * @throws IllegalArgumentException If f is null.
- */
- public void addFigure(Figure f)
- {
- if(f==null)
- throw new IllegalArgumentException("f is null.");//$NON-NLS-1$
-
- f.onRelease();
- figures.add(f);
- updateBorders();
- updateGravityCenter();
- }
-
-
-
-
- /**
- * Allows to add a figure to the drawing at a given position.
- * @param f The figure to add.
- * @param index THe position where insert the figure.
- * @throws IllegalArgumentException If f is null or if the index is bad.
- */
- public void addFigure(Figure f, int index)
- {
- if(index<0 || (index>=figures.size() && index>0))
- throw new IllegalArgumentException("Bad index.");//$NON-NLS-1$
-
- if(f==null)
- throw new IllegalArgumentException("f is null.");//$NON-NLS-1$
-
- f.onRelease();
- figures.add(index, f);
- updateBorders();
- updateGravityCenter();
- }
-
-
-
-
-
- @Override
- public synchronized void setOnRotation(boolean on)
- {
- super.setOnRotation(on);
- int i, size=figures.size();
-
- for(i=0; i<size; i++)
- figures.elementAt(i).setOnRotation(on);
-
- if(!on)
- {
- borders.rotationAngle = 0;
- updateBorders();
- updateGravityCenter();
- }
- }
-
-
-
-
- /**
- * Allows to remove a figure of the drawing.
- * @param f The figure to remove.
- */
- public void removeFigure(Figure f)
- {
- if(f!=null && figures.contains(f))
- {
- figures.remove(f);
- updateBorders();
- }
- }
-
-
- /**
- * Allows to remove a figure of the drawing.
- * @param id the position of the figure in the vector.
- * @exception IllegalArgumentException if the <code>id</code> is invalid.
- * @return The deleted figure.
- * @since 1.9.1
- */
- public Figure removeFigureAt(int id)
- {
- if(id<0 || id>=figures.size())
- throw new IllegalArgumentException();
-
- Figure f = figures.remove(id);
- updateBorders();
-
- return f;
- }
-
-
-
-
- /**
- * Allows to update the dimension and the position of the borders of the drawing.
- */
- public void updateBorders()
- {
- if(minBorders==null) initializeBorders();
- if(borders==null) initializeBorders();
-
- if(figures.isEmpty())
- {
- borders.setFirstPoint(0, 0);
- borders.setLastPoint(0, 0);
- minBorders.setFirstPoint(0, 0);
- minBorders.setLastPoint(0, 0);
- }
- else
- {
- int size = figures.size(), i;
- LaTeXDrawPoint2D NW, SE, NW2, SE2;
- LaTeXDrawPoint2D NWb, SEb, NW2b, SE2b;
- Figure f = figures.firstElement();
-
- NW = (LaTeXDrawPoint2D) f.getTheNWBoundPoint().clone();
- SE = (LaTeXDrawPoint2D) f.getTheSEBoundPoint().clone();
-
- if(f instanceof Draw)
- {
- NWb = (LaTeXDrawPoint2D)((Draw)f).minBorders.getTheNWPoint().clone();
- SEb = (LaTeXDrawPoint2D)((Draw)f).minBorders.getTheSEPoint().clone();
- }
- else
- {
- NWb = (LaTeXDrawPoint2D) f.getTheNWPoint().clone();
- SEb = (LaTeXDrawPoint2D) f.getTheSEPoint().clone();
- }
-
- for(i=1; i<size; i++)
- {
- f = figures.elementAt(i);
-
- NW2 = f.getTheNWBoundPoint();
- SE2 = f.getTheSEBoundPoint();
-
- if(f instanceof Draw)
- {
- NW2b = (LaTeXDrawPoint2D)((Draw)f).minBorders.getTheNWPoint().clone();
- SE2b = (LaTeXDrawPoint2D)((Draw)f).minBorders.getTheSEPoint().clone();
- }
- else
- {
- NW2b = (LaTeXDrawPoint2D) f.getTheNWPoint().clone();
- SE2b = (LaTeXDrawPoint2D) f.getTheSEPoint().clone();
- }
-
- if(NW2.x<NW.x) NW.x = NW2.x;
- if(NW2.y<NW.y) NW.y = NW2.y;
- if(SE2.x>SE.x) SE.x = SE2.x;
- if(SE2.y>SE.y) SE.y = SE2.y;
-
- if(NW2b.x<NWb.x) NWb.x = NW2b.x;
- if(NW2b.y<NWb.y) NWb.y = NW2b.y;
- if(SE2b.x>SEb.x) SEb.x = SE2b.x;
- if(SE2b.y>SEb.y) SEb.y = SE2b.y;
- }
-
- borders.setFirstPoint(NW.x, NW.y);
- borders.setLastPoint(SE);
- minBorders.setFirstPoint(NWb);
- minBorders.setLastPoint(SEb);
- shape = createShape2D();
- }
- }
-
-
-
-
- @Override
- public void onDragged(Point formerPt, Point newPt) throws Exception
- {
- if(formerPt.equals(newPt)) return;
-
- int i, size = figures.size();
-
- if(figures.size()==1 && !drawFigures)
- {
- figures.firstElement().onDragged(formerPt, newPt);
- updateBorders();
- updateGravityCenter();
- return;
- }
-
- if(borders.dSelected!=null)
- {
- if(isOnRotation)
- {
- double angle = computeRotationAngle(formerPt, newPt);
-
- rotationAngle+=angle;
- rotationAngle%=(2*Math.PI);
-
- if(formerGravityC==null)
- throw new IllegalArgumentException("beginRotate must be called before to initialise the rotation"); //$NON-NLS-1$
-
- for(i=0; i<size; i++)
- figures.elementAt(i).rotate(formerGravityC, angle);
-
- return ;
- }
-
- if((borders.dSelected==borders.dNE || borders.dSelected==borders.dNW ||
- borders.dSelected==borders.dN) && newPt.y>=borders.dS.getY())
- return ;
- if((borders.dSelected==borders.dSE || borders.dSelected==borders.dSW ||
- borders.dSelected==borders.dS) && newPt.y<=borders.dN.getY())
- return ;
- if((borders.dSelected==borders.dSE || borders.dSelected==borders.dNE ||
- borders.dSelected==borders.dE) && newPt.x<=borders.dW.getX())
- return ;
- if((borders.dSelected==borders.dSW || borders.dSelected==borders.dNW ||
- borders.dSelected==borders.dW) && newPt.x>=borders.dE.getX())
- return ;
-
- boolean rescalable;
- Figure f;
-
- if(borders.dSelected==borders.dE || borders.dSelected==borders.dNE || borders.dSelected==borders.dSE)
- {
-
- double dEx = borders.dE.getX(), dWx = borders.dW.getX();
- double percent = Math.abs((newPt.x-dWx)/(dEx-dWx));
- rescalable = true;
- i=0;
-
- while(i<size && rescalable)
- {
- f = getFigureAt(i);
- if(f.isResizable())
- {
- if(f.isTooSmallToBeRescaled() && dEx>=newPt.x)
- rescalable = false;
- }
- else rescalable = false;
- i++;
- }
-
- // The user must not be able to reduce too much to figure
- if(rescalable)
- rescaleX(minBorders.getTheSEPoint().x,
- minBorders.getTheSEPoint().x+dEx-newPt.x, percent, minBorders);
- }
- if(borders.dSelected==borders.dW || borders.dSelected==borders.dNW || borders.dSelected==borders.dSW)
- {
- double dEx = borders.dE.getX(), dWx = borders.dW.getX();
- double percent = Math.abs((newPt.x-dEx)/(dWx-dEx));
- rescalable = true;
- i=0;
-
- while(i<size && rescalable)
- {
- f = getFigureAt(i);
- if(f.isResizable())
- {
- if(f.isTooSmallToBeRescaled() && dWx<=newPt.x)
- rescalable = false;
- }
- else rescalable = false;
- i++;
- }
-
- if(rescalable)
- rescaleX(minBorders.getTheNWPoint().x,
- minBorders.getTheNWPoint().x+dWx-newPt.x, percent, minBorders);
- }
- if(borders.dSelected==borders.dN || borders.dSelected==borders.dNW || borders.dSelected==borders.dNE)
- {
- double dNy = borders.dN.getY(), dSy = borders.dS.getY();
- double percent = Math.abs((newPt.y-dSy)/(dNy-dSy));
- rescalable = true;
- i=0;
-
- while(i<size && rescalable)
- {
- f = getFigureAt(i);
- if(f.isResizable())
- {
- if(f.isTooSmallToBeRescaled() && dNy<=newPt.y)
- rescalable = false;
- }
- else rescalable = false;
- i++;
- }
-
- if(rescalable)
- // The user must not be able to reduce too much to figure
- rescaleY(minBorders.getTheNWPoint().y,
- minBorders.getTheNWPoint().y, percent, minBorders);
- }
- if(borders.dSelected==borders.dS || borders.dSelected==borders.dSW || borders.dSelected==borders.dSE)
- {
- double dNy = borders.dN.getY(), dSy = borders.dS.getY();
- double percent = Math.abs((newPt.y-dNy)/(dSy-dNy));
- rescalable = true;
- i=0;
-
- while(i<size && rescalable)
- {
- f = getFigureAt(i);
- if(f.isResizable())
- {
- if(f.isTooSmallToBeRescaled() && dSy>=newPt.y)
- rescalable = false;
- }
- else rescalable = false;
- i++;
- }
-
- if(rescalable)
- // The user must not be able to reduce too much to figure
- rescaleY(minBorders.getTheSEPoint().y,
- minBorders.getTheSEPoint().y-dSy+newPt.y, percent, minBorders);
- }
- }//if(borders.dSelected==null)
- else
- for(i=0; i<size; i++)
- figures.elementAt(i).onDragged(formerPt, newPt);
-
- updateBorders();
- updateGravityCenter();
- }
-
-
-
-
-
- /**
- * Allows to know if a figure is in the drawing.
- * @param f The figure that we want to know if it's in the drawing .
- * @return True if the figure is in the drawing.
- */
- public boolean contains(Figure f)
- {
- if(f!=null)
- return figures.contains(f);
- return false;
- }
-
-
-
-
-
- @Override
- public void draw(Graphics2D g, Object antiAlias, Object rendering, Object alphaInter, Object colorRendering)
- {
- if(drawFigures)
- {
- int i, size = size();
-
- for(i=0; i<size; i++)
- figures.elementAt(i).draw(g, antiAlias, rendering, alphaInter, colorRendering);
- }
-
- if(figures.size()>1 && isSelected && borders!=null)
- borders.draw(g, antiAlias, rendering, alphaInter, colorRendering);
- }
-
-
-
-
-
- /**
- * Allows to know if there is a figure in the drawing.
- * @return True if there is at least one figure in the drawing.
- */
- public boolean isEmpty()
- {
- return figures.isEmpty();
- }
-
-
-
-
-
- @Override
- public boolean isIn(LaTeXDrawPoint2D pt)
- {
- int i, size = figures.size();
- boolean in = false;
-
- for(i=0; i<size && !in; i++)
- in = figures.elementAt(i).isIn(pt);
-
- if(in) return true;
-
- return borders.isIn(pt);
- }
-
-
-
-
-
- /**
- * Allows to get the figure which contains the point <code>point</code>.
- * @param pt The point of reference.
- * @return The figure which contains the point.
- */
- public Figure whereIsIt(Point pt)
- {
- int i, size = figures.size();
- boolean here = false;
-
- for(i=0; i<size && !here; i++)
- here = figures.elementAt(i).isIn(pt);
-
- if(here) return figures.elementAt(i-1);
- return null;
-
- }
-
-
-
- /**
- * Allows to get the figure placed at the position <code>id</code> in the vector <code>Figures</code>.
- * @param id The position of the figure in the vector Figures.
- * @return The figure corresponding to the identifier.
- */
- public Figure getFigureAt(int id)
- {
- if(id<0 || id>=figures.size())
- throw new ArrayIndexOutOfBoundsException(id);
-
- return figures.elementAt(id);
- }
-
-
-
- /**
- * Allows to get the number of figures which contains the drawing.
- * @return The number of figures in the drawing.
- */
- public int size()
- {
- return figures.size();
- }
-
-
-
-
-
- @Override
- public String getCodePSTricks(DrawBorders drawBorders, float ppc)
- {
- int i, size = figures.size();
- if(drawFigures && size>0)
- {
- String code=""; //$NON-NLS-1$
-
- for(i=0; i<size-1; i++)
- code+=figures.elementAt(i).getCodePSTricks(drawBorders, ppc)+"\n"; //$NON-NLS-1$
- code+= figures.lastElement().getCodePSTricks(drawBorders, ppc);
-
- return code;
- }
-
- return null;
- }
-
-
-
- @Override
- public void onClick(Point pt)
- {
- super.onClick(pt);
-
- if(!drawFigures && size()==1)
- figures.elementAt(0).onClick(pt);
- }
-
-
-
- @Override
- public void onRelease()
- {
- super.onRelease();
-
- int i,size=figures.size();
-
- for(i=0; i<size; i++)
- figures.elementAt(i).onRelease();
- }
-
-
-
- @Override
- public void onDelimitorRelease()
- {
- super.onDelimitorRelease();
-
- int i,size=figures.size();
-
- for(i=0; i<size; i++)
- figures.elementAt(i).onDelimitorRelease();
- }
-
-
-
-
- @Override
- public void shift(double shiftX, double shiftY)
- {
- if(shiftX==0 && shiftY==0) return ;
-
- for(Figure f: figures)
- f.shift(shiftX, shiftY);
-
- updateBorders();
- updateGravityCenter();
- }
-
-
-
- @Override
- public synchronized void setSelected(boolean state)
- {
- super.setSelected(state);
-
- if(drawFigures || !state)
- for(Figure f : figures)
- f.setSelected(false);
- else
- if(size()>=1)
- figures.firstElement().setSelected(size()==1);
- }
-
-
-
-
- @Override
- public synchronized void setRotationAngle(double theta)
- {
- double angle = theta - rotationAngle;
- super.setRotationAngle(theta);
-
- if(drawFigures)
- {
- int i, size = figures.size();
-
- for(i=0; i<size; i++)
- figures.elementAt(i).rotate(gravityCenter, angle);
- }
-
- borders.setRotationAngle(0);
- updateBorders();
- updateGravityCenter();
- }
-
-
-
-
- @Override
- public synchronized void setLastPoint(double x, double y)
- {
- updateGravityCenter();
- }
-
-
-
-
- @Override
- public synchronized void setFirstPoint(double x, double y)
- {
- updateGravityCenter();
- }
-
-
-
- /**
- * Allows to clear the drawing: remove and unselect all the figures of the vector <code>figures</code>.
- */
- public void clear()
- {
- setSelected(false);
- figures.removeAllElements();
- shape = createShape2D();
- }
-
-
-
- @Override
- public Object clone() throws CloneNotSupportedException
- {
- Draw d = (Draw) super.clone();
- d.drawFigures = drawFigures;
-
- int i, size = size();
- d.figures = new Vector<Figure>();
-
- for(i=0; i<size; i++)
- d.addFigure((Figure) getFigureAt(i).clone());
-
- d.borders = (LaTeXDrawRectangle) borders.clone();
- d.updateBorders();
- d.updateGravityCenter();
-
- return d;
- }
-
-
-
-
- @Override
- public void updateGravityCenter()
- {
- LaTeXDrawPoint2D nw = new LaTeXDrawPoint2D(Double.MAX_VALUE, Double.MAX_VALUE);
- LaTeXDrawPoint2D se = new LaTeXDrawPoint2D(Double.MIN_VALUE, Double.MIN_VALUE);
- LaTeXDrawPoint2D nw2, se2;
-
- for(Figure f : figures)
- {
- nw2 = f.getTheNWRotatedPoint();
- se2 = f.getTheSERotatedPoint();
-
- if(nw2.x<nw.x) nw.x = nw2.x;
- if(nw2.y<nw.y) nw.y = nw2.y;
- if(se2.x>se.x) se.x = se2.x;
- if(se2.y>se.y) se.y = se2.y;
- }
-
- gravityCenter.x = (nw.x+se.x)/2.;
- gravityCenter.y = (nw.y+se.y)/2.;
- }
-
-
-
-
- @Override
- public void updateStyleOfDelimitors()
- {
- super.updateStyleOfDelimitors();
-
- for(int i=0, size=figures.size(); i<size; i++)
- figures.elementAt(i).updateStyleOfDelimitors();
- }
-
-
-
-
- @Override
- public boolean intersected(Rectangle2D.Double r)
- {
- boolean inter = false;
- int i=0, size = figures.size();
-
- while(!inter && i<size)
- if(figures.elementAt(i).intersected(r))
- inter = true;
- else i++;
-
- return inter;
- }
-
-
-
-
-
- @Override
- public Shape createShape2D()
- {
- return borders.shape;
- }
-
-
-
-
-
- @Override
- public void rescaleX(double formerX, double newX, double percent, LaTeXDrawRectangle bound)
- {
- if(percent==1.) return ;
- if(bound==null) throw new IllegalArgumentException();
-
- int i, size = figures.size();
-
- for(i=0; i<size; i++)
- figures.elementAt(i).rescaleX(formerX, newX, percent, bound);
-
- updateBorders();
- }
-
-
-
-
-
- @Override
- public void rescaleY(double formerY, double newY, double percent, LaTeXDrawRectangle bound)
- {
- if(percent==1.) return ;
- if(bound==null) throw new IllegalArgumentException();
-
- int i, size = figures.size();
-
- for(i=0; i<size; i++)
- figures.elementAt(i).rescaleY(formerY, newY, percent, bound);
-
- updateBorders();
- }
-
-
-
-
- @SuppressWarnings("unchecked")
- private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException
- {
- rotationAngle = ois.readDouble();
- isSelected = ois.readBoolean();
- isOnRotation = ois.readBoolean();
- borders =(LaTeXDrawRectangle) ois.readObject();
-
- if(LaTeXDrawFrame.getVersionOfFile().compareTo("1.6")<0) //$NON-NLS-1$
- ois.readDouble();
- figures = (Vector<Figure>) ois.readObject();
-
- if(LaTeXDrawFrame.getVersionOfFile().compareTo("1.5")>=0)//$NON-NLS-1$
- drawFigures = ois.readBoolean();
- else
- {
- ois.readObject();
- drawFigures = DEFAULT_DRAWFIGURE;
- }
-
- updateStyleOfDelimitors();
- canBeFilled = false;
- initializeBorders();
-
- if(linesColor==null)
- {
- linesColor = DEFAULT_BORDERS_COL;
- doubleColor = DEFAULT_DOUBLE_COLOR;
- interiorColor = DEFAULT_INTERIOR_COL;
- hatchingColor = DEFAULT_HATCH_COL;
- gradientEndColor = PSTricksConstants.DEFAULT_GRADIENT_END_COLOR;
- gradientStartColor = PSTricksConstants.DEFAULT_GRADIENT_START_COLOR;
- shadowColor = DEFAULT_SHADOW_COLOR;
- }
- }
-
-
-
- /**
- * @return Returns the drawFigures.
- */
- public boolean isDrawFigures()
- {
- return drawFigures;
- }
-
-
-
-
- /**
- * @param drawFigures The drawFigures to set.
- */
- public synchronized void setDrawFigures(boolean drawFigures)
- {
- this.drawFigures = drawFigures;
- }
-
-
-
- @Override
- public Shape createNonRotatedShape2D()
- {
- return borders.createNonRotatedShape2D();
- }
-
-
-
-
- @Override
- @Deprecated
- public void updateShape()
- {
- /* The shape is not used by a drawing. */
- }
-
-
-
- /**
- * @return the minBorders.
- */
- public LaTeXDrawRectangle getMinBorders()
- {
- return minBorders;
- }
-
-
-
-
- /**
- * @param minBorders the minBorders to set.
- */
- public void setMinBorders(LaTeXDrawRectangle minBorders)
- {
- this.minBorders = minBorders;
- }
-
-
-
-
- @Override
- public boolean isTooSmallToBeRescaled()
- {
- // TODO Auto-generated method stub
- return false;
- }
-
-
-
- @Override
- public void rotate(LaTeXDrawPoint2D gravityC, double angle)
- {
- for(Figure f : figures)
- f.rotate(gravityC, angle);
-
- updateBorders();
- }
-
-
-
-
- @Override
- public void mirrorHorizontal(LaTeXDrawPoint2D origin)
- {
- for(Figure f : figures)
- f.mirrorHorizontal(origin);
-
- updateBorders();
- updateGravityCenter();
- }
-
-
-
-
- @Override
- public void mirrorVertical(LaTeXDrawPoint2D origin)
- {
- for(Figure f : figures)
- f.mirrorVertical(origin);
-
- updateBorders();
- updateGravityCenter();
- }
-
-
-
-
- @Override
- public synchronized LaTeXDrawPoint2D getLastPoint()
- {
- return null;
- }
-
-
-
-
- /**
- * @since 1.9
- * @return The figures of the drawing.
- */
- public synchronized Vector<Figure> getFigures()
- {
- return figures;
- }
-
-
-
-
- @Override
- public void updateToGrid(MagneticGrid grid)
- {
- for(Figure figure : figures)
- figure.updateToGrid(grid);
-
- updateBorders();
- }
-
-
-
-
- @Override
- public int getSelectedDelimitorOrientation()
- {
- if(size()==1)
- return getFigureAt(0).getSelectedDelimitorOrientation();
-
- return borders.getSelectedDelimitorOrientation();
- }
-
-
-
- @Override
- public int hashCode()
- {
- return super.hashCode()^5;
- }
-
-
-
-
- /**
- * This method must be called before each rotation of the selection. Initialize the rotation.
- * @since 1.9
- */
- public void beginRotation()
- {
- updateGravityCenter();
- formerGravityC = (LaTeXDrawPoint2D)gravityCenter.clone();
-
- if(!drawFigures)
- for(Figure f : figures)
- if(f instanceof Draw)
- ((Draw)f).beginRotation();
- }
-
-
-
- /**
- * This method must be called after each rotation of the selection. Deinitialize the rotation.
- * @since 1.9
- */
- public void endRotation()
- {
- updateGravityCenter();
- updateBorders();
- formerGravityC = null;
-
- if(!drawFigures)
- for(Figure f : figures)
- if(f instanceof Draw)
- ((Draw)f).endRotation();
- }
-
-
- @Override
- public synchronized float getThickness()
- {
- if(figures==null || figures.isEmpty())
- return super.getThickness();
-
- return figures.firstElement().getThickness();
- }
-
-
-
-
- @Override
- public synchronized void setThickness(float value)
- {
- if(figures!=null)
- for(Figure f : figures)
- f.setThickness(value);
- }
-
-
-
-
- @Override
- public synchronized Color getDoubleColor()
- {
- if(figures==null || figures.isEmpty())
- return super.getDoubleColor();
-
- int i, size = figures.size();
- boolean ok;
-
- for(i=0, ok=true; i<size && ok; i++)
- if(figures.elementAt(i).isDoubleBoundaryable())
- ok = false;
-
- if(!ok && size>1)
- return figures.elementAt(i).getDoubleColor();
-
- return figures.firstElement().getDoubleColor();
- }
-
-
-
-
- @Override
- public synchronized Color getGradientEndColor()
- {
- if(figures==null || figures.isEmpty())
- return super.getGradientEndColor();
-
- int i, size = figures.size();
- boolean ok;
-
- for(i=0, ok=true; i<size && ok; i++)
- if(figures.elementAt(i).canBeHatched())
- ok = false;
-
- if(!ok && size>1)
- return figures.elementAt(i).getGradientEndColor();
-
- return figures.firstElement().getGradientEndColor();
- }
-
-
-
-
- @Override
- public synchronized Color getGradientStartColor()
- {
- if(figures==null || figures.isEmpty())
- return super.getGradientStartColor();
-
- int i, size = figures.size();
- boolean ok;
-
- for(i=0, ok=true; i<size && ok; i++)
- if(figures.elementAt(i).canBeHatched())
- ok = false;
-
- if(!ok && size>1)
- return figures.elementAt(i).getGradientStartColor();
-
- return figures.firstElement().getGradientStartColor();
- }
-
-
-
-
- @Override
- public synchronized Color getHatchingColor()
- {
- if(figures==null || figures.isEmpty())
- return super.getHatchingColor();
-
- int i, size = figures.size();
- boolean ok;
-
- for(i=0, ok=true; i<size && ok; i++)
- if(figures.elementAt(i).canBeHatched())
- ok = false;
-
- if(!ok && size>1)
- return figures.elementAt(i).getHatchingColor();
-
- return figures.firstElement().getHatchingColor();
- }
-
-
-
-
- @Override
- public synchronized String getHatchingStyle()
- {
- if(figures==null || figures.isEmpty())
- return super.getHatchingStyle();
-
- int i, size = figures.size();
- boolean ok;
-
- for(i=0, ok=true; i<size && ok; i++)
- if(figures.elementAt(i).canBeHatched())
- ok = false;
-
- if(!ok && size>1)
- return figures.elementAt(i).getHatchingStyle();
-
- return figures.firstElement().getHatchingStyle();
- }
-
-
-
-
- @Override
- public synchronized Color getInteriorColor()
- {
- if(figures==null || figures.isEmpty())
- return super.getInteriorColor();
-
- int i, size = figures.size();
- boolean ok;
-
- for(i=0, ok=true; i<size && ok; i++)
- if(figures.elementAt(i).canBeFilled())
- ok = false;
-
- if(!ok && size>1)
- return figures.elementAt(i).getInteriorColor();
-
- return figures.firstElement().getInteriorColor();
- }
-
-
-
-
- @Override
- public synchronized Color getLinesColor()
- {
- if(figures==null || figures.isEmpty())
- return super.getLinesColor();
-
- return figures.firstElement().getLinesColor();
- }
-
-
-
-
- @Override
- public synchronized String getLineStyle()
- {
- if(figures==null || figures.isEmpty())
- return super.getLineStyle();
-
- int i, size = figures.size();
- boolean ok;
-
- for(i=0, ok=true; i<size && ok; i++)
- if(figures.elementAt(i).isDashableOrDotable())
- ok = false;
-
- if(!ok && size>1)
- return figures.elementAt(i).getLineStyle();
-
- return figures.firstElement().getLineStyle();
- }
-
-
-
-
- @Override
- public synchronized boolean hasDoubleBoundary()
- {
- if(figures==null || figures.isEmpty())
- return super.hasDoubleBoundary();
-
- int i, size = figures.size();
- boolean ok;
-
- for(i=0, ok=true; i<size && ok; i++)
- if(figures.elementAt(i).isDoubleBoundaryable())
- ok = false;
-
- if(!ok && size>1)
- return figures.elementAt(i).hasDoubleBoundary();
-
- return figures.firstElement().hasDoubleBoundary();
- }
-
-
-
-
- @Override
- public synchronized boolean hasShadow()
- {
- if(figures==null || figures.isEmpty())
- return super.hasShadow();
-
- int i, size = figures.size();
- boolean ok;
-
- for(i=0, ok=true; i<size && ok; i++)
- if(figures.elementAt(i).canHaveShadow())
- ok = false;
-
- if(!ok && size>1)
- return figures.elementAt(i).hasShadow();
-
- return figures.firstElement().hasShadow();
- }
-
-
-
-
- @Override
- public synchronized boolean isFilled()
- {
- if(figures==null || figures.isEmpty())
- return super.isFilled();
-
- int i, size = figures.size();
- boolean ok;
-
- for(i=0, ok=true; i<size && ok; i++)
- if(figures.elementAt(i).canBeFilled())
- ok = false;
-
- if(!ok && size>1)
- return figures.elementAt(i).isFilled();
-
- return figures.firstElement().isFilled();
- }
-
-
-
- @Override
- public String toString()
- {
- String str = "["; //$NON-NLS-1$
-
- for(int i=0, size=figures.size()-1; i<size; i++)
- str += figures.elementAt(i).getClass().getName() + '(' + figures.elementAt(i).getNumber() + "), " ; //$NON-NLS-1$
-
- if(!figures.isEmpty())
- str += figures.lastElement().getClass().getCanonicalName() + '(' + figures.lastElement().getNumber() + ")" ; //$NON-NLS-1$
-
- return str + ']';
- }
-
-
-
-
- @Override
- public synchronized void setDoubleColor(Color doublecolor)
- {
- if(figures!=null)
- for(Figure f : figures)
- if(f.isDoubleBoundaryable())
- f.setDoubleColor(doublecolor);
- }
-
-
-
-
- @Override
- public synchronized void setGradientEndColor(Color gradientEndColor)
- {
- if(figures!=null)
- for(Figure f : figures)
- if(f.canBeFilled())
- f.setGradientEndColor(gradientEndColor);
- }
-
-
-
-
- @Override
- public synchronized void setGradientStartColor(Color gradientStartColor)
- {
- if(figures!=null)
- for(Figure f : figures)
- if(f.canBeFilled())
- f.setGradientStartColor(gradientStartColor);
- }
-
-
-
-
- @Override
- public synchronized void setHasDoubleBoundary(boolean hasDoubleBoundary)
- {
- if(figures!=null)
- for(Figure f : figures)
- if(f.isDoubleBoundaryable())
- f.setHasDoubleBoundary(hasDoubleBoundary);
- }
-
-
-
-
- @Override
- public synchronized void setHasShadow(boolean hasShadow)
- {
- if(figures!=null)
- for(Figure f : figures)
- if(f.canHaveShadow())
- f.setHasShadow(hasShadow);
- }
-
-
-
-
- @Override
- public synchronized void setHatchingColor(Color color)
- {
- if(figures!=null)
- for(Figure f : figures)
- if(f.canBeHatched())
- f.setHatchingColor(color);
- }
-
-
-
-
- @Override
- public synchronized void setHatchingStyle(String style)
- {
- if(figures!=null)
- for(Figure f : figures)
- if(f.canBeHatched())
- f.setHatchingStyle(style);
- }
-
-
-
-
- @Override
- public synchronized void setInteriorColor(Color c)
- {
- if(figures!=null)
- for(Figure f : figures)
- if(f.canBeFilled())
- f.setInteriorColor(c);
- }
-
-
-
-
- @Override
- public synchronized void setLinesColor(Color c)
- {
- if(figures!=null)
- for(Figure f : figures)
- f.setLinesColor(c);
- }
-
-
-
-
- @Override
- public synchronized void setLineStyle(String style)
- {
- if(figures!=null)
- for(Figure f : figures)
- if(f.isDashableOrDotable())
- f.setLineStyle(style);
- }
-
-
-
-
- @Override
- public synchronized void setShadowColor(Color shadowColor)
- {
- if(figures!=null)
- for(Figure f : figures)
- if(f.canHaveShadow())
- f.setShadowColor(shadowColor);
- }
-
-
-
- @Override
- public synchronized void setIsFilled(boolean filled)
- {
- if(figures!=null)
- for(Figure f : figures)
- if(f.canBeFilled())
- f.setIsFilled(filled);
- }
-
-
-
-
- /**
- * Distributes vertically at equal distance between the bottom sides of the selected figures.
- * @since 2.0.0
- */
- public void distributeVertBottom()
- {
- if(size()<2)
- return ;
-
- LinkedList<Figure> sortedF = new LinkedList<Figure>();
- LinkedList<Double> ses = new LinkedList<Double>();
- LaTeXDrawPoint2D pt;
- boolean ok;
- double gap;
- int i, size;
-
- for(Figure f : figures)
- {
- pt = f.getTheSERotatedPoint();
- ok = true;
-
- for(i=0, size=sortedF.size(); i<size && ok; i++)
- if(pt.y<ses.get(i))
- ok = false;
-
- if(ok)
- {
- sortedF.addLast(f);
- ses.addLast(pt.y);
- }
- else
- {
- sortedF.add(i-1, f);
- ses.add(i-1, pt.y);
- }
- }
-
- gap = (ses.getLast()-ses.getFirst())/(size()-1);
- size = sortedF.size()-1;
-
- for(i=1; i<size; i++)
- sortedF.get(i).shift(0, (ses.getFirst()+i*gap)-ses.get(i));
-
- updateBorders();
- }
-
-
-
- /**
- * Distributes vertically at equal distance between the middle of the selected figures.
- * @since 2.0.0
- */
- public void distributeVertMiddle()
- {
- LinkedList<Figure> sortedF = new LinkedList<Figure>();
- LinkedList<Double> gcs = new LinkedList<Double>();
- LaTeXDrawPoint2D pt;
- int i, size;
- boolean ok;
- double gap;
-
- for(Figure f : figures)
- {
- pt = f.getGravityCenter();
- ok = true;
-
- for(i=0, size=sortedF.size(); i<size && ok; i++)
- if(pt.y<gcs.get(i))
- ok = false;
-
- if(ok)
- {
- sortedF.addLast(f);
- gcs.addLast(pt.y);
- }
- else
- {
- sortedF.add(i-1, f);
- gcs.add(i-1, pt.y);
- }
- }
-
- gap = (gcs.getLast()-gcs.getFirst())/(size()-1);
- size = sortedF.size()-1;
-
- for(i=1; i<size; i++)
- sortedF.get(i).shift(0, (gcs.getFirst()+i*gap)-gcs.get(i));
-
- updateBorders();
- }
-
-
-
- /**
- * Distributes vertically at equal distance between the top sides of the selected figures.
- * @since 2.0.0
- */
- public void distributeVertTop()
- {
- if(size()<2)
- return ;
-
- LinkedList<Figure> sortedF = new LinkedList<Figure>();
- LinkedList<Double> nws = new LinkedList<Double>();
- LaTeXDrawPoint2D pt;
- int i, size;
- boolean ok;
- double gap;
-
- for(Figure f : figures)
- {
- pt = f.getTheNWRotatedPoint();
- ok = true;
-
- for(i=0, size=sortedF.size(); i<size && ok; i++)
- if(pt.y<nws.get(i))
- ok = false;
-
- if(ok)
- {
- sortedF.addLast(f);
- nws.addLast(pt.y);
- }
- else
- {
- sortedF.add(i-1, f);
- nws.add(i-1, pt.y);
- }
- }
-
- gap = (nws.getLast()-nws.getFirst())/(size()-1);
- size = sortedF.size()-1;
-
- for(i=1; i<size; i++)
- sortedF.get(i).shift(0, (nws.getFirst()+i*gap)-nws.get(i));
-
- updateBorders();
- }
-
-
-
- /**
- * Distributes horizontally at equal distance between the selected figures.
- * @since 2.0.0
- */
- public void distributeVertEqual()
- {
- if(size()<2)
- return ;
-
- LinkedList<Figure> sortedF = new LinkedList<Figure>();
- LinkedList<Double> tops = new LinkedList<Double>();
- LinkedList<Double> bots = new LinkedList<Double>();
- LaTeXDrawPoint2D pt;
- int i, size;
- boolean ok;
- double gap;
-
- for(Figure f : figures)
- {
- pt = f.getTheNWRotatedPoint();
-
- ok = true;
- for(i=0, size=tops.size(); i<size && ok; i++)
- if(pt.y<tops.get(i))
- ok = false;
-
- if(ok)
- {
- sortedF.addLast(f);
- tops.addLast(pt.y);
- bots.addLast(f.getTheSERotatedPoint().y);
- }
- else
- {
- sortedF.add(i-1, f);
- tops.add(i-1, pt.y);
- bots.add(i-1, f.getTheSERotatedPoint().y);
- }
- }
-
- gap = tops.getLast() - bots.getFirst();
- size = sortedF.size()-1;
-
- for(i=1; i<size; i++)
- gap -= bots.get(i) - tops.get(i);
-
- gap/=size;
-
- for(i=1; i<size; i++)
- sortedF.get(i).shift(0, (sortedF.get(i-1).getTheSERotatedPoint().y + gap) - tops.get(i));
-
- updateBorders();
- }
-
-
-
- /**
- * Distributes vertically at equal distance between the left sides of the selected figures.
- * @since 2.0.0
- */
- public void distributeHorizLeft()
- {
- if(size()<2)
- return ;
-
- LinkedList<Figure> sortedF = new LinkedList<Figure>();
- LinkedList<Double> nws = new LinkedList<Double>();
- LaTeXDrawPoint2D pt;
- int i, size;
- boolean ok;
- double gap;
-
- for(Figure f : figures)
- {
- pt = f.getTheNWRotatedPoint();
- ok = true;
-
- for(i=0, size=sortedF.size(); i<size && ok; i++)
- if(pt.x<nws.get(i))
- ok = false;
-
- if(ok)
- {
- sortedF.addLast(f);
- nws.addLast(pt.x);
- }
- else
- {
- sortedF.add(i-1, f);
- nws.add(i-1, pt.x);
- }
- }
-
- gap = (nws.getLast()-nws.getFirst())/(size()-1);
- size = sortedF.size()-1;
-
- for(i=1; i<size; i++)
- sortedF.get(i).shift((nws.getFirst()+i*gap)-nws.get(i), 0);
-
- updateBorders();
- }
-
-
-
- /**
- * Distributes vertically at equal distance between the middle of the selected figures.
- * @since 2.0.0
- */
- public void distributeHorizMiddle()
- {
- if(size()<2)
- return ;
-
- LinkedList<Figure> sortedF = new LinkedList<Figure>();
- LinkedList<Double> gcs = new LinkedList<Double>();
- LaTeXDrawPoint2D pt;
- int i, size;
- boolean ok;
- double gap;
-
- for(Figure f : figures)
- {
- pt = f.getGravityCenter();
- ok = true;
-
- for(i=0, size=sortedF.size(); i<size && ok; i++)
- if(pt.x<gcs.get(i))
- ok = false;
-
- if(ok)
- {
- sortedF.addLast(f);
- gcs.addLast(pt.x);
- }
- else
- {
- sortedF.add(i-1, f);
- gcs.add(i-1, pt.x);
- }
- }
-
- gap = (gcs.getLast()-gcs.getFirst())/(size()-1);
- size = sortedF.size()-1;
-
- for(i=1; i<size; i++)
- sortedF.get(i).shift((gcs.getFirst()+i*gap)-gcs.get(i), 0);
-
- updateBorders();
- }
-
-
-
- /**
- * Distributes vertically at equal distance between the right sides of the selected figures.
- * @since 2.0.0
- */
- public void distributeHorizRight()
- {
- if(size()<2)
- return ;
-
- LinkedList<Figure> sortedF = new LinkedList<Figure>();
- LinkedList<Double> ses = new LinkedList<Double>();
- LaTeXDrawPoint2D pt;
- int i, size;
- boolean ok;
- double gap;
-
- for(Figure f : figures)
- {
- pt = f.getTheSERotatedPoint();
-
- ok = true;
- for(i=0, size=sortedF.size(); i<size && ok; i++)
- if(pt.x<ses.get(i))
- ok = false;
-
- if(ok)
- {
- sortedF.addLast(f);
- ses.addLast(pt.x);
- }
- else
- {
- sortedF.add(i-1, f);
- ses.add(i-1, pt.x);
- }
- }
-
- gap = (ses.getLast()-ses.getFirst())/(size()-1);
- size = sortedF.size()-1;
-
- for(i=1; i<size; i++)
- sortedF.get(i).shift((ses.getFirst()+i*gap)-ses.get(i), 0);
-
- updateBorders();
- }
-
-
-
- /**
- * Distributes vertically at equal distance between the selected figures.
- * @since 2.0.0
- */
- public void distributeHorizEqual()
- {
- if(size()<2)
- return ;
-
- LinkedList<Figure> sortedF = new LinkedList<Figure>();
- LinkedList<Double> rights = new LinkedList<Double>();
- LinkedList<Double> lefts = new LinkedList<Double>();
- LaTeXDrawPoint2D pt;
- int i, size;
- boolean ok;
- double gap;
-
- for(Figure f : figures)
- {
- pt = f.getTheNWRotatedPoint();
- ok = true;
-
- for(i=0, size=lefts.size(); i<size && ok; i++)
- if(pt.x<lefts.get(i))
- ok = false;
-
- if(ok)
- {
- sortedF.addLast(f);
- lefts.addLast(pt.x);
- rights.addLast(f.getTheSERotatedPoint().x);
- }
- else
- {
- sortedF.add(i-1, f);
- lefts.add(i-1, pt.x);
- rights.add(i-1, f.getTheSERotatedPoint().x);
- }
- }
-
- gap = lefts.getLast() - rights.getFirst();
- size = sortedF.size()-1;
-
- for(i=1; i<size; i++)
- gap -= rights.get(i) - lefts.get(i);
-
- gap/=size;
-
- for(i=1; i<size; i++)
- sortedF.get(i).shift((sortedF.get(i-1).getTheSERotatedPoint().x + gap) - lefts.get(i), 0);
- }
-
-
-
-
- /**
- * Align the selected figures to the figure on the left.
- * @since 2.0.0
- */
- public void alignLeft()
- {
- if(size()<2)
- return ;
-
- LinkedList<LaTeXDrawPoint2D> nws = new LinkedList<LaTeXDrawPoint2D>();
- double minX = Double.MAX_VALUE;
- LaTeXDrawPoint2D pt;
-
- for(Figure f : figures)
- {
- pt = f.getTheNWRotatedPoint();
- nws.add(pt);
-
- if(pt.x<minX)
- minX = pt.x;
- }
-
- for(Figure f : figures)
- {
- pt = nws.poll();
-
- if(((float)minX)!=((float)pt.x))
- f.shift(minX-pt.x, 0);
- }
-
- updateBorders();
- }
-
-
-
-
- /**
- * Align the selected figures to the figure on the right.
- * @since 2.0.0
- */
- public void alignRight()
- {
- if(size()<2)
- return ;
-
- LinkedList<LaTeXDrawPoint2D> ses = new LinkedList<LaTeXDrawPoint2D>();
- double maxX = Double.MIN_VALUE;
- LaTeXDrawPoint2D pt;
-
- for(Figure f : figures)
- {
- pt = f.getTheSERotatedPoint();
- ses.add(pt);
-
- if(pt.x>maxX)
- maxX = pt.x;
- }
-
- for(Figure f : figures)
- {
- pt = ses.poll();
-
- if(((float)maxX)!=((float)pt.x))
- f.shift(maxX-pt.x, 0);
- }
-
- updateBorders();
- }
-
-
-
- /**
- * Align the selected figures to the figure on the top.
- * @since 2.0.0
- */
- public void alignTop()
- {
- if(size()<2)
- return ;
-
- LinkedList<LaTeXDrawPoint2D> nws = new LinkedList<LaTeXDrawPoint2D>();
- double minY = Double.MAX_VALUE;
- LaTeXDrawPoint2D pt;
-
- for(Figure f : figures)
- {
- pt = f.getTheNWRotatedPoint();
- nws.add(pt);
-
- if(pt.y<minY)
- minY = pt.y;
- }
-
- for(Figure f : figures)
- {
- pt = nws.poll();
-
- if(((float)minY)!=((float)pt.x))
- f.shift(0, minY-pt.y);
- }
-
- updateBorders();
- }
-
-
-
- /**
- * Align the selected figures to the figure on the bottom.
- * @since 2.0.0
- */
- public void alignBottom()
- {
- if(size()<2)
- return ;
-
- LinkedList<LaTeXDrawPoint2D> ses = new LinkedList<LaTeXDrawPoint2D>();
- double maxY = Double.MIN_VALUE;
- LaTeXDrawPoint2D pt;
-
- for(Figure f : figures)
- {
- pt = f.getTheSERotatedPoint();
- ses.add(pt);
-
- if(pt.y>maxY)
- maxY = pt.y;
- }
-
- for(Figure f : figures)
- {
- pt = ses.poll();
-
- if(((float)maxY)!=((float)pt.y))
- f.shift(0, maxY-pt.y);
- }
-
- updateBorders();
- }
-
-
-
- /**
- * Align vertically the selected figures to the figure in the middle.
- * @since 2.0.0
- */
- public void alignMiddleVertically()
- {
- if(size()<2)
- return ;
-
- LinkedList<Double> middles = new LinkedList<Double>();
- double maxX = Double.MIN_VALUE;
- double minX = Double.MAX_VALUE, middle, middle2;
- LaTeXDrawPoint2D pt, pt2;
-
- for(Figure f : figures)
- {
- pt = f.getTheNWRotatedPoint();
- pt2 = f.getTheSERotatedPoint();
-
- if(pt.x<minX)
- minX = pt.x;
-
- if(pt2.x>maxX)
- maxX = pt2.x;
-
- middles.add((pt.x+pt2.x)/2.);
- }
-
- middle = (minX+maxX)/2.;
-
- for(Figure f : figures)
- {
- middle2 = middles.poll();
-
- if(((float)middle2)!=((float)middle))
- f.shift(middle-middle2, 0);
- }
-
- updateBorders();
- }
-
-
-
- /**
- * Align horizontally the selected figures to the figure in the middle.
- * @since 2.0.0
- */
- public void alignMiddleHorizontally()
- {
- if(size()<2)
- return ;
-
- LinkedList<Double> middles = new LinkedList<Double>();
- double maxY = Double.MIN_VALUE;
- double minY = Double.MAX_VALUE, middle, middle2;
- LaTeXDrawPoint2D pt, pt2;
-
- for(Figure f : figures)
- {
- pt = f.getTheNWRotatedPoint();
- pt2 = f.getTheSERotatedPoint();
-
- if(pt.y<minY)
- minY = pt.y;
-
- if(pt2.y>maxY)
- maxY = pt2.y;
-
- middles.add((pt.y+pt2.y)/2.);
- }
-
- middle = (minY+maxY)/2.;
-
- for(Figure f : figures)
- {
- middle2 = middles.poll();
-
- if(((float)middle2)!=((float)middle))
- f.shift(0, middle-middle2);
- }
-
- updateBorders();
- }
-
-}
+package latexDraw.figures;
+
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Point;
+import java.awt.Shape;
+import java.awt.geom.Rectangle2D;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.util.LinkedList;
+import java.util.Vector;
+
+import latexDraw.psTricks.PSTricksConstants;
+import latexDraw.ui.LaTeXDrawFrame;
+import latexDraw.ui.components.MagneticGrid;
+import latexDraw.util.LaTeXDrawPoint2D;
+
+/**
+ * This file is part of LaTeXDraw<br>
+ * Copyright (c) 2005-2008 Arnaud BLOUIN<br>
+ *<br>
+ * 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
+ * any later version.<br>
+ *<br>
+ * 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.<br>
+ *<br>
+ * 01/20/06<br>
+ * @author Arnaud BLOUIN<br>
+ * @version 2.0.0<br>
+ */
+public class Draw extends Figure
+{
+ private static final long serialVersionUID = 1L;
+
+ /** All the figures which constitute the drawing. */
+ protected Vector<Figure> figures;
+
+ /** Defines the borders of the draw without taking account of the thickness of the figures. */
+ protected LaTeXDrawRectangle minBorders;
+
+ /** True: the figures of the drawing must be drawn (and the method get code get there code. */
+ protected boolean drawFigures;
+
+ /** The point is useful to rotate the selection. */
+ protected transient LaTeXDrawPoint2D formerGravityC = null;
+
+ /** The value by default of the attribute drawFigure */
+ public static final boolean DEFAULT_DRAWFIGURE = false;
+
+
+
+
+ /**
+ * The constructor by default.
+ */
+ public Draw(boolean drawFigures, boolean increaseMeter)
+ {
+ this(null, drawFigures, increaseMeter);
+ }
+
+
+
+ public Draw(Vector<Figure> figs, boolean drawFigures, boolean increaseMeter, boolean cloneFigures)
+ {
+ super(increaseMeter);
+
+ canHaveShadow = true;
+ isResizable = true;
+ isBordersMovable = true;
+ isDashableOrDotable = true;
+ isDoubleBoundaryable = true;
+ this.drawFigures = drawFigures;
+ canBeFilled = true;
+ isCustomizable = true;
+ isThicknessable = true;
+
+ initializeBorders();
+ figures = new Vector<Figure>();
+
+ if(figs!=null)
+ if(cloneFigures)
+ {
+ for(Figure f : figs)
+ if(f!=null)
+ try { addFigure((Figure)f.clone()); }
+ catch(CloneNotSupportedException e) { e.printStackTrace(); }
+ }
+ else
+ for(Figure f : figs)
+ if(f!=null)
+ addFigure(f);
+
+ shape = createShape2D();
+ }
+
+
+
+ public Draw(Vector<Figure> figs, boolean drawFigures, boolean increaseMeter)
+ {
+ this(figs, drawFigures, increaseMeter, false);
+ }
+
+
+
+
+ /**
+ * Initialise the minBorders and the borders (colour, style, ...).
+ */
+ protected void initializeBorders()
+ {
+ if(minBorders==null)
+ minBorders = new LaTeXDrawRectangle(false);
+
+ if(borders==null)
+ borders = new LaTeXDrawRectangle(false);
+
+ borders.setLinesColor(Color.gray);
+ borders.setLineStyle(PSTricksConstants.LINE_DASHED_STYLE);
+ }
+
+
+
+
+
+ /**
+ * Allows to add a figure to the drawing.
+ * @param f The figure to add.
+ * @throws IllegalArgumentException If f is null.
+ */
+ public void addFigure(Figure f)
+ {
+ if(f==null)
+ throw new IllegalArgumentException("f is null.");//$NON-NLS-1$
+
+ f.onRelease();
+ figures.add(f);
+ updateBorders();
+ updateGravityCenter();
+ }
+
+
+
+
+ /**
+ * Allows to add a figure to the drawing at a given position.
+ * @param f The figure to add.
+ * @param index THe position where insert the figure.
+ * @throws IllegalArgumentException If f is null or if the index is bad.
+ */
+ public void addFigure(Figure f, int index)
+ {
+ if(index<0 || (index>=figures.size() && index>0))
+ throw new IllegalArgumentException("Bad index.");//$NON-NLS-1$
+
+ if(f==null)
+ throw new IllegalArgumentException("f is null.");//$NON-NLS-1$
+
+ f.onRelease();
+ figures.add(index, f);
+ updateBorders();
+ updateGravityCenter();
+ }
+
+
+
+
+
+ @Override
+ public synchronized void setOnRotation(boolean on)
+ {
+ super.setOnRotation(on);
+ int i, size=figures.size();
+
+ for(i=0; i<size; i++)
+ figures.elementAt(i).setOnRotation(on);
+
+ if(!on)
+ {
+ borders.rotationAngle = 0;
+ updateBorders();
+ updateGravityCenter();
+ }
+ }
+
+
+
+
+ /**
+ * Allows to remove a figure of the drawing.
+ * @param f The figure to remove.
+ */
+ public void removeFigure(Figure f)
+ {
+ if(f!=null && figures.contains(f))
+ {
+ figures.remove(f);
+ updateBorders();
+ }
+ }
+
+
+ /**
+ * Allows to remove a figure of the drawing.
+ * @param id the position of the figure in the vector.
+ * @exception IllegalArgumentException if the <code>id</code> is invalid.
+ * @return The deleted figure.
+ * @since 1.9.1
+ */
+ public Figure removeFigureAt(int id)
+ {
+ if(id<0 || id>=figures.size())
+ throw new IllegalArgumentException();
+
+ Figure f = figures.remove(id);
+ updateBorders();
+
+ return f;
+ }
+
+
+
+
+ /**
+ * Allows to update the dimension and the position of the borders of the drawing.
+ */
+ public void updateBorders()
+ {
+ if(minBorders==null) initializeBorders();
+ if(borders==null) initializeBorders();
+
+ if(figures.isEmpty())
+ {
+ borders.setFirstPoint(0, 0);
+ borders.setLastPoint(0, 0);
+ minBorders.setFirstPoint(0, 0);
+ minBorders.setLastPoint(0, 0);
+ }
+ else
+ {
+ int size = figures.size(), i;
+ LaTeXDrawPoint2D NW, SE, NW2, SE2;
+ LaTeXDrawPoint2D NWb, SEb, NW2b, SE2b;
+ Figure f = figures.firstElement();
+
+ NW = (LaTeXDrawPoint2D) f.getTheNWBoundPoint().clone();
+ SE = (LaTeXDrawPoint2D) f.getTheSEBoundPoint().clone();
+
+ if(f instanceof Draw)
+ {
+ NWb = (LaTeXDrawPoint2D)((Draw)f).minBorders.getTheNWPoint().clone();
+ SEb = (LaTeXDrawPoint2D)((Draw)f).minBorders.getTheSEPoint().clone();
+ }
+ else
+ {
+ NWb = (LaTeXDrawPoint2D) f.getTheNWPoint().clone();
+ SEb = (LaTeXDrawPoint2D) f.getTheSEPoint().clone();
+ }
+
+ for(i=1; i<size; i++)
+ {
+ f = figures.elementAt(i);
+
+ NW2 = f.getTheNWBoundPoint();
+ SE2 = f.getTheSEBoundPoint();
+
+ if(f instanceof Draw)
+ {
+ NW2b = (LaTeXDrawPoint2D)((Draw)f).minBorders.getTheNWPoint().clone();
+ SE2b = (LaTeXDrawPoint2D)((Draw)f).minBorders.getTheSEPoint().clone();
+ }
+ else
+ {
+ NW2b = (LaTeXDrawPoint2D) f.getTheNWPoint().clone();
+ SE2b = (LaTeXDrawPoint2D) f.getTheSEPoint().clone();
+ }
+
+ if(NW2.x<NW.x) NW.x = NW2.x;
+ if(NW2.y<NW.y) NW.y = NW2.y;
+ if(SE2.x>SE.x) SE.x = SE2.x;
+ if(SE2.y>SE.y) SE.y = SE2.y;
+
+ if(NW2b.x<NWb.x) NWb.x = NW2b.x;
+ if(NW2b.y<NWb.y) NWb.y = NW2b.y;
+ if(SE2b.x>SEb.x) SEb.x = SE2b.x;
+ if(SE2b.y>SEb.y) SEb.y = SE2b.y;
+ }
+
+ borders.setFirstPoint(NW.x, NW.y);
+ borders.setLastPoint(SE);
+ minBorders.setFirstPoint(NWb);
+ minBorders.setLastPoint(SEb);
+ shape = createShape2D();
+ }
+ }
+
+
+
+
+ @Override
+ public void onDragged(Point formerPt, Point newPt) throws Exception
+ {
+ if(formerPt.equals(newPt)) return;
+
+ int i, size = figures.size();
+
+ if(figures.size()==1 && !drawFigures)
+ {
+ figures.firstElement().onDragged(formerPt, newPt);
+ updateBorders();
+ updateGravityCenter();
+ return;
+ }
+
+ if(borders.dSelected!=null)
+ {
+ if(isOnRotation)
+ {
+ double angle = computeRotationAngle(formerPt, newPt);
+
+ rotationAngle+=angle;
+ rotationAngle%=(2*Math.PI);
+
+ if(formerGravityC==null)
+ throw new IllegalArgumentException("beginRotate must be called before to initialise the rotation"); //$NON-NLS-1$
+
+ for(i=0; i<size; i++)
+ figures.elementAt(i).rotate(formerGravityC, angle);
+
+ return ;
+ }
+
+ if((borders.dSelected==borders.dNE || borders.dSelected==borders.dNW ||
+ borders.dSelected==borders.dN) && newPt.y>=borders.dS.getY())
+ return ;
+ if((borders.dSelected==borders.dSE || borders.dSelected==borders.dSW ||
+ borders.dSelected==borders.dS) && newPt.y<=borders.dN.getY())
+ return ;
+ if((borders.dSelected==borders.dSE || borders.dSelected==borders.dNE ||
+ borders.dSelected==borders.dE) && newPt.x<=borders.dW.getX())
+ return ;
+ if((borders.dSelected==borders.dSW || borders.dSelected==borders.dNW ||
+ borders.dSelected==borders.dW) && newPt.x>=borders.dE.getX())
+ return ;
+
+ boolean rescalable;
+ Figure f;
+
+ if(borders.dSelected==borders.dE || borders.dSelected==borders.dNE || borders.dSelected==borders.dSE)
+ {
+
+ double dEx = borders.dE.getX(), dWx = borders.dW.getX();
+ double percent = Math.abs((newPt.x-dWx)/(dEx-dWx));
+ rescalable = true;
+ i=0;
+
+ while(i<size && rescalable)
+ {
+ f = getFigureAt(i);
+ if(f.isResizable())
+ {
+ if(f.isTooSmallToBeRescaled() && dEx>=newPt.x)
+ rescalable = false;
+ }
+ else rescalable = false;
+ i++;
+ }
+
+ // The user must not be able to reduce too much to figure
+ if(rescalable)
+ rescaleX(minBorders.getTheSEPoint().x,
+ minBorders.getTheSEPoint().x+dEx-newPt.x, percent, minBorders);
+ }
+ if(borders.dSelected==borders.dW || borders.dSelected==borders.dNW || borders.dSelected==borders.dSW)
+ {
+ double dEx = borders.dE.getX(), dWx = borders.dW.getX();
+ double percent = Math.abs((newPt.x-dEx)/(dWx-dEx));
+ rescalable = true;
+ i=0;
+
+ while(i<size && rescalable)
+ {
+ f = getFigureAt(i);
+ if(f.isResizable())
+ {
+ if(f.isTooSmallToBeRescaled() && dWx<=newPt.x)
+ rescalable = false;
+ }
+ else rescalable = false;
+ i++;
+ }
+
+ if(rescalable)
+ rescaleX(minBorders.getTheNWPoint().x,
+ minBorders.getTheNWPoint().x+dWx-newPt.x, percent, minBorders);
+ }
+ if(borders.dSelected==borders.dN || borders.dSelected==borders.dNW || borders.dSelected==borders.dNE)
+ {
+ double dNy = borders.dN.getY(), dSy = borders.dS.getY();
+ double percent = Math.abs((newPt.y-dSy)/(dNy-dSy));
+ rescalable = true;
+ i=0;
+
+ while(i<size && rescalable)
+ {
+ f = getFigureAt(i);
+ if(f.isResizable())
+ {
+ if(f.isTooSmallToBeRescaled() && dNy<=newPt.y)
+ rescalable = false;
+ }
+ else rescalable = false;
+ i++;
+ }
+
+ if(rescalable)
+ // The user must not be able to reduce too much to figure
+ rescaleY(minBorders.getTheNWPoint().y,
+ minBorders.getTheNWPoint().y, percent, minBorders);
+ }
+ if(borders.dSelected==borders.dS || borders.dSelected==borders.dSW || borders.dSelected==borders.dSE)
+ {
+ double dNy = borders.dN.getY(), dSy = borders.dS.getY();
+ double percent = Math.abs((newPt.y-dNy)/(dSy-dNy));
+ rescalable = true;
+ i=0;
+
+ while(i<size && rescalable)
+ {
+ f = getFigureAt(i);
+ if(f.isResizable())
+ {
+ if(f.isTooSmallToBeRescaled() && dSy>=newPt.y)
+ rescalable = false;
+ }
+ else rescalable = false;
+ i++;
+ }
+
+ if(rescalable)
+ // The user must not be able to reduce too much to figure
+ rescaleY(minBorders.getTheSEPoint().y,
+ minBorders.getTheSEPoint().y-dSy+newPt.y, percent, minBorders);
+ }
+ }//if(borders.dSelected==null)
+ else
+ for(i=0; i<size; i++)
+ figures.elementAt(i).onDragged(formerPt, newPt);
+
+ updateBorders();
+ updateGravityCenter();
+ }
+
+
+
+
+
+ /**
+ * Allows to know if a figure is in the drawing.
+ * @param f The figure that we want to know if it's in the drawing .
+ * @return True if the figure is in the drawing.
+ */
+ public boolean contains(Figure f)
+ {
+ if(f!=null)
+ return figures.contains(f);
+ return false;
+ }
+
+
+
+
+
+ @Override
+ public void draw(Graphics2D g, Object antiAlias, Object rendering, Object alphaInter, Object colorRendering)
+ {
+ if(drawFigures)
+ {
+ int i, size = size();
+
+ for(i=0; i<size; i++)
+ figures.elementAt(i).draw(g, antiAlias, rendering, alphaInter, colorRendering);
+ }
+
+ if(figures.size()>1 && isSelected && borders!=null)
+ borders.draw(g, antiAlias, rendering, alphaInter, colorRendering);
+ }
+
+
+
+
+
+ /**
+ * Allows to know if there is a figure in the drawing.
+ * @return True if there is at least one figure in the drawing.
+ */
+ public boolean isEmpty()
+ {
+ return figures.isEmpty();
+ }
+
+
+
+
+
+ @Override
+ public boolean isIn(LaTeXDrawPoint2D pt)
+ {
+ int i, size = figures.size();
+ boolean in = false;
+
+ for(i=0; i<size && !in; i++)
+ in = figures.elementAt(i).isIn(pt);
+
+ if(in) return true;
+
+ return borders.isIn(pt);
+ }
+
+
+
+
+
+ /**
+ * Allows to get the figure which contains the point <code>point</code>.
+ * @param pt The point of reference.
+ * @return The figure which contains the point.
+ */
+ public Figure whereIsIt(Point pt)
+ {
+ int i, size = figures.size();
+ boolean here = false;
+
+ for(i=0; i<size && !here; i++)
+ here = figures.elementAt(i).isIn(pt);
+
+ if(here) return figures.elementAt(i-1);
+ return null;
+
+ }
+
+
+
+ /**
+ * Allows to get the figure placed at the position <code>id</code> in the vector <code>Figures</code>.
+ * @param id The position of the figure in the vector Figures.
+ * @return The figure corresponding to the identifier.
+ */
+ public Figure getFigureAt(int id)
+ {
+ if(id<0 || id>=figures.size())
+ throw new ArrayIndexOutOfBoundsException(id);
+
+ return figures.elementAt(id);
+ }
+
+
+
+ /**
+ * Allows to get the number of figures which contains the drawing.
+ * @return The number of figures in the drawing.
+ */
+ public int size()
+ {
+ return figures.size();
+ }
+
+
+
+
+
+ @Override
+ public String getCodePSTricks(DrawBorders drawBorders, float ppc)
+ {
+ int i, size = figures.size();
+ if(drawFigures && size>0)
+ {
+ String code=""; //$NON-NLS-1$
+
+ for(i=0; i<size-1; i++)
+ code+=figures.elementAt(i).getCodePSTricks(drawBorders, ppc)+"\n"; //$NON-NLS-1$
+ code+= figures.lastElement().getCodePSTricks(drawBorders, ppc);
+
+ return code;
+ }
+
+ return null;
+ }
+
+
+
+ @Override
+ public void onClick(Point pt)
+ {
+ super.onClick(pt);
+
+ if(!drawFigures && size()==1)
+ figures.elementAt(0).onClick(pt);
+ }
+
+
+
+ @Override
+ public void onRelease()
+ {
+ super.onRelease();
+
+ int i,size=figures.size();
+
+ for(i=0; i<size; i++)
+ figures.elementAt(i).onRelease();
+ }
+
+
+
+ @Override
+ public void onDelimitorRelease()
+ {
+ super.onDelimitorRelease();
+
+ int i,size=figures.size();
+
+ for(i=0; i<size; i++)
+ figures.elementAt(i).onDelimitorRelease();
+ }
+
+
+
+
+ @Override
+ public void shift(double shiftX, double shiftY)
+ {
+ if(shiftX==0 && shiftY==0) return ;
+
+ for(Figure f: figures)
+ f.shift(shiftX, shiftY);
+
+ updateBorders();
+ updateGravityCenter();
+ }
+
+
+
+ @Override
+ public synchronized void setSelected(boolean state)
+ {
+ super.setSelected(state);
+
+ if(drawFigures || !state)
+ for(Figure f : figures)
+ f.setSelected(false);
+ else
+ if(size()>=1)
+ figures.firstElement().setSelected(size()==1);
+ }
+
+
+
+
+ @Override
+ public synchronized void setRotationAngle(double theta)
+ {
+ double angle = theta - rotationAngle;
+ super.setRotationAngle(theta);
+
+ if(drawFigures)
+ {
+ int i, size = figures.size();
+
+ for(i=0; i<size; i++)
+ figures.elementAt(i).rotate(gravityCenter, angle);
+ }
+
+ borders.setRotationAngle(0);
+ updateBorders();
+ updateGravityCenter();
+ }
+
+
+
+
+ @Override
+ public synchronized void setLastPoint(double x, double y)
+ {
+ updateGravityCenter();
+ }
+
+
+
+
+ @Override
+ public synchronized void setFirstPoint(double x, double y)
+ {
+ updateGravityCenter();
+ }
+
+
+
+ /**
+ * Allows to clear the drawing: remove and unselect all the figures of the vector <code>figures</code>.
+ */
+ public void clear()
+ {
+ setSelected(false);
+ figures.removeAllElements();
+ shape = createShape2D();
+ }
+
+
+
+ @Override
+ public Object clone() throws CloneNotSupportedException
+ {
+ Draw d = (Draw) super.clone();
+ d.drawFigures = drawFigures;
+
+ int i, size = size();
+ d.figures = new Vector<Figure>();
+
+ for(i=0; i<size; i++)
+ d.addFigure((Figure) getFigureAt(i).clone());
+
+ d.borders = (LaTeXDrawRectangle) borders.clone();
+ d.updateBorders();
+ d.updateGravityCenter();
+
+ return d;
+ }
+
+
+
+
+ @Override
+ public void updateGravityCenter()
+ {
+ LaTeXDrawPoint2D nw = new LaTeXDrawPoint2D(Double.MAX_VALUE, Double.MAX_VALUE);
+ LaTeXDrawPoint2D se = new LaTeXDrawPoint2D(Double.MIN_VALUE, Double.MIN_VALUE);
+ LaTeXDrawPoint2D nw2, se2;
+
+ for(Figure f : figures)
+ {
+ nw2 = f.getTheNWRotatedPoint();
+ se2 = f.getTheSERotatedPoint();
+
+ if(nw2.x<nw.x) nw.x = nw2.x;
+ if(nw2.y<nw.y) nw.y = nw2.y;
+ if(se2.x>se.x) se.x = se2.x;
+ if(se2.y>se.y) se.y = se2.y;
+ }
+
+ gravityCenter.x = (nw.x+se.x)/2.;
+ gravityCenter.y = (nw.y+se.y)/2.;
+ }
+
+
+
+
+ @Override
+ public void updateStyleOfDelimitors()
+ {
+ super.updateStyleOfDelimitors();
+
+ for(int i=0, size=figures.size(); i<size; i++)
+ figures.elementAt(i).updateStyleOfDelimitors();
+ }
+
+
+
+
+ @Override
+ public boolean intersected(Rectangle2D.Double r)
+ {
+ boolean inter = false;
+ int i=0, size = figures.size();
+
+ while(!inter && i<size)
+ if(figures.elementAt(i).intersected(r))
+ inter = true;
+ else i++;
+
+ return inter;
+ }
+
+
+
+
+
+ @Override
+ public Shape createShape2D()
+ {
+ return borders.shape;
+ }
+
+
+
+
+
+ @Override
+ public void rescaleX(double formerX, double newX, double percent, LaTeXDrawRectangle bound)
+ {
+ if(percent==1.) return ;
+ if(bound==null) throw new IllegalArgumentException();
+
+ int i, size = figures.size();
+
+ for(i=0; i<size; i++)
+ figures.elementAt(i).rescaleX(formerX, newX, percent, bound);
+
+ updateBorders();
+ }
+
+
+
+
+
+ @Override
+ public void rescaleY(double formerY, double newY, double percent, LaTeXDrawRectangle bound)
+ {
+ if(percent==1.) return ;
+ if(bound==null) throw new IllegalArgumentException();
+
+ int i, size = figures.size();
+
+ for(i=0; i<size; i++)
+ figures.elementAt(i).rescaleY(formerY, newY, percent, bound);
+
+ updateBorders();
+ }
+
+
+
+
+ @SuppressWarnings("unchecked")
+ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException
+ {
+ rotationAngle = ois.readDouble();
+ isSelected = ois.readBoolean();
+ isOnRotation = ois.readBoolean();
+ borders =(LaTeXDrawRectangle) ois.readObject();
+
+ if(LaTeXDrawFrame.getVersionOfFile().compareTo("1.6")<0) //$NON-NLS-1$
+ ois.readDouble();
+ figures = (Vector<Figure>) ois.readObject();
+
+ if(LaTeXDrawFrame.getVersionOfFile().compareTo("1.5")>=0)//$NON-NLS-1$
+ drawFigures = ois.readBoolean();
+ else
+ {
+ ois.readObject();
+ drawFigures = DEFAULT_DRAWFIGURE;
+ }
+
+ updateStyleOfDelimitors();
+ canBeFilled = false;
+ initializeBorders();
+
+ if(linesColor==null)
+ {
+ linesColor = DEFAULT_BORDERS_COL;
+ doubleColor = DEFAULT_DOUBLE_COLOR;
+ interiorColor = DEFAULT_INTERIOR_COL;
+ hatchingColor = DEFAULT_HATCH_COL;
+ gradientEndColor = PSTricksConstants.DEFAULT_GRADIENT_END_COLOR;
+ gradientStartColor = PSTricksConstants.DEFAULT_GRADIENT_START_COLOR;
+ shadowColor = DEFAULT_SHADOW_COLOR;
+ }
+ }
+
+
+
+ /**
+ * @return Returns the drawFigures.
+ */
+ public boolean isDrawFigures()
+ {
+ return drawFigures;
+ }
+
+
+
+
+ /**
+ * @param drawFigures The drawFigures to set.
+ */
+ public synchronized void setDrawFigures(boolean drawFigures)
+ {
+ this.drawFigures = drawFigures;
+ }
+
+
+
+ @Override
+ public Shape createNonRotatedShape2D()
+ {
+ return borders.createNonRotatedShape2D();
+ }
+
+
+
+
+ @Override
+ @Deprecated
+ public void updateShape()
+ {
+ /* The shape is not used by a drawing. */
+ }
+
+
+
+ /**
+ * @return the minBorders.
+ */
+ public LaTeXDrawRectangle getMinBorders()
+ {
+ return minBorders;
+ }
+
+
+
+
+ /**
+ * @param minBorders the minBorders to set.
+ */
+ public void setMinBorders(LaTeXDrawRectangle minBorders)
+ {
+ this.minBorders = minBorders;
+ }
+
+
+
+
+ @Override
+ public boolean isTooSmallToBeRescaled()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+
+
+ @Override
+ public void rotate(LaTeXDrawPoint2D gravityC, double angle)
+ {
+ for(Figure f : figures)
+ f.rotate(gravityC, angle);
+
+ updateBorders();
+ }
+
+
+
+
+ @Override
+ public void mirrorHorizontal(LaTeXDrawPoint2D origin)
+ {
+ for(Figure f : figures)
+ f.mirrorHorizontal(origin);
+
+ updateBorders();
+ updateGravityCenter();
+ }
+
+
+
+
+ @Override
+ public void mirrorVertical(LaTeXDrawPoint2D origin)
+ {
+ for(Figure f : figures)
+ f.mirrorVertical(origin);
+
+ updateBorders();
+ updateGravityCenter();
+ }
+
+
+
+
+ @Override
+ public synchronized LaTeXDrawPoint2D getLastPoint()
+ {
+ return null;
+ }
+
+
+
+
+ /**
+ * @since 1.9
+ * @return The figures of the drawing.
+ */
+ public synchronized Vector<Figure> getFigures()
+ {
+ return figures;
+ }
+
+
+
+
+ @Override
+ public void updateToGrid(MagneticGrid grid)
+ {
+ for(Figure figure : figures)
+ figure.updateToGrid(grid);
+
+ updateBorders();
+ }
+
+
+
+
+ @Override
+ public int getSelectedDelimitorOrientation()
+ {
+ if(size()==1)
+ return getFigureAt(0).getSelectedDelimitorOrientation();
+
+ return borders.getSelectedDelimitorOrientation();
+ }
+
+
+
+ @Override
+ public int hashCode()
+ {
+ return super.hashCode()^5;
+ }
+
+
+
+
+ /**
+ * This method must be called before each rotation of the selection. Initialize the rotation.
+ * @since 1.9
+ */
+ public void beginRotation()
+ {
+ updateGravityCenter();
+ formerGravityC = (LaTeXDrawPoint2D)gravityCenter.clone();
+
+ if(!drawFigures)
+ for(Figure f : figures)
+ if(f instanceof Draw)
+ ((Draw)f).beginRotation();
+ }
+
+
+
+ /**
+ * This method must be called after each rotation of the selection. Deinitialize the rotation.
+ * @since 1.9
+ */
+ public void endRotation()
+ {
+ updateGravityCenter();
+ updateBorders();
+ formerGravityC = null;
+
+ if(!drawFigures)
+ for(Figure f : figures)
+ if(f instanceof Draw)
+ ((Draw)f).endRotation();
+ }
+
+
+ @Override
+ public synchronized float getThickness()
+ {
+ if(figures==null || figures.isEmpty())
+ return super.getThickness();
+
+ return figures.firstElement().getThickness();
+ }
+
+
+
+
+ @Override
+ public synchronized void setThickness(float value)
+ {
+ if(figures!=null)
+ for(Figure f : figures)
+ f.setThickness(value);
+ }
+
+
+
+
+ @Override
+ public synchronized Color getDoubleColor()
+ {
+ if(figures==null || figures.isEmpty())
+ return super.getDoubleColor();
+
+ int i=0, size = figures.size();
+ boolean ok=true;
+
+ while(ok && i<size)
+ if(figures.elementAt(i).isDoubleBoundaryable())
+ ok = false;
+ else
+ i++;
+
+ if(!ok && size>1)
+ return figures.elementAt(i).getDoubleColor();
+
+ return figures.firstElement().getDoubleColor();
+ }
+
+
+
+
+ @Override
+ public synchronized Color getGradientEndColor()
+ {
+ if(figures==null || figures.isEmpty())
+ return super.getGradientEndColor();
+
+ int i=0, size = figures.size();
+ boolean ok=true;
+
+ while(ok && i<size)
+ if(figures.elementAt(i).canBeHatched())
+ ok = false;
+ else
+ i++;
+
+ if(!ok && size>1)
+ return figures.elementAt(i).getGradientEndColor();
+
+ return figures.firstElement().getGradientEndColor();
+ }
+
+
+
+
+ @Override
+ public synchronized Color getGradientStartColor()
+ {
+ if(figures==null || figures.isEmpty())
+ return super.getGradientStartColor();
+
+ int i=0, size = figures.size();
+ boolean ok=true;
+
+ while(ok && i<size)
+ if(figures.elementAt(i).canBeHatched())
+ ok = false;
+ else
+ i++;
+
+ if(!ok && size>1)
+ return figures.elementAt(i).getGradientStartColor();
+
+ return figures.firstElement().getGradientStartColor();
+ }
+
+
+
+
+ @Override
+ public synchronized Color getHatchingColor()
+ {
+ if(figures==null || figures.isEmpty())
+ return super.getHatchingColor();
+
+ int i=0, size = figures.size();
+ boolean ok=true;
+
+ while(ok && i<size)
+ if(figures.elementAt(i).canBeHatched())
+ ok = false;
+ else
+ i++;
+
+ if(!ok && size>1)
+ return figures.elementAt(i).getHatchingColor();
+
+ return figures.firstElement().getHatchingColor();
+ }
+
+
+
+
+ @Override
+ public synchronized String getHatchingStyle()
+ {
+ if(figures==null || figures.isEmpty())
+ return super.getHatchingStyle();
+
+ int i=0, size = figures.size();
+ boolean ok=true;
+
+ while(ok && i<size)
+ if(figures.elementAt(i).canBeHatched())
+ ok = false;
+ else
+ i++;
+
+ if(!ok && size>1)
+ return figures.elementAt(i).getHatchingStyle();
+
+ return figures.firstElement().getHatchingStyle();
+ }
+
+
+
+
+ @Override
+ public synchronized Color getInteriorColor()
+ {
+ if(figures==null || figures.isEmpty())
+ return super.getInteriorColor();
+
+ int i=0, size = figures.size();
+ boolean ok=true;
+
+ while(ok && i<size)
+ if(figures.elementAt(i).canBeFilled())
+ ok = false;
+ else
+ i++;
+
+ if(!ok && size>1)
+ return figures.elementAt(i).getInteriorColor();
+
+ return figures.firstElement().getInteriorColor();
+ }
+
+
+
+
+ @Override
+ public synchronized Color getLinesColor()
+ {
+ if(figures==null || figures.isEmpty())
+ return super.getLinesColor();
+
+ return figures.firstElement().getLinesColor();
+ }
+
+
+
+
+ @Override
+ public synchronized String getLineStyle()
+ {
+ if(figures==null || figures.isEmpty())
+ return super.getLineStyle();
+
+ int i=0, size = figures.size();
+ boolean ok=true;
+
+ while(ok && i<size)
+ if(figures.elementAt(i).isDashableOrDotable())
+ ok = false;
+ else
+ i++;
+
+ if(!ok && size>1)
+ return figures.elementAt(i).getLineStyle();
+
+ return figures.firstElement().getLineStyle();
+ }
+
+
+
+
+ @Override
+ public synchronized boolean hasDoubleBoundary()
+ {
+ if(figures==null || figures.isEmpty())
+ return super.hasDoubleBoundary();
+
+ int i=0, size = figures.size();
+ boolean ok=true;
+
+ while(ok && i<size)
+ if(figures.elementAt(i).isDoubleBoundaryable())
+ ok = false;
+ else
+ i++;
+
+ if(!ok && size>1)
+ return figures.elementAt(i).hasDoubleBoundary();
+
+ return figures.firstElement().hasDoubleBoundary();
+ }
+
+
+
+
+ @Override
+ public synchronized boolean hasShadow()
+ {
+ if(figures==null || figures.isEmpty())
+ return super.hasShadow();
+
+ int i=0, size = figures.size();
+ boolean ok=true;
+
+ while(ok && i<size)
+ if(figures.elementAt(i).canHaveShadow())
+ ok = false;
+ else
+ i++;
+
+ if(!ok && size>1)
+ return figures.elementAt(i).hasShadow();
+
+ return figures.firstElement().hasShadow();
+ }
+
+
+
+
+ @Override
+ public synchronized boolean isFilled()
+ {
+ if(figures==null || figures.isEmpty())
+ return super.isFilled();
+
+ int i=0, size = figures.size();
+ boolean ok=true;
+
+ while(ok && i<size)
+ if(figures.elementAt(i).canBeFilled())
+ ok = false;
+ else
+ i++;
+
+ if(!ok && size>1)
+ return figures.elementAt(i).isFilled();
+
+ return figures.firstElement().isFilled();
+ }
+
+
+
+ @Override
+ public String toString()
+ {
+ String str = "["; //$NON-NLS-1$
+
+ for(int i=0, size=figures.size()-1; i<size; i++)
+ str += figures.elementAt(i).getClass().getName() + '(' + figures.elementAt(i).getNumber() + "), " ; //$NON-NLS-1$
+
+ if(!figures.isEmpty())
+ str += figures.lastElement().getClass().getCanonicalName() + '(' + figures.lastElement().getNumber() + ")" ; //$NON-NLS-1$
+
+ return str + ']';
+ }
+
+
+
+
+ @Override
+ public synchronized void setDoubleColor(Color doublecolor)
+ {
+ if(figures!=null)
+ for(Figure f : figures)
+ if(f.isDoubleBoundaryable())
+ f.setDoubleColor(doublecolor);
+ }
+
+
+
+
+ @Override
+ public synchronized void setGradientEndColor(Color gradientEndColor)
+ {
+ if(figures!=null)
+ for(Figure f : figures)
+ if(f.canBeFilled())
+ f.setGradientEndColor(gradientEndColor);
+ }
+
+
+
+
+ @Override
+ public synchronized void setGradientStartColor(Color gradientStartColor)
+ {
+ if(figures!=null)
+ for(Figure f : figures)
+ if(f.canBeFilled())
+ f.setGradientStartColor(gradientStartColor);
+ }
+
+
+
+
+ @Override
+ public synchronized void setHasDoubleBoundary(boolean hasDoubleBoundary)
+ {
+ if(figures!=null)
+ for(Figure f : figures)
+ if(f.isDoubleBoundaryable())
+ f.setHasDoubleBoundary(hasDoubleBoundary);
+ }
+
+
+
+
+ @Override
+ public synchronized void setHasShadow(boolean hasShadow)
+ {
+ if(figures!=null)
+ for(Figure f : figures)
+ if(f.canHaveShadow())
+ f.setHasShadow(hasShadow);
+ }
+
+
+
+
+ @Override
+ public synchronized void setHatchingColor(Color color)
+ {
+ if(figures!=null)
+ for(Figure f : figures)
+ if(f.canBeHatched())
+ f.setHatchingColor(color);
+ }
+
+
+
+
+ @Override
+ public synchronized void setHatchingStyle(String style)
+ {
+ if(figures!=null)
+ for(Figure f : figures)
+ if(f.canBeHatched())
+ f.setHatchingStyle(style);
+ }
+
+
+
+
+ @Override
+ public synchronized void setInteriorColor(Color c)
+ {
+ if(figures!=null)
+ for(Figure f : figures)
+ if(f.canBeFilled())
+ f.setInteriorColor(c);
+ }
+
+
+
+
+ @Override
+ public synchronized void setLinesColor(Color c)
+ {
+ if(figures!=null)
+ for(Figure f : figures)
+ f.setLinesColor(c);
+ }
+
+
+
+
+ @Override
+ public synchronized void setLineStyle(String style)
+ {
+ if(figures!=null)
+ for(Figure f : figures)
+ if(f.isDashableOrDotable())
+ f.setLineStyle(style);
+ }
+
+
+
+
+ @Override
+ public synchronized void setShadowColor(Color shadowColor)
+ {
+ if(figures!=null)
+ for(Figure f : figures)
+ if(f.canHaveShadow())
+ f.setShadowColor(shadowColor);
+ }
+
+
+
+ @Override
+ public synchronized void setIsFilled(boolean filled)
+ {
+ if(figures!=null)
+ for(Figure f : figures)
+ if(f.canBeFilled())
+ f.setIsFilled(filled);
+ }
+
+
+
+
+ /**
+ * Distributes vertically at equal distance between the bottom sides of the selected figures.
+ * @since 2.0.0
+ */
+ public void distributeVertBottom()
+ {
+ if(size()<2)
+ return ;
+
+ LinkedList<Figure> sortedF = new LinkedList<Figure>();
+ LinkedList<Double> ses = new LinkedList<Double>();
+ LaTeXDrawPoint2D pt;
+ boolean ok;
+ double gap;
+ int i, size;
+
+ for(Figure f : figures)
+ {
+ pt = f.getTheSERotatedPoint();
+ ok = true;
+
+ for(i=0, size=sortedF.size(); i<size && ok; i++)
+ if(pt.y<ses.get(i))
+ ok = false;
+
+ if(ok)
+ {
+ sortedF.addLast(f);
+ ses.addLast(pt.y);
+ }
+ else
+ {
+ sortedF.add(i-1, f);
+ ses.add(i-1, pt.y);
+ }
+ }
+
+ gap = (ses.getLast()-ses.getFirst())/(size()-1);
+ size = sortedF.size()-1;
+
+ for(i=1; i<size; i++)
+ sortedF.get(i).shift(0, (ses.getFirst()+i*gap)-ses.get(i));
+
+ updateBorders();
+ }
+
+
+
+ /**
+ * Distributes vertically at equal distance between the middle of the selected figures.
+ * @since 2.0.0
+ */
+ public void distributeVertMiddle()
+ {
+ LinkedList<Figure> sortedF = new LinkedList<Figure>();
+ LinkedList<Double> gcs = new LinkedList<Double>();
+ LaTeXDrawPoint2D pt;
+ int i, size;
+ boolean ok;
+ double gap;
+
+ for(Figure f : figures)
+ {
+ pt = f.getGravityCenter();
+ ok = true;
+
+ for(i=0, size=sortedF.size(); i<size && ok; i++)
+ if(pt.y<gcs.get(i))
+ ok = false;
+
+ if(ok)
+ {
+ sortedF.addLast(f);
+ gcs.addLast(pt.y);
+ }
+ else
+ {
+ sortedF.add(i-1, f);
+ gcs.add(i-1, pt.y);
+ }
+ }
+
+ gap = (gcs.getLast()-gcs.getFirst())/(size()-1);
+ size = sortedF.size()-1;
+
+ for(i=1; i<size; i++)
+ sortedF.get(i).shift(0, (gcs.getFirst()+i*gap)-gcs.get(i));
+
+ updateBorders();
+ }
+
+
+
+ /**
+ * Distributes vertically at equal distance between the top sides of the selected figures.
+ * @since 2.0.0
+ */
+ public void distributeVertTop()
+ {
+ if(size()<2)
+ return ;
+
+ LinkedList<Figure> sortedF = new LinkedList<Figure>();
+ LinkedList<Double> nws = new LinkedList<Double>();
+ LaTeXDrawPoint2D pt;
+ int i, size;
+ boolean ok;
+ double gap;
+
+ for(Figure f : figures)
+ {
+ pt = f.getTheNWRotatedPoint();
+ ok = true;
+
+ for(i=0, size=sortedF.size(); i<size && ok; i++)
+ if(pt.y<nws.get(i))
+ ok = false;
+
+ if(ok)
+ {
+ sortedF.addLast(f);
+ nws.addLast(pt.y);
+ }
+ else
+ {
+ sortedF.add(i-1, f);
+ nws.add(i-1, pt.y);
+ }
+ }
+
+ gap = (nws.getLast()-nws.getFirst())/(size()-1);
+ size = sortedF.size()-1;
+
+ for(i=1; i<size; i++)
+ sortedF.get(i).shift(0, (nws.getFirst()+i*gap)-nws.get(i));
+
+ updateBorders();
+ }
+
+
+
+ /**
+ * Distributes horizontally at equal distance between the selected figures.
+ * @since 2.0.0
+ */
+ public void distributeVertEqual()
+ {
+ if(size()<2)
+ return ;
+
+ LinkedList<Figure> sortedF = new LinkedList<Figure>();
+ LinkedList<Double> tops = new LinkedList<Double>();
+ LinkedList<Double> bots = new LinkedList<Double>();
+ LaTeXDrawPoint2D pt;
+ int i, size;
+ boolean ok;
+ double gap;
+
+ for(Figure f : figures)
+ {
+ pt = f.getTheNWRotatedPoint();
+
+ ok = true;
+ for(i=0, size=tops.size(); i<size && ok; i++)
+ if(pt.y<tops.get(i))
+ ok = false;
+
+ if(ok)
+ {
+ sortedF.addLast(f);
+ tops.addLast(pt.y);
+ bots.addLast(f.getTheSERotatedPoint().y);
+ }
+ else
+ {
+ sortedF.add(i-1, f);
+ tops.add(i-1, pt.y);
+ bots.add(i-1, f.getTheSERotatedPoint().y);
+ }
+ }
+
+ gap = tops.getLast() - bots.getFirst();
+ size = sortedF.size()-1;
+
+ for(i=1; i<size; i++)
+ gap -= bots.get(i) - tops.get(i);
+
+ gap/=size;
+
+ for(i=1; i<size; i++)
+ sortedF.get(i).shift(0, (sortedF.get(i-1).getTheSERotatedPoint().y + gap) - tops.get(i));
+
+ updateBorders();
+ }
+
+
+
+ /**
+ * Distributes vertically at equal distance between the left sides of the selected figures.
+ * @since 2.0.0
+ */
+ public void distributeHorizLeft()
+ {
+ if(size()<2)
+ return ;
+
+ LinkedList<Figure> sortedF = new LinkedList<Figure>();
+ LinkedList<Double> nws = new LinkedList<Double>();
+ LaTeXDrawPoint2D pt;
+ int i, size;
+ boolean ok;
+ double gap;
+
+ for(Figure f : figures)
+ {
+ pt = f.getTheNWRotatedPoint();
+ ok = true;
+
+ for(i=0, size=sortedF.size(); i<size && ok; i++)
+ if(pt.x<nws.get(i))
+ ok = false;
+
+ if(ok)
+ {
+ sortedF.addLast(f);
+ nws.addLast(pt.x);
+ }
+ else
+ {
+ sortedF.add(i-1, f);
+ nws.add(i-1, pt.x);
+ }
+ }
+
+ gap = (nws.getLast()-nws.getFirst())/(size()-1);
+ size = sortedF.size()-1;
+
+ for(i=1; i<size; i++)
+ sortedF.get(i).shift((nws.getFirst()+i*gap)-nws.get(i), 0);
+
+ updateBorders();
+ }
+
+
+
+ /**
+ * Distributes vertically at equal distance between the middle of the selected figures.
+ * @since 2.0.0
+ */
+ public void distributeHorizMiddle()
+ {
+ if(size()<2)
+ return ;
+
+ LinkedList<Figure> sortedF = new LinkedList<Figure>();
+ LinkedList<Double> gcs = new LinkedList<Double>();
+ LaTeXDrawPoint2D pt;
+ int i, size;
+ boolean ok;
+ double gap;
+
+ for(Figure f : figures)
+ {
+ pt = f.getGravityCenter();
+ ok = true;
+
+ for(i=0, size=sortedF.size(); i<size && ok; i++)
+ if(pt.x<gcs.get(i))
+ ok = false;
+
+ if(ok)
+ {
+ sortedF.addLast(f);
+ gcs.addLast(pt.x);
+ }
+ else
+ {
+ sortedF.add(i-1, f);
+ gcs.add(i-1, pt.x);
+ }
+ }
+
+ gap = (gcs.getLast()-gcs.getFirst())/(size()-1);
+ size = sortedF.size()-1;
+
+ for(i=1; i<size; i++)
+ sortedF.get(i).shift((gcs.getFirst()+i*gap)-gcs.get(i), 0);
+
+ updateBorders();
+ }
+
+
+
+ /**
+ * Distributes vertically at equal distance between the right sides of the selected figures.
+ * @since 2.0.0
+ */
+ public void distributeHorizRight()
+ {
+ if(size()<2)
+ return ;
+
+ LinkedList<Figure> sortedF = new LinkedList<Figure>();
+ LinkedList<Double> ses = new LinkedList<Double>();
+ LaTeXDrawPoint2D pt;
+ int i, size;
+ boolean ok;
+ double gap;
+
+ for(Figure f : figures)
+ {
+ pt = f.getTheSERotatedPoint();
+
+ ok = true;
+ for(i=0, size=sortedF.size(); i<size && ok; i++)
+ if(pt.x<ses.get(i))
+ ok = false;
+
+ if(ok)
+ {
+ sortedF.addLast(f);
+ ses.addLast(pt.x);
+ }
+ else
+ {
+ sortedF.add(i-1, f);
+ ses.add(i-1, pt.x);
+ }
+ }
+
+ gap = (ses.getLast()-ses.getFirst())/(size()-1);
+ size = sortedF.size()-1;
+
+ for(i=1; i<size; i++)
+ sortedF.get(i).shift((ses.getFirst()+i*gap)-ses.get(i), 0);
+
+ updateBorders();
+ }
+
+
+
+ /**
+ * Distributes vertically at equal distance between the selected figures.
+ * @since 2.0.0
+ */
+ public void distributeHorizEqual()
+ {
+ if(size()<2)
+ return ;
+
+ LinkedList<Figure> sortedF = new LinkedList<Figure>();
+ LinkedList<Double> rights = new LinkedList<Double>();
+ LinkedList<Double> lefts = new LinkedList<Double>();
+ LaTeXDrawPoint2D pt;
+ int i, size;
+ boolean ok;
+ double gap;
+
+ for(Figure f : figures)
+ {
+ pt = f.getTheNWRotatedPoint();
+ ok = true;
+
+ for(i=0, size=lefts.size(); i<size && ok; i++)
+ if(pt.x<lefts.get(i))
+ ok = false;
+
+ if(ok)
+ {
+ sortedF.addLast(f);
+ lefts.addLast(pt.x);
+ rights.addLast(f.getTheSERotatedPoint().x);
+ }
+ else
+ {
+ sortedF.add(i-1, f);
+ lefts.add(i-1, pt.x);
+ rights.add(i-1, f.getTheSERotatedPoint().x);
+ }
+ }
+
+ gap = lefts.getLast() - rights.getFirst();
+ size = sortedF.size()-1;
+
+ for(i=1; i<size; i++)
+ gap -= rights.get(i) - lefts.get(i);
+
+ gap/=size;
+
+ for(i=1; i<size; i++)
+ sortedF.get(i).shift((sortedF.get(i-1).getTheSERotatedPoint().x + gap) - lefts.get(i), 0);
+ }
+
+
+
+
+ /**
+ * Align the selected figures to the figure on the left.
+ * @since 2.0.0
+ */
+ public void alignLeft()
+ {
+ if(size()<2)
+ return ;
+
+ LinkedList<LaTeXDrawPoint2D> nws = new LinkedList<LaTeXDrawPoint2D>();
+ double minX = Double.MAX_VALUE;
+ LaTeXDrawPoint2D pt;
+
+ for(Figure f : figures)
+ {
+ pt = f.getTheNWRotatedPoint();
+ nws.add(pt);
+
+ if(pt.x<minX)
+ minX = pt.x;
+ }
+
+ for(Figure f : figures)
+ {
+ pt = nws.poll();
+
+ if(((float)minX)!=((float)pt.x))
+ f.shift(minX-pt.x, 0);
+ }
+
+ updateBorders();
+ }
+
+
+
+
+ /**
+ * Align the selected figures to the figure on the right.
+ * @since 2.0.0
+ */
+ public void alignRight()
+ {
+ if(size()<2)
+ return ;
+
+ LinkedList<LaTeXDrawPoint2D> ses = new LinkedList<LaTeXDrawPoint2D>();
+ double maxX = Double.MIN_VALUE;
+ LaTeXDrawPoint2D pt;
+
+ for(Figure f : figures)
+ {
+ pt = f.getTheSERotatedPoint();
+ ses.add(pt);
+
+ if(pt.x>maxX)
+ maxX = pt.x;
+ }
+
+ for(Figure f : figures)
+ {
+ pt = ses.poll();
+
+ if(((float)maxX)!=((float)pt.x))
+ f.shift(maxX-pt.x, 0);
+ }
+
+ updateBorders();
+ }
+
+
+
+ /**
+ * Align the selected figures to the figure on the top.
+ * @since 2.0.0
+ */
+ public void alignTop()
+ {
+ if(size()<2)
+ return ;
+
+ LinkedList<LaTeXDrawPoint2D> nws = new LinkedList<LaTeXDrawPoint2D>();
+ double minY = Double.MAX_VALUE;
+ LaTeXDrawPoint2D pt;
+
+ for(Figure f : figures)
+ {
+ pt = f.getTheNWRotatedPoint();
+ nws.add(pt);
+
+ if(pt.y<minY)
+ minY = pt.y;
+ }
+
+ for(Figure f : figures)
+ {
+ pt = nws.poll();
+
+ if(((float)minY)!=((float)pt.x))
+ f.shift(0, minY-pt.y);
+ }
+
+ updateBorders();
+ }
+
+
+
+ /**
+ * Align the selected figures to the figure on the bottom.
+ * @since 2.0.0
+ */
+ public void alignBottom()
+ {
+ if(size()<2)
+ return ;
+
+ LinkedList<LaTeXDrawPoint2D> ses = new LinkedList<LaTeXDrawPoint2D>();
+ double maxY = Double.MIN_VALUE;
+ LaTeXDrawPoint2D pt;
+
+ for(Figure f : figures)
+ {
+ pt = f.getTheSERotatedPoint();
+ ses.add(pt);
+
+ if(pt.y>maxY)
+ maxY = pt.y;
+ }
+
+ for(Figure f : figures)
+ {
+ pt = ses.poll();
+
+ if(((float)maxY)!=((float)pt.y))
+ f.shift(0, maxY-pt.y);
+ }
+
+ updateBorders();
+ }
+
+
+
+ /**
+ * Align vertically the selected figures to the figure in the middle.
+ * @since 2.0.0
+ */
+ public void alignMiddleVertically()
+ {
+ if(size()<2)
+ return ;
+
+ LinkedList<Double> middles = new LinkedList<Double>();
+ double maxX = Double.MIN_VALUE;
+ double minX = Double.MAX_VALUE, middle, middle2;
+ LaTeXDrawPoint2D pt, pt2;
+
+ for(Figure f : figures)
+ {
+ pt = f.getTheNWRotatedPoint();
+ pt2 = f.getTheSERotatedPoint();
+
+ if(pt.x<minX)
+ minX = pt.x;
+
+ if(pt2.x>maxX)
+ maxX = pt2.x;
+
+ middles.add((pt.x+pt2.x)/2.);
+ }
+
+ middle = (minX+maxX)/2.;
+
+ for(Figure f : figures)
+ {
+ middle2 = middles.poll();
+
+ if(((float)middle2)!=((float)middle))
+ f.shift(middle-middle2, 0);
+ }
+
+ updateBorders();
+ }
+
+
+
+ /**
+ * Align horizontally the selected figures to the figure in the middle.
+ * @since 2.0.0
+ */
+ public void alignMiddleHorizontally()
+ {
+ if(size()<2)
+ return ;
+
+ LinkedList<Double> middles = new LinkedList<Double>();
+ double maxY = Double.MIN_VALUE;
+ double minY = Double.MAX_VALUE, middle, middle2;
+ LaTeXDrawPoint2D pt, pt2;
+
+ for(Figure f : figures)
+ {
+ pt = f.getTheNWRotatedPoint();
+ pt2 = f.getTheSERotatedPoint();
+
+ if(pt.y<minY)
+ minY = pt.y;
+
+ if(pt2.y>maxY)
+ maxY = pt2.y;
+
+ middles.add((pt.y+pt2.y)/2.);
+ }
+
+ middle = (minY+maxY)/2.;
+
+ for(Figure f : figures)
+ {
+ middle2 = middles.poll();
+
+ if(((float)middle2)!=((float)middle))
+ f.shift(0, middle-middle2);
+ }
+
+ updateBorders();
+ }
+
+}
diff --git a/latexDraw/figures/Figure.java b/latexDraw/figures/Figure.java
index c63e1b0..8b1ae5d 100644
--- a/latexDraw/figures/Figure.java
+++ b/latexDraw/figures/Figure.java
@@ -9,7 +9,6 @@ import java.awt.geom.GeneralPath;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
-import java.awt.image.BufferedImage;
import java.io.Serializable;
import javax.swing.JLabel;
@@ -1196,50 +1195,39 @@ public abstract class Figure implements Serializable, Cloneable, Drawable
return;
}
+ Shape oldClip = g.getClip();
+ Rectangle2D bounds = s.getBounds2D();
+ g.setClip(s);
- double val = hatchingWidth+hatchingSep;
- Paint paintOld = g.getPaint();
- BufferedImage bi = new BufferedImage((int)val, (int)val, BufferedImage.TYPE_INT_ARGB);
- Graphics2D gi = bi.createGraphics();
-
if(isFilled() || hasShadow())
{
- gi.setColor(interiorColor);
- gi.fillRect(0, 0, (int)val, (int)val);
+ g.setColor(interiorColor);
+ g.fill(bounds);
}
- if(!isHatched()) return;
-
- gi.setStroke(new BasicStroke(hatchingWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER));
- gi.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antiAlias);
- gi.setRenderingHint(RenderingHints.KEY_RENDERING, rendering);
- gi.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, alphaInter);
- gi.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, colorRendering);
- gi.setColor(hatchingColor);
-
- if(hatchingStyle.equals(PSTricksConstants.TOKEN_FILL_CROSSHATCH) ||
- hatchingStyle.equals(PSTricksConstants.TOKEN_FILL_CROSSHATCH_F))
+ if(isHatched())
{
- gi.draw(new Line2D.Double(-val/2, val/2, val+val/2, val/2));
- gi.draw(new Line2D.Double(val/2, -val/2, val/2, val+val/2));
+ Stroke oldStroke = g.getStroke();
+
+ if(hatchingStyle.equals(PSTricksConstants.TOKEN_FILL_VLINES) ||
+ hatchingStyle.equals(PSTricksConstants.TOKEN_FILL_VLINES_F))
+ paintHatchings2(g, hatchingAngle, bounds);
+ else
+ if(hatchingStyle.equals(PSTricksConstants.TOKEN_FILL_HLINES) ||
+ hatchingStyle.equals(PSTricksConstants.TOKEN_FILL_HLINES_F))
+ paintHatchings2(g, hatchingAngle>0?hatchingAngle-Math.PI/2.:hatchingAngle+Math.PI/2., bounds);
+ else
+ if(hatchingStyle.equals(PSTricksConstants.TOKEN_FILL_CROSSHATCH) ||
+ hatchingStyle.equals(PSTricksConstants.TOKEN_FILL_CROSSHATCH_F))
+ {
+ paintHatchings2(g, hatchingAngle, bounds);
+ paintHatchings2(g, hatchingAngle>0?hatchingAngle-Math.PI/2.:hatchingAngle+Math.PI/2., bounds);
+ }
+
+ g.setStroke(oldStroke);
}
- else
- if(hatchingStyle.equals(PSTricksConstants.TOKEN_FILL_HLINES) ||
- hatchingStyle.equals(PSTricksConstants.TOKEN_FILL_HLINES_F))
- gi.draw(new Line2D.Double(-val/2, val/2, val+val/2, val/2));
- else
- gi.draw(new Line2D.Double(val/2, -val/2, val/2, val+val/2));
-
- TexturePaint blacklines = new TexturePaint(bi, new Rectangle2D.Double(0, 0, (int)val, (int)val));
- g.setPaint(blacklines);
- g.fill(p);
- g.setPaint(paintOld);
- blacklines = null;
- gi.dispose();
- bi.flush();
- gi = null;
- bi = null;
+ g.setClip(oldClip);
}
else
if(isFilled)
@@ -1254,7 +1242,102 @@ public abstract class Figure implements Serializable, Cloneable, Drawable
g.setColor(formerColor);
}
-
+
+
+ /**
+ * Paints the hatchings.
+ * @param g The graphics to paint.
+ * @param angle2 The angle of the hatchings (in radian).
+ * @param clip The clip box.
+ */
+ private void paintHatchings2(Graphics2D g, double angle, Rectangle2D clip)
+ {
+ if(g==null || clip==null)
+ return ;
+
+ double angle2 = angle%(Math.PI*2.);
+ float halphPI = (float)(Math.PI/2.);
+
+ if(angle2>0)
+ {
+ if((float)angle2>3f*halphPI)
+ angle2 = angle2-Math.PI*2.;
+ else
+ if((float)angle2>halphPI)
+ angle2 = angle2-Math.PI;
+ }
+ else
+ if((float)angle2<-3f*halphPI)
+ angle2 = angle2+Math.PI*2.;
+ else
+ if((float)angle2<-halphPI)
+ angle2 = angle2+Math.PI;
+
+ Line2D.Double line = new Line2D.Double();
+ double val = hatchingWidth+hatchingSep;
+ float fAngle = (float)angle2;
+
+ g.setStroke(new BasicStroke(hatchingWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER));
+ g.setPaint(getHatchingColor());
+
+ if(fAngle==0f)
+ {
+ line.y1 = clip.getMinY();
+ line.y2 = clip.getMaxY();
+ double maxX = clip.getMaxX();
+
+ for(double x = clip.getMinX(); x<maxX; x+=val)
+ {
+ line.x1 = line.x2 = x;
+ g.draw(line);
+ }
+ }
+ else
+ if(fAngle==halphPI || fAngle==-halphPI)
+ {
+ line.x1 = clip.getMinX();
+ line.x2 = clip.getMaxX();
+ double maxY = clip.getMaxY();
+
+ for(double y = clip.getMinY(); y<maxY; y+=val)
+ {
+ line.y1 = line.y2 = y;
+ g.draw(line);
+ }
+ }
+ else
+ {
+ double incX = val/Math.cos(angle2);
+ double incY = val/Math.sin(angle2);
+ double maxX;
+
+ if(fAngle>0f)
+ {
+ line.y1 = clip.getMinY();
+ maxX = clip.getMaxX() + (clip.getMaxY()-(clip.getMinY()<0?clip.getMinY():0)) * Math.tan(angle2);
+ }
+ else
+ {
+ line.y1 = clip.getMaxY();
+ maxX = clip.getMaxX() - clip.getMaxY() * Math.tan(angle2);
+ }
+
+ line.x1 = clip.getMinX();
+ line.x2 = line.x1;
+ line.y2 = line.y1;
+
+ if(((float)incX)<=0f)
+ return ;
+
+ while(line.x2 < maxX)
+ {
+ line.x2 += incX;
+ line.y1 += incY;
+ g.draw(line);
+ }
+ }
+ }
+
/**
@@ -2061,7 +2144,7 @@ public abstract class Figure implements Serializable, Cloneable, Drawable
public synchronized void setHatchingAngle(double hatchingAngle)
{
if(!Double.isInfinite(hatchingAngle) && !Double.isNaN(hatchingAngle))
- this.hatchingAngle = hatchingAngle;
+ this.hatchingAngle = hatchingAngle%(Math.PI*2.);
}
@@ -2402,7 +2485,7 @@ public abstract class Figure implements Serializable, Cloneable, Drawable
str += "*"; //$NON-NLS-1$
str += ",hatchwidth=" + (getHatchingWidth()/ppc) + ",hatchangle=" + //$NON-NLS-1$ //$NON-NLS-2$
- 0;//(float)Math.toDegrees(hatchingAngle);
+ (float)Math.toDegrees(hatchingAngle);
if(((float)hatchingSep)!=((float)DEFAULT_HATCH_SEP))
str+=",hatchsep="+(float)(hatchingSep/PPC); //$NON-NLS-1$
diff --git a/latexDraw/generators/svg/LShapeSVGGenerator.java b/latexDraw/generators/svg/LShapeSVGGenerator.java
index c3f9786..d045085 100644
--- a/latexDraw/generators/svg/LShapeSVGGenerator.java
+++ b/latexDraw/generators/svg/LShapeSVGGenerator.java
@@ -9,9 +9,13 @@ import java.text.ParseException;
import latexDraw.figures.ArrowHead;
import latexDraw.figures.Figure;
+import latexDraw.figures.LaTeXDrawRectangle;
import latexDraw.figures.Line;
import latexDraw.parsers.svg.*;
import latexDraw.parsers.svg.elements.*;
+import latexDraw.parsers.svg.elements.path.SVGPathSegLineto;
+import latexDraw.parsers.svg.elements.path.SVGPathSegList;
+import latexDraw.parsers.svg.elements.path.SVGPathSegMoveto;
import latexDraw.parsers.svg.parsers.SVGLengthParser;
import latexDraw.parsers.svg.parsers.URIReferenceParser;
import latexDraw.psTricks.PSTricksConstants;
@@ -607,55 +611,36 @@ public abstract class LShapeSVGGenerator
String id = SVGElements.SVG_PATTERN + shape.getNumber();
Element hatch = doc.createElement(SVGElements.SVG_PATTERN);
Element gPath = doc.createElement(SVGElements.SVG_G);
- int lgth = (int)((shape.getHatchingSep()+shape.getHatchingWidth())*10);
+ LaTeXDrawPoint2D max = shape.getTheSENonRotatedBoundPoint();
root.setAttribute(SVGAttributes.SVG_FILL, "url(#" + id + ')');//$NON-NLS-1$
hatch.setAttribute(LaTeXDrawNamespace.LATEXDRAW_NAMESPACE+':'+LaTeXDrawNamespace.XML_TYPE, shape.getHatchingStyle());
+ hatch.setAttribute(LaTeXDrawNamespace.LATEXDRAW_NAMESPACE+':'+LaTeXDrawNamespace.XML_ROTATION,
+ String.valueOf(shape.getHatchingAngle()));
+ hatch.setAttribute(LaTeXDrawNamespace.LATEXDRAW_NAMESPACE+':'+LaTeXDrawNamespace.XML_SIZE,
+ String.valueOf(shape.getHatchingSep()));
hatch.setAttribute(SVGAttributes.SVG_PATTERN_UNITS, SVGAttributes.SVG_UNITS_VALUE_USR);
hatch.setAttribute(SVGAttributes.SVG_ID, id);
- hatch.setAttribute(SVGAttributes.SVG_X, "0");//$NON-NLS-1$
- hatch.setAttribute(SVGAttributes.SVG_Y, "0");//$NON-NLS-1$
- hatch.setAttribute(SVGAttributes.SVG_WIDTH, String.valueOf(lgth));
- hatch.setAttribute(SVGAttributes.SVG_HEIGHT, String.valueOf(lgth));
+ hatch.setAttribute(SVGAttributes.SVG_X, "0");
+ hatch.setAttribute(SVGAttributes.SVG_Y, "0");
+ hatch.setAttribute(SVGAttributes.SVG_WIDTH, String.valueOf((int)max.x));
+ hatch.setAttribute(SVGAttributes.SVG_HEIGHT, String.valueOf((int)max.y));
gPath.setAttribute(SVGAttributes.SVG_STROKE, CSSColors.getColorName(shape.getHatchingColor(), true));
gPath.setAttribute(SVGAttributes.SVG_STROKE_WIDTH, String.valueOf(shape.getHatchingWidth()));
gPath.setAttribute(SVGAttributes.SVG_STROKE_DASHARRAY, SVGAttributes.SVG_VALUE_NONE);
- if(shape.getHatchingStyle().equals(PSTricksConstants.TOKEN_FILL_CROSSHATCH) ||
- shape.getHatchingStyle().equals(PSTricksConstants.TOKEN_FILL_VLINES))
- {
- Element path = doc.createElement(SVGElements.SVG_PATH);
- int gap=(int)(shape.getHatchingSep()+shape.getHatchingWidth()), x;
- String d = "";//TODO use path //$NON-NLS-1$
-
- for(x=gap>>1; x<lgth; x+=gap)
- d+=" M " + x + " 0 L " + x + " " + lgth; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- path.setAttribute(SVGAttributes.SVG_D, d);
- gPath.appendChild(path);
- }
+ Element path = doc.createElement(SVGElements.SVG_PATH);
- if(shape.getHatchingStyle().equals(PSTricksConstants.TOKEN_FILL_CROSSHATCH) ||
- shape.getHatchingStyle().equals(PSTricksConstants.TOKEN_FILL_HLINES))
- {
- Element path = doc.createElement(SVGElements.SVG_PATH);
- int gap=(int)(shape.getHatchingSep()+shape.getHatchingWidth()), y;
- String d = ""; //$NON-NLS-1$
- //TODO use path
- for(y=gap>>1; y<lgth; y+=gap)
- d+=" M 0 " + y + " L " + lgth + " " + y; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- path.setAttribute(SVGAttributes.SVG_D, d);
- gPath.appendChild(path);
- }
+ path.setAttribute(SVGAttributes.SVG_D, getSVGHatchingsPath().toString());
+ gPath.appendChild(path);
if(shape.isFilled() || (shape.hasShadow() && shadowFills))
{
Element fill = doc.createElement(SVGElements.SVG_RECT);
- fill.setAttribute(SVGAttributes.SVG_FILL, CSSColors.getColorName(shape.getInteriorColor(), true));
+ fill.setAttribute(SVGAttributes.SVG_FILL, CSSColors.getColorName(shape.getInteriorColor(), true));
fill.setAttribute(SVGAttributes.SVG_STROKE, SVGAttributes.SVG_VALUE_NONE);
- fill.setAttribute(SVGAttributes.SVG_WIDTH, String.valueOf(lgth));
- fill.setAttribute(SVGAttributes.SVG_HEIGHT, String.valueOf(lgth));
+ fill.setAttribute(SVGAttributes.SVG_WIDTH, String.valueOf((int)max.x));
+ fill.setAttribute(SVGAttributes.SVG_HEIGHT, String.valueOf((int)max.y));
hatch.appendChild(fill);
}
@@ -672,6 +657,121 @@ public abstract class LShapeSVGGenerator
+ /**
+ * @return The path of the hatchings of the shape.
+ * @since 2.0.0
+ */
+ public SVGPathSegList getSVGHatchingsPath()
+ {
+ SVGPathSegList path = new SVGPathSegList();
+
+ if(!shape.isHatched())
+ return path;
+
+ String hatchingStyle = shape.getHatchingStyle();
+ double hatchingAngle = shape.getHatchingAngle();
+ LaTeXDrawRectangle bound = new LaTeXDrawRectangle(shape.getTheNWNonRotatedBoundPoint(),
+ shape.getTheSENonRotatedBoundPoint(), false);
+
+ if(hatchingStyle.equals(PSTricksConstants.TOKEN_FILL_VLINES) ||
+ hatchingStyle.equals(PSTricksConstants.TOKEN_FILL_VLINES_F))
+ getSVGHatchingsPath_(path, hatchingAngle, bound);
+ else
+ if(hatchingStyle.equals(PSTricksConstants.TOKEN_FILL_HLINES) ||
+ hatchingStyle.equals(PSTricksConstants.TOKEN_FILL_HLINES_F))
+ getSVGHatchingsPath_(path, hatchingAngle>0?hatchingAngle-Math.PI/2.:hatchingAngle+Math.PI/2., bound);
+ else
+ if(hatchingStyle.equals(PSTricksConstants.TOKEN_FILL_CROSSHATCH) ||
+ hatchingStyle.equals(PSTricksConstants.TOKEN_FILL_CROSSHATCH_F))
+ {
+ getSVGHatchingsPath_(path, hatchingAngle, bound);
+ getSVGHatchingsPath_(path, hatchingAngle>0?hatchingAngle-Math.PI/2.:hatchingAngle+Math.PI/2., bound);
+ }
+
+ return path;
+ }
+
+
+
+ private void getSVGHatchingsPath_(SVGPathSegList path, double hAngle, LaTeXDrawRectangle bound)
+ {
+ if(path == null || bound==null)
+ return;
+
+ double angle2 = hAngle%(Math.PI*2.);
+ float halphPI = (float)(Math.PI/2.);
+ double hatchingWidth = shape.getHatchingWidth();
+ double hatchingSep = shape.getHatchingSep();
+ LaTeXDrawPoint2D nw = bound.getTheNWPoint();
+ LaTeXDrawPoint2D se = bound.getTheSEPoint();
+
+ if(angle2>0)
+ {
+ if((float)angle2>3f*halphPI)
+ angle2 = angle2-Math.PI*2.;
+ else
+ if((float)angle2>halphPI)
+ angle2 = angle2-Math.PI;
+ }
+ else
+ if((float)angle2<-3f*halphPI)
+ angle2 = angle2+Math.PI*2.;
+ else
+ if((float)angle2<-halphPI)
+ angle2 = angle2+Math.PI;
+
+ double val = hatchingWidth+hatchingSep;
+ float fAngle = (float)angle2;
+
+ if(fAngle==0f)
+ for(double x = nw.x; x<se.x; x+=val)
+ {
+ path.add(new SVGPathSegMoveto(x, nw.y, false));
+ path.add(new SVGPathSegLineto(x, se.y, false));
+ }
+ else
+ if(fAngle==halphPI || fAngle==-halphPI)
+ for(double y = nw.y; y<se.y; y+=val)
+ {
+ path.add(new SVGPathSegMoveto(nw.x, y, false));
+ path.add(new SVGPathSegLineto(se.x, y, false));
+ }
+ else
+ {
+ double incX = val/Math.cos(angle2);
+ double incY = val/Math.sin(angle2);
+ double maxX;
+ double y1, x2, y2, x1;
+
+ if(fAngle>0f)
+ {
+ y1 = nw.y;
+ maxX = se.x + (se.y-(nw.y<0?nw.y:0)) * Math.tan(angle2);
+ }
+ else
+ {
+ y1 = se.y;
+ maxX = se.x - se.y * Math.tan(angle2);
+ }
+
+ x1 = nw.x;
+ x2 = x1;
+ y2 = y1;
+
+ if(((float)incX)<=0f)
+ return ;
+
+ while(x2 < maxX)
+ {
+ x2 += incX;
+ y1 += incY;
+ path.add(new SVGPathSegMoveto(x1, y1, false));
+ path.add(new SVGPathSegLineto(x2, y2, false));
+ }
+ }
+ }
+
+
/**
* Gets the points needed to the gradient definition. The given points must not be null, there value will be set in the method.
@@ -797,23 +897,41 @@ public abstract class LShapeSVGGenerator
{
SVGPatternElement pat = (SVGPatternElement)def;
Color c = pat.getBackgroundColor();
- double v = pat.getHatchingSep();
String str = pat.getAttribute(pat.getUsablePrefix(LaTeXDrawNamespace.LATEXDRAW_NAMESPACE_URI)+LaTeXDrawNamespace.XML_TYPE);
+ double angle;
+ double sep;
+ double width;
+ String attr;
+
+ try { angle = Double.valueOf(pat.getAttribute(pat.getUsablePrefix(LaTeXDrawNamespace.LATEXDRAW_NAMESPACE_URI)+
+ LaTeXDrawNamespace.XML_ROTATION));
+ }catch(Exception e) { angle = 0.; }
+
+ attr = pat.getAttribute(pat.getUsablePrefix(LaTeXDrawNamespace.LATEXDRAW_NAMESPACE_URI)+LaTeXDrawNamespace.XML_SIZE);
+
+ if(attr==null)
+ sep = pat.getHatchingSep();
+ else
+ try { sep = Double.valueOf(attr);
+ }catch(Exception e) { sep = 0.; }
if(PSTricksConstants.isValidFillStyle(str))
f.setHatchingStyle(str);
+ if(!Double.isNaN(angle))
+ f.setHatchingAngle(angle);
+
f.setIsFilled(c!=null);
f.setInteriorColor(c);
f.setHatchingColor(pat.getHatchingColor());
- if(!Double.isNaN(v))
- f.setHatchingSep(v);
+ if(!Double.isNaN(sep))
+ f.setHatchingSep(sep);
- v = pat.getHatchingStrokeWidth();
+ width = pat.getHatchingStrokeWidth();
- if(!Double.isNaN(v))
- f.setHatchingWidth((float)v);
+ if(!Double.isNaN(width))
+ f.setHatchingWidth((float)width);
}
else
if(def instanceof SVGLinearGradientElement)
diff --git a/latexDraw/generators/svg/LTextSVGGenerator.java b/latexDraw/generators/svg/LTextSVGGenerator.java
index ffec5a0..e61a071 100644
--- a/latexDraw/generators/svg/LTextSVGGenerator.java
+++ b/latexDraw/generators/svg/LTextSVGGenerator.java
@@ -96,6 +96,12 @@ public class LTextSVGGenerator extends LShapeSVGGenerator
double x, y = 0;
String v;
NodeList nl;
+ String fontFam = elt.getAttribute(SVGAttributes.SVG_FONT_FAMILY);
+ int fontSize;
+ Text t;
+
+ try { fontSize = Double.valueOf(elt.getAttribute(SVGAttributes.SVG_FONT_SIZE)).intValue(); }
+ catch(NumberFormatException e) { fontSize = Text.DEFAULT_SIZE.getSize(); }
setNumber(elt);
setTextAttributes(elt);
@@ -109,7 +115,6 @@ public class LTextSVGGenerator extends LShapeSVGGenerator
SVGTextElement text = (SVGTextElement)nl.item(0);
LaTeXDrawPSTricksParserActions action = new LaTeXDrawPSTricksParserActions();
PSTricksParser parser = new PSTricksParser(action);
- Text t;
String code = "\\begin{pspicture}(10,10)\n\\rput(0,0){" + text.getText() + "}\n\\end{pspicture}";//$NON-NLS-1$ //$NON-NLS-2$
@@ -128,6 +133,12 @@ public class LTextSVGGenerator extends LShapeSVGGenerator
else
throw new IllegalArgumentException();
+ t = (Text)shape;
+ t.setSize(fontSize);
+ t.setTextFont(fontFam);
+ t.setIsBold(SVGAttributes.SVG_FONT_WEIGHT_BOLD.equals(elt.getAttribute(SVGAttributes.SVG_FONT_WEIGHT)));
+ t.setIsItalic(SVGAttributes.SVG_FONT_STYLE_ITALIC.equals(elt.getAttribute(SVGAttributes.SVG_FONT_STYLE)));
+
if(withTransformation)
applyTransformations(elt);
}
diff --git a/latexDraw/parsers/pstricks/LaTeXDrawPSTricksParserActions.java b/latexDraw/parsers/pstricks/LaTeXDrawPSTricksParserActions.java
index 0d31085..d57b928 100644
--- a/latexDraw/parsers/pstricks/LaTeXDrawPSTricksParserActions.java
+++ b/latexDraw/parsers/pstricks/LaTeXDrawPSTricksParserActions.java
@@ -1,1669 +1,1668 @@
-/*
- * LaTeXDrawPSTricksParserActions.java
- */
-package latexDraw.parsers.pstricks;
-
-import java.awt.geom.Arc2D;
-import java.awt.geom.Point2D;
-import java.util.Vector;
-
-import latexDraw.figures.*;
-import latexDraw.figures.properties.Arrowable;
-import latexDraw.parsers.InvalidFormatCommandException;
-import latexDraw.parsers.NotFullyManagedException;
-import latexDraw.parsers.pstricks.PSTricksParameters.PositionParameters;
-import latexDraw.psTricks.PSTricksConstants;
-import latexDraw.util.LaTeXDrawPoint2D;
-
-
-/**
- * This class defines actions to do on a given command for the LaTeXDraw project.<br>
- *<br>
- * This file is part of LaTeXDraw<br>
- * Copyright (c) 2005-2008 Arnaud BLOUIN<br>
- *<br>
- * 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
- * any later version.<br>
- *<br>
- * 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.<br>
- *<br>
- *
- * 09/06/06<br>
- * @author Arnaud BLOUIN<br>
- * @version 0.5<br>
- */
-public class LaTeXDrawPSTricksParserActions extends PSTricksParserActionsManager
-{
- /** The parsed figures. */
- protected Vector<Figure> figures;
-
- /** The figures contained in the pscustom command. Cleared at the end of each <code>pscustom</code> command.*/
- public Vector<Figure> psCustFigures;
-
-
-
- /**
- * The constructor by default.
- */
- public LaTeXDrawPSTricksParserActions()
- {
- super();
- psCustFigures = new Vector<Figure>();
- figures = new Vector<Figure>();
- }
-
-
-
-
- @Override
- public void actionsOnText(Vector<PSTricksParameters> params) throws InvalidFormatCommandException
- {
- if(params.isEmpty()) return;
-
- if(params.lastElement().textParsed.length()!=0)
- {
- PSTricksParameters last = params.lastElement();
-
- PositionParameters pp = null;
- int i = params.size()-1;
-
- while(pp==null && i>=0)
- {
- pp = params.elementAt(i).getPosition();
- i--;
- }
-
- if(pp==null)
- pp = new PositionParameters();
-
- Text t = new Text(true);
- Point2D.Double position = moveCoordinate(params, new Point2D.Double(0,0));
- double angle = Math.toRadians(PSTricksParameters.getWholeRotationAngle(params));
-
- if(position==null) throw new InvalidFormatCommandException("text", -1); //$NON-NLS-1$
-
- if(last.textSize!=null && last.textSize.length()!=0)
- t.setSizeByCommand(last.textSize);
-
- if((last.textSeries!=null && last.textSeries.equals("b")) || last.textBold) //$NON-NLS-1$
- t.setIsBold(true);
- else t.setIsBold(false);
-
- if((last.textShape!=null && (last.textShape.equals("sl") || //$NON-NLS-1$
- last.textShape.equals("it")) || last.textItalic)) //$NON-NLS-1$
- t.setIsItalic(true);
- else t.setIsItalic(false);
-
- t.setRotationAngle(-angle);
- t.setText(last.textParsed);
- t.setLinesColor(last.textColor);
-
- if(last.textFamily!=null && last.textFamily.length()!=0)
- t.setTextFontByFamily(last.textFamily);
-
- t.updateFontsBorders();
-
- LaTeXDrawPoint2D pos = new LaTeXDrawPoint2D(position.x*Figure.PPC-t.getWidth()/2.,
- (position.y*Figure.PPC-t.getFontMetrics().getHeight()/4.)*-1);
-
- if(pp.refPoint!=PositionParameters.REF_POINT_DEFAULT_CENTER)
- {
- double addX=0, addY=0;
- Point2D.Double gc = new Point2D.Double((pos.x+t.getWidth())/2.,(pos.y+t.getHeight())/2.);
-
- if(pp.refPoint==PositionParameters.REF_POINT_BASE)
- addY=-t.getFontMetrics().getDescent();
- else if(pp.refPoint==PositionParameters.REF_POINT_TOP)
- addY=t.getFontMetrics().getAscent()/2.;
- else if(pp.refPoint==PositionParameters.REF_POINT_BOTTOM)
- addY=-t.getFontMetrics().getDescent()*2;
- else if(pp.refPoint==PositionParameters.REF_POINT_LEFT)
- addX=t.getWidth()/2.;
- else if(pp.refPoint==PositionParameters.REF_POINT_RIGHT)
- addX=-t.getWidth()/2.;
- else if(pp.refPoint==PositionParameters.REF_POINT_RIGHT+PositionParameters.REF_POINT_BASE)
- {
- addY=-t.getFontMetrics().getDescent();
- addX=-t.getWidth()/2.;
- }else if(pp.refPoint==PositionParameters.REF_POINT_RIGHT+PositionParameters.REF_POINT_BOTTOM)
- {
- addY=-t.getFontMetrics().getDescent()*2;
- addX=-t.getWidth()/2.;
- }else if(pp.refPoint==PositionParameters.REF_POINT_RIGHT+PositionParameters.REF_POINT_TOP)
- {
- addY=t.getFontMetrics().getAscent()/2.;
- addX=-t.getWidth()/2.;
- }else if(pp.refPoint==PositionParameters.REF_POINT_LEFT+PositionParameters.REF_POINT_BASE)
- {
- addY=-t.getFontMetrics().getDescent();
- addX=t.getWidth()/2.;
- }else if(pp.refPoint==PositionParameters.REF_POINT_LEFT+PositionParameters.REF_POINT_BOTTOM)
- {
- addY=-t.getFontMetrics().getDescent()*2;
- addX=t.getWidth()/2.;
- }else if(pp.refPoint==PositionParameters.REF_POINT_LEFT+PositionParameters.REF_POINT_TOP)
- {
- addY=t.getFontMetrics().getAscent()/2.;
- addX=t.getWidth()/2.;
- }
-
- addX+=pp.labelSep*Figure.PPC;
-
- Point2D.Double pt = rotatePoint(new Point2D.Double(gc.x+addX, gc.y-addY), gc, angle);
- pos.setLocation(pos.x+(pt.x-gc.x), pos.y-(pt.y-gc.y));
- }
-
- t.setPosition(pos);
- t.updateFontsBorders();
-
- if(last.psCustomP.fromPsCustom)
- psCustFigures.add(t);
- else
- figures.add(t);
- }
- }
-
-
-
-
- /**
- * @return the figures
- */
- public Vector<Figure> getFigures()
- {
- return figures;
- }
-
-
-
- /**
- * Allows to set the parameters of a figure <code>f</code>.
- */
- public void setFigureParameters(PSTricksParameters p, Figure f, boolean hasStar)
- {
- if(f==null) return ;
-
- if(f.canHaveShadow())
- {
- f.setHasShadow(p.isShadow);
- f.setShadowAngle(Math.toRadians(p.shadowAngle));
- f.setShadowSize(Math.abs(p.shadowSize)*Figure.PPC);
- f.setShadowColor(p.shadowCol);
- }
-
- if(f.canBeHatched())
- {
- f.setHatchingSep(p.hatchSep*Figure.PPC);
- f.setGradientAngle(Math.toRadians(p.gradAngle));
- f.setGradientEndColor(p.gradEnd);
- f.setGradientMidPoint(p.gradMidPoint);
- f.setGradientStartColor(p.gradBegin);
- }
-
- f.setLinesColor(p.lineColor);
- f.setBordersPosition(p.borderPos);
- f.setDoubleColor(p.dbleColor);
- f.setDoubleSep(Math.abs(p.dbleSep*Figure.PPC));
- f.setHasDoubleBoundary(p.dbleLine);
- f.setHatchingColor(p.hatchCol);
- if(p.fillStyle.equals(PSTricksConstants.TOKEN_FILL_SOLID))
- f.setHatchingStyle(PSTricksConstants.TOKEN_FILL_NONE);
- else f.setHatchingStyle(
- p.fillStyle.endsWith("*") ? p.fillStyle.substring(0, p.fillStyle.length()-1) : p.fillStyle);//$NON-NLS-1$
- f.setHatchingWidth((float)Math.abs(p.hatchWidth*Figure.PPC));
- f.setDotSep((float) p.dotStep*Figure.PPC);
- f.setHatchingAngle(0);//TODO hatching angle
-// f.setHatchingAngle(Math.toRadians(p.hatchAngle));
- f.setBlackDashLength((float)p.dashBlack*Figure.PPC);
- f.setWhiteDashLength((float)p.dashWhite*Figure.PPC);
- f.setInteriorColor(p.fillColor);
- f.setIsFilled(p.fillStyle.equals(PSTricksConstants.TOKEN_FILL_SOLID) ||
- p.fillStyle.equals(PSTricksConstants.TOKEN_FILL_CROSSHATCH_F) ||
- p.fillStyle.equals(PSTricksConstants.TOKEN_FILL_HLINES_F) ||
- p.fillStyle.equals(PSTricksConstants.TOKEN_FILL_VLINES_F));
- f.setLineStyle(p.lineStyle);
- f.setThickness((float)(Math.abs(p.lineWidth*Figure.PPC)));
-
- if(hasStar)
- {
- f.setIsFilled(true);
- f.setInteriorColor(f.getLinesColor());
- f.setHasDoubleBoundary(false);
- f.setLineStyle(PSTricksConstants.LINE_NONE_STYLE);
- f.setHatchingStyle(PSTricksConstants.TOKEN_FILL_NONE);
- f.setBordersPosition(PSTricksConstants.BORDERS_INSIDE);
- }
- }
-
-
-
-
-
-
- @Override
- public int actionsOnFrameEllipse(int line, boolean hasStar, Vector<PSTricksParameters> ps, String params,
- boolean isFrame) throws InvalidFormatCommandException
- {
- try
- {
- if(ps.isEmpty()) return ERR_END_CMD_INDEX;
-
- Point2D.Double p3;
- PSTricksParameters p = ps.lastElement();
- Point2D.Double p1 = new Point2D.Double(p.origin.x, p.origin.y);
- Point2D.Double p2 = new Point2D.Double();
- PSTricksParameters newP = new PSTricksParameters(p);
- double angle = Math.toRadians(-PSTricksParameters.getWholeRotationAngle(ps));
- int end = parseParametersFrameEllipse(line, params, p1, p2, newP);
- double xunit = newP.unit==PSTricksConstants.DEFAULT_UNIT? newP.xUnit : newP.unit;
- double yunit = newP.unit==PSTricksConstants.DEFAULT_UNIT? newP.yUnit : newP.unit ;
- Figure f;
- p1.setLocation(p1.x+p.origin.x, p1.y+p.origin.y);
-
- if(isFrame)
- {
- p2.setLocation(p2.x+p.origin.x, p2.y+p.origin.y);
- if(ps.size()>1)
- {
- p1 = moveCoordinate(ps, p1);
- p2 = moveCoordinate(ps, p2);
- p3 = new Point2D.Double((p1.x+p2.x)/2.,(p1.y+p2.y)/2.);
- p1 = rotatePoint(p1, p3, angle);
- p2 = rotatePoint(p2, p3, angle);
- }
-
- p1.setLocation(p1.x*Figure.PPC*xunit, p1.y*Figure.PPC*-1*yunit);
- p2.setLocation(p2.x*Figure.PPC*xunit, p2.y*Figure.PPC*-1*yunit);
-
- LaTeXDrawPoint2D pt1 = new LaTeXDrawPoint2D(p1.x, p2.y);
- LaTeXDrawPoint2D pt2 = new LaTeXDrawPoint2D(p2.x, p2.y);
- LaTeXDrawPoint2D pt3 = new LaTeXDrawPoint2D(p1.x, p1.y);
- LaTeXDrawPoint2D pt4 = new LaTeXDrawPoint2D(p2.x, p1.y);
-
- f = new LaTeXDrawRectangle(pt1, pt2, pt3, pt4, true);
- ((LaTeXDrawRectangle)f).setIsRound(newP.frameArc>0);
- if(newP.frameArc>0) ((LaTeXDrawRectangle)f).setFrameArc(newP.frameArc);
- }
- else
- {
- p1 = moveCoordinate(ps, p1);
- p1.setLocation(p1.x*Figure.PPC*xunit, p1.y*Figure.PPC*-1*yunit);
- p2.setLocation(p2.x*Figure.PPC*xunit, p2.y*Figure.PPC*-1*yunit);
-
- LaTeXDrawPoint2D pt1 = new LaTeXDrawPoint2D(p1.x-p2.x, p1.y+p2.y);
- LaTeXDrawPoint2D pt2 = new LaTeXDrawPoint2D(p1.x+p2.x, p1.y+p2.y);
- LaTeXDrawPoint2D pt3 = new LaTeXDrawPoint2D(p1.x-p2.x, p1.y-p2.y);
- LaTeXDrawPoint2D pt4 = new LaTeXDrawPoint2D(p1.x+p2.x, p1.y-p2.y);
-
- f = new Ellipse(pt1, pt2, pt3, pt4, true);
- }
-
- setFigureParameters(newP, f, hasStar);
- f.setRotationAngle(angle);
-
- if(p.psCustomP.fromPsCustom)
- psCustFigures.add(f);
- else
- figures.add(f);
-
- return end;
-
- }catch(Exception e)
- {
- if(isFrame)
- throw new InvalidFormatCommandException("psframe", line); //$NON-NLS-1$
- throw new InvalidFormatCommandException("psellipse", line); //$NON-NLS-1$
- }
- }
-
-
-
-
- @Override
- public int actionsOnCircle(int line, boolean hasStar, Vector<PSTricksParameters> ps, String params)
- throws InvalidFormatCommandException
- {
- try
- {
- PSTricksParameters p = ps.lastElement();
- Point2D.Double center = new Point2D.Double(p.origin.x, p.origin.y);
- double[] radius = {1};
- PSTricksParameters newP = new PSTricksParameters(p);
- Figure c;
- double angle = Math.toRadians(-PSTricksParameters.getWholeRotationAngle(ps));
- int end = parseParametersCircle(line, params, center, radius, newP);
- LaTeXDrawPoint2D pt1, pt2, pt3, pt4;
- center = moveCoordinate(ps, center);
-
- pt1 = new LaTeXDrawPoint2D((p.origin.x+center.x-radius[0])*Figure.PPC*newP.unit,
- (p.origin.y+center.y+radius[0])*Figure.PPC*-1*newP.unit);
- pt2 = new LaTeXDrawPoint2D((p.origin.x+center.x+radius[0])*Figure.PPC*newP.unit,
- (p.origin.y+center.y+radius[0])*Figure.PPC*-1*newP.unit);
- pt3 = new LaTeXDrawPoint2D((p.origin.x+center.x-radius[0])*Figure.PPC*newP.unit,
- (p.origin.y+center.y-radius[0])*Figure.PPC*-1*newP.unit);
- pt4 = new LaTeXDrawPoint2D((p.origin.x+center.x+radius[0])*Figure.PPC*newP.unit,
- (p.origin.y+center.y-radius[0])*Figure.PPC*-1*newP.unit);
-
- c = new Circle(pt1, pt2, pt3, pt4, true);
- setFigureParameters(newP, c, hasStar);
- c.setRotationAngle(angle);
-
- if(p.psCustomP.fromPsCustom)
- psCustFigures.add(c);
- else
- figures.add(c);
-
- return end;
-
- }catch(Exception e) { throw new InvalidFormatCommandException("pscircle", line); } //$NON-NLS-1$
- }
-
-
-
-
-
-
- @Override
- public int actionsOnDot(int line, Vector<PSTricksParameters> ps, String params,
- boolean noCoordinatePossible) throws InvalidFormatCommandException
- {
- try
- {
- if(ps==null || ps.isEmpty()) return ERR_END_CMD_INDEX;
- // It can have several points defined
- Vector<Point2D.Double> center = new Vector<Point2D.Double>();
- PSTricksParameters last = ps.lastElement();
- PSTricksParameters newP = new PSTricksParameters(last);
- double angle = Math.toRadians(-PSTricksParameters.getWholeRotationAngle(ps));
- int end = parseParametersDot(line, params, center, newP, noCoordinatePossible);
- double xunit = newP.unit==PSTricksConstants.DEFAULT_UNIT? newP.xUnit : newP.unit;
- double yunit = newP.unit==PSTricksConstants.DEFAULT_UNIT? newP.yUnit : newP.unit ;
- newP.arrowDotSD = newP.arrowDotSD+newP.arrowDotSN<0 ? Math.abs(newP.arrowDotSD) : newP.arrowDotSD;
- newP.arrowDotSN = newP.arrowDotSD+newP.arrowDotSN<0 ? Math.abs(newP.arrowDotSN) : newP.arrowDotSN;
- newP.dotScale1 = Math.abs(newP.dotScale1);
-
- for(Point2D.Double pt: center)
- {
- pt = moveCoordinate(ps, pt);
- Dot d = new Dot(new LaTeXDrawPoint2D(pt.x*Figure.PPC*xunit, pt.y*Figure.PPC*-1*yunit),
- true);
- setFigureParameters(newP, d, false);
-
- d.setCurrentStyle(newP.dotStyle);
- d.setWidth((float)((newP.arrowDotSD+newP.arrowDotSN*newP.lineWidth)*newP.dotScale1)*Figure.PPC);
- d.setRotationAngle(Math.toRadians(-newP.dotAngle)+angle);
- d.setInteriorColor(newP.fillColor);
-
- if(!last.psCustomP.fromPsCustom)
- figures.add(d);
- }
-
- return end;
-
- }catch(Exception e) { throw new InvalidFormatCommandException("psdot", line); }//$NON-NLS-1$
- }
-
-
-
-
-
-
- @Override
- public int actionsOnLine(int line, boolean hasStar, Vector<PSTricksParameters> ps,
- String params) throws InvalidFormatCommandException
- {
- try
- {
- if(ps==null || ps.isEmpty()) return ERR_END_CMD_INDEX;
-
- Vector<Point2D.Double> pts = new Vector<Point2D.Double>();
- PSTricksParameters last = ps.lastElement();
- PSTricksParameters newP = new PSTricksParameters(last);
- Figure f;
- int end = parseParametersLine(line, params, pts, newP);
- double xunit = newP.unit==PSTricksConstants.DEFAULT_UNIT? newP.xUnit : newP.unit;
- double yunit = newP.unit==PSTricksConstants.DEFAULT_UNIT? newP.yUnit : newP.unit ;
-
- if(pts.isEmpty()) return end;
-
- if(ps.size()>1)
- for(Point2D.Double pt : pts)
- pt.setLocation(moveCoordinate(ps, pt));
-
- if(pts.size()>2)//joined lines
- f = new JoinedLines(new LaTeXDrawPoint2D(), new LaTeXDrawPoint2D(), true);
- else
- f = new Line(new LaTeXDrawPoint2D(), new LaTeXDrawPoint2D(), true);
-
-
- Point2D.Double ptOld= null;
-
- for(Point2D.Double pt : pts)
- if(!pt.equals(ptOld))
- {
- ((LaTeXDrawPolygon)f).addPoint(new LaTeXDrawPoint2D(pt.x*Figure.PPC*xunit,
- pt.y*Figure.PPC*-1*yunit));
- ptOld = pt;
- }
-
- if(pts.size()>2)//joined lines
- {
- ((JoinedLines)f).removePointAt(0);
- ((JoinedLines)f).removePointAt(0);
- ((JoinedLines)f).setArrow2Style(ArrowHead.invertArrowStyle(newP.arrowStyle[1]));
-
- if(((JoinedLines)f).getNbPoints()<2)
- return end;
- }
- else
- {
- ((Line)f).removePointAt(0);
- ((Line)f).removePointAt(0);
- ((Line)f).setArrow2Style(newP.arrowStyle[1]);
- }
-
- ((Arrowable)f).setArrow1Style(newP.arrowStyle[0]);
- setArrowParameters(((Arrowable)f).getArrowHead1(), newP);
- setArrowParameters(((Arrowable)f).getArrowHead2(), newP);
- setFigureParameters(newP, f, hasStar);
-
- if(last.psCustomP.fromPsCustom)
- psCustFigures.add(f);
- else
- figures.add(f);
-
- return end;
-
- }catch(Exception e) { e.printStackTrace(); throw new InvalidFormatCommandException("psline", line); }//$NON-NLS-1$
- }
-
-
-
-
- /**
- * Sets the parameters of an arrowhead.
- * @param ah The arrowhead.
- * @param param The parameters.
- * @since 0.2.1
- */
- protected void setArrowParameters(ArrowHead ah, PSTricksParameters param)
- {
- ah.setArrowInset(param.arrowInset);
- ah.setArrowLength(param.arrowLgth);
- ah.setArrowSizeDim(param.arrowSizeD*Figure.PPC);
- ah.setArrowSizeNum(param.arrowSizeN);
- ah.setBracketNum(param.arrowBrLgth);
- ah.setDotSizeDim((param.arrowDotSD+param.arrowDotSN<0 ? Math.abs(param.arrowDotSD) : param.arrowDotSD)*Figure.PPC);
- ah.setDotSizeNum(param.arrowDotSD+param.arrowDotSN<0 ? Math.abs(param.arrowDotSN) : param.arrowDotSN);
- ah.setRBracketNum(param.arrowrBrLgth);
- ah.setTBarSizeDim(param.arrowTBarSD+param.arrowTBarSD<0 ? Math.abs(param.arrowTBarSD) : param.arrowTBarSD*Figure.PPC);
- ah.setTBarSizeNum(param.arrowTBarSD+param.arrowTBarSD<0 ? Math.abs(param.arrowTBarSN) : param.arrowTBarSN);
-
- }
-
-
-
- @Override
- public int actionsOnPolygon(int line, boolean hasStar, Vector<PSTricksParameters> ps,
- String params) throws InvalidFormatCommandException
- {
- try
- {
- if(ps==null || ps.isEmpty()) return ERR_END_CMD_INDEX;
-
- Vector<Point2D.Double> pts = new Vector<Point2D.Double>();
- PSTricksParameters last = ps.lastElement();
- PSTricksParameters newP = new PSTricksParameters(last);
- int end = parseParametersPolygon(line, params, pts, newP);
- double xunit = newP.unit!=PSTricksConstants.DEFAULT_UNIT? newP.unit : newP.xUnit;
- double yunit = newP.unit!=PSTricksConstants.DEFAULT_UNIT? newP.unit : newP.yUnit;
-
- if(pts.size()<2) return end;
-
- LaTeXDrawPolygon pol = new LaTeXDrawPolygon(new LaTeXDrawPoint2D(), new LaTeXDrawPoint2D(), true);
- Point2D.Double ptOld= null;
-
- if(pts.size()==2)
- pts.add(new Point2D.Double(newP.origin.x, newP.origin.y));
-
- for(Point2D.Double pt : pts)
- {
- pt.setLocation(moveCoordinate(ps, pt));
- if(!pt.equals(ptOld))
- {
- pol.addPoint(new LaTeXDrawPoint2D(pt.x*Figure.PPC*xunit, pt.y*Figure.PPC*-1*yunit));
- ptOld = pt;
- }
- }
-
- pol.removePointAt(0);
- pol.removePointAt(0);
-
- if(pol.getNbPoints()<3)
- return end;
-
- setFigureParameters(newP, pol, hasStar);
-
- pol.updateBorders();
- pol.updateGravityCenter();
-
- if(last.psCustomP.fromPsCustom)
- psCustFigures.add(pol);
- else
- figures.add(pol);
-
- return end;
-
- }catch(Exception e) { throw new InvalidFormatCommandException("pspolygon", line); }//$NON-NLS-1$
- }
-
-
-
-
-
-
-
- @Override
- public int actionsOnDiamondTriangle(int line, boolean hasStar, Vector<PSTricksParameters> ps,
- String params, boolean isDiamondNotTriangle) throws InvalidFormatCommandException
- {
- try
- {
- if(ps==null || ps.isEmpty()) return ERR_END_CMD_INDEX;
-
- PSTricksParameters p = ps.lastElement();
- Point2D.Double p1 = new Point2D.Double(p.origin.x, p.origin.y);
- Point2D.Double p2 = new Point2D.Double();
- PSTricksParameters newP = new PSTricksParameters(p);
- Figure f;
- double angle = Math.toRadians(-PSTricksParameters.getWholeRotationAngle(ps));
- int end = parseParametersFrameEllipse(line, params, p1, p2, newP);
- double xunit = newP.unit!=PSTricksConstants.DEFAULT_UNIT? newP.unit : newP.xUnit;
- double yunit = newP.unit!=PSTricksConstants.DEFAULT_UNIT? newP.unit : newP.yUnit;
- p1.setLocation(p1.x+p.origin.x, p1.y+p.origin.y);
- double moduloA;
- if(ps.size()>1) moduloA = ps.elementAt(ps.size()-2).degrees;
- else moduloA = 360;
-
- if(isDiamondNotTriangle)
- {
- if(ps.size()>1)
- p1 = moveCoordinate(ps, p1);
-
- LaTeXDrawPoint2D pt1 = new LaTeXDrawPoint2D((p1.x-p2.x)*Figure.PPC*xunit,
- (p1.y-p2.y)*Figure.PPC*-1*yunit);
- LaTeXDrawPoint2D pt2 = new LaTeXDrawPoint2D((p1.x+p2.x)*Figure.PPC*xunit,
- (p1.y-p2.y)*Figure.PPC*-1*yunit);
- LaTeXDrawPoint2D pt3 = new LaTeXDrawPoint2D((p1.x-p2.x)*Figure.PPC*xunit,
- (p1.y+p2.y)*Figure.PPC*-1*yunit);
- LaTeXDrawPoint2D pt4 = new LaTeXDrawPoint2D((p1.x+p2.x)*Figure.PPC*xunit,
- (p1.y+p2.y)*Figure.PPC*-1*yunit);
-
- f = new Rhombus(pt1, pt2, pt3, pt4, true);
- }
- else
- {
- Point2D.Double p3 = new Point2D.Double();
- if(ps.size()>1)
- {
- p1 = moveCoordinate(ps, p1);
- p3 = new Point2D.Double(p1.x,p1.y-p2.y/2.);
- p1 = rotatePoint(p1, p3, -angle);
- }
-
- LaTeXDrawPoint2D pt1 = new LaTeXDrawPoint2D((p1.x-p2.x/2.)*Figure.PPC*xunit,
- (p1.y+p2.y)*Figure.PPC*-1*yunit);
- LaTeXDrawPoint2D pt2 = new LaTeXDrawPoint2D((p1.x+p2.x/2.)*Figure.PPC*xunit,
- (p1.y+p2.y)*Figure.PPC*-1*yunit);
- LaTeXDrawPoint2D pt3 = new LaTeXDrawPoint2D((p1.x-p2.x/2.)*Figure.PPC*xunit,
- (p1.y)*Figure.PPC*-1*yunit);
- LaTeXDrawPoint2D pt4 = new LaTeXDrawPoint2D((p1.x+p2.x/2.)*Figure.PPC*xunit,
- (p1.y)*Figure.PPC*-1*yunit);
-
- f = new Triangle(pt1, pt2, pt3, pt4, true);
-
- if((newP.gangle%moduloA)!=0)
- {
- LaTeXDrawPoint2D gc = f.getGravityCenter();
- LaTeXDrawPoint2D base = new LaTeXDrawPoint2D((pt1.x+pt2.x)/2., pt3.y);
- LaTeXDrawPoint2D newGc = Figure.rotatePoint(gc, base, Math.toRadians(-(360/moduloA)*newP.gangle));
- f.shift(gc, newGc);
- }
- }
-
- setFigureParameters(newP, f, hasStar);
-
- if(isDiamondNotTriangle)
- {
- Rhombus r = ((Rhombus)f);
- r.setShadowAngle(r.getShadowAngle()-Math.toRadians(newP.gangle%moduloA));
- r.setHatchingAngle(r.getHatchingAngle()-Math.toRadians(newP.gangle%moduloA));
- r.setGradientAngle(r.getGradientAngle()-Math.toRadians(newP.gangle%moduloA));
-
- if((newP.gangle%moduloA)!=0)
- r.setRotationAngle(Math.toRadians(-(360/moduloA)*newP.gangle)+angle);
- else r.setRotationAngle(angle);
- }
- else
- {
- Triangle t = ((Triangle)f);
- boolean reverse = t.getPoint(0).y>t.getPoint(2).y;
-
- t.setRotationAngle(angle); // fixes #1556340
- if(reverse)
- {
- t.setShadowAngle(t.getShadowAngle()+Math.PI);
- t.setGradientAngle(t.getGradientAngle()+Math.PI);
- }
- }
-
- if(p.psCustomP.fromPsCustom)
- psCustFigures.add(f);
- else
- figures.add(f);
-
- return end;
-
- }catch(Exception e)
- {
- if(isDiamondNotTriangle)
- throw new InvalidFormatCommandException("psdiamond", line); //$NON-NLS-1$
- throw new InvalidFormatCommandException("triangle", line); //$NON-NLS-1$
- }
- }
-
-
-
-
-
- @Override
- public int actionsOnBezierCurve(int line, boolean hasStar, Vector<PSTricksParameters> ps,
- String params) throws InvalidFormatCommandException
- {
- try
- {
- if(ps==null || ps.isEmpty()) return ERR_END_CMD_INDEX;
-
- Vector<Point2D.Double> pts = new Vector<Point2D.Double>();
- PSTricksParameters last = ps.lastElement();
- PSTricksParameters newP = new PSTricksParameters(last);
- LaTeXDrawPoint2D p1;
- int ended = parseParametersBezierCurve(line, params, pts, newP), i, size, j;
- double xunit = newP.unit!=PSTricksConstants.DEFAULT_UNIT? newP.unit : newP.xUnit;
- double yunit = newP.unit!=PSTricksConstants.DEFAULT_UNIT? newP.unit : newP.yUnit;
-
- if(pts.size()<3) return ended;
-
- for(Point2D.Double pt : pts)
- pt.setLocation(moveCoordinate(ps, pt));
-
- if(pts.size()%3==0)
- p1 = new LaTeXDrawPoint2D(newP.origin.x*Figure.PPC*xunit, newP.origin.y*-1*Figure.PPC*yunit);
- else
- {
- p1 = new LaTeXDrawPoint2D(pts.firstElement().x*Figure.PPC*xunit, pts.firstElement().y*-1*Figure.PPC*yunit);
- pts.removeElementAt(0);
- }
-
- Point2D.Double pt2;
- BezierCurve f = new BezierCurve(p1,
- new LaTeXDrawPoint2D(pts.elementAt(2).x*Figure.PPC*xunit,
- pts.elementAt(2).y*-1*Figure.PPC*yunit), true);
-
- f.setXCoordFirstCtrl(pts.firstElement().x*Figure.PPC*xunit, 0);
- f.setYCoordFirstCtrl(pts.firstElement().y*-1*Figure.PPC*yunit, 0);
- f.setXCoordFirstCtrl(pts.elementAt(1).x*Figure.PPC*xunit, 1);
- f.setYCoordFirstCtrl(pts.elementAt(1).y*-1*Figure.PPC*yunit, 1);
-
- i = 4;
- j = 2;
- size = pts.size();
-
- while(i<size)
- {
- pt2 = pts.elementAt(i);
- ++i;
-
- f.addPoint(new LaTeXDrawPoint2D(pts.elementAt(i).x*Figure.PPC*xunit,
- pts.elementAt(i).y*-1*Figure.PPC*yunit));
-
- f.setXCoordFirstCtrl(pt2.x*Figure.PPC*xunit, j);
- f.setYCoordFirstCtrl(pt2.y*-1*Figure.PPC*yunit, j);
- j++;
- i+=2;
- }
-
- setFigureParameters(newP, f, hasStar);
-
- f.updateSecondControlPoints();
- f.updateShape();
- f.updateBorders();
- f.setShowPoints(newP.showPoints);
- f.setOpen(true);
- f.replaceLastPointByClosing();
-
- ((Arrowable)f).setArrow1Style(newP.arrowStyle[0]);
- ((Arrowable)f).setArrow2Style(ArrowHead.invertArrowStyle(newP.arrowStyle[1]));
- setArrowParameters(((Arrowable)f).getArrowHead1(), newP);
- setArrowParameters(((Arrowable)f).getArrowHead2(), newP);
-
- if(f.getNbPoints()>1)
- if(last.psCustomP.fromPsCustom)
- psCustFigures.add(f);
- else
- figures.add(f);
-
- return ended;
-
- }catch(Exception e) { throw new InvalidFormatCommandException("psbezier", line); } //$NON-NLS-1$
- }
-
-
-
-
-
- @Override
- public int actionsOnArcWedge(int line, boolean hasStar, Vector<PSTricksParameters> ps, String params,
- boolean isArc) throws InvalidFormatCommandException
- {
- try
- {
- PSTricksParameters p = ps.lastElement();
- Point2D.Double center = (Point2D.Double)p.origin.clone();
- PSTricksParameters newP = new PSTricksParameters(p);
- double[] angle1 = {0}, angle2 = {0}, radius = {0};
- double angle = Math.toRadians(-PSTricksParameters.getWholeRotationAngle(ps));
-
- int end = parseParametersArcWedge(line, params, radius, center, angle1, angle2, newP, isArc);
-
- center = moveCoordinate(ps, center);
-
- Arc f = new Arc(new LaTeXDrawPoint2D((center.x-radius[0])*Figure.PPC*newP.xUnit,
- (center.y+radius[0])*Figure.PPC*-1*newP.xUnit),
- new LaTeXDrawPoint2D((center.x+radius[0])*Figure.PPC*newP.xUnit,
- (center.y-radius[0])*Figure.PPC*-1*newP.xUnit), isArc ? Arc2D.OPEN : Arc2D.PIE, true);
-
- f.setStartAngle(Math.toRadians(angle1[0]));
- f.setEndAngle(Math.toRadians(angle2[0]));
- f.setShowPoints(newP.showPoints);
- f.setArrow1Style(newP.arrowStyle[0]);
-
- String currentArrowRStyle = newP.arrowStyle[1];
- if(currentArrowRStyle.equals(PSTricksConstants.DLARROW_STYLE))
- currentArrowRStyle = PSTricksConstants.DRARROW_STYLE;
- else if(currentArrowRStyle.equals(PSTricksConstants.DRARROW_STYLE))
- currentArrowRStyle = PSTricksConstants.DLARROW_STYLE;
- else if(currentArrowRStyle.equals(PSTricksConstants.RARROW_STYLE))
- currentArrowRStyle = PSTricksConstants.LARROW_STYLE;
- else if(currentArrowRStyle.equals(PSTricksConstants.LARROW_STYLE))
- currentArrowRStyle = PSTricksConstants.RARROW_STYLE;
- else if(currentArrowRStyle.equals(PSTricksConstants.DLARROW_STYLE))
- currentArrowRStyle = PSTricksConstants.DRARROW_STYLE;
- else if(currentArrowRStyle.equals(PSTricksConstants.LRBRACKET_STYLE))
- currentArrowRStyle = PSTricksConstants.RRBRACKET_STYLE;
- else if(currentArrowRStyle.equals(PSTricksConstants.RRBRACKET_STYLE))
- currentArrowRStyle = PSTricksConstants.LRBRACKET_STYLE;
- else if(currentArrowRStyle.equals(PSTricksConstants.RSBRACKET_STYLE))
- currentArrowRStyle = PSTricksConstants.LSBRACKET_STYLE;
- else if(currentArrowRStyle.equals(PSTricksConstants.LSBRACKET_STYLE))
- currentArrowRStyle = PSTricksConstants.RSBRACKET_STYLE;
-
- f.setArrow2Style(currentArrowRStyle);
-
- setArrowParameters(f.getArrowHead1(), newP);
- setArrowParameters(f.getArrowHead2(), newP);
- setFigureParameters(newP, f, hasStar);
- f.setRotationAngle(angle);
-
- if(p.psCustomP.fromPsCustom)
- psCustFigures.add(f);
- else
- figures.add(f);
-
- return end;
-
- }catch(Exception e)
- {
- if(isArc)
- throw new InvalidFormatCommandException("psarc", line); //$NON-NLS-1$
- throw new InvalidFormatCommandException("pswedge", line); //$NON-NLS-1$
- }
- }
-
-
-
-
- @Override
- public int actionsOnGridAxes(int line, Vector<PSTricksParameters> ps, Point2D.Double pictureSWPt,
- Point2D.Double pictureNEPt, String params, boolean isGrid) throws InvalidFormatCommandException
- {
- try
- {
- if(ps==null || ps.isEmpty()) return ERR_END_CMD_INDEX;
-
- Vector<Point2D.Double> pts = new Vector<Point2D.Double>();
- PSTricksParameters last = ps.lastElement();
- PSTricksParameters newP = new PSTricksParameters(last);
- int gridEndX, gridEndY, gridStartX, gridStartY, originX, originY;
- double angle = Math.toRadians(-PSTricksParameters.getWholeRotationAngle(ps));
- int end = parseParametersGridAxes(line, params, pts, newP);
- double xunit = newP.unit!=PSTricksConstants.DEFAULT_UNIT? newP.unit : newP.xUnit;
- double yunit = newP.unit!=PSTricksConstants.DEFAULT_UNIT? newP.unit : newP.yUnit;
- newP.origin.setLocation(moveCoordinate(ps, newP.origin));
- boolean isGridXLabelReverse = false;
- boolean isGridYLabelReverse = false;
-
- if(pts.isEmpty())
- {
- if(pictureNEPt.x>=0)
- gridEndX = (pictureNEPt.x-((int)pictureNEPt.x))>0.5 ? (int)pictureNEPt.x+1 : (int)pictureNEPt.x;
- else gridEndX = (((int)pictureNEPt.x)-pictureNEPt.x)>0.5 ? (int)pictureNEPt.x-1 : (int)pictureNEPt.x;
- if(pictureNEPt.y>=0)
- gridEndY = (pictureNEPt.y-((int)pictureNEPt.y))>0.5 ? (int)pictureNEPt.y+1 : (int)pictureNEPt.y;
- else gridEndY = (((int)pictureNEPt.y)-pictureNEPt.y)>0.5 ? (int)pictureNEPt.y-1 : (int)pictureNEPt.y;
-
- if(pictureSWPt.x>=0)
- gridStartX = originX = (pictureSWPt.x-((int)pictureSWPt.x))>0.5 ? (int)pictureSWPt.x+1 : (int)pictureSWPt.x;
- else gridStartX = originX = (((int)pictureSWPt.x)-pictureSWPt.x)>0.5 ? (int)pictureSWPt.x-1 : (int)pictureSWPt.x;
-
- if(pictureSWPt.y>=0)
- gridStartY = originY = (pictureSWPt.y-((int)pictureSWPt.y))>0.5 ? (int)pictureSWPt.y+1 : (int)pictureSWPt.y;
- else gridStartY = originY = (((int)pictureSWPt.y)-pictureSWPt.y)>0.5 ? (int)pictureSWPt.y-1 : (int)pictureSWPt.y;
- }
- else
- if(pts.size()==1)
- {
- gridStartX = gridStartY = originX = originY = 0;
- gridEndX = (int)pts.firstElement().x;
- gridEndY = (int)pts.firstElement().y;
- }
- else
- if(pts.size()==2)
- {
- originX = gridStartX = (int)pts.firstElement().x;
- originY = gridStartY = (int)pts.firstElement().y;
- gridEndX = (int)pts.elementAt(1).x;
- gridEndY = (int)pts.elementAt(1).y;
- }
- else
- {
- originX = (int)pts.firstElement().x;
- originY = (int)pts.firstElement().y;
- gridStartX = (int)pts.elementAt(1).x;
- gridStartY = (int)pts.elementAt(1).y;
- gridEndX = (int)pts.elementAt(2).x;
- gridEndY = (int)pts.elementAt(2).y;
- }
-
- if(gridStartX>=gridEndX)
- {
- int tmp = gridEndX;
- gridEndX = gridStartX;
- gridStartX = tmp;
- isGridXLabelReverse = true;
- }
-
- if(gridStartY>=gridEndY)
- {
- int tmp = gridEndY;
- gridEndY = gridStartY;
- gridStartY = tmp;
- isGridYLabelReverse = true;
- }
-
- LaTeXDrawPoint2D position = new LaTeXDrawPoint2D(newP.origin.x*Figure.PPC,newP.origin.y*Figure.PPC*-1);
- GridShape f=null;
-
- if(angle!=0)
- {
- Point2D.Double tmp1 = new Point2D.Double(
- position.x+((gridEndX+gridStartX)/2.)*Figure.PPC*xunit,
- position.y-((gridEndY+gridStartY)/2.)*Figure.PPC*yunit);
- Point2D.Double tmp = rotatePoint(tmp1, position, angle);
- position.setLocation(position.x+(tmp.x-tmp1.x), position.y+(tmp.y-tmp1.y));
- }
-
- if(isGrid)
- {
- f = new Grid(position, true);
- Grid g = (Grid)f;
- g.setUnit(xunit);
- g.setGridDots(newP.gridDots);
- g.setGridLabelsColor(newP.labelsGridCol);
- g.setGridLabelsSize((int)((newP.gridLabel*PSTricksConstants.CM_VAL_PT)/0.6));
- g.setGridWidth((float)Math.abs(newP.gridWidth*Figure.PPC));
- g.setSubGridColor(newP.subGridCol);
- g.setSubGridDiv(newP.subGridDiv);
- g.setSubGridDots(newP.subGridDots);
- g.setSubGridWidth((float)Math.abs(newP.subGridWidth*Figure.PPC));
- g.setOriginX(originX);
- g.setOriginY(originY);
- g.setLinesColor(newP.gridColor);
- }
- else
- {
- f = new Axe(position, true);
- Axe a = (Axe)f;
- a.setOriginX((int)newP.ox);
- a.setOriginY((int)newP.oy);
- a.setLabelsDisplayedToken(newP.labels);
- a.setTicksDisplayedToken(newP.ticks);
- a.setTicksStyleToken(newP.ticksStyle);
- a.setTicksSize(newP.ticksSize*Figure.PPC);
- a.setIncrementX(newP.dxIncrement);
- a.setIncrementY(newP.dyIncrement);
- a.setDistLabelsX(newP.dxLabelDist);
- a.setDistLabelsY(newP.dyLabelDist);
- a.setShowOrigin(newP.showOrigin);
- a.setAxesStyleToken(newP.axesStyle);
- setFigureParameters(newP, a, false);
-
- String arrowHead2Style = newP.arrowStyle[1];
-
- if(arrowHead2Style.equals(PSTricksConstants.DLARROW_STYLE))
- arrowHead2Style = PSTricksConstants.DRARROW_STYLE;
- else if(arrowHead2Style.equals(PSTricksConstants.DRARROW_STYLE))
- arrowHead2Style = PSTricksConstants.DLARROW_STYLE;
- else if(arrowHead2Style.equals(PSTricksConstants.RARROW_STYLE))
- arrowHead2Style = PSTricksConstants.LARROW_STYLE;
- else if(arrowHead2Style.equals(PSTricksConstants.LARROW_STYLE))
- arrowHead2Style = PSTricksConstants.RARROW_STYLE;
- else if(arrowHead2Style.equals(PSTricksConstants.DLARROW_STYLE))
- arrowHead2Style = PSTricksConstants.DRARROW_STYLE;
- else if(arrowHead2Style.equals(PSTricksConstants.LRBRACKET_STYLE))
- arrowHead2Style = PSTricksConstants.RRBRACKET_STYLE;
- else if(arrowHead2Style.equals(PSTricksConstants.RRBRACKET_STYLE))
- arrowHead2Style = PSTricksConstants.LRBRACKET_STYLE;
- else if(arrowHead2Style.equals(PSTricksConstants.RSBRACKET_STYLE))
- arrowHead2Style = PSTricksConstants.LSBRACKET_STYLE;
- else if(arrowHead2Style.equals(PSTricksConstants.LSBRACKET_STYLE))
- arrowHead2Style = PSTricksConstants.RSBRACKET_STYLE;
-
- ((Arrowable)a).setArrow1Style(newP.arrowStyle[0]);
- ((Arrowable)a).setArrow2Style(arrowHead2Style);
- setArrowParameters(((Arrowable)a).getArrowHead1(), newP);
- setArrowParameters(((Arrowable)a).getArrowHead2(), newP);
- }
-
- f.setGridEndX(gridEndX);
- f.setGridEndY(gridEndY);
- f.setGridStartX(gridStartX);
- f.setGridStartY(gridStartY);
- f.updateFonts();
- f.updateBorders(null);
- f.updateBorders();
- f.setRotationAngle(angle);
- f.setXLabelSouth(!isGridYLabelReverse);
- f.setYLabelWest(!isGridXLabelReverse);
-
- if(!last.psCustomP.fromPsCustom)
- figures.add(f);
-
- return end;
-
- }catch(Exception e) { throw new InvalidFormatCommandException("psgrid or psaxes", line); } //$NON-NLS-1$
- }
-
-
-
-
- @Override
- public int actionsOnPicture(int line, Vector<PSTricksParameters> ps,
- String params) throws InvalidFormatCommandException
- {
- try
- {
- String[] path = {""};//$NON-NLS-1$
- int end = parseParametersPicture(line, params, path);
-// LaTeXDrawPoint2D position = new LaTeXDrawPoint2D();
-// BatchConvertFrame bcf = new BatchConvertFrame();
-// Image image = bcf.getImage(new File(path[0]));
-// BufferedImage bufferedI = new BufferedImage(image.getWidth(null),
-// image.getHeight(null), BufferedImage.TYPE_INT_RGB );
-// Graphics g = bufferedI.createGraphics();
-// g.drawImage(image,0,0,null);
-// g.dispose();
-//
-// Picture p = new Picture(true, position, bufferedI, path[0]);
-//
-// figures.add(p);
-
- return end;
-
- }catch(Exception e)
- {
- e.printStackTrace();
- throw new InvalidFormatCommandException("includegraphics", line); //$NON-NLS-1$
- }
- }
-
-
-
-
- @Override
- public int actionsOnFramedBox(int nLine, boolean hasStar, Vector<PSTricksParameters> ps,
- String cmd, String params, int type) throws InvalidFormatCommandException
- {
- int i = ps.size()-1;
- PSTricksParameters pp = null;
-
- while(pp==null && i>=0)
- if(ps.elementAt(i).getPosition()!=null)
- pp = ps.elementAt(i);
- else i--;
-
- if(pp==null)
- pp = ps.firstElement();
-
- FramedBox fb = new FramedBox(pp.psBoxText);
- fb.setStart(pp.textForFrame.length());
- pp.psBox.add(fb);
- PSTricksParameters newP = new PSTricksParameters(ps.lastElement());
- int end = -1;
- int[] j = {0};
- try
- {
- goToNextChar(params, j);
- if(params.charAt(j[0])=='*')
- {
- j[0]++;
- goToNextChar(params, j);
- }
- }
- catch(Exception e1) { throw new InvalidFormatCommandException(nLine); }
-
- if(params.charAt(j[0])=='[')
- {
- switch(type)
- {
- case 0:
- fb.setBoxType(FramedBox.BOX_RECTANGLE);
- end = parseParametersFrameEllipse(nLine, params, null, null, newP);
- if(newP.frameArc>0)
- {
- ((LaTeXDrawRectangle)fb.getBox()).setFrameArc(newP.frameArc);
- ((LaTeXDrawRectangle)fb.getBox()).setIsRound(true);
- }
- break;
- case 1:
- fb.setBoxType(FramedBox.BOX_CIRCLE);
- end = parseParametersCircle(nLine, params, null, null, newP);
- break;
- case 2:
- fb.setBoxType(FramedBox.BOX_TRIANGLE);
- end = parseParametersPolygon(nLine, params, null, newP);
- break;
- case 3:
- fb.setBoxType(FramedBox.BOX_DIAMOND);
- end = parseParametersPolygon(nLine, params, null, newP);
- break;
- case 4:
- fb.setBoxType(FramedBox.BOX_ELLIPSE);
- end = parseParametersFrameEllipse(nLine, params, null, null, newP);
- break;
- case 5:
- fb.setBoxType(FramedBox.BOX_RECTANGLE);
- end = parseParametersFrameEllipse(nLine, params, null, null, newP);
- if(newP.frameArc>0)
- {
- ((LaTeXDrawRectangle)fb.getBox()).setFrameArc(newP.frameArc);
- ((LaTeXDrawRectangle)fb.getBox()).setIsRound(true);
- }
- break;
- case 6:
- fb.setBoxType(FramedBox.BOX_RECTANGLE);
- end = parseParametersFrameEllipse(nLine, params, null, null, newP);
- if(newP.frameArc>0)
- {
- ((LaTeXDrawRectangle)fb.getBox()).setFrameArc(newP.frameArc);
- ((LaTeXDrawRectangle)fb.getBox()).setIsRound(true);
- }
- break;
- }
- j[0] = end;
- }
-
- try
- {
- goToNextChar(params, j);
- } catch(Exception e1) { throw new InvalidFormatCommandException(nLine); }
-
- switch(type)
- {
- case 0:
- fb.setBoxType(FramedBox.BOX_RECTANGLE);
- break;
- case 1:
- fb.setBoxType(FramedBox.BOX_CIRCLE);
- break;
- case 2:
- fb.setBoxType(FramedBox.BOX_TRIANGLE);
- break;
- case 3:
- fb.setBoxType(FramedBox.BOX_DIAMOND);
- break;
- case 4:
- fb.setBoxType(FramedBox.BOX_ELLIPSE);
- break;
- case 5:
- fb.setBoxType(FramedBox.BOX_RECTANGLE);
- break;
- case 6:
- fb.setBoxType(FramedBox.BOX_RECTANGLE);
- break;
- }
-
-
- if(params.charAt(j[0])!='{')//psframebox3, psframebox[framesep=0.3]3 for instance.
- {
- PSTricksParameters p;
- boolean again = true;
- int k = ps.size()-1;
-
- while(again && k>=0)
- {
- p = ps.elementAt(k);
- if(p.getPosition()!=null)
- {
- again = false;
- p.textForFrame+=params.charAt(j[0]);
- }
- else
- {
- p.textForFrame+=params.charAt(j[0]);
- k--;
- }
- }
-
- k = ps.size()-1;
- p=null;
-
- while(p==null && k>=0)
- if(ps.elementAt(k).getPosition()!=null)
- p = ps.elementAt(k);
- else k--;
-
- if(p==null)
- p = ps.firstElement();
-
- p.psBox.lastElement().setEnd(p.textForFrame.length());
- p.psBox.add(0, p.psBox.remove(p.psBox.size()-1));
-
- end=j[0]+1;
- }
-
- fb.setFrameSep(newP.frameSep*Figure.PPC);
- fb.setBoxSep(newP.boxSep);
-
- setFigureParameters(newP, fb.getBox(), hasStar);
-
- if(hasStar)
- {
- fb.getBox().setIsFilled(true);
- fb.getBox().setInteriorColor(newP.fillColor);
- fb.getBox().setLinesColor(newP.fillColor);
- }
-
- switch(type)
- {
- case 5:
- fb.getBox().setHasDoubleBoundary(true);
- break;
- case 6:
- fb.getBox().setHasShadow(true);
- break;
- }
-
- if(end==-1)
- end = j[0];
-
- return end;
- }
-
-
-
-
-
- @Override
- public void actionsOnTerminatedFramedBoxes(Vector<PSTricksParameters> params) throws InvalidFormatCommandException
- {
- PSTricksParameters pp = params.lastElement();
-
- String str = pp.psBoxText.getText();
-
- if(str.length()==0)
- str = " ";//$NON-NLS-1$
-
- pp.textParsed = pp.textForFrame;
- actionsOnText(params);
-
- if(pp.psBox.isEmpty())
- return;
-
- Text txt = (Text)figures.remove(figures.size()-1);
- boolean simpleBox = pp.psBox.size()==1 && pp.psBox.firstElement().getBoxedText().equals(txt.getText());
-
- if(simpleBox)
- {
- FramedBox fb = pp.psBox.firstElement();
- fb.setText(txt);
- fb.setStart(-1);
- fb.setEnd(-1);
- fb.getBox().setBordersPosition(PSTricksConstants.BORDERS_OUTSIDE);
- txt.setSimpleBox(fb);
- }
- else
- for(FramedBox fb : pp.psBox)
- {
- fb.setText(txt);
- txt.addBox(fb);
- fb.getBox().setBordersPosition(PSTricksConstants.BORDERS_OUTSIDE);
- }
-
- txt.setHasFramedBox(!pp.psBox.isEmpty());
- txt.setHasSimpleFramedBox(simpleBox);
- txt.updateFramedBoxes();
- txt.updateFontsBorders();
-
- if(!pp.psCustomP.fromPsCustom)
- figures.add(txt);
-
- if(simpleBox)
- {
- if(txt.getSimpleBox().getBoxType()==FramedBox.BOX_TRIANGLE)
- {
- double height = (txt.getSimpleBox().getBox().getTheSEBoundPoint().y-
- txt.getSimpleBox().getBox().getTheNWBoundPoint().y)/4.;
- LaTeXDrawPoint2D pos = txt.getPosition();
- txt.setPosition(new LaTeXDrawPoint2D(pos.x, pos.y+height));
- txt.getSimpleBox().getBox().updateShape();
- }
- }
- else
- {
- FramedBox fb, max=null;
- double xMin=Double.MAX_VALUE;
- int i=0, size = txt.getMultipleBox().size();
-
- while(i<size)
- {
- fb = txt.getMultipleBox().elementAt(i);
-
- if(fb.isBoxSep() && fb.getBoxType()==FramedBox.BOX_TRIANGLE &&
- fb.getBox().getTheNWBoundPoint().x<xMin)
- {
- xMin = fb.getBox().getTheNWBoundPoint().x;
- max = fb;
- }
- else i++;
- }
-
- if(max!=null)
- {
- double height = (max.getBox().getTheSEBoundPoint().y-max.getBox().getTheNWBoundPoint().y)/4.;
-
- LaTeXDrawPoint2D pos = txt.getPosition();
- txt.setPosition(new LaTeXDrawPoint2D(pos.x, pos.y+height));
- max.getBox().updateShape();
- }
-
- }
-
- txt.updateFramedBoxes();
- txt.updateFontsBorders();
- }
-
-
-
-
-
- /**
- * Optimises the figures; for instance, frame are transformed in square.
- * @param vFigures The figures to optimise.
- * @since 1.9
- */
- public static void optimizeCode(Vector<Figure> vFigures)
- {
- Vector<Arc> vArcs = new Vector<Arc>();
- Vector<Line> vLines = new Vector<Line>();
- Vector<BezierCurve> vCurves = new Vector<BezierCurve>();
- int sizevl, i, size, j;
-
- for(Figure f : vFigures)
- if(f instanceof Line)
- vLines.add((Line)f);
- else
- if(f instanceof Arc)
- vArcs.add((Arc)f);
- else
- if(f instanceof BezierCurve)
- vCurves.add((BezierCurve)f);
-
- sizevl = vLines.size();
-
- for(Arc a : vArcs)// We check if we can convert arc+line in chord.
- if(a.getType()==Arc2D.OPEN)
- {
- boolean again = true;
- i=0;
- LaTeXDrawPoint2D startP, endP, p1, p2;
- Line l=null;
-
- while(again && i<sizevl)
- {
- l = vLines.elementAt(i);
- startP = a.getStartPoint(true);
- endP = a.getEndPoint(true);
- p1 = l.getPt1();
- p2 = l.getPt2();
- startP.y*=-1;
- endP.y*=-1;
-
- if((startP.equals(p1, 1) && endP.equals(p2, 1)) ||
- (startP.equals(p2, 1) && endP.equals(p1, 1)))
- again = false;
- else
- i++;
- }
-
- if(!again && a.isParametersEquals(l, false, true))
- {
- vFigures.remove(l);
- a.setType(Arc2D.CHORD);
- }
- }
-
- if(vCurves.size()>1)// We try to concat the Bézier curves.
- {
- if(vCurves.size()<200)// We must set a limit otherwise it may have a freeze.
- {
- BezierCurve b1, b2;
-
- for(j=0; j<vCurves.size(); j++)
- {
- i = j+1;
- b1 = vCurves.elementAt(j);
-
- while(i<vCurves.size())
- {
- b2 = vCurves.elementAt(i);
-
- if(b1.isJoined(b2)==1 && b1.isParametersEquals(b2, true, true))
- {
- vCurves.remove(b2);
- vFigures.remove(b2);
- b1.join(b2);
- i=j+1;
- }
- else
- i++;
- }
- } //for
- }
-
- for(BezierCurve bc : vCurves)
- bc.replaceLastPointByClosing();
- }//if
-
- i = 0;
- while(i<vCurves.size()) // We check if the it is possible to close a curve.
- {
- BezierCurve bc = vCurves.elementAt(i);
- bc.replaceLastPointByClosing();
-
- if(bc.isOpen())
- {
- boolean again = true;
- size = vLines.size();
-
- for(int k=0; k<size && again; k++)//We try to close it with a line.
- if(bc.isLineClosingCurve(vLines.elementAt(k)) &&
- bc.isParametersEquals(vLines.elementAt(k), true, false))
- {
- bc.setOpen(false);
- bc.setCloseType(BezierCurve.CLOSE_TYPE_LINE);
- again = false;
- vFigures.remove(vLines.elementAt(k));
- }
-
- if(again)//We try to close it with a two-points curve.
- {
- j = 0;
-
- while(j<i && again)
- {
- BezierCurve bc2 = vCurves.elementAt(j);
-
- if(bc2.getNbPoints()==2 && bc.isOpen() && bc2.isCurveClosingCurve(bc)==1 &&
- bc.isParametersEquals(bc2, true, false))
- {
- bc.setOpen(false);
- bc.setCloseType(BezierCurve.CLOSE_TYPE_CURVE);
- again = false;
- vCurves.remove(j);
- vFigures.remove(bc2);
- i--;
- }
- else j++;
- }
-
- j = i+1;
- while(j<vCurves.size() && again)
- {
- BezierCurve bc2 = vCurves.elementAt(j);
-
- if(bc2.getNbPoints()==2 && bc.isOpen() && bc.isCurveClosingCurve(bc2)==1 &&
- bc.isParametersEquals(bc2, true, false))
- {
- bc.setOpen(false);
- bc.setCloseType(BezierCurve.CLOSE_TYPE_CURVE);
- again = false;
- vCurves.remove(j);
- vFigures.remove(bc2);
- }
- else j++;
- }
- }
- }//if(bc.isOpen())
- i++;
- }
-
- i=0;
- size = vFigures.size();
- while(i<size)
- {
- Figure f = vFigures.elementAt(i);
-
- if(f instanceof LaTeXDrawRectangle && !(f instanceof Square))
- {// We check if we can convert frame in square.
- LaTeXDrawRectangle frame = (LaTeXDrawRectangle)f;
-
- if(frame.getHeight()==frame.getWidth())
- {
- Square square = new Square(frame,true);
- vFigures.remove(i);
- vFigures.add(i, square);
- }
- }
- i++;
- }
- }
-
-
-
-
- @Override
- public void actionsOnterminatedPsCustom(PSTricksParameters param) throws NotFullyManagedException
- {
- Figure f;
- int i=0;
-
- while(!psCustFigures.isEmpty())
- {
- f = psCustFigures.remove(0);
-
- if(!(f instanceof AkinPoints) || ((AkinPoints)f).getNbPoints()>1)
- {
- if(f instanceof AkinPoints && ((AkinPoints)f).getType()==AkinPoints.TYPE_CURVES)
- {// We must transform the read points.
- AkinPoints ak = (AkinPoints)f;
- int j, size = ak.getNbPoints();
- LaTeXDrawPoint2D prev, curr = ak.getPoint(0);
-
- for(j=1; j<size; j++)
- {
- prev = curr;
- curr = ak.getPoint(j);
- curr.setLocation(2*curr.x-prev.x, 2*curr.y-prev.y);
- }
-
- ((AkinPoints)f).updateBorders();
- }
-
- figures.add(f);
- i++;
- }
- }
- }
-
-
-
-
- @Override
- public void actionsOnNewPath(int line)
- {
- psCustFigures.clear();
- }
-
-
-
-
- @Override
- public int parseOpenShadowCommand(PSTricksParameters param, int line, String txt) throws InvalidFormatCommandException
- {
- PSTricksParameters pstp = new PSTricksParameters(param);
- int end = super.parseOpenShadowCommand(pstp, line, txt);
-
- for(Figure f : psCustFigures)
- {
- f.setHasShadow(true);
- f.setShadowAngle(Math.toRadians(pstp.shadowAngle));
- f.setShadowColor(pstp.shadowCol);
- f.setShadowSize(Math.abs(pstp.shadowSize)*Figure.PPC);
- }
-
- if(psCustFigures.size()>0 && psCustFigures.lastElement() instanceof AkinPoints)
- {
- double xunit = param.unit!=PSTricksConstants.DEFAULT_UNIT? param.unit : param.xUnit;
- double yunit = param.unit!=PSTricksConstants.DEFAULT_UNIT? param.unit : param.yUnit;
-
- AkinPoints ak = new AkinPoints(new LaTeXDrawPoint2D(
- param.psCustomP.lastPosition.x*Figure.PPC*xunit,
- param.psCustomP.lastPosition.y*Figure.PPC*yunit*-1), true);
- ak.setInterval(1);
- ak.setType(AkinPoints.TYPE_LINES);
- psCustFigures.add(ak);
- }
-
- return end;
- }
-
-
-
-
- @Override
- public int actionsOnCurveTo(int line, Vector<PSTricksParameters> params, String txt)
- throws InvalidFormatCommandException
- {
- Point2D.Double p1 = new Point2D.Double();
- Point2D.Double p2 = new Point2D.Double();
- Point2D.Double p3 = new Point2D.Double();
- int end = parseParametersCurveTo(line, txt, p1, p2, p3);
- PSTricksParameters last = params.lastElement();
- AkinPoints ak ;
- double xunit = last.unit!=PSTricksConstants.DEFAULT_UNIT? last.unit : last.xUnit;
- double yunit = last.unit!=PSTricksConstants.DEFAULT_UNIT? last.unit : last.yUnit;
-
- if(psCustFigures.isEmpty() || !(psCustFigures.lastElement() instanceof AkinPoints))
- {
- ak = new AkinPoints(new LaTeXDrawPoint2D(last.psCustomP.lastPosition.x*Figure.PPC*xunit,
- last.psCustomP.lastPosition.y*Figure.PPC*-1*yunit), true);
- setFigureParameters(params.lastElement(), ak, false);
- ak.setInterval(1);
- psCustFigures.add(ak);
- }
- else ak = (AkinPoints)psCustFigures.lastElement();
-
- ak.setType(AkinPoints.TYPE_CURVES);
- ak.addPoint(new LaTeXDrawPoint2D(p3.x*Figure.PPC*xunit, p3.y*Figure.PPC*-1*yunit));
- last.psCustomP.lastPosition.setLocation(p3);
-
- return end;
- }
-
-
-
-
- @Override
- public int actionsOnLineTo(int line, Vector<PSTricksParameters> params, String txt) throws InvalidFormatCommandException
- {
- Point2D.Double p1 = new Point2D.Double();
- int end = parseParametersLineMoveTo(line, txt, p1);
- PSTricksParameters last = params.lastElement();
- AkinPoints ak ;
- double xunit = last.unit!=PSTricksConstants.DEFAULT_UNIT? last.unit : last.xUnit;
- double yunit = last.unit!=PSTricksConstants.DEFAULT_UNIT? last.unit : last.yUnit;
-
- if(psCustFigures.isEmpty() || !(psCustFigures.lastElement() instanceof AkinPoints))
- {
- ak = new AkinPoints(new LaTeXDrawPoint2D(last.psCustomP.lastPosition.x*Figure.PPC*xunit,
- last.psCustomP.lastPosition.y*Figure.PPC*-1*yunit), true);
- setFigureParameters(params.lastElement(), ak, false);
- ak.setInterval(1);
- ak.setType(AkinPoints.TYPE_LINES);
- psCustFigures.add(ak);
- }
- else ak = (AkinPoints)psCustFigures.lastElement();
-
- ak.addPoint(new LaTeXDrawPoint2D(p1.x*Figure.PPC*xunit, p1.y*Figure.PPC*-1*yunit));
- last.psCustomP.lastPosition.setLocation(p1);
-
- return end;
- }
-
-
-
-
- @Override
- public int actionsOnMoveTo(int line, Vector<PSTricksParameters> params, String txt) throws InvalidFormatCommandException
- {
- Point2D.Double p1 = new Point2D.Double();
- int end = parseParametersLineMoveTo(line, txt, p1);
- PSTricksParameters last = params.lastElement();
- last.psCustomP.lastPosition.setLocation(p1);
-
- return end;
- }
-
-
-
-
- @Override
- public void actionsOnClosePathCommand(int line)
- {
- if(!psCustFigures.isEmpty())
- {
- Figure f = psCustFigures.lastElement();
-
- if(f instanceof AkinPoints)
- ((AkinPoints)f).setOpen(false);
- }
- }
-
-}
-
-
+/*
+ * LaTeXDrawPSTricksParserActions.java
+ */
+package latexDraw.parsers.pstricks;
+
+import java.awt.geom.Arc2D;
+import java.awt.geom.Point2D;
+import java.util.Vector;
+
+import latexDraw.figures.*;
+import latexDraw.figures.properties.Arrowable;
+import latexDraw.parsers.InvalidFormatCommandException;
+import latexDraw.parsers.NotFullyManagedException;
+import latexDraw.parsers.pstricks.PSTricksParameters.PositionParameters;
+import latexDraw.psTricks.PSTricksConstants;
+import latexDraw.util.LaTeXDrawPoint2D;
+
+
+/**
+ * This class defines actions to do on a given command for the LaTeXDraw project.<br>
+ *<br>
+ * This file is part of LaTeXDraw<br>
+ * Copyright (c) 2005-2008 Arnaud BLOUIN<br>
+ *<br>
+ * 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
+ * any later version.<br>
+ *<br>
+ * 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.<br>
+ *<br>
+ *
+ * 09/06/06<br>
+ * @author Arnaud BLOUIN<br>
+ * @version 0.5<br>
+ */
+public class LaTeXDrawPSTricksParserActions extends PSTricksParserActionsManager
+{
+ /** The parsed figures. */
+ protected Vector<Figure> figures;
+
+ /** The figures contained in the pscustom command. Cleared at the end of each <code>pscustom</code> command.*/
+ public Vector<Figure> psCustFigures;
+
+
+
+ /**
+ * The constructor by default.
+ */
+ public LaTeXDrawPSTricksParserActions()
+ {
+ super();
+ psCustFigures = new Vector<Figure>();
+ figures = new Vector<Figure>();
+ }
+
+
+
+
+ @Override
+ public void actionsOnText(Vector<PSTricksParameters> params) throws InvalidFormatCommandException
+ {
+ if(params.isEmpty()) return;
+
+ if(params.lastElement().textParsed.length()!=0)
+ {
+ PSTricksParameters last = params.lastElement();
+
+ PositionParameters pp = null;
+ int i = params.size()-1;
+
+ while(pp==null && i>=0)
+ {
+ pp = params.elementAt(i).getPosition();
+ i--;
+ }
+
+ if(pp==null)
+ pp = new PositionParameters();
+
+ Text t = new Text(true);
+ Point2D.Double position = moveCoordinate(params, new Point2D.Double(0,0));
+ double angle = Math.toRadians(PSTricksParameters.getWholeRotationAngle(params));
+
+ if(position==null) throw new InvalidFormatCommandException("text", -1); //$NON-NLS-1$
+
+ if(last.textSize!=null && last.textSize.length()!=0)
+ t.setSizeByCommand(last.textSize);
+
+ if((last.textSeries!=null && last.textSeries.equals("b")) || last.textBold) //$NON-NLS-1$
+ t.setIsBold(true);
+ else t.setIsBold(false);
+
+ if((last.textShape!=null && (last.textShape.equals("sl") || //$NON-NLS-1$
+ last.textShape.equals("it")) || last.textItalic)) //$NON-NLS-1$
+ t.setIsItalic(true);
+ else t.setIsItalic(false);
+
+ t.setRotationAngle(-angle);
+ t.setText(last.textParsed);
+ t.setLinesColor(last.textColor);
+
+ if(last.textFamily!=null && last.textFamily.length()!=0)
+ t.setTextFontByFamily(last.textFamily);
+
+ t.updateFontsBorders();
+
+ LaTeXDrawPoint2D pos = new LaTeXDrawPoint2D(position.x*Figure.PPC-t.getWidth()/2.,
+ (position.y*Figure.PPC-t.getFontMetrics().getHeight()/4.)*-1);
+
+ if(pp.refPoint!=PositionParameters.REF_POINT_DEFAULT_CENTER)
+ {
+ double addX=0, addY=0;
+ Point2D.Double gc = new Point2D.Double((pos.x+t.getWidth())/2.,(pos.y+t.getHeight())/2.);
+
+ if(pp.refPoint==PositionParameters.REF_POINT_BASE)
+ addY=-t.getFontMetrics().getDescent();
+ else if(pp.refPoint==PositionParameters.REF_POINT_TOP)
+ addY=t.getFontMetrics().getAscent()/2.;
+ else if(pp.refPoint==PositionParameters.REF_POINT_BOTTOM)
+ addY=-t.getFontMetrics().getDescent()*2;
+ else if(pp.refPoint==PositionParameters.REF_POINT_LEFT)
+ addX=t.getWidth()/2.;
+ else if(pp.refPoint==PositionParameters.REF_POINT_RIGHT)
+ addX=-t.getWidth()/2.;
+ else if(pp.refPoint==PositionParameters.REF_POINT_RIGHT+PositionParameters.REF_POINT_BASE)
+ {
+ addY=-t.getFontMetrics().getDescent();
+ addX=-t.getWidth()/2.;
+ }else if(pp.refPoint==PositionParameters.REF_POINT_RIGHT+PositionParameters.REF_POINT_BOTTOM)
+ {
+ addY=-t.getFontMetrics().getDescent()*2;
+ addX=-t.getWidth()/2.;
+ }else if(pp.refPoint==PositionParameters.REF_POINT_RIGHT+PositionParameters.REF_POINT_TOP)
+ {
+ addY=t.getFontMetrics().getAscent()/2.;
+ addX=-t.getWidth()/2.;
+ }else if(pp.refPoint==PositionParameters.REF_POINT_LEFT+PositionParameters.REF_POINT_BASE)
+ {
+ addY=-t.getFontMetrics().getDescent();
+ addX=t.getWidth()/2.;
+ }else if(pp.refPoint==PositionParameters.REF_POINT_LEFT+PositionParameters.REF_POINT_BOTTOM)
+ {
+ addY=-t.getFontMetrics().getDescent()*2;
+ addX=t.getWidth()/2.;
+ }else if(pp.refPoint==PositionParameters.REF_POINT_LEFT+PositionParameters.REF_POINT_TOP)
+ {
+ addY=t.getFontMetrics().getAscent()/2.;
+ addX=t.getWidth()/2.;
+ }
+
+ addX+=pp.labelSep*Figure.PPC;
+
+ Point2D.Double pt = rotatePoint(new Point2D.Double(gc.x+addX, gc.y-addY), gc, angle);
+ pos.setLocation(pos.x+(pt.x-gc.x), pos.y-(pt.y-gc.y));
+ }
+
+ t.setPosition(pos);
+ t.updateFontsBorders();
+
+ if(last.psCustomP.fromPsCustom)
+ psCustFigures.add(t);
+ else
+ figures.add(t);
+ }
+ }
+
+
+
+
+ /**
+ * @return the figures
+ */
+ public Vector<Figure> getFigures()
+ {
+ return figures;
+ }
+
+
+
+ /**
+ * Allows to set the parameters of a figure <code>f</code>.
+ */
+ public void setFigureParameters(PSTricksParameters p, Figure f, boolean hasStar)
+ {
+ if(f==null) return ;
+
+ if(f.canHaveShadow())
+ {
+ f.setHasShadow(p.isShadow);
+ f.setShadowAngle(Math.toRadians(p.shadowAngle));
+ f.setShadowSize(Math.abs(p.shadowSize)*Figure.PPC);
+ f.setShadowColor(p.shadowCol);
+ }
+
+ if(f.canBeHatched())
+ {
+ f.setHatchingSep(p.hatchSep*Figure.PPC);
+ f.setGradientAngle(Math.toRadians(p.gradAngle));
+ f.setGradientEndColor(p.gradEnd);
+ f.setGradientMidPoint(p.gradMidPoint);
+ f.setGradientStartColor(p.gradBegin);
+ }
+
+ f.setLinesColor(p.lineColor);
+ f.setBordersPosition(p.borderPos);
+ f.setDoubleColor(p.dbleColor);
+ f.setDoubleSep(Math.abs(p.dbleSep*Figure.PPC));
+ f.setHasDoubleBoundary(p.dbleLine);
+ f.setHatchingColor(p.hatchCol);
+ if(p.fillStyle.equals(PSTricksConstants.TOKEN_FILL_SOLID))
+ f.setHatchingStyle(PSTricksConstants.TOKEN_FILL_NONE);
+ else f.setHatchingStyle(
+ p.fillStyle.endsWith("*") ? p.fillStyle.substring(0, p.fillStyle.length()-1) : p.fillStyle);//$NON-NLS-1$
+ f.setHatchingWidth((float)Math.abs(p.hatchWidth*Figure.PPC));
+ f.setDotSep((float) p.dotStep*Figure.PPC);
+ f.setHatchingAngle(Math.toRadians(p.hatchAngle));
+ f.setBlackDashLength((float)p.dashBlack*Figure.PPC);
+ f.setWhiteDashLength((float)p.dashWhite*Figure.PPC);
+ f.setInteriorColor(p.fillColor);
+ f.setIsFilled(p.fillStyle.equals(PSTricksConstants.TOKEN_FILL_SOLID) ||
+ p.fillStyle.equals(PSTricksConstants.TOKEN_FILL_CROSSHATCH_F) ||
+ p.fillStyle.equals(PSTricksConstants.TOKEN_FILL_HLINES_F) ||
+ p.fillStyle.equals(PSTricksConstants.TOKEN_FILL_VLINES_F));
+ f.setLineStyle(p.lineStyle);
+ f.setThickness((float)(Math.abs(p.lineWidth*Figure.PPC)));
+
+ if(hasStar)
+ {
+ f.setIsFilled(true);
+ f.setInteriorColor(f.getLinesColor());
+ f.setHasDoubleBoundary(false);
+ f.setLineStyle(PSTricksConstants.LINE_NONE_STYLE);
+ f.setHatchingStyle(PSTricksConstants.TOKEN_FILL_NONE);
+ f.setBordersPosition(PSTricksConstants.BORDERS_INSIDE);
+ }
+ }
+
+
+
+
+
+
+ @Override
+ public int actionsOnFrameEllipse(int line, boolean hasStar, Vector<PSTricksParameters> ps, String params,
+ boolean isFrame) throws InvalidFormatCommandException
+ {
+ try
+ {
+ if(ps.isEmpty()) return ERR_END_CMD_INDEX;
+
+ Point2D.Double p3;
+ PSTricksParameters p = ps.lastElement();
+ Point2D.Double p1 = new Point2D.Double(p.origin.x, p.origin.y);
+ Point2D.Double p2 = new Point2D.Double();
+ PSTricksParameters newP = new PSTricksParameters(p);
+ double angle = Math.toRadians(-PSTricksParameters.getWholeRotationAngle(ps));
+ int end = parseParametersFrameEllipse(line, params, p1, p2, newP);
+ double xunit = newP.unit==PSTricksConstants.DEFAULT_UNIT? newP.xUnit : newP.unit;
+ double yunit = newP.unit==PSTricksConstants.DEFAULT_UNIT? newP.yUnit : newP.unit ;
+ Figure f;
+ p1.setLocation(p1.x+p.origin.x, p1.y+p.origin.y);
+
+ if(isFrame)
+ {
+ p2.setLocation(p2.x+p.origin.x, p2.y+p.origin.y);
+ if(ps.size()>1)
+ {
+ p1 = moveCoordinate(ps, p1);
+ p2 = moveCoordinate(ps, p2);
+ p3 = new Point2D.Double((p1.x+p2.x)/2.,(p1.y+p2.y)/2.);
+ p1 = rotatePoint(p1, p3, angle);
+ p2 = rotatePoint(p2, p3, angle);
+ }
+
+ p1.setLocation(p1.x*Figure.PPC*xunit, p1.y*Figure.PPC*-1*yunit);
+ p2.setLocation(p2.x*Figure.PPC*xunit, p2.y*Figure.PPC*-1*yunit);
+
+ LaTeXDrawPoint2D pt1 = new LaTeXDrawPoint2D(p1.x, p2.y);
+ LaTeXDrawPoint2D pt2 = new LaTeXDrawPoint2D(p2.x, p2.y);
+ LaTeXDrawPoint2D pt3 = new LaTeXDrawPoint2D(p1.x, p1.y);
+ LaTeXDrawPoint2D pt4 = new LaTeXDrawPoint2D(p2.x, p1.y);
+
+ f = new LaTeXDrawRectangle(pt1, pt2, pt3, pt4, true);
+ ((LaTeXDrawRectangle)f).setIsRound(newP.frameArc>0);
+ if(newP.frameArc>0) ((LaTeXDrawRectangle)f).setFrameArc(newP.frameArc);
+ }
+ else
+ {
+ p1 = moveCoordinate(ps, p1);
+ p1.setLocation(p1.x*Figure.PPC*xunit, p1.y*Figure.PPC*-1*yunit);
+ p2.setLocation(p2.x*Figure.PPC*xunit, p2.y*Figure.PPC*-1*yunit);
+
+ LaTeXDrawPoint2D pt1 = new LaTeXDrawPoint2D(p1.x-p2.x, p1.y+p2.y);
+ LaTeXDrawPoint2D pt2 = new LaTeXDrawPoint2D(p1.x+p2.x, p1.y+p2.y);
+ LaTeXDrawPoint2D pt3 = new LaTeXDrawPoint2D(p1.x-p2.x, p1.y-p2.y);
+ LaTeXDrawPoint2D pt4 = new LaTeXDrawPoint2D(p1.x+p2.x, p1.y-p2.y);
+
+ f = new Ellipse(pt1, pt2, pt3, pt4, true);
+ }
+
+ setFigureParameters(newP, f, hasStar);
+ f.setRotationAngle(angle);
+
+ if(p.psCustomP.fromPsCustom)
+ psCustFigures.add(f);
+ else
+ figures.add(f);
+
+ return end;
+
+ }catch(Exception e)
+ {
+ if(isFrame)
+ throw new InvalidFormatCommandException("psframe", line); //$NON-NLS-1$
+ throw new InvalidFormatCommandException("psellipse", line); //$NON-NLS-1$
+ }
+ }
+
+
+
+
+ @Override
+ public int actionsOnCircle(int line, boolean hasStar, Vector<PSTricksParameters> ps, String params)
+ throws InvalidFormatCommandException
+ {
+ try
+ {
+ PSTricksParameters p = ps.lastElement();
+ Point2D.Double center = new Point2D.Double(p.origin.x, p.origin.y);
+ double[] radius = {1};
+ PSTricksParameters newP = new PSTricksParameters(p);
+ Figure c;
+ double angle = Math.toRadians(-PSTricksParameters.getWholeRotationAngle(ps));
+ int end = parseParametersCircle(line, params, center, radius, newP);
+ LaTeXDrawPoint2D pt1, pt2, pt3, pt4;
+ center = moveCoordinate(ps, center);
+
+ pt1 = new LaTeXDrawPoint2D((p.origin.x+center.x-radius[0])*Figure.PPC*newP.unit,
+ (p.origin.y+center.y+radius[0])*Figure.PPC*-1*newP.unit);
+ pt2 = new LaTeXDrawPoint2D((p.origin.x+center.x+radius[0])*Figure.PPC*newP.unit,
+ (p.origin.y+center.y+radius[0])*Figure.PPC*-1*newP.unit);
+ pt3 = new LaTeXDrawPoint2D((p.origin.x+center.x-radius[0])*Figure.PPC*newP.unit,
+ (p.origin.y+center.y-radius[0])*Figure.PPC*-1*newP.unit);
+ pt4 = new LaTeXDrawPoint2D((p.origin.x+center.x+radius[0])*Figure.PPC*newP.unit,
+ (p.origin.y+center.y-radius[0])*Figure.PPC*-1*newP.unit);
+
+ c = new Circle(pt1, pt2, pt3, pt4, true);
+ setFigureParameters(newP, c, hasStar);
+ c.setRotationAngle(angle);
+
+ if(p.psCustomP.fromPsCustom)
+ psCustFigures.add(c);
+ else
+ figures.add(c);
+
+ return end;
+
+ }catch(Exception e) { throw new InvalidFormatCommandException("pscircle", line); } //$NON-NLS-1$
+ }
+
+
+
+
+
+
+ @Override
+ public int actionsOnDot(int line, Vector<PSTricksParameters> ps, String params,
+ boolean noCoordinatePossible) throws InvalidFormatCommandException
+ {
+ try
+ {
+ if(ps==null || ps.isEmpty()) return ERR_END_CMD_INDEX;
+ // It can have several points defined
+ Vector<Point2D.Double> center = new Vector<Point2D.Double>();
+ PSTricksParameters last = ps.lastElement();
+ PSTricksParameters newP = new PSTricksParameters(last);
+ double angle = Math.toRadians(-PSTricksParameters.getWholeRotationAngle(ps));
+ int end = parseParametersDot(line, params, center, newP, noCoordinatePossible);
+ double xunit = newP.unit==PSTricksConstants.DEFAULT_UNIT? newP.xUnit : newP.unit;
+ double yunit = newP.unit==PSTricksConstants.DEFAULT_UNIT? newP.yUnit : newP.unit ;
+ newP.arrowDotSD = newP.arrowDotSD+newP.arrowDotSN<0 ? Math.abs(newP.arrowDotSD) : newP.arrowDotSD;
+ newP.arrowDotSN = newP.arrowDotSD+newP.arrowDotSN<0 ? Math.abs(newP.arrowDotSN) : newP.arrowDotSN;
+ newP.dotScale1 = Math.abs(newP.dotScale1);
+
+ for(Point2D.Double pt: center)
+ {
+ pt = moveCoordinate(ps, pt);
+ Dot d = new Dot(new LaTeXDrawPoint2D(pt.x*Figure.PPC*xunit, pt.y*Figure.PPC*-1*yunit),
+ true);
+ setFigureParameters(newP, d, false);
+
+ d.setCurrentStyle(newP.dotStyle);
+ d.setWidth((float)((newP.arrowDotSD+newP.arrowDotSN*newP.lineWidth)*newP.dotScale1)*Figure.PPC);
+ d.setRotationAngle(Math.toRadians(-newP.dotAngle)+angle);
+ d.setInteriorColor(newP.fillColor);
+
+ if(!last.psCustomP.fromPsCustom)
+ figures.add(d);
+ }
+
+ return end;
+
+ }catch(Exception e) { throw new InvalidFormatCommandException("psdot", line); }//$NON-NLS-1$
+ }
+
+
+
+
+
+
+ @Override
+ public int actionsOnLine(int line, boolean hasStar, Vector<PSTricksParameters> ps,
+ String params) throws InvalidFormatCommandException
+ {
+ try
+ {
+ if(ps==null || ps.isEmpty()) return ERR_END_CMD_INDEX;
+
+ Vector<Point2D.Double> pts = new Vector<Point2D.Double>();
+ PSTricksParameters last = ps.lastElement();
+ PSTricksParameters newP = new PSTricksParameters(last);
+ Figure f;
+ int end = parseParametersLine(line, params, pts, newP);
+ double xunit = newP.unit==PSTricksConstants.DEFAULT_UNIT? newP.xUnit : newP.unit;
+ double yunit = newP.unit==PSTricksConstants.DEFAULT_UNIT? newP.yUnit : newP.unit ;
+
+ if(pts.isEmpty()) return end;
+
+ if(ps.size()>1)
+ for(Point2D.Double pt : pts)
+ pt.setLocation(moveCoordinate(ps, pt));
+
+ if(pts.size()>2)//joined lines
+ f = new JoinedLines(new LaTeXDrawPoint2D(), new LaTeXDrawPoint2D(), true);
+ else
+ f = new Line(new LaTeXDrawPoint2D(), new LaTeXDrawPoint2D(), true);
+
+
+ Point2D.Double ptOld= null;
+
+ for(Point2D.Double pt : pts)
+ if(!pt.equals(ptOld))
+ {
+ ((LaTeXDrawPolygon)f).addPoint(new LaTeXDrawPoint2D(pt.x*Figure.PPC*xunit,
+ pt.y*Figure.PPC*-1*yunit));
+ ptOld = pt;
+ }
+
+ if(pts.size()>2)//joined lines
+ {
+ ((JoinedLines)f).removePointAt(0);
+ ((JoinedLines)f).removePointAt(0);
+ ((JoinedLines)f).setArrow2Style(ArrowHead.invertArrowStyle(newP.arrowStyle[1]));
+
+ if(((JoinedLines)f).getNbPoints()<2)
+ return end;
+ }
+ else
+ {
+ ((Line)f).removePointAt(0);
+ ((Line)f).removePointAt(0);
+ ((Line)f).setArrow2Style(newP.arrowStyle[1]);
+ }
+
+ ((Arrowable)f).setArrow1Style(newP.arrowStyle[0]);
+ setArrowParameters(((Arrowable)f).getArrowHead1(), newP);
+ setArrowParameters(((Arrowable)f).getArrowHead2(), newP);
+ setFigureParameters(newP, f, hasStar);
+
+ if(last.psCustomP.fromPsCustom)
+ psCustFigures.add(f);
+ else
+ figures.add(f);
+
+ return end;
+
+ }catch(Exception e) { e.printStackTrace(); throw new InvalidFormatCommandException("psline", line); }//$NON-NLS-1$
+ }
+
+
+
+
+ /**
+ * Sets the parameters of an arrowhead.
+ * @param ah The arrowhead.
+ * @param param The parameters.
+ * @since 0.2.1
+ */
+ protected void setArrowParameters(ArrowHead ah, PSTricksParameters param)
+ {
+ ah.setArrowInset(param.arrowInset);
+ ah.setArrowLength(param.arrowLgth);
+ ah.setArrowSizeDim(param.arrowSizeD*Figure.PPC);
+ ah.setArrowSizeNum(param.arrowSizeN);
+ ah.setBracketNum(param.arrowBrLgth);
+ ah.setDotSizeDim((param.arrowDotSD+param.arrowDotSN<0 ? Math.abs(param.arrowDotSD) : param.arrowDotSD)*Figure.PPC);
+ ah.setDotSizeNum(param.arrowDotSD+param.arrowDotSN<0 ? Math.abs(param.arrowDotSN) : param.arrowDotSN);
+ ah.setRBracketNum(param.arrowrBrLgth);
+ ah.setTBarSizeDim(param.arrowTBarSD+param.arrowTBarSD<0 ? Math.abs(param.arrowTBarSD) : param.arrowTBarSD*Figure.PPC);
+ ah.setTBarSizeNum(param.arrowTBarSD+param.arrowTBarSD<0 ? Math.abs(param.arrowTBarSN) : param.arrowTBarSN);
+
+ }
+
+
+
+ @Override
+ public int actionsOnPolygon(int line, boolean hasStar, Vector<PSTricksParameters> ps,
+ String params) throws InvalidFormatCommandException
+ {
+ try
+ {
+ if(ps==null || ps.isEmpty()) return ERR_END_CMD_INDEX;
+
+ Vector<Point2D.Double> pts = new Vector<Point2D.Double>();
+ PSTricksParameters last = ps.lastElement();
+ PSTricksParameters newP = new PSTricksParameters(last);
+ int end = parseParametersPolygon(line, params, pts, newP);
+ double xunit = newP.unit!=PSTricksConstants.DEFAULT_UNIT? newP.unit : newP.xUnit;
+ double yunit = newP.unit!=PSTricksConstants.DEFAULT_UNIT? newP.unit : newP.yUnit;
+
+ if(pts.size()<2) return end;
+
+ LaTeXDrawPolygon pol = new LaTeXDrawPolygon(new LaTeXDrawPoint2D(), new LaTeXDrawPoint2D(), true);
+ Point2D.Double ptOld= null;
+
+ if(pts.size()==2)
+ pts.add(new Point2D.Double(newP.origin.x, newP.origin.y));
+
+ for(Point2D.Double pt : pts)
+ {
+ pt.setLocation(moveCoordinate(ps, pt));
+ if(!pt.equals(ptOld))
+ {
+ pol.addPoint(new LaTeXDrawPoint2D(pt.x*Figure.PPC*xunit, pt.y*Figure.PPC*-1*yunit));
+ ptOld = pt;
+ }
+ }
+
+ pol.removePointAt(0);
+ pol.removePointAt(0);
+
+ if(pol.getNbPoints()<3)
+ return end;
+
+ setFigureParameters(newP, pol, hasStar);
+
+ pol.updateBorders();
+ pol.updateGravityCenter();
+
+ if(last.psCustomP.fromPsCustom)
+ psCustFigures.add(pol);
+ else
+ figures.add(pol);
+
+ return end;
+
+ }catch(Exception e) { throw new InvalidFormatCommandException("pspolygon", line); }//$NON-NLS-1$
+ }
+
+
+
+
+
+
+
+ @Override
+ public int actionsOnDiamondTriangle(int line, boolean hasStar, Vector<PSTricksParameters> ps,
+ String params, boolean isDiamondNotTriangle) throws InvalidFormatCommandException
+ {
+ try
+ {
+ if(ps==null || ps.isEmpty()) return ERR_END_CMD_INDEX;
+
+ PSTricksParameters p = ps.lastElement();
+ Point2D.Double p1 = new Point2D.Double(p.origin.x, p.origin.y);
+ Point2D.Double p2 = new Point2D.Double();
+ PSTricksParameters newP = new PSTricksParameters(p);
+ Figure f;
+ double angle = Math.toRadians(-PSTricksParameters.getWholeRotationAngle(ps));
+ int end = parseParametersFrameEllipse(line, params, p1, p2, newP);
+ double xunit = newP.unit!=PSTricksConstants.DEFAULT_UNIT? newP.unit : newP.xUnit;
+ double yunit = newP.unit!=PSTricksConstants.DEFAULT_UNIT? newP.unit : newP.yUnit;
+ p1.setLocation(p1.x+p.origin.x, p1.y+p.origin.y);
+ double moduloA;
+ if(ps.size()>1) moduloA = ps.elementAt(ps.size()-2).degrees;
+ else moduloA = 360;
+
+ if(isDiamondNotTriangle)
+ {
+ if(ps.size()>1)
+ p1 = moveCoordinate(ps, p1);
+
+ LaTeXDrawPoint2D pt1 = new LaTeXDrawPoint2D((p1.x-p2.x)*Figure.PPC*xunit,
+ (p1.y-p2.y)*Figure.PPC*-1*yunit);
+ LaTeXDrawPoint2D pt2 = new LaTeXDrawPoint2D((p1.x+p2.x)*Figure.PPC*xunit,
+ (p1.y-p2.y)*Figure.PPC*-1*yunit);
+ LaTeXDrawPoint2D pt3 = new LaTeXDrawPoint2D((p1.x-p2.x)*Figure.PPC*xunit,
+ (p1.y+p2.y)*Figure.PPC*-1*yunit);
+ LaTeXDrawPoint2D pt4 = new LaTeXDrawPoint2D((p1.x+p2.x)*Figure.PPC*xunit,
+ (p1.y+p2.y)*Figure.PPC*-1*yunit);
+
+ f = new Rhombus(pt1, pt2, pt3, pt4, true);
+ }
+ else
+ {
+ Point2D.Double p3 = new Point2D.Double();
+ if(ps.size()>1)
+ {
+ p1 = moveCoordinate(ps, p1);
+ p3 = new Point2D.Double(p1.x,p1.y-p2.y/2.);
+ p1 = rotatePoint(p1, p3, -angle);
+ }
+
+ LaTeXDrawPoint2D pt1 = new LaTeXDrawPoint2D((p1.x-p2.x/2.)*Figure.PPC*xunit,
+ (p1.y+p2.y)*Figure.PPC*-1*yunit);
+ LaTeXDrawPoint2D pt2 = new LaTeXDrawPoint2D((p1.x+p2.x/2.)*Figure.PPC*xunit,
+ (p1.y+p2.y)*Figure.PPC*-1*yunit);
+ LaTeXDrawPoint2D pt3 = new LaTeXDrawPoint2D((p1.x-p2.x/2.)*Figure.PPC*xunit,
+ (p1.y)*Figure.PPC*-1*yunit);
+ LaTeXDrawPoint2D pt4 = new LaTeXDrawPoint2D((p1.x+p2.x/2.)*Figure.PPC*xunit,
+ (p1.y)*Figure.PPC*-1*yunit);
+
+ f = new Triangle(pt1, pt2, pt3, pt4, true);
+
+ if((newP.gangle%moduloA)!=0)
+ {
+ LaTeXDrawPoint2D gc = f.getGravityCenter();
+ LaTeXDrawPoint2D base = new LaTeXDrawPoint2D((pt1.x+pt2.x)/2., pt3.y);
+ LaTeXDrawPoint2D newGc = Figure.rotatePoint(gc, base, Math.toRadians(-(360/moduloA)*newP.gangle));
+ f.shift(gc, newGc);
+ }
+ }
+
+ setFigureParameters(newP, f, hasStar);
+
+ if(isDiamondNotTriangle)
+ {
+ Rhombus r = ((Rhombus)f);
+ r.setShadowAngle(r.getShadowAngle()-Math.toRadians(newP.gangle%moduloA));
+ r.setHatchingAngle(r.getHatchingAngle()-Math.toRadians(newP.gangle%moduloA));
+ r.setGradientAngle(r.getGradientAngle()-Math.toRadians(newP.gangle%moduloA));
+
+ if((newP.gangle%moduloA)!=0)
+ r.setRotationAngle(Math.toRadians(-(360/moduloA)*newP.gangle)+angle);
+ else r.setRotationAngle(angle);
+ }
+ else
+ {
+ Triangle t = ((Triangle)f);
+ boolean reverse = t.getPoint(0).y>t.getPoint(2).y;
+
+ t.setRotationAngle(angle); // fixes #1556340
+ if(reverse)
+ {
+ t.setShadowAngle(t.getShadowAngle()+Math.PI);
+ t.setGradientAngle(t.getGradientAngle()+Math.PI);
+ }
+ }
+
+ if(p.psCustomP.fromPsCustom)
+ psCustFigures.add(f);
+ else
+ figures.add(f);
+
+ return end;
+
+ }catch(Exception e)
+ {
+ if(isDiamondNotTriangle)
+ throw new InvalidFormatCommandException("psdiamond", line); //$NON-NLS-1$
+ throw new InvalidFormatCommandException("triangle", line); //$NON-NLS-1$
+ }
+ }
+
+
+
+
+
+ @Override
+ public int actionsOnBezierCurve(int line, boolean hasStar, Vector<PSTricksParameters> ps,
+ String params) throws InvalidFormatCommandException
+ {
+ try
+ {
+ if(ps==null || ps.isEmpty()) return ERR_END_CMD_INDEX;
+
+ Vector<Point2D.Double> pts = new Vector<Point2D.Double>();
+ PSTricksParameters last = ps.lastElement();
+ PSTricksParameters newP = new PSTricksParameters(last);
+ LaTeXDrawPoint2D p1;
+ int ended = parseParametersBezierCurve(line, params, pts, newP), i, size, j;
+ double xunit = newP.unit!=PSTricksConstants.DEFAULT_UNIT? newP.unit : newP.xUnit;
+ double yunit = newP.unit!=PSTricksConstants.DEFAULT_UNIT? newP.unit : newP.yUnit;
+
+ if(pts.size()<3) return ended;
+
+ for(Point2D.Double pt : pts)
+ pt.setLocation(moveCoordinate(ps, pt));
+
+ if(pts.size()%3==0)
+ p1 = new LaTeXDrawPoint2D(newP.origin.x*Figure.PPC*xunit, newP.origin.y*-1*Figure.PPC*yunit);
+ else
+ {
+ p1 = new LaTeXDrawPoint2D(pts.firstElement().x*Figure.PPC*xunit, pts.firstElement().y*-1*Figure.PPC*yunit);
+ pts.removeElementAt(0);
+ }
+
+ Point2D.Double pt2;
+ BezierCurve f = new BezierCurve(p1,
+ new LaTeXDrawPoint2D(pts.elementAt(2).x*Figure.PPC*xunit,
+ pts.elementAt(2).y*-1*Figure.PPC*yunit), true);
+
+ f.setXCoordFirstCtrl(pts.firstElement().x*Figure.PPC*xunit, 0);
+ f.setYCoordFirstCtrl(pts.firstElement().y*-1*Figure.PPC*yunit, 0);
+ f.setXCoordFirstCtrl(pts.elementAt(1).x*Figure.PPC*xunit, 1);
+ f.setYCoordFirstCtrl(pts.elementAt(1).y*-1*Figure.PPC*yunit, 1);
+
+ i = 4;
+ j = 2;
+ size = pts.size();
+
+ while(i<size)
+ {
+ pt2 = pts.elementAt(i);
+ ++i;
+
+ f.addPoint(new LaTeXDrawPoint2D(pts.elementAt(i).x*Figure.PPC*xunit,
+ pts.elementAt(i).y*-1*Figure.PPC*yunit));
+
+ f.setXCoordFirstCtrl(pt2.x*Figure.PPC*xunit, j);
+ f.setYCoordFirstCtrl(pt2.y*-1*Figure.PPC*yunit, j);
+ j++;
+ i+=2;
+ }
+
+ setFigureParameters(newP, f, hasStar);
+
+ f.updateSecondControlPoints();
+ f.updateShape();
+ f.updateBorders();
+ f.setShowPoints(newP.showPoints);
+ f.setOpen(true);
+ f.replaceLastPointByClosing();
+
+ ((Arrowable)f).setArrow1Style(newP.arrowStyle[0]);
+ ((Arrowable)f).setArrow2Style(ArrowHead.invertArrowStyle(newP.arrowStyle[1]));
+ setArrowParameters(((Arrowable)f).getArrowHead1(), newP);
+ setArrowParameters(((Arrowable)f).getArrowHead2(), newP);
+
+ if(f.getNbPoints()>1)
+ if(last.psCustomP.fromPsCustom)
+ psCustFigures.add(f);
+ else
+ figures.add(f);
+
+ return ended;
+
+ }catch(Exception e) { throw new InvalidFormatCommandException("psbezier", line); } //$NON-NLS-1$
+ }
+
+
+
+
+
+ @Override
+ public int actionsOnArcWedge(int line, boolean hasStar, Vector<PSTricksParameters> ps, String params,
+ boolean isArc) throws InvalidFormatCommandException
+ {
+ try
+ {
+ PSTricksParameters p = ps.lastElement();
+ Point2D.Double center = (Point2D.Double)p.origin.clone();
+ PSTricksParameters newP = new PSTricksParameters(p);
+ double[] angle1 = {0}, angle2 = {0}, radius = {0};
+ double angle = Math.toRadians(-PSTricksParameters.getWholeRotationAngle(ps));
+
+ int end = parseParametersArcWedge(line, params, radius, center, angle1, angle2, newP, isArc);
+
+ center = moveCoordinate(ps, center);
+
+ Arc f = new Arc(new LaTeXDrawPoint2D((center.x-radius[0])*Figure.PPC*newP.xUnit,
+ (center.y+radius[0])*Figure.PPC*-1*newP.xUnit),
+ new LaTeXDrawPoint2D((center.x+radius[0])*Figure.PPC*newP.xUnit,
+ (center.y-radius[0])*Figure.PPC*-1*newP.xUnit), isArc ? Arc2D.OPEN : Arc2D.PIE, true);
+
+ f.setStartAngle(Math.toRadians(angle1[0]));
+ f.setEndAngle(Math.toRadians(angle2[0]));
+ f.setShowPoints(newP.showPoints);
+ f.setArrow1Style(newP.arrowStyle[0]);
+
+ String currentArrowRStyle = newP.arrowStyle[1];
+ if(currentArrowRStyle.equals(PSTricksConstants.DLARROW_STYLE))
+ currentArrowRStyle = PSTricksConstants.DRARROW_STYLE;
+ else if(currentArrowRStyle.equals(PSTricksConstants.DRARROW_STYLE))
+ currentArrowRStyle = PSTricksConstants.DLARROW_STYLE;
+ else if(currentArrowRStyle.equals(PSTricksConstants.RARROW_STYLE))
+ currentArrowRStyle = PSTricksConstants.LARROW_STYLE;
+ else if(currentArrowRStyle.equals(PSTricksConstants.LARROW_STYLE))
+ currentArrowRStyle = PSTricksConstants.RARROW_STYLE;
+ else if(currentArrowRStyle.equals(PSTricksConstants.DLARROW_STYLE))
+ currentArrowRStyle = PSTricksConstants.DRARROW_STYLE;
+ else if(currentArrowRStyle.equals(PSTricksConstants.LRBRACKET_STYLE))
+ currentArrowRStyle = PSTricksConstants.RRBRACKET_STYLE;
+ else if(currentArrowRStyle.equals(PSTricksConstants.RRBRACKET_STYLE))
+ currentArrowRStyle = PSTricksConstants.LRBRACKET_STYLE;
+ else if(currentArrowRStyle.equals(PSTricksConstants.RSBRACKET_STYLE))
+ currentArrowRStyle = PSTricksConstants.LSBRACKET_STYLE;
+ else if(currentArrowRStyle.equals(PSTricksConstants.LSBRACKET_STYLE))
+ currentArrowRStyle = PSTricksConstants.RSBRACKET_STYLE;
+
+ f.setArrow2Style(currentArrowRStyle);
+
+ setArrowParameters(f.getArrowHead1(), newP);
+ setArrowParameters(f.getArrowHead2(), newP);
+ setFigureParameters(newP, f, hasStar);
+ f.setRotationAngle(angle);
+
+ if(p.psCustomP.fromPsCustom)
+ psCustFigures.add(f);
+ else
+ figures.add(f);
+
+ return end;
+
+ }catch(Exception e)
+ {
+ if(isArc)
+ throw new InvalidFormatCommandException("psarc", line); //$NON-NLS-1$
+ throw new InvalidFormatCommandException("pswedge", line); //$NON-NLS-1$
+ }
+ }
+
+
+
+
+ @Override
+ public int actionsOnGridAxes(int line, Vector<PSTricksParameters> ps, Point2D.Double pictureSWPt,
+ Point2D.Double pictureNEPt, String params, boolean isGrid) throws InvalidFormatCommandException
+ {
+ try
+ {
+ if(ps==null || ps.isEmpty()) return ERR_END_CMD_INDEX;
+
+ Vector<Point2D.Double> pts = new Vector<Point2D.Double>();
+ PSTricksParameters last = ps.lastElement();
+ PSTricksParameters newP = new PSTricksParameters(last);
+ int gridEndX, gridEndY, gridStartX, gridStartY, originX, originY;
+ double angle = Math.toRadians(-PSTricksParameters.getWholeRotationAngle(ps));
+ int end = parseParametersGridAxes(line, params, pts, newP);
+ double xunit = newP.unit!=PSTricksConstants.DEFAULT_UNIT? newP.unit : newP.xUnit;
+ double yunit = newP.unit!=PSTricksConstants.DEFAULT_UNIT? newP.unit : newP.yUnit;
+ newP.origin.setLocation(moveCoordinate(ps, newP.origin));
+ boolean isGridXLabelReverse = false;
+ boolean isGridYLabelReverse = false;
+
+ if(pts.isEmpty())
+ {
+ if(pictureNEPt.x>=0)
+ gridEndX = (pictureNEPt.x-((int)pictureNEPt.x))>0.5 ? (int)pictureNEPt.x+1 : (int)pictureNEPt.x;
+ else gridEndX = (((int)pictureNEPt.x)-pictureNEPt.x)>0.5 ? (int)pictureNEPt.x-1 : (int)pictureNEPt.x;
+ if(pictureNEPt.y>=0)
+ gridEndY = (pictureNEPt.y-((int)pictureNEPt.y))>0.5 ? (int)pictureNEPt.y+1 : (int)pictureNEPt.y;
+ else gridEndY = (((int)pictureNEPt.y)-pictureNEPt.y)>0.5 ? (int)pictureNEPt.y-1 : (int)pictureNEPt.y;
+
+ if(pictureSWPt.x>=0)
+ gridStartX = originX = (pictureSWPt.x-((int)pictureSWPt.x))>0.5 ? (int)pictureSWPt.x+1 : (int)pictureSWPt.x;
+ else gridStartX = originX = (((int)pictureSWPt.x)-pictureSWPt.x)>0.5 ? (int)pictureSWPt.x-1 : (int)pictureSWPt.x;
+
+ if(pictureSWPt.y>=0)
+ gridStartY = originY = (pictureSWPt.y-((int)pictureSWPt.y))>0.5 ? (int)pictureSWPt.y+1 : (int)pictureSWPt.y;
+ else gridStartY = originY = (((int)pictureSWPt.y)-pictureSWPt.y)>0.5 ? (int)pictureSWPt.y-1 : (int)pictureSWPt.y;
+ }
+ else
+ if(pts.size()==1)
+ {
+ gridStartX = gridStartY = originX = originY = 0;
+ gridEndX = (int)pts.firstElement().x;
+ gridEndY = (int)pts.firstElement().y;
+ }
+ else
+ if(pts.size()==2)
+ {
+ originX = gridStartX = (int)pts.firstElement().x;
+ originY = gridStartY = (int)pts.firstElement().y;
+ gridEndX = (int)pts.elementAt(1).x;
+ gridEndY = (int)pts.elementAt(1).y;
+ }
+ else
+ {
+ originX = (int)pts.firstElement().x;
+ originY = (int)pts.firstElement().y;
+ gridStartX = (int)pts.elementAt(1).x;
+ gridStartY = (int)pts.elementAt(1).y;
+ gridEndX = (int)pts.elementAt(2).x;
+ gridEndY = (int)pts.elementAt(2).y;
+ }
+
+ if(gridStartX>=gridEndX)
+ {
+ int tmp = gridEndX;
+ gridEndX = gridStartX;
+ gridStartX = tmp;
+ isGridXLabelReverse = true;
+ }
+
+ if(gridStartY>=gridEndY)
+ {
+ int tmp = gridEndY;
+ gridEndY = gridStartY;
+ gridStartY = tmp;
+ isGridYLabelReverse = true;
+ }
+
+ LaTeXDrawPoint2D position = new LaTeXDrawPoint2D(newP.origin.x*Figure.PPC,newP.origin.y*Figure.PPC*-1);
+ GridShape f=null;
+
+ if(angle!=0)
+ {
+ Point2D.Double tmp1 = new Point2D.Double(
+ position.x+((gridEndX+gridStartX)/2.)*Figure.PPC*xunit,
+ position.y-((gridEndY+gridStartY)/2.)*Figure.PPC*yunit);
+ Point2D.Double tmp = rotatePoint(tmp1, position, angle);
+ position.setLocation(position.x+(tmp.x-tmp1.x), position.y+(tmp.y-tmp1.y));
+ }
+
+ if(isGrid)
+ {
+ f = new Grid(position, true);
+ Grid g = (Grid)f;
+ g.setUnit(xunit);
+ g.setGridDots(newP.gridDots);
+ g.setGridLabelsColor(newP.labelsGridCol);
+ g.setGridLabelsSize((int)((newP.gridLabel*PSTricksConstants.CM_VAL_PT)/0.6));
+ g.setGridWidth((float)Math.abs(newP.gridWidth*Figure.PPC));
+ g.setSubGridColor(newP.subGridCol);
+ g.setSubGridDiv(newP.subGridDiv);
+ g.setSubGridDots(newP.subGridDots);
+ g.setSubGridWidth((float)Math.abs(newP.subGridWidth*Figure.PPC));
+ g.setOriginX(originX);
+ g.setOriginY(originY);
+ g.setLinesColor(newP.gridColor);
+ }
+ else
+ {
+ f = new Axe(position, true);
+ Axe a = (Axe)f;
+ a.setOriginX((int)newP.ox);
+ a.setOriginY((int)newP.oy);
+ a.setLabelsDisplayedToken(newP.labels);
+ a.setTicksDisplayedToken(newP.ticks);
+ a.setTicksStyleToken(newP.ticksStyle);
+ a.setTicksSize(newP.ticksSize*Figure.PPC);
+ a.setIncrementX(newP.dxIncrement);
+ a.setIncrementY(newP.dyIncrement);
+ a.setDistLabelsX(newP.dxLabelDist);
+ a.setDistLabelsY(newP.dyLabelDist);
+ a.setShowOrigin(newP.showOrigin);
+ a.setAxesStyleToken(newP.axesStyle);
+ setFigureParameters(newP, a, false);
+
+ String arrowHead2Style = newP.arrowStyle[1];
+
+ if(arrowHead2Style.equals(PSTricksConstants.DLARROW_STYLE))
+ arrowHead2Style = PSTricksConstants.DRARROW_STYLE;
+ else if(arrowHead2Style.equals(PSTricksConstants.DRARROW_STYLE))
+ arrowHead2Style = PSTricksConstants.DLARROW_STYLE;
+ else if(arrowHead2Style.equals(PSTricksConstants.RARROW_STYLE))
+ arrowHead2Style = PSTricksConstants.LARROW_STYLE;
+ else if(arrowHead2Style.equals(PSTricksConstants.LARROW_STYLE))
+ arrowHead2Style = PSTricksConstants.RARROW_STYLE;
+ else if(arrowHead2Style.equals(PSTricksConstants.DLARROW_STYLE))
+ arrowHead2Style = PSTricksConstants.DRARROW_STYLE;
+ else if(arrowHead2Style.equals(PSTricksConstants.LRBRACKET_STYLE))
+ arrowHead2Style = PSTricksConstants.RRBRACKET_STYLE;
+ else if(arrowHead2Style.equals(PSTricksConstants.RRBRACKET_STYLE))
+ arrowHead2Style = PSTricksConstants.LRBRACKET_STYLE;
+ else if(arrowHead2Style.equals(PSTricksConstants.RSBRACKET_STYLE))
+ arrowHead2Style = PSTricksConstants.LSBRACKET_STYLE;
+ else if(arrowHead2Style.equals(PSTricksConstants.LSBRACKET_STYLE))
+ arrowHead2Style = PSTricksConstants.RSBRACKET_STYLE;
+
+ ((Arrowable)a).setArrow1Style(newP.arrowStyle[0]);
+ ((Arrowable)a).setArrow2Style(arrowHead2Style);
+ setArrowParameters(((Arrowable)a).getArrowHead1(), newP);
+ setArrowParameters(((Arrowable)a).getArrowHead2(), newP);
+ }
+
+ f.setGridEndX(gridEndX);
+ f.setGridEndY(gridEndY);
+ f.setGridStartX(gridStartX);
+ f.setGridStartY(gridStartY);
+ f.updateFonts();
+ f.updateBorders(null);
+ f.updateBorders();
+ f.setRotationAngle(angle);
+ f.setXLabelSouth(!isGridYLabelReverse);
+ f.setYLabelWest(!isGridXLabelReverse);
+
+ if(!last.psCustomP.fromPsCustom)
+ figures.add(f);
+
+ return end;
+
+ }catch(Exception e) { throw new InvalidFormatCommandException("psgrid or psaxes", line); } //$NON-NLS-1$
+ }
+
+
+
+
+ @Override
+ public int actionsOnPicture(int line, Vector<PSTricksParameters> ps,
+ String params) throws InvalidFormatCommandException
+ {
+ try
+ {
+ String[] path = {""};//$NON-NLS-1$
+ int end = parseParametersPicture(line, params, path);
+// LaTeXDrawPoint2D position = new LaTeXDrawPoint2D();
+// BatchConvertFrame bcf = new BatchConvertFrame();
+// Image image = bcf.getImage(new File(path[0]));
+// BufferedImage bufferedI = new BufferedImage(image.getWidth(null),
+// image.getHeight(null), BufferedImage.TYPE_INT_RGB );
+// Graphics g = bufferedI.createGraphics();
+// g.drawImage(image,0,0,null);
+// g.dispose();
+//
+// Picture p = new Picture(true, position, bufferedI, path[0]);
+//
+// figures.add(p);
+
+ return end;
+
+ }catch(Exception e)
+ {
+ e.printStackTrace();
+ throw new InvalidFormatCommandException("includegraphics", line); //$NON-NLS-1$
+ }
+ }
+
+
+
+
+ @Override
+ public int actionsOnFramedBox(int nLine, boolean hasStar, Vector<PSTricksParameters> ps,
+ String cmd, String params, int type) throws InvalidFormatCommandException
+ {
+ int i = ps.size()-1;
+ PSTricksParameters pp = null;
+
+ while(pp==null && i>=0)
+ if(ps.elementAt(i).getPosition()!=null)
+ pp = ps.elementAt(i);
+ else i--;
+
+ if(pp==null)
+ pp = ps.firstElement();
+
+ FramedBox fb = new FramedBox(pp.psBoxText);
+ fb.setStart(pp.textForFrame.length());
+ pp.psBox.add(fb);
+ PSTricksParameters newP = new PSTricksParameters(ps.lastElement());
+ int end = -1;
+ int[] j = {0};
+ try
+ {
+ goToNextChar(params, j);
+ if(params.charAt(j[0])=='*')
+ {
+ j[0]++;
+ goToNextChar(params, j);
+ }
+ }
+ catch(Exception e1) { throw new InvalidFormatCommandException(nLine); }
+
+ if(params.charAt(j[0])=='[')
+ {
+ switch(type)
+ {
+ case 0:
+ fb.setBoxType(FramedBox.BOX_RECTANGLE);
+ end = parseParametersFrameEllipse(nLine, params, null, null, newP);
+ if(newP.frameArc>0)
+ {
+ ((LaTeXDrawRectangle)fb.getBox()).setFrameArc(newP.frameArc);
+ ((LaTeXDrawRectangle)fb.getBox()).setIsRound(true);
+ }
+ break;
+ case 1:
+ fb.setBoxType(FramedBox.BOX_CIRCLE);
+ end = parseParametersCircle(nLine, params, null, null, newP);
+ break;
+ case 2:
+ fb.setBoxType(FramedBox.BOX_TRIANGLE);
+ end = parseParametersPolygon(nLine, params, null, newP);
+ break;
+ case 3:
+ fb.setBoxType(FramedBox.BOX_DIAMOND);
+ end = parseParametersPolygon(nLine, params, null, newP);
+ break;
+ case 4:
+ fb.setBoxType(FramedBox.BOX_ELLIPSE);
+ end = parseParametersFrameEllipse(nLine, params, null, null, newP);
+ break;
+ case 5:
+ fb.setBoxType(FramedBox.BOX_RECTANGLE);
+ end = parseParametersFrameEllipse(nLine, params, null, null, newP);
+ if(newP.frameArc>0)
+ {
+ ((LaTeXDrawRectangle)fb.getBox()).setFrameArc(newP.frameArc);
+ ((LaTeXDrawRectangle)fb.getBox()).setIsRound(true);
+ }
+ break;
+ case 6:
+ fb.setBoxType(FramedBox.BOX_RECTANGLE);
+ end = parseParametersFrameEllipse(nLine, params, null, null, newP);
+ if(newP.frameArc>0)
+ {
+ ((LaTeXDrawRectangle)fb.getBox()).setFrameArc(newP.frameArc);
+ ((LaTeXDrawRectangle)fb.getBox()).setIsRound(true);
+ }
+ break;
+ }
+ j[0] = end;
+ }
+
+ try
+ {
+ goToNextChar(params, j);
+ } catch(Exception e1) { throw new InvalidFormatCommandException(nLine); }
+
+ switch(type)
+ {
+ case 0:
+ fb.setBoxType(FramedBox.BOX_RECTANGLE);
+ break;
+ case 1:
+ fb.setBoxType(FramedBox.BOX_CIRCLE);
+ break;
+ case 2:
+ fb.setBoxType(FramedBox.BOX_TRIANGLE);
+ break;
+ case 3:
+ fb.setBoxType(FramedBox.BOX_DIAMOND);
+ break;
+ case 4:
+ fb.setBoxType(FramedBox.BOX_ELLIPSE);
+ break;
+ case 5:
+ fb.setBoxType(FramedBox.BOX_RECTANGLE);
+ break;
+ case 6:
+ fb.setBoxType(FramedBox.BOX_RECTANGLE);
+ break;
+ }
+
+
+ if(params.charAt(j[0])!='{')//psframebox3, psframebox[framesep=0.3]3 for instance.
+ {
+ PSTricksParameters p;
+ boolean again = true;
+ int k = ps.size()-1;
+
+ while(again && k>=0)
+ {
+ p = ps.elementAt(k);
+ if(p.getPosition()!=null)
+ {
+ again = false;
+ p.textForFrame+=params.charAt(j[0]);
+ }
+ else
+ {
+ p.textForFrame+=params.charAt(j[0]);
+ k--;
+ }
+ }
+
+ k = ps.size()-1;
+ p=null;
+
+ while(p==null && k>=0)
+ if(ps.elementAt(k).getPosition()!=null)
+ p = ps.elementAt(k);
+ else k--;
+
+ if(p==null)
+ p = ps.firstElement();
+
+ p.psBox.lastElement().setEnd(p.textForFrame.length());
+ p.psBox.add(0, p.psBox.remove(p.psBox.size()-1));
+
+ end=j[0]+1;
+ }
+
+ fb.setFrameSep(newP.frameSep*Figure.PPC);
+ fb.setBoxSep(newP.boxSep);
+
+ setFigureParameters(newP, fb.getBox(), hasStar);
+
+ if(hasStar)
+ {
+ fb.getBox().setIsFilled(true);
+ fb.getBox().setInteriorColor(newP.fillColor);
+ fb.getBox().setLinesColor(newP.fillColor);
+ }
+
+ switch(type)
+ {
+ case 5:
+ fb.getBox().setHasDoubleBoundary(true);
+ break;
+ case 6:
+ fb.getBox().setHasShadow(true);
+ break;
+ }
+
+ if(end==-1)
+ end = j[0];
+
+ return end;
+ }
+
+
+
+
+
+ @Override
+ public void actionsOnTerminatedFramedBoxes(Vector<PSTricksParameters> params) throws InvalidFormatCommandException
+ {
+ PSTricksParameters pp = params.lastElement();
+
+ String str = pp.psBoxText.getText();
+
+ if(str.length()==0)
+ str = " ";//$NON-NLS-1$
+
+ pp.textParsed = pp.textForFrame;
+ actionsOnText(params);
+
+ if(pp.psBox.isEmpty())
+ return;
+
+ Text txt = (Text)figures.remove(figures.size()-1);
+ boolean simpleBox = pp.psBox.size()==1 && pp.psBox.firstElement().getBoxedText().equals(txt.getText());
+
+ if(simpleBox)
+ {
+ FramedBox fb = pp.psBox.firstElement();
+ fb.setText(txt);
+ fb.setStart(-1);
+ fb.setEnd(-1);
+ fb.getBox().setBordersPosition(PSTricksConstants.BORDERS_OUTSIDE);
+ txt.setSimpleBox(fb);
+ }
+ else
+ for(FramedBox fb : pp.psBox)
+ {
+ fb.setText(txt);
+ txt.addBox(fb);
+ fb.getBox().setBordersPosition(PSTricksConstants.BORDERS_OUTSIDE);
+ }
+
+ txt.setHasFramedBox(!pp.psBox.isEmpty());
+ txt.setHasSimpleFramedBox(simpleBox);
+ txt.updateFramedBoxes();
+ txt.updateFontsBorders();
+
+ if(!pp.psCustomP.fromPsCustom)
+ figures.add(txt);
+
+ if(simpleBox)
+ {
+ if(txt.getSimpleBox().getBoxType()==FramedBox.BOX_TRIANGLE)
+ {
+ double height = (txt.getSimpleBox().getBox().getTheSEBoundPoint().y-
+ txt.getSimpleBox().getBox().getTheNWBoundPoint().y)/4.;
+ LaTeXDrawPoint2D pos = txt.getPosition();
+ txt.setPosition(new LaTeXDrawPoint2D(pos.x, pos.y+height));
+ txt.getSimpleBox().getBox().updateShape();
+ }
+ }
+ else
+ {
+ FramedBox fb, max=null;
+ double xMin=Double.MAX_VALUE;
+ int i=0, size = txt.getMultipleBox().size();
+
+ while(i<size)
+ {
+ fb = txt.getMultipleBox().elementAt(i);
+
+ if(fb.isBoxSep() && fb.getBoxType()==FramedBox.BOX_TRIANGLE &&
+ fb.getBox().getTheNWBoundPoint().x<xMin)
+ {
+ xMin = fb.getBox().getTheNWBoundPoint().x;
+ max = fb;
+ }
+ else i++;
+ }
+
+ if(max!=null)
+ {
+ double height = (max.getBox().getTheSEBoundPoint().y-max.getBox().getTheNWBoundPoint().y)/4.;
+
+ LaTeXDrawPoint2D pos = txt.getPosition();
+ txt.setPosition(new LaTeXDrawPoint2D(pos.x, pos.y+height));
+ max.getBox().updateShape();
+ }
+
+ }
+
+ txt.updateFramedBoxes();
+ txt.updateFontsBorders();
+ }
+
+
+
+
+
+ /**
+ * Optimises the figures; for instance, frame are transformed in square.
+ * @param vFigures The figures to optimise.
+ * @since 1.9
+ */
+ public static void optimizeCode(Vector<Figure> vFigures)
+ {
+ Vector<Arc> vArcs = new Vector<Arc>();
+ Vector<Line> vLines = new Vector<Line>();
+ Vector<BezierCurve> vCurves = new Vector<BezierCurve>();
+ int sizevl, i, size, j;
+
+ for(Figure f : vFigures)
+ if(f instanceof Line)
+ vLines.add((Line)f);
+ else
+ if(f instanceof Arc)
+ vArcs.add((Arc)f);
+ else
+ if(f instanceof BezierCurve)
+ vCurves.add((BezierCurve)f);
+
+ sizevl = vLines.size();
+
+ for(Arc a : vArcs)// We check if we can convert arc+line in chord.
+ if(a.getType()==Arc2D.OPEN)
+ {
+ boolean again = true;
+ i=0;
+ LaTeXDrawPoint2D startP, endP, p1, p2;
+ Line l=null;
+
+ while(again && i<sizevl)
+ {
+ l = vLines.elementAt(i);
+ startP = a.getStartPoint(true);
+ endP = a.getEndPoint(true);
+ p1 = l.getPt1();
+ p2 = l.getPt2();
+ startP.y*=-1;
+ endP.y*=-1;
+
+ if((startP.equals(p1, 1) && endP.equals(p2, 1)) ||
+ (startP.equals(p2, 1) && endP.equals(p1, 1)))
+ again = false;
+ else
+ i++;
+ }
+
+ if(!again && a.isParametersEquals(l, false, true))
+ {
+ vFigures.remove(l);
+ a.setType(Arc2D.CHORD);
+ }
+ }
+
+ if(vCurves.size()>1)// We try to concat the Bézier curves.
+ {
+ if(vCurves.size()<200)// We must set a limit otherwise it may have a freeze.
+ {
+ BezierCurve b1, b2;
+
+ for(j=0; j<vCurves.size(); j++)
+ {
+ i = j+1;
+ b1 = vCurves.elementAt(j);
+
+ while(i<vCurves.size())
+ {
+ b2 = vCurves.elementAt(i);
+
+ if(b1.isJoined(b2)==1 && b1.isParametersEquals(b2, true, true))
+ {
+ vCurves.remove(b2);
+ vFigures.remove(b2);
+ b1.join(b2);
+ i=j+1;
+ }
+ else
+ i++;
+ }
+ } //for
+ }
+
+ for(BezierCurve bc : vCurves)
+ bc.replaceLastPointByClosing();
+ }//if
+
+ i = 0;
+ while(i<vCurves.size()) // We check if the it is possible to close a curve.
+ {
+ BezierCurve bc = vCurves.elementAt(i);
+ bc.replaceLastPointByClosing();
+
+ if(bc.isOpen())
+ {
+ boolean again = true;
+ size = vLines.size();
+
+ for(int k=0; k<size && again; k++)//We try to close it with a line.
+ if(bc.isLineClosingCurve(vLines.elementAt(k)) &&
+ bc.isParametersEquals(vLines.elementAt(k), true, false))
+ {
+ bc.setOpen(false);
+ bc.setCloseType(BezierCurve.CLOSE_TYPE_LINE);
+ again = false;
+ vFigures.remove(vLines.elementAt(k));
+ }
+
+ if(again)//We try to close it with a two-points curve.
+ {
+ j = 0;
+
+ while(j<i && again)
+ {
+ BezierCurve bc2 = vCurves.elementAt(j);
+
+ if(bc2.getNbPoints()==2 && bc.isOpen() && bc2.isCurveClosingCurve(bc)==1 &&
+ bc.isParametersEquals(bc2, true, false))
+ {
+ bc.setOpen(false);
+ bc.setCloseType(BezierCurve.CLOSE_TYPE_CURVE);
+ again = false;
+ vCurves.remove(j);
+ vFigures.remove(bc2);
+ i--;
+ }
+ else j++;
+ }
+
+ j = i+1;
+ while(j<vCurves.size() && again)
+ {
+ BezierCurve bc2 = vCurves.elementAt(j);
+
+ if(bc2.getNbPoints()==2 && bc.isOpen() && bc.isCurveClosingCurve(bc2)==1 &&
+ bc.isParametersEquals(bc2, true, false))
+ {
+ bc.setOpen(false);
+ bc.setCloseType(BezierCurve.CLOSE_TYPE_CURVE);
+ again = false;
+ vCurves.remove(j);
+ vFigures.remove(bc2);
+ }
+ else j++;
+ }
+ }
+ }//if(bc.isOpen())
+ i++;
+ }
+
+ i=0;
+ size = vFigures.size();
+ while(i<size)
+ {
+ Figure f = vFigures.elementAt(i);
+
+ if(f instanceof LaTeXDrawRectangle && !(f instanceof Square))
+ {// We check if we can convert frame in square.
+ LaTeXDrawRectangle frame = (LaTeXDrawRectangle)f;
+
+ if(frame.getHeight()==frame.getWidth())
+ {
+ Square square = new Square(frame,true);
+ vFigures.remove(i);
+ vFigures.add(i, square);
+ }
+ }
+ i++;
+ }
+ }
+
+
+
+
+ @Override
+ public void actionsOnterminatedPsCustom(PSTricksParameters param) throws NotFullyManagedException
+ {
+ Figure f;
+ int i=0;
+
+ while(!psCustFigures.isEmpty())
+ {
+ f = psCustFigures.remove(0);
+
+ if(!(f instanceof AkinPoints) || ((AkinPoints)f).getNbPoints()>1)
+ {
+ if(f instanceof AkinPoints && ((AkinPoints)f).getType()==AkinPoints.TYPE_CURVES)
+ {// We must transform the read points.
+ AkinPoints ak = (AkinPoints)f;
+ int j, size = ak.getNbPoints();
+ LaTeXDrawPoint2D prev, curr = ak.getPoint(0);
+
+ for(j=1; j<size; j++)
+ {
+ prev = curr;
+ curr = ak.getPoint(j);
+ curr.setLocation(2*curr.x-prev.x, 2*curr.y-prev.y);
+ }
+
+ ((AkinPoints)f).updateBorders();
+ }
+
+ figures.add(f);
+ i++;
+ }
+ }
+ }
+
+
+
+
+ @Override
+ public void actionsOnNewPath(int line)
+ {
+ psCustFigures.clear();
+ }
+
+
+
+
+ @Override
+ public int parseOpenShadowCommand(PSTricksParameters param, int line, String txt) throws InvalidFormatCommandException
+ {
+ PSTricksParameters pstp = new PSTricksParameters(param);
+ int end = super.parseOpenShadowCommand(pstp, line, txt);
+
+ for(Figure f : psCustFigures)
+ {
+ f.setHasShadow(true);
+ f.setShadowAngle(Math.toRadians(pstp.shadowAngle));
+ f.setShadowColor(pstp.shadowCol);
+ f.setShadowSize(Math.abs(pstp.shadowSize)*Figure.PPC);
+ }
+
+ if(psCustFigures.size()>0 && psCustFigures.lastElement() instanceof AkinPoints)
+ {
+ double xunit = param.unit!=PSTricksConstants.DEFAULT_UNIT? param.unit : param.xUnit;
+ double yunit = param.unit!=PSTricksConstants.DEFAULT_UNIT? param.unit : param.yUnit;
+
+ AkinPoints ak = new AkinPoints(new LaTeXDrawPoint2D(
+ param.psCustomP.lastPosition.x*Figure.PPC*xunit,
+ param.psCustomP.lastPosition.y*Figure.PPC*yunit*-1), true);
+ ak.setInterval(1);
+ ak.setType(AkinPoints.TYPE_LINES);
+ psCustFigures.add(ak);
+ }
+
+ return end;
+ }
+
+
+
+
+ @Override
+ public int actionsOnCurveTo(int line, Vector<PSTricksParameters> params, String txt)
+ throws InvalidFormatCommandException
+ {
+ Point2D.Double p1 = new Point2D.Double();
+ Point2D.Double p2 = new Point2D.Double();
+ Point2D.Double p3 = new Point2D.Double();
+ int end = parseParametersCurveTo(line, txt, p1, p2, p3);
+ PSTricksParameters last = params.lastElement();
+ AkinPoints ak ;
+ double xunit = last.unit!=PSTricksConstants.DEFAULT_UNIT? last.unit : last.xUnit;
+ double yunit = last.unit!=PSTricksConstants.DEFAULT_UNIT? last.unit : last.yUnit;
+
+ if(psCustFigures.isEmpty() || !(psCustFigures.lastElement() instanceof AkinPoints))
+ {
+ ak = new AkinPoints(new LaTeXDrawPoint2D(last.psCustomP.lastPosition.x*Figure.PPC*xunit,
+ last.psCustomP.lastPosition.y*Figure.PPC*-1*yunit), true);
+ setFigureParameters(params.lastElement(), ak, false);
+ ak.setInterval(1);
+ psCustFigures.add(ak);
+ }
+ else ak = (AkinPoints)psCustFigures.lastElement();
+
+ ak.setType(AkinPoints.TYPE_CURVES);
+ ak.addPoint(new LaTeXDrawPoint2D(p3.x*Figure.PPC*xunit, p3.y*Figure.PPC*-1*yunit));
+ last.psCustomP.lastPosition.setLocation(p3);
+
+ return end;
+ }
+
+
+
+
+ @Override
+ public int actionsOnLineTo(int line, Vector<PSTricksParameters> params, String txt) throws InvalidFormatCommandException
+ {
+ Point2D.Double p1 = new Point2D.Double();
+ int end = parseParametersLineMoveTo(line, txt, p1);
+ PSTricksParameters last = params.lastElement();
+ AkinPoints ak ;
+ double xunit = last.unit!=PSTricksConstants.DEFAULT_UNIT? last.unit : last.xUnit;
+ double yunit = last.unit!=PSTricksConstants.DEFAULT_UNIT? last.unit : last.yUnit;
+
+ if(psCustFigures.isEmpty() || !(psCustFigures.lastElement() instanceof AkinPoints))
+ {
+ ak = new AkinPoints(new LaTeXDrawPoint2D(last.psCustomP.lastPosition.x*Figure.PPC*xunit,
+ last.psCustomP.lastPosition.y*Figure.PPC*-1*yunit), true);
+ setFigureParameters(params.lastElement(), ak, false);
+ ak.setInterval(1);
+ ak.setType(AkinPoints.TYPE_LINES);
+ psCustFigures.add(ak);
+ }
+ else ak = (AkinPoints)psCustFigures.lastElement();
+
+ ak.addPoint(new LaTeXDrawPoint2D(p1.x*Figure.PPC*xunit, p1.y*Figure.PPC*-1*yunit));
+ last.psCustomP.lastPosition.setLocation(p1);
+
+ return end;
+ }
+
+
+
+
+ @Override
+ public int actionsOnMoveTo(int line, Vector<PSTricksParameters> params, String txt) throws InvalidFormatCommandException
+ {
+ Point2D.Double p1 = new Point2D.Double();
+ int end = parseParametersLineMoveTo(line, txt, p1);
+ PSTricksParameters last = params.lastElement();
+ last.psCustomP.lastPosition.setLocation(p1);
+
+ return end;
+ }
+
+
+
+
+ @Override
+ public void actionsOnClosePathCommand(int line)
+ {
+ if(!psCustFigures.isEmpty())
+ {
+ Figure f = psCustFigures.lastElement();
+
+ if(f instanceof AkinPoints)
+ ((AkinPoints)f).setOpen(false);
+ }
+ }
+
+}
+
+
diff --git a/latexDraw/parsers/svg/elements/SVGPatternElement.java b/latexDraw/parsers/svg/elements/SVGPatternElement.java
index 7fa18f5..33a645f 100644
--- a/latexDraw/parsers/svg/elements/SVGPatternElement.java
+++ b/latexDraw/parsers/svg/elements/SVGPatternElement.java
@@ -207,6 +207,7 @@ public class SVGPatternElement extends SVGElement
* hatching).
* @since 2.0.0
*/
+ @Deprecated
public double getHatchingSep()
{
SVGGElement g = getGElement();
diff --git a/latexDraw/ui/DrawContainer.java b/latexDraw/ui/DrawContainer.java
index 27b9776..083f395 100644
--- a/latexDraw/ui/DrawContainer.java
+++ b/latexDraw/ui/DrawContainer.java
@@ -31,6 +31,7 @@ import javax.swing.SwingConstants;
import latexDraw.figures.*;
import latexDraw.figures.properties.Arrowable;
+import latexDraw.parsers.svg.SVGAttributes;
import latexDraw.parsers.svg.SVGDocument;
import latexDraw.parsers.svg.SVGElements;
import latexDraw.parsers.svg.elements.SVGMetadataElement;
@@ -48,6 +49,7 @@ import net.sourceforge.jiu.gui.awt.BufferedRGB24Image;
import org.sourceforge.jlibeps.epsgraphics.EpsGraphics2D;
import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -194,7 +196,7 @@ public final class DrawContainer extends JComponent implements Scrollable, Print
selected = new Draw(false, false);
figures = new Vector<Figure>();
pixelsPerCm = DEFAULT_PIXPERCM;
- inSelection = false;
+ inSelection = true;
setIsModified(false);
renderingValue = DEFAULT_RENDERING_VAL;
alphaInterpolValue = DEFAULT_ALPHAINTER_VAL;
@@ -753,7 +755,7 @@ public final class DrawContainer extends JComponent implements Scrollable, Print
figures.clear();
pixelsPerCm = 50;
selected = new Draw(false, false);
- inSelection = false;
+ inSelection = true;
setIsModified(false);
onRotation = false;
bordersComplete = null;
@@ -2632,6 +2634,18 @@ public final class DrawContainer extends JComponent implements Scrollable, Print
elt.appendChild(document.createTextNode(String.valueOf(isAutoAdjustement())));
meta.appendChild(elt);
+ if(!isAutoAdjustement() && bordersComplete!=null)
+ {// We have to save the dimension of the borders.
+ LaTeXDrawPoint2D pt = bordersComplete.getTheNWPoint();
+
+ elt = document.createElement(LaTeXDrawNamespace.LATEXDRAW_NAMESPACE+':'+LaTeXDrawNamespace.XML_BORDER);
+ elt.setAttribute(SVGAttributes.SVG_X, String.valueOf(pt.x));
+ elt.setAttribute(SVGAttributes.SVG_Y, String.valueOf(pt.y));
+ elt.setAttribute(SVGAttributes.SVG_HEIGHT, String.valueOf(bordersComplete.getHeight()));
+ elt.setAttribute(SVGAttributes.SVG_WIDTH, String.valueOf(bordersComplete.getWidth()));
+ meta.appendChild(elt);
+ }
+
elt = document.createElement(LaTeXDrawNamespace.LATEXDRAW_NAMESPACE+':'+LaTeXDrawNamespace.XML_PPC);
elt.appendChild(document.createTextNode(String.valueOf(getPixelsPerCm())));
meta.appendChild(elt);
@@ -2887,7 +2901,29 @@ public final class DrawContainer extends JComponent implements Scrollable, Print
try
{
if(name.endsWith(LaTeXDrawNamespace.XML_AUTO_ADJUST))
- setAutoAdjustement(Boolean.valueOf(n.getTextContent()).booleanValue());
+ {
+ boolean is = Boolean.valueOf(n.getTextContent()).booleanValue();
+
+ if(bordersComplete==null)
+ bordersComplete = new DrawBorders(false);
+
+ setAutoAdjustement(is);
+ parentPanel.getFrameParent().getLMenuBar().getAutoAdjustBorders().setSelected(is);
+ }
+ else if(name.endsWith(LaTeXDrawNamespace.XML_BORDER))
+ {
+ NamedNodeMap nnm = n.getAttributes();
+ double x = Double.valueOf(nnm.getNamedItem(SVGAttributes.SVG_X).getNodeValue()).doubleValue();
+ double y = Double.valueOf(nnm.getNamedItem(SVGAttributes.SVG_Y).getNodeValue()).doubleValue();
+ double w = Double.valueOf(nnm.getNamedItem(SVGAttributes.SVG_WIDTH).getNodeValue()).doubleValue();
+ double h = Double.valueOf(nnm.getNamedItem(SVGAttributes.SVG_HEIGHT).getNodeValue()).doubleValue();
+
+ if(bordersComplete==null)
+ bordersComplete = new DrawBorders(false);
+
+ bordersComplete.setFirstPoint(x, y);
+ bordersComplete.setLastPoint(x+w, y+h);
+ }
else if(name.endsWith(LaTeXDrawNamespace.XML_PPC))
setPixelsPerCm(Double.valueOf(n.getTextContent()).intValue());
else if(name.endsWith(LaTeXDrawNamespace.XML_ZOOM))
diff --git a/latexDraw/ui/LaTeXDrawFrame.java b/latexDraw/ui/LaTeXDrawFrame.java
index 178756f..95ef909 100644
--- a/latexDraw/ui/LaTeXDrawFrame.java
+++ b/latexDraw/ui/LaTeXDrawFrame.java
@@ -63,7 +63,7 @@ public final class LaTeXDrawFrame extends JFrame implements ActionListener, Item
private static final long serialVersionUID = 1L;
/** The version of the application */
- public final static String VERSION = "2.0.0";//$NON-NLS-1$
+ public final static String VERSION = "2.0.1";//$NON-NLS-1$
public final static String VERSION_STABILITY = ""; //$NON-NLS-1$
@@ -110,7 +110,7 @@ public final class LaTeXDrawFrame extends JFrame implements ActionListener, Item
protected LMenuBar menuBar;
/** The identifier of the build */
- private static final String ID_BUILD = "20080724";//$NON-NLS-1$
+ private static final String ID_BUILD = "20081031";//$NON-NLS-1$
/** Allows to realize undo and redo */
protected transient UndoRedoManager undoManager;
diff --git a/latexDraw/ui/dialog/AbstractParametersFrame.java b/latexDraw/ui/dialog/AbstractParametersFrame.java
index 1cd90ad..8056479 100644
--- a/latexDraw/ui/dialog/AbstractParametersFrame.java
+++ b/latexDraw/ui/dialog/AbstractParametersFrame.java
@@ -1,2270 +1,2310 @@
-package latexDraw.ui.dialog;
-
-import java.awt.*;
-import java.awt.event.*;
-
-import javax.swing.*;
-import javax.swing.border.CompoundBorder;
-import javax.swing.border.EmptyBorder;
-import javax.swing.border.TitledBorder;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-
-import latexDraw.figures.*;
-import latexDraw.figures.properties.Arrowable;
-import latexDraw.lang.LaTeXDrawLang;
-import latexDraw.psTricks.PSTricksConstants;
-import latexDraw.ui.DrawPanel;
-import latexDraw.ui.components.ButtonIcon;
-import latexDraw.ui.components.ColorButton;
-import latexDraw.ui.components.LaTeXDrawComboBox;
-import latexDraw.util.LaTeXDrawPoint2D;
-import latexDraw.util.LaTeXDrawResources;
-import latexDraw.util.UndoRedoManager;
-
-
-/**
- * This class defines the pattern for the frames which allow to change the parameters of the figures.<br>
- *<br>
- * This file is part of LaTeXDraw<br>
- * Copyright (c) 2005-2008 Arnaud BLOUIN<br>
- *<br>
- * 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.<br>
- *<br>
- * 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.<br>
- *<br>
- * 01/20/06<br>
- * @author Arnaud BLOUIN<br>
- * @version 2.0.0<br>
- */
-public abstract class AbstractParametersFrame extends JDialog implements ActionListener, ItemListener, KeyListener, ChangeListener
-{
- private static final long serialVersionUID = 1L;
-
- protected boolean deleteOnCancel;
-
- /** The panel containing the drawing */
- protected DrawPanel drawPanel;
-
- /** The figure to modify */
- protected Figure figure;
-
- /** The title of the frame */
- protected String title;
-
- /** The width of many panels. */
- public static final int WIDTH_PANELS = 430;
-
- /** The label of the panel : Position/dimensions. */
- public static final String LABEL_POSITION_DIMENSIONS = LaTeXDrawLang.getString1_7("AbstractParametersFrame.0"); //$NON-NLS-1$
-
- /** The name of the button ok */
- public static final String NAME_BUTTON_OK = "BUTTON_OK";//$NON-NLS-1$
-
- /** The name of the button cancel */
- public static final String NAME_BUTTON_CANCEL = "BUTTON_CANCEL";//$NON-NLS-1$
-
- /** The name of the button default */
- public static final String NAME_BUTTON_DEFAULT = "BUTTON_DEFAULT";//$NON-NLS-1$
-
- /** Allows to know if the frame has been launched by the main frame:
- * if true, the undo/redo manager will be used. */
- protected boolean attachToMainFrame;
-
- protected JSpinner dotSizeNum;
-
- protected JSpinner dotSizeDim;
-
- protected JSpinner bracketNum;
-
- protected JSpinner rbracketNum;
-
- protected JSpinner tbarsizeNum;
-
- protected JSpinner tbarsizeDim;
-
- protected JSpinner arrowSizeDim;
-
- protected JSpinner arrowSizeNum;
-
- protected JSpinner arrowLength;
-
- protected JSpinner arrowInset;
-
- public static final String LABEL_DOTSIZENUM = "DotSizeNum";//$NON-NLS-1$
-
- public static final String LABEL_DOTSIZEDIM = "DotSizeDim";//$NON-NLS-1$
-
- public static final String LABEL_BRACKETNUM = "BracketNum";//$NON-NLS-1$
-
- public static final String LABEL_RBRACKETNUM = "rBracketNum";//$NON-NLS-1$
-
- public static final String LABEL_TBARSIZENUM = "tBarSizeNum"; //$NON-NLS-1$
-
- public static final String LABEL_TBARSIZEDIM = "tBarSizeDim"; //$NON-NLS-1$
-
- public static final String LABEL_ARROWLENGTH = "arrowLength";//$NON-NLS-1$
-
- public static final String LABEL_ARROWINSET = "arrowInset"; //$NON-NLS-1$
-
- public static final String LABEL_ARROWSIZENUM = "arrowSizeNum";//$NON-NLS-1$
-
- public static final String LABEL_ARROWSIZEDIM = "arrowSizeDim"; //$NON-NLS-1$
-
- /** Allows to change the mid point of the gradient. */
- protected JSpinner gradientMidPtField;
-
- /** Allows to change the angle of the gradient. */
- protected JSpinner gradientAngleField;
-
- /** Allows to change the colour of the shadow. */
- protected ColorButton gradientStartColButton;
-
- /** Allows to change the colour of the shadow. */
- protected ColorButton gradientEndColButton;
-
- /** Allows to change the size of the shadow. */
- protected JSpinner shadowSizeField;
-
- /** Allows to change the colour of the shadow. */
- protected ColorButton shadowColorButton;
-
- /** Allows to change the angle of the shadow. */
- protected JSpinner shadowAngleField;
-
- /** Allows to set if the figure has a shadow or not. */
- protected JCheckBox shadowCheckBox;
-
- /** Allows to change the thickness of the figure */
- protected JSpinner thicknessField;
-
- /** Allows to change the colour of the borders of the figure */
- protected ColorButton bordersButton;
-
- /** Allows to change the colour of the hatch */
- protected ColorButton hatchButton;
-
- /** Allows to set if the figure is filled */
- protected JCheckBox filledCheckBox;
-
- /** Allows to change the colour of the interior of the figure */
- protected ColorButton interiorButton;
-
- /** Allows to change the colour of the double boundary of the figure */
- protected ColorButton doublecolorButton;
-
- /** Allows to change the kind of the line */
- protected LaTeXDrawComboBox lineChoice;
-
- /** Allows to change the kind of hatch */
- protected LaTeXDrawComboBox hatchChoice;
-
- /** Allows to change the position of the borders */
- protected LaTeXDrawComboBox bordersPositionChoice;
-
- /** Allows to change the angle of rotation of the figure */
- protected JSpinner hatchSepField;
-
- /** Allows to change the angle of rotation of the figure */
- protected JSpinner rotationField;
-
- /** Allows to change the width of the hatch */
- protected JSpinner hatchWidthField;
-
- /** Allows to set the separation between the double line */
- protected JSpinner doubleSep;
-
- /** Allows to set if the figure must have double boundary or not */
- protected JCheckBox doubleLine;
-
- /** The button ok */
- protected JButton buttonOk;
-
- /** The panel where the figure is displayed */
- protected GlimpsePanel glimpsePanel;
-
- /** This scrollpane contains the glimpsepanel */
- protected JPanel glimpsePanelZoom;
-
- /** The scroll pane of the frame to see the figure. */
- protected JScrollPane glimpseScrollPane;
-
- /** The first arrow choice */
- protected LaTeXDrawComboBox arrow1Choice;
-
- /** The second arrow choice */
- protected LaTeXDrawComboBox arrow2Choice;
-
- /** Defines if the shape has been modified with the frame. @since 2.0.0 */
- protected boolean isModified;
-
- /** The label of the check box which set if the figure has a shadow or not. */
- public static final String LABEL_SHADOW_CB = LaTeXDrawResources.LABEL_SHADOW_CHECKBOX;
-
- /** The label of the button which set the angle of the shadow. */
- public static final String LABEL_SHADOW_ANGLE = LaTeXDrawLang.getString1_7("AbstractParametersFrame.1"); //$NON-NLS-1$
-
- /** The label of the button which set the size of the shadow. */
- public static final String LABEL_SHADOW_SIZE = LaTeXDrawLang.getString1_7("AbstractParametersFrame.2"); //$NON-NLS-1$
-
- /** The label of the button which set the angle of the gradient. */
- public static final String LABEL_GRADIENT_ANGLE = LaTeXDrawLang.getString1_7("AbstractParametersFrame.3"); //$NON-NLS-1$
-
- /** The label of the button which set the middle point of the gradient. */
- public static final String LABEL_GRADIENT_MID_PT = LaTeXDrawLang.getString1_7("AbstractParametersFrame.4"); //$NON-NLS-1$
-
- public static final String TITLE_TABBED_PANE_GENERAL = LaTeXDrawLang.getString1_8("LaTeXDrawFrame.24"); //$NON-NLS-1$
-
- public static final String TITLE_TABBED_PANE_OTHERS = LaTeXDrawLang.getString1_7("AbstractParametersFrame.6"); //$NON-NLS-1$
-
- public static final String LABEL_BUTTON_BOUNDARY = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.0"); //$NON-NLS-1$
-
- public static final String LABEL_DOUBLELINE = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.1"); //$NON-NLS-1$
-
- public static final String LABEL_DOUBLESEP = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.2"); //$NON-NLS-1$
-
- public static final String LABEL_HATCH_SEP = LaTeXDrawLang.getString1_8("AbstractParametersFrame.0"); //$NON-NLS-1$
-
- public static final String TITLE_GENERAL = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.3"); //$NON-NLS-1$
-
- public static final String LABEL_ARROWS = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.38"); //$NON-NLS-1$
-
- public static final String LABEL_OK = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.4"); //$NON-NLS-1$
-
- public static final String LABEL_DEFAULT = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.5"); //$NON-NLS-1$
-
- public static final String LABEL_CANCEL = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.6"); //$NON-NLS-1$
-
- public static final String LABEL_ROTATION = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.7"); //$NON-NLS-1$
-
- public static final String LABEL_THICKNESS = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.8"); //$NON-NLS-1$
-
- public static final String LABEL_GENERAL = LaTeXDrawLang.getDialogFrameString("PreferencesFrame.general"); //$NON-NLS-1$
-
- public static final String LABEL_TYPE_LINE = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.10"); //$NON-NLS-1$
-
- public static final String LABEL_HATCH_WIDTH = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.11"); //$NON-NLS-1$
-
- public static final String LABEL_LEFT_ARROW = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.12"); //$NON-NLS-1$
-
- public static final String LABEL_RIGHT_ARROW = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.13"); //$NON-NLS-1$
-
- public static final String NAME_TABBEDPANE_ARROW = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.14"); //$NON-NLS-1$
-
- /** The label of the showPointsCB JCheckBox */
- public static final String LABEL_SHOWPOINTCB = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.15"); //$NON-NLS-1$
-
- /** The label of the isRound checkbox */
- public static final String LABEL_ISROUND = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.16"); //$NON-NLS-1$
-
- /** The label of the field frameArcField */
- public static final String LABEL_ROUND_CORNER = LaTeXDrawLang.getString1_7("AbstractParametersFrame.7"); //$NON-NLS-1$
-
- /** The label of the X-centre field */
- public static final String LABEL_CENTER_X = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.17"); //$NON-NLS-1$
-
- /** The label of the Y-centre field */
- public static final String LABEL_CENTER_Y = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.18"); //$NON-NLS-1$
-
- /** The label of the radius field */
- public static final String LABEL_RADIUS = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.19"); //$NON-NLS-1$
-
- public static final String LABEL_DOTSIZE = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.20"); //$NON-NLS-1$
-
- public static final String LABEL_TBARSIZE = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.21"); //$NON-NLS-1$
-
- public static final String LABEL_BRACKET_LGTH = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.22"); //$NON-NLS-1$
-
- public static final String LABEL_RBRACKET_LGTH = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.23"); //$NON-NLS-1$
-
- public static final String LABEL_CROSS_THICKNESS = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.24"); //$NON-NLS-1$
-
- public static final String LABEL_CROSS_WIDTH = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.25"); //$NON-NLS-1$
-
- public static final String LABEL_ARROW_LENGTH = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.26"); //$NON-NLS-1$
-
- public static final String LABEL_ARROW_INSET = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.27"); //$NON-NLS-1$
-
- public static final String LABEL_ARROW_WIDTH = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.28"); //$NON-NLS-1$
-
- public static final String LABEL_X = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.29"); //$NON-NLS-1$
-
- public static final String LABEL_Y = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.30"); //$NON-NLS-1$
-
- /** The label of the width field */
- public static final String LABEL_WIDTH = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.31"); //$NON-NLS-1$
-
- /** The label of the height field */
- public static final String LABEL_HEIGHT = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.32"); //$NON-NLS-1$
-
-
-
- /**
- * 01/20/06<br>
- * @version 1.9<br>
- */
- protected static class GlimpsePanel extends JPanel implements Scrollable, MouseListener, MouseMotionListener
- {
- private static final long serialVersionUID = 1L;
-
- /** The figure to display in the panel */
- protected Figure glimpseFigure;
-
- /** The zoom by default (100%) */
- public static final double DEFAULT_ZOOM = 1.;
-
- /** The biggest zoom we can do */
- public static final double MAX_ZOOM = 4.5;
-
- /** The smallest zoom we can do */
- public static final double MIN_ZOOM = 0.25;
-
- /** The value we add to the zoom when to user click on a zoom button */
- public static final double DEFAULT_ADD_ZOOM = 0.25;
-
- /** The zoom : MIN_ZOOM<=zoom<=MAX_ZOOM */
- protected double zoom;
-
- private transient Cursor formerCursor;
-
- private transient Point formerPoint;
-
- private transient double tx;
-
- private transient double ty;
-
-
- /**
- * The constructor by default
- * @param f The figure to display (can be null)
- */
- public GlimpsePanel(Figure f)
- {
- if(f!=null)
- f.setSelected(false);
- glimpseFigure = f;
- zoom = DEFAULT_ZOOM;
- formerCursor = null;
- formerPoint = null;
- tx = ty = 0.;
- addMouseListener(this);
- addMouseMotionListener(this);
- }
-
-
- /**
- * Allows to zoom out the drawing (up to 25%).
- */
- public void zoomOut()
- {
- if(zoom-DEFAULT_ADD_ZOOM>=MIN_ZOOM && glimpseFigure!=null)
- {
- zoom-=DEFAULT_ADD_ZOOM;
- updateTxTy();
- repaint();
- updatePreferredSize();
- revalidate();
- }
- }
-
-
- /**
- * Allows to set the zoom to default. In fact the zoom is not set at ZOOM_DEFAULT, it's set to see the whole figure.
- */
- public void zoomDefault()
- {
- if(glimpseFigure!=null)
- {
- LaTeXDrawPoint2D nw = glimpseFigure.getTheNWBoundPoint();
- LaTeXDrawPoint2D se = glimpseFigure.getTheSEBoundPoint();
- double figWidth = se.x-nw.x;
- double figHeight = se.y-nw.y;
- int height = getParent().getParent().getHeight();
- int width = getParent().getParent().getWidth();
- zoom = DEFAULT_ZOOM;
-
- while(((figHeight*zoom)>height || (figWidth*zoom)>width) && zoom>MIN_ZOOM)
- {
- zoom-=DEFAULT_ADD_ZOOM;
- }
-
- if(zoom<MIN_ZOOM)
- zoom = MIN_ZOOM;
-
- updateTxTy();
- repaint();
- updatePreferredSize();
- revalidate();
- }
- }
-
-
- /**
- * Allows to zoom in the drawing (up to 450%)
- */
- public void zoomIn()
- {
- if(zoom+DEFAULT_ADD_ZOOM<=MAX_ZOOM && glimpseFigure!=null)
- {
- zoom+=DEFAULT_ADD_ZOOM;
- updateTxTy();
- updatePreferredSize();
- repaint();
- revalidate();
- }
- }
-
-
-
- /**
- * Updates the fields tx and ty.
- * @since 1.9.2
- */
- public void updateTxTy()
- {
- LaTeXDrawPoint2D nw = glimpseFigure.getTheNWBoundPoint();
-
- tx = getParent().getParent().getWidth()/2.-glimpseFigure.getGravityCenter().x*zoom;
- ty = getParent().getParent().getHeight()/2.-glimpseFigure.getGravityCenter().y*zoom;
-
- if(nw.x*zoom+tx<0)
- tx = Math.min(-nw.x*zoom+30, -30);
-
- if(nw.y*zoom+ty<0)
- ty = Math.min(-nw.y*zoom+30, -30);
- }
-
-
-
- /**
- * Allows to set the figure to display
- * @param f The new figure to display
- */
- public void setGlimpseFigure(Figure f)
- {
- glimpseFigure = f;
-
- if(f!=null)
- {
- f.setSelected(false);
- zoomDefault();
- }
- else
- tx = ty = 0.;
- }
-
-
-
- /**
- * Allows to get the figure to display.
- * @return The glimpse figure.
- */
- public Figure getGlimpseFigure()
- {
- return glimpseFigure;
- }
-
-
-
- @Override
- public void paintComponent(Graphics g)
- {
- if(g==null || glimpseFigure==null) return;
-
- Graphics2D g2 = (Graphics2D) g;
- g2.setColor(Color.WHITE);
- g2.fillRect(0, 0, getWidth(), getHeight());
- g2.translate(tx, ty);
- g2.scale(zoom, zoom);
-
- g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
- g2.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
- g2.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
- g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
-
- glimpseFigure.draw(g2, RenderingHints.VALUE_ANTIALIAS_ON, RenderingHints.VALUE_RENDER_QUALITY,
- RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
- }
-
-
-
-
- /**
- * Allows to update the dimensions of the drawing (needed for the scrollers)
- */
- public void updatePreferredSize()
- {
- if(glimpseFigure==null)
- setPreferredSize(new Dimension(0,0));
- else
- {
- LaTeXDrawPoint2D SE = glimpseFigure.getTheSEBoundPoint();
- setPreferredSize(new Dimension((int)(SE.x*zoom+tx), (int)(SE.y*zoom+ty)));
- }
- }
-
-
-
- @Override
- public void repaint()
- {
- updatePreferredSize();
- revalidate();
- super.repaint();
- }
-
-
-
- /**
- * Useful for scrollbar
- */
- public Dimension getPreferredScrollableViewportSize()
- { return new Dimension(-100, 100); }
-
-
-
- /**
- * Useful for scrollbar
- */
- public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
- {
- return (orientation == SwingConstants.VERTICAL) ? visibleRect.height :
- visibleRect.width;
- }
-
-
-
- /**
- * Useful for scrollbar
- */
- public boolean getScrollableTracksViewportHeight()
- {
- if(this.getParent() instanceof JViewport)
- return (((JViewport)getParent()).getHeight() > getPreferredSize().height);
- return false;
- }
-
-
-
-
- /**
- * Useful for scrollbar
- */
- public boolean getScrollableTracksViewportWidth()
- {
- if(getParent() instanceof JViewport)
- return (((JViewport)getParent()).getWidth() > getPreferredSize().width);
- return false;
- }
-
-
-
- /**
- * Useful for scrollbar
- */
- public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
- {
- return 4;
- }
-
-
- public void mouseClicked(MouseEvent e)
- {
- // Nothing to do.
- }
-
-
- public void mouseEntered(MouseEvent e)
- {
- formerCursor = getCursor();
- setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
- }
-
-
- public void mouseExited(MouseEvent e)
- {
- if(formerCursor!=null)
- {
- setCursor(formerCursor);
- formerCursor = null;
- }
- }
-
-
- public void mousePressed(MouseEvent e)
- {
- // Nothing to do.
- }
-
-
- public void mouseReleased(MouseEvent e)
- {
- formerPoint = null;
- }
-
-
- public void mouseDragged(MouseEvent e)
- {
- if(formerPoint!=null)
- {
- tx += e.getPoint().x-formerPoint.x;
- ty += e.getPoint().y-formerPoint.y;
- repaint();
- }
-
- formerPoint = e.getPoint();
- }
-
-
- public void mouseMoved(MouseEvent e)
- {
- // Nothing to do.
- }
- }
-
-
-
- /**
- * The abstract constructor
- * @param d The drawpanel
- */
- protected AbstractParametersFrame(Frame parent, DrawPanel d, boolean attachToMainFrame)
- {
- super(parent, true);
- try
- {
- setModified(false);
- this.attachToMainFrame = attachToMainFrame;
- drawPanel = d;
- glimpsePanel = new GlimpsePanel(null);
- glimpseScrollPane = new JScrollPane(glimpsePanel);
- glimpsePanel.updatePreferredSize();
- glimpsePanel.revalidate();
- glimpsePanelZoom = new JPanel(new BorderLayout());
- glimpsePanelZoom.add(glimpseScrollPane, BorderLayout.CENTER);
- glimpsePanelZoom.add(createZoomPanel(), BorderLayout.EAST);
- glimpsePanelZoom.setBorder(new CompoundBorder(new TitledBorder(null, "", //$NON-NLS-1$
- TitledBorder.LEFT, TitledBorder.TOP), new EmptyBorder(0,0,0,0)));
- glimpsePanelZoom.setPreferredSize(new Dimension(420, 190));
- glimpsePanelZoom.setMaximumSize(new Dimension(700, 240));
- createRotationField();
-
- setResizable(true);
-
- addWindowListener(
- new WindowAdapter()
- {
- @Override
- public void windowClosing(WindowEvent e)
- {
- if(deleteOnCancel)
- {
- drawPanel.getDraw().deleteFigure(figure, null);
- deleteOnCancel = false;
- }
- }
- });
-
- }catch(Exception e)
- {
- e.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(e);
- }
- }
-
-
-
-
- /**
- * Allows to create a panel containing buttons to zoom the 'glimpse figure'.
- * @return The created panel.
- */
- public JPanel createZoomPanel()
- {
- JPanel panel = new JPanel();
- JPanel panel2 = new JPanel();
- panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
- panel2.setLayout(new BoxLayout(panel2, BoxLayout.Y_AXIS));
-
- JButton zoomIn = new JButton(LaTeXDrawResources.zoomInIcon);
- zoomIn.setActionCommand(LaTeXDrawResources.LABEL_ZOOM_IN);
- zoomIn.addActionListener(this);
-
- JButton zoomOut = new JButton(LaTeXDrawResources.zoomOutIcon);
- zoomOut.setActionCommand(LaTeXDrawResources.LABEL_ZOOM_OUT);
- zoomOut.addActionListener(this);
-
- JButton zoomDefault = new JButton(LaTeXDrawResources.zoomDefaultIcon);
- zoomDefault.setActionCommand(LaTeXDrawResources.LABEL_ZOOM_DEFAULT);
- zoomDefault.addActionListener(this);
-
- panel2.add(zoomDefault);
- panel2.add(zoomIn);
- panel2.add(zoomOut);
- panel.add(panel2);
-
- return panel;
- }
-
-
-
-
- /**
- * Allows to set the title of the frame
- */
- public void setTitle()
- {
- setTitle(LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.33")+ " #" +figure.getNumber()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-
-
-
- /**
- * Allows to save the values of the fields in the attributes of the figure.
- */
- public void saveParameters()
- {
- try
- {
- if(attachToMainFrame && !deleteOnCancel)
- {
- drawPanel.getFrameParent().getUndoManager().add(UndoRedoManager.LABEL_CHANGE_PARAM,
- drawPanel.getDraw().getFigures().indexOf(figure), figure.clone());
- drawPanel.getFrameParent().updateUndoRedo();
- }
-
- if(figure.canHaveArrow())
- {
- ArrowHead leftA = ((Arrowable)figure).getArrowHead1();
- ArrowHead rightA = ((Arrowable)figure).getArrowHead2();
-
- JLabel lab = (JLabel)arrow1Choice.getSelectedItem();
- ((Arrowable)figure).setArrow1Style(lab.getText());
- lab = (JLabel)arrow2Choice.getSelectedItem();
- ((Arrowable)figure).setArrow2Style(lab.getText());
-
- leftA.setBracketNum(Double.valueOf(bracketNum.getValue().toString()).doubleValue());
- rightA.setBracketNum(Double.valueOf(bracketNum.getValue().toString()).doubleValue());
- leftA.setDotSizeDim(Double.valueOf(dotSizeDim.getValue().toString()).doubleValue());
- rightA.setDotSizeDim(Double.valueOf(dotSizeDim.getValue().toString()).doubleValue());
- leftA.setDotSizeNum(Double.valueOf(dotSizeNum.getValue().toString()).doubleValue());
- rightA.setDotSizeNum(Double.valueOf(dotSizeNum.getValue().toString()).doubleValue());
- leftA.setRBracketNum(Double.valueOf(rbracketNum.getValue().toString()).doubleValue());
- rightA.setRBracketNum(Double.valueOf(rbracketNum.getValue().toString()).doubleValue());
- leftA.setTBarSizeDim(Double.valueOf(tbarsizeDim.getValue().toString()).doubleValue());
- rightA.setTBarSizeDim(Double.valueOf(tbarsizeDim.getValue().toString()).doubleValue());
- leftA.setTBarSizeNum(Double.valueOf(tbarsizeNum.getValue().toString()).doubleValue());
- rightA.setTBarSizeNum(Double.valueOf(tbarsizeNum.getValue().toString()).doubleValue());
- leftA.setArrowSizeNum(Double.valueOf(arrowSizeNum.getValue().toString()).doubleValue());
- rightA.setArrowSizeNum(Double.valueOf(arrowSizeNum.getValue().toString()).doubleValue());
- leftA.setArrowSizeDim(Double.valueOf(arrowSizeDim.getValue().toString()).doubleValue());
- rightA.setArrowSizeDim(Double.valueOf(arrowSizeDim.getValue().toString()).doubleValue());
- leftA.setArrowLength(Double.valueOf(arrowLength.getValue().toString()).doubleValue());
- rightA.setArrowLength(Double.valueOf(arrowLength.getValue().toString()).doubleValue());
- leftA.setArrowInset(Double.valueOf(arrowInset.getValue().toString()).doubleValue());
- rightA.setArrowInset(Double.valueOf(arrowInset.getValue().toString()).doubleValue());
- }
-
- if(doublecolorButton!=null)
- figure.setDoubleColor(doublecolorButton.getColor());
-
- if(bordersPositionChoice!=null)
- {
- JLabel l = (JLabel) bordersPositionChoice.getSelectedItem();
- figure.setBordersPosition(l.getText());
- }
-
- if(doubleLine!=null)
- {
- figure.setHasDoubleBoundary(doubleLine.isSelected());
- figure.setDoubleSep(Double.valueOf(doubleSep.getValue().toString()));
- }
-
- if(lineChoice!=null)
- {
- JLabel l = (JLabel) lineChoice.getSelectedItem();
- figure.setLineStyle(l.getText());
- }
-
- if(thicknessField!=null)
- figure.setThickness(Float.valueOf(thicknessField.getValue().toString()));
-
- if(bordersButton!=null)
- figure.setLinesColor(bordersButton.getColor());
-
- if(interiorButton!=null)
- figure.setInteriorColor(interiorButton.getColor());
-
- if(figure.canHaveShadow())
- {
- figure.setHasShadow(shadowCheckBox.isSelected());
- figure.setShadowSize(Double.valueOf(shadowSizeField.getValue().toString()).doubleValue());
- figure.setShadowAngle(Math.toRadians(Double.valueOf(shadowAngleField.getValue().toString()).doubleValue()));
- figure.setShadowColor(shadowColorButton.getColor());
- }
-
- if(filledCheckBox!=null)
- figure.setIsFilled(filledCheckBox.isSelected());
-
- if(figure.canBeHatched())
- {
- figure.setHatchingSep(Float.valueOf(hatchSepField.getValue().toString()));
- figure.setHatchingWidth(Float.valueOf(hatchWidthField.getValue().toString()));
- figure.setHatchingColor(hatchButton.getColor());
- JLabel l = (JLabel) hatchChoice.getSelectedItem();
- figure.setHatchingStyle(l.getText());
- figure.setGradientAngle(Math.toRadians(Double.valueOf(gradientAngleField.getValue().toString()).doubleValue()));
- figure.setGradientEndColor(((ButtonIcon)gradientEndColButton.getIcon()).getColor());
- figure.setGradientStartColor(((ButtonIcon)gradientStartColButton.getIcon()).getColor());
- figure.setGradientMidPoint(Double.valueOf(gradientMidPtField.getValue().toString()).doubleValue());
- }
-
- if(rotationField!=null)
- figure.setRotationAngle(Math.toRadians(
- Double.valueOf(rotationField.getValue().toString()).doubleValue()));
-
- drawPanel.getDraw().updateBorders();
- drawPanel.updateDraw(true);
-
- }catch(Exception e)
- {
- e.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(e);
- }
- }
-
-
-
-
- public void keyTyped(KeyEvent e)
- {
- /* No action to do */
- }
-
-
- public void keyReleased(KeyEvent e)
- {
- /* No action to do */
- }
-
-
- public void keyPressed(KeyEvent e)
- {
- /* No action to do */
- }
-
-
-
-
- public void actionPerformed(ActionEvent e)
- {
- Object o = e.getSource();
-
- try
- {
- if(o instanceof JButton || o instanceof JCheckBox)
- {
- String label = ((AbstractButton)o).getActionCommand();
- Figure f = glimpsePanel.getGlimpseFigure();
-
- if(label.equals(LaTeXDrawResources.LABEL_ZOOM_IN))
- {
- glimpsePanel.zoomIn();
- return;
- }
-
- if(label.equals(LaTeXDrawResources.LABEL_ZOOM_OUT))
- {
- glimpsePanel.zoomOut();
- return;
- }
-
- if(label.equals(LaTeXDrawResources.LABEL_ZOOM_DEFAULT))
- {
- glimpsePanel.zoomDefault();
- return;
- }
-
- if(label.equals(LABEL_DOUBLELINE))
- {
- setModified(true);
- f.setHasDoubleBoundary(doubleLine.isSelected());
- doubleSep.setEnabled(doubleLine.isSelected());
- doublecolorButton.setEnabled(doubleLine.isSelected());
- glimpsePanel.repaint();
- return ;
- }
-
- if(label.equals(NAME_BUTTON_CANCEL))
- {
- if(deleteOnCancel)
- {
- drawPanel.getDraw().deleteFigure(figure, null);
- deleteOnCancel = false;
- }
- super.setVisible(false);
- return;
- }
-
- if(label.equals(NAME_BUTTON_DEFAULT))
- {
- setDefaultsValues();
- glimpsePanel.repaint();
- return;
- }
-
- if(label.equals(NAME_BUTTON_OK))
- {
- saveParameters();
-
- drawPanel.getFrameParent().updateFrameFields();
-
- if(isModified())
- drawPanel.setIsModified(true);
-
- setVisible(false);
- return;
- }
-
-
- if(label.equals(LaTeXDrawResources.LABEL_FILLED_CHECKBOX))
- {
- if(interiorButton!=null)
- {
- setModified(true);
- f.setIsFilled(filledCheckBox.isSelected());
- glimpsePanel.repaint();
- }
- return;
- }
-
- if(label.equals(LaTeXDrawResources.LABEL_SHADOW_CHECKBOX))
- {
- if(shadowColorButton!=null)
- {
- setModified(true);
- shadowColorButton.setEnabled(shadowCheckBox.isSelected());
- shadowAngleField.setEnabled(shadowCheckBox.isSelected());
- shadowSizeField.setEnabled(shadowCheckBox.isSelected());
- f.setHasShadow(shadowCheckBox.isSelected());
- updateFilledCB();
- glimpsePanel.repaint();
- }
- return;
- }
-
- if(label.equals(LaTeXDrawResources.LABEL_COLOR_GRADIENT_FIRST))
- {
- Color c = JColorChooser.showDialog((Component) e.getSource(),
- LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.34"), //$NON-NLS-1$
- ((ColorButton)o).getColor());
-
- if(c!=null)
- {
- setModified(true);
- ((ColorButton)o).setColor(c);
- f.setGradientStartColor(c);
- glimpsePanel.repaint();
- }
- return ;
- }
-
- if(label.equals(LaTeXDrawResources.LABEL_COLOR_GRADIENT_SECOND))
- {
- Color c = JColorChooser.showDialog((Component) e.getSource(),
- LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.34"), //$NON-NLS-1$
- ((ColorButton)o).getColor());
-
- if(c!=null)
- {
- setModified(true);
- ((ColorButton)o).setColor(c);
- f.setGradientEndColor(c);
- glimpsePanel.repaint();
- }
- return ;
- }
-
- if(label.equals(LaTeXDrawResources.LABEL_COLOR_HATCH))
- {
- Color c = JColorChooser.showDialog((Component) e.getSource(),
- LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.34"), //$NON-NLS-1$
- ((ColorButton)o).getColor());
-
- if(c!=null)
- {
- setModified(true);
- ((ColorButton)o).setColor(c);
- f.setHatchingColor(c);
- glimpsePanel.repaint();
- }
- return ;
- }
-
- if(label.equals(LaTeXDrawResources.LABEL_COLOR_SHADOW))
- {
- Color c = JColorChooser.showDialog((Component) e.getSource(),
- LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.34"), //$NON-NLS-1$
- ((ColorButton)o).getColor());
-
- if(c!=null)
- {
- setModified(true);
- ((ColorButton)o).setColor(c);
- f.setShadowColor(c);
- glimpsePanel.repaint();
- }
- return ;
- }
-
- if(label.equals(LABEL_BUTTON_BOUNDARY))
- {
- Color c = JColorChooser.showDialog((Component) e.getSource(),
- LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.35"), //$NON-NLS-1$
- ((ColorButton)o).getColor());
-
- if(c!=null)
- {
- setModified(true);
- ((ColorButton)o).setColor(c);
- f.setDoubleColor(c);
- glimpsePanel.repaint();
- }
- return ;
- }
-
- if(label.equals(LaTeXDrawResources.LABEL_COLOR_BUTTON))
- {
- Color c = JColorChooser.showDialog((Component) e.getSource(),
- LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.36"), //$NON-NLS-1$
- ((ColorButton)o).getColor());
-
- if(c!=null)
- {
- setModified(true);
- ((ColorButton)o).setColor(c);
- f.setLinesColor(c);
- glimpsePanel.repaint();
- }
- return ;
- }
-
- if(label.equals(LaTeXDrawResources.LABEL_COLOR_INTERIOR_BUTTON))
- {
- Color c = JColorChooser.showDialog((Component) e.getSource(),
- LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.37"), //$NON-NLS-1$
- ((ColorButton)o).getColor());
-
- if(c!=null)
- {
- setModified(true);
- ((ColorButton)o).setColor(c);
- f.setInteriorColor(c);
- glimpsePanel.repaint();
- }
- return;
- }
- } // if(o instanceof JButton)
- }catch(Exception ex)
- {
- ex.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(ex);
- }
- }
-
-
-
-
- /**
- * Allows to set the value of the specific fields of the frame
- * from the attributes of the figure
- */
- public abstract void setFigureFrameField();
-
-
-
-
- /**
- * Initialises some fields of the frame and set visible or not it.
- * @param visible True: the frame must be visible.
- * @param selected The selected figure.
- * @param deleteOnCancel True: the figure must be deleted if the user click on the button cancel.
- */
- public void setVisible(boolean visible, Figure selected, boolean deleteOnCancel, boolean isFramedBox)
- {
- try
- {
- if(visible)
- {
- setModified(false);
- this.deleteOnCancel = deleteOnCancel;
- figure = selected;
- setTitle();
-
- glimpsePanel.setGlimpseFigure((Figure) selected.clone());
- glimpsePanel.updatePreferredSize();
- glimpsePanel.revalidate();
- glimpsePanel.repaint();
-
- setFigureFrameField();
-
- if(figure.canHaveArrow())
- {
- arrow1Choice.setSelectedItem(((Arrowable)figure).getArrow1Style());
- arrow2Choice.setSelectedItem(((Arrowable)figure).getArrow2Style());
-
- ArrowHead rightA = ((Arrowable)figure).getArrowHead2();
-
- arrowInset.setValue(rightA.getArrowInset());
- arrowLength.setValue(rightA.getArrowLength());
- arrowSizeDim.setValue(rightA.getArrowSizeDim());
- arrowSizeNum.setValue(rightA.getArrowSizeNum());
- bracketNum.setValue(rightA.getBracketNum());
- dotSizeDim.setValue(rightA.getDotSizeDim());
- dotSizeNum.setValue(rightA.getDotSizeNum());
- rbracketNum.setValue(rightA.getRBracketNum());
- tbarsizeDim.setValue(rightA.getTBarSizeDim());
- tbarsizeNum.setValue(rightA.getTBarSizeNum());
-
- updateEnableParamsArrow();
- }
-
- if(doublecolorButton!=null)
- {
- doublecolorButton.setEnabled(figure.hasDoubleBoundary());
- doublecolorButton.setColor(figure.getDoubleColor());
- }
-
- if(bordersPositionChoice!=null)
- {
- bordersPositionChoice.setEnabled(figure.isBordersMovable() && !isFramedBox);
- bordersPositionChoice.setSelectedItem(figure.getBordersPosition());
- }
-
- if(doubleLine!=null)
- {
- doubleLine.setSelected(figure.hasDoubleBoundary());
- doubleSep.setEnabled(doubleLine.isSelected());
- doubleSep.setValue(figure.getDoubleSep());
- }
-
- if(rotationField!=null)
- {
- rotationField.setEnabled(!isFramedBox);
- rotationField.setValue(Math.toDegrees(selected.getRotationAngle()));
- }
-
- if(lineChoice!=null)
- lineChoice.setSelectedItem(selected.getLineStyle());
-
- if(thicknessField!=null)
- thicknessField.setValue((double)selected.getThickness());
-
- if(bordersButton!=null)
- bordersButton.setColor(selected.getLinesColor());
-
- String txt = selected.getHatchingStyle();
- int num=0;
- if(txt.equals(PSTricksConstants.TOKEN_FILL_GRADIENT))
- num=1;
- else if(txt.equals(PSTricksConstants.TOKEN_FILL_NONE) ||
- txt.equals(PSTricksConstants.TOKEN_FILL_SOLID))
- num=2;
-
- if(selected.canBeHatched())
- {
- hatchChoice.setSelectedItem(selected.getHatchingStyle());
- hatchButton.setEnabled(num==0);
- hatchWidthField.setValue((double)selected.getHatchingWidth());
- hatchSepField.setValue(selected.getHatchingSep());
- hatchButton.setColor(selected.getHatchingColor());
- hatchWidthField.setEnabled(num==0);
- hatchSepField.setEnabled(num==0);
- gradientAngleField.setEnabled(num==1);
- gradientAngleField.setValue(Math.toDegrees(selected.getGradientAngle()));
- gradientEndColButton.setEnabled(num==1);
- gradientMidPtField.setEnabled(num==1);
- gradientMidPtField.setValue(selected.getGradientMidPoint());
- gradientStartColButton.setEnabled(num==1);
- updateFilledCB();
- filledCheckBox.setSelected(selected.isFilled() && selected.canBeFilled());
- gradientEndColButton.setColor(selected.getGradientEndColor());
- gradientStartColButton.setColor(selected.getGradientStartColor());
- }
-
- if(interiorButton!=null)
- interiorButton.setColor(selected.getInteriorColor());
-
- if(selected.canHaveShadow())
- {
- shadowSizeField.setValue(figure.getShadowSize());
- shadowAngleField.setValue(Math.toDegrees(figure.getShadowAngle()));
- shadowColorButton.setEnabled(figure.hasShadow());
- shadowColorButton.setColor(figure.getShadowColor());
- shadowCheckBox.setSelected(figure.hasShadow());
- shadowColorButton.setEnabled(shadowCheckBox.isSelected());
- shadowAngleField.setEnabled(shadowCheckBox.isSelected());
- shadowSizeField.setEnabled(shadowCheckBox.isSelected());
- }
- }
- updateFilledCB();
-
- }catch(Exception e)
- {
- e.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(e);
- }
- super.setVisible(visible);
- }
-
-
-
-
- /**
- * @return A panel with components to change the parameters of the hatching of the figure.
- */
- public JPanel createHatchingPanel()
- {
- JPanel hatchingP = new JPanel(new FlowLayout(FlowLayout.LEFT));
-
- hatchButton = new ColorButton(LaTeXDrawResources.LABEL_COLOR_HATCH, new ButtonIcon(Figure.DEFAULT_BORDERS_COL));
- hatchButton.setActionCommand(LaTeXDrawResources.LABEL_COLOR_HATCH);
- hatchButton.addActionListener(this);
- hatchingP.add(hatchButton);
-
- hatchingP.add(new JLabel(LABEL_HATCH_WIDTH));
-
- SpinnerModel model = new SpinnerNumberModel(Figure.DEFAULT_HATCH_WIDTH, 0.1, 100,0.1);
- hatchWidthField = new JSpinner(model);
- hatchWidthField.setEditor(new JSpinner.NumberEditor(hatchWidthField, "0.0"));//$NON-NLS-1$
- hatchWidthField.addChangeListener(this);
- hatchWidthField.setName(Figure.LABEL_HATCH_WIDTH);
- hatchingP.add(hatchWidthField);
-
- hatchingP.add(new JLabel(LABEL_HATCH_SEP));
-
- model = new SpinnerNumberModel(Figure.DEFAULT_HATCH_SEP, 0.01, 1000,1);
- hatchSepField = new JSpinner(model);
- hatchSepField.setEditor(new JSpinner.NumberEditor(hatchSepField, "0.00"));//$NON-NLS-1$
- hatchSepField.addChangeListener(this);
- hatchSepField.setName(LABEL_HATCH_SEP);
- hatchingP.add(hatchSepField);
-
- hatchingP.setBorder(new CompoundBorder(new TitledBorder(null, LaTeXDrawLang.getString1_7("AbstractParametersFrame.8"), //$NON-NLS-1$
- TitledBorder.LEFT, TitledBorder.TOP), new EmptyBorder(0,0,0,0)));
-
- return hatchingP;
- }
-
-
-
-
- /**
- * @return A panel with components to change the parameters of the double borders of the figure.
- */
- public JPanel createDoubleLinePanel()
- {
- JPanel fillingP = new JPanel(new FlowLayout(FlowLayout.LEFT));
-
- doubleLine = new JCheckBox(LABEL_DOUBLELINE);
- doubleLine.setActionCommand(LABEL_DOUBLELINE);
- doubleLine.addActionListener(this);
- fillingP.add(doubleLine);
-
- fillingP.add(new JLabel(LABEL_DOUBLESEP));
-
- SpinnerModel model = new SpinnerNumberModel(Figure.DEFAULT_DOUBLESEP, 1, 1000,1);
- doubleSep = new JSpinner(model);
- doubleSep.setEditor(new JSpinner.NumberEditor(doubleSep, "0")); //$NON-NLS-1$
- doubleSep.setName(LABEL_DOUBLESEP);
- doubleSep.addChangeListener(this);
- doubleSep.setEnabled(doubleLine.isSelected());
- fillingP.add(doubleSep);
-
- doublecolorButton = new ColorButton(LABEL_BUTTON_BOUNDARY, new ButtonIcon(Figure.DEFAULT_DOUBLE_COLOR));
- doublecolorButton.setActionCommand(LABEL_BUTTON_BOUNDARY);
- doublecolorButton.addActionListener(this);
- fillingP.add(doublecolorButton);
- fillingP.setBorder(new CompoundBorder(new TitledBorder(null, LaTeXDrawLang.getString1_7("AbstractParametersFrame.9"), //$NON-NLS-1$
- TitledBorder.LEFT, TitledBorder.TOP), new EmptyBorder(0,0,0,0)));
-
- return fillingP;
- }
-
-
-
-
- /**
- * @return A panel with components to change the parameters of the borders of the figure.
- */
- public JPanel createBordersPanel(boolean movable)
- {
- JPanel borderP = new JPanel(new FlowLayout(FlowLayout.LEFT));
- borderP.add(new JLabel(LABEL_THICKNESS));
-
- SpinnerModel model = new SpinnerNumberModel(Figure.DEFAULT_THICKNESS, 0.1, 100,0.1);
- thicknessField = new JSpinner(model);
- thicknessField.setName(LaTeXDrawResources.NAME_THICKNESS_FIELD);
- thicknessField.setEditor(new JSpinner.NumberEditor(thicknessField, "0.0"));//$NON-NLS-1$
- thicknessField.addChangeListener(this);
- borderP.add(thicknessField);
-
- bordersButton = new ColorButton(LaTeXDrawResources.LABEL_COLOR_BUTTON, new ButtonIcon(Figure.DEFAULT_BORDERS_COL));
- bordersButton.setActionCommand(LaTeXDrawResources.LABEL_COLOR_BUTTON);
- bordersButton.addActionListener(this);
- borderP.add(bordersButton);
- borderP.add(new JLabel(LABEL_TYPE_LINE));
-
- lineChoice = createLineChoice(this);
- borderP.add(lineChoice);
-
- if(movable)
- {
- bordersPositionChoice = Figure.createBordersPositionChoice();
- bordersPositionChoice.addItemListener(this);
- borderP.add(bordersPositionChoice);
- }
-
- borderP.setBorder(new CompoundBorder(new TitledBorder(null, LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.47"), //$NON-NLS-1$
- TitledBorder.LEFT, TitledBorder.TOP), new EmptyBorder(0,0,0,0)));
-
- return borderP;
- }
-
-
-
-
- /**
- * @return A panel with components to change the parameters of the filling of the figure.
- */
- public JPanel createFillPanel()
- {
- JPanel fillingP = new JPanel(new FlowLayout(FlowLayout.LEFT));
-
- filledCheckBox = new JCheckBox(LaTeXDrawResources.LABEL_FILLED_CHECKBOX);
- filledCheckBox.setActionCommand(LaTeXDrawResources.LABEL_FILLED_CHECKBOX);
- filledCheckBox.addActionListener(this);
- fillingP.add(filledCheckBox);
-
- interiorButton = new ColorButton(LaTeXDrawResources.LABEL_COLOR_INTERIOR_BUTTON, new ButtonIcon(Figure.DEFAULT_INTERIOR_COL));
- interiorButton.setActionCommand(LaTeXDrawResources.LABEL_COLOR_INTERIOR_BUTTON);
- interiorButton.addActionListener(this);
- fillingP.add(interiorButton);
-
- hatchChoice = Figure.createFillChoice();
- hatchChoice.setPreferredSize(new Dimension(60,25));
- hatchChoice.addItemListener(this);
- fillingP.add(hatchChoice);
-
- fillingP.setBorder(new CompoundBorder(new TitledBorder(null, LaTeXDrawLang.getString1_7("AbstractParametersFrame.11"), //$NON-NLS-1$
- TitledBorder.LEFT, TitledBorder.TOP), new EmptyBorder(0,0,0,0)));
-
- return fillingP;
- }
-
-
-
-
- /**
- * @return A panel with components to change the parameters of the shadow of the figure.
- */
- public JPanel createGradientPanel()
- {
- GridBagConstraints constraint = new GridBagConstraints();
- constraint.gridx = 0; constraint.gridy = 0;
- constraint.gridwidth = 1; constraint.gridheight = 1;
- constraint.weightx = 0.1; constraint.weighty = 0.1;
- constraint.fill = GridBagConstraints.NONE;
- constraint.anchor = GridBagConstraints.WEST;
-
- JPanel gradientP = new JPanel(new GridBagLayout());
-
- gradientStartColButton = new ColorButton(LaTeXDrawResources.LABEL_COLOR_GRADIENT_FIRST, new ButtonIcon(PSTricksConstants.DEFAULT_GRADIENT_START_COLOR));
- gradientStartColButton.setActionCommand(LaTeXDrawResources.LABEL_COLOR_GRADIENT_FIRST);
- gradientStartColButton.addActionListener(this);
- gradientP.add(gradientStartColButton, constraint);
-
- gradientEndColButton = new ColorButton(LaTeXDrawResources.LABEL_COLOR_GRADIENT_SECOND, new ButtonIcon(PSTricksConstants.DEFAULT_GRADIENT_END_COLOR));
- gradientEndColButton.setActionCommand(LaTeXDrawResources.LABEL_COLOR_GRADIENT_SECOND);
- gradientEndColButton.addActionListener(this);
- constraint.gridx++;
- gradientP.add(gradientEndColButton, constraint);
-
- constraint.gridy++; constraint.gridx=0;
- gradientP.add(new JLabel(LABEL_GRADIENT_MID_PT), constraint);
-
- constraint.gridx++;
- SpinnerModel model = new SpinnerNumberModel(Figure.DEFAULT_GRADIENT_MID_POINT,0,1,0.01);
- gradientMidPtField = new JSpinner(model);
- gradientMidPtField.setEditor(new JSpinner.NumberEditor(gradientMidPtField, "0.000"));//$NON-NLS-1$
- gradientMidPtField.addChangeListener(this);
- gradientMidPtField.setName(LABEL_GRADIENT_MID_PT);
- gradientP.add(gradientMidPtField, constraint);
-
- constraint.gridx++;
- gradientP.add(new JLabel(LABEL_GRADIENT_ANGLE), constraint);
-
- constraint.gridx++;
- model = new SpinnerNumberModel(Math.toDegrees(Figure.DEFAULT_GRADIENT_ANGLE), -360, 360,0.5);
- gradientAngleField = new JSpinner(model);
- gradientAngleField.setEditor(new JSpinner.NumberEditor(gradientAngleField, "0.0"));//$NON-NLS-1$
- gradientAngleField.addChangeListener(this);
- gradientAngleField.setName(LABEL_GRADIENT_ANGLE);
- constraint.gridx++;
- gradientP.add(gradientAngleField, constraint);
-
- gradientP.setBorder(new CompoundBorder(new TitledBorder(null, LaTeXDrawLang.getString1_7("AbstractParametersFrame.12"), //$NON-NLS-1$
- TitledBorder.LEFT, TitledBorder.TOP), new EmptyBorder(0,0,0,0)));
-
- return gradientP;
- }
-
-
-
- /**
- * @return A panel with components to change the parameters of the shadow of the figure.
- */
- public JPanel createShadowPanel()
- {
- GridBagConstraints constraint = new GridBagConstraints();
- constraint.gridx = 0; constraint.gridy = 0;
- constraint.gridwidth = 1; constraint.gridheight = 1;
- constraint.weightx = 0.1; constraint.weighty = 0.1;
- constraint.fill = GridBagConstraints.NONE;
- constraint.anchor = GridBagConstraints.CENTER;
-
- JPanel shadowP = new JPanel(new GridBagLayout());
-
- constraint.gridy=0; constraint.gridx=0;
- shadowCheckBox = new JCheckBox(LaTeXDrawResources.LABEL_SHADOW_CHECKBOX);
- shadowCheckBox.setActionCommand(LaTeXDrawResources.LABEL_SHADOW_CHECKBOX);
- shadowCheckBox.addActionListener(this);
- constraint.gridx=0; constraint.gridy=0;
- shadowP.add(shadowCheckBox, constraint);
-
- shadowColorButton = new ColorButton(LaTeXDrawResources.LABEL_COLOR_SHADOW, new ButtonIcon(Figure.DEFAULT_SHADOW_COLOR));
- shadowColorButton.setActionCommand(LaTeXDrawResources.LABEL_COLOR_SHADOW);
- shadowColorButton.addActionListener(this);
- constraint.gridx++;
- shadowP.add(shadowColorButton, constraint);
-
- constraint.gridy++; constraint.gridx=0;
- shadowP.add(new JLabel(LABEL_SHADOW_SIZE), constraint);
-
- constraint.gridx++;
- SpinnerModel model = new SpinnerNumberModel(Figure.DEFAULT_SHADOW_SIZE,0.01,1000,1);
- shadowSizeField = new JSpinner(model);
- shadowSizeField.setEditor(new JSpinner.NumberEditor(shadowSizeField, "0.00"));//$NON-NLS-1$
- shadowSizeField.addChangeListener(this);
- shadowSizeField.setName(LABEL_SHADOW_SIZE);
- shadowP.add(shadowSizeField, constraint);
-
- constraint.gridx++;
- shadowP.add(new JLabel(LABEL_SHADOW_ANGLE), constraint);
-
- constraint.gridx++;
- model = new SpinnerNumberModel(Math.toDegrees(Figure.DEFAULT_SHADOW_ANGLE), -360, 360,0.5);
- shadowAngleField = new JSpinner(model);
- shadowAngleField.setEditor(new JSpinner.NumberEditor(shadowAngleField, "0.0"));//$NON-NLS-1$
- shadowAngleField.addChangeListener(this);
- shadowAngleField.setName(LABEL_SHADOW_ANGLE);
- constraint.gridx++;
- shadowP.add(shadowAngleField, constraint);
-
- shadowP.setBorder(new CompoundBorder(new TitledBorder(null, LaTeXDrawLang.getString1_7("LaTeXDrawFrame.0"), //$NON-NLS-1$
- TitledBorder.LEFT, TitledBorder.TOP), new EmptyBorder(0,0,0,0)));
-
- return shadowP;
- }
-
-
-
-
- /**
- * Allows to create a panel with defaults buttons (ok, cancel, default)
- * @param frame The frame which ask the panel
- * @return The created panel
- */
- public JPanel createButtonsPanel(AbstractParametersFrame frame)
- {
- JPanel panel = new JPanel();
-
- buttonOk = new JButton(LABEL_OK);
- JButton buttonCancel = new JButton(LABEL_CANCEL),
- buttonDefault = new JButton(LABEL_DEFAULT);
-
- buttonOk.setActionCommand(NAME_BUTTON_OK);
- buttonCancel.setActionCommand(NAME_BUTTON_CANCEL);
- buttonDefault.setActionCommand(NAME_BUTTON_DEFAULT);
-
- panel.add(buttonOk);
- panel.add(buttonCancel);
- panel.add(buttonDefault);
- panel.setPreferredSize(new Dimension(280, 40));
- panel.setMaximumSize(new Dimension(280, 40));
- buttonOk.addActionListener(frame);
- buttonCancel.addActionListener(frame);
- buttonDefault.addActionListener(frame);
-
- return panel;
- }
-
-
-
-
- /**
- * Allows to set by default some fields of the frame
- */
- public void setDefaultsValues()
- {
- Figure f = glimpsePanel.getGlimpseFigure();
- setModified(true);
-
- if(f.canHaveShadow())
- {
- f.setHasShadow(PSTricksConstants.DEFAULT_SHADOW);
- shadowAngleField.setValue(Math.toDegrees(Figure.DEFAULT_SHADOW_ANGLE));
- shadowSizeField.setValue(Figure.DEFAULT_SHADOW_SIZE);
- shadowColorButton.setEnabled(Figure.DEFAULT_SHADOW_HAS);
- shadowColorButton.setColor(Figure.DEFAULT_SHADOW_COLOR);
- f.setShadowColor(Figure.DEFAULT_SHADOW_COLOR);
- glimpsePanel.glimpseFigure.setDoubleColor(Figure.DEFAULT_SHADOW_COLOR);
- shadowCheckBox.setSelected(Figure.DEFAULT_SHADOW_HAS);
- shadowSizeField.setEnabled(shadowCheckBox.isSelected());
- shadowAngleField.setEnabled(shadowCheckBox.isSelected());
- }
-
- if(f.canHaveArrow())
- {
- ((Arrowable)f).setArrow1Style(ArrowHead.DEFAULT_STYLE);
- ((Arrowable)f).setArrow2Style(ArrowHead.DEFAULT_STYLE);
- arrow1Choice.setSelectedItem(ArrowHead.DEFAULT_STYLE);
- arrow2Choice.setSelectedItem(ArrowHead.DEFAULT_STYLE);
-
- bracketNum.setValue(ArrowHead.DEFAULT_BRACKET_NUM);
- dotSizeDim.setValue(ArrowHead.DEFAULT_DOT_SIZE_DIM);
- dotSizeNum.setValue(ArrowHead.DEFAULT_ARROW_SIZE_NUM);
- rbracketNum.setValue(ArrowHead.DEFAULT_RBRACKET_NUM);
- tbarsizeDim.setValue(ArrowHead.DEFAULT_TBAR_SIZE_DIM);
- tbarsizeNum.setValue(ArrowHead.DEFAULT_TBAR_SIZE_NUM);
- arrowInset.setValue(ArrowHead.DEFAULT_ARROW_INSET);
- arrowLength.setValue(ArrowHead.DEFAULT_ARROW_LGTH);
- arrowSizeDim.setValue(ArrowHead.DEFAULT_ARROW_SIZE_DIM);
- arrowSizeNum.setValue(ArrowHead.DEFAULT_ARROW_SIZE_NUM);
-
- ArrowHead leftA = ((Arrowable)f).getArrowHead1();
- ArrowHead rightA = ((Arrowable)f).getArrowHead2();
-
- leftA.setBracketNum(ArrowHead.DEFAULT_BRACKET_NUM);
- rightA.setBracketNum(ArrowHead.DEFAULT_BRACKET_NUM);
- leftA.setDotSizeDim(ArrowHead.DEFAULT_DOT_SIZE_DIM);
- rightA.setDotSizeDim(ArrowHead.DEFAULT_DOT_SIZE_DIM);
- leftA.setDotSizeNum(ArrowHead.DEFAULT_ARROW_SIZE_NUM);
- rightA.setDotSizeNum(ArrowHead.DEFAULT_ARROW_SIZE_NUM);
- leftA.setRBracketNum(ArrowHead.DEFAULT_RBRACKET_NUM);
- rightA.setRBracketNum(ArrowHead.DEFAULT_RBRACKET_NUM);
- leftA.setTBarSizeDim(ArrowHead.DEFAULT_TBAR_SIZE_DIM);
- rightA.setTBarSizeDim(ArrowHead.DEFAULT_TBAR_SIZE_DIM);
- leftA.setTBarSizeNum(ArrowHead.DEFAULT_TBAR_SIZE_NUM);
- rightA.setTBarSizeNum(ArrowHead.DEFAULT_TBAR_SIZE_NUM);
-
- leftA.setArrowSizeNum(ArrowHead.DEFAULT_ARROW_SIZE_NUM);
- rightA.setArrowSizeNum(ArrowHead.DEFAULT_ARROW_SIZE_NUM);
- leftA.setArrowSizeDim(ArrowHead.DEFAULT_ARROW_SIZE_DIM);
- rightA.setArrowSizeDim(ArrowHead.DEFAULT_ARROW_SIZE_DIM);
- leftA.setArrowLength(ArrowHead.DEFAULT_ARROW_LGTH);
- rightA.setArrowLength(ArrowHead.DEFAULT_ARROW_LGTH);
- leftA.setArrowInset(ArrowHead.DEFAULT_ARROW_INSET);
- rightA.setArrowInset(ArrowHead.DEFAULT_ARROW_INSET);
-
- updateEnableParamsArrow();
- }
-
- if(doublecolorButton!=null)
- {
- doublecolorButton.setEnabled(Figure.DEFAULT_DOUBLELINE);
- doublecolorButton.setColor(Figure.DEFAULT_DOUBLE_COLOR);
- glimpsePanel.glimpseFigure.setDoubleColor(Figure.DEFAULT_DOUBLE_COLOR);
- }
-
- if(bordersPositionChoice!=null)
- {
- bordersPositionChoice.setSelectedItem(Figure.DEFAULT_BORDERS_POSITION);
- glimpsePanel.glimpseFigure.setBordersPosition(Figure.DEFAULT_BORDERS_POSITION);
- }
-
- if(doubleLine!=null)
- {
- glimpsePanel.glimpseFigure.setHasDoubleBoundary(Figure.DEFAULT_DOUBLELINE);
- glimpsePanel.glimpseFigure.setDoubleSep(Figure.DEFAULT_DOUBLESEP);
- doubleLine.setSelected(Figure.DEFAULT_DOUBLELINE);
- doubleSep.setValue(Figure.DEFAULT_DOUBLESEP);
- }
-
- if(lineChoice!=null)
- lineChoice.setSelectedItem(Figure.DEFAULT_LINE_STYLE);
-
- if(f.canBeHatched())
- {
- hatchButton.setColor(Figure.DEFAULT_HATCH_COL);
- glimpsePanel.getGlimpseFigure().setHatchingColor(Figure.DEFAULT_HATCH_COL);
- hatchChoice.setSelectedItem(Figure.DEFAULT_HATCH_STYLE);
- hatchWidthField.setValue((double)Figure.DEFAULT_HATCH_WIDTH);
- hatchSepField.setValue(Figure.DEFAULT_HATCH_SEP);
- }
-
- if(bordersButton!=null)
- {
- bordersButton.setColor(Figure.DEFAULT_BORDERS_COL);
- glimpsePanel.getGlimpseFigure().setLinesColor(Figure.DEFAULT_BORDERS_COL);
- }
-
- if(interiorButton!=null)
- {
- interiorButton.setColor(Figure.DEFAULT_INTERIOR_COL);
- glimpsePanel.getGlimpseFigure().setInteriorColor(Figure.DEFAULT_INTERIOR_COL);
- }
-
- if(filledCheckBox!=null)
- filledCheckBox.setSelected(Figure.DEFAULT_IS_FILLED);
-
- if(f.canBeHatched())
- {
- gradientAngleField.setValue(Math.toDegrees(Figure.DEFAULT_GRADIENT_ANGLE));
- gradientMidPtField.setValue(Figure.DEFAULT_GRADIENT_MID_POINT);
- gradientEndColButton.setColor(PSTricksConstants.DEFAULT_GRADIENT_END_COLOR);
- boolean ok = Figure.DEFAULT_HATCH_STYLE.equals(PSTricksConstants.TOKEN_FILL_GRADIENT);
- gradientEndColButton.setEnabled(ok);
- gradientStartColButton.setColor(PSTricksConstants.DEFAULT_GRADIENT_START_COLOR);
- gradientStartColButton.setEnabled(ok);
- gradientMidPtField.setEnabled(ok);
- gradientAngleField.setEnabled(ok);
- }
-
- if(rotationField!=null)
- rotationField.setValue(Figure.DEFAULT_ROTATION_ANGLE);
-
- if(thicknessField!=null)
- thicknessField.setValue((double)Figure.DEFAULT_THICKNESS);
-
- glimpsePanel.repaint();
- }
-
-
-
-
- /**
- * Allows to create the list of the different styles of line.
- * @param frame The frame which ask the Choice.
- * @return The created Choice.
- */
- public LaTeXDrawComboBox createLineChoice(AbstractParametersFrame frame)
- {
- LaTeXDrawComboBox choice = Figure.createStyleLineChoice();
- choice.setActionCommand(LaTeXDrawResources.CHOICE_LINE_NAME);
- choice.setName(LaTeXDrawResources.CHOICE_LINE_NAME);
- choice.addItemListener(frame);
-
- return choice;
- }
-
-
-
-
- public void itemStateChanged(ItemEvent e)
- {
- try
- {
- Object o = e.getSource();
- Figure f = glimpsePanel.getGlimpseFigure();
-
- if(o instanceof LaTeXDrawComboBox)
- {
- String ac = ((LaTeXDrawComboBox)o).getActionCommand();
-
- if(ac.equals(LaTeXDrawResources.CHOICE_LINE_NAME))
- {
- JLabel l = (JLabel) lineChoice.getSelectedItem();
-
- setModified(true);
- f.setLineStyle(l.getText());
- glimpsePanel.repaint();
- return ;
- }
-
- if(ac.equals(Figure.LABEL_BORDERS_POSITION_CHOICE))
- {
- JLabel l = (JLabel) bordersPositionChoice.getSelectedItem();
-
- setModified(true);
- f.setBordersPosition(l.getText());
- glimpsePanel.repaint();
- return ;
- }
-
- if(ac.equals(Figure.LABEL_HATCH_CHOICE))
- {
- String txt = ((JLabel)hatchChoice.getSelectedItem()).getText();
- int num=0;
-
- if(txt.equals(PSTricksConstants.TOKEN_FILL_GRADIENT))
- num=1;
- else if(txt.equals(PSTricksConstants.TOKEN_FILL_NONE) || txt.equals(PSTricksConstants.TOKEN_FILL_SOLID))
- num=2;
-
- setModified(true);
- f.setHatchingStyle(txt);
- hatchButton.setEnabled(num==0);
- hatchWidthField.setEnabled(num==0);
- hatchSepField.setEnabled(num==0);
- gradientAngleField.setEnabled(num==1);
- gradientEndColButton.setEnabled(num==1);
- gradientMidPtField.setEnabled(num==1);
- gradientStartColButton.setEnabled(num==1);
- updateFilledCB();
- glimpsePanel.repaint();
- return ;
- }
-
- if(ac.equals(LaTeXDrawResources.CHOICE_ARROW_LEFT_NAME))
- {
- JLabel label = (JLabel) arrow1Choice.getSelectedItem();
-
- setModified(true);
- ((Arrowable)f).setArrow1Style(label.getText());
- updateEnableParamsArrow();
- glimpsePanel.repaint();
- return ;
- }
-
- if(ac.equals(LaTeXDrawResources.CHOICE_ARROW_RIGHT_NAME))
- {
- JLabel label = (JLabel) arrow2Choice.getSelectedItem();
-
- setModified(true);
- ((Arrowable)f).setArrow2Style(label.getText());
- updateEnableParamsArrow();
- glimpsePanel.repaint();
- return ;
- }
- }
- }catch(Exception ex)
- {
- ex.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(ex);
- }
- }
-
-
-
-
- /**
- * Defines actions to do when a item like JSpinner has changed
- */
- public void stateChanged(ChangeEvent e)
- {
- try
- {
- Object o = e.getSource();
-
- if(o instanceof JSpinner)
- {
- String name = ((JSpinner)o).getName();
- Figure f = glimpsePanel.getGlimpseFigure();
- double v = Double.valueOf(((JSpinner)o).getValue().toString()).doubleValue();
-
- if(name.equals(LaTeXDrawResources.NAME_THICKNESS_FIELD))
- {
- if(f instanceof Dot)
- ((Dot)f).setWidth((float)v);
- else
- f.setThickness((float)v);
-
- setModified(true);
- glimpsePanel.repaint();
- return ;
- }
-
- if(name.equals(LABEL_DOUBLESEP))
- {
- setModified(true);
- f.setDoubleSep(v);
- glimpsePanel.repaint();
- return ;
- }
-
- if(name.equals(LABEL_HATCH_SEP))
- {
- setModified(true);
- f.setHatchingSep(v);
- glimpsePanel.repaint();
- return ;
- }
-
- if(name.equals(LABEL_GRADIENT_ANGLE))
- {
- setModified(true);
- f.setGradientAngle(Math.toRadians(v));
- glimpsePanel.repaint();
- return ;
- }
-
- if(name.equals(LABEL_GRADIENT_MID_PT))
- {
- setModified(true);
- f.setGradientMidPoint(v);
- glimpsePanel.repaint();
- return ;
- }
-
- if(name.equals(LABEL_SHADOW_ANGLE))
- {
- setModified(true);
- f.setShadowAngle(v);
- glimpsePanel.repaint();
- return ;
- }
-
- if(name.equals(LABEL_SHADOW_SIZE))
- {
- setModified(true);
- f.setShadowSize(v);
- glimpsePanel.repaint();
- return ;
- }
-
- if(name.equals(Figure.LABEL_HATCH_WIDTH))
- {
- setModified(true);
- f.setHatchingWidth((float)v);
- glimpsePanel.repaint();
- return ;
- }
-
- if(name.equals(LaTeXDrawResources.LABEL_ROTATE))
- {
- setModified(true);
- f.setRotationAngle(Math.toRadians(v));
- glimpsePanel.repaint();
- return;
- }
-
- if(name.equals(LABEL_BRACKETNUM))
- {
- setModified(true);
- ((Arrowable)f).getArrowHead2().setBracketNum(v);
- ((Arrowable)f).getArrowHead1().setBracketNum(v);
- glimpsePanel.repaint();
- return;
- }
-
- if(name.equals(LABEL_DOTSIZEDIM))
- {
- setModified(true);
- ((Arrowable)f).getArrowHead1().setDotSizeDim(v);
- ((Arrowable)f).getArrowHead2().setDotSizeDim(v);
- glimpsePanel.repaint();
- return;
- }
-
- if(name.equals(LABEL_DOTSIZENUM))
- {
- setModified(true);
- ((Arrowable)f).getArrowHead1().setDotSizeNum(v);
- ((Arrowable)f).getArrowHead2().setDotSizeNum(v);
- glimpsePanel.repaint();
- return;
- }
-
- if(name.equals(LABEL_RBRACKETNUM))
- {
- setModified(true);
- ((Arrowable)f).getArrowHead1().setRBracketNum(v);
- ((Arrowable)f).getArrowHead2().setRBracketNum(v);
- glimpsePanel.repaint();
- return;
- }
-
- if(name.equals(LABEL_TBARSIZEDIM))
- {
- setModified(true);
- ((Arrowable)f).getArrowHead1().setTBarSizeDim(v);
- ((Arrowable)f).getArrowHead2().setTBarSizeDim(v);
- glimpsePanel.repaint();
- return;
- }
-
- if(name.equals(LABEL_TBARSIZENUM))
- {
- setModified(true);
- ((Arrowable)f).getArrowHead1().setTBarSizeNum(v);
- ((Arrowable)f).getArrowHead2().setTBarSizeNum(v);
- glimpsePanel.repaint();
- return;
- }
-
- if(name.equals(LABEL_ARROWSIZENUM))
- {
- setModified(true);
- ((Arrowable)f).getArrowHead1().setArrowSizeNum(v);
- ((Arrowable)f).getArrowHead2().setArrowSizeNum(v);
- glimpsePanel.repaint();
- return;
- }
-
- if(name.equals(LABEL_ARROWSIZEDIM))
- {
- setModified(true);
- ((Arrowable)f).getArrowHead1().setArrowSizeDim(v);
- ((Arrowable)f).getArrowHead2().setArrowSizeDim(v);
- glimpsePanel.repaint();
- return ;
- }
-
- if(name.equals(LABEL_ARROWLENGTH))
- {
- setModified(true);
- ((Arrowable)f).getArrowHead1().setArrowLength(v);
- ((Arrowable)f).getArrowHead2().setArrowLength(v);
- glimpsePanel.repaint();
- return ;
- }
-
- if(name.equals(LABEL_ARROWINSET))
- {
- setModified(true);
- ((Arrowable)f).getArrowHead1().setArrowInset(v);
- ((Arrowable)f).getArrowHead2().setArrowInset(v);
- glimpsePanel.repaint();
- return ;
- }
- }
- }catch(Exception ex)
- {
- ex.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(ex);
- }
- }
-
-
-
- /**
- * Allows to set the field rotationField.
- */
- public void createRotationField()
- {
- SpinnerModel model = new SpinnerNumberModel(Figure.DEFAULT_ROTATION_ANGLE, -360, 360,0.1);
- rotationField = new JSpinner(model);
- rotationField.setEditor(new JSpinner.NumberEditor(rotationField, "0.0")); //$NON-NLS-1$
- rotationField.setName(LaTeXDrawResources.LABEL_ROTATE);
- rotationField.addChangeListener(this);
- rotationField.setName(LaTeXDrawResources.LABEL_ROTATE);
- }
-
-
-
- /**
- * @return Create a panel with fields to modify the arrows.
- * @param twoLeftArrows True if the figure has two 'left' arrows like arc and not a right arrow and a left arrow like line.
- */
- public JPanel createArrowPanel(boolean twoLeftArrows, boolean withFillButton)
- {
- JPanel arrowP = new JPanel(new GridBagLayout());
- GridBagConstraints constraint = new GridBagConstraints();
- constraint.gridx = 0;
- constraint.gridy = 0;
- constraint.gridwidth = 1;
- constraint.gridheight = 1;
- constraint.weightx = 0.1;
- constraint.weighty = 0.1;
- constraint.fill = GridBagConstraints.NONE;
- constraint.anchor = GridBagConstraints.WEST;
-
- arrowP.add(new JLabel(LABEL_LEFT_ARROW), constraint);
-
- arrow1Choice = ArrowHead.createLeftArrowStyleList();
- arrow1Choice.setName(LaTeXDrawResources.CHOICE_ARROW_LEFT_NAME);
- arrow1Choice.setActionCommand(LaTeXDrawResources.CHOICE_ARROW_LEFT_NAME);
- arrow1Choice.setSelectedItem(PSTricksConstants.NONEARROW_STYLE);
- arrow1Choice.addItemListener(this);
- constraint.gridx++;
- arrowP.add(arrow1Choice, constraint);
-
- constraint.gridx++;
- arrowP.add(new JLabel(LABEL_RIGHT_ARROW), constraint);
-
- if(twoLeftArrows)
- arrow2Choice = ArrowHead.createLeftArrowStyleList();
- else
- arrow2Choice = ArrowHead.createRightArrowStyleList();
- arrow2Choice.setName(LaTeXDrawResources.CHOICE_ARROW_RIGHT_NAME);
- arrow2Choice.setActionCommand(LaTeXDrawResources.CHOICE_ARROW_RIGHT_NAME);
- arrow2Choice.setSelectedItem(PSTricksConstants.NONEARROW_STYLE);
- arrow2Choice.addItemListener(this);
- constraint.gridx++;
- arrowP.add(arrow2Choice, constraint);
-
- constraint.gridx=0; constraint.gridy++;
- arrowP.add(new JLabel(LABEL_DOTSIZE), constraint);
-
- SpinnerNumberModel model = new SpinnerNumberModel(ArrowHead.DEFAULT_DOT_SIZE_NUM, 0.1, 100,0.1);
- dotSizeNum = new JSpinner(model);
- dotSizeNum.setName(LABEL_DOTSIZENUM);
- dotSizeNum.setEditor(new JSpinner.NumberEditor(dotSizeNum, "0.0000"));//$NON-NLS-1$
- dotSizeNum.addChangeListener(this);
- constraint.gridx++;
- arrowP.add(dotSizeNum, constraint);
-
- constraint.gridx++;
- arrowP.add(new JLabel(LABEL_CROSS_THICKNESS), constraint);
-
- model = new SpinnerNumberModel(ArrowHead.DEFAULT_DOT_SIZE_DIM, 0, 1000,1);
- dotSizeDim = new JSpinner(model);
- dotSizeDim.setName(LABEL_DOTSIZEDIM);
- dotSizeDim.setEditor(new JSpinner.NumberEditor(dotSizeDim, "0.00"));//$NON-NLS-1$
- dotSizeDim.addChangeListener(this);
- constraint.gridx++;
- arrowP.add(dotSizeDim, constraint);
-
- constraint.gridx = 0;
- constraint.gridy++;
- arrowP.add(new JLabel(LABEL_TBARSIZE), constraint);
-
- model = new SpinnerNumberModel(ArrowHead.DEFAULT_TBAR_SIZE_NUM,0.1, 100,0.1);
- tbarsizeNum = new JSpinner(model);
- tbarsizeNum.setName(LABEL_TBARSIZENUM);
- tbarsizeNum.setEditor(new JSpinner.NumberEditor(tbarsizeNum, "0.0000"));//$NON-NLS-1$
- tbarsizeNum.addChangeListener(this);
- constraint.gridx++;
- arrowP.add(tbarsizeNum, constraint);
-
- constraint.gridx++;
- arrowP.add(new JLabel(LABEL_CROSS_THICKNESS), constraint);
-
- model = new SpinnerNumberModel(ArrowHead.DEFAULT_TBAR_SIZE_DIM, 0, 1000,1);
- tbarsizeDim = new JSpinner(model);
- tbarsizeDim.setName(LABEL_TBARSIZEDIM);
- tbarsizeDim.setEditor(new JSpinner.NumberEditor(tbarsizeDim, "0.00"));//$NON-NLS-1$
- tbarsizeDim.addChangeListener(this);
- constraint.gridx++;
- arrowP.add(tbarsizeDim, constraint);
-
- constraint.gridx = 0;
- constraint.gridy++;
- arrowP.add(new JLabel(LABEL_BRACKET_LGTH), constraint);
-
- model = new SpinnerNumberModel(ArrowHead.DEFAULT_BRACKET_NUM, 0.001, 100,0.01);
- bracketNum = new JSpinner(model);
- bracketNum.setName(LABEL_BRACKETNUM);
- bracketNum.setEditor(new JSpinner.NumberEditor(bracketNum, "0.0000"));//$NON-NLS-1$
- bracketNum.addChangeListener(this);
- constraint.gridx++;
- arrowP.add(bracketNum, constraint);
-
- constraint.gridx++;
- arrowP.add(new JLabel(LABEL_CROSS_WIDTH), constraint);
-
- constraint.gridx = 0;
- constraint.gridy++;
- arrowP.add(new JLabel(LABEL_RBRACKET_LGTH), constraint);
-
- model = new SpinnerNumberModel(ArrowHead.DEFAULT_RBRACKET_NUM, 0.001, 100,0.01);
- rbracketNum = new JSpinner(model);
- rbracketNum.setName(LABEL_RBRACKETNUM);
- rbracketNum.setEditor(new JSpinner.NumberEditor(rbracketNum, "0.0000"));//$NON-NLS-1$
- rbracketNum.addChangeListener(this);
- constraint.gridx++;
- arrowP.add(rbracketNum, constraint);
-
- constraint.gridx++;
- arrowP.add(new JLabel(LABEL_CROSS_WIDTH), constraint);
-
- constraint.gridx=0;
- constraint.gridy++;
- arrowP.add(new JLabel(LABEL_ARROW_WIDTH), constraint);
-
- model = new SpinnerNumberModel(ArrowHead.DEFAULT_ARROW_SIZE_NUM, 0.001, 100,0.01);
- arrowSizeNum = new JSpinner(model);
- arrowSizeNum.setName(LABEL_ARROWSIZENUM);
- arrowSizeNum.setEditor(new JSpinner.NumberEditor(arrowSizeNum, "0.0000"));//$NON-NLS-1$
- arrowSizeNum.addChangeListener(this);
- constraint.gridx++;
- arrowP.add(arrowSizeNum, constraint);
-
- constraint.gridx++;
- arrowP.add(new JLabel(LABEL_CROSS_THICKNESS), constraint);
-
- model = new SpinnerNumberModel(ArrowHead.DEFAULT_ARROW_SIZE_DIM, 0, 1000, 1);
- arrowSizeDim = new JSpinner(model);
- arrowSizeDim.setName(LABEL_ARROWSIZEDIM);
- arrowSizeDim.setEditor(new JSpinner.NumberEditor(arrowSizeDim, "0.00"));//$NON-NLS-1$
- arrowSizeDim.addChangeListener(this);
- constraint.gridx++;
- arrowP.add(arrowSizeDim, constraint);
-
- constraint.gridx=0;
- constraint.gridy++;
- arrowP.add(new JLabel(LABEL_ARROW_LENGTH), constraint);
-
- model = new SpinnerNumberModel(ArrowHead.DEFAULT_ARROW_LGTH, 0, 100,0.01);
- arrowLength = new JSpinner(model);
- arrowLength.setName(LABEL_ARROWLENGTH);
- arrowLength.setEditor(new JSpinner.NumberEditor(arrowLength, "0.0000"));//$NON-NLS-1$
- arrowLength.addChangeListener(this);
- constraint.gridx++;
- arrowP.add(arrowLength, constraint);
-
- constraint.gridx=0;
- constraint.gridy++;
- arrowP.add(new JLabel(LABEL_ARROW_INSET), constraint);
-
- model = new SpinnerNumberModel(ArrowHead.DEFAULT_ARROW_INSET, 0, 100,0.01);
- arrowInset = new JSpinner(model);
- arrowInset.setName(LABEL_ARROWINSET);
- arrowInset.setEditor(new JSpinner.NumberEditor(arrowInset, "0.0000"));//$NON-NLS-1$
- arrowInset.addChangeListener(this);
- constraint.gridx++;
- arrowP.add(arrowInset, constraint);
-
- if(withFillButton)
- {
- interiorButton = new ColorButton(LaTeXDrawResources.LABEL_COLOR_INTERIOR_BUTTON, new ButtonIcon(Figure.DEFAULT_INTERIOR_COL));
- interiorButton.setActionCommand(LaTeXDrawResources.LABEL_COLOR_INTERIOR_BUTTON);
- interiorButton.addActionListener(this);
- constraint.gridx++;
- arrowP.add(interiorButton, constraint);
- }
-
- arrowP.setBorder(new CompoundBorder(new TitledBorder(null, LABEL_ARROWS,
- TitledBorder.LEFT, TitledBorder.TOP), new EmptyBorder(0,0,0,0)));
- return arrowP;
- }
-
-
-
- /**
- * Allows to set enable or disable the parameters of the left arrow
- */
- public void updateEnableParamsArrow()
- {
- JLabel label1 = (JLabel) arrow2Choice.getSelectedItem();
- JLabel label2 = (JLabel) arrow1Choice.getSelectedItem();
- String text1 = label1.getText();
- String text2 = label2.getText();
-
- boolean ok = text1.equals(PSTricksConstants.BAREND_STYLE) ||
- text1.equals(PSTricksConstants.BARIN_STYLE) ||
- text1.equals(PSTricksConstants.LSBRACKET_STYLE) ||
- text1.equals(PSTricksConstants.RSBRACKET_STYLE) ||
- text1.equals(PSTricksConstants.RRBRACKET_STYLE) ||
- text1.equals(PSTricksConstants.LRBRACKET_STYLE) ||
- text2.equals(PSTricksConstants.BAREND_STYLE) ||
- text2.equals(PSTricksConstants.BARIN_STYLE) ||
- text2.equals(PSTricksConstants.LSBRACKET_STYLE) ||
- text2.equals(PSTricksConstants.RSBRACKET_STYLE) ||
- text2.equals(PSTricksConstants.RRBRACKET_STYLE) ||
- text2.equals(PSTricksConstants.LRBRACKET_STYLE) ;
-
- tbarsizeDim.setEnabled(ok);
- tbarsizeNum.setEnabled(ok);
- bracketNum.setEnabled(text1.equals(PSTricksConstants.RSBRACKET_STYLE) ||
- text1.equals(PSTricksConstants.LSBRACKET_STYLE) ||
- text2.equals(PSTricksConstants.RSBRACKET_STYLE) ||
- text2.equals(PSTricksConstants.LSBRACKET_STYLE));
-
- rbracketNum.setEnabled(text1.equals(PSTricksConstants.RRBRACKET_STYLE) ||
- text1.equals(PSTricksConstants.LRBRACKET_STYLE) ||
- text2.equals(PSTricksConstants.RRBRACKET_STYLE) ||
- text2.equals(PSTricksConstants.LRBRACKET_STYLE));
-
- ok = text1.equals(PSTricksConstants.CIRCLEEND_STYLE) ||
- text1.equals(PSTricksConstants.CIRCLEIN_STYLE) ||
- text1.equals(PSTricksConstants.DISKEND_STYLE) ||
- text1.equals(PSTricksConstants.DISKIN_STYLE) ||
- text2.equals(PSTricksConstants.CIRCLEEND_STYLE) ||
- text2.equals(PSTricksConstants.CIRCLEIN_STYLE) ||
- text2.equals(PSTricksConstants.DISKEND_STYLE) ||
- text2.equals(PSTricksConstants.DISKIN_STYLE);
-
- dotSizeDim.setEnabled(ok);
- dotSizeNum.setEnabled(ok);
-
- ok = (text1.equals(PSTricksConstants.DLARROW_STYLE) ||
- text1.equals(PSTricksConstants.LARROW_STYLE) ||
- text1.equals(PSTricksConstants.DRARROW_STYLE) ||
- text1.equals(PSTricksConstants.RARROW_STYLE) ||
- text2.equals(PSTricksConstants.DLARROW_STYLE) ||
- text2.equals(PSTricksConstants.LARROW_STYLE) ||
- text2.equals(PSTricksConstants.DRARROW_STYLE) ||
- text2.equals(PSTricksConstants.RARROW_STYLE));
-
- arrowInset.setEnabled(ok);
- arrowLength.setEnabled(ok);
- arrowSizeDim.setEnabled(ok);
- arrowSizeNum.setEnabled(ok);
- }
-
-
-
-
- /**
- * Defines if the checkbox "filledCB" must be enable or not.
- * @since 1.9
- */
- protected void updateFilledCB()
- {
- Figure f = glimpsePanel.getGlimpseFigure();
-
- if(!f.canBeFilled() || filledCheckBox==null)
- return ;
-
- String txt = f.getHatchingStyle();
-
- if(txt.equals(PSTricksConstants.TOKEN_FILL_GRADIENT))
- {
- filledCheckBox.setEnabled(false);
- return ;
- }
-
- if(f instanceof JoinedLines || f instanceof BezierCurve || f instanceof AkinPoints)
- {
- filledCheckBox.setEnabled(!(shadowCheckBox.isSelected() && f.canHaveShadow() &&
- (txt.equals(PSTricksConstants.TOKEN_FILL_CROSSHATCH) ||
- txt.equals(PSTricksConstants.TOKEN_FILL_CROSSHATCH_F) ||
- txt.equals(PSTricksConstants.TOKEN_FILL_HLINES) ||
- txt.equals(PSTricksConstants.TOKEN_FILL_HLINES_F) ||
- txt.equals(PSTricksConstants.TOKEN_FILL_VLINES) ||
- txt.equals(PSTricksConstants.TOKEN_FILL_VLINES_F))));
- }
- else
- filledCheckBox.setEnabled(!f.canHaveShadow() || !shadowCheckBox.isSelected());
- }
-
-
-
- /**
- * @return the isModified.
- * @since 2.0.0
- */
- public synchronized boolean isModified()
- {
- return isModified;
- }
-
-
- /**
- * @param isModified the isModified to set.
- * @since 2.0.0
- */
- public synchronized void setModified(boolean isModified)
- {
- this.isModified = isModified;
- }
-}
+package latexDraw.ui.dialog;
+
+import java.awt.*;
+import java.awt.event.*;
+
+import javax.swing.*;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.TitledBorder;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+import latexDraw.figures.*;
+import latexDraw.figures.properties.Arrowable;
+import latexDraw.lang.LaTeXDrawLang;
+import latexDraw.psTricks.PSTricksConstants;
+import latexDraw.ui.DrawPanel;
+import latexDraw.ui.components.ButtonIcon;
+import latexDraw.ui.components.ColorButton;
+import latexDraw.ui.components.LaTeXDrawComboBox;
+import latexDraw.util.LaTeXDrawPoint2D;
+import latexDraw.util.LaTeXDrawResources;
+import latexDraw.util.UndoRedoManager;
+
+
+/**
+ * This class defines the pattern for the frames which allow to change the parameters of the figures.<br>
+ *<br>
+ * This file is part of LaTeXDraw<br>
+ * Copyright (c) 2005-2008 Arnaud BLOUIN<br>
+ *<br>
+ * 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.<br>
+ *<br>
+ * 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.<br>
+ *<br>
+ * 01/20/06<br>
+ * @author Arnaud BLOUIN<br>
+ * @version 2.0.0<br>
+ */
+public abstract class AbstractParametersFrame extends JDialog implements ActionListener, ItemListener, KeyListener, ChangeListener
+{
+ private static final long serialVersionUID = 1L;
+
+ protected boolean deleteOnCancel;
+
+ /** The panel containing the drawing */
+ protected DrawPanel drawPanel;
+
+ /** The figure to modify */
+ protected Figure figure;
+
+ /** The title of the frame */
+ protected String title;
+
+ /** The width of many panels. */
+ public static final int WIDTH_PANELS = 430;
+
+ /** The label of the panel : Position/dimensions. */
+ public static final String LABEL_POSITION_DIMENSIONS = LaTeXDrawLang.getString1_7("AbstractParametersFrame.0"); //$NON-NLS-1$
+
+ /** The name of the button ok */
+ public static final String NAME_BUTTON_OK = "BUTTON_OK";//$NON-NLS-1$
+
+ /** The name of the button cancel */
+ public static final String NAME_BUTTON_CANCEL = "BUTTON_CANCEL";//$NON-NLS-1$
+
+ /** The name of the button default */
+ public static final String NAME_BUTTON_DEFAULT = "BUTTON_DEFAULT";//$NON-NLS-1$
+
+ /** Allows to know if the frame has been launched by the main frame:
+ * if true, the undo/redo manager will be used. */
+ protected boolean attachToMainFrame;
+
+ protected JSpinner dotSizeNum;
+
+ protected JSpinner dotSizeDim;
+
+ protected JSpinner bracketNum;
+
+ protected JSpinner rbracketNum;
+
+ protected JSpinner tbarsizeNum;
+
+ protected JSpinner tbarsizeDim;
+
+ protected JSpinner arrowSizeDim;
+
+ protected JSpinner arrowSizeNum;
+
+ protected JSpinner arrowLength;
+
+ protected JSpinner arrowInset;
+
+ public static final String LABEL_DOTSIZENUM = "DotSizeNum";//$NON-NLS-1$
+
+ public static final String LABEL_DOTSIZEDIM = "DotSizeDim";//$NON-NLS-1$
+
+ public static final String LABEL_BRACKETNUM = "BracketNum";//$NON-NLS-1$
+
+ public static final String LABEL_RBRACKETNUM = "rBracketNum";//$NON-NLS-1$
+
+ public static final String LABEL_TBARSIZENUM = "tBarSizeNum"; //$NON-NLS-1$
+
+ public static final String LABEL_TBARSIZEDIM = "tBarSizeDim"; //$NON-NLS-1$
+
+ public static final String LABEL_ARROWLENGTH = "arrowLength";//$NON-NLS-1$
+
+ public static final String LABEL_ARROWINSET = "arrowInset"; //$NON-NLS-1$
+
+ public static final String LABEL_ARROWSIZENUM = "arrowSizeNum";//$NON-NLS-1$
+
+ public static final String LABEL_ARROWSIZEDIM = "arrowSizeDim"; //$NON-NLS-1$
+
+ /** Allows to change the mid point of the gradient. */
+ protected JSpinner gradientMidPtField;
+
+ /** Allows to change the angle of the gradient. */
+ protected JSpinner gradientAngleField;
+
+ /** Allows to change the colour of the shadow. */
+ protected ColorButton gradientStartColButton;
+
+ /** Allows to change the colour of the shadow. */
+ protected ColorButton gradientEndColButton;
+
+ /** Allows to change the size of the shadow. */
+ protected JSpinner shadowSizeField;
+
+ /** Allows to change the colour of the shadow. */
+ protected ColorButton shadowColorButton;
+
+ /** Allows to change the angle of the shadow. */
+ protected JSpinner shadowAngleField;
+
+ /** Allows to set if the figure has a shadow or not. */
+ protected JCheckBox shadowCheckBox;
+
+ /** Allows to change the thickness of the figure */
+ protected JSpinner thicknessField;
+
+ /** Allows to change the colour of the borders of the figure */
+ protected ColorButton bordersButton;
+
+ /** Allows to change the colour of the hatch */
+ protected ColorButton hatchButton;
+
+ /** Allows to set if the figure is filled */
+ protected JCheckBox filledCheckBox;
+
+ /** Allows to change the colour of the interior of the figure */
+ protected ColorButton interiorButton;
+
+ /** Allows to change the colour of the double boundary of the figure */
+ protected ColorButton doublecolorButton;
+
+ /** Allows to change the kind of the line */
+ protected LaTeXDrawComboBox lineChoice;
+
+ /** Allows to change the kind of hatch */
+ protected LaTeXDrawComboBox hatchChoice;
+
+ /** Allows to change the position of the borders */
+ protected LaTeXDrawComboBox bordersPositionChoice;
+
+ /** Allows to change the angle of rotation of the figure */
+ protected JSpinner hatchSepField;
+
+ protected JSpinner hatchAngleField;
+
+ /** Allows to change the angle of rotation of the figure */
+ protected JSpinner rotationField;
+
+ /** Allows to change the width of the hatch */
+ protected JSpinner hatchWidthField;
+
+ /** Allows to set the separation between the double line */
+ protected JSpinner doubleSep;
+
+ /** Allows to set if the figure must have double boundary or not */
+ protected JCheckBox doubleLine;
+
+ /** The button ok */
+ protected JButton buttonOk;
+
+ /** The panel where the figure is displayed */
+ protected GlimpsePanel glimpsePanel;
+
+ /** This scrollpane contains the glimpsepanel */
+ protected JPanel glimpsePanelZoom;
+
+ /** The scroll pane of the frame to see the figure. */
+ protected JScrollPane glimpseScrollPane;
+
+ /** The first arrow choice */
+ protected LaTeXDrawComboBox arrow1Choice;
+
+ /** The second arrow choice */
+ protected LaTeXDrawComboBox arrow2Choice;
+
+ /** Defines if the shape has been modified with the frame. @since 2.0.0 */
+ protected boolean isModified;
+
+ /** The label of the check box which set if the figure has a shadow or not. */
+ public static final String LABEL_SHADOW_CB = LaTeXDrawResources.LABEL_SHADOW_CHECKBOX;
+
+ /** The label of the button which set the angle of the shadow. */
+ public static final String LABEL_SHADOW_ANGLE = LaTeXDrawLang.getString1_7("AbstractParametersFrame.1"); //$NON-NLS-1$
+
+ /** The label of the button which set the size of the shadow. */
+ public static final String LABEL_SHADOW_SIZE = LaTeXDrawLang.getString1_7("AbstractParametersFrame.2"); //$NON-NLS-1$
+
+ /** The label of the button which set the angle of the gradient. */
+ public static final String LABEL_GRADIENT_ANGLE = LaTeXDrawLang.getString1_7("AbstractParametersFrame.3"); //$NON-NLS-1$
+
+ public static final String LABEL_HATCHINGS_ANGLE = "hatchAngle";
+
+ /** The label of the button which set the middle point of the gradient. */
+ public static final String LABEL_GRADIENT_MID_PT = LaTeXDrawLang.getString1_7("AbstractParametersFrame.4"); //$NON-NLS-1$
+
+ public static final String TITLE_TABBED_PANE_GENERAL = LaTeXDrawLang.getString1_8("LaTeXDrawFrame.24"); //$NON-NLS-1$
+
+ public static final String TITLE_TABBED_PANE_OTHERS = LaTeXDrawLang.getString1_7("AbstractParametersFrame.6"); //$NON-NLS-1$
+
+ public static final String LABEL_BUTTON_BOUNDARY = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.0"); //$NON-NLS-1$
+
+ public static final String LABEL_DOUBLELINE = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.1"); //$NON-NLS-1$
+
+ public static final String LABEL_DOUBLESEP = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.2"); //$NON-NLS-1$
+
+ public static final String LABEL_HATCH_SEP = LaTeXDrawLang.getString1_8("AbstractParametersFrame.0"); //$NON-NLS-1$
+
+ public static final String TITLE_GENERAL = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.3"); //$NON-NLS-1$
+
+ public static final String LABEL_ARROWS = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.38"); //$NON-NLS-1$
+
+ public static final String LABEL_OK = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.4"); //$NON-NLS-1$
+
+ public static final String LABEL_DEFAULT = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.5"); //$NON-NLS-1$
+
+ public static final String LABEL_CANCEL = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.6"); //$NON-NLS-1$
+
+ public static final String LABEL_ROTATION = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.7"); //$NON-NLS-1$
+
+ public static final String LABEL_THICKNESS = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.8"); //$NON-NLS-1$
+
+ public static final String LABEL_GENERAL = LaTeXDrawLang.getDialogFrameString("PreferencesFrame.general"); //$NON-NLS-1$
+
+ public static final String LABEL_TYPE_LINE = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.10"); //$NON-NLS-1$
+
+ public static final String LABEL_HATCH_WIDTH = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.11"); //$NON-NLS-1$
+
+ public static final String LABEL_LEFT_ARROW = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.12"); //$NON-NLS-1$
+
+ public static final String LABEL_RIGHT_ARROW = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.13"); //$NON-NLS-1$
+
+ public static final String NAME_TABBEDPANE_ARROW = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.14"); //$NON-NLS-1$
+
+ /** The label of the showPointsCB JCheckBox */
+ public static final String LABEL_SHOWPOINTCB = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.15"); //$NON-NLS-1$
+
+ /** The label of the isRound checkbox */
+ public static final String LABEL_ISROUND = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.16"); //$NON-NLS-1$
+
+ /** The label of the field frameArcField */
+ public static final String LABEL_ROUND_CORNER = LaTeXDrawLang.getString1_7("AbstractParametersFrame.7"); //$NON-NLS-1$
+
+ /** The label of the X-centre field */
+ public static final String LABEL_CENTER_X = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.17"); //$NON-NLS-1$
+
+ /** The label of the Y-centre field */
+ public static final String LABEL_CENTER_Y = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.18"); //$NON-NLS-1$
+
+ /** The label of the radius field */
+ public static final String LABEL_RADIUS = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.19"); //$NON-NLS-1$
+
+ public static final String LABEL_DOTSIZE = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.20"); //$NON-NLS-1$
+
+ public static final String LABEL_TBARSIZE = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.21"); //$NON-NLS-1$
+
+ public static final String LABEL_BRACKET_LGTH = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.22"); //$NON-NLS-1$
+
+ public static final String LABEL_RBRACKET_LGTH = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.23"); //$NON-NLS-1$
+
+ public static final String LABEL_CROSS_THICKNESS = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.24"); //$NON-NLS-1$
+
+ public static final String LABEL_CROSS_WIDTH = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.25"); //$NON-NLS-1$
+
+ public static final String LABEL_ARROW_LENGTH = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.26"); //$NON-NLS-1$
+
+ public static final String LABEL_ARROW_INSET = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.27"); //$NON-NLS-1$
+
+ public static final String LABEL_ARROW_WIDTH = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.28"); //$NON-NLS-1$
+
+ public static final String LABEL_X = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.29"); //$NON-NLS-1$
+
+ public static final String LABEL_Y = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.30"); //$NON-NLS-1$
+
+ /** The label of the width field */
+ public static final String LABEL_WIDTH = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.31"); //$NON-NLS-1$
+
+ /** The label of the height field */
+ public static final String LABEL_HEIGHT = LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.32"); //$NON-NLS-1$
+
+
+
+ /**
+ * 01/20/06<br>
+ * @version 1.9<br>
+ */
+ protected static class GlimpsePanel extends JPanel implements Scrollable, MouseListener, MouseMotionListener
+ {
+ private static final long serialVersionUID = 1L;
+
+ /** The figure to display in the panel */
+ protected Figure glimpseFigure;
+
+ /** The zoom by default (100%) */
+ public static final double DEFAULT_ZOOM = 1.;
+
+ /** The biggest zoom we can do */
+ public static final double MAX_ZOOM = 4.5;
+
+ /** The smallest zoom we can do */
+ public static final double MIN_ZOOM = 0.25;
+
+ /** The value we add to the zoom when to user click on a zoom button */
+ public static final double DEFAULT_ADD_ZOOM = 0.25;
+
+ /** The zoom : MIN_ZOOM<=zoom<=MAX_ZOOM */
+ protected double zoom;
+
+ private transient Cursor formerCursor;
+
+ private transient Point formerPoint;
+
+ private transient double tx;
+
+ private transient double ty;
+
+
+ /**
+ * The constructor by default
+ * @param f The figure to display (can be null)
+ */
+ public GlimpsePanel(Figure f)
+ {
+ if(f!=null)
+ f.setSelected(false);
+ glimpseFigure = f;
+ zoom = DEFAULT_ZOOM;
+ formerCursor = null;
+ formerPoint = null;
+ tx = ty = 0.;
+ addMouseListener(this);
+ addMouseMotionListener(this);
+ }
+
+
+ /**
+ * Allows to zoom out the drawing (up to 25%).
+ */
+ public void zoomOut()
+ {
+ if(zoom-DEFAULT_ADD_ZOOM>=MIN_ZOOM && glimpseFigure!=null)
+ {
+ zoom-=DEFAULT_ADD_ZOOM;
+ updateTxTy();
+ repaint();
+ updatePreferredSize();
+ revalidate();
+ }
+ }
+
+
+ /**
+ * Allows to set the zoom to default. In fact the zoom is not set at ZOOM_DEFAULT, it's set to see the whole figure.
+ */
+ public void zoomDefault()
+ {
+ if(glimpseFigure!=null)
+ {
+ LaTeXDrawPoint2D nw = glimpseFigure.getTheNWBoundPoint();
+ LaTeXDrawPoint2D se = glimpseFigure.getTheSEBoundPoint();
+ double figWidth = se.x-nw.x;
+ double figHeight = se.y-nw.y;
+ int height = getParent().getParent().getHeight();
+ int width = getParent().getParent().getWidth();
+ zoom = DEFAULT_ZOOM;
+
+ while(((figHeight*zoom)>height || (figWidth*zoom)>width) && zoom>MIN_ZOOM)
+ {
+ zoom-=DEFAULT_ADD_ZOOM;
+ }
+
+ if(zoom<MIN_ZOOM)
+ zoom = MIN_ZOOM;
+
+ updateTxTy();
+ repaint();
+ updatePreferredSize();
+ revalidate();
+ }
+ }
+
+
+ /**
+ * Allows to zoom in the drawing (up to 450%)
+ */
+ public void zoomIn()
+ {
+ if(zoom+DEFAULT_ADD_ZOOM<=MAX_ZOOM && glimpseFigure!=null)
+ {
+ zoom+=DEFAULT_ADD_ZOOM;
+ updateTxTy();
+ updatePreferredSize();
+ repaint();
+ revalidate();
+ }
+ }
+
+
+
+ /**
+ * Updates the fields tx and ty.
+ * @since 1.9.2
+ */
+ public void updateTxTy()
+ {
+ LaTeXDrawPoint2D nw = glimpseFigure.getTheNWBoundPoint();
+
+ tx = getParent().getParent().getWidth()/2.-glimpseFigure.getGravityCenter().x*zoom;
+ ty = getParent().getParent().getHeight()/2.-glimpseFigure.getGravityCenter().y*zoom;
+
+ if(nw.x*zoom+tx<0)
+ tx = Math.min(-nw.x*zoom+30, -30);
+
+ if(nw.y*zoom+ty<0)
+ ty = Math.min(-nw.y*zoom+30, -30);
+ }
+
+
+
+ /**
+ * Allows to set the figure to display
+ * @param f The new figure to display
+ */
+ public void setGlimpseFigure(Figure f)
+ {
+ glimpseFigure = f;
+
+ if(f!=null)
+ {
+ f.setSelected(false);
+ zoomDefault();
+ }
+ else
+ tx = ty = 0.;
+ }
+
+
+
+ /**
+ * Allows to get the figure to display.
+ * @return The glimpse figure.
+ */
+ public Figure getGlimpseFigure()
+ {
+ return glimpseFigure;
+ }
+
+
+
+ @Override
+ public void paintComponent(Graphics g)
+ {
+ if(g==null || glimpseFigure==null) return;
+
+ Graphics2D g2 = (Graphics2D) g;
+ g2.setColor(Color.WHITE);
+ g2.fillRect(0, 0, getWidth(), getHeight());
+ g2.translate(tx, ty);
+ g2.scale(zoom, zoom);
+
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+ g2.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
+ g2.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+ g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+
+ glimpseFigure.draw(g2, RenderingHints.VALUE_ANTIALIAS_ON, RenderingHints.VALUE_RENDER_QUALITY,
+ RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+ }
+
+
+
+
+ /**
+ * Allows to update the dimensions of the drawing (needed for the scrollers)
+ */
+ public void updatePreferredSize()
+ {
+ if(glimpseFigure==null)
+ setPreferredSize(new Dimension(0,0));
+ else
+ {
+ LaTeXDrawPoint2D SE = glimpseFigure.getTheSEBoundPoint();
+ setPreferredSize(new Dimension((int)(SE.x*zoom+tx), (int)(SE.y*zoom+ty)));
+ }
+ }
+
+
+
+ @Override
+ public void repaint()
+ {
+ updatePreferredSize();
+ revalidate();
+ super.repaint();
+ }
+
+
+
+ /**
+ * Useful for scrollbar
+ */
+ public Dimension getPreferredScrollableViewportSize()
+ { return new Dimension(-100, 100); }
+
+
+
+ /**
+ * Useful for scrollbar
+ */
+ public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
+ {
+ return (orientation == SwingConstants.VERTICAL) ? visibleRect.height :
+ visibleRect.width;
+ }
+
+
+
+ /**
+ * Useful for scrollbar
+ */
+ public boolean getScrollableTracksViewportHeight()
+ {
+ if(this.getParent() instanceof JViewport)
+ return (((JViewport)getParent()).getHeight() > getPreferredSize().height);
+ return false;
+ }
+
+
+
+
+ /**
+ * Useful for scrollbar
+ */
+ public boolean getScrollableTracksViewportWidth()
+ {
+ if(getParent() instanceof JViewport)
+ return (((JViewport)getParent()).getWidth() > getPreferredSize().width);
+ return false;
+ }
+
+
+
+ /**
+ * Useful for scrollbar
+ */
+ public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
+ {
+ return 4;
+ }
+
+
+ public void mouseClicked(MouseEvent e)
+ {
+ // Nothing to do.
+ }
+
+
+ public void mouseEntered(MouseEvent e)
+ {
+ formerCursor = getCursor();
+ setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
+ }
+
+
+ public void mouseExited(MouseEvent e)
+ {
+ if(formerCursor!=null)
+ {
+ setCursor(formerCursor);
+ formerCursor = null;
+ }
+ }
+
+
+ public void mousePressed(MouseEvent e)
+ {
+ // Nothing to do.
+ }
+
+
+ public void mouseReleased(MouseEvent e)
+ {
+ formerPoint = null;
+ }
+
+
+ public void mouseDragged(MouseEvent e)
+ {
+ if(formerPoint!=null)
+ {
+ tx += e.getPoint().x-formerPoint.x;
+ ty += e.getPoint().y-formerPoint.y;
+ repaint();
+ }
+
+ formerPoint = e.getPoint();
+ }
+
+
+ public void mouseMoved(MouseEvent e)
+ {
+ // Nothing to do.
+ }
+ }
+
+
+
+ /**
+ * The abstract constructor
+ * @param d The drawpanel
+ */
+ protected AbstractParametersFrame(Frame parent, DrawPanel d, boolean attachToMainFrame)
+ {
+ super(parent, true);
+ try
+ {
+ setModified(false);
+ this.attachToMainFrame = attachToMainFrame;
+ drawPanel = d;
+ glimpsePanel = new GlimpsePanel(null);
+ glimpseScrollPane = new JScrollPane(glimpsePanel);
+ glimpsePanel.updatePreferredSize();
+ glimpsePanel.revalidate();
+ glimpsePanelZoom = new JPanel(new BorderLayout());
+ glimpsePanelZoom.add(glimpseScrollPane, BorderLayout.CENTER);
+ glimpsePanelZoom.add(createZoomPanel(), BorderLayout.EAST);
+ glimpsePanelZoom.setBorder(new CompoundBorder(new TitledBorder(null, "", //$NON-NLS-1$
+ TitledBorder.LEFT, TitledBorder.TOP), new EmptyBorder(0,0,0,0)));
+ glimpsePanelZoom.setPreferredSize(new Dimension(420, 190));
+ glimpsePanelZoom.setMaximumSize(new Dimension(700, 240));
+ createRotationField();
+
+ setResizable(true);
+
+ addWindowListener(
+ new WindowAdapter()
+ {
+ @Override
+ public void windowClosing(WindowEvent e)
+ {
+ if(deleteOnCancel)
+ {
+ drawPanel.getDraw().deleteFigure(figure, null);
+ deleteOnCancel = false;
+ }
+ }
+ });
+
+ }catch(Exception e)
+ {
+ e.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(e);
+ }
+ }
+
+
+
+
+ /**
+ * Allows to create a panel containing buttons to zoom the 'glimpse figure'.
+ * @return The created panel.
+ */
+ public JPanel createZoomPanel()
+ {
+ JPanel panel = new JPanel();
+ JPanel panel2 = new JPanel();
+ panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
+ panel2.setLayout(new BoxLayout(panel2, BoxLayout.Y_AXIS));
+
+ JButton zoomIn = new JButton(LaTeXDrawResources.zoomInIcon);
+ zoomIn.setActionCommand(LaTeXDrawResources.LABEL_ZOOM_IN);
+ zoomIn.addActionListener(this);
+
+ JButton zoomOut = new JButton(LaTeXDrawResources.zoomOutIcon);
+ zoomOut.setActionCommand(LaTeXDrawResources.LABEL_ZOOM_OUT);
+ zoomOut.addActionListener(this);
+
+ JButton zoomDefault = new JButton(LaTeXDrawResources.zoomDefaultIcon);
+ zoomDefault.setActionCommand(LaTeXDrawResources.LABEL_ZOOM_DEFAULT);
+ zoomDefault.addActionListener(this);
+
+ panel2.add(zoomDefault);
+ panel2.add(zoomIn);
+ panel2.add(zoomOut);
+ panel.add(panel2);
+
+ return panel;
+ }
+
+
+
+
+ /**
+ * Allows to set the title of the frame
+ */
+ public void setTitle()
+ {
+ setTitle(LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.33")+ " #" +figure.getNumber()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+
+
+
+ /**
+ * Allows to save the values of the fields in the attributes of the figure.
+ */
+ public void saveParameters()
+ {
+ try
+ {
+ if(attachToMainFrame && !deleteOnCancel)
+ {
+ drawPanel.getFrameParent().getUndoManager().add(UndoRedoManager.LABEL_CHANGE_PARAM,
+ drawPanel.getDraw().getFigures().indexOf(figure), figure.clone());
+ drawPanel.getFrameParent().updateUndoRedo();
+ }
+
+ if(figure.canHaveArrow())
+ {
+ ArrowHead leftA = ((Arrowable)figure).getArrowHead1();
+ ArrowHead rightA = ((Arrowable)figure).getArrowHead2();
+
+ JLabel lab = (JLabel)arrow1Choice.getSelectedItem();
+ ((Arrowable)figure).setArrow1Style(lab.getText());
+ lab = (JLabel)arrow2Choice.getSelectedItem();
+ ((Arrowable)figure).setArrow2Style(lab.getText());
+
+ leftA.setBracketNum(Double.valueOf(bracketNum.getValue().toString()).doubleValue());
+ rightA.setBracketNum(Double.valueOf(bracketNum.getValue().toString()).doubleValue());
+ leftA.setDotSizeDim(Double.valueOf(dotSizeDim.getValue().toString()).doubleValue());
+ rightA.setDotSizeDim(Double.valueOf(dotSizeDim.getValue().toString()).doubleValue());
+ leftA.setDotSizeNum(Double.valueOf(dotSizeNum.getValue().toString()).doubleValue());
+ rightA.setDotSizeNum(Double.valueOf(dotSizeNum.getValue().toString()).doubleValue());
+ leftA.setRBracketNum(Double.valueOf(rbracketNum.getValue().toString()).doubleValue());
+ rightA.setRBracketNum(Double.valueOf(rbracketNum.getValue().toString()).doubleValue());
+ leftA.setTBarSizeDim(Double.valueOf(tbarsizeDim.getValue().toString()).doubleValue());
+ rightA.setTBarSizeDim(Double.valueOf(tbarsizeDim.getValue().toString()).doubleValue());
+ leftA.setTBarSizeNum(Double.valueOf(tbarsizeNum.getValue().toString()).doubleValue());
+ rightA.setTBarSizeNum(Double.valueOf(tbarsizeNum.getValue().toString()).doubleValue());
+ leftA.setArrowSizeNum(Double.valueOf(arrowSizeNum.getValue().toString()).doubleValue());
+ rightA.setArrowSizeNum(Double.valueOf(arrowSizeNum.getValue().toString()).doubleValue());
+ leftA.setArrowSizeDim(Double.valueOf(arrowSizeDim.getValue().toString()).doubleValue());
+ rightA.setArrowSizeDim(Double.valueOf(arrowSizeDim.getValue().toString()).doubleValue());
+ leftA.setArrowLength(Double.valueOf(arrowLength.getValue().toString()).doubleValue());
+ rightA.setArrowLength(Double.valueOf(arrowLength.getValue().toString()).doubleValue());
+ leftA.setArrowInset(Double.valueOf(arrowInset.getValue().toString()).doubleValue());
+ rightA.setArrowInset(Double.valueOf(arrowInset.getValue().toString()).doubleValue());
+ }
+
+ if(doublecolorButton!=null)
+ figure.setDoubleColor(doublecolorButton.getColor());
+
+ if(bordersPositionChoice!=null)
+ {
+ JLabel l = (JLabel) bordersPositionChoice.getSelectedItem();
+ figure.setBordersPosition(l.getText());
+ }
+
+ if(doubleLine!=null)
+ {
+ figure.setHasDoubleBoundary(doubleLine.isSelected());
+ figure.setDoubleSep(Double.valueOf(doubleSep.getValue().toString()));
+ }
+
+ if(lineChoice!=null)
+ {
+ JLabel l = (JLabel) lineChoice.getSelectedItem();
+ figure.setLineStyle(l.getText());
+ }
+
+ if(thicknessField!=null)
+ figure.setThickness(Float.valueOf(thicknessField.getValue().toString()));
+
+ if(bordersButton!=null)
+ figure.setLinesColor(bordersButton.getColor());
+
+ if(interiorButton!=null)
+ figure.setInteriorColor(interiorButton.getColor());
+
+ if(figure.canHaveShadow())
+ {
+ figure.setHasShadow(shadowCheckBox.isSelected());
+ figure.setShadowSize(Double.valueOf(shadowSizeField.getValue().toString()).doubleValue());
+ figure.setShadowAngle(Math.toRadians(Double.valueOf(shadowAngleField.getValue().toString()).doubleValue()));
+ figure.setShadowColor(shadowColorButton.getColor());
+ }
+
+ if(filledCheckBox!=null)
+ figure.setIsFilled(filledCheckBox.isSelected());
+
+ if(figure.canBeHatched())
+ {
+ figure.setHatchingAngle(Math.toRadians(Double.valueOf(hatchAngleField.getValue().toString()).doubleValue()));
+ figure.setHatchingSep(Float.valueOf(hatchSepField.getValue().toString()));
+ figure.setHatchingWidth(Float.valueOf(hatchWidthField.getValue().toString()));
+ figure.setHatchingColor(hatchButton.getColor());
+ JLabel l = (JLabel) hatchChoice.getSelectedItem();
+ figure.setHatchingStyle(l.getText());
+ figure.setGradientAngle(Math.toRadians(Double.valueOf(gradientAngleField.getValue().toString()).doubleValue()));
+ figure.setGradientEndColor(((ButtonIcon)gradientEndColButton.getIcon()).getColor());
+ figure.setGradientStartColor(((ButtonIcon)gradientStartColButton.getIcon()).getColor());
+ figure.setGradientMidPoint(Double.valueOf(gradientMidPtField.getValue().toString()).doubleValue());
+ }
+
+ if(rotationField!=null)
+ figure.setRotationAngle(Math.toRadians(
+ Double.valueOf(rotationField.getValue().toString()).doubleValue()));
+
+ drawPanel.getDraw().updateBorders();
+ drawPanel.updateDraw(true);
+
+ }catch(Exception e)
+ {
+ e.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(e);
+ }
+ }
+
+
+
+
+ public void keyTyped(KeyEvent e)
+ {
+ /* No action to do */
+ }
+
+
+ public void keyReleased(KeyEvent e)
+ {
+ /* No action to do */
+ }
+
+
+ public void keyPressed(KeyEvent e)
+ {
+ /* No action to do */
+ }
+
+
+
+
+ public void actionPerformed(ActionEvent e)
+ {
+ Object o = e.getSource();
+
+ try
+ {
+ if(o instanceof JButton || o instanceof JCheckBox)
+ {
+ String label = ((AbstractButton)o).getActionCommand();
+ Figure f = glimpsePanel.getGlimpseFigure();
+
+ if(label.equals(LaTeXDrawResources.LABEL_ZOOM_IN))
+ {
+ glimpsePanel.zoomIn();
+ return;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_ZOOM_OUT))
+ {
+ glimpsePanel.zoomOut();
+ return;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_ZOOM_DEFAULT))
+ {
+ glimpsePanel.zoomDefault();
+ return;
+ }
+
+ if(label.equals(LABEL_DOUBLELINE))
+ {
+ setModified(true);
+ f.setHasDoubleBoundary(doubleLine.isSelected());
+ doubleSep.setEnabled(doubleLine.isSelected());
+ doublecolorButton.setEnabled(doubleLine.isSelected());
+ glimpsePanel.repaint();
+ return ;
+ }
+
+ if(label.equals(NAME_BUTTON_CANCEL))
+ {
+ if(deleteOnCancel)
+ {
+ drawPanel.getDraw().deleteFigure(figure, null);
+ deleteOnCancel = false;
+ }
+ super.setVisible(false);
+ return;
+ }
+
+ if(label.equals(NAME_BUTTON_DEFAULT))
+ {
+ setDefaultsValues();
+ glimpsePanel.repaint();
+ return;
+ }
+
+ if(label.equals(NAME_BUTTON_OK))
+ {
+ saveParameters();
+
+ drawPanel.getFrameParent().updateFrameFields();
+
+ if(isModified())
+ drawPanel.setIsModified(true);
+
+ setVisible(false);
+ return;
+ }
+
+
+ if(label.equals(LaTeXDrawResources.LABEL_FILLED_CHECKBOX))
+ {
+ if(interiorButton!=null)
+ {
+ setModified(true);
+ f.setIsFilled(filledCheckBox.isSelected());
+ glimpsePanel.repaint();
+ }
+ return;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_SHADOW_CHECKBOX))
+ {
+ if(shadowColorButton!=null)
+ {
+ setModified(true);
+ shadowColorButton.setEnabled(shadowCheckBox.isSelected());
+ shadowAngleField.setEnabled(shadowCheckBox.isSelected());
+ shadowSizeField.setEnabled(shadowCheckBox.isSelected());
+ f.setHasShadow(shadowCheckBox.isSelected());
+ updateFilledCB();
+ glimpsePanel.repaint();
+ }
+ return;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_COLOR_GRADIENT_FIRST))
+ {
+ Color c = JColorChooser.showDialog((Component) e.getSource(),
+ LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.34"), //$NON-NLS-1$
+ ((ColorButton)o).getColor());
+
+ if(c!=null)
+ {
+ setModified(true);
+ ((ColorButton)o).setColor(c);
+ f.setGradientStartColor(c);
+ glimpsePanel.repaint();
+ }
+ return ;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_COLOR_GRADIENT_SECOND))
+ {
+ Color c = JColorChooser.showDialog((Component) e.getSource(),
+ LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.34"), //$NON-NLS-1$
+ ((ColorButton)o).getColor());
+
+ if(c!=null)
+ {
+ setModified(true);
+ ((ColorButton)o).setColor(c);
+ f.setGradientEndColor(c);
+ glimpsePanel.repaint();
+ }
+ return ;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_COLOR_HATCH))
+ {
+ Color c = JColorChooser.showDialog((Component) e.getSource(),
+ LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.34"), //$NON-NLS-1$
+ ((ColorButton)o).getColor());
+
+ if(c!=null)
+ {
+ setModified(true);
+ ((ColorButton)o).setColor(c);
+ f.setHatchingColor(c);
+ glimpsePanel.repaint();
+ }
+ return ;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_COLOR_SHADOW))
+ {
+ Color c = JColorChooser.showDialog((Component) e.getSource(),
+ LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.34"), //$NON-NLS-1$
+ ((ColorButton)o).getColor());
+
+ if(c!=null)
+ {
+ setModified(true);
+ ((ColorButton)o).setColor(c);
+ f.setShadowColor(c);
+ glimpsePanel.repaint();
+ }
+ return ;
+ }
+
+ if(label.equals(LABEL_BUTTON_BOUNDARY))
+ {
+ Color c = JColorChooser.showDialog((Component) e.getSource(),
+ LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.35"), //$NON-NLS-1$
+ ((ColorButton)o).getColor());
+
+ if(c!=null)
+ {
+ setModified(true);
+ ((ColorButton)o).setColor(c);
+ f.setDoubleColor(c);
+ glimpsePanel.repaint();
+ }
+ return ;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_COLOR_BUTTON))
+ {
+ Color c = JColorChooser.showDialog((Component) e.getSource(),
+ LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.36"), //$NON-NLS-1$
+ ((ColorButton)o).getColor());
+
+ if(c!=null)
+ {
+ setModified(true);
+ ((ColorButton)o).setColor(c);
+ f.setLinesColor(c);
+ glimpsePanel.repaint();
+ }
+ return ;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_COLOR_INTERIOR_BUTTON))
+ {
+ Color c = JColorChooser.showDialog((Component) e.getSource(),
+ LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.37"), //$NON-NLS-1$
+ ((ColorButton)o).getColor());
+
+ if(c!=null)
+ {
+ setModified(true);
+ ((ColorButton)o).setColor(c);
+ f.setInteriorColor(c);
+ glimpsePanel.repaint();
+ }
+ return;
+ }
+ } // if(o instanceof JButton)
+ }catch(Exception ex)
+ {
+ ex.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(ex);
+ }
+ }
+
+
+
+
+ /**
+ * Allows to set the value of the specific fields of the frame
+ * from the attributes of the figure
+ */
+ public abstract void setFigureFrameField();
+
+
+
+
+ /**
+ * Initialises some fields of the frame and set visible or not it.
+ * @param visible True: the frame must be visible.
+ * @param selected The selected figure.
+ * @param deleteOnCancel True: the figure must be deleted if the user click on the button cancel.
+ */
+ public void setVisible(boolean visible, Figure selected, boolean deleteOnCancel, boolean isFramedBox)
+ {
+ try
+ {
+ if(visible)
+ {
+ setModified(false);
+ this.deleteOnCancel = deleteOnCancel;
+ figure = selected;
+ setTitle();
+
+ glimpsePanel.setGlimpseFigure((Figure) selected.clone());
+ glimpsePanel.updatePreferredSize();
+ glimpsePanel.revalidate();
+ glimpsePanel.repaint();
+
+ setFigureFrameField();
+
+ if(figure.canHaveArrow())
+ {
+ arrow1Choice.setSelectedItem(((Arrowable)figure).getArrow1Style());
+ arrow2Choice.setSelectedItem(((Arrowable)figure).getArrow2Style());
+
+ ArrowHead rightA = ((Arrowable)figure).getArrowHead2();
+
+ arrowInset.setValue(rightA.getArrowInset());
+ arrowLength.setValue(rightA.getArrowLength());
+ arrowSizeDim.setValue(rightA.getArrowSizeDim());
+ arrowSizeNum.setValue(rightA.getArrowSizeNum());
+ bracketNum.setValue(rightA.getBracketNum());
+ dotSizeDim.setValue(rightA.getDotSizeDim());
+ dotSizeNum.setValue(rightA.getDotSizeNum());
+ rbracketNum.setValue(rightA.getRBracketNum());
+ tbarsizeDim.setValue(rightA.getTBarSizeDim());
+ tbarsizeNum.setValue(rightA.getTBarSizeNum());
+
+ updateEnableParamsArrow();
+ }
+
+ if(doublecolorButton!=null)
+ {
+ doublecolorButton.setEnabled(figure.hasDoubleBoundary());
+ doublecolorButton.setColor(figure.getDoubleColor());
+ }
+
+ if(bordersPositionChoice!=null)
+ {
+ bordersPositionChoice.setEnabled(figure.isBordersMovable() && !isFramedBox);
+ bordersPositionChoice.setSelectedItem(figure.getBordersPosition());
+ }
+
+ if(doubleLine!=null)
+ {
+ doubleLine.setSelected(figure.hasDoubleBoundary());
+ doubleSep.setEnabled(doubleLine.isSelected());
+ doubleSep.setValue(figure.getDoubleSep());
+ }
+
+ if(rotationField!=null)
+ {
+ rotationField.setEnabled(!isFramedBox);
+ rotationField.setValue(Math.toDegrees(selected.getRotationAngle()));
+ }
+
+ if(lineChoice!=null)
+ lineChoice.setSelectedItem(selected.getLineStyle());
+
+ if(thicknessField!=null)
+ thicknessField.setValue((double)selected.getThickness());
+
+ if(bordersButton!=null)
+ bordersButton.setColor(selected.getLinesColor());
+
+ String txt = selected.getHatchingStyle();
+ int num=0;
+ if(txt.equals(PSTricksConstants.TOKEN_FILL_GRADIENT))
+ num=1;
+ else if(txt.equals(PSTricksConstants.TOKEN_FILL_NONE) ||
+ txt.equals(PSTricksConstants.TOKEN_FILL_SOLID))
+ num=2;
+
+ if(selected.canBeHatched())
+ {
+ hatchAngleField.setEnabled(num==0);
+ hatchAngleField.setValue(Math.toDegrees(selected.getHatchingAngle()));
+ hatchChoice.setSelectedItem(selected.getHatchingStyle());
+ hatchButton.setEnabled(num==0);
+ hatchWidthField.setValue((double)selected.getHatchingWidth());
+ hatchSepField.setValue(selected.getHatchingSep());
+ hatchButton.setColor(selected.getHatchingColor());
+ hatchWidthField.setEnabled(num==0);
+ hatchSepField.setEnabled(num==0);
+ gradientAngleField.setEnabled(num==1);
+ gradientAngleField.setValue(Math.toDegrees(selected.getGradientAngle()));
+ gradientEndColButton.setEnabled(num==1);
+ gradientMidPtField.setEnabled(num==1);
+ gradientMidPtField.setValue(selected.getGradientMidPoint());
+ gradientStartColButton.setEnabled(num==1);
+ updateFilledCB();
+ filledCheckBox.setSelected(selected.isFilled() && selected.canBeFilled());
+ gradientEndColButton.setColor(selected.getGradientEndColor());
+ gradientStartColButton.setColor(selected.getGradientStartColor());
+ }
+
+ if(interiorButton!=null)
+ interiorButton.setColor(selected.getInteriorColor());
+
+ if(selected.canHaveShadow())
+ {
+ shadowSizeField.setValue(figure.getShadowSize());
+ shadowAngleField.setValue(Math.toDegrees(figure.getShadowAngle()));
+ shadowColorButton.setEnabled(figure.hasShadow());
+ shadowColorButton.setColor(figure.getShadowColor());
+ shadowCheckBox.setSelected(figure.hasShadow());
+ shadowColorButton.setEnabled(shadowCheckBox.isSelected());
+ shadowAngleField.setEnabled(shadowCheckBox.isSelected());
+ shadowSizeField.setEnabled(shadowCheckBox.isSelected());
+ }
+ }
+ updateFilledCB();
+
+ }catch(Exception e)
+ {
+ e.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(e);
+ }
+ super.setVisible(visible);
+ }
+
+
+
+
+ /**
+ * @return A panel with components to change the parameters of the hatching of the figure.
+ */
+ public JPanel createHatchingPanel()
+ {
+ GridBagConstraints constraint = new GridBagConstraints();
+ constraint.gridx = 0; constraint.gridy = 0;
+ constraint.gridwidth = 1; constraint.gridheight = 1;
+ constraint.weightx = 0.1; constraint.weighty = 0.1;
+ constraint.fill = GridBagConstraints.NONE;
+ constraint.anchor = GridBagConstraints.WEST;
+
+ JPanel hatchingP = new JPanel(new GridBagLayout());
+
+ hatchButton = new ColorButton(LaTeXDrawResources.LABEL_COLOR_HATCH, new ButtonIcon(Figure.DEFAULT_BORDERS_COL));
+ hatchButton.setActionCommand(LaTeXDrawResources.LABEL_COLOR_HATCH);
+ hatchButton.addActionListener(this);
+ hatchingP.add(hatchButton, constraint);
+
+ constraint.gridx++;
+ hatchingP.add(new JLabel(LABEL_HATCH_WIDTH), constraint);
+
+ constraint.gridx++;
+ SpinnerModel model = new SpinnerNumberModel(Figure.DEFAULT_HATCH_WIDTH, 0.1, 100,0.1);
+ hatchWidthField = new JSpinner(model);
+ hatchWidthField.setEditor(new JSpinner.NumberEditor(hatchWidthField, "0.0"));//$NON-NLS-1$
+ hatchWidthField.addChangeListener(this);
+ hatchWidthField.setName(Figure.LABEL_HATCH_WIDTH);
+ hatchingP.add(hatchWidthField, constraint);
+
+ constraint.gridx++;
+ hatchingP.add(new JLabel(LABEL_HATCH_SEP), constraint);
+
+ constraint.gridx++;
+ model = new SpinnerNumberModel(Figure.DEFAULT_HATCH_SEP, 0.01, 1000,1);
+ hatchSepField = new JSpinner(model);
+ hatchSepField.setEditor(new JSpinner.NumberEditor(hatchSepField, "0.00"));//$NON-NLS-1$
+ hatchSepField.addChangeListener(this);
+ hatchSepField.setName(LABEL_HATCH_SEP);
+ hatchingP.add(hatchSepField, constraint);
+
+ constraint.gridy++;
+ constraint.gridx=1;
+ hatchingP.add(new JLabel("angle"), constraint);
+
+ constraint.gridx++;
+ model = new SpinnerNumberModel(0., -1000., 1000., 1.);
+ hatchAngleField = new JSpinner(model);
+ hatchAngleField.setEditor(new JSpinner.NumberEditor(hatchAngleField, "0.00"));//$NON-NLS-1$
+ hatchAngleField.addChangeListener(this);
+ hatchAngleField.setName(LABEL_HATCHINGS_ANGLE);
+ hatchingP.add(hatchAngleField, constraint);
+
+ hatchingP.setBorder(new CompoundBorder(new TitledBorder(null, LaTeXDrawLang.getString1_7("AbstractParametersFrame.8"), //$NON-NLS-1$
+ TitledBorder.LEFT, TitledBorder.TOP), new EmptyBorder(0,0,0,0)));
+
+ return hatchingP;
+ }
+
+
+
+
+ /**
+ * @return A panel with components to change the parameters of the double borders of the figure.
+ */
+ public JPanel createDoubleLinePanel()
+ {
+ JPanel fillingP = new JPanel(new FlowLayout(FlowLayout.LEFT));
+
+ doubleLine = new JCheckBox(LABEL_DOUBLELINE);
+ doubleLine.setActionCommand(LABEL_DOUBLELINE);
+ doubleLine.addActionListener(this);
+ fillingP.add(doubleLine);
+
+ fillingP.add(new JLabel(LABEL_DOUBLESEP));
+
+ SpinnerModel model = new SpinnerNumberModel(Figure.DEFAULT_DOUBLESEP, 1, 1000,1);
+ doubleSep = new JSpinner(model);
+ doubleSep.setEditor(new JSpinner.NumberEditor(doubleSep, "0")); //$NON-NLS-1$
+ doubleSep.setName(LABEL_DOUBLESEP);
+ doubleSep.addChangeListener(this);
+ doubleSep.setEnabled(doubleLine.isSelected());
+ fillingP.add(doubleSep);
+
+ doublecolorButton = new ColorButton(LABEL_BUTTON_BOUNDARY, new ButtonIcon(Figure.DEFAULT_DOUBLE_COLOR));
+ doublecolorButton.setActionCommand(LABEL_BUTTON_BOUNDARY);
+ doublecolorButton.addActionListener(this);
+ fillingP.add(doublecolorButton);
+ fillingP.setBorder(new CompoundBorder(new TitledBorder(null, LaTeXDrawLang.getString1_7("AbstractParametersFrame.9"), //$NON-NLS-1$
+ TitledBorder.LEFT, TitledBorder.TOP), new EmptyBorder(0,0,0,0)));
+
+ return fillingP;
+ }
+
+
+
+
+ /**
+ * @return A panel with components to change the parameters of the borders of the figure.
+ */
+ public JPanel createBordersPanel(boolean movable)
+ {
+ JPanel borderP = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ borderP.add(new JLabel(LABEL_THICKNESS));
+
+ SpinnerModel model = new SpinnerNumberModel(Figure.DEFAULT_THICKNESS, 0.1, 100,0.1);
+ thicknessField = new JSpinner(model);
+ thicknessField.setName(LaTeXDrawResources.NAME_THICKNESS_FIELD);
+ thicknessField.setEditor(new JSpinner.NumberEditor(thicknessField, "0.0"));//$NON-NLS-1$
+ thicknessField.addChangeListener(this);
+ borderP.add(thicknessField);
+
+ bordersButton = new ColorButton(LaTeXDrawResources.LABEL_COLOR_BUTTON, new ButtonIcon(Figure.DEFAULT_BORDERS_COL));
+ bordersButton.setActionCommand(LaTeXDrawResources.LABEL_COLOR_BUTTON);
+ bordersButton.addActionListener(this);
+ borderP.add(bordersButton);
+ borderP.add(new JLabel(LABEL_TYPE_LINE));
+
+ lineChoice = createLineChoice(this);
+ borderP.add(lineChoice);
+
+ if(movable)
+ {
+ bordersPositionChoice = Figure.createBordersPositionChoice();
+ bordersPositionChoice.addItemListener(this);
+ borderP.add(bordersPositionChoice);
+ }
+
+ borderP.setBorder(new CompoundBorder(new TitledBorder(null, LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.47"), //$NON-NLS-1$
+ TitledBorder.LEFT, TitledBorder.TOP), new EmptyBorder(0,0,0,0)));
+
+ return borderP;
+ }
+
+
+
+
+ /**
+ * @return A panel with components to change the parameters of the filling of the figure.
+ */
+ public JPanel createFillPanel()
+ {
+ JPanel fillingP = new JPanel(new FlowLayout(FlowLayout.LEFT));
+
+ filledCheckBox = new JCheckBox(LaTeXDrawResources.LABEL_FILLED_CHECKBOX);
+ filledCheckBox.setActionCommand(LaTeXDrawResources.LABEL_FILLED_CHECKBOX);
+ filledCheckBox.addActionListener(this);
+ fillingP.add(filledCheckBox);
+
+ interiorButton = new ColorButton(LaTeXDrawResources.LABEL_COLOR_INTERIOR_BUTTON, new ButtonIcon(Figure.DEFAULT_INTERIOR_COL));
+ interiorButton.setActionCommand(LaTeXDrawResources.LABEL_COLOR_INTERIOR_BUTTON);
+ interiorButton.addActionListener(this);
+ fillingP.add(interiorButton);
+
+ hatchChoice = Figure.createFillChoice();
+ hatchChoice.setPreferredSize(new Dimension(60,25));
+ hatchChoice.addItemListener(this);
+ fillingP.add(hatchChoice);
+
+ fillingP.setBorder(new CompoundBorder(new TitledBorder(null, LaTeXDrawLang.getString1_7("AbstractParametersFrame.11"), //$NON-NLS-1$
+ TitledBorder.LEFT, TitledBorder.TOP), new EmptyBorder(0,0,0,0)));
+
+ return fillingP;
+ }
+
+
+
+
+ /**
+ * @return A panel with components to change the parameters of the shadow of the figure.
+ */
+ public JPanel createGradientPanel()
+ {
+ GridBagConstraints constraint = new GridBagConstraints();
+ constraint.gridx = 0; constraint.gridy = 0;
+ constraint.gridwidth = 1; constraint.gridheight = 1;
+ constraint.weightx = 0.1; constraint.weighty = 0.1;
+ constraint.fill = GridBagConstraints.NONE;
+ constraint.anchor = GridBagConstraints.WEST;
+
+ JPanel gradientP = new JPanel(new GridBagLayout());
+
+ gradientStartColButton = new ColorButton(LaTeXDrawResources.LABEL_COLOR_GRADIENT_FIRST, new ButtonIcon(PSTricksConstants.DEFAULT_GRADIENT_START_COLOR));
+ gradientStartColButton.setActionCommand(LaTeXDrawResources.LABEL_COLOR_GRADIENT_FIRST);
+ gradientStartColButton.addActionListener(this);
+ gradientP.add(gradientStartColButton, constraint);
+
+ gradientEndColButton = new ColorButton(LaTeXDrawResources.LABEL_COLOR_GRADIENT_SECOND, new ButtonIcon(PSTricksConstants.DEFAULT_GRADIENT_END_COLOR));
+ gradientEndColButton.setActionCommand(LaTeXDrawResources.LABEL_COLOR_GRADIENT_SECOND);
+ gradientEndColButton.addActionListener(this);
+ constraint.gridx++;
+ gradientP.add(gradientEndColButton, constraint);
+
+ constraint.gridy++; constraint.gridx=0;
+ gradientP.add(new JLabel(LABEL_GRADIENT_MID_PT), constraint);
+
+ constraint.gridx++;
+ SpinnerModel model = new SpinnerNumberModel(Figure.DEFAULT_GRADIENT_MID_POINT,0,1,0.01);
+ gradientMidPtField = new JSpinner(model);
+ gradientMidPtField.setEditor(new JSpinner.NumberEditor(gradientMidPtField, "0.000"));//$NON-NLS-1$
+ gradientMidPtField.addChangeListener(this);
+ gradientMidPtField.setName(LABEL_GRADIENT_MID_PT);
+ gradientP.add(gradientMidPtField, constraint);
+
+ constraint.gridx++;
+ gradientP.add(new JLabel(LABEL_GRADIENT_ANGLE), constraint);
+
+ constraint.gridx++;
+ model = new SpinnerNumberModel(Math.toDegrees(Figure.DEFAULT_GRADIENT_ANGLE), -360, 360,0.5);
+ gradientAngleField = new JSpinner(model);
+ gradientAngleField.setEditor(new JSpinner.NumberEditor(gradientAngleField, "0.0"));//$NON-NLS-1$
+ gradientAngleField.addChangeListener(this);
+ gradientAngleField.setName(LABEL_GRADIENT_ANGLE);
+ constraint.gridx++;
+ gradientP.add(gradientAngleField, constraint);
+
+ gradientP.setBorder(new CompoundBorder(new TitledBorder(null, LaTeXDrawLang.getString1_7("AbstractParametersFrame.12"), //$NON-NLS-1$
+ TitledBorder.LEFT, TitledBorder.TOP), new EmptyBorder(0,0,0,0)));
+
+ return gradientP;
+ }
+
+
+
+ /**
+ * @return A panel with components to change the parameters of the shadow of the figure.
+ */
+ public JPanel createShadowPanel()
+ {
+ GridBagConstraints constraint = new GridBagConstraints();
+ constraint.gridx = 0; constraint.gridy = 0;
+ constraint.gridwidth = 1; constraint.gridheight = 1;
+ constraint.weightx = 0.1; constraint.weighty = 0.1;
+ constraint.fill = GridBagConstraints.NONE;
+ constraint.anchor = GridBagConstraints.CENTER;
+
+ JPanel shadowP = new JPanel(new GridBagLayout());
+
+ constraint.gridy=0; constraint.gridx=0;
+ shadowCheckBox = new JCheckBox(LaTeXDrawResources.LABEL_SHADOW_CHECKBOX);
+ shadowCheckBox.setActionCommand(LaTeXDrawResources.LABEL_SHADOW_CHECKBOX);
+ shadowCheckBox.addActionListener(this);
+ constraint.gridx=0; constraint.gridy=0;
+ shadowP.add(shadowCheckBox, constraint);
+
+ shadowColorButton = new ColorButton(LaTeXDrawResources.LABEL_COLOR_SHADOW, new ButtonIcon(Figure.DEFAULT_SHADOW_COLOR));
+ shadowColorButton.setActionCommand(LaTeXDrawResources.LABEL_COLOR_SHADOW);
+ shadowColorButton.addActionListener(this);
+ constraint.gridx++;
+ shadowP.add(shadowColorButton, constraint);
+
+ constraint.gridy++; constraint.gridx=0;
+ shadowP.add(new JLabel(LABEL_SHADOW_SIZE), constraint);
+
+ constraint.gridx++;
+ SpinnerModel model = new SpinnerNumberModel(Figure.DEFAULT_SHADOW_SIZE,0.01,1000,1);
+ shadowSizeField = new JSpinner(model);
+ shadowSizeField.setEditor(new JSpinner.NumberEditor(shadowSizeField, "0.00"));//$NON-NLS-1$
+ shadowSizeField.addChangeListener(this);
+ shadowSizeField.setName(LABEL_SHADOW_SIZE);
+ shadowP.add(shadowSizeField, constraint);
+
+ constraint.gridx++;
+ shadowP.add(new JLabel(LABEL_SHADOW_ANGLE), constraint);
+
+ constraint.gridx++;
+ model = new SpinnerNumberModel(Math.toDegrees(Figure.DEFAULT_SHADOW_ANGLE), -360, 360,0.5);
+ shadowAngleField = new JSpinner(model);
+ shadowAngleField.setEditor(new JSpinner.NumberEditor(shadowAngleField, "0.0"));//$NON-NLS-1$
+ shadowAngleField.addChangeListener(this);
+ shadowAngleField.setName(LABEL_SHADOW_ANGLE);
+ constraint.gridx++;
+ shadowP.add(shadowAngleField, constraint);
+
+ shadowP.setBorder(new CompoundBorder(new TitledBorder(null, LaTeXDrawLang.getString1_7("LaTeXDrawFrame.0"), //$NON-NLS-1$
+ TitledBorder.LEFT, TitledBorder.TOP), new EmptyBorder(0,0,0,0)));
+
+ return shadowP;
+ }
+
+
+
+
+ /**
+ * Allows to create a panel with defaults buttons (ok, cancel, default)
+ * @param frame The frame which ask the panel
+ * @return The created panel
+ */
+ public JPanel createButtonsPanel(AbstractParametersFrame frame)
+ {
+ JPanel panel = new JPanel();
+
+ buttonOk = new JButton(LABEL_OK);
+ JButton buttonCancel = new JButton(LABEL_CANCEL),
+ buttonDefault = new JButton(LABEL_DEFAULT);
+
+ buttonOk.setActionCommand(NAME_BUTTON_OK);
+ buttonCancel.setActionCommand(NAME_BUTTON_CANCEL);
+ buttonDefault.setActionCommand(NAME_BUTTON_DEFAULT);
+
+ panel.add(buttonOk);
+ panel.add(buttonCancel);
+ panel.add(buttonDefault);
+ panel.setPreferredSize(new Dimension(280, 40));
+ panel.setMaximumSize(new Dimension(280, 40));
+ buttonOk.addActionListener(frame);
+ buttonCancel.addActionListener(frame);
+ buttonDefault.addActionListener(frame);
+
+ return panel;
+ }
+
+
+
+
+ /**
+ * Allows to set by default some fields of the frame
+ */
+ public void setDefaultsValues()
+ {
+ Figure f = glimpsePanel.getGlimpseFigure();
+ setModified(true);
+
+ if(f.canHaveShadow())
+ {
+ f.setHasShadow(PSTricksConstants.DEFAULT_SHADOW);
+ shadowAngleField.setValue(Math.toDegrees(Figure.DEFAULT_SHADOW_ANGLE));
+ shadowSizeField.setValue(Figure.DEFAULT_SHADOW_SIZE);
+ shadowColorButton.setEnabled(Figure.DEFAULT_SHADOW_HAS);
+ shadowColorButton.setColor(Figure.DEFAULT_SHADOW_COLOR);
+ f.setShadowColor(Figure.DEFAULT_SHADOW_COLOR);
+ glimpsePanel.glimpseFigure.setDoubleColor(Figure.DEFAULT_SHADOW_COLOR);
+ shadowCheckBox.setSelected(Figure.DEFAULT_SHADOW_HAS);
+ shadowSizeField.setEnabled(shadowCheckBox.isSelected());
+ shadowAngleField.setEnabled(shadowCheckBox.isSelected());
+ }
+
+ if(f.canHaveArrow())
+ {
+ ((Arrowable)f).setArrow1Style(ArrowHead.DEFAULT_STYLE);
+ ((Arrowable)f).setArrow2Style(ArrowHead.DEFAULT_STYLE);
+ arrow1Choice.setSelectedItem(ArrowHead.DEFAULT_STYLE);
+ arrow2Choice.setSelectedItem(ArrowHead.DEFAULT_STYLE);
+
+ bracketNum.setValue(ArrowHead.DEFAULT_BRACKET_NUM);
+ dotSizeDim.setValue(ArrowHead.DEFAULT_DOT_SIZE_DIM);
+ dotSizeNum.setValue(ArrowHead.DEFAULT_ARROW_SIZE_NUM);
+ rbracketNum.setValue(ArrowHead.DEFAULT_RBRACKET_NUM);
+ tbarsizeDim.setValue(ArrowHead.DEFAULT_TBAR_SIZE_DIM);
+ tbarsizeNum.setValue(ArrowHead.DEFAULT_TBAR_SIZE_NUM);
+ arrowInset.setValue(ArrowHead.DEFAULT_ARROW_INSET);
+ arrowLength.setValue(ArrowHead.DEFAULT_ARROW_LGTH);
+ arrowSizeDim.setValue(ArrowHead.DEFAULT_ARROW_SIZE_DIM);
+ arrowSizeNum.setValue(ArrowHead.DEFAULT_ARROW_SIZE_NUM);
+
+ ArrowHead leftA = ((Arrowable)f).getArrowHead1();
+ ArrowHead rightA = ((Arrowable)f).getArrowHead2();
+
+ leftA.setBracketNum(ArrowHead.DEFAULT_BRACKET_NUM);
+ rightA.setBracketNum(ArrowHead.DEFAULT_BRACKET_NUM);
+ leftA.setDotSizeDim(ArrowHead.DEFAULT_DOT_SIZE_DIM);
+ rightA.setDotSizeDim(ArrowHead.DEFAULT_DOT_SIZE_DIM);
+ leftA.setDotSizeNum(ArrowHead.DEFAULT_ARROW_SIZE_NUM);
+ rightA.setDotSizeNum(ArrowHead.DEFAULT_ARROW_SIZE_NUM);
+ leftA.setRBracketNum(ArrowHead.DEFAULT_RBRACKET_NUM);
+ rightA.setRBracketNum(ArrowHead.DEFAULT_RBRACKET_NUM);
+ leftA.setTBarSizeDim(ArrowHead.DEFAULT_TBAR_SIZE_DIM);
+ rightA.setTBarSizeDim(ArrowHead.DEFAULT_TBAR_SIZE_DIM);
+ leftA.setTBarSizeNum(ArrowHead.DEFAULT_TBAR_SIZE_NUM);
+ rightA.setTBarSizeNum(ArrowHead.DEFAULT_TBAR_SIZE_NUM);
+
+ leftA.setArrowSizeNum(ArrowHead.DEFAULT_ARROW_SIZE_NUM);
+ rightA.setArrowSizeNum(ArrowHead.DEFAULT_ARROW_SIZE_NUM);
+ leftA.setArrowSizeDim(ArrowHead.DEFAULT_ARROW_SIZE_DIM);
+ rightA.setArrowSizeDim(ArrowHead.DEFAULT_ARROW_SIZE_DIM);
+ leftA.setArrowLength(ArrowHead.DEFAULT_ARROW_LGTH);
+ rightA.setArrowLength(ArrowHead.DEFAULT_ARROW_LGTH);
+ leftA.setArrowInset(ArrowHead.DEFAULT_ARROW_INSET);
+ rightA.setArrowInset(ArrowHead.DEFAULT_ARROW_INSET);
+
+ updateEnableParamsArrow();
+ }
+
+ if(doublecolorButton!=null)
+ {
+ doublecolorButton.setEnabled(Figure.DEFAULT_DOUBLELINE);
+ doublecolorButton.setColor(Figure.DEFAULT_DOUBLE_COLOR);
+ glimpsePanel.glimpseFigure.setDoubleColor(Figure.DEFAULT_DOUBLE_COLOR);
+ }
+
+ if(bordersPositionChoice!=null)
+ {
+ bordersPositionChoice.setSelectedItem(Figure.DEFAULT_BORDERS_POSITION);
+ glimpsePanel.glimpseFigure.setBordersPosition(Figure.DEFAULT_BORDERS_POSITION);
+ }
+
+ if(doubleLine!=null)
+ {
+ glimpsePanel.glimpseFigure.setHasDoubleBoundary(Figure.DEFAULT_DOUBLELINE);
+ glimpsePanel.glimpseFigure.setDoubleSep(Figure.DEFAULT_DOUBLESEP);
+ doubleLine.setSelected(Figure.DEFAULT_DOUBLELINE);
+ doubleSep.setValue(Figure.DEFAULT_DOUBLESEP);
+ }
+
+ if(lineChoice!=null)
+ lineChoice.setSelectedItem(Figure.DEFAULT_LINE_STYLE);
+
+ if(f.canBeHatched())
+ {
+ hatchButton.setColor(Figure.DEFAULT_HATCH_COL);
+ glimpsePanel.getGlimpseFigure().setHatchingColor(Figure.DEFAULT_HATCH_COL);
+ hatchChoice.setSelectedItem(Figure.DEFAULT_HATCH_STYLE);
+ hatchWidthField.setValue((double)Figure.DEFAULT_HATCH_WIDTH);
+ hatchSepField.setValue(Figure.DEFAULT_HATCH_SEP);
+ hatchAngleField.setValue(0.);
+ }
+
+ if(bordersButton!=null)
+ {
+ bordersButton.setColor(Figure.DEFAULT_BORDERS_COL);
+ glimpsePanel.getGlimpseFigure().setLinesColor(Figure.DEFAULT_BORDERS_COL);
+ }
+
+ if(interiorButton!=null)
+ {
+ interiorButton.setColor(Figure.DEFAULT_INTERIOR_COL);
+ glimpsePanel.getGlimpseFigure().setInteriorColor(Figure.DEFAULT_INTERIOR_COL);
+ }
+
+ if(filledCheckBox!=null)
+ filledCheckBox.setSelected(Figure.DEFAULT_IS_FILLED);
+
+ if(f.canBeHatched())
+ {
+ gradientAngleField.setValue(Math.toDegrees(Figure.DEFAULT_GRADIENT_ANGLE));
+ gradientMidPtField.setValue(Figure.DEFAULT_GRADIENT_MID_POINT);
+ gradientEndColButton.setColor(PSTricksConstants.DEFAULT_GRADIENT_END_COLOR);
+ boolean ok = Figure.DEFAULT_HATCH_STYLE.equals(PSTricksConstants.TOKEN_FILL_GRADIENT);
+ gradientEndColButton.setEnabled(ok);
+ gradientStartColButton.setColor(PSTricksConstants.DEFAULT_GRADIENT_START_COLOR);
+ gradientStartColButton.setEnabled(ok);
+ gradientMidPtField.setEnabled(ok);
+ gradientAngleField.setEnabled(ok);
+ }
+
+ if(rotationField!=null)
+ rotationField.setValue(Figure.DEFAULT_ROTATION_ANGLE);
+
+ if(thicknessField!=null)
+ thicknessField.setValue((double)Figure.DEFAULT_THICKNESS);
+
+ glimpsePanel.repaint();
+ }
+
+
+
+
+ /**
+ * Allows to create the list of the different styles of line.
+ * @param frame The frame which ask the Choice.
+ * @return The created Choice.
+ */
+ public LaTeXDrawComboBox createLineChoice(AbstractParametersFrame frame)
+ {
+ LaTeXDrawComboBox choice = Figure.createStyleLineChoice();
+ choice.setActionCommand(LaTeXDrawResources.CHOICE_LINE_NAME);
+ choice.setName(LaTeXDrawResources.CHOICE_LINE_NAME);
+ choice.addItemListener(frame);
+
+ return choice;
+ }
+
+
+
+
+ public void itemStateChanged(ItemEvent e)
+ {
+ try
+ {
+ Object o = e.getSource();
+ Figure f = glimpsePanel.getGlimpseFigure();
+
+ if(o instanceof LaTeXDrawComboBox)
+ {
+ String ac = ((LaTeXDrawComboBox)o).getActionCommand();
+
+ if(ac.equals(LaTeXDrawResources.CHOICE_LINE_NAME))
+ {
+ JLabel l = (JLabel) lineChoice.getSelectedItem();
+
+ setModified(true);
+ f.setLineStyle(l.getText());
+ glimpsePanel.repaint();
+ return ;
+ }
+
+ if(ac.equals(Figure.LABEL_BORDERS_POSITION_CHOICE))
+ {
+ JLabel l = (JLabel) bordersPositionChoice.getSelectedItem();
+
+ setModified(true);
+ f.setBordersPosition(l.getText());
+ glimpsePanel.repaint();
+ return ;
+ }
+
+ if(ac.equals(Figure.LABEL_HATCH_CHOICE))
+ {
+ String txt = ((JLabel)hatchChoice.getSelectedItem()).getText();
+ int num=0;
+
+ if(txt.equals(PSTricksConstants.TOKEN_FILL_GRADIENT))
+ num=1;
+ else if(txt.equals(PSTricksConstants.TOKEN_FILL_NONE) || txt.equals(PSTricksConstants.TOKEN_FILL_SOLID))
+ num=2;
+
+ setModified(true);
+ f.setHatchingStyle(txt);
+ hatchButton.setEnabled(num==0);
+ hatchWidthField.setEnabled(num==0);
+ hatchAngleField.setEnabled(num==0);
+ hatchSepField.setEnabled(num==0);
+ gradientAngleField.setEnabled(num==1);
+ gradientEndColButton.setEnabled(num==1);
+ gradientMidPtField.setEnabled(num==1);
+ gradientStartColButton.setEnabled(num==1);
+ updateFilledCB();
+ glimpsePanel.repaint();
+ return ;
+ }
+
+ if(ac.equals(LaTeXDrawResources.CHOICE_ARROW_LEFT_NAME))
+ {
+ JLabel label = (JLabel) arrow1Choice.getSelectedItem();
+
+ setModified(true);
+ ((Arrowable)f).setArrow1Style(label.getText());
+ updateEnableParamsArrow();
+ glimpsePanel.repaint();
+ return ;
+ }
+
+ if(ac.equals(LaTeXDrawResources.CHOICE_ARROW_RIGHT_NAME))
+ {
+ JLabel label = (JLabel) arrow2Choice.getSelectedItem();
+
+ setModified(true);
+ ((Arrowable)f).setArrow2Style(label.getText());
+ updateEnableParamsArrow();
+ glimpsePanel.repaint();
+ return ;
+ }
+ }
+ }catch(Exception ex)
+ {
+ ex.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(ex);
+ }
+ }
+
+
+
+
+ /**
+ * Defines actions to do when a item like JSpinner has changed
+ */
+ public void stateChanged(ChangeEvent e)
+ {
+ try
+ {
+ Object o = e.getSource();
+
+ if(o instanceof JSpinner)
+ {
+ String name = ((JSpinner)o).getName();
+ Figure f = glimpsePanel.getGlimpseFigure();
+ double v = Double.valueOf(((JSpinner)o).getValue().toString()).doubleValue();
+
+ if(name.equals(LaTeXDrawResources.NAME_THICKNESS_FIELD))
+ {
+ if(f instanceof Dot)
+ ((Dot)f).setWidth((float)v);
+ else
+ f.setThickness((float)v);
+
+ setModified(true);
+ glimpsePanel.repaint();
+ return ;
+ }
+
+ if(name.equals(LABEL_DOUBLESEP))
+ {
+ setModified(true);
+ f.setDoubleSep(v);
+ glimpsePanel.repaint();
+ return ;
+ }
+
+ if(name.equals(LABEL_HATCH_SEP))
+ {
+ setModified(true);
+ f.setHatchingSep(v);
+ glimpsePanel.repaint();
+ return ;
+ }
+
+ if(name.equals(LABEL_HATCHINGS_ANGLE))
+ {
+ setModified(true);
+ f.setHatchingAngle(Math.toRadians(v));
+ glimpsePanel.repaint();
+ return ;
+ }
+
+ if(name.equals(LABEL_GRADIENT_ANGLE))
+ {
+ setModified(true);
+ f.setGradientAngle(Math.toRadians(v));
+ glimpsePanel.repaint();
+ return ;
+ }
+
+ if(name.equals(LABEL_GRADIENT_MID_PT))
+ {
+ setModified(true);
+ f.setGradientMidPoint(v);
+ glimpsePanel.repaint();
+ return ;
+ }
+
+ if(name.equals(LABEL_SHADOW_ANGLE))
+ {
+ setModified(true);
+ f.setShadowAngle(v);
+ glimpsePanel.repaint();
+ return ;
+ }
+
+ if(name.equals(LABEL_SHADOW_SIZE))
+ {
+ setModified(true);
+ f.setShadowSize(v);
+ glimpsePanel.repaint();
+ return ;
+ }
+
+ if(name.equals(Figure.LABEL_HATCH_WIDTH))
+ {
+ setModified(true);
+ f.setHatchingWidth((float)v);
+ glimpsePanel.repaint();
+ return ;
+ }
+
+ if(name.equals(LaTeXDrawResources.LABEL_ROTATE))
+ {
+ setModified(true);
+ f.setRotationAngle(Math.toRadians(v));
+ glimpsePanel.repaint();
+ return;
+ }
+
+ if(name.equals(LABEL_BRACKETNUM))
+ {
+ setModified(true);
+ ((Arrowable)f).getArrowHead2().setBracketNum(v);
+ ((Arrowable)f).getArrowHead1().setBracketNum(v);
+ glimpsePanel.repaint();
+ return;
+ }
+
+ if(name.equals(LABEL_DOTSIZEDIM))
+ {
+ setModified(true);
+ ((Arrowable)f).getArrowHead1().setDotSizeDim(v);
+ ((Arrowable)f).getArrowHead2().setDotSizeDim(v);
+ glimpsePanel.repaint();
+ return;
+ }
+
+ if(name.equals(LABEL_DOTSIZENUM))
+ {
+ setModified(true);
+ ((Arrowable)f).getArrowHead1().setDotSizeNum(v);
+ ((Arrowable)f).getArrowHead2().setDotSizeNum(v);
+ glimpsePanel.repaint();
+ return;
+ }
+
+ if(name.equals(LABEL_RBRACKETNUM))
+ {
+ setModified(true);
+ ((Arrowable)f).getArrowHead1().setRBracketNum(v);
+ ((Arrowable)f).getArrowHead2().setRBracketNum(v);
+ glimpsePanel.repaint();
+ return;
+ }
+
+ if(name.equals(LABEL_TBARSIZEDIM))
+ {
+ setModified(true);
+ ((Arrowable)f).getArrowHead1().setTBarSizeDim(v);
+ ((Arrowable)f).getArrowHead2().setTBarSizeDim(v);
+ glimpsePanel.repaint();
+ return;
+ }
+
+ if(name.equals(LABEL_TBARSIZENUM))
+ {
+ setModified(true);
+ ((Arrowable)f).getArrowHead1().setTBarSizeNum(v);
+ ((Arrowable)f).getArrowHead2().setTBarSizeNum(v);
+ glimpsePanel.repaint();
+ return;
+ }
+
+ if(name.equals(LABEL_ARROWSIZENUM))
+ {
+ setModified(true);
+ ((Arrowable)f).getArrowHead1().setArrowSizeNum(v);
+ ((Arrowable)f).getArrowHead2().setArrowSizeNum(v);
+ glimpsePanel.repaint();
+ return;
+ }
+
+ if(name.equals(LABEL_ARROWSIZEDIM))
+ {
+ setModified(true);
+ ((Arrowable)f).getArrowHead1().setArrowSizeDim(v);
+ ((Arrowable)f).getArrowHead2().setArrowSizeDim(v);
+ glimpsePanel.repaint();
+ return ;
+ }
+
+ if(name.equals(LABEL_ARROWLENGTH))
+ {
+ setModified(true);
+ ((Arrowable)f).getArrowHead1().setArrowLength(v);
+ ((Arrowable)f).getArrowHead2().setArrowLength(v);
+ glimpsePanel.repaint();
+ return ;
+ }
+
+ if(name.equals(LABEL_ARROWINSET))
+ {
+ setModified(true);
+ ((Arrowable)f).getArrowHead1().setArrowInset(v);
+ ((Arrowable)f).getArrowHead2().setArrowInset(v);
+ glimpsePanel.repaint();
+ return ;
+ }
+ }
+ }catch(Exception ex)
+ {
+ ex.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(ex);
+ }
+ }
+
+
+
+ /**
+ * Allows to set the field rotationField.
+ */
+ public void createRotationField()
+ {
+ SpinnerModel model = new SpinnerNumberModel(Figure.DEFAULT_ROTATION_ANGLE, -360, 360,0.1);
+ rotationField = new JSpinner(model);
+ rotationField.setEditor(new JSpinner.NumberEditor(rotationField, "0.0")); //$NON-NLS-1$
+ rotationField.setName(LaTeXDrawResources.LABEL_ROTATE);
+ rotationField.addChangeListener(this);
+ rotationField.setName(LaTeXDrawResources.LABEL_ROTATE);
+ }
+
+
+
+ /**
+ * @return Create a panel with fields to modify the arrows.
+ * @param twoLeftArrows True if the figure has two 'left' arrows like arc and not a right arrow and a left arrow like line.
+ */
+ public JPanel createArrowPanel(boolean twoLeftArrows, boolean withFillButton)
+ {
+ JPanel arrowP = new JPanel(new GridBagLayout());
+ GridBagConstraints constraint = new GridBagConstraints();
+ constraint.gridx = 0;
+ constraint.gridy = 0;
+ constraint.gridwidth = 1;
+ constraint.gridheight = 1;
+ constraint.weightx = 0.1;
+ constraint.weighty = 0.1;
+ constraint.fill = GridBagConstraints.NONE;
+ constraint.anchor = GridBagConstraints.WEST;
+
+ arrowP.add(new JLabel(LABEL_LEFT_ARROW), constraint);
+
+ arrow1Choice = ArrowHead.createLeftArrowStyleList();
+ arrow1Choice.setName(LaTeXDrawResources.CHOICE_ARROW_LEFT_NAME);
+ arrow1Choice.setActionCommand(LaTeXDrawResources.CHOICE_ARROW_LEFT_NAME);
+ arrow1Choice.setSelectedItem(PSTricksConstants.NONEARROW_STYLE);
+ arrow1Choice.addItemListener(this);
+ constraint.gridx++;
+ arrowP.add(arrow1Choice, constraint);
+
+ constraint.gridx++;
+ arrowP.add(new JLabel(LABEL_RIGHT_ARROW), constraint);
+
+ if(twoLeftArrows)
+ arrow2Choice = ArrowHead.createLeftArrowStyleList();
+ else
+ arrow2Choice = ArrowHead.createRightArrowStyleList();
+ arrow2Choice.setName(LaTeXDrawResources.CHOICE_ARROW_RIGHT_NAME);
+ arrow2Choice.setActionCommand(LaTeXDrawResources.CHOICE_ARROW_RIGHT_NAME);
+ arrow2Choice.setSelectedItem(PSTricksConstants.NONEARROW_STYLE);
+ arrow2Choice.addItemListener(this);
+ constraint.gridx++;
+ arrowP.add(arrow2Choice, constraint);
+
+ constraint.gridx=0; constraint.gridy++;
+ arrowP.add(new JLabel(LABEL_DOTSIZE), constraint);
+
+ SpinnerNumberModel model = new SpinnerNumberModel(ArrowHead.DEFAULT_DOT_SIZE_NUM, 0.1, 100,0.1);
+ dotSizeNum = new JSpinner(model);
+ dotSizeNum.setName(LABEL_DOTSIZENUM);
+ dotSizeNum.setEditor(new JSpinner.NumberEditor(dotSizeNum, "0.0000"));//$NON-NLS-1$
+ dotSizeNum.addChangeListener(this);
+ constraint.gridx++;
+ arrowP.add(dotSizeNum, constraint);
+
+ constraint.gridx++;
+ arrowP.add(new JLabel(LABEL_CROSS_THICKNESS), constraint);
+
+ model = new SpinnerNumberModel(ArrowHead.DEFAULT_DOT_SIZE_DIM, 0, 1000,1);
+ dotSizeDim = new JSpinner(model);
+ dotSizeDim.setName(LABEL_DOTSIZEDIM);
+ dotSizeDim.setEditor(new JSpinner.NumberEditor(dotSizeDim, "0.00"));//$NON-NLS-1$
+ dotSizeDim.addChangeListener(this);
+ constraint.gridx++;
+ arrowP.add(dotSizeDim, constraint);
+
+ constraint.gridx = 0;
+ constraint.gridy++;
+ arrowP.add(new JLabel(LABEL_TBARSIZE), constraint);
+
+ model = new SpinnerNumberModel(ArrowHead.DEFAULT_TBAR_SIZE_NUM,0.1, 100,0.1);
+ tbarsizeNum = new JSpinner(model);
+ tbarsizeNum.setName(LABEL_TBARSIZENUM);
+ tbarsizeNum.setEditor(new JSpinner.NumberEditor(tbarsizeNum, "0.0000"));//$NON-NLS-1$
+ tbarsizeNum.addChangeListener(this);
+ constraint.gridx++;
+ arrowP.add(tbarsizeNum, constraint);
+
+ constraint.gridx++;
+ arrowP.add(new JLabel(LABEL_CROSS_THICKNESS), constraint);
+
+ model = new SpinnerNumberModel(ArrowHead.DEFAULT_TBAR_SIZE_DIM, 0, 1000,1);
+ tbarsizeDim = new JSpinner(model);
+ tbarsizeDim.setName(LABEL_TBARSIZEDIM);
+ tbarsizeDim.setEditor(new JSpinner.NumberEditor(tbarsizeDim, "0.00"));//$NON-NLS-1$
+ tbarsizeDim.addChangeListener(this);
+ constraint.gridx++;
+ arrowP.add(tbarsizeDim, constraint);
+
+ constraint.gridx = 0;
+ constraint.gridy++;
+ arrowP.add(new JLabel(LABEL_BRACKET_LGTH), constraint);
+
+ model = new SpinnerNumberModel(ArrowHead.DEFAULT_BRACKET_NUM, 0.001, 100,0.01);
+ bracketNum = new JSpinner(model);
+ bracketNum.setName(LABEL_BRACKETNUM);
+ bracketNum.setEditor(new JSpinner.NumberEditor(bracketNum, "0.0000"));//$NON-NLS-1$
+ bracketNum.addChangeListener(this);
+ constraint.gridx++;
+ arrowP.add(bracketNum, constraint);
+
+ constraint.gridx++;
+ arrowP.add(new JLabel(LABEL_CROSS_WIDTH), constraint);
+
+ constraint.gridx = 0;
+ constraint.gridy++;
+ arrowP.add(new JLabel(LABEL_RBRACKET_LGTH), constraint);
+
+ model = new SpinnerNumberModel(ArrowHead.DEFAULT_RBRACKET_NUM, 0.001, 100,0.01);
+ rbracketNum = new JSpinner(model);
+ rbracketNum.setName(LABEL_RBRACKETNUM);
+ rbracketNum.setEditor(new JSpinner.NumberEditor(rbracketNum, "0.0000"));//$NON-NLS-1$
+ rbracketNum.addChangeListener(this);
+ constraint.gridx++;
+ arrowP.add(rbracketNum, constraint);
+
+ constraint.gridx++;
+ arrowP.add(new JLabel(LABEL_CROSS_WIDTH), constraint);
+
+ constraint.gridx=0;
+ constraint.gridy++;
+ arrowP.add(new JLabel(LABEL_ARROW_WIDTH), constraint);
+
+ model = new SpinnerNumberModel(ArrowHead.DEFAULT_ARROW_SIZE_NUM, 0.001, 100,0.01);
+ arrowSizeNum = new JSpinner(model);
+ arrowSizeNum.setName(LABEL_ARROWSIZENUM);
+ arrowSizeNum.setEditor(new JSpinner.NumberEditor(arrowSizeNum, "0.0000"));//$NON-NLS-1$
+ arrowSizeNum.addChangeListener(this);
+ constraint.gridx++;
+ arrowP.add(arrowSizeNum, constraint);
+
+ constraint.gridx++;
+ arrowP.add(new JLabel(LABEL_CROSS_THICKNESS), constraint);
+
+ model = new SpinnerNumberModel(ArrowHead.DEFAULT_ARROW_SIZE_DIM, 0, 1000, 1);
+ arrowSizeDim = new JSpinner(model);
+ arrowSizeDim.setName(LABEL_ARROWSIZEDIM);
+ arrowSizeDim.setEditor(new JSpinner.NumberEditor(arrowSizeDim, "0.00"));//$NON-NLS-1$
+ arrowSizeDim.addChangeListener(this);
+ constraint.gridx++;
+ arrowP.add(arrowSizeDim, constraint);
+
+ constraint.gridx=0;
+ constraint.gridy++;
+ arrowP.add(new JLabel(LABEL_ARROW_LENGTH), constraint);
+
+ model = new SpinnerNumberModel(ArrowHead.DEFAULT_ARROW_LGTH, 0, 100,0.01);
+ arrowLength = new JSpinner(model);
+ arrowLength.setName(LABEL_ARROWLENGTH);
+ arrowLength.setEditor(new JSpinner.NumberEditor(arrowLength, "0.0000"));//$NON-NLS-1$
+ arrowLength.addChangeListener(this);
+ constraint.gridx++;
+ arrowP.add(arrowLength, constraint);
+
+ constraint.gridx=0;
+ constraint.gridy++;
+ arrowP.add(new JLabel(LABEL_ARROW_INSET), constraint);
+
+ model = new SpinnerNumberModel(ArrowHead.DEFAULT_ARROW_INSET, 0, 100,0.01);
+ arrowInset = new JSpinner(model);
+ arrowInset.setName(LABEL_ARROWINSET);
+ arrowInset.setEditor(new JSpinner.NumberEditor(arrowInset, "0.0000"));//$NON-NLS-1$
+ arrowInset.addChangeListener(this);
+ constraint.gridx++;
+ arrowP.add(arrowInset, constraint);
+
+ if(withFillButton)
+ {
+ interiorButton = new ColorButton(LaTeXDrawResources.LABEL_COLOR_INTERIOR_BUTTON, new ButtonIcon(Figure.DEFAULT_INTERIOR_COL));
+ interiorButton.setActionCommand(LaTeXDrawResources.LABEL_COLOR_INTERIOR_BUTTON);
+ interiorButton.addActionListener(this);
+ constraint.gridx++;
+ arrowP.add(interiorButton, constraint);
+ }
+
+ arrowP.setBorder(new CompoundBorder(new TitledBorder(null, LABEL_ARROWS,
+ TitledBorder.LEFT, TitledBorder.TOP), new EmptyBorder(0,0,0,0)));
+ return arrowP;
+ }
+
+
+
+ /**
+ * Allows to set enable or disable the parameters of the left arrow
+ */
+ public void updateEnableParamsArrow()
+ {
+ JLabel label1 = (JLabel) arrow2Choice.getSelectedItem();
+ JLabel label2 = (JLabel) arrow1Choice.getSelectedItem();
+ String text1 = label1.getText();
+ String text2 = label2.getText();
+
+ boolean ok = text1.equals(PSTricksConstants.BAREND_STYLE) ||
+ text1.equals(PSTricksConstants.BARIN_STYLE) ||
+ text1.equals(PSTricksConstants.LSBRACKET_STYLE) ||
+ text1.equals(PSTricksConstants.RSBRACKET_STYLE) ||
+ text1.equals(PSTricksConstants.RRBRACKET_STYLE) ||
+ text1.equals(PSTricksConstants.LRBRACKET_STYLE) ||
+ text2.equals(PSTricksConstants.BAREND_STYLE) ||
+ text2.equals(PSTricksConstants.BARIN_STYLE) ||
+ text2.equals(PSTricksConstants.LSBRACKET_STYLE) ||
+ text2.equals(PSTricksConstants.RSBRACKET_STYLE) ||
+ text2.equals(PSTricksConstants.RRBRACKET_STYLE) ||
+ text2.equals(PSTricksConstants.LRBRACKET_STYLE) ;
+
+ tbarsizeDim.setEnabled(ok);
+ tbarsizeNum.setEnabled(ok);
+ bracketNum.setEnabled(text1.equals(PSTricksConstants.RSBRACKET_STYLE) ||
+ text1.equals(PSTricksConstants.LSBRACKET_STYLE) ||
+ text2.equals(PSTricksConstants.RSBRACKET_STYLE) ||
+ text2.equals(PSTricksConstants.LSBRACKET_STYLE));
+
+ rbracketNum.setEnabled(text1.equals(PSTricksConstants.RRBRACKET_STYLE) ||
+ text1.equals(PSTricksConstants.LRBRACKET_STYLE) ||
+ text2.equals(PSTricksConstants.RRBRACKET_STYLE) ||
+ text2.equals(PSTricksConstants.LRBRACKET_STYLE));
+
+ ok = text1.equals(PSTricksConstants.CIRCLEEND_STYLE) ||
+ text1.equals(PSTricksConstants.CIRCLEIN_STYLE) ||
+ text1.equals(PSTricksConstants.DISKEND_STYLE) ||
+ text1.equals(PSTricksConstants.DISKIN_STYLE) ||
+ text2.equals(PSTricksConstants.CIRCLEEND_STYLE) ||
+ text2.equals(PSTricksConstants.CIRCLEIN_STYLE) ||
+ text2.equals(PSTricksConstants.DISKEND_STYLE) ||
+ text2.equals(PSTricksConstants.DISKIN_STYLE);
+
+ dotSizeDim.setEnabled(ok);
+ dotSizeNum.setEnabled(ok);
+
+ ok = (text1.equals(PSTricksConstants.DLARROW_STYLE) ||
+ text1.equals(PSTricksConstants.LARROW_STYLE) ||
+ text1.equals(PSTricksConstants.DRARROW_STYLE) ||
+ text1.equals(PSTricksConstants.RARROW_STYLE) ||
+ text2.equals(PSTricksConstants.DLARROW_STYLE) ||
+ text2.equals(PSTricksConstants.LARROW_STYLE) ||
+ text2.equals(PSTricksConstants.DRARROW_STYLE) ||
+ text2.equals(PSTricksConstants.RARROW_STYLE));
+
+ arrowInset.setEnabled(ok);
+ arrowLength.setEnabled(ok);
+ arrowSizeDim.setEnabled(ok);
+ arrowSizeNum.setEnabled(ok);
+ }
+
+
+
+
+ /**
+ * Defines if the checkbox "filledCB" must be enable or not.
+ * @since 1.9
+ */
+ protected void updateFilledCB()
+ {
+ Figure f = glimpsePanel.getGlimpseFigure();
+
+ if(!f.canBeFilled() || filledCheckBox==null)
+ return ;
+
+ String txt = f.getHatchingStyle();
+
+ if(txt.equals(PSTricksConstants.TOKEN_FILL_GRADIENT))
+ {
+ filledCheckBox.setEnabled(false);
+ return ;
+ }
+
+ if(f instanceof JoinedLines || f instanceof BezierCurve || f instanceof AkinPoints)
+ {
+ filledCheckBox.setEnabled(!(shadowCheckBox.isSelected() && f.canHaveShadow() &&
+ (txt.equals(PSTricksConstants.TOKEN_FILL_CROSSHATCH) ||
+ txt.equals(PSTricksConstants.TOKEN_FILL_CROSSHATCH_F) ||
+ txt.equals(PSTricksConstants.TOKEN_FILL_HLINES) ||
+ txt.equals(PSTricksConstants.TOKEN_FILL_HLINES_F) ||
+ txt.equals(PSTricksConstants.TOKEN_FILL_VLINES) ||
+ txt.equals(PSTricksConstants.TOKEN_FILL_VLINES_F))));
+ }
+ else
+ filledCheckBox.setEnabled(!f.canHaveShadow() || !shadowCheckBox.isSelected());
+ }
+
+
+
+ /**
+ * @return the isModified.
+ * @since 2.0.0
+ */
+ public synchronized boolean isModified()
+ {
+ return isModified;
+ }
+
+
+ /**
+ * @param isModified the isModified to set.
+ * @since 2.0.0
+ */
+ public synchronized void setModified(boolean isModified)
+ {
+ this.isModified = isModified;
+ }
+}
diff --git a/latexDraw/util/LaTeXDrawNamespace.java b/latexDraw/util/LaTeXDrawNamespace.java
index fb06dac..1022c6d 100644
--- a/latexDraw/util/LaTeXDrawNamespace.java
+++ b/latexDraw/util/LaTeXDrawNamespace.java
@@ -56,6 +56,7 @@ public abstract class LaTeXDrawNamespace
public static final String XML_TYPE_GRID_SUB = "subGrid"; //$NON-NLS-1$
public static final String XML_TYPE_BG = "background"; //$NON-NLS-1$
+ public static final String XML_BORDER = "border"; //$NON-NLS-1$
public static final String XML_CAPTION = "caption"; //$NON-NLS-1$
public static final String XML_LABEL = "label"; //$NON-NLS-1$
public static final String XML_POSITION_VERT = "positionVert"; //$NON-NLS-1$
diff --git a/release_note.txt b/release_note.txt
index c33795a..447e74e 100644
--- a/release_note.txt
+++ b/release_note.txt
@@ -1,619 +1,631 @@
-*******************************************************************
-Version 2.0 - July 25th 2008
-
-- added: SVG import/export
-- added: can align (left, right, top,...) figures
-- added: can distribute figures
-- added: a menu item to create a new drawing with the selected figures
-- added: a button to copy the code of the selected figures
-- added: US English language (clear distinction between US and British English)
-- added: German translation
-- added: the latex command 'put' is managed. But its use is not advice since it is not a PSTricks command and it creates some problems with rput and uput commands. You should use the rput command instead
-
-- improvement: new icons;
-- improvement: better performance when the grid is displayed
-- improvement: can open latexdraw with a pstricks file
-- improvement: preferences are now stored in an XML file
-- improvement: the position of the main frame, its size and position of the slidebar are now saved in the preferences file
-- improvement: better plotting of rhombus, triangle and polygon
-
-- change: the default format of latexdraw is now SVG, files with the old format can still be opened
-- change: closed bézier-curves cannot have a second arrow anymore
-- change: the shape handlers are more simply drawn in order to be less CPU and memory consumers
-
-- fixed #1884433: changing rotation angle in the parameters panel do nothing (for lines and polygons)
-- fixed: while saving, wrong dialog title displayed when the interface ask if the drawing must be replaced
-- fixed: it was impossible to select a item of a toolbar with Compiz activated on Linux
-- fixed: problem of focus with toolbars on Linux
-- fixed: rotation field in the freehand parameters panel
-- fixed: no warning when quitting and when the drawing was modified via a parameters frame
-- fixed: some dot shapes were badly plotted
-- fixed: bezier curves and lines have their borders not well drawn when having a shadow
-- fixed: the cancel button of the preferences panel had no effect
-- fixed: a lot of minor bugs
-
-PSTricks parser 0.5:
-- added: rotatebox, rotateleft, rotateright and rotatedown commands are managed
-- added: definecolor{name}{cmyk}{c m y k} is supported
-- added: newrgbcolor, newcmykcolor, newgray and newhsbcolor commands are supported
-
-- fixed: false error report when some unknown commands are parsed
-- fixed: when importing a document, figures can be inserted several times
-- fixed: freeze when importing a lot of Bézier curves because of the code optimisations
-- fixed: crash when importing a bad formed piece of code containing too many closing braces
-- fixed: crash when importing a pscustom block composed of Bézier curves
-- fixed: crash when importing a Bézier curve having only two equal points
-- fixed: unit definition was not considered while parsing rput command
-- fixed: \} not well parsed
-
-
-***************************************************************
-Version 1.9.5 - October 20th 2007
-
-- fixed: transparency not always managed in imported pictures;
-- fixed: problem when trying to select a figure to put behind/in front of the selected figure;
-- fixed: crash when undo "join figures";
-- fixed: crash when putting a figure behind one another;
-- fixed: cannot open a .ldp containing a picture;
-- fixed: crash when joining several figures;
-- fixed: cannot change the parameters of joined figures;
-- fixed: a selected figure can be exported with its border.
-
-
-***************************************************************
-Version 1.9.4 - September 1st 2007
-
-- fixed: an error occurred when using alt-right/left/... and no figure was selected;
-- fixed: saving a drawing froze the program under gtk theme under Linux;
-- fixed: the size of an elliptic framed box was badly computed (again!);
-- fixed: bezier curves: arrow colour not exported in PSTricks;
-- fixed: joined-lines arrows can be in the wrong side;
-- fixed: "joined-lines" menu was missing in the popup-menu;
-- fixed: too small figures cannot be created;
-- fixed: problems with arrows and line/joined-lines;
-- fixed: a line/joined-lines/arc/bezier curve/circle is not visible when all its points are at the same location;
-- fixed: the code is never updated before its printing;
-- fixed: the grid was printed with the drawing;
-- fixed: grid: the dotted sub-grid not well defined;
-- fixed: the pstricks code of a grid can generate number such as 1E-07;
-- fixed: the dot-size field is not updated when resizing a dot;
-- fixed: an error can occurred when using mirrors/position buttons with no selected figure;
-- fixed: the printed code is always a unique page;
-
-- change: jlibeps replaces EPSGraphics;
-- change: importation of a WMF picture is removed.
-
-PSTricks parser 0.4.2:
-
-- fixed: parameters beginning with '9' cannot be parsed;
-- fixed #1703716: origin={...} in parameters does not work.
-
-
-***************************************************************
-Version 1.9.3 - June 20th 2007
-
-- fixed: wrong colour definition for carnationPink;
-- fixed: undo/redo manager not always well updated;
-- fixed: sometimes, no warning appears when the drawing is modified and the user leaves LaTeXDraw;
-- fixed: choices list do nothing when selecting the same choice;
-- fixed: export menu not updated when cutting and pasting;
-- fixed: problem with toolbar, gtk "look and feel" and java 6;
-- fixed: buttons not well updated with ctrl-A;
-- fixed: in rare case, joined figures can launch exceptions;
-- fixed: when separating joined figures, the code is not updated;
-- fixed: freehand: if first point=last point, the figure is not created;
-- fixed: user comments can be truncated.
-
-PSTricks parser 0.4.1:
-
-- fixed #1703713: {} and {>} arrows command should be parsed.
-
-
-****************************************************************
-Version 1.9.2 - May 31th 2007
-
-- added: a button in the frame of errors to copy the log;
-
-- improvement: preferences and templates are stored in the profile of the user
+*******************************************************************
+Version 2.0.1 - October 31th 2008
+
+- added: hatchings angle is now managed
+
+- fixed #289881: crash when joining figures
+- fixed #264270: text font and text size not loaded from SVG documents
+- fixed #268037: italic and bold text not loaded from SVG documents
+- fixed #268979: borders of the auto adjustment not saved
+- fixed #267117: translation error
+- fixed #268973: borders cannot be selected when in auto adjustment
+
+*******************************************************************
+Version 2.0 - July 25th 2008
+
+- added: SVG import/export
+- added: can align (left, right, top,...) figures
+- added: can distribute figures
+- added: a menu item to create a new drawing with the selected figures
+- added: a button to copy the code of the selected figures
+- added: US English language (clear distinction between US and British English)
+- added: German translation
+- added: the latex command 'put' is managed. But its use is not advice since it is not a PSTricks command and it creates some problems with rput and uput commands. You should use the rput command instead
+
+- improvement: new icons;
+- improvement: better performance when the grid is displayed
+- improvement: can open latexdraw with a pstricks file
+- improvement: preferences are now stored in an XML file
+- improvement: the position of the main frame, its size and position of the slidebar are now saved in the preferences file
+- improvement: better plotting of rhombus, triangle and polygon
+
+- change: the default format of latexdraw is now SVG, files with the old format can still be opened
+- change: closed bézier-curves cannot have a second arrow anymore
+- change: the shape handlers are more simply drawn in order to be less CPU and memory consumers
+
+- fixed #1884433: changing rotation angle in the parameters panel do nothing (for lines and polygons)
+- fixed: while saving, wrong dialog title displayed when the interface ask if the drawing must be replaced
+- fixed: it was impossible to select a item of a toolbar with Compiz activated on Linux
+- fixed: problem of focus with toolbars on Linux
+- fixed: rotation field in the freehand parameters panel
+- fixed: no warning when quitting and when the drawing was modified via a parameters frame
+- fixed: some dot shapes were badly plotted
+- fixed: bezier curves and lines have their borders not well drawn when having a shadow
+- fixed: the cancel button of the preferences panel had no effect
+- fixed: a lot of minor bugs
+
+PSTricks parser 0.5:
+- added: rotatebox, rotateleft, rotateright and rotatedown commands are managed
+- added: definecolor{name}{cmyk}{c m y k} is supported
+- added: newrgbcolor, newcmykcolor, newgray and newhsbcolor commands are supported
+
+- fixed: false error report when some unknown commands are parsed
+- fixed: when importing a document, figures can be inserted several times
+- fixed: freeze when importing a lot of Bézier curves because of the code optimisations
+- fixed: crash when importing a bad formed piece of code containing too many closing braces
+- fixed: crash when importing a pscustom block composed of Bézier curves
+- fixed: crash when importing a Bézier curve having only two equal points
+- fixed: unit definition was not considered while parsing rput command
+- fixed: \} not well parsed
+
+
+***************************************************************
+Version 1.9.5 - October 20th 2007
+
+- fixed: transparency not always managed in imported pictures;
+- fixed: problem when trying to select a figure to put behind/in front of the selected figure;
+- fixed: crash when undo "join figures";
+- fixed: crash when putting a figure behind one another;
+- fixed: cannot open a .ldp containing a picture;
+- fixed: crash when joining several figures;
+- fixed: cannot change the parameters of joined figures;
+- fixed: a selected figure can be exported with its border.
+
+
+***************************************************************
+Version 1.9.4 - September 1st 2007
+
+- fixed: an error occurred when using alt-right/left/... and no figure was selected;
+- fixed: saving a drawing froze the program under gtk theme under Linux;
+- fixed: the size of an elliptic framed box was badly computed (again!);
+- fixed: bezier curves: arrow colour not exported in PSTricks;
+- fixed: joined-lines arrows can be in the wrong side;
+- fixed: "joined-lines" menu was missing in the popup-menu;
+- fixed: too small figures cannot be created;
+- fixed: problems with arrows and line/joined-lines;
+- fixed: a line/joined-lines/arc/bezier curve/circle is not visible when all its points are at the same location;
+- fixed: the code is never updated before its printing;
+- fixed: the grid was printed with the drawing;
+- fixed: grid: the dotted sub-grid not well defined;
+- fixed: the pstricks code of a grid can generate number such as 1E-07;
+- fixed: the dot-size field is not updated when resizing a dot;
+- fixed: an error can occurred when using mirrors/position buttons with no selected figure;
+- fixed: the printed code is always a unique page;
+
+- change: jlibeps replaces EPSGraphics;
+- change: importation of a WMF picture is removed.
+
+PSTricks parser 0.4.2:
+
+- fixed: parameters beginning with '9' cannot be parsed;
+- fixed #1703716: origin={...} in parameters does not work.
+
+
+***************************************************************
+Version 1.9.3 - June 20th 2007
+
+- fixed: wrong colour definition for carnationPink;
+- fixed: undo/redo manager not always well updated;
+- fixed: sometimes, no warning appears when the drawing is modified and the user leaves LaTeXDraw;
+- fixed: choices list do nothing when selecting the same choice;
+- fixed: export menu not updated when cutting and pasting;
+- fixed: problem with toolbar, gtk "look and feel" and java 6;
+- fixed: buttons not well updated with ctrl-A;
+- fixed: in rare case, joined figures can launch exceptions;
+- fixed: when separating joined figures, the code is not updated;
+- fixed: freehand: if first point=last point, the figure is not created;
+- fixed: user comments can be truncated.
+
+PSTricks parser 0.4.1:
+
+- fixed #1703713: {} and {>} arrows command should be parsed.
+
+
+****************************************************************
+Version 1.9.2 - May 31th 2007
+
+- added: a button in the frame of errors to copy the log;
+
+- improvement: preferences and templates are stored in the profile of the user
- improvement: templates are not loaded at start-up;
-- improvement: double line for joined-lines;
-- improvement: can define the compression rate when exporting in jpg format;
-- improvement: in the frame of parameters, the glimpse panel automatically
- zoom in/out to view to whole figure and the figure is always
- placed in the centre of the panel;
-- improvement: in the frame of parameters, you can move the glimpse figure
- with the mouse;
-- improvement: in the frame of parameters for Bézier curve, you can choose
+- improvement: double line for joined-lines;
+- improvement: can define the compression rate when exporting in jpg format;
+- improvement: in the frame of parameters, the glimpse panel automatically
+ zoom in/out to view to whole figure and the figure is always
+ placed in the centre of the panel;
+- improvement: in the frame of parameters, you can move the glimpse figure
+ with the mouse;
+- improvement: in the frame of parameters for Bézier curve, you can choose
if, when moving a point, its control points are moved too;
-
-- fixed #1703723: figure not always well filled;
-- fixed: the stroke of double-line was badly used for bezier curves/joined-lines
-- fixed: when importing a picture, its eps version is saved in the profile if
- we can save it in the folder;
-- fixed: exception and some problems when undo/redo joined figures;
-- fixed: scalebox{1} must be placed before begin{pspicture};
-- fixed: exception when rotating several joined figures;
-- fixed: a template menu item will not be created if its .ldt file does not exist;
+
+- fixed #1703723: figure not always well filled;
+- fixed: the stroke of double-line was badly used for bezier curves/joined-lines
+- fixed: when importing a picture, its eps version is saved in the profile if
+ we can save it in the folder;
+- fixed: exception and some problems when undo/redo joined figures;
+- fixed: scalebox{1} must be placed before begin{pspicture};
+- fixed: exception when rotating several joined figures;
+- fixed: a template menu item will not be created if its .ldt file does not exist;
- fixed: template thumbnails were not always updated;
-- fixed: selection did not always work with arcs and Bézier curves.
-
-PSTricks parser 0.4:
-
-- added: \pspicture and \endpspicture are managed;
-- added: \normalcolor is managed;
-- added: arrows=<-| is managed;
-
-- fixed: an invalid \begin{pspicture} command must launch a fatal error;
-- fixed: unknown command not always well parsed;
-- fixed: a single end{pspicture} command must launch a fatal error;
-
-
-****************************************************************************
-Version 1.9.1 - April 4th 2007
-
-- added: more shortcuts:
- - "space" selects the first or the next figure (in selection mode);
- - ctrl+mouse wheel zoom in/out;
-- added: comment explaining how to rescale the whole drawing (request #1628137);
-
-- improvement: can change the parameters of several selected figures in the
- same time;
-- improvement: can define the parameters before creating a figure;
-- improvement: all the frames can be easily resized;
-- improvement: the definition of a dot is almost totally rewritten to improve
- the selection and to fix several bugs;
-
-- fixed #1681687: the parameters toolbar is not updated when importing a tex file;
-- fixed #1690426: figure not deleted when cancelling its creation with to top-right button;
-- fixed #1691145: freezes when a wrong file is given in command line;
-- fixed: exception in some cases when the frame of parameters of a dot is open;
-- fixed: the selection of figures works better now;
-- fixed: a rotated dot doesn't correctly move after loading a project;
-- fixed: problem when exporting a drawing as picture;
-- fixed: the drawing is no more affected when the number of pixels per
- cm changes (only the generated code);
-- fixed: problem when redoing after having cut several figures;
-- fixed: the size of the ellipse framed box was badly computed;
-- fixed: minor bugs.
-
-
-****************************************************************************
-Version 1.9 - February 8th 2007
-
-- added: a splash screen;
-- added: recent files manager;
-- added: more shortcuts:
- - ctrl+A select all the figures;
- - ctrl/shift key can be used to add/remove a figure to the selection;
- - can move scrollbars and figures with left, up, shift,...;
-- added: can update figures to the displayed grid;
-- added: a shortcuts frame;
-- added: when the code panel is closed, a button, copying the all the generated
- code, is visible in the toolbar;
-- added: a menu item to set visible all the hidden figures;
-- added: can choose the look and feel;
-- added: can change the transparency of the delimiters;
-- added: a menu to check update;
-- added: a popup menu to cut/paste/copy text from/to "insert PSTricks code" and
- "add comment" frames;
-- added: "move"/"resize/rotate" cursor is displayed when move/resize/rotate figures;
-- added: "code" menu now contains all code options;
-
-- improvement: free hand can be either curves or lines;
-- improvement: free hand can be closed or opened;
-- improvement: you can define the interval between each point of free hand;
-- improvement: akin points can be dotted/dashed;
-- improvement: akin points can be filled/hatched and can have a gradient;
-- improvement: a Bézier curve can be closed with a line or a curve;
-- improvement: can equilibrate the control points of a Bézier curve;
-- improvement: update jiu to 0.14.1;
-- improvement: a right-click doesn't remove the last point anymore (during the
- creation of a polygon/joined-lines/Bézier curve;
-
-- fixed #1621630: figures were not updated to the magnetic grid when rotated;
-- fixed #1621632: a very small rectangle can disappear when rotated of 90°;
-- fixed #1621633: cannot select a too small rectangle;
-- fixed #1621634: the selection of a text without framed box didn't work very well;
-- fixed #1621635: figures not always follow the magnetic grid when dragged;
-- fixed #1624345: cannot stop the creation of a polygon on Mac (mouse has one button);
-- fixed #1644659: the main frame lost the focus when a ListJToogleButton is displayed;
-- fixed #1644660: the gravity centre of a set of figures was badly computed;
-- fixed #1644660: polygons move when violently rotated;
-- fixed #1644662: problem when closing and displaying the code panel;
-- fixed #1644663: the parameters of the second arrow of joined lines/Bézier curve are never generated;
-- fixed #1645157: joined-lines are automatically filled when having a shadow;
-- fixed #1645158: space between dots of a dotted polygon with double boundaries was badly computed;
-- fixed #1645160: the fact that a dot can be filled or not was badly managed;
-- fixed: the size of delimiters (polygons, Bézier curves) aren't always updated;
-- fixed: arrows are not moved when mirrors are used (Bézier curve);
-- fixed: cut and paste doesn't work;
-- fixed: for axes, in some cases the labels are badly placed;
-- fixed: a lot of minor bugs;
-
-PSTricks parser 0.3:
-- added: \begin{figure} and \begin{center} are managed;
-- added: \pscustom is partially managed;
-
-- improvement: Can parse a Bézier curve with more than two points;
-- improvement: squared psframe is now converted in square;
-- improvement: arc with a line at the start to the end point is transformed in chord;
-
-
-***********************************************************************************
-Version 1.8.2 - November 15th 2006
-
-- fixed #1580023: the printed code doesn't take care about the width of the page;
-- fixed #1538675: Bézier curve/polygons/joined lines still rotate badly;
-- fixed #1581400: you can select a empty Bézier curve by clicking at the interior;
-- fixed #1591309: borders of a Bézier curve were not displayed;
-- fixed #1591310: can move a figure by using its borders;
-- fixed #1593762: parameters panel - undo has no effect when modifying a Bézier curve;
-- fixed #1591312: not enable to select a too small rectangle/ellipse;
-- fixed #1596421: a too small rectangle/ellipse is not visible;
-- fixed # : we must not be able to select a figure with its shadow;
-- fixed # : can select joinedlines/arc with the line joining their extremities;
-- fixed: minor bugs.
-
-PSTricks parser 0.2.3:
-- fixed #1579820: parser freezes when the code has { ... };
-- fixed #1586013: problem when parsing a line or a polygon like \psline(2,2)(2,2)(2,2).
-
-
-***********************************************************************************
-Version 1.8.1 - October 17th 2006
-
-- fixed #1554750: problem with round corner (frame and square);
-- fixed #1561789: "code autoupdate" field (in the preferences frame) had not effect;
-- fixed #1562954: problem with the look & feel "metal";
-- fixed #1564478: vertical mirror was horizontal mirror for text;
-- fixed #1564477: picture was not moved when using mirrors;
-- fixed #1573703: problem with checkboxes and jre 1.5.0_09 with XP look & feel;
-- fixed #1508200: delimiters of triangles and rhombus are sometimes badly updated;
-- fixed #1538675: polygons move when rotating violently;
-- fixed #1508202: Bézier curves rotate badly;
-- fixed: a lot of minor bugs.
-
-PSTricks parser 0.2.2:
-- fixed #1573706: problem when having both unit and xunit/yunit in the parameters.
-
-
-***********************************************************************************
-Version 1.8 - September 13th 2006
-
-- added: new localisation, Spanish;
-- added: new shape, axes;
-- added: magnetic grid;
-- added: mirrors to move figures;
-- added: buttons to rotate figures of 90, 180 and 270°;
-- added: a button to launch your LaTeX editor;
-
-- improvement: the help can be loaded with you browser: help/index.html;
-- improvement: Bézier curve can have arrows;
-- improvement: a button to close the mini-toolbars;
-- improvement: Bézier curve can have a double boundary;
-- improvement: Bézier curve can be filled, hatched and can have a gradient;
-- improvement: an arrow with the 'dot' shape can have its interior colour changed;
-- improvement: hatchsep attribute is managed;
-- improvement: new "About LaTeXDraw" frame;
-
-- fixed #1555339: the ilk of an arc (open, pie or chord) was never saved;
-- fixed #1554729: dotted/dashed double line has not it good background colour (for polygon);
-- fixed #1554162: the borders of the drawing are not always updated (with auto adjustment
- disable);
-- fixed #1553683: with command line, preferences and templates are not loaded;
-- fixed #1540561: crashing when launching the help;
-- fixed #1536603: eps exported files were not vectorial;
-- fixed #1528919: shadow for a polygon with double boundary is too small;
-- fixed #1528562: joined lines parameters frame: a change has no effect;
-- fixed #1538724: bad rotation in the frame of parameters of a drawing;
-- fixed #1547234: the 'draw labels' checkbox doesn't work very well in the frame
- of parameters of the grid;
-- fixed #1547235: default buttons did not always reinitialise values;
-- fixed #1547236: crashing when clicking on the default button of the dot frame;
-- fixed #1547239: round panel, for rectangle and square, is not always visible;
-- fixed #1548699: with JRE 1.5_08, the buttons of the toolbars are too big;
-- fixed #1556362: sometimes LaTeXDraw froze at startup when it checked new version;
-- fixed #1557509: vertical and horizontal line can be difficulty selected;
-- fixed: minor bugs.
-
-PSTricks parser 0.2.1:
-- added: axes management;
-
-- fixed #1556340: rotation angle was not managed (since 1.7) for triangle;
-- fixed #1556544: inversion of positions between X-labels and Y-labels;
-- fixed #1556548: a rotated grid (with unit not equal to 1) was badly placed.
-
-
-**************************************************************************************
-Version 1.7 - July 23th 2006
-
-- added: shadow management;
-- added: colour shifting management;
-- added: framed box management;
-- added: buttons in the frames of parameters to zoom in/out the figure;
-
-- improvement: the background of a text can be opaque;
-- improvement: polygons can have doubles lines;
-- improvement: can change the size of the rounds corners for rectangles and squares;
-- improvement: the frames of parameters have a better interface;
-- improvement: gif can be included or converted;
-- improvement: batch conversion: a check box define if the pictures must be converted
- in their directory or not;
-- improvement: new icons;
-
-- fixed #1404791: when refreshing the templates, there thumbnails were not updated;
-- fixed #1487192: when a frame of parameters is opened, the figure can be deleted or modified;
-- fixed #1481272: the colour of the interior of the arrows with the circle shape must be as the
- interior of the figure;
-- fixed #1487185: scrollbars are not updated when changing the font or the size of a text;
-- fixed #1489350: the size of a text change when zooming in and zooming out;
-- fixed #1489644: scrollbars of the parameters frame of grids are not always updated.
-- fixed #1489551: labels of grids and texts are not resized when you change the number
- of pixels per cm/inch of the draw;
-- fixed #1502040: when subgriddiv=1, borders must not be drawn;
-- fixed #1502043: some defaults values of lines' parameters were false;
-- fixed #1502048: for arcs, the start angle can be greater than the end angle to avoid problems
- during the drawing and the parsing (\pswedge(2,1){1.5}{300}{200});
-- fixed #1502046: for Bézier curves, the controls points had a wrong size;
-- fixed #1502049: we must be able to fill the dot shape 'o';
-- fixed #1512530: LaTeXDraw files containing picture cannot be loaded;
-- fixed #1512533: undo/redo: bad undo management when creating and cancelling a text/grid;
-- fixed #1512537: undo/redo: toolbar still active when redo a 'delete' action ;
-- fixed #1512538: undo/redo: the redo was never cleared when an action, different than
- redo, occurred;
-- fixed #1515149: bug in the method Line.getPerpendicularLine(): when the x-coordinate of a
- point of a triangle/rhombus is 0 a problem in the display occurred;
-- fixed #1516288: % not always replaced by \% during the code generation;
-- fixed #1523877: when a file is loaded, the undo/redo manager is not cleared;
-- fixed #1524381: batch conversion: output path was never used;
-- fixed #1525086: for rhombus, hatchings did not rotate because of gangle;
-- fixed #1526315: when "show points" option for a Bézier curve is selected, the curve must
- be dashed too;
-- fixed # : exception in Polygon.getBorders when three points have the same X-coordinate;
-- fixed: minor bugs.
-
-
-PSTricks parser 0.2:
-- added: shadow management;
-- added: colour shifting management;
-- added: framed box management;
-- added: millimetres are managed;
-- added: support +1 number (positive sign);
-- added: support numbers like ++++1, -----1, ++-+--+1;
-- added: support unit parameter;
-
-- fixed #1488716: linewidth=-1 must be understood as linewidth=1, idem for dotsize, ...;
-- fixed #1502052: for lines and arcs, arrows were not read in some cases (\psline{*->}(0,3)(5,5));
-- fixed #1502053: dots was never filled;
-- fixed #1502711: when parsing a polygon with only two points, the third point was not created;
-- fixed #1502712: parsing the command \psset{origin={1,1}} launched an exception;
-- fixed #1502713: coordinate like (1pt, 2in) and size like {1cm} must be parsed;
-- fixed #1502714: when insert PSTricks code with \begin{pspicture} in comment, this commented
- command was understood like an uncommented command;
-- fixed #1502715: the format \pswedge{3}{0}{70} was not supported;
-- fixed #1515871: when you insert pstricks code like \begin{center}\begin{pspicture} the
- \begin{pspicture} was ignored;
-- fixed #1516165: the \% command was ignored;
-- fixed #1519847: pink colour not managed;
-- fixed #1519934: text not always parsed;
-- fixed #1520384: \bf and \it have no effect;
-- fixed #1523726: error during the parsing of the command \psgrid; for instance \rput(0,0){\psgrid}
- didn't work.
-
-
-**************************************************************************************
-Version 1.6 - May 2nd 2006:
-
-WARNING: YOU MUST REPLACE THE FORMER 'Classic grid.ldp' OF THE TEMPLATES DIRECTORY BY THE NEW
- 'Classic grid.ldp' OF THE LaTeXDraw1.6_bin.zip.
-
-- fixed: several fields were exported to be localisable, while they should not to be (1);
-- fixed: polygon: borders was not updated when the thickness was changed;
-- fixed: problem when check the version of the preferences file;
-- fixed: grids did not rotate very when rotating several figures;
-- fixed: when paste, the scrollbars were not updated;
-- fixed: the grid was exported with the draw;
-- fixed: the packages \usepackage{color} and \usepackage{pstricks} are replaced by
- \usepackage[usenames,dvipsnames]{pstricks};
-- fixed: "move figure" was badly managed by the undo/redo manager;
-- fixed: a problem when resize several selected figures containing polygons or
- derived figures;
-- fixed: when loading a file, the delimiters of severals figures were not updated;
-- fixed: when paste, toolbar was still activated;
-- fixed: for rectangles, delimiters were not updated when paste;
-- fixed: for circles and ellipses, borders were not updated when the thickness changed;
-- fixed: toolbar was still activated when click in a empty place when searching a figure
- to put behind/in front;
-- fixed: \caption{fig: is replaced by \caption{;
-- fixed: { and } were replaced by \string \{ ... So no command was possible;
-- fixed: the description of the draw was not saved (label, caption ,...);
-- fixed: when load a file with comments, the comments are too much '%';
-- fixed: the borders of the selection was not updated when pasted several texts;
-- fixed: not able to have French translation;
-- fixed: the borders of the texts and of the grids were not always updated -> bad
- position of texts;
-- fixed: if a text was empty, you could not select it but it existed in the code panel;
-- fixed: problem in the management of the position of grids;
-- fixed: grids had not read/write stream methods (2);
-- fixed: when change a coordinate in a parameters frame and close the frame, the modified
- figure is not updated whereas;
-- fixed: glimpse figures (rectangle, square, ..) were not updated when change their width, ...
- in their parameters frame;
-- fixed: the grid was exported when exporting in eps;
-- fixed: in several cases, a figure does not rotate when the angle is 180°;
-- fixed: figures can move during the resizement of several polygons ;
-- fixed: the zoom was not managed when loading a file;
-- fixed: "dot-in" arrows change of position when the arrows is moved;
-- fixed: space between a double arrow must be like the arrows not like the line;
-- fixed: one of the doubles arrows for arc was not updated by the parameters of the arrow;
-- fixed: if the arrows are of the same kind, there parameters must be the same;
-- fixed: when you save a drawing and a figure is selected, it was hardly to unselect it;
-- fixed: it was possible to have an code for arrows like '{>>--}...' instead of '{>>-}';
-- fixed: space between two lines of an hatching was badly managed;
-- fixed: problem when copy/paste a rhombus or a triangle;
-- fixed: problem when editing points of rhombus/triangle with their frame of parameters;
-- fixed: scrollbars not updated when cut/delete the unique figure of a drawing;
-- fixed: problem when resize several figures;
-- fixed: option "showpoints" was not save for arcs;
-- fixed: several minor bugs;
-- improvement: for dot, 'rput' is replaced by 'dotangle';
-- improvement: more shapes for arrows: )-( and ]-[ are managed;
-- improvement: better management of the arrowheads and the grids;
-- improvement: for rhombus, 'rput' is replaced by 'gangle';
-- improvement: can change the position of the labels of the grids;
-- improvement: CPU, memory, speed optimisation;
-- improvement: akin points code generator generates less points;
-- added: export as PNG;
-- added: export as BMP;
-- added: export as PPM;
-- added: can insert pictures;
-- added: new figure, joined lines;
-- added: LaTeXDraw can be used to convert jpeg|png|wmf|bmp|ppm pictures in
- eps|jpeg|png|ppm pictures with a batch processing;
-- added: the LaTeXDraw manual;
-- added: import PSTricks code (PSTricks parser version 0.1);
-- added: can insert PSTricks code in a draw (use the PSTricks parser).
-
-
-- regression: if, you load a saved project with 1.5.1 or 1.5.1.1 , the language is
- French and several figures of the draw have doubles boundaries, then
- the position of the doubles boundaries will be always 'inner'; because
- of the bug (1);
-- regression: because of the bug (2), LaTeXDraw can not open file from 1.5.1.1 and older
- with grids. By the same way, old templates with grids are not compatible with
- LaTeXDraw 1.6.
-
-
-**************************************************************************************
-Version 1.5.1.1 - January 28th 2006:
-
-- fixed: minor bug with the isModified attribute;
-- fixed: ellipse didn't rotate very well;
-- fixed: error during the read of templates: templates could not be loaded;
-- fixed: when put '%' in comments or in a text, it was considered as a start of a
- comment by the TeX parser;
-- fixed: when a '\' was in a text, the label, ... it was considered as a command;
-- fixed: an exception appeared during the selection of figures when the draw was empty;
-- fixed: display->grid was not updated when change the unit of length (always in cm);
-- fixed: an exception occurred when drawing a triangle;
-- fixed: borders could not move;
-- fixed: problem when clicking on a triangle or on a rhombus;
-- fixed: problem when change a triangle or a rhombus;
-- fixed: the rectangle was not updated when dragging one of these delimiters;
-- fixed: polygon generate now a pspolygon, not a psline;
-- fixed: error when testing the version of the software.
-
-
-
-**************************************************************************************
-Version 1.5.1 - January 20th 2006:
-
-- fixed: figure id could be as big as 12982109 for example;
-- fixed: params button was active when several figures were selected;
-- fixed: the rotation of several selected or joined figures didn't
- rotated the gravity centre of these figures;
-- fixed: error when shifting a triangle or a rhombus (shift method
- not overridden);
-- fixed: a dotted line began before the first point;
-- fixed: the delimiters of a square could not be selected (pb in isIn);
-- fixed: isModified was activated when we confirmed preferences frame;
-- fixed: a problem when loading a template from former version;
-- fixed: arc choice created a problem of display in the parameters frame;
-- fixed: cut/paste managed in the undo/redo;
-- fixed: cut figures didn't remove them from the selection;
-- fixed: change cm to inch, didn't update the scales;
-- fixed: an error when initialise components of the square parameters frame;
-- fixed: dble boundaries weren't filled very well with round rectangle/square;
-- fixed: getBorders(..) not overridden in the class BézierCurve;
-- fixed: menu "export as template" was never activated;
-- improvement: better rotation of the figures;
-- improvement: CPU, memory, speed optimisation;
-- improvement: better management of the resizing of rotated figures;
-- added: can check new version;
-- added: status bar;
-- added: support localisation;
-- added: new localisation, French.
-
-
-**************************************************************************************
-Version 1.5 - January 13th 2006:
-
-- fixed: bug in intersect method;
-- fixed: bug with the default button in the parameters frames;
-- fixed: when we click the button default during the creation of a text or a
- grid, the figure wasn't deleted;
-- fixed: bug when saving parameters of a line in the parameters frame;
-- fixed: problem with the rescale methods;
-- fixed: minor bug in the code generation methods with the interior colour;
-- fixed: an horizontal line cannot be selected with the rectangle selector;
-- fixed: in the draw method of ArrowHead; round bracket used wrong attribute;
-- fixed: bugs in the ArrowHead code generator method;
-- fixed: bug in the arc code generator method;
-- fixed: problem when resize several figures containing at least a non-resizable
- figure like grid or text;
-- fixed: problem during the first selection akin points: the borders were wrong;
-- fixed: problem when resize several figures after a rotation;
-- fixed: wrong management of the bounds of the figures;
-- fixed: North-East-South-West rectangle's delimiters where managed with squares;
-- fixed: problem of approximations in the code generator methods: values
- like 10E-4 could appeared;
-- fixed: problem when drawing a line, in the setLastPoint method;
-- fixed: a bug in the method line.findPoints(Point p, double distance) with
- horizontal line;
-- fixed: in the method Figure.getBordersPoint(int), if id=-1, the function didn't
- return the good point;
-- fixed: It was possible to create a polygon with 2 points; it's not the goal of
- a polygon but a line;
-- fixed: with wedge and pie, the interiors line were not managed in the isIn method;
-- fixed: the borders of a text were too small;
-- fixed: when launch a new project, the name of the former project still remain;
-- fixed: print draw: if several figures were selected, they weren't printed;
-- fixed: print draw: zoom was activated;
-- fixed: when export as PSTricks, the code was not updated;
-- fixed: Delimiter write method didn't save the dimension of the delimiter;
-- fixed: PSTricks position of a text was wrong;
-- fixed: error when redo;
-- fixed: the draw method of a dot didn't display round shape well;
-- fixed: bug with links in the help frame;
-- fixed: Figure class could not be deserialisable;
-- fixed: several minor bugs;
-- improvement: new icons;
-- improvement: improvement of the exceptions management;
-- improvement: changes in the parameters toolbar;
-- improvement: use of spinners;
-- improvement: new kind of buttons;
-- improvement: code optimisations (thanks to Eclipse);
-- improvement: a lots of more parameters for figures;
-- improvement: "showpoints" function is now enable for arc;
-- improvement: arrowheads for arc;
-- improvement: the PSTricks code is updated only on the mouse released (speed
- optimisation);
-- added: a panel is into the parameters frames in order to have a glimpse
- of the modified figure;
-- added: new figure, grid;
-- added: hatching management;
-- added: can join/separate several figures;
-- added: can create and import patterns (groups of figures) ;
-- added: new figure, Bézier curve;
-- added: a frame for the properties of the draw: can add label, caption, position;
-- added: double boundary;
-- added: the borders of the figures can be in the position "inner", "outer" or "middle";
-- added: a button in the codepanel in order to close the panel;
-- added: a button to copy all the text and one to copy the selected text in the clipboard.
-
-
-**************************************************************************************
-Version 1.0.2 - 10/22/2005:
-
-- TeXDraw is now LaTeXDraw
-- fixed: bug in the polygon code generation method
-- fixed: bug in all code generation methods
-- fixed: bug in the ellipse, circle, arc code generation methods
-
-
-
-**************************************************************************************
-Version 1.0.1 - 10/10/2005:
-
-- fixed: bug with isModified attribute
-- fixed: a possible bug with open/save actions
+- fixed: selection did not always work with arcs and Bézier curves.
+
+PSTricks parser 0.4:
+
+- added: \pspicture and \endpspicture are managed;
+- added: \normalcolor is managed;
+- added: arrows=<-| is managed;
+
+- fixed: an invalid \begin{pspicture} command must launch a fatal error;
+- fixed: unknown command not always well parsed;
+- fixed: a single end{pspicture} command must launch a fatal error;
+
+
+****************************************************************************
+Version 1.9.1 - April 4th 2007
+
+- added: more shortcuts:
+ - "space" selects the first or the next figure (in selection mode);
+ - ctrl+mouse wheel zoom in/out;
+- added: comment explaining how to rescale the whole drawing (request #1628137);
+
+- improvement: can change the parameters of several selected figures in the
+ same time;
+- improvement: can define the parameters before creating a figure;
+- improvement: all the frames can be easily resized;
+- improvement: the definition of a dot is almost totally rewritten to improve
+ the selection and to fix several bugs;
+
+- fixed #1681687: the parameters toolbar is not updated when importing a tex file;
+- fixed #1690426: figure not deleted when cancelling its creation with to top-right button;
+- fixed #1691145: freezes when a wrong file is given in command line;
+- fixed: exception in some cases when the frame of parameters of a dot is open;
+- fixed: the selection of figures works better now;
+- fixed: a rotated dot doesn't correctly move after loading a project;
+- fixed: problem when exporting a drawing as picture;
+- fixed: the drawing is no more affected when the number of pixels per
+ cm changes (only the generated code);
+- fixed: problem when redoing after having cut several figures;
+- fixed: the size of the ellipse framed box was badly computed;
+- fixed: minor bugs.
+
+
+****************************************************************************
+Version 1.9 - February 8th 2007
+
+- added: a splash screen;
+- added: recent files manager;
+- added: more shortcuts:
+ - ctrl+A select all the figures;
+ - ctrl/shift key can be used to add/remove a figure to the selection;
+ - can move scrollbars and figures with left, up, shift,...;
+- added: can update figures to the displayed grid;
+- added: a shortcuts frame;
+- added: when the code panel is closed, a button, copying the all the generated
+ code, is visible in the toolbar;
+- added: a menu item to set visible all the hidden figures;
+- added: can choose the look and feel;
+- added: can change the transparency of the delimiters;
+- added: a menu to check update;
+- added: a popup menu to cut/paste/copy text from/to "insert PSTricks code" and
+ "add comment" frames;
+- added: "move"/"resize/rotate" cursor is displayed when move/resize/rotate figures;
+- added: "code" menu now contains all code options;
+
+- improvement: free hand can be either curves or lines;
+- improvement: free hand can be closed or opened;
+- improvement: you can define the interval between each point of free hand;
+- improvement: akin points can be dotted/dashed;
+- improvement: akin points can be filled/hatched and can have a gradient;
+- improvement: a Bézier curve can be closed with a line or a curve;
+- improvement: can equilibrate the control points of a Bézier curve;
+- improvement: update jiu to 0.14.1;
+- improvement: a right-click doesn't remove the last point anymore (during the
+ creation of a polygon/joined-lines/Bézier curve;
+
+- fixed #1621630: figures were not updated to the magnetic grid when rotated;
+- fixed #1621632: a very small rectangle can disappear when rotated of 90°;
+- fixed #1621633: cannot select a too small rectangle;
+- fixed #1621634: the selection of a text without framed box didn't work very well;
+- fixed #1621635: figures not always follow the magnetic grid when dragged;
+- fixed #1624345: cannot stop the creation of a polygon on Mac (mouse has one button);
+- fixed #1644659: the main frame lost the focus when a ListJToogleButton is displayed;
+- fixed #1644660: the gravity centre of a set of figures was badly computed;
+- fixed #1644660: polygons move when violently rotated;
+- fixed #1644662: problem when closing and displaying the code panel;
+- fixed #1644663: the parameters of the second arrow of joined lines/Bézier curve are never generated;
+- fixed #1645157: joined-lines are automatically filled when having a shadow;
+- fixed #1645158: space between dots of a dotted polygon with double boundaries was badly computed;
+- fixed #1645160: the fact that a dot can be filled or not was badly managed;
+- fixed: the size of delimiters (polygons, Bézier curves) aren't always updated;
+- fixed: arrows are not moved when mirrors are used (Bézier curve);
+- fixed: cut and paste doesn't work;
+- fixed: for axes, in some cases the labels are badly placed;
+- fixed: a lot of minor bugs;
+
+PSTricks parser 0.3:
+- added: \begin{figure} and \begin{center} are managed;
+- added: \pscustom is partially managed;
+
+- improvement: Can parse a Bézier curve with more than two points;
+- improvement: squared psframe is now converted in square;
+- improvement: arc with a line at the start to the end point is transformed in chord;
+
+
+***********************************************************************************
+Version 1.8.2 - November 15th 2006
+
+- fixed #1580023: the printed code doesn't take care about the width of the page;
+- fixed #1538675: Bézier curve/polygons/joined lines still rotate badly;
+- fixed #1581400: you can select a empty Bézier curve by clicking at the interior;
+- fixed #1591309: borders of a Bézier curve were not displayed;
+- fixed #1591310: can move a figure by using its borders;
+- fixed #1593762: parameters panel - undo has no effect when modifying a Bézier curve;
+- fixed #1591312: not enable to select a too small rectangle/ellipse;
+- fixed #1596421: a too small rectangle/ellipse is not visible;
+- fixed # : we must not be able to select a figure with its shadow;
+- fixed # : can select joinedlines/arc with the line joining their extremities;
+- fixed: minor bugs.
+
+PSTricks parser 0.2.3:
+- fixed #1579820: parser freezes when the code has { ... };
+- fixed #1586013: problem when parsing a line or a polygon like \psline(2,2)(2,2)(2,2).
+
+
+***********************************************************************************
+Version 1.8.1 - October 17th 2006
+
+- fixed #1554750: problem with round corner (frame and square);
+- fixed #1561789: "code autoupdate" field (in the preferences frame) had not effect;
+- fixed #1562954: problem with the look & feel "metal";
+- fixed #1564478: vertical mirror was horizontal mirror for text;
+- fixed #1564477: picture was not moved when using mirrors;
+- fixed #1573703: problem with checkboxes and jre 1.5.0_09 with XP look & feel;
+- fixed #1508200: delimiters of triangles and rhombus are sometimes badly updated;
+- fixed #1538675: polygons move when rotating violently;
+- fixed #1508202: Bézier curves rotate badly;
+- fixed: a lot of minor bugs.
+
+PSTricks parser 0.2.2:
+- fixed #1573706: problem when having both unit and xunit/yunit in the parameters.
+
+
+***********************************************************************************
+Version 1.8 - September 13th 2006
+
+- added: new localisation, Spanish;
+- added: new shape, axes;
+- added: magnetic grid;
+- added: mirrors to move figures;
+- added: buttons to rotate figures of 90, 180 and 270°;
+- added: a button to launch your LaTeX editor;
+
+- improvement: the help can be loaded with you browser: help/index.html;
+- improvement: Bézier curve can have arrows;
+- improvement: a button to close the mini-toolbars;
+- improvement: Bézier curve can have a double boundary;
+- improvement: Bézier curve can be filled, hatched and can have a gradient;
+- improvement: an arrow with the 'dot' shape can have its interior colour changed;
+- improvement: hatchsep attribute is managed;
+- improvement: new "About LaTeXDraw" frame;
+
+- fixed #1555339: the ilk of an arc (open, pie or chord) was never saved;
+- fixed #1554729: dotted/dashed double line has not it good background colour (for polygon);
+- fixed #1554162: the borders of the drawing are not always updated (with auto adjustment
+ disable);
+- fixed #1553683: with command line, preferences and templates are not loaded;
+- fixed #1540561: crashing when launching the help;
+- fixed #1536603: eps exported files were not vectorial;
+- fixed #1528919: shadow for a polygon with double boundary is too small;
+- fixed #1528562: joined lines parameters frame: a change has no effect;
+- fixed #1538724: bad rotation in the frame of parameters of a drawing;
+- fixed #1547234: the 'draw labels' checkbox doesn't work very well in the frame
+ of parameters of the grid;
+- fixed #1547235: default buttons did not always reinitialise values;
+- fixed #1547236: crashing when clicking on the default button of the dot frame;
+- fixed #1547239: round panel, for rectangle and square, is not always visible;
+- fixed #1548699: with JRE 1.5_08, the buttons of the toolbars are too big;
+- fixed #1556362: sometimes LaTeXDraw froze at startup when it checked new version;
+- fixed #1557509: vertical and horizontal line can be difficulty selected;
+- fixed: minor bugs.
+
+PSTricks parser 0.2.1:
+- added: axes management;
+
+- fixed #1556340: rotation angle was not managed (since 1.7) for triangle;
+- fixed #1556544: inversion of positions between X-labels and Y-labels;
+- fixed #1556548: a rotated grid (with unit not equal to 1) was badly placed.
+
+
+**************************************************************************************
+Version 1.7 - July 23th 2006
+
+- added: shadow management;
+- added: colour shifting management;
+- added: framed box management;
+- added: buttons in the frames of parameters to zoom in/out the figure;
+
+- improvement: the background of a text can be opaque;
+- improvement: polygons can have doubles lines;
+- improvement: can change the size of the rounds corners for rectangles and squares;
+- improvement: the frames of parameters have a better interface;
+- improvement: gif can be included or converted;
+- improvement: batch conversion: a check box define if the pictures must be converted
+ in their directory or not;
+- improvement: new icons;
+
+- fixed #1404791: when refreshing the templates, there thumbnails were not updated;
+- fixed #1487192: when a frame of parameters is opened, the figure can be deleted or modified;
+- fixed #1481272: the colour of the interior of the arrows with the circle shape must be as the
+ interior of the figure;
+- fixed #1487185: scrollbars are not updated when changing the font or the size of a text;
+- fixed #1489350: the size of a text change when zooming in and zooming out;
+- fixed #1489644: scrollbars of the parameters frame of grids are not always updated.
+- fixed #1489551: labels of grids and texts are not resized when you change the number
+ of pixels per cm/inch of the draw;
+- fixed #1502040: when subgriddiv=1, borders must not be drawn;
+- fixed #1502043: some defaults values of lines' parameters were false;
+- fixed #1502048: for arcs, the start angle can be greater than the end angle to avoid problems
+ during the drawing and the parsing (\pswedge(2,1){1.5}{300}{200});
+- fixed #1502046: for Bézier curves, the controls points had a wrong size;
+- fixed #1502049: we must be able to fill the dot shape 'o';
+- fixed #1512530: LaTeXDraw files containing picture cannot be loaded;
+- fixed #1512533: undo/redo: bad undo management when creating and cancelling a text/grid;
+- fixed #1512537: undo/redo: toolbar still active when redo a 'delete' action ;
+- fixed #1512538: undo/redo: the redo was never cleared when an action, different than
+ redo, occurred;
+- fixed #1515149: bug in the method Line.getPerpendicularLine(): when the x-coordinate of a
+ point of a triangle/rhombus is 0 a problem in the display occurred;
+- fixed #1516288: % not always replaced by \% during the code generation;
+- fixed #1523877: when a file is loaded, the undo/redo manager is not cleared;
+- fixed #1524381: batch conversion: output path was never used;
+- fixed #1525086: for rhombus, hatchings did not rotate because of gangle;
+- fixed #1526315: when "show points" option for a Bézier curve is selected, the curve must
+ be dashed too;
+- fixed # : exception in Polygon.getBorders when three points have the same X-coordinate;
+- fixed: minor bugs.
+
+
+PSTricks parser 0.2:
+- added: shadow management;
+- added: colour shifting management;
+- added: framed box management;
+- added: millimetres are managed;
+- added: support +1 number (positive sign);
+- added: support numbers like ++++1, -----1, ++-+--+1;
+- added: support unit parameter;
+
+- fixed #1488716: linewidth=-1 must be understood as linewidth=1, idem for dotsize, ...;
+- fixed #1502052: for lines and arcs, arrows were not read in some cases (\psline{*->}(0,3)(5,5));
+- fixed #1502053: dots was never filled;
+- fixed #1502711: when parsing a polygon with only two points, the third point was not created;
+- fixed #1502712: parsing the command \psset{origin={1,1}} launched an exception;
+- fixed #1502713: coordinate like (1pt, 2in) and size like {1cm} must be parsed;
+- fixed #1502714: when insert PSTricks code with \begin{pspicture} in comment, this commented
+ command was understood like an uncommented command;
+- fixed #1502715: the format \pswedge{3}{0}{70} was not supported;
+- fixed #1515871: when you insert pstricks code like \begin{center}\begin{pspicture} the
+ \begin{pspicture} was ignored;
+- fixed #1516165: the \% command was ignored;
+- fixed #1519847: pink colour not managed;
+- fixed #1519934: text not always parsed;
+- fixed #1520384: \bf and \it have no effect;
+- fixed #1523726: error during the parsing of the command \psgrid; for instance \rput(0,0){\psgrid}
+ didn't work.
+
+
+**************************************************************************************
+Version 1.6 - May 2nd 2006:
+
+WARNING: YOU MUST REPLACE THE FORMER 'Classic grid.ldp' OF THE TEMPLATES DIRECTORY BY THE NEW
+ 'Classic grid.ldp' OF THE LaTeXDraw1.6_bin.zip.
+
+- fixed: several fields were exported to be localisable, while they should not to be (1);
+- fixed: polygon: borders was not updated when the thickness was changed;
+- fixed: problem when check the version of the preferences file;
+- fixed: grids did not rotate very when rotating several figures;
+- fixed: when paste, the scrollbars were not updated;
+- fixed: the grid was exported with the draw;
+- fixed: the packages \usepackage{color} and \usepackage{pstricks} are replaced by
+ \usepackage[usenames,dvipsnames]{pstricks};
+- fixed: "move figure" was badly managed by the undo/redo manager;
+- fixed: a problem when resize several selected figures containing polygons or
+ derived figures;
+- fixed: when loading a file, the delimiters of severals figures were not updated;
+- fixed: when paste, toolbar was still activated;
+- fixed: for rectangles, delimiters were not updated when paste;
+- fixed: for circles and ellipses, borders were not updated when the thickness changed;
+- fixed: toolbar was still activated when click in a empty place when searching a figure
+ to put behind/in front;
+- fixed: \caption{fig: is replaced by \caption{;
+- fixed: { and } were replaced by \string \{ ... So no command was possible;
+- fixed: the description of the draw was not saved (label, caption ,...);
+- fixed: when load a file with comments, the comments are too much '%';
+- fixed: the borders of the selection was not updated when pasted several texts;
+- fixed: not able to have French translation;
+- fixed: the borders of the texts and of the grids were not always updated -> bad
+ position of texts;
+- fixed: if a text was empty, you could not select it but it existed in the code panel;
+- fixed: problem in the management of the position of grids;
+- fixed: grids had not read/write stream methods (2);
+- fixed: when change a coordinate in a parameters frame and close the frame, the modified
+ figure is not updated whereas;
+- fixed: glimpse figures (rectangle, square, ..) were not updated when change their width, ...
+ in their parameters frame;
+- fixed: the grid was exported when exporting in eps;
+- fixed: in several cases, a figure does not rotate when the angle is 180°;
+- fixed: figures can move during the resizement of several polygons ;
+- fixed: the zoom was not managed when loading a file;
+- fixed: "dot-in" arrows change of position when the arrows is moved;
+- fixed: space between a double arrow must be like the arrows not like the line;
+- fixed: one of the doubles arrows for arc was not updated by the parameters of the arrow;
+- fixed: if the arrows are of the same kind, there parameters must be the same;
+- fixed: when you save a drawing and a figure is selected, it was hardly to unselect it;
+- fixed: it was possible to have an code for arrows like '{>>--}...' instead of '{>>-}';
+- fixed: space between two lines of an hatching was badly managed;
+- fixed: problem when copy/paste a rhombus or a triangle;
+- fixed: problem when editing points of rhombus/triangle with their frame of parameters;
+- fixed: scrollbars not updated when cut/delete the unique figure of a drawing;
+- fixed: problem when resize several figures;
+- fixed: option "showpoints" was not save for arcs;
+- fixed: several minor bugs;
+- improvement: for dot, 'rput' is replaced by 'dotangle';
+- improvement: more shapes for arrows: )-( and ]-[ are managed;
+- improvement: better management of the arrowheads and the grids;
+- improvement: for rhombus, 'rput' is replaced by 'gangle';
+- improvement: can change the position of the labels of the grids;
+- improvement: CPU, memory, speed optimisation;
+- improvement: akin points code generator generates less points;
+- added: export as PNG;
+- added: export as BMP;
+- added: export as PPM;
+- added: can insert pictures;
+- added: new figure, joined lines;
+- added: LaTeXDraw can be used to convert jpeg|png|wmf|bmp|ppm pictures in
+ eps|jpeg|png|ppm pictures with a batch processing;
+- added: the LaTeXDraw manual;
+- added: import PSTricks code (PSTricks parser version 0.1);
+- added: can insert PSTricks code in a draw (use the PSTricks parser).
+
+
+- regression: if, you load a saved project with 1.5.1 or 1.5.1.1 , the language is
+ French and several figures of the draw have doubles boundaries, then
+ the position of the doubles boundaries will be always 'inner'; because
+ of the bug (1);
+- regression: because of the bug (2), LaTeXDraw can not open file from 1.5.1.1 and older
+ with grids. By the same way, old templates with grids are not compatible with
+ LaTeXDraw 1.6.
+
+
+**************************************************************************************
+Version 1.5.1.1 - January 28th 2006:
+
+- fixed: minor bug with the isModified attribute;
+- fixed: ellipse didn't rotate very well;
+- fixed: error during the read of templates: templates could not be loaded;
+- fixed: when put '%' in comments or in a text, it was considered as a start of a
+ comment by the TeX parser;
+- fixed: when a '\' was in a text, the label, ... it was considered as a command;
+- fixed: an exception appeared during the selection of figures when the draw was empty;
+- fixed: display->grid was not updated when change the unit of length (always in cm);
+- fixed: an exception occurred when drawing a triangle;
+- fixed: borders could not move;
+- fixed: problem when clicking on a triangle or on a rhombus;
+- fixed: problem when change a triangle or a rhombus;
+- fixed: the rectangle was not updated when dragging one of these delimiters;
+- fixed: polygon generate now a pspolygon, not a psline;
+- fixed: error when testing the version of the software.
+
+
+
+**************************************************************************************
+Version 1.5.1 - January 20th 2006:
+
+- fixed: figure id could be as big as 12982109 for example;
+- fixed: params button was active when several figures were selected;
+- fixed: the rotation of several selected or joined figures didn't
+ rotated the gravity centre of these figures;
+- fixed: error when shifting a triangle or a rhombus (shift method
+ not overridden);
+- fixed: a dotted line began before the first point;
+- fixed: the delimiters of a square could not be selected (pb in isIn);
+- fixed: isModified was activated when we confirmed preferences frame;
+- fixed: a problem when loading a template from former version;
+- fixed: arc choice created a problem of display in the parameters frame;
+- fixed: cut/paste managed in the undo/redo;
+- fixed: cut figures didn't remove them from the selection;
+- fixed: change cm to inch, didn't update the scales;
+- fixed: an error when initialise components of the square parameters frame;
+- fixed: dble boundaries weren't filled very well with round rectangle/square;
+- fixed: getBorders(..) not overridden in the class BézierCurve;
+- fixed: menu "export as template" was never activated;
+- improvement: better rotation of the figures;
+- improvement: CPU, memory, speed optimisation;
+- improvement: better management of the resizing of rotated figures;
+- added: can check new version;
+- added: status bar;
+- added: support localisation;
+- added: new localisation, French.
+
+
+**************************************************************************************
+Version 1.5 - January 13th 2006:
+
+- fixed: bug in intersect method;
+- fixed: bug with the default button in the parameters frames;
+- fixed: when we click the button default during the creation of a text or a
+ grid, the figure wasn't deleted;
+- fixed: bug when saving parameters of a line in the parameters frame;
+- fixed: problem with the rescale methods;
+- fixed: minor bug in the code generation methods with the interior colour;
+- fixed: an horizontal line cannot be selected with the rectangle selector;
+- fixed: in the draw method of ArrowHead; round bracket used wrong attribute;
+- fixed: bugs in the ArrowHead code generator method;
+- fixed: bug in the arc code generator method;
+- fixed: problem when resize several figures containing at least a non-resizable
+ figure like grid or text;
+- fixed: problem during the first selection akin points: the borders were wrong;
+- fixed: problem when resize several figures after a rotation;
+- fixed: wrong management of the bounds of the figures;
+- fixed: North-East-South-West rectangle's delimiters where managed with squares;
+- fixed: problem of approximations in the code generator methods: values
+ like 10E-4 could appeared;
+- fixed: problem when drawing a line, in the setLastPoint method;
+- fixed: a bug in the method line.findPoints(Point p, double distance) with
+ horizontal line;
+- fixed: in the method Figure.getBordersPoint(int), if id=-1, the function didn't
+ return the good point;
+- fixed: It was possible to create a polygon with 2 points; it's not the goal of
+ a polygon but a line;
+- fixed: with wedge and pie, the interiors line were not managed in the isIn method;
+- fixed: the borders of a text were too small;
+- fixed: when launch a new project, the name of the former project still remain;
+- fixed: print draw: if several figures were selected, they weren't printed;
+- fixed: print draw: zoom was activated;
+- fixed: when export as PSTricks, the code was not updated;
+- fixed: Delimiter write method didn't save the dimension of the delimiter;
+- fixed: PSTricks position of a text was wrong;
+- fixed: error when redo;
+- fixed: the draw method of a dot didn't display round shape well;
+- fixed: bug with links in the help frame;
+- fixed: Figure class could not be deserialisable;
+- fixed: several minor bugs;
+- improvement: new icons;
+- improvement: improvement of the exceptions management;
+- improvement: changes in the parameters toolbar;
+- improvement: use of spinners;
+- improvement: new kind of buttons;
+- improvement: code optimisations (thanks to Eclipse);
+- improvement: a lots of more parameters for figures;
+- improvement: "showpoints" function is now enable for arc;
+- improvement: arrowheads for arc;
+- improvement: the PSTricks code is updated only on the mouse released (speed
+ optimisation);
+- added: a panel is into the parameters frames in order to have a glimpse
+ of the modified figure;
+- added: new figure, grid;
+- added: hatching management;
+- added: can join/separate several figures;
+- added: can create and import patterns (groups of figures) ;
+- added: new figure, Bézier curve;
+- added: a frame for the properties of the draw: can add label, caption, position;
+- added: double boundary;
+- added: the borders of the figures can be in the position "inner", "outer" or "middle";
+- added: a button in the codepanel in order to close the panel;
+- added: a button to copy all the text and one to copy the selected text in the clipboard.
+
+
+**************************************************************************************
+Version 1.0.2 - 10/22/2005:
+
+- TeXDraw is now LaTeXDraw
+- fixed: bug in the polygon code generation method
+- fixed: bug in all code generation methods
+- fixed: bug in the ellipse, circle, arc code generation methods
+
+
+
+**************************************************************************************
+Version 1.0.1 - 10/10/2005:
+
+- fixed: bug with isModified attribute
+- fixed: a possible bug with open/save actions
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/latexdraw.git
More information about the pkg-java-commits
mailing list