org.mosspaper.Env - java examples

Here are the examples of the java api org.mosspaper.Env taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

39 Examples 7

19 View Complete Implementation : AbsAlign.java
Copyright Apache License 2.0
Author : teneighty
public void postDraw(Env env) {
}

19 View Complete Implementation : AbsAlign.java
Copyright Apache License 2.0
Author : teneighty
public void preDraw(Env env) {
}

19 View Complete Implementation : AbsBarObject.java
Copyright Apache License 2.0
Author : teneighty
protected void doDraw(Env env, float perc) {
    Bar b = new Bar();
    b.drawBar(env, perc, height, width);
}

19 View Complete Implementation : AbsMossObject.java
Copyright Apache License 2.0
Author : teneighty
public void draw(Env env) {
    Common.drawText(env, toString());
}

19 View Complete Implementation : AbsTop.java
Copyright Apache License 2.0
Author : teneighty
@Override
public void preDraw(Env env) {
    if (getList() != null) {
        return;
    }
    setList(procList.getProcesses());
    Collections.sort(getList(), getComparator());
    Collections.reverse(getList());
}

19 View Complete Implementation : AbsTop.java
Copyright Apache License 2.0
Author : teneighty
@Override
public void postDraw(Env env) {
    setList(null);
}

19 View Complete Implementation : AlignC.java
Copyright Apache License 2.0
Author : teneighty
public void draw(Env env) {
    if (curX != null && curX == lastX) {
        env.setX(curX);
        return;
    }
    Env tmpEnv = buildEnv(env);
    if (tmpEnv == null) {
        return;
    }
    float delta = tmpEnv.getX() - env.getX();
    lastX = curX;
    curX = (env.getMaxX() / 2.0f) - (delta / 2.0f);
    env.setX(curX);
}

19 View Complete Implementation : AlignR.java
Copyright Apache License 2.0
Author : teneighty
public void draw(Env env) {
    if (curX != null && curX == lastX) {
        env.setX(curX);
        return;
    }
    Env tmpEnv = buildEnv(env);
    if (tmpEnv == null) {
        return;
    }
    float delta = tmpEnv.getX() - env.getX();
    if (env.getMaxX() > delta && env.getX() < env.getMaxX() - delta) {
        lastX = curX;
        curX = env.getMaxX() - delta;
        env.setX(curX);
    }
}

19 View Complete Implementation : BatteryBar.java
Copyright Apache License 2.0
Author : teneighty
public void draw(Env env) {
    doDraw(env, battInfo.getLevelFrac());
}

19 View Complete Implementation : CpuBar.java
Copyright Apache License 2.0
Author : teneighty
public void draw(Env env) {
    doDraw(env, cpuInfo.getCpuUsage());
}

19 View Complete Implementation : CpuGraph.java
Copyright Apache License 2.0
Author : teneighty
public void preDraw(Env env) {
    if (null == history) {
        history = cpuInfo.getCpuHistory();
    }
}

19 View Complete Implementation : CpuGraph.java
Copyright Apache License 2.0
Author : teneighty
public void postDraw(Env env) {
    history = null;
}

19 View Complete Implementation : DownSpeedGraph.java
Copyright Apache License 2.0
Author : teneighty
public void preDraw(Env env) {
    if (null == history) {
        history = netDevInfo.getDownHistory(device);
        if (null == history) {
            return;
        }
    }
}

19 View Complete Implementation : FSBar.java
Copyright Apache License 2.0
Author : teneighty
public void draw(Env env) {
    StatFS stat = fs.getStatFS(mountPoint);
    float frac = stat.usedBytes / (float) stat.totalBytes;
    doDraw(env, frac);
}

19 View Complete Implementation : Goto.java
Copyright Apache License 2.0
Author : teneighty
public void draw(Env env) {
    env.setX(mPosition);
}

19 View Complete Implementation : Image.java
Copyright Apache License 2.0
Author : teneighty
public void preDraw(Env env) {
    if (bitmap != null) {
        return;
    }
    File image = new File(imagePath);
    if (image.isAbsolute()) {
        bitmap = BitmapFactory.decodeFile(imagePath);
    } else {
        File parentFile = env.getConfigFile().getParentFile();
        bitmap = BitmapFactory.decodeFile(new File(parentFile, imagePath).toString());
    }
}

19 View Complete Implementation : Length.java
Copyright Apache License 2.0
Author : teneighty
public void postDraw(Env env) {
    object.postDraw(env);
}

19 View Complete Implementation : Length.java
Copyright Apache License 2.0
Author : teneighty
public void preDraw(Env env) {
    object.preDraw(env);
}

19 View Complete Implementation : MemBar.java
Copyright Apache License 2.0
Author : teneighty
public void draw(Env env) {
    float perc = 0.0f;
    if (memInfo.getMemTotal() > 0) {
        perc = (memInfo.getMemTotal() - memInfo.getMemFree()) / (float) memInfo.getMemTotal();
    }
    doDraw(env, perc);
}

19 View Complete Implementation : Offset.java
Copyright Apache License 2.0
Author : teneighty
public void draw(Env env) {
    env.setX(env.getX() + mPixels);
}

19 View Complete Implementation : Printf.java
Copyright Apache License 2.0
Author : teneighty
public void postDraw(Env env) {
    for (Object o : objects) {
        if (o instanceof MossObject) {
            ((MossObject) o).postDraw(env);
        }
    }
}

19 View Complete Implementation : Printf.java
Copyright Apache License 2.0
Author : teneighty
public void preDraw(Env env) {
    for (Object o : objects) {
        if (o instanceof MossObject) {
            ((MossObject) o).preDraw(env);
        }
    }
}

19 View Complete Implementation : SwapBar.java
Copyright Apache License 2.0
Author : teneighty
public void draw(Env env) {
    float perc = 0.0f;
    if (memInfo.getSwapTotal() > 0) {
        perc = (memInfo.getSwapTotal() - memInfo.getSwapFree()) / (float) memInfo.getSwapTotal();
    }
    doDraw(env, perc);
}

19 View Complete Implementation : UpSpeedGraph.java
Copyright Apache License 2.0
Author : teneighty
public void preDraw(Env env) {
    if (null == history) {
        history = netDevInfo.getUpHistory(device);
        if (null == history) {
            return;
        }
        int i = 0;
    }
}

19 View Complete Implementation : VGoto.java
Copyright Apache License 2.0
Author : teneighty
public void draw(Env env) {
    env.setY(mPosition);
}

19 View Complete Implementation : VOffset.java
Copyright Apache License 2.0
Author : teneighty
public void draw(Env env) {
    env.setY(env.getY() + mPixels);
}

19 View Complete Implementation : Bar.java
Copyright Apache License 2.0
Author : teneighty
public void drawBar(final Env env, final float perc) {
    drawBar(env, perc, env.getLineHeight(), env.getMaxX() - env.getX());
}

18 View Complete Implementation : Color.java
Copyright Apache License 2.0
Author : teneighty
public void draw(Env env) {
    int c = -1;
    if (null == this.color || this.color < 0) {
        c = env.getConfig().getDefaultColor();
    } else {
        c = this.color;
    }
    if (c > -1) {
        env.getPaint().setColor(c);
        env.getPaint().setAlpha(0xFF);
    }
}

18 View Complete Implementation : Font.java
Copyright Apache License 2.0
Author : teneighty
public static void loadTypeface(Env env, String family, String path) throws ParseException {
    try {
        Typeface t = null;
        File f = new File(path);
        if (f.isAbsolute()) {
            t = Typeface.createFromFile(path);
        } else {
            if (null != env && env.getConfigFile() != null) {
                File parentFile = env.getConfigFile().getParentFile();
                if (parentFile != null) {
                    File fullpath = new File(parentFile, path);
                    t = Typeface.createFromFile(fullpath.toString());
                }
            }
        }
        if (t != null) {
            ttfMap.put(family, t);
        } else {
            throw new ParseException("Unable to load " + path);
        }
    } catch (RuntimeException e) {
        throw new ParseException("Unable to load " + path);
    }
}

18 View Complete Implementation : Image.java
Copyright Apache License 2.0
Author : teneighty
public void draw(Env env) {
    if (bitmap != null) {
        env.getCanvas().drawBitmap(bitmap, env.getX(), env.getY(), env.getPaint());
    }
}

18 View Complete Implementation : Bar.java
Copyright Apache License 2.0
Author : teneighty
public void drawBar(final Env env, final float perc, final float height, final float width) {
    final Paint p = env.getPaint();
    final int origColor = p.getColor();
    final Style origStyle = p.getStyle();
    if (-1 != env.getConfig().getOutlineColor()) {
        int c = env.getConfig().getOutlineColor();
        c |= 0xFF000000;
        p.setColor(c);
    }
    p.setStyle(Style.STROKE);
    float boxWidth = (width == -1.0f) ? env.getMaxX() : width;
    float barWidth = boxWidth * perc;
    float x = env.getX();
    float top = env.getY() + PADDING;
    float y = top + height;
    env.setLineHeight(height);
    /* Draw Outline */
    env.getCanvas().drawRect(x, top, x + boxWidth, y, p);
    if (-1 != env.getConfig().getShadeColor()) {
        int c = env.getConfig().getShadeColor();
        c |= 0xFF000000;
        p.setColor(c);
    }
    p.setStyle(Style.FILL);
    /* Draw Bar */
    env.getCanvas().drawRect(x, top, x + barWidth, y, env.getPaint());
    p.setStyle(origStyle);
    p.setColor(origColor);
    env.setX(x + boxWidth);
}

18 View Complete Implementation : Graph.java
Copyright Apache License 2.0
Author : teneighty
public void draw(Env env) {
    final Paint p = env.getPaint();
    final int origColor = p.getColor();
    final Style origStyle = p.getStyle();
    if (-1 != env.getConfig().getOutlineColor()) {
        int c = env.getConfig().getOutlineColor();
        c |= 0xFF000000;
        p.setColor(c);
    }
    p.setStyle(Style.STROKE);
    float x = env.getX();
    float y = env.getY();
    if (width <= 0) {
        width = env.getMaxX() - x;
    }
    float maxX = x + (width > 0 ? width : env.getMaxX());
    float maxY = y + height;
    env.setLineHeight(height);
    /* Draw Outline */
    env.getCanvas().drawRect(x, y, maxX, maxY, p);
    p.setStyle(Style.FILL);
    /* Move inside border */
    maxX -= 1.0f;
    maxY -= 1.0f;
    width -= 2.0f;
    /* Start from right */
    if (null != data) {
        long max = 0L;
        int count = 0;
        if (scale > 0) {
            max = scale;
        } else {
            for (Graphable g : data) {
                if (count > width) {
                    break;
                }
                max = Math.max(max, g.getValue());
                count++;
            }
        }
        count = 0;
        int nextColor = colorRight;
        for (Graphable g : data) {
            float currx = maxX - count;
            float curry = maxY;
            if (max > 0f) {
                float frac = Math.min(1.0f, g.getValue() / (float) max);
                float diff = maxY - y;
                curry = maxY - (frac * diff);
            }
            if (curry < 0 || curry > maxY) {
                curry = maxY;
            }
            p.setColor(nextColor);
            p.setAlpha(0xff);
            env.getCanvas().drawLine(currx, curry, currx, maxY, p);
            nextColor = calcNextColor((int) width - count, colorLeft, nextColor);
            if (count > width) {
                break;
            }
            count++;
        }
    }
    p.setStyle(origStyle);
    p.setColor(origColor);
    env.setX(maxX);
}

17 View Complete Implementation : AbsAlign.java
Copyright Apache License 2.0
Author : teneighty
protected Env buildEnv(Env env) {
    Env tmpEnv = env.dummyClone();
    /* Draw from here to end of line */
    Layout objs = env.getLayout();
    if (objs == null) {
        return null;
    }
    int start = objs.indexOf(this);
    for (int i = start; ; i++) {
        MossObject m = objs.get(i);
        if (m instanceof NewLine) {
            break;
        }
        m.draw(tmpEnv);
    }
    return tmpEnv;
}

17 View Complete Implementation : AbsGraphObject.java
Copyright Apache License 2.0
Author : teneighty
public void draw(Env env) {
    Graph g = new Graph();
    g.setHeight(height);
    g.setWidth(width);
    g.setScale(scale);
    g.setColorLeft(colorLeft);
    g.setColorRight(colorRight);
    g.setData(history);
    g.draw(env);
}

17 View Complete Implementation : PrefUtils.java
Copyright Apache License 2.0
Author : teneighty
public static void defaultPrefs(Env env, SharedPreferences prefs) {
    SharedPreferences.Editor edit = prefs.edit();
    if (-1.0f == prefs.getFloat("update_interval", -1.0f)) {
        edit.putFloat("update_interval", env.getConfig().getUpdateInterval());
    }
    if (-1.0f == prefs.getFloat("font_size", -1.0f)) {
        edit.putFloat("font_size", env.getConfig().getFontSize());
    }
    if (-1.0f == prefs.getFloat("gap_x", -1.0f)) {
        edit.putFloat("gap_x", env.getGapX());
    }
    if (-1.0f == prefs.getFloat("gap_y", -1.0f)) {
        edit.putFloat("gap_y", env.getGapY());
    }
    if (-1 == prefs.getInt("background_color", -1)) {
        int c = env.getConfig().getBackgroundColor();
        if (-1 != c) {
            c |= 0xFF000000;
            edit.putInt("background_color", c);
        }
    }
    if (-1 == prefs.getInt("mod_color", -1)) {
        int c = env.getConfig().getModColor();
        if (-1 != c) {
            c |= 0xFF000000;
            edit.putInt("mod_color", c);
        }
    }
    edit.commit();
}

17 View Complete Implementation : PrefUtils.java
Copyright Apache License 2.0
Author : teneighty
public static void resetPrefs(Env env, SharedPreferences prefs) {
    SharedPreferences.Editor edit = prefs.edit();
    for (String k : defaultable) {
        edit.remove(k);
    }
    edit.commit();
}

16 View Complete Implementation : Font.java
Copyright Apache License 2.0
Author : teneighty
public void draw(Env env) {
    if (mFontInfo == null) {
        env.getPaint().setTextSize(env.getFontSize());
        env.getPaint().setTypeface(Typeface.MONOSPACE);
    } else {
        Typeface t = ttfMap.get(mFontInfo.family);
        if (t != null) {
            env.getPaint().setTypeface(t);
        }
        env.getPaint().setTextSize(mFontInfo.size);
    }
    env.setLineHeight(env.getPaint().getTextSize());
}

16 View Complete Implementation : HRule.java
Copyright Apache License 2.0
Author : teneighty
public void draw(Env env) {
    final Paint p = env.getPaint();
    Style s = p.getStyle();
    p.setStyle(Style.FILL);
    /* move cursor to bottom of text and draw up */
    float y = env.getY() + env.getLineHeight();
    env.getCanvas().drawRect(env.getX(), y, env.getMaxX(), y - lineHeight, env.getPaint());
    p.setStyle(s);
// env.setX(env.getMaxX());
}

16 View Complete Implementation : StippledHRule.java
Copyright Apache License 2.0
Author : teneighty
public void draw(Env env) {
    final Paint p = env.getPaint();
    Style s = p.getStyle();
    p.setStyle(Paint.Style.STROKE);
    p.setPathEffect(new DashPathEffect(new float[] { space, space }, 0));
    env.getCanvas().drawLine(env.getX(), env.getY(), env.getMaxX(), env.getY(), env.getPaint());
    env.setY(env.getY() + env.getPaint().getTextSize());
    p.setPathEffect(null);
    p.setStyle(s);
}