List of usage examples for android.graphics PointF PointF
public PointF(float x, float y)
From source file:project.pamela.slambench.fragments.FrequencyPlot.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Replace LinearLayout by the type of the root element of the layout you're trying to load LinearLayout llLayout = (LinearLayout) inflater.inflate(R.layout.fragment_plot, container, false); // Retrieve bench number Intent mIntent = super.getActivity().getIntent(); final int intValue = mIntent.getIntExtra(ResultActivity.SELECTED_TEST_TAG, 0); SLAMResult value = SLAMBenchApplication.getResults().get(intValue); if (!value.isFinished()) { Log.e(SLAMBenchApplication.LOG_TAG, this.getResources().getString(R.string.debug_proposed_value_not_valid)); return llLayout; }/*from w ww . j a v a 2 s . c o m*/ // initialize our XYPlot reference: XYPlot plot = (XYPlot) llLayout.findViewById(R.id.mySimpleXYPlot); plot.setBackgroundColor(Color.WHITE); plot.setTitle(value.test.name); plot.setDomainLabel(this.getResources().getString(R.string.legend_frame_number)); plot.setRangeLabel(this.getResources().getString(R.string.frequency_domain)); plot.setBackgroundColor(Color.WHITE); plot.getGraphWidget().getBackgroundPaint().setColor(Color.WHITE); plot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE); plot.getGraphWidget().getDomainLabelPaint().setColor(Color.BLACK); plot.getGraphWidget().getRangeLabelPaint().setColor(Color.BLACK); plot.getGraphWidget().getDomainOriginLabelPaint().setColor(Color.BLACK); plot.getGraphWidget().getDomainOriginLinePaint().setColor(Color.BLACK); plot.getGraphWidget().getRangeOriginLinePaint().setColor(Color.BLACK); plot.getGraphWidget().setRangeValueFormat(new DecimalFormat("#####.##")); int border = 60; int legendsize = 110; plot.getGraphWidget().position(border, XLayoutStyle.ABSOLUTE_FROM_LEFT, border, YLayoutStyle.ABSOLUTE_FROM_BOTTOM, AnchorPosition.LEFT_BOTTOM); plot.getGraphWidget() .setSize(new SizeMetrics(border + legendsize, SizeLayoutType.FILL, border, SizeLayoutType.FILL)); // reduce the number of range labels plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 10); plot.setDomainValueFormat(new DecimalFormat("#")); plot.setRangeStep(XYStepMode.SUBDIVIDE, 10); //Remove legend //plot.getLayoutManager().remove(plot.getLegendWidget()); //plot.getLayoutManager().remove(plot.getDomainLabelWidget()); //plot.getLayoutManager().remove(plot.getRangeLabelWidget()); plot.getLayoutManager().remove(plot.getTitleWidget()); // Set legend plot.getLegendWidget().setTableModel(new DynamicTableModel(4, 2)); Paint bgPaint = new Paint(); bgPaint.setColor(Color.BLACK); bgPaint.setStyle(Paint.Style.FILL); bgPaint.setAlpha(140); plot.getLegendWidget().setBackgroundPaint(bgPaint); plot.getLegendWidget() .setSize(new SizeMetrics(legendsize, SizeLayoutType.ABSOLUTE, 0, SizeLayoutType.FILL)); plot.getLegendWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_RIGHT, 0, YLayoutStyle.ABSOLUTE_FROM_TOP, AnchorPosition.RIGHT_TOP); plot.getDomainLabelWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_CENTER, 0, YLayoutStyle.RELATIVE_TO_BOTTOM, AnchorPosition.BOTTOM_MIDDLE); for (int i = 0; i < value.getCPUCount(); i++) { int strokecolor = Color.rgb(i * (255 / value.getCPUCount()), 137, 192); int fillcolor = Color.rgb(i * (255 / value.getCPUCount()), 229, 255); Double frequencyNumbers[] = value.getfrequencyList(i); XYSeries series = new SimpleXYSeries(Arrays.asList(frequencyNumbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, this.getResources().getString(R.string.frequency_legend, i)); LineAndPointFormatter seriesFormat = new LineAndPointFormatter(strokecolor, strokecolor, null, null); seriesFormat.setPointLabeler(new PointLabeler() { @Override public String getLabel(XYSeries series, int index) { return "o"; } }); Paint lineFill = new Paint(); lineFill.setAlpha(150); DisplayMetrics metrics = new DisplayMetrics(); super.getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics); lineFill.setShader(new LinearGradient(0, 0, 0, metrics.heightPixels, Color.WHITE, fillcolor, Shader.TileMode.MIRROR)); seriesFormat.setFillPaint(lineFill); plot.addSeries(series, seriesFormat); } plot.redraw(); plot.calculateMinMaxVals(); PointF minXY = new PointF(plot.getCalculatedMinX().floatValue(), plot.getCalculatedMinY().floatValue()); PointF maxXY = new PointF(plot.getCalculatedMaxX().floatValue(), plot.getCalculatedMaxY().floatValue()); plot.setDomainBoundaries(0, value.test.dataset.getFrameCount() - 1, BoundaryMode.FIXED); plot.setRangeBoundaries(Math.min(0, minXY.y), maxXY.y * 1.2f, BoundaryMode.FIXED); plot.redraw(); return llLayout; }
From source file:com.jrummyapps.android.widget.AnimatedSvgView.java
private void init(Context context, AttributeSet attrs) { mFillPaint = new Paint(); mFillPaint.setAntiAlias(true);//from w ww . ja va 2 s. c o m mFillPaint.setStyle(Paint.Style.FILL); mTraceColors = new int[1]; mTraceColors[0] = Color.BLACK; mTraceResidueColors = new int[1]; mTraceResidueColors[0] = 0x32000000; if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AnimatedSvgView); mViewportWidth = a.getInt(R.styleable.AnimatedSvgView_animatedSvgImageSizeX, 512); aspectRatioWidth = a.getInt(R.styleable.AnimatedSvgView_animatedSvgImageSizeX, 512); mViewportHeight = a.getInt(R.styleable.AnimatedSvgView_animatedSvgImageSizeY, 512); aspectRatioHeight = a.getInt(R.styleable.AnimatedSvgView_animatedSvgImageSizeY, 512); mTraceTime = a.getInt(R.styleable.AnimatedSvgView_animatedSvgTraceTime, 2000); mTraceTimePerGlyph = a.getInt(R.styleable.AnimatedSvgView_animatedSvgTraceTimePerGlyph, 1000); mFillStart = a.getInt(R.styleable.AnimatedSvgView_animatedSvgFillStart, 1200); mFillTime = a.getInt(R.styleable.AnimatedSvgView_animatedSvgFillTime, 1000); int traceMarkerLength = a.getInt(R.styleable.AnimatedSvgView_animatedSvgTraceMarkerLength, 16); mMarkerLength = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, traceMarkerLength, getResources().getDisplayMetrics()); // int glyphStringsId = a.getResourceId(R.styleable.AnimatedSvgView_animatedSvgGlyphStrings, 0); int traceResidueColorsId = a.getResourceId(R.styleable.AnimatedSvgView_animatedSvgTraceResidueColors, 0); int traceColorsId = a.getResourceId(R.styleable.AnimatedSvgView_animatedSvgTraceColors, 0); //int fillColorsId = a.getResourceId(R.styleable.AnimatedSvgView_animatedSvgFillColors, 0); a.recycle(); // if (glyphStringsId != 0) { // setGlyphStrings(getResources().getStringArray(glyphStringsId)); // setTraceResidueColor(Color.argb(50, 0, 0, 0)); // setTraceColor(Color.BLACK); // } if (traceResidueColorsId != 0) { setTraceResidueColors(getResources().getIntArray(traceResidueColorsId)); } if (traceColorsId != 0) { setTraceColors(getResources().getIntArray(traceColorsId)); } // if (fillColorsId != 0) { // setFillColors(getResources().getIntArray(fillColorsId)); // } mViewport = new PointF(mViewportWidth, mViewportHeight); } // Note: using a software layer here is an optimization. This view works with hardware accelerated rendering but // every time a path is modified (when the dash path effect is modified), the graphics pipeline will rasterize // the path again in a new texture. Since we are dealing with dozens of paths, it is much more efficient to // rasterize the entire view into a single re-usable texture instead. Ideally this should be toggled using a // heuristic based on the number and or dimensions of paths to render. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { setLayerType(LAYER_TYPE_SOFTWARE, null); } }
From source file:vi.pdfscanner.fragment.CropFragment.java
private Map<Integer, PointF> getOutlinePoints(Bitmap tempBitmap) { Map<Integer, PointF> outlinePoints = new HashMap<>(); outlinePoints.put(0, new PointF(0, 0)); outlinePoints.put(1, new PointF(tempBitmap.getWidth(), 0)); outlinePoints.put(2, new PointF(0, tempBitmap.getHeight())); outlinePoints.put(3, new PointF(tempBitmap.getWidth(), tempBitmap.getHeight())); return outlinePoints; }
From source file:project.pamela.slambench.fragments.AccuracyPlot.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Replace LinearLayout by the type of the root element of the layout you're trying to load LinearLayout llLayout = (LinearLayout) inflater.inflate(R.layout.fragment_plot, container, false); // Retrieve bench number Intent mIntent = super.getActivity().getIntent(); final int intValue = mIntent.getIntExtra(ResultActivity.SELECTED_TEST_TAG, 0); SLAMResult value = SLAMBenchApplication.getResults().get(intValue); if (!value.isFinished()) { Log.e(SLAMBenchApplication.LOG_TAG, this.getResources().getString(R.string.debug_proposed_value_not_valid)); return llLayout; }/*from w w w . j a va2s. co m*/ // initialize our XYPlot reference: XYPlot plot = (XYPlot) llLayout.findViewById(R.id.mySimpleXYPlot); plot.setTitle(value.test.name); plot.setDomainLabel(this.getResources().getString(R.string.legend_frame_number)); plot.setRangeLabel(this.getResources().getString(R.string.legend_ate)); plot.setBackgroundColor(Color.WHITE); plot.getGraphWidget().getBackgroundPaint().setColor(Color.WHITE); plot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE); plot.getGraphWidget().getDomainLabelPaint().setColor(Color.BLACK); plot.getGraphWidget().getRangeLabelPaint().setColor(Color.BLACK); plot.getGraphWidget().getDomainOriginLabelPaint().setColor(Color.BLACK); plot.getGraphWidget().getDomainOriginLinePaint().setColor(Color.BLACK); plot.getGraphWidget().getRangeOriginLinePaint().setColor(Color.BLACK); plot.getGraphWidget().setRangeValueFormat(new DecimalFormat("#####.##")); int border = 60; int legendsize = 110; plot.getGraphWidget().position(border, XLayoutStyle.ABSOLUTE_FROM_LEFT, border, YLayoutStyle.ABSOLUTE_FROM_BOTTOM, AnchorPosition.LEFT_BOTTOM); plot.getGraphWidget() .setSize(new SizeMetrics(border + legendsize, SizeLayoutType.FILL, border, SizeLayoutType.FILL)); // reduce the number of range labels plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 10); plot.setDomainValueFormat(new DecimalFormat("#")); plot.setRangeStep(XYStepMode.SUBDIVIDE, 10); plot.getLayoutManager().remove(plot.getTitleWidget()); // Set legend plot.getLegendWidget().setTableModel(new DynamicTableModel(4, 2)); Paint bgPaint = new Paint(); bgPaint.setColor(Color.BLACK); bgPaint.setStyle(Paint.Style.FILL); bgPaint.setAlpha(140); plot.getLegendWidget().setBackgroundPaint(bgPaint); plot.getLegendWidget() .setSize(new SizeMetrics(legendsize, SizeLayoutType.ABSOLUTE, 0, SizeLayoutType.FILL)); plot.getLegendWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_RIGHT, 0, YLayoutStyle.ABSOLUTE_FROM_TOP, AnchorPosition.RIGHT_TOP); plot.getDomainLabelWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_CENTER, 0, YLayoutStyle.RELATIVE_TO_BOTTOM, AnchorPosition.BOTTOM_MIDDLE); int fillcolor = Color.rgb(255, 213, 226); int strokecolor = Color.rgb(225, 99, 70); Double accuracyNumbers[] = value.getATEList(); XYSeries series = new SimpleXYSeries(Arrays.asList(accuracyNumbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, this.getResources().getString(R.string.legend_ate)); LineAndPointFormatter seriesFormat = new LineAndPointFormatter(strokecolor, strokecolor, null, null); Paint lineFill = new Paint(); lineFill.setAlpha(200); DisplayMetrics metrics = new DisplayMetrics(); super.getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics); lineFill.setShader( new LinearGradient(0, 0, 0, metrics.heightPixels, Color.WHITE, fillcolor, Shader.TileMode.MIRROR)); seriesFormat.setPointLabeler(new PointLabeler() { @Override public String getLabel(XYSeries series, int index) { return "o"; } }); seriesFormat.setFillPaint(lineFill); plot.addSeries(series, seriesFormat); // same as above LineAndPointFormatter lineFormat = new LineAndPointFormatter(Color.BLACK, null, null, null); //change the line width Paint paint = lineFormat.getLinePaint(); paint.setStrokeWidth(5); lineFormat.setLinePaint(paint); if (SLAMBenchApplication.getBenchmark() != null) { Number[] line = { 0, SLAMBenchApplication.getBenchmark().getMaxAccuracyError(), value.test.dataset.getFrameCount() - 1, SLAMBenchApplication.getBenchmark().getMaxAccuracyError() }; XYSeries expected = new SimpleXYSeries(Arrays.asList(line), SimpleXYSeries.ArrayFormat.XY_VALS_INTERLEAVED, getResources().getString(R.string.legend_error_limit)); plot.addSeries(expected, lineFormat); } plot.redraw(); plot.calculateMinMaxVals(); PointF maxXY = new PointF(plot.getCalculatedMaxX().floatValue(), plot.getCalculatedMaxY().floatValue()); plot.setDomainBoundaries(0, value.test.dataset.getFrameCount() - 1, BoundaryMode.FIXED); plot.setRangeBoundaries(0, maxXY.y * 1.2f, BoundaryMode.FIXED); plot.redraw(); return llLayout; }
From source file:project.pamela.slambench.fragments.PowerPlot.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Replace LinearLayout by the type of the root element of the layout you're trying to load LinearLayout llLayout = (LinearLayout) inflater.inflate(R.layout.fragment_plot, container, false); // Retrieve bench number Intent mIntent = super.getActivity().getIntent(); final int intValue = mIntent.getIntExtra(ResultActivity.SELECTED_TEST_TAG, 0); SLAMResult value = SLAMBenchApplication.getResults().get(intValue); if (!value.isFinished()) { Log.e(SLAMBenchApplication.LOG_TAG, this.getResources().getString(R.string.debug_proposed_value_not_valid)); return llLayout; }/*from ww w . j a v a2 s . c o m*/ // initialize our XYPlot reference: XYPlot plot = (XYPlot) llLayout.findViewById(R.id.mySimpleXYPlot); plot.setTitle(value.test.name); plot.setDomainLabel(this.getResources().getString(R.string.legend_frame_number)); plot.setRangeLabel(this.getResources().getString(R.string.legend_power)); plot.setBackgroundColor(Color.WHITE); plot.getBorderPaint().setColor(Color.WHITE); plot.getGraphWidget().getBackgroundPaint().setColor(Color.WHITE); plot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE); plot.getGraphWidget().getDomainLabelPaint().setColor(Color.BLACK); plot.getGraphWidget().getRangeLabelPaint().setColor(Color.BLACK); plot.getGraphWidget().getDomainOriginLabelPaint().setColor(Color.BLACK); plot.getGraphWidget().getDomainOriginLinePaint().setColor(Color.BLACK); plot.getGraphWidget().getRangeOriginLinePaint().setColor(Color.BLACK); plot.getGraphWidget().setRangeValueFormat(new DecimalFormat("#####.##")); int border = 60; int legendsize = 110; plot.getGraphWidget().position(border, XLayoutStyle.ABSOLUTE_FROM_LEFT, border, YLayoutStyle.ABSOLUTE_FROM_BOTTOM, AnchorPosition.LEFT_BOTTOM); plot.getGraphWidget() .setSize(new SizeMetrics(border + legendsize, SizeLayoutType.FILL, border, SizeLayoutType.FILL)); // reduce the number of range labels plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 10); plot.setDomainValueFormat(new DecimalFormat("#")); plot.setRangeStep(XYStepMode.SUBDIVIDE, 10); //Remove legend //plot.getLayoutManager().remove(plot.getLegendWidget()); //plot.getLayoutManager().remove(plot.getDomainLabelWidget()); //plot.getLayoutManager().remove(plot.getRangeLabelWidget()); plot.getLayoutManager().remove(plot.getTitleWidget()); // Set legend plot.getLegendWidget().setTableModel(new DynamicTableModel(4, 2)); Paint bgPaint = new Paint(); bgPaint.setColor(Color.BLACK); bgPaint.setStyle(Paint.Style.FILL); bgPaint.setAlpha(140); plot.getLegendWidget().setBackgroundPaint(bgPaint); plot.getLegendWidget() .setSize(new SizeMetrics(legendsize, SizeLayoutType.ABSOLUTE, 0, SizeLayoutType.FILL)); plot.getLegendWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_RIGHT, 0, YLayoutStyle.ABSOLUTE_FROM_TOP, AnchorPosition.RIGHT_TOP); plot.getDomainLabelWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_CENTER, 0, YLayoutStyle.RELATIVE_TO_BOTTOM, AnchorPosition.BOTTOM_MIDDLE); int strokecolor = Color.rgb(91, 255, 159); int fillcolor = Color.rgb(91, 255, 184); Double powerNumbers[] = value.getPowerList(); for (int i = 0; i < value.test.dataset.getFrameCount(); i++) { powerNumbers[i] = powerNumbers[i] / -1000; } XYSeries series = new SimpleXYSeries(Arrays.asList(powerNumbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, this.getResources().getString(R.string.legend_power)); LineAndPointFormatter seriesFormat = new LineAndPointFormatter(strokecolor, strokecolor, null, null); Paint lineFill = new Paint(); lineFill.setAlpha(200); DisplayMetrics metrics = new DisplayMetrics(); super.getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics); lineFill.setShader( new LinearGradient(0, 0, 0, metrics.heightPixels, Color.WHITE, fillcolor, Shader.TileMode.MIRROR)); seriesFormat.setPointLabeler(new PointLabeler() { @Override public String getLabel(XYSeries series, int index) { return "o"; } }); seriesFormat.setFillPaint(lineFill); plot.addSeries(series, seriesFormat); // same as above LineAndPointFormatter lineFormat = new LineAndPointFormatter(Color.BLACK, null, null, null); //change the line width Paint paint = lineFormat.getLinePaint(); paint.setStrokeWidth(5); lineFormat.setLinePaint(paint); Number[] line = { 0, 3, value.test.dataset.getFrameCount() - 1, 3 }; XYSeries expected = new SimpleXYSeries(Arrays.asList(line), SimpleXYSeries.ArrayFormat.XY_VALS_INTERLEAVED, getResources().getString(R.string.legend_power_limit)); plot.addSeries(expected, lineFormat); plot.redraw(); plot.calculateMinMaxVals(); PointF minXY = new PointF(plot.getCalculatedMinX().floatValue(), plot.getCalculatedMinY().floatValue()); PointF maxXY = new PointF(plot.getCalculatedMaxX().floatValue(), plot.getCalculatedMaxY().floatValue()); plot.setDomainBoundaries(0, value.test.dataset.getFrameCount() - 1, BoundaryMode.FIXED); plot.setRangeBoundaries(Math.min(0, minXY.y), maxXY.y * 1.2f, BoundaryMode.FIXED); plot.redraw(); return llLayout; }
From source file:com.facebook.react.views.slider.ReactSlider.java
private NinePatchDrawable createNineDrawable(Bitmap src) { if (src.getNinePatchChunk() != null) { return NinePatchDrawableFactory.convertBitmap(getResources(), src, null); }/* ww w. j a va 2 s .co m*/ Bitmap desc = Bitmap.createBitmap(src.getWidth() + 4, src.getHeight() + 4, Bitmap.Config.ARGB_4444); PointF center = new PointF(desc.getWidth() / 2, desc.getHeight() / 2); Canvas canvas = new Canvas(desc); canvas.drawBitmap(src, 2, 2, null); Paint p = new Paint(); p.setColor(Color.BLACK); canvas.drawLine(center.x, 0, center.x + 1, 0, p); canvas.drawLine(0, center.y, 0, center.y + 1, p); NinePatchDrawable drawable = NinePatchDrawableFactory.convertBitmap(getResources(), desc, null); desc.recycle(); return drawable; }
From source file:color.kidpaint.com.kidpaintcolor.tools.implementation.TextTool.java
protected void changeTextColor() { float width = mBoxWidth; float height = mBoxHeight; PointF position = new PointF(mToolPosition.x, mToolPosition.y); mTextPaint.setColor(mCanvasPaint.getColor()); createAndSetBitmap();//from www . j a v a 2 s . c o m mToolPosition = position; mBoxWidth = width; mBoxHeight = height; }
From source file:project.pamela.slambench.fragments.DurationPlot.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Replace LinearLayout by the type of the root element of the layout you're trying to load LinearLayout llLayout = (LinearLayout) inflater.inflate(R.layout.fragment_plot, container, false); // Retrieve bench number Intent mIntent = super.getActivity().getIntent(); final int intValue = mIntent.getIntExtra(ResultActivity.SELECTED_TEST_TAG, 0); SLAMResult value = SLAMBenchApplication.getResults().get(intValue); if (!value.isFinished()) { Log.e(SLAMBenchApplication.LOG_TAG, this.getResources().getString(R.string.debug_proposed_value_not_valid)); return llLayout; }/*w w w. jav a2 s .co m*/ // initialize our XYPlot reference: XYPlot plot = (XYPlot) llLayout.findViewById(R.id.mySimpleXYPlot); plot.setTitle(value.test.name); plot.setDomainLabel(this.getResources().getString(R.string.legend_frame_number)); plot.setRangeLabel(this.getResources().getString(R.string.legend_duration)); plot.setBackgroundColor(Color.WHITE); plot.getGraphWidget().getBackgroundPaint().setColor(Color.WHITE); plot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE); plot.getGraphWidget().getDomainLabelPaint().setColor(Color.BLACK); plot.getGraphWidget().getRangeLabelPaint().setColor(Color.BLACK); plot.getGraphWidget().getDomainOriginLabelPaint().setColor(Color.BLACK); plot.getGraphWidget().getDomainOriginLinePaint().setColor(Color.BLACK); plot.getGraphWidget().getRangeOriginLinePaint().setColor(Color.BLACK); plot.getGraphWidget().setRangeValueFormat(new DecimalFormat("#####.##")); int border = 60; int legendsize = 110; plot.getGraphWidget().position(border, XLayoutStyle.ABSOLUTE_FROM_LEFT, border, YLayoutStyle.ABSOLUTE_FROM_BOTTOM, AnchorPosition.LEFT_BOTTOM); plot.getGraphWidget() .setSize(new SizeMetrics(border + legendsize, SizeLayoutType.FILL, border, SizeLayoutType.FILL)); // reduce the number of range labels plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 10); plot.setDomainValueFormat(new DecimalFormat("#")); plot.setRangeStep(XYStepMode.SUBDIVIDE, 10); //Remove legend //plot.getLayoutManager().remove(plot.getLegendWidget()); //plot.getLayoutManager().remove(plot.getDomainLabelWidget()); //plot.getLayoutManager().remove(plot.getRangeLabelWidget()); plot.getLayoutManager().remove(plot.getTitleWidget()); // Set legend plot.getLegendWidget().setTableModel(new DynamicTableModel(4, 2)); Paint bgPaint = new Paint(); bgPaint.setColor(Color.BLACK); bgPaint.setStyle(Paint.Style.FILL); bgPaint.setAlpha(140); plot.getLegendWidget().setBackgroundPaint(bgPaint); plot.getLegendWidget() .setSize(new SizeMetrics(legendsize, SizeLayoutType.ABSOLUTE, 0, SizeLayoutType.FILL)); plot.getLegendWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_RIGHT, 0, YLayoutStyle.ABSOLUTE_FROM_TOP, AnchorPosition.RIGHT_TOP); plot.getDomainLabelWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_CENTER, 0, YLayoutStyle.RELATIVE_TO_BOTTOM, AnchorPosition.BOTTOM_MIDDLE); // Prepare Data (fill stack and add lines) KFusion.FieldIndex[] stackIndex = new KFusion.FieldIndex[] { (KFusion.FieldIndex.AQUISITION_DURATION), (KFusion.FieldIndex.PREPROCESSING_DURATION), (KFusion.FieldIndex.TRACKING_DURATION), (KFusion.FieldIndex.INTEGRATION_DURATION), (KFusion.FieldIndex.RAYCASTING_DURATION), (KFusion.FieldIndex.RENDERING_DURATION), (KFusion.FieldIndex.TOTAL_DURATION) }; Double[][] stackNumbers = new Double[][] { value.getField(stackIndex[0]), value.getField(stackIndex[1]), value.getField(stackIndex[2]), value.getField(stackIndex[3]), value.getField(stackIndex[4]), value.getField(stackIndex[5]) }; Double[][] stack = new Double[stackNumbers.length + 1][stackNumbers[0].length]; int[] stackColor = new int[] { Color.rgb(240, 0, 0), Color.rgb(255, 155, 0), Color.rgb(255, 255, 0), Color.rgb(155, 255, 98), Color.rgb(0, 212, 255), Color.rgb(0, 155, 255), Color.rgb(0, 0, 127) }; stack[0] = stackNumbers[0]; for (int i = 0; i < stackNumbers[0].length; ++i) { for (int j = 1; j < stackNumbers.length; ++j) { stack[j][i] = stack[j - 1][i] + stackNumbers[j][i]; } } stack[stackNumbers.length] = value.getField(KFusion.FieldIndex.TOTAL_DURATION); for (int i = stack.length - 1; i >= 0; --i) { // Turn the above arrays into XYSeries': XYSeries series = new SimpleXYSeries(Arrays.asList(stack[i]), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, stackIndex[i].getName()); LineAndPointFormatter seriesFormat = new LineAndPointFormatter(Color.rgb(73, 73, 73), null, stackColor[i], null); Paint paint = seriesFormat.getLinePaint(); paint.setStrokeWidth(1.0f); seriesFormat.setLinePaint(paint); // 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, stackColor[i], Shader.TileMode.MIRROR)); //seriesFormat.setFillPaint(lineFill); plot.addSeries(series, seriesFormat); } // same as above LineAndPointFormatter lineFormat = new LineAndPointFormatter(Color.BLACK, null, null, null); //change the line width Paint paint = lineFormat.getLinePaint(); paint.setStrokeWidth(5); lineFormat.setLinePaint(paint); Number[] line = { 0, 0.033, stack[0].length - 1, 0.033 }; XYSeries expected = new SimpleXYSeries(Arrays.asList(line), SimpleXYSeries.ArrayFormat.XY_VALS_INTERLEAVED, getResources().getString(R.string.legend_realtime_limit)); plot.addSeries(expected, lineFormat); plot.redraw(); plot.calculateMinMaxVals(); PointF maxXY = new PointF(plot.getCalculatedMaxX().floatValue(), plot.getCalculatedMaxY().floatValue()); plot.setDomainBoundaries(0, value.test.dataset.getFrameCount() - 1, BoundaryMode.FIXED); plot.setRangeBoundaries(0, maxXY.y * 1.2f, BoundaryMode.FIXED); plot.redraw(); return llLayout; }
From source file:com.color.kid.kidpaint.tools.implementation.TextTool.java
@Override protected void onClickInBox() { PointF toolPosition = new PointF(mToolPosition.x, mToolPosition.y); Command command = new TextToolCommand(mMultilineText, mTextPaint, mBoxOffset, mBoxWidth, mBoxHeight, toolPosition, mBoxRotation); ((TextToolCommand) command).addObserver(this); IndeterminateProgressDialog.getInstance().show(); PaintroidApplication.commandManager.commitCommand(command); }
From source file:color.kidpaint.com.kidpaintcolor.tools.implementation.TextTool.java
@Override protected void onClickInBox() { PointF toolPosition = new PointF(mToolPosition.x, mToolPosition.y); Command command = new TextToolCommand(mMultilineText, mTextPaint, mBoxOffset, mBoxWidth, mBoxHeight, toolPosition, mBoxRotation); ((TextToolCommand) command).addObserver(this); IndeterminateProgressDialog.getInstance().show(); AnimalsColoringApplication.commandManager.commitCommand(command); }