Example usage for android.graphics PointF PointF

List of usage examples for android.graphics PointF PointF

Introduction

In this page you can find the example usage for android.graphics PointF PointF.

Prototype

public PointF(float x, float y) 

Source Link

Usage

From source file:com.funzio.pure2D.demo.particles.NovaActivity.java

private void addObject(final float x, final float y) {
    // null check
    if (mNovaFactory == null) {
        return;//from w w  w .  j a va 2 s .c om
    }

    ArrayList<NovaEmitter> emitters = mNovaFactory.createEmitters(new PointF(x, y));
    for (NovaEmitter emitter : emitters) {
        mScene.addChild(emitter);
    }
}

From source file:ac.robinson.ticqr.TicQRActivity.java

@Override
protected void onPageIdFound(String id) {
    // Toast.makeText(TicQRActivity.this, "Page ID found", Toast.LENGTH_SHORT).show();

    RequestParams params = new RequestParams("lookup", id);
    new AsyncHttpClient().get(SERVER_URL, params, new JsonHttpResponseHandler() {
        private void handleFailure(int reason) {
            // TODO: there are concurrency issues here with hiding the progress bar and showing the rescan button
            // TODO: (e.g., this task and photo taking complete in different orders)
            findViewById(R.id.parse_progress).setVisibility(View.GONE);
            getSupportActionBar().setTitle(R.string.title_activity_image_only);
            supportInvalidateOptionsMenu();
            Toast.makeText(TicQRActivity.this, getString(reason), Toast.LENGTH_SHORT).show();
        }/*from ww  w .  jav  a 2s  .  c  o m*/

        @Override
        public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
            try {
                if ("ok".equals(response.getString("status"))) {
                    mDestinationEmail = response.isNull("destination") ? null
                            : response.getString("destination");

                    JSONArray boxes = response.getJSONArray("tickBoxes");
                    if (boxes != null && !boxes.isNull(0)) {
                        for (int i = 0; i < boxes.length(); i++) {
                            JSONObject jsonBox = boxes.getJSONObject(i);

                            TickBoxHolder box = new TickBoxHolder(
                                    new PointF(jsonBox.getInt("x"), jsonBox.getInt("y")),
                                    jsonBox.getString("description"), jsonBox.getInt("quantity"));

                            box.ticked = true; // first we assume all boxes are ticked
                            box.foundOnImage = false; // (but not yet found on the image)
                            mServerTickBoxes.add(box);
                        }
                    }

                    mBoxesLoaded = true;
                    if (mImageParsed) {
                        verifyBoxes();
                    }
                } else {
                    handleFailure(R.string.hint_json_error);
                }
            } catch (JSONException e) {
                handleFailure(R.string.hint_json_error);
            }
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) {
            handleFailure(R.string.hint_connection_error);
        }
    });
}

From source file:de.uni_weimar.mheinz.androidtouchscope.display.HandleView.java

private PointF getCircleCenter() {
    float posX, posY;
    if (mOrientation == HandleDirection.UP || mOrientation == HandleDirection.DOWN) {
        posX = mHandlePos;//Math.max(mBounds.left, Math.min(mBounds.right, mHandlePos));
        posY = mBounds.centerY();// ww  w.j a  v  a  2  s .c  o  m
    } else {
        posX = mBounds.centerX();
        posY = mHandlePos;//Math.max(mBounds.top, Math.min(mBounds.bottom, mHandlePos));
    }
    return new PointF(posX, posY);
}

From source file:com.jest.phone.PhoneActivity.java

/** Called when the activity is first created. */
@Override/*from  w  w  w . ja  va2s  .co m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_phone);

    // ////// DATABASE ////////////
    MDM = new MotionDatabaseManager(PhoneActivity.this);

    // ////////////////////////////

    playPause = (Button) findViewById(R.id.pause);
    resetButton = (Button) findViewById(R.id.resetButton);
    resetButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            minXY.x = xHistorySeries.getX(0).floatValue();
            maxXY.x = xHistorySeries.getX(xHistorySeries.size() - 1).floatValue();
            sensorHistoryPlot.setDomainBoundaries(minXY.x, maxXY.x, BoundaryMode.FIXED);

            // pre 0.5.1 users should use postRedraw() instead.
            sensorHistoryPlot.redraw();
        }
    });
    saveDataButton = (Button) findViewById(R.id.save_data_unused);
    saveDataButton.setOnClickListener(new OnClickListener() {
        // The purpose of DEBUG is to grab and display data for debugging
        // and data analysis
        @Override
        public void onClick(View v) {
            // TEST: current boundaries of what we're looking at
            Toast.makeText(getApplicationContext(), "Min: " + minXY.x + " | Max: " + maxXY.x, Toast.LENGTH_LONG)
                    .show();
            SaveDataDialog sdd = new SaveDataDialog();
            FragmentManager fm = getSupportFragmentManager();
            sdd.show(fm, "SaveDataDialog");

        }
    });
    analyzeDataButton = (Button) findViewById(R.id.analyze_data);
    analyzeDataButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

        }
    });
    viewDataButton = (Button) findViewById(R.id.view_data);
    viewDataButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent i = new Intent(PhoneActivity.this, ViewMotionDataActivity.class);
            startActivity(i);

        }
    });
    trainMotionSet = (Button) findViewById(R.id.train_motion_set);
    trainMotionSet.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ChooseSetDialog csd = new ChooseSetDialog();
            FragmentManager fm = getSupportFragmentManager();
            csd.show(fm, "ChooseSetDialog");

        }
    });

    xSeries = new SimpleXYSeries("X");
    ySeries = new SimpleXYSeries("Y");
    zSeries = new SimpleXYSeries("Z");

    // setup the APR History plot:
    sensorHistoryPlot = (XYPlot) findViewById(R.id.sensorHistoryPlot);
    sensorHistoryPlot.setOnTouchListener(this);

    xHistorySeries = new SimpleXYSeries("aX");
    xHistorySeries.useImplicitXVals();
    yHistorySeries = new SimpleXYSeries("aY");
    yHistorySeries.useImplicitXVals();
    zHistorySeries = new SimpleXYSeries("aZ");
    zHistorySeries.useImplicitXVals();

    sensorHistoryPlot.setRangeBoundaries(-180, 359, BoundaryMode.FIXED);
    sensorHistoryPlot.setDomainBoundaries(0, HISTORY_SIZE, BoundaryMode.FIXED);
    sensorHistoryPlot.addSeries(xHistorySeries,
            new LineAndPointFormatter(Color.rgb(100, 100, 200), null, null, null));
    sensorHistoryPlot.addSeries(yHistorySeries,
            new LineAndPointFormatter(Color.rgb(100, 200, 100), null, null, null));
    sensorHistoryPlot.addSeries(zHistorySeries,
            new LineAndPointFormatter(Color.rgb(200, 100, 100), null, null, null));
    sensorHistoryPlot.setDomainStepMode(XYStepMode.INCREMENT_BY_VAL);
    sensorHistoryPlot.setDomainStepValue(HISTORY_SIZE / 10);
    sensorHistoryPlot.setTicksPerRangeLabel(3);
    sensorHistoryPlot.setDomainLabel("Sample Index");
    sensorHistoryPlot.getDomainLabelWidget().pack();
    sensorHistoryPlot.setRangeLabel("Acceleration (M/s2)");
    sensorHistoryPlot.getRangeLabelWidget().pack();

    sensorHistoryPlot.setRangeValueFormat(new DecimalFormat("#"));
    sensorHistoryPlot.setDomainValueFormat(new DecimalFormat("#"));

    int maxValue = 360; // TODO - make this not be empirical... Based on
    // device's accelerometer range.
    int minValue = maxValue * -1;
    sensorHistoryPlot.setRangeBoundaries(minValue, maxValue, BoundaryMode.FIXED);
    sensorHistoryPlot.calculateMinMaxVals();
    minXY = new PointF(sensorHistoryPlot.getCalculatedMinX().floatValue(),
            sensorHistoryPlot.getCalculatedMinY().floatValue());
    maxXY = new PointF(sensorHistoryPlot.getCalculatedMaxX().floatValue(),
            sensorHistoryPlot.getCalculatedMaxY().floatValue());

    redrawer = new Redrawer(Arrays.asList(new Plot[] { sensorHistoryPlot }), 100, false); // ,
    // aprLevelsPlot
    playPause.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            play = !play;
        }
    });

    // //////// NETWORKING // //////////////////////////////////////////////

    // hostText = (EditText) findViewById(R.id.host_text);
    portText = (EditText) findViewById(R.id.port_text);
    connectButton = (Button) findViewById(R.id.connect_button);

    connectButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // connectButton.setClickable(false);

            // HOST_NAME = hostText.getText().toString();
            PORT_NAME = portText.getText().toString();
            if (PORT_NAME == null) {
                Toast.makeText(PhoneActivity.this, "Host and/or port not set!", Toast.LENGTH_LONG).show();
                return;
            }
            PORT = Integer.parseInt(PORT_NAME);
            new initNetworkTask().execute();
        }
    });

    connectButton.setOnLongClickListener(new OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            hostText.setText("192.168.43.249");
            portText.setText("4444");
            return false;
        }
    });
}

From source file:com.richtodd.android.quiltdesign.block.PaperPiecedBlockPiece.java

public List<PointF> createPoints(int width, int height) {
    ArrayList<PointF> points = new ArrayList<PointF>(5);

    int right = width;
    int bottom = height;

    PointF pieceFrom = getFrom();/*from  w  w w  . ja  v a 2s .  c o  m*/
    PointF pieceTo = getTo();

    Edges edgeFrom = getEdge(pieceFrom);
    Edges edgeTo = getEdge(pieceTo);

    if (edgeFrom == edgeTo) { // Block encompasses entire rectangle.
        points.add(new PointF(0, 0));
        points.add(new PointF(right, 0));
        points.add(new PointF(right, bottom));
        points.add(new PointF(0, bottom - 0));
    } else {
        PointF blockFrom = getBlockFrom(width, height);
        PointF blockTo = getBlockTo(width, height);

        points.add(blockFrom);
        points.add(blockTo);

        while (edgeTo != edgeFrom) {
            switch (edgeTo) {
            case TOP:
                points.add(new PointF(right, 0));
                edgeTo = Edges.RIGHT;
                break;
            case RIGHT:
                points.add(new PointF(right, bottom));
                edgeTo = Edges.BOTTOM;
                break;
            case BOTTOM:
                points.add(new PointF(0, bottom));
                edgeTo = Edges.LEFT;
                break;
            case LEFT:
                points.add(new PointF(0, 0));
                edgeTo = Edges.TOP;
                break;
            }
        }
    }

    return points;
}

From source file:org.witness.informacam.app.editors.image.ImageRegion.java

public boolean onTouch(View v, MotionEvent event) {

    fingerCount = event.getPointerCount();
    //   Log.v(LOGTAG,"onTouch: fingers=" + fingerCount);

    switch (event.getAction() & MotionEvent.ACTION_MASK) {

    case MotionEvent.ACTION_DOWN:

        mImageEditor.doRealtimePreview = true;
        mImageEditor.updateDisplayImage();
        //mTmpBounds = new RectF(mBounds);

        if (fingerCount == 1) {
            //float[] points = {event.getX(), event.getY()};                   
            //iMatrix.mapPoints(points);
            //mStartPoint = new PointF(points[0],points[1]);
            mStartPoint = new PointF(event.getX(), event.getY());
            //Log.v(LOGTAG,"startPoint: " + mStartPoint.x + " " + mStartPoint.y);
        }//from   w  w  w  . ja v  a  2  s  .  c o  m

        moved = false;

        return false;
    case MotionEvent.ACTION_POINTER_UP:

        Log.v(LOGTAG, "second finger removed - pointer up!");

        return moved;

    case MotionEvent.ACTION_UP:

        mImageEditor.doRealtimePreview = true;
        mImageEditor.updateDisplayImage();
        //mTmpBounds = null;

        return moved;

    case MotionEvent.ACTION_MOVE:

        if (fingerCount > 1) {

            float[] points = { event.getX(0), event.getY(0), event.getX(1), event.getY(1) };
            iMatrix.mapPoints(points);

            mStartPoint = new PointF(points[0], points[1]);

            RectF newBox = new RectF();
            newBox.left = Math.min(points[0], points[2]);
            newBox.top = Math.min(points[1], points[3]);
            newBox.right = Math.max(points[0], points[2]);
            newBox.bottom = Math.max(points[1], points[3]);

            moved = true;

            if (newBox.left != newBox.right && newBox.top != newBox.bottom) {

                updateBounds(newBox.left, newBox.top, newBox.right, newBox.bottom);
            }

        } else if (fingerCount == 1) {

            if (Math.abs(mStartPoint.x - event.getX()) > MIN_MOVE) {
                moved = true;

                float[] points = { mStartPoint.x, mStartPoint.y, event.getX(), event.getY() };

                iMatrix.mapPoints(points);

                float diffX = points[0] - points[2];
                float diffY = points[1] - points[3];

                float left = 0, top = 0, right = 0, bottom = 0;

                if (cornerMode == CORNER_NONE) {

                    left = mBounds.left - diffX;
                    top = mBounds.top - diffY;
                    right = mBounds.right - diffX;
                    bottom = mBounds.bottom - diffY;
                } else if (cornerMode == CORNER_UPPER_LEFT) {
                    left = mBounds.left - diffX;
                    top = mBounds.top - diffY;
                    right = mBounds.right;
                    bottom = mBounds.bottom;

                } else if (cornerMode == CORNER_LOWER_LEFT) {
                    left = mBounds.left - diffX;
                    top = mBounds.top;
                    right = mBounds.right;
                    bottom = mBounds.bottom - diffY;

                } else if (cornerMode == CORNER_UPPER_RIGHT) {
                    left = mBounds.left;
                    top = mBounds.top - diffY;
                    right = mBounds.right - diffX;
                    bottom = mBounds.bottom;
                } else if (cornerMode == CORNER_LOWER_RIGHT) {
                    left = mBounds.left;
                    top = mBounds.top;
                    right = mBounds.right - diffX;
                    bottom = mBounds.bottom - diffY;
                }

                if ((left + CORNER_MAX) > right || (top + CORNER_MAX) > bottom)
                    return false;

                //updateBounds(Math.min(left, right), Math.min(top,bottom), Math.max(left, right), Math.max(top, bottom));
                updateBounds(left, top, right, bottom);

                mStartPoint = new PointF(event.getX(), event.getY());
            } else {
                moved = false;
            }

        }

        mImageEditor.updateDisplayImage();

        return true;

    }

    return false;

}

From source file:com.rstar.mobile.thermocouple.functions.Fn.java

public PointF[] getEMFCurveControlPoints(int internalPtsPerSegment) {
    double[] controlTemperature = getControlTemperaturesForEMF(internalPtsPerSegment);
    if (controlTemperature == null || controlTemperature.length == 0)
        return null;

    try {//www .jav a 2  s .  c om
        int count = controlTemperature.length;
        double[] voltage = new double[count];
        for (int index = 0; index < count; index++) {
            voltage[index] = computeE(controlTemperature[index]);
        }
        PointF[] pointF = new PointF[count];
        for (int index = 0; index < count; index++) {
            pointF[index] = new PointF((float) controlTemperature[index], (float) voltage[index]);
        }
        return pointF;
    } catch (Exception e) {
        return null;
    }
}

From source file:org.thoughtcrime.securesms.scribbles.widget.MotionView.java

@Nullable
private MotionEntity findEntityAtPoint(float x, float y) {
    MotionEntity selected = null;/*from   w w  w .j a  v a 2s  . c o  m*/
    PointF p = new PointF(x, y);
    for (int i = entities.size() - 1; i >= 0; i--) {
        if (entities.get(i).pointInLayerRect(p)) {
            selected = entities.get(i);
            break;
        }
    }
    return selected;
}

From source file:com.alibaba.android.layoutmanager.ExposeLinearLayoutManagerEx.java

public PointF computeScrollVectorForPosition(int targetPosition) {
    if (getChildCount() == 0) {
        return null;
    }//from ww  w .  jav a 2s. co  m
    final int firstChildPos = getPosition(getChildAt(0));
    final int direction = targetPosition < firstChildPos != mShouldReverseLayoutExpose ? -1 : 1;
    if (getOrientation() == HORIZONTAL) {
        return new PointF(direction, 0);
    } else {
        return new PointF(0, direction);
    }
}

From source file:com.heneryh.aquanotes.ui.controllers.GraphsFragment.java

/**
 * Handle {@link VendorsQuery} {@link Cursor}.
 *///w ww.ja  v a  2  s  .  c o  m
private void onProbeDataQueryComplete(Cursor cursor) {
    if (mCursor != null) {
        // In case cancelOperation() doesn't work and we end up with consecutive calls to this
        // callback.
        getActivity().stopManagingCursor(mCursor);
        mCursor = null;
    }
    mySimpleXYPlot = (XYPlot) mRootView.findViewById(R.id.mySimpleXYPlot);
    mySimpleXYPlot.setOnTouchListener(this);
    mySimpleXYPlot.clear();

    //Creation of the series
    final Vector<Double> vector = new Vector<Double>();
    int numDataPoints = 0;
    String probeName = null;
    Long timestamp = (long) 0;
    String valueS = null;
    try {
        /** For each datapoint in the database, */
        while (cursor.moveToNext()) {
            probeName = cursor.getString(ProbeDataViewQuery.NAME);
            timestamp = cursor.getLong(ProbeDataViewQuery.TIMESTAMP);
            valueS = cursor.getString(ProbeDataViewQuery.VALUE);
            Double valueD = Double.valueOf(valueS);
            vector.add(timestamp.doubleValue());
            vector.add(valueD);
            numDataPoints++;
        } // end of while()
    } finally {
        cursor.close();
        if (numDataPoints < 2)
            return;
    }
    // create our series from our array of nums:
    mySeries = new SimpleXYSeries(vector, ArrayFormat.XY_VALS_INTERLEAVED, probeName);

    mySimpleXYPlot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE);
    mySimpleXYPlot.getGraphWidget().getGridLinePaint().setColor(Color.BLACK);
    mySimpleXYPlot.getGraphWidget().getGridLinePaint()
            .setPathEffect(new DashPathEffect(new float[] { 1, 1 }, 1));
    mySimpleXYPlot.getGraphWidget().getDomainOriginLinePaint().setColor(Color.BLACK);
    mySimpleXYPlot.getGraphWidget().getRangeOriginLinePaint().setColor(Color.BLACK);

    mySimpleXYPlot.setBorderStyle(Plot.BorderStyle.SQUARE, null, null);
    mySimpleXYPlot.getBorderPaint().setStrokeWidth(1);
    mySimpleXYPlot.getBorderPaint().setAntiAlias(false);
    mySimpleXYPlot.getBorderPaint().setColor(Color.WHITE);

    // Create a formatter to use for drawing a series using LineAndPointRenderer:
    LineAndPointFormatter series1Format = new LineAndPointFormatter(Color.rgb(0, 100, 0), // line color
            Color.rgb(0, 100, 0), // point color
            Color.rgb(100, 200, 0)); // fill color

    // setup our line fill paint to be a slightly transparent gradient:
    Paint lineFill = new Paint();
    lineFill.setAlpha(200);
    //lineFill.setShader(new LinearGradient(0, 0, 0, 250, Color.WHITE, Color.GREEN, Shader.TileMode.MIRROR));

    LineAndPointFormatter formatter = new LineAndPointFormatter(Color.rgb(0, 0, 0), Color.BLUE, Color.RED);
    //       formatter.setFillPaint(lineFill);
    formatter.setFillPaint(null);
    //       formatter.setVertexPaint(null);
    formatter.getLinePaint().setShadowLayer(0, 0, 0, 0);
    mySimpleXYPlot.getGraphWidget().setPaddingRight(2);
    mySimpleXYPlot.addSeries(mySeries, formatter);

    // draw a domain tick for each year:
    //mySimpleXYPlot.setDomainStep(XYStepMode.SUBDIVIDE, numDataPoints);

    // customize our domain/range labels
    mySimpleXYPlot.setDomainLabel("Time");
    mySimpleXYPlot.setRangeLabel(probeName);

    // get rid of decimal points in our range labels:
    mySimpleXYPlot.setRangeValueFormat(new DecimalFormat("#0.00"));

    mySimpleXYPlot.setDomainValueFormat(new MyDateFormat());

    // by default, AndroidPlot displays developer guides to aid in laying out your plot.
    // To get rid of them call disableAllMarkup():
    mySimpleXYPlot.disableAllMarkup();

    //Set of internal variables for keeping track of the boundaries
    mySimpleXYPlot.calculateMinMaxVals();
    minXY = new PointF(mySimpleXYPlot.getCalculatedMinX().floatValue(),
            mySimpleXYPlot.getCalculatedMinY().floatValue()); //initial minimum data point
    absMinX = minXY.x; //absolute minimum data point
    //absolute minimum value for the domain boundary maximum
    minNoError = Math.round(mySeries.getX(1).floatValue() + 2);
    maxXY = new PointF(mySimpleXYPlot.getCalculatedMaxX().floatValue(),
            mySimpleXYPlot.getCalculatedMaxY().floatValue()); //initial maximum data point
    absMaxX = maxXY.x; //absolute maximum data point
    //absolute maximum value for the domain boundary minimum
    maxNoError = (float) Math.round(mySeries.getX(mySeries.size() - 1).floatValue()) - 2;

    //Check x data to find the minimum difference between two neighboring domain values
    //Will use to prevent zooming further in than this distance
    double temp1 = mySeries.getX(0).doubleValue();
    double temp2 = mySeries.getX(1).doubleValue();
    double temp3;
    double thisDif;
    minDif = 100000000; //increase if necessary for domain values
    for (int i = 2; i < mySeries.size(); i++) {
        temp3 = mySeries.getX(i).doubleValue();
        thisDif = Math.abs(temp1 - temp3);
        if (thisDif < minDif)
            minDif = thisDif;
        temp1 = temp2;
        temp2 = temp3;
    }
    minDif = minDif + difPadding; //with padding, the minimum difference

    mySimpleXYPlot.redraw();

}