label precision
This commit is contained in:
parent
c2f80332b2
commit
0975a933e5
|
@ -132,6 +132,7 @@ class Configuration(RawConfigParser):
|
|||
set_option(section, "marker-size", "11")
|
||||
set_option(section, "curve-color", "0, 255, 0")
|
||||
set_option(section, "label-size", "16")
|
||||
set_option(section, "label-precision", "2")
|
||||
set_option(section, "axis-label-count", "8")
|
||||
|
||||
def read_project_config_file(self):
|
||||
|
@ -352,7 +353,7 @@ class TypeDeclarations(dict):
|
|||
"event": {"int": "command-id-offset"},
|
||||
|
||||
"interpolator-gui": {"int": ["margin", "marker-size", "label-size",
|
||||
"axis-label-count"],
|
||||
"axis-label-count", "label-precision"],
|
||||
|
||||
"int-list": ["marker-color", "curve-color"]},
|
||||
|
||||
|
|
|
@ -204,6 +204,7 @@ class GUI(GameChild):
|
|||
self.curve_color = config["curve-color"]
|
||||
self.marker_size = config["marker-size"]
|
||||
self.marker_color = config["marker-color"]
|
||||
self.label_precision = config["label-precision"]
|
||||
|
||||
def set_background(self):
|
||||
surface = Surface(self.display_surface.get_size())
|
||||
|
@ -257,12 +258,12 @@ class GUI(GameChild):
|
|||
rect = self.plot_rect
|
||||
for ii in xrange(count):
|
||||
ratio = float(ii) / (count - 1)
|
||||
x = "%.3f" % ((xr[1] - xr[0]) * ratio + xr[0])
|
||||
x = self.get_formatted_measure((xr[1] - xr[0]) * ratio + xr[0])
|
||||
xs = self.font.render(x, True, (0, 0, 0), (255, 255, 255))
|
||||
xsr = xs.get_rect()
|
||||
xsr.midtop = (rect.right - rect.left) * ratio + rect.left, \
|
||||
rect.bottom
|
||||
y = "%.3f" % ((yr[1] - yr[0]) * ratio + yr[0])
|
||||
y = self.get_formatted_measure((yr[1] - yr[0]) * ratio + yr[0])
|
||||
ys = self.font.render(y, True, (0, 0, 0), (255, 255, 255))
|
||||
ysr = ys.get_rect()
|
||||
ysr.midright = rect.left, rect.bottom - (rect.bottom - rect.top) * \
|
||||
|
@ -273,6 +274,9 @@ class GUI(GameChild):
|
|||
def get_nodeset(self):
|
||||
return self.parent[self.nodeset_index]
|
||||
|
||||
def get_formatted_measure(self, measure):
|
||||
return "%s" % float(("%." + str(self.label_precision) + "g") % measure)
|
||||
|
||||
def deactivate(self):
|
||||
self.active = False
|
||||
self.time_filter.open()
|
||||
|
|
Loading…
Reference in New Issue