|
From: <de...@us...> - 2012-10-04 22:36:04
|
Revision: 7704
http://fudaa.svn.sourceforge.net/fudaa/?rev=7704&view=rev
Author: deniger
Date: 2012-10-04 22:35:58 +0000 (Thu, 04 Oct 2012)
Log Message:
-----------
am?\195?\169lioration des courbes: labels verticaux, banni?\195?\168res...
Modified Paths:
--------------
trunk/framework/ebli-common/src/main/java/org/fudaa/ebli/trace/TraceBox.java
trunk/framework/ebli-common/src/main/resources/org/fudaa/ebli/ressource/ebli_en.fr_txt
Modified: trunk/framework/ebli-common/src/main/java/org/fudaa/ebli/trace/TraceBox.java
===================================================================
--- trunk/framework/ebli-common/src/main/java/org/fudaa/ebli/trace/TraceBox.java 2012-10-04 21:32:58 UTC (rev 7703)
+++ trunk/framework/ebli-common/src/main/java/org/fudaa/ebli/trace/TraceBox.java 2012-10-04 22:35:58 UTC (rev 7704)
@@ -9,9 +9,11 @@
import com.memoire.fu.FuLib;
import java.awt.Color;
+import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
+import java.awt.geom.AffineTransform;
import javax.swing.SwingConstants;
@@ -22,12 +24,13 @@
* @author Fred Deniger
* @version $Id: TraceBox.java,v 1.5 2006-09-19 14:55:49 deniger Exp $
*/
-public class TraceBox extends AbstractTraceBoxedData{
+public class TraceBox extends AbstractTraceBoxedData {
private Color colorFond_;
private Color colorBoite_;
private Color colorText_;
private boolean drawBox_;
+ private boolean vertical;
private boolean drawFond_;
private int hMargin_;
private TraceLigne traceLigne_;
@@ -51,6 +54,14 @@
return colorFond_;
}
+ public boolean isVertical() {
+ return vertical;
+ }
+
+ public void setVertical(boolean vertical) {
+ this.vertical = vertical;
+ }
+
public Color getColorBoite() {
if (colorBoite_ == null) {
colorBoite_ = Color.BLACK;
@@ -69,7 +80,6 @@
return hMargin_;
}
-
public TraceLigne getTraceLigne() {
return traceLigne_;
}
@@ -78,7 +88,6 @@
return vMargin_;
}
-
public boolean isDrawBox() {
return drawBox_;
}
@@ -92,26 +101,45 @@
paintBox(_g2d, _x, _y, _s, null);
}
+ public int getTotalHeightMargin() {
+ return 2 * hMargin_ + (int) (2 * traceLigne_.getEpaisseur());
+ }
+
+ public int getTotalWidthMargin() {
+ return 2 * hMargin_ + (int) (2 * traceLigne_.getEpaisseur());
+ }
+
+ public Dimension getDimension(final Graphics2D _g2d, final String _s) {
+ if (traceLigne_ == null) {
+ traceLigne_ = new TraceLigne();
+ }
+ final FontMetrics fm = _g2d.getFontMetrics();
+ String[] lines = FuLib.split(_s, '\n');
+ final int fontHeight = fm.getHeight();
+ final int hString = (fontHeight) * lines.length + (lines.length - 1) * vMargin_;
+ int wString = getMaxStringWith(fm, lines);
+ int hOuter = hString + getTotalHeightMargin();
+ int wOuter = wString + getTotalWidthMargin();
+ if (vertical) {
+ int tmp = hOuter;
+ hOuter = wOuter;
+ wOuter = tmp;
+ }
+ return new Dimension(wOuter, hOuter);
+ }
+
public void paintBox(final Graphics2D _g2d, final int _x, final int _y, final String _s, Rectangle view) {
+ Dimension dimension = getDimension(_g2d, _s);
+ int hOuter = dimension.height;
+ int wOuter = dimension.width;
if (traceLigne_ == null) {
traceLigne_ = new TraceLigne();
}
final FontMetrics fm = _g2d.getFontMetrics();
String[] lines = FuLib.split(_s, '\n');
final int fontHeight = fm.getHeight();
-// int[] width = new int[lines.length];
final int hString = (fontHeight) * lines.length + (lines.length - 1) * vMargin_;
- int wString = fm.stringWidth(lines[0]);
-// width[0] = wString;
- for (int i = 0; i < lines.length; i++) {
- final int stringWidth = fm.stringWidth(lines[i]);
-// width[i] = stringWidth;
- wString = Math.max(stringWidth, wString);
- }
- final int hInner = hString + 2 * hMargin_;
- final int wInner = wString + 2 * vMargin_;
- final int hOuter = hInner + (int) (2 * traceLigne_.getEpaisseur());
- final int wOuter = wInner + (int) (2 * traceLigne_.getEpaisseur());
+ int wString = getMaxStringWith(fm, lines);
int xTopLeft = _x;
if (hPosition_ == SwingConstants.CENTER) {
xTopLeft -= wOuter / 2;
@@ -142,10 +170,17 @@
_g2d.setColor(getColorText());
final int x = xTopLeft + wOuter / 2 - wString / 2;
final int stringTopLeft = yTopLeft + hOuter / 2 - hString / 2;
+ AffineTransform save = null;
+ if (vertical) {
+ save = _g2d.getTransform();
+ _g2d.rotate(-Math.PI / 2, xTopLeft + wOuter / 2, yTopLeft + hOuter / 2);
+ }
for (int i = 0; i < lines.length; i++) {
_g2d.drawString(lines[i], x, stringTopLeft + (i + 1) * fontHeight + (i - 1) * vMargin_ - fm.getDescent());
-
}
+ if (save != null) {
+ _g2d.setTransform(save);
+ }
}
@@ -173,7 +208,6 @@
hMargin_ = _margin;
}
-
public void setTraceLigne(final TraceLigne _traceLigne) {
traceLigne_ = _traceLigne;
}
@@ -182,7 +216,6 @@
vMargin_ = _margin;
}
-
public TraceBox duplicate() {
TraceBox duplic = new TraceBox();
duplic.colorBoite_ = this.colorBoite_;
@@ -198,4 +231,13 @@
return duplic;
}
-}
\ No newline at end of file
+
+ private int getMaxStringWith(final FontMetrics fm, String[] lines) {
+ int wString = fm.stringWidth(lines[0]);
+ for (int i = 0; i < lines.length; i++) {
+ final int stringWidth = fm.stringWidth(lines[i]);
+ wString = Math.max(stringWidth, wString);
+ }
+ return wString;
+ }
+}
Modified: trunk/framework/ebli-common/src/main/resources/org/fudaa/ebli/ressource/ebli_en.fr_txt
===================================================================
--- trunk/framework/ebli-common/src/main/resources/org/fudaa/ebli/ressource/ebli_en.fr_txt 2012-10-04 21:32:58 UTC (rev 7703)
+++ trunk/framework/ebli-common/src/main/resources/org/fudaa/ebli/ressource/ebli_en.fr_txt 2012-10-04 22:35:58 UTC (rev 7704)
@@ -850,4 +850,6 @@
L\xE9gende calque=Layer legend
S\xE9lectionnez l'emplacement de votre projet=Select the location of your project
Configurer les courbes=Configure curves
-Ajouter des points=Add points
\ No newline at end of file
+Ajouter des points=Add points
+Afficher les labels des points=Display points label
+Labels verticaux=Vertical labels
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|