List of usage examples for android.graphics Paint Paint
public Paint(Paint paint)
From source file:com.cssweb.android.view.KlineView.java
public void onDraw(Canvas canvas) { paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(1);/*from w ww. ja v a 2 s. com*/ tPaint = new Paint(); tPaint.setStyle(Paint.Style.STROKE); tPaint.setTypeface(Typeface.DEFAULT_BOLD); tPaint.setAntiAlias(true); tPaint.setTextSize(dTextSize); // tips = (int) tPaint.measureText("0"); try { if (actualDataLen == 0) { return; } if (zs) axisLabelWidth = (int) Math.max(tPaint.measureText("99999.99"), tPaint.measureText("11000")); else axisLabelWidth = (int) tPaint.measureText("11000"); klineWidth = width - axisLabelWidth; //?spaceWidth??? visualKLineCount = (int) ((klineWidth - spaceWidth) / (spaceWidth + shapeWidth)); if (isSingleMoved == false && isTrackStatus == false) { if (actualDataLen > visualKLineCount) { actualPos = actualDataLen - visualKLineCount; count = visualKLineCount; } else { actualPos = 0; count = actualDataLen; } } //Log.i("@@@@@@@@isTrackStatus@@@@@@@@@", isTrackStatus+">>>>>>"+actualDataLen+">>>>>>"+isTrackNumber + ">>>>>>>>>" + actualPos); calcMaxMin(actualPos); // axisLabelHeight = Font.getFontHeight(dTextSize); klineX = axisLabelWidth; klineY = axisLabelHeight; klineHeight = (int) ((height - axisLabelHeight) * 0.6); volumeHeight = (int) ((height - axisLabelHeight) * 0.4); axisX = klineX; if (!isTrackStatus) { moveQuote(actualDataLen - 1); } else { //isTrackNumber = (isTrackNumber>actualDataLen-1)?actualDataLen-1:isTrackNumber; if (trackLineV == 0) { trackLineV = (int) (visualPos * (spaceWidth + shapeWidth) - shapeWidth / 2); isTrackNumber = actualPos + visualPos - 1; } if (isTrackNumber < 0) { isTrackNumber = 0; } else if (isTrackNumber > actualDataLen - 1) { isTrackNumber = actualDataLen - 1; } paint.setColor(GlobalColor.clrGrayLine); canvas.drawLine(klineX + trackLineV, axisLabelHeight, klineX + trackLineV, height - axisLabelHeight, paint); moveQuote(isTrackNumber); drawQuoteWin(canvas, quoteData, isTrackNumber); } // tPaint.setTextAlign(Paint.Align.LEFT); tPaint.setColor(GlobalColor.colorM5); canvas.drawText(lblIndicatorName, (float) (klineX + tips), axisLabelHeight - 5, tPaint); float size = tPaint.measureText(lblIndicatorName) + tips * 2; tPaint.setColor(GlobalColor.colorM10); canvas.drawText(lblIndicatorT1, (float) (klineX + size), axisLabelHeight - 5, tPaint); size += tPaint.measureText(lblIndicatorT1) + tips; if (size <= (klineWidth - tPaint.measureText(lblIndicatorT2))) { //tPaint.setColor(GlobalColor.colorM20); tPaint.setARGB(255, 255, 0, 255); canvas.drawText(lblIndicatorT2, (float) (klineX + size), axisLabelHeight - 5, tPaint); } size += tPaint.measureText(lblIndicatorT2) + tips; if (size <= (klineWidth - tPaint.measureText(lblIndicatorT3))) { tPaint.setColor(GlobalColor.colorM60); canvas.drawText(lblIndicatorT3, (float) (klineX + size), axisLabelHeight - 5, tPaint); } //? tPaint.setColor(GlobalColor.colorLabelName); canvas.drawText(lblmainIndicatorT1, (float) (klineX + tips), klineY + klineHeight + axisLabelHeight - 5, tPaint); size = tPaint.measureText(lblmainIndicatorT1) + tips * 2; tPaint.setColor(GlobalColor.colorM5); canvas.drawText(lblmainIndicatorT2, (float) (klineX + size), klineY + klineHeight + axisLabelHeight - 5, tPaint); size += tPaint.measureText(lblmainIndicatorT2) + tips; if (size <= (klineWidth - tPaint.measureText(lblmainIndicatorT3))) { tPaint.setColor(GlobalColor.colorM10); canvas.drawText(lblmainIndicatorT3, (float) (klineX + size), klineY + klineHeight + axisLabelHeight - 5, tPaint); } size += tPaint.measureText(lblmainIndicatorT3) + tips; if (size <= (klineWidth - tPaint.measureText(lblmainIndicatorT4))) { tPaint.setARGB(255, 255, 0, 255); canvas.drawText(lblmainIndicatorT4, (float) (klineX + size), klineY + klineHeight + axisLabelHeight - 5, tPaint); } //??? rowHeight = klineHeight / rowNum; scale = klineHeight / (highPrice - lowPrice); double ratio = (highPrice - lowPrice) / rowNum; paint.setColor(GlobalColor.clrLine); tPaint.setColor(GlobalColor.colorTicklabel); tPaint.setTextAlign(Paint.Align.RIGHT); for (int i = 0; i <= rowNum; i++) { if (i == rowNum || i == 0) { canvas.drawLine(klineX, klineY + rowHeight * i, width, klineY + rowHeight * i, paint); } else { Graphics.drawDashline(canvas, klineX, klineY + rowHeight * i, width, klineY + rowHeight * i, paint); } if (i != rowNum && isTrackStatus == false) { double AxisLabelPrice = highPrice - ratio * i; String AxisLabelPriceText; AxisLabelPriceText = Utils.dataFormation(AxisLabelPrice, stockdigit); canvas.drawText(AxisLabelPriceText, klineX - tips / 4, klineY + rowHeight * i + axisLabelHeight / 2, tPaint); } } // if (quoteData != null) { //axisX = 0; for (int i = actualPos; i < (actualPos + count); i++) { if (i == 0) drawKLine(canvas, i - actualPos, quoteData.getJSONArray("K").getJSONArray(i).getDouble(1), quoteData.getJSONArray("K").getJSONArray(i).getDouble(2), quoteData.getJSONArray("K").getJSONArray(i).getDouble(3), quoteData.getJSONArray("K").getJSONArray(i).getDouble(4), quoteData.getJSONArray("K").getJSONArray(i).getDouble(4)); else drawKLine(canvas, i - actualPos, quoteData.getJSONArray("K").getJSONArray(i).getDouble(1), quoteData.getJSONArray("K").getJSONArray(i).getDouble(2), quoteData.getJSONArray("K").getJSONArray(i).getDouble(3), quoteData.getJSONArray("K").getJSONArray(i).getDouble(4), quoteData.getJSONArray("K").getJSONArray(i - 1).getDouble(4)); } if (mainIndicatorType.toUpperCase().equals("MA")) drawMA(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); else if (mainIndicatorType.toUpperCase().equals("BOLL")) drawBoll(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); rowHeight = (volumeHeight - axisLabelHeight * 2) / rowNum; klineY = klineHeight + axisLabelHeight * 2; volumeHeight = rowNum * rowHeight; if (indicatorType.toUpperCase().equals("VOLUME")) drawVOLUME(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); else if (indicatorType.toUpperCase().equals("MACD")) drawMACD(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); else if (indicatorType.toUpperCase().equals("CCI")) drawCCI(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); else if (indicatorType.toUpperCase().equals("BIAS")) drawBIAS(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); else if (indicatorType.toUpperCase().equals("KDJ")) drawKDJ(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); else if (indicatorType.toUpperCase().equals("RSI")) drawRSI(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); else if (indicatorType.toUpperCase().equals("OBV")) drawOBV(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); else if (indicatorType.toUpperCase().equals("PSY")) drawOther(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen, "PSY"); else if (indicatorType.toUpperCase().equals("ROC")) drawROC(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen, "ROC"); else if (indicatorType.toUpperCase().equals("VR")) drawOther(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen, "VR"); else if (indicatorType.toUpperCase().equals("WR")) drawOther(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen, "WR"); drawTimeAix(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); } //????? paint.setColor(GlobalColor.clrLine); canvas.drawLine(klineX, 0, width, 0, paint); canvas.drawLine(klineX, 0, klineX, height - axisLabelHeight, paint); canvas.drawLine(width, 0, width, height - axisLabelHeight, paint); //canvas.drawLine(klineX, height - axisLabelHeight, width, height - axisLabelHeight, paint); } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.cssweb.android.view.KlineViewSingle.java
public void onDraw(Canvas canvas) { paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(1);//from w ww .ja va2 s . co m tPaint = new Paint(); tPaint.setStyle(Paint.Style.STROKE); tPaint.setTypeface(Typeface.DEFAULT_BOLD); tPaint.setAntiAlias(true); tPaint.setTextSize(dTextSize); // tips = (int) tPaint.measureText("0"); try { if (actualDataLen == 0) { return; } if (zs) axisLabelWidth = (int) Math.max(tPaint.measureText("99999.99"), tPaint.measureText("11000")); else axisLabelWidth = (int) tPaint.measureText("11000"); klineWidth = width - axisLabelWidth; //?spaceWidth??? visualKLineCount = (int) ((klineWidth - spaceWidth) / (spaceWidth + shapeWidth)); if (isSingleMoved == false && isTrackStatus == false) { if (actualDataLen > visualKLineCount) { actualPos = actualDataLen - visualKLineCount; count = visualKLineCount; } else { actualPos = 0; count = actualDataLen; } } calcMaxMin(actualPos); // axisLabelHeight = Font.getFontHeight(dTextSize); klineX = axisLabelWidth; klineY = axisLabelHeight; klineHeight = (int) ((height - axisLabelHeight) * 0.6); volumeHeight = (int) ((height - axisLabelHeight) * 0.4); axisX = klineX; if (!isTrackStatus) { moveQuote(actualDataLen - 1); } else { if (trackLineV == 0) { trackLineV = (int) (visualPos * (spaceWidth + shapeWidth) - shapeWidth / 2); isTrackNumber = actualPos + visualPos - 1; } if (isTrackNumber < 0) { isTrackNumber = 0; } else if (isTrackNumber > actualDataLen - 1) { isTrackNumber = actualDataLen - 1; } paint.setColor(GlobalColor.clrGrayLine); canvas.drawLine(klineX + trackLineV, axisLabelHeight, klineX + trackLineV, height - axisLabelHeight, paint); moveQuote(isTrackNumber); drawQuoteWin(canvas, quoteData, isTrackNumber); } // tPaint.setTextAlign(Paint.Align.LEFT); tPaint.setColor(GlobalColor.colorM5); canvas.drawText(lblIndicatorName, (float) (klineX + tips), axisLabelHeight - 5, tPaint); float size = tPaint.measureText(lblIndicatorName) + tips * 2; tPaint.setColor(GlobalColor.colorM10); canvas.drawText(lblIndicatorT1, (float) (klineX + size), axisLabelHeight - 5, tPaint); size += tPaint.measureText(lblIndicatorT1) + tips; if (size <= (klineWidth - tPaint.measureText(lblIndicatorT2))) { //tPaint.setColor(GlobalColor.colorM20); tPaint.setARGB(255, 255, 0, 255); canvas.drawText(lblIndicatorT2, (float) (klineX + size), axisLabelHeight - 5, tPaint); } size += tPaint.measureText(lblIndicatorT2) + tips; if (size <= (klineWidth - tPaint.measureText(lblIndicatorT3))) { tPaint.setColor(GlobalColor.colorM60); canvas.drawText(lblIndicatorT3, (float) (klineX + size), axisLabelHeight - 5, tPaint); } //? tPaint.setColor(GlobalColor.colorLabelName); canvas.drawText(lblmainIndicatorT1, (float) (klineX + tips), klineY + klineHeight + axisLabelHeight - 5, tPaint); size = tPaint.measureText(lblmainIndicatorT1) + tips * 2; tPaint.setColor(GlobalColor.colorM5); canvas.drawText(lblmainIndicatorT2, (float) (klineX + size), klineY + klineHeight + axisLabelHeight - 5, tPaint); size += tPaint.measureText(lblmainIndicatorT2) + tips; if (size <= (klineWidth - tPaint.measureText(lblmainIndicatorT3))) { tPaint.setColor(GlobalColor.colorM10); canvas.drawText(lblmainIndicatorT3, (float) (klineX + size), klineY + klineHeight + axisLabelHeight - 5, tPaint); } size += tPaint.measureText(lblmainIndicatorT3) + tips; if (size <= (klineWidth - tPaint.measureText(lblmainIndicatorT4))) { tPaint.setARGB(255, 255, 0, 255); canvas.drawText(lblmainIndicatorT4, (float) (klineX + size), klineY + klineHeight + axisLabelHeight - 5, tPaint); } //??? rowHeight = klineHeight / rowNum; scale = klineHeight / (highPrice - lowPrice); double ratio = (highPrice - lowPrice) / rowNum; paint.setColor(GlobalColor.clrLine); tPaint.setColor(GlobalColor.colorTicklabel); tPaint.setTextAlign(Paint.Align.RIGHT); for (int i = 0; i <= rowNum; i++) { if (i == rowNum || i == 0) { canvas.drawLine(klineX, klineY + rowHeight * i, width, klineY + rowHeight * i, paint); } else { Graphics.drawDashline(canvas, klineX, klineY + rowHeight * i, width, klineY + rowHeight * i, paint); } if (i != rowNum && isTrackStatus == false) { double AxisLabelPrice = highPrice - ratio * i; String AxisLabelPriceText; AxisLabelPriceText = Utils.dataFormation(AxisLabelPrice, stockdigit); canvas.drawText(AxisLabelPriceText, klineX - tips / 4, klineY + rowHeight * i + axisLabelHeight / 2, tPaint); } } // if (quoteData != null) { //axisX = 0; for (int i = actualPos; i < (actualPos + count); i++) { if (i == 0) drawKLine(canvas, i - actualPos, quoteData.getJSONArray("K").getJSONArray(i).getDouble(1), quoteData.getJSONArray("K").getJSONArray(i).getDouble(2), quoteData.getJSONArray("K").getJSONArray(i).getDouble(3), quoteData.getJSONArray("K").getJSONArray(i).getDouble(4), quoteData.getJSONArray("K").getJSONArray(i).getDouble(4)); else drawKLine(canvas, i - actualPos, quoteData.getJSONArray("K").getJSONArray(i).getDouble(1), quoteData.getJSONArray("K").getJSONArray(i).getDouble(2), quoteData.getJSONArray("K").getJSONArray(i).getDouble(3), quoteData.getJSONArray("K").getJSONArray(i).getDouble(4), quoteData.getJSONArray("K").getJSONArray(i - 1).getDouble(4)); } if (mainIndicatorType.toUpperCase().equals("MA")) drawMA(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); else if (mainIndicatorType.toUpperCase().equals("BOLL")) drawBoll(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); rowHeight = (volumeHeight - axisLabelHeight * 2) / rowNum; klineY = klineHeight + axisLabelHeight * 2; volumeHeight = rowNum * rowHeight; if (indicatorType.toUpperCase().equals("VOLUME")) drawVOLUME(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); else if (indicatorType.toUpperCase().equals("MACD")) drawMACD(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); else if (indicatorType.toUpperCase().equals("CCI")) drawCCI(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); else if (indicatorType.toUpperCase().equals("BIAS")) drawBIAS(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); else if (indicatorType.toUpperCase().equals("KDJ")) drawKDJ(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); else if (indicatorType.toUpperCase().equals("RSI")) drawRSI(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); else if (indicatorType.toUpperCase().equals("OBV")) drawOBV(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); else if (indicatorType.toUpperCase().equals("PSY")) drawOther(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen, "PSY"); else if (indicatorType.toUpperCase().equals("ROC")) drawROC(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen, "ROC"); else if (indicatorType.toUpperCase().equals("VR")) drawOther(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen, "VR"); else if (indicatorType.toUpperCase().equals("WR")) drawOther(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen, "WR"); drawTimeAix(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); } //????? paint.setColor(GlobalColor.clrLine); canvas.drawLine(klineX, 0, width, 0, paint); canvas.drawLine(klineX, 0, klineX, height - axisLabelHeight, paint); canvas.drawLine(width, 0, width, height - axisLabelHeight, paint); //canvas.drawLine(klineX, height - axisLabelHeight, width, height - axisLabelHeight, paint); } catch (JSONException e) { e.printStackTrace(); } }
From source file:android.support.design.widget.CollapsingTextHelper.java
private void ensureExpandedTexture() { if (mExpandedTitleTexture != null || mExpandedBounds.isEmpty() || TextUtils.isEmpty(mTextToDraw)) { return;//from w w w .ja va2 s .com } calculateOffsets(0f); mTextureAscent = mTextPaint.ascent(); mTextureDescent = mTextPaint.descent(); final int w = Math.round(mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length())); final int h = Math.round(mTextureDescent - mTextureAscent); if (w <= 0 || h <= 0) { return; // If the width or height are 0, return } mExpandedTitleTexture = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(mExpandedTitleTexture); c.drawText(mTextToDraw, 0, mTextToDraw.length(), 0, h - mTextPaint.descent(), mTextPaint); if (mTexturePaint == null) { // Make sure we have a paint mTexturePaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG); } }
From source file:net.droidsolutions.droidcharts.core.plot.CategoryPlot.java
/** * Creates a new plot.//from w ww . j a v a 2 s. com * * @param dataset * the dataset (<code>null</code> permitted). * @param domainAxis * the domain axis (<code>null</code> permitted). * @param rangeAxis * the range axis (<code>null</code> permitted). * @param renderer * the item renderer (<code>null</code> permitted). * */ public CategoryPlot(CategoryDataset dataset, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryItemRenderer renderer) { super(); this.orientation = PlotOrientation.VERTICAL; // allocate storage for dataset, axes and renderers this.domainAxes = new ObjectList(); this.domainAxisLocations = new ObjectList(); this.rangeAxes = new ObjectList(); this.rangeAxisLocations = new ObjectList(); this.datasetToDomainAxesMap = new TreeMap(); this.datasetToRangeAxesMap = new TreeMap(); this.renderers = new ObjectList(); this.datasets = new ObjectList(); this.datasets.set(0, dataset); this.axisOffset = RectangleInsets.ZERO_INSETS; setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT, false); setRangeAxisLocation(AxisLocation.TOP_OR_LEFT, false); this.renderers.set(0, renderer); if (renderer != null) { renderer.setPlot(this); renderer.addChangeListener(this); } this.domainAxes.set(0, domainAxis); this.mapDatasetToDomainAxis(0, 0); if (domainAxis != null) { domainAxis.setPlot(this); } this.drawSharedDomainAxis = false; this.rangeAxes.set(0, rangeAxis); this.mapDatasetToRangeAxis(0, 0); if (rangeAxis != null) { rangeAxis.setPlot(this); } configureDomainAxes(); configureRangeAxes(); this.domainGridlinesVisible = DEFAULT_DOMAIN_GRIDLINES_VISIBLE; this.domainGridlinePosition = CategoryAnchor.MIDDLE; this.domainGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.domainGridlinePaint = DEFAULT_GRIDLINE_PAINT; this.rangeZeroBaselineVisible = false; Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.BLACK); this.rangeZeroBaselinePaint = paint; this.rangeZeroBaselineStroke = .5f; this.rangeGridlinesVisible = DEFAULT_RANGE_GRIDLINES_VISIBLE; this.rangeGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.rangeGridlinePaint = DEFAULT_GRIDLINE_PAINT; this.rangeMinorGridlinesVisible = false; this.rangeMinorGridlineStroke = DEFAULT_GRIDLINE_STROKE; paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.WHITE); this.rangeMinorGridlinePaint = paint; this.foregroundDomainMarkers = new HashMap(); this.backgroundDomainMarkers = new HashMap(); this.foregroundRangeMarkers = new HashMap(); this.backgroundRangeMarkers = new HashMap(); this.anchorValue = 0.0; this.domainCrosshairVisible = false; this.domainCrosshairStroke = DEFAULT_CROSSHAIR_STROKE; this.domainCrosshairPaint = DEFAULT_CROSSHAIR_PAINT; this.rangeCrosshairVisible = DEFAULT_CROSSHAIR_VISIBLE; this.rangeCrosshairValue = 0.0; this.rangeCrosshairStroke = DEFAULT_CROSSHAIR_STROKE; this.rangeCrosshairPaint = DEFAULT_CROSSHAIR_PAINT; this.annotations = new java.util.ArrayList(); this.rangePannable = false; }
From source file:com.chrynan.guitarchords.view.GuitarChordView.java
protected float getVerticalCenterTextPosition(float originalYPosition, String text, int textSizeInPixels) { Paint p = new Paint(Paint.ANTI_ALIAS_FLAG); p.setTextAlign(Paint.Align.CENTER); p.setTextSize(textSizeInPixels);/*from w w w . j ava2 s .co m*/ return getVerticalCenterTextPosition(originalYPosition, text, p); }
From source file:android.support.design.widget.CustomCollapsingTextHelper.java
private void ensureExpandedTexture() { if (mExpandedTitleTexture != null || mExpandedBounds.isEmpty() || TextUtils.isEmpty(mTextToDraw)) { return;// ww w . ja va2s.c om } calculateOffsets(0f); mTextureAscent = mTitlePaint.ascent(); mTextureDescent = mTitlePaint.descent(); final int w = Math.round(mTitlePaint.measureText(mTextToDraw, 0, mTextToDraw.length())); final int h = Math.round(mTextureDescent - mTextureAscent); if (w <= 0 || h <= 0) { return; // If the width or height are 0, return } mExpandedTitleTexture = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(mExpandedTitleTexture); c.drawText(mTextToDraw, 0, mTextToDraw.length(), 0, h - mTitlePaint.descent(), mTitlePaint); if (mTexturePaint == null) { // Make sure we have a paint mTexturePaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG); } }
From source file:net.droidsolutions.droidcharts.core.plot.XYPlot.java
/** * Creates a new plot with the specified dataset, axes and renderer. Any of * the arguments can be <code>null</code>, but in that case you should take * care to specify the value before using the plot (otherwise a * <code>NullPointerException</code> may be thrown). * /* w w w . j a v a2 s. c o m*/ * @param dataset * the dataset (<code>null</code> permitted). * @param domainAxis * the domain axis (<code>null</code> permitted). * @param rangeAxis * the range axis (<code>null</code> permitted). * @param renderer * the renderer (<code>null</code> permitted). */ public XYPlot(XYDataset dataset, ValueAxis domainAxis, ValueAxis rangeAxis, XYItemRenderer renderer) { super(); this.orientation = PlotOrientation.VERTICAL; this.weight = 1; // only relevant when this is a subplot this.axisOffset = RectangleInsets.ZERO_INSETS; // allocate storage for datasets, axes and renderers (all optional) this.domainAxes = new ObjectList(); this.domainAxisLocations = new ObjectList(); this.foregroundDomainMarkers = new HashMap(); this.backgroundDomainMarkers = new HashMap(); this.rangeAxes = new ObjectList(); this.rangeAxisLocations = new ObjectList(); this.foregroundRangeMarkers = new HashMap(); this.backgroundRangeMarkers = new HashMap(); this.datasets = new ObjectList(); this.renderers = new ObjectList(); this.datasetToDomainAxesMap = new TreeMap(); this.datasetToRangeAxesMap = new TreeMap(); this.annotations = new java.util.ArrayList(); this.datasets.set(0, dataset); if (dataset != null) { // dataset.addChangeListener(this); } this.renderers.set(0, renderer); if (renderer != null) { renderer.setPlot(this); renderer.addChangeListener(this); } this.domainAxes.set(0, domainAxis); this.mapDatasetToDomainAxis(0, 0); if (domainAxis != null) { domainAxis.setPlot(this); // domainAxis.addChangeListener(this); } this.domainAxisLocations.set(0, AxisLocation.BOTTOM_OR_LEFT); this.rangeAxes.set(0, rangeAxis); this.mapDatasetToRangeAxis(0, 0); if (rangeAxis != null) { rangeAxis.setPlot(this); // rangeAxis.addChangeListener(this); } this.rangeAxisLocations.set(0, AxisLocation.BOTTOM_OR_LEFT); configureDomainAxes(); configureRangeAxes(); Paint white = new Paint(Paint.ANTI_ALIAS_FLAG); white.setColor(Color.WHITE); Paint black = new Paint(Paint.ANTI_ALIAS_FLAG); white.setColor(Color.BLACK); this.domainGridlinesVisible = true; this.domainGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.domainGridlinePaint = DEFAULT_GRIDLINE_PAINT; this.domainMinorGridlinesVisible = false; this.domainMinorGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.domainMinorGridlinePaint = white; this.domainZeroBaselineVisible = false; this.domainZeroBaselinePaint = black; this.domainZeroBaselineStroke = 1f; this.rangeGridlinesVisible = true; this.rangeGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.rangeGridlinePaint = DEFAULT_GRIDLINE_PAINT; this.rangeMinorGridlinesVisible = false; this.rangeMinorGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.rangeMinorGridlinePaint = white; this.rangeZeroBaselineVisible = false; this.rangeZeroBaselinePaint = black; this.rangeZeroBaselineStroke = 1f; this.domainCrosshairVisible = false; this.domainCrosshairValue = 0.0; this.domainCrosshairStroke = DEFAULT_CROSSHAIR_STROKE; this.domainCrosshairPaint = DEFAULT_CROSSHAIR_PAINT; this.rangeCrosshairVisible = false; this.rangeCrosshairValue = 0.0; this.rangeCrosshairStroke = DEFAULT_CROSSHAIR_STROKE; this.rangeCrosshairPaint = DEFAULT_CROSSHAIR_PAINT; }
From source file:com.juick.android.MessagesFragment.java
public Paint getPaintFromCache(Paint original) { if (original instanceof TextPaint) { return new TextPaint(original); } else {/*from ww w . ja va2 s . c o m*/ return new Paint(original); } }