|
|
@ -19,10 +19,12 @@ import com.jme3.shader.UniformBinding; |
|
|
|
import com.jme3.shader.VarType; |
|
|
|
import com.jme3.shader.VarType; |
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Component; |
|
|
|
import java.awt.Component; |
|
|
|
|
|
|
|
import java.awt.Cursor; |
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.Font; |
|
|
|
import java.awt.Font; |
|
|
|
import java.awt.Graphics; |
|
|
|
import java.awt.Graphics; |
|
|
|
import java.awt.Point; |
|
|
|
import java.awt.Point; |
|
|
|
|
|
|
|
import java.awt.Rectangle; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
import java.awt.event.ComponentEvent; |
|
|
|
import java.awt.event.ComponentEvent; |
|
|
@ -39,6 +41,7 @@ import javax.swing.JMenuItem; |
|
|
|
import javax.swing.JOptionPane; |
|
|
|
import javax.swing.JOptionPane; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPopupMenu; |
|
|
|
import javax.swing.JPopupMenu; |
|
|
|
|
|
|
|
import javax.swing.JScrollPane; |
|
|
|
import javax.swing.JSeparator; |
|
|
|
import javax.swing.JSeparator; |
|
|
|
import javax.swing.JViewport; |
|
|
|
import javax.swing.JViewport; |
|
|
|
import javax.swing.SwingUtilities; |
|
|
|
import javax.swing.SwingUtilities; |
|
|
@ -67,7 +70,7 @@ public class Diagram extends JPanel implements MouseListener, MouseMotionListene |
|
|
|
|
|
|
|
|
|
|
|
addMouseListener(this); |
|
|
|
addMouseListener(this); |
|
|
|
addMouseMotionListener(this); |
|
|
|
addMouseMotionListener(this); |
|
|
|
createPopupMenu(); |
|
|
|
createPopupMenu(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -77,64 +80,79 @@ public class Diagram extends JPanel implements MouseListener, MouseMotionListene |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
|
|
|
|
|
|
|
|
for (OutBusPanel outBusPanel : outBuses) { |
|
|
|
if (e.getButton() == MouseEvent.BUTTON1) { |
|
|
|
Point p = SwingUtilities.convertPoint(this, e.getX(), e.getY(), outBusPanel); |
|
|
|
for (OutBusPanel outBusPanel : outBuses) { |
|
|
|
if (outBusPanel.contains(p)) { |
|
|
|
Point p = SwingUtilities.convertPoint(this, e.getX(), e.getY(), outBusPanel); |
|
|
|
MouseEvent me = SwingUtilities.convertMouseEvent(this, e, outBusPanel); |
|
|
|
if (outBusPanel.contains(p)) { |
|
|
|
outBusPanel.dispatchEvent(me); |
|
|
|
MouseEvent me = SwingUtilities.convertMouseEvent(this, e, outBusPanel); |
|
|
|
|
|
|
|
outBusPanel.dispatchEvent(me); |
|
|
|
|
|
|
|
if (me.isConsumed()) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Connection connection : connections) { |
|
|
|
|
|
|
|
MouseEvent me = SwingUtilities.convertMouseEvent(this, e, connection); |
|
|
|
|
|
|
|
connection.select(me); |
|
|
|
if (me.isConsumed()) { |
|
|
|
if (me.isConsumed()) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Connection connection : connections) { |
|
|
|
selectedItem = null; |
|
|
|
MouseEvent me = SwingUtilities.convertMouseEvent(this, e, connection); |
|
|
|
repaint(); |
|
|
|
connection.select(me); |
|
|
|
} else if (e.getButton() == MouseEvent.BUTTON2) { |
|
|
|
if (me.isConsumed()) { |
|
|
|
setCursor(hndCursor); |
|
|
|
return; |
|
|
|
pp.setLocation(e.getPoint()); |
|
|
|
} |
|
|
|
((JScrollPane)getParent().getParent()).setWheelScrollingEnabled(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
selectedItem = null; |
|
|
|
|
|
|
|
repaint(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void refreshPreviews(Material mat) { |
|
|
|
public void refreshPreviews(Material mat) { |
|
|
|
for (OutBusPanel outBusPanel : outBuses) { |
|
|
|
for (OutBusPanel outBusPanel : outBuses) { |
|
|
|
outBusPanel.updatePreview(mat); |
|
|
|
outBusPanel.updatePreview(mat); |
|
|
|
} |
|
|
|
} |
|
|
|
if(backDrop.isVisible()){ |
|
|
|
if (backDrop.isVisible()) { |
|
|
|
backDrop.showMaterial(mat); |
|
|
|
backDrop.showMaterial(mat); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void displayBackdrop(){ |
|
|
|
public void displayBackdrop() { |
|
|
|
if(backDrop.getParent()== null){ |
|
|
|
if (backDrop.getParent() == null) { |
|
|
|
add(backDrop); |
|
|
|
add(backDrop); |
|
|
|
((JViewport)getParent()).addChangeListener(backDrop); |
|
|
|
((JViewport) getParent()).addChangeListener(backDrop); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
backDrop.setVisible(true); |
|
|
|
backDrop.setVisible(true); |
|
|
|
backDrop.update(((JViewport)getParent())); |
|
|
|
backDrop.update(((JViewport) getParent())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Point clickLoc = new Point(0, 0); |
|
|
|
Point clickLoc = new Point(0, 0); |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
if (draggedFrom != null && draggedFrom.getNode() instanceof OutBusPanel) { |
|
|
|
|
|
|
|
MouseEvent me = SwingUtilities.convertMouseEvent(this, e, draggedFrom.getNode()); |
|
|
|
switch (e.getButton()) { |
|
|
|
draggedFrom.getNode().dispatchEvent(me); |
|
|
|
case MouseEvent.BUTTON1: |
|
|
|
if (me.isConsumed()) { |
|
|
|
if (draggedFrom != null && draggedFrom.getNode() instanceof OutBusPanel) { |
|
|
|
return; |
|
|
|
MouseEvent me = SwingUtilities.convertMouseEvent(this, e, draggedFrom.getNode()); |
|
|
|
} |
|
|
|
draggedFrom.getNode().dispatchEvent(me); |
|
|
|
} |
|
|
|
if (me.isConsumed()) { |
|
|
|
if (e.getButton() != MouseEvent.BUTTON3) { |
|
|
|
return; |
|
|
|
dispatchToOutBuses(e); |
|
|
|
} |
|
|
|
} else { |
|
|
|
} |
|
|
|
contextMenu.show(this, e.getX(), e.getY()); |
|
|
|
|
|
|
|
clickLoc.setLocation(e.getX(), e.getY()); |
|
|
|
dispatchToOutBuses(e); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case MouseEvent.BUTTON2: |
|
|
|
|
|
|
|
setCursor(defCursor); |
|
|
|
|
|
|
|
((JScrollPane)getParent().getParent()).setWheelScrollingEnabled(true); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case MouseEvent.BUTTON3: |
|
|
|
|
|
|
|
contextMenu.show(this, e.getX(), e.getY()); |
|
|
|
|
|
|
|
clickLoc.setLocation(e.getX(), e.getY()); |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -151,11 +169,11 @@ public class Diagram extends JPanel implements MouseListener, MouseMotionListene |
|
|
|
} |
|
|
|
} |
|
|
|
repaint(); |
|
|
|
repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void showEdit(NodePanel node) { |
|
|
|
protected void showEdit(NodePanel node) { |
|
|
|
parent.showShaderEditor(node.getName(),node.getType(),node.filePaths); |
|
|
|
parent.showShaderEditor(node.getName(), node.getType(), node.filePaths); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void notifyMappingCreation(Connection conn) { |
|
|
|
public void notifyMappingCreation(Connection conn) { |
|
|
|
parent.makeMapping(conn); |
|
|
|
parent.makeMapping(conn); |
|
|
|
} |
|
|
|
} |
|
|
@ -284,14 +302,28 @@ public class Diagram extends JPanel implements MouseListener, MouseMotionListene |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final Cursor defCursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); |
|
|
|
|
|
|
|
private final Cursor hndCursor = Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR); |
|
|
|
|
|
|
|
private final Point pp = new Point(); |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mouseDragged(MouseEvent e) { |
|
|
|
public void mouseDragged(MouseEvent e) { |
|
|
|
if (draggedFrom == null) { |
|
|
|
if (SwingUtilities.isLeftMouseButton(e)) { |
|
|
|
if (selectedItem instanceof OutBusPanel) { |
|
|
|
if (draggedFrom == null) { |
|
|
|
OutBusPanel bus = (OutBusPanel) selectedItem; |
|
|
|
if (selectedItem instanceof OutBusPanel) { |
|
|
|
MouseEvent me = SwingUtilities.convertMouseEvent(this, e, bus); |
|
|
|
OutBusPanel bus = (OutBusPanel) selectedItem; |
|
|
|
bus.dispatchEvent(me); |
|
|
|
MouseEvent me = SwingUtilities.convertMouseEvent(this, e, bus); |
|
|
|
|
|
|
|
bus.dispatchEvent(me); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else if (SwingUtilities.isMiddleMouseButton(e)) { |
|
|
|
|
|
|
|
JViewport vport = (JViewport) getParent(); |
|
|
|
|
|
|
|
Point cp = e.getPoint(); |
|
|
|
|
|
|
|
Point vp = vport.getViewPosition(); |
|
|
|
|
|
|
|
vp.translate(pp.x - cp.x, pp.y - cp.y); |
|
|
|
|
|
|
|
scrollRectToVisible(new Rectangle(vp, vport.getSize())); |
|
|
|
|
|
|
|
//pp.setLocation(cp);
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -313,7 +345,6 @@ public class Diagram extends JPanel implements MouseListener, MouseMotionListene |
|
|
|
start.connect(conn); |
|
|
|
start.connect(conn); |
|
|
|
end.connect(conn); |
|
|
|
end.connect(conn); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addConnection(conn); |
|
|
|
addConnection(conn); |
|
|
|
|
|
|
|
|
|
|
|
return conn; |
|
|
|
return conn; |
|
|
@ -401,14 +432,13 @@ public class Diagram extends JPanel implements MouseListener, MouseMotionListene |
|
|
|
return item; |
|
|
|
return item; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void clear() { |
|
|
|
public void clear(){ |
|
|
|
|
|
|
|
removeAll(); |
|
|
|
removeAll(); |
|
|
|
outBuses.clear(); |
|
|
|
outBuses.clear(); |
|
|
|
connections.clear(); |
|
|
|
connections.clear(); |
|
|
|
nodes.clear(); |
|
|
|
nodes.clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void createPopupMenu() { |
|
|
|
private void createPopupMenu() { |
|
|
|
contextMenu.setFont(new Font("Tahoma", 1, 10)); // NOI18N
|
|
|
|
contextMenu.setFont(new Font("Tahoma", 1, 10)); // NOI18N
|
|
|
|
contextMenu.setOpaque(true); |
|
|
|
contextMenu.setOpaque(true); |
|
|
@ -421,7 +451,6 @@ public class Diagram extends JPanel implements MouseListener, MouseMotionListene |
|
|
|
contextMenu.setBorder(BorderFactory.createCompoundBorder(contextMenu.getBorder(), |
|
|
|
contextMenu.setBorder(BorderFactory.createCompoundBorder(contextMenu.getBorder(), |
|
|
|
labelBorder)); |
|
|
|
labelBorder)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JMenuItem nodeItem = createMenuItem("Node", Icons.node); |
|
|
|
JMenuItem nodeItem = createMenuItem("Node", Icons.node); |
|
|
|
nodeItem.addActionListener(new ActionListener() { |
|
|
|
nodeItem.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|