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

org.opentcs.operationsdesk.util.Cursors Maven / Gradle / Ivy

There is a newer version: 6.2.0
Show newest version
/**
 * Copyright (c) The openTCS Authors.
 *
 * This program is free software and subject to the MIT license. (For details,
 * see the licensing information (LICENSE.txt) you should have received with
 * this copy of the software.)
 */
package org.opentcs.operationsdesk.util;

import java.awt.Cursor;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;

/**
 * Provides cursors for various situations.
 */
public final class Cursors {

  /**
   * A cursor suitable for dragging a vehicle to a destination point.
   */
  private static final Cursor DRAG_VEHICLE_CURSOR = createDragVehicleCursor();

  /**
   * Prevents instantiation.
   */
  private Cursors() {
  }

  /**
   * Returns a cursor suitable for dragging a vehicle to a destination point.
   *
   * @return A cursor suitable for dragging a vehicle to a destination point.
   */
  public static Cursor getDragVehicleCursor() {
    return DRAG_VEHICLE_CURSOR;
  }

  private static Cursor createDragVehicleCursor() {
    // Load an image for the vehicle drag cursor.
    BufferedImage bi = new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB);
    bi.createGraphics().drawImage(
        new ImageIcon(
            Cursors.class.getClassLoader().getResource(
                "org/opentcs/guing/res/symbols/toolbar/create-order.22.png"
            )
        ).getImage(),
        0,
        0,
        null
    );
    return Toolkit.getDefaultToolkit().createCustomCursor(bi, new Point(0, 0), "toCursor");
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy