Merged left and right display for debug frames, implemented better display for gear debug frame
This commit is contained in:
parent
d7cb8c8a64
commit
6cb7904e30
3 changed files with 85 additions and 55 deletions
|
@ -1,5 +1,7 @@
|
||||||
package resonantinduction.mechanical.energy.grid;
|
package resonantinduction.mechanical.energy.grid;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Dimension;
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
import java.awt.Label;
|
import java.awt.Label;
|
||||||
import java.awt.Panel;
|
import java.awt.Panel;
|
||||||
|
@ -7,7 +9,12 @@ import java.awt.Panel;
|
||||||
import javax.swing.AbstractListModel;
|
import javax.swing.AbstractListModel;
|
||||||
import javax.swing.DefaultListModel;
|
import javax.swing.DefaultListModel;
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.table.AbstractTableModel;
|
||||||
|
import javax.swing.table.TableModel;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import resonant.api.grid.INode;
|
import resonant.api.grid.INode;
|
||||||
import resonant.api.grid.INodeProvider;
|
import resonant.api.grid.INodeProvider;
|
||||||
import resonantinduction.core.debug.FrameNodeDebug;
|
import resonantinduction.core.debug.FrameNodeDebug;
|
||||||
|
@ -54,44 +61,73 @@ public class MechanicalNodeFrame extends FrameNodeDebug
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildRight(UpdatePanel panel)
|
public void buildCenter(UpdatePanel panel)
|
||||||
{
|
{
|
||||||
panel.setLayout(new GridLayout(2, 1, 0, 0));
|
panel.setLayout(new BorderLayout());
|
||||||
|
TableModel dataModel = new AbstractTableModel()
|
||||||
Label label = new Label("Connections");
|
|
||||||
panel.add(label);
|
|
||||||
|
|
||||||
AbstractListModel model = new AbstractListModel()
|
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public int getSize()
|
public int getColumnCount()
|
||||||
{
|
{
|
||||||
if (getNode() != null)
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getColumnName(int column)
|
||||||
|
{
|
||||||
|
switch (column)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return "Direction";
|
||||||
|
case 1:
|
||||||
|
return "Tile";
|
||||||
|
case 2:
|
||||||
|
return "Torque";
|
||||||
|
case 3:
|
||||||
|
return "Speed";
|
||||||
|
}
|
||||||
|
return "---";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRowCount()
|
||||||
|
{
|
||||||
|
if (getNode() != null && getNode().getConnections() != null)
|
||||||
{
|
{
|
||||||
return getNode().getConnections().size();
|
return getNode().getConnections().size();
|
||||||
}
|
}
|
||||||
return 0;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getElementAt(int index)
|
public Object getValueAt(int row, int col)
|
||||||
{
|
{
|
||||||
if (getNode() != null)
|
if (getNode() != null && getNode().getConnections() != null)
|
||||||
{
|
{
|
||||||
return "[" + getNode().getConnections().keySet().toArray()[index] + "@" + getNode().getConnections().values().toArray()[index] + "]";
|
ForgeDirection dir = (ForgeDirection) getNode().getConnections().values().toArray()[row];
|
||||||
|
MechanicalNode node = (MechanicalNode) getNode().getConnections().keySet().toArray()[row];
|
||||||
|
switch(col)
|
||||||
|
{
|
||||||
|
case 0: return dir;
|
||||||
|
case 1: return node;
|
||||||
|
case 2: return node.getTorque();
|
||||||
|
case 3: return node.getAngularSpeed();
|
||||||
}
|
}
|
||||||
return null;
|
}
|
||||||
|
return "00000";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
connectionList_component = new JList(model);
|
JTable table = new JTable(dataModel);
|
||||||
|
table.setAutoCreateRowSorter(true);
|
||||||
|
JScrollPane tableScroll = new JScrollPane(table);
|
||||||
|
Dimension tablePreferred = tableScroll.getPreferredSize();
|
||||||
|
tableScroll.setPreferredSize(new Dimension(tablePreferred.width, tablePreferred.height / 3));
|
||||||
|
|
||||||
panel.add(connectionList_component);
|
panel.add(tableScroll, BorderLayout.SOUTH);
|
||||||
}
|
|
||||||
|
UpdatePanel topPanel = new UpdatePanel();
|
||||||
|
topPanel.setLayout(new GridLayout(1, 3, 0, 0));
|
||||||
|
|
||||||
@Override
|
|
||||||
public void buildLeft(UpdatePanel panel)
|
|
||||||
{
|
|
||||||
panel.setLayout(new GridLayout(3, 1, 0, 0));
|
|
||||||
UpdatedLabel velLabel = new UpdatedLabel("Vel: ")
|
UpdatedLabel velLabel = new UpdatedLabel("Vel: ")
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -100,7 +136,7 @@ public class MechanicalNodeFrame extends FrameNodeDebug
|
||||||
return super.buildLabel() + MechanicalNodeFrame.this.getNode().angularVelocity;
|
return super.buildLabel() + MechanicalNodeFrame.this.getNode().angularVelocity;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
panel.add(velLabel);
|
topPanel.add(velLabel);
|
||||||
|
|
||||||
UpdatedLabel angleLabel = new UpdatedLabel("Angle: ")
|
UpdatedLabel angleLabel = new UpdatedLabel("Angle: ")
|
||||||
{
|
{
|
||||||
|
@ -110,7 +146,7 @@ public class MechanicalNodeFrame extends FrameNodeDebug
|
||||||
return super.buildLabel() + MechanicalNodeFrame.this.getNode().renderAngle;
|
return super.buildLabel() + MechanicalNodeFrame.this.getNode().renderAngle;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
panel.add(angleLabel);
|
topPanel.add(angleLabel);
|
||||||
|
|
||||||
UpdatedLabel torqueLabel = new UpdatedLabel("Torque: ")
|
UpdatedLabel torqueLabel = new UpdatedLabel("Torque: ")
|
||||||
{
|
{
|
||||||
|
@ -120,7 +156,8 @@ public class MechanicalNodeFrame extends FrameNodeDebug
|
||||||
return super.buildLabel() + MechanicalNodeFrame.this.getNode().torque;
|
return super.buildLabel() + MechanicalNodeFrame.this.getNode().torque;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
panel.add(torqueLabel);
|
topPanel.add(torqueLabel);
|
||||||
|
panel.add(topPanel, BorderLayout.NORTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package resonantinduction.mechanical.fluid.pipe;
|
package resonantinduction.mechanical.fluid.pipe;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
|
|
||||||
|
@ -52,8 +53,9 @@ public class PipeNodeFrame extends FrameNodeDebug
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildRight(UpdatePanel panel)
|
public void buildCenter(UpdatePanel panel)
|
||||||
{
|
{
|
||||||
|
panel.setLayout(new BorderLayout());
|
||||||
TableModel dataModel = new AbstractTableModel()
|
TableModel dataModel = new AbstractTableModel()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -95,9 +97,12 @@ public class PipeNodeFrame extends FrameNodeDebug
|
||||||
ForgeDirection dir = (ForgeDirection) getNode().getConnections().values().toArray()[row];
|
ForgeDirection dir = (ForgeDirection) getNode().getConnections().values().toArray()[row];
|
||||||
switch (col)
|
switch (col)
|
||||||
{
|
{
|
||||||
case 0: return dir;
|
case 0:
|
||||||
case 1: return getNode().getConnections().keySet().toArray()[row];
|
return dir;
|
||||||
case 2: return getNode().getPressure(dir);
|
case 1:
|
||||||
|
return getNode().getConnections().keySet().toArray()[row];
|
||||||
|
case 2:
|
||||||
|
return getNode().getPressure(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "00000";
|
return "00000";
|
||||||
|
@ -109,13 +114,10 @@ public class PipeNodeFrame extends FrameNodeDebug
|
||||||
Dimension tablePreferred = tableScroll.getPreferredSize();
|
Dimension tablePreferred = tableScroll.getPreferredSize();
|
||||||
tableScroll.setPreferredSize(new Dimension(tablePreferred.width, tablePreferred.height / 3));
|
tableScroll.setPreferredSize(new Dimension(tablePreferred.width, tablePreferred.height / 3));
|
||||||
|
|
||||||
panel.add(tableScroll);
|
panel.add(tableScroll, BorderLayout.SOUTH);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
UpdatePanel topPanel = new UpdatePanel();
|
||||||
public void buildLeft(UpdatePanel panel)
|
topPanel.setLayout(new GridLayout(1, 2, 0, 0));
|
||||||
{
|
|
||||||
panel.setLayout(new GridLayout(2, 1, 0, 0));
|
|
||||||
UpdatedLabel velLabel = new UpdatedLabel("Fluid: ")
|
UpdatedLabel velLabel = new UpdatedLabel("Fluid: ")
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -124,7 +126,7 @@ public class PipeNodeFrame extends FrameNodeDebug
|
||||||
return super.buildLabel() + PipeNodeFrame.this.getNode().pipe().tank.getFluid();
|
return super.buildLabel() + PipeNodeFrame.this.getNode().pipe().tank.getFluid();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
panel.add(velLabel);
|
topPanel.add(velLabel);
|
||||||
|
|
||||||
UpdatedLabel angleLabel = new UpdatedLabel("Volume: ")
|
UpdatedLabel angleLabel = new UpdatedLabel("Volume: ")
|
||||||
{
|
{
|
||||||
|
@ -134,7 +136,8 @@ public class PipeNodeFrame extends FrameNodeDebug
|
||||||
return super.buildLabel() + PipeNodeFrame.this.getNode().pipe().tank.getFluidAmount() + "mb";
|
return super.buildLabel() + PipeNodeFrame.this.getNode().pipe().tank.getFluidAmount() + "mb";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
panel.add(angleLabel);
|
topPanel.add(angleLabel);
|
||||||
|
panel.add(topPanel, BorderLayout.NORTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -44,23 +44,19 @@ public class FrameDebug extends Frame implements IVectorWorld
|
||||||
Border loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
|
Border loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
|
||||||
UpdatePanel topPanel = new UpdatePanel();
|
UpdatePanel topPanel = new UpdatePanel();
|
||||||
UpdatePanel botPanel = new UpdatePanel();
|
UpdatePanel botPanel = new UpdatePanel();
|
||||||
UpdatePanel leftPanel = new UpdatePanel();
|
|
||||||
UpdatePanel rightPanel = new UpdatePanel();
|
UpdatePanel rightPanel = new UpdatePanel();
|
||||||
|
|
||||||
topPanel.setBorder(loweredetched);
|
topPanel.setBorder(loweredetched);
|
||||||
botPanel.setBorder(loweredetched);
|
botPanel.setBorder(loweredetched);
|
||||||
leftPanel.setBorder(loweredetched);
|
|
||||||
rightPanel.setBorder(loweredetched);
|
rightPanel.setBorder(loweredetched);
|
||||||
|
|
||||||
buildTop(topPanel);
|
buildTop(topPanel);
|
||||||
buildBottom(botPanel);
|
buildBottom(botPanel);
|
||||||
buildLeft(leftPanel);
|
buildCenter(rightPanel);
|
||||||
buildRight(rightPanel);
|
|
||||||
|
|
||||||
this.add(topPanel, BorderLayout.NORTH);
|
this.add(topPanel, BorderLayout.NORTH);
|
||||||
this.add(botPanel, BorderLayout.SOUTH);
|
this.add(botPanel, BorderLayout.SOUTH);
|
||||||
this.add(rightPanel, BorderLayout.EAST);
|
this.add(rightPanel, BorderLayout.CENTER);
|
||||||
this.add(leftPanel, BorderLayout.WEST);
|
|
||||||
|
|
||||||
//exit icon handler
|
//exit icon handler
|
||||||
addWindowListener(new WindowAdapter()
|
addWindowListener(new WindowAdapter()
|
||||||
|
@ -135,9 +131,9 @@ public class FrameDebug extends Frame implements IVectorWorld
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Left are of the Frame */
|
/** Left are of the Frame */
|
||||||
public void buildRight(UpdatePanel panel)
|
public void buildCenter(UpdatePanel panel)
|
||||||
{
|
{
|
||||||
panel.setLayout(new GridLayout(1, 2, 0, 0));
|
panel.setLayout(new GridLayout(1, 4, 0, 0));
|
||||||
UpdatedLabel tickLabel = new UpdatedLabel("Valid: ")
|
UpdatedLabel tickLabel = new UpdatedLabel("Valid: ")
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -147,12 +143,6 @@ public class FrameDebug extends Frame implements IVectorWorld
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
panel.add(tickLabel);
|
panel.add(tickLabel);
|
||||||
}
|
|
||||||
|
|
||||||
/** Right are of the Frame */
|
|
||||||
public void buildLeft(UpdatePanel panel)
|
|
||||||
{
|
|
||||||
panel.setLayout(new GridLayout(4, 1, 0, 0));
|
|
||||||
UpdatedLabel block_label = new UpdatedLabel("BLOCK: ")
|
UpdatedLabel block_label = new UpdatedLabel("BLOCK: ")
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue