Some work on graphs
This commit is contained in:
parent
47834c5e15
commit
411c3b8161
3 changed files with 60 additions and 8 deletions
|
@ -0,0 +1,50 @@
|
|||
package resonantinduction.electrical.multimeter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Graph
|
||||
{
|
||||
private final int maxPoints;
|
||||
|
||||
/**
|
||||
* Each point represents a tick.
|
||||
*/
|
||||
private List<Long> points = new ArrayList<Long>();
|
||||
private long peak;
|
||||
|
||||
public Graph(int maxPoints)
|
||||
{
|
||||
this.maxPoints = maxPoints;
|
||||
}
|
||||
|
||||
public void add(long y)
|
||||
{
|
||||
if (y > peak)
|
||||
{
|
||||
peak = y;
|
||||
}
|
||||
|
||||
points.add(0, y);
|
||||
|
||||
if (points.size() > maxPoints)
|
||||
{
|
||||
if (points.get(maxPoints) == peak)
|
||||
{
|
||||
peak = 0;
|
||||
}
|
||||
|
||||
points.remove(maxPoints);
|
||||
}
|
||||
}
|
||||
|
||||
public long getPeak()
|
||||
{
|
||||
return peak;
|
||||
}
|
||||
|
||||
public long get(int x)
|
||||
{
|
||||
return points.get(x);
|
||||
}
|
||||
}
|
|
@ -64,8 +64,6 @@ public class PartMultimeter extends JCuboidPart implements TFacePart, JNormalOcc
|
|||
}
|
||||
}
|
||||
|
||||
public Set<EntityPlayer> playersUsing = new HashSet<EntityPlayer>();
|
||||
|
||||
public enum DetectMode
|
||||
{
|
||||
NONE("none"), LESS_THAN("lessThan"), LESS_THAN_EQUAL("lessThanOrEqual"), EQUAL("equal"),
|
||||
|
@ -79,6 +77,8 @@ public class PartMultimeter extends JCuboidPart implements TFacePart, JNormalOcc
|
|||
}
|
||||
}
|
||||
|
||||
public Set<EntityPlayer> playersUsing = new HashSet<EntityPlayer>();
|
||||
|
||||
private DetectMode detectMode = DetectMode.NONE;
|
||||
private long peakDetection;
|
||||
private long energyLimit;
|
||||
|
@ -88,6 +88,8 @@ public class PartMultimeter extends JCuboidPart implements TFacePart, JNormalOcc
|
|||
private byte side;
|
||||
private int ticks;
|
||||
|
||||
public Graph graph;
|
||||
|
||||
public void preparePlacement(int side, int itemDamage)
|
||||
{
|
||||
this.side = (byte) (side ^ 1);
|
||||
|
@ -377,19 +379,19 @@ public class PartMultimeter extends JCuboidPart implements TFacePart, JNormalOcc
|
|||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @Override
|
||||
public boolean canConnectRedstone(int arg0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//@Override
|
||||
// @Override
|
||||
public int strongPowerLevel(int arg0)
|
||||
{
|
||||
return redstoneOn ? 14 : 0;
|
||||
}
|
||||
|
||||
//@Override
|
||||
// @Override
|
||||
public int weakPowerLevel(int arg0)
|
||||
{
|
||||
return redstoneOn ? 14 : 0;
|
||||
|
|
|
@ -31,7 +31,7 @@ public class RenderMultimeter
|
|||
{
|
||||
GL11.glPushMatrix();
|
||||
RenderUtility.rotateFaceBlockToSide(part.getDirection());
|
||||
|
||||
|
||||
/**
|
||||
* The more space we have, the more information we render.
|
||||
*
|
||||
|
@ -39,8 +39,8 @@ public class RenderMultimeter
|
|||
* 1x2: Show storage + capacity
|
||||
* 3x3: Show graph behind
|
||||
*/
|
||||
|
||||
|
||||
|
||||
RenderUtility.renderText("test", 0, 1, x, y, z);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue