Juha Komulainen avatar Juha Komulainen committed 3391d66

Updated to Kotlin M4.

Comments (0)

Files changed (15)

+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="AntConfiguration">
+    <defaultAnt bundledAnt="true" />
+  </component>
+</project>
+

.idea/compiler.xml

 <project version="4">
   <component name="CompilerConfiguration">
     <option name="DEFAULT_COMPILER" value="Javac" />
+    <excludeFromCompile>
+      <directory url="file://$PROJECT_DIR$/target/generated-sources/annotations" includeSubdirectories="true" />
+      <directory url="file://$PROJECT_DIR$/target/generated-test-sources/test-annotations" includeSubdirectories="true" />
+    </excludeFromCompile>
     <resourceExtensions />
     <wildcardResourcePatterns>
       <entry name="?*.properties" />

.idea/libraries/Maven__org_jetbrains_kotlin_kotlin_runtime_0_4_297.xml

+<component name="libraryTable">
+  <library name="Maven: org.jetbrains.kotlin:kotlin-runtime:0.4.297">
+    <CLASSES>
+      <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-runtime/0.4.297/kotlin-runtime-0.4.297.jar!/" />
+    </CLASSES>
+    <JAVADOC>
+      <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-runtime/0.4.297/kotlin-runtime-0.4.297-javadoc.jar!/" />
+    </JAVADOC>
+    <SOURCES>
+      <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-runtime/0.4.297/kotlin-runtime-0.4.297-sources.jar!/" />
+    </SOURCES>
+  </library>
+</component>

.idea/libraries/Maven__org_jetbrains_kotlin_kotlin_runtime_0_4_68.xml

-<component name="libraryTable">
-  <library name="Maven: org.jetbrains.kotlin:kotlin-runtime:0.4.68">
-    <CLASSES>
-      <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-runtime/0.4.68/kotlin-runtime-0.4.68.jar!/" />
-    </CLASSES>
-    <JAVADOC>
-      <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-runtime/0.4.68/kotlin-runtime-0.4.68-javadoc.jar!/" />
-    </JAVADOC>
-    <SOURCES>
-      <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-runtime/0.4.68/kotlin-runtime-0.4.68-sources.jar!/" />
-    </SOURCES>
-  </library>
-</component>

.idea/libraries/Maven__org_jetbrains_kotlin_kotlin_stdlib_0_4_297.xml

+<component name="libraryTable">
+  <library name="Maven: org.jetbrains.kotlin:kotlin-stdlib:0.4.297">
+    <CLASSES>
+      <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/0.4.297/kotlin-stdlib-0.4.297.jar!/" />
+    </CLASSES>
+    <JAVADOC>
+      <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/0.4.297/kotlin-stdlib-0.4.297-javadoc.jar!/" />
+    </JAVADOC>
+    <SOURCES>
+      <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/0.4.297/kotlin-stdlib-0.4.297-sources.jar!/" />
+    </SOURCES>
+  </library>
+</component>

.idea/libraries/Maven__org_jetbrains_kotlin_kotlin_stdlib_0_4_68.xml

-<component name="libraryTable">
-  <library name="Maven: org.jetbrains.kotlin:kotlin-stdlib:0.4.68">
-    <CLASSES>
-      <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/0.4.68/kotlin-stdlib-0.4.68.jar!/" />
-    </CLASSES>
-    <JAVADOC>
-      <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/0.4.68/kotlin-stdlib-0.4.68-javadoc.jar!/" />
-    </JAVADOC>
-    <SOURCES>
-      <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/0.4.68/kotlin-stdlib-0.4.68-sources.jar!/" />
-    </SOURCES>
-  </library>
-</component>

.idea/libraries/Maven__org_jetbrains_kotlin_kotlin_swing_0_4_297.xml

+<component name="libraryTable">
+  <library name="Maven: org.jetbrains.kotlin:kotlin-swing:0.4.297">
+    <CLASSES>
+      <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-swing/0.4.297/kotlin-swing-0.4.297.jar!/" />
+    </CLASSES>
+    <JAVADOC>
+      <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-swing/0.4.297/kotlin-swing-0.4.297-javadoc.jar!/" />
+    </JAVADOC>
+    <SOURCES>
+      <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-swing/0.4.297/kotlin-swing-0.4.297-sources.jar!/" />
+    </SOURCES>
+  </library>
+</component>

.idea/libraries/Maven__org_jetbrains_kotlin_kotlin_swing_0_4_68.xml

-<component name="libraryTable">
-  <library name="Maven: org.jetbrains.kotlin:kotlin-swing:0.4.68">
-    <CLASSES>
-      <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-swing/0.4.68/kotlin-swing-0.4.68.jar!/" />
-    </CLASSES>
-    <JAVADOC>
-      <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-swing/0.4.68/kotlin-swing-0.4.68-javadoc.jar!/" />
-    </JAVADOC>
-    <SOURCES>
-      <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-swing/0.4.68/kotlin-swing-0.4.68-sources.jar!/" />
-    </SOURCES>
-  </library>
-</component>

contextual-kotlin.iml

     <output url="file://$MODULE_DIR$/target/classes" />
     <output-test url="file://$MODULE_DIR$/target/test-classes" />
     <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/src/test/kotlin" isTestSource="true" />
-      <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" />
       <excludeFolder url="file://$MODULE_DIR$/target/classes" />
-      <excludeFolder url="file://$MODULE_DIR$/target/maven-archiver" />
-      <excludeFolder url="file://$MODULE_DIR$/target/surefire" />
       <excludeFolder url="file://$MODULE_DIR$/target/test-classes" />
     </content>
     <orderEntry type="jdk" jdkName="1.7" jdkType="JavaSDK" />
     <orderEntry type="sourceFolder" forTests="false" />
-    <orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib:0.4.68" level="project" />
-    <orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-runtime:0.4.68" level="project" />
-    <orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-swing:0.4.68" level="project" />
+    <orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib:0.4.297" level="project" />
+    <orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-runtime:0.4.297" level="project" />
+    <orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-swing:0.4.297" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.10" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
   </component>
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <kotlin.version>0.4.68</kotlin.version>
+        <kotlin.version>0.4.297</kotlin.version>
     </properties>
 
     <dependencies>

src/main/kotlin/contextual/HSBColor.kt

     fun withHue(h: Int)          = HSBColor(h, saturation, brightness)
     fun withSaturation(s: Float) = HSBColor(hue, norm(s), brightness)
     fun withBrightness(b: Float) = HSBColor(hue, saturation, norm(b))
-    fun toColor() = Color.getHSBColor(hue / 360.toFloat(), saturation, brightness)!!
+    fun toColor() = Color.getHSBColor(hue / 360.toFloat(), saturation, brightness)
     fun toString() = "($hue, $saturation, $brightness)"
 
     fun plus(c: HSBColor) = HSBColor(hue + c.hue, saturation + c.saturation, brightness + c.brightness)

src/main/kotlin/contextual/Main.kt

     initialTransform.scale(1.0, -1.0)
 
     val processor = Processor()
-    processor.addWorkItems(arrayList(root), DrawState(HSBColor.BLACK, initialTransform), 0)
+    processor.addWorkItems(listOf(root), DrawState(HSBColor.BLACK, initialTransform), 0)
 
     while (true)
         canvas.draw(processor.takeResult())

src/main/kotlin/contextual/PrimitiveDrawingCanvas.kt

         imageContext.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON)
     }
 
-    override fun paintComponent(g: Graphics?) {
-        g!!
+    override fun paintComponent(g: Graphics) {
         g.setColor(getBackground())
         g.fillRect(0, 0, getWidth(), getHeight())
 

src/main/kotlin/contextual/Processor.kt

 class Processor(val threads: Int = 3, val maxDepth: Int = 500) {
 
     private val resultQueue = ArrayBlockingQueue<Primitive>(1000)
-    private val workerScheduler = Executors.newFixedThreadPool(threads)!!
+    private val workerScheduler = Executors.newFixedThreadPool(threads)
     private val random = Random()
 
     fun addResult(shape: Shape, state: DrawState) {

src/main/kotlin/contextual/TransformationBuilder.kt

             throw UnsupportedOperationException("flip is supported only for 90 degrees")
 
     fun build(): (DrawState) -> DrawState =
-        if (color == HSBColor.BLACK && coordinateTransform.isIdentity())
-            { s -> s }
-        else if (color == HSBColor.BLACK)
-            { s -> DrawState(s.color, s.coordinateTransform * coordinateTransform) }
-        else if (coordinateTransform.isIdentity())
-            { s -> DrawState(s.color + color, s.coordinateTransform) }
-        else
-            { s -> DrawState(s.color + color, s.coordinateTransform * coordinateTransform) }
+        when {
+            color == HSBColor.BLACK && coordinateTransform.isIdentity() ->
+                { s -> s }
+            color == HSBColor.BLACK ->
+                { s -> DrawState(s.color, s.coordinateTransform * coordinateTransform) }
+            coordinateTransform.isIdentity() ->
+                { s -> DrawState(s.color + color, s.coordinateTransform) }
+            else  ->
+                { s -> DrawState(s.color + color, s.coordinateTransform * coordinateTransform) }
+        }
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.