mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-13 14:56:29 -04:00
adds a wire tool tip
This commit is contained in:
parent
051852f9d0
commit
11fd98a087
@ -18,6 +18,8 @@ import de.neemann.digital.draw.elements.*;
|
||||
import de.neemann.digital.draw.graphics.Vector;
|
||||
import de.neemann.digital.draw.graphics.*;
|
||||
import de.neemann.digital.draw.library.*;
|
||||
import de.neemann.digital.draw.model.Net;
|
||||
import de.neemann.digital.draw.model.NetList;
|
||||
import de.neemann.digital.draw.shapes.Drawable;
|
||||
import de.neemann.digital.draw.shapes.InputShape;
|
||||
import de.neemann.digital.draw.shapes.ShapeFactory;
|
||||
@ -134,6 +136,8 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
private Circuit shallowCopy;
|
||||
private CircuitScrollPanel circuitScrollPanel;
|
||||
private TutorialListener tutorialListener;
|
||||
private boolean toolTipHighlighted = false;
|
||||
private NetList toolTipNetList;
|
||||
|
||||
|
||||
/**
|
||||
@ -429,6 +433,7 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
public void modify(Modification<Circuit> modification) {
|
||||
try {
|
||||
if (modification != null) {
|
||||
toolTipNetList = null;
|
||||
undoManager.apply(modification);
|
||||
if (tutorialListener != null)
|
||||
tutorialListener.modified(modification);
|
||||
@ -513,6 +518,11 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
|
||||
@Override
|
||||
public String getToolTipText(MouseEvent event) {
|
||||
if (toolTipHighlighted) {
|
||||
toolTipHighlighted = false;
|
||||
removeHighLighted();
|
||||
}
|
||||
|
||||
Vector pos = getPosVector(event);
|
||||
VisualElement ve = getCircuit().getElementAt(pos);
|
||||
if (ve != null) {
|
||||
@ -540,6 +550,22 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
ObservableValue v = w.getValue();
|
||||
if (v != null)
|
||||
return v.getValueString();
|
||||
else {
|
||||
if (highLighted == null || highLighted.isEmpty() || toolTipHighlighted) {
|
||||
try {
|
||||
if (toolTipNetList == null)
|
||||
toolTipNetList = new NetList(getCircuit());
|
||||
Net n = toolTipNetList.getNetOfPos(w.p1);
|
||||
if (n != null) {
|
||||
removeHighLighted();
|
||||
addHighLighted(n.getWires());
|
||||
toolTipHighlighted = true;
|
||||
}
|
||||
} catch (PinException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -921,6 +947,8 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
undoAction.setEnabled(false);
|
||||
redoAction.setEnabled(false);
|
||||
|
||||
toolTipNetList = null;
|
||||
|
||||
if (circuitScrollPanel != null)
|
||||
circuitScrollPanel.sizeChanged();
|
||||
fitCircuit();
|
||||
@ -1332,6 +1360,10 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
if (toolTipHighlighted) {
|
||||
removeHighLighted();
|
||||
toolTipHighlighted = false;
|
||||
}
|
||||
lastMousePos = new Vector(e.getX(), e.getY());
|
||||
activeMouseController.moved(e);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user