Update Main

This commit is contained in:
Julius de Jeu 2019-01-17 17:33:09 +01:00
parent e771a75512
commit b300c3c114

View file

@ -22,11 +22,6 @@ val filenameRegex = ".*\\.(png|jpe?g|bmp)".toRegex()
val jf = JFrame("WaterMarker")
object obs : Observable() {
fun observe() {
setChanged()
}
}
fun main(args: Array<String>) {
var watermark: File? = null
@ -127,7 +122,7 @@ fun main(args: Array<String>) {
fun doTheThing(basedir: File, outdir: File, watermarkpath: File) {
val watermark = ImageIO.read(watermarkpath)
//JOptionPane.showMessageDialog(jf, "", "Inserting watermark!", JOptionPane.INFORMATION_MESSAGE, ImageIcon(watermark))
FrmPopUpInfo("Inserting Watermark", watermark)
//FrmPopUpInfo("Inserting Watermark", watermark)
for (f in basedir.listFiles()) {
if (filenameRegex.matches(f.name.toString()) && !"jpe?g".toRegex().matches(f.extension)) {
val image = ImageIO.read(f)
@ -158,8 +153,6 @@ fun doTheThing(basedir: File, outdir: File, watermarkpath: File) {
writer.dispose()
}
}
obs.observe()
obs.notifyObservers()
}
fun Component.forceToCenter(): Component = JPanel().apply { this.add(this@forceToCenter) }
@ -174,23 +167,23 @@ fun addWM(watermark: BufferedImage, image: BufferedImage): Image {
return combined
}
class FrmPopUpInfo(message: String, image: Image) : JFrame() {
init {
this.title = message
this.add(JLabel(ImageIcon(image)))
this.background = Color.WHITE
this.pack()
this.setLocationRelativeTo(null)
obs.addObserver { o, arg ->
java.util.Timer().schedule(timerTask {
}, 5 * 1000)
this@FrmPopUpInfo.isVisible = false
this@FrmPopUpInfo.dispose()
}
this.isVisible = true
}
}
//class FrmPopUpInfo(message: String, image: Image) : JFrame() {
// init {
// this.title = message
// this.add(JLabel(ImageIcon(image)))
// this.background = Color.WHITE
// this.pack()
//
// this.setLocationRelativeTo(null)
// obs.addObserver { _, _ ->
// java.util.Timer().schedule(timerTask {
//
// }, 5 * 1000)
// this@FrmPopUpInfo.isVisible = false
//
// this@FrmPopUpInfo.dispose()
// }
//
// this.isVisible = true
// }
//}