Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

42
LINES

< > BotCompany Repo | #1002592 // Graphical CPU Meter (LIVE)

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Uses 180K of libraries. Click here for Pure Java version (6826L/45K/154K).

!7
lib 1001955 // charts4j

import com.googlecode.charts4j.*;
import static com.googlecode.charts4j.Color.*;
import static com.googlecode.charts4j.Shape.*;
import static com.googlecode.charts4j.UrlUtil.normalize;
import com.googlecode.charts4j.Color;

p {
  botIfMain();
}

answer {
  if "cpu meter" exceptionToUser {
    double percent = (double) call(getBot("#1001405"), "getInProcessCPU");
    GoogleOMeter chart = GCharts.newGoogleOMeter(percent, "Utilized", "In-Java CPU Percentage", Color.newColor("1148D4"), Color.newColor("5766DE"), Color.newColor("DB3270"), Color.newColor("D41111"));
    chart.setTitle("Eleu CPU", BLACK, 14);
    chart.setSize(400, 200);
    final LinearGradientFill fill = Fills.newLinearGradientFill(0, BLUE, 100);
    fill.addColorAndOffset(RED, 0);
    chart.setBackgroundFill(fill);
    chart.setAreaFill(Fills.newSolidFill(Color.newColor(GRAY, 70)));
    String url = chart.toURLString();
    
    ret returnImage(url);
  }
}

static S returnImage(S imageURL) {
  // TODO: caching
  /*
  byte[] data = loadBinaryPage(imageURL);
  S md5 = md5(data);
  S fileName = "chart-" + md5 + ".png";
  saveBinaryFile(getProgramFile(fileName), data);
  S newURL = "bots.tinybrain.de/" + getProgramID() + "/raw/" + fileName;
  ret "Lookie here: " + newURL;*/
  
  imageURL = urlShortener(imageURL);
  ret "Lookie here: " + imageURL;
}

Author comment

Began life as a copy of #1002496

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, vpdwwinrgdga

No comments. add comment

Snippet ID: #1002592
Snippet name: Graphical CPU Meter (LIVE)
Eternal ID of this version: #1002592/2
Text MD5: c046646ec27d7710efc56c108bb4bda0
Transpilation MD5: 1667685ca4e7d33160e9330c7e9436dc
Author: stefan
Category: eleu
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-26 14:48:27
Source code size: 1396 bytes / 42 lines
Pitched / IR pitched: No / No
Views / Downloads: 705 / 1169
Version history: 1 change(s)
Referenced in: [show references]