Skip to content

Instantly share code, notes, and snippets.

View ahinchman1's full-sized avatar

Amanda Hinchman-Dominguez ahinchman1

View GitHub Profile
@ahinchman1
ahinchman1 / Fertility.json
Created March 31, 2017 00:31
Interactive map
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ahinchman1
ahinchman1 / description.kt
Last active February 7, 2018 01:14
Naming conventions, descriptive vs oversimplified
private fun drop(evt : MouseEvent) {
val mousePt = workArea.sceneToLocal( evt.sceneX, evt.sceneY )
val targetNode = evt.target as Node
val tileTarget = targetNode.findParentOfType(Tile::class)
if (::inFlightTileProperties.isInitialized && isDragAndDrop) {
if (tileTarget is Tile && workArea.contains(mousePt) &&
inFlightTileProperties.title.toIntOrNull() == null) {
// find the grid tile the dragging tile drops on
@ahinchman1
ahinchman1 / oversimplified.kt
Last active February 5, 2018 23:45
Naming conventions, descriptive vs oversimplified
private fun d(e : MouseEvent) {
val m = w.sceneToLocal( e.sceneX, e.sceneY )
val tN = e.target as Node
val tT = tN.findParentOfType(Tile::class)
if (::i.isInitialized && dnd) {
if (tT is Tile && w.contains(mousePt) &&
i.t.toIntOrNull() == null) {
p(m.x, m.y)
@ahinchman1
ahinchman1 / DragAndDrop.kt
Last active February 28, 2018 04:34
TornadoFX View setup for custom DnD
class DragAndDrop : View() {
/***** Global Variables *****/
private val tileBuilderController: TileBuilderController by inject()
val workbenchController: WorkbenchController by inject()
private val controller: TileGUIController by inject()
var workArea: GridPane by singleAssign()
var moduleBoxItems = mutableListOf<Node>()
lateinit var gridInfo: GridInfo
/**
* Grabs a tile and its properties to prepare for the animateDrag
* and drop events.
*
* @property MouseEvent evt
*/
private fun startDrag(evt : MouseEvent) {
val targetNode = evt.target as Node
val tileTarget = targetNode.findParentOfType(Tile::class)
/**
* Compare selected dragging tile with the location of the drop
* and render the module tile accordingly
*
* @property MouseEvent evt
*/
private fun drop(evt : MouseEvent) {
val mousePt = workArea.sceneToLocal( evt.sceneX, evt.sceneY )
val targetNode = evt.target as Node
public class Person {
// instance variables
String firstName;
String lastName;
int age;
// constructor
public Person(String firstName, String lastName, int age) {
setOnDragOver { event ->
if (event.dragboard.hasFiles()) event.acceptTransferModes(TransferMode.COPY)
event.consume()
}
@ahinchman1
ahinchman1 / NeighborhoodView.kt
Created May 21, 2018 02:58
Quick and dirty GridPane
package com.example.demo.view
import javafx.geometry.Pos
import javafx.scene.layout.StackPane
import tornadofx.*
import java.util.*
class NeighborhoodView: View() {
// set up neighborhood
@ahinchman1
ahinchman1 / oneRowGridPane.java
Created May 23, 2018 03:46
JavaFX GridPane example
class GridPaneExample {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage primaryStage) {