Some work on graphs

This commit is contained in:
Calclavia 2014-01-29 13:36:27 +08:00
parent 47834c5e15
commit 411c3b8161
3 changed files with 60 additions and 8 deletions

View file

@ -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);
}
}

View file

@ -64,8 +64,6 @@ public class PartMultimeter extends JCuboidPart implements TFacePart, JNormalOcc
} }
} }
public Set<EntityPlayer> playersUsing = new HashSet<EntityPlayer>();
public enum DetectMode public enum DetectMode
{ {
NONE("none"), LESS_THAN("lessThan"), LESS_THAN_EQUAL("lessThanOrEqual"), EQUAL("equal"), 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 DetectMode detectMode = DetectMode.NONE;
private long peakDetection; private long peakDetection;
private long energyLimit; private long energyLimit;
@ -88,6 +88,8 @@ public class PartMultimeter extends JCuboidPart implements TFacePart, JNormalOcc
private byte side; private byte side;
private int ticks; private int ticks;
public Graph graph;
public void preparePlacement(int side, int itemDamage) public void preparePlacement(int side, int itemDamage)
{ {
this.side = (byte) (side ^ 1); this.side = (byte) (side ^ 1);
@ -377,19 +379,19 @@ public class PartMultimeter extends JCuboidPart implements TFacePart, JNormalOcc
} }
} }
// @Override // @Override
public boolean canConnectRedstone(int arg0) public boolean canConnectRedstone(int arg0)
{ {
return true; return true;
} }
//@Override // @Override
public int strongPowerLevel(int arg0) public int strongPowerLevel(int arg0)
{ {
return redstoneOn ? 14 : 0; return redstoneOn ? 14 : 0;
} }
//@Override // @Override
public int weakPowerLevel(int arg0) public int weakPowerLevel(int arg0)
{ {
return redstoneOn ? 14 : 0; return redstoneOn ? 14 : 0;

View file

@ -31,7 +31,7 @@ public class RenderMultimeter
{ {
GL11.glPushMatrix(); GL11.glPushMatrix();
RenderUtility.rotateFaceBlockToSide(part.getDirection()); RenderUtility.rotateFaceBlockToSide(part.getDirection());
/** /**
* The more space we have, the more information we render. * The more space we have, the more information we render.
* *
@ -39,8 +39,8 @@ public class RenderMultimeter
* 1x2: Show storage + capacity * 1x2: Show storage + capacity
* 3x3: Show graph behind * 3x3: Show graph behind
*/ */
RenderUtility.renderText("test", 0, 1, x, y, z);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }