Correction drag acc
This commit is contained in:
parent
805ff7b813
commit
8a68404cf8
@ -1,78 +1,92 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
|
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
|
||||||
<properties>
|
<properties>
|
||||||
<comment>This file is automaticaly generated by AdecWatt application at 10:39 AM on Apr 17, 2019.</comment>
|
<comment>This file is automaticaly generated by AdecWatt application at 7:40 AM on Apr 18, 2019.</comment>
|
||||||
|
|
||||||
<entry key="DownloaddataChecked">true</entry>
|
<entry key="DownloaddataChecked">true</entry>
|
||||||
<entry key="RoleFurnitureManager">true</entry>
|
|
||||||
<entry key="Uploadhelp-en_USChecked">false</entry>
|
|
||||||
<entry key="HelpOrder">4</entry>
|
<entry key="HelpOrder">4</entry>
|
||||||
<entry key="Uploadhelp-br_FR_bretonChecked">false</entry>
|
|
||||||
|
|
||||||
|
|
||||||
<entry key="dumpDir">data/log/</entry>
|
<entry key="dumpDir">data/log/</entry>
|
||||||
<entry key="RoleStageManager">true</entry>
|
|
||||||
<entry key="EditChecked">true</entry>
|
<entry key="EditChecked">true</entry>
|
||||||
<entry key="RoleArchitect">true</entry>
|
|
||||||
<entry key="BoundGlue">true</entry>
|
<entry key="BoundGlue">true</entry>
|
||||||
<entry key="InSegmentGlue">false</entry>
|
<entry key="InSegmentGlue">false</entry>
|
||||||
<entry key="LastExport">/home/felix/perso/adecWatt56/data/export/CendresLampionsChapelleBleue.lpz</entry>
|
<entry key="LastExport">/home/felix/perso/adecWatt56/data/export/CendresLampionsChapelleBleue.lpz</entry>
|
||||||
<entry key="RemoteRemovehelp-es_ESChecked">false</entry>
|
|
||||||
<entry key="HelpPlace">North</entry>
|
<entry key="HelpPlace">North</entry>
|
||||||
<entry key="UploadsoftChecked">true</entry>
|
|
||||||
|
|
||||||
|
|
||||||
<entry key="GridGlue">true</entry>
|
<entry key="GridGlue">true</entry>
|
||||||
<entry key="FileOrder">0</entry>
|
<entry key="FileOrder">0</entry>
|
||||||
<entry key="UserId">0</entry>
|
|
||||||
<entry key="RemoteRemovesoftChecked">true</entry>
|
|
||||||
<entry key="LocalServerChecked">false</entry>
|
|
||||||
|
|
||||||
|
|
||||||
<entry key="EditOrder">1</entry>
|
<entry key="EditOrder">1</entry>
|
||||||
<entry key="HelpChecked">true</entry>
|
<entry key="HelpChecked">true</entry>
|
||||||
<entry key="ProxyPort">3128</entry>
|
<entry key="ProxyPort">3128</entry>
|
||||||
<entry key="TestedServerChecked">false</entry>
|
|
||||||
<entry key="Country">FR</entry>
|
|
||||||
<entry key="SearchOrder">5</entry>
|
<entry key="SearchOrder">5</entry>
|
||||||
<entry key="FilePlace">North</entry>
|
<entry key="FilePlace">North</entry>
|
||||||
<entry key="AboutLocation">[x=3 200,y=146]</entry>
|
|
||||||
|
<entry key="AboutLocation">[x=0,y=31]</entry>
|
||||||
|
|
||||||
<entry key="SearchUndocked">false</entry>
|
<entry key="SearchUndocked">false</entry>
|
||||||
|
|
||||||
<entry key="FileChecked">true</entry>
|
<entry key="FileChecked">true</entry>
|
||||||
<entry key="FrameLocation">[x=73,y=212]</entry>
|
<entry key="FrameLocation">[x=600,y=665]</entry>
|
||||||
<entry key="EditPlace">North</entry>
|
<entry key="EditPlace">North</entry>
|
||||||
<entry key="Uploadhelp-fr_FRChecked">false</entry>
|
|
||||||
<entry key="CheckPeriod">Day</entry>
|
<entry key="CheckPeriod">Day</entry>
|
||||||
<entry key="AboutChecked">false</entry>
|
<entry key="AboutChecked">false</entry>
|
||||||
<entry key="LicenceLocation">[x=3 200,y=146]</entry>
|
<entry key="LicenceLocation">[x=0,y=31]</entry>
|
||||||
<entry key="JConsoleLocation">[x=3 200,y=146]</entry>
|
|
||||||
<entry key="PlacementChecked">true</entry>
|
<entry key="PlacementChecked">true</entry>
|
||||||
<entry key="SliderUndocked">false</entry>
|
<entry key="SliderUndocked">false</entry>
|
||||||
<entry key="SliderOrder">2</entry>
|
<entry key="SliderOrder">2</entry>
|
||||||
<entry key="SearchPlace">North</entry>
|
<entry key="SearchPlace">North</entry>
|
||||||
<entry key="UploaddataChecked">false</entry>
|
|
||||||
<entry key="SearchChecked">true</entry>
|
<entry key="SearchChecked">true</entry>
|
||||||
<entry key="Uploadhelp-es_ESChecked">false</entry>
|
|
||||||
<entry key="JConsoleChecked">false</entry>
|
|
||||||
<entry key="Variant"/>
|
<entry key="Variant"/>
|
||||||
<entry key="RemoteRemovedataChecked">false</entry>
|
|
||||||
<entry key="DownloadsoftChecked">true</entry>
|
<entry key="DownloadsoftChecked">true</entry>
|
||||||
<entry key="SliderChecked">true</entry>
|
<entry key="SliderChecked">true</entry>
|
||||||
<entry key="AdecWattIcon">data/images/adecWatt.png</entry>
|
<entry key="AdecWattIcon">data/images/adecWatt.png</entry>
|
||||||
<entry key="RemoteRemovehelp-en_USChecked">false</entry>
|
|
||||||
<entry key="Language">fr</entry>
|
|
||||||
<entry key="FileUndocked">false</entry>
|
<entry key="FileUndocked">false</entry>
|
||||||
<entry key="SliderPlace">North</entry>
|
<entry key="SliderPlace">North</entry>
|
||||||
<entry key="Uploadhelp-imagesChecked">false</entry>
|
|
||||||
<entry key="Login">webmestre</entry>
|
|
||||||
<entry key="HelpUndocked">false</entry>
|
<entry key="HelpUndocked">false</entry>
|
||||||
|
|
||||||
<entry key="ManualChecked">false</entry>
|
<entry key="ManualChecked">false</entry>
|
||||||
<entry key="RemoteRemovehelp-br_FR_galloChecked">false</entry>
|
<entry key="LastCheck">20190418</entry>
|
||||||
<entry key="LastCheck">20190417</entry>
|
|
||||||
<entry key="RemoteRemovehelp-br_FR_bretonChecked">false</entry>
|
|
||||||
<entry key="HttpServerChecked">false</entry>
|
|
||||||
<entry key="LicenceChecked">false</entry>
|
<entry key="LicenceChecked">false</entry>
|
||||||
<entry key="HandleGlue">true</entry>
|
<entry key="HandleGlue">true</entry>
|
||||||
<entry key="PlacementOrder">3</entry>
|
<entry key="PlacementOrder">3</entry>
|
||||||
<entry key="RemoteRemovehelp-imagesChecked">false</entry>
|
|
||||||
<entry key="Uploadhelp-br_FR_galloChecked">false</entry>
|
|
||||||
<entry key="EditUndocked">false</entry>
|
<entry key="EditUndocked">false</entry>
|
||||||
<entry key="ManualLocation">[x=3 200,y=146]</entry>
|
<entry key="ManualLocation">[x=0,y=31]</entry>
|
||||||
<entry key="PlacementUndocked">false</entry>
|
<entry key="PlacementUndocked">false</entry>
|
||||||
<entry key="RemoteRemovehelp-fr_FRChecked">false</entry>
|
|
||||||
|
|
||||||
|
|
||||||
<entry key="PlacementPlace">North</entry>
|
<entry key="PlacementPlace">North</entry>
|
||||||
|
|
||||||
<entry key=""/>
|
<entry key=""/>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -53,26 +53,29 @@ public abstract class Item<P extends XmlPermanent<T, A>, T extends Enum<?>, A ex
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ========================================
|
// ========================================
|
||||||
|
public boolean onAcc (String accId, double theta, Point2D.Double realPos, double close) {
|
||||||
|
try {
|
||||||
|
double [] coord = new double [] {realPos.x, realPos.y};
|
||||||
|
Point2D.Double accPos = accCenter.get (accId);
|
||||||
|
DimensionDouble accSize = this.accSize.get (accId);
|
||||||
|
AffineTransform at = new AffineTransform ();
|
||||||
|
at.rotate (theta);
|
||||||
|
at.translate (-accPos.x, -accPos.y);
|
||||||
|
at.transform (coord, 0, coord, 0, 1);
|
||||||
|
double halfWidth = accSize.width/2+close, halfHeight = accSize.height/2+close;
|
||||||
|
if (coord[0] >= -halfWidth && coord[0] <= halfWidth &&
|
||||||
|
coord[1] >= -halfHeight && coord[1] <= halfHeight)
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
public ArrayList<Acc> findAccs (Point2D.Double realPos, double close) {
|
public ArrayList<Acc> findAccs (Point2D.Double realPos, double close) {
|
||||||
ArrayList<Acc> result = new ArrayList<Acc> ();
|
ArrayList<Acc> result = new ArrayList<Acc> ();
|
||||||
double theta = Math.toRadians (-getThetaDegree ());
|
double theta = Math.toRadians (-getThetaDegree ());
|
||||||
double [] coord = new double [] {realPos.x, realPos.y};
|
|
||||||
for (String accId : getEmbeddedIds ())
|
for (String accId : getEmbeddedIds ())
|
||||||
try {
|
if (onAcc (accId, theta, realPos, close))
|
||||||
coord[0] = realPos.x;
|
result.add (findEmbedded (accId));
|
||||||
coord[1] = realPos.y;
|
|
||||||
Point2D.Double accPos = accCenter.get (accId);
|
|
||||||
DimensionDouble accSize = this.accSize.get (accId);
|
|
||||||
AffineTransform at = new AffineTransform ();
|
|
||||||
at.rotate (theta);
|
|
||||||
at.translate (-accPos.x, -accPos.y);
|
|
||||||
at.transform (coord, 0, coord, 0, 1);
|
|
||||||
double halfWidth = accSize.width/2+close, halfHeight = accSize.height/2+close;
|
|
||||||
if (coord[0] >= -halfWidth && coord[0] <= halfWidth &&
|
|
||||||
coord[1] >= -halfHeight && coord[1] <= halfHeight)
|
|
||||||
result.add (findEmbedded (accId));
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package adecWatt.view;
|
package adecWatt.view;
|
||||||
|
|
||||||
|
import adecWatt.model.Acc;
|
||||||
|
import adecWatt.model.Item;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import adecWatt.model.Acc;
|
|
||||||
import adecWatt.model.Item;
|
|
||||||
|
|
||||||
@SuppressWarnings ("serial")
|
@SuppressWarnings ("serial")
|
||||||
public class JAcc extends JLabel {
|
public class JAcc extends JLabel {
|
||||||
@ -27,9 +28,9 @@ public class JAcc extends JLabel {
|
|||||||
setIcon (acc.getModel ().getIcon (16));
|
setIcon (acc.getModel ().getIcon (16));
|
||||||
setSize (getPreferredSize ());
|
setSize (getPreferredSize ());
|
||||||
setPos ();
|
setPos ();
|
||||||
AccMouseAdapter accMouseAdapter = new AccMouseAdapter ();
|
// AccMouseAdapter accMouseAdapter = new AccMouseAdapter ();
|
||||||
addMouseListener (accMouseAdapter);
|
// addMouseListener (accMouseAdapter);
|
||||||
addMouseMotionListener (accMouseAdapter);
|
// addMouseMotionListener (accMouseAdapter);
|
||||||
}
|
}
|
||||||
public void setPos () {
|
public void setPos () {
|
||||||
setPos (jWorkspaceView.scaleModelToView (item.getAccCenter (acc.getId ())));
|
setPos (jWorkspaceView.scaleModelToView (item.getAccCenter (acc.getId ())));
|
||||||
@ -112,6 +113,11 @@ public class JAcc extends JLabel {
|
|||||||
// } catch (Exception e2) {
|
// } catch (Exception e2) {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
// ========================================
|
||||||
|
public boolean contains (Point2D.Double realPos, double close) {
|
||||||
|
double theta = Math.toRadians (-item.getThetaDegree ());
|
||||||
|
return item.onAcc (acc.getId (), theta, realPos, close);
|
||||||
|
}
|
||||||
|
|
||||||
// ========================================
|
// ========================================
|
||||||
public void dragAcc (Dimension delta) {
|
public void dragAcc (Dimension delta) {
|
||||||
|
@ -4,6 +4,7 @@ import java.awt.Point;
|
|||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -22,8 +23,15 @@ import adecWatt.control.AdecWattManager;
|
|||||||
this.jWorkspaceView = jWorkspaceView;
|
this.jWorkspaceView = jWorkspaceView;
|
||||||
this.mouseEvent = mouseEvent;
|
this.mouseEvent = mouseEvent;
|
||||||
Point pos = mouseEvent.getPoint ();
|
Point pos = mouseEvent.getPoint ();
|
||||||
|
if (jWorkspaceView.selectedAcc != null) {
|
||||||
|
Point2D.Double realPos = jWorkspaceView.scaleViewToModel (new Point (pos.x, pos.y));
|
||||||
|
if (jWorkspaceView.selectedAcc.contains (realPos, jWorkspaceView.closePixelsAccs/jWorkspaceView.scale))
|
||||||
|
return;
|
||||||
|
}
|
||||||
ArrayList<Item> overlapItems = jWorkspaceView.findItems (pos);
|
ArrayList<Item> overlapItems = jWorkspaceView.findItems (pos);
|
||||||
if (mouseEvent.getID () == MouseEvent.MOUSE_PRESSED && !SwingUtilities.isRightMouseButton (mouseEvent) &&
|
if (mouseEvent.getID () == MouseEvent.MOUSE_PRESSED &&
|
||||||
|
!mouseEvent.isShiftDown () &&
|
||||||
|
!SwingUtilities.isRightMouseButton (mouseEvent) &&
|
||||||
jWorkspaceView.selectedItems.size () > 0) {
|
jWorkspaceView.selectedItems.size () > 0) {
|
||||||
for (final JItem jItem : jWorkspaceView.selectedItems.values ())
|
for (final JItem jItem : jWorkspaceView.selectedItems.values ())
|
||||||
if (overlapItems.contains (jItem.getItem ())) {
|
if (overlapItems.contains (jItem.getItem ())) {
|
||||||
@ -53,6 +61,7 @@ import adecWatt.control.AdecWattManager;
|
|||||||
});
|
});
|
||||||
add (menuItem);
|
add (menuItem);
|
||||||
}
|
}
|
||||||
|
jWorkspaceView.noDrag ();
|
||||||
show (jWorkspaceView, pos.x, pos.y);
|
show (jWorkspaceView, pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,7 +241,11 @@ import adecWatt.model.unit.Workspace;
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//private ArrayList<Item> overlapItems;
|
public void noDrag () {
|
||||||
|
refHandle = null;
|
||||||
|
handleOff = null;
|
||||||
|
//firstClick = lastClick = null;
|
||||||
|
}
|
||||||
public void startDrag (Item<?,?,?> item, Point mPos) {
|
public void startDrag (Item<?,?,?> item, Point mPos) {
|
||||||
firstClick = lastClick = mPos;
|
firstClick = lastClick = mPos;
|
||||||
selectionRefHandle (item, mPos);
|
selectionRefHandle (item, mPos);
|
||||||
@ -256,6 +260,7 @@ import adecWatt.model.unit.Workspace;
|
|||||||
}
|
}
|
||||||
Hashtable<Item, ArrayList<Acc>> overlapAccs = findAccs (mPos, item);
|
Hashtable<Item, ArrayList<Acc>> overlapAccs = findAccs (mPos, item);
|
||||||
if (overlapAccs.size () > 0) {
|
if (overlapAccs.size () > 0) {
|
||||||
|
firstClick = lastClick = mPos;
|
||||||
lastSelectedAccId = (lastSelectedAccId+1)%nbOverlapAccs (overlapAccs);
|
lastSelectedAccId = (lastSelectedAccId+1)%nbOverlapAccs (overlapAccs);
|
||||||
setSelectedAcc (overlapAccs, lastSelectedAccId);
|
setSelectedAcc (overlapAccs, lastSelectedAccId);
|
||||||
return;
|
return;
|
||||||
@ -265,11 +270,8 @@ import adecWatt.model.unit.Workspace;
|
|||||||
if (e.isShiftDown ()) {
|
if (e.isShiftDown ()) {
|
||||||
//invertItemSelection (overlapItems.get (0));
|
//invertItemSelection (overlapItems.get (0));
|
||||||
invertItemSelection (item);
|
invertItemSelection (item);
|
||||||
if (selectedItems.size () < 1) {
|
if (selectedItems.size () < 1)
|
||||||
firstClick = lastClick = null;
|
noDrag ();
|
||||||
refHandle = null;
|
|
||||||
handleOff = null;
|
|
||||||
}
|
|
||||||
// XXX changement du choix de la poignée de référence ?
|
// XXX changement du choix de la poignée de référence ?
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -453,6 +455,7 @@ import adecWatt.model.unit.Workspace;
|
|||||||
protected void setSelectedAcc () {
|
protected void setSelectedAcc () {
|
||||||
if (selectedAcc == null)
|
if (selectedAcc == null)
|
||||||
return;
|
return;
|
||||||
|
firstClick = lastClick = null;
|
||||||
remove (selectedAcc);
|
remove (selectedAcc);
|
||||||
selectedAcc = null;
|
selectedAcc = null;
|
||||||
updateSelection ();
|
updateSelection ();
|
||||||
@ -688,8 +691,6 @@ import adecWatt.model.unit.Workspace;
|
|||||||
ArrayList<Item> dstItems = workspace.findItems (realPos, closePixelsItems/scale);
|
ArrayList<Item> dstItems = workspace.findItems (realPos, closePixelsItems/scale);
|
||||||
PermanentDB permanentDB = adecWatt.getPermanentDB ();
|
PermanentDB permanentDB = adecWatt.getPermanentDB ();
|
||||||
if (selectedAcc.getAcc ().getDirectUnit ().isDescendingFrom (permanentDB.getPowerPlugId ())) {
|
if (selectedAcc.getAcc ().getDirectUnit ().isDescendingFrom (permanentDB.getPowerPlugId ())) {
|
||||||
|
|
||||||
|
|
||||||
if (dstItems.size () < 1) {
|
if (dstItems.size () < 1) {
|
||||||
eraseAcc (selectedAcc.getAcc ());
|
eraseAcc (selectedAcc.getAcc ());
|
||||||
return;
|
return;
|
||||||
@ -794,9 +795,7 @@ import adecWatt.model.unit.Workspace;
|
|||||||
} catch (Exception e2) {
|
} catch (Exception e2) {
|
||||||
e2.printStackTrace ();
|
e2.printStackTrace ();
|
||||||
} finally {
|
} finally {
|
||||||
firstClick = lastClick = null;
|
noDrag ();
|
||||||
refHandle = null;
|
|
||||||
handleOff = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void storyRotResizeItem (JItem jItem) {
|
public void storyRotResizeItem (JItem jItem) {
|
||||||
|
Loading…
Reference in New Issue
Block a user