Merged left and right display for debug frames, implemented better display for gear debug frame

This commit is contained in:
Robert S 2014-06-15 14:23:51 -04:00
parent d7cb8c8a64
commit 6cb7904e30
3 changed files with 85 additions and 55 deletions

View file

@ -1,5 +1,7 @@
package resonantinduction.mechanical.energy.grid;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Panel;
@ -7,7 +9,12 @@ import java.awt.Panel;
import javax.swing.AbstractListModel;
import javax.swing.DefaultListModel;
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.INodeProvider;
import resonantinduction.core.debug.FrameNodeDebug;
@ -54,44 +61,73 @@ public class MechanicalNodeFrame extends FrameNodeDebug
}
@Override
public void buildRight(UpdatePanel panel)
{
panel.setLayout(new GridLayout(2, 1, 0, 0));
Label label = new Label("Connections");
panel.add(label);
AbstractListModel model = new AbstractListModel()
public void buildCenter(UpdatePanel panel)
{
panel.setLayout(new BorderLayout());
TableModel dataModel = new AbstractTableModel()
{
@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 0;
return 10;
}
@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);
}
@Override
public void buildLeft(UpdatePanel panel)
{
panel.setLayout(new GridLayout(3, 1, 0, 0));
panel.add(tableScroll, BorderLayout.SOUTH);
UpdatePanel topPanel = new UpdatePanel();
topPanel.setLayout(new GridLayout(1, 3, 0, 0));
UpdatedLabel velLabel = new UpdatedLabel("Vel: ")
{
@Override
@ -100,7 +136,7 @@ public class MechanicalNodeFrame extends FrameNodeDebug
return super.buildLabel() + MechanicalNodeFrame.this.getNode().angularVelocity;
}
};
panel.add(velLabel);
topPanel.add(velLabel);
UpdatedLabel angleLabel = new UpdatedLabel("Angle: ")
{
@ -110,7 +146,7 @@ public class MechanicalNodeFrame extends FrameNodeDebug
return super.buildLabel() + MechanicalNodeFrame.this.getNode().renderAngle;
}
};
panel.add(angleLabel);
topPanel.add(angleLabel);
UpdatedLabel torqueLabel = new UpdatedLabel("Torque: ")
{
@ -120,7 +156,8 @@ public class MechanicalNodeFrame extends FrameNodeDebug
return super.buildLabel() + MechanicalNodeFrame.this.getNode().torque;
}
};
panel.add(torqueLabel);
topPanel.add(torqueLabel);
panel.add(topPanel, BorderLayout.NORTH);
}
@Override

View file

@ -1,5 +1,6 @@
package resonantinduction.mechanical.fluid.pipe;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
@ -52,8 +53,9 @@ public class PipeNodeFrame extends FrameNodeDebug
}
@Override
public void buildRight(UpdatePanel panel)
public void buildCenter(UpdatePanel panel)
{
panel.setLayout(new BorderLayout());
TableModel dataModel = new AbstractTableModel()
{
@Override
@ -93,11 +95,14 @@ public class PipeNodeFrame extends FrameNodeDebug
if (getNode() != null && getNode().getConnections() != null)
{
ForgeDirection dir = (ForgeDirection) getNode().getConnections().values().toArray()[row];
switch(col)
switch (col)
{
case 0: return dir;
case 1: return getNode().getConnections().keySet().toArray()[row];
case 2: return getNode().getPressure(dir);
case 0:
return dir;
case 1:
return getNode().getConnections().keySet().toArray()[row];
case 2:
return getNode().getPressure(dir);
}
}
return "00000";
@ -109,13 +114,10 @@ public class PipeNodeFrame extends FrameNodeDebug
Dimension tablePreferred = tableScroll.getPreferredSize();
tableScroll.setPreferredSize(new Dimension(tablePreferred.width, tablePreferred.height / 3));
panel.add(tableScroll);
}
panel.add(tableScroll, BorderLayout.SOUTH);
@Override
public void buildLeft(UpdatePanel panel)
{
panel.setLayout(new GridLayout(2, 1, 0, 0));
UpdatePanel topPanel = new UpdatePanel();
topPanel.setLayout(new GridLayout(1, 2, 0, 0));
UpdatedLabel velLabel = new UpdatedLabel("Fluid: ")
{
@Override
@ -124,7 +126,7 @@ public class PipeNodeFrame extends FrameNodeDebug
return super.buildLabel() + PipeNodeFrame.this.getNode().pipe().tank.getFluid();
}
};
panel.add(velLabel);
topPanel.add(velLabel);
UpdatedLabel angleLabel = new UpdatedLabel("Volume: ")
{
@ -134,7 +136,8 @@ public class PipeNodeFrame extends FrameNodeDebug
return super.buildLabel() + PipeNodeFrame.this.getNode().pipe().tank.getFluidAmount() + "mb";
}
};
panel.add(angleLabel);
topPanel.add(angleLabel);
panel.add(topPanel, BorderLayout.NORTH);
}
@Override

View file

@ -44,23 +44,19 @@ public class FrameDebug extends Frame implements IVectorWorld
Border loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
UpdatePanel topPanel = new UpdatePanel();
UpdatePanel botPanel = new UpdatePanel();
UpdatePanel leftPanel = new UpdatePanel();
UpdatePanel rightPanel = new UpdatePanel();
topPanel.setBorder(loweredetched);
botPanel.setBorder(loweredetched);
leftPanel.setBorder(loweredetched);
rightPanel.setBorder(loweredetched);
buildTop(topPanel);
buildBottom(botPanel);
buildLeft(leftPanel);
buildRight(rightPanel);
buildCenter(rightPanel);
this.add(topPanel, BorderLayout.NORTH);
this.add(botPanel, BorderLayout.SOUTH);
this.add(rightPanel, BorderLayout.EAST);
this.add(leftPanel, BorderLayout.WEST);
this.add(rightPanel, BorderLayout.CENTER);
//exit icon handler
addWindowListener(new WindowAdapter()
@ -135,9 +131,9 @@ public class FrameDebug extends Frame implements IVectorWorld
}
/** 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: ")
{
@Override
@ -147,12 +143,6 @@ public class FrameDebug extends Frame implements IVectorWorld
}
};
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: ")
{
@Override
@ -162,7 +152,7 @@ public class FrameDebug extends Frame implements IVectorWorld
}
};
panel.add(block_label);
UpdatedLabel meta_label = new UpdatedLabel("META: ")
{
@Override
@ -172,7 +162,7 @@ public class FrameDebug extends Frame implements IVectorWorld
}
};
panel.add(meta_label);
UpdatedLabel id_label = new UpdatedLabel("ID: ")
{
@Override