import new texture
@ -2,6 +2,9 @@ package org.hso.texturesyncclient.controller
 | 
			
		||||
 | 
			
		||||
import javafx.collections.ObservableList
 | 
			
		||||
import org.hso.texturesyncclient.controller.net.Connection
 | 
			
		||||
import org.hso.texturesyncclient.model.Sha256
 | 
			
		||||
import org.hso.texturesyncclient.model.Texture
 | 
			
		||||
import org.hso.texturesyncclient.model.TextureFormat
 | 
			
		||||
import org.hso.texturesyncclient.view.importView.ImportViewController
 | 
			
		||||
import org.hso.texturesyncclient.view.mainView.MainViewController
 | 
			
		||||
import org.hso.texturesyncclient.view.startupView.StartupViewController
 | 
			
		||||
@ -10,6 +13,12 @@ import java.net.InetAddress
 | 
			
		||||
import java.util.Calendar
 | 
			
		||||
import java.io.File
 | 
			
		||||
import javax.imageio.ImageIO
 | 
			
		||||
import java.util.UUID
 | 
			
		||||
import java.nio.file.Files
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -50,13 +59,20 @@ class RootController : Controller() {
 | 
			
		||||
     * @param tags all tags for the file
 | 
			
		||||
     */
 | 
			
		||||
    fun importTexture(path: String, name: String, tags: ObservableList<String>) {
 | 
			
		||||
        val data = Files.readAllBytes(File(path).toPath()) // this is the image as byte array
 | 
			
		||||
 | 
			
		||||
        val cal = Calendar.getInstance() //calendar obj with current time
 | 
			
		||||
        val uuid = UUID.randomUUID()
 | 
			
		||||
        val format = if (File(path).extension.toLowerCase() == "png") TextureFormat.PNG else TextureFormat.JPEG
 | 
			
		||||
        val bimg = ImageIO.read(File(path)) //image for obtaining resolution
 | 
			
		||||
        val resolution = Pair(bimg.height, bimg.width)
 | 
			
		||||
        val cal = Calendar.getInstance() //calendar obj with current time
 | 
			
		||||
        val hash =  Sha256(data)
 | 
			
		||||
 | 
			
		||||
        println(cal.time)
 | 
			
		||||
        println("Height: ${bimg.getHeight()} With: ${bimg.getWidth()}")
 | 
			
		||||
        //Todo free image
 | 
			
		||||
 | 
			
		||||
        val newTexture = Texture(uuid, name, tags.toTypedArray(), format, resolution, cal, hash)
 | 
			
		||||
 | 
			
		||||
        con.uploadTexture(newTexture, data)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -5,9 +5,6 @@ import java.util.*
 | 
			
		||||
import java.security.MessageDigest
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DataModel
 | 
			
		||||
 | 
			
		||||
enum class TextureFormat {
 | 
			
		||||
    PNG, JPEG,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -12,8 +12,6 @@ class ImportViewController : Controller() {
 | 
			
		||||
    private val rootc = find(RootController::class)
 | 
			
		||||
 | 
			
		||||
    fun btnFileChooserAction() {
 | 
			
		||||
        println("btn click")
 | 
			
		||||
 | 
			
		||||
        val list = listOf("*.png", "*.PNG", "*.jpg", "*.JPG", "*.jpeg", "*.JPEG")
 | 
			
		||||
        val arrayFilter = arrayOf(ExtensionFilter("Texturen vom Bildformat: PNG oder JPG", list))
 | 
			
		||||
        val file = chooseFile("Textur auswählen", arrayFilter, FileChooserMode.Single, owner = null)
 | 
			
		||||
 | 
			
		||||
@ -10,9 +10,6 @@ import javax.swing.JColorChooser.showDialog
 | 
			
		||||
import java.io.File
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class MainViewController : Controller() {
 | 
			
		||||
 | 
			
		||||
    private val mv = find(MainView::class)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								client/src/main/resources/textures/sample_texture_3.PNG
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 85 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								client/src/main/resources/textures/sample_texture_4.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 85 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								client/src/main/resources/textures/sample_texture_5.JPG
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 6.2 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								client/src/main/resources/textures/sample_texture_6.JPEG
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 6.2 KiB  |