|
From: <de...@us...> - 2012-08-31 17:25:35
|
Revision: 7599
http://fudaa.svn.sourceforge.net/fudaa/?rev=7599&view=rev
Author: deniger
Date: 2012-08-31 17:25:25 +0000 (Fri, 31 Aug 2012)
Log Message:
-----------
Modified Paths:
--------------
trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGGrapheSimpleModel.java
trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGPaletteLegendeGraphe.java
trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGTableGraphePanel.java
Added Paths:
-----------
trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGIconForCourbe.java
trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGLegendPanelManager.java
Modified: trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGGrapheSimpleModel.java
===================================================================
--- trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGGrapheSimpleModel.java 2012-08-31 09:13:28 UTC (rev 7598)
+++ trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGGrapheSimpleModel.java 2012-08-31 17:25:25 UTC (rev 7599)
@@ -41,48 +41,74 @@
* @version $Id: EGGrapheSimpleModel.java,v 1.19 2007-05-04 13:49:42 deniger Exp $
*/
public class EGGrapheSimpleModel extends AbstractListModel implements EGGrapheModel {
-
+
+ public void removeCurves(final TIntObjectHashMap curvesRemoveOldIndice, final CtuluCommandManager _mng) {
+ if (!curvesRemoveOldIndice.isEmpty()) {
+ element_.removeAll(Arrays.asList(curvesRemoveOldIndice.getValues()));
+ final int[] idx = curvesRemoveOldIndice.keys();
+ Arrays.sort(idx);
+ final EGCourbeSimple[] courbes = new EGCourbeSimple[idx.length];
+ int minIdxRemove = idx[0];
+ courbes[0] = (EGCourbeSimple) curvesRemoveOldIndice.get(minIdxRemove);
+ int maxIdxRemove = minIdxRemove;
+ for (int i = idx.length - 1; i > 0; i--) {
+ final int k = idx[i];
+ courbes[i] = (EGCourbeSimple) curvesRemoveOldIndice.get(k);
+ if (k < minIdxRemove) {
+ minIdxRemove = k;
+ }
+ if (k > maxIdxRemove) {
+ maxIdxRemove = k;
+ }
+ }
+ if (_mng != null) {
+ _mng.addCmd(new CourbesRemovedCommand(idx, courbes));
+ }
+ fireIntervalRemoved(this, minIdxRemove, maxIdxRemove);
+ }
+ }
+
public class CbModel extends AbstractListModel implements ComboBoxModel {
-
+
Object selected_;
EGAxeVertical vert_;
-
+
public CbModel(final EGAxeVertical _vert) {
super();
vert_ = _vert;
}
-
+
public Object getElementAt(final int _index) {
return getCourbe(_index);
}
-
+
public Object getSelectedItem() {
return selected_;
}
-
+
public int getSize() {
return getNbEGObject();
}
-
+
public void setSelectedItem(final Object _anItem) {
if (_anItem != selected_ && (vert_ != null && vert_ != _anItem)) {
selected_ = _anItem;
fireContentsChanged(this, -1, -1);
}
-
+
}
}
-
+
private class CourbeAddCommand implements CtuluCommand {
-
+
EGCourbeSimple courbeAdd_;
int idx_;
-
+
public CourbeAddCommand(final EGCourbeSimple _s, final int _idx) {
courbeAdd_ = _s;
idx_ = _idx;
}
-
+
public void redo() {
if (idx_ >= 0) {
internalAddElement(idx_, courbeAdd_);
@@ -92,34 +118,34 @@
internalAddElement(courbeAdd_);
selection_.setSelectionInterval(i, i);
}
-
+
}
-
+
public void undo() {
internalRemoveElement(courbeAdd_);
}
}
-
+
private class CourbesAddCommand implements CtuluCommand {
-
+
EGCourbeSimple[] courbeAdd_;
-
+
public CourbesAddCommand(final EGCourbeSimple[] _s) {
courbeAdd_ = _s;
}
-
+
public void redo() {
internalAddElement(courbeAdd_);
-
+
}
-
+
public void undo() {
internalRemoveElement(courbeAdd_);
}
}
-
+
private class CourbesRemovedCommand implements CtuluCommand {
-
+
EGCourbeSimple[] courbes_;
int[] idx_;
@@ -131,7 +157,7 @@
idx_ = _idx;
courbes_ = _cs;
}
-
+
public void redo() {
selection_.clearSelection();
for (int i = idx_.length - 1; i >= 0; i--) {
@@ -139,7 +165,7 @@
}
fireIntervalRemoved(this, idx_[0], idx_[idx_.length - 1]);
}
-
+
public void undo() {
final int n = idx_.length;
selection_.clearSelection();
@@ -156,18 +182,18 @@
}
}
}
-
+
class SimpleTableModel extends AbstractTableModel {
-
+
@Override
public Class getColumnClass(final int _columnIndex) {
return EGObject.class;
}
-
+
public int getColumnCount() {
return 3;
}
-
+
@Override
public String getColumnName(final int _column) {
if (_column == 2) {
@@ -177,22 +203,22 @@
}
return CtuluLibString.ESPACE;
}
-
+
public int getRowCount() {
return getSize();
}
-
+
public Object getValueAt(final int _rowIndex, final int _columnIndex) {
return getElementAt(_rowIndex);
}
-
+
@Override
public boolean isCellEditable(final int _rowIndex, final int _columnIndex) {
// la colonne 1 represente la case a cocher visible
// la colonne 2 : le nom de la courbe: modifiable si le model l'autorise
return _columnIndex == 1 || (_columnIndex == 2 && getCourbe(_rowIndex).isTitleModifiable());
}
-
+
@Override
public void setValueAt(final Object _value, final int _rowIndex, final int _columnIndex) {
if (_columnIndex == 1 && _value instanceof Boolean) {
@@ -205,19 +231,19 @@
}
}
}
-
+
public static EGGrapheSimpleModel createSimpleModel(final EGCourbeSimple[] _cs) {
return new EGGrapheSimpleModel(_cs) {
@Override
public boolean canAddCourbe() {
return false;
}
-
+
@Override
public boolean isContentModifiable() {
return false;
}
-
+
@Override
public boolean isStructureModifiable() {
return false;
@@ -229,11 +255,11 @@
boolean isUpdating;
protected DefaultListSelectionModel selection_;
SimpleTableModel tableModel_;
-
+
public EGGrapheSimpleModel() {
this(null);
}
-
+
public EGGrapheSimpleModel(final EGCourbeSimple[] _s) {
if (_s != null) {
element_ = new ArrayList(Arrays.asList(_s));
@@ -271,7 +297,7 @@
public void addCourbe(final EGCourbeSimple _obj, final CtuluCommandManager _mng, final int _idx) {
addCourbe(_obj, _mng, _idx, true);
}
-
+
public void addCourbe(final EGCourbeSimple _obj, final CtuluCommandManager _mng, final int _idx, boolean select) {
if (!isStructureModifiable()) {
return;
@@ -282,7 +308,7 @@
}
createCmdForCourbeAdd(_obj, _mng, _idx);
}
-
+
public void addCourbes(final EGCourbeSimple[] _obj, final CtuluCommandManager _mng) {
if (!isStructureModifiable()) {
return;
@@ -293,22 +319,22 @@
for (int i = idx.length - 1; i >= 0; i--) {
selection_.addSelectionInterval(idx[i], idx[i]);
}
-
+
}
createCmdForCourbeAdd(_obj, _mng);
}
-
+
public void addModelListener(final EGGrapheModelListener _l) {
listenerList.add(EGGrapheModelListener.class, _l);
}
-
+
public void addNewCourbe(final CtuluCommandManager _cmd, final Component _p, final EGGraphe _graphe) {
}
-
+
public void addSelectionListener(final EGSelectionListener _l) {
selection_.addListSelectionListener(_l);
}
-
+
public boolean canAddCourbe() {
return true;
}
@@ -322,11 +348,11 @@
protected boolean canAddCourbe(final EGCourbeSimple _s) {
return true;
}
-
+
public boolean canDeleteCourbes() {
return isStructureModifiable();
}
-
+
public boolean canDescendre(final EGObject _o) {
if (element_.size() <= 1) {
return false;
@@ -334,7 +360,7 @@
final int i = element_.indexOf(_o);
return i >= 0 && i < element_.size() - 1;
}
-
+
public boolean canMonter(final EGObject _o) {
if (element_.size() <= 1) {
return false;
@@ -351,44 +377,44 @@
public boolean canRemoveCourbe(final EGCourbeSimple _s) {
return _s.getModel().isRemovable();
}
-
+
public boolean contains(final EGCourbe _c) {
return element_ == null ? false : element_.contains(_c);
}
-
+
public JComboBox createCbForSelectCourbe() {
return createCbForSelectCourbe(null);
}
-
+
public JComboBox createCbForSelectCourbe(final EGAxeVertical _vertical) {
final BuComboBox cb = new BuComboBox(new CbModel(null));
cb.setRenderer(_vertical == null ? new EGTreeCellRenderer(true) : new EGTreeCellRenderer.AxeChooserRenderer(
_vertical));
return cb;
}
-
+
protected void createCmdForCourbeAdd(final EGCourbeSimple _courbeAdd, final CtuluCommandManager _cmd, final int _idx) {
if (_cmd != null) {
_cmd.addCmd(new CourbeAddCommand(_courbeAdd, _idx));
}
}
-
+
protected void createCmdForCourbeAdd(final EGCourbeSimple[] _courbeAdd, final CtuluCommandManager _cmd) {
if (_cmd != null) {
_cmd.addCmd(new CourbesAddCommand(_courbeAdd));
}
}
-
+
public TableModel createTableTreeModel() {
if (tableModel_ == null) {
tableModel_ = new SimpleTableModel();
}
return tableModel_;
}
-
+
public void decoreAddButton(final EbliActionInterface _b) {
}
-
+
public void descendre(final EGObject _o) {
final int i = element_.indexOf(_o);
final int lastIdx = element_.size() - 1;
@@ -402,9 +428,9 @@
fireContentsChanged(this, i, i + 1);
selection_.setSelectionInterval(i + 1, i + 1);
}
-
+
}
-
+
protected EGCourbeSimple doDuplicateCourbe(final EGCourbe _c) {
return null;
}
@@ -415,12 +441,12 @@
//--duplication de la liste des courbes --//
ArrayList<EGCourbeSimple> listeElements = new ArrayList<EGCourbeSimple>(element_.size());
-
+
for (Iterator<EGCourbeSimple> it = this.element_.iterator(); it.hasNext();) {
EGCourbeSimple courbe = it.next();
listeElements.add((EGCourbeSimple) courbe.duplicate(this, _duplicator));
}
-
+
EGGrapheSimpleModel duplic = new EGGrapheSimpleModel((EGCourbeSimple[]) listeElements.toArray());
//a corriger
duplic.axeX_ = this.axeX_.duplicate();
@@ -440,10 +466,10 @@
//FRED ok
// duplic.tableModel_ = new SimpleTableModel();
-
+
return duplic;
}
-
+
public void duplicateCourbe(final CtuluCommandManager _mng, final EGCourbe _c) {
if (_c == null || (element_ == null) || element_.size() == 0) {
return;
@@ -456,15 +482,15 @@
if (c != null) {
addCourbe(c, _mng, idx + 1);
}
-
+
}
-
+
public void duplicateCourbeForSrc(CtuluCommandManager _mng, EGCourbe _c) {
-
+
JOptionPane.showMessageDialog(null, "ne gere pas le multi source ");
duplicateCourbe(_mng, _c);
}
-
+
public void enDernier(final EGObject _o) {
final int i = element_.indexOf(_o);
final int lastIdx = element_.size() - 1;
@@ -474,9 +500,9 @@
fireContentsChanged(this, i, lastIdx);
selection_.setSelectionInterval(lastIdx, lastIdx);
}
-
+
}
-
+
public void enPremier(final EGObject _o) {
final int i = element_.indexOf(_o);
if (i > 0) {
@@ -485,17 +511,17 @@
fireContentsChanged(this, 0, i);
selection_.setSelectionInterval(0, 0);
}
-
+
}
-
+
public final void fireAxeAspectChanged(final EGAxe _a) {
EGGrapheTreeModel.fireAxeAspectChanged(_a, listenerList);
}
-
+
public final void fireAxeContentChanged(final EGAxe _a) {
EGGrapheTreeModel.fireAxeContentChanged(_a, listenerList);
}
-
+
@Override
protected final void fireContentsChanged(final Object _source, final int _index0, final int _index1) {
super.fireContentsChanged(_source, _index0, _index1);
@@ -503,22 +529,22 @@
tableModel_.fireTableRowsUpdated(_index0, _index1);
}
}
-
+
public final void fireCourbeAspectChanged(final EGObject _o, final boolean _visibility) {
internFireCourbeChanged(_o);
EGGrapheTreeModel.fireCourbeAspectChanged(_o, _visibility, listenerList);
}
-
+
public final void fireCourbeContentChanged(final EGObject _o) {
fireCourbeContentChanged(_o, false);
}
-
+
public final void fireCourbeContentChanged(final EGObject _o, final boolean _mustRestore) {
internFireCourbeChanged(_o);
-
+
EGGrapheTreeModel.fireCourbeContentChanged(_o, listenerList, _mustRestore);
}
-
+
@Override
protected final void fireIntervalAdded(final Object _source, final int _index0, final int _index1) {
super.fireIntervalAdded(_source, _index0, _index1);
@@ -528,7 +554,7 @@
EGGrapheTreeModel.fireStructureChanged(listenerList);
selection_.setSelectionInterval(_index0, _index1);
}
-
+
@Override
protected final void fireIntervalRemoved(final Object _source, final int _index0, final int _index1) {
super.fireIntervalRemoved(_source, _index0, _index1);
@@ -538,7 +564,7 @@
selection_.clearSelection();
EGGrapheTreeModel.fireStructureChanged(listenerList);
}
-
+
public void fireObjectChanged(final EGObject _o) {
if (element_ != null) {
if (_o == null) {
@@ -550,27 +576,27 @@
}
}
}
-
+
}
-
+
public final void fireStructureChanged() {
fireIntervalAdded(this, 0, getNbEGObject());
if (tableModel_ != null) {
tableModel_.fireTableStructureChanged();
}
}
-
+
public EGAxeHorizontal getAxeX() {
return axeX_;
}
-
+
public EGCourbeSimple getCourbe(final int _i) {
if (element_ == null) {
return null;
}
return (EGCourbeSimple) element_.get(_i);
}
-
+
public EGCourbeSimple[] getCourbes() {
final EGCourbeSimple[] r = new EGCourbeSimple[element_ == null ? 0 : element_.size()];
if (element_ != null) {
@@ -578,27 +604,27 @@
}
return r;
}
-
+
public synchronized EGObject getEGObject(final int _i) {
return element_ == null ? null : (EGObject) element_.get(_i);
}
-
+
public Object getElementAt(final int _index) {
return getEGObject(_index);
}
-
+
public ListSelectionModel getListSelection() {
return selection_;
}
-
+
public EGGrapheModel getMainModel() {
return this;
}
-
+
public int getNbEGObject() {
return element_ == null ? 0 : element_.size();
}
-
+
public int getNbSelectedObjects() {
if (selection_.isSelectionEmpty()) {
return 0;
@@ -612,7 +638,7 @@
}
return r;
}
-
+
public EGCourbe getSelectedComponent() {
if (selection_ == null || selection_.isSelectionEmpty()) {
return null;
@@ -625,11 +651,11 @@
}
return null;
}
-
+
public EGObject getSelectedObject() {
return getSelectedComponent();
}
-
+
public EGObject[] getSelectedObjects() {
if (selection_.isSelectionEmpty()) {
return null;
@@ -648,21 +674,21 @@
r.toArray(rf);
return rf;
}
-
+
public int getSize() {
return getNbEGObject();
}
-
+
public Object getSpecificPersitDatas(Map parameters) {
// TODO Auto-generated method stub
return null;
}
-
+
public List<EbliActionInterface> getSpecificsActionsCurvesOnly(EGGraphe _target, CtuluUI ui) {
// TODO Auto-generated method stub
return null;
}
-
+
protected int internalAddElement(final EGCourbeSimple _obj) {
if (!canAddCourbe(_obj)) {
return -1;
@@ -676,7 +702,7 @@
fireIntervalAdded(this, i, i);
return i;
}
-
+
protected int[] internalAddElement(final EGCourbeSimple[] _obj) {
if (_obj == null) {
return null;
@@ -690,7 +716,7 @@
}
return list.toNativeArray();
}
-
+
protected int internalAddElement(final int _index, final EGCourbeSimple _g) {
if (_index < 0 || element_ == null || _index == element_.size()) {
internalAddElement(_g);
@@ -704,7 +730,7 @@
fireIntervalAdded(this, _index, _index);
return _index;
}
-
+
protected void internalRemoveElement(final EGCourbeSimple _o) {
if (!canRemoveCourbe(_o)) {
return;
@@ -718,7 +744,7 @@
fireIntervalRemoved(this, i, i);
}
}
-
+
protected void internalRemoveElement(final EGCourbeSimple[] _o) {
if (_o != null) {
for (int i = _o.length - 1; i >= 0; i--) {
@@ -726,10 +752,10 @@
}
}
}
-
+
private void internFireCourbeChanged(final EGObject _o) {
if (_o == null) {
-
+
fireContentsChanged(this, 0, getNbEGObject());
} else {
if (element_ == null) {
@@ -739,17 +765,17 @@
fireContentsChanged(this, i, i);
}
}
-
+
protected void internFireStructureChanged() {
if (element_ != null) {
super.fireIntervalAdded(this, 0, element_.size());
}
}
-
+
public boolean isContentModifiable() {
return true;
}
-
+
public boolean isSomethingToDisplay() {
for (int i = getNbEGObject() - 1; i >= 0; i--) {
if (getCourbe(i).isVisible_) {
@@ -758,7 +784,7 @@
}
return false;
}
-
+
public boolean isStructureModifiable() {
return true;
}
@@ -769,7 +795,7 @@
public boolean isUpdating() {
return isUpdating;
}
-
+
public void monter(final EGObject _o) {
final int i = element_.indexOf(_o);
if (i > 0) {
@@ -779,11 +805,25 @@
selection_.setSelectionInterval(i - 1, i - 1);
}
}
-
+
public void removeModelListener(final EGGrapheModelListener _l) {
listenerList.remove(EGGrapheModelListener.class, _l);
}
-
+
+ public void removeCurves(int[] idx, final CtuluCommandManager _mng) {
+ if (idx == null) {
+ return;
+ }
+ final TIntObjectHashMap curvesRemoveOldIndice = new TIntObjectHashMap();
+ for (int i = 0; i < idx.length; i++) {
+ int index = idx[i];
+ if (getCourbe(index).getModel().isRemovable()) {
+ curvesRemoveOldIndice.put(index, element_.get(index));
+ }
+ }
+ removeCurves(curvesRemoveOldIndice, _mng);
+ }
+
public void removeSelectedCurves(final CtuluCommandManager _mng) {
if (selection_.isSelectionEmpty()) {
return;
@@ -795,29 +835,7 @@
curvesRemoveOldIndice.put(i, getCourbe(i));
}
}
- if (!curvesRemoveOldIndice.isEmpty()) {
- element_.removeAll(Arrays.asList(curvesRemoveOldIndice.getValues()));
- final int[] idx = curvesRemoveOldIndice.keys();
- Arrays.sort(idx);
- final EGCourbeSimple[] courbes = new EGCourbeSimple[idx.length];
- int minIdxRemove = idx[0];
- courbes[0] = (EGCourbeSimple) curvesRemoveOldIndice.get(minIdxRemove);
- int maxIdxRemove = minIdxRemove;
- for (int i = idx.length - 1; i > 0; i--) {
- final int k = idx[i];
- courbes[i] = (EGCourbeSimple) curvesRemoveOldIndice.get(k);
- if (k < minIdxRemove) {
- minIdxRemove = k;
- }
- if (k > maxIdxRemove) {
- maxIdxRemove = k;
- }
- }
- if (_mng != null) {
- _mng.addCmd(new CourbesRemovedCommand(idx, courbes));
- }
- fireIntervalRemoved(this, minIdxRemove, maxIdxRemove);
- }
+ removeCurves(curvesRemoveOldIndice, _mng);
}
/**
@@ -829,14 +847,14 @@
return;
}
CtuluLibArray.fillIncremental(idx, 0);
-
+
if (_mng != null) {
_mng.addCmd(new CourbesRemovedCommand(idx, getCourbes()));
}
fireIntervalRemoved(this, 0, idx.length - 1);
internalRemoveElement(getCourbes());
}
-
+
public void removeSelectionListener(final EGSelectionListener _l) {
selection_.removeListSelectionListener(_l);
}
@@ -847,20 +865,20 @@
public void select(final int _i) {
selection_.setSelectionInterval(_i, _i);
}
-
+
public void setAxeX(final EGAxeHorizontal _h) {
axeX_ = _h;
-
+
}
-
+
public void setSelectedComponent(final EGCourbe _c) {
final int idx = element_.indexOf(_c);
if (idx >= 0) {
select(idx);
}
-
+
}
-
+
public void setSpecificPersitDatas(Object sepcPersitData, Map parameters) {
// TODO Auto-generated method stub
}
@@ -871,4 +889,4 @@
public void setUpdating(boolean isUpdating) {
this.isUpdating = isUpdating;
}
-}
\ No newline at end of file
+}
Added: trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGIconForCourbe.java
===================================================================
--- trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGIconForCourbe.java (rev 0)
+++ trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGIconForCourbe.java 2012-08-31 17:25:25 UTC (rev 7599)
@@ -0,0 +1,49 @@
+/*
+ GPL 2
+ */
+package org.fudaa.ebli.courbe;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import javax.swing.Icon;
+import org.fudaa.ebli.trace.TraceIcon;
+import org.fudaa.ebli.trace.TraceLigne;
+
+/**
+ * Un icone
+ *
+ * @author deniger
+ */
+public class EGIconForCourbe implements Icon {
+
+ TraceLigne traceLigne_ = new TraceLigne();
+ TraceIcon traceIcon_ = new TraceIcon();
+ int height = 20;
+ int width = 30;
+
+ public int getIconHeight() {
+ return height;
+ }
+
+ public int getIconWidth() {
+ return width;
+ }
+
+ public void paintIcon(final Component _c, final Graphics _g, final int _x, final int _y) {
+ final Graphics2D g = (Graphics2D) _g;
+ g.setColor(Color.white);
+ g.fillRect(_x, _y, _x + getIconWidth(), _y + getIconHeight());
+ final int middleH = _y + getIconHeight() / 2;
+ traceLigne_.dessineTrait(g, _x, middleH, _x + getIconWidth(), middleH);
+ traceIcon_.paintIconCentre(g, _x + getIconWidth() / 2, middleH);
+ }
+
+ public void updateFromCourbe(final EGCourbe _c) {
+ traceLigne_.getModel().updateData(_c.getLigneModel());
+ traceIcon_.getModel().updateData(_c.getIconModel());
+ traceIcon_.setTaille(getIconHeight() / 4); // a voir
+ // a voir
+ }
+}
Added: trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGLegendPanelManager.java
===================================================================
--- trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGLegendPanelManager.java (rev 0)
+++ trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGLegendPanelManager.java 2012-08-31 17:25:25 UTC (rev 7599)
@@ -0,0 +1,121 @@
+/*
+ GPL 2
+ */
+package org.fudaa.ebli.courbe;
+
+import com.memoire.bu.BuGridLayout;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import org.fudaa.ctulu.gui.CtuluPopupListener;
+
+/**
+ *
+ * @author Frederic Deniger
+ */
+public class EGLegendPanelManager extends MouseAdapter implements EGGrapheModelListener {
+
+ JPanel panel;
+ EGGraphe graphe;
+
+ void createPanel() {
+ panel = new JPanel(new BuGridLayout(1, 1, 3, true, true));
+ rebuild();
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ if (graphe == null) {
+ return;
+ }
+ if (e.getClickCount() >= 2) {
+ JComponent jc = (JComponent) e.getComponent();
+ Object clientProperty = jc.getClientProperty("COURBE");
+ if (clientProperty != null) {
+ EGPaletteLegendeGraphe pnLegend = new EGPaletteLegendeGraphe(graphe);
+ pnLegend.selectCourbe((EGCourbe) clientProperty);
+ pnLegend.afficheModale(panel);
+ }
+
+ }
+ }
+
+ public void setGraphe(EGGraphe graphe) {
+ if (this.graphe != null) {
+ this.graphe.getModel().removeModelListener(this);
+ }
+ this.graphe = graphe;
+ if (graphe == null) {
+ return;
+ }
+ this.graphe.getModel().addModelListener(this);
+ if (panel != null) {
+ rebuild();
+ }
+ }
+ boolean editable = true;
+
+ public boolean isEditable() {
+ return editable;
+ }
+
+ public void setEditable(boolean editable) {
+ this.editable = editable;
+ }
+
+ @Override
+ public void structureChanged() {
+ rebuild();
+ }
+
+ @Override
+ public void courbeContentChanged(EGObject _c, boolean _mustRestore) {
+ }
+
+ @Override
+ public void courbeAspectChanged(EGObject _c, boolean _visibil) {
+ rebuild();
+ }
+
+ @Override
+ public void axeContentChanged(EGAxe _c) {
+ }
+
+ @Override
+ public void axeAspectChanged(EGAxe _c) {
+ }
+
+ public EGGraphe getGraphe() {
+ return graphe;
+ }
+
+ public JPanel getPanel() {
+ if (panel == null) {
+ createPanel();
+ }
+ return panel;
+ }
+
+ private void rebuild() {
+ panel.removeAll();
+ panel.setDoubleBuffered(false);
+ EGCourbe[] courbes = graphe.getModel().getCourbes();
+ for (EGCourbe eGCourbe : courbes) {
+ JLabel label = new JLabel();
+ EGIconForCourbe icon = new EGIconForCourbe();
+ icon.updateFromCourbe(eGCourbe);
+ label.setIcon(icon);
+ label.setText(eGCourbe.getTitle());
+ label.setToolTipText(eGCourbe.getTitle());
+ label.putClientProperty("COURBE", eGCourbe);
+ label.setOpaque(false);
+ panel.add(label);
+ label.addMouseListener(this);
+ }
+ panel.revalidate();
+ panel.repaint(0);
+// if(panel.get)
+ }
+}
Modified: trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGPaletteLegendeGraphe.java
===================================================================
--- trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGPaletteLegendeGraphe.java 2012-08-31 09:13:28 UTC (rev 7598)
+++ trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGPaletteLegendeGraphe.java 2012-08-31 17:25:25 UTC (rev 7599)
@@ -3,17 +3,12 @@
import gnu.trove.TIntArrayList;
import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Component;
import java.awt.Dimension;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
-import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JList;
@@ -43,165 +38,118 @@
import org.fudaa.ctulu.gui.CtuluDialogPanel;
import org.fudaa.ebli.commun.EbliLib;
import org.fudaa.ebli.ressource.EbliResource;
-import org.fudaa.ebli.trace.TraceIcon;
-import org.fudaa.ebli.trace.TraceLigne;
/**
* Palette de l\xE9gende des graphes. Utilis\xE9e pour \xE9diter les l\xE9gendes des graphes
- *
+ *
* @author Adrien Hadoux
*/
public class EGPaletteLegendeGraphe extends CtuluDialogPanel implements ActionListener, ListSelectionListener,
- BuBorders {
-
+ BuBorders {
+
private final class EGGrapheModelListenerImplementation implements EGGrapheModelListener {
+
public void structureChanged() {
-
}
-
- public void courbeContentChanged(final EGObject c, final boolean mustRestore) {}
-
+
+ public void courbeContentChanged(final EGObject c, final boolean mustRestore) {
+ }
+
public void courbeAspectChanged(final EGObject c, final boolean visibil) {
model_.fireContentsChanged(this, 0, model_.getSize() - 1);
-
+
}
-
+
public void axeContentChanged(final EGAxe c) {
-
}
-
- public void axeAspectChanged(final EGAxe c) {}
- }
-
- /**
- * Un icone
- *
- * @author deniger
- */
- private static class CellRendererIcon implements Icon {
- TraceLigne traceLigne_ = new TraceLigne();
- TraceIcon traceIcon_ = new TraceIcon();
-
- public int getIconHeight() {
- return 20;
+
+ public void axeAspectChanged(final EGAxe c) {
}
-
- public int getIconWidth() {
- return 30;
- }
-
- public void paintIcon(final Component _c, final Graphics _g, final int _x, final int _y) {
- final Graphics2D g = (Graphics2D) _g;
- g.setColor(Color.white);
- g.fillRect(_x, _y, _x + getIconWidth(), _y + getIconHeight());
- final int middleH = _y + getIconHeight() / 2;
- traceLigne_.dessineTrait(g, _x, middleH, _x + getIconWidth(), middleH);
- traceIcon_.paintIconCentre(g, _x + getIconWidth() / 2, middleH);
-
- }
-
- protected void setCourbe(final EGCourbe _c) {
- traceLigne_.getModel().updateData(_c.getLigneModel());
- traceIcon_.getModel().updateData(_c.getIconModel());
- traceIcon_.setTaille(getIconHeight() / 4);// a voir
- }
-
}
/**
* Renderer qui affiche la courbe sous forme de sa courbe miniature et son libell\xE9 \xE0 cot\xE9
- *
+ *
* @author Adrien Hadoux
*/
@SuppressWarnings("serial")
private static class LegendeRenderer extends CtuluCellTextRenderer { // ne pas refaire le travail !!!!!!!
- private final CellRendererIcon icon_ = new CellRendererIcon();
-
- public LegendeRenderer() {}
-
+ private final EGIconForCourbe icon_ = new EGIconForCourbe();
+
+ public LegendeRenderer() {
+ }
+
@Override
protected void setValue(final Object _value) {
final EGCourbe cb = (EGCourbe) _value;
- icon_.setCourbe(cb);
+ icon_.updateFromCourbe(cb);
setIcon(icon_);
setText(cb.getTitle());
setOpaque(true);
}
-
}
-
+
class CustomDefaultListModel extends DefaultListModel {
-
+
@Override
public void fireContentsChanged(Object source, int index0, int index1) {
super.fireContentsChanged(source, index0, index1);
}
-
+
@Override
public void fireIntervalAdded(Object source, int index0, int index1) {
super.fireIntervalAdded(source, index0, index1);
}
-
+
@Override
public void fireIntervalRemoved(Object source, int index0, int index1) {
super.fireIntervalRemoved(source, index0, index1);
}
-
}
-
/**
* Graphe associ\xE9 a la palette
*/
private final EGGraphe graphe_;
-
/**
* Bouton qui applique les changements
*/
private JButton btApply_;
-
private BuButton btFormat_;
-
private JButton btRefresh_;
-
EGConfigureActionPalette paletteAction;
-
/**
* Format des nombres des l\xE9gendes
*/
private CtuluNumberFormatI format_ = CtuluNumberFormatDefault.DEFAULT_FMT;
-
/**
* S\xE9parateur entre les formats
*/
private String separatorFormat_ = "-";
-
/**
* La liste des courbes
*/
private JList list_;
-
CustomDefaultListModel model_;
-
private EGGrapheModelListenerImplementation modelListener;
-
+
public EGPaletteLegendeGraphe(final EGGraphe graphe) {
graphe_ = graphe;
buildContent();
}
-
+
@Override
public boolean cancel() {
graphe_.removeModelListener(modelListener);
return super.cancel();
}
-
+
@Override
public boolean ok() {
graphe_.removeModelListener(modelListener);
return super.ok();
}
-
+
@Override
public void closeDialog() {
graphe_.removeModelListener(modelListener);
@@ -212,9 +160,8 @@
* Appelee lorsqu'on appuie sur le bouton appliquer
*/
private void actionApply() {
-
}
-
+
private void actionFormat() {
final CtuluNumberFormatI ctuluNumberFormatI = format_;
/*
@@ -235,7 +182,7 @@
tf.setText(separatorFormat_);
pnSep.add(tf);
pn.add(pnSep);
-
+
if (ctuluNumberFormatI == null || ctuluNumberFormatI.isDecimal()) {
fmtSelect.setBorder(BorderFactory.createTitledBorder(EbliLib.getS("Format d\xE9cimal")));
pn.add(fmtSelect);
@@ -244,12 +191,12 @@
format_ = fmtSelect.getCurrentFmt();
separatorFormat_ = tf.getText();
ajusteAllLegendes();
-
+
}
}
-
+
public void actionPerformed(final ActionEvent _e) {
-
+
final Object s = _e.getSource();
if (s == btApply_) {
actionApply();
@@ -258,20 +205,36 @@
} else if (btFormat_ == _e.getSource()) {
actionFormat();
}
-
+
}
/**
* Methode qui ajuste toutes les l\xE9gendes en fonction du format choisi et du separator.
*/
protected void ajusteAllLegendes() {
-
}
-
+
+ public int getLine(EGCourbe c) {
+ int nb = model_.getSize();
+ for (int i = 0; i < nb; i++) {
+ if (model_.get(i) == c) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public void selectCourbe(EGCourbe c) {
+ int idx = getLine(c);
+ if (idx >= 0) {
+ list_.getSelectionModel().setSelectionInterval(idx, idx);
+ }
+ }
+
private void buildContent() {
-
+
final EGCourbe[] cs = graphe_.getModel().getCourbes();
-
+
final BuBorderLayout lay = new BuBorderLayout(2, 2);
setLayout(lay);
@@ -292,12 +255,12 @@
list_.setCellRenderer(new LegendeRenderer());
list_.getSelectionModel().addListSelectionListener(this);
list_.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
-
+
final BuScrollPane sp = new BuScrollPane(list_);
sp.setPreferredSize(new Dimension(600, 100));
sp.setBorder(BorderFactory.createTitledBorder(EbliResource.EBLI.getString("Liste des courbes")));
add(sp, BuBorderLayout.NORTH);
-
+
final BuPanel pnColor = new BuPanel();
pnColor.setLayout(new BuButtonLayout(1, SwingConstants.LEFT));
@@ -307,7 +270,7 @@
final JComponent paletteComp = paletteAction.getPaletteContent();
updatePanelData();
paletteComp.setBorder(BorderFactory.createTitledBorder(EbliResource.EBLI.getString("Param\xE9trage")));
-
+
add(paletteComp, BorderLayout.CENTER);
if (selection.size() > 0) {
list_.setSelectedIndices(selection.toNativeArray());
@@ -323,18 +286,20 @@
btRefresh_.setEnabled(true);
final BuPanel btpn = new BuPanel();
btpn.setLayout(new BuButtonLayout(1, SwingConstants.RIGHT));
-
+
btpn.add(btRefresh_);
add(btpn, BuBorderLayout.SOUTH);
-
+
this.setPreferredSize(new Dimension(600, 500));
this.setMinimumSize(new Dimension(600, 500));
-
+
}
-
+
private EGCourbe[] getSelectedCourbes() {
final int[] select = this.list_.getSelectedIndices();
- if (select == null) { return null; }
+ if (select == null) {
+ return null;
+ }
final EGCourbe[] res = new EGCourbe[select.length];
for (int i = 0; i < res.length; i++) {
res[i] = (EGCourbe) list_.getModel().getElementAt(select[i]);
@@ -356,9 +321,8 @@
private void updatePanelData() {
paletteAction.setPaletteTarget(getSelectedCourbes());
}
-
+
public void valueChanged(final ListSelectionEvent e) {
updatePanelData();
}
-
}
Modified: trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGTableGraphePanel.java
===================================================================
--- trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGTableGraphePanel.java 2012-08-31 09:13:28 UTC (rev 7598)
+++ trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGTableGraphePanel.java 2012-08-31 17:25:25 UTC (rev 7599)
@@ -134,7 +134,6 @@
if (!r && graphePanel.lbXyInfo_ != null) {
graphePanel.lbError_.setText(EbliLib.getS("Point non ajout\xE9 !"));
new Timer().schedule(new TimerTask() {
-
public void run() {
graphePanel.lbError_.setText(CtuluLibString.ESPACE);
}
@@ -158,7 +157,6 @@
private static Action getEnterAction() {
return new AbstractAction() {
-
public void actionPerformed(final ActionEvent _e) {
final JTable t = (JTable) _e.getSource();
SpecTableModel tableModel = (SpecTableModel) t.getModel();
@@ -423,7 +421,6 @@
}
}
final TableCellRenderer renderer_ = new CtuluCellTextRenderer() {
-
public Component getTableCellRendererComponent(JTable _table, Object _value, boolean _isSelected,
boolean _hasFocus, int _row, int _column) {
Component res = super.getTableCellRendererComponent(_table, _value, _isSelected, _hasFocus, _row, _column);
@@ -473,7 +470,6 @@
add(lb_, BuBorderLayout.NORTH);
}
t_ = new EvolTable() {
-
public TableCellEditor getCellEditor(final int _row, final int _column) {
if (!isCellEditable(_row, _column)) {
return null;
@@ -501,7 +497,6 @@
final BuTextField txt = BuTextField.createDoubleField();
txt.setColumns(10);
t_.setDefaultEditor(Double.class, new BuTableCellEditor(txt) {
-
public boolean isCellEditable(final EventObject _evt) {
if (_evt instanceof MouseEvent) {
return ((MouseEvent) _evt).getClickCount() >= 2;
@@ -699,7 +694,6 @@
final InputMap m = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
m.put(ks, "deleteLine");
getActionMap().put("deleteLine", new AbstractAction() {
-
public void actionPerformed(final ActionEvent _e) {
btRemove_.doClick();
}
@@ -707,6 +701,18 @@
}
+ public static void removeButton(JButton bt) {
+ if (bt != null && bt.getParent() != null) {
+ bt.getParent().remove(bt);
+ }
+ }
+
+ public void removeEditButtons() {
+ removeButton(btAdd_);
+ removeButton(btAlign_);
+ removeButton(btRemove_);
+ }
+
public void setLabel(final BuLabel _lb) {
lbXyInfo_ = _lb;
}
@@ -776,7 +782,6 @@
}
selection_ = _s;
updater_ = new CtuluSelectionListTableModelUpdater(t_, selection_.getSelection()) {
-
protected void doAfterCtuluListSectionChanged() {
updateButtons();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|