Example usage for android.graphics Paint setStrokeWidth

List of usage examples for android.graphics Paint setStrokeWidth

Introduction

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

Prototype

public void setStrokeWidth(float width) 

Source Link

Document

Set the width for stroking.

Usage

From source file:edumsg.edumsg_android_app.MainActivity.java

/**
 *
 * The onCreate method first retrieves the sessionId and username from the parent {@link android.content.Intent},
 * which is either created from a {@link LoginFragment} or a {@link RegisterFragment}. Afterwards,
 * it configures the action bar and performs view look-ups for the action bar buttons, followed
 * by setting the onClick listeners for the action bar buttons. Finally, it initializes the
 * properties, sets the onRefresh listener for the swipe refresh layout, and calls the method
 * {@link MainActivity#getFeed()}./*from  ww w  .  j av a 2 s .c om*/
 *
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    sessionId = getIntent().getExtras().getString("sessionId");
    username = getIntent().getExtras().getString("username");
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    setSupportActionBar(toolbar);
    final ViewGroup actionBarLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.menu_main, null);
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.setCustomView(actionBarLayout);
    ImageButton homeButton = ButterKnife.findById(actionBarLayout, R.id.btn_home);
    final ImageButton searchButton = ButterKnife.findById(actionBarLayout, R.id.btn_search);
    ImageButton createButton = ButterKnife.findById(actionBarLayout, R.id.btn_create);
    ImageButton navButton = ButterKnife.findById(actionBarLayout, R.id.btn_nav);

    final ViewGroup searchLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.menu_search, null);
    final SearchView searchView = ButterKnife.findById(searchLayout, R.id.search);
    final ImageButton backBtn = ButterKnife.findById(searchLayout, R.id.btn_back);

    homeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

        }
    });

    searchButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            actionBar.setCustomView(searchLayout);
            SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
            searchView.setSearchableInfo(searchManager
                    .getSearchableInfo(new ComponentName(MainActivity.this, SearchResultsActivity.class)));
            searchView.setQuery("", false);
            searchView.setIconified(false);
            searchView.setFocusable(true);
            searchView.requestFocusFromTouch();
        }
    });

    backBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            actionBar.setCustomView(actionBarLayout);
            InputMethodManager imm = (InputMethodManager) getApplicationContext()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(
                    MainActivity.this.getWindow().getDecorView().getRootView().getWindowToken(), 0);
        }
    });

    createButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);

            final EditText input = new EditText(MainActivity.this);
            input.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
            input.setLines(4);
            input.setSingleLine(false);
            input.setBackgroundDrawable(null);
            builder.setView(input);
            builder.setPositiveButton("Tweet", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    createTweet(input.getText().toString());
                }
            });
            builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
            final AlertDialog dialog = builder.create();

            dialog.setOnShowListener(new DialogInterface.OnShowListener() {
                @Override
                public void onShow(DialogInterface dialogInterface) {
                    Button posBtn = dialog.getButton(AlertDialog.BUTTON_NEGATIVE);
                    posBtn.setBackgroundColor(cPrimary);
                    posBtn.setTextColor(Color.WHITE);
                    final float scale = getApplicationContext().getResources().getDisplayMetrics().density;
                    int pixels = (int) (10 * scale + 0.5f);
                    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
                            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                    layoutParams.setMargins(0, 0, pixels, 0);
                    posBtn.setLayoutParams(layoutParams);
                    Button negBtn = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
                    negBtn.setBackgroundColor(cPrimary);
                    negBtn.setTextColor(Color.WHITE);
                }
            });
            dialog.show();
        }
    });

    navButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            FragmentManager fragmentManager = getSupportFragmentManager();
            List<Fragment> fragments = fragmentManager.getFragments();
            if (fragments != null) {
                for (Fragment fragment : fragments) {
                    if (fragment instanceof NavigationFragment)
                        return;
                }
            }
            NavigationFragment navigationFragment = new NavigationFragment();
            //                Bundle bundle = new_user Bundle();
            //                bundle.putInt("userId", userId);
            //                mainActivityFragment.setArguments(bundle);
            fragmentManager.beginTransaction().add(android.R.id.content, navigationFragment)
                    .addToBackStack("nav").commit();
            //                logout();
            //                launchMessages();
            //                Intent intent = new_user Intent(MainActivity.this, ProfileActivity.class);
            //                intent.putExtra("username", getUsername());
            //                intent.putExtra("name", getName());
            //                intent.putExtra("avatar_url", getAvatar_url());
            //                intent.putExtra("bio", getBio());
            //                intent.putExtra("creatorId", getUserId());
            //                intent.putExtra("userId", getUserId());
            //                startActivity(intent);
        }
    });

    recyclerView.setHasFixedSize(true);
    final float scale = getApplicationContext().getResources().getDisplayMetrics().density;
    int pixels = (int) (160 * scale + 0.5f);
    Paint paint = new Paint();
    paint.setStrokeWidth(3.0f);
    paint.setColor(Color.rgb(220, 220, 220));
    paint.setAntiAlias(true);
    recyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(this).paint(paint).build());
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(linearLayoutManager);

    tweetObjects = new ArrayList<>();
    rvAdapter = new RVAdapter(this, tweetObjects, sessionId);
    recyclerView.setAdapter(rvAdapter);

    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            tweetObjects.clear();
            getFeed();
        }
    });

    getFeed();
}

From source file:com.longle1.facedetection.MainActivity.java

@Override
protected void onDraw(Canvas canvas) {
    Paint paint = new Paint();
    paint.setColor(Color.GREEN);//from ww  w  . j ava 2  s  . co m
    paint.setTextSize(20);

    String s = "FacePreview - This side up.";
    float textWidth = paint.measureText(s);
    canvas.drawText(s, (getWidth() - textWidth) / 2, 20, paint);

    if (faces != null) {
        paint.setStrokeWidth(5);
        paint.setStyle(Paint.Style.STROKE);
        float scaleX = (float) getWidth() / grayImage.width();
        float scaleY = (float) getHeight() / grayImage.height();
        int total = faces.total();
        for (int i = 0; i < total; i++) {
            CvRect r = new CvRect(cvGetSeqElem(faces, i));
            int x = r.x(), y = r.y(), w = r.width(), h = r.height();
            canvas.drawRect(x * scaleX, y * scaleY, (x + w) * scaleX, (y + h) * scaleY, paint);
        }
    }
}

From source file:app.axe.imooc.zxing.app.CaptureActivity.java

/**
 * Superimpose a line for 1D or dots for 2D to highlight the key features of
 * the barcode./*from   w  w w . ja  v  a 2  s .  co m*/
 *
 * @param barcode   A bitmap of the captured image.
 * @param rawResult The decoded results which contains the points to draw.
 */
private void drawResultPoints(Bitmap barcode, Result rawResult) {
    ResultPoint[] points = rawResult.getResultPoints();
    if (points != null && points.length > 0) {
        Canvas canvas = new Canvas(barcode);
        Paint paint = new Paint();
        paint.setColor(getResources().getColor(R.color.result_image_border));
        paint.setStrokeWidth(3.0f);
        paint.setStyle(Paint.Style.STROKE);
        Rect border = new Rect(2, 2, barcode.getWidth() - 2, barcode.getHeight() - 2);
        canvas.drawRect(border, paint);

        paint.setColor(getResources().getColor(R.color.result_points));
        if (points.length == 2) {
            paint.setStrokeWidth(4.0f);
            drawLine(canvas, paint, points[0], points[1]);
        } else if (points.length == 4 && (rawResult.getBarcodeFormat().equals(BarcodeFormat.UPC_A))
                || (rawResult.getBarcodeFormat().equals(BarcodeFormat.EAN_13))) {
            // Hacky special case -- draw two lines, for the barcode and
            // metadata
            drawLine(canvas, paint, points[0], points[1]);
            drawLine(canvas, paint, points[2], points[3]);
        } else {
            paint.setStrokeWidth(10.0f);
            for (ResultPoint point : points) {
                canvas.drawPoint(point.getX(), point.getY(), paint);
            }
        }
    }
}

From source file:com.forrestguice.suntimeswidget.LightMapView.java

private void drawPoint(Calendar calendar, int radius, Canvas c, Paint p) {
    if (calendar != null) {
        int w = c.getWidth();
        int h = c.getHeight();

        double minute = calendar.get(Calendar.HOUR_OF_DAY) * 60 + calendar.get(Calendar.MINUTE);
        int x = (int) Math.round((minute / MINUTES_IN_DAY) * w);
        int y = h / 2;

        p.setStyle(Paint.Style.FILL);
        p.setColor(colorPointFill);//from  w  w  w. ja  v  a2  s.  com
        c.drawCircle(x, y, radius, p);

        p.setStyle(Paint.Style.STROKE);
        p.setStrokeWidth(pointStrokeWidth);
        p.setColor(colorPointStroke);
        c.drawCircle(x, y, radius, p);
    }
}

From source file:de.uni.stuttgart.informatik.ToureNPlaner.UI.Activities.MapScreen.MapScreen.java

private void setupWayOverlay() {
    Path p = new Path();
    p.moveTo(4.f, 0.f);//from w ww .  j  a  v  a 2 s . co m
    p.lineTo(0.f, -4.f);
    p.lineTo(8.f, -4.f);
    p.lineTo(12.f, 0.f);
    p.lineTo(8.f, 4.f);
    p.lineTo(0.f, 4.f);

    Paint fastWayOverlayColor = new Paint(Paint.ANTI_ALIAS_FLAG);
    fastWayOverlayColor.setStyle(Paint.Style.STROKE);
    fastWayOverlayColor.setColor(Color.BLUE);
    fastWayOverlayColor.setAlpha(160);
    fastWayOverlayColor.setStrokeWidth(5.f);
    fastWayOverlayColor.setStrokeJoin(Paint.Join.ROUND);
    fastWayOverlayColor.setPathEffect(new ComposePathEffect(
            new PathDashPathEffect(p, 12.f, 0.f, PathDashPathEffect.Style.ROTATE), new CornerPathEffect(30.f)));

    // create the WayOverlay and add the ways
    this.fastWayOverlay = new FastWayOverlay(session, fastWayOverlayColor);
    mapView.getOverlays().add(this.fastWayOverlay);
    Result result = session.getResult();
    if (result != null) {
        addPathToMap(result.getWay());
    }
}

From source file:com.semfapp.adamdilger.semf.Take5PdfDocument.java

public PdfDocument createDocument() {
    //create new document
    PdfDocument document = new PdfDocument();

    // crate a page description
    PdfDocument.PageInfo pageInfo = new PdfDocument.PageInfo.Builder(A4_WIDTH, A4_HEIGHT, 1).create();

    // start a page
    PdfDocument.Page page = document.startPage(pageInfo);

    can = page.getCanvas();/*w  w  w  .  j a v a2s .  c o m*/
    Paint paint = new Paint();
    paint.setStrokeWidth(0.5f);
    paint.setColor(Color.BLACK);
    paint.setStyle(Paint.Style.STROKE);
    can.drawRect(1, 1, 594, 395, paint);

    /**
     * Page one Text Fields
     */
    drawText("Job Reference:", 9, 21, FONT14, carlitoBold);
    drawText("Date:", 354, 21, FONT14, carlitoBold);
    drawText("Time:", 473, 21, FONT14, carlitoBold);
    drawText("Location:", 9, 48, FONT14, carlitoBold);
    drawText("Task:", 261, 48, FONT14, carlitoBold);

    paint.setPathEffect(new DashPathEffect(new float[] { 1.5f, 1 }, 0));
    can.drawLine(85, 36, 350, 36, paint);
    can.drawLine(386, 36, 468, 36, paint);
    can.drawLine(506, 36, 585, 36, paint);
    can.drawLine(59, 60, 256, 60, paint);
    can.drawLine(291, 60, 585, 60, paint);

    if (mEditTextValues[0] != null) {
        drawText(mEditTextValues[0], 98, 19, FONT14, roboto);
    }
    if (mEditTextValues[1] != null) {
        drawText(mEditTextValues[1], 65, 44, FONT14, roboto);
    }
    if (mEditTextValues[2] != null) {
        drawText(mEditTextValues[2], 297, 44, FONT14, roboto);
    }
    drawText(mDateString, 390, 19, FONT14, roboto);
    drawText(mTimeString, 509, 19, FONT14, roboto);

    /**
     * Section One (Stop, step back...)
     */
    drawHeader1(8, 69, 202, "Stop, step back and think", 1);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(0.35f);
    paint.setPathEffect(null);
    int left, top;

    //draw left boxes
    left = 177;
    top = 108;
    for (int x = 0; x < mCheckBoxSectionOne.size(); x++) {
        Take5Data.CheckValue isYes = mCheckBoxSectionOne.get(x).getCheckValue();
        float topLoc = top + (x * 33);

        if (x < 1) { //allowing for different 1st row size
            drawBox(left, topLoc, paint, true, isYes);
        } else {
            float newTop = topLoc - 6;
            if (x < 3) {
                drawBox(left, newTop, paint, false, isYes);
            } else {
                drawBox(left, newTop, paint, true, isYes);
            }
        }
    }

    DashPathEffect pathEffect = new DashPathEffect(new float[] { 1, 1.5f }, 0);

    drawText(mCheckBoxSectionOne.get(0).getHeading(), 13, 113, FONT12, carlitoBold);

    for (int x = 1; x < mCheckBoxSectionOne.size(); x++) {
        int height = 132 + ((x - 1) * 33);
        drawText(mCheckBoxSectionOne.get(x).getHeading(), 13, height, FONT12, carlitoBold);
        paint.setPathEffect(pathEffect);
        can.drawLine(10, height - 6, 222, height - 6, paint);
        paint.setPathEffect(null);
    }

    /**
     * Section Two (Identidy the Hazards...)
     */
    drawHeader1(230, 69, 345, "Identify the hazard(s)", 2);

    //draw right boxes
    left = 542;
    top = 104;
    for (int x = 0; x < mCheckBoxSectionTwo.size(); x++) {
        float topLoc = top + (x * 20.7f);
        Take5Data.CheckValue isYes = mCheckBoxSectionTwo.get(x).getCheckValue();
        drawBox(left, topLoc, paint, false, isYes);
    }

    for (int x = 0; x < mCheckBoxSectionTwo.size(); x++) {
        float height = 105 + (x * 20.7f);
        drawText(mCheckBoxSectionTwo.get(x).getHeading(), 238, height + 3, FONT12, carlitoBold);
        if (x > 0) {
            paint.setPathEffect(pathEffect);
            can.drawLine(238, height - 4, 581, height - 4, paint);
            paint.setPathEffect(null);
        }
    }

    /**
     * draw section 3,4,5 (including checkboxes)
     */
    drawSmallCircle(8, 331, "Assess the level of risk", 3);
    drawSmallCircle(202, 331, "Control the hazards", 4);
    drawSmallCircle(398, 331, "Proceed safely", 5);

    /**
     * Draw Page Two
     */
    int xLoc = 7;
    int yLoc = 420;
    int height;
    int width = 565;
    int RADIUS = 14;
    float INNER_RADIUS = 13;
    int centre = yLoc + 7 + RADIUS;
    width = xLoc + width;
    int middle = width - 340;
    can.drawRect(1, 420, 594, 420 + 395, paint);

    paint.setStyle(Paint.Style.FILL);
    paint.setTypeface(impact);
    paint.setTextSize(12);

    can.drawCircle(xLoc + RADIUS, centre, RADIUS, paint);
    can.drawRect(xLoc + RADIUS, centre - RADIUS, width, centre + RADIUS, paint);
    can.drawCircle(width, centre, RADIUS, paint);
    paint.setColor(Color.WHITE);
    can.drawCircle(xLoc + RADIUS, centre, INNER_RADIUS, paint);
    can.drawCircle(width, centre, INNER_RADIUS, paint);
    can.drawRect(middle, centre - INNER_RADIUS, width, centre + INNER_RADIUS, paint);
    paint.setColor(Color.BLACK);
    can.drawCircle(middle, centre, RADIUS, paint);

    paint.setColor(Color.WHITE);
    can.drawText("SAFE WORK METHOD STATEMENT (SWMS)", xLoc + 31, centre + 5, paint);
    paint.setTextSize(16);
    paint.setColor(Color.BLACK);
    can.drawText(String.valueOf(4), xLoc + RADIUS - 4, centre + 6, paint);

    height = 50;
    drawText("What are the hazards and risks?", 25, yLoc + height, FONT12, carlitoBold);
    drawText("Risk\nRating", 267, yLoc + 47, FONT12, carlitoBold);
    drawText("How will hazards and risks be controlled?", 319, yLoc + height, FONT12, carlitoBold);

    paint.setPathEffect(pathEffect);
    can.drawLine(262, yLoc + 45, 262, yLoc + 320, paint);
    can.drawLine(302, yLoc + 45, 302, yLoc + 320, paint);
    paint.setPathEffect(null);

    float currentItemHeight = yLoc + 75;
    float padding = 5;

    for (int x = 0; x < mRiskElements.size(); x++) {
        int textHeight = (int) currentItemHeight;
        float totalItemHeight = drawRiskElement(textHeight, mRiskElements.get(x));
        currentItemHeight += totalItemHeight + padding;
    }

    paint.setPathEffect(pathEffect);
    height = yLoc + 350;
    drawText("Name/s:", 12, height, FONT12, carlitoBold);
    drawText(mEditTextValues[3], 55, height - 3, FONT14, roboto);
    paint.setPathEffect(pathEffect);
    can.drawLine(50, height + 12, 580, height + 12, paint);
    paint.setPathEffect(null);

    height = yLoc + 372;
    drawText("Signatures:", 12, height, FONT12, carlitoBold);
    drawText("Date:", 468, height, FONT12, carlitoBold);
    drawText(mDateString, 497, height - 3, FONT14, roboto);
    paint.setPathEffect(pathEffect);
    can.drawLine(60, height + 12, 464, height + 12, paint);
    can.drawLine(492, height + 12, 580, height + 12, paint);
    paint.setPathEffect(null);

    // finish the page
    document.finishPage(page);

    int imagePageCount = 2;

    for (Take5RiskElement risk : mRiskElements) {

        if (risk.imagePath != null) {

            // crate a page description
            PdfDocument.PageInfo pageInfo1 = new PdfDocument.PageInfo.Builder(A4_WIDTH, A4_HEIGHT,
                    imagePageCount).create();

            PdfDocument.Page imagePage = document.startPage(pageInfo1);
            Canvas canvas = imagePage.getCanvas();

            try {

                Bitmap original = BitmapFactory.decodeFile(risk.imagePath);

                Bitmap b = resize(original, canvas.getWidth() - 100, canvas.getHeight() - 100);
                canvas.drawBitmap(b, 50, 60, new Paint());
                //                    canvas.drawText(risk.getOne(), 50, 40, new Paint());

                Path textPath = new Path();
                textPath.moveTo(50, 50);
                textPath.lineTo(canvas.getWidth() - 100, 50);

                canvas.drawTextOnPath(risk.getOne(), textPath, 0, 0, new Paint());

            } catch (Exception e) {
                e.printStackTrace();
            }

            document.finishPage(imagePage);

            imagePageCount++;

            new File(risk.imagePath).delete();
        }
    }

    // add more pages
    return document;
}

From source file:ee.ioc.phon.android.speak.Utils.java

static Bitmap bytesToBitmap(byte[] byteBuffer, int w, int h, int startPosition, int endPosition) {
    final ShortBuffer waveBuffer = ByteBuffer.wrap(byteBuffer).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer();
    final Bitmap b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
    final Canvas c = new Canvas(b);
    final Paint paint = new Paint();
    paint.setColor(0xFFFFFFFF); // 0xAARRGGBB
    paint.setAntiAlias(true);//  w w  w. j  ava 2  s.  c  o  m
    paint.setStyle(Paint.Style.STROKE);
    paint.setAlpha(80);

    final PathEffect effect = new CornerPathEffect(3);
    paint.setPathEffect(effect);

    final int numSamples = waveBuffer.remaining();
    int endIndex;
    if (endPosition == 0) {
        endIndex = numSamples;
    } else {
        endIndex = Math.min(endPosition, numSamples);
    }

    int startIndex = startPosition - 2000; // include 250ms before speech
    if (startIndex < 0) {
        startIndex = 0;
    }
    final int numSamplePerWave = 200; // 8KHz 25ms = 200 samples
    final float scale = 10.0f / 65536.0f;

    final int count = (endIndex - startIndex) / numSamplePerWave;
    final float deltaX = 1.0f * w / count;
    int yMax = h / 2;
    Path path = new Path();
    c.translate(0, yMax);
    float x = 0;
    path.moveTo(x, 0);
    for (int i = 0; i < count; i++) {
        final int avabs = getAverageAbs(waveBuffer, startIndex, i, numSamplePerWave);
        int sign = ((i & 01) == 0) ? -1 : 1;
        final float y = Math.min(yMax, avabs * h * scale) * sign;
        path.lineTo(x, y);
        x += deltaX;
        path.lineTo(x, y);
    }
    if (deltaX > 4) {
        paint.setStrokeWidth(2);
    } else {
        paint.setStrokeWidth(Math.max(0, (int) (deltaX - .05)));
    }
    c.drawPath(path, paint);
    return b;
}

From source file:com.spatialnetworks.fulcrum.widget.DynamicListView.java

/**
 * Draws a black border over the screenshot of the view passed in.
 *//*  w w  w .  ja  va 2s .  com*/
private Bitmap getBitmapWithBorder(View v) {
    Bitmap bitmap = getBitmapFromView(v);
    Canvas can = new Canvas(bitmap);

    Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());

    Paint paint = new Paint();
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(LINE_THICKNESS);
    paint.setColor(ContextCompat.getColor(getContext(), R.color.gray_230));

    can.drawBitmap(bitmap, 0, 0, null);
    can.drawRect(rect, paint);

    return bitmap;
}

From source file:net.line2soft.preambul.views.SlippyMapActivity.java

/**
 * Change the navigation instruction to display.
 * It updates the current path segment and set zoom and location.
 * @param id The ID of the instruction/*from  w w  w . ja  v a2s.c om*/
 */
public void setNavigationInstructionToDisplay(int id) {
    try {
        //Display the segment on map
        MapView mv = (MapView) findViewById(R.id.mapView);
        //Get and set segment
        Paint color = createPaint(getResources().getColor(R.color.Green), 170);
        OverlayWay path = MapController.getInstance(this).getCurrentLocation().getExcursions(this)
                .get(MapController.getInstance().getPathToDisplay()).getInstructions()[id].getSegment();
        Paint haloColor = createPaint(getResources().getColor(R.color.Blue), 100);
        haloColor.setStrokeWidth(17);
        path.setPaint(color, haloColor);
        if (segment != null) {
            overlayPaths.removeWay(segment);
        }
        segment = new OverlayWayText(path, "");
        overlayPaths.addWay(segment);
        //Set zoom and center
        GeoPoint start = path.getWayNodes()[0][0];
        boolean positionValid = mv.getMapViewLimits().getBottomLimit() <= start.getLatitude()
                && mv.getMapViewLimits().getTopLimit() >= start.getLatitude()
                && mv.getMapViewLimits().getLeftLimit() <= start.getLongitude()
                && mv.getMapViewLimits().getRightLimit() >= start.getLongitude();
        if (positionValid) {
            mv.zoomToPoint(start);
            //Show destination on map
            removeMarker("NAV");
            addMarkerOnMap(start, "NAV", getResources().getDrawable(R.drawable.marker_location_nav));
        } else {
            displayInfo(getString(R.string.message_map_position_out_of_bounds));
        }

        //Change the instruction
        ViewPager myPager = (ViewPager) findViewById(R.id.pager_nav);
        myPager.setCurrentItem(id);

        //Change images
        ImageView right = (ImageView) findViewById(R.id.imageRight);
        ImageView left = (ImageView) findViewById(R.id.imageLeft);
        left.setVisibility(View.VISIBLE);
        right.setVisibility(View.VISIBLE);
        int nbInstructions = MapController.getInstance(this).getCurrentLocation().getExcursions(this)
                .get(MapController.getInstance().getPathToDisplay()).getInstructions().length;
        if (id == 0) {
            left.setVisibility(View.INVISIBLE);
        } else if (id == nbInstructions - 1) {
            right.setVisibility(View.INVISIBLE);
        }

        //MapController.getInstance(this).setInstructionToDisplay(id);
    } catch (Exception e) {
        displayInfo(getString(R.string.message_map_navigation_error));
        e.printStackTrace();
    }
}