-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow overriding of Swing component painting behavior
- Loading branch information
Showing
3 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
vis-svg-mapper-batik/src/jvmMain/kotlin/vis/swing/BatikGraphicsNodeRenderer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2023. JetBrains s.r.o. | ||
* Use of this source code is governed by the MIT license that can be found in the LICENSE file. | ||
*/ | ||
|
||
package jetbrains.datalore.vis.swing | ||
|
||
import org.apache.batik.gvt.GraphicsNode | ||
import java.awt.Graphics2D | ||
import java.util.* | ||
|
||
interface BatikGraphicsNodeRenderer { | ||
val priority: Int | ||
fun paint(node: GraphicsNode, g: Graphics2D) | ||
|
||
object Default : BatikGraphicsNodeRenderer { | ||
override val priority: Int | ||
get() = 0 | ||
|
||
override fun paint(node: GraphicsNode, g: Graphics2D) { | ||
node.paint(g) | ||
} | ||
} | ||
|
||
companion object { | ||
fun getInstance(): BatikGraphicsNodeRenderer { | ||
val serviceClass = BatikGraphicsNodeRenderer::class.java | ||
val loader = ServiceLoader.load(serviceClass, serviceClass.classLoader) | ||
return loader.maxByOrNull { it.priority } ?: Default | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters