Commits

Wolfram Rittmeyer committed 78afeef

Added the possibility to set an x range

Comments (0)

Files changed (1)

HoloGraphLibrary/src/com/echo/holographlibrary/LineGraph.java

 		Line line = getLine(lineIndex);
 		line.addPoint(point);
 		lines.set(lineIndex, line);
-		resetYLimits();
+		resetLimits();
 		shouldUpdate = true;
 		postInvalidate();
 	}
 			line.addPoint(point);
 		}
 		lines.set(lineIndex, line);
-		resetYLimits();
+		resetLimits();
 		shouldUpdate = true;
 		postInvalidate();
 	}
 				line.removePoint(point);
 		}
 		lines.set(lineIndex, line);
-		resetYLimits();
+		resetLimits();
 		shouldUpdate = true;
 		postInvalidate();
 	}
 			line.removePoint(point);
 		}
 		lines.set(lineIndex, line);
-		resetYLimits();
+		resetLimits();
 		shouldUpdate = true;
 		postInvalidate();
 	}
 		Line line = getLine(lineIndex);
 		line.removePoint(point);
 		lines.set(lineIndex, line);
-		resetYLimits();
+		resetLimits();
 		shouldUpdate = true;
 		postInvalidate();
 	}
 		float range = getMaxY() - getMinY();
 		setRangeY(getMinY()-range*getRangeYRatio(), getMaxY()+range*getRangeYRatio());
 	}
+	public void resetXLimits(){
+		float range = getMaxX() - getMinX();
+		setRangeY(getMinX()-range*getRangeXRatio(), getMaxX()+range*getRangeXRatio());
+	}
+	public void resetLimits() {
+		resetYLimits();
+		resetXLimits();
+	}
 	public ArrayList<Line> getLines() {
 		return lines;
 	}
 		minY = (float)min;
 		maxY = (float)max;
 	}
+	public void setRangeX(float min, float max) {
+		minX = min;
+		maxX = max;
+	}
+	private void setRangeX(double min, double max){
+		minX = (float)min;
+		maxX = (float)max;
+	}
 	public float getMaxY(){
 		float max = lines.get(0).getPoint(0).getY();
 		for (Line line : lines){
 	public float getMaxLimY(){
 		return maxY;
 	}
+	public float getMinLimX(){
+		return minX;
+	}
+	public float getMaxLimX(){
+		return maxX;
+	}
 	public float getMaxX(){
 		float max = lines.size() > 0 ? lines.get(0).getPoint(0).getX() : 0;
 		for (Line line : lines){
 
 			float maxY = getMaxLimY();
 			float minY = getMinLimY();
-			float range = getMaxX() - getMinX();
-			float maxX = (float)(getMaxX()+range*getRangeXRatio());
-			float minX = (float)(getMinX()-range*getRangeXRatio());
-			
+			float maxX = getMaxLimX();
+			float minX = getMinLimX();
+
 	        
 			int lineCount = 0;
 			for (Line line : lines){