List of usage examples for android.graphics Paint setStyle
public void setStyle(Style style)
From source file:net.line2soft.preambul.views.SlippyMapActivity.java
/** * Creates a {@link Paint} object with a certain color * @param color The wanted color// w w w . j a v a 2 s.c om * @param alpha The alpha channel * @return The created Paint object */ private Paint createPaint(int color, int alpha) { Paint pnt = new Paint(Paint.ANTI_ALIAS_FLAG); pnt.setColor(color); pnt.setAlpha(alpha); pnt.setStyle(Paint.Style.STROKE); pnt.setStrokeWidth(7); pnt.setStrokeJoin(Paint.Join.ROUND); pnt.setStrokeCap(Paint.Cap.ROUND); //pnt.setPathEffect(new DashPathEffect(new float[] { 20, 20 }, 0)); return pnt; }
From source file:com.longle1.facedetection.MainActivity.java
@Override protected void onDraw(Canvas canvas) { Paint paint = new Paint(); paint.setColor(Color.GREEN);/* ww w . j a v a 2s .com*/ 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 ww w . j a v a2s. com * * @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.yk.notification.util.BitmapUtil.java
/** * //from w w w .j av a 2 s . co m * @param bitmap * @return */ public static Bitmap createRoundImageWithBorder(Context context, Bitmap bitmap) { // int bitmapWidth = bitmap.getWidth(); // int bitmapHeight = bitmap.getHeight(); // pixel int borderWidthHalf = 20; //?? int bitmapSquareWidth = Math.min(bitmapWidth, bitmapHeight); //? int newBitmapSquareWidth = bitmapSquareWidth + borderWidthHalf; Bitmap roundedBitmap = Bitmap.createBitmap(newBitmapSquareWidth, newBitmapSquareWidth, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(roundedBitmap); int x = borderWidthHalf + bitmapSquareWidth - bitmapWidth; int y = borderWidthHalf + bitmapSquareWidth - bitmapHeight; //???,?X,Y?2 ?? canvas.drawBitmap(bitmap, x / 2, y / 2, null); Paint borderPaint = new Paint(); borderPaint.setStyle(Paint.Style.STROKE); borderPaint.setStrokeWidth(borderWidthHalf); borderPaint.setColor(Color.WHITE); // canvas.drawCircle(canvas.getWidth() / 2, canvas.getWidth() / 2, newBitmapSquareWidth / 2, borderPaint); RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), roundedBitmap); roundedBitmapDrawable.setGravity(Gravity.CENTER); roundedBitmapDrawable.setCircular(true); return getBitmapFromDrawable(roundedBitmapDrawable); }
From source file:com.android.contacts.common.ContactPhotoManager.java
/** * If necessary, decodes bytes stored in the holder to Bitmap. As long as the * bitmap is held either by {@link #mBitmapCache} or by a soft reference in * the holder, it will not be necessary to decode the bitmap. *///from w w w .jav a 2 s. c o m private static void inflateBitmap(BitmapHolder holder, int requestedExtent) { final int sampleSize = BitmapUtil.findOptimalSampleSize(holder.originalSmallerExtent, requestedExtent); byte[] bytes = holder.bytes; if (bytes == null || bytes.length == 0) { return; } if (sampleSize == holder.decodedSampleSize) { // Check the soft reference. If will be retained if the bitmap is also // in the LRU cache, so we don't need to check the LRU cache explicitly. if (holder.bitmapRef != null) { holder.bitmap = holder.bitmapRef.get(); if (holder.bitmap != null) { return; } } } try { Bitmap bitmap = BitmapUtil.decodeBitmapFromBytes(bytes, sampleSize); // TODO: As a temporary workaround while framework support is being added to // clip non-square bitmaps into a perfect circle, manually crop the bitmap into // into a square if it will be displayed as a thumbnail so that it can be cropped // into a circle. final int height = bitmap.getHeight(); final int width = bitmap.getWidth(); // The smaller dimension of a scaled bitmap can range from anywhere from 0 to just // below twice the length of a thumbnail image due to the way we calculate the optimal // sample size. if (height != width && Math.min(height, width) <= mThumbnailSize * 2) { final int dimension = Math.min(height, width); bitmap = ThumbnailUtils.extractThumbnail(bitmap, dimension, dimension); } // make bitmap mutable and draw size onto it if (DEBUG_SIZES) { Bitmap original = bitmap; bitmap = bitmap.copy(bitmap.getConfig(), true); original.recycle(); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); paint.setTextSize(16); paint.setColor(Color.BLUE); paint.setStyle(Style.FILL); canvas.drawRect(0.0f, 0.0f, 50.0f, 20.0f, paint); paint.setColor(Color.WHITE); paint.setAntiAlias(true); canvas.drawText(bitmap.getWidth() + "/" + sampleSize, 0, 15, paint); } holder.decodedSampleSize = sampleSize; holder.bitmap = bitmap; holder.bitmapRef = new SoftReference<Bitmap>(bitmap); if (DEBUG) { Log.d(TAG, "inflateBitmap " + btk(bytes.length) + " -> " + bitmap.getWidth() + "x" + bitmap.getHeight() + ", " + btk(bitmap.getByteCount())); } } catch (OutOfMemoryError e) { // Do nothing - the photo will appear to be missing } }
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 av a2 s .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:com.waz.zclient.pages.main.conversation.LocationFragment.java
private Bitmap getMarker() { if (marker != null) { return marker; }//from ww w. j a v a 2s . c o m int size = getResources().getDimensionPixelSize(R.dimen.share_location__current_location_marker__size); int outerCircleRadius = getResources() .getDimensionPixelSize(R.dimen.share_location__current_location_marker__outer_ring_radius); int midCircleRadius = getResources() .getDimensionPixelSize(R.dimen.share_location__current_location_marker__mid_ring_radius); int innerCircleRadius = getResources() .getDimensionPixelSize(R.dimen.share_location__current_location_marker__inner_ring_radius); Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); paint.setColor(getControllerFactory().getAccentColorController().getColor()); paint.setAntiAlias(true); paint.setStyle(Paint.Style.FILL); paint.setAlpha( getResources().getInteger(R.integer.share_location__current_location_marker__outer_ring_alpha)); canvas.drawCircle(size / 2, size / 2, outerCircleRadius, paint); paint.setAlpha( getResources().getInteger(R.integer.share_location__current_location_marker__mid_ring_alpha)); canvas.drawCircle(size / 2, size / 2, midCircleRadius, paint); paint.setAlpha( getResources().getInteger(R.integer.share_location__current_location_marker__inner_ring_alpha)); canvas.drawCircle(size / 2, size / 2, innerCircleRadius, paint); marker = bitmap; return marker; }
From source file:org.mdc.chess.ChessBoard.java
public ChessBoard(Context context, AttributeSet attrs) { super(context, attrs); pos = new Position(); selectedSquare = -1;//from w w w .j a v a 2 s .c o m userSelectedSquare = false; cursorX = cursorY = 0; cursorVisible = false; x0 = y0 = sqSize = 0; pieceXDelta = pieceYDelta = -1; flipped = false; drawSquareLabels = false; toggleSelection = false; highlightLastMove = true; blindMode = false; darkPaint = new Paint(); brightPaint = new Paint(); selectedSquarePaint = new Paint(); selectedSquarePaint.setStyle(Paint.Style.STROKE); selectedSquarePaint.setAntiAlias(true); cursorSquarePaint = new Paint(); cursorSquarePaint.setStyle(Paint.Style.STROKE); cursorSquarePaint.setAntiAlias(true); whitePiecePaint = new Paint(); whitePiecePaint.setAntiAlias(true); blackPiecePaint = new Paint(); blackPiecePaint.setAntiAlias(true); labelPaint = new Paint(); labelPaint.setAntiAlias(true); decorationPaint = new Paint(); decorationPaint.setAntiAlias(true); moveMarkPaint = new ArrayList<>(); for (int i = 0; i < 6; i++) { Paint p = new Paint(); p.setStyle(Paint.Style.FILL); p.setAntiAlias(true); moveMarkPaint.add(p); } if (isInEditMode()) { return; } Typeface chessFont = Typeface.createFromAsset(getContext().getAssets(), "fonts/ChessCases.ttf"); whitePiecePaint.setTypeface(chessFont); blackPiecePaint.setTypeface(chessFont); setColors(); }
From source file:eu.hydrologis.geopaparazzi.chart.ProfileChartActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.profilechart); int backgroundColor = getResources().getColor(R.color.main_background); int decorationsColor = getResources().getColor(R.color.main_decorations_dark); int textColor = getResources().getColor(R.color.main_text_color_neutral); Bundle extras = getIntent().getExtras(); if (extras != null) { try {//from ww w . ja v a2s. c o m long logid = extras.getLong(Constants.ID); line = DaoGpsLog.getGpslogAsLine(logid, -1); } catch (IOException e) { GPLog.error(this, e.getLocalizedMessage(), e); e.printStackTrace(); } } else { Toast.makeText(this, R.string.an_error_occurred_while_creating_the_chart_, Toast.LENGTH_LONG).show(); } final float f26 = PixelUtils.dpToPix(26); final float f10 = PixelUtils.dpToPix(10); final SizeMetrics sm = new SizeMetrics(0, SizeLayoutType.FILL, 0, SizeLayoutType.FILL); xyPlotSpeed = (XYPlot) findViewById(R.id.speed_plot); xyPlotElev = (XYPlot) findViewById(R.id.elevation_plot); xyPlotSpeed.setOnTouchListener(this); infoTextView = (TextView) findViewById(R.id.info_text); Button resetButton = (Button) findViewById(R.id.reset_chart_button); resetButton.setOnClickListener(this); drawerLayout = (DrawerLayout) findViewById(R.id.container_drawer); // Disable Hardware Acceleration on the xyPlot view object. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { xyPlotSpeed.setLayerType(View.LAYER_TYPE_SOFTWARE, null); xyPlotElev.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } /* * Setup the Plots */ xyPlotSpeed.setPlotMargins(0, 0, 0, 0); xyPlotElev.setPlotMargins(0, 0, 0, 0); xyPlotSpeed.setPlotPadding(0, 0, 0, 0); xyPlotElev.setPlotPadding(0, 0, 0, 0); xyPlotElev.getDomainLabelWidget().setVisible(false); xyPlotElev.getRangeLabelWidget().setVisible(false); xyPlotElev.getTitleWidget().setVisible(false); xyPlotElev.setBorderPaint(null); xyPlotElev.setBackgroundPaint(null); /* * Setup the Graph Widgets */ XYGraphWidget graphWidgetSpeed = xyPlotSpeed.getGraphWidget(); XYGraphWidget graphWidgetElev = xyPlotElev.getGraphWidget(); graphWidgetSpeed.setSize(sm); graphWidgetElev.setSize(sm); graphWidgetSpeed.setMargins(0, 0, 0, 0); graphWidgetElev.setMargins(0, 0, 0, 0); graphWidgetSpeed.setPadding(f26, f10, f26, f26); graphWidgetElev.setPadding(f26, f10, f26, f26); graphWidgetSpeed.setRangeAxisPosition(true, false, 4, "10"); graphWidgetElev.setRangeAxisPosition(false, false, 4, "10"); graphWidgetSpeed.setRangeLabelVerticalOffset(-3); graphWidgetElev.setRangeLabelVerticalOffset(-3); graphWidgetSpeed.setRangeOriginLabelPaint(null); graphWidgetElev.setRangeOriginLabelPaint(null); graphWidgetSpeed.setRangeLabelWidth(0); graphWidgetElev.setRangeLabelWidth(0); graphWidgetSpeed.setDomainLabelWidth(0); graphWidgetElev.setDomainLabelWidth(0); graphWidgetElev.setBackgroundPaint(null); graphWidgetElev.setDomainLabelPaint(null); graphWidgetElev.setGridBackgroundPaint(null); graphWidgetElev.setDomainOriginLabelPaint(null); graphWidgetElev.setRangeOriginLinePaint(null); graphWidgetElev.setDomainGridLinePaint(null); graphWidgetElev.setRangeGridLinePaint(null); graphWidgetSpeed.getBackgroundPaint().setColor(backgroundColor); graphWidgetSpeed.getGridBackgroundPaint().setColor(backgroundColor); graphWidgetSpeed.getRangeOriginLinePaint().setColor(decorationsColor); graphWidgetSpeed.getRangeOriginLinePaint().setStrokeWidth(3f); graphWidgetSpeed.getDomainOriginLinePaint().setColor(decorationsColor); graphWidgetSpeed.getDomainOriginLinePaint().setStrokeWidth(3f); graphWidgetSpeed.getRangeGridLinePaint().setColor(decorationsColor); graphWidgetSpeed.getRangeGridLinePaint().setStrokeWidth(1f); graphWidgetSpeed.getDomainGridLinePaint().setColor(decorationsColor); graphWidgetSpeed.getDomainGridLinePaint().setStrokeWidth(1f); graphWidgetSpeed.getRangeLabelPaint().setColor(textColor); graphWidgetSpeed.getDomainLabelPaint().setColor(textColor); graphWidgetSpeed.getDomainOriginLabelPaint().setColor(textColor); Paint rangeOriginLabelPaint = graphWidgetSpeed.getRangeOriginLabelPaint(); if (rangeOriginLabelPaint == null) { rangeOriginLabelPaint = new Paint(Paint.ANTI_ALIAS_FLAG); rangeOriginLabelPaint.setStyle(Paint.Style.STROKE); graphWidgetSpeed.setRangeOriginLabelPaint(rangeOriginLabelPaint); } rangeOriginLabelPaint.setColor(textColor); graphWidgetSpeed.getRangeLabelPaint().setTextSize(PixelUtils.dpToPix(8)); graphWidgetElev.getRangeLabelPaint().setTextSize(PixelUtils.dpToPix(8)); graphWidgetSpeed.getDomainOriginLabelPaint().setTextSize(PixelUtils.dpToPix(8)); graphWidgetSpeed.getDomainLabelPaint().setTextSize(PixelUtils.dpToPix(8)); float textSize = graphWidgetSpeed.getRangeLabelPaint().getTextSize(); graphWidgetSpeed.setRangeLabelVerticalOffset((textSize / 2) * -1); graphWidgetElev.setRangeLabelVerticalOffset(graphWidgetSpeed.getRangeLabelVerticalOffset()); /* * Position the Graph Widgets in the Centre */ graphWidgetSpeed.position(0, XLayoutStyle.ABSOLUTE_FROM_CENTER, 0, YLayoutStyle.ABSOLUTE_FROM_CENTER, AnchorPosition.CENTER); graphWidgetElev.position(0, XLayoutStyle.ABSOLUTE_FROM_CENTER, 0, YLayoutStyle.ABSOLUTE_FROM_CENTER, AnchorPosition.CENTER); /* * Position the Label Widgets */ xyPlotSpeed.getDomainLabelWidget().setWidth(100); xyPlotSpeed.getRangeLabelWidget().setWidth(100); xyPlotSpeed.getDomainLabelWidget().position(0, XLayoutStyle.RELATIVE_TO_CENTER, 1, YLayoutStyle.ABSOLUTE_FROM_BOTTOM, AnchorPosition.BOTTOM_MIDDLE); xyPlotSpeed.getRangeLabelWidget().position(1, XLayoutStyle.ABSOLUTE_FROM_LEFT, -20, YLayoutStyle.ABSOLUTE_FROM_CENTER, AnchorPosition.LEFT_BOTTOM); /* * Setup and Position the speed Legend */ XYLegendWidget legendWidgetSpeed = xyPlotSpeed.getLegendWidget(); legendWidgetSpeed.setSize(new SizeMetrics(100, SizeLayoutType.ABSOLUTE, 200, SizeLayoutType.ABSOLUTE)); legendWidgetSpeed.setPadding(1, 1, 1, 1); legendWidgetSpeed.setTableModel(new DynamicTableModel(1, 3)); legendWidgetSpeed.setIconSizeMetrics(new SizeMetrics(PixelUtils.dpToPix(10), SizeLayoutType.ABSOLUTE, PixelUtils.dpToPix(10), SizeLayoutType.ABSOLUTE)); legendWidgetSpeed.getTextPaint().setColor(textColor); legendWidgetSpeed.getTextPaint().setTextSize(PixelUtils.dpToPix(9)); legendWidgetSpeed.position(PixelUtils.dpToPix(30), XLayoutStyle.ABSOLUTE_FROM_LEFT, f10 + 2, YLayoutStyle.ABSOLUTE_FROM_TOP, AnchorPosition.LEFT_TOP); /* * Setup and Position the elev Legend */ XYLegendWidget legendWidgetElev = xyPlotElev.getLegendWidget(); legendWidgetElev.setSize(new SizeMetrics(100, SizeLayoutType.ABSOLUTE, 200, SizeLayoutType.ABSOLUTE)); legendWidgetElev.setPadding(1, 1, 1, 1); legendWidgetElev.setTableModel(new DynamicTableModel(1, 3)); legendWidgetElev.setIconSizeMetrics(new SizeMetrics(PixelUtils.dpToPix(10), SizeLayoutType.ABSOLUTE, PixelUtils.dpToPix(10), SizeLayoutType.ABSOLUTE)); // legendWidgetElev.getTextPaint().setColor(textColor); legendWidgetElev.getTextPaint().setTextSize(PixelUtils.dpToPix(9)); legendWidgetElev.getTextPaint().setTextAlign(Align.RIGHT); legendWidgetElev.setMarginLeft(185); legendWidgetElev.position(PixelUtils.dpToPix(30), XLayoutStyle.ABSOLUTE_FROM_RIGHT, f10 + 2, YLayoutStyle.ABSOLUTE_FROM_TOP, AnchorPosition.RIGHT_TOP); // Setup the formatters int rgbSpeedLine = Color.rgb(0, 200, 0); int rgbSpeedPoints = Color.rgb(0, 100, 0); int rgbElevLine = Color.rgb(0, 0, 200); int rgbElevPoints = Color.rgb(0, 0, 100); seriesSpeedFormat = new LineAndPointFormatter(rgbSpeedLine, rgbSpeedPoints, null, null); seriesElevFormat = new LineAndPointFormatter(rgbElevLine, rgbElevPoints, null, null); }
From source file:org.navitproject.navit.NavitGraphics.java
protected void draw_circle(Paint paint, int x, int y, int r) { paint.setStyle(Paint.Style.STROKE); draw_canvas.drawCircle(x, y, r / 2, paint); }