@Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;
    if (v == null) {
      LayoutInflater vi =
          (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      v = vi.inflate(R.layout.storage_row, null);
    }
    Map<String, Object> map = items.get(position);
    if (map != null) {
      TextView storagePath = (TextView) v.findViewById(R.id.storage_path);

      if (storagePath != null) {
        String path = (String) map.get(STORAGE_PATH);
        String description = (String) map.get(STORAGE_DESCRIPTION);
        storagePath.setText(description + " (" + path + ")");
      }
      Long capacity = (Long) map.get(STORAGE_CAPACITY);
      if (capacity == null) {
        v.findViewById(R.id.used_space_row).setVisibility(View.GONE);
        v.findViewById(R.id.free_space_row).setVisibility(View.GONE);
        v.findViewById(R.id.used_space_bar).setVisibility(View.GONE);

        TextView capacityView = (TextView) v.findViewById(R.id.capacity_space);

        capacityView.setText(
            getContext().getResources().getString(R.string.unable_to_determine_capacity));

      } else {
        v.findViewById(R.id.used_space_row).setVisibility(View.VISIBLE);
        v.findViewById(R.id.free_space_row).setVisibility(View.VISIBLE);
        v.findViewById(R.id.used_space_bar).setVisibility(View.VISIBLE);

        long freeSpace = (Long) map.get(STORAGE_FREE_SPACE);
        long usedSpace = (Long) map.get(STORAGE_USED_SPACE);
        int colorIndex = (int) (usedSpace * colorUtils.getColorsCount() / capacity);

        TextView capacityView = (TextView) v.findViewById(R.id.capacity_space);
        TextView usedView = (TextView) v.findViewById(R.id.used_space);
        TextView freeView = (TextView) v.findViewById(R.id.free_space);

        ProgressBar progressBar = (ProgressBar) v.findViewById(R.id.used_space_bar);
        progressBar.setMax(colorUtils.getColorsCount());
        progressBar.setProgressDrawable(colorUtils.getClipDrawable(colorIndex));
        progressBar.setBackgroundDrawable(progressHorizontal);
        progressBar.setProgress(colorIndex);

        if (capacityView != null) {
          capacityView.setText(Utils.stringFromFileSize(capacity));
        }
        if (usedView != null) {
          usedView.setText(Utils.stringFromFileSize(usedSpace));
        }
        if (freeView != null) {
          freeView.setText(Utils.stringFromFileSize(freeSpace));
        }
      }
    }
    return v;
  }
  public static RippleDrawable createRipple(
      Palette palette,
      @FloatRange(from = 0f, to = 1f) float darkAlpha,
      @FloatRange(from = 0f, to = 1f) float lightAlpha,
      @ColorInt int fallbackColor,
      boolean bounded) {
    int rippleColor = fallbackColor;
    // try the named swatches in preference order
    if (palette != null) {
      if (palette.getVibrantSwatch() != null) {
        rippleColor = ColorUtils.modifyAlpha(palette.getVibrantSwatch().getRgb(), darkAlpha);
      } else if (palette.getLightVibrantSwatch() != null) {
        rippleColor = ColorUtils.modifyAlpha(palette.getLightVibrantSwatch().getRgb(), lightAlpha);
      } else if (palette.getDarkVibrantSwatch() != null) {
        rippleColor = ColorUtils.modifyAlpha(palette.getDarkVibrantSwatch().getRgb(), darkAlpha);
      } else if (palette.getMutedSwatch() != null) {
        rippleColor = ColorUtils.modifyAlpha(palette.getMutedSwatch().getRgb(), darkAlpha);
      } else if (palette.getLightMutedSwatch() != null) {
        rippleColor = ColorUtils.modifyAlpha(palette.getLightMutedSwatch().getRgb(), lightAlpha);
      } else if (palette.getDarkMutedSwatch() != null) {
        rippleColor = ColorUtils.modifyAlpha(palette.getDarkMutedSwatch().getRgb(), darkAlpha);
      }
    }

    return new RippleDrawable(
        ColorStateList.valueOf(rippleColor), null, bounded ? new ColorDrawable(Color.WHITE) : null);
  }
  /**
   * Returns a color from white-green-red-blue according to the degree of <tt>vertex</tt>.
   *
   * @param vertex a vertex
   */
  @Override
  public Color getColor(Object vertex) {
    int val = ((Vertex) vertex).getEdges().size();
    double color = 0;
    if (logscale) {
      double min2 = Math.log(k_min + 1);
      double max2 = Math.log(k_max + 1);
      color = (Math.log(val + 1) - min2) / (max2 - min2);
    } else {
      color = (val - k_min) / (double) (k_max - k_min);
    }

    return ColorUtils.getGRBColor(color);
  }
  /**
   * Draws the shape.
   *
   * @param g2d 2D Graphics object.
   * @param w width of the button
   * @param h height of the Button
   */
  private void drawShape(Graphics2D g2d, int w, int h) {
    color = ColorUtils.getInStance().getGradientColor(this.colorTheme, getHeight(), null);
    if (shapeType.equals(ShapeType.ROUNDED_RECTANGULAR)) {

      g2d.setPaint(color);
      g2d.fillRoundRect(0, 0, w, h, 10, 10);
      g2d.setPaint(new Color(100, 100, 100, 100));
      g2d.drawRoundRect(0, 0, w - 1, h - 1, 10, 10);
      g2d.setPaint(new Color(255, 255, 255, 50));
      g2d.drawRoundRect(1, 1, w - 3, h - 3, 10, 10);
    } else if (shapeType.equals(ShapeType.RECTANGULAR)) {
      g2d.setPaint(color);
      g2d.fillRect(1, 1, w - 2, h - 2);
      g2d.setPaint(new Color(100, 100, 100, 100));
      g2d.drawRect(0, 0, w - 1, h - 1);
    } else if (shapeType.equals(ShapeType.OVAL)) {
      g2d.setPaint(color);
      g2d.fillOval(1, 1, w - 20, h - 2);
      g2d.setPaint(new Color(100, 100, 100, 100));
      g2d.drawOval(0, 0, w - 20, h - 1);
    } else if (shapeType.equals(ShapeType.ELLIPSE)) {
      g2d.setPaint(color);
      Shape shape = new Ellipse2D.Double(1, 1, w - 2, h - 2);
      g2d.fill(shape);
      g2d.setPaint(new Color(100, 100, 100, 100));
      shape = new Ellipse2D.Double(0, 0, w - 1, h - 1);
      g2d.draw(shape);
    } else if (shapeType.equals(ShapeType.CIRCULAR)) {
      int size = Math.min(getWidth(), getHeight() - 2);
      g2d.setPaint(color);
      g2d.fillOval(2, 2, (size - 2 * 2), (size - 2 * 2));
      g2d.setStroke(new BasicStroke(2));
      g2d.setColor(new Color(100, 100, 100, 100));
      g2d.drawOval(2, 2, (size - 2 * 2), (size - 2 * 2));
    } else if (shapeType.equals(ShapeType.ROUNDED)) {
      g2d.setPaint(color);
      g2d.fillRoundRect(1, 1, w - 2, h - 2, h - 5, h - 5);
      g2d.setPaint(new Color(100, 100, 100, 100));
      g2d.drawRoundRect(0, 0, w - 1, h - 1, h - 3, h - 3);
    } else {; // nothing to do
    }
  }
示例#5
0
  public ColorContainer(String container) {
    String[] parts = container.split(";");
    for (int i = 0; i < parts.length; i++) {
      String part = parts[i];
      if (part.contains("swatch=")) {
        this.swatch = Integer.valueOf(part.split("=")[1]);
      } else if (part.contains("color=")) {
        this.color = Integer.valueOf(part.split("=")[1]);
      } else if (part.contains("color_value=")) {
        this.colorValue = Integer.valueOf(part.split("=")[1]);
      } else if (part.contains("locked=")) {
        this.locked = Boolean.valueOf(part.split("=")[1]);
      } else if (part.contains("from_wallpaper=")) {
        this.fromWallpaper = Integer.valueOf(part.split("=")[1]);
      }
    }

    if (this.colorValue == -1 && this.swatch >= 0 && this.color >= 0) {
      this.colorValue = ColorUtils.getColor(swatch, color + 1);
    }
  }
  /**
   * Swap Tab effect(color or cross fade)
   *
   * @param position The page position
   * @param positionOffset The page position offset
   */
  private void swapTabColor(int position, float positionOffset, boolean left) {
    final int colorDefault = mTabColorize.getDefaultTabColor(position);
    final int colorSelected = mTabColorize.getSelectedTabColor(position);
    final int nextColorDefault = mTabColorize.getDefaultTabColor(position + 1);
    final int nextColorSelected = mTabColorize.getSelectedTabColor(position + 1);

    int color = colorDefault;
    int nextColor = nextColorSelected;

    if (mTabColorBlendMode == TabColorBlendMode.DEFAULT_SELECTED) {
      if (colorDefault != colorSelected) {
        color = ColorUtils.blendColors(colorDefault, colorSelected, positionOffset);
      }

      if (nextColorDefault != nextColorSelected) {
        nextColor = ColorUtils.blendColors(nextColorSelected, nextColorDefault, positionOffset);
      }
    } else if (mTabColorBlendMode == TabColorBlendMode.NEXT_SELECTED) {
      if (!left) {
        if (colorDefault != colorSelected) {
          color = ColorUtils.blendColors(colorDefault, colorSelected, positionOffset);
        }

        if (nextColorSelected != colorSelected) {
          nextColor = ColorUtils.blendColors(nextColorSelected, colorSelected, positionOffset);
        }
      } else {
        if (colorSelected != nextColorSelected) {
          color = ColorUtils.blendColors(colorSelected, nextColorSelected, 1 - positionOffset);
        }

        if (nextColorDefault != nextColorSelected) {
          nextColor =
              ColorUtils.blendColors(nextColorDefault, nextColorSelected, 1 - positionOffset);
        }
      }
    }

    setTabColor(getNeededView(position), color);
    setTabColor(getNeededView(position + 1), nextColor);
  }
 private boolean shouldIgnoreColor(int color565) {
   final int rgb = approximateToRgb888(color565);
   ColorUtils.colorToHSL(rgb, mTempHsl);
   return shouldIgnoreColor(rgb, mTempHsl);
 }
示例#8
0
 public void setPresetColor(int swatch, int color) {
   this.swatch = swatch;
   this.color = color;
   this.colorValue = ColorUtils.getColor(swatch, color + 1);
 }
示例#9
0
 public ColorContainer(int swatch, int color, boolean locked) {
   this.swatch = swatch;
   this.color = color;
   this.colorValue = ColorUtils.getColor(swatch, color + 1);
   this.locked = locked;
 }
示例#10
0
 public ColorContainer(int swatch, int color) {
   this.swatch = swatch;
   this.color = color;
   this.colorValue = ColorUtils.getColor(swatch, color + 1);
 }
 public void setColor(final String color) {
   final int[] rgb = ColorUtils.getRGB(color);
   final int[] hsl = ColorUtils.rgb2hsl(rgb);
   huePicker.setHue(hsl[0]);
   slPicker.setColor(color);
 }
示例#12
0
 public static RippleDrawable createRipple(
     @ColorInt int color, @FloatRange(from = 0f, to = 1f) float alpha, boolean bounded) {
   color = ColorUtils.modifyAlpha(color, alpha);
   return new RippleDrawable(
       ColorStateList.valueOf(color), null, bounded ? new ColorDrawable(Color.WHITE) : null);
 }
示例#13
0
  @Override
  protected void drawGLScene() {
    float t_g = tickTimer.getTime();

    // synchro
    if (isSoundEnabled()) {
      modPlayer.stream();
      // System.out.println(modPlayer);

      int ord = modPlayer.getOrd();
      int row = modPlayer.getRow();

      if (row == 0 || firstDraw) {
        firstDraw = false;

        switch (ord) {
          case 0:
            if (!scene.getMapping().isEnabled()) {
              scene.getMapping().setSynchroTime(t_g);
              scene.getMapping().setEnabled(true);
            }
            break;

          case 1:
            scene.getLiner().setEnabled(true);
            break;

          case 2:
            scene.getGlenz().setEnabled(true);
            boolean jumpEnabled = scene.getJump().isEnabled();
            scene.getRez().setEnabled(jumpEnabled);
            scene.getParticles().setEnabled(false);
            scene.getLiner().setEnabled(false);
            scene.getTitle().setEnabled(true);
            if (!scene.getZoom().isEnabled()) {
              scene.getZoom().setSynchroTime(t_g);
              scene.getZoom().setEnabled(true);
            }
            break;

          case 4:
            scene.getRez().setEnabled(true);
            scene.getParticles().setEnabled(true);
            scene.getLiner().setEnabled(true);
            if (!scene.getJump().isEnabled()) {
              scene.getJump().setSynchroTime(t_g);
              scene.getJump().setEnabled(true);
            }
            scene.getLiner().setTxtCredits();
            break;

          case 6:
            scene.getRez().setEnabled(false);
            scene.getGlenz().setEnabled(false);
            scene.getLiner().setTxtLoop();
            break;
        }
      }
      if (row % 8 == 0) {
        f_n = 0.25f;
        f_v2 = f_n;
        f_t2 = t_g;
      }
      if (row == 0) {
        f_n = 0.5f;
        f_v1 = f_n;
        f_t1 = t_g;
        f_v2 = 0;
      }
      if ((((row % 8 - 4) == 0) || (row == 60) || (row == 62)) && (ord > 1)) {
        scene.getCube().setJumpAngle(0.0f);
        scene.getCube().setJump(0.5f);
        scene.getCube().setSynchroTime(t_g);
      }
    }

    Color f_c = ColorUtils.safe(f_v1 + f_v2, f_v1 + f_v2, f_v1 + f_v2, 1.0f); // fog color
    if (f_v1 > 0) {
      f_v1 = (float) (f_n - f_n * 2.0 * (t_g - f_t1));
    }
    if (f_v2 > 0) {
      f_v2 = (float) (f_n - f_n * 2.0 * (t_g - f_t2));
    }

    // 3d mode
    scene.init3D();
    scene.draw(f_c, t_g);
  }
示例#14
0
 public JCheckBoxMenuItemEx(Action a) {
   super(a);
   setForeground(ColorUtils.getForeground());
   setBackground(ColorUtils.getBackground());
 }
示例#15
0
  /**
   * Draw indicator
   *
   * @param canvas The canvas
   */
  private void drawIndicator(Canvas canvas) {
    if (mShowIndicator) {
      final int height = getHeight();
      final int childCount = getChildCount();

      if (childCount > 0) {
        View tabView = getChildAt(mSelectedPosition);
        int left = tabView.getLeft();
        int right = tabView.getRight();
        int color = mTabStripColorize.getIndicatorColor(mSelectedPosition);

        if (mSelectionOffset > 0f && mSelectedPosition < (getChildCount() - 1)) {
          int nextColor = mTabStripColorize.getIndicatorColor(mSelectedPosition + 1);
          if (color != nextColor) {
            color = ColorUtils.blendColors(nextColor, color, mSelectionOffset);
          }

          // Draw the selection partway between the tabs
          View nextTabView = getChildAt(mSelectedPosition + 1);
          left =
              (int) (mSelectionOffset * nextTabView.getLeft() + (1.0f - mSelectionOffset) * left);
          right =
              (int) (mSelectionOffset * nextTabView.getRight() + (1.0f - mSelectionOffset) * right);
        }

        mIndicatorPaint.setColor(color);

        RectF rectF =
            new RectF(
                left,
                height - mIndicatorHeight - mIndicatorPaddingBottom,
                right,
                height - mIndicatorPaddingBottom);
        switch (mIndicatorGravity) {
          case TOP:
            {
              rectF.set(left, mIndicatorPaddingTop, right, mIndicatorHeight + mIndicatorPaddingTop);
              break;
            }
          case CENTER:
            {
              rectF.set(
                  left, (height - mIndicatorHeight) / 2, right, (height + mIndicatorHeight) / 2);
              break;
            }
        }

        if (mIndicatorCornerRadius > 0f) {
          mIndicatorPaint.setAntiAlias(true);
          canvas.drawRoundRect(
              rectF, mIndicatorCornerRadius, mIndicatorCornerRadius, mIndicatorPaint);
        } else {
          mIndicatorPaint.setAntiAlias(false);
          canvas.drawRect(rectF, mIndicatorPaint);
        }

        if (mOnIndicatorColorChangedListener != null) {
          mOnIndicatorColorChangedListener.onIndicatorColorChanged(
              (NiceTabLayout) this.getParent(), color);
        }
      }
    }
  }
  /**
   * webview 显示本地图片,自适应布局大小,图片可缩放
   *
   * @param mContext
   * @param webview
   * @param imageLocalUrl
   * @param isAdapterScreenWidth 是否自适应屏幕宽度
   * @param color 0-255
   */
  public static void showLocalImage(
      Context mContext,
      final WebView webview,
      final String imageLocalUrl,
      int color,
      boolean isAdapterScreenWidth,
      boolean doubleClickEabled) {

    boolean fileExist = FileUtils.isExists(imageLocalUrl);

    if (fileExist) {
      String bgcolor = ColorUtils.toBrowserColor(color);

      ZogUtils.printLog(WebViewUtils.class, "bgcolor:" + bgcolor);

      String adapterScreenWidth = "";
      if (isAdapterScreenWidth) {
        adapterScreenWidth = " width:99.9%;";
      }

      String style =
          "<style>"
              + "* { margin:0; padding:0; background-color:"
              + bgcolor
              + ";  }"
              + "img { "
              + adapterScreenWidth
              + " margin:0; padding:0; }"
              + "div{"
              + adapterScreenWidth
              +
              //                            "     border: thin solid #F00;" +
              "    margin:0; padding:0;"
              + " }/*这里的width height 大于图片的宽高*/"
              + "table{ height:100%; width:100%; text-align:center;}"
              + " </style>";

      String body =
          "    <body>"
              + "        <div>"
              + "            <table>"
              + "                <tr>"
              + "                    <td>"
              + "                       <img src=\"file://"
              + imageLocalUrl
              + "\""
              +
              //                            "                                width=" + width +
              "                               margin="
              + 0
              + "                               padding="
              + 0
              +
              //                    "                               height="+height+
              "                           />"
              + "                    </td>"
              + "                </tr>"
              + "            </table>"
              + "        </div>"
              + "    </body>"
              + "";

      String data = style + body;

      webview.loadDataWithBaseURL("file://" + imageLocalUrl, data, "text/html", "utf-8", null);

      // webview.loadUrl(imageUrl);//直接显示网上图片

      webview.setVerticalScrollBarEnabled(false); // 取消Vertical ScrollBar显示
      webview.setHorizontalScrollBarEnabled(false); // 取消Horizontal ScrollBar显示
      webview.getSettings().setBuiltInZoomControls(true); // 显示放大缩小 controler
      webview.getSettings().setSupportZoom(true); // 可以缩放
      setZoomControlGone(webview); // 去掉zoom按钮

      if (doubleClickEabled) { // 双击缩放
        webview.getSettings().setUseWideViewPort(true);
        webview.getSettings().setLoadWithOverviewMode(true);
      }
      webview.setSaveEnabled(true);
    }
  }
示例#17
0
  /**
   * Creates an approximated cubic gradient using a multi-stop linear gradient. See <a
   * href="https://plus.google.com/+RomanNurik/posts/2QvHVFWrHZf">this post</a> for more details.
   */
  public static Drawable makeCubicGradientScrimDrawable(
      @ColorInt int baseColor, int numStops, int gravity) {
    numStops = Math.max(numStops, 2);

    PaintDrawable paintDrawable = new PaintDrawable();
    paintDrawable.setShape(new RectShape());

    final int[] stopColors = new int[numStops];

    int alpha = Color.alpha(baseColor);

    for (int i = 0; i < numStops; i++) {
      float x = i * 1f / (numStops - 1);
      float opacity = MathUtils.constrain(0, 1, (float) Math.pow(x, 3));
      stopColors[i] = ColorUtils.modifyAlpha(baseColor, (int) (alpha * opacity));
    }

    final float x0, x1, y0, y1;
    switch (gravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
      case Gravity.LEFT:
        x0 = 1;
        x1 = 0;
        break;
      case Gravity.RIGHT:
        x0 = 0;
        x1 = 1;
        break;
      default:
        x0 = 0;
        x1 = 0;
        break;
    }
    switch (gravity & Gravity.VERTICAL_GRAVITY_MASK) {
      case Gravity.TOP:
        y0 = 1;
        y1 = 0;
        break;
      case Gravity.BOTTOM:
        y0 = 0;
        y1 = 1;
        break;
      default:
        y0 = 0;
        y1 = 0;
        break;
    }

    paintDrawable.setShaderFactory(
        new ShapeDrawable.ShaderFactory() {
          @Override
          public Shader resize(int width, int height) {
            LinearGradient linearGradient =
                new LinearGradient(
                    width * x0,
                    height * y0,
                    width * x1,
                    height * y1,
                    stopColors,
                    null,
                    Shader.TileMode.CLAMP);
            return linearGradient;
          }
        });

    return paintDrawable;
  }