Function bodies 149 total
setFullScreen method · java · L583-L589 (7 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void setFullScreen() {
width = mNativeLib.getXRes();
height = mNativeLib.getYRes();
displayHeight = mNativeLib.getYRes();
displayWidth = mNativeLib.getXRes();
setPos(mNativeLib.getXRes()/2.0f, mNativeLib.getYRes()/2.0f, 1.0f);
}setPos method · java · L592-L608 (17 LOC)app/src/main/java/byrne/fractal/FractalView.java
private boolean setPos(float centerX, float centerY, float scale) {
float ws = (width / 2) * scale, hs = (height / 2) * scale;
float newMinX = centerX - ws, newMinY = centerY - hs, newMaxX = centerX + ws, newMaxY = centerY + hs;
if (newMinX > displayWidth - SCREEN_MARGIN || newMaxX < SCREEN_MARGIN || newMinY > displayHeight - SCREEN_MARGIN || newMaxY < SCREEN_MARGIN)
return false;
this.centerX = centerX;
this.centerY = centerY;
this.scale = scale;
this.minX = newMinX;
this.minY = newMinY;
this.maxX = newMaxX;
this.maxY = newMaxY;
return true;
}draw method · java · L610-L613 (4 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void draw(Canvas canvas) {
drawable.setBounds((int) minX, (int) minY, (int) maxX, (int) maxY);
drawable.draw(canvas);
}getDrawable method · java · L615-L617 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public BitmapDrawable getDrawable() {
return drawable;
}setDrawable method · java · L619-L621 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void setDrawable(BitmapDrawable bd) {
drawable = bd;
}getWidth method · java · L623-L625 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public int getWidth() {
return width;
}getHeight method · java · L627-L629 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public int getHeight() {
return height;
}Want fix-PRs on findings? Install Repobility's GitHub App · github.com/apps/repobility-bot
getCenterX method · java · L631-L633 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public float getCenterX() {
return centerX;
}getCenterY method · java · L635-L637 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public float getCenterY() {
return centerY;
}getScale method · java · L639-L641 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public float getScale() {
return scale;
}getMinX method · java · L643-L645 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public float getMinX() {
return minX;
}getMaxX method · java · L647-L649 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public float getMaxX() {
return maxX;
}getMinY method · java · L651-L653 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public float getMinY() {
return minY;
}getMaxY method · java · L655-L657 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public float getMaxY() {
return maxY;
}Fractoid class · java · L42-L406 (365 LOC)app/src/main/java/byrne/fractal/Fractoid.java
public class Fractoid extends Activity {
private FractalView fractalView;
private Button juliaButton, calibrateButton;
MenuItem itemPhoenix;
boolean relativeColors = false;
private final int MAX_ITERATIONS_DIALOG = 1;
private final int TRAP_FACTOR_DIALOG = 2;
private int checkedColorId = R.id.rainbow_button;
private int checkedEquationId = R.id.z2_button;
private int checkedAlgorithmId = R.id.escape_time_button;
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main_layout);
//Debug.startMethodTracing("calc");
fractalView = (FractalView) findViewById(R.id.mFractalView);
fractalView.setFractoid(this);
juliaButton = (Button) findViewById(R.id.juliaButton);
juliaButton.setOnClickListener(new View.OnClickListRepobility — same analyzer, your code, free for public repos · /scan/
onClick method · java · L68-L72 (5 LOC)app/src/main/java/byrne/fractal/Fractoid.java
public void onClick(View v) {
setJuliaButtonEnabled(false);
fractalView.setZoom(false);
fractalView.postInvalidate();
}onClick method · java · L77-L91 (15 LOC)app/src/main/java/byrne/fractal/Fractoid.java
public void onClick(View v) {
PopupMenu popup = new PopupMenu(Fractoid.this, v);
popup.getMenuInflater().inflate(R.menu.options_menu, popup.getMenu());
Menu menu = popup.getMenu();
itemPhoenix = menu.findItem(R.id.phoenix_button);
menu.findItem(checkedColorId).setChecked(true);
menu.findItem(checkedEquationId).setChecked(true);
menu.findItem(checkedAlgorithmId).setChecked(true);
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
return onOptionsItemSelected(item);
}
});
popup.show();
}onMenuItemClick method · java · L86-L88 (3 LOC)app/src/main/java/byrne/fractal/Fractoid.java
public boolean onMenuItemClick(MenuItem item) {
return onOptionsItemSelected(item);
}onClick method · java · L96-L105 (10 LOC)app/src/main/java/byrne/fractal/Fractoid.java
public void onClick(View v) {
if (!relativeColors) {
relativeColors = true;
} else {
relativeColors = false;
}
fractalView.setRelative(relativeColors);
fractalView.startFractalTask(false);
fractalView.postInvalidate();
}onClick method · java · L143-L148 (6 LOC)app/src/main/java/byrne/fractal/Fractoid.java
public void onClick(View v) {
try {
fractalView.setMaxIterations(Integer.parseInt(maxIterationsText.getText().toString()));
dismissDialog(MAX_ITERATIONS_DIALOG);
} catch (NumberFormatException e) {System.out.println(e);}
}onClick method · java · L163-L169 (7 LOC)app/src/main/java/byrne/fractal/Fractoid.java
public void onClick(View v) {
try {
fractalView.setTrapFactor(Integer.parseInt(trapFactorText.getText().toString()));
dismissDialog(TRAP_FACTOR_DIALOG);
fractalView.startFractalTask(true);
} catch (NumberFormatException e) {System.out.println(e);}
}saveImage method · java · L179-L188 (10 LOC)app/src/main/java/byrne/fractal/Fractoid.java
public Uri saveImage() {
//TODO Display an error dialog if user tries to save while image is being rendered
try{
String path = Media.insertImage(getContentResolver(), fractalView.getFractal(), "Fractal", "Generated using Fractoid");
return Uri.parse(path);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}setCalibrateButtonEnabled method · java · L190-L202 (13 LOC)app/src/main/java/byrne/fractal/Fractoid.java
public void setCalibrateButtonEnabled(boolean b, boolean r) {
if (b) {
relativeColors = r;
if (relativeColors)
calibrateButton.setText("Absolute Colors");
else
calibrateButton.setText("Relative Colors");
calibrateButton.setVisibility(View.VISIBLE);
} else {
calibrateButton.setVisibility(View.INVISIBLE);
}
calibrateButton.setEnabled(b);
}Repobility · code-quality intelligence platform · https://repobility.com
setJuliaButtonEnabled method · java · L204-L211 (8 LOC)app/src/main/java/byrne/fractal/Fractoid.java
public void setJuliaButtonEnabled(boolean b) {
if (b) {
juliaButton.setVisibility(View.VISIBLE);
} else {
juliaButton.setVisibility(View.INVISIBLE);
}
juliaButton.setEnabled(b);
}switchColorSet method · java · L213-L217 (5 LOC)app/src/main/java/byrne/fractal/Fractoid.java
public void switchColorSet(MenuItem item, ColorSet cs) {
checkedColorId = item.getItemId();
fractalView.setColorSet(cs);
item.setChecked(true);
}switchAlgorithm method · java · L219-L223 (5 LOC)app/src/main/java/byrne/fractal/Fractoid.java
public void switchAlgorithm(MenuItem item, Algorithm alg) {
checkedAlgorithmId = item.getItemId();
fractalView.setAlgorithm(alg);
item.setChecked(true);
}switchEquation method · java · L225-L239 (15 LOC)app/src/main/java/byrne/fractal/Fractoid.java
public void switchEquation(MenuItem item, ComplexEquation e) {
checkedEquationId = item.getItemId();
item.setChecked(true);
fractalView.setEquation(e);
if (item.getItemId() == R.id.phoenix_button) {
/*
The mandelbrot fractal for this equation is ugly so
we only allow the user to explore the Julia version
*/
setJuliaButtonEnabled(false);
} else {
setJuliaButtonEnabled(true);
}
fractalView.resetCoords();
}onOptionsItemSelected method · java · L249-L405 (157 LOC)app/src/main/java/byrne/fractal/Fractoid.java
public boolean onOptionsItemSelected(MenuItem item) {
if (fractalView.getType() == FractalType.MANDELBROT) {
setJuliaButtonEnabled(true);
fractalView.setZoom(true);
}
switch (item.getItemId()) {
case R.id.reset_button:
if (!itemPhoenix.isChecked())
setJuliaButtonEnabled(true);
fractalView.resetCoords();
return true;
case R.id.max_iteration_button:
showDialog(MAX_ITERATIONS_DIALOG);
return true;
case R.id.rainbow_button:
switchColorSet(item,ColorSet.RAINBOW);
return true;
case R.id.winter_button:
switchColorSet(item,ColorSet.WINTER);
return true;
case R.id.summer_button:
switchColorSet(item,ColorSet.SUMMER);
return true;
case R.id.orange_button:
switchColorSet(item,ColorSet.ORANGE);
return true;
case R.id.night_sky_button:
switchColorSet(item,ColorSet.NIGHT_SKY);
return true;
case R.id.camp_fire_buttonGenerateFractalTask class · java · L25-L135 (111 LOC)app/src/main/java/byrne/fractal/GenerateFractalTask.java
public class GenerateFractalTask extends AsyncTask<Void, Bitmap, Bitmap> {
FractalView fractalView;
long startTime;
NativeLib mNativeLib;
Paint paint;
int[] colors;
int prog = 0;
boolean relative;
public GenerateFractalTask(FractalView fv, boolean rel) {
fractalView = fv;
colors = fractalView.getColorSet();
paint = new Paint();
paint.setStyle(Paint.Style.FILL_AND_STROKE);
relative = rel;
mNativeLib = new NativeLib();
}
private Bitmap createBitmap() {
double realmin = mNativeLib.getRealMin();
double realmax = mNativeLib.getRealMax();
double imagmin = mNativeLib.getImagMin();
double imagmax = mNativeLib.getImagMax();
int xres = mNativeLib.getXRes();
int yres = mNativeLib.getYRes();
int minimum = mNativeLib.getMin();
int maximum = mNativeLib.getMax();
int range = maximum-minimum+1;
Bitmap b = Bitmap.createBitmap(xres, yres, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(GenerateFractalTask method · java · L35-L42 (8 LOC)app/src/main/java/byrne/fractal/GenerateFractalTask.java
public GenerateFractalTask(FractalView fv, boolean rel) {
fractalView = fv;
colors = fractalView.getColorSet();
paint = new Paint();
paint.setStyle(Paint.Style.FILL_AND_STROKE);
relative = rel;
mNativeLib = new NativeLib();
}createBitmap method · java · L44-L115 (72 LOC)app/src/main/java/byrne/fractal/GenerateFractalTask.java
private Bitmap createBitmap() {
double realmin = mNativeLib.getRealMin();
double realmax = mNativeLib.getRealMax();
double imagmin = mNativeLib.getImagMin();
double imagmax = mNativeLib.getImagMax();
int xres = mNativeLib.getXRes();
int yres = mNativeLib.getYRes();
int minimum = mNativeLib.getMin();
int maximum = mNativeLib.getMax();
int range = maximum-minimum+1;
Bitmap b = Bitmap.createBitmap(xres, yres, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
int[] rowColors;
double deltaP = (realmax - realmin)/xres;
double deltaQ = (imagmax - imagmin)/yres;
final int PASSES = 2;
int updateCount=0;
int state = 0;
for (int rpass = 0; rpass < PASSES; rpass++) {
paint.setStrokeWidth(PASSES-rpass);
for (int row=0; row < yres; row += PASSES-rpass) {
prog++;
updateCount++;
if (isCancelled()) {
return b;
}
if (uAbout: code-quality intelligence by Repobility · https://repobility.com
NativeLib class · java · L22-L51 (30 LOC)app/src/main/java/byrne/fractal/NativeLib.java
class NativeLib {
public native void resetValues();
public native void resetCurrentRow();
public native void freeValues();
public native void setResolution(int xres, int yres);
public native void setEquation(int equation, int power);
public native void setCoords(double realmin, double realmax, double imagmin, double imagmax);
public native void setMaxIterations(int max);
public native void setTrapFactor(int trapFactor);
public native void setFractalType(int type);
public native void setAlgorithm(int alg, int bailout);
public native void setCValue(double P, double Q);
public native int[] getFractalRow(int row, int state);
public native double getRealMin();
public native double getRealMax();
public native double getImagMin();
public native double getImagMax();
public native int getXRes();
public native int getYRes();
public native int getMin();
public native int getMax();
static {
System.loadLibrary("FractalMath");
}
}extractCurrPtInfo method · java · L108-L117 (10 LOC)app/src/main/java/org/metalev/multitouch/controller/MultiTouchController.java
private void extractCurrPtInfo() {
// Get new drag/pinch params. Only read multitouch fields that are needed,
// to avoid unnecessary computation (diameter and angle are expensive operations).
mCurrPtX = mCurrPt.getX();
mCurrPtY = mCurrPt.getY();
mCurrPtDiam = Math.max(MIN_MULTITOUCH_SEPARATION * .71f, !mCurrXform.updateScale ? 0.0f : mCurrPt.getMultiTouchDiameter());
mCurrPtWidth = Math.max(MIN_MULTITOUCH_SEPARATION, !mCurrXform.updateScaleXY ? 0.0f : mCurrPt.getMultiTouchWidth());
mCurrPtHeight = Math.max(MIN_MULTITOUCH_SEPARATION, !mCurrXform.updateScaleXY ? 0.0f : mCurrPt.getMultiTouchHeight());
mCurrPtAng = !mCurrXform.updateAngle ? 0.0f : mCurrPt.getMultiTouchAngle();
}MultiTouchController method · java · L159-L161 (3 LOC)app/src/main/java/org/metalev/multitouch/controller/MultiTouchController.java
public MultiTouchController(MultiTouchObjectCanvas<T> objectCanvas) {
this(objectCanvas, true);
}MultiTouchController method · java · L164-L169 (6 LOC)app/src/main/java/org/metalev/multitouch/controller/MultiTouchController.java
public MultiTouchController(MultiTouchObjectCanvas<T> objectCanvas, boolean handleSingleTouchEvents) {
this.mCurrPt = new PointInfo();
this.mPrevPt = new PointInfo();
this.handleSingleTouchEvents = handleSingleTouchEvents;
this.objectCanvas = objectCanvas;
}setHandleSingleTouchEvents method · java · L176-L178 (3 LOC)app/src/main/java/org/metalev/multitouch/controller/MultiTouchController.java
protected void setHandleSingleTouchEvents(boolean handleSingleTouchEvents) {
this.handleSingleTouchEvents = handleSingleTouchEvents;
}getHandleSingleTouchEvents method · java · L183-L185 (3 LOC)app/src/main/java/org/metalev/multitouch/controller/MultiTouchController.java
protected boolean getHandleSingleTouchEvents() {
return handleSingleTouchEvents;
}onTouchEvent method · java · L237-L297 (61 LOC)app/src/main/java/org/metalev/multitouch/controller/MultiTouchController.java
public boolean onTouchEvent(MotionEvent event) {
try {
int pointerCount = multiTouchSupported ? (Integer) m_getPointerCount.invoke(event) : 1;
if (DEBUG)
Log.i("MultiTouch", "Got here 1 - " + multiTouchSupported + " " + mMode + " " + handleSingleTouchEvents + " " + pointerCount);
if (mMode == MODE_NOTHING && !handleSingleTouchEvents && pointerCount == 1)
// Not handling initial single touch events, just pass them on
return false;
if (DEBUG)
Log.i("MultiTouch", "Got here 2");
// Handle history first (we sometimes get history with ACTION_MOVE events)
int action = event.getAction();
int histLen = event.getHistorySize() / pointerCount;
for (int histIddecodeTouchEvent method · java · L299-L310 (12 LOC)app/src/main/java/org/metalev/multitouch/controller/MultiTouchController.java
private void decodeTouchEvent(int pointerCount, float[] x, float[] y, float[] pressure, int[] pointerIds, int action, boolean down, long eventTime) {
if (DEBUG)
Log.i("MultiTouch", "Got here 5 - " + pointerCount + " " + action + " " + down);
// Swap curr/prev points
PointInfo tmp = mPrevPt;
mPrevPt = mCurrPt;
mCurrPt = tmp;
// Overwrite old prev point
mCurrPt.set(pointerCount, x, y, pressure, pointerIds, action, down, eventTime);
multiTouchController();
}Want fix-PRs on findings? Install Repobility's GitHub App · github.com/apps/repobility-bot
anchorAtThisPositionAndScale method · java · L315-L335 (21 LOC)app/src/main/java/org/metalev/multitouch/controller/MultiTouchController.java
private void anchorAtThisPositionAndScale() {
if (selectedObject == null)
return;
// Get selected object's current position and scale
objectCanvas.getPositionAndScale(selectedObject, mCurrXform);
// Figure out the object coords of the drag start point's screen coords.
// All stretching should be around this point in object-coord-space.
// Also figure out out ratio between object scale factor and multitouch
// diameter at beginning of drag; same for angle and optional anisotropic
// scale.
float currScaleInv = 1.0f / (!mCurrXform.updateScale ? 1.0f : mCurrXform.scale == 0.0f ? 1.0f : mCurrXform.scale);
extractCurrPtInfo();
startPosX = (mCurrPtX - mCurrXform.xOff) * currScaleInv;
startPosY = (mCurrPtY - mCurrXform.yOff) * currScaleInv;
startScaleOverperformDragOrPinch method · java · L338-L359 (22 LOC)app/src/main/java/org/metalev/multitouch/controller/MultiTouchController.java
private void performDragOrPinch() {
// Don't do anything if we're not dragging anything
if (selectedObject == null)
return;
// Calc new position of dragged object
float currScale = !mCurrXform.updateScale ? 1.0f : mCurrXform.scale == 0.0f ? 1.0f : mCurrXform.scale;
extractCurrPtInfo();
float newPosX = mCurrPtX - startPosX * currScale;
float newPosY = mCurrPtY - startPosY * currScale;
float newScale = startScaleOverPinchDiam * mCurrPtDiam;
float newScaleX = startScaleXOverPinchWidth * mCurrPtWidth;
float newScaleY = startScaleYOverPinchHeight * mCurrPtHeight;
float newAngle = startAngleMinusPinchAngle + mCurrPtAng;
// Set the new obj coords, scale, and angle as appropriate (notifying the subclass of the change).
mCurrXform.set(newPosX, newPosY, newSmultiTouchController method · java · L365-L458 (94 LOC)app/src/main/java/org/metalev/multitouch/controller/MultiTouchController.java
private void multiTouchController() {
if (DEBUG)
Log.i("MultiTouch", "Got here 6 - " + mMode + " " + mCurrPt.getNumTouchPoints() + " " + mCurrPt.isDown() + mCurrPt.isMultiTouch());
switch (mMode) {
case MODE_NOTHING:
// Not doing anything currently
if (mCurrPt.isDown()) {
// Start a new single-point drag
selectedObject = objectCanvas.getDraggableObjectAtPoint(mCurrPt);
if (selectedObject != null) {
// Started a new single-point drag
mMode = MODE_DRAG;
objectCanvas.selectObject(selectedObject, mCurrPt);
anchorAtThisPositionAndScale();
// Don't need any settling time if PointInfo class · java · L463-L688 (226 LOC)app/src/main/java/org/metalev/multitouch/controller/MultiTouchController.java
public static class PointInfo {
// Multitouch information
private int numPoints;
private float[] xs = new float[MAX_TOUCH_POINTS];
private float[] ys = new float[MAX_TOUCH_POINTS];
private float[] pressures = new float[MAX_TOUCH_POINTS];
private int[] pointerIds = new int[MAX_TOUCH_POINTS];
// Midpoint of pinch operations
private float xMid, yMid, pressureMid;
// Width/diameter/angle of pinch operations
private float dx, dy, diameter, diameterSq, angle;
// Whether or not there is at least one finger down (isDown) and/or at least two fingers down (isMultiTouch)
private boolean isDown, isMultiTouch;
// Whether or not these fields have already been calculated, for caching purposes
private boolean diameterSqIsCalculated, diameterIsCalculated, angleIsCalculatset method · java · L490-L522 (33 LOC)app/src/main/java/org/metalev/multitouch/controller/MultiTouchController.java
private void set(int numPoints, float[] x, float[] y, float[] pressure, int[] pointerIds, int action, boolean isDown, long eventTime) {
if (DEBUG)
Log.i("MultiTouch", "Got here 8 - " + +numPoints + " " + x[0] + " " + y[0] + " " + (numPoints > 1 ? x[1] : x[0]) + " "
+ (numPoints > 1 ? y[1] : y[0]) + " " + action + " " + isDown);
this.eventTime = eventTime;
this.action = action;
this.numPoints = numPoints;
for (int i = 0; i < numPoints; i++) {
this.xs[i] = x[i];
this.ys[i] = y[i];
this.pressures[i] = pressure[i];
this.pointerIds[i] = pointerIds[i];
}
this.isDown = isDown;
this.isset method · java · L528-L551 (24 LOC)app/src/main/java/org/metalev/multitouch/controller/MultiTouchController.java
public void set(PointInfo other) {
this.numPoints = other.numPoints;
for (int i = 0; i < numPoints; i++) {
this.xs[i] = other.xs[i];
this.ys[i] = other.ys[i];
this.pressures[i] = other.pressures[i];
this.pointerIds[i] = other.pointerIds[i];
}
this.xMid = other.xMid;
this.yMid = other.yMid;
this.pressureMid = other.pressureMid;
this.dx = other.dx;
this.dy = other.dy;
this.diameter = other.diameter;
this.diameterSq = other.diameterSq;
this.angle = other.angle;
this.isDown = other.isDown;
this.action = other.action;
tisMultiTouch method · java · L556-L558 (3 LOC)app/src/main/java/org/metalev/multitouch/controller/MultiTouchController.java
public boolean isMultiTouch() {
return isMultiTouch;
}getMultiTouchWidth method · java · L561-L563 (3 LOC)app/src/main/java/org/metalev/multitouch/controller/MultiTouchController.java
public float getMultiTouchWidth() {
return isMultiTouch ? dx : 0.0f;
}Repobility — same analyzer, your code, free for public repos · /scan/
getMultiTouchHeight method · java · L566-L568 (3 LOC)app/src/main/java/org/metalev/multitouch/controller/MultiTouchController.java
public float getMultiTouchHeight() {
return isMultiTouch ? dy : 0.0f;
}julery_isqrt method · java · L571-L580 (10 LOC)app/src/main/java/org/metalev/multitouch/controller/MultiTouchController.java
private int julery_isqrt(int val) {
int temp, g = 0, b = 0x8000, bshft = 15;
do {
if (val >= (temp = (((g << 1) + b) << bshft--))) {
g += b;
val -= temp;
}
} while ((b >>= 1) > 0);
return g;
}getMultiTouchDiameterSq method · java · L583-L589 (7 LOC)app/src/main/java/org/metalev/multitouch/controller/MultiTouchController.java
public float getMultiTouchDiameterSq() {
if (!diameterSqIsCalculated) {
diameterSq = (isMultiTouch ? dx * dx + dy * dy : 0.0f);
diameterSqIsCalculated = true;
}
return diameterSq;
}