All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fernice.reflare.resource.TInsets.kt Maven / Gradle / Ivy

There is a newer version: 1.3.1
Show newest version
/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package org.fernice.reflare.resource

import java.awt.Insets

internal interface TInsets : Owned {
    val top: Float
    val right: Float
    val bottom: Float
    val left: Float
}

internal operator fun TInsets.plus(other: TInsets): TInsets {
    checkResourceOperationAccess(this, other)

    return ResourceContext.TInsets(
        top + other.top,
        right + other.right,
        bottom + other.bottom,
        left + other.left
    )
}

internal operator fun TInsets.minus(other: TInsets): TInsets {
    checkResourceOperationAccess(this, other)

    return ResourceContext.TInsets(
        top - other.top,
        right - other.right,
        bottom - other.bottom,
        left - other.left
    )
}

internal operator fun Insets.plusAssign(other: TInsets) {
    checkResourceOperationAccess(other)

    this.top += other.top.toInt()
    this.right = other.right.toInt()
    this.bottom = other.bottom.toInt()
    this.left = other.left.toInt()
}

internal operator fun TInsets.plus(other: Insets): TInsets {
    checkResourceOperationAccess(this)

    return ResourceContext.TInsets(
        top + other.top,
        right + other.right,
        bottom + other.bottom,
        left + other.left
    )
}

internal fun TInsets.toAWTInsets(insets: Insets? = null): Insets {
    checkResourceAccess(this)

    val destination = insets ?: Insets(0, 0, 0, 0)

    destination.top = top.toInt()
    destination.right = right.toInt()
    destination.bottom = bottom.toInt()
    destination.left = left.toInt()

    return destination
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy