Android Open Source - android-usable-location-privacy Graph View Style






From Project

Back to project page android-usable-location-privacy.

License

The source code is released under:

Apache License

If you think the Android project android-usable-location-privacy listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * This file is part of GraphView.//w w  w.j a v a 2s. c o m
 *
 * GraphView is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * GraphView is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GraphView.  If not, see <http://www.gnu.org/licenses/lgpl.html>.
 *
 * Copyright Jonas Gehring
 */

package com.jjoe64.graphview;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.Paint.Align;
import android.view.ContextThemeWrapper;

/**
 * Styles for the GraphView
 * Important: Use {@link com.jjoe64.graphview.GraphViewSeries.GraphViewSeriesStyle} for series-specify styling
 *
 */
public class GraphViewStyle {
  private int verticalLabelsColor;
  private int horizontalLabelsColor;
  private int gridColor;
  private GridStyle gridStyle = GridStyle.BOTH;
  private float textSize;
  private int verticalLabelsWidth;
  private int numVerticalLabels;
  private int numHorizontalLabels;
  private int legendWidth;
  private int legendBorder;
  private int legendSpacing;
  private int legendMarginBottom;
  private Align verticalLabelsAlign;

  public GraphViewStyle() {
    setDefaults();
  }

  public GraphViewStyle(int vLabelsColor, int hLabelsColor, int gridColor) {
    setDefaults();
    this.verticalLabelsColor = vLabelsColor;
    this.horizontalLabelsColor = hLabelsColor;
    this.gridColor = gridColor;
  }

  public int getGridColor() {
    return gridColor;
  }
  
  public GridStyle getGridStyle() {
    return gridStyle;
  }

  public int getHorizontalLabelsColor() {
    return horizontalLabelsColor;
  }

  public int getLegendBorder() {
    return legendBorder;
  }

  public int getLegendSpacing() {
    return legendSpacing;
  }

  public int getLegendWidth() {
    return legendWidth;
  }

  public int getLegendMarginBottom() {
    return legendMarginBottom;
  }

  public int getNumHorizontalLabels() {
    return numHorizontalLabels;
  }

  public int getNumVerticalLabels() {
    return numVerticalLabels;
  }

  public float getTextSize() {
    return textSize;
  }

  public Align getVerticalLabelsAlign() {
    return verticalLabelsAlign;
  }

  public int getVerticalLabelsColor() {
    return verticalLabelsColor;
  }

  public int getVerticalLabelsWidth() {
    return verticalLabelsWidth;
  }

  private void setDefaults() {
    verticalLabelsColor = Color.WHITE;
    horizontalLabelsColor = Color.WHITE;
    gridColor = Color.DKGRAY;
    textSize = 30f;
    legendWidth = 120;
    legendBorder = 10;
    legendSpacing = 10;
    legendMarginBottom = 0;
    verticalLabelsAlign = Align.LEFT;
  }

  public void setGridStyle(GridStyle style) {
    gridStyle = style;
  }
  
  public void setGridColor(int c) {
    gridColor = c;
  }

  public void setHorizontalLabelsColor(int c) {
    horizontalLabelsColor = c;
  }

  public void setLegendBorder(int legendBorder) {
    this.legendBorder = legendBorder;
  }

  public void setLegendSpacing(int legendSpacing) {
    this.legendSpacing = legendSpacing;
  }

  public void setLegendWidth(int legendWidth) {
    this.legendWidth = legendWidth;
  }

  public void setLegendMarginBottom(int legendMarginBottom) {
    this.legendMarginBottom = legendMarginBottom;
  }

  /**
   * @param numHorizontalLabels 0 = auto
   */
  public void setNumHorizontalLabels(int numHorizontalLabels) {
    this.numHorizontalLabels = numHorizontalLabels;
  }

  /**
   * @param numVerticalLabels 0 = auto
   */
  public void setNumVerticalLabels(int numVerticalLabels) {
    this.numVerticalLabels = numVerticalLabels;
  }

  public void setTextSize(float textSize) {
    this.textSize = textSize;
  }

  public void setVerticalLabelsAlign(Align verticalLabelsAlign) {
    this.verticalLabelsAlign = verticalLabelsAlign;
  }

  public void setVerticalLabelsColor(int c) {
    verticalLabelsColor = c;
  }

  /**
   * @param verticalLabelsWidth 0 = auto
   */
  public void setVerticalLabelsWidth(int verticalLabelsWidth) {
    this.verticalLabelsWidth = verticalLabelsWidth;
  }

  /**
   * tries to get the theme's font color and use it for labels
   * @param context must be instance of ContextThemeWrapper
   */
  public void useTextColorFromTheme(Context context) {
    if (context instanceof ContextThemeWrapper) {
      TypedArray array = ((ContextThemeWrapper) context).getTheme().obtainStyledAttributes(new int[] {android.R.attr.textColorPrimary});
      int color = array.getColor(0, getVerticalLabelsColor());
      array.recycle();

      setVerticalLabelsColor(color);
      setHorizontalLabelsColor(color);
    }
  }

    /**
     * Definition which lines will be drawn in the background
     */
  public enum GridStyle {
    BOTH, VERTICAL, HORIZONTAL
  }
}




Java Source Code List

android.locationprivacy.algorithm.GeoReverseGeo.java
android.locationprivacy.algorithm.RadiusDistance.java
android.locationprivacy.control.CryptoDatabase.java
android.locationprivacy.control.LocationPrivacyManager.java
android.locationprivacy.model.AbstractLocationPrivacyAlgorithm.java
android.locationprivacy.model.Coordinate.java
android.locationprivacy.model.LocationPrivacyAlgorithmValues.java
android.locationprivacy.model.LocationPrivacyApplication.java
com.android.server.LocationManagerService.java
com.android.settings.Settings.java
com.android.settings.locationprivacy.LPPresetConfigAdapter.java
com.android.settings.locationprivacy.LocationPrivacyAdvancedSettings.java
com.android.settings.locationprivacy.LocationPrivacyAppPreference.java
com.android.settings.locationprivacy.LocationPrivacyDialog.java
com.android.settings.locationprivacy.LocationPrivacyMap.java
com.android.settings.locationprivacy.LocationPrivacyOfflineObfuscation.java
com.android.settings.locationprivacy.LocationPrivacyOnlineInfoActivity.java
com.android.settings.locationprivacy.LocationPrivacySettings.java
com.android.settings.locationprivacy.LocationPrivacyStatisticOverview.java
com.android.settings.locationprivacy.LocationPrivacyStatistic.java
com.android.settings.locationprivacy.SendDataService.java
com.android.settings.locationprivacy.StatisticDiagram24HPreference.java
com.android.settings.locationprivacy.StatisticDiagramPreference.java
com.android.settings.locationprivacy.UserRecoverableAuth.java
com.cyanogenmod.trebuchet.Launcher.java
com.jjoe64.graphview.BarGraphView.java
com.jjoe64.graphview.CustomLabelFormatter.java
com.jjoe64.graphview.GraphViewDataInterface.java
com.jjoe64.graphview.GraphViewSeries.java
com.jjoe64.graphview.GraphViewStyle.java
com.jjoe64.graphview.GraphView.java
com.jjoe64.graphview.LineGraphView.java
com.jjoe64.graphview.StatisticGraphView.java
com.jjoe64.graphview.ValueDependentColor.java
com.jjoe64.graphview.compatible.RealScaleGestureDetector.java
com.jjoe64.graphview.compatible.ScaleGestureDetector.java