Skip to content

Commit

Permalink
Refactored Color class. Matplotlib color scheme was incorrectly ident…
Browse files Browse the repository at this point in the history
…ified as tk previously
  • Loading branch information
manna committed Jun 18, 2016
1 parent 9ce5e4a commit f2e6f3f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions datk/core/colorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ class Color(Enum):
def toQt(self):
return self.value

def toTk(self):
tk = {
def toMpl(self):
mpl = {
'red': 'r',
'blue': 'b',
'green': 'g',
'black': 'k',
'yellow': 'y'
}
return tk[self.value]
return mpl[self.value]

def toRealTk(self):
def toTk(self):
return self.value

def Colorizer(algorithm, network, algorithm_type):
Expand Down
4 changes: 2 additions & 2 deletions datk/core/distalgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,12 @@ def setup(network):
network.setup_canvas(new_fig=new_fig)

def e_draw(network, edge, color=Color.black):
color = color.toTk()
color = color.toMpl()
(start_x, start_y), (end_x, end_y) = edge
network.ax.plot((start_x, end_x), (start_y, end_y), color)

def v_draw(network, vertex, color=Color.black):
color = color.toTk()+'o'
color = color.toMpl()+'o'
x,y = vertex
network.ax.plot( [x], [y], color)

Expand Down
4 changes: 2 additions & 2 deletions datk/core/simulator_mpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ def setup(network):
self.setup_fig()

def e_draw(network, edge, color=Color.black):
color = color.toTk()
color = color.toMpl()
start, end = edge
self.ax.plot( (start[0], end[0]), (start[1], end[1]), color)

def v_draw(network, vertex, color=Color.black):
color = color.toTk()+'o'
color = color.toMpl()+'o'
x,y = vertex
self.ax.plot( [x], [y], color)

Expand Down
4 changes: 2 additions & 2 deletions datk/core/simulator_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def scale(v):

def v_draw(network, vertex, color=Color.black, radius=5):
x,y = scale(vertex)
color = color.toRealTk()
color = color.toTk()
self.create_oval(
x-radius,
y-radius,
Expand All @@ -61,7 +61,7 @@ def e_draw(network, edge, color=Color.black):
start, end = scale(start), scale(end)
x1,y1 = start
x2,y2 = end
color = color.toRealTk()
color = color.toTk()
self.create_line(x1, y1, x2, y2, fill=color)

self.delete(ALL)
Expand Down

0 comments on commit f2e6f3f

Please sign in to comment.