mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-14 15:26:52 -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.Vector;
|
||||||
import de.neemann.digital.draw.graphics.*;
|
import de.neemann.digital.draw.graphics.*;
|
||||||
import de.neemann.digital.draw.library.*;
|
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.Drawable;
|
||||||
import de.neemann.digital.draw.shapes.InputShape;
|
import de.neemann.digital.draw.shapes.InputShape;
|
||||||
import de.neemann.digital.draw.shapes.ShapeFactory;
|
import de.neemann.digital.draw.shapes.ShapeFactory;
|
||||||
@ -134,6 +136,8 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
|||||||
private Circuit shallowCopy;
|
private Circuit shallowCopy;
|
||||||
private CircuitScrollPanel circuitScrollPanel;
|
private CircuitScrollPanel circuitScrollPanel;
|
||||||
private TutorialListener tutorialListener;
|
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) {
|
public void modify(Modification<Circuit> modification) {
|
||||||
try {
|
try {
|
||||||
if (modification != null) {
|
if (modification != null) {
|
||||||
|
toolTipNetList = null;
|
||||||
undoManager.apply(modification);
|
undoManager.apply(modification);
|
||||||
if (tutorialListener != null)
|
if (tutorialListener != null)
|
||||||
tutorialListener.modified(modification);
|
tutorialListener.modified(modification);
|
||||||
@ -513,6 +518,11 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getToolTipText(MouseEvent event) {
|
public String getToolTipText(MouseEvent event) {
|
||||||
|
if (toolTipHighlighted) {
|
||||||
|
toolTipHighlighted = false;
|
||||||
|
removeHighLighted();
|
||||||
|
}
|
||||||
|
|
||||||
Vector pos = getPosVector(event);
|
Vector pos = getPosVector(event);
|
||||||
VisualElement ve = getCircuit().getElementAt(pos);
|
VisualElement ve = getCircuit().getElementAt(pos);
|
||||||
if (ve != null) {
|
if (ve != null) {
|
||||||
@ -540,6 +550,22 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
|||||||
ObservableValue v = w.getValue();
|
ObservableValue v = w.getValue();
|
||||||
if (v != null)
|
if (v != null)
|
||||||
return v.getValueString();
|
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;
|
return null;
|
||||||
@ -921,6 +947,8 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
|||||||
undoAction.setEnabled(false);
|
undoAction.setEnabled(false);
|
||||||
redoAction.setEnabled(false);
|
redoAction.setEnabled(false);
|
||||||
|
|
||||||
|
toolTipNetList = null;
|
||||||
|
|
||||||
if (circuitScrollPanel != null)
|
if (circuitScrollPanel != null)
|
||||||
circuitScrollPanel.sizeChanged();
|
circuitScrollPanel.sizeChanged();
|
||||||
fitCircuit();
|
fitCircuit();
|
||||||
@ -1332,6 +1360,10 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseMoved(MouseEvent e) {
|
public void mouseMoved(MouseEvent e) {
|
||||||
|
if (toolTipHighlighted) {
|
||||||
|
removeHighLighted();
|
||||||
|
toolTipHighlighted = false;
|
||||||
|
}
|
||||||
lastMousePos = new Vector(e.getX(), e.getY());
|
lastMousePos = new Vector(e.getX(), e.getY());
|
||||||
activeMouseController.moved(e);
|
activeMouseController.moved(e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user