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

23
LINES

< > BotCompany Repo | #1036167 // ScaledDiagram

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (9676L) is out of date.

sclass ScaledDiagram {
  settable int w = 600;
  settable int h = 400;
  int horizontalMargin = 10;
  int verticalMargin = 10;
  
  settable DoubleRange horizontalRange;
  settable DoubleRange verticalRange;

  DoubleRange xRange() { ret doubleRange(horizontalMargin, w-horizontalMargin); }
  DoubleRange yRange() { ret doubleRange(h-verticalMargin, verticalMargin); }
  
  double xToScreen(double x) { ret transformBetweenDoubleRanges(x, horizontalRange(), xRange()); }
  double yToScreen(double y) { ret transformBetweenDoubleRanges(y, verticalRange(), yRange()); }
  
  double xFromScreen(double x) { ret transformBetweenDoubleRanges(x, xRange(), horizontalRange()); }
  double yFromScreen(double y) { ret transformBetweenDoubleRanges(y, yRange(), verticalRange()); }
  
  public int getWidth() { ret w; }
  public int getHeight() { ret h; }
  
  bool hasScale() { ret horizontalRange != null && verticalRange != null; }
}

Author comment

Began life as a copy of #1036145

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): elmgxqgtpvxh, mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1036167
Snippet name: ScaledDiagram
Eternal ID of this version: #1036167/4
Text MD5: 6cb11d063968f0c9f21c48be3b4c173c
Author: stefan
Category: javax / gazelle 22
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-11-26 23:03:04
Source code size: 947 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 18 / 44
Version history: 3 change(s)
Referenced in: [show references]