Skip to content

Commit cdd6084

Browse files
committed
Minor cleanup
1 parent 6d4bedd commit cdd6084

1 file changed

Lines changed: 1 addition & 43 deletions

File tree

src/main/kotlin/be/ugent/topl/mio/ui/GraphPanel.kt

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class GraphPanel(private val graph: MultiverseGraph) : JPanel(),
2626
addMouseWheelListener(this)
2727
}
2828
private val textColour = UIManager.getDefaults().getColor("RadioButton.foreground")
29-
//private val borderColour = Color(125, 125, 125)
3029
private val borderColour = UIManager.getDefaults().getColor("CheckBox.icon.borderColor")
3130
private val primaryColour = UIManager.getDefaults().getColor("Panel.foreground")
3231
private val backgroundColour = UIManager.getDefaults().getColor("CheckBox.icon.background")
@@ -45,7 +44,6 @@ class GraphPanel(private val graph: MultiverseGraph) : JPanel(),
4544

4645
// Panning
4746
private var startPos = Point(0, 0)
48-
var associatedScrollPane: JScrollPane? = null
4947
var allowSelection = true
5048

5149
data class Node(val x: Int, val y: Int, val w: Int, val h: Int, val value: MultiverseNode)
@@ -75,13 +73,6 @@ class GraphPanel(private val graph: MultiverseGraph) : JPanel(),
7573
}
7674

7775
fun drawMiniMap(g: Graphics2D) {
78-
//val scale = min(100.0/renderedHeight, width.toDouble()/renderedWidth)
79-
val scale = min(100.0/renderedHeight, (100.0 * width/height)/renderedWidth)
80-
//g.drawString("camera pos = ($xOffset, $yOffset)", 5, 10)
81-
82-
val graphWidth = (renderedWidth * scale).roundToInt()
83-
val offset = width - graphWidth
84-
8576
// Zoom str
8677
if (scaleFactor != 1.0) {
8778
val zoomStr = "${(scaleFactor * 100).roundToInt()}%"
@@ -116,27 +107,6 @@ class GraphPanel(private val graph: MultiverseGraph) : JPanel(),
116107
g.color = green
117108
g.fillRect(xPos.toInt(), 0, 3, barHeight)
118109
}
119-
120-
// Graph rectangle
121-
/*g.color = Color(100, 100, 100, 50)
122-
val rectangle = Rectangle(offset, 0, graphWidth, (renderedHeight * scale).roundToInt())
123-
g.fillRect(rectangle.x, rectangle.y, rectangle.width, rectangle.height)
124-
g.color = Color(150, 150, 255, 150)
125-
val oldClip = g.clip // If we don't do this the component will be able to draw outside of itself.
126-
g.clip = rectangle
127-
val cameraPosX = (xOffset * scale).roundToInt()
128-
val cameraPosY = (yOffset * scale).roundToInt()
129-
val cameraWidth = (width/scaleFactor * scale).roundToInt()
130-
val cameraHeight = (height/scaleFactor * scale).roundToInt()
131-
g.fillRect(offset + cameraPosX, cameraPosY, cameraWidth, cameraHeight)
132-
g.color = Color(150, 150, 255, 255)
133-
g.drawRect(offset + cameraPosX, cameraPosY, cameraWidth, cameraHeight)
134-
g.clip = oldClip*/
135-
/*g.color = Color(200, 100, 100, 255)
136-
g.drawString("C", cameraPosX, cameraPosY + 10)*/
137-
/*g.scale(scale, scale)
138-
drawPaths(g, graph.rootNode)
139-
g.scale(1/scale, 1/scale)*/
140110
}
141111

142112
private fun scrollBarPosition(): Int {
@@ -408,8 +378,6 @@ class GraphPanel(private val graph: MultiverseGraph) : JPanel(),
408378
}
409379

410380
println("" + e.x + " " + e.y)
411-
/*associatedScrollPane?.horizontalScrollBar?.value -= delta.x
412-
associatedScrollPane?.verticalScrollBar?.value -= delta.y*/
413381
xOffset -= (delta.x / scaleFactor).toInt()
414382
yOffset -= (delta.y / scaleFactor).toInt()
415383
repaint()
@@ -449,11 +417,7 @@ class GraphPanel(private val graph: MultiverseGraph) : JPanel(),
449417
val oldScaleFactor = scaleFactor
450418
val adjustment = e.wheelRotation / 20.0
451419
scaleFactor -= adjustment
452-
scaleFactor = kotlin.math.max(0.1, scaleFactor)
453-
/*val oldW = height * oldScaleFactor
454-
val newW = height * scaleFactor
455-
val delta = (newW - oldW)/scaleFactor
456-
yOffset += (delta/2).toInt()*/
420+
scaleFactor = max(0.1, scaleFactor)
457421

458422
val oldH = height/oldScaleFactor
459423
val newH = height/scaleFactor
@@ -465,12 +429,6 @@ class GraphPanel(private val graph: MultiverseGraph) : JPanel(),
465429
val deltaW = (newW - oldW)
466430
xOffset -= (deltaW/2).toInt()
467431

468-
/*associatedScrollPane?.horizontalScrollBar?.value = ((associatedScrollPane?.horizontalScrollBar?.value!! / oldScaleFactor) * scaleFactor).toInt()
469-
associatedScrollPane?.verticalScrollBar?.value = ((associatedScrollPane?.verticalScrollBar?.value!! / oldScaleFactor) * scaleFactor).toInt()*/
470-
println("Scale = $scaleFactor")
471432
repaint()
472-
473-
/*associatedScrollPane?.verticalScrollBar?.revalidate()
474-
associatedScrollPane?.horizontalScrollBar?.revalidate()*/
475433
}
476434
}

0 commit comments

Comments
 (0)