|
From: <de...@us...> - 2013-03-14 15:49:28
|
Revision: 8327
http://fudaa.svn.sourceforge.net/fudaa/?rev=8327&view=rev
Author: deniger
Date: 2013-03-14 15:49:17 +0000 (Thu, 14 Mar 2013)
Log Message:
-----------
Modified Paths:
--------------
trunk/framework/ctulu-common/src/main/resources/org/fudaa/ctulu/ctulu_en.fr_txt
trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/action/ActionsInstaller.java
trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/action/MaximizeDialogAction.java
trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/action/MinimizeDialogAction.java
trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGAxeVertical.java
trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGCourbe.java
trunk/framework/ebli-common/src/main/java/org/fudaa/ebli/commun/EbliActionAbstract.java
Added Paths:
-----------
trunk/framework/ctulu-bu/src/main/resources/com/memoire/bu/down_left.png
trunk/framework/ctulu-bu/src/main/resources/com/memoire/bu/up_right.png
trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/action/SwitchMinMaxDialogAction.java
trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/border/
trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/border/BorderWithIcon.java
trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/border/BorderWithIconInstaller.java
Added: trunk/framework/ctulu-bu/src/main/resources/com/memoire/bu/down_left.png
===================================================================
(Binary files differ)
Property changes on: trunk/framework/ctulu-bu/src/main/resources/com/memoire/bu/down_left.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/framework/ctulu-bu/src/main/resources/com/memoire/bu/up_right.png
===================================================================
(Binary files differ)
Property changes on: trunk/framework/ctulu-bu/src/main/resources/com/memoire/bu/up_right.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/framework/ctulu-common/src/main/resources/org/fudaa/ctulu/ctulu_en.fr_txt
===================================================================
--- trunk/framework/ctulu-common/src/main/resources/org/fudaa/ctulu/ctulu_en.fr_txt 2013-03-14 08:20:13 UTC (rev 8326)
+++ trunk/framework/ctulu-common/src/main/resources/org/fudaa/ctulu/ctulu_en.fr_txt 2013-03-14 15:49:17 UTC (rev 8327)
@@ -330,4 +330,6 @@
L'URL n'est pas renseign\xE9e=The URL is not defined
Une incoh\xE9rence a \xE9t\xE9 d\xE9tect\xE9e\: le fichier xml est valide mais les balises {0} ne sont pas support\xE9es par l'application=A mismatch has been detected\: the xml file is valid but the application doesn't support the tag {0}
Erreur lors de la validation du fichier xml\: {0}=Error while validating the XML file\: {0}
-Indexation des points=Points indexation
\ No newline at end of file
+Indexation des points=Points indexation
+Restaurer la fen\xEAtre parente=Restore the parent window
+Maximiser la fen\xEAtre parente=Maximize the parent window
\ No newline at end of file
Modified: trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/action/ActionsInstaller.java
===================================================================
--- trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/action/ActionsInstaller.java 2013-03-14 08:20:13 UTC (rev 8326)
+++ trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/action/ActionsInstaller.java 2013-03-14 15:49:17 UTC (rev 8327)
@@ -3,12 +3,14 @@
*/
package org.fudaa.ctulu.action;
+import java.awt.event.KeyEvent;
import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.KeyStroke;
+import javax.swing.UIManager;
/**
*
@@ -23,6 +25,45 @@
updateMapKeyStrokeForButton(jc, new MinimizeDialogAction(jc), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
}
+ public static String getAcceleratorText(final KeyStroke _accelerator) {
+ String acceleratorDelimiter = UIManager.getString("MenuItem.acceleratorDelimiter");
+ if (acceleratorDelimiter == null) {
+ acceleratorDelimiter = "+";
+ }
+
+ final StringBuffer acceleratorText = new StringBuffer(50);
+ if (_accelerator != null) {
+ final int modifiers = _accelerator.getModifiers();
+ if (modifiers > 0) {
+ acceleratorText.append(KeyEvent.getKeyModifiersText(modifiers)).append(acceleratorDelimiter);
+ }
+
+ final int keyCode = _accelerator.getKeyCode();
+ if (keyCode == 0) {
+ acceleratorText.append(_accelerator.getKeyChar());
+ } else {
+ acceleratorText.append(KeyEvent.getKeyText(keyCode));
+ }
+ }
+ return acceleratorText.toString();
+ }
+
+ public static SwitchMinMaxDialogAction installAndCreateSwitchAction(JComponent jc) {
+ final MaximizeDialogAction maximizeDialogAction = new MaximizeDialogAction(jc);
+ updateMapKeyStrokeForButton(jc, maximizeDialogAction, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+ final MinimizeDialogAction minimizeDialogAction = new MinimizeDialogAction(jc);
+ updateMapKeyStrokeForButton(jc, minimizeDialogAction, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+ return new SwitchMinMaxDialogAction(jc, maximizeDialogAction, minimizeDialogAction);
+ }
+
+ public MaximizeDialogAction getRegisteredMaximizeAction(JComponent jc) {
+ return (MaximizeDialogAction) jc.getActionMap().get(MaximizeDialogAction.class);
+ }
+
+ public MinimizeDialogAction getRegisteredMinimizeAction(JComponent jc) {
+ return (MinimizeDialogAction) jc.getActionMap().get(MinimizeDialogAction.class);
+ }
+
public static void install(JDialog dialog) {
install(dialog.getRootPane());
}
Modified: trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/action/MaximizeDialogAction.java
===================================================================
--- trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/action/MaximizeDialogAction.java 2013-03-14 08:20:13 UTC (rev 8326)
+++ trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/action/MaximizeDialogAction.java 2013-03-14 15:49:17 UTC (rev 8327)
@@ -3,6 +3,7 @@
*/
package org.fudaa.ctulu.action;
+import com.memoire.bu.BuResource;
import java.awt.EventQueue;
import java.awt.Frame;
import java.awt.Rectangle;
@@ -11,13 +12,17 @@
import java.awt.event.ComponentListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
import javax.swing.AbstractAction;
import javax.swing.Action;
+import static javax.swing.Action.NAME;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
+import org.fudaa.ctulu.CtuluLib;
import org.fudaa.ctulu.gui.CtuluLibDialog;
/**
@@ -28,55 +33,108 @@
public static final String PROP_OLD_BOUNDS = "OLD_BOUNDS";
private final JComponent jc;
+ private SwitchMinMaxDialogAction switcher;
public MaximizeDialogAction(JComponent jc) {
+ super(CtuluLib.getS("Maximiser la fen\xEAtre parente"));
this.jc = jc;
putValue(Action.ACTION_COMMAND_KEY, getClass().getSimpleName());
- putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.ALT_DOWN_MASK));
+ final KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.ALT_DOWN_MASK);
+ putValue(Action.ACCELERATOR_KEY, keyStroke);
+ putValue(Action.SMALL_ICON, BuResource.BU.getIcon("up_right"));
+ putValue(Action.SHORT_DESCRIPTION, getValue(NAME) + " : " + ActionsInstaller.getAcceleratorText(keyStroke));
}
+ public SwitchMinMaxDialogAction getSwitcher() {
+ return switcher;
+ }
+
+ public void setSwitcher(SwitchMinMaxDialogAction switcher) {
+ this.switcher = switcher;
+ }
+
@Override
public void actionPerformed(ActionEvent e) {
final JDialog dialog = (JDialog) SwingUtilities.getAncestorOfClass(JDialog.class, jc);
if (dialog != null) {
+
Rectangle initBounds = dialog.getBounds();
-
Rectangle maximizedWindowBounds = CtuluLibDialog.getMaximizedWindowBounds(initBounds);
if (!maximizedWindowBounds.equals(initBounds)) {
- dialog.getRootPane().putClientProperty(PROP_OLD_BOUNDS, dialog.getBounds());
- dialog.setLocation(maximizedWindowBounds.getLocation());
- dialog.setSize(maximizedWindowBounds.getSize());
- EventQueue.invokeLater(new Runnable() {
- @Override
- public void run() {
- new DialogListener(dialog);
- }
- });
+ maximizeDialog(dialog, maximizedWindowBounds);
+ if (switcher != null) {
+ switcher.switchedToMax();
+ }
}
} else {
JFrame parent = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, jc);
if (parent != null) {
parent.setExtendedState(Frame.MAXIMIZED_BOTH);
+ if (switcher != null) {
+ switcher.switchedToMax();
+ }
}
}
}
- private static class DialogListener implements ComponentListener {
+ public void maximizeDialog(final JDialog dialog, Rectangle maximizedWindowBounds) {
+ dialog.getRootPane().putClientProperty(PROP_OLD_BOUNDS, dialog.getBounds());
+ dialog.setLocation(maximizedWindowBounds.getLocation());
+ dialog.setSize(maximizedWindowBounds.getSize());
+ EventQueue.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ new DialogListener(dialog);
+ }
+ });
+ }
+ private static class DialogListener implements ComponentListener, WindowListener {
+
private final JDialog dialog;
public DialogListener(JDialog dialog) {
this.dialog = dialog;
dialog.addComponentListener(this);
+ dialog.addWindowListener(this);
}
@Override
+ public void windowOpened(WindowEvent e) {
+ }
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ }
+
+ @Override
+ public void windowClosed(WindowEvent e) {
+ remove();
+ }
+
+ @Override
+ public void windowIconified(WindowEvent e) {
+ }
+
+ @Override
+ public void windowDeiconified(WindowEvent e) {
+ }
+
+ @Override
+ public void windowActivated(WindowEvent e) {
+ }
+
+ @Override
+ public void windowDeactivated(WindowEvent e) {
+ }
+
+ @Override
public void componentResized(ComponentEvent e) {
remove();
}
private void remove() {
- dialog.getRootPane().putClientProperty("OLD_BOUNDS", null);
+ dialog.getRootPane().putClientProperty(PROP_OLD_BOUNDS, null);
dialog.removeComponentListener(this);
}
Modified: trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/action/MinimizeDialogAction.java
===================================================================
--- trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/action/MinimizeDialogAction.java 2013-03-14 08:20:13 UTC (rev 8326)
+++ trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/action/MinimizeDialogAction.java 2013-03-14 15:49:17 UTC (rev 8327)
@@ -3,6 +3,7 @@
*/
package org.fudaa.ctulu.action;
+import com.memoire.bu.BuResource;
import java.awt.Frame;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
@@ -15,6 +16,7 @@
import javax.swing.JFrame;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
+import org.fudaa.ctulu.CtuluLib;
import org.fudaa.ctulu.gui.CtuluLibDialog;
/**
@@ -24,13 +26,26 @@
public class MinimizeDialogAction extends AbstractAction {
private final JComponent jc;
+ private SwitchMinMaxDialogAction switcher;
public MinimizeDialogAction(JComponent jc) {
+ super(CtuluLib.getS("Restaurer la fen\xEAtre parente"));
this.jc = jc;
putValue(Action.ACTION_COMMAND_KEY, getClass().getSimpleName());
- putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.ALT_DOWN_MASK));
+ final KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.ALT_DOWN_MASK);
+ putValue(Action.ACCELERATOR_KEY, keyStroke);
+ putValue(Action.SMALL_ICON, BuResource.BU.getIcon("down_left"));
+ putValue(Action.SHORT_DESCRIPTION, getValue(NAME) + " : " + ActionsInstaller.getAcceleratorText(keyStroke));
}
+ public SwitchMinMaxDialogAction getSwitcher() {
+ return switcher;
+ }
+
+ public void setSwitcher(SwitchMinMaxDialogAction switcher) {
+ this.switcher = switcher;
+ }
+
@Override
public void actionPerformed(ActionEvent e) {
JDialog dialog = (JDialog) SwingUtilities.getAncestorOfClass(JDialog.class, jc);
@@ -38,24 +53,34 @@
Rectangle initBounds = dialog.getBounds();
Rectangle maximizedWindowBounds = CtuluLibDialog.getMaximizedWindowBounds(initBounds);
if (initBounds.equals(maximizedWindowBounds)) {
- Rectangle old = (Rectangle) dialog.getRootPane().getClientProperty(MaximizeDialogAction.PROP_OLD_BOUNDS);
- if (old != null) {
- dialog.setLocation(old.getLocation());
- dialog.setSize(old.getSize());
- } else {
- initBounds.x = initBounds.x + initBounds.width / 4;
- initBounds.y = initBounds.y + initBounds.height / 4;
- initBounds.height = initBounds.height / 2;
- initBounds.width = initBounds.width / 2;
- dialog.setLocation(initBounds.getLocation());
- dialog.setSize(initBounds.getSize());
+ minimizeDialog(dialog, initBounds);
+ if (switcher != null) {
+ switcher.switchedToMin();
}
}
} else {
JFrame parent = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, jc);
if (parent != null) {
parent.setExtendedState(Frame.NORMAL);
+ if (switcher != null) {
+ switcher.switchedToMin();
+ }
}
}
}
+
+ public void minimizeDialog(JDialog dialog, Rectangle initBounds) {
+ Rectangle old = (Rectangle) dialog.getRootPane().getClientProperty(MaximizeDialogAction.PROP_OLD_BOUNDS);
+ if (old != null) {
+ dialog.setLocation(old.getLocation());
+ dialog.setSize(old.getSize());
+ } else {
+ initBounds.x = initBounds.x + initBounds.width / 4;
+ initBounds.y = initBounds.y + initBounds.height / 4;
+ initBounds.height = initBounds.height / 2;
+ initBounds.width = initBounds.width / 2;
+ dialog.setLocation(initBounds.getLocation());
+ dialog.setSize(initBounds.getSize());
+ }
+ }
}
Added: trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/action/SwitchMinMaxDialogAction.java
===================================================================
--- trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/action/SwitchMinMaxDialogAction.java (rev 0)
+++ trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/action/SwitchMinMaxDialogAction.java 2013-03-14 15:49:17 UTC (rev 8327)
@@ -0,0 +1,156 @@
+/*
+ GPL 2
+ */
+package org.fudaa.ctulu.action;
+
+import java.awt.EventQueue;
+import java.awt.Frame;
+import java.awt.Rectangle;
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+import org.fudaa.ctulu.gui.CtuluLibDialog;
+
+/**
+ *
+ * @author Frederic Deniger
+ */
+public class SwitchMinMaxDialogAction extends AbstractAction {
+
+ private final JComponent jc;
+ private final MaximizeDialogAction maxAction;
+ private final MinimizeDialogAction minAction;
+
+ public SwitchMinMaxDialogAction(JComponent jc, MaximizeDialogAction maxAction, MinimizeDialogAction minAction) {
+ this.jc = jc;
+ this.maxAction = maxAction;
+ this.minAction = minAction;
+ maxAction.setSwitcher(this);
+ minAction.setSwitcher(this);
+ putValue(Action.ACTION_COMMAND_KEY, getClass().getSimpleName());
+ putValue(Action.SMALL_ICON, maxAction.getValue(Action.SMALL_ICON));
+ putValue(Action.SHORT_DESCRIPTION, maxAction.getValue(Action.SHORT_DESCRIPTION));
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ final JDialog dialog = (JDialog) SwingUtilities.getAncestorOfClass(JDialog.class, jc);
+ if (dialog != null) {
+
+ Rectangle initBounds = dialog.getBounds();
+ Rectangle maximizedWindowBounds = CtuluLibDialog.getMaximizedWindowBounds(initBounds);
+ if (!maximizedWindowBounds.equals(initBounds)) {
+ maxAction.maximizeDialog(dialog, maximizedWindowBounds);
+ switchedToMax();
+ EventQueue.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ new DialogListener(dialog);
+ }
+ });
+ } else {
+ minAction.minimizeDialog(dialog, initBounds);
+ switchedToMin();
+ }
+ } else {
+ final JFrame parent = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, jc);
+ if (parent != null) {
+ if (parent.getExtendedState() == Frame.NORMAL) {
+ parent.setExtendedState(Frame.MAXIMIZED_BOTH);
+ switchedToMax();
+ EventQueue.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ new DialogListener(parent);
+ }
+ });
+ } else {
+ parent.setExtendedState(Frame.NORMAL);
+ switchedToMin();
+ }
+ }
+ }
+ }
+
+ public void switchedToMax() {
+ putValue(Action.SMALL_ICON, minAction.getValue(Action.SMALL_ICON));
+ putValue(Action.SHORT_DESCRIPTION, minAction.getValue(Action.SHORT_DESCRIPTION));
+ }
+
+ public void switchedToMin() {
+ putValue(Action.SMALL_ICON, maxAction.getValue(Action.SMALL_ICON));
+ putValue(Action.SHORT_DESCRIPTION, maxAction.getValue(Action.SHORT_DESCRIPTION));
+ }
+
+ private class DialogListener implements ComponentListener, WindowListener {
+
+ private final Window dialog;
+
+ public DialogListener(Window dialog) {
+ this.dialog = dialog;
+ dialog.addComponentListener(this);
+ dialog.addWindowListener(this);
+ }
+
+ @Override
+ public void windowOpened(WindowEvent e) {
+ }
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ }
+
+ @Override
+ public void windowClosed(WindowEvent e) {
+ remove();
+ }
+
+ @Override
+ public void windowIconified(WindowEvent e) {
+ }
+
+ @Override
+ public void windowDeiconified(WindowEvent e) {
+ }
+
+ @Override
+ public void windowActivated(WindowEvent e) {
+ }
+
+ @Override
+ public void windowDeactivated(WindowEvent e) {
+ }
+
+ @Override
+ public void componentResized(ComponentEvent e) {
+ remove();
+ }
+
+ private void remove() {
+ switchedToMin();
+ dialog.removeComponentListener(this);
+ }
+
+ @Override
+ public void componentMoved(ComponentEvent e) {
+ remove();
+ }
+
+ @Override
+ public void componentShown(ComponentEvent e) {
+ }
+
+ @Override
+ public void componentHidden(ComponentEvent e) {
+ }
+ }
+}
Added: trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/border/BorderWithIcon.java
===================================================================
--- trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/border/BorderWithIcon.java (rev 0)
+++ trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/border/BorderWithIcon.java 2013-03-14 15:49:17 UTC (rev 8327)
@@ -0,0 +1,134 @@
+/*
+ GPL 2
+ */
+package org.fudaa.ctulu.border;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.Insets;
+import javax.swing.Icon;
+import javax.swing.JDialog;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.border.EmptyBorder;
+
+/**
+ * Border that display an icon and focus if set.
+ *
+ * @author Frederic Deniger
+ */
+public class BorderWithIcon extends EmptyBorder {
+
+ protected Icon icon;
+ protected boolean paintFocus;
+ private boolean paintInDialogOnly;
+ protected Color focus = UIManager.getColor("activeCaptionBorder");
+
+ public BorderWithIcon(int top, int left, int bottom, int right, Icon tileIcon) {
+ super(top, left, bottom, right);
+ this.icon = tileIcon;
+ }
+
+ public boolean isPaintInDialogOnly() {
+ return paintInDialogOnly;
+ }
+
+ public void setPaintInDialogOnly(boolean paintInDialogOnly) {
+ this.paintInDialogOnly = paintInDialogOnly;
+ }
+
+ public BorderWithIcon(Insets borderInsets, Icon tileIcon) {
+ super(borderInsets);
+ this.icon = tileIcon;
+ }
+
+ public BorderWithIcon(Icon tileIcon) {
+ this(-1, -1, -1, -1, tileIcon);
+ }
+
+ public boolean isSelected(Component c, int x, int y) {
+ int width = c.getWidth();
+ int minx = width - icon.getIconWidth() - 1;
+ int maxx = width;
+ if (x >= minx && x <= maxx) {
+ int miny = 0;
+ int maxy = icon.getIconHeight();
+ return y >= miny && y <= maxy;
+ }
+ return false;
+ }
+
+ /**
+ * Paints the matte border.
+ */
+ @Override
+ public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
+ if (paintInDialogOnly) {
+ if (SwingUtilities.getAncestorOfClass(JDialog.class, c) == null) {
+ return;
+ }
+ }
+ if (icon != null) {
+ icon.paintIcon(c, g, x + width - icon.getIconWidth() - 1, y + 1);
+ if (paintFocus) {
+ Color old = g.getColor();
+ g.setColor(focus);
+ g.drawRect(x + width - icon.getIconWidth() - 1, y, icon.getIconWidth(), icon.getIconHeight());
+ g.setColor(old);
+ }
+ }
+ }
+
+ @Override
+ public Insets getBorderInsets(Component c, Insets insets) {
+ if (paintInDialogOnly) {
+ if (SwingUtilities.getAncestorOfClass(JDialog.class, c) == null) {
+ return super.getBorderInsets(c, insets);
+ }
+ }
+ return computeInsets(insets);
+ }
+
+ public void setIcon(Icon icon) {
+ this.icon = icon;
+ }
+
+ /**
+ * Returns the insets of the border.
+ *
+ * @since 1.3
+ */
+ @Override
+ public Insets getBorderInsets() {
+ return computeInsets(new Insets(0, 0, 0, 0));
+ }
+
+ /* should be protected once api changes area allowed */
+ private Insets computeInsets(Insets insets) {
+ int w = icon == null ? 0 : icon.getIconWidth();
+ int h = icon == null ? 0 : icon.getIconHeight();
+ insets.left = left;
+ insets.top = top + h + 2;
+ insets.right = right;
+ insets.bottom = bottom;
+ return insets;
+ }
+
+ /**
+ * Returns the icon used for tiling the border or null if a solid color is being used.
+ *
+ * @since 1.3
+ */
+ public Icon getTileIcon() {
+ return icon;
+ }
+
+ /**
+ * Returns whether or not the border is opaque.
+ */
+ @Override
+ public boolean isBorderOpaque() {
+ return false;
+ }
+}
Added: trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/border/BorderWithIconInstaller.java
===================================================================
--- trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/border/BorderWithIconInstaller.java (rev 0)
+++ trunk/framework/ctulu-ui/src/main/java/org/fudaa/ctulu/border/BorderWithIconInstaller.java 2013-03-14 15:49:17 UTC (rev 8327)
@@ -0,0 +1,107 @@
+/*
+ GPL 2
+ */
+package org.fudaa.ctulu.border;
+
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import javax.swing.Action;
+import static javax.swing.Action.SHORT_DESCRIPTION;
+import javax.swing.Icon;
+import javax.swing.JComponent;
+
+/**
+ *
+ * @author Frederic Deniger
+ */
+public class BorderWithIconInstaller {
+
+ /**
+ * install a border with the icon of the action. if user clicked on icon, the action is performed.
+ *
+ * @param jc
+ * @param action
+ */
+ public static void install(JComponent jc, Action action, boolean onlyInDialog) {
+ BorderWithIcon border = new BorderWithIcon((Icon) action.getValue(Action.SMALL_ICON));
+ border.setPaintInDialogOnly(onlyInDialog);
+ jc.setBorder(border);
+ jc.addMouseMotionListener(new IconBorderMouseListener(jc, border, action));
+ jc.addMouseListener(new IconBorderMouseListener(jc, border, action));
+ }
+
+ private static class IconBorderMouseListener extends MouseAdapter implements PropertyChangeListener {
+
+ private final JComponent jc;
+ private final Action action;
+ private final BorderWithIcon border;
+ private String oldTooltip;
+ private boolean tooltipChanged;
+
+ public IconBorderMouseListener(JComponent jc, BorderWithIcon border, Action action) {
+ this.jc = jc;
+ this.border = border;
+ this.action = action;
+ action.addPropertyChangeListener(this);
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (Action.SMALL_ICON.equals(evt.getPropertyName())) {
+ border.setIcon((Icon) action.getValue(Action.SMALL_ICON));
+ jc.repaint();
+ }
+ if (Action.SHORT_DESCRIPTION.equals(evt.getPropertyName()) && tooltipChanged) {
+ jc.setToolTipText(getTooltipFromAction());
+ }
+ }
+
+ @Override
+ public void mouseMoved(MouseEvent e) {
+ boolean old = border.paintFocus;
+ boolean isSelected = border.isSelected(jc, e.getX(), e.getY());
+
+ if (old != isSelected) {
+ border.paintFocus = isSelected;
+ jc.repaint();
+ if (isSelected && action.getValue(SHORT_DESCRIPTION) != null) {
+ oldTooltip = jc.getToolTipText();
+ tooltipChanged = true;
+ jc.setToolTipText(getTooltipFromAction());
+ } else if (!isSelected && tooltipChanged) {
+ restoreOldTooltip();
+ }
+ }
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e) {
+ if (border.paintFocus) {
+ border.paintFocus = false;
+ if (tooltipChanged) {
+ restoreOldTooltip();
+ }
+ jc.repaint();
+ }
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ if (border.paintFocus && action != null) {
+ action.actionPerformed(null);
+ }
+ }
+
+ public void restoreOldTooltip() {
+ jc.setToolTipText(oldTooltip);
+ tooltipChanged = false;
+ oldTooltip = null;
+ }
+
+ public String getTooltipFromAction() {
+ return (String) action.getValue(SHORT_DESCRIPTION);
+ }
+ }
+}
Modified: trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGAxeVertical.java
===================================================================
--- trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGAxeVertical.java 2013-03-14 08:20:13 UTC (rev 8326)
+++ trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGAxeVertical.java 2013-03-14 15:49:17 UTC (rev 8327)
@@ -32,11 +32,8 @@
public static final String PROP_TITLE_VERTICAL_DROITE = "axeTitleVerticalDroite";
public static final String PROP_DROITE = "axeTitleDroite";
public static final String PROP_TITLE_VERTICAL = "axeTitleVertical";
-
boolean droite_;
-
boolean titreVertical_;
-
boolean titreVerticalDroite_;
public EGAxeVertical() {
@@ -60,7 +57,7 @@
/**
* Ajuste les bornes de cet axe pour prendre en compte les valeurs de l'objet _o.
- *
+ *
* @param _o l'objet a prendre en compte
*/
public void ajusteFor(final EGObject _o) {
@@ -84,8 +81,8 @@
}
private int dessineGraduation(final Graphics2D _g2d, final EGRepere _t, final FontMetrics _fm, final int _x,
- final boolean _grille) {
- String t;
+ final boolean _grille) {
+
int maxStringwidth = 0;
if (graduations_ || _grille) {
// java.text.NumberFormat nf = getNumberFormat();
@@ -109,7 +106,7 @@
final TickIterator iterator = buildUpToDateMainTickIterator();
for (final TickIterator it = iterator; it.hasNext(); it.next()) {
final double s = it.currentValue();
-
+ String t;
final int ye = _t.getYEcran(s, this);
if (graduations_) {
if (it.isMajorTick()) {
@@ -169,7 +166,9 @@
if (FuLog.isDebug() && Fu.DEBUG) {
FuLog.debug(getClass().getName() + " axe vertical begin ...");
}
- if (!visible_) { return; }
+ if (!visible_) {
+ return;
+ }
final Font old = _g2d.getFont();
if (font_ != null) {
_g2d.setFont(font_);
@@ -231,23 +230,28 @@
}
}
-
public int getHeightNeeded(final Graphics2D _g) {
int r = 0;
if (isExtremiteDessinee_) {
r += 3;
}
_g.setFont(getFont());
- if ((isTitreVisible() || isUniteVisible()) && !titreVertical_) { return r
- + _g.getFontMetrics(getFont()).getHeight() + _g.getFontMetrics(getFont()).getAscent(); }
+ if ((isTitreVisible() || isUniteVisible()) && !titreVertical_) {
+ return r
+ + _g.getFontMetrics(getFont()).getHeight() + _g.getFontMetrics(getFont()).getAscent();
+ }
return r;
}
public int getWidthNeeded(final Graphics2D _g2d) {
- if (!visible_) { return 0; }
+ if (!visible_) {
+ return 0;
+ }
// epaisseur trait
int r = 3;
- if (_g2d == null) { return r; }
+ if (_g2d == null) {
+ return r;
+ }
if (font_ == null) {
font_ = EGGraphe.DEFAULT_FONT;
}
@@ -278,8 +282,8 @@
r += fm.getHeight() + 6;
} else {
final String axeTexte = getAxeTexte();
- final int wT = (fm.stringWidth(axeTexte) + 4)/2;
- r=wT+Math.max(r, wT);
+ final int wT = (fm.stringWidth(axeTexte) + 4) / 2;
+ r = wT + Math.max(r, wT);
}
}
return r;
@@ -290,18 +294,24 @@
* @return la dimension de la partie dessine dans le graphe: en general la moiti\xE9 de la largeur du titre
*/
public int getWidthDrawnInGraphe(final Graphics2D _g2d) {
- if (!visible_) { return 0; }
+ if (!visible_) {
+ return 0;
+ }
// epaisseur trait
final int r = 0;
- if (_g2d == null) { return r; }
+ if (_g2d == null) {
+ return r;
+ }
if (font_ == null) {
font_ = EGGraphe.DEFAULT_FONT;
}
final FontMetrics fm = _g2d.getFontMetrics(this.font_);
if (isUniteVisible() || isTitreVisible()) {
if (titreVertical_) {
- if ((isTitreVerticalDroite() && !isDroite()) || (!isTitreVerticalDroite() && isDroite())) { return fm
- .getHeight() + 6; }
+ if ((isTitreVerticalDroite() && !isDroite()) || (!isTitreVerticalDroite() && isDroite())) {
+ return fm
+ .getHeight() + 6;
+ }
} else {
final String axeTexte = getAxeTexte();
return (fm.stringWidth(axeTexte) + 4) / 2;
@@ -360,5 +370,4 @@
duplic.nbSousGraduations_ = nbSousGraduations_;
return duplic;
}
-
}
\ No newline at end of file
Modified: trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGCourbe.java
===================================================================
--- trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGCourbe.java 2013-03-14 08:20:13 UTC (rev 8326)
+++ trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGCourbe.java 2013-03-14 15:49:17 UTC (rev 8327)
@@ -511,7 +511,7 @@
final Shape oldClip = _g.getClip();
final int minX = _t.getMinEcranX();
final int adjust = 3;
- _g.setClip(minX - adjust, 0, _t.getMaxEcranX() - minX + adjust * 2, _t.getH());
+ _g.setClip(minX - adjust, _t.getMinEcranY(), _t.getMaxEcranX() - minX + adjust * 2, _t.getMaxEcranY() - _t.getMinEcranY());
final int nbPt = model_.getNbValues();
double xi, yi, xie, yie;
boolean xiVisible;
@@ -550,7 +550,8 @@
yiVisible = true;
} else {
yie = _t.getYEcran(yi, getAxeY());
- yiVisible = getAxeY().containsPoint(yi);
+ yiVisible = true;
+// yiVisible = getAxeY().containsPoint(yi);
}
xiVisible = _t.getXAxe().containsPoint(xi);
@@ -607,8 +608,10 @@
canDraw = range.isValueContained(yi) || range.isValueContained(ypeVal);
}
if (canDraw) {
- double newyie = getYEcran(yi, _t);
- double newyie2 = getYEcran(ypeVal, _t);
+// double newyie = getYEcran(yi, _t);
+ double newyie = yie;
+// double newyie2 = getYEcran(ypeVal, _t);
+ double newyie2 = ype;
trLigne.dessineTrait(_g, xie, newyie, xpe, newyie2);
}
Modified: trunk/framework/ebli-common/src/main/java/org/fudaa/ebli/commun/EbliActionAbstract.java
===================================================================
--- trunk/framework/ebli-common/src/main/java/org/fudaa/ebli/commun/EbliActionAbstract.java 2013-03-14 08:20:13 UTC (rev 8326)
+++ trunk/framework/ebli-common/src/main/java/org/fudaa/ebli/commun/EbliActionAbstract.java 2013-03-14 15:49:17 UTC (rev 8327)
@@ -9,7 +9,6 @@
package org.fudaa.ebli.commun;
import java.awt.event.ActionEvent;
-import java.awt.event.KeyEvent;
import java.beans.PropertyChangeListener;
import java.util.Collection;
@@ -18,9 +17,9 @@
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.KeyStroke;
-import javax.swing.UIManager;
import org.fudaa.ctulu.CtuluResource;
+import org.fudaa.ctulu.action.ActionsInstaller;
/**
* Une action avec tooltip adapt\xE9 \xE0 l'\xE9tat du bouton. Si le bouton est d\xE9sactiv\xE9, un tooltip expliquant commant le rendre actif est affich\xE9.
@@ -68,26 +67,7 @@
}
public static String getAcceleratorText(final KeyStroke _accelerator) {
- String acceleratorDelimiter = UIManager.getString("MenuItem.acceleratorDelimiter");
- if (acceleratorDelimiter == null) {
- acceleratorDelimiter = "+";
- }
-
- final StringBuffer acceleratorText = new StringBuffer(50);
- if (_accelerator != null) {
- final int modifiers = _accelerator.getModifiers();
- if (modifiers > 0) {
- acceleratorText.append(KeyEvent.getKeyModifiersText(modifiers)).append(acceleratorDelimiter);
- }
-
- final int keyCode = _accelerator.getKeyCode();
- if (keyCode == 0) {
- acceleratorText.append(_accelerator.getKeyChar());
- } else {
- acceleratorText.append(KeyEvent.getKeyText(keyCode));
- }
- }
- return acceleratorText.toString();
+ return ActionsInstaller.getAcceleratorText(_accelerator);
}
public final String getDefaultTooltip() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|