|
From: <de...@us...> - 2013-03-18 16:37:44
|
Revision: 8333
http://fudaa.svn.sourceforge.net/fudaa/?rev=8333&view=rev
Author: deniger
Date: 2013-03-18 16:37:37 +0000 (Mon, 18 Mar 2013)
Log Message:
-----------
Modified Paths:
--------------
trunk/framework/ebli-common/src/main/java/org/fudaa/ebli/trace/TraceImage.java
Modified: trunk/framework/ebli-common/src/main/java/org/fudaa/ebli/trace/TraceImage.java
===================================================================
--- trunk/framework/ebli-common/src/main/java/org/fudaa/ebli/trace/TraceImage.java 2013-03-18 16:37:11 UTC (rev 8332)
+++ trunk/framework/ebli-common/src/main/java/org/fudaa/ebli/trace/TraceImage.java 2013-03-18 16:37:37 UTC (rev 8333)
@@ -12,8 +12,8 @@
import java.awt.Rectangle;
import java.awt.image.ImageObserver;
import javax.swing.Icon;
-
import javax.swing.SwingConstants;
+import org.fudaa.ebli.geometrie.GrBoite;
/**
* Une classe permettant de dessiner un icone externe en le positionnant horizontalement/verticalement
@@ -32,24 +32,8 @@
public void paintIcon(final Graphics2D _g2d, final int _x, final int _y, Icon icon, Rectangle view) {
final int hInner = icon.getIconHeight();
final int wInner = icon.getIconWidth();
- int xTopLeft = _x;
- if (hPosition_ == SwingConstants.CENTER) {
- xTopLeft -= wInner / 2;
- } else if (hPosition_ == SwingConstants.RIGHT) {
- xTopLeft -= wInner;
- }
- int yTopLeft = _y;
- if (vPosition_ == SwingConstants.CENTER) {
- yTopLeft -= hInner / 2;
- } else if (vPosition_ == SwingConstants.BOTTOM) {
- yTopLeft -= hInner;
- }
- if (view != null) {
- xTopLeft = Math.min(view.x + view.width - wInner, xTopLeft);
- yTopLeft = Math.min(view.y + view.height - hInner, yTopLeft);
- xTopLeft = Math.max(xTopLeft, view.x);
- yTopLeft = Math.max(yTopLeft, view.y);
- }
+ int xTopLeft = getXTopLeft(_x, wInner, view);
+ int yTopLeft = getYTopLeft(_y, hInner, view);
icon.paintIcon(null, _g2d, xTopLeft, yTopLeft);
}
@@ -57,12 +41,57 @@
public void paintImage(final Graphics2D _g2d, final int _x, final int _y, Image image, Rectangle view, ImageObserver observer) {
final int hInner = image.getHeight(observer);
final int wInner = image.getWidth(observer);
+ int xTopLeft = getXTopLeft(_x, wInner, view);
+ int yTopLeft = getYTopLeft(_y, hInner, view);
+ _g2d.drawImage(image, xTopLeft, yTopLeft, observer);
+ }
+
+ /**
+ *
+ * @param iconBoite une boite a initialiser. si null, une nouvelle instance est cr\xE9\xE9e
+ * @param icon l'icon pour avoir largeur/hauteur
+ * @param x x dessin\xE9
+ * @param y y dessine
+ * @return la boite dans laquelle l'icone sera dessin\xE9 en coordonn\xE9es \xE9cran
+ */
+ public GrBoite getBoite(GrBoite iconBoite, Icon icon, int x, int y) {
+ GrBoite res = iconBoite;
+ if (res == null) {
+ res = new GrBoite();
+ }
+ res.e_ = null;
+ res.o_ = null;
+ final int hInner = icon.getIconHeight();
+ final int wInner = icon.getIconWidth();
+ int xTopLeft = getXTopLeft(x, wInner, null);
+ int yTopLeft = getYTopLeft(y, hInner, null);
+ res.ajuste(xTopLeft, yTopLeft, 0);
+ res.ajuste(xTopLeft + icon.getIconWidth(), yTopLeft + icon.getIconHeight(), 0);
+ return res;
+ }
+
+ public TraceImage duplicate() {
+ TraceImage duplic = new TraceImage();
+ duplic.hPosition_ = this.hPosition_;
+ duplic.vPosition_ = this.vPosition_;
+ return duplic;
+ }
+
+ public int getXTopLeft(final int _x, final int wInner, Rectangle view) {
int xTopLeft = _x;
if (hPosition_ == SwingConstants.CENTER) {
xTopLeft -= wInner / 2;
} else if (hPosition_ == SwingConstants.RIGHT) {
xTopLeft -= wInner;
}
+ if (view != null) {
+ xTopLeft = Math.min(view.x + view.width - wInner, xTopLeft);
+ xTopLeft = Math.max(xTopLeft, view.x);
+ }
+ return xTopLeft;
+ }
+
+ public int getYTopLeft(final int _y, final int hInner, Rectangle view) {
int yTopLeft = _y;
if (vPosition_ == SwingConstants.CENTER) {
yTopLeft -= hInner / 2;
@@ -70,18 +99,9 @@
yTopLeft -= hInner;
}
if (view != null) {
- xTopLeft = Math.min(view.x + view.width - wInner, xTopLeft);
yTopLeft = Math.min(view.y + view.height - hInner, yTopLeft);
- xTopLeft = Math.max(xTopLeft, view.x);
yTopLeft = Math.max(yTopLeft, view.y);
}
- _g2d.drawImage(image, xTopLeft, yTopLeft, observer);
+ return yTopLeft;
}
-
- public TraceImage duplicate() {
- TraceImage duplic = new TraceImage();
- duplic.hPosition_ = this.hPosition_;
- duplic.vPosition_ = this.vPosition_;
- return duplic;
- }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|