Example usage for android.graphics Color rgb

List of usage examples for android.graphics Color rgb

Introduction

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

Prototype

@ColorInt
public static int rgb(float red, float green, float blue) 

Source Link

Document

Return a color-int from red, green, blue float components in the range \([0..1]\).

Usage

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 www  .j a v  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_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:com.ecml.MidiOptions.java

/** Initialize the default settings/options for the given MidiFile
 * /* w ww . j a  va 2  s .  c  o m*/
 * @param midifile
 */
public MidiOptions(MidiFile midifile) {
    showPiano = true;
    showNoteColors = false;
    int num_tracks = midifile.getTracks().size();
    tracks = new boolean[num_tracks];
    mute = new boolean[num_tracks];
    for (int i = 0; i < tracks.length; i++) {
        tracks[i] = true;
        mute[i] = false;
        if (midifile.getTracks().get(i).getInstrumentName().equals("Percussion")) {
            tracks[i] = false;
            mute[i] = true;
        }
    }
    useDefaultInstruments = true;
    instruments = new int[num_tracks];
    for (int i = 0; i < instruments.length; i++) {
        instruments[i] = midifile.getTracks().get(i).getInstrument();
    }
    scrollVert = true;
    largeNoteSize = true;
    if (tracks.length != 2) {
        twoStaffs = true;
    } else {
        twoStaffs = false;
    }
    showNoteLetters = NoteNameNone;
    showMeasures = true;
    showLyrics = true;
    delay = 1000;
    shifttime = 0;
    transpose = 0;
    time = null;
    defaultTime = midifile.getTime();
    key = -1;
    combineInterval = 40;
    shade1Color = Color.rgb(210, 205, 220);
    shade2Color = Color.rgb(150, 200, 220);

    tempo = midifile.getTime().getTempo();
    pauseTime = 0;
    lastMeasure = midifile.EndTime() / midifile.getTime().getMeasure();
    playMeasuresInLoop = false;
    playMeasuresInLoopStart = 0;
    playMeasuresInLoopEnd = lastMeasure;
}

From source file:com.ab.view.sliding.AbBottomTabView_fix.java

/**
 * Instantiates a new ab bottom tab view.
 *
 * @param context the context/*from  w  ww . j  av a 2 s  .co  m*/
 * @param attrs the attrs
 */
public AbBottomTabView_fix(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;

    this.setOrientation(LinearLayout.VERTICAL);
    this.setBackgroundColor(Color.rgb(255, 255, 255));

    mTabLayout = new LinearLayout(context);
    mTabLayout.setOrientation(LinearLayout.HORIZONTAL);
    mTabLayout.setGravity(Gravity.CENTER);

    //View?
    mViewPager = new AbViewPager(context);
    //ViewPager,setId()id
    mViewPager.setId(1985);
    pagerItemList = new ArrayList<Fragment>();
    this.addView(mViewPager, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0, 1));

    //?
    mTabImg = new ImageView(context);
    mTabImg.setBackgroundColor(tabSlidingColor);
    this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight));

    this.addView(mTabLayout,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    //Tab?
    tabItemList = new ArrayList<AbTabItemView>();
    tabItemTextList = new ArrayList<String>();
    tabItemDrawableList = new ArrayList<Drawable>();
    //?FragmentActivity
    if (!(this.context instanceof FragmentActivity)) {
        AbLogUtil.e(AbBottomTabView_fix.class,
                "AbSlidingTabView?context,FragmentActivity");
    }

    DisplayMetrics mDisplayMetrics = AbAppUtil.getDisplayMetrics(context);
    mWidth = mDisplayMetrics.widthPixels;

    FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager();
    mFragmentPagerAdapter = new AbFragmentPagerStateAdapter(mFragmentManager, pagerItemList);
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    mViewPager.setOffscreenPageLimit(3);

}

From source file:org.deviceconnect.android.deviceplugin.hitoe.fragment.HitoeProfileStressEstimationFragment.java

/**
 * Update view.//  w w w  .  j a  v  a2  s  .c om
 * @param timestamp timestamp
 * @param lfhf stress estimation
 */
public void updateView(final long timestamp, final double lfhf) {

    final int scoreRGB;
    final int scoreR;
    final int scoreG;
    final int scoreB;

    if (timestamp == -1) {

        return;
    }
    scoreRGB = (int) (150 * (lfhf / 5));
    if (105 + scoreRGB < 255) {
        scoreR = 105 + scoreRGB;
    } else {
        scoreR = 255;
    }
    if (255 - scoreRGB > 0) {
        scoreG = 255 - scoreRGB;
        scoreB = 255 - scoreRGB;
    } else {
        scoreG = 0;
        scoreB = 0;
    }

    mLFHF.setText("LF/HF:" + String.valueOf(lfhf));
    mLFHFGradientDrawable.setColors(new int[] { 0xFFCDFFFF, Color.rgb(scoreR, scoreG, scoreB) });
}

From source file:com.tony.selene.sliding.AbBottomTabView.java

/**
 * Instantiates a new ab bottom tab view.
 *
 * @param context//from   w ww.  ja  v  a 2 s.c  om
 *            the context
 * @param attrs
 *            the attrs
 */
public AbBottomTabView(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;

    this.setOrientation(LinearLayout.VERTICAL);
    this.setBackgroundColor(Color.rgb(255, 255, 255));

    mTabLayout = new LinearLayout(context);
    mTabLayout.setOrientation(LinearLayout.HORIZONTAL);
    mTabLayout.setGravity(Gravity.CENTER);

    // View?
    mViewPager = new AbViewPager(context);
    // ViewPager,setId()id
    mViewPager.setId(1985);
    pagerItemList = new ArrayList<Fragment>();
    this.addView(mViewPager, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0, 1));

    // ?
    mTabImg = new ImageView(context);
    mTabImg.setBackgroundColor(tabSlidingColor);
    this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight));

    this.addView(mTabLayout,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    // Tab?
    tabItemList = new ArrayList<AbTabItemView>();
    tabItemTextList = new ArrayList<String>();
    tabItemDrawableList = new ArrayList<Drawable>();
    // ?FragmentActivity
    if (!(this.context instanceof FragmentActivity)) {
        AbLogUtil.e(AbBottomTabView.class,
                "AbSlidingTabView?context,FragmentActivity");
    }

    DisplayMetrics mDisplayMetrics = AbAppUtil.getDisplayMetrics(context);
    mWidth = mDisplayMetrics.widthPixels;

    FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager();
    mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList);
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    mViewPager.setOffscreenPageLimit(3);

}

From source file:net.networksaremadeofstring.rhybudd.DiagnosticActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_diagnostics);
    try {//from  www. j  a  v  a2  s. c  o  m
        getActionBar().setTitle("Diagnostics App");
        getActionBar().setSubtitle("Helps to pin point any problems getting events");
        getActionBar().setDisplayHomeAsUpEnabled(true);
        getActionBar().setHomeButtonEnabled(true);
    } catch (Exception e) {

    }

    DiagnosticOutput = (TextView) findViewById(R.id.DiagOutput);
    progressBar = (ProgressBar) findViewById(R.id.progressBar);

    ((Button) findViewById(R.id.StartDiagButton)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            findViewById(R.id.progressBar2).setVisibility(View.VISIBLE);
            DiagnosticOutput.setText("");
            DoDiagnostics();
            view.setEnabled(false);
        }
    });

    progressHandler = new Handler() {
        public void handleMessage(Message msg) {
            try {
                DiagnosticOutput.setText(DiagnosticOutput.getText().toString()
                        + msg.getData().getString(DIAGNOSTIC_OUTPUT) + "\n");
            } catch (Exception e) {
                DiagnosticOutput.setText(DiagnosticOutput.getText().toString()
                        + "A diagnostic message was received but there was an issue displaying it\n");
            }

            if (msg.what == DIAGNOSTIC_PRE) {
                try {
                    if (progressBar.getSecondaryProgress() < 20)
                        progressBar.setSecondaryProgress((progressBar.getSecondaryProgress() + 1));
                } catch (Exception e) {

                }
            } else if (msg.what == DIAGNOSTIC_SUCCESS) {
                try {
                    if (progressBar.getProgress() < 20)
                        progressBar.setProgress((progressBar.getProgress() + 1));
                } catch (Exception e) {

                }
            } else if (msg.what == DIAGNOSTIC_FAILURE) {
                try {
                    DiagnosticOutput.setTextColor(getResources().getColor(R.color.WarningRed));
                    findViewById(R.id.progressBar2).setVisibility(View.INVISIBLE);
                    findViewById(R.id.StartDiagButton).setEnabled(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else if (msg.what == DIAGNOSTIC_COMPLETE) {
                try {
                    DiagnosticOutput.setTextColor(Color.rgb(50, 102, 50));
                    progressBar.setProgress(20);
                    findViewById(R.id.progressBar2).setVisibility(View.INVISIBLE);
                } catch (Exception e) {
                    e.printStackTrace();
                }

                try {
                    Toast.makeText(DiagnosticActivity.this, "Diagnostics Complete!", Toast.LENGTH_SHORT).show();
                    findViewById(R.id.StartDiagButton).setEnabled(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                //Not much else
            }

            try {
                progressBar.invalidate();
            } catch (Exception e) {

            }
        }
    };
}

From source file:com.devbrackets.android.exomediademo.test.CircleProgressBar.java

private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressBar, defStyleAttr, 0);
    //        <attr name="mlpb_inner_radius" format="dimension"/>
    //        <attr name="mlpb_background_color" format="color"/>
    //        <attr name="mlpb_progress_color" format="color"/>
    //        <attr name="mlpb_progress_stoke_width" format="dimension"/>
    //        <attr name="mlpb_arrow_width" format="dimension"/>
    //        <attr name="mlpb_arrow_height" format="dimension"/>
    ///*w  ww  . j a va 2 s . com*/
    //        <attr name="mlpb_progress" format="integer"/>
    //        <attr name="mlpb_max" format="integer"/>
    //
    //
    //        <attr name="mlpb_progress_text_size" format="dimension"/>
    //        <attr name="mlpb_progress_text_color" format="color"/>
    //
    //        <attr name="mlpb_progress_text_offset" format="dimension"/>
    //
    //        <attr name="mlpb_progress_text_visibility" format="enum">
    //        <enum name="visible" value="0"/>
    //        <enum name="invisible" value="1"/>
    //        </attr>
    final float density = getContext().getResources().getDisplayMetrics().density;

    mBackGroundColor = a.getColor(R.styleable.CircleProgressBar_mlpb_background_color, DEFAULT_CIRCLE_BG_LIGHT);

    mProgressColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_color, DEFAULT_CIRCLE_BG_LIGHT);
    mColors = new int[] { Color.rgb(192, 255, 140), Color.rgb(255, 247, 140), Color.rgb(255, 208, 140),
            Color.rgb(140, 234, 255), Color.WHITE };

    mInnerRadius = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_inner_radius, -1);

    mProgressStokeWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_stoke_width,
            (int) (STROKE_WIDTH_LARGE * density));
    mArrowWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_width, -1);
    mArrowHeight = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_height, -1);
    mTextSize = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_text_size,
            (int) (DEFAULT_TEXT_SIZE * density));
    mTextColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_text_color, Color.BLACK);

    mShowArrow = a.getBoolean(R.styleable.CircleProgressBar_mlpb_show_arrow, false);
    mCircleBackgroundEnabled = a.getBoolean(R.styleable.CircleProgressBar_mlpb_enable_circle_background, false);

    mProgress = a.getInt(R.styleable.CircleProgressBar_mlpb_progress, 0);
    mMax = a.getInt(R.styleable.CircleProgressBar_mlpb_max, 100);
    int textVisible = a.getInt(R.styleable.CircleProgressBar_mlpb_progress_text_visibility, 1);
    if (textVisible != 1) {
        mIfDrawText = true;
    }

    mTextPaint = new Paint();
    mTextPaint.setStyle(Paint.Style.FILL);
    mTextPaint.setColor(mTextColor);
    mTextPaint.setTextSize(mTextSize);
    mTextPaint.setAntiAlias(true);
    a.recycle();
    mProgressDrawable = new MaterialProgressDrawable(getContext(), this);
    super.setImageDrawable(mProgressDrawable);
}

From source file:org.proto.led.network.WiFiControllerService.java

private ArrayList<LightDto> parseLights(byte[] b, int numberOfLights) {
    int startOfLight = 48;
    ArrayList<LightDto> lights = new ArrayList<>();
    for (int i = 0; i < numberOfLights; i++) {
        String lightName = new String(b, startOfLight, 32).trim();
        byte lightType = b[startOfLight + 32];
        LightDto parsedLight = null;/*from w  w w  . j a v  a  2 s.c  om*/
        switch (lightType) {
        case 1: // ON/OFF
            LightDto lightDto = new LightDto();
            lightDto.setChannel(b[startOfLight + 32 + 1]);
            lightDto.setOn(b[startOfLight + 32 + 2] == 0);
            parsedLight = lightDto;
            startOfLight = startOfLight + 32 + 2 + 1;
            break;
        case 2: // RGB
            RgbLightDto rgbLightDto = new RgbLightDto();
            int rgb = Color.rgb(b[startOfLight + 32 + 2] * 4, b[startOfLight + 32 + 4] * 4,
                    b[startOfLight + 32 + 6] * 4);
            rgbLightDto.setColor(rgb);
            rgbLightDto.setRedChannel(b[startOfLight + 32 + 1]);
            rgbLightDto.setGreenChannel(b[startOfLight + 32 + 3]);
            rgbLightDto.setBlueChannel(b[startOfLight + 32 + 5]);
            rgbLightDto.setOn(rgbLightDto.getRedValue() > 0 || rgbLightDto.getGreenValue() > 0
                    || rgbLightDto.getBlueValue() > 0);
            parsedLight = rgbLightDto;
            startOfLight = startOfLight + 32 + 6 + 1;
            break;
        case 3: // DIMMABLE
            DimmableLightDto dimmableLightDto = new DimmableLightDto();
            dimmableLightDto.setChannel(b[startOfLight + 32 + 1]);
            dimmableLightDto.setOn(b[startOfLight + 32 + 1 + 1] > 0);
            dimmableLightDto.setIntensity(b[startOfLight + 32 + 1 + 1]);
            parsedLight = dimmableLightDto;
            startOfLight = startOfLight + 32 + 2 + 1;
            break;
        }
        parsedLight.setName(lightName);
        lights.add(parsedLight);
    }
    return lights;
}

From source file:project.pamela.slambench.fragments.TemperaturePlot.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  ww  .  j a va 2 s.  com*/

    // 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.legend_degrees));
    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);

    int strokecolor = Color.rgb(67, 137, 192);
    int fillcolor = Color.rgb(213, 229, 255);

    Double temperatureNumbers[] = value.gettemperatureList();
    XYSeries series = new SimpleXYSeries(Arrays.asList(temperatureNumbers),
            SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, this.getResources().getString(R.string.legend_degrees));
    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);

    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.mchp.android.PIC32_BTSK.ColorFragment.java

@Override
public void onColorChanged(int color) {
    mColor = color;//from w  w  w .j av a2 s  .  co  m

    r = Color.red(mColor);
    g = Color.green(mColor);
    b = Color.blue(mColor);

    r = (r <= seekBarMax) ? r : seekBarMax;
    g = (g <= seekBarMax) ? g : seekBarMax;
    b = (b <= seekBarMax) ? b : seekBarMax;

    mColor = Color.rgb(r, g, b);
    setProgressText();
    setSeekBarProgress();
    mNewColor.setColor(mColor);

    sendLedCmd(r, g, b);
}