Skip to content

Commit

Permalink
Merge pull request #2 from Martomate/develop
Browse files Browse the repository at this point in the history
Release 1.1
  • Loading branch information
Martomate authored Nov 10, 2018
2 parents 1d1cead + 22bce36 commit a892f8f
Show file tree
Hide file tree
Showing 78 changed files with 2,386 additions and 1,383 deletions.
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Use container-based infrastructure
sudo: false

# These directories are cached to S3 at the end of the build
cache:
directories:
- $HOME/.ivy2/cache
- $HOME/.sbt

before_cache:
# Cleanup the cached directories to avoid unnecessary cache updates
- find $HOME/.ivy2/cache -name "ivydata-*.properties" -print -delete
- find $HOME/.sbt -name "*.lock" -print -delete

language: scala
scala:
- 2.12.6
script:
- sbt coverage test coverageReport coveralls
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# TriPaint
Like Paint, but for images with triangular pixels

[![Build Status](https://travis-ci.org/Martomate/TriPaint.svg?branch=master)](https://travis-ci.org/Martomate/TriPaint)
[![Coverage Status](https://coveralls.io/repos/github/Martomate/TriPaint/badge.svg?branch=master)](https://coveralls.io/github/Martomate/TriPaint?branch=master)
10 changes: 8 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ scalaVersion := "2.12.6"

name := "TriPaint"
organization := "com.martomate"
version := "1.0.1"
version := "1.1"

libraryDependencies += "org.scalafx" %% "scalafx" % "8.0.144-R12"
enablePlugins(LauncherJarPlugin)

libraryDependencies ++= Seq(
"org.scalactic" %% "scalactic" % "3.0.5",
"org.scalatest" %% "scalatest" % "3.0.5" % "test",
"org.scalafx" %% "scalafx" % "8.0.144-R12"
)
3 changes: 3 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.5")
File renamed without changes
File renamed without changes
81 changes: 0 additions & 81 deletions src/main/scala/com/martomate/tripaint/DialogUtils.scala

This file was deleted.

10 changes: 5 additions & 5 deletions src/main/scala/com/martomate/tripaint/EditMode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import scalafx.scene.image.ImageView

class EditMode(imagePath: String, val tooltipText: String, val shortCut: KeyCodeCombination = null) {
val toolboxButton: ToggleButton = {
val t = new ToggleButton(null, new ImageView("icons/editmode/" + imagePath + ".png"))
val t = new ToggleButton(null, new ImageView("icons/editmodes/" + imagePath + ".png"))
t.tooltip = new Tooltip(s"$tooltipText\n(Shortcut: $shortCut)")
t.onAction = _ => select()
t
Expand Down Expand Up @@ -36,11 +36,11 @@ object EditMode {

def currentModeProperty: ReadOnlyObjectProperty[EditMode] = _currentMode.readOnlyProperty

val Select = new EditMode("select", "Select", new KeyCodeCombination(KeyCode.S))
val Draw = new EditMode("draw", "Draw", new KeyCodeCombination(KeyCode.P))
val Fill = new EditMode("fill", "Fill", new KeyCodeCombination(KeyCode.F))
val Select = new EditMode("select", "Select", new KeyCodeCombination(KeyCode.S))
val Draw = new EditMode("draw", "Draw", new KeyCodeCombination(KeyCode.P))
val Fill = new EditMode("fill", "Fill", new KeyCodeCombination(KeyCode.F))
val PickColor = new EditMode("pickColor", "Pick Color", new KeyCodeCombination(KeyCode.K))
val Organize = new EditMode("organize", "Organize", new KeyCodeCombination(KeyCode.O))
val Organize = new EditMode("organize", "Organize", new KeyCodeCombination(KeyCode.O))

Draw.select()

Expand Down
82 changes: 0 additions & 82 deletions src/main/scala/com/martomate/tripaint/ImagePane.scala

This file was deleted.

44 changes: 44 additions & 0 deletions src/main/scala/com/martomate/tripaint/InjectiveHashMap.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.martomate.tripaint

import scala.collection.mutable

class InjectiveHashMap[L, R] extends InjectiveMap[L, R] {
private val leftToRight: mutable.Map[L, R] = mutable.Map.empty
private val rightToLeft: mutable.Map[R, L] = mutable.Map.empty

override def getRight(left: L): Option[R] = leftToRight.get(left)

override def getLeft(right: R): Option[L] = rightToLeft.get(right)

override def set(left: L, right: R): Boolean = {
val newMapping = !getRight(left).contains(right)
if (newMapping) {
removeLeft(left)
removeRight(right)
leftToRight.put(left, right)
rightToLeft.put(right, left)
}
newMapping
}

override def containsLeft(left: L): Boolean = leftToRight.contains(left)

override def containsRight(right: R): Boolean = rightToLeft.contains(right)

override def removeRight(right: R): Boolean = {
val l = getLeft(right)
l.foreach(left => removeUnchecked(left, right))
l.isDefined
}

override def removeLeft(left: L): Boolean = {
val r = getRight(left)
r.foreach(right => removeUnchecked(left, right))
r.isDefined
}

private def removeUnchecked(left: L, right: R): Unit = {
leftToRight.remove(left)
rightToLeft.remove(right)
}
}
26 changes: 26 additions & 0 deletions src/main/scala/com/martomate/tripaint/InjectiveMap.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.martomate.tripaint

/**
* An `InjectiveMap` is like a bidirectional Map with both unique keys and unique values.
* This makes the mapping injective.<br />
* It can be seen as a collection of pairs `(l, r)` where both l and r can be used to find, update and remove the mappings.<br />
* If you call e.g. `removeLeft(l)`, then the pair `(l, r)` will be removed (which means that r is removed too, and since
* it doesn't exist in any other pair it is no longer present in this map).<br />
*
* @tparam L The Left type
* @tparam R The Right type
*
*/
trait InjectiveMap[L, R] {
def getRight(left: L): Option[R]
def getLeft(right: R): Option[L]

def set(left: L, right: R): Boolean

def containsLeft(left: L): Boolean
def containsRight(right: R): Boolean

def removeRight(right: R): Boolean
def removeLeft(left: L): Boolean
}

16 changes: 16 additions & 0 deletions src/main/scala/com/martomate/tripaint/Listenable.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.martomate.tripaint

import scala.collection.mutable.ArrayBuffer

/**
* Like Observable but with custom listener class
*
* @tparam L the listener trait/interface
*/
trait Listenable[L] {
private val listeners: ArrayBuffer[L] = ArrayBuffer.empty
final def addListener(listener: L): Unit = listeners += listener
final def removeListener(listener: L): Unit = listeners -= listener

final protected def notifyListeners(func: L => Unit): Unit = listeners.foreach(func)
}
Loading

0 comments on commit a892f8f

Please sign in to comment.