diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..21b4487f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Project exclude paths +/out/ \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..73f69e09 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/artifacts/kyanite_jar.xml b/.idea/artifacts/kyanite_jar.xml new file mode 100644 index 00000000..cd4eaca5 --- /dev/null +++ b/.idea/artifacts/kyanite_jar.xml @@ -0,0 +1,15 @@ + + + $PROJECT_DIR$/out/artifacts/kyanite_jar + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/description.html b/.idea/description.html new file mode 100644 index 00000000..db5f1295 --- /dev/null +++ b/.idea/description.html @@ -0,0 +1 @@ +Simple Java application that includes a class with main() method \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 00000000..97626ba4 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/jackson.xml b/.idea/libraries/jackson.xml new file mode 100644 index 00000000..bf39d550 --- /dev/null +++ b/.idea/libraries/jackson.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/jsfml.xml b/.idea/libraries/jsfml.xml new file mode 100644 index 00000000..fd2d36c5 --- /dev/null +++ b/.idea/libraries/jsfml.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..f07a036c --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..9c81de2c --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/project-template.xml b/.idea/project-template.xml new file mode 100644 index 00000000..1f08b887 --- /dev/null +++ b/.idea/project-template.xml @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 00000000..e96534fb --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/changelog.txt b/changelog.txt new file mode 100644 index 00000000..a1d3a2cd --- /dev/null +++ b/changelog.txt @@ -0,0 +1,36 @@ +October 28th, 2021 +[1.5.3] +- Added a method for extracting an InputStream from assets located in the source root directory +- Failed attempt to load a native Asset now raises a critical error and exits the program instread of causing it to stop responding + +October 26th, 2021 +[1.5.2] +- Added icon asset type +- Added native window icon management +- Assets can now be constructed with an InputStream +- Fixed binding from a JSON object to the Dictionary class object during DataAsset conversion + +October 25th, 2021 +[1.5.1] +- Fixed the Dictionary class visibility + +October 24th, 2021 +[1.5] +- Added a JSON data asset type +- Added an animated entity interface +- Added a method for testing and calculating intersection with another GlobalBounds +- Added a method for calculating the direction vector between two points +- Added a method for calculating the moving circle vs fixed rectangle collision direction vector +- Added native support for window background texture +- The getDeltaTime method has been moved to the Scene class +- Enabling vertical synchronization is now done by calling the framerate limit setter with Window.Framerate.VSYNC argument +- The GlobalBounds class is no longer a record class, which means that its fields are called without parentheses + +October 21st, 2021 +[1.4.1] +- Added support for changing the sound pitch and volume +- GlobalBounds objects can now be tested for containing a certain point + +October 20th, 2021 +[1.4] +- First public release \ No newline at end of file diff --git a/doc/allclasses-index.html b/doc/allclasses-index.html new file mode 100644 index 00000000..77542473 --- /dev/null +++ b/doc/allclasses-index.html @@ -0,0 +1,159 @@ + + + + +All Classes and Interfaces + + + + + + + + + + + + + + + +
+ +
+
+
+

All Classes and Interfaces

+
+
+
+
+
+
Class
+
Description
+ +
+
An external asset.
+
+ +
+
Indicates that the annotated String is an asset identifier.
+
+ +
+
Provides a handy assets storage.
+
+ +
+
Provides functionality for time measurement.
+
+ +
 
+ +
+
An entity consisting of many components.
+
+ +
+
If the application is running on macOS, it must be started with the -XstartOnFirstThread JVM option.
+
+ +
 
+ +
 
+ +
+
A wrapper class for JSFML Font objects, representing a font face asset.
+
+ +
+
Provides a set of references to the basic objects used by the game.
+
+ +
 
+ +
 
+ +
 
+ +
 
+ +
 
+ +
 
+ +
 
+ +
 
+ +
 
+ +
 
+ +
 
+ +
 
+ +
+
An alias type for an ArrayList of Drawables.
+
+ +
+
A wrapper class for JSFML Sound objects, representing a sound asset.
+
+ +
+
Represents a graphical text that can be transformed and drawn to a render target.
+
+ +
+
Values for the alignment mode.
+
+ +
 
+ +
+
A wrapper class for JSFML Texture objects, representing a texture asset.
+
+ +
+
Provides a window that can serve as a target for 2D drawing.
+
+
+
+
+
+
+
+ + diff --git a/doc/allpackages-index.html b/doc/allpackages-index.html new file mode 100644 index 00000000..f42140ec --- /dev/null +++ b/doc/allpackages-index.html @@ -0,0 +1,89 @@ + + + + +All Packages + + + + + + + + + + + + + + + +
+ +
+
+
+

All Packages

+
+
Package Summary
+
+
Package
+
Description
+ +
+
Contains classes related to the game content.
+
+ +
+
Contains classes related to assets, which are loaded from external sources.
+
+ +
 
+ +
 
+ +
+
Contains classes that provide core functionality, common data types and exceptions.
+
+ +
 
+ +
+
Contains classes related to graphic interface
+
+ +
+
Contains classes representing window events and event listeners.
+
+
+
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/game/GameContext.html b/doc/com/rubynaxela/kyanite/game/GameContext.html new file mode 100644 index 00000000..3ed7f293 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/game/GameContext.html @@ -0,0 +1,189 @@ + + + + +GameContext + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class GameContext

+
+
java.lang.Object +
com.rubynaxela.kyanite.game.GameContext
+
+
+
+
public final class GameContext +extends Object
+
Provides a set of references to the basic objects used by the game. The instance of this class can be accessed via the + getInstance() method. Only one GameContext instance can exist in a single game instance.
+
+
+ +
+
+
    + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      getInstance

      +
      public static GameContext getInstance()
      +
      +
      Returns:
      +
      reference to the instance of the bundle
      +
      +
      +
    • +
    • +
      +

      getWindow

      +
      public Window getWindow()
      +
      +
      Returns:
      +
      reference to the game window
      +
      +
      +
    • +
    • +
      +

      getAssetsBundle

      +
      public AssetsBundle getAssetsBundle()
      +
      +
      Returns:
      +
      reference to the game assets bundle
      +
      +
      +
    • +
    • +
      +

      getClock

      +
      public Clock getClock()
      +
      +
      Returns:
      +
      reference to the game clock
      +
      +
      +
    • +
    • +
      +

      startGame

      +
      public void startGame()
      +
      Starts the game clock and the window loop
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/game/assets/Asset.html b/doc/com/rubynaxela/kyanite/game/assets/Asset.html new file mode 100644 index 00000000..a7affff2 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/game/assets/Asset.html @@ -0,0 +1,87 @@ + + + + +Asset + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Interface Asset

+
+
+
+
All Known Implementing Classes:
+
FontFace, Sound, Texture
+
+
+
public interface Asset
+
An external asset. This tagging interface groups assets allowing them to be stored + in an AssetsBundle. Kyanite provides several basic types of assets, but the + programmer should feel free to implement this interface in their own asset types.
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/game/assets/AssetsBundle.html b/doc/com/rubynaxela/kyanite/game/assets/AssetsBundle.html new file mode 100644 index 00000000..e3ab1765 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/game/assets/AssetsBundle.html @@ -0,0 +1,192 @@ + + + + +AssetsBundle + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class AssetsBundle

+
+
java.lang.Object +
com.rubynaxela.kyanite.game.assets.AssetsBundle
+
+
+
+
public final class AssetsBundle +extends Object
+
Provides a handy assets storage. Assets are registered and retrieved with String identifiers. An identifier can be + any text, however it is good to keep the identifiers organized, compliant with a consistent convention. For example, + kyanite:texture.flowers.purple makes up a good identifier, however txt_flower_13 does not.
+
+
+ +
+
+
    + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      AssetsBundle

      +
      public AssetsBundle()
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      register

      +
      public <T extends Asset> void register(@AssetId + String id, + T asset)
      +
      Registers an Asset in the bundle.
      +
      +
      Parameters:
      +
      id - the identifier of this asset
      +
      asset - the asset to be stored
      +
      +
      +
    • +
    • +
      +

      get

      +
      public <T extends Asset> T get(@AssetId + String id)
      +
      Finds an Asset by its identifier.
      +
      +
      Parameters:
      +
      id - the identifier of this asset
      +
      Returns:
      +
      an Asset object
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/game/assets/FontFace.html b/doc/com/rubynaxela/kyanite/game/assets/FontFace.html new file mode 100644 index 00000000..b1b7f8bd --- /dev/null +++ b/doc/com/rubynaxela/kyanite/game/assets/FontFace.html @@ -0,0 +1,210 @@ + + + + +FontFace + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class FontFace

+
+
java.lang.Object +
com.rubynaxela.kyanite.game.assets.FontFace
+
+
+
+
All Implemented Interfaces:
+
Asset
+
+
+
public class FontFace +extends Object +implements Asset
+
A wrapper class for JSFML Font objects, representing a font face asset. The source must be the path + to an font file. Supported formats are: TrueType, Type 1, CFF, OpenType, SFNT, X11 PCF, Windows FNT, BDF, PFR and Type 42.
+
+
+
    + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    +
    FontFace(File file)
    +
    +
    Creates a new font from the source font file.
    +
    + +
    +
    Creates a new font from the source given by the path.
    +
    +
    FontFace(Path path)
    +
    +
    Creates a new font from the source given by the path.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    void
    +
    apply(org.jsfml.graphics.Text text)
    +
    +
    Applies this font on the Text.
    +
    +
    +
    +
    +
    +

    Methods inherited from class java.lang.Object

    +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      FontFace

      +
      public FontFace(Path path)
      +
      Creates a new font from the source given by the path.
      +
      +
      Parameters:
      +
      path - path of the data source
      +
      +
      +
    • +
    • +
      +

      FontFace

      +
      public FontFace(String path)
      +
      Creates a new font from the source given by the path.
      +
      +
      Parameters:
      +
      path - path of the data source
      +
      +
      +
    • +
    • +
      +

      FontFace

      +
      public FontFace(File file)
      +
      Creates a new font from the source font file.
      +
      +
      Parameters:
      +
      file - the data source file
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      apply

      +
      public void apply(org.jsfml.graphics.Text text)
      +
      Applies this font on the Text.
      +
      +
      Parameters:
      +
      text - a Text to apply this font on
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/game/assets/Sound.html b/doc/com/rubynaxela/kyanite/game/assets/Sound.html new file mode 100644 index 00000000..dd5fa592 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/game/assets/Sound.html @@ -0,0 +1,255 @@ + + + + +Sound + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class Sound

+
+
java.lang.Object +
com.rubynaxela.kyanite.game.assets.Sound
+
+
+
+
All Implemented Interfaces:
+
Asset
+
+
+
public class Sound +extends Object +implements Asset
+
A wrapper class for JSFML Sound objects, representing a sound asset. + The source must be the path to an audio file. Supported formats are: WAV, OGG/Vorbis and FLAC.
+
+
+
    + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    +
    Sound(File file)
    +
    +
    Creates a new sound from the source sound file.
    +
    +
    Sound(String path)
    +
    +
    Creates a new sound from the source given by the path.
    +
    +
    Sound(Path path)
    +
    +
    Creates a new sound from the source given by the path.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    void
    + +
    +
    Pauses the sound if it is currently playing.
    +
    +
    void
    + +
    +
    Starts playing the sound or resumes it if it is currently paused.
    +
    +
    void
    +
    setLooping(boolean looping)
    +
     
    +
    void
    +
    setSkip(org.jsfml.system.Time time)
    +
    +
    Sets the playing offset from where to play the underlying audio data.
    +
    +
    void
    + +
    +
    Stops the sound if it is currently playing or paused.
    +
    +
    +
    +
    +
    +

    Methods inherited from class java.lang.Object

    +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Sound

      +
      public Sound(Path path)
      +
      Creates a new sound from the source given by the path.
      +
      +
      Parameters:
      +
      path - path of the data source
      +
      +
      +
    • +
    • +
      +

      Sound

      +
      public Sound(String path)
      +
      Creates a new sound from the source given by the path.
      +
      +
      Parameters:
      +
      path - path of the data source
      +
      +
      +
    • +
    • +
      +

      Sound

      +
      public Sound(File file)
      +
      Creates a new sound from the source sound file.
      +
      +
      Parameters:
      +
      file - the data audio file
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      play

      +
      public void play()
      +
      Starts playing the sound or resumes it if it is currently paused.
      +
      +
    • +
    • +
      +

      pause

      +
      public void pause()
      +
      Pauses the sound if it is currently playing.
      +
      +
    • +
    • +
      +

      stop

      +
      public void stop()
      +
      Stops the sound if it is currently playing or paused.
      +
      +
    • +
    • +
      +

      setLooping

      +
      public void setLooping(boolean looping)
      +
      +
    • +
    • +
      +

      setSkip

      +
      public void setSkip(org.jsfml.system.Time time)
      +
      Sets the playing offset from where to play the underlying audio data.
      +
      +
      Parameters:
      +
      time - the playing offset in the underlaying audio data.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/game/assets/Texture.html b/doc/com/rubynaxela/kyanite/game/assets/Texture.html new file mode 100644 index 00000000..8d621218 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/game/assets/Texture.html @@ -0,0 +1,284 @@ + + + + +Texture + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class Texture

+
+
java.lang.Object +
com.rubynaxela.kyanite.game.assets.Texture
+
+
+
+
All Implemented Interfaces:
+
Asset
+
+
+
public class Texture +extends Object +implements Asset
+
A wrapper class for JSFML Texture objects, representing a texture asset. + The source must be the path to an image file. Supported formats are: BMP, DDS, JPEG, PNG, TGA and PSD.
+
+
+
    + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    +
    Texture(File file)
    +
    +
    Creates a new texture from the source image file.
    +
    + +
    +
    Creates a new texture from the source given by the path.
    +
    +
    Texture(Path path)
    +
    +
    Creates a new texture from the source given by the path.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    void
    +
    apply(org.jsfml.graphics.Shape shape)
    +
    +
    Applies this texture on the Shape without affecting the texture rectangle.
    +
    +
    void
    +
    apply(org.jsfml.graphics.Sprite sprite)
    +
    +
    Applies this texture on the Sprite without affecting the texture rectangle.
    +
    +
    boolean
    + +
     
    +
    boolean
    + +
     
    +
    void
    +
    setSmooth(boolean smooth)
    +
    +
    Enables or disables the smooth filter.
    +
    +
    void
    +
    setTileable(boolean tileable)
    +
    +
    Enables or disables texture repeating.
    +
    +
    +
    +
    +
    +

    Methods inherited from class java.lang.Object

    +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Texture

      +
      public Texture(Path path)
      +
      Creates a new texture from the source given by the path.
      +
      +
      Parameters:
      +
      path - path of the data source
      +
      +
      +
    • +
    • +
      +

      Texture

      +
      public Texture(String path)
      +
      Creates a new texture from the source given by the path.
      +
      +
      Parameters:
      +
      path - path of the data source
      +
      +
      +
    • +
    • +
      +

      Texture

      +
      public Texture(File file)
      +
      Creates a new texture from the source image file.
      +
      +
      Parameters:
      +
      file - the data source file
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      apply

      +
      public void apply(org.jsfml.graphics.Shape shape)
      +
      Applies this texture on the Shape without affecting the texture rectangle.
      +
      +
      Parameters:
      +
      shape - the Shape to apply this texture on
      +
      +
      +
    • +
    • +
      +

      apply

      +
      public void apply(org.jsfml.graphics.Sprite sprite)
      +
      Applies this texture on the Sprite without affecting the texture rectangle.
      +
      +
      Parameters:
      +
      sprite - the Sprite to apply this texture on
      +
      +
      +
    • +
    • +
      +

      isTileable

      +
      public boolean isTileable()
      +
      +
      Returns:
      +
      whether texture repeating is enabled for this texture
      +
      +
      +
    • +
    • +
      +

      setTileable

      +
      public void setTileable(boolean tileable)
      +
      Enables or disables texture repeating. Texture repeating is disabled by default.
      +
      +
      Parameters:
      +
      tileable - true to enable, false to disable
      +
      +
      +
    • +
    • +
      +

      isSmooth

      +
      public boolean isSmooth()
      +
      +
      Returns:
      +
      whether texture smooth filter is enabled for this texture
      +
      +
      +
    • +
    • +
      +

      setSmooth

      +
      public void setSmooth(boolean smooth)
      +
      Enables or disables the smooth filter. The smooth filter is disabled by default.
      +
      +
      Parameters:
      +
      smooth - true to enable, false to disable
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/game/assets/package-summary.html b/doc/com/rubynaxela/kyanite/game/assets/package-summary.html new file mode 100644 index 00000000..e97df686 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/game/assets/package-summary.html @@ -0,0 +1,127 @@ + + + + +com.rubynaxela.kyanite.game.assets + + + + + + + + + + + + + + + +
+ +
+
+
+

Package com.rubynaxela.kyanite.game.assets

+
+
+
package com.rubynaxela.kyanite.game.assets
+
+
Contains classes related to assets, which are loaded from external sources.
+
+
+ +
+
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/game/assets/package-tree.html b/doc/com/rubynaxela/kyanite/game/assets/package-tree.html new file mode 100644 index 00000000..991e49d6 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/game/assets/package-tree.html @@ -0,0 +1,81 @@ + + + + +com.rubynaxela.kyanite.game.assets Class Hierarchy + + + + + + + + + + + + + + + +
+ +
+
+
+

Hierarchy For Package com.rubynaxela.kyanite.game.assets

+Package Hierarchies: + +
+
+

Class Hierarchy

+
    +
  • java.lang.Object +
      +
    • com.rubynaxela.kyanite.game.assets.AssetsBundle
    • +
    • com.rubynaxela.kyanite.game.assets.FontFace (implements com.rubynaxela.kyanite.game.assets.Asset)
    • +
    • com.rubynaxela.kyanite.game.assets.Sound (implements com.rubynaxela.kyanite.game.assets.Asset)
    • +
    • com.rubynaxela.kyanite.game.assets.Texture (implements com.rubynaxela.kyanite.game.assets.Asset)
    • +
    +
  • +
+
+
+

Interface Hierarchy

+
    +
  • com.rubynaxela.kyanite.game.assets.Asset
  • +
+
+
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/game/entities/CompoundEntity.html b/doc/com/rubynaxela/kyanite/game/entities/CompoundEntity.html new file mode 100644 index 00000000..d260597f --- /dev/null +++ b/doc/com/rubynaxela/kyanite/game/entities/CompoundEntity.html @@ -0,0 +1,558 @@ + + + + +CompoundEntity + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class CompoundEntity

+
+
java.lang.Object +
com.rubynaxela.kyanite.game.entities.CompoundEntity
+
+
+
+
All Implemented Interfaces:
+
org.jsfml.graphics.Drawable, org.jsfml.graphics.Transformable
+
+
+
public class CompoundEntity +extends Object +implements org.jsfml.graphics.Transformable, org.jsfml.graphics.Drawable
+
An entity consisting of many components. A CompoundEntity can be drawn to a render target, + as well as positioned in the scene, rotated and scaled around an origin. This class can be used, + for instance, to create complex structures out of primitive shapes or to compose spannable texts.
+
+
+
    + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    + +
    +
    Creates an empty compound entity.
    +
    +
    CompoundEntity(@NotNull org.jsfml.system.Vector2f position)
    +
    +
    Creates an empty compound entity with initial position.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    void
    +
    add(@NotNull Object object, + @NotNull org.jsfml.system.Vector2f relativePosition)
    +
    +
    Adds an object and puts it on its relative position.
    +
    +
    void
    +
    draw(@NotNull org.jsfml.graphics.RenderTarget target, + @NotNull org.jsfml.graphics.RenderStates states)
    +
    +
    Draws a drawable object to the render target using the given render states.
    +
    +
    org.jsfml.graphics.FloatRect
    + +
     
    +
    org.jsfml.graphics.Transform
    + +
     
    +
    org.jsfml.system.Vector2f
    + +
     
    +
    org.jsfml.system.Vector2f
    + +
     
    +
    float
    + +
     
    +
    org.jsfml.system.Vector2f
    + +
     
    +
    org.jsfml.graphics.Transform
    + +
     
    +
    void
    +
    move(float x, + float y)
    +
    +
    Moves this object.
    +
    +
    void
    +
    move(@NotNull org.jsfml.system.Vector2f offset)
    +
    +
    Moves the object.
    +
    +
    void
    +
    rotate(float angle)
    +
    +
    Rotates this object around its origin.
    +
    +
    void
    +
    scale(float x, + float y)
    +
    +
    Scales the object, using its origin as the scaling center.
    +
    +
    void
    +
    scale(@NotNull org.jsfml.system.Vector2f factors)
    +
    +
    Scales the object, using its origin as the scaling center.
    +
    +
    void
    +
    setOrigin(float x, + float y)
    +
    +
    Sets the rotation, scaling and drawing origin of this object.
    +
    +
    void
    +
    setOrigin(@NotNull org.jsfml.system.Vector2f origin)
    +
    +
    Sets the rotation, scaling and drawing origin of this object.
    +
    +
    void
    +
    setPosition(float x, + float y)
    +
    +
    Sets the position of this object in the scene so that its origin will be exactly on it.
    +
    +
    void
    +
    setPosition(@NotNull org.jsfml.system.Vector2f position)
    +
    +
    Sets the position of this object in the scene so that its origin will be exactly on it.
    +
    +
    void
    +
    setRotation(float angle)
    +
    +
    Sets the rotation of this object around its origin.
    +
    +
    void
    +
    setScale(float x, + float y)
    +
    +
    Sets the scaling of this object, using its origin as the scaling center.
    +
    +
    void
    +
    setScale(@NotNull org.jsfml.system.Vector2f factors)
    +
    +
    Sets the scaling of this object, using its origin as the scaling center.
    +
    +
    +
    +
    +
    +

    Methods inherited from class java.lang.Object

    +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      CompoundEntity

      +
      public CompoundEntity()
      +
      Creates an empty compound entity.
      +
      +
    • +
    • +
      +

      CompoundEntity

      +
      public CompoundEntity(@NotNull + @NotNull org.jsfml.system.Vector2f position)
      +
      Creates an empty compound entity with initial position.
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      add

      +
      public void add(@NotNull + @NotNull Object object, + @NotNull + @NotNull org.jsfml.system.Vector2f relativePosition)
      +
      Adds an object and puts it on its relative position.
      +
      +
      Parameters:
      +
      object - an object of a class that implements both Transformable and Drawable interfaces
      +
      relativePosition - the object's position relative to the top-left corner of this compound entity
      +
      +
      +
    • +
    • +
      +

      getGlobalBounds

      +
      public org.jsfml.graphics.FloatRect getGlobalBounds()
      +
      +
      Returns:
      +
      the object's global bounding rectangle in the scene, taking the object's transformation into account
      +
      +
      +
    • +
    • +
      +

      draw

      +
      public void draw(@NotNull + @NotNull org.jsfml.graphics.RenderTarget target, + @NotNull + @NotNull org.jsfml.graphics.RenderStates states)
      +
      Draws a drawable object to the render target using the given render states.
      +
      +
      Specified by:
      +
      draw in interface org.jsfml.graphics.Drawable
      +
      Parameters:
      +
      target - the object to draw
      +
      states - the render states to use for drawing
      +
      +
      +
    • +
    • +
      +

      setPosition

      +
      public void setPosition(float x, + float y)
      +
      Sets the position of this object in the scene so that its origin will be exactly on it.
      +
      +
      Specified by:
      +
      setPosition in interface org.jsfml.graphics.Transformable
      +
      Parameters:
      +
      x - the new X coordinate.
      +
      y - the new Y coordinate.
      +
      +
      +
    • +
    • +
      +

      setPosition

      +
      public void setPosition(@NotNull + @NotNull org.jsfml.system.Vector2f position)
      +
      Sets the position of this object in the scene so that its origin will be exactly on it.
      +
      +
      Specified by:
      +
      setPosition in interface org.jsfml.graphics.Transformable
      +
      Parameters:
      +
      position - the new position of this object
      +
      +
      +
    • +
    • +
      +

      setRotation

      +
      public void setRotation(float angle)
      +
      Sets the rotation of this object around its origin.
      +
      +
      Specified by:
      +
      setRotation in interface org.jsfml.graphics.Transformable
      +
      Parameters:
      +
      angle - the new rotation angle in degrees
      +
      +
      +
    • +
    • +
      +

      setScale

      +
      public void setScale(float x, + float y)
      +
      Sets the scaling of this object, using its origin as the scaling center.
      +
      +
      Specified by:
      +
      setScale in interface org.jsfml.graphics.Transformable
      +
      Parameters:
      +
      x - the new X scaling factor
      +
      y - the new Y scaling factor
      +
      +
      +
    • +
    • +
      +

      setScale

      +
      public void setScale(@NotNull + @NotNull org.jsfml.system.Vector2f factors)
      +
      Sets the scaling of this object, using its origin as the scaling center.
      +
      +
      Specified by:
      +
      setScale in interface org.jsfml.graphics.Transformable
      +
      Parameters:
      +
      factors - the new scaling factors
      +
      +
      +
    • +
    • +
      +

      setOrigin

      +
      public void setOrigin(float x, + float y)
      +
      Sets the rotation, scaling and drawing origin of this object.
      +
      +
      Specified by:
      +
      setOrigin in interface org.jsfml.graphics.Transformable
      +
      Parameters:
      +
      x - the new X coordinate of the origin
      +
      y - the new Y coordinate of the origin
      +
      +
      +
    • +
    • +
      +

      setOrigin

      +
      public void setOrigin(@NotNull + @NotNull org.jsfml.system.Vector2f origin)
      +
      Sets the rotation, scaling and drawing origin of this object.
      +
      +
      Specified by:
      +
      setOrigin in interface org.jsfml.graphics.Transformable
      +
      Parameters:
      +
      origin - the new origin
      +
      +
      +
    • +
    • +
      +

      getPosition

      +
      public org.jsfml.system.Vector2f getPosition()
      +
      +
      Specified by:
      +
      getPosition in interface org.jsfml.graphics.Transformable
      +
      Returns:
      +
      the position of this object
      +
      +
      +
    • +
    • +
      +

      getRotation

      +
      public float getRotation()
      +
      +
      Specified by:
      +
      getRotation in interface org.jsfml.graphics.Transformable
      +
      Returns:
      +
      the current rotation angle of this object in degrees
      +
      +
      +
    • +
    • +
      +

      getScale

      +
      public org.jsfml.system.Vector2f getScale()
      +
      +
      Specified by:
      +
      getScale in interface org.jsfml.graphics.Transformable
      +
      Returns:
      +
      the current scaling factors of this object
      +
      +
      +
    • +
    • +
      +

      getOrigin

      +
      public org.jsfml.system.Vector2f getOrigin()
      +
      +
      Specified by:
      +
      getOrigin in interface org.jsfml.graphics.Transformable
      +
      Returns:
      +
      the current origin of this object
      +
      +
      +
    • +
    • +
      +

      move

      +
      public void move(float x, + float y)
      +
      Moves this object.
      +
      +
      Specified by:
      +
      move in interface org.jsfml.graphics.Transformable
      +
      Parameters:
      +
      x - the X offset added to the current position
      +
      y - the Y offset added to the current position
      +
      +
      +
    • +
    • +
      +

      move

      +
      public void move(@NotNull + @NotNull org.jsfml.system.Vector2f offset)
      +
      Moves the object.
      +
      +
      Specified by:
      +
      move in interface org.jsfml.graphics.Transformable
      +
      Parameters:
      +
      offset - the offset vector added to the current position
      +
      +
      +
    • +
    • +
      +

      rotate

      +
      public void rotate(float angle)
      +
      Rotates this object around its origin.
      +
      +
      Specified by:
      +
      rotate in interface org.jsfml.graphics.Transformable
      +
      Parameters:
      +
      angle - the rotation angle in degrees
      +
      +
      +
    • +
    • +
      +

      scale

      +
      public void scale(float x, + float y)
      +
      Scales the object, using its origin as the scaling center. Given + scaling factors are multiplied by the current factors of this object.
      +
      +
      Specified by:
      +
      scale in interface org.jsfml.graphics.Transformable
      +
      Parameters:
      +
      x - the X scaling factor
      +
      y - the Y scaling factor
      +
      +
      +
    • +
    • +
      +

      scale

      +
      public void scale(@NotNull + @NotNull org.jsfml.system.Vector2f factors)
      +
      Scales the object, using its origin as the scaling center. Given + scaling factors are multiplied by the current factors of this object.
      +
      +
      Specified by:
      +
      scale in interface org.jsfml.graphics.Transformable
      +
      Parameters:
      +
      factors - the scaling factors
      +
      +
      +
    • +
    • +
      +

      getTransform

      +
      public org.jsfml.graphics.Transform getTransform()
      +
      +
      Specified by:
      +
      getTransform in interface org.jsfml.graphics.Transformable
      +
      Returns:
      +
      the current transformation matrix of this object
      +
      +
      +
    • +
    • +
      +

      getInverseTransform

      +
      public org.jsfml.graphics.Transform getInverseTransform()
      +
      +
      Specified by:
      +
      getInverseTransform in interface org.jsfml.graphics.Transformable
      +
      Returns:
      +
      the inverse of the current transformation matrix of this object
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/game/entities/HitBox.html b/doc/com/rubynaxela/kyanite/game/entities/HitBox.html new file mode 100644 index 00000000..5b1d4b22 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/game/entities/HitBox.html @@ -0,0 +1,309 @@ + + + + +HitBox + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Record Class HitBox

+
+
java.lang.Object +
java.lang.Record +
com.rubynaxela.kyanite.game.entities.GlobalBounds
+
+
+
+
+
public record HitBox(float top, float right, float bottom, float left) +extends Record
+
+
+
    + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    +
    HitBox(float top, + float right, + float bottom, + float left)
    +
    +
    Creates an instance of a HitBox record class.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    float
    + +
    +
    Returns the value of the bottom record component.
    +
    +
    final boolean
    + +
    +
    Indicates whether some other object is "equal to" this one.
    +
    +
    static HitBox
    +
    from(@NotNull org.jsfml.graphics.FloatRect boundingBox)
    +
     
    +
    final int
    + +
    +
    Returns a hash code value for this object.
    +
    +
    float
    + +
    +
    Returns the value of the left record component.
    +
    +
    float
    + +
    +
    Returns the value of the right record component.
    +
    +
    org.jsfml.graphics.FloatRect
    + +
     
    +
    float
    +
    top()
    +
    +
    Returns the value of the top record component.
    +
    + + +
    +
    Returns a string representation of this record class.
    +
    +
    +
    +
    +
    +

    Methods inherited from class java.lang.Object

    +clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      HitBox

      +
      public HitBox(float top, + float right, + float bottom, + float left)
      +
      Creates an instance of a HitBox record class.
      +
      +
      Parameters:
      +
      top - the value for the top record component
      +
      right - the value for the right record component
      +
      bottom - the value for the bottom record component
      +
      left - the value for the left record component
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      from

      +
      @Contract(pure=true, + value="_ -> new") +public static HitBox from(@NotNull + @NotNull org.jsfml.graphics.FloatRect boundingBox)
      +
      +
    • +
    • +
      +

      toFloatRect

      +
      public org.jsfml.graphics.FloatRect toFloatRect()
      +
      +
    • +
    • +
      +

      toString

      +
      public String toString()
      +
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      +
      +
      Specified by:
      +
      toString in class Record
      +
      Returns:
      +
      a string representation of this object
      +
      +
      +
    • +
    • +
      +

      hashCode

      +
      public final int hashCode()
      +
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      +
      +
      Specified by:
      +
      hashCode in class Record
      +
      Returns:
      +
      a hash code value for this object
      +
      +
      +
    • +
    • +
      +

      equals

      +
      public final boolean equals(Object o)
      +
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      +
      +
      Specified by:
      +
      equals in class Record
      +
      Parameters:
      +
      o - the object with which to compare
      +
      Returns:
      +
      true if this object is the same as the o argument; false otherwise.
      +
      +
      +
    • +
    • +
      +

      top

      +
      public float top()
      +
      Returns the value of the top record component.
      +
      +
      Returns:
      +
      the value of the top record component
      +
      +
      +
    • +
    • +
      +

      right

      +
      public float right()
      +
      Returns the value of the right record component.
      +
      +
      Returns:
      +
      the value of the right record component
      +
      +
      +
    • +
    • +
      +

      bottom

      +
      public float bottom()
      +
      Returns the value of the bottom record component.
      +
      +
      Returns:
      +
      the value of the bottom record component
      +
      +
      +
    • +
    • +
      +

      left

      +
      public float left()
      +
      Returns the value of the left record component.
      +
      +
      Returns:
      +
      the value of the left record component
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/game/entities/package-summary.html b/doc/com/rubynaxela/kyanite/game/entities/package-summary.html new file mode 100644 index 00000000..b25aa0f4 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/game/entities/package-summary.html @@ -0,0 +1,112 @@ + + + + +com.rubynaxela.kyanite.game.entities + + + + + + + + + + + + + + + +
+ +
+
+
+

Package com.rubynaxela.kyanite.game.entities

+
+
+
package com.rubynaxela.kyanite.game.entities
+
+ +
+
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/game/entities/package-tree.html b/doc/com/rubynaxela/kyanite/game/entities/package-tree.html new file mode 100644 index 00000000..4f661eaf --- /dev/null +++ b/doc/com/rubynaxela/kyanite/game/entities/package-tree.html @@ -0,0 +1,77 @@ + + + + +com.rubynaxela.kyanite.game.entities Class Hierarchy + + + + + + + + + + + + + + + +
+ +
+
+
+

Hierarchy For Package com.rubynaxela.kyanite.game.entities

+Package Hierarchies: + +
+
+

Class Hierarchy

+
    +
  • java.lang.Object +
      +
    • com.rubynaxela.kyanite.game.entities.CompoundEntity (implements org.jsfml.graphics.Drawable, org.jsfml.graphics.Transformable)
    • +
    • java.lang.Record +
        +
      • com.rubynaxela.kyanite.game.entities.HitBox
      • +
      +
    • +
    +
  • +
+
+
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/game/gui/Font.html b/doc/com/rubynaxela/kyanite/game/gui/Font.html new file mode 100644 index 00000000..2b20f08f --- /dev/null +++ b/doc/com/rubynaxela/kyanite/game/gui/Font.html @@ -0,0 +1,239 @@ + + + + +Font + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class Font

+
+
java.lang.Object +
com.rubynaxela.kyanite.game.gui.Font
+
+
+
+
public class Font +extends Object
+
+
+ +
+
+
    + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Font

      +
      public Font(@NotNull + @NotNull FontFace fontFace, + int size, + int style)
      +
      Creates a new font.
      +
      +
      Parameters:
      +
      fontFace - the font face
      +
      size - the character size
      +
      style - the font style
      +
      +
      +
    • +
    • +
      +

      Font

      +
      public Font(@NotNull + @NotNull FontFace fontFace, + int size)
      +
      Creates a new font with default style.
      +
      +
      Parameters:
      +
      fontFace - the font face
      +
      size - the character size
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      getFontFace

      +
      public FontFace getFontFace()
      +
      +
      Returns:
      +
      the font face
      +
      +
      +
    • +
    • +
      +

      getSize

      +
      public int getSize()
      +
      +
      Returns:
      +
      the character size of this font
      +
      +
      +
    • +
    • +
      +

      getStyle

      +
      public int getStyle()
      +
      +
      Returns:
      +
      the style of this font
      +
      +
      +
    • +
    • +
      +

      apply

      +
      public void apply(@NotNull + @NotNull org.jsfml.graphics.Text text)
      +
      Applies this font on a Text object.
      +
      +
      Parameters:
      +
      text - the Text object to apply this font on
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/game/gui/Text.Alignment.html b/doc/com/rubynaxela/kyanite/game/gui/Text.Alignment.html new file mode 100644 index 00000000..c4c8c6ec --- /dev/null +++ b/doc/com/rubynaxela/kyanite/game/gui/Text.Alignment.html @@ -0,0 +1,288 @@ + + + + +Text.Alignment + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Enum Class Text.Alignment

+
+
java.lang.Object +
java.lang.Enum<Text.Alignment> +
com.rubynaxela.kyanite.game.gui.Text.Alignment
+
+
+
+
+
All Implemented Interfaces:
+
Serializable, Comparable<Text.Alignment>, Constable
+
+
+
Enclosing class:
+
Text
+
+
+
public static enum Text.Alignment +extends Enum<Text.Alignment>
+
Values for the alignment mode. The first word of the name indicates vertical alignment and the second + word indicates horizontal alignment. The CENTER value indicates centering on both axes.
+
+
See Also:
+
+ +
+
+
+
+ +
+
+
    + +
  • +
    +

    Enum Constant Details

    + +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      values

      +
      public static Text.Alignment[] values()
      +
      Returns an array containing the constants of this enum class, in +the order they are declared.
      +
      +
      Returns:
      +
      an array containing the constants of this enum class, in the order they are declared
      +
      +
      +
    • +
    • +
      +

      valueOf

      +
      public static Text.Alignment valueOf(String name)
      +
      Returns the enum constant of this class with the specified name. +The string must match exactly an identifier used to declare an +enum constant in this class. (Extraneous whitespace characters are +not permitted.)
      +
      +
      Parameters:
      +
      name - the name of the enum constant to be returned.
      +
      Returns:
      +
      the enum constant with the specified name
      +
      Throws:
      +
      IllegalArgumentException - if this enum class has no constant with the specified name
      +
      NullPointerException - if the argument is null
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/game/gui/Text.html b/doc/com/rubynaxela/kyanite/game/gui/Text.html new file mode 100644 index 00000000..bb39ce10 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/game/gui/Text.html @@ -0,0 +1,524 @@ + + + + +Text + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class Text

+
+
java.lang.Object +
org.jsfml.internal.SFMLNativeObject +
org.jsfml.graphics.Text +
com.rubynaxela.kyanite.game.gui.Text
+
+
+
+
+
+
All Implemented Interfaces:
+
org.jsfml.graphics.Drawable, org.jsfml.graphics.TextStyle, org.jsfml.graphics.Transformable
+
+
+
public class Text +extends org.jsfml.graphics.Text
+
Represents a graphical text that can be transformed and drawn to a render target.
+
+
+
    + +
  • +
    +

    Nested Class Summary

    +
    Nested Classes
    +
    +
    Modifier and Type
    +
    Class
    +
    Description
    +
    static enum 
    + +
    +
    Values for the alignment mode.
    +
    +
    +
    +
  • + +
  • +
    +

    Field Summary

    +
    +

    Fields inherited from interface org.jsfml.graphics.TextStyle

    +BOLD, ITALIC, REGULAR, UNDERLINED
    +
    +
  • + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    + +
    +
    Creates a new empty text.
    +
    +
    Text(@NotNull Font font)
    +
    +
    Creates a new empty text.
    +
    +
    Text(@NotNull String text)
    +
    +
    Creates an invisible text with no font.
    +
    +
    Text(@NotNull String text, + @NotNull Font font)
    +
    +
    Creates a text.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    + + +
     
    +
    org.jsfml.graphics.Transform
    + +
     
    +
    org.jsfml.system.Vector2f
    + +
     
    +
    org.jsfml.system.Vector2f
    + +
     
    +
    float
    + +
     
    +
    org.jsfml.system.Vector2f
    + +
     
    +
    org.jsfml.graphics.Transform
    + +
     
    +
    final void
    +
    move(float arg0, + float arg1)
    +
     
    +
    final void
    +
    move(org.jsfml.system.Vector2f arg0)
    +
     
    +
    final void
    +
    rotate(float arg0)
    +
     
    +
    final void
    +
    scale(float arg0, + float arg1)
    +
     
    +
    final void
    +
    scale(org.jsfml.system.Vector2f arg0)
    +
     
    +
    void
    +
    setAlignment(@NotNull Text.Alignment alignment)
    +
    +
    Sets the alignment mode of this text.
    +
    +
    void
    +
    setFont(@NotNull Font font)
    +
    +
    Sets the font of this text.
    +
    +
    final void
    +
    setOrigin(float arg0, + float arg1)
    +
     
    +
    final void
    +
    setPosition(float arg0, + float arg1)
    +
     
    +
    final void
    +
    setScale(float arg0, + float arg1)
    +
     
    +
    void
    +
    setString(@NotNull String text)
    +
    +
    Deprecated. +
    Use the setText(java.lang.String) method instead.
    +
    +
    +
    void
    +
    setText(@NotNull String text)
    +
    +
    Sets the string to display.
    +
    +
    +
    +
    +
    +

    Methods inherited from class org.jsfml.graphics.Text

    +draw, findCharacterPos, getCharacterSize, getColor, getFont, getGlobalBounds, getLocalBounds, getString, getStyle, nativeCreate, nativeDelete, nativeSetExPtr, setCharacterSize, setColor, setFont, setOrigin, setPosition, setRotation, setScale, setStyle
    +
    +

    Methods inherited from class org.jsfml.internal.SFMLNativeObject

    +finalize
    +
    +

    Methods inherited from class java.lang.Object

    +clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Text

      +
      public Text()
      +
      Creates a new empty text.
      +
      +
    • +
    • +
      +

      Text

      +
      public Text(@NotNull + @NotNull Font font)
      +
      Creates a new empty text.
      +
      +
      Parameters:
      +
      font - the font face to use
      +
      +
      +
    • +
    • +
      +

      Text

      +
      public Text(@NotNull + @NotNull String text)
      +
      Creates an invisible text with no font.
      +
      +
      Parameters:
      +
      text - the text string
      +
      +
      +
    • +
    • +
      +

      Text

      +
      public Text(@NotNull + @NotNull String text, + @NotNull + @NotNull Font font)
      +
      Creates a text.
      +
      +
      Parameters:
      +
      text - the text string
      +
      font - the font face to use
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      setFont

      +
      public void setFont(@NotNull + @NotNull Font font)
      +
      Sets the font of this text.
      +
      +
      Parameters:
      +
      font - the new font of this text
      +
      +
      +
    • +
    • +
      +

      setString

      +
      @Deprecated +public void setString(@NotNull + @NotNull String text)
      +
      Deprecated. +
      Use the setText(java.lang.String) method instead.
      +
      +
      +
      Overrides:
      +
      setString in class org.jsfml.graphics.Text
      +
      +
      +
    • +
    • +
      +

      setText

      +
      public void setText(@NotNull + @NotNull String text)
      +
      Sets the string to display.
      +
      +
      Parameters:
      +
      text - the string to display
      +
      +
      +
    • +
    • +
      +

      getAlignment

      +
      public Text.Alignment getAlignment()
      +
      +
      Returns:
      +
      the alignment mode of this text
      +
      +
      +
    • +
    • +
      +

      setAlignment

      +
      public void setAlignment(@NotNull + @NotNull Text.Alignment alignment)
      +
      Sets the alignment mode of this text. The default value is TOP_LEFT.
      +
      +
      Parameters:
      +
      alignment - the new alignment mode of this text
      +
      +
      +
    • +
    • +
      +

      setPosition

      +
      public final void setPosition(float arg0, + float arg1)
      +
      +
      Specified by:
      +
      setPosition in interface org.jsfml.graphics.Transformable
      +
      +
      +
    • +
    • +
      +

      setScale

      +
      public final void setScale(float arg0, + float arg1)
      +
      +
      Specified by:
      +
      setScale in interface org.jsfml.graphics.Transformable
      +
      +
      +
    • +
    • +
      +

      setOrigin

      +
      public final void setOrigin(float arg0, + float arg1)
      +
      +
      Specified by:
      +
      setOrigin in interface org.jsfml.graphics.Transformable
      +
      +
      +
    • +
    • +
      +

      getPosition

      +
      public org.jsfml.system.Vector2f getPosition()
      +
      +
      Specified by:
      +
      getPosition in interface org.jsfml.graphics.Transformable
      +
      +
      +
    • +
    • +
      +

      getRotation

      +
      public float getRotation()
      +
      +
      Specified by:
      +
      getRotation in interface org.jsfml.graphics.Transformable
      +
      +
      +
    • +
    • +
      +

      getScale

      +
      public org.jsfml.system.Vector2f getScale()
      +
      +
      Specified by:
      +
      getScale in interface org.jsfml.graphics.Transformable
      +
      +
      +
    • +
    • +
      +

      getOrigin

      +
      public org.jsfml.system.Vector2f getOrigin()
      +
      +
      Specified by:
      +
      getOrigin in interface org.jsfml.graphics.Transformable
      +
      +
      +
    • +
    • +
      +

      move

      +
      public final void move(float arg0, + float arg1)
      +
      +
      Specified by:
      +
      move in interface org.jsfml.graphics.Transformable
      +
      +
      +
    • +
    • +
      +

      move

      +
      public final void move(org.jsfml.system.Vector2f arg0)
      +
      +
      Specified by:
      +
      move in interface org.jsfml.graphics.Transformable
      +
      +
      +
    • +
    • +
      +

      rotate

      +
      public final void rotate(float arg0)
      +
      +
      Specified by:
      +
      rotate in interface org.jsfml.graphics.Transformable
      +
      +
      +
    • +
    • +
      +

      scale

      +
      public final void scale(float arg0, + float arg1)
      +
      +
      Specified by:
      +
      scale in interface org.jsfml.graphics.Transformable
      +
      +
      +
    • +
    • +
      +

      scale

      +
      public final void scale(org.jsfml.system.Vector2f arg0)
      +
      +
      Specified by:
      +
      scale in interface org.jsfml.graphics.Transformable
      +
      +
      +
    • +
    • +
      +

      getTransform

      +
      public org.jsfml.graphics.Transform getTransform()
      +
      +
      Specified by:
      +
      getTransform in interface org.jsfml.graphics.Transformable
      +
      +
      +
    • +
    • +
      +

      getInverseTransform

      +
      public org.jsfml.graphics.Transform getInverseTransform()
      +
      +
      Specified by:
      +
      getInverseTransform in interface org.jsfml.graphics.Transformable
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/game/gui/package-summary.html b/doc/com/rubynaxela/kyanite/game/gui/package-summary.html new file mode 100644 index 00000000..6b449eb7 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/game/gui/package-summary.html @@ -0,0 +1,116 @@ + + + + +com.rubynaxela.kyanite.game.gui + + + + + + + + + + + + + + + +
+ +
+
+
+

Package com.rubynaxela.kyanite.game.gui

+
+
+
package com.rubynaxela.kyanite.game.gui
+
+ +
+
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/game/gui/package-tree.html b/doc/com/rubynaxela/kyanite/game/gui/package-tree.html new file mode 100644 index 00000000..6515b8db --- /dev/null +++ b/doc/com/rubynaxela/kyanite/game/gui/package-tree.html @@ -0,0 +1,95 @@ + + + + +com.rubynaxela.kyanite.game.gui Class Hierarchy + + + + + + + + + + + + + + + +
+ +
+
+
+

Hierarchy For Package com.rubynaxela.kyanite.game.gui

+Package Hierarchies: + +
+
+

Class Hierarchy

+
    +
  • java.lang.Object +
      +
    • com.rubynaxela.kyanite.game.gui.Font
    • +
    • org.jsfml.internal.SFMLNativeObject +
        +
      • org.jsfml.graphics.Text (implements org.jsfml.graphics.Drawable, org.jsfml.graphics.TextStyle) +
          +
        • com.rubynaxela.kyanite.game.gui.Text
        • +
        +
      • +
      +
    • +
    +
  • +
+
+
+

Enum Class Hierarchy

+ +
+
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/game/package-summary.html b/doc/com/rubynaxela/kyanite/game/package-summary.html new file mode 100644 index 00000000..59db2073 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/game/package-summary.html @@ -0,0 +1,105 @@ + + + + +com.rubynaxela.kyanite.game + + + + + + + + + + + + + + + +
+ +
+
+
+

Package com.rubynaxela.kyanite.game

+
+
+
package com.rubynaxela.kyanite.game
+
+
Contains classes related to the game content.
+
+
+ +
+
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/game/package-tree.html b/doc/com/rubynaxela/kyanite/game/package-tree.html new file mode 100644 index 00000000..b13c9ecd --- /dev/null +++ b/doc/com/rubynaxela/kyanite/game/package-tree.html @@ -0,0 +1,72 @@ + + + + +com.rubynaxela.kyanite.game Class Hierarchy + + + + + + + + + + + + + + + +
+ +
+
+
+

Hierarchy For Package com.rubynaxela.kyanite.game

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/system/AssetId.html b/doc/com/rubynaxela/kyanite/system/AssetId.html new file mode 100644 index 00000000..e1d60bb2 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/system/AssetId.html @@ -0,0 +1,83 @@ + + + + +AssetId + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Annotation Interface AssetId

+
+
+
+
@Documented +@Target({PARAMETER,FIELD,METHOD}) +@Retention(SOURCE) +public @interface AssetId
+
Indicates that the annotated String is an asset identifier. The programmer can use + this annotation to enhance code readability. It does not have any uses other than that.
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/system/Clock.html b/doc/com/rubynaxela/kyanite/system/Clock.html new file mode 100644 index 00000000..e0a722bd --- /dev/null +++ b/doc/com/rubynaxela/kyanite/system/Clock.html @@ -0,0 +1,230 @@ + + + + +Clock + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class Clock

+
+
java.lang.Object +
com.rubynaxela.kyanite.system.Clock
+
+
+
+
public final class Clock +extends Object
+
Provides functionality for time measurement.
+
+
+
    + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    + +
    +
    Constructs a clock and starts it.
    +
    +
    Clock(boolean started)
    +
    +
    Constructs a clock.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    org.jsfml.system.Time
    + +
    +
    Gets the elapsed time since the clock was created or this function was last called.
    +
    +
    org.jsfml.system.Time
    + +
    +
    Gets the elapsed time since the clock was created or last restarted.
    +
    +
    org.jsfml.system.Time
    + +
    +
    Yields the elapsed time and restarts the clock.
    +
    +
    void
    + +
    +
    Starts the clock.
    +
    +
    +
    +
    +
    +

    Methods inherited from class java.lang.Object

    +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Clock

      +
      public Clock(boolean started)
      +
      Constructs a clock.
      +
      +
      Parameters:
      +
      started - whether this clock is automatically started by the constructor + (if false, requires calling start() to start it)
      +
      +
      +
    • +
    • +
      +

      Clock

      +
      public Clock()
      +
      Constructs a clock and starts it.
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      start

      +
      public void start()
      +
      Starts the clock.
      +
      +
    • +
    • +
      +

      getTime

      +
      public org.jsfml.system.Time getTime()
      +
      Gets the elapsed time since the clock was created or last restarted.
      +
      +
      Returns:
      +
      the elapsed time since the clock was created or last restarted.
      +
      +
      +
    • +
    • +
      +

      getDeltaTime

      +
      public org.jsfml.system.Time getDeltaTime()
      +
      Gets the elapsed time since the clock was created or this function was last called.
      +
      +
      Returns:
      +
      the elapsed time since the clock was created or this function was last called.
      +
      +
      +
    • +
    • +
      +

      restart

      +
      public org.jsfml.system.Time restart()
      +
      Yields the elapsed time and restarts the clock.
      +
      +
      Returns:
      +
      the elapsed time since the clock was created or last restarted.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/system/FirstThreadTool.html b/doc/com/rubynaxela/kyanite/system/FirstThreadTool.html new file mode 100644 index 00000000..1795d9fc --- /dev/null +++ b/doc/com/rubynaxela/kyanite/system/FirstThreadTool.html @@ -0,0 +1,141 @@ + + + + +FirstThreadTool + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class FirstThreadTool

+
+
java.lang.Object +
com.rubynaxela.kyanite.system.FirstThreadTool
+
+
+
+
public final class FirstThreadTool +extends Object
+
If the application is running on macOS, it must be started with the -XstartOnFirstThread JVM option. + Otherwise, the application thread will not be allowed to create a window. This is an SWT limitation.
+
+
+ +
+
+
    + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      restartIfNecessary

      +
      public static void restartIfNecessary(String[] args)
      +
      Reboots the JVM on Mac OS X with VM option -XstartOnFirstThread if the VM wasn't started with it already.
      +
      +
      Parameters:
      +
      args - arguments for the new instance of the application
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/system/package-summary.html b/doc/com/rubynaxela/kyanite/system/package-summary.html new file mode 100644 index 00000000..5c7b9aa1 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/system/package-summary.html @@ -0,0 +1,102 @@ + + + + +com.rubynaxela.kyanite.system + + + + + + + + + + + + + + + +
+ +
+
+
+

Package com.rubynaxela.kyanite.system

+
+
+
package com.rubynaxela.kyanite.system
+
+
Contains classes that provide core functionality, common data types and exceptions.
+
+
+
    +
  • +
    +
    +
    +
    +
    Class
    +
    Description
    + +
    +
    Indicates that the annotated String is an asset identifier.
    +
    + +
    +
    Provides functionality for time measurement.
    +
    + +
    +
    If the application is running on macOS, it must be started with the -XstartOnFirstThread JVM option.
    +
    +
    +
    +
    +
  • +
+
+
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/system/package-tree.html b/doc/com/rubynaxela/kyanite/system/package-tree.html new file mode 100644 index 00000000..e9ef7ede --- /dev/null +++ b/doc/com/rubynaxela/kyanite/system/package-tree.html @@ -0,0 +1,79 @@ + + + + +com.rubynaxela.kyanite.system Class Hierarchy + + + + + + + + + + + + + + + +
+ +
+
+
+

Hierarchy For Package com.rubynaxela.kyanite.system

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+
+

Annotation Interface Hierarchy

+
    +
  • com.rubynaxela.kyanite.system.AssetId (implements java.lang.annotation.Annotation)
  • +
+
+
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/util/MathUtils.html b/doc/com/rubynaxela/kyanite/util/MathUtils.html new file mode 100644 index 00000000..3e557188 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/util/MathUtils.html @@ -0,0 +1,169 @@ + + + + +MathUtils + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class MathUtils

+
+
java.lang.Object +
com.rubynaxela.kyanite.util.MathUtils
+
+
+
+
public final class MathUtils +extends Object
+
+
+ +
+
+
    + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      min

      +
      public static <T extends Number> T min(T a, + T b)
      +
      Returns the smaller of two numeric values. If the arguments have the same value, the result is that same value. + If either value is NaN, then the result is also NaN. If exactly one of the arguments is null, the result + is the other argument, whereas if both values are null, then the result is also null.
      +
      +
      Parameters:
      +
      a - first operand
      +
      b - second operand
      +
      Returns:
      +
      the smaller of a and b
      +
      +
      +
    • +
    • +
      +

      max

      +
      public static <T extends Number> T max(T a, + T b)
      +
      Returns the bigger of two numeric values. If the arguments have the same value, the result is that same value. + If either value is NaN, then the result is also NaN. If exactly one of the arguments is null, the result + is the other argument, whereas if both values are null, then the result is also null.
      +
      +
      Parameters:
      +
      a - first operand
      +
      b - second operand
      +
      Returns:
      +
      the bigger of a and b
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/util/Pair.html b/doc/com/rubynaxela/kyanite/util/Pair.html new file mode 100644 index 00000000..b84578c8 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/util/Pair.html @@ -0,0 +1,250 @@ + + + + +Pair + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Record Class Pair<T1,T2>

+
+
java.lang.Object +
java.lang.Record +
com.rubynaxela.kyanite.util.Pair<T1,T2>
+
+
+
+
+
public record Pair<T1,T2>(T1 value1, T2 value2) +extends Record
+
+
+
    + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    +
    Pair(T1 value1, + T2 value2)
    +
    +
    Creates an instance of a Pair record class.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    final boolean
    + +
    +
    Indicates whether some other object is "equal to" this one.
    +
    +
    final int
    + +
    +
    Returns a hash code value for this object.
    +
    +
    final String
    + +
    +
    Returns a string representation of this record class.
    +
    + + +
    +
    Returns the value of the value1 record component.
    +
    + + +
    +
    Returns the value of the value2 record component.
    +
    +
    +
    +
    +
    +

    Methods inherited from class java.lang.Object

    +clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Pair

      +
      public Pair(T1 value1, + T2 value2)
      +
      Creates an instance of a Pair record class.
      +
      +
      Parameters:
      +
      value1 - the value for the value1 record component
      +
      value2 - the value for the value2 record component
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      toString

      +
      public final String toString()
      +
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      +
      +
      Specified by:
      +
      toString in class Record
      +
      Returns:
      +
      a string representation of this object
      +
      +
      +
    • +
    • +
      +

      hashCode

      +
      public final int hashCode()
      +
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      +
      +
      Specified by:
      +
      hashCode in class Record
      +
      Returns:
      +
      a hash code value for this object
      +
      +
      +
    • +
    • +
      +

      equals

      +
      public final boolean equals(Object o)
      +
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      +
      +
      Specified by:
      +
      equals in class Record
      +
      Parameters:
      +
      o - the object with which to compare
      +
      Returns:
      +
      true if this object is the same as the o argument; false otherwise.
      +
      +
      +
    • +
    • +
      +

      value1

      +
      public T1 value1()
      +
      Returns the value of the value1 record component.
      +
      +
      Returns:
      +
      the value of the value1 record component
      +
      +
      +
    • +
    • +
      +

      value2

      +
      public T2 value2()
      +
      Returns the value of the value2 record component.
      +
      +
      Returns:
      +
      the value of the value2 record component
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/util/package-summary.html b/doc/com/rubynaxela/kyanite/util/package-summary.html new file mode 100644 index 00000000..afba61f2 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/util/package-summary.html @@ -0,0 +1,91 @@ + + + + +com.rubynaxela.kyanite.util + + + + + + + + + + + + + + + +
+ +
+
+
+

Package com.rubynaxela.kyanite.util

+
+
+
package com.rubynaxela.kyanite.util
+
+
    +
  • +
    +
    +
    +
    +
    Class
    +
    Description
    + +
     
    +
    Pair<T1,T2>
    +
     
    +
    +
    +
    +
  • +
+
+
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/util/package-tree.html b/doc/com/rubynaxela/kyanite/util/package-tree.html new file mode 100644 index 00000000..8a5cebd1 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/util/package-tree.html @@ -0,0 +1,77 @@ + + + + +com.rubynaxela.kyanite.util Class Hierarchy + + + + + + + + + + + + + + + +
+ +
+
+
+

Hierarchy For Package com.rubynaxela.kyanite.util

+Package Hierarchies: + +
+
+

Class Hierarchy

+
    +
  • java.lang.Object +
      +
    • com.rubynaxela.kyanite.util.MathUtils
    • +
    • java.lang.Record +
        +
      • com.rubynaxela.kyanite.util.Pair<T1,T2>
      • +
      +
    • +
    +
  • +
+
+
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/window/Scene.html b/doc/com/rubynaxela/kyanite/window/Scene.html new file mode 100644 index 00000000..4292e369 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/window/Scene.html @@ -0,0 +1,220 @@ + + + + +Scene + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class Scene

+
+
java.lang.Object +
java.util.AbstractCollection<E> +
java.util.AbstractList<E> +
java.util.ArrayList<org.jsfml.graphics.Drawable> +
com.rubynaxela.kyanite.game.Scene
+
+
+
+
+
+
+
All Implemented Interfaces:
+
Serializable, Cloneable, Iterable<org.jsfml.graphics.Drawable>, Collection<org.jsfml.graphics.Drawable>, List<org.jsfml.graphics.Drawable>, RandomAccess
+
+
+
public class Scene +extends ArrayList<org.jsfml.graphics.Drawable>
+
An alias type for an ArrayList of Drawables.
+
+
See Also:
+
+ +
+
+
+
+ +
+
+
    + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Scene

      +
      public Scene()
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      setLoop

      +
      public void setLoop(@NotNull + @NotNull Runnable loop)
      +
      Sets the scene loop action which will be executed every frame
      +
      +
      Parameters:
      +
      loop - logic to run every frame
      +
      +
      +
    • +
    • +
      +

      isInitialized

      +
      public boolean isInitialized()
      +
      +
      Returns:
      +
      whether the scene loop is not null
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/window/Window.html b/doc/com/rubynaxela/kyanite/window/Window.html new file mode 100644 index 00000000..700bcb72 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/window/Window.html @@ -0,0 +1,548 @@ + + + + +Window + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class Window

+
+
java.lang.Object +
org.jsfml.internal.SFMLNativeObject +
org.jsfml.window.Window +
org.jsfml.graphics.RenderWindow +
com.rubynaxela.kyanite.window.Window
+
+
+
+
+
+
+
All Implemented Interfaces:
+
org.jsfml.graphics.RenderTarget, org.jsfml.window.WindowStyle
+
+
+
public class Window +extends org.jsfml.graphics.RenderWindow
+
Provides a window that can serve as a target for 2D drawing. The window is already + initialized with an empty scene to which Drawable objects can be added.
+
+
+
    + +
  • +
    +

    Field Summary

    +
    +

    Fields inherited from interface org.jsfml.window.WindowStyle

    +CLOSE, DEFAULT, FULLSCREEN, NONE, RESIZE, TITLEBAR
    +
    +
  • + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    + +
    +
    Constructs a new render window without actually creating (opening) it.
    +
    +
    Window(@NotNull org.jsfml.window.VideoMode videoMode, + @NotNull String title)
    +
    +
    Constructs a new render window and creates it with default style and context settings.
    +
    +
    Window(@NotNull org.jsfml.window.VideoMode videoMode, + @NotNull String title, + int style)
    +
    +
    Constructs a new render window and creates it with default context settings.
    +
    +
    Window(@NotNull org.jsfml.window.VideoMode videoMode, + @NotNull String title, + int style, + @NotNull org.jsfml.window.ContextSettings contextSettings)
    +
    +
    Constructs a new render window and creates it with the specified parameters.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    @NotNull Scene
    + +
     
    +
    void
    + +
    +
    Sets the size of the window to fill the whole screen, excluding system toolbars.
    +
    +
    void
    +
    setBackgroundColor(@NotNull org.jsfml.graphics.Color backgroundColor)
    +
     
    +
    void
    +
    setCloseListener(@NotNull CloseListener listener)
    +
    +
    Adds the specified close listener to receive the close button press event from this window.
    +
    +
    void
    +
    setFocusListener(@NotNull FocusListener listener)
    +
    +
    Adds the specified focus listener to receive focus events from this window.
    +
    +
    void
    + +
    +
    Adds the specified joystick button listener to receive joystick button events from this window.
    +
    +
    void
    + +
    +
    Adds the specified joystick connection listener to receive joystick connection and disconnection events from this window.
    +
    +
    void
    + +
    +
    Adds the specified joystick listener to receive joystick movement events from this window.
    +
    +
    void
    +
    setKeyListener(@NotNull KeyListener listener)
    +
    +
    Adds the specified key listener to receive key events from this window.
    +
    +
    void
    + +
    +
    Adds the specified mouse button listener to receive mouse button events from this window.
    +
    +
    void
    +
    setMouseListener(@NotNull MouseListener listener)
    +
    +
    Adds the specified mouse listener to receive mouse events from this window.
    +
    +
    void
    + +
    +
    Adds the specified mouse wheel listener to receive mouse wheel events from this window.
    +
    +
    void
    +
    setResizeListener(@NotNull ResizeListener listener)
    +
    +
    Adds the specified resize listener to receive resize events from this window.
    +
    +
    void
    +
    setScene(@NotNull Scene scene)
    +
    +
    Changes the current scene of this window.
    +
    +
    void
    +
    setSize(int width, + int height)
    +
    +
    Sets the size of the window.
    +
    +
    void
    +
    setSize(@NotNull org.jsfml.system.Vector2i size)
    +
    +
    Sets the size of the window.
    +
    +
    void
    +
    setTextListener(@NotNull TextListener listener)
    +
    +
    Adds the specified text listener to receive text input events from this window.
    +
    +
    void
    +
    startLoop(@NotNull GameContext context)
    +
    +
    Starts the window loop.
    +
    +
    +
    +
    +
    +

    Methods inherited from class org.jsfml.graphics.RenderWindow

    +capture, clear, clear, create, draw, draw, draw, draw, getDefaultView, getView, getViewport, mapCoordsToPixel, mapCoordsToPixel, mapPixelToCoords, mapPixelToCoords, nativeCreate, nativeDelete, nativeSetExPtr, popGLStates, pushGLStates, resetGLStates, setView
    +
    +

    Methods inherited from class org.jsfml.window.Window

    +close, create, create, display, getPosition, getSettings, getSize, isLegalWindowThread, isOpen, pollEvent, pollEvents, setActive, setActive, setFramerateLimit, setIcon, setJoystickTreshold, setKeyRepeatEnabled, setMouseCursorVisible, setPosition, setTitle, setVerticalSyncEnabled, setVisible, waitEvent
    +
    +

    Methods inherited from class org.jsfml.internal.SFMLNativeObject

    +finalize
    +
    +

    Methods inherited from class java.lang.Object

    +clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    +
    +

    Methods inherited from interface org.jsfml.graphics.RenderTarget

    +getSize
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Window

      +
      public Window(@NotNull + @NotNull org.jsfml.window.VideoMode videoMode, + @NotNull + @NotNull String title, + int style, + @NotNull + @NotNull org.jsfml.window.ContextSettings contextSettings)
      +
      Constructs a new render window and creates it with the specified parameters.
      +
      +
      Parameters:
      +
      videoMode - the video mode to use for rendering
      +
      title - the window title
      +
      style - the window style
      +
      contextSettings - the settings for the OpenGL context
      +
      +
      +
    • +
    • +
      +

      Window

      +
      public Window(@NotNull + @NotNull org.jsfml.window.VideoMode videoMode, + @NotNull + @NotNull String title, + int style)
      +
      Constructs a new render window and creates it with default context settings.
      +
      +
      Parameters:
      +
      videoMode - the video mode to use for rendering
      +
      title - the window title
      +
      style - the window style
      +
      +
      +
    • +
    • +
      +

      Window

      +
      public Window(@NotNull + @NotNull org.jsfml.window.VideoMode videoMode, + @NotNull + @NotNull String title)
      +
      Constructs a new render window and creates it with default style and context settings.
      +
      +
      Parameters:
      +
      videoMode - the video mode to use for rendering
      +
      title - the window title
      +
      +
      +
    • +
    • +
      +

      Window

      +
      public Window()
      +
      Constructs a new render window without actually creating (opening) it.
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      setSize

      +
      public void setSize(@NotNull + @NotNull org.jsfml.system.Vector2i size)
      +
      Sets the size of the window.
      +
      +
      Overrides:
      +
      setSize in class org.jsfml.window.Window
      +
      Parameters:
      +
      size - the new size of the window
      +
      +
      +
    • +
    • +
      +

      setSize

      +
      public void setSize(int width, + int height)
      +
      Sets the size of the window.
      +
      +
      Parameters:
      +
      width - the new width of the window
      +
      height - the new height of the window
      +
      +
      +
    • +
    • +
      +

      maximize

      +
      public void maximize()
      +
      Sets the size of the window to fill the whole screen, excluding system toolbars.
      +
      +
    • +
    • +
      +

      setBackgroundColor

      +
      public void setBackgroundColor(@NotNull + @NotNull org.jsfml.graphics.Color backgroundColor)
      +
      +
    • +
    • +
      +

      setCloseListener

      +
      public void setCloseListener(@NotNull + @NotNull CloseListener listener)
      +
      Adds the specified close listener to receive the close button press event from this window.
      +
      +
      Parameters:
      +
      listener - the close button press event listener
      +
      +
      +
    • +
    • +
      +

      setResizeListener

      +
      public void setResizeListener(@NotNull + @NotNull ResizeListener listener)
      +
      Adds the specified resize listener to receive resize events from this window.
      +
      +
      Parameters:
      +
      listener - the resize event listener
      +
      +
      +
    • +
    • +
      +

      setFocusListener

      +
      public void setFocusListener(@NotNull + @NotNull FocusListener listener)
      +
      Adds the specified focus listener to receive focus events from this window.
      +
      +
      Parameters:
      +
      listener - the focus event listener
      +
      +
      +
    • +
    • +
      +

      setTextListener

      +
      public void setTextListener(@NotNull + @NotNull TextListener listener)
      +
      Adds the specified text listener to receive text input events from this window.
      +
      +
      Parameters:
      +
      listener - the text input event listener
      +
      +
      +
    • +
    • +
      +

      setKeyListener

      +
      public void setKeyListener(@NotNull + @NotNull KeyListener listener)
      +
      Adds the specified key listener to receive key events from this window.
      +
      +
      Parameters:
      +
      listener - the key event listener
      +
      +
      +
    • +
    • +
      +

      setMouseWheelListener

      +
      public void setMouseWheelListener(@NotNull + @NotNull MouseWheelListener listener)
      +
      Adds the specified mouse wheel listener to receive mouse wheel events from this window.
      +
      +
      Parameters:
      +
      listener - the mouse wheel event listener
      +
      +
      +
    • +
    • +
      +

      setMouseButtonListener

      +
      public void setMouseButtonListener(@NotNull + @NotNull MouseButtonListener listener)
      +
      Adds the specified mouse button listener to receive mouse button events from this window.
      +
      +
      Parameters:
      +
      listener - the mouse button event listener
      +
      +
      +
    • +
    • +
      +

      setMouseListener

      +
      public void setMouseListener(@NotNull + @NotNull MouseListener listener)
      +
      Adds the specified mouse listener to receive mouse events from this window.
      +
      +
      Parameters:
      +
      listener - the mouse event listener
      +
      +
      +
    • +
    • +
      +

      setJoystickButtonListener

      +
      public void setJoystickButtonListener(@NotNull + @NotNull JoystickButtonListener listener)
      +
      Adds the specified joystick button listener to receive joystick button events from this window.
      +
      +
      Parameters:
      +
      listener - the joystick button event listener
      +
      +
      +
    • +
    • +
      +

      setJoystickListener

      +
      public void setJoystickListener(@NotNull + @NotNull JoystickListener listener)
      +
      Adds the specified joystick listener to receive joystick movement events from this window.
      +
      +
      Parameters:
      +
      listener - the joystick movement event listener
      +
      +
      +
    • +
    • +
      +

      setJoystickConnectionListener

      +
      public void setJoystickConnectionListener(@NotNull + @NotNull JoystickConnectionListener listener)
      +
      Adds the specified joystick connection listener to receive joystick connection and disconnection events from this window.
      +
      +
      Parameters:
      +
      listener - the joystick connection event listener
      +
      +
      +
    • +
    • +
      +

      getScene

      +
      @NotNull +public @NotNull Scene getScene()
      +
      +
      Returns:
      +
      reference to the current render scene of this window.
      +
      +
      +
    • +
    • +
      +

      setScene

      +
      public void setScene(@NotNull + @NotNull Scene scene)
      +
      Changes the current scene of this window.
      +
      +
    • +
    • +
      +

      startLoop

      +
      public void startLoop(@NotNull + @NotNull GameContext context)
      +
      Starts the window loop.
      +
      +
      Parameters:
      +
      context - since the GameContext class cannot be instantiated, this parameter + makes it so that only the GameContext class can call this function
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/window/event/CloseListener.html b/doc/com/rubynaxela/kyanite/window/event/CloseListener.html new file mode 100644 index 00000000..836de0c0 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/window/event/CloseListener.html @@ -0,0 +1,133 @@ + + + + +CloseListener + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Interface CloseListener

+
+
+
+
All Superinterfaces:
+
EventListener
+
+
+
public interface CloseListener +extends EventListener
+
+
+
    + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    void
    + +
    +
    Invoked when the user clicked on the window's close button.
    +
    +
    +
    +
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      closed

      +
      void closed()
      +
      Invoked when the user clicked on the window's close button.
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/window/event/FocusListener.html b/doc/com/rubynaxela/kyanite/window/event/FocusListener.html new file mode 100644 index 00000000..0cbad762 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/window/event/FocusListener.html @@ -0,0 +1,145 @@ + + + + +FocusListener + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Interface FocusListener

+
+
+
+
All Superinterfaces:
+
EventListener
+
+
+
public interface FocusListener +extends EventListener
+
+
+
    + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    void
    + +
    +
    Invoked when the window lost focus.
    +
    +
    void
    + +
    +
    Invoked when the window gained focus.
    +
    +
    +
    +
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      focusGained

      +
      void focusGained()
      +
      Invoked when the window lost focus.
      +
      +
    • +
    • +
      +

      focusLost

      +
      void focusLost()
      +
      Invoked when the window gained focus.
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/window/event/JoystickButtonListener.html b/doc/com/rubynaxela/kyanite/window/event/JoystickButtonListener.html new file mode 100644 index 00000000..2b30689d --- /dev/null +++ b/doc/com/rubynaxela/kyanite/window/event/JoystickButtonListener.html @@ -0,0 +1,153 @@ + + + + +JoystickButtonListener + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Interface JoystickButtonListener

+
+
+
+
All Superinterfaces:
+
EventListener
+
+
+
public interface JoystickButtonListener +extends EventListener
+
+
+
    + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    void
    +
    joystickButtonPressed(org.jsfml.window.event.JoystickButtonEvent e)
    +
    +
    Invoked when a joystick or gamepad button was pressed while the window had focus.
    +
    +
    void
    +
    joystickButtonReleased(org.jsfml.window.event.JoystickButtonEvent e)
    +
    +
    Invoked when a joystick or gamepad button was released while the window had focus.
    +
    +
    +
    +
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      joystickButtonPressed

      +
      void joystickButtonPressed(org.jsfml.window.event.JoystickButtonEvent e)
      +
      Invoked when a joystick or gamepad button was pressed while the window had focus.
      +
      +
      Parameters:
      +
      e - the event to be processed
      +
      +
      +
    • +
    • +
      +

      joystickButtonReleased

      +
      void joystickButtonReleased(org.jsfml.window.event.JoystickButtonEvent e)
      +
      Invoked when a joystick or gamepad button was released while the window had focus.
      +
      +
      Parameters:
      +
      e - the event to be processed
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/window/event/JoystickConnectionListener.html b/doc/com/rubynaxela/kyanite/window/event/JoystickConnectionListener.html new file mode 100644 index 00000000..6c4836d1 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/window/event/JoystickConnectionListener.html @@ -0,0 +1,148 @@ + + + + +JoystickConnectionListener + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Interface JoystickConnectionListener

+
+
+
+
public interface JoystickConnectionListener
+
+
+
    + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    void
    +
    joystickConnected(org.jsfml.window.event.JoystickEvent e)
    +
    +
    Invoked when a joystick or gamepad was connected..
    +
    +
    void
    +
    joystickDisconnected(org.jsfml.window.event.JoystickEvent e)
    +
    +
    Invoked when a joystick or gamepad was disconnected.
    +
    +
    +
    +
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      joystickConnected

      +
      void joystickConnected(org.jsfml.window.event.JoystickEvent e)
      +
      Invoked when a joystick or gamepad was connected..
      +
      +
      Parameters:
      +
      e - the event to be processed
      +
      +
      +
    • +
    • +
      +

      joystickDisconnected

      +
      void joystickDisconnected(org.jsfml.window.event.JoystickEvent e)
      +
      Invoked when a joystick or gamepad was disconnected.
      +
      +
      Parameters:
      +
      e - the event to be processed
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/window/event/JoystickListener.html b/doc/com/rubynaxela/kyanite/window/event/JoystickListener.html new file mode 100644 index 00000000..24893d93 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/window/event/JoystickListener.html @@ -0,0 +1,132 @@ + + + + +JoystickListener + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Interface JoystickListener

+
+
+
+
public interface JoystickListener
+
+
+
    + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    void
    +
    joystickMoved(org.jsfml.window.event.JoystickMoveEvent e)
    +
    +
    Invoked when a joystick or gamepad axis was moved while the window had focus.
    +
    +
    +
    +
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      joystickMoved

      +
      void joystickMoved(org.jsfml.window.event.JoystickMoveEvent e)
      +
      Invoked when a joystick or gamepad axis was moved while the window had focus.
      +
      +
      Parameters:
      +
      e - the event to be processed
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/window/event/KeyListener.html b/doc/com/rubynaxela/kyanite/window/event/KeyListener.html new file mode 100644 index 00000000..ce1f08ba --- /dev/null +++ b/doc/com/rubynaxela/kyanite/window/event/KeyListener.html @@ -0,0 +1,153 @@ + + + + +KeyListener + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Interface KeyListener

+
+
+
+
All Superinterfaces:
+
EventListener
+
+
+
public interface KeyListener +extends EventListener
+
+
+
    + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    void
    +
    keyPressed(org.jsfml.window.event.KeyEvent e)
    +
    +
    Invoked when a keyboard key was pressed while the window had focus.
    +
    +
    void
    +
    keyReleased(org.jsfml.window.event.KeyEvent e)
    +
    +
    Invoked when a keyboard key was released while the window had focus.
    +
    +
    +
    +
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      keyPressed

      +
      void keyPressed(org.jsfml.window.event.KeyEvent e)
      +
      Invoked when a keyboard key was pressed while the window had focus.
      +
      +
      Parameters:
      +
      e - the event to be processed
      +
      +
      +
    • +
    • +
      +

      keyReleased

      +
      void keyReleased(org.jsfml.window.event.KeyEvent e)
      +
      Invoked when a keyboard key was released while the window had focus.
      +
      +
      Parameters:
      +
      e - the event to be processed
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/window/event/MouseButtonListener.html b/doc/com/rubynaxela/kyanite/window/event/MouseButtonListener.html new file mode 100644 index 00000000..e1b00bcd --- /dev/null +++ b/doc/com/rubynaxela/kyanite/window/event/MouseButtonListener.html @@ -0,0 +1,153 @@ + + + + +MouseButtonListener + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Interface MouseButtonListener

+
+
+
+
All Superinterfaces:
+
EventListener
+
+
+
public interface MouseButtonListener +extends EventListener
+
+
+
    + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    void
    +
    mouseButtonPressed(org.jsfml.window.event.MouseButtonEvent e)
    +
    +
    Invoked when a mouse button was pressed while the window had focus.
    +
    +
    void
    +
    mouseButtonReleased(org.jsfml.window.event.MouseButtonEvent e)
    +
    +
    Invoked when a mouse button was released while the window had focus.
    +
    +
    +
    +
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      mouseButtonPressed

      +
      void mouseButtonPressed(org.jsfml.window.event.MouseButtonEvent e)
      +
      Invoked when a mouse button was pressed while the window had focus.
      +
      +
      Parameters:
      +
      e - the event to be processed
      +
      +
      +
    • +
    • +
      +

      mouseButtonReleased

      +
      void mouseButtonReleased(org.jsfml.window.event.MouseButtonEvent e)
      +
      Invoked when a mouse button was released while the window had focus.
      +
      +
      Parameters:
      +
      e - the event to be processed
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/window/event/MouseListener.html b/doc/com/rubynaxela/kyanite/window/event/MouseListener.html new file mode 100644 index 00000000..0694a008 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/window/event/MouseListener.html @@ -0,0 +1,169 @@ + + + + +MouseListener + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Interface MouseListener

+
+
+
+
All Superinterfaces:
+
EventListener
+
+
+
public interface MouseListener +extends EventListener
+
+
+
    + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    void
    +
    mouseEntered(org.jsfml.window.event.MouseEvent e)
    +
    +
    Invoked when the mouse cursor entered the window's boundaries.
    +
    +
    void
    +
    mouseLeft(org.jsfml.window.event.MouseEvent e)
    +
    +
    Invoked when the mouse cursor left the window's boundaries.
    +
    +
    void
    +
    mouseMoved(org.jsfml.window.event.MouseEvent e)
    +
    +
    Invoked when the mouse cursor was moved within the window's boundaries.
    +
    +
    +
    +
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      mouseMoved

      +
      void mouseMoved(org.jsfml.window.event.MouseEvent e)
      +
      Invoked when the mouse cursor was moved within the window's boundaries.
      +
      +
      Parameters:
      +
      e - the event to be processed
      +
      +
      +
    • +
    • +
      +

      mouseEntered

      +
      void mouseEntered(org.jsfml.window.event.MouseEvent e)
      +
      Invoked when the mouse cursor entered the window's boundaries.
      +
      +
      Parameters:
      +
      e - the event to be processed
      +
      +
      +
    • +
    • +
      +

      mouseLeft

      +
      void mouseLeft(org.jsfml.window.event.MouseEvent e)
      +
      Invoked when the mouse cursor left the window's boundaries.
      +
      +
      Parameters:
      +
      e - the event to be processed
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/window/event/MouseWheelListener.html b/doc/com/rubynaxela/kyanite/window/event/MouseWheelListener.html new file mode 100644 index 00000000..f7d24d73 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/window/event/MouseWheelListener.html @@ -0,0 +1,137 @@ + + + + +MouseWheelListener + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Interface MouseWheelListener

+
+
+
+
All Superinterfaces:
+
EventListener
+
+
+
public interface MouseWheelListener +extends EventListener
+
+
+
    + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    void
    +
    mouseWheelMoved(org.jsfml.window.event.MouseWheelEvent e)
    +
    +
    Invoked when the mouse wheel was moved while the window had focus.
    +
    +
    +
    +
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      mouseWheelMoved

      +
      void mouseWheelMoved(org.jsfml.window.event.MouseWheelEvent e)
      +
      Invoked when the mouse wheel was moved while the window had focus.
      +
      +
      Parameters:
      +
      e - the event to be processed
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/window/event/ResizeEvent.html b/doc/com/rubynaxela/kyanite/window/event/ResizeEvent.html new file mode 100644 index 00000000..d64fe56a --- /dev/null +++ b/doc/com/rubynaxela/kyanite/window/event/ResizeEvent.html @@ -0,0 +1,231 @@ + + + + +ResizeEvent + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Record Class ResizeEvent

+
+
java.lang.Object +
java.lang.Record +
com.rubynaxela.kyanite.window.event.ResizeEvent
+
+
+
+
+
public record ResizeEvent(org.jsfml.system.Vector2i newSize) +extends Record
+
+
+
    + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    +
    ResizeEvent(org.jsfml.system.Vector2i newSize)
    +
    +
    Creates an instance of a ResizeEvent record class.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    final boolean
    + +
    +
    Indicates whether some other object is "equal to" this one.
    +
    +
    final int
    + +
    +
    Returns a hash code value for this object.
    +
    +
    org.jsfml.system.Vector2i
    + +
    +
    Returns the value of the newSize record component.
    +
    +
    final String
    + +
    +
    Returns a string representation of this record class.
    +
    +
    +
    +
    +
    +

    Methods inherited from class java.lang.Object

    +clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      ResizeEvent

      +
      public ResizeEvent(org.jsfml.system.Vector2i newSize)
      +
      Creates an instance of a ResizeEvent record class.
      +
      +
      Parameters:
      +
      newSize - the value for the newSize record component
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      toString

      +
      public final String toString()
      +
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      +
      +
      Specified by:
      +
      toString in class Record
      +
      Returns:
      +
      a string representation of this object
      +
      +
      +
    • +
    • +
      +

      hashCode

      +
      public final int hashCode()
      +
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      +
      +
      Specified by:
      +
      hashCode in class Record
      +
      Returns:
      +
      a hash code value for this object
      +
      +
      +
    • +
    • +
      +

      equals

      +
      public final boolean equals(Object o)
      +
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      +
      +
      Specified by:
      +
      equals in class Record
      +
      Parameters:
      +
      o - the object with which to compare
      +
      Returns:
      +
      true if this object is the same as the o argument; false otherwise.
      +
      +
      +
    • +
    • +
      +

      newSize

      +
      public org.jsfml.system.Vector2i newSize()
      +
      Returns the value of the newSize record component.
      +
      +
      Returns:
      +
      the value of the newSize record component
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/window/event/ResizeListener.html b/doc/com/rubynaxela/kyanite/window/event/ResizeListener.html new file mode 100644 index 00000000..5fe465ce --- /dev/null +++ b/doc/com/rubynaxela/kyanite/window/event/ResizeListener.html @@ -0,0 +1,137 @@ + + + + +ResizeListener + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Interface ResizeListener

+
+
+
+
All Superinterfaces:
+
EventListener
+
+
+
public interface ResizeListener +extends EventListener
+
+
+
    + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    void
    + +
    +
    Invoked when the window was resized.
    +
    +
    +
    +
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      resized

      +
      void resized(ResizeEvent e)
      +
      Invoked when the window was resized.
      +
      +
      Parameters:
      +
      e - the event to be processed
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/window/event/TextListener.html b/doc/com/rubynaxela/kyanite/window/event/TextListener.html new file mode 100644 index 00000000..76fdf5ee --- /dev/null +++ b/doc/com/rubynaxela/kyanite/window/event/TextListener.html @@ -0,0 +1,137 @@ + + + + +TextListener + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Interface TextListener

+
+
+
+
All Superinterfaces:
+
EventListener
+
+
+
public interface TextListener +extends EventListener
+
+
+
    + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    void
    +
    textEntered(org.jsfml.window.event.TextEvent e)
    +
    +
    Invoked when a text character was entered using the keyboard while the window had focus.
    +
    +
    +
    +
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      textEntered

      +
      void textEntered(org.jsfml.window.event.TextEvent e)
      +
      Invoked when a text character was entered using the keyboard while the window had focus.
      +
      +
      Parameters:
      +
      e - the event to be processed
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/window/event/package-summary.html b/doc/com/rubynaxela/kyanite/window/event/package-summary.html new file mode 100644 index 00000000..1797e559 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/window/event/package-summary.html @@ -0,0 +1,128 @@ + + + + +com.rubynaxela.kyanite.window.event + + + + + + + + + + + + + + + +
+ +
+
+
+

Package + com.rubynaxela.kyanite.window.event

+
+
+
package com.rubynaxela.kyanite.window.event
+
+
Contains classes representing window events and event listeners.
+
+
+ +
+
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/window/event/package-tree.html b/doc/com/rubynaxela/kyanite/window/event/package-tree.html new file mode 100644 index 00000000..ff68fd15 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/window/event/package-tree.html @@ -0,0 +1,96 @@ + + + + +com.rubynaxela.kyanite.window.event Class Hierarchy + + + + + + + + + + + + + + + +
+ +
+
+
+

Hierarchy For Package com.rubynaxela.kyanite.window.event

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+
+

Interface Hierarchy

+ +
+
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/window/package-summary.html b/doc/com/rubynaxela/kyanite/window/package-summary.html new file mode 100644 index 00000000..721813ba --- /dev/null +++ b/doc/com/rubynaxela/kyanite/window/package-summary.html @@ -0,0 +1,105 @@ + + + + +com.rubynaxela.kyanite.window + + + + + + + + + + + + + + + +
+ +
+
+
+

Package com.rubynaxela.kyanite.window

+
+
+
package com.rubynaxela.kyanite.window
+
+
Contains classes related to graphic interface
+
+
+
    +
  • + +
  • +
  • +
    +
    Classes
    +
    +
    Class
    +
    Description
    + +
    +
    An alias type for an ArrayList of Drawables.
    +
    + +
    +
    Provides a window that can serve as a target for 2D drawing.
    +
    +
    +
    +
  • +
+
+
+
+
+ + diff --git a/doc/com/rubynaxela/kyanite/window/package-tree.html b/doc/com/rubynaxela/kyanite/window/package-tree.html new file mode 100644 index 00000000..f730f4e4 --- /dev/null +++ b/doc/com/rubynaxela/kyanite/window/package-tree.html @@ -0,0 +1,97 @@ + + + + +com.rubynaxela.kyanite.window Class Hierarchy + + + + + + + + + + + + + + + +
+ +
+
+
+

Hierarchy For Package com.rubynaxela.kyanite.window

+Package Hierarchies: + +
+
+

Class Hierarchy

+
    +
  • java.lang.Object +
      +
    • java.util.AbstractCollection<E> (implements java.util.Collection<E>) + +
    • +
    • org.jsfml.internal.SFMLNativeObject +
        +
      • org.jsfml.window.Window (implements org.jsfml.window.WindowStyle) +
          +
        • org.jsfml.graphics.RenderWindow (implements org.jsfml.graphics.RenderTarget) +
            +
          • com.rubynaxela.kyanite.window.Window
          • +
          +
        • +
        +
      • +
      +
    • +
    +
  • +
+
+
+
+
+ + diff --git a/doc/deprecated-list.html b/doc/deprecated-list.html new file mode 100644 index 00000000..cb47b6fa --- /dev/null +++ b/doc/deprecated-list.html @@ -0,0 +1,77 @@ + + + + +Deprecated List + + + + + + + + + + + + + + + +
+ +
+
+
+

Deprecated API

+

Contents

+ +
+ +
+
+
+ + diff --git a/doc/element-list b/doc/element-list new file mode 100644 index 00000000..ce5735c0 --- /dev/null +++ b/doc/element-list @@ -0,0 +1,8 @@ +com.rubynaxela.kyanite.game +com.rubynaxela.kyanite.game.assets +com.rubynaxela.kyanite.game.entities +com.rubynaxela.kyanite.game.gui +com.rubynaxela.kyanite.system +com.rubynaxela.kyanite.util +com.rubynaxela.kyanite.window +com.rubynaxela.kyanite.window.event diff --git a/doc/help-doc.html b/doc/help-doc.html new file mode 100644 index 00000000..22d47a18 --- /dev/null +++ b/doc/help-doc.html @@ -0,0 +1,187 @@ + + + + +API Help + + + + + + + + + + + + + + + +
+ +
+
+

JavaDoc Help

+ +
+
+

Navigation

+Starting from the Overview page, you can browse the documentation using the links in each page, and in the navigation bar at the top of each page. The Index and Search box allow you to navigate to specific declarations and summary pages, including: All Packages, All Classes and Interfaces + +
+
+
+

Kinds of Pages

+The following sections describe the different kinds of pages in this collection. +
+

Overview

+

The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.

+
+
+

Package

+

Each package has a page that contains a list of its classes and interfaces, with a summary for each. These pages may contain the following categories:

+
    +
  • Interfaces
  • +
  • Classes
  • +
  • Enum Classes
  • +
  • Exceptions
  • +
  • Errors
  • +
  • Annotation Interfaces
  • +
+
+
+

Class or Interface

+

Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a declaration and description, member summary tables, and detailed member descriptions. Entries in each of these sections are omitted if they are empty or not applicable.

+
    +
  • Class Inheritance Diagram
  • +
  • Direct Subclasses
  • +
  • All Known Subinterfaces
  • +
  • All Known Implementing Classes
  • +
  • Class or Interface Declaration
  • +
  • Class or Interface Description
  • +
+
+
    +
  • Nested Class Summary
  • +
  • Enum Constant Summary
  • +
  • Field Summary
  • +
  • Property Summary
  • +
  • Constructor Summary
  • +
  • Method Summary
  • +
  • Required Element Summary
  • +
  • Optional Element Summary
  • +
+
+
    +
  • Enum Constant Details
  • +
  • Field Details
  • +
  • Property Details
  • +
  • Constructor Details
  • +
  • Method Details
  • +
  • Element Details
  • +
+

Note: Annotation interfaces have required and optional elements, but not methods. Only enum classes have enum constants. The components of a record class are displayed as part of the declaration of the record class. Properties are a feature of JavaFX.

+

The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

+
+
+

Other Files

+

Packages and modules may contain pages with additional information related to the declarations nearby.

+
+
+

Tree (Class Hierarchy)

+

There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. Classes are organized by inheritance structure starting with java.lang.Object. Interfaces do not inherit from java.lang.Object.

+
    +
  • When viewing the Overview page, clicking on TREE displays the hierarchy for all packages.
  • +
  • When viewing a particular package, class or interface page, clicking on TREE displays the hierarchy for only that package.
  • +
+
+
+

Deprecated API

+

The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to shortcomings, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

+
+
+

Serialized Form

+

Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to those who implement rather than use the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See Also" section of the class description.

+
+
+

All Packages

+

The All Packages page contains an alphabetic index of all packages contained in the documentation.

+
+
+

All Classes and Interfaces

+

The All Classes and Interfaces page contains an alphabetic index of all classes and interfaces contained in the documentation, including annotation interfaces, enum classes, and record classes.

+
+
+

Index

+

The Index contains an alphabetic index of all classes, interfaces, constructors, methods, and fields in the documentation, as well as summary pages such as All Packages, All Classes and Interfaces.

+
+
+
+This help file applies to API documentation generated by the standard doclet.
+
+
+ + diff --git a/doc/index-files/index-1.html b/doc/index-files/index-1.html new file mode 100644 index 00000000..1477a2c5 --- /dev/null +++ b/doc/index-files/index-1.html @@ -0,0 +1,96 @@ + + + + +A-Index + + + + + + + + + + + + + + + +
+ +
+
+
+

Index

+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form +

A

+
+
add(Object, Vector2f) - Method in class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
+
Adds an object and puts it on its relative position.
+
+
apply(Text) - Method in class com.rubynaxela.kyanite.game.gui.Font
+
+
Applies this font on a Text object.
+
+
apply(Shape) - Method in class com.rubynaxela.kyanite.game.assets.Texture
+
+
Applies this texture on the Shape without affecting the texture rectangle.
+
+
apply(Sprite) - Method in class com.rubynaxela.kyanite.game.assets.Texture
+
+
Applies this texture on the Sprite without affecting the texture rectangle.
+
+
apply(Text) - Method in class com.rubynaxela.kyanite.game.assets.FontFace
+
+
Applies this font on the Text.
+
+
Asset - Interface in com.rubynaxela.kyanite.game.assets
+
+
An external asset.
+
+
AssetId - Annotation Interface in com.rubynaxela.kyanite.system
+
+
Indicates that the annotated String is an asset identifier.
+
+
AssetsBundle - Class in com.rubynaxela.kyanite.game.assets
+
+
Provides a handy assets storage.
+
+
AssetsBundle() - Constructor for class com.rubynaxela.kyanite.game.assets.AssetsBundle
+
 
+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form
+
+
+ + diff --git a/doc/index-files/index-10.html b/doc/index-files/index-10.html new file mode 100644 index 00000000..22ee9583 --- /dev/null +++ b/doc/index-files/index-10.html @@ -0,0 +1,88 @@ + + + + +J-Index + + + + + + + + + + + + + + + +
+ +
+
+
+

Index

+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form +

J

+
+
JoystickButtonListener - Interface in com.rubynaxela.kyanite.window.event
+
 
+
joystickButtonPressed(JoystickButtonEvent) - Method in interface com.rubynaxela.kyanite.window.event.JoystickButtonListener
+
+
Invoked when a joystick or gamepad button was pressed while the window had focus.
+
+
joystickButtonReleased(JoystickButtonEvent) - Method in interface com.rubynaxela.kyanite.window.event.JoystickButtonListener
+
+
Invoked when a joystick or gamepad button was released while the window had focus.
+
+
joystickConnected(JoystickEvent) - Method in interface com.rubynaxela.kyanite.window.event.JoystickConnectionListener
+
+
Invoked when a joystick or gamepad was connected..
+
+
JoystickConnectionListener - Interface in com.rubynaxela.kyanite.window.event
+
 
+
joystickDisconnected(JoystickEvent) - Method in interface com.rubynaxela.kyanite.window.event.JoystickConnectionListener
+
+
Invoked when a joystick or gamepad was disconnected.
+
+
JoystickListener - Interface in com.rubynaxela.kyanite.window.event
+
 
+
joystickMoved(JoystickMoveEvent) - Method in interface com.rubynaxela.kyanite.window.event.JoystickListener
+
+
Invoked when a joystick or gamepad axis was moved while the window had focus.
+
+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form
+
+
+ + diff --git a/doc/index-files/index-11.html b/doc/index-files/index-11.html new file mode 100644 index 00000000..e7e97092 --- /dev/null +++ b/doc/index-files/index-11.html @@ -0,0 +1,72 @@ + + + + +K-Index + + + + + + + + + + + + + + + +
+ +
+
+
+

Index

+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form +

K

+
+
KeyListener - Interface in com.rubynaxela.kyanite.window.event
+
 
+
keyPressed(KeyEvent) - Method in interface com.rubynaxela.kyanite.window.event.KeyListener
+
+
Invoked when a keyboard key was pressed while the window had focus.
+
+
keyReleased(KeyEvent) - Method in interface com.rubynaxela.kyanite.window.event.KeyListener
+
+
Invoked when a keyboard key was released while the window had focus.
+
+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form
+
+
+ + diff --git a/doc/index-files/index-12.html b/doc/index-files/index-12.html new file mode 100644 index 00000000..d41b2a47 --- /dev/null +++ b/doc/index-files/index-12.html @@ -0,0 +1,66 @@ + + + + +L-Index + + + + + + + + + + + + + + + +
+ +
+
+
+

Index

+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form +

L

+
+
left() - Method in record class com.rubynaxela.kyanite.game.entities.HitBox
+
+
Returns the value of the left record component.
+
+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form
+
+
+ + diff --git a/doc/index-files/index-13.html b/doc/index-files/index-13.html new file mode 100644 index 00000000..9d90351b --- /dev/null +++ b/doc/index-files/index-13.html @@ -0,0 +1,118 @@ + + + + +M-Index + + + + + + + + + + + + + + + +
+ +
+
+
+

Index

+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form +

M

+
+
MathUtils - Class in com.rubynaxela.kyanite.util
+
 
+
max(T, T) - Static method in class com.rubynaxela.kyanite.util.MathUtils
+
+
Returns the bigger of two numeric values.
+
+
maximize() - Method in class com.rubynaxela.kyanite.window.Window
+
+
Sets the size of the window to fill the whole screen, excluding system toolbars.
+
+
min(T, T) - Static method in class com.rubynaxela.kyanite.util.MathUtils
+
+
Returns the smaller of two numeric values.
+
+
MouseButtonListener - Interface in com.rubynaxela.kyanite.window.event
+
 
+
mouseButtonPressed(MouseButtonEvent) - Method in interface com.rubynaxela.kyanite.window.event.MouseButtonListener
+
+
Invoked when a mouse button was pressed while the window had focus.
+
+
mouseButtonReleased(MouseButtonEvent) - Method in interface com.rubynaxela.kyanite.window.event.MouseButtonListener
+
+
Invoked when a mouse button was released while the window had focus.
+
+
mouseEntered(MouseEvent) - Method in interface com.rubynaxela.kyanite.window.event.MouseListener
+
+
Invoked when the mouse cursor entered the window's boundaries.
+
+
mouseLeft(MouseEvent) - Method in interface com.rubynaxela.kyanite.window.event.MouseListener
+
+
Invoked when the mouse cursor left the window's boundaries.
+
+
MouseListener - Interface in com.rubynaxela.kyanite.window.event
+
 
+
mouseMoved(MouseEvent) - Method in interface com.rubynaxela.kyanite.window.event.MouseListener
+
+
Invoked when the mouse cursor was moved within the window's boundaries.
+
+
MouseWheelListener - Interface in com.rubynaxela.kyanite.window.event
+
 
+
mouseWheelMoved(MouseWheelEvent) - Method in interface com.rubynaxela.kyanite.window.event.MouseWheelListener
+
+
Invoked when the mouse wheel was moved while the window had focus.
+
+
move(float, float) - Method in class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
+
Moves this object.
+
+
move(float, float) - Method in class com.rubynaxela.kyanite.game.gui.Text
+
 
+
move(Vector2f) - Method in class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
+
Moves the object.
+
+
move(Vector2f) - Method in class com.rubynaxela.kyanite.game.gui.Text
+
 
+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form
+
+
+ + diff --git a/doc/index-files/index-14.html b/doc/index-files/index-14.html new file mode 100644 index 00000000..db9f4cbd --- /dev/null +++ b/doc/index-files/index-14.html @@ -0,0 +1,66 @@ + + + + +N-Index + + + + + + + + + + + + + + + +
+ +
+
+
+

Index

+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form +

N

+
+
newSize() - Method in record class com.rubynaxela.kyanite.window.event.ResizeEvent
+
+
Returns the value of the newSize record component.
+
+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form
+
+
+ + diff --git a/doc/index-files/index-15.html b/doc/index-files/index-15.html new file mode 100644 index 00000000..5be242df --- /dev/null +++ b/doc/index-files/index-15.html @@ -0,0 +1,76 @@ + + + + +P-Index + + + + + + + + + + + + + + + +
+ +
+
+
+

Index

+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form +

P

+
+
Pair<T1,T2> - Record Class in com.rubynaxela.kyanite.util
+
 
+
Pair(T1, T2) - Constructor for record class com.rubynaxela.kyanite.util.Pair
+
+
Creates an instance of a Pair record class.
+
+
pause() - Method in class com.rubynaxela.kyanite.game.assets.Sound
+
+
Pauses the sound if it is currently playing.
+
+
play() - Method in class com.rubynaxela.kyanite.game.assets.Sound
+
+
Starts playing the sound or resumes it if it is currently paused.
+
+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form
+
+
+ + diff --git a/doc/index-files/index-16.html b/doc/index-files/index-16.html new file mode 100644 index 00000000..56e8be0f --- /dev/null +++ b/doc/index-files/index-16.html @@ -0,0 +1,96 @@ + + + + +R-Index + + + + + + + + + + + + + + + +
+ +
+
+
+

Index

+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form +

R

+
+
register(String, T) - Method in class com.rubynaxela.kyanite.game.assets.AssetsBundle
+
+
Registers an Asset in the bundle.
+
+
resized(ResizeEvent) - Method in interface com.rubynaxela.kyanite.window.event.ResizeListener
+
+
Invoked when the window was resized.
+
+
ResizeEvent - Record Class in com.rubynaxela.kyanite.window.event
+
 
+
ResizeEvent(Vector2i) - Constructor for record class com.rubynaxela.kyanite.window.event.ResizeEvent
+
+
Creates an instance of a ResizeEvent record class.
+
+
ResizeListener - Interface in com.rubynaxela.kyanite.window.event
+
 
+
restart() - Method in class com.rubynaxela.kyanite.system.Clock
+
+
Yields the elapsed time and restarts the clock.
+
+
restartIfNecessary(String[]) - Static method in class com.rubynaxela.kyanite.system.FirstThreadTool
+
+
Reboots the JVM on Mac OS X with VM option -XstartOnFirstThread if the VM wasn't started with it already.
+
+
right() - Method in record class com.rubynaxela.kyanite.game.entities.HitBox
+
+
Returns the value of the right record component.
+
+
rotate(float) - Method in class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
+
Rotates this object around its origin.
+
+
rotate(float) - Method in class com.rubynaxela.kyanite.game.gui.Text
+
 
+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form
+
+
+ + diff --git a/doc/index-files/index-17.html b/doc/index-files/index-17.html new file mode 100644 index 00000000..c9901fb9 --- /dev/null +++ b/doc/index-files/index-17.html @@ -0,0 +1,240 @@ + + + + +S-Index + + + + + + + + + + + + + + + +
+ +
+
+
+

Index

+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form +

S

+
+
scale(float, float) - Method in class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
+
Scales the object, using its origin as the scaling center.
+
+
scale(float, float) - Method in class com.rubynaxela.kyanite.game.gui.Text
+
 
+
scale(Vector2f) - Method in class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
+
Scales the object, using its origin as the scaling center.
+
+
scale(Vector2f) - Method in class com.rubynaxela.kyanite.game.gui.Text
+
 
+
Scene - Class in com.rubynaxela.kyanite.window
+
+
An alias type for an ArrayList of Drawables.
+
+
Scene() - Constructor for class com.rubynaxela.kyanite.window.Scene
+
 
+
setAlignment(Text.Alignment) - Method in class com.rubynaxela.kyanite.game.gui.Text
+
+
Sets the alignment mode of this text.
+
+
setBackgroundColor(Color) - Method in class com.rubynaxela.kyanite.window.Window
+
 
+
setCloseListener(CloseListener) - Method in class com.rubynaxela.kyanite.window.Window
+
+
Adds the specified close listener to receive the close button press event from this window.
+
+
setFocusListener(FocusListener) - Method in class com.rubynaxela.kyanite.window.Window
+
+
Adds the specified focus listener to receive focus events from this window.
+
+
setFont(Font) - Method in class com.rubynaxela.kyanite.game.gui.Text
+
+
Sets the font of this text.
+
+
setJoystickButtonListener(JoystickButtonListener) - Method in class com.rubynaxela.kyanite.window.Window
+
+
Adds the specified joystick button listener to receive joystick button events from this window.
+
+
setJoystickConnectionListener(JoystickConnectionListener) - Method in class com.rubynaxela.kyanite.window.Window
+
+
Adds the specified joystick connection listener to receive joystick connection and disconnection events from this window.
+
+
setJoystickListener(JoystickListener) - Method in class com.rubynaxela.kyanite.window.Window
+
+
Adds the specified joystick listener to receive joystick movement events from this window.
+
+
setKeyListener(KeyListener) - Method in class com.rubynaxela.kyanite.window.Window
+
+
Adds the specified key listener to receive key events from this window.
+
+
setLoop(Runnable) - Method in class com.rubynaxela.kyanite.window.Scene
+
+
Sets the scene loop action which will be executed every frame
+
+
setLooping(boolean) - Method in class com.rubynaxela.kyanite.game.assets.Sound
+
 
+
setMouseButtonListener(MouseButtonListener) - Method in class com.rubynaxela.kyanite.window.Window
+
+
Adds the specified mouse button listener to receive mouse button events from this window.
+
+
setMouseListener(MouseListener) - Method in class com.rubynaxela.kyanite.window.Window
+
+
Adds the specified mouse listener to receive mouse events from this window.
+
+
setMouseWheelListener(MouseWheelListener) - Method in class com.rubynaxela.kyanite.window.Window
+
+
Adds the specified mouse wheel listener to receive mouse wheel events from this window.
+
+
setOrigin(float, float) - Method in class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
+
Sets the rotation, scaling and drawing origin of this object.
+
+
setOrigin(float, float) - Method in class com.rubynaxela.kyanite.game.gui.Text
+
 
+
setOrigin(Vector2f) - Method in class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
+
Sets the rotation, scaling and drawing origin of this object.
+
+
setPosition(float, float) - Method in class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
+
Sets the position of this object in the scene so that its origin will be exactly on it.
+
+
setPosition(float, float) - Method in class com.rubynaxela.kyanite.game.gui.Text
+
 
+
setPosition(Vector2f) - Method in class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
+
Sets the position of this object in the scene so that its origin will be exactly on it.
+
+
setResizeListener(ResizeListener) - Method in class com.rubynaxela.kyanite.window.Window
+
+
Adds the specified resize listener to receive resize events from this window.
+
+
setRotation(float) - Method in class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
+
Sets the rotation of this object around its origin.
+
+
setScale(float, float) - Method in class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
+
Sets the scaling of this object, using its origin as the scaling center.
+
+
setScale(float, float) - Method in class com.rubynaxela.kyanite.game.gui.Text
+
 
+
setScale(Vector2f) - Method in class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
+
Sets the scaling of this object, using its origin as the scaling center.
+
+
setScene(Scene) - Method in class com.rubynaxela.kyanite.window.Window
+
+
Changes the current scene of this window.
+
+
setSize(int, int) - Method in class com.rubynaxela.kyanite.window.Window
+
+
Sets the size of the window.
+
+
setSize(Vector2i) - Method in class com.rubynaxela.kyanite.window.Window
+
+
Sets the size of the window.
+
+
setSkip(Time) - Method in class com.rubynaxela.kyanite.game.assets.Sound
+
+
Sets the playing offset from where to play the underlying audio data.
+
+
setSmooth(boolean) - Method in class com.rubynaxela.kyanite.game.assets.Texture
+
+
Enables or disables the smooth filter.
+
+
setString(String) - Method in class com.rubynaxela.kyanite.game.gui.Text
+
+
Deprecated. +
Use the Text.setText(java.lang.String) method instead.
+
+
+
setText(String) - Method in class com.rubynaxela.kyanite.game.gui.Text
+
+
Sets the string to display.
+
+
setTextListener(TextListener) - Method in class com.rubynaxela.kyanite.window.Window
+
+
Adds the specified text listener to receive text input events from this window.
+
+
setTileable(boolean) - Method in class com.rubynaxela.kyanite.game.assets.Texture
+
+
Enables or disables texture repeating.
+
+
Sound - Class in com.rubynaxela.kyanite.game.assets
+
+
A wrapper class for JSFML Sound objects, representing a sound asset.
+
+
Sound(File) - Constructor for class com.rubynaxela.kyanite.game.assets.Sound
+
+
Creates a new sound from the source sound file.
+
+
Sound(String) - Constructor for class com.rubynaxela.kyanite.game.assets.Sound
+
+
Creates a new sound from the source given by the path.
+
+
Sound(Path) - Constructor for class com.rubynaxela.kyanite.game.assets.Sound
+
+
Creates a new sound from the source given by the path.
+
+
start() - Method in class com.rubynaxela.kyanite.system.Clock
+
+
Starts the clock.
+
+
startGame() - Method in class com.rubynaxela.kyanite.game.GameContext
+
+
Starts the game clock and the window loop
+
+
startLoop(GameContext) - Method in class com.rubynaxela.kyanite.window.Window
+
+
Starts the window loop.
+
+
stop() - Method in class com.rubynaxela.kyanite.game.assets.Sound
+
+
Stops the sound if it is currently playing or paused.
+
+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form
+
+
+ + diff --git a/doc/index-files/index-18.html b/doc/index-files/index-18.html new file mode 100644 index 00000000..2bcd67ac --- /dev/null +++ b/doc/index-files/index-18.html @@ -0,0 +1,132 @@ + + + + +T-Index + + + + + + + + + + + + + + + +
+ +
+
+
+

Index

+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form +

T

+
+
Text - Class in com.rubynaxela.kyanite.game.gui
+
+
Represents a graphical text that can be transformed and drawn to a render target.
+
+
Text() - Constructor for class com.rubynaxela.kyanite.game.gui.Text
+
+
Creates a new empty text.
+
+
Text(Font) - Constructor for class com.rubynaxela.kyanite.game.gui.Text
+
+
Creates a new empty text.
+
+
Text(String) - Constructor for class com.rubynaxela.kyanite.game.gui.Text
+
+
Creates an invisible text with no font.
+
+
Text(String, Font) - Constructor for class com.rubynaxela.kyanite.game.gui.Text
+
+
Creates a text.
+
+
Text.Alignment - Enum Class in com.rubynaxela.kyanite.game.gui
+
+
Values for the alignment mode.
+
+
textEntered(TextEvent) - Method in interface com.rubynaxela.kyanite.window.event.TextListener
+
+
Invoked when a text character was entered using the keyboard while the window had focus.
+
+
TextListener - Interface in com.rubynaxela.kyanite.window.event
+
 
+
Texture - Class in com.rubynaxela.kyanite.game.assets
+
+
A wrapper class for JSFML Texture objects, representing a texture asset.
+
+
Texture(File) - Constructor for class com.rubynaxela.kyanite.game.assets.Texture
+
+
Creates a new texture from the source image file.
+
+
Texture(String) - Constructor for class com.rubynaxela.kyanite.game.assets.Texture
+
+
Creates a new texture from the source given by the path.
+
+
Texture(Path) - Constructor for class com.rubynaxela.kyanite.game.assets.Texture
+
+
Creates a new texture from the source given by the path.
+
+
toFloatRect() - Method in record class com.rubynaxela.kyanite.game.entities.HitBox
+
 
+
top() - Method in record class com.rubynaxela.kyanite.game.entities.HitBox
+
+
Returns the value of the top record component.
+
+
TOP_CENTER - Enum constant in enum class com.rubynaxela.kyanite.game.gui.Text.Alignment
+
 
+
TOP_LEFT - Enum constant in enum class com.rubynaxela.kyanite.game.gui.Text.Alignment
+
 
+
TOP_RIGHT - Enum constant in enum class com.rubynaxela.kyanite.game.gui.Text.Alignment
+
 
+
toString() - Method in record class com.rubynaxela.kyanite.game.entities.HitBox
+
+
Returns a string representation of this record class.
+
+
toString() - Method in record class com.rubynaxela.kyanite.util.Pair
+
+
Returns a string representation of this record class.
+
+
toString() - Method in record class com.rubynaxela.kyanite.window.event.ResizeEvent
+
+
Returns a string representation of this record class.
+
+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form
+
+
+ + diff --git a/doc/index-files/index-19.html b/doc/index-files/index-19.html new file mode 100644 index 00000000..6352c4ff --- /dev/null +++ b/doc/index-files/index-19.html @@ -0,0 +1,79 @@ + + + + +V-Index + + + + + + + + + + + + + + + +
+ +
+
+
+

Index

+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form +

V

+
+
value1() - Method in record class com.rubynaxela.kyanite.util.Pair
+
+
Returns the value of the value1 record component.
+
+
value2() - Method in record class com.rubynaxela.kyanite.util.Pair
+
+
Returns the value of the value2 record component.
+
+
valueOf(String) - Static method in enum class com.rubynaxela.kyanite.game.gui.Text.Alignment
+
+
Returns the enum constant of this class with the specified name.
+
+
values() - Static method in enum class com.rubynaxela.kyanite.game.gui.Text.Alignment
+
+
Returns an array containing the constants of this enum class, in +the order they are declared.
+
+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form
+
+
+ + diff --git a/doc/index-files/index-2.html b/doc/index-files/index-2.html new file mode 100644 index 00000000..c22b5cf9 --- /dev/null +++ b/doc/index-files/index-2.html @@ -0,0 +1,72 @@ + + + + +B-Index + + + + + + + + + + + + + + + +
+ +
+
+
+

Index

+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form +

B

+
+
bottom() - Method in record class com.rubynaxela.kyanite.game.entities.HitBox
+
+
Returns the value of the bottom record component.
+
+
BOTTOM_CENTER - Enum constant in enum class com.rubynaxela.kyanite.game.gui.Text.Alignment
+
 
+
BOTTOM_LEFT - Enum constant in enum class com.rubynaxela.kyanite.game.gui.Text.Alignment
+
 
+
BOTTOM_RIGHT - Enum constant in enum class com.rubynaxela.kyanite.game.gui.Text.Alignment
+
 
+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form
+
+
+ + diff --git a/doc/index-files/index-20.html b/doc/index-files/index-20.html new file mode 100644 index 00000000..446c4418 --- /dev/null +++ b/doc/index-files/index-20.html @@ -0,0 +1,82 @@ + + + + +W-Index + + + + + + + + + + + + + + + +
+ +
+
+
+

Index

+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form +

W

+
+
Window - Class in com.rubynaxela.kyanite.window
+
+
Provides a window that can serve as a target for 2D drawing.
+
+
Window() - Constructor for class com.rubynaxela.kyanite.window.Window
+
+
Constructs a new render window without actually creating (opening) it.
+
+
Window(VideoMode, String) - Constructor for class com.rubynaxela.kyanite.window.Window
+
+
Constructs a new render window and creates it with default style and context settings.
+
+
Window(VideoMode, String, int) - Constructor for class com.rubynaxela.kyanite.window.Window
+
+
Constructs a new render window and creates it with default context settings.
+
+
Window(VideoMode, String, int, ContextSettings) - Constructor for class com.rubynaxela.kyanite.window.Window
+
+
Constructs a new render window and creates it with the specified parameters.
+
+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form
+
+
+ + diff --git a/doc/index-files/index-3.html b/doc/index-files/index-3.html new file mode 100644 index 00000000..670dc4c0 --- /dev/null +++ b/doc/index-files/index-3.html @@ -0,0 +1,124 @@ + + + + +C-Index + + + + + + + + + + + + + + + +
+ +
+
+
+

Index

+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form +

C

+
+
CENTER - Enum constant in enum class com.rubynaxela.kyanite.game.gui.Text.Alignment
+
 
+
CENTER_LEFT - Enum constant in enum class com.rubynaxela.kyanite.game.gui.Text.Alignment
+
 
+
CENTER_RIGHT - Enum constant in enum class com.rubynaxela.kyanite.game.gui.Text.Alignment
+
 
+
Clock - Class in com.rubynaxela.kyanite.system
+
+
Provides functionality for time measurement.
+
+
Clock() - Constructor for class com.rubynaxela.kyanite.system.Clock
+
+
Constructs a clock and starts it.
+
+
Clock(boolean) - Constructor for class com.rubynaxela.kyanite.system.Clock
+
+
Constructs a clock.
+
+
closed() - Method in interface com.rubynaxela.kyanite.window.event.CloseListener
+
+
Invoked when the user clicked on the window's close button.
+
+
CloseListener - Interface in com.rubynaxela.kyanite.window.event
+
 
+
com.rubynaxela.kyanite.game - package com.rubynaxela.kyanite.game
+
+
Contains classes related to the game content.
+
+
com.rubynaxela.kyanite.game.assets - package com.rubynaxela.kyanite.game.assets
+
+
Contains classes related to assets, which are loaded from external sources.
+
+
com.rubynaxela.kyanite.game.entities - package com.rubynaxela.kyanite.game.entities
+
 
+
com.rubynaxela.kyanite.game.gui - package com.rubynaxela.kyanite.game.gui
+
 
+
com.rubynaxela.kyanite.system - package com.rubynaxela.kyanite.system
+
+
Contains classes that provide core functionality, common data types and exceptions.
+
+
com.rubynaxela.kyanite.util - package com.rubynaxela.kyanite.util
+
 
+
com.rubynaxela.kyanite.window - package com.rubynaxela.kyanite.window
+
+
Contains classes related to graphic interface
+
+
com.rubynaxela.kyanite.window.event - package com.rubynaxela.kyanite.window.event
+
+
Contains classes representing window events and event listeners.
+
+
CompoundEntity - Class in com.rubynaxela.kyanite.game.entities
+
+
An entity consisting of many components.
+
+
CompoundEntity() - Constructor for class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
+
Creates an empty compound entity.
+
+
CompoundEntity(Vector2f) - Constructor for class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
+
Creates an empty compound entity with initial position.
+
+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form
+
+
+ + diff --git a/doc/index-files/index-4.html b/doc/index-files/index-4.html new file mode 100644 index 00000000..16e280d7 --- /dev/null +++ b/doc/index-files/index-4.html @@ -0,0 +1,66 @@ + + + + +D-Index + + + + + + + + + + + + + + + +
+ +
+
+
+

Index

+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form +

D

+
+
draw(RenderTarget, RenderStates) - Method in class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
+
Draws a drawable object to the render target using the given render states.
+
+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form
+
+
+ + diff --git a/doc/index-files/index-5.html b/doc/index-files/index-5.html new file mode 100644 index 00000000..bfe37af5 --- /dev/null +++ b/doc/index-files/index-5.html @@ -0,0 +1,74 @@ + + + + +E-Index + + + + + + + + + + + + + + + +
+ +
+
+
+

Index

+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form +

E

+
+
equals(Object) - Method in record class com.rubynaxela.kyanite.game.entities.HitBox
+
+
Indicates whether some other object is "equal to" this one.
+
+
equals(Object) - Method in record class com.rubynaxela.kyanite.util.Pair
+
+
Indicates whether some other object is "equal to" this one.
+
+
equals(Object) - Method in record class com.rubynaxela.kyanite.window.event.ResizeEvent
+
+
Indicates whether some other object is "equal to" this one.
+
+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form
+
+
+ + diff --git a/doc/index-files/index-6.html b/doc/index-files/index-6.html new file mode 100644 index 00000000..180cbbac --- /dev/null +++ b/doc/index-files/index-6.html @@ -0,0 +1,104 @@ + + + + +F-Index + + + + + + + + + + + + + + + +
+ +
+
+
+

Index

+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form +

F

+
+
FirstThreadTool - Class in com.rubynaxela.kyanite.system
+
+
If the application is running on macOS, it must be started with the -XstartOnFirstThread JVM option.
+
+
focusGained() - Method in interface com.rubynaxela.kyanite.window.event.FocusListener
+
+
Invoked when the window lost focus.
+
+
FocusListener - Interface in com.rubynaxela.kyanite.window.event
+
 
+
focusLost() - Method in interface com.rubynaxela.kyanite.window.event.FocusListener
+
+
Invoked when the window gained focus.
+
+
Font - Class in com.rubynaxela.kyanite.game.gui
+
 
+
Font(FontFace, int) - Constructor for class com.rubynaxela.kyanite.game.gui.Font
+
+
Creates a new font with default style.
+
+
Font(FontFace, int, int) - Constructor for class com.rubynaxela.kyanite.game.gui.Font
+
+
Creates a new font.
+
+
FontFace - Class in com.rubynaxela.kyanite.game.assets
+
+
A wrapper class for JSFML Font objects, representing a font face asset.
+
+
FontFace(File) - Constructor for class com.rubynaxela.kyanite.game.assets.FontFace
+
+
Creates a new font from the source font file.
+
+
FontFace(String) - Constructor for class com.rubynaxela.kyanite.game.assets.FontFace
+
+
Creates a new font from the source given by the path.
+
+
FontFace(Path) - Constructor for class com.rubynaxela.kyanite.game.assets.FontFace
+
+
Creates a new font from the source given by the path.
+
+
from(FloatRect) - Static method in record class com.rubynaxela.kyanite.game.entities.HitBox
+
 
+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form
+
+
+ + diff --git a/doc/index-files/index-7.html b/doc/index-files/index-7.html new file mode 100644 index 00000000..cffc4818 --- /dev/null +++ b/doc/index-files/index-7.html @@ -0,0 +1,122 @@ + + + + +G-Index + + + + + + + + + + + + + + + +
+ +
+
+
+

Index

+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form +

G

+
+
GameContext - Class in com.rubynaxela.kyanite.game
+
+
Provides a set of references to the basic objects used by the game.
+
+
get(String) - Method in class com.rubynaxela.kyanite.game.assets.AssetsBundle
+
+
Finds an Asset by its identifier.
+
+
getAlignment() - Method in class com.rubynaxela.kyanite.game.gui.Text
+
 
+
getAssetsBundle() - Method in class com.rubynaxela.kyanite.game.GameContext
+
 
+
getClock() - Method in class com.rubynaxela.kyanite.game.GameContext
+
 
+
getDeltaTime() - Method in class com.rubynaxela.kyanite.system.Clock
+
+
Gets the elapsed time since the clock was created or this function was last called.
+
+
getFontFace() - Method in class com.rubynaxela.kyanite.game.gui.Font
+
 
+
getGlobalBounds() - Method in class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
 
+
getInstance() - Static method in class com.rubynaxela.kyanite.game.GameContext
+
 
+
getInverseTransform() - Method in class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
 
+
getInverseTransform() - Method in class com.rubynaxela.kyanite.game.gui.Text
+
 
+
getOrigin() - Method in class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
 
+
getOrigin() - Method in class com.rubynaxela.kyanite.game.gui.Text
+
 
+
getPosition() - Method in class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
 
+
getPosition() - Method in class com.rubynaxela.kyanite.game.gui.Text
+
 
+
getRotation() - Method in class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
 
+
getRotation() - Method in class com.rubynaxela.kyanite.game.gui.Text
+
 
+
getScale() - Method in class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
 
+
getScale() - Method in class com.rubynaxela.kyanite.game.gui.Text
+
 
+
getScene() - Method in class com.rubynaxela.kyanite.window.Window
+
 
+
getSize() - Method in class com.rubynaxela.kyanite.game.gui.Font
+
 
+
getStyle() - Method in class com.rubynaxela.kyanite.game.gui.Font
+
 
+
getTime() - Method in class com.rubynaxela.kyanite.system.Clock
+
+
Gets the elapsed time since the clock was created or last restarted.
+
+
getTransform() - Method in class com.rubynaxela.kyanite.game.entities.CompoundEntity
+
 
+
getTransform() - Method in class com.rubynaxela.kyanite.game.gui.Text
+
 
+
getWindow() - Method in class com.rubynaxela.kyanite.game.GameContext
+
 
+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form
+
+
+ + diff --git a/doc/index-files/index-8.html b/doc/index-files/index-8.html new file mode 100644 index 00000000..6d96610d --- /dev/null +++ b/doc/index-files/index-8.html @@ -0,0 +1,80 @@ + + + + +H-Index + + + + + + + + + + + + + + + +
+ +
+
+
+

Index

+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form +

H

+
+
hashCode() - Method in record class com.rubynaxela.kyanite.game.entities.HitBox
+
+
Returns a hash code value for this object.
+
+
hashCode() - Method in record class com.rubynaxela.kyanite.util.Pair
+
+
Returns a hash code value for this object.
+
+
hashCode() - Method in record class com.rubynaxela.kyanite.window.event.ResizeEvent
+
+
Returns a hash code value for this object.
+
+
HitBox - Record Class in com.rubynaxela.kyanite.game.entities
+
 
+
HitBox(float, float, float, float) - Constructor for record class com.rubynaxela.kyanite.game.entities.HitBox
+
+
Creates an instance of a HitBox record class.
+
+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form
+
+
+ + diff --git a/doc/index-files/index-9.html b/doc/index-files/index-9.html new file mode 100644 index 00000000..c5493495 --- /dev/null +++ b/doc/index-files/index-9.html @@ -0,0 +1,68 @@ + + + + +I-Index + + + + + + + + + + + + + + + +
+ +
+
+
+

Index

+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form +

I

+
+
isInitialized() - Method in class com.rubynaxela.kyanite.window.Scene
+
 
+
isSmooth() - Method in class com.rubynaxela.kyanite.game.assets.Texture
+
 
+
isTileable() - Method in class com.rubynaxela.kyanite.game.assets.Texture
+
 
+
+A B C D E F G H I J K L M N P R S T V W 
All Classes and Interfaces|All Packages|Serialized Form
+
+
+ + diff --git a/doc/index.html b/doc/index.html new file mode 100644 index 00000000..54f437f6 --- /dev/null +++ b/doc/index.html @@ -0,0 +1,88 @@ + + + + +Overview + + + + + + + + + + + + + + + +
+ +
+
+
+
Packages
+
+
Package
+
Description
+ +
+
Contains classes related to the game content.
+
+ +
+
Contains classes related to assets, which are loaded from external sources.
+
+ +
 
+ +
 
+ +
+
Contains classes that provide core functionality, common data types and exceptions.
+
+ +
 
+ +
+
Contains classes related to graphic interface
+
+ +
+
Contains classes representing window events and event listeners.
+
+
+
+
+
+
+ + diff --git a/doc/jquery-ui.overrides.css b/doc/jquery-ui.overrides.css new file mode 100644 index 00000000..f89acb63 --- /dev/null +++ b/doc/jquery-ui.overrides.css @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +.ui-state-active, +.ui-widget-content .ui-state-active, +.ui-widget-header .ui-state-active, +a.ui-button:active, +.ui-button:active, +.ui-button.ui-state-active:hover { + /* Overrides the color of selection used in jQuery UI */ + background: #F8981D; +} diff --git a/doc/legal/ADDITIONAL_LICENSE_INFO b/doc/legal/ADDITIONAL_LICENSE_INFO new file mode 100644 index 00000000..ff700cd0 --- /dev/null +++ b/doc/legal/ADDITIONAL_LICENSE_INFO @@ -0,0 +1,37 @@ + ADDITIONAL INFORMATION ABOUT LICENSING + +Certain files distributed by Oracle America, Inc. and/or its affiliates are +subject to the following clarification and special exception to the GPLv2, +based on the GNU Project exception for its Classpath libraries, known as the +GNU Classpath Exception. + +Note that Oracle includes multiple, independent programs in this software +package. Some of those programs are provided under licenses deemed +incompatible with the GPLv2 by the Free Software Foundation and others. +For example, the package includes programs licensed under the Apache +License, Version 2.0 and may include FreeType. Such programs are licensed +to you under their original licenses. + +Oracle facilitates your further distribution of this package by adding the +Classpath Exception to the necessary parts of its GPLv2 code, which permits +you to use that code in combination with other independent modules not +licensed under the GPLv2. However, note that this would not permit you to +commingle code under an incompatible license with Oracle's GPLv2 licensed +code by, for example, cutting and pasting such code into a file also +containing Oracle's GPLv2 licensed code and then distributing the result. + +Additionally, if you were to remove the Classpath Exception from any of the +files to which it applies and distribute the result, you would likely be +required to license some or all of the other code in that distribution under +the GPLv2 as well, and since the GPLv2 is incompatible with the license terms +of some items included in the distribution by Oracle, removing the Classpath +Exception could therefore effectively compromise your ability to further +distribute the package. + +Failing to distribute notices associated with some files may also create +unexpected legal consequences. + +Proceed with caution and we recommend that you obtain the advice of a lawyer +skilled in open source matters before removing the Classpath Exception or +making modifications to this package which may subsequently be redistributed +and/or involve the use of third party software. diff --git a/doc/legal/ASSEMBLY_EXCEPTION b/doc/legal/ASSEMBLY_EXCEPTION new file mode 100644 index 00000000..065b8d90 --- /dev/null +++ b/doc/legal/ASSEMBLY_EXCEPTION @@ -0,0 +1,27 @@ + +OPENJDK ASSEMBLY EXCEPTION + +The OpenJDK source code made available by Oracle America, Inc. (Oracle) at +openjdk.java.net ("OpenJDK Code") is distributed under the terms of the GNU +General Public License version 2 +only ("GPL2"), with the following clarification and special exception. + + Linking this OpenJDK Code statically or dynamically with other code + is making a combined work based on this library. Thus, the terms + and conditions of GPL2 cover the whole combination. + + As a special exception, Oracle gives you permission to link this + OpenJDK Code with certain code licensed by Oracle as indicated at + http://openjdk.java.net/legal/exception-modules-2007-05-08.html + ("Designated Exception Modules") to produce an executable, + regardless of the license terms of the Designated Exception Modules, + and to copy and distribute the resulting executable under GPL2, + provided that the Designated Exception Modules continue to be + governed by the licenses under which they were offered by Oracle. + +As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code +to build an executable that includes those portions of necessary code that +Oracle could not provide under GPL2 (or that Oracle has provided under GPL2 +with the Classpath exception). If you modify or add to the OpenJDK code, +that new GPL2 code may still be combined with Designated Exception Modules +if the new code is made subject to this exception by its copyright holder. diff --git a/doc/legal/LICENSE b/doc/legal/LICENSE new file mode 100644 index 00000000..8b400c7a --- /dev/null +++ b/doc/legal/LICENSE @@ -0,0 +1,347 @@ +The GNU General Public License (GPL) + +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Everyone is permitted to copy and distribute verbatim copies of this license +document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share +and change it. By contrast, the GNU General Public License is intended to +guarantee your freedom to share and change free software--to make sure the +software is free for all its users. This General Public License applies to +most of the Free Software Foundation's software and to any other program whose +authors commit to using it. (Some other Free Software Foundation software is +covered by the GNU Library General Public License instead.) You can apply it to +your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our +General Public Licenses are designed to make sure that you have the freedom to +distribute copies of free software (and charge for this service if you wish), +that you receive source code or can get it if you want it, that you can change +the software or use pieces of it in new free programs; and that you know you +can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny +you these rights or to ask you to surrender the rights. These restrictions +translate to certain responsibilities for you if you distribute copies of the +software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for +a fee, you must give the recipients all the rights that you have. You must +make sure that they, too, receive or can get the source code. And you must +show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) +offer you this license which gives you legal permission to copy, distribute +and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that +everyone understands that there is no warranty for this free software. If the +software is modified by someone else and passed on, we want its recipients to +know that what they have is not the original, so that any problems introduced +by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We +wish to avoid the danger that redistributors of a free program will +individually obtain patent licenses, in effect making the program proprietary. +To prevent this, we have made it clear that any patent must be licensed for +everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification +follow. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice +placed by the copyright holder saying it may be distributed under the terms of +this General Public License. The "Program", below, refers to any such program +or work, and a "work based on the Program" means either the Program or any +derivative work under copyright law: that is to say, a work containing the +Program or a portion of it, either verbatim or with modifications and/or +translated into another language. (Hereinafter, translation is included +without limitation in the term "modification".) Each licensee is addressed as +"you". + +Activities other than copying, distribution and modification are not covered by +this License; they are outside its scope. The act of running the Program is +not restricted, and the output from the Program is covered only if its contents +constitute a work based on the Program (independent of having been made by +running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as +you receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice and +disclaimer of warranty; keep intact all the notices that refer to this License +and to the absence of any warranty; and give any other recipients of the +Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may +at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus +forming a work based on the Program, and copy and distribute such modifications +or work under the terms of Section 1 above, provided that you also meet all of +these conditions: + + a) You must cause the modified files to carry prominent notices stating + that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in whole or + in part contains or is derived from the Program or any part thereof, to be + licensed as a whole at no charge to all third parties under the terms of + this License. + + c) If the modified program normally reads commands interactively when run, + you must cause it, when started running for such interactive use in the + most ordinary way, to print or display an announcement including an + appropriate copyright notice and a notice that there is no warranty (or + else, saying that you provide a warranty) and that users may redistribute + the program under these conditions, and telling the user how to view a copy + of this License. (Exception: if the Program itself is interactive but does + not normally print such an announcement, your work based on the Program is + not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable +sections of that work are not derived from the Program, and can be reasonably +considered independent and separate works in themselves, then this License, and +its terms, do not apply to those sections when you distribute them as separate +works. But when you distribute the same sections as part of a whole which is a +work based on the Program, the distribution of the whole must be on the terms +of this License, whose permissions for other licensees extend to the entire +whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your +rights to work written entirely by you; rather, the intent is to exercise the +right to control the distribution of derivative or collective works based on +the Program. + +In addition, mere aggregation of another work not based on the Program with the +Program (or with a work based on the Program) on a volume of a storage or +distribution medium does not bring the other work under the scope of this +License. + +3. You may copy and distribute the Program (or a work based on it, under +Section 2) in object code or executable form under the terms of Sections 1 and +2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable source + code, which must be distributed under the terms of Sections 1 and 2 above + on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three years, to + give any third party, for a charge no more than your cost of physically + performing source distribution, a complete machine-readable copy of the + corresponding source code, to be distributed under the terms of Sections 1 + and 2 above on a medium customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer to + distribute corresponding source code. (This alternative is allowed only + for noncommercial distribution and only if you received the program in + object code or executable form with such an offer, in accord with + Subsection b above.) + +The source code for a work means the preferred form of the work for making +modifications to it. For an executable work, complete source code means all +the source code for all modules it contains, plus any associated interface +definition files, plus the scripts used to control compilation and installation +of the executable. However, as a special exception, the source code +distributed need not include anything that is normally distributed (in either +source or binary form) with the major components (compiler, kernel, and so on) +of the operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the source +code from the same place counts as distribution of the source code, even though +third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as +expressly provided under this License. Any attempt otherwise to copy, modify, +sublicense or distribute the Program is void, and will automatically terminate +your rights under this License. However, parties who have received copies, or +rights, from you under this License will not have their licenses terminated so +long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. +However, nothing else grants you permission to modify or distribute the Program +or its derivative works. These actions are prohibited by law if you do not +accept this License. Therefore, by modifying or distributing the Program (or +any work based on the Program), you indicate your acceptance of this License to +do so, and all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), +the recipient automatically receives a license from the original licensor to +copy, distribute or modify the Program subject to these terms and conditions. +You may not impose any further restrictions on the recipients' exercise of the +rights granted herein. You are not responsible for enforcing compliance by +third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), conditions +are imposed on you (whether by court order, agreement or otherwise) that +contradict the conditions of this License, they do not excuse you from the +conditions of this License. If you cannot distribute so as to satisfy +simultaneously your obligations under this License and any other pertinent +obligations, then as a consequence you may not distribute the Program at all. +For example, if a patent license would not permit royalty-free redistribution +of the Program by all those who receive copies directly or indirectly through +you, then the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply and +the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or +other property right claims or to contest validity of any such claims; this +section has the sole purpose of protecting the integrity of the free software +distribution system, which is implemented by public license practices. Many +people have made generous contributions to the wide range of software +distributed through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing to +distribute software through any other system and a licensee cannot impose that +choice. + +This section is intended to make thoroughly clear what is believed to be a +consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain +countries either by patents or by copyrighted interfaces, the original +copyright holder who places the Program under this License may add an explicit +geographical distribution limitation excluding those countries, so that +distribution is permitted only in or among countries not thus excluded. In +such case, this License incorporates the limitation as if written in the body +of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the +General Public License from time to time. Such new versions will be similar in +spirit to the present version, but may differ in detail to address new problems +or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any later +version", you have the option of following the terms and conditions either of +that version or of any later version published by the Free Software Foundation. +If the Program does not specify a version number of this License, you may +choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs +whose distribution conditions are different, write to the author to ask for +permission. For software which is copyrighted by the Free Software Foundation, +write to the Free Software Foundation; we sometimes make exceptions for this. +Our decision will be guided by the two goals of preserving the free status of +all derivatives of our free software and of promoting the sharing and reuse of +software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR +THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE +STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE +PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND +PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, +YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL +ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE +PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR +INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA +BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER +OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible +use to the public, the best way to achieve this is to make it free software +which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach +them to the start of each source file to most effectively convey the exclusion +of warranty; and each file should have at least the "copyright" line and a +pointer to where the full notice is found. + + One line to give the program's name and a brief idea of what it does. + + Copyright (C) + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when it +starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author Gnomovision comes + with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free + software, and you are welcome to redistribute it under certain conditions; + type 'show c' for details. + +The hypothetical commands 'show w' and 'show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may be +called something other than 'show w' and 'show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, +if any, to sign a "copyright disclaimer" for the program, if necessary. Here +is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + 'Gnomovision' (which makes passes at compilers) written by James Hacker. + + signature of Ty Coon, 1 April 1989 + + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General Public +License instead of this License. + + +"CLASSPATH" EXCEPTION TO THE GPL + +Certain source files distributed by Oracle America and/or its affiliates are +subject to the following clarification and special exception to the GPL, but +only where Oracle has expressly included in the particular source file's header +the words "Oracle designates this particular file as subject to the "Classpath" +exception as provided by Oracle in the LICENSE file that accompanied this code." + + Linking this library statically or dynamically with other modules is making + a combined work based on this library. Thus, the terms and conditions of + the GNU General Public License cover the whole combination. + + As a special exception, the copyright holders of this library give you + permission to link this library with independent modules to produce an + executable, regardless of the license terms of these independent modules, + and to copy and distribute the resulting executable under terms of your + choice, provided that you also meet, for each linked independent module, + the terms and conditions of the license of that module. An independent + module is a module which is not derived from or based on this library. If + you modify this library, you may extend this exception to your version of + the library, but you are not obligated to do so. If you do not wish to do + so, delete this exception statement from your version. diff --git a/doc/legal/jquery.md b/doc/legal/jquery.md new file mode 100644 index 00000000..8054a34c --- /dev/null +++ b/doc/legal/jquery.md @@ -0,0 +1,72 @@ +## jQuery v3.5.1 + +### jQuery License +``` +jQuery v 3.5.1 +Copyright JS Foundation and other contributors, https://js.foundation/ + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +****************************************** + +The jQuery JavaScript Library v3.5.1 also includes Sizzle.js + +Sizzle.js includes the following license: + +Copyright JS Foundation and other contributors, https://js.foundation/ + +This software consists of voluntary contributions made by many +individuals. For exact contribution history, see the revision history +available at https://github.com/jquery/sizzle + +The following license applies to all parts of this software except as +documented below: + +==== + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +==== + +All files located in the node_modules and external directories are +externally maintained libraries used by this software which have their +own licenses; we recommend you read them, as their terms may differ from +the terms above. + +********************* + +``` diff --git a/doc/legal/jqueryUI.md b/doc/legal/jqueryUI.md new file mode 100644 index 00000000..8031bdb5 --- /dev/null +++ b/doc/legal/jqueryUI.md @@ -0,0 +1,49 @@ +## jQuery UI v1.12.1 + +### jQuery UI License +``` +Copyright jQuery Foundation and other contributors, https://jquery.org/ + +This software consists of voluntary contributions made by many +individuals. For exact contribution history, see the revision history +available at https://github.com/jquery/jquery-ui + +The following license applies to all parts of this software except as +documented below: + +==== + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +==== + +Copyright and related rights for sample code are waived via CC0. Sample +code is defined as all source code contained within the demos directory. + +CC0: http://creativecommons.org/publicdomain/zero/1.0/ + +==== + +All files located in the node_modules and external directories are +externally maintained libraries used by this software which have their +own licenses; we recommend you read them, as their terms may differ from +the terms above. + +``` diff --git a/doc/member-search-index.js b/doc/member-search-index.js new file mode 100644 index 00000000..072cb31e --- /dev/null +++ b/doc/member-search-index.js @@ -0,0 +1 @@ +memberSearchIndex = [{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"add(Object, Vector2f)","u":"add(java.lang.Object,org.jsfml.system.Vector2f)"},{"p":"com.rubynaxela.kyanite.game.assets","c":"Texture","l":"apply(Shape)","u":"apply(org.jsfml.graphics.Shape)"},{"p":"com.rubynaxela.kyanite.game.assets","c":"Texture","l":"apply(Sprite)","u":"apply(org.jsfml.graphics.Sprite)"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Font","l":"apply(Text)","u":"apply(org.jsfml.graphics.Text)"},{"p":"com.rubynaxela.kyanite.game.assets","c":"FontFace","l":"apply(Text)","u":"apply(org.jsfml.graphics.Text)"},{"p":"com.rubynaxela.kyanite.game.assets","c":"AssetsBundle","l":"AssetsBundle()","u":"%3Cinit%3E()"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Text.Alignment","l":"BOTTOM_CENTER"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Text.Alignment","l":"BOTTOM_LEFT"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Text.Alignment","l":"BOTTOM_RIGHT"},{"p":"com.rubynaxela.kyanite.game.entities","c":"HitBox","l":"bottom()"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Text.Alignment","l":"CENTER"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Text.Alignment","l":"CENTER_LEFT"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Text.Alignment","l":"CENTER_RIGHT"},{"p":"com.rubynaxela.kyanite.system","c":"Clock","l":"Clock()","u":"%3Cinit%3E()"},{"p":"com.rubynaxela.kyanite.system","c":"Clock","l":"Clock(boolean)","u":"%3Cinit%3E(boolean)"},{"p":"com.rubynaxela.kyanite.window.event","c":"CloseListener","l":"closed()"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"CompoundEntity()","u":"%3Cinit%3E()"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"CompoundEntity(Vector2f)","u":"%3Cinit%3E(org.jsfml.system.Vector2f)"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"draw(RenderTarget, RenderStates)","u":"draw(org.jsfml.graphics.RenderTarget,org.jsfml.graphics.RenderStates)"},{"p":"com.rubynaxela.kyanite.game.entities","c":"HitBox","l":"equals(Object)","u":"equals(java.lang.Object)"},{"p":"com.rubynaxela.kyanite.util","c":"Pair","l":"equals(Object)","u":"equals(java.lang.Object)"},{"p":"com.rubynaxela.kyanite.window.event","c":"ResizeEvent","l":"equals(Object)","u":"equals(java.lang.Object)"},{"p":"com.rubynaxela.kyanite.window.event","c":"FocusListener","l":"focusGained()"},{"p":"com.rubynaxela.kyanite.window.event","c":"FocusListener","l":"focusLost()"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Font","l":"Font(FontFace, int)","u":"%3Cinit%3E(com.rubynaxela.kyanite.game.assets.FontFace,int)"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Font","l":"Font(FontFace, int, int)","u":"%3Cinit%3E(com.rubynaxela.kyanite.game.assets.FontFace,int,int)"},{"p":"com.rubynaxela.kyanite.game.assets","c":"FontFace","l":"FontFace(File)","u":"%3Cinit%3E(java.io.File)"},{"p":"com.rubynaxela.kyanite.game.assets","c":"FontFace","l":"FontFace(Path)","u":"%3Cinit%3E(java.nio.file.Path)"},{"p":"com.rubynaxela.kyanite.game.assets","c":"FontFace","l":"FontFace(String)","u":"%3Cinit%3E(java.lang.String)"},{"p":"com.rubynaxela.kyanite.game.entities","c":"HitBox","l":"from(FloatRect)","u":"from(org.jsfml.graphics.FloatRect)"},{"p":"com.rubynaxela.kyanite.game.assets","c":"AssetsBundle","l":"get(String)","u":"get(java.lang.String)"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Text","l":"getAlignment()"},{"p":"com.rubynaxela.kyanite.game","c":"GameContext","l":"getAssetsBundle()"},{"p":"com.rubynaxela.kyanite.game","c":"GameContext","l":"getClock()"},{"p":"com.rubynaxela.kyanite.system","c":"Clock","l":"getDeltaTime()"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Font","l":"getFontFace()"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"getGlobalBounds()"},{"p":"com.rubynaxela.kyanite.game","c":"GameContext","l":"getInstance()"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"getInverseTransform()"},{"p":"org.jsfml.graphics","c":"Text","l":"getInverseTransform()"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"getOrigin()"},{"p":"org.jsfml.graphics","c":"Text","l":"getOrigin()"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"getPosition()"},{"p":"org.jsfml.graphics","c":"Text","l":"getPosition()"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"getRotation()"},{"p":"org.jsfml.graphics","c":"Text","l":"getRotation()"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"getScale()"},{"p":"org.jsfml.graphics","c":"Text","l":"getScale()"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"getScene()"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Font","l":"getSize()"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Font","l":"getStyle()"},{"p":"com.rubynaxela.kyanite.system","c":"Clock","l":"getTime()"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"getTransform()"},{"p":"org.jsfml.graphics","c":"Text","l":"getTransform()"},{"p":"com.rubynaxela.kyanite.game","c":"GameContext","l":"getWindow()"},{"p":"com.rubynaxela.kyanite.game.entities","c":"HitBox","l":"hashCode()"},{"p":"com.rubynaxela.kyanite.util","c":"Pair","l":"hashCode()"},{"p":"com.rubynaxela.kyanite.window.event","c":"ResizeEvent","l":"hashCode()"},{"p":"com.rubynaxela.kyanite.game.entities","c":"HitBox","l":"HitBox(float, float, float, float)","u":"%3Cinit%3E(float,float,float,float)"},{"p":"com.rubynaxela.kyanite.window","c":"Scene","l":"isInitialized()"},{"p":"com.rubynaxela.kyanite.game.assets","c":"Texture","l":"isSmooth()"},{"p":"com.rubynaxela.kyanite.game.assets","c":"Texture","l":"isTileable()"},{"p":"com.rubynaxela.kyanite.window.event","c":"JoystickButtonListener","l":"joystickButtonPressed(JoystickButtonEvent)","u":"joystickButtonPressed(org.jsfml.window.event.JoystickButtonEvent)"},{"p":"com.rubynaxela.kyanite.window.event","c":"JoystickButtonListener","l":"joystickButtonReleased(JoystickButtonEvent)","u":"joystickButtonReleased(org.jsfml.window.event.JoystickButtonEvent)"},{"p":"com.rubynaxela.kyanite.window.event","c":"JoystickConnectionListener","l":"joystickConnected(JoystickEvent)","u":"joystickConnected(org.jsfml.window.event.JoystickEvent)"},{"p":"com.rubynaxela.kyanite.window.event","c":"JoystickConnectionListener","l":"joystickDisconnected(JoystickEvent)","u":"joystickDisconnected(org.jsfml.window.event.JoystickEvent)"},{"p":"com.rubynaxela.kyanite.window.event","c":"JoystickListener","l":"joystickMoved(JoystickMoveEvent)","u":"joystickMoved(org.jsfml.window.event.JoystickMoveEvent)"},{"p":"com.rubynaxela.kyanite.window.event","c":"KeyListener","l":"keyPressed(KeyEvent)","u":"keyPressed(org.jsfml.window.event.KeyEvent)"},{"p":"com.rubynaxela.kyanite.window.event","c":"KeyListener","l":"keyReleased(KeyEvent)","u":"keyReleased(org.jsfml.window.event.KeyEvent)"},{"p":"com.rubynaxela.kyanite.game.entities","c":"HitBox","l":"left()"},{"p":"com.rubynaxela.kyanite.util","c":"MathUtils","l":"max(T, T)","u":"max(T,T)"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"maximize()"},{"p":"com.rubynaxela.kyanite.util","c":"MathUtils","l":"min(T, T)","u":"min(T,T)"},{"p":"com.rubynaxela.kyanite.window.event","c":"MouseButtonListener","l":"mouseButtonPressed(MouseButtonEvent)","u":"mouseButtonPressed(org.jsfml.window.event.MouseButtonEvent)"},{"p":"com.rubynaxela.kyanite.window.event","c":"MouseButtonListener","l":"mouseButtonReleased(MouseButtonEvent)","u":"mouseButtonReleased(org.jsfml.window.event.MouseButtonEvent)"},{"p":"com.rubynaxela.kyanite.window.event","c":"MouseListener","l":"mouseEntered(MouseEvent)","u":"mouseEntered(org.jsfml.window.event.MouseEvent)"},{"p":"com.rubynaxela.kyanite.window.event","c":"MouseListener","l":"mouseLeft(MouseEvent)","u":"mouseLeft(org.jsfml.window.event.MouseEvent)"},{"p":"com.rubynaxela.kyanite.window.event","c":"MouseListener","l":"mouseMoved(MouseEvent)","u":"mouseMoved(org.jsfml.window.event.MouseEvent)"},{"p":"com.rubynaxela.kyanite.window.event","c":"MouseWheelListener","l":"mouseWheelMoved(MouseWheelEvent)","u":"mouseWheelMoved(org.jsfml.window.event.MouseWheelEvent)"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"move(float, float)","u":"move(float,float)"},{"p":"org.jsfml.graphics","c":"Text","l":"move(float, float)","u":"move(float,float)"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"move(Vector2f)","u":"move(org.jsfml.system.Vector2f)"},{"p":"org.jsfml.graphics","c":"Text","l":"move(Vector2f)","u":"move(org.jsfml.system.Vector2f)"},{"p":"com.rubynaxela.kyanite.window.event","c":"ResizeEvent","l":"newSize()"},{"p":"com.rubynaxela.kyanite.util","c":"Pair","l":"Pair(T1, T2)","u":"%3Cinit%3E(T1,T2)"},{"p":"com.rubynaxela.kyanite.game.assets","c":"Sound","l":"pause()"},{"p":"com.rubynaxela.kyanite.game.assets","c":"Sound","l":"play()"},{"p":"com.rubynaxela.kyanite.game.assets","c":"AssetsBundle","l":"register(String, T)","u":"register(java.lang.String,T)"},{"p":"com.rubynaxela.kyanite.window.event","c":"ResizeListener","l":"resized(ResizeEvent)","u":"resized(com.rubynaxela.kyanite.window.event.ResizeEvent)"},{"p":"com.rubynaxela.kyanite.window.event","c":"ResizeEvent","l":"ResizeEvent(Vector2i)","u":"%3Cinit%3E(org.jsfml.system.Vector2i)"},{"p":"com.rubynaxela.kyanite.system","c":"Clock","l":"restart()"},{"p":"com.rubynaxela.kyanite.system","c":"FirstThreadTool","l":"restartIfNecessary(String[])","u":"restartIfNecessary(java.lang.String[])"},{"p":"com.rubynaxela.kyanite.game.entities","c":"HitBox","l":"right()"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"rotate(float)"},{"p":"org.jsfml.graphics","c":"Text","l":"rotate(float)"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"scale(float, float)","u":"scale(float,float)"},{"p":"org.jsfml.graphics","c":"Text","l":"scale(float, float)","u":"scale(float,float)"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"scale(Vector2f)","u":"scale(org.jsfml.system.Vector2f)"},{"p":"org.jsfml.graphics","c":"Text","l":"scale(Vector2f)","u":"scale(org.jsfml.system.Vector2f)"},{"p":"com.rubynaxela.kyanite.window","c":"Scene","l":"Scene()","u":"%3Cinit%3E()"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Text","l":"setAlignment(Text.Alignment)","u":"setAlignment(com.rubynaxela.kyanite.game.gui.Text.Alignment)"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"setBackgroundColor(Color)","u":"setBackgroundColor(org.jsfml.graphics.Color)"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"setCloseListener(CloseListener)","u":"setCloseListener(com.rubynaxela.kyanite.window.event.CloseListener)"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"setFocusListener(FocusListener)","u":"setFocusListener(com.rubynaxela.kyanite.window.event.FocusListener)"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Text","l":"setFont(Font)","u":"setFont(com.rubynaxela.kyanite.game.gui.Font)"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"setJoystickButtonListener(JoystickButtonListener)","u":"setJoystickButtonListener(com.rubynaxela.kyanite.window.event.JoystickButtonListener)"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"setJoystickConnectionListener(JoystickConnectionListener)","u":"setJoystickConnectionListener(com.rubynaxela.kyanite.window.event.JoystickConnectionListener)"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"setJoystickListener(JoystickListener)","u":"setJoystickListener(com.rubynaxela.kyanite.window.event.JoystickListener)"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"setKeyListener(KeyListener)","u":"setKeyListener(com.rubynaxela.kyanite.window.event.KeyListener)"},{"p":"com.rubynaxela.kyanite.window","c":"Scene","l":"setLoop(Runnable)","u":"setLoop(java.lang.Runnable)"},{"p":"com.rubynaxela.kyanite.game.assets","c":"Sound","l":"setLooping(boolean)"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"setMouseButtonListener(MouseButtonListener)","u":"setMouseButtonListener(com.rubynaxela.kyanite.window.event.MouseButtonListener)"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"setMouseListener(MouseListener)","u":"setMouseListener(com.rubynaxela.kyanite.window.event.MouseListener)"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"setMouseWheelListener(MouseWheelListener)","u":"setMouseWheelListener(com.rubynaxela.kyanite.window.event.MouseWheelListener)"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"setOrigin(float, float)","u":"setOrigin(float,float)"},{"p":"org.jsfml.graphics","c":"Text","l":"setOrigin(float, float)","u":"setOrigin(float,float)"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"setOrigin(Vector2f)","u":"setOrigin(org.jsfml.system.Vector2f)"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"setPosition(float, float)","u":"setPosition(float,float)"},{"p":"org.jsfml.graphics","c":"Text","l":"setPosition(float, float)","u":"setPosition(float,float)"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"setPosition(Vector2f)","u":"setPosition(org.jsfml.system.Vector2f)"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"setResizeListener(ResizeListener)","u":"setResizeListener(com.rubynaxela.kyanite.window.event.ResizeListener)"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"setRotation(float)"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"setScale(float, float)","u":"setScale(float,float)"},{"p":"org.jsfml.graphics","c":"Text","l":"setScale(float, float)","u":"setScale(float,float)"},{"p":"com.rubynaxela.kyanite.game.entities","c":"CompoundEntity","l":"setScale(Vector2f)","u":"setScale(org.jsfml.system.Vector2f)"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"setScene(Scene)","u":"setScene(com.rubynaxela.kyanite.window.Scene)"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"setSize(int, int)","u":"setSize(int,int)"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"setSize(Vector2i)","u":"setSize(org.jsfml.system.Vector2i)"},{"p":"com.rubynaxela.kyanite.game.assets","c":"Sound","l":"setSkip(Time)","u":"setSkip(org.jsfml.system.Time)"},{"p":"com.rubynaxela.kyanite.game.assets","c":"Texture","l":"setSmooth(boolean)"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Text","l":"setString(String)","u":"setString(java.lang.String)"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Text","l":"setText(String)","u":"setText(java.lang.String)"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"setTextListener(TextListener)","u":"setTextListener(com.rubynaxela.kyanite.window.event.TextListener)"},{"p":"com.rubynaxela.kyanite.game.assets","c":"Texture","l":"setTileable(boolean)"},{"p":"com.rubynaxela.kyanite.game.assets","c":"Sound","l":"Sound(File)","u":"%3Cinit%3E(java.io.File)"},{"p":"com.rubynaxela.kyanite.game.assets","c":"Sound","l":"Sound(Path)","u":"%3Cinit%3E(java.nio.file.Path)"},{"p":"com.rubynaxela.kyanite.game.assets","c":"Sound","l":"Sound(String)","u":"%3Cinit%3E(java.lang.String)"},{"p":"com.rubynaxela.kyanite.system","c":"Clock","l":"start()"},{"p":"com.rubynaxela.kyanite.game","c":"GameContext","l":"startGame()"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"startLoop(GameContext)","u":"startLoop(com.rubynaxela.kyanite.game.GameContext)"},{"p":"com.rubynaxela.kyanite.game.assets","c":"Sound","l":"stop()"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Text","l":"Text()","u":"%3Cinit%3E()"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Text","l":"Text(Font)","u":"%3Cinit%3E(com.rubynaxela.kyanite.game.gui.Font)"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Text","l":"Text(String)","u":"%3Cinit%3E(java.lang.String)"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Text","l":"Text(String, Font)","u":"%3Cinit%3E(java.lang.String,com.rubynaxela.kyanite.game.gui.Font)"},{"p":"com.rubynaxela.kyanite.window.event","c":"TextListener","l":"textEntered(TextEvent)","u":"textEntered(org.jsfml.window.event.TextEvent)"},{"p":"com.rubynaxela.kyanite.game.assets","c":"Texture","l":"Texture(File)","u":"%3Cinit%3E(java.io.File)"},{"p":"com.rubynaxela.kyanite.game.assets","c":"Texture","l":"Texture(Path)","u":"%3Cinit%3E(java.nio.file.Path)"},{"p":"com.rubynaxela.kyanite.game.assets","c":"Texture","l":"Texture(String)","u":"%3Cinit%3E(java.lang.String)"},{"p":"com.rubynaxela.kyanite.game.entities","c":"HitBox","l":"toFloatRect()"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Text.Alignment","l":"TOP_CENTER"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Text.Alignment","l":"TOP_LEFT"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Text.Alignment","l":"TOP_RIGHT"},{"p":"com.rubynaxela.kyanite.game.entities","c":"HitBox","l":"top()"},{"p":"com.rubynaxela.kyanite.game.entities","c":"HitBox","l":"toString()"},{"p":"com.rubynaxela.kyanite.util","c":"Pair","l":"toString()"},{"p":"com.rubynaxela.kyanite.window.event","c":"ResizeEvent","l":"toString()"},{"p":"com.rubynaxela.kyanite.util","c":"Pair","l":"value1()"},{"p":"com.rubynaxela.kyanite.util","c":"Pair","l":"value2()"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Text.Alignment","l":"valueOf(String)","u":"valueOf(java.lang.String)"},{"p":"com.rubynaxela.kyanite.game.gui","c":"Text.Alignment","l":"values()"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"Window()","u":"%3Cinit%3E()"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"Window(VideoMode, String)","u":"%3Cinit%3E(org.jsfml.window.VideoMode,java.lang.String)"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"Window(VideoMode, String, int)","u":"%3Cinit%3E(org.jsfml.window.VideoMode,java.lang.String,int)"},{"p":"com.rubynaxela.kyanite.window","c":"Window","l":"Window(VideoMode, String, int, ContextSettings)","u":"%3Cinit%3E(org.jsfml.window.VideoMode,java.lang.String,int,org.jsfml.window.ContextSettings)"}];updateSearchResults(); \ No newline at end of file diff --git a/doc/module-search-index.js b/doc/module-search-index.js new file mode 100644 index 00000000..0d59754f --- /dev/null +++ b/doc/module-search-index.js @@ -0,0 +1 @@ +moduleSearchIndex = [];updateSearchResults(); \ No newline at end of file diff --git a/doc/overview-summary.html b/doc/overview-summary.html new file mode 100644 index 00000000..4a19f460 --- /dev/null +++ b/doc/overview-summary.html @@ -0,0 +1,26 @@ + + + + +Generated Documentation (Untitled) + + + + + + + + + + + +
+ +

index.html

+
+ + diff --git a/doc/overview-tree.html b/doc/overview-tree.html new file mode 100644 index 00000000..39aa393d --- /dev/null +++ b/doc/overview-tree.html @@ -0,0 +1,167 @@ + + + + +Class Hierarchy + + + + + + + + + + + + + + + +
+ +
+
+ +
+

Class Hierarchy

+
    +
  • java.lang.Object +
      +
    • java.util.AbstractCollection<E> (implements java.util.Collection<E>) + +
    • +
    • com.rubynaxela.kyanite.game.assets.AssetsBundle
    • +
    • com.rubynaxela.kyanite.system.Clock
    • +
    • com.rubynaxela.kyanite.game.entities.CompoundEntity (implements org.jsfml.graphics.Drawable, org.jsfml.graphics.Transformable)
    • +
    • com.rubynaxela.kyanite.system.FirstThreadTool
    • +
    • com.rubynaxela.kyanite.game.gui.Font
    • +
    • com.rubynaxela.kyanite.game.assets.FontFace (implements com.rubynaxela.kyanite.game.assets.Asset)
    • +
    • com.rubynaxela.kyanite.game.GameContext
    • +
    • com.rubynaxela.kyanite.util.MathUtils
    • +
    • java.lang.Record +
        +
      • com.rubynaxela.kyanite.game.entities.HitBox
      • +
      • com.rubynaxela.kyanite.util.Pair<T1,T2>
      • +
      • com.rubynaxela.kyanite.window.event.ResizeEvent
      • +
      +
    • +
    • org.jsfml.internal.SFMLNativeObject +
        +
      • org.jsfml.graphics.Text (implements org.jsfml.graphics.Drawable, org.jsfml.graphics.TextStyle) +
          +
        • com.rubynaxela.kyanite.game.gui.Text
        • +
        +
      • +
      • org.jsfml.window.Window (implements org.jsfml.window.WindowStyle) +
          +
        • org.jsfml.graphics.RenderWindow (implements org.jsfml.graphics.RenderTarget) +
            +
          • com.rubynaxela.kyanite.window.Window
          • +
          +
        • +
        +
      • +
      +
    • +
    • com.rubynaxela.kyanite.game.assets.Sound (implements com.rubynaxela.kyanite.game.assets.Asset)
    • +
    • com.rubynaxela.kyanite.game.assets.Texture (implements com.rubynaxela.kyanite.game.assets.Asset)
    • +
    +
  • +
+
+
+

Interface Hierarchy

+ +
+
+

Annotation Interface Hierarchy

+
    +
  • com.rubynaxela.kyanite.system.AssetId (implements java.lang.annotation.Annotation)
  • +
+
+
+

Enum Class Hierarchy

+ +
+
+
+
+ + diff --git a/doc/package-search-index.js b/doc/package-search-index.js new file mode 100644 index 00000000..bb92456b --- /dev/null +++ b/doc/package-search-index.js @@ -0,0 +1 @@ +packageSearchIndex = [{"l":"All Packages","u":"allpackages-index.html"},{"l":"com.rubynaxela.kyanite.game"},{"l":"com.rubynaxela.kyanite.game.assets"},{"l":"com.rubynaxela.kyanite.game.entities"},{"l":"com.rubynaxela.kyanite.game.gui"},{"l":"com.rubynaxela.kyanite.system"},{"l":"com.rubynaxela.kyanite.util"},{"l":"com.rubynaxela.kyanite.window"},{"l":"com.rubynaxela.kyanite.window.event"}];updateSearchResults(); \ No newline at end of file diff --git a/doc/resources/glass.png b/doc/resources/glass.png new file mode 100644 index 00000000..a7f591f4 Binary files /dev/null and b/doc/resources/glass.png differ diff --git a/doc/resources/x.png b/doc/resources/x.png new file mode 100644 index 00000000..30548a75 Binary files /dev/null and b/doc/resources/x.png differ diff --git a/doc/script-dir/images/ui-bg_glass_55_fbf9ee_1x400.png b/doc/script-dir/images/ui-bg_glass_55_fbf9ee_1x400.png new file mode 100644 index 00000000..34abd18f Binary files /dev/null and b/doc/script-dir/images/ui-bg_glass_55_fbf9ee_1x400.png differ diff --git a/doc/script-dir/images/ui-bg_glass_65_dadada_1x400.png b/doc/script-dir/images/ui-bg_glass_65_dadada_1x400.png new file mode 100644 index 00000000..f058a938 Binary files /dev/null and b/doc/script-dir/images/ui-bg_glass_65_dadada_1x400.png differ diff --git a/doc/script-dir/images/ui-bg_glass_75_dadada_1x400.png b/doc/script-dir/images/ui-bg_glass_75_dadada_1x400.png new file mode 100644 index 00000000..2ce04c16 Binary files /dev/null and b/doc/script-dir/images/ui-bg_glass_75_dadada_1x400.png differ diff --git a/doc/script-dir/images/ui-bg_glass_75_e6e6e6_1x400.png b/doc/script-dir/images/ui-bg_glass_75_e6e6e6_1x400.png new file mode 100644 index 00000000..a90afb8b Binary files /dev/null and b/doc/script-dir/images/ui-bg_glass_75_e6e6e6_1x400.png differ diff --git a/doc/script-dir/images/ui-bg_glass_95_fef1ec_1x400.png b/doc/script-dir/images/ui-bg_glass_95_fef1ec_1x400.png new file mode 100644 index 00000000..dbe091f6 Binary files /dev/null and b/doc/script-dir/images/ui-bg_glass_95_fef1ec_1x400.png differ diff --git a/doc/script-dir/images/ui-bg_highlight-soft_75_cccccc_1x100.png b/doc/script-dir/images/ui-bg_highlight-soft_75_cccccc_1x100.png new file mode 100644 index 00000000..5dc3593e Binary files /dev/null and b/doc/script-dir/images/ui-bg_highlight-soft_75_cccccc_1x100.png differ diff --git a/doc/script-dir/images/ui-icons_222222_256x240.png b/doc/script-dir/images/ui-icons_222222_256x240.png new file mode 100644 index 00000000..e723e17c Binary files /dev/null and b/doc/script-dir/images/ui-icons_222222_256x240.png differ diff --git a/doc/script-dir/images/ui-icons_2e83ff_256x240.png b/doc/script-dir/images/ui-icons_2e83ff_256x240.png new file mode 100644 index 00000000..1f5f4975 Binary files /dev/null and b/doc/script-dir/images/ui-icons_2e83ff_256x240.png differ diff --git a/doc/script-dir/images/ui-icons_454545_256x240.png b/doc/script-dir/images/ui-icons_454545_256x240.png new file mode 100644 index 00000000..618f5b0c Binary files /dev/null and b/doc/script-dir/images/ui-icons_454545_256x240.png differ diff --git a/doc/script-dir/images/ui-icons_888888_256x240.png b/doc/script-dir/images/ui-icons_888888_256x240.png new file mode 100644 index 00000000..ee5e33f2 Binary files /dev/null and b/doc/script-dir/images/ui-icons_888888_256x240.png differ diff --git a/doc/script-dir/images/ui-icons_cd0a0a_256x240.png b/doc/script-dir/images/ui-icons_cd0a0a_256x240.png new file mode 100644 index 00000000..7e8ebc18 Binary files /dev/null and b/doc/script-dir/images/ui-icons_cd0a0a_256x240.png differ diff --git a/doc/script-dir/jquery-3.5.1.min.js b/doc/script-dir/jquery-3.5.1.min.js new file mode 100644 index 00000000..b0614034 --- /dev/null +++ b/doc/script-dir/jquery-3.5.1.min.js @@ -0,0 +1,2 @@ +/*! jQuery v3.5.1 | (c) JS Foundation and other contributors | jquery.org/license */ +!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.5.1",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),ne=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(p.childNodes),p.childNodes),t[p.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&(U.test(t)||z.test(t))){(f=ee.test(t)&&ye(e.parentNode)||e)===e&&d.scope||((s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=S)),o=(l=h(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+xe(l[o]);c=l.join(",")}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){N(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return g(t.replace($,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[S]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e.namespaceURI,n=(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:p;return r!=C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),p!=C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.scope=ce(function(e){return a.appendChild(e).appendChild(C.createElement("div")),"undefined"!=typeof e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=S,!C.getElementsByName||!C.getElementsByName(S).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){var t;a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+S+"-]").length||v.push("~="),(t=C.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||v.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+S+"+*").length||v.push(".#.+[+~]"),e.querySelectorAll("\\\f"),v.push("[\\r\\n\\f]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",F)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e==C||e.ownerDocument==p&&y(p,e)?-1:t==C||t.ownerDocument==p&&y(p,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e==C?-1:t==C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]==p?-1:s[r]==p?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if(T(e),d.matchesSelector&&E&&!N[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){N(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=m[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&m(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function D(e,n,r){return m(n)?S.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?S.grep(e,function(e){return e===n!==r}):"string"!=typeof n?S.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(S.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||j,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof S?t[0]:t,S.merge(this,S.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),N.test(r[1])&&S.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(S):S.makeArray(e,this)}).prototype=S.fn,j=S(E);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){while((e=e[t])&&1!==e.nodeType);return e}S.fn.extend({has:function(e){var t=S(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i;ce=E.createDocumentFragment().appendChild(E.createElement("div")),(fe=E.createElement("input")).setAttribute("type","radio"),fe.setAttribute("checked","checked"),fe.setAttribute("name","t"),ce.appendChild(fe),y.checkClone=ce.cloneNode(!0).cloneNode(!0).lastChild.checked,ce.innerHTML="",y.noCloneChecked=!!ce.cloneNode(!0).lastChild.defaultValue,ce.innerHTML="",y.option=!!ce.lastChild;var ge={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;n",""]);var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d\s*$/g;function qe(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&S(e).children("tbody")[0]||e}function Le(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function He(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Oe(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(Y.hasData(e)&&(s=Y.get(e).events))for(i in Y.remove(t,"handle events"),s)for(n=0,r=s[i].length;n").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var Ut,Xt=[],Vt=/(=)\?(?=&|$)|\?\?/;S.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Xt.pop()||S.expando+"_"+Ct.guid++;return this[e]=!0,e}}),S.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Vt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Vt.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Vt,"$1"+r):!1!==e.jsonp&&(e.url+=(Et.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||S.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?S(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Xt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((Ut=E.implementation.createHTMLDocument("").body).innerHTML="
",2===Ut.childNodes.length),S.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=N.exec(e))?[t.createElement(i[1])]:(i=xe([e],t,o),o&&o.length&&S(o).remove(),S.merge([],i.childNodes)));var r,i,o},S.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):("number"==typeof f.top&&(f.top+="px"),"number"==typeof f.left&&(f.left+="px"),c.css(f))}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return $(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=$e(y.pixelPosition,function(e,t){if(t)return t=Be(e,n),Me.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return $(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0a;a++)for(s in o[a])n=o[a][s],o[a].hasOwnProperty(s)&&void 0!==n&&(e[s]=t.isPlainObject(n)?t.isPlainObject(e[s])?t.widget.extend({},e[s],n):t.widget.extend({},n):n);return e},t.widget.bridge=function(e,s){var n=s.prototype.widgetFullName||e;t.fn[e]=function(o){var a="string"==typeof o,r=i.call(arguments,1),l=this;return a?this.length||"instance"!==o?this.each(function(){var i,s=t.data(this,n);return"instance"===o?(l=s,!1):s?t.isFunction(s[o])&&"_"!==o.charAt(0)?(i=s[o].apply(s,r),i!==s&&void 0!==i?(l=i&&i.jquery?l.pushStack(i.get()):i,!1):void 0):t.error("no such method '"+o+"' for "+e+" widget instance"):t.error("cannot call methods on "+e+" prior to initialization; "+"attempted to call method '"+o+"'")}):l=void 0:(r.length&&(o=t.widget.extend.apply(null,[o].concat(r))),this.each(function(){var e=t.data(this,n);e?(e.option(o||{}),e._init&&e._init()):t.data(this,n,new s(o,this))})),l}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
",options:{classes:{},disabled:!1,create:null},_createWidget:function(i,s){s=t(s||this.defaultElement||this)[0],this.element=t(s),this.uuid=e++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=t(),this.hoverable=t(),this.focusable=t(),this.classesElementLookup={},s!==this&&(t.data(s,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===s&&this.destroy()}}),this.document=t(s.style?s.ownerDocument:s.document||s),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this.options=t.widget.extend({},this.options,this._getCreateOptions(),i),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){var e=this;this._destroy(),t.each(this.classesElementLookup,function(t,i){e._removeClass(i,t)}),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:t.noop,widget:function(){return this.element},option:function(e,i){var s,n,o,a=e;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof e)if(a={},s=e.split("."),e=s.shift(),s.length){for(n=a[e]=t.widget.extend({},this.options[e]),o=0;s.length-1>o;o++)n[s[o]]=n[s[o]]||{},n=n[s[o]];if(e=s.pop(),1===arguments.length)return void 0===n[e]?null:n[e];n[e]=i}else{if(1===arguments.length)return void 0===this.options[e]?null:this.options[e];a[e]=i}return this._setOptions(a),this},_setOptions:function(t){var e;for(e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return"classes"===t&&this._setOptionClasses(e),this.options[t]=e,"disabled"===t&&this._setOptionDisabled(e),this},_setOptionClasses:function(e){var i,s,n;for(i in e)n=this.classesElementLookup[i],e[i]!==this.options.classes[i]&&n&&n.length&&(s=t(n.get()),this._removeClass(n,i),s.addClass(this._classes({element:s,keys:i,classes:e,add:!0})))},_setOptionDisabled:function(t){this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,!!t),t&&(this._removeClass(this.hoverable,null,"ui-state-hover"),this._removeClass(this.focusable,null,"ui-state-focus"))},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_classes:function(e){function i(i,o){var a,r;for(r=0;i.length>r;r++)a=n.classesElementLookup[i[r]]||t(),a=e.add?t(t.unique(a.get().concat(e.element.get()))):t(a.not(e.element).get()),n.classesElementLookup[i[r]]=a,s.push(i[r]),o&&e.classes[i[r]]&&s.push(e.classes[i[r]])}var s=[],n=this;return e=t.extend({element:this.element,classes:this.options.classes||{}},e),this._on(e.element,{remove:"_untrackClassesElement"}),e.keys&&i(e.keys.match(/\S+/g)||[],!0),e.extra&&i(e.extra.match(/\S+/g)||[]),s.join(" ")},_untrackClassesElement:function(e){var i=this;t.each(i.classesElementLookup,function(s,n){-1!==t.inArray(e.target,n)&&(i.classesElementLookup[s]=t(n.not(e.target).get()))})},_removeClass:function(t,e,i){return this._toggleClass(t,e,i,!1)},_addClass:function(t,e,i){return this._toggleClass(t,e,i,!0)},_toggleClass:function(t,e,i,s){s="boolean"==typeof s?s:i;var n="string"==typeof t||null===t,o={extra:n?e:i,keys:n?t:e,element:n?this.element:t,add:s};return o.element.toggleClass(this._classes(o),s),this},_on:function(e,i,s){var n,o=this;"boolean"!=typeof e&&(s=i,i=e,e=!1),s?(i=n=t(i),this.bindings=this.bindings.add(i)):(s=i,i=this.element,n=this.widget()),t.each(s,function(s,a){function r(){return e||o.options.disabled!==!0&&!t(this).hasClass("ui-state-disabled")?("string"==typeof a?o[a]:a).apply(o,arguments):void 0}"string"!=typeof a&&(r.guid=a.guid=a.guid||r.guid||t.guid++);var l=s.match(/^([\w:-]*)\s*(.*)$/),h=l[1]+o.eventNamespace,c=l[2];c?n.on(h,c,r):i.on(h,r)})},_off:function(e,i){i=(i||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.off(i).off(i),this.bindings=t(this.bindings.not(e).get()),this.focusable=t(this.focusable.not(e).get()),this.hoverable=t(this.hoverable.not(e).get())},_delay:function(t,e){function i(){return("string"==typeof t?s[t]:t).apply(s,arguments)}var s=this;return setTimeout(i,e||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(e){this._addClass(t(e.currentTarget),null,"ui-state-hover")},mouseleave:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(e){this._addClass(t(e.currentTarget),null,"ui-state-focus")},focusout:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-focus")}})},_trigger:function(e,i,s){var n,o,a=this.options[e];if(s=s||{},i=t.Event(i),i.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),i.target=this.element[0],o=i.originalEvent)for(n in o)n in i||(i[n]=o[n]);return this.element.trigger(i,s),!(t.isFunction(a)&&a.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},t.each({show:"fadeIn",hide:"fadeOut"},function(e,i){t.Widget.prototype["_"+e]=function(s,n,o){"string"==typeof n&&(n={effect:n});var a,r=n?n===!0||"number"==typeof n?i:n.effect||i:e;n=n||{},"number"==typeof n&&(n={duration:n}),a=!t.isEmptyObject(n),n.complete=o,n.delay&&s.delay(n.delay),a&&t.effects&&t.effects.effect[r]?s[e](n):r!==e&&s[r]?s[r](n.duration,n.easing,o):s.queue(function(i){t(this)[e](),o&&o.call(s[0]),i()})}}),t.widget,function(){function e(t,e,i){return[parseFloat(t[0])*(u.test(t[0])?e/100:1),parseFloat(t[1])*(u.test(t[1])?i/100:1)]}function i(e,i){return parseInt(t.css(e,i),10)||0}function s(e){var i=e[0];return 9===i.nodeType?{width:e.width(),height:e.height(),offset:{top:0,left:0}}:t.isWindow(i)?{width:e.width(),height:e.height(),offset:{top:e.scrollTop(),left:e.scrollLeft()}}:i.preventDefault?{width:0,height:0,offset:{top:i.pageY,left:i.pageX}}:{width:e.outerWidth(),height:e.outerHeight(),offset:e.offset()}}var n,o=Math.max,a=Math.abs,r=/left|center|right/,l=/top|center|bottom/,h=/[\+\-]\d+(\.[\d]+)?%?/,c=/^\w+/,u=/%$/,d=t.fn.position;t.position={scrollbarWidth:function(){if(void 0!==n)return n;var e,i,s=t("
"),o=s.children()[0];return t("body").append(s),e=o.offsetWidth,s.css("overflow","scroll"),i=o.offsetWidth,e===i&&(i=s[0].clientWidth),s.remove(),n=e-i},getScrollInfo:function(e){var i=e.isWindow||e.isDocument?"":e.element.css("overflow-x"),s=e.isWindow||e.isDocument?"":e.element.css("overflow-y"),n="scroll"===i||"auto"===i&&e.widthi?"left":e>0?"right":"center",vertical:0>r?"top":s>0?"bottom":"middle"};h>p&&p>a(e+i)&&(u.horizontal="center"),c>f&&f>a(s+r)&&(u.vertical="middle"),u.important=o(a(e),a(i))>o(a(s),a(r))?"horizontal":"vertical",n.using.call(this,t,u)}),l.offset(t.extend(D,{using:r}))})},t.ui.position={fit:{left:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollLeft:s.offset.left,a=s.width,r=t.left-e.collisionPosition.marginLeft,l=n-r,h=r+e.collisionWidth-a-n;e.collisionWidth>a?l>0&&0>=h?(i=t.left+l+e.collisionWidth-a-n,t.left+=l-i):t.left=h>0&&0>=l?n:l>h?n+a-e.collisionWidth:n:l>0?t.left+=l:h>0?t.left-=h:t.left=o(t.left-r,t.left)},top:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollTop:s.offset.top,a=e.within.height,r=t.top-e.collisionPosition.marginTop,l=n-r,h=r+e.collisionHeight-a-n;e.collisionHeight>a?l>0&&0>=h?(i=t.top+l+e.collisionHeight-a-n,t.top+=l-i):t.top=h>0&&0>=l?n:l>h?n+a-e.collisionHeight:n:l>0?t.top+=l:h>0?t.top-=h:t.top=o(t.top-r,t.top)}},flip:{left:function(t,e){var i,s,n=e.within,o=n.offset.left+n.scrollLeft,r=n.width,l=n.isWindow?n.scrollLeft:n.offset.left,h=t.left-e.collisionPosition.marginLeft,c=h-l,u=h+e.collisionWidth-r-l,d="left"===e.my[0]?-e.elemWidth:"right"===e.my[0]?e.elemWidth:0,p="left"===e.at[0]?e.targetWidth:"right"===e.at[0]?-e.targetWidth:0,f=-2*e.offset[0];0>c?(i=t.left+d+p+f+e.collisionWidth-r-o,(0>i||a(c)>i)&&(t.left+=d+p+f)):u>0&&(s=t.left-e.collisionPosition.marginLeft+d+p+f-l,(s>0||u>a(s))&&(t.left+=d+p+f))},top:function(t,e){var i,s,n=e.within,o=n.offset.top+n.scrollTop,r=n.height,l=n.isWindow?n.scrollTop:n.offset.top,h=t.top-e.collisionPosition.marginTop,c=h-l,u=h+e.collisionHeight-r-l,d="top"===e.my[1],p=d?-e.elemHeight:"bottom"===e.my[1]?e.elemHeight:0,f="top"===e.at[1]?e.targetHeight:"bottom"===e.at[1]?-e.targetHeight:0,g=-2*e.offset[1];0>c?(s=t.top+p+f+g+e.collisionHeight-r-o,(0>s||a(c)>s)&&(t.top+=p+f+g)):u>0&&(i=t.top-e.collisionPosition.marginTop+p+f+g-l,(i>0||u>a(i))&&(t.top+=p+f+g))}},flipfit:{left:function(){t.ui.position.flip.left.apply(this,arguments),t.ui.position.fit.left.apply(this,arguments)},top:function(){t.ui.position.flip.top.apply(this,arguments),t.ui.position.fit.top.apply(this,arguments)}}}}(),t.ui.position,t.ui.keyCode={BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38},t.fn.extend({uniqueId:function(){var t=0;return function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++t)})}}(),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&t(this).removeAttr("id")})}}),t.ui.safeActiveElement=function(t){var e;try{e=t.activeElement}catch(i){e=t.body}return e||(e=t.body),e.nodeName||(e=t.body),e},t.widget("ui.menu",{version:"1.12.1",defaultElement:"
    ",delay:300,options:{icons:{submenu:"ui-icon-caret-1-e"},items:"> *",menus:"ul",position:{my:"left top",at:"right top"},role:"menu",blur:null,focus:null,select:null},_create:function(){this.activeMenu=this.element,this.mouseHandled=!1,this.element.uniqueId().attr({role:this.options.role,tabIndex:0}),this._addClass("ui-menu","ui-widget ui-widget-content"),this._on({"mousedown .ui-menu-item":function(t){t.preventDefault()},"click .ui-menu-item":function(e){var i=t(e.target),s=t(t.ui.safeActiveElement(this.document[0]));!this.mouseHandled&&i.not(".ui-state-disabled").length&&(this.select(e),e.isPropagationStopped()||(this.mouseHandled=!0),i.has(".ui-menu").length?this.expand(e):!this.element.is(":focus")&&s.closest(".ui-menu").length&&(this.element.trigger("focus",[!0]),this.active&&1===this.active.parents(".ui-menu").length&&clearTimeout(this.timer)))},"mouseenter .ui-menu-item":function(e){if(!this.previousFilter){var i=t(e.target).closest(".ui-menu-item"),s=t(e.currentTarget);i[0]===s[0]&&(this._removeClass(s.siblings().children(".ui-state-active"),null,"ui-state-active"),this.focus(e,s))}},mouseleave:"collapseAll","mouseleave .ui-menu":"collapseAll",focus:function(t,e){var i=this.active||this.element.find(this.options.items).eq(0);e||this.focus(t,i)},blur:function(e){this._delay(function(){var i=!t.contains(this.element[0],t.ui.safeActiveElement(this.document[0]));i&&this.collapseAll(e)})},keydown:"_keydown"}),this.refresh(),this._on(this.document,{click:function(t){this._closeOnDocumentClick(t)&&this.collapseAll(t),this.mouseHandled=!1}})},_destroy:function(){var e=this.element.find(".ui-menu-item").removeAttr("role aria-disabled"),i=e.children(".ui-menu-item-wrapper").removeUniqueId().removeAttr("tabIndex role aria-haspopup");this.element.removeAttr("aria-activedescendant").find(".ui-menu").addBack().removeAttr("role aria-labelledby aria-expanded aria-hidden aria-disabled tabIndex").removeUniqueId().show(),i.children().each(function(){var e=t(this);e.data("ui-menu-submenu-caret")&&e.remove()})},_keydown:function(e){var i,s,n,o,a=!0;switch(e.keyCode){case t.ui.keyCode.PAGE_UP:this.previousPage(e);break;case t.ui.keyCode.PAGE_DOWN:this.nextPage(e);break;case t.ui.keyCode.HOME:this._move("first","first",e);break;case t.ui.keyCode.END:this._move("last","last",e);break;case t.ui.keyCode.UP:this.previous(e);break;case t.ui.keyCode.DOWN:this.next(e);break;case t.ui.keyCode.LEFT:this.collapse(e);break;case t.ui.keyCode.RIGHT:this.active&&!this.active.is(".ui-state-disabled")&&this.expand(e);break;case t.ui.keyCode.ENTER:case t.ui.keyCode.SPACE:this._activate(e);break;case t.ui.keyCode.ESCAPE:this.collapse(e);break;default:a=!1,s=this.previousFilter||"",o=!1,n=e.keyCode>=96&&105>=e.keyCode?""+(e.keyCode-96):String.fromCharCode(e.keyCode),clearTimeout(this.filterTimer),n===s?o=!0:n=s+n,i=this._filterMenuItems(n),i=o&&-1!==i.index(this.active.next())?this.active.nextAll(".ui-menu-item"):i,i.length||(n=String.fromCharCode(e.keyCode),i=this._filterMenuItems(n)),i.length?(this.focus(e,i),this.previousFilter=n,this.filterTimer=this._delay(function(){delete this.previousFilter},1e3)):delete this.previousFilter}a&&e.preventDefault()},_activate:function(t){this.active&&!this.active.is(".ui-state-disabled")&&(this.active.children("[aria-haspopup='true']").length?this.expand(t):this.select(t))},refresh:function(){var e,i,s,n,o,a=this,r=this.options.icons.submenu,l=this.element.find(this.options.menus);this._toggleClass("ui-menu-icons",null,!!this.element.find(".ui-icon").length),s=l.filter(":not(.ui-menu)").hide().attr({role:this.options.role,"aria-hidden":"true","aria-expanded":"false"}).each(function(){var e=t(this),i=e.prev(),s=t("").data("ui-menu-submenu-caret",!0);a._addClass(s,"ui-menu-icon","ui-icon "+r),i.attr("aria-haspopup","true").prepend(s),e.attr("aria-labelledby",i.attr("id"))}),this._addClass(s,"ui-menu","ui-widget ui-widget-content ui-front"),e=l.add(this.element),i=e.find(this.options.items),i.not(".ui-menu-item").each(function(){var e=t(this);a._isDivider(e)&&a._addClass(e,"ui-menu-divider","ui-widget-content")}),n=i.not(".ui-menu-item, .ui-menu-divider"),o=n.children().not(".ui-menu").uniqueId().attr({tabIndex:-1,role:this._itemRole()}),this._addClass(n,"ui-menu-item")._addClass(o,"ui-menu-item-wrapper"),i.filter(".ui-state-disabled").attr("aria-disabled","true"),this.active&&!t.contains(this.element[0],this.active[0])&&this.blur()},_itemRole:function(){return{menu:"menuitem",listbox:"option"}[this.options.role]},_setOption:function(t,e){if("icons"===t){var i=this.element.find(".ui-menu-icon");this._removeClass(i,null,this.options.icons.submenu)._addClass(i,null,e.submenu)}this._super(t,e)},_setOptionDisabled:function(t){this._super(t),this.element.attr("aria-disabled",t+""),this._toggleClass(null,"ui-state-disabled",!!t)},focus:function(t,e){var i,s,n;this.blur(t,t&&"focus"===t.type),this._scrollIntoView(e),this.active=e.first(),s=this.active.children(".ui-menu-item-wrapper"),this._addClass(s,null,"ui-state-active"),this.options.role&&this.element.attr("aria-activedescendant",s.attr("id")),n=this.active.parent().closest(".ui-menu-item").children(".ui-menu-item-wrapper"),this._addClass(n,null,"ui-state-active"),t&&"keydown"===t.type?this._close():this.timer=this._delay(function(){this._close()},this.delay),i=e.children(".ui-menu"),i.length&&t&&/^mouse/.test(t.type)&&this._startOpening(i),this.activeMenu=e.parent(),this._trigger("focus",t,{item:e})},_scrollIntoView:function(e){var i,s,n,o,a,r;this._hasScroll()&&(i=parseFloat(t.css(this.activeMenu[0],"borderTopWidth"))||0,s=parseFloat(t.css(this.activeMenu[0],"paddingTop"))||0,n=e.offset().top-this.activeMenu.offset().top-i-s,o=this.activeMenu.scrollTop(),a=this.activeMenu.height(),r=e.outerHeight(),0>n?this.activeMenu.scrollTop(o+n):n+r>a&&this.activeMenu.scrollTop(o+n-a+r))},blur:function(t,e){e||clearTimeout(this.timer),this.active&&(this._removeClass(this.active.children(".ui-menu-item-wrapper"),null,"ui-state-active"),this._trigger("blur",t,{item:this.active}),this.active=null)},_startOpening:function(t){clearTimeout(this.timer),"true"===t.attr("aria-hidden")&&(this.timer=this._delay(function(){this._close(),this._open(t)},this.delay))},_open:function(e){var i=t.extend({of:this.active},this.options.position);clearTimeout(this.timer),this.element.find(".ui-menu").not(e.parents(".ui-menu")).hide().attr("aria-hidden","true"),e.show().removeAttr("aria-hidden").attr("aria-expanded","true").position(i)},collapseAll:function(e,i){clearTimeout(this.timer),this.timer=this._delay(function(){var s=i?this.element:t(e&&e.target).closest(this.element.find(".ui-menu"));s.length||(s=this.element),this._close(s),this.blur(e),this._removeClass(s.find(".ui-state-active"),null,"ui-state-active"),this.activeMenu=s},this.delay)},_close:function(t){t||(t=this.active?this.active.parent():this.element),t.find(".ui-menu").hide().attr("aria-hidden","true").attr("aria-expanded","false")},_closeOnDocumentClick:function(e){return!t(e.target).closest(".ui-menu").length},_isDivider:function(t){return!/[^\-\u2014\u2013\s]/.test(t.text())},collapse:function(t){var e=this.active&&this.active.parent().closest(".ui-menu-item",this.element);e&&e.length&&(this._close(),this.focus(t,e))},expand:function(t){var e=this.active&&this.active.children(".ui-menu ").find(this.options.items).first();e&&e.length&&(this._open(e.parent()),this._delay(function(){this.focus(t,e)}))},next:function(t){this._move("next","first",t)},previous:function(t){this._move("prev","last",t)},isFirstItem:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},isLastItem:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},_move:function(t,e,i){var s;this.active&&(s="first"===t||"last"===t?this.active["first"===t?"prevAll":"nextAll"](".ui-menu-item").eq(-1):this.active[t+"All"](".ui-menu-item").eq(0)),s&&s.length&&this.active||(s=this.activeMenu.find(this.options.items)[e]()),this.focus(i,s)},nextPage:function(e){var i,s,n;return this.active?(this.isLastItem()||(this._hasScroll()?(s=this.active.offset().top,n=this.element.height(),this.active.nextAll(".ui-menu-item").each(function(){return i=t(this),0>i.offset().top-s-n}),this.focus(e,i)):this.focus(e,this.activeMenu.find(this.options.items)[this.active?"last":"first"]())),void 0):(this.next(e),void 0)},previousPage:function(e){var i,s,n;return this.active?(this.isFirstItem()||(this._hasScroll()?(s=this.active.offset().top,n=this.element.height(),this.active.prevAll(".ui-menu-item").each(function(){return i=t(this),i.offset().top-s+n>0}),this.focus(e,i)):this.focus(e,this.activeMenu.find(this.options.items).first())),void 0):(this.next(e),void 0)},_hasScroll:function(){return this.element.outerHeight()",options:{appendTo:null,autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null,change:null,close:null,focus:null,open:null,response:null,search:null,select:null},requestIndex:0,pending:0,_create:function(){var e,i,s,n=this.element[0].nodeName.toLowerCase(),o="textarea"===n,a="input"===n;this.isMultiLine=o||!a&&this._isContentEditable(this.element),this.valueMethod=this.element[o||a?"val":"text"],this.isNewMenu=!0,this._addClass("ui-autocomplete-input"),this.element.attr("autocomplete","off"),this._on(this.element,{keydown:function(n){if(this.element.prop("readOnly"))return e=!0,s=!0,i=!0,void 0;e=!1,s=!1,i=!1;var o=t.ui.keyCode;switch(n.keyCode){case o.PAGE_UP:e=!0,this._move("previousPage",n);break;case o.PAGE_DOWN:e=!0,this._move("nextPage",n);break;case o.UP:e=!0,this._keyEvent("previous",n);break;case o.DOWN:e=!0,this._keyEvent("next",n);break;case o.ENTER:this.menu.active&&(e=!0,n.preventDefault(),this.menu.select(n));break;case o.TAB:this.menu.active&&this.menu.select(n);break;case o.ESCAPE:this.menu.element.is(":visible")&&(this.isMultiLine||this._value(this.term),this.close(n),n.preventDefault());break;default:i=!0,this._searchTimeout(n)}},keypress:function(s){if(e)return e=!1,(!this.isMultiLine||this.menu.element.is(":visible"))&&s.preventDefault(),void 0;if(!i){var n=t.ui.keyCode;switch(s.keyCode){case n.PAGE_UP:this._move("previousPage",s);break;case n.PAGE_DOWN:this._move("nextPage",s);break;case n.UP:this._keyEvent("previous",s);break;case n.DOWN:this._keyEvent("next",s)}}},input:function(t){return s?(s=!1,t.preventDefault(),void 0):(this._searchTimeout(t),void 0)},focus:function(){this.selectedItem=null,this.previous=this._value()},blur:function(t){return this.cancelBlur?(delete this.cancelBlur,void 0):(clearTimeout(this.searching),this.close(t),this._change(t),void 0)}}),this._initSource(),this.menu=t("
      ").appendTo(this._appendTo()).menu({role:null}).hide().menu("instance"),this._addClass(this.menu.element,"ui-autocomplete","ui-front"),this._on(this.menu.element,{mousedown:function(e){e.preventDefault(),this.cancelBlur=!0,this._delay(function(){delete this.cancelBlur,this.element[0]!==t.ui.safeActiveElement(this.document[0])&&this.element.trigger("focus")})},menufocus:function(e,i){var s,n;return this.isNewMenu&&(this.isNewMenu=!1,e.originalEvent&&/^mouse/.test(e.originalEvent.type))?(this.menu.blur(),this.document.one("mousemove",function(){t(e.target).trigger(e.originalEvent)}),void 0):(n=i.item.data("ui-autocomplete-item"),!1!==this._trigger("focus",e,{item:n})&&e.originalEvent&&/^key/.test(e.originalEvent.type)&&this._value(n.value),s=i.item.attr("aria-label")||n.value,s&&t.trim(s).length&&(this.liveRegion.children().hide(),t("
      ").text(s).appendTo(this.liveRegion)),void 0)},menuselect:function(e,i){var s=i.item.data("ui-autocomplete-item"),n=this.previous;this.element[0]!==t.ui.safeActiveElement(this.document[0])&&(this.element.trigger("focus"),this.previous=n,this._delay(function(){this.previous=n,this.selectedItem=s})),!1!==this._trigger("select",e,{item:s})&&this._value(s.value),this.term=this._value(),this.close(e),this.selectedItem=s}}),this.liveRegion=t("
      ",{role:"status","aria-live":"assertive","aria-relevant":"additions"}).appendTo(this.document[0].body),this._addClass(this.liveRegion,null,"ui-helper-hidden-accessible"),this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_destroy:function(){clearTimeout(this.searching),this.element.removeAttr("autocomplete"),this.menu.element.remove(),this.liveRegion.remove()},_setOption:function(t,e){this._super(t,e),"source"===t&&this._initSource(),"appendTo"===t&&this.menu.element.appendTo(this._appendTo()),"disabled"===t&&e&&this.xhr&&this.xhr.abort()},_isEventTargetInWidget:function(e){var i=this.menu.element[0];return e.target===this.element[0]||e.target===i||t.contains(i,e.target)},_closeOnClickOutside:function(t){this._isEventTargetInWidget(t)||this.close()},_appendTo:function(){var e=this.options.appendTo;return e&&(e=e.jquery||e.nodeType?t(e):this.document.find(e).eq(0)),e&&e[0]||(e=this.element.closest(".ui-front, dialog")),e.length||(e=this.document[0].body),e},_initSource:function(){var e,i,s=this;t.isArray(this.options.source)?(e=this.options.source,this.source=function(i,s){s(t.ui.autocomplete.filter(e,i.term))}):"string"==typeof this.options.source?(i=this.options.source,this.source=function(e,n){s.xhr&&s.xhr.abort(),s.xhr=t.ajax({url:i,data:e,dataType:"json",success:function(t){n(t)},error:function(){n([])}})}):this.source=this.options.source},_searchTimeout:function(t){clearTimeout(this.searching),this.searching=this._delay(function(){var e=this.term===this._value(),i=this.menu.element.is(":visible"),s=t.altKey||t.ctrlKey||t.metaKey||t.shiftKey;(!e||e&&!i&&!s)&&(this.selectedItem=null,this.search(null,t))},this.options.delay)},search:function(t,e){return t=null!=t?t:this._value(),this.term=this._value(),t.length").append(t("
      ").text(i.label)).appendTo(e)},_move:function(t,e){return this.menu.element.is(":visible")?this.menu.isFirstItem()&&/^previous/.test(t)||this.menu.isLastItem()&&/^next/.test(t)?(this.isMultiLine||this._value(this.term),this.menu.blur(),void 0):(this.menu[t](e),void 0):(this.search(null,e),void 0)},widget:function(){return this.menu.element},_value:function(){return this.valueMethod.apply(this.element,arguments)},_keyEvent:function(t,e){(!this.isMultiLine||this.menu.element.is(":visible"))&&(this._move(t,e),e.preventDefault())},_isContentEditable:function(t){if(!t.length)return!1;var e=t.prop("contentEditable");return"inherit"===e?this._isContentEditable(t.parent()):"true"===e}}),t.extend(t.ui.autocomplete,{escapeRegex:function(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")},filter:function(e,i){var s=RegExp(t.ui.autocomplete.escapeRegex(i),"i");return t.grep(e,function(t){return s.test(t.label||t.value||t)})}}),t.widget("ui.autocomplete",t.ui.autocomplete,{options:{messages:{noResults:"No search results.",results:function(t){return t+(t>1?" results are":" result is")+" available, use up and down arrow keys to navigate."}}},__response:function(e){var i;this._superApply(arguments),this.options.disabled||this.cancelSearch||(i=e&&e.length?this.options.messages.results(e.length):this.options.messages.noResults,this.liveRegion.children().hide(),t("
      ").text(i).appendTo(this.liveRegion))}}),t.ui.autocomplete}); \ No newline at end of file diff --git a/doc/script-dir/jquery-ui.structure.min.css b/doc/script-dir/jquery-ui.structure.min.css new file mode 100644 index 00000000..e8808927 --- /dev/null +++ b/doc/script-dir/jquery-ui.structure.min.css @@ -0,0 +1,5 @@ +/*! jQuery UI - v1.12.1 - 2018-12-06 +* http://jqueryui.com +* Copyright jQuery Foundation and other contributors; Licensed MIT */ + +.ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important;pointer-events:none}.ui-icon{display:inline-block;vertical-align:middle;margin-top:-.25em;position:relative;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-icon-block{left:50%;margin-left:-8px;display:block}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-autocomplete{position:absolute;top:0;left:0;cursor:default}.ui-menu{list-style:none;padding:0;margin:0;display:block;outline:0}.ui-menu .ui-menu{position:absolute}.ui-menu .ui-menu-item{margin:0;cursor:pointer;list-style-image:url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")}.ui-menu .ui-menu-item-wrapper{position:relative;padding:3px 1em 3px .4em}.ui-menu .ui-menu-divider{margin:5px 0;height:0;font-size:0;line-height:0;border-width:1px 0 0 0}.ui-menu .ui-state-focus,.ui-menu .ui-state-active{margin:-1px}.ui-menu-icons{position:relative}.ui-menu-icons .ui-menu-item-wrapper{padding-left:2em}.ui-menu .ui-icon{position:absolute;top:0;bottom:0;left:.2em;margin:auto 0}.ui-menu .ui-menu-icon{left:auto;right:0} \ No newline at end of file diff --git a/doc/script.js b/doc/script.js new file mode 100644 index 00000000..864989cf --- /dev/null +++ b/doc/script.js @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +var moduleSearchIndex; +var packageSearchIndex; +var typeSearchIndex; +var memberSearchIndex; +var tagSearchIndex; +function loadScripts(doc, tag) { + createElem(doc, tag, 'search.js'); + + createElem(doc, tag, 'module-search-index.js'); + createElem(doc, tag, 'package-search-index.js'); + createElem(doc, tag, 'type-search-index.js'); + createElem(doc, tag, 'member-search-index.js'); + createElem(doc, tag, 'tag-search-index.js'); +} + +function createElem(doc, tag, path) { + var script = doc.createElement(tag); + var scriptElement = doc.getElementsByTagName(tag)[0]; + script.src = pathtoroot + path; + scriptElement.parentNode.insertBefore(script, scriptElement); +} + +function show(tableId, selected, columns) { + if (tableId !== selected) { + document.querySelectorAll('div.' + tableId + ':not(.' + selected + ')') + .forEach(function(elem) { + elem.style.display = 'none'; + }); + } + document.querySelectorAll('div.' + selected) + .forEach(function(elem, index) { + elem.style.display = ''; + var isEvenRow = index % (columns * 2) < columns; + elem.classList.remove(isEvenRow ? oddRowColor : evenRowColor); + elem.classList.add(isEvenRow ? evenRowColor : oddRowColor); + }); + updateTabs(tableId, selected); +} + +function updateTabs(tableId, selected) { + document.querySelector('div#' + tableId +' .summary-table') + .setAttribute('aria-labelledby', selected); + document.querySelectorAll('button[id^="' + tableId + '"]') + .forEach(function(tab, index) { + if (selected === tab.id || (tableId === selected && index === 0)) { + tab.className = activeTableTab; + tab.setAttribute('aria-selected', true); + tab.setAttribute('tabindex',0); + } else { + tab.className = tableTab; + tab.setAttribute('aria-selected', false); + tab.setAttribute('tabindex',-1); + } + }); +} + +function switchTab(e) { + var selected = document.querySelector('[aria-selected=true]'); + if (selected) { + if ((e.keyCode === 37 || e.keyCode === 38) && selected.previousSibling) { + // left or up arrow key pressed: move focus to previous tab + selected.previousSibling.click(); + selected.previousSibling.focus(); + e.preventDefault(); + } else if ((e.keyCode === 39 || e.keyCode === 40) && selected.nextSibling) { + // right or down arrow key pressed: move focus to next tab + selected.nextSibling.click(); + selected.nextSibling.focus(); + e.preventDefault(); + } + } +} + +var updateSearchResults = function() {}; + +function indexFilesLoaded() { + return moduleSearchIndex + && packageSearchIndex + && typeSearchIndex + && memberSearchIndex + && tagSearchIndex; +} + +// Workaround for scroll position not being included in browser history (8249133) +document.addEventListener("DOMContentLoaded", function(e) { + var contentDiv = document.querySelector("div.flex-content"); + window.addEventListener("popstate", function(e) { + if (e.state !== null) { + contentDiv.scrollTop = e.state; + } + }); + window.addEventListener("hashchange", function(e) { + history.replaceState(contentDiv.scrollTop, document.title); + }); + contentDiv.addEventListener("scroll", function(e) { + var timeoutID; + if (!timeoutID) { + timeoutID = setTimeout(function() { + history.replaceState(contentDiv.scrollTop, document.title); + timeoutID = null; + }, 100); + } + }); + if (!location.hash) { + history.replaceState(contentDiv.scrollTop, document.title); + } +}); diff --git a/doc/search.js b/doc/search.js new file mode 100644 index 00000000..db3b2f4a --- /dev/null +++ b/doc/search.js @@ -0,0 +1,354 @@ +/* + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +var noResult = {l: "No results found"}; +var loading = {l: "Loading search index..."}; +var catModules = "Modules"; +var catPackages = "Packages"; +var catTypes = "Classes and Interfaces"; +var catMembers = "Members"; +var catSearchTags = "Search Tags"; +var highlight = "$&"; +var searchPattern = ""; +var fallbackPattern = ""; +var RANKING_THRESHOLD = 2; +var NO_MATCH = 0xffff; +var MIN_RESULTS = 3; +var MAX_RESULTS = 500; +var UNNAMED = ""; +function escapeHtml(str) { + return str.replace(//g, ">"); +} +function getHighlightedText(item, matcher, fallbackMatcher) { + var escapedItem = escapeHtml(item); + var highlighted = escapedItem.replace(matcher, highlight); + if (highlighted === escapedItem) { + highlighted = escapedItem.replace(fallbackMatcher, highlight) + } + return highlighted; +} +function getURLPrefix(ui) { + var urlPrefix=""; + var slash = "/"; + if (ui.item.category === catModules) { + return ui.item.l + slash; + } else if (ui.item.category === catPackages && ui.item.m) { + return ui.item.m + slash; + } else if (ui.item.category === catTypes || ui.item.category === catMembers) { + if (ui.item.m) { + urlPrefix = ui.item.m + slash; + } else { + $.each(packageSearchIndex, function(index, item) { + if (item.m && ui.item.p === item.l) { + urlPrefix = item.m + slash; + } + }); + } + } + return urlPrefix; +} +function createSearchPattern(term) { + var pattern = ""; + var isWordToken = false; + term.replace(/,\s*/g, ", ").trim().split(/\s+/).forEach(function(w, index) { + if (index > 0) { + // whitespace between identifiers is significant + pattern += (isWordToken && /^\w/.test(w)) ? "\\s+" : "\\s*"; + } + var tokens = w.split(/(?=[A-Z,.()<>[\/])/); + for (var i = 0; i < tokens.length; i++) { + var s = tokens[i]; + if (s === "") { + continue; + } + pattern += $.ui.autocomplete.escapeRegex(s); + isWordToken = /\w$/.test(s); + if (isWordToken) { + pattern += "([a-z0-9_$<>\\[\\]]*?)"; + } + } + }); + return pattern; +} +function createMatcher(pattern, flags) { + var isCamelCase = /[A-Z]/.test(pattern); + return new RegExp(pattern, flags + (isCamelCase ? "" : "i")); +} +var watermark = 'Search'; +$(function() { + var search = $("#search-input"); + var reset = $("#reset-button"); + search.val(''); + search.prop("disabled", false); + reset.prop("disabled", false); + search.val(watermark).addClass('watermark'); + search.blur(function() { + if ($(this).val().length === 0) { + $(this).val(watermark).addClass('watermark'); + } + }); + search.on('click keydown paste', function() { + if ($(this).val() === watermark) { + $(this).val('').removeClass('watermark'); + } + }); + reset.click(function() { + search.val('').focus(); + }); + search.focus()[0].setSelectionRange(0, 0); +}); +$.widget("custom.catcomplete", $.ui.autocomplete, { + _create: function() { + this._super(); + this.widget().menu("option", "items", "> :not(.ui-autocomplete-category)"); + }, + _renderMenu: function(ul, items) { + var rMenu = this; + var currentCategory = ""; + rMenu.menu.bindings = $(); + $.each(items, function(index, item) { + var li; + if (item.category && item.category !== currentCategory) { + ul.append("
    • " + item.category + "
    • "); + currentCategory = item.category; + } + li = rMenu._renderItemData(ul, item); + if (item.category) { + li.attr("aria-label", item.category + " : " + item.l); + li.attr("class", "result-item"); + } else { + li.attr("aria-label", item.l); + li.attr("class", "result-item"); + } + }); + }, + _renderItem: function(ul, item) { + var label = ""; + var matcher = createMatcher(escapeHtml(searchPattern), "g"); + var fallbackMatcher = new RegExp(fallbackPattern, "gi") + if (item.category === catModules) { + label = getHighlightedText(item.l, matcher, fallbackMatcher); + } else if (item.category === catPackages) { + label = getHighlightedText(item.l, matcher, fallbackMatcher); + } else if (item.category === catTypes) { + label = (item.p && item.p !== UNNAMED) + ? getHighlightedText(item.p + "." + item.l, matcher, fallbackMatcher) + : getHighlightedText(item.l, matcher, fallbackMatcher); + } else if (item.category === catMembers) { + label = (item.p && item.p !== UNNAMED) + ? getHighlightedText(item.p + "." + item.c + "." + item.l, matcher, fallbackMatcher) + : getHighlightedText(item.c + "." + item.l, matcher, fallbackMatcher); + } else if (item.category === catSearchTags) { + label = getHighlightedText(item.l, matcher, fallbackMatcher); + } else { + label = item.l; + } + var li = $("
    • ").appendTo(ul); + var div = $("
      ").appendTo(li); + if (item.category === catSearchTags && item.h) { + if (item.d) { + div.html(label + " (" + item.h + ")
      " + + item.d + "
      "); + } else { + div.html(label + " (" + item.h + ")"); + } + } else { + if (item.m) { + div.html(item.m + "/" + label); + } else { + div.html(label); + } + } + return li; + } +}); +function rankMatch(match, category) { + if (!match) { + return NO_MATCH; + } + var index = match.index; + var input = match.input; + var leftBoundaryMatch = 2; + var periferalMatch = 0; + // make sure match is anchored on a left word boundary + if (index === 0 || /\W/.test(input[index - 1]) || "_" === input[index]) { + leftBoundaryMatch = 0; + } else if ("_" === input[index - 1] || (input[index] === input[index].toUpperCase() && !/^[A-Z0-9_$]+$/.test(input))) { + leftBoundaryMatch = 1; + } + var matchEnd = index + match[0].length; + var leftParen = input.indexOf("("); + var endOfName = leftParen > -1 ? leftParen : input.length; + // exclude peripheral matches + if (category !== catModules && category !== catSearchTags) { + var delim = category === catPackages ? "/" : "."; + if (leftParen > -1 && leftParen < index) { + periferalMatch += 2; + } else if (input.lastIndexOf(delim, endOfName) >= matchEnd) { + periferalMatch += 2; + } + } + var delta = match[0].length === endOfName ? 0 : 1; // rank full match higher than partial match + for (var i = 1; i < match.length; i++) { + // lower ranking if parts of the name are missing + if (match[i]) + delta += match[i].length; + } + if (category === catTypes) { + // lower ranking if a type name contains unmatched camel-case parts + if (/[A-Z]/.test(input.substring(matchEnd))) + delta += 5; + if (/[A-Z]/.test(input.substring(0, index))) + delta += 5; + } + return leftBoundaryMatch + periferalMatch + (delta / 200); + +} +function doSearch(request, response) { + var result = []; + searchPattern = createSearchPattern(request.term); + fallbackPattern = createSearchPattern(request.term.toLowerCase()); + if (searchPattern === "") { + return this.close(); + } + var camelCaseMatcher = createMatcher(searchPattern, ""); + var fallbackMatcher = new RegExp(fallbackPattern, "i"); + + function searchIndexWithMatcher(indexArray, matcher, category, nameFunc) { + if (indexArray) { + var newResults = []; + $.each(indexArray, function (i, item) { + item.category = category; + var ranking = rankMatch(matcher.exec(nameFunc(item)), category); + if (ranking < RANKING_THRESHOLD) { + newResults.push({ranking: ranking, item: item}); + } + return newResults.length <= MAX_RESULTS; + }); + return newResults.sort(function(e1, e2) { + return e1.ranking - e2.ranking; + }).map(function(e) { + return e.item; + }); + } + return []; + } + function searchIndex(indexArray, category, nameFunc) { + var primaryResults = searchIndexWithMatcher(indexArray, camelCaseMatcher, category, nameFunc); + result = result.concat(primaryResults); + if (primaryResults.length <= MIN_RESULTS && !camelCaseMatcher.ignoreCase) { + var secondaryResults = searchIndexWithMatcher(indexArray, fallbackMatcher, category, nameFunc); + result = result.concat(secondaryResults.filter(function (item) { + return primaryResults.indexOf(item) === -1; + })); + } + } + + searchIndex(moduleSearchIndex, catModules, function(item) { return item.l; }); + searchIndex(packageSearchIndex, catPackages, function(item) { + return (item.m && request.term.indexOf("/") > -1) + ? (item.m + "/" + item.l) : item.l; + }); + searchIndex(typeSearchIndex, catTypes, function(item) { + return request.term.indexOf(".") > -1 ? item.p + "." + item.l : item.l; + }); + searchIndex(memberSearchIndex, catMembers, function(item) { + return request.term.indexOf(".") > -1 + ? item.p + "." + item.c + "." + item.l : item.l; + }); + searchIndex(tagSearchIndex, catSearchTags, function(item) { return item.l; }); + + if (!indexFilesLoaded()) { + updateSearchResults = function() { + doSearch(request, response); + } + result.unshift(loading); + } else { + updateSearchResults = function() {}; + } + response(result); +} +$(function() { + $("#search-input").catcomplete({ + minLength: 1, + delay: 300, + source: doSearch, + response: function(event, ui) { + if (!ui.content.length) { + ui.content.push(noResult); + } else { + $("#search-input").empty(); + } + }, + autoFocus: true, + focus: function(event, ui) { + return false; + }, + position: { + collision: "flip" + }, + select: function(event, ui) { + if (ui.item.category) { + var url = getURLPrefix(ui); + if (ui.item.category === catModules) { + url += "module-summary.html"; + } else if (ui.item.category === catPackages) { + if (ui.item.u) { + url = ui.item.u; + } else { + url += ui.item.l.replace(/\./g, '/') + "/package-summary.html"; + } + } else if (ui.item.category === catTypes) { + if (ui.item.u) { + url = ui.item.u; + } else if (ui.item.p === UNNAMED) { + url += ui.item.l + ".html"; + } else { + url += ui.item.p.replace(/\./g, '/') + "/" + ui.item.l + ".html"; + } + } else if (ui.item.category === catMembers) { + if (ui.item.p === UNNAMED) { + url += ui.item.c + ".html" + "#"; + } else { + url += ui.item.p.replace(/\./g, '/') + "/" + ui.item.c + ".html" + "#"; + } + if (ui.item.u) { + url += ui.item.u; + } else { + url += ui.item.l; + } + } else if (ui.item.category === catSearchTags) { + url += ui.item.u; + } + if (top !== window) { + parent.classFrame.location = pathtoroot + url; + } else { + window.location.href = pathtoroot + url; + } + $("#search-input").focus(); + } + } + }); +}); diff --git a/doc/serialized-form.html b/doc/serialized-form.html new file mode 100644 index 00000000..b8db20b7 --- /dev/null +++ b/doc/serialized-form.html @@ -0,0 +1,86 @@ + + + + +Serialized Form + + + + + + + + + + + + + + + +
      + +
      +
      +
      +

      Serialized Form

      +
      + +
      +
      +
      + + diff --git a/doc/stylesheet.css b/doc/stylesheet.css new file mode 100644 index 00000000..836c62da --- /dev/null +++ b/doc/stylesheet.css @@ -0,0 +1,865 @@ +/* + * Javadoc style sheet + */ + +@import url('resources/fonts/dejavu.css'); + +/* + * Styles for individual HTML elements. + * + * These are styles that are specific to individual HTML elements. Changing them affects the style of a particular + * HTML element throughout the page. + */ + +body { + background-color:#ffffff; + color:#353833; + font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; + font-size:14px; + margin:0; + padding:0; + height:100%; + width:100%; +} +iframe { + margin:0; + padding:0; + height:100%; + width:100%; + overflow-y:scroll; + border:none; +} +a:link, a:visited { + text-decoration:none; + color:#4A6782; +} +a[href]:hover, a[href]:focus { + text-decoration:none; + color:#bb7a2a; +} +a[name] { + color:#353833; +} +pre { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; +} +h1 { + font-size:20px; +} +h2 { + font-size:18px; +} +h3 { + font-size:16px; +} +h4 { + font-size:15px; +} +h5 { + font-size:14px; +} +h6 { + font-size:13px; +} +ul { + list-style-type:disc; +} +code, tt { + font-family:'DejaVu Sans Mono', monospace; +} +:not(h1, h2, h3, h4, h5, h6) > code, +:not(h1, h2, h3, h4, h5, h6) > tt { + font-size:14px; + padding-top:4px; + margin-top:8px; + line-height:1.4em; +} +dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; +} +.summary-table dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + vertical-align:top; + padding-top:4px; +} +sup { + font-size:8px; +} +button { + font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; + font-size: 14px; +} +/* + * Styles for HTML generated by javadoc. + * + * These are style classes that are used by the standard doclet to generate HTML documentation. + */ + +/* + * Styles for document title and copyright. + */ +.clear { + clear:both; + height:0; + overflow:hidden; +} +.about-language { + float:right; + padding:0 21px 8px 8px; + font-size:11px; + margin-top:-9px; + height:2.9em; +} +.legal-copy { + margin-left:.5em; +} +.tab { + background-color:#0066FF; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* + * Styles for navigation bar. + */ +@media screen { + .flex-box { + position:fixed; + display:flex; + flex-direction:column; + height: 100%; + width: 100%; + } + .flex-header { + flex: 0 0 auto; + } + .flex-content { + flex: 1 1 auto; + overflow-y: auto; + } +} +.top-nav { + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + min-height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.sub-nav { + background-color:#dee3e9; + float:left; + width:100%; + overflow:hidden; + font-size:12px; +} +.sub-nav div { + clear:left; + float:left; + padding:0 0 5px 6px; + text-transform:uppercase; +} +.sub-nav .nav-list { + padding-top:5px; +} +ul.nav-list { + display:block; + margin:0 25px 0 0; + padding:0; +} +ul.sub-nav-list { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.nav-list li { + list-style:none; + float:left; + padding: 5px 6px; + text-transform:uppercase; +} +.sub-nav .nav-list-search { + float:right; + margin:0 0 0 0; + padding:5px 6px; + clear:none; +} +.nav-list-search label { + position:relative; + right:-16px; +} +ul.sub-nav-list li { + list-style:none; + float:left; + padding-top:10px; +} +.top-nav a:link, .top-nav a:active, .top-nav a:visited { + color:#FFFFFF; + text-decoration:none; + text-transform:uppercase; +} +.top-nav a:hover { + text-decoration:none; + color:#bb7a2a; + text-transform:uppercase; +} +.nav-bar-cell1-rev { + background-color:#F8981D; + color:#253441; + margin: auto 5px; +} +.skip-nav { + position:absolute; + top:auto; + left:-9999px; + overflow:hidden; +} +/* + * Hide navigation links and search box in print layout + */ +@media print { + ul.nav-list, div.sub-nav { + display:none; + } +} +/* + * Styles for page header and footer. + */ +.title { + color:#2c4557; + margin:10px 0; +} +.sub-title { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 15px 0; + padding:0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:13px; +} +/* + * Styles for headings. + */ +body.class-declaration-page .summary h2, +body.class-declaration-page .details h2, +body.class-use-page h2, +body.module-declaration-page .block-list h2 { + font-style: italic; + padding:0; + margin:15px 0; +} +body.class-declaration-page .summary h3, +body.class-declaration-page .details h3, +body.class-declaration-page .summary .inherited-list h2 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +/* + * Styles for page layout containers. + */ +main { + clear:both; + padding:10px 20px; + position:relative; +} +dl.notes > dt { + font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; + font-size:12px; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +dl.notes > dd { + margin:5px 10px 10px 0; + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; +} +dl.name-value > dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +dl.name-value > dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* + * Styles for lists. + */ +li.circle { + list-style:circle; +} +ul.horizontal li { + display:inline; + font-size:0.9em; +} +div.inheritance { + margin:0; + padding:0; +} +div.inheritance div.inheritance { + margin-left:2em; +} +ul.block-list, +ul.details-list, +ul.member-list, +ul.summary-list { + margin:10px 0 10px 0; + padding:0; +} +ul.block-list > li, +ul.details-list > li, +ul.member-list > li, +ul.summary-list > li { + list-style:none; + margin-bottom:15px; + line-height:1.4; +} +.summary-table dl, .summary-table dl dt, .summary-table dl dd { + margin-top:0; + margin-bottom:1px; +} +ul.see-list, ul.see-list-long { + padding-left: 0; + list-style: none; +} +ul.see-list li { + display: inline; +} +ul.see-list li:not(:last-child):after, +ul.see-list-long li:not(:last-child):after { + content: ", "; + white-space: pre-wrap; +} +/* + * Styles for tables. + */ +.summary-table, .details-table { + width:100%; + border-spacing:0; + border-left:1px solid #EEE; + border-right:1px solid #EEE; + border-bottom:1px solid #EEE; + padding:0; +} +.caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#253441; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0; + padding-top:10px; + padding-left:1px; + margin:0; + white-space:pre; +} +.caption a:link, .caption a:visited { + color:#1f389c; +} +.caption a:hover, +.caption a:active { + color:#FFFFFF; +} +.caption span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + padding-bottom:7px; + display:inline-block; + float:left; + background-color:#F8981D; + border: none; + height:16px; +} +div.table-tabs { + padding:10px 0 0 1px; + margin:0; +} +div.table-tabs > button { + border: none; + cursor: pointer; + padding: 5px 12px 7px 12px; + font-weight: bold; + margin-right: 3px; +} +div.table-tabs > button.active-table-tab { + background: #F8981D; + color: #253441; +} +div.table-tabs > button.table-tab { + background: #4D7A97; + color: #FFFFFF; +} +.two-column-summary { + display: grid; + grid-template-columns: minmax(15%, max-content) minmax(15%, auto); +} +.three-column-summary { + display: grid; + grid-template-columns: minmax(10%, max-content) minmax(15%, max-content) minmax(15%, auto); +} +.four-column-summary { + display: grid; + grid-template-columns: minmax(10%, max-content) minmax(10%, max-content) minmax(10%, max-content) minmax(10%, auto); +} +@media screen and (max-width: 600px) { + .two-column-summary { + display: grid; + grid-template-columns: 1fr; + } +} +@media screen and (max-width: 800px) { + .three-column-summary { + display: grid; + grid-template-columns: minmax(10%, max-content) minmax(25%, auto); + } + .three-column-summary .col-last { + grid-column-end: span 2; + } +} +@media screen and (max-width: 1000px) { + .four-column-summary { + display: grid; + grid-template-columns: minmax(15%, max-content) minmax(15%, auto); + } +} +.summary-table > div, .details-table > div { + text-align:left; + padding: 8px 3px 3px 7px; +} +.col-first, .col-second, .col-last, .col-constructor-name, .col-summary-item-name { + vertical-align:top; + padding-right:0; + padding-top:8px; + padding-bottom:3px; +} +.table-header { + background:#dee3e9; + font-weight: bold; +} +.col-first, .col-first { + font-size:13px; +} +.col-second, .col-second, .col-last, .col-constructor-name, .col-summary-item-name, .col-last { + font-size:13px; +} +.col-first, .col-second, .col-constructor-name { + vertical-align:top; + overflow: auto; +} +.col-last { + white-space:normal; +} +.col-first a:link, .col-first a:visited, +.col-second a:link, .col-second a:visited, +.col-first a:link, .col-first a:visited, +.col-second a:link, .col-second a:visited, +.col-constructor-name a:link, .col-constructor-name a:visited, +.col-summary-item-name a:link, .col-summary-item-name a:visited, +.constant-values-container a:link, .constant-values-container a:visited, +.all-classes-container a:link, .all-classes-container a:visited, +.all-packages-container a:link, .all-packages-container a:visited { + font-weight:bold; +} +.table-sub-heading-color { + background-color:#EEEEFF; +} +.even-row-color, .even-row-color .table-header { + background-color:#FFFFFF; +} +.odd-row-color, .odd-row-color .table-header { + background-color:#EEEEEF; +} +/* + * Styles for contents. + */ +.deprecated-content { + margin:0; + padding:10px 0; +} +div.block { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; +} +.col-last div { + padding-top:0; +} +.col-last a { + padding-bottom:3px; +} +.module-signature, +.package-signature, +.type-signature, +.member-signature { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + margin:14px 0; + white-space: pre-wrap; +} +.module-signature, +.package-signature, +.type-signature { + margin-top: 0; +} +.member-signature .type-parameters-long, +.member-signature .parameters, +.member-signature .exceptions { + display: inline-block; + vertical-align: top; + white-space: pre; +} +.member-signature .type-parameters { + white-space: normal; +} +/* + * Styles for formatting effect. + */ +.source-line-no { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:10px; +} +.block { + display:block; + margin:0 10px 5px 0; + color:#474747; +} +.deprecated-label, .descfrm-type-label, .implementation-label, .member-name-label, .member-name-link, +.module-label-in-package, .module-label-in-type, .override-specify-label, .package-label-in-type, +.package-hierarchy-label, .type-name-label, .type-name-link, .search-tag-link, .preview-label { + font-weight:bold; +} +.deprecation-comment, .help-footnote, .preview-comment { + font-style:italic; +} +.deprecation-block { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; + border-style:solid; + border-width:thin; + border-radius:10px; + padding:10px; + margin-bottom:10px; + margin-right:10px; + display:inline-block; +} +.preview-block { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; + border-style:solid; + border-width:thin; + border-radius:10px; + padding:10px; + margin-bottom:10px; + margin-right:10px; + display:inline-block; +} +div.block div.deprecation-comment { + font-style:normal; +} +/* + * Styles specific to HTML5 elements. + */ +main, nav, header, footer, section { + display:block; +} +/* + * Styles for javadoc search. + */ +.ui-autocomplete-category { + font-weight:bold; + font-size:15px; + padding:7px 0 7px 3px; + background-color:#4D7A97; + color:#FFFFFF; +} +.result-item { + font-size:13px; +} +.ui-autocomplete { + max-height:85%; + max-width:65%; + overflow-y:scroll; + overflow-x:scroll; + white-space:nowrap; + box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23); +} +ul.ui-autocomplete { + position:fixed; + z-index:999999; +} +ul.ui-autocomplete li { + float:left; + clear:both; + width:100%; +} +.result-highlight { + font-weight:bold; +} +#search-input { + background-image:url('resources/glass.png'); + background-size:13px; + background-repeat:no-repeat; + background-position:2px 3px; + padding-left:20px; + position:relative; + right:-18px; + width:400px; +} +#reset-button { + background-color: rgb(255,255,255); + background-image:url('resources/x.png'); + background-position:center; + background-repeat:no-repeat; + background-size:12px; + border:0 none; + width:16px; + height:16px; + position:relative; + left:-4px; + top:-4px; + font-size:0px; +} +.watermark { + color:#545454; +} +.search-tag-desc-result { + font-style:italic; + font-size:11px; +} +.search-tag-holder-result { + font-style:italic; + font-size:12px; +} +.search-tag-result:target { + background-color:yellow; +} +.module-graph span { + display:none; + position:absolute; +} +.module-graph:hover span { + display:block; + margin: -100px 0 0 100px; + z-index: 1; +} +.inherited-list { + margin: 10px 0 10px 0; +} +section.class-description { + line-height: 1.4; +} +.summary section[class$="-summary"], .details section[class$="-details"], +.class-uses .detail, .serialized-class-details { + padding: 0px 20px 5px 10px; + border: 1px solid #ededed; + background-color: #f8f8f8; +} +.inherited-list, section[class$="-details"] .detail { + padding:0 0 5px 8px; + background-color:#ffffff; + border:none; +} +.vertical-separator { + padding: 0 5px; +} +ul.help-section-list { + margin: 0; +} +ul.help-subtoc > li { + display: inline-block; + padding-right: 5px; + font-size: smaller; +} +ul.help-subtoc > li::before { + content: "\2022" ; + padding-right:2px; +} +span.help-note { + font-style: italic; +} +/* + * Indicator icon for external links. + */ +main a[href*="://"]::after { + content:""; + display:inline-block; + background-image:url('data:image/svg+xml; utf8, \ + \ + \ + '); + background-size:100% 100%; + width:7px; + height:7px; + margin-left:2px; + margin-bottom:4px; +} +main a[href*="://"]:hover::after, +main a[href*="://"]:focus::after { + background-image:url('data:image/svg+xml; utf8, \ + \ + \ + '); +} + +/* + * Styles for user-provided tables. + * + * borderless: + * No borders, vertical margins, styled caption. + * This style is provided for use with existing doc comments. + * In general, borderless tables should not be used for layout purposes. + * + * plain: + * Plain borders around table and cells, vertical margins, styled caption. + * Best for small tables or for complex tables for tables with cells that span + * rows and columns, when the "striped" style does not work well. + * + * striped: + * Borders around the table and vertical borders between cells, striped rows, + * vertical margins, styled caption. + * Best for tables that have a header row, and a body containing a series of simple rows. + */ + +table.borderless, +table.plain, +table.striped { + margin-top: 10px; + margin-bottom: 10px; +} +table.borderless > caption, +table.plain > caption, +table.striped > caption { + font-weight: bold; + font-size: smaller; +} +table.borderless th, table.borderless td, +table.plain th, table.plain td, +table.striped th, table.striped td { + padding: 2px 5px; +} +table.borderless, +table.borderless > thead > tr > th, table.borderless > tbody > tr > th, table.borderless > tr > th, +table.borderless > thead > tr > td, table.borderless > tbody > tr > td, table.borderless > tr > td { + border: none; +} +table.borderless > thead > tr, table.borderless > tbody > tr, table.borderless > tr { + background-color: transparent; +} +table.plain { + border-collapse: collapse; + border: 1px solid black; +} +table.plain > thead > tr, table.plain > tbody tr, table.plain > tr { + background-color: transparent; +} +table.plain > thead > tr > th, table.plain > tbody > tr > th, table.plain > tr > th, +table.plain > thead > tr > td, table.plain > tbody > tr > td, table.plain > tr > td { + border: 1px solid black; +} +table.striped { + border-collapse: collapse; + border: 1px solid black; +} +table.striped > thead { + background-color: #E3E3E3; +} +table.striped > thead > tr > th, table.striped > thead > tr > td { + border: 1px solid black; +} +table.striped > tbody > tr:nth-child(even) { + background-color: #EEE +} +table.striped > tbody > tr:nth-child(odd) { + background-color: #FFF +} +table.striped > tbody > tr > th, table.striped > tbody > tr > td { + border-left: 1px solid black; + border-right: 1px solid black; +} +table.striped > tbody > tr > th { + font-weight: normal; +} +/** + * Tweak font sizes and paddings for small screens. + */ +@media screen and (max-width: 1050px) { + #search-input { + width: 300px; + } +} +@media screen and (max-width: 800px) { + #search-input { + width: 200px; + } + .top-nav, + .bottom-nav { + font-size: 11px; + padding-top: 6px; + } + .sub-nav { + font-size: 11px; + } + .about-language { + padding-right: 16px; + } + ul.nav-list li, + .sub-nav .nav-list-search { + padding: 6px; + } + ul.sub-nav-list li { + padding-top: 5px; + } + main { + padding: 10px; + } + .summary section[class$="-summary"], .details section[class$="-details"], + .class-uses .detail, .serialized-class-details { + padding: 0 8px 5px 8px; + } + body { + -webkit-text-size-adjust: none; + } +} +@media screen and (max-width: 500px) { + #search-input { + width: 150px; + } + .top-nav, + .bottom-nav { + font-size: 10px; + } + .sub-nav { + font-size: 10px; + } + .about-language { + font-size: 10px; + padding-right: 12px; + } +} diff --git a/doc/tag-search-index.js b/doc/tag-search-index.js new file mode 100644 index 00000000..f38b3cb3 --- /dev/null +++ b/doc/tag-search-index.js @@ -0,0 +1 @@ +tagSearchIndex = [{"l":"Serialized Form","h":"","u":"serialized-form.html"}];updateSearchResults(); \ No newline at end of file diff --git a/doc/type-search-index.js b/doc/type-search-index.js new file mode 100644 index 00000000..2ebf78b1 --- /dev/null +++ b/doc/type-search-index.js @@ -0,0 +1 @@ +typeSearchIndex = [{"p":"com.rubynaxela.kyanite.game.gui","l":"Text.Alignment"},{"l":"All Classes and Interfaces","u":"allclasses-index.html"},{"p":"com.rubynaxela.kyanite.game.assets","l":"Asset"},{"p":"com.rubynaxela.kyanite.system","l":"AssetId"},{"p":"com.rubynaxela.kyanite.game.assets","l":"AssetsBundle"},{"p":"com.rubynaxela.kyanite.system","l":"Clock"},{"p":"com.rubynaxela.kyanite.window.event","l":"CloseListener"},{"p":"com.rubynaxela.kyanite.game.entities","l":"CompoundEntity"},{"p":"com.rubynaxela.kyanite.system","l":"FirstThreadTool"},{"p":"com.rubynaxela.kyanite.window.event","l":"FocusListener"},{"p":"com.rubynaxela.kyanite.game.gui","l":"Font"},{"p":"com.rubynaxela.kyanite.game.assets","l":"FontFace"},{"p":"com.rubynaxela.kyanite.game","l":"GameContext"},{"p":"com.rubynaxela.kyanite.game.entities","l":"HitBox"},{"p":"com.rubynaxela.kyanite.window.event","l":"JoystickButtonListener"},{"p":"com.rubynaxela.kyanite.window.event","l":"JoystickConnectionListener"},{"p":"com.rubynaxela.kyanite.window.event","l":"JoystickListener"},{"p":"com.rubynaxela.kyanite.window.event","l":"KeyListener"},{"p":"com.rubynaxela.kyanite.util","l":"MathUtils"},{"p":"com.rubynaxela.kyanite.window.event","l":"MouseButtonListener"},{"p":"com.rubynaxela.kyanite.window.event","l":"MouseListener"},{"p":"com.rubynaxela.kyanite.window.event","l":"MouseWheelListener"},{"p":"com.rubynaxela.kyanite.util","l":"Pair"},{"p":"com.rubynaxela.kyanite.window.event","l":"ResizeEvent"},{"p":"com.rubynaxela.kyanite.window.event","l":"ResizeListener"},{"p":"com.rubynaxela.kyanite.window","l":"Scene"},{"p":"com.rubynaxela.kyanite.game.assets","l":"Sound"},{"p":"com.rubynaxela.kyanite.game.gui","l":"Text"},{"p":"com.rubynaxela.kyanite.window.event","l":"TextListener"},{"p":"com.rubynaxela.kyanite.game.assets","l":"Texture"},{"p":"com.rubynaxela.kyanite.window","l":"Window"}];updateSearchResults(); \ No newline at end of file diff --git a/kyanite.iml b/kyanite.iml new file mode 100644 index 00000000..de90c35a --- /dev/null +++ b/kyanite.iml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/annotations-20.1.0.jar b/lib/annotations-20.1.0.jar new file mode 100644 index 00000000..8bd96c58 Binary files /dev/null and b/lib/annotations-20.1.0.jar differ diff --git a/lib/jackson-annotations-2.13.0.jar b/lib/jackson-annotations-2.13.0.jar new file mode 100644 index 00000000..ad9613d0 Binary files /dev/null and b/lib/jackson-annotations-2.13.0.jar differ diff --git a/lib/jackson-core-2.13.0.jar b/lib/jackson-core-2.13.0.jar new file mode 100644 index 00000000..fd8c2ed5 Binary files /dev/null and b/lib/jackson-core-2.13.0.jar differ diff --git a/lib/jackson-databind-2.13.0.jar b/lib/jackson-databind-2.13.0.jar new file mode 100644 index 00000000..d72f47ec Binary files /dev/null and b/lib/jackson-databind-2.13.0.jar differ diff --git a/lib/jsfml/bin/jsfml.jar b/lib/jsfml/bin/jsfml.jar new file mode 100644 index 00000000..1ec34110 Binary files /dev/null and b/lib/jsfml/bin/jsfml.jar differ diff --git a/lib/jsfml/src/java/org/jsfml/audio/ConstSoundBuffer.java b/lib/jsfml/src/java/org/jsfml/audio/ConstSoundBuffer.java new file mode 100644 index 00000000..eca1e1b7 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/audio/ConstSoundBuffer.java @@ -0,0 +1,65 @@ +package org.jsfml.audio; + +import org.jsfml.internal.Const; +import org.jsfml.system.Time; + +import java.io.IOException; +import java.nio.file.Path; + + +/** + * Read-only interface for sound buffers. + *

      + * It provides methods to can gain information from a sound buffer (such as the duration) + * and save it to a file. + *

      + * Note that this interface is expected to be implemented by a {@link SoundBuffer}. + * It is not recommended to be implemented outside of the JSFML API. + * + * @see Const + */ +public interface ConstSoundBuffer extends Const { + /** + * Attempts to save the sound buffer to a file. + * + * @param path the path to the file to write. + * @throws IOException in case saving failed. + */ + public void saveToFile(Path path) throws IOException; + + /** + * Retrieves the raw 16-bit audio samples stored in the buffer. + * + * @return the raw audio 16-bit samples stored in the buffer. + */ + public short[] getSamples(); + + /** + * Retrieves the amount of samples stored in the buffer. + * + * @return the amount of samples stored in the buffer. + */ + public int getSampleCount(); + + /** + * Gets the sound buffer's sample rate in samples per second. + * + * @return the sound buffer's sample rate in samples per second. + */ + public int getSampleRate(); + + /** + * Gets the amount of audio channels in the buffer + * (e.g. 1 for mono, 2 for stereo etc). + * + * @return the amount of audio channels in the buffer. + */ + public int getChannelCount(); + + /** + * Gets the duration of the sound. + * + * @return the duration of the sound. + */ + public Time getDuration(); +} diff --git a/lib/jsfml/src/java/org/jsfml/audio/Listener.java b/lib/jsfml/src/java/org/jsfml/audio/Listener.java new file mode 100644 index 00000000..03585db6 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/audio/Listener.java @@ -0,0 +1,129 @@ +package org.jsfml.audio; + +import org.jsfml.internal.SFMLNative; +import org.jsfml.system.Vector3f; + +/** + * Represents the point in the scene from where all the sounds are heard and + * provides funcionality to modify it. + *

      + * Modifying the position and orientation ("view direction") of the listener + * changes the way sounds are heard to accomplish 3D sound. + * Sounds will be panned and attenuated according to their position relative to the listener + * and the listener's orientation.. + */ +public final class Listener { + static { + SFMLNative.loadNativeLibraries(); + } + + //cache + private static float volume = 100; + private static Vector3f position = Vector3f.ZERO; + private static Vector3f direction = Vector3f.ZERO; + + private static native void nativeSetGlobalVolume(float volume); + + /** + * Sets the global sound volume. + *

      + * The default global volume is 100 (maximum). + * + * @param volume the global sound volume, ranging between 0 (silence) and 100 (full volume). + */ + public static void setGlobalVolume(float volume) { + nativeSetGlobalVolume(volume); + Listener.volume = volume; + } + + /** + * Gets the global sound volume. + * + * @return the global sound volume, ranging between 0 (silence) and 100 (full volume). + */ + public static float getGlobalVolume() { + return volume; + } + + private static native void nativeSetPosition(float x, float y, float z); + + /** + * Sets the position of the listener in the scene. + *

      + * Initially, the listener is located at the origin (0, 0, 0). + * + * @param x the X coordinate of the listener's new position. + * @param y the Y coordinate of the listener's new position. + * @param z the Z coordinate of the listener's new position. + * @see SoundSource#setPosition(org.jsfml.system.Vector3f) + */ + public static void setPosition(float x, float y, float z) { + setPosition(new Vector3f(x, y, z)); + } + + /** + * Sets the position of the listener in the scene. + *

      + * Initially, the listener is located at the origin (0, 0, 0). + * + * @param v the listener's new position. + * @see SoundSource#setPosition(org.jsfml.system.Vector3f) + */ + public static void setPosition(Vector3f v) { + nativeSetPosition(v.x, v.y, v.z); + Listener.position = v; + } + + /** + * Gets the listener's current position in the scene. + * + * @return the listener's current position in the scene. + */ + public static Vector3f getPosition() { + return position; + } + + private static native void nativeSetDirection(float x, float y, float z); + + /** + * Sets the orientation or "view direction" of the listener in the scene. + *

      + * The vector passed does not need to be normalized. Initially, the listener's orientation + * is along the Z axis, looking "into" the screen (0, 0, -1). + * + * @param x the X component of the listener's new orientation. + * @param y the Y component of the listener's new orientation. + * @param z the Z component of the listener's new orientation. + * @see SoundSource#setPosition(org.jsfml.system.Vector3f) + */ + public static void setDirection(float x, float y, float z) { + setDirection(new Vector3f(x, y, z)); + } + + /** + * Sets the orientation or "view direction" of the listener in the scene. + *

      + * The vector passed does not need to be normalized. Initially, the listener's orientation + * is along the Z axis, looking "into" the screen (0, 0, -1). + * + * @param v the listener's new orientation. + * @see SoundSource#setPosition(org.jsfml.system.Vector3f) + */ + public static void setDirection(Vector3f v) { + nativeSetDirection(v.x, v.y, v.z); + Listener.direction = v; + } + + /** + * Gets the listener's current orientation or "view direction" in the scene. + * + * @return the listener's current orientation in the scene. + */ + public static Vector3f getDirection() { + return direction; + } + + //cannot instantiate + private Listener() { + } +} diff --git a/lib/jsfml/src/java/org/jsfml/audio/Music.java b/lib/jsfml/src/java/org/jsfml/audio/Music.java new file mode 100644 index 00000000..a47bfe49 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/audio/Music.java @@ -0,0 +1,123 @@ +package org.jsfml.audio; + +import org.jsfml.internal.IntercomHelper; +import org.jsfml.internal.SFMLErrorCapture; +import org.jsfml.internal.SFMLInputStream; +import org.jsfml.system.Time; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Objects; + +/** + * Provides functionality to play music streams from common audio file formats. + *

      + * Audio files can be opened using either the {@link #openFromFile(java.nio.file.Path)} or + * {@link #openFromStream(java.io.InputStream)} methods. + *

      + * The supported audio file formats are: + * {@code ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, w64, mat4, + * mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64} + */ +public class Music extends SoundStream { + private final SFMLInputStream.NativeStreamRef streamRef = + new SFMLInputStream.NativeStreamRef(); + + private Time duration = Time.ZERO; + + /** + * Constructs a music. + */ + public Music() { + super(); + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native long nativeCreate(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeSetExPtr(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeDelete(); + + private native boolean nativeOpenFromStream(SFMLInputStream.NativeStreamRef stream); + + /** + * Attempts to open the music from an {@code InputStream}. + * + * @param in the input stream to stream from. + * @throws java.io.IOException in case an I/O error occurs. + */ + public void openFromStream(InputStream in) throws IOException { + streamRef.initialize(new SFMLInputStream(Objects.requireNonNull(in))); + + SFMLErrorCapture.start(); + final boolean success = nativeOpenFromStream(streamRef); + final String msg = SFMLErrorCapture.finish(); + + if (!success) { + throw new IOException(msg); + } + + sync(); + } + + /** + * Attempts to open the music from a file. + * + * @param path the file to stream from. + * @throws IOException in case an I/O error occurs. + */ + public void openFromFile(Path path) throws IOException { + openFromStream(Files.newInputStream(path)); + } + + private native void nativeGetData(Buffer buffer); + + private void sync() { + final ByteBuffer buffer = IntercomHelper.getBuffer(); + nativeGetData(buffer); + + this.duration = Time.getMicroseconds(buffer.asLongBuffer().get(0)); + + final IntBuffer ints = buffer.asIntBuffer(); + setData(ints.get(2), ints.get(3)); + } + + /** + * Gets the total duration of the music. + * + * @return the total duration of the music. + */ + public Time getDuration() { + return duration; + } + + @Override + protected final void initialize(int channelCount, int sampleRate) { + //Music is implemented natively, so this is not used. + } + + @Override + protected final Chunk onGetData() { + //Music is implemented natively, so this is not used. + return null; + } + + @Override + protected final void onSeek(Time time) { + //Music is implemented natively, so this is not used. + } +} diff --git a/lib/jsfml/src/java/org/jsfml/audio/Sound.java b/lib/jsfml/src/java/org/jsfml/audio/Sound.java new file mode 100644 index 00000000..48174c07 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/audio/Sound.java @@ -0,0 +1,161 @@ +package org.jsfml.audio; + +import org.jsfml.internal.IntercomHelper; +import org.jsfml.internal.UnsafeOperations; +import org.jsfml.system.Time; + +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.util.Objects; + +/** + * Provides functionality to instantiate a {@code SoundBuffer} and play a buffered sound. + */ +public class Sound extends SoundSource { + //cache + private ConstSoundBuffer soundBuffer = null; + private boolean loop = false; + private Time playingOffset = Time.ZERO; + + /** + * Constructs an empty sound. + */ + public Sound() { + super(); + } + + /** + * Constructs a sound with the specified {@link SoundBuffer} + * + * @param soundBuffer the sound buffer to use. + */ + public Sound(ConstSoundBuffer soundBuffer) { + this(); + setBuffer(soundBuffer); + } + + /** + * Constructs a sound by copying another sound. + * + * @param other the sound to copy. + */ + @SuppressWarnings("deprecation") + public Sound(Sound other) { + super(other.nativeCopy()); + UnsafeOperations.manageSFMLObject(this, true); + + final ByteBuffer buffer = IntercomHelper.getBuffer(); + nativeGetData(buffer); + + this.loop = (buffer.get(0) == 1); + this.playingOffset = Time.getMicroseconds(buffer.asLongBuffer().get(1)); + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native long nativeCreate(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeSetExPtr(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeDelete(); + + private native long nativeCopy(); + + private native void nativeGetData(Buffer buffer); + + /** + * Starts playing the sound or resumes it if it is currently paused. + */ + public native void play(); + + /** + * Pauses the sound if it is currently playing. + */ + public native void pause(); + + /** + * Stops the sound if it is currently playing or paused. + */ + public native void stop(); + + private native void nativeSetBuffer(SoundBuffer soundBuffer); + + /** + * Sets the sound buffer used by this sound. + * + * @param soundBuffer the new sound buffer. + */ + public void setBuffer(ConstSoundBuffer soundBuffer) { + this.soundBuffer = Objects.requireNonNull(soundBuffer); + nativeSetBuffer((SoundBuffer) soundBuffer); + } + + private native void nativeSetLoop(boolean loop); + + /** + * Enables or disables repeated looping of the sound. + *

      + * If this is set to {@code true} and the sound has finished playing, it will + * be restarted from the beginning as if {@code setPlayingOffset(Time.ZERO)} was called. + * + * @param loop {@code true} to enable looping, {@code false} to disable. + */ + public void setLoop(boolean loop) { + nativeSetLoop(loop); + this.loop = loop; + } + + private native void nativeSetPlayingOffset(long offset); + + /** + * Sets the playing offset from where to play the underlying buffer. + * + * @param offset the playing offset in the underlaying buffer. + */ + public void setPlayingOffset(Time offset) { + nativeSetPlayingOffset(offset.asMicroseconds()); + this.playingOffset = offset; + } + + /** + * Gets the underlying sound buffer that this sound plays from. + * + * @return the underlying sound buffer that this sound plays from. + */ + public ConstSoundBuffer getBuffer() { + return soundBuffer; + } + + /** + * Returns whether or not the sound is looping. + * + * @return {@code true} if this sound is looping, {@code false} if not. + */ + public boolean isLoop() { + return loop; + } + + /** + * Gets the playing offset from where to start playing the underlying buffer. + * + * @return the playing offset from where to start playing the underlying buffer. + */ + public Time getPlayingOffset() { + return playingOffset; + } + + @Override + native int nativeGetStatus(); + + @Override + public Status getStatus() { + return super.getStatus(); + } +} diff --git a/lib/jsfml/src/java/org/jsfml/audio/SoundBuffer.java b/lib/jsfml/src/java/org/jsfml/audio/SoundBuffer.java new file mode 100644 index 00000000..5a784aec --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/audio/SoundBuffer.java @@ -0,0 +1,234 @@ +package org.jsfml.audio; + + +import org.jsfml.internal.*; +import org.jsfml.system.Time; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.*; +import java.nio.file.Path; + +/** + * Buffer of audio samples, providing an audio data source for a {@code Sound}. + */ +public class SoundBuffer extends SFMLNativeObject implements ConstSoundBuffer { + //cache + private int sampleCount = 0; + private int sampleRate = 0; + private int channelCount = 0; + private Time duration = Time.ZERO; + + private boolean needsSync = true; + private boolean samplesNeedSync = true; + private ShortBuffer samplesBuffer = null; + + /** + * Constructs a sound buffer. + */ + public SoundBuffer() { + super(); + } + + @SuppressWarnings("deprecation") + SoundBuffer(long wrap) { + super(wrap); + } + + /** + * Constructs a sound buffer by copying another sound buffer. + * + * @param other the sound buffer to copy. + */ + @SuppressWarnings("deprecation") + public SoundBuffer(ConstSoundBuffer other) { + super(((SoundBuffer) other).nativeCopy()); + UnsafeOperations.manageSFMLObject(this, true); + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native long nativeCreate(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected void nativeSetExPtr() { + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeDelete(); + + private native long nativeCopy(); + + private native boolean nativeLoadFromMemory(byte[] memory); + + /** + * Fully loads all available bytes from the specified {@link java.io.InputStream} + * and attempts to load the sound buffer from it. + * + * @param in the input stream to read from. + * @throws java.io.IOException in case an I/O error occurs. + */ + public void loadFromStream(InputStream in) throws IOException { + SFMLErrorCapture.start(); + final boolean success = nativeLoadFromMemory(StreamUtil.readStream(in)); + final String err = SFMLErrorCapture.finish(); + + if (!success) { + throw new IOException(err); + } + + needsSync = true; + samplesNeedSync = true; + } + + /** + * Attempts to load the sound buffer from a file. + * + * @param path the path to the file to load the sound buffer from. + * @throws IOException in case an I/O error occurs. + */ + public void loadFromFile(Path path) throws IOException { + SFMLErrorCapture.start(); + final boolean success = nativeLoadFromMemory(StreamUtil.readFile(path)); + final String err = SFMLErrorCapture.finish(); + + if (!success) { + throw new IOException(err); + } + + needsSync = true; + samplesNeedSync = true; + } + + private native boolean nativeLoadFromSamples(Buffer samples, int n, int channelCount, int sampleRate); + + /** + * Attempts to load the sound buffer from an array of raw 16-bit audio samples. + * + * @param samples the samples data. + * @param channelCount the amount of audio channels. + * @param sampleRate the sample rate in samples per second. + * @throws java.io.IOException in case an I/O error occurs. + */ + public void loadFromSamples(short[] samples, int channelCount, int sampleRate) + throws IOException { + + final ShortBuffer buffer = ByteBuffer.allocateDirect(2 * samples.length).order( + ByteOrder.nativeOrder()).asShortBuffer(); + + buffer.put(samples); + + SFMLErrorCapture.start(); + final boolean success = nativeLoadFromSamples( + buffer, samples.length, channelCount, sampleRate); + + final String err = SFMLErrorCapture.finish(); + + if (!success) { + throw new IOException(err); + } + + this.samplesBuffer = buffer; + this.sampleCount = samples.length; + this.channelCount = channelCount; + this.sampleRate = sampleRate; + + needsSync = true; + samplesNeedSync = false; + } + + private native boolean nativeSaveToFile(String fileName); + + @Override + public void saveToFile(Path path) throws IOException { + SFMLErrorCapture.start(); + final boolean success = nativeSaveToFile(path.toAbsolutePath().toString()); + final String err = SFMLErrorCapture.finish(); + + if (!success) { + throw new IOException(err); + } + } + + private native void nativeGetData(Buffer buffer); + + private void sync() { + if (needsSync) { + final IntBuffer ints = IntercomHelper.getBuffer().asIntBuffer(); + final LongBuffer longs = IntercomHelper.getBuffer().asLongBuffer(); + + nativeGetData(IntercomHelper.getBuffer()); + sampleCount = ints.get(0); + sampleRate = ints.get(1); + channelCount = ints.get(2); + duration = Time.getMicroseconds(longs.get(2)); + + needsSync = false; + } + } + + private native void nativeGetSamples(int n, Buffer buffer); + + private void syncSamples() { + if (samplesNeedSync) { + final int samples = getSampleCount(); + samplesBuffer = ByteBuffer.allocateDirect(2 * getSampleCount()).order( + ByteOrder.nativeOrder()).asShortBuffer(); + + nativeGetSamples(samples, samplesBuffer); + samplesNeedSync = false; + } + } + + @Override + public short[] getSamples() { + if (samplesNeedSync) { + syncSamples(); + } + + final short[] copy = new short[sampleCount]; + samplesBuffer.get(copy); + return copy; + } + + @Override + public int getSampleCount() { + if (needsSync) { + sync(); + } + + return sampleCount; + } + + @Override + public int getSampleRate() { + if (needsSync) { + sync(); + } + + return sampleRate; + } + + @Override + public int getChannelCount() { + if (needsSync) { + sync(); + } + + return channelCount; + } + + @Override + public Time getDuration() { + if (needsSync) { + sync(); + } + + return duration; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/audio/SoundBufferRecorder.java b/lib/jsfml/src/java/org/jsfml/audio/SoundBufferRecorder.java new file mode 100644 index 00000000..331a80f1 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/audio/SoundBufferRecorder.java @@ -0,0 +1,62 @@ +package org.jsfml.audio; + +/** + * A {@code SoundRecorder} which stores captured audio data into a {@code SoundBuffer}. + */ +public class SoundBufferRecorder extends SoundRecorder { + private SoundBuffer soundBuffer; + + /** + * Constructs a sound buffer recorder. + */ + public SoundBufferRecorder() { + super(); + soundBuffer = new SoundBuffer(nativeGetBuffer()); + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native long nativeCreate(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeSetExPtr(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeDelete(); + + private native long nativeGetBuffer(); + + /** + * Gets the sound buffer containing the captured audio data. + *

      + * The sound buffer will remain empty until any sound has been successfully captured + * using the {@link #start(int)} and {@link #stop()} methods. + * + * @return the sound buffer containing the captured audio data. + */ + public ConstSoundBuffer getBuffer() { + return soundBuffer; + } + + @Override + protected final boolean onStart() { + //SoundBufferRecorder is implemented natively, so this is not used. + return true; + } + + @Override + protected final boolean onProcessSamples(short[] samples) { + //SoundBufferRecorder is implemented natively, so this is not used. + return true; + } + + @Override + protected final void onStop() { + //SoundBufferRecorder is implemented natively, so this is not used. + } +} diff --git a/lib/jsfml/src/java/org/jsfml/audio/SoundRecorder.java b/lib/jsfml/src/java/org/jsfml/audio/SoundRecorder.java new file mode 100644 index 00000000..4b622a1d --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/audio/SoundRecorder.java @@ -0,0 +1,101 @@ +package org.jsfml.audio; + +import org.jsfml.internal.SFMLNative; +import org.jsfml.internal.SFMLNativeObject; + +/** + * Abstract base class for sound recorders, which provide functionality to capture audio data. + */ +public abstract class SoundRecorder extends SFMLNativeObject { + static { + SFMLNative.loadNativeLibraries(); + } + + /** + * Checks whether audio capturing is available on this system. + * + * @return {@code true} if audio capturing is available, {@code false} otherwise. + */ + public static native boolean isAvailable(); + + /** + * Constructs a sound recorder. + */ + protected SoundRecorder() { + super(); + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native long nativeCreate(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeSetExPtr(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeDelete(); + + /** + * Starts capturing audio data with the specified sample rate. + * + * @param sampleRate the sample rate in samples per second. + */ + public final native void start(int sampleRate); + + /** + * Starts capturing audio data with a sample rate of 44,100 Hz. + */ + public final void start() { + start(44100); + } + + /** + * Stops capturing audio data. + */ + public final native void stop(); + + /** + * Gets the sample rate that audio is being captured with. + * + * @return the audio sample rate in samples per second. + */ + public final native int getSampleRate(); + + /** + * Called when the sound recorder starts recording. + *

      + * This method can be implemented by deriving classes to perform any actions + * necessary before audio recording actually starts. + * + * @return {@code true} to start recording after this method is done, {@code false} to cancel. + */ + protected abstract boolean onStart(); + + /** + * Called when a new batch of audio samples comes in. + *

      + * Implementing classes can then process the captured audio data. + *

      + * Note that this method will be called in a separate audio capturing thread. + *

      + * Also note that this method is currently hardcoded to be called every 100ms, which might + * be changed in the future. + * + * @param samples the 16-bit mono samples that were captured. + * @return {@code true} to continue recording after this method is done, {@code false} + * to stop recording. + */ + protected abstract boolean onProcessSamples(short[] samples); + + /** + * Called when the audio capture has stopped. + *

      + * Note that this method will be called in a separate audio capturing thread. + */ + protected abstract void onStop(); +} diff --git a/lib/jsfml/src/java/org/jsfml/audio/SoundSource.java b/lib/jsfml/src/java/org/jsfml/audio/SoundSource.java new file mode 100644 index 00000000..45639dce --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/audio/SoundSource.java @@ -0,0 +1,276 @@ +package org.jsfml.audio; + +import org.jsfml.internal.IntercomHelper; +import org.jsfml.internal.SFMLNativeObject; +import org.jsfml.system.Vector3f; + +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; + +/** + * Abstract base class for playable sound sources. + */ +public abstract class SoundSource extends SFMLNativeObject { + /** + * Enumeration of possible sound source states. + */ + public static enum Status { + /** + * Indicates that the sound is currently stopped or has finished playing. + */ + STOPPED, + + /** + * Indicates that the sound is currently paused and can be resumed. + */ + PAUSED, + + /** + * Indicates that the sound is currently playing. + */ + PLAYING + } + + //cache + private float volume = 100; + private float pitch = 1; + private Vector3f position = Vector3f.ZERO; + private boolean relativeToListener = false; + private float minDistance = 1; + private float attenuation = 1; + + /** + * Constructs a sound source. + */ + public SoundSource() { + super(); + } + + @Deprecated + @SuppressWarnings("deprecation") + SoundSource(long wrap) { + super(wrap); + + final ByteBuffer buffer = IntercomHelper.getBuffer(); + final FloatBuffer floats = IntercomHelper.getBuffer().asFloatBuffer(); + + nativeGetData(buffer); + this.relativeToListener = (buffer.get(0) == 1); + this.volume = floats.get(1); + this.pitch = floats.get(2); + this.position = new Vector3f(floats.get(3), floats.get(4), floats.get(5)); + this.minDistance = floats.get(6); + this.attenuation = floats.get(7); + + } + + private native void nativeGetData(Buffer buffer); + + private native void nativeSetPitch(float pitch); + + /** + * Sets the pitch factor of the sound. + *

      + * This factor is used to scale the sound's original pitch. This means that the default + * value of 1 will not affect the pitch at all. Values between 0 and 1 will pitch + * down the sound, while values greater than 1 will pitch it up. + * + * @param pitch the new pitch factor of the sound. + */ + public void setPitch(float pitch) { + nativeSetPitch(pitch); + this.pitch = pitch; + } + + private native void nativeSetVolume(float volume); + + /** + * Sets the volume of the sound. + *

      + * The sound volume is a percentages and ranges between 0 (silence) and 100 (full volume). + * The default volume of a sound is 100. + * + * @param volume the new volume of the sound, ranging between 0 and 100. + */ + public void setVolume(float volume) { + nativeSetVolume(volume); + this.volume = volume; + } + + private native void nativeSetPosition(float x, float y, float z); + + /** + * Sets the position of the sound in the scene. + *

      + * This allows for sound spatialization, also involving the {@link Listener}. + * The sound position is set either absolutely in the scene or relatively to the + * {@code Listener}, depending on whether {@link #isRelativeToListener()} is + * {@code true} or {@code false}. + *

      + * By default, a sound is located at the origin {@code (0, 0, 0)}. + *

      + * Note that only mono sounds (ie 1 audio channel) can be spatialized. + * + * @param x the sound's new X coordinate. + * @param y the sound's new Y coordinate. + * @param z the sound's new Z coordinate. + * @see #setRelativeToListener(boolean) + */ + public final void setPosition(float x, float y, float z) { + setPosition(new Vector3f(x, y, z)); + } + + /** + * Sets the position of the sound in the scene. + *

      + * This allows for sound spatialization, also involving the {@link Listener}. + * The sound position is set either absolutely in the scene or relatively to the + * {@code Listener}, depending on whether {@link #isRelativeToListener()} is + * {@code true} or {@code false}. + *

      + * By default, a sound is located at the origin {@code (0, 0, 0)}. + *

      + * Note that only mono sounds (ie 1 audio channel) can be spatialized. + * + * @param v the sound's new position. + * @see #setRelativeToListener(boolean) + */ + public void setPosition(Vector3f v) { + nativeSetPosition(v.x, v.y, v.z); + this.position = v; + } + + private native void nativeSetRelativeToListener(boolean relative); + + /** + * Determines whether the sound position is bound to be relative to the {@link Listener} + * or whether it is positioned absolutely in the scene. + *

      + * By default, the sound's position in the scene is absolute. + * + * @param relative {@code true} to make the sound position relative to the listener, + * {@code false} to make it absolute. + * @see SoundSource#setPosition(float, float, float) + */ + public void setRelativeToListener(boolean relative) { + nativeSetRelativeToListener(relative); + this.relativeToListener = relative; + } + + private native void nativeSetMinDistance(float distance); + + /** + * Sets the minimum distance of the sound before attenuation kicks in. + *

      + * If the distance between the sound and the {@link Listener} is less or equal to this value, + * the sound will be heard at its maximum volume. As the distance becomes larger, + * the sound is attenuated (ie become more quiet) according to its attenuation factor. + *

      + * The default minimum distance is 1. + * + * @param distance the minimum distance before attenuation in world units. + * @see SoundSource#setAttenuation(float) + */ + public void setMinDistance(float distance) { + nativeSetMinDistance(distance); + this.minDistance = distance; + } + + private native void nativeSetAttenuation(float att); + + /** + * Sets the sound's attenuation factor. + *

      + * As the distance between the sound and the {@link Listener} becomes higher than the + * minimum distance, the sound volume will decrease according to this factor. + *

      + * The attenuation factor ranges between 0 (no attenuation) and 100 (instant attenuation), + * where the default value is 1. + * + * @param att the new attenuation factor, ranging between 0 (no attenuation) + * and 100 (instant attenuation). + * @see SoundSource#setMinDistance(float) + */ + public void setAttenuation(float att) { + nativeSetAttenuation(att); + this.attenuation = att; + } + + /** + * Gets the sound's current pitch factor. + *

      + * A value of 1 means that the sound is not pitched, a value between 0 and 1 means that + * the sound is pitched down, a value greater than 1 means that the sound is pitched up. + * + * @return the sound's current pitch factor. + */ + public float getPitch() { + return pitch; + } + + /** + * Gets the sound's current volume. + *

      + * The volume level ranges between 0 (silence) and 100 (full volume). + * + * @return the sound's current volume, ranging between 0 (silence) and 100 (full volume). + */ + public float getVolume() { + return volume; + } + + /** + * Gets the sound's current position in the scene. + * + * @return the sound's current position in the scene. + */ + public Vector3f getPosition() { + return position; + } + + /** + * Returns whether the sound's position is relative to the {@link Listener}. + * + * @return {@code true} if the sound's position is relative to the listener, {@code false} if + * it is absolute. + * @see SoundSource#setRelativeToListener(boolean) + */ + public boolean isRelativeToListener() { + return relativeToListener; + } + + /** + * Gets the sound's minimum distance from the {@link Listener} before attenuation sets in. + * + * @return the sound's minimum distance before attenuation sets in. + * @see SoundSource#setMinDistance(float) + */ + public float getMinDistance() { + return minDistance; + } + + /** + * Gets the sound's attenuation factor. + *

      + * The attenuation factor ranges between 0 (no attenuation) and 100 (instant attenuation), + * where the default value is 1. + * + * @return the sound's attenuation factor. + * @see SoundSource#setAttenuation(float) + */ + public float getAttenuation() { + return attenuation; + } + + abstract int nativeGetStatus(); + + /** + * Gets the current state of the sound stream. + * + * @return the current state of the sound stream. + */ + protected Status getStatus() { + return Status.values()[nativeGetStatus()]; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/audio/SoundStream.java b/lib/jsfml/src/java/org/jsfml/audio/SoundStream.java new file mode 100644 index 00000000..626571f3 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/audio/SoundStream.java @@ -0,0 +1,244 @@ +package org.jsfml.audio; + +import org.jsfml.internal.Intercom; +import org.jsfml.system.Time; + +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.ShortBuffer; +import java.util.Objects; + +/** + * Abstract base class for streamed sound sources. + *

      + * Unlike buffered sounds, streamed sounds are not held in memory in their entirety, but only + * a certain amount of sound chunks. When the currently buffered chunk is done being played, + * the next chunk is requested from the stream's source. + *

      + * This approach should be preferred for long sounds + * that do not need to be sought around in often, such as music or procedurally generated + * sounds. + * + * @see Chunk + */ +@Intercom +public abstract class SoundStream extends SoundSource { + /** + * Represents a chunk of audio data provided by a {@code SoundStream} when + * new data is requested. + */ + public static class Chunk { + private final short[] data; + private final boolean last; + + /** + * Constructs a new chunk containing the specified data. + * + * @param data An array of 16-bit samples representing the chunk's audio data. + * @param last Determines whether this audio chunk is the last in the stream. If set to + * {@code true}, the stream will stop playing once this chunk has finished + * playing. + */ + public Chunk(short[] data, boolean last) { + this.data = Objects.requireNonNull(data); + this.last = last; + } + } + + //Cache + private int channelCount = 0; + private int sampleRate = 0; + private boolean loop = false; + private Time playingOffset = Time.ZERO; + + /** + * Constructs a sound stream. + */ + public SoundStream() { + super(); + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native long nativeCreate(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeSetExPtr(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeDelete(); + + /** + * Starts playing the stream or resumes it if it is currently paused. + */ + public native void play(); + + /** + * Pauses playback of the stream if it is currently playing. + */ + public native void pause(); + + /** + * Stops playing the stream. + */ + public native void stop(); + + /** + * Gets the amount of audio channels of this stream. + * + * @return the amount of audio channels of this stream. + */ + public int getChannelCount() { + return channelCount; + } + + /** + * Gets the sample rate of this stream. + * + * @return the sample rate of this stream in samples per second. + */ + public int getSampleRate() { + return sampleRate; + } + + private native void nativeSetPlayingOffset(long offset); + + /** + * Sets the current playing offset at which to play from the stream. + * + * @param offset the playing offset at which to play from the stream. + */ + public final void setPlayingOffset(Time offset) { + nativeSetPlayingOffset(offset.asMicroseconds()); + this.playingOffset = offset; + } + + /** + * Gets the playing offset at which to play from the stream. + * + * @return the playing offset at which to play from the stream. + */ + public Time getPlayingOffset() { + return playingOffset; + } + + private native void nativeSetLoop(boolean loop); + + /** + * Enables or disables repeated looping of the sound stream playback. + *

      + * If a looping sound stream has finished playing its last audio chunk, it will + * restart playing from the first chunk as if {@code setPlayingOffset(Time.ZERO)} was invoked. + * + * @param loop {@code true} to enable looping, {@code false} to disable. + */ + public void setLoop(boolean loop) { + nativeSetLoop(loop); + this.loop = loop; + } + + /** + * Returns whether or not the sound stream playback is looping. + *

      + * If a looping sound stream has finished playing its last audio chunk, it will + * restart playing from the first chunk as if {@code setPlayingOffset(Time.ZERO)} was invoked. + * + * @return {@code true} if it is looping, {@code false} if not. + */ + public boolean isLoop() { + return loop; + } + + @Override + native int nativeGetStatus(); + + @Override + public Status getStatus() { + return super.getStatus(); + } + + final void setData(int channelCount, int sampleRate) { + this.channelCount = channelCount; + this.sampleRate = sampleRate; + } + + private native void nativeInitialize(int channelCount, int sampleRate); + + /** + * Defines the audio stream parameters. + *

      + * Before the stream can be played, the implementing class must call this method. + * + * @param channelCount the amount of audio channels (e.g. 1 for mono, 2 for stereo). + * @param sampleRate the sample rate in samples per second. + */ + protected void initialize(int channelCount, int sampleRate) { + nativeInitialize(channelCount, sampleRate); + setData(channelCount, sampleRate); + } + + @Intercom + @SuppressWarnings("unused") + private Buffer onGetDataInternal() { + final Chunk chunk = onGetData(); + if (chunk != null && chunk.data.length > 0) { + final ByteBuffer buffer = ByteBuffer.allocateDirect(4 + 2 * chunk.data.length).order( + ByteOrder.nativeOrder()); + + int header = chunk.data.length & 0x7FFFFFFF; + if (chunk.last) { + header |= 0x80000000; + } + + buffer.asIntBuffer().put(header); + + final ShortBuffer samples = buffer.asShortBuffer(); + samples.position(2); + samples.put(chunk.data); + + return buffer; + } else { + return null; + } + } + + /** + * Requests a new chunk of audio data. + *

      + * This method is called when the audio stream has played all buffered samples and needs + * new samples to continue playing. + *

      + * Note that this method will be called within a separate playback thread. + * + * @return the next chunk of audio data. If the chunk is marked as the last chunk, + * the stream will either stop playing after playing this chunk, or restart + * from the beginning if {@link #isLoop()} returns {@code true}. + * To stop playback immediately, {@code null} may be returned. + * @see Chunk + */ + protected abstract Chunk onGetData(); + + @Intercom + @SuppressWarnings("unused") + private void onSeekInternal(long time) { + onSeek(Time.getMicroseconds(time)); + } + + /** + * Re-positions the stream's current playing offset. + *

      + * This method is called when the stream is reset or a re-positioning has been requested + * via {@link #setPlayingOffset(org.jsfml.system.Time)}. + *

      + * Note that this method will be called within a separate playback thread. + * + * @param time the time offset to jump to. + */ + protected abstract void onSeek(Time time); +} diff --git a/lib/jsfml/src/java/org/jsfml/audio/package-info.java b/lib/jsfml/src/java/org/jsfml/audio/package-info.java new file mode 100644 index 00000000..4d6cd877 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/audio/package-info.java @@ -0,0 +1,4 @@ +/** + * Contains classes related to audio playback and recording. + */ +package org.jsfml.audio; diff --git a/lib/jsfml/src/java/org/jsfml/graphics/BasicTransformable.java b/lib/jsfml/src/java/org/jsfml/graphics/BasicTransformable.java new file mode 100644 index 00000000..f31ed3f1 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/BasicTransformable.java @@ -0,0 +1,156 @@ +package org.jsfml.graphics; + +import org.jsfml.system.Vector2f; + +/** + * Implementation of the {@link Transformable} interface. + *

      + * Classes can inherit from this in order to provide the {@link Transformable} interface. + * The implementation equals that of the original SFML implementation. + */ +public class BasicTransformable implements Transformable { + private Vector2f origin = Vector2f.ZERO; + private Vector2f position = Vector2f.ZERO; + private float rotation = 0; + private Vector2f scale = new Vector2f(1, 1); + + private Transform transform = Transform.IDENTITY; + private boolean transformNeedsUpdate = false; + private Transform inverseTransform = Transform.IDENTITY; + private boolean inverseTransformNeedsUpdate = false; + + /** + * Default constructor, initializes this object with an identity transformation. + */ + public BasicTransformable() { + } + + @Override + public final void setPosition(float x, float y) { + setPosition(new Vector2f(x, y)); + } + + @Override + public void setPosition(Vector2f v) { + this.position = v; + + transformNeedsUpdate = true; + inverseTransformNeedsUpdate = true; + } + + @Override + public void setRotation(float angle) { + this.rotation = angle % 360.0f; + if (this.rotation < 0) + this.rotation += 360.0f; + + transformNeedsUpdate = true; + inverseTransformNeedsUpdate = true; + } + + @Override + public final void setScale(float x, float y) { + setScale(new Vector2f(x, y)); + } + + @Override + public void setScale(Vector2f factors) { + this.scale = factors; + + transformNeedsUpdate = true; + inverseTransformNeedsUpdate = true; + } + + @Override + public final void setOrigin(float x, float y) { + setOrigin(new Vector2f(x, y)); + } + + @Override + public void setOrigin(Vector2f v) { + this.origin = v; + + transformNeedsUpdate = true; + inverseTransformNeedsUpdate = true; + } + + @Override + public Vector2f getPosition() { + return position; + } + + @Override + public float getRotation() { + return rotation; + } + + @Override + public Vector2f getScale() { + return scale; + } + + @Override + public Vector2f getOrigin() { + return origin; + } + + @Override + public final void move(float x, float y) { + move(new Vector2f(x, y)); + } + + @Override + public void move(Vector2f v) { + setPosition(Vector2f.add(position, v)); + } + + @Override + public void rotate(float angle) { + setRotation(rotation + angle); + } + + @Override + public final void scale(float x, float y) { + scale(new Vector2f(x, y)); + } + + @Override + public void scale(Vector2f factors) { + setScale(Vector2f.componentwiseMul(scale, factors)); + } + + @Override + public Transform getTransform() { + if (transformNeedsUpdate) { + double angle = -Math.toRadians(rotation); + float cos = (float) Math.cos(angle); + float sin = (float) Math.sin(angle); + + float sxc = scale.x * cos; + float syc = scale.y * cos; + float sxs = scale.x * sin; + float sys = scale.y * sin; + float tx = -origin.x * sxc - origin.y * sys + position.x; + float ty = origin.x * sxs - origin.y * syc + position.y; + + transform = new Transform( + sxc, sys, tx, + -sxs, syc, ty, + 0, 0, 1); + + transformNeedsUpdate = false; + } + + return transform; + } + + @Override + public Transform getInverseTransform() { + if (inverseTransformNeedsUpdate) { + inverseTransform = getTransform().getInverse(); + inverseTransformNeedsUpdate = false; + } + + return inverseTransform; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/BlendMode.java b/lib/jsfml/src/java/org/jsfml/graphics/BlendMode.java new file mode 100644 index 00000000..ecb64857 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/BlendMode.java @@ -0,0 +1,34 @@ +package org.jsfml.graphics; + +/** + * Enumeration of the supported blending modes for drawing. + */ +public enum BlendMode { + /** + * Blends source and destrination colors by using a common alpha blending formula. + *

      + * {@code Pixel = Source * Source.a + Dest * (1 - Source.a)} + */ + ALPHA, + + /** + * Blends source and destination colors by performing a component-wise addition. + *

      + * {@code Pixel = Source + Dest} + */ + ADD, + + /** + * Blends source and destination colors by performing a component-wise multiplication. + *

      + * {@code Pixel = Source * Dest} + */ + MULTIPLY, + + /** + * Does not blend and overrides the destination color with the source color. + *

      + * {@code Pixel = Source} + */ + NONE +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/CircleShape.java b/lib/jsfml/src/java/org/jsfml/graphics/CircleShape.java new file mode 100644 index 00000000..9231400d --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/CircleShape.java @@ -0,0 +1,89 @@ +package org.jsfml.graphics; + +/** + * A specialized shape representing a circle. + */ +public class CircleShape extends Shape { + //cache + private float radius = 0; + + /** + * Constructs a new circle shape with a zero radius, approximated using 30 points. + */ + public CircleShape() { + super(); + } + + /** + * Constructs a new circle shape with the specified radius, approximated using 30 points. + * + * @param radius the circle's radius. + */ + public CircleShape(float radius) { + this(); + setRadius(radius); + } + + /** + * Constructs a new circle shape with the specified parameters. + * + * @param radius the circle's radius. + * @param points the amount of points to approximate the circle with. + * @see CircleShape#setPointCount(int) + */ + public CircleShape(float radius, int points) { + this(radius); + setPointCount(points); + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native long nativeCreate(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeSetExPtr(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeDelete(); + + private native void nativeSetRadius(float radius); + + /** + * Sets the radius of this circle. + * + * @param radius the new radius of the circle shape. + */ + public void setRadius(float radius) { + nativeSetRadius(radius); + this.radius = radius; + pointsNeedUpdate = true; + } + + /** + * Gets the radius of this circle. + * + * @return the radius of this circle shape. + */ + public float getRadius() { + return radius; + } + + private native void nativeSetPointCount(int count); + + /** + * Sets the amount of points the circle should be approximated with. + *

      + * A higher amount of points will yield a smoother result at the cost of performance. + * + * @param count the amount of points used to approximate the circle. + */ + public void setPointCount(int count) { + nativeSetPointCount(count); + pointsNeedUpdate = true; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/Color.java b/lib/jsfml/src/java/org/jsfml/graphics/Color.java new file mode 100644 index 00000000..36e8a3b5 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/Color.java @@ -0,0 +1,194 @@ +package org.jsfml.graphics; + + +import java.io.Serializable; + +/** + * Represents RGBA colors. + */ +public final class Color implements Serializable { + private static final long serialVersionUID = -161207563051572152L; + + /** + * Black {@code (0, 0, 0)} + */ + public final static Color BLACK = new Color(0, 0, 0); + + /** + * White {@code (255, 255, 255)} + */ + public final static Color WHITE = new Color(255, 255, 255); + + /** + * Red {@code (255, 0, 0)} + */ + public final static Color RED = new Color(255, 0, 0); + + /** + * Green {@code (0, 255, 0)} + */ + public final static Color GREEN = new Color(0, 255, 0); + + /** + * Blue {@code (0, 0, 255)} + */ + public final static Color BLUE = new Color(0, 0, 255); + + /** + * Yellow {@code (255, 255, 0)} + */ + public final static Color YELLOW = new Color(255, 255, 0); + + /** + * Magenta {@code (255, 255, 0)} + */ + public final static Color MAGENTA = new Color(255, 0, 255); + + /** + * Cyan {@code (0, 255, 255)} + */ + public final static Color CYAN = new Color(0, 255, 255); + + /** + * Transparent {@code (0, 0, 0, 0)} + */ + public final static Color TRANSPARENT = new Color(0, 0, 0, 0); + + /** + * Modulates two colors by performing a component-wise addition. + * + * @param a the first color. + * @param b the second color. + * @return the modulated color. + */ + public static Color add(Color a, Color b) { + return new Color( + a.r + b.r, + a.g + b.g, + a.b + b.b, + a.a + b.a); + } + + /** + * Modulates two colors by performing a component-wise multiplication. + * + * @param a the first color. + * @param b the second color. + * @return the modulated color. + */ + public static Color mul(Color a, Color b) { + return new Color( + (a.r * b.r) / 255, + (a.g * b.g) / 255, + (a.b * b.b) / 255, + (a.a * b.a) / 255); + } + + /** + * Modulates a color by multiplying its components with a factor. + * + * @param color the color. + * @param f the factor. + * @return the modulated color. + */ + public static Color mul(Color color, float f) { + return new Color( + (int) (color.r * f), + (int) (color.g * f), + (int) (color.b * f), + (int) (color.a * f)); + } + + private static int clamp(int x) { + return Math.max(0, Math.min(x, 255)); + } + + /** + * The red component of the color. + */ + public final int r; + + /** + * The green component of the color. + */ + public final int g; + + /** + * The blue component of the color. + */ + public final int b; + + /** + * The alpha component of the color, ranging between 0 (transparent) and 255 (fully opaque). + */ + public final int a; + + /** + * Constructs a new color with the specified color components and an alpha value of 255 + * (fully opaque). + * + * @param r the color's red component. + * @param g the color's green component. + * @param b the color's blue component. + */ + public Color(int r, int g, int b) { + this(r, g, b, 255); + } + + /** + * Constructs a new color with the specified color and alpha components. + * + * @param r the color's red component. + * @param g the color's green component. + * @param b the color's blue component. + * @param a the color's alpha component, ranging between 0 (transparent) and 255 (fully opaque). + */ + public Color(int r, int g, int b, int a) { + this.r = clamp(r); + this.g = clamp(g); + this.b = clamp(b); + this.a = clamp(a); + } + + /** + * Constructs a new color by copying another color and resetting the alpha value. + * + * @param color the color to copy. + * @param alpha the alpha value of the new color, + * ranging between 0 (transparent) and 255 (fully opaque). + */ + public Color(Color color, int alpha) { + this.r = color.r; + this.g = color.g; + this.b = color.b; + this.a = clamp(alpha); + } + + @Override + public boolean equals(Object o) { + return (o instanceof Color && + ((Color) o).r == r && + ((Color) o).g == g && + ((Color) o).b == b && + ((Color) o).a == a); + } + + @Override + public int hashCode() { + int result = r; + result = 31 * result + g; + result = 31 * result + b; + result = 31 * result + a; + return result; + } + + @Override + public String toString() { + return "Color{" + + "r=" + r + + ", g=" + g + + ", b=" + b + + ", a=" + a + + '}'; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/ConstFont.java b/lib/jsfml/src/java/org/jsfml/graphics/ConstFont.java new file mode 100644 index 00000000..f5a7cc0b --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/ConstFont.java @@ -0,0 +1,55 @@ +package org.jsfml.graphics; + +import org.jsfml.internal.Const; + +/** + * Interface for read-only fonts. + *

      + * It provides methods to can gain information from a font, but none to modify it + * in any way. + *

      + * Note that this interface is expected to be implemented by a {@link Font}. + * It is not recommended to be implemented outside of the JSFML API. + * + * @see org.jsfml.internal.Const + */ +public interface ConstFont extends Const { + /** + * Gets a glyph information structure from the font. + * + * @param unicode the unicode (UTF-32) of the character to retrieve the glyph for. + * @param characterSize the character size in question. + * @param bold {@code true} if the bold glyph version should be returned, + * {@code false} for the regular version. + * @return the {@link Glyph} representing the given unicode character. + */ + public Glyph getGlyph(int unicode, int characterSize, boolean bold); + + /** + * Gets the kerning offset between two glyphs. + * + * @param first the unicode (UTF-32) of the first character. + * @param second the unicode (UTF-32) of the second character. + * @param characterSize the character size in question. + * @return the kerning offset between the two glyphs. + */ + public int getKerning(int first, int second, int characterSize); + + /** + * Gets the line spacing of the font. + * + * @param characterSize the character size in question. + * @return the line spacing of the font. + */ + public int getLineSpacing(int characterSize); + + /** + * Retrieves the texture containing the font's glyphs. + *

      + * The texture returned is immutable. + * + * @param characterSize the character size in question. + * @return the texture containing the font's glyphs of the character given size. + */ + public ConstTexture getTexture(int characterSize); +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/ConstShader.java b/lib/jsfml/src/java/org/jsfml/graphics/ConstShader.java new file mode 100644 index 00000000..d7c0edf6 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/ConstShader.java @@ -0,0 +1,17 @@ +package org.jsfml.graphics; + +import org.jsfml.internal.Const; + +/** + * Interface for read-only textures. + *

      + * It provides methods to can gain information from a shader, but none to modify it + * in any way. + *

      + * Note that this interface is expected to be implemented by a {@link Shader}. + * It is not recommended to be implemented outside of the JSFML API. + * + * @see org.jsfml.internal.Const + */ +public interface ConstShader extends Const { +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/ConstTexture.java b/lib/jsfml/src/java/org/jsfml/graphics/ConstTexture.java new file mode 100644 index 00000000..803e32f4 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/ConstTexture.java @@ -0,0 +1,45 @@ +package org.jsfml.graphics; + +import org.jsfml.internal.Const; +import org.jsfml.system.Vector2i; + +/** + * Interface for read-only textures. + *

      + * It provides methods to can gain information from a texture, but none to modify it + * in any way. + *

      + * Note that this interface is expected to be implemented by a {@link Texture}. + * It is not recommended to be implemented outside of the JSFML API. + * + * @see Const + */ +public interface ConstTexture extends Const { + /** + * Gets the dimensions of the texture. + * + * @return the dimensions of the texture. + */ + public Vector2i getSize(); + + /** + * Copies this texture to an editable {@link Image}. + * + * @return the image that contains a coyp of the texure's contents. + */ + public Image copyToImage(); + + /** + * Checks whether the smooth filter is enabled. + * + * @return {@code true} if enabled, {@code false} if disabled. + */ + public boolean isSmooth(); + + /** + * Checks whether texture repeating is enabled. + * + * @return {@code true} if enabled, {@code false} if disabled. + */ + public boolean isRepeated(); +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/ConstView.java b/lib/jsfml/src/java/org/jsfml/graphics/ConstView.java new file mode 100644 index 00000000..92c4bc83 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/ConstView.java @@ -0,0 +1,61 @@ +package org.jsfml.graphics; + +import org.jsfml.internal.Const; +import org.jsfml.system.Vector2f; + +/** + * Interface for read-only views. + *

      + * It provides methods to can gain information from a view, but none to modify it + * in any way. + *

      + * Note that this interface is expected to be implemented by a {@link View}. It is not + * recommended to be implemented outside of the JSFML API. + * + * @see Const + */ +public interface ConstView extends Const { + /** + * Gets the current center of the view. + * + * @return the current center of the view. + */ + public Vector2f getCenter(); + + /** + * Gets the current dimensions of the view in pixels. + * + * @return the current dimensions of the view in pixels. + */ + public Vector2f getSize(); + + /** + * Gets the current rotation angle of the view in degrees. + * + * @return the current rotation angle of the view in degrees. + */ + public float getRotation(); + + /** + * Gets the current viewport rectangle of this view. + * + * @return the current viewport rectangle of this view. + */ + public FloatRect getViewport(); + + /** + * Gets the view's current transformation matrix as determined by its center, + * size and rotation angle. + * + * @return the view's current transformation matrix. + */ + public Transform getTransform(); + + /** + * Gets the inverse of the view's current transformation matrix as determined + * by its center, size and rotation angle. + * + * @return the inverse of the view's current transformation matrix. + */ + public Transform getInverseTransform(); +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/ConvexShape.java b/lib/jsfml/src/java/org/jsfml/graphics/ConvexShape.java new file mode 100644 index 00000000..41bfe855 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/ConvexShape.java @@ -0,0 +1,122 @@ +package org.jsfml.graphics; + +import org.jsfml.system.Vector2f; + +import java.util.Objects; + +/** + * Specialized shape representing a convex polygon. + */ +public class ConvexShape extends Shape { + /** + * Constructs a new empty polygon. + */ + public ConvexShape() { + super(); + } + + /** + * Constructs a new empty polygon and allocates a certain amount of points. + *

      + * This is equal to calling {@link ConvexShape#setPointCount(int)} directly after + * construction of the polygon. + * + * @param points the amount of points of the polygon. + */ + public ConvexShape(int points) { + this(); + setPointCount(points); + } + + /** + * Constructs a new polygon from a given set of points. + *

      + * This is equal to calling {@link ConvexShape#setPoints(org.jsfml.system.Vector2f...)} + * directly after construction of the polygon. + * + * @param points the points of the polygon. + */ + public ConvexShape(Vector2f... points) { + this(); + setPoints(points); + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native long nativeCreate(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeSetExPtr(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeDelete(); + + private native void nativeSetPointCount(int count); + + private native void nativeSetPoint(int i, float x, float y); + + /** + * Sets the amount of points that belong to the polygon. + * + * @param pointCount the amount of points of the polygon. + */ + public void setPointCount(int pointCount) { + nativeSetPointCount(pointCount); + + points = new Vector2f[pointCount]; + for (int i = 0; i < pointCount; i++) { + points[i] = Vector2f.ZERO; + } + } + + /** + * Sets a point of the polygon. + * + * @param i the index of the point to set. Note that this index must be within the bounds + * of the polygon's point count, ie the point count needs to be set properly + * using {@link ConvexShape#setPointCount(int)} first. + * @param v the point to set at the given index. + */ + public void setPoint(int i, Vector2f v) { + if (points == null || i < 0 || i >= points.length) + throw new IndexOutOfBoundsException(Integer.toString(i)); + + nativeSetPoint(i, v.x, v.y); + points[i] = v; + } + + /** + * Sets the points of the polygon. + *

      + * The use of this method equals consecutive calls of {@link ConvexShape#setPointCount(int)} + * and {@link ConvexShape#setPoint(int, org.jsfml.system.Vector2f)} for each point + * in the given array. + * + * @param points the points of the polygon. + */ + public void setPoints(Vector2f... points) { + this.points = Objects.requireNonNull(points); + nativeSetPointCount(points.length); + + for (int i = 0; i < points.length; i++) { + if (points[i] == null) { + setPointCount(0); + this.points = null; + throw new NullPointerException("point " + i + " is null."); + } + + nativeSetPoint(i, points[i].x, points[i].y); + } + } + + @Override + public Vector2f[] getPoints() { + pointsNeedUpdate = false; + return super.getPoints(); + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/Drawable.java b/lib/jsfml/src/java/org/jsfml/graphics/Drawable.java new file mode 100644 index 00000000..773a891f --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/Drawable.java @@ -0,0 +1,17 @@ +package org.jsfml.graphics; + +/** + * Interface for objects that can be drawn to a render target. + *

      + * Implementing classes can be conveniently used for the {@link RenderTarget#draw(Drawable)} + * method, but serve no additional purpose otherwise. + */ +public interface Drawable { + /** + * Draws the object to a render target. + * + * @param target the target to draw this object on. + * @param states the current render states. + */ + void draw(RenderTarget target, RenderStates states); +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/FloatRect.java b/lib/jsfml/src/java/org/jsfml/graphics/FloatRect.java new file mode 100644 index 00000000..21bb60ec --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/FloatRect.java @@ -0,0 +1,205 @@ +/* + This class uses direct C++ to Java translations from SFML source code, hence the following notice: + + //////////////////////////////////////////////////////////// + // + // SFML - Simple and Fast Multimedia Library + // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) + // + // This software is provided 'as-is', without any express or implied warranty. + // In no event will the authors be held liable for any damages arising from the use of this software. + // + // Permission is granted to anyone to use this software for any purpose, + // including commercial applications, and to alter it and redistribute it freely, + // subject to the following restrictions: + // + // 1. The origin of this software must not be misrepresented; + // you must not claim that you wrote the original software. + // If you use this software in a product, an acknowledgment + // in the product documentation would be appreciated but is not required. + // + // 2. Altered source versions must be plainly marked as such, + // and must not be misrepresented as being the original software. + // + // 3. This notice may not be removed or altered from any source distribution. + // + //////////////////////////////////////////////////////////// +*/ + +package org.jsfml.graphics; + +import org.jsfml.system.Vector2f; + +import java.io.Serializable; + +/** + * Represents an axis-aligned rectangle using floating point coordinates. + */ +public final strictfp class FloatRect implements Serializable { + private static final long serialVersionUID = -8603980852893951558L; + + /** + * An empty rectangle with no dimensions. + */ + public static final FloatRect EMPTY = new FloatRect(0, 0, 0, 0); + + /** + * The X coordinate of the rectangle's left edge. + */ + public final float left; + + /** + * The Y coordinate of the rectangle's top edge. + */ + public final float top; + + /** + * The width of the rectangle. + */ + public final float width; + + /** + * The height of the rectangle. + */ + public final float height; + + /** + * Constructs a new rectangle with the specified parameters. + * + * @param left the X coordinate of the rectangle's left edge. + * @param top the Y coordinate of the rectangle's top edge. + * @param width the rectangle's width. + * @param height the rectangle's height. + */ + public FloatRect(float left, float top, float width, float height) { + this.left = left; + this.top = top; + this.width = width; + this.height = height; + } + + /** + * Constructs a new rectangle with the specified parameters. + * + * @param position the position of the rectangle's top left corner. + * @param size the rectangle's dimension. + */ + public FloatRect(Vector2f position, Vector2f size) { + this.left = position.x; + this.top = position.y; + this.width = size.x; + this.height = size.y; + } + + /** + * Constructs a new rectangle by converting an intergral rectangle. + *

      + * The fractions of the components will be set to zero. + * + * @param rect the rectangle to convert. + */ + public FloatRect(IntRect rect) { + this((float) rect.left, (float) rect.top, (float) rect.width, (float) rect.height); + } + + /** + * Tests whether a point is inside the rectangle's boundaries, including its edges. + * + * @param x the X coordinate of the tested point. + * @param y the Y coordinate of the tested point. + * @return {@code true} if the point lies within the rectangle's boundaries, + * {@code false} otherwise. + */ + public boolean contains(float x, float y) { + //direct port of SFML code + final float minX = Math.min(left, left + width); + final float maxX = Math.max(left, left + width); + final float minY = Math.min(top, top + height); + final float maxY = Math.max(top, top + height); + + return (x >= minX) && (x < maxX) && (y >= minY) && (y < maxY); + } + + /** + * Tests whether a point is inside the rectangle's boundaries, including its edges. + * + * @param point the point to be tested. + * @return {@code true} if the point lies within the rectangle's boundaries, + * {@code false} otherwise. + */ + public boolean contains(Vector2f point) { + return contains(point.x, point.y); + } + + /** + * Tests whether this rectangle intersects with another rectangle and + * calculates the rectangle of intersection. + * + * @param rect the rectangle to test against. + * @return the intersection rectangle, or {@code null} if the rectangles do not intersect. + */ + public FloatRect intersection(FloatRect rect) { + //direct port of SFML code + + // Compute the min and max of the first rectangle on both axes + final float r1MinX = Math.min(left, left + width); + final float r1MaxX = Math.max(left, left + width); + final float r1MinY = Math.min(top, top + height); + final float r1MaxY = Math.max(top, top + height); + + // Compute the min and max of the second rectangle on both axes + final float r2MinX = Math.min(rect.left, rect.left + rect.width); + final float r2MaxX = Math.max(rect.left, rect.left + rect.width); + final float r2MinY = Math.min(rect.top, rect.top + rect.height); + final float r2MaxY = Math.max(rect.top, rect.top + rect.height); + + // Compute the intersection boundaries + final float interLeft = Math.max(r1MinX, r2MinX); + final float interTop = Math.max(r1MinY, r2MinY); + final float interRight = Math.min(r1MaxX, r2MaxX); + final float interBottom = Math.min(r1MaxY, r2MaxY); + + // If the intersection is valid (positive non zero area), then there is an intersection + if ((interLeft < interRight) && (interTop < interBottom)) { + return new FloatRect( + interLeft, + interTop, + interRight - interLeft, + interBottom - interTop); + } else { + return null; + } + } + + @Override + public boolean equals(Object o) { + if (o instanceof FloatRect) { + FloatRect r = (FloatRect) o; + return (left == r.left && + top == r.top && + width == r.width && + height == r.height); + } else { + return false; + } + } + + @Override + public int hashCode() { + int result = (left != +0.0f ? Float.floatToIntBits(left) : 0); + result = 31 * result + (top != +0.0f ? Float.floatToIntBits(top) : 0); + result = 31 * result + (width != +0.0f ? Float.floatToIntBits(width) : 0); + result = 31 * result + (height != +0.0f ? Float.floatToIntBits(height) : 0); + return result; + } + + @Override + public String toString() { + return "FloatRect{" + + "left=" + left + + ", top=" + top + + ", width=" + width + + ", height=" + height + + '}'; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/Font.java b/lib/jsfml/src/java/org/jsfml/graphics/Font.java new file mode 100644 index 00000000..14c57170 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/Font.java @@ -0,0 +1,172 @@ +package org.jsfml.graphics; + +import org.jsfml.internal.*; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.Buffer; +import java.nio.IntBuffer; +import java.nio.file.Path; +import java.util.Map; +import java.util.TreeMap; + +/** + * Holds a character font for use in text displays. + */ +public class Font extends SFMLNativeObject implements ConstFont { + private class SizeInfo { + final int characterSize, lineSpacing; + final ConstTexture texture; + final TreeMap kerning = new TreeMap<>(); + final TreeMap glyphs = new TreeMap<>(); + final TreeMap boldGlyphs = new TreeMap<>(); + + SizeInfo(int characterSize, int lineSpacing, ConstTexture texture) { + this.characterSize = characterSize; + this.lineSpacing = lineSpacing; + this.texture = texture; + } + } + + private final Map sizeInfos = new TreeMap<>(); + + /** + * Memory reference and heap pointer that keeps alive the data input stream for freetype. + */ + private final NativeRef memoryRef = new NativeRef() { + @Override + protected long nativeInitialize(byte[] ref) { + return nativeLoadFromMemory(ref); + } + + @Override + protected void nativeRelease(byte[] ref, long ptr) { + nativeReleaseMemory(ref, ptr); + } + }; + + /** + * Constructs a new font. + */ + public Font() { + super(); + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native long nativeCreate(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected void nativeSetExPtr() { + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeDelete(); + + private native long nativeLoadFromMemory(byte[] memory); + + private native void nativeReleaseMemory(byte[] memory, long ptr); + + /** + * Fully loads all available bytes from an {@link java.io.InputStream} + * and attempts to load the texture from it. + * + * @param in the input stream to read from. + * @throws java.io.IOException in case an I/O error occurs. + */ + public void loadFromStream(InputStream in) throws IOException { + SFMLErrorCapture.start(); + memoryRef.initialize(StreamUtil.readStream(in)); + final String msg = SFMLErrorCapture.finish(); + + if (!memoryRef.hasNonZeroPointer()) { + throw new IOException(msg); + } + } + + /** + * Attempts to load the texture from a file. + * + * @param path the path to the file to load the texture from. + * @throws IOException in case an I/O error occurs. + */ + public void loadFromFile(Path path) throws IOException { + SFMLErrorCapture.start(); + memoryRef.initialize(StreamUtil.readFile(path)); + final String msg = SFMLErrorCapture.finish(); + + if (!memoryRef.hasNonZeroPointer()) { + throw new IOException(msg); + } + } + + private native long nativeGetTexture(int characterSize); + + private native int nativeGetLineSpacing(int characterSize); + + private native void nativeGetGlyph(int unicode, int characterSize, boolean bold, Buffer buf); + + private native int nativeGetKerning(int first, int second, int characterSize); + + private SizeInfo getSizeInfo(int characterSize) { + SizeInfo info = sizeInfos.get(characterSize); + if (info == null) { + final int lineSpacing = nativeGetLineSpacing(characterSize); + final long p = nativeGetTexture(characterSize); + final ConstTexture tex = (p != 0) ? new Texture(p) : null; + + info = new SizeInfo(characterSize, lineSpacing, tex); + sizeInfos.put(characterSize, info); + } + return info; + } + + @Override + public Glyph getGlyph(int unicode, int characterSize, boolean bold) { + final SizeInfo info = getSizeInfo(characterSize); + final Map glyphMap = bold ? info.boldGlyphs : info.glyphs; + + Glyph glyph = glyphMap.get(unicode); + if (glyph == null) { + final IntBuffer buf = IntercomHelper.getBuffer().asIntBuffer(); + + nativeGetGlyph(unicode, characterSize, bold, buf); + glyph = new Glyph( + buf.get(0), + new IntRect(buf.get(1), buf.get(2), buf.get(3), buf.get(4)), + new IntRect(buf.get(5), buf.get(6), buf.get(7), buf.get(8))); + + glyphMap.put(unicode, glyph); + } + + return glyph; + } + + @Override + public int getKerning(int first, int second, int characterSize) { + final SizeInfo info = getSizeInfo(characterSize); + final long x = ((long) first << 32) | (long) second; + Integer kerning = info.kerning.get(x); + if (kerning == null) { + kerning = nativeGetKerning(first, second, characterSize); + info.kerning.put(x, kerning); + } + + return kerning; + } + + @Override + public int getLineSpacing(int characterSize) { + return getSizeInfo(characterSize).lineSpacing; + } + + @Override + public ConstTexture getTexture(int characterSize) { + return getSizeInfo(characterSize).texture; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/Glyph.java b/lib/jsfml/src/java/org/jsfml/graphics/Glyph.java new file mode 100644 index 00000000..b2c88e9f --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/Glyph.java @@ -0,0 +1,41 @@ +package org.jsfml.graphics; + +/** + * Describes a glyph in a {@link Font}. + * + * @see Font + */ +public final class Glyph { + /** + * The offset to move horizontally to the next character. + */ + public final int advance; + + /** + * The bounding rectangle of the glyph, in coordinates relative to the baseline. + */ + public final IntRect bounds; + + /** + * The texture coordinates of the glyph on the font's texture. + */ + public final IntRect textureRect; + + /** + * Constructs a glyph with the specified parameters. + *

      + * Note that this constructor is reserved for internal use and should + * never be required to be used directly. Glyphs should be obtained + * using the {@link Font#getGlyph(int, int, boolean)} method. + * + * @param advance the offset to move horizontally to the next character. + * @param bounds the boundaries of the glyph. + * @param textureRect the texture rectangle used by the glyph. + * @see Font#getGlyph(int, int, boolean) + */ + public Glyph(int advance, IntRect bounds, IntRect textureRect) { + this.advance = advance; + this.bounds = bounds; + this.textureRect = textureRect; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/Image.java b/lib/jsfml/src/java/org/jsfml/graphics/Image.java new file mode 100644 index 00000000..95f56073 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/Image.java @@ -0,0 +1,511 @@ +package org.jsfml.graphics; + +import org.jsfml.internal.IntercomHelper; +import org.jsfml.internal.SFMLErrorCapture; +import org.jsfml.internal.SFMLNativeObject; +import org.jsfml.internal.StreamUtil; +import org.jsfml.system.Vector2i; + +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.InputStream; +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.IntBuffer; +import java.nio.file.Path; + +/** + * Provides methods for loading, manipulating and saving images. + */ +public class Image extends SFMLNativeObject { + private static int srcBlend(int s, int d) { + final int sa = (s >> 24) & 0xFF; + final int sb = (s >> 16) & 0xFF; + final int sg = (s >> 8) & 0xFF; + final int sr = s & 0xFF; + + final int da = (d >> 24) & 0xFF; + final int db = (d >> 16) & 0xFF; + final int dg = (d >> 8) & 0xFF; + final int dr = d & 0xFF; + + final int r = (sr * sa + dr * (255 - sa)) / 255; + final int g = (sg * sa + dg * (255 - sa)) / 255; + final int b = (sb * sa + db * (255 - sa)) / 255; + final int a = (sa + da * (255 - sa)) / 255; + + return (a << 24) | (b << 16) | (g << 8) | r; + } + + private static int swapRB(int s) { + return (s & 0xFF00FF00) | + ((s & 0xFF) << 16) | + ((s >> 16) & 0xFF); + } + + private Vector2i size = Vector2i.ZERO; + private IntBuffer pixels = null; + private boolean changed = true; + + /** + * Constructs a new empty image. + */ + public Image() { + super(); + } + + @SuppressWarnings("deprecation") + Image(long wrap) { + super(wrap); + sync(); + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native long nativeCreate(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected void nativeSetExPtr() { + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeDelete(); + + /** + * Generates a new image and fills it with a color. + * + * @param width the image's width. + * @param height the image's height. + * @param color the fill color of the image. + */ + public void create(int width, int height, Color color) { + if (width < 0 || height < 0) { + throw new IllegalArgumentException("width: " + width + ", height: " + height); + } + + size = new Vector2i(width, height); + + if (width > 0 && height > 0) { + pixels = ByteBuffer.allocateDirect(4 * width * height).order( + ByteOrder.LITTLE_ENDIAN).asIntBuffer(); + } else { + pixels = null; + } + + if (!color.equals(Color.BLACK)) { + fill(color); + } + } + + /** + * Generates a new image and fills it with black. + * + * @param width the image's width. + * @param height the image's height. + */ + public final void create(int width, int height) { + create(width, height, Color.BLACK); + } + + /** + * Creates a new image by converting an AWT {@link BufferedImage}. + * + * @param image the AWT buffered image to convert. + */ + public void create(BufferedImage image) { + final int w = image.getWidth(); + final int h = image.getHeight(); + + final int[] data = new int[w * h]; + create(w, h, image.getRGB(0, 0, w, h, data, 0, w)); + } + + /** + * Creates a new image from the given pixel data. + *

      + * The pixel data is expected to be in the {@link BufferedImage#TYPE_INT_ARGB} + * color format. + * + * @param width the image's width. + * @param height the image's height. + * @param pixels the image's pixel data in 32-bit ARGB format. + */ + public void create(int width, int height, int[] pixels) { + if (pixels.length != width * height) { + throw new IllegalArgumentException( + "pixel buffer size does not fit the specified dimensions"); + } + + create(width, height); + + if (width > 0 && height > 0) { + //Pixels are in ARGB, we need ABGR + for (int i = 0; i < pixels.length; i++) { + pixels[i] = swapRB(pixels[i]); + } + + this.pixels.rewind(); + this.pixels.put(pixels); + } + } + + private native boolean nativeLoadFromMemory(byte[] memory); + + /** + * Fully loads all available bytes from an {@link java.io.InputStream} + * and attempts to load the image from it. + * + * @param in the input stream to read from. + * @throws java.io.IOException in case an I/O error occurs. + */ + public void loadFromStream(InputStream in) throws IOException { + SFMLErrorCapture.start(); + final boolean success = nativeLoadFromMemory(StreamUtil.readStream(in)); + final String err = SFMLErrorCapture.finish(); + + if (!success) { + throw new IOException(err); + } + + sync(); + } + + /** + * Attempts to load an image from a file. + * + * @param path the file to load the texture from. + * @throws IOException in case an I/O error occurs. + */ + public void loadFromFile(Path path) throws IOException { + SFMLErrorCapture.start(); + final boolean success = nativeLoadFromMemory(StreamUtil.readFile(path)); + final String err = SFMLErrorCapture.finish(); + + if (!success) { + throw new IOException(err); + } + + sync(); + } + + private native boolean nativeSaveToFile(String fileName); + + /** + * Attempts to save the image to a file. + * + * @param path the path to the file to write. + * @throws IOException in case an I/O error occurs. + */ + public void saveToFile(Path path) throws IOException { + commit(); + + SFMLErrorCapture.start(); + final boolean success = nativeSaveToFile(path.toAbsolutePath().toString()); + final String err = SFMLErrorCapture.finish(); + + if (!success) { + throw new IOException(err); + } + } + + private native long nativeGetSize(); + + private native void nativeSync(int width, int height, Buffer buffer); + + final void sync() { + size = IntercomHelper.decodeVector2i(nativeGetSize()); + create(size.x, size.y); + + if (size.x > 0 && size.y > 0) { + nativeSync(size.x, size.y, pixels); + } + + changed = false; + } + + private native void nativeCommit(int width, int height, Buffer buffer); + + final void commit() { + if (changed) { + nativeCommit(size.x, size.y, pixels); + changed = false; + } + } + + private int pixel(int x, int y) { + return y * size.x + x; + } + + /** + * Gets the size of the image. + * + * @return the size of the image. + */ + public Vector2i getSize() { + return size; + } + + private void fill(Color color) { + final int c = IntercomHelper.encodeColor(color); + for (int i = 0; i < size.x * size.y; i++) { + pixels.put(i, c); + } + } + + /** + * Creates a transparency mask from the given color. + * + * @param color the color to be made transparent. + * @param alpha the alpha value to assign to pixels matching the color key. + */ + public void createMaskFromColor(Color color, int alpha) { + final int c = IntercomHelper.encodeColor(color); + final int a = alpha << 24; + + for (int i = 0; i < size.x * size.y; i++) { + final int s = pixels.get(i); + if (pixels.get(i) == c) { + pixels.put(i, a | (s & 0xFFFFFF)); + } + } + + changed = true; + } + + /** + * Creates a transparency mask from the given color, making matching pixels fully transparent. + * + * @param color the color to be made transparent. + */ + public final void createMaskFromColor(Color color) { + createMaskFromColor(color, 0); + } + + /** + * Copies a portion of another image onto this image. + * + * @param source the source image. + * @param destX the destination X coordinate. + * @param destY the destination X coordinate. + * @param sourceRect the source rectangle. An empty rectangle means the full image. + * @param applyAlpha {@code true} to copy alpha values as well, {@code false} to leave the destination alpha. + */ + public void copy(Image source, int destX, int destY, IntRect sourceRect, boolean applyAlpha) { + //Code partially translated from SFML + + //Make sure both images are valid + if (size.x == 0 || size.y == 0 || source.size.x == 0 || source.size.y == 0) { + return; + } + + //Adjust source rectangle + int left, top, width, height; + + if (sourceRect.width == 0 || sourceRect.height == 0) { + left = 0; + top = 0; + width = source.size.x; + height = source.size.y; + } else { + left = Math.max(0, sourceRect.top); + top = Math.max(0, sourceRect.top); + width = Math.min(sourceRect.width, source.size.x - left); + height = Math.min(sourceRect.height, source.size.y - top); + } + + //Adjust destination rectangle + if (destX + width > size.x) width = size.x - destX; + if (destY + height > size.y) height = size.y - destY; + + //Validate + if (width <= 0 || height <= 0) { + return; + } + + //Copy + if (applyAlpha) { + //Pixel by pixel... + for (int y = 0; y < height; y++) { + int src = source.pixel(left, top + y); + int dst = pixel(destX, destY + y); + + for (int x = 0; x < width; x++) { + final int s = source.pixels.get(src); + final int d = pixels.get(dst); + + //Blend + pixels.put(dst, srcBlend(s, d)); + + src++; + dst++; + } + } + } else { + //"lines" + final int[] buffer = new int[width]; + for (int y = 0; y < height; y++) { + source.pixels.position(source.pixel(left, top + y)); + source.pixels.get(buffer, 0, width); + + pixels.position(pixel(destX, destY + y)); + pixels.put(buffer, 0, width); + } + } + + changed = true; + } + + /** + * Copies a portion of another image onto this image. + * + * @param source the source image. + * @param destX the destination X coordinate. + * @param destY the destination X coordinate. + * @param sourceRect the source rectangle. An empty rectangle means the full image. + */ + public final void copy(Image source, int destX, int destY, IntRect sourceRect) { + copy(source, destX, destY, sourceRect, false); + } + + /** + * Copies another image onto this image. + * + * @param source the source image. + * @param destX the destination X coordinate. + * @param destY the destination X coordinate. + */ + public final void copy(Image source, int destX, int destY) { + copy(source, destX, destY, IntRect.EMPTY, false); + } + + /** + * Sets the color of a certain pixel. + * + * @param x the pixel's X coordinate. + * @param y the pixel's Y coordinate. + * @param color the color to apply to the pixel. + */ + public void setPixel(int x, int y, Color color) { + if (x < 0 || y < 0 || x >= size.x || y >= size.y) { + throw new PixelOutOfBoundsException(x, y); + } + + pixels.put(y * size.x + x, IntercomHelper.encodeColor(color)); + changed = true; + } + + /** + * Gets the color of a certain pixel. + * + * @param x the pixel's X coordinate. + * @param y the pixel's Y coordinate. + * @return the pixel's color. + */ + public Color getPixel(int x, int y) { + if (x < 0 || y < 0 || x >= size.x || y >= size.y) { + throw new PixelOutOfBoundsException(x, y); + } + + return IntercomHelper.decodeColor(pixels.get(y * size.x + x)); + } + + /** + * Retrieves a copy of all the pixels of the image in 32-bit ARGB color format. + *

      + * The retrieved image data is compatible to the {@link BufferedImage#TYPE_INT_ARGB} + * color format. + * + * @return a copy of all the pixels of the image in 32-bit ARGB color format. + */ + public int[] getPixels() { + final int[] data = new int[pixels.capacity()]; + + //Pixels are in ABGR, we promise ARGB + for (int i = 0; i < data.length; i++) { + data[i] = swapRB(pixels.get(i)); + } + + return data; + } + + /** + * Converts this image to an AWT {@link BufferedImage}. + *

      + * The resulting buffered image will be of {@link BufferedImage#TYPE_INT_ARGB} + * color format. + * + * @return the resulting buffered image. + */ + public BufferedImage toBufferedImage() { + final BufferedImage bufferedImage = new BufferedImage( + size.x, size.y, BufferedImage.TYPE_INT_ARGB); + + if (size.x > 0 && size.y > 0) { + bufferedImage.setRGB(0, 0, size.x, size.y, getPixels(), 0, size.x); + } + + return bufferedImage; + } + + /** + * Flips the image horizontally. + */ + public void flipHorizontally() { + for (int y = 0; y < size.y; y++) { + for (int x = 0; x < size.x / 2; x++) { + final int i1 = y * size.x + x; + final int i2 = y * size.x + size.x - 1 - x; + + if (i1 != i2) { + final int t = pixels.get(i1); + pixels.put(i1, pixels.get(i2)); + pixels.put(i2, t); + } + } + } + changed = true; + } + + /** + * Flips the image vertically. + */ + public void flipVertically() { + for (int x = 0; x < size.x; x++) { + for (int y = 0; y < size.y / 2; y++) { + final int i1 = y * size.x + x; + final int i2 = (size.y - 1 - y) * size.x + x; + + if (i1 != i2) { + final int t = pixels.get(i1); + pixels.put(i1, pixels.get(i2)); + pixels.put(i2, t); + } + } + } + changed = true; + } + + /** + * Thrown if a non-existing pixel is being accessed by either {@link #getPixel(int, int)} + * or {@link #setPixel(int, int, Color)}. + */ + public static class PixelOutOfBoundsException extends RuntimeException { + private static final long serialVersionUID = -7306446590734505000L; + + /** + * Constructs a new exception. + * + * @param x the X coordinate of the pixel that was being accessed. + * @param y the Y coordinate of the pixel that was being accessed. + */ + public PixelOutOfBoundsException(int x, int y) { + super("(" + x + ", " + y + ")"); + } + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/IntRect.java b/lib/jsfml/src/java/org/jsfml/graphics/IntRect.java new file mode 100644 index 00000000..7156e672 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/IntRect.java @@ -0,0 +1,205 @@ +/* + This class uses direct C++ to Java translations from SFML source code, hence the following notice: + + //////////////////////////////////////////////////////////// + // + // SFML - Simple and Fast Multimedia Library + // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) + // + // This software is provided 'as-is', without any express or implied warranty. + // In no event will the authors be held liable for any damages arising from the use of this software. + // + // Permission is granted to anyone to use this software for any purpose, + // including commercial applications, and to alter it and redistribute it freely, + // subject to the following restrictions: + // + // 1. The origin of this software must not be misrepresented; + // you must not claim that you wrote the original software. + // If you use this software in a product, an acknowledgment + // in the product documentation would be appreciated but is not required. + // + // 2. Altered source versions must be plainly marked as such, + // and must not be misrepresented as being the original software. + // + // 3. This notice may not be removed or altered from any source distribution. + // + //////////////////////////////////////////////////////////// +*/ + +package org.jsfml.graphics; + +import org.jsfml.system.Vector2i; + +import java.io.Serializable; + +/** + * Represents an axis-aligned rectangle using integer coordinates. + */ +public final class IntRect implements Serializable { + private static final long serialVersionUID = -4430448425788537785L; + + /** + * An empty rectangle with no dimensions. + */ + public static final IntRect EMPTY = new IntRect(0, 0, 0, 0); + + /** + * The X coordinate of the rectangle's left edge. + */ + public final int left; + + /** + * The Y coordinate of the rectangle's top edge. + */ + public final int top; + + /** + * The width of the rectangle. + */ + public final int width; + + /** + * The height of the rectangle. + */ + public final int height; + + /** + * Constructs a new rectangle with the specified parameters. + * + * @param left the X coordinate of the rectangle's left edge. + * @param top the Y coordinate of the rectangle's top edge. + * @param width the rectangle's width. + * @param height the rectangle's height. + */ + public IntRect(int left, int top, int width, int height) { + this.left = left; + this.top = top; + this.width = width; + this.height = height; + } + + /** + * Constructs a new rectangle with the specified parameters. + * + * @param position the position of the rectangle's top left corner. + * @param size the rectangle's dimension. + */ + public IntRect(Vector2i position, Vector2i size) { + this.left = position.x; + this.top = position.y; + this.width = size.x; + this.height = size.y; + } + + /** + * Constructs a new rectangle by converting a floating point rectangle. + *

      + * The fractions of the components will be removed. + * + * @param rect the rectangle to convert. + */ + public IntRect(FloatRect rect) { + this((int) rect.left, (int) rect.top, (int) rect.width, (int) rect.height); + } + + /** + * Tests whether a point is inside the rectangle's boundaries, including its edges. + * + * @param x the X coordinate of the tested point. + * @param y the Y coordinate of the tested point. + * @return {@code true} if the point lies within the rectangle's boundaries, + * {@code false} otherwise. + */ + public boolean contains(int x, int y) { + //direct port of SFML code + final int minX = Math.min(left, left + width); + final int maxX = Math.max(left, left + width); + final int minY = Math.min(top, top + height); + final int maxY = Math.max(top, top + height); + + return (x >= minX) && (x < maxX) && (y >= minY) && (y < maxY); + } + + /** + * Tests whether a point is inside the rectangle's boundaries, including its edges. + * + * @param point the point to be tested. + * @return {@code true} if the point lies within the rectangle's boundaries, + * {@code false} otherwise. + */ + public boolean contains(Vector2i point) { + return contains(point.x, point.y); + } + + /** + * Tests whether this rectangle intersects with another rectangle and + * calculates the rectangle of intersection. + * + * @param rect the rectangle to test against. + * @return the intersection rectangle, or {@code null} if the rectangles do not intersect. + */ + public IntRect intersection(IntRect rect) { + //direct port of SFML code + + // Compute the min and max of the first rectangle on both axes + final int r1MinX = Math.min(left, left + width); + final int r1MaxX = Math.max(left, left + width); + final int r1MinY = Math.min(top, top + height); + final int r1MaxY = Math.max(top, top + height); + + // Compute the min and max of the second rectangle on both axes + final int r2MinX = Math.min(rect.left, rect.left + rect.width); + final int r2MaxX = Math.max(rect.left, rect.left + rect.width); + final int r2MinY = Math.min(rect.top, rect.top + rect.height); + final int r2MaxY = Math.max(rect.top, rect.top + rect.height); + + // Compute the intersection boundaries + final int interLeft = Math.max(r1MinX, r2MinX); + final int interTop = Math.max(r1MinY, r2MinY); + final int interRight = Math.min(r1MaxX, r2MaxX); + final int interBottom = Math.min(r1MaxY, r2MaxY); + + // If the intersection is valid (positive non zero area), then there is an intersection + if ((interLeft < interRight) && (interTop < interBottom)) { + return new IntRect( + interLeft, + interTop, + interRight - interLeft, + interBottom - interTop); + } else { + return null; + } + } + + @Override + public boolean equals(Object o) { + if (o instanceof IntRect) { + IntRect r = (IntRect) o; + return (left == r.left && + top == r.top && + width == r.width && + height == r.height); + } else { + return false; + } + } + + @Override + public int hashCode() { + int result = left; + result = 31 * result + top; + result = 31 * result + width; + result = 31 * result + height; + return result; + } + + @Override + public String toString() { + return "IntRect{" + + "left=" + left + + ", top=" + top + + ", width=" + width + + ", height=" + height + + '}'; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/PrimitiveType.java b/lib/jsfml/src/java/org/jsfml/graphics/PrimitiveType.java new file mode 100644 index 00000000..5aea2cc9 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/PrimitiveType.java @@ -0,0 +1,45 @@ +package org.jsfml.graphics; + +/** + * Enumeration of supported primitive types. + * + * @see VertexArray + */ +public enum PrimitiveType { + /** + * A list of individual points. + */ + POINTS, + + /** + * A list of individual lines. + */ + LINES, + + /** + * A list of connected lines, where each point gets connected to the previous point. + */ + LINE_STRIP, + + /** + * A list of individual triangles. + */ + TRIANGLES, + + /** + * A list of connected triangles, where ech point uses the two previous points + * to form a triangle. + */ + TRIANGLE_STRIP, + + /** + * A list of connected triangles, where each point uses the common center and the + * previous point to form a triangle. + */ + TRIANGLE_FAN, + + /** + * A list of individual quads. + */ + QUADS +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/RectangleShape.java b/lib/jsfml/src/java/org/jsfml/graphics/RectangleShape.java new file mode 100644 index 00000000..527c6ce6 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/RectangleShape.java @@ -0,0 +1,65 @@ +package org.jsfml.graphics; + +import org.jsfml.system.Vector2f; + +/** + * A specialized shape representing a rectangle. + */ +public class RectangleShape extends Shape { + //cache + private Vector2f size = Vector2f.ZERO; + + /** + * Constructs a new rectangle shape with no dimensions. + */ + public RectangleShape() { + super(); + } + + /** + * Constructs a new rectangle shape with the specified dimensions. + * + * @param size the rectangle's dimensions. + */ + public RectangleShape(Vector2f size) { + this(); + setSize(size); + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native long nativeCreate(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeSetExPtr(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeDelete(); + + private native void nativeSetSize(float w, float h); + + /** + * Sets the dimensions of the rectangle. + * + * @param size the new dimensions of the rectangle. + */ + public void setSize(Vector2f size) { + nativeSetSize(size.x, size.y); + this.size = size; + pointsNeedUpdate = true; + } + + /** + * Gets the dimensions of the rectangle. + * + * @return the dimensions of the rectangle. + */ + public Vector2f getSize() { + return size; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/RenderStates.java b/lib/jsfml/src/java/org/jsfml/graphics/RenderStates.java new file mode 100644 index 00000000..5a1b3126 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/RenderStates.java @@ -0,0 +1,136 @@ +package org.jsfml.graphics; + +import java.util.Objects; + +/** + * Defines drawing properties when drawing objects to a {@link RenderTarget}. + */ +public final class RenderStates { + /** + * Pre-defined instance holding the default render states using + * {@link BlendMode#ALPHA} blending, the identity transformation and no texture or shader. + */ + public static final RenderStates DEFAULT = + new RenderStates(BlendMode.ALPHA, Transform.IDENTITY, null, null); + + /** + * The blending mode used for drawing. + */ + public final BlendMode blendMode; + + /** + * The transformation matrix used for drawing. + */ + public final Transform transform; + + /** + * The texture used for drawing. + */ + public final ConstTexture texture; + + /** + * The shader used for drawing. + */ + public final ConstShader shader; + + /** + * Constructs a new set of render states with default settings and + * the specified blending mode. + * + * @param blendMode the blending mode used for drawing. + */ + public RenderStates(BlendMode blendMode) { + this(blendMode, Transform.IDENTITY, null, null); + } + + /** + * Constructs a new set of render states with default settings and + * the specified transformation matrix. + * + * @param transform the transformation matrix used for drawing. + */ + public RenderStates(Transform transform) { + this(BlendMode.ALPHA, transform, null, null); + } + + /** + * Constructs a new set of render states with default settings and + * the specified texture. + * + * @param texture the texture used for drawing, + * or {@code null} to indicate that no texture should be used. + */ + public RenderStates(ConstTexture texture) { + this(BlendMode.ALPHA, Transform.IDENTITY, texture, null); + } + + /** + * Constructs a new set of render states with default settings and + * the specified shader. + * + * @param shader the shader applied to whatever is drawn using these states, + * or {@code null} to indicate that no shader should be used. + */ + public RenderStates(ConstShader shader) { + this(BlendMode.ALPHA, Transform.IDENTITY, null, shader); + } + + /** + * Constructs a new set of render states by copying other states, + * but changing the blend mode. + * + * @param blendMode the blending mode used for drawing. + */ + public RenderStates(RenderStates states, BlendMode blendMode) { + this(blendMode, states.transform, states.texture, states.shader); + } + + /** + * Constructs a new set of render states by copying other states, + * but changing the transformation. + * + * @param transform the transformation matrix used for drawing. + */ + public RenderStates(RenderStates states, Transform transform) { + this(states.blendMode, transform, states.texture, states.shader); + } + + /** + * Constructs a new set of render states by copying other states, + * but changing the texture. + * + * @param texture the texture used for drawing, or {@code null} to indicate that + * no texture should be used. + */ + public RenderStates(RenderStates states, ConstTexture texture) { + this(states.blendMode, states.transform, texture, states.shader); + } + + /** + * Constructs a new set of render states by copying other states, + * but changing the shader. + * + * @param shader the shader applied to whatever is drawn using these states, + * or {@code null} to indicate that no shader should be used. + */ + public RenderStates(RenderStates states, ConstShader shader) { + this(states.blendMode, states.transform, states.texture, shader); + } + + /** + * Constructs a new set of render states with the specified parameters. + * + * @param blendMode the blending mode used for drawing. + * @param transform the transformation matrix used for drawing. + * @param texture the texture used for drawing, + * or {@code null} to indicate that no texture should be used. + * @param shader the shader applied to whatever is drawn using these states, + * or {@code null} to indicate that no shader should be used. + */ + public RenderStates(BlendMode blendMode, Transform transform, ConstTexture texture, ConstShader shader) { + this.blendMode = Objects.requireNonNull(blendMode); + this.transform = Objects.requireNonNull(transform); + this.texture = texture; + this.shader = shader; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/RenderTarget.java b/lib/jsfml/src/java/org/jsfml/graphics/RenderTarget.java new file mode 100644 index 00000000..436c63cb --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/RenderTarget.java @@ -0,0 +1,135 @@ +package org.jsfml.graphics; + +import org.jsfml.system.Vector2f; +import org.jsfml.system.Vector2i; + +/** + * Interface for render targets. + */ +public interface RenderTarget { + /** + * Clears the render target and fills it with a constant color. + * + * @param color the color to fill the target with. + */ + public void clear(Color color); + + /** + * Sets the target's view. + * + * @param view the target's new view. + */ + public void setView(ConstView view); + + /** + * Gets the target's current view. + * + * @return the target's current view. + */ + public ConstView getView(); + + /** + * Gets the target's default view. + * + * @return the target's default view. + */ + public ConstView getDefaultView(); + + /** + * Computes the viewport of the given view applied to this render target. + * + * @param view the view. + * @return the viewport of the given view applied to this render target. + */ + public IntRect getViewport(ConstView view); + + /** + * Converts a point from target coordinates to world coordinates using the target's + * current view. + * + * @param point the point on the render target. + * @return the matching point in the world. + */ + public Vector2f mapPixelToCoords(Vector2i point); + + /** + * Converts a point from target coordinates to world coordinates for a certain view. + * + * @param point the point on the render target. + * @param view the view to use for conversion. + * @return the matching point in the world. + */ + public Vector2f mapPixelToCoords(Vector2i point, ConstView view); + + /** + * Converts a point from world coordinates to target coordinates using the target's + * current view. + * + * @param point the point in the world. + * @return the matching point on the render target. + */ + public Vector2i mapCoordsToPixel(Vector2f point); + + /** + * Converts a point from world coordinates to target coordinates for a certain view. + * + * @param point the point in the world. + * @param view the view to use for conversion. + * @return the matching point on the render target. + */ + public Vector2i mapCoordsToPixel(Vector2f point, ConstView view); + + /** + * Draws a drawable object to the render target using the default render states. + * + * @param drawable the object to draw. + */ + public void draw(Drawable drawable); + + /** + * Draws a drawable object to the render target using the given render states. + * + * @param drawable the object to draw. + * @param renderStates the render states to use for drawing. + */ + public void draw(Drawable drawable, RenderStates renderStates); + + /** + * Draws a primitive of the given type using the given vertices and the default render states. + * + * @param vertices the vertices to draw. + * @param type the type of OpenGL primitive to draw. + */ + public void draw(Vertex[] vertices, PrimitiveType type); + + /** + * Draws a primitive of the given type using the given vertices and the given render states. + * + * @param vertices the vertices to draw. + * @param type the type of OpenGL primitive to draw. + * @param states the render states to use for drawing. + */ + public void draw(Vertex[] vertices, PrimitiveType type, RenderStates states); + + /** + * Gets the size of the render region. + * + * @return the size of the render region. + */ + public Vector2i getSize(); + + /** + * Pushes the current OpenGL states and matrices to the stack. + */ + public void pushGLStates(); + + /** + * Pops the last OpenGL states and matrices from the top of the stack. + */ + public void popGLStates(); + + /** + * Resets the internal OpenGL states so that the target is ready for drawing. + */ + public void resetGLStates(); +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/RenderTexture.java b/lib/jsfml/src/java/org/jsfml/graphics/RenderTexture.java new file mode 100644 index 00000000..ca6bad8e --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/RenderTexture.java @@ -0,0 +1,256 @@ +package org.jsfml.graphics; + +import org.jsfml.internal.IntercomHelper; +import org.jsfml.internal.SFMLErrorCapture; +import org.jsfml.internal.SFMLNative; +import org.jsfml.internal.SFMLNativeObject; +import org.jsfml.system.Vector2f; +import org.jsfml.system.Vector2i; + +import java.util.Objects; + +/** + * Provides a render target for off-screen 2D rendering into a texture. + */ +public class RenderTexture extends SFMLNativeObject implements RenderTarget { + private Vector2i size = Vector2i.ZERO; + + private ConstView defaultView; + private ConstView view; + private final Texture texture; + + /** + * Constructs a new render texture. + */ + public RenderTexture() { + super(); + SFMLNative.ensureDisplay(); + + texture = new Texture(nativeGetTexture()); + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native long nativeCreate(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeSetExPtr(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeDelete(); + + private native boolean nativeCreateTexture(int width, int height, boolean depthBuffer); + + /** + * Sets up the render texture. + * + * @param width the texture's width. + * @param height the texture's height. + * @param depthBuffer {@code true} to generate a depth buffer, {@code false} otherwise. + * Use this only in case you wish to do 3D rendering to this texture. + * @throws TextureCreationException if the render texture could not be created. + */ + public void create(int width, int height, boolean depthBuffer) + throws TextureCreationException { + + size = Vector2i.ZERO; + + SFMLErrorCapture.start(); + final boolean success = nativeCreateTexture(width, height, depthBuffer); + final String msg = SFMLErrorCapture.finish(); + + if (!success) + throw new TextureCreationException(msg); + + defaultView = new View(nativeGetDefaultView()); + + if(view == null) { + view = defaultView; + } + + size = new Vector2i(width, height); + } + + /** + * Sets up the render texture without a depth buffer. + * + * @param width the texture's width. + * @param height the texture's height. + * @throws TextureCreationException if the render texture could not be created. + */ + public final void create(int width, int height) throws TextureCreationException { + create(width, height, false); + } + + /** + * Enables or disables textures smoothing. + * + * @param smooth {@code true} to enable, {@code false} to disable. + */ + public void setSmooth(boolean smooth) { + texture.setSmooth(smooth); + } + + /** + * Checks whether texture smoothing is enabled. + * + * @return {@code true} if enabled, {@code false} if not. + */ + public boolean isSmooth() { + return texture.isSmooth(); + } + + /** + * Enables or disables texture repeating for the underlying texture. + *

      + * Texture repeating is disabled by default. + * + * @param repeated {@code true} to enable, {@code false} to disable. + */ + public void setRepeated(boolean repeated) { + texture.setRepeated(repeated); + } + + /** + * Checks whether texture repeating is enabled for the underlying texture. + * + * @return {@code true} if enabled, {@code false} if disabled. + */ + public boolean isRepeated() { + return texture.isRepeated(); + } + + /** + * Activates or deactivates the render texture for rendering. + * + * @param active {@code true} to activate, {@code false} to deactivate. + */ + public native void setActive(boolean active); + + /** + * Updates the contents of the target texture. + */ + public native void display(); + + private native long nativeGetTexture(); + + /** + * Gets the target texture. + * + * @return the target texture. + */ + public ConstTexture getTexture() { + return texture; + } + + @Override + public Vector2i getSize() { + return size; + } + + private native void nativeClear(int color); + + @Override + public void clear(Color color) { + nativeClear(IntercomHelper.encodeColor(color)); + } + + /** + * Clears the target with black. + */ + public void clear() { + nativeClear(0xFF000000); + } + + private native void nativeSetView(View view); + + @Override + public void setView(ConstView view) { + this.view = Objects.requireNonNull(view); + nativeSetView((View) view); + } + + @Override + public ConstView getView() { + return view; + } + + private native long nativeGetDefaultView(); + + @Override + public ConstView getDefaultView() { + return defaultView; + } + + @Override + public IntRect getViewport(ConstView view) { + final FloatRect viewport = view.getViewport(); + final Vector2i size = getSize(); + + return new IntRect( + (int) (0.5f + viewport.left * size.x), + (int) (0.5f + viewport.top * size.y), + (int) (viewport.width * size.x), + (int) (viewport.height * size.y)); + } + + private native long nativeMapPixelToCoords(long point, ConstView view); + + @Override + public final Vector2f mapPixelToCoords(Vector2i point) { + return mapPixelToCoords(point, view); + } + + @Override + public Vector2f mapPixelToCoords(Vector2i point, ConstView view) { + return IntercomHelper.decodeVector2f( + nativeMapPixelToCoords(IntercomHelper.encodeVector2i(point), view)); + } + + private native long nativeMapCoordsToPixel(long point, ConstView view); + + @Override + public final Vector2i mapCoordsToPixel(Vector2f point) { + return mapCoordsToPixel(point, view); + } + + @Override + public Vector2i mapCoordsToPixel(Vector2f point, ConstView view) { + return IntercomHelper.decodeVector2i( + nativeMapCoordsToPixel(IntercomHelper.encodeVector2f(point), view)); + } + + @Override + public final void draw(Drawable drawable) { + draw(drawable, RenderStates.DEFAULT); + } + + @Override + public void draw(Drawable drawable, RenderStates renderStates) { + drawable.draw(this, renderStates); + } + + @Override + public final void draw(Vertex[] vertices, PrimitiveType type) { + draw(vertices, type, RenderStates.DEFAULT); + } + + @Override + public void draw(Vertex[] vertices, PrimitiveType type, RenderStates states) { + SFMLNativeDrawer.drawVertices(vertices, type, this, states); + } + + @Override + public native void pushGLStates(); + + @Override + public native void popGLStates(); + + @Override + public native void resetGLStates(); +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/RenderWindow.java b/lib/jsfml/src/java/org/jsfml/graphics/RenderWindow.java new file mode 100644 index 00000000..3d3a7f69 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/RenderWindow.java @@ -0,0 +1,219 @@ +package org.jsfml.graphics; + +import org.jsfml.internal.IntercomHelper; +import org.jsfml.internal.UnsafeOperations; +import org.jsfml.system.Vector2f; +import org.jsfml.system.Vector2i; +import org.jsfml.window.ContextSettings; +import org.jsfml.window.VideoMode; +import org.jsfml.window.Window; + +import java.util.Objects; + +/** + * Provides a window that can serve as a target for 2D drawing. + */ +public class RenderWindow extends Window implements RenderTarget { + private ConstView defaultView = null; + private ConstView view = null; + + /** + * Constructs a new render window without actually creating (opening) it. + * + * @see RenderWindow#create(org.jsfml.window.VideoMode, String, int, org.jsfml.window.ContextSettings) + */ + public RenderWindow() { + super(); + } + + @Deprecated + @SuppressWarnings("deprecation") + RenderWindow(long ptr) { + super(ptr); + + defaultView = new View(nativeGetDefaultView()); + view = defaultView; + } + + /** + * Constructs a new render window and creates it with the specified parameters. + * + * @param mode the video mode to use for rendering. + * @param title the window title. + * @param style the window style. + * @param settings the settings for the OpenGL context. + * @see #create(org.jsfml.window.VideoMode, String, int, org.jsfml.window.ContextSettings) + */ + public RenderWindow(VideoMode mode, String title, int style, ContextSettings settings) { + this(); + create(mode, title, style, settings); + } + + /** + * Constructs a new render window and creates it with default context settings. + * + * @param mode the video mode to use for rendering. + * @param title the window title. + * @param style the window style. + * @see #create(org.jsfml.window.VideoMode, String, int) + */ + public RenderWindow(VideoMode mode, String title, int style) { + this(); + create(mode, title, style, new ContextSettings()); + } + + /** + * Constructs a new render window and creates it with default style and context settings. + * + * @param mode The video mode to use for rendering. + * @param title The window title. + */ + public RenderWindow(VideoMode mode, String title) { + this(); + create(mode, title, DEFAULT, new ContextSettings()); + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native long nativeCreate(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeSetExPtr(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeDelete(); + + @Override + public void create(VideoMode mode, String title, int style, ContextSettings settings) { + super.create(mode, title, style, settings); + + defaultView = new View(nativeGetDefaultView()); + + if (view == null) { + view = defaultView; + } + } + + private native long nativeCapture(); + + /** + * Copies the current contents of the window to an image. + *

      + * This is a slow operation and should be used to take screenshots, not to re-use + * resulting image as a texture. For that, use {@link Texture#update(org.jsfml.window.Window)} + * or a {@link RenderTexture} instead. + * + * @return the image with the current contents of the window. + */ + public Image capture() { + final Image image = new Image(nativeCapture()); + UnsafeOperations.manageSFMLObject(image, true); + return image; + } + + private native void nativeClear(int color); + + @Override + public void clear(Color color) { + nativeClear(IntercomHelper.encodeColor(color)); + } + + /** + * Clears the target with black. + */ + public void clear() { + nativeClear(0xFF000000); + } + + private native void nativeSetView(View view); + + @Override + public void setView(ConstView view) { + this.view = Objects.requireNonNull(view); + nativeSetView((View) view); + } + + @Override + public ConstView getView() { + return view; + } + + private native long nativeGetDefaultView(); + + @Override + public ConstView getDefaultView() { + return defaultView; + } + + @Override + public IntRect getViewport(ConstView view) { + final FloatRect viewport = view.getViewport(); + final Vector2i size = getSize(); + + return new IntRect( + (int) (0.5f + viewport.left * size.x), + (int) (0.5f + viewport.top * size.y), + (int) (viewport.width * size.x), + (int) (viewport.height * size.y)); + } + + private native long nativeMapPixelToCoords(long point, ConstView view); + + @Override + public final Vector2f mapPixelToCoords(Vector2i point) { + return mapPixelToCoords(point, view); + } + + @Override + public Vector2f mapPixelToCoords(Vector2i point, ConstView view) { + return IntercomHelper.decodeVector2f( + nativeMapPixelToCoords(IntercomHelper.encodeVector2i(point), view)); + } + + private native long nativeMapCoordsToPixel(long point, ConstView view); + + @Override + public final Vector2i mapCoordsToPixel(Vector2f point) { + return mapCoordsToPixel(point, view); + } + + @Override + public Vector2i mapCoordsToPixel(Vector2f point, ConstView view) { + return IntercomHelper.decodeVector2i( + nativeMapCoordsToPixel(IntercomHelper.encodeVector2f(point), view)); + } + + @Override + public final void draw(Drawable drawable) { + draw(drawable, RenderStates.DEFAULT); + } + + @Override + public void draw(Drawable drawable, RenderStates renderStates) { + drawable.draw(this, renderStates); + } + + @Override + public final void draw(Vertex[] vertices, PrimitiveType type) { + draw(vertices, type, RenderStates.DEFAULT); + } + + @Override + public void draw(Vertex[] vertices, PrimitiveType type, RenderStates states) { + SFMLNativeDrawer.drawVertices(vertices, type, this, states); + } + + @Override + public native void pushGLStates(); + + @Override + public native void popGLStates(); + + @Override + public native void resetGLStates(); +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/SFMLNativeDrawer.java b/lib/jsfml/src/java/org/jsfml/graphics/SFMLNativeDrawer.java new file mode 100644 index 00000000..a7a35a17 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/SFMLNativeDrawer.java @@ -0,0 +1,78 @@ +package org.jsfml.graphics; + +import org.jsfml.internal.IntercomHelper; + +import java.nio.*; + +/** + * Provides generic implementations of the {@code draw} methods for + * native SFML drawables and vertices. + */ +final class SFMLNativeDrawer { + private static final int NATIVE_VERTEX_SIZE = 20; + private static final int MAX_VERTICES = 1024; + + private static final ThreadLocal vertexBuffer = new ThreadLocal() { + @Override + protected ByteBuffer initialValue() { + return ByteBuffer.allocateDirect(MAX_VERTICES * NATIVE_VERTEX_SIZE).order(ByteOrder.nativeOrder()); + } + }; + + private static native void nativeDrawVertices( + int num, + Buffer vbuf, + int type, + RenderTarget target, + int blendMode, + Buffer xform, + ConstTexture texture, + ConstShader shader); + + static void drawVertices(Vertex[] vertices, PrimitiveType type, RenderTarget target, RenderStates states) { + final ByteBuffer vbuf = vertexBuffer.get(); + final FloatBuffer vfloats = vbuf.asFloatBuffer(); + final IntBuffer vints = vbuf.asIntBuffer(); + + final int sz = NATIVE_VERTEX_SIZE / 4; + for (int i = 0; i < vertices.length; i++) { + final Vertex v = vertices[i]; + final int x = i * sz; + + //keep away from children! + vfloats.put(x, v.position.x); + vfloats.put(x + 1, v.position.y); + vints.put(x + 2, IntercomHelper.encodeColor(v.color)); + vfloats.put(x + 3, v.texCoords.x); + vfloats.put(x + 4, v.texCoords.y); + } + + nativeDrawVertices( + vertices.length, + vbuf, + type.ordinal(), + target, + states.blendMode.ordinal(), + IntercomHelper.encodeTransform(states.transform), + states.texture, + states.shader); + } + + private static native void nativeDrawDrawable( + Drawable drawable, + RenderTarget target, + int blendMode, + Buffer xform, + ConstTexture texture, + ConstShader shader); + + static void draw(Drawable drawable, RenderTarget target, RenderStates states) { + nativeDrawDrawable( + drawable, + target, + states.blendMode.ordinal(), + IntercomHelper.encodeTransform(states.transform), + states.texture, + states.shader); + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/SFMLNativeTransformable.java b/lib/jsfml/src/java/org/jsfml/graphics/SFMLNativeTransformable.java new file mode 100644 index 00000000..99e62035 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/SFMLNativeTransformable.java @@ -0,0 +1,152 @@ +package org.jsfml.graphics; + +import org.jsfml.internal.IntercomHelper; +import org.jsfml.internal.SFMLNativeObject; +import org.jsfml.system.Vector2f; + +import java.nio.Buffer; +import java.util.Objects; + +/** + * Decomposed transform defined by a position, a rotation and a scale. + */ +abstract class SFMLNativeTransformable extends SFMLNativeObject implements Transformable { + //cache + private Vector2f position = Vector2f.ZERO; + private float rotation = 0; + private Vector2f scale = new Vector2f(1, 1); + private Vector2f origin = Vector2f.ZERO; + + private boolean transformNeedsUpdate = true; + private Transform transformCache = null; + private Transform inverseTransformCache = null; + + protected SFMLNativeTransformable() { + super(); + } + + private native void nativeSetPosition(float x, float y); + + @Override + public final void setPosition(float x, float y) { + setPosition(new Vector2f(x, y)); + } + + @Override + public void setPosition(Vector2f v) { + position = Objects.requireNonNull(v); + nativeSetPosition(v.x, v.y); + transformNeedsUpdate = true; + } + + private native void nativeSetRotation(float angle); + + @Override + public void setRotation(float angle) { + rotation = angle; + nativeSetRotation(angle); + transformNeedsUpdate = true; + } + + private native void nativeSetScale(float x, float y); + + @Override + public final void setScale(float x, float y) { + setScale(new Vector2f(x, y)); + } + + @Override + public void setScale(Vector2f v) { + scale = Objects.requireNonNull(v); + nativeSetScale(v.x, v.y); + transformNeedsUpdate = true; + } + + private native void nativeSetOrigin(float x, float y); + + @Override + public final void setOrigin(float x, float y) { + setOrigin(new Vector2f(x, y)); + } + + @Override + public void setOrigin(Vector2f v) { + origin = Objects.requireNonNull(v); + nativeSetOrigin(v.x, v.y); + transformNeedsUpdate = true; + } + + @Override + public Vector2f getPosition() { + return position; + } + + @Override + public float getRotation() { + return rotation; + } + + @Override + public Vector2f getScale() { + return scale; + } + + @Override + public Vector2f getOrigin() { + return origin; + } + + @Override + public final void move(float x, float y) { + setPosition(new Vector2f(position.x + x, position.y + y)); + } + + @Override + public final void move(Vector2f v) { + move(v.x, v.y); + } + + @Override + public final void rotate(float angle) { + setRotation(rotation + angle); + } + + @Override + public final void scale(float x, float y) { + setScale(new Vector2f(scale.x * x, scale.y * y)); + } + + @Override + public final void scale(Vector2f factors) { + scale(factors.x, factors.y); + } + + private native void nativeGetTransform(Buffer buf); + + private void updateTransform() { + if (transformNeedsUpdate) { + nativeGetTransform(IntercomHelper.getBuffer()); + transformCache = IntercomHelper.decodeTransform(); + inverseTransformCache = transformCache.getInverse(); + transformNeedsUpdate = false; + } + } + + @Override + public Transform getTransform() { + if (transformNeedsUpdate) { + updateTransform(); + } + + return transformCache; + } + + @Override + public Transform getInverseTransform() { + if (transformNeedsUpdate) { + updateTransform(); + } + + return inverseTransformCache; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/Shader.java b/lib/jsfml/src/java/org/jsfml/graphics/Shader.java new file mode 100644 index 00000000..4323e9d3 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/Shader.java @@ -0,0 +1,344 @@ +package org.jsfml.graphics; + +import org.jsfml.internal.*; +import org.jsfml.system.Vector2f; +import org.jsfml.system.Vector3f; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.Buffer; +import java.nio.file.Path; +import java.util.Objects; + +/** + * Represents a GLSL shader program, consisting of a vertex and a fragment shader. + */ +public class Shader extends SFMLNativeObject implements ConstShader { + static { + SFMLNative.loadNativeLibraries(); + } + + /** + * Special type denoting that the texture of the object being drawn + * should be used, which cannot be known before it is actually being drawn. + * + * @see Shader#setParameter(String, org.jsfml.graphics.Shader.CurrentTextureType) + */ + public static final class CurrentTextureType { + private CurrentTextureType() { + //cannot instantiate from outside. + } + } + + /** + * Special value denoting that the texture of the object being drawn + * should be used, which cannot be known before it is actually being drawn. + * + * @see Shader#setParameter(String, org.jsfml.graphics.Shader.CurrentTextureType) + */ + public static final CurrentTextureType CURRENT_TEXTURE = new CurrentTextureType(); + + /** + * Activates a shader for rendering. + *

      + * This is required only if you wish to use JSFML shaders in custom OpenGL code. + * + * @param shader the shader to activate, or {@code null} to indicate that no shader + * is to be used. + */ + public static native void bind(ConstShader shader); + + /** + * Checks if shaders are available on this system. + * + * @return {@code true} if shaders are available, {@code false} otherwise. + */ + public static native boolean isAvailable(); + + /** + * Enumeration of shader types. + */ + public static enum Type { + /** + * Vertex shaders. + */ + VERTEX, + + /** + * Fragment shaders. + */ + FRAGMENT + } + + /** + * Constructs a new shader. + */ + public Shader() { + super(); + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native long nativeCreate(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected void nativeSetExPtr() { + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeDelete(); + + private native boolean nativeLoadFromSource1(String source, int shaderType); + + private native boolean nativeLoadFromSource2(String vertSource, String fragSource); + + private void throwException(String msg) throws IOException, ShaderSourceException { + if (msg.startsWith("Failed to compile") || msg.startsWith("Failed to link")) { + throw new ShaderSourceException(msg); + } else { + throw new IOException(msg); + } + } + + /** + * Attempts to load a shader from GLSL source code. + * + * @param source the GLSL source code. + * @param shaderType the shader type. + * @throws IOException in case an I/O error occurs. + * @throws ShaderSourceException in case the shader could not be compiled or linked. + */ + public void loadFromSource(String source, Type shaderType) + throws IOException, ShaderSourceException { + + SFMLErrorCapture.start(); + final boolean result = nativeLoadFromSource1( + Objects.requireNonNull(source), shaderType.ordinal()); + + final String msg = SFMLErrorCapture.finish(); + + if (!result) { + throwException(msg); + } + } + + /** + * Attempts to load a shader from GLSL source code. + * + * @param vertexShaderSource the vertex shader's GLSL source code. + * @param fragmentShaderSource the fragment shader's GLSL source code. + * @throws IOException in case an I/O error occurs. + * @throws ShaderSourceException in case the shader could not be compiled or linked. + */ + public void loadFromSource(String vertexShaderSource, String fragmentShaderSource) + throws IOException, ShaderSourceException { + + SFMLErrorCapture.start(); + final boolean result = nativeLoadFromSource2( + Objects.requireNonNull(vertexShaderSource), + Objects.requireNonNull(fragmentShaderSource)); + + final String msg = SFMLErrorCapture.finish(); + + if (!result) { + throwException(msg); + } + } + + /** + * Fully loads all available bytes from an {@link InputStream} + * and attempts to load the shader from it. + * + * @param in the input stream to read from. + * @param shaderType the shader type. + * @throws IOException in case an I/O error occurs. + * @throws ShaderSourceException in case the shader could not be compiled or linked. + */ + public void loadFromStream(InputStream in, Type shaderType) + throws IOException, ShaderSourceException { + + loadFromSource(new String(StreamUtil.readStream(in)), Objects.requireNonNull(shaderType)); + } + + /** + * Fully loads all available bytes from an {@link InputStream} + * and attempts to load the shader from it. + * + * @param vertexShaderIn the input stream to read the vertex shader from. + * @param fragmentShaderIn the input stream to read the fragment shader from. + * @throws IOException in case an I/O error occurs. + * @throws ShaderSourceException in case the shader could not be compiled or linked. + */ + public void loadFromStream(InputStream vertexShaderIn, InputStream fragmentShaderIn) + throws IOException, ShaderSourceException { + + loadFromSource( + new String(StreamUtil.readStream(vertexShaderIn)), + new String(StreamUtil.readStream(fragmentShaderIn))); + } + + /** + * Attempts to load the shader from a file. + * + * @param path the path to the file to load. + * @param shaderType the shader type. + * @throws IOException in case an I/O error occurs. + * @throws ShaderSourceException in case the shader could not be compiled or linked. + */ + public void loadFromFile(Path path, Type shaderType) + throws IOException, ShaderSourceException { + + loadFromSource(new String(StreamUtil.readFile(path)), Objects.requireNonNull(shaderType)); + } + + /** + * Attempts to load the shader from files. + * + * @param vertexShaderFile the path to the file to read the vertex shader from. + * @param fragmentShaderFile the path to the file to read the fragment shader from. + * @throws IOException in case an I/O error occurs. + * @throws ShaderSourceException in case the shader could not be compiled or linked. + */ + public void loadFromFile(Path vertexShaderFile, Path fragmentShaderFile) + throws IOException, ShaderSourceException { + + loadFromSource( + new String(StreamUtil.readFile(vertexShaderFile)), + new String(StreamUtil.readFile(fragmentShaderFile))); + } + + private native void nativeSetParameterFloat(String name, float x); + + /** + * Sets a float parameter ({@code float}) value in the shader. + * + * @param name the parameter's name. + * @param value the parameter's value. + */ + public void setParameter(String name, float value) { + nativeSetParameterFloat(Objects.requireNonNull(name), value); + } + + private native void nativeSetParameterVec2(String name, float x, float y); + + /** + * Sets a 2-component-float ({@code vec2}) parameter value in the shader. + * + * @param name the parameter's name. + * @param x the parameter's value. + * @param y the parameter's value. + */ + public void setParameter(String name, float x, float y) { + nativeSetParameterVec2(Objects.requireNonNull(name), x, y); + } + + /** + * Sets a 2-component-float ({@code vec2}) parameter value in the shader. + * + * @param name the parameter's name. + * @param v the parameter's value. + */ + public void setParameter(String name, Vector2f v) { + setParameter(name, v.x, v.y); + } + + private native void nativeSetParameterVec3(String name, float x, float y, float z); + + /** + * Sets a 3-component-float ({@code vec3}) parameter value in the shader. + * + * @param name the parameter's name. + * @param x the parameter's value. + * @param y the parameter's value. + * @param z the parameter's value. + */ + public void setParameter(String name, float x, float y, float z) { + nativeSetParameterVec3(Objects.requireNonNull(name), x, y, z); + } + + /** + * Sets a 3-component-float ({@code vec3}) parameter value in the shader. + * + * @param name the parameter's name. + * @param v the parameter's value. + */ + public void setParameter(String name, Vector3f v) { + setParameter(name, v.x, v.y, v.z); + } + + private native void nativeSetParameterVec4(String name, float x, float y, float z, float w); + + /** + * Sets a 4-component-float ({@code vec4}) parameter value in the shader. + * + * @param name the parameter's name. + * @param x the parameter's value. + * @param y the parameter's value. + * @param z the parameter's value. + * @param w the parameter's value. + */ + public void setParameter(String name, float x, float y, float z, float w) { + nativeSetParameterVec4(Objects.requireNonNull(name), x, y, z, w); + } + + /** + * Sets a color (vec4) parameter value in the shader. + * + * @param name the parameter's name. + * @param color the parameter's value. + */ + public void setParameter(String name, Color color) { + setParameter(name, + (float) color.r / 255.0f, + (float) color.g / 255.0f, + (float) color.b / 255.0f, + (float) color.a / 255.0f); + } + + private native void nativeSetParameterMat4(String name, Buffer xform); + + /** + * Sets a matrix (mat4) parameter value in the shader. + * + * @param name the parameter's name. + * @param xform the parameter's value. + */ + public void setParameter(String name, Transform xform) { + nativeSetParameterMat4( + Objects.requireNonNull(name), + IntercomHelper.encodeTransform(xform)); + } + + private native void nativeSetParameterSampler2d(String name, Texture texture); + + /** + * Sets a texture (sampler2D) parameter value in the shader. + * + * @param name the parameter's name. + * @param texture the parameter's value. + */ + public void setParameter(String name, ConstTexture texture) { + nativeSetParameterSampler2d(Objects.requireNonNull(name), (Texture) Objects.requireNonNull(texture)); + } + + private native void nativeSetParameterCurrentTexture(String name); + + /** + * Sets a texture (sampler2D) parameter value in the shader to the texture + * of the object being drawn in the moment the shader is applied. + *

      + * Since that texture cannot be known before the object is actually being drawn, + * this overload can be used to tell the shader to use it when applied. + * + * @param name the parameter's name. + * @param currentTexture should be {@link Shader#CURRENT_TEXTURE}. + */ + public void setParameter(String name, CurrentTextureType currentTexture) { + nativeSetParameterCurrentTexture(Objects.requireNonNull(name)); + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/ShaderSourceException.java b/lib/jsfml/src/java/org/jsfml/graphics/ShaderSourceException.java new file mode 100644 index 00000000..82c5ba6a --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/ShaderSourceException.java @@ -0,0 +1,17 @@ +package org.jsfml.graphics; + +/** + * Thrown if a vertex or fragment shader source could not be compiled or linked. + */ +public class ShaderSourceException extends Exception { + private static final long serialVersionUID = -6514888818053624276L; + + /** + * Constructs a shader compilation exception with the specified message. + * + * @param msg the error message. + */ + public ShaderSourceException(String msg) { + super(msg); + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/Shape.java b/lib/jsfml/src/java/org/jsfml/graphics/Shape.java new file mode 100644 index 00000000..0e417720 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/Shape.java @@ -0,0 +1,302 @@ +package org.jsfml.graphics; + +import org.jsfml.internal.IntercomHelper; +import org.jsfml.system.Vector2f; + +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; +import java.util.Objects; + +/** + * Abstract base class for (optionally) textured shapes with (optional) outlines. + */ +public abstract class Shape extends SFMLNativeTransformable implements Drawable { + //cache + private Color fillColor = Color.WHITE; + private Color outlineColor = Color.WHITE; + private float outlineThickness = 0; + private IntRect textureRect = IntRect.EMPTY; + private ConstTexture texture = null; + + protected boolean pointsNeedUpdate = true; + protected Vector2f[] points = null; + + private boolean boundsNeedUpdate = true; + private FloatRect localBounds = null; + private FloatRect globalBounds = null; + + /** + * Default constructor. + */ + public Shape() { + super(); + } + + private native void nativeSetTexture(Texture texture, boolean resetRect); + + /** + * Sets the texture of the shape. + *

      + * The texture may be {@code null} if no texture is to be used. + * + * @param texture the texture of the shape, or {@code null} to indicate that no texture + * is to be used. + * @param resetRect {@code true} to reset the texture rect, {@code false} otherwise. + */ + public void setTexture(ConstTexture texture, boolean resetRect) { + this.texture = texture; + nativeSetTexture((Texture) texture, resetRect); + } + + /** + * Sets the texture of the shape without affecting the texture rectangle. + *

      + * The texture may be {@code null} if no texture is to be used. + * + * @param texture the texture of the shape, or {@code null} to indicate that no texture + * is to be used. + */ + public final void setTexture(ConstTexture texture) { + setTexture(texture, false); + } + + private native void nativeSetTextureRect(Buffer buffer); + + /** + * Sets the portion of the texture that will be used for drawing. + *

      + * An empty rectangle can be passed to indicate that the whole texture shall be used. + *

      + * The width and / or height of the rectangle may be negative to indicate that the + * respective axis should be flipped. For example, a width of {@code -32} will + * result in a sprite that is 32 pixels wide and flipped horizontally. + * + * @param rect the texture portion. + */ + public void setTextureRect(IntRect rect) { + nativeSetTextureRect(IntercomHelper.encodeIntRect(rect)); + this.textureRect = rect; + } + + private native void nativeSetFillColor(int color); + + /** + * Sets the fill color of the shape. + * + * @param color the new fill color of the shape, or {@link Color#TRANSPARENT} to indicate + * that the shape should not be filled. + */ + public void setFillColor(Color color) { + nativeSetFillColor(IntercomHelper.encodeColor(color)); + this.fillColor = color; + } + + private native void nativeSetOutlineColor(int color); + + /** + * Sets the outline color of the shape. + * + * @param color the new outline color of the shape. + */ + public void setOutlineColor(Color color) { + nativeSetOutlineColor(IntercomHelper.encodeColor(color)); + this.outlineColor = color; + } + + private native void nativeSetOutlineThickness(float thickness); + + /** + * Sets the thickness of the shape's outline. + * + * @param thickness the thickness of the shape's outline, or 0 to indicate that no + * outline should be drawn. + */ + public void setOutlineThickness(float thickness) { + nativeSetOutlineThickness(thickness); + this.outlineThickness = thickness; + } + + /** + * Gets the shape's current texture. + * + * @return the shape's current texture. + */ + public ConstTexture getTexture() { + return texture; + } + + /** + * Gets the shape's current texture portion. + * + * @return the shape's current texture portion. + */ + public IntRect getTextureRect() { + return textureRect; + } + + /** + * Gets the shape's current fill color. + * + * @return the shape's current fill color. + */ + public Color getFillColor() { + return fillColor; + } + + /** + * Gets the shape's current outline color. + * + * @return the shape's current outline color. + */ + public Color getOutlineColor() { + return outlineColor; + } + + /** + * Gets the shape's current outline thickness. + * + * @return the shape's current outline thickness. + */ + public float getOutlineThickness() { + return outlineThickness; + } + + private native int nativeGetPointCount(); + + private native void nativeGetPoints(int n, Buffer buffer); + + private void updatePoints() { + if (pointsNeedUpdate) { + final int n = nativeGetPointCount(); + final FloatBuffer buffer = ByteBuffer.allocateDirect(2 * n * 4).order( + ByteOrder.nativeOrder()).asFloatBuffer(); + + nativeGetPoints(n, buffer); + points = new Vector2f[n]; + for (int i = 0; i < n; i++) { + points[i] = new Vector2f(buffer.get(2 * i), buffer.get(2 * i + 1)); + } + + pointsNeedUpdate = false; + } + } + + /** + * Gets the amount of points that defines this shape. + * + * @return the amount of points that defines this shape. + */ + public int getPointCount() { + if (pointsNeedUpdate) { + updatePoints(); + } + + return points.length; + } + + /** + * Gets a point of the shape. + * + * @param i the index of the point to retrieve. + * @return the point at the given index. + */ + public Vector2f getPoint(int i) { + if (pointsNeedUpdate) { + updatePoints(); + } + + return points[i]; + } + + /** + * Gets all the points of the shape. + * + * @return an array containing the points of the shape. + */ + public Vector2f[] getPoints() { + int n = getPointCount(); + Vector2f[] points = new Vector2f[n]; + + System.arraycopy(this.points, 0, points, 0, n); + return points; + } + + private native void nativeGetLocalBounds(Buffer buf); + + private native void nativeGetGlobalBounds(Buffer buf); + + private void updateBounds() { + if(boundsNeedUpdate) { + nativeGetLocalBounds(IntercomHelper.getBuffer()); + localBounds = IntercomHelper.decodeFloatRect(); + + nativeGetGlobalBounds(IntercomHelper.getBuffer()); + globalBounds = IntercomHelper.decodeFloatRect(); + + boundsNeedUpdate = false; + } + } + + /** + * Gets the text's local bounding rectangle, + * not taking the text's transformation into account. + * + * @return the text's local bounding rectangle. + * @see org.jsfml.graphics.Sprite#getGlobalBounds() + */ + public FloatRect getLocalBounds() { + if(boundsNeedUpdate) { + updateBounds(); + } + + return localBounds; + } + + /** + * Gets the text's global bounding rectangle in the scene, + * taking the text's transformation into account. + * + * @return the text's global bounding rectangle. + * @see org.jsfml.graphics.Text#getLocalBounds() + */ + public FloatRect getGlobalBounds() { + if(boundsNeedUpdate) { + updateBounds(); + } + + return globalBounds; + } + + @Override + public void setPosition(Vector2f v) { + super.setPosition(v); + boundsNeedUpdate = true; + } + + @Override + public void setRotation(float angle) { + super.setRotation(angle); + boundsNeedUpdate = true; + } + + @Override + public void setScale(Vector2f v) { + super.setScale(v); + boundsNeedUpdate = true; + } + + @Override + public void setOrigin(Vector2f v) { + super.setOrigin(v); + boundsNeedUpdate = true; + } + + @Override + public void draw(RenderTarget target, RenderStates states) { + SFMLNativeDrawer.draw(this, + Objects.requireNonNull(target), + Objects.requireNonNull(states)); + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/Sprite.java b/lib/jsfml/src/java/org/jsfml/graphics/Sprite.java new file mode 100644 index 00000000..ce0a2307 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/Sprite.java @@ -0,0 +1,227 @@ +package org.jsfml.graphics; + +import org.jsfml.internal.IntercomHelper; +import org.jsfml.system.Vector2f; + +import java.nio.Buffer; +import java.util.Objects; + +/** + * Represents a drawable instance of a texture or texture portion. + */ +public class Sprite extends SFMLNativeTransformable implements Drawable { + //cache + private Color color = Color.WHITE; + private IntRect textureRect = IntRect.EMPTY; + private ConstTexture texture = null; + + private boolean boundsNeedUpdate = true; + private FloatRect localBounds = null; + private FloatRect globalBounds = null; + + /** + * Constructs a new sprite without a texture. + */ + public Sprite() { + super(); + } + + /** + * Constructs a new sprite with the specified texture. + * + * @param texture the texture. + */ + public Sprite(ConstTexture texture) { + this(); + setTexture(texture); + } + + /** + * Constructs a new sprite with the specified texture and texture portion. + * + * @param texture the texture. + * @param rect the portion of the texture to use. + */ + public Sprite(ConstTexture texture, IntRect rect) { + this(texture); + setTextureRect(rect); + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native long nativeCreate(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeSetExPtr(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeDelete(); + + private native void nativeSetTexture(Texture texture, boolean resetRect); + + /** + * Sets the texture of this sprite. + * + * @param texture the new texture. + * @param resetRect {@code true} to reset the texture rectangle, {@code false} otherwise. + */ + public void setTexture(ConstTexture texture, boolean resetRect) { + nativeSetTexture((Texture) Objects.requireNonNull(texture), resetRect); + this.texture = texture; + + if(resetRect) { + textureRect = IntRect.EMPTY; + } + + boundsNeedUpdate = true; + } + + /** + * Sets the texture of this sprite without affecting the texture rectangle. + * + * @param texture the new texture. + */ + public final void setTexture(ConstTexture texture) { + setTexture(texture, false); + } + + private native void nativeSetTextureRect(Buffer rect); + + /** + * Sets the portion of the texture that will be used for drawing. + *

      + * An empty rectangle can be passed to indicate that the whole texture shall be used. + *

      + * The width and / or height of the rectangle may be negative to indicate that the + * respective axis should be flipped. For example, a width of {@code -32} will + * result in a sprite that is 32 pixels wide and flipped horizontally. + * + * @param rect the texture portion. + */ + public void setTextureRect(IntRect rect) { + this.textureRect = rect; + nativeSetTextureRect(IntercomHelper.encodeIntRect(rect)); + boundsNeedUpdate = true; + } + + private native void nativeSetColor(int color); + + /** + * Sets the color mask of the sprite. + * + * @param color the new color. + */ + public void setColor(Color color) { + this.color = color; + nativeSetColor(IntercomHelper.encodeColor(color)); + } + + /** + * Gets the sprite's current texture. + * + * @return the sprite's current texture. + */ + public ConstTexture getTexture() { + return texture; + } + + /** + * Gets the sprite's current texture rectangle. + * + * @return the sprite's current texture rectangle. + */ + public IntRect getTextureRect() { + return textureRect; + } + + /** + * Gets the sprite's current color mask. + * + * @return the sprite's current color mask. + */ + public Color getColor() { + return color; + } + + private native void nativeGetLocalBounds(Buffer buf); + + private native void nativeGetGlobalBounds(Buffer buf); + + private void updateBounds() { + if(boundsNeedUpdate) { + nativeGetLocalBounds(IntercomHelper.getBuffer()); + localBounds = IntercomHelper.decodeFloatRect(); + + nativeGetGlobalBounds(IntercomHelper.getBuffer()); + globalBounds = IntercomHelper.decodeFloatRect(); + + boundsNeedUpdate = false; + } + } + + /** + * Gets the sprite's local bounding rectangle, + * not taking the sprite's transformation into account. + * + * @return the sprite's local bounding rectangle. + * @see org.jsfml.graphics.Sprite#getGlobalBounds() + */ + public FloatRect getLocalBounds() { + if(boundsNeedUpdate) { + updateBounds(); + } + + return localBounds; + } + + /** + * Gets the sprite's global bounding rectangle in the scene, + * taking the sprite's transformation into account. + * + * @return the sprite's global bounding rectangle. + * @see org.jsfml.graphics.Sprite#getLocalBounds() + */ + public FloatRect getGlobalBounds() { + if(boundsNeedUpdate) { + updateBounds(); + } + + return globalBounds; + } + + @Override + public void setPosition(Vector2f v) { + super.setPosition(v); + boundsNeedUpdate = true; + } + + @Override + public void setRotation(float angle) { + super.setRotation(angle); + boundsNeedUpdate = true; + } + + @Override + public void setScale(Vector2f v) { + super.setScale(v); + boundsNeedUpdate = true; + } + + @Override + public void setOrigin(Vector2f v) { + super.setOrigin(v); + boundsNeedUpdate = true; + } + + @Override + public void draw(RenderTarget target, RenderStates states) { + SFMLNativeDrawer.draw(this, + Objects.requireNonNull(target), + Objects.requireNonNull(states)); + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/Text.java b/lib/jsfml/src/java/org/jsfml/graphics/Text.java new file mode 100644 index 00000000..a5896214 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/Text.java @@ -0,0 +1,278 @@ +package org.jsfml.graphics; + +import org.jsfml.internal.IntercomHelper; +import org.jsfml.system.Vector2f; + +import java.nio.Buffer; +import java.util.Objects; + +/** + * Represents a graphical text that can be transformed and drawn to a render target. + *

      + * This class implements the {@code TextStyle} interface for quick access to the constants + * provided by it. + */ +public class Text extends SFMLNativeTransformable implements Drawable, TextStyle { + private ConstFont font = null; + private String string = ""; + private Color color = Color.WHITE; + private int style = TextStyle.REGULAR; + private int characterSize = 30; + + private boolean boundsNeedUpdate = true; + private FloatRect localBounds = null; + private FloatRect globalBounds = null; + + /** + * Creates a new empty text. + */ + public Text() { + super(); + } + + /** + * Creates a new text. + * + * @param string The text string. + * @param font The font to use. + */ + public Text(String string, ConstFont font) { + this(); + setFont(font); + setString(string); + } + + /** + * Creates a new text. + * + * @param string The text string. + * @param font The font to use. + * @param characterSize The font size. + */ + public Text(String string, ConstFont font, int characterSize) { + this(); + setCharacterSize(characterSize); + setFont(font); + setString(string); + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native long nativeCreate(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeSetExPtr(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeDelete(); + + private native void nativeSetString(String string); + + /** + * Sets the string to display. + * + * @param string The string to display. + */ + public void setString(String string) { + this.string = Objects.requireNonNull(string); + nativeSetString(string); + boundsNeedUpdate = true; + } + + private native void nativeSetFont(Font font); + + /** + * Sets the text's font. + * + * @param font The text's font. + */ + public void setFont(ConstFont font) { + this.font = Objects.requireNonNull(font); + nativeSetFont((Font) font); + boundsNeedUpdate = true; + } + + private native void nativeSetCharacterSize(int characterSize); + + /** + * Sets the font size for this text. + * + * @param characterSize The font size for this text. + */ + public void setCharacterSize(int characterSize) { + nativeSetCharacterSize(characterSize); + this.characterSize = characterSize; + boundsNeedUpdate = true; + } + + private native void nativeSetStyle(int style); + + /** + * Sets the font drawing style. + * + * @param style The font drawing style. This should be an combination ({@code OR}) + * of the style flags {@link TextStyle#BOLD}, {@link TextStyle#ITALIC} and + * {@link TextStyle#UNDERLINED}, or {@link TextStyle#REGULAR} for the + * regular style. + */ + public void setStyle(int style) { + nativeSetStyle(style); + this.style = style; + boundsNeedUpdate = true; + } + + private native void nativeSetColor(int color); + + /** + * Sets the font color for this text. + * + * @param color The font color for this text. + */ + public void setColor(Color color) { + nativeSetColor(IntercomHelper.encodeColor(color)); + this.color = color; + } + + /** + * Gets the text's string. + * + * @return The text strng. + */ + public String getString() { + return string; + } + + /** + * Gets the text's current font. + * + * @return The text's current font. This may be {@code null} if no font has been set yet. + */ + public ConstFont getFont() { + return font; + } + + /** + * Gets the text's current font size. + * + * @return The text's current font size. + */ + public int getCharacterSize() { + return characterSize; + } + + /** + * Gets the text's current font style. + * + * @return The text's current font style. + * @see Text#setStyle(int) + */ + public int getStyle() { + return style; + } + + /** + * Gets the text's current font color. + * + * @return The text's current font color. + */ + public Color getColor() { + return color; + } + + private native long nativeFindCharacterPos(int i); + + /** + * Returns the position of a character inside the string. + * + * @param i The index of the character to return the position for. + * @return The position of the character at the given index. + */ + public Vector2f findCharacterPos(int i) { + if (i < 0 || i >= string.length()) + throw new StringIndexOutOfBoundsException(Integer.toString(i)); + + return IntercomHelper.decodeVector2f(nativeFindCharacterPos(i)); + } + + private native void nativeGetLocalBounds(Buffer buf); + + private native void nativeGetGlobalBounds(Buffer buf); + + private void updateBounds() { + if(boundsNeedUpdate) { + nativeGetLocalBounds(IntercomHelper.getBuffer()); + localBounds = IntercomHelper.decodeFloatRect(); + + nativeGetGlobalBounds(IntercomHelper.getBuffer()); + globalBounds = IntercomHelper.decodeFloatRect(); + + boundsNeedUpdate = false; + } + } + + /** + * Gets the text's local bounding rectangle, + * not taking the text's transformation into account. + * + * @return the text's local bounding rectangle. + * @see org.jsfml.graphics.Sprite#getGlobalBounds() + */ + public FloatRect getLocalBounds() { + if(boundsNeedUpdate) { + updateBounds(); + } + + return localBounds; + } + + /** + * Gets the text's global bounding rectangle in the scene, + * taking the text's transformation into account. + * + * @return the text's global bounding rectangle. + * @see org.jsfml.graphics.Text#getLocalBounds() + */ + public FloatRect getGlobalBounds() { + if(boundsNeedUpdate) { + updateBounds(); + } + + return globalBounds; + } + + @Override + public void setPosition(Vector2f v) { + super.setPosition(v); + boundsNeedUpdate = true; + } + + @Override + public void setRotation(float angle) { + super.setRotation(angle); + boundsNeedUpdate = true; + } + + @Override + public void setScale(Vector2f v) { + super.setScale(v); + boundsNeedUpdate = true; + } + + @Override + public void setOrigin(Vector2f v) { + super.setOrigin(v); + boundsNeedUpdate = true; + } + + @Override + public void draw(RenderTarget target, RenderStates states) { + SFMLNativeDrawer.draw(this, + Objects.requireNonNull(target), + Objects.requireNonNull(states)); + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/TextStyle.java b/lib/jsfml/src/java/org/jsfml/graphics/TextStyle.java new file mode 100644 index 00000000..8853c607 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/TextStyle.java @@ -0,0 +1,29 @@ +package org.jsfml.graphics; + +/** + * Provides text style constants. + *

      + * These constants can be combined using an arithmetic {@code OR} operation to define + * a text style. + */ +public interface TextStyle { + /** + * Regular drawing style. + */ + public static final int REGULAR = 0; + + /** + * Bold drawing style. + */ + public static final int BOLD = 0x01; + + /** + * Italic drawing style. + */ + public static final int ITALIC = 0x02; + + /** + * Underlined drawing style. + */ + public static final int UNDERLINED = 0x04; +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/Texture.java b/lib/jsfml/src/java/org/jsfml/graphics/Texture.java new file mode 100644 index 00000000..df65da8e --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/Texture.java @@ -0,0 +1,358 @@ +package org.jsfml.graphics; + +import org.jsfml.internal.*; +import org.jsfml.system.Vector2i; +import org.jsfml.window.Context; +import org.jsfml.window.Window; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.Buffer; +import java.nio.file.Path; +import java.util.Objects; + +/** + * Represents a 2D texture stored on the graphics card for rendering. + */ +public class Texture extends SFMLNativeObject implements ConstTexture { + private static final int maximumSize; + + static { + SFMLNative.loadNativeLibraries(); + maximumSize = nativeGetMaximumSize(); + } + + private static native int nativeGetMaximumSize(); + + /** + * Gets the maximum texture size supported by the current hardware. + * + * @return the maximum texture size supported by the current hardware. + */ + public static int getMaximumSize() { + return maximumSize; + } + + /** + * Enumeation of texture coordinate types that can be used for rendering. + */ + public static enum CoordinateType { + /** + * Normalized OpenGL coordinates, ranging from 0 to 1. + */ + NORMALIZED, + + /** + * Pixel coordinates, ranging from 0 to the respective dimension (width or height). + */ + PIXELS + } + + private static native void nativeBind(Texture texture, int coordinateType); + + /** + * Activates a texture for rendering with the specified coordinate type. + *

      + * This is required only if you wish to use JSFML textures in custom OpenGL code. + * + * @param texture the texture to bind, or {@code null} to indicate that + * no texture is to be used.. + * @param coordinateType the coordinate type to use. + */ + public static void bind(ConstTexture texture, CoordinateType coordinateType) { + nativeBind((Texture) texture, coordinateType.ordinal()); + } + + /** + * Activates a texture for rendering, using the + * {@link Texture.CoordinateType#NORMALIZED} coordinate type. + */ + public static void bind(ConstTexture texture) { + bind(texture, CoordinateType.NORMALIZED); + } + + //cache + private Vector2i size = Vector2i.ZERO; + private boolean smooth = false; + private boolean repeated = false; + + /** + * Constructs a new texture. + */ + public Texture() { + super(); + } + + @SuppressWarnings("deprecation") + Texture(long wrap) { + super(wrap); + updateSize(); + smooth = nativeIsSmooth(); + repeated = nativeIsRepeated(); + } + + /** + * Constructs a new texture by copying another texture. + * + * @param other The texture to copy. + */ + @SuppressWarnings("deprecation") + public Texture(ConstTexture other) { + super(((Texture) other).nativeCopy()); + UnsafeOperations.manageSFMLObject(this, true); + updateSize(); + smooth = nativeIsSmooth(); + repeated = nativeIsRepeated(); + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native long nativeCreate(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected void nativeSetExPtr() { + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeDelete(); + + private native long nativeCopy(); + + private native boolean nativeCreate(int width, int height); + + /** + * Generates an empty texture with the specified dimensions. + * + * @param width the texture's width. + * @param height the texture's height. + * @throws TextureCreationException if the texture could not be created. + */ + public void create(int width, int height) throws TextureCreationException { + if (!nativeCreate(width, height)) { + throw new TextureCreationException("Failed to create texture."); + } + + updateSize(); + } + + private native boolean nativeLoadFromStream( + SFMLInputStream.NativeStreamRef stm, Buffer area); + + /** + * Fully loads all available bytes from an {@link InputStream} + * and attempts to load the texture portion from it. + * + * @param in the input stream to read from. + * @param area the area of the image to load into the texture. + * @throws IOException in case an I/O error occurs. + */ + public void loadFromStream(InputStream in, IntRect area) throws IOException { + Context.getContext(); + + final SFMLInputStream.NativeStreamRef streamRef = + new SFMLInputStream.NativeStreamRef(); + + streamRef.initialize(new SFMLInputStream(Objects.requireNonNull(in))); + + SFMLErrorCapture.start(); + final boolean success = nativeLoadFromStream( + streamRef, IntercomHelper.encodeIntRect(area)); + + final String msg = SFMLErrorCapture.finish(); + + if (!success) { + throw new IOException(msg); + } + + updateSize(); + } + + /** + * Fully loads all available bytes from an {@link InputStream} + * and attempts to load the texture from it. + * + * @param in the input stream to read from. + * @throws IOException in case an I/O error occurs. + */ + public final void loadFromStream(InputStream in) throws IOException { + loadFromStream(in, IntRect.EMPTY); + } + + private native boolean nativeLoadFromFile(String path, Buffer area); + + /** + * Attempts to load the texture from a file. + * + * @param path the path to the file to load the texture from. + * @param area the area of the image to load into the texture. + * @throws IOException in case an I/O error occurs. + */ + public void loadFromFile(Path path, IntRect area) throws IOException { + Context.getContext(); + + SFMLErrorCapture.start(); + + final boolean success = nativeLoadFromFile( + path.toAbsolutePath().toString(), + IntercomHelper.encodeIntRect(area)); + + final String msg = SFMLErrorCapture.finish(); + + if (!success) { + throw new IOException(msg); + } + + updateSize(); + } + + /** + * Attempts to load the texture from a file. + * + * @param path the path to the file to load the texture from. + * @throws IOException in case an I/O error occurs. + */ + public final void loadFromFile(Path path) throws IOException { + loadFromFile(path, IntRect.EMPTY); + } + + private native boolean nativeLoadFromImage(Image image, Buffer area); + + /** + * Attempts to load the texture from a source image portion. + * + * @param image the source image. + * @param area the area of the image to load into the texture. + * @throws TextureCreationException if the texture could not be loaded from the image. + */ + public void loadFromImage(Image image, IntRect area) + throws TextureCreationException { + + image.commit(); + + Context.getContext(); + + if (!nativeLoadFromImage(image, IntercomHelper.encodeIntRect(area))) { + throw new TextureCreationException("Failed to load texture from image."); + } + + updateSize(); + } + + /** + * Attempts to load the texture from a source image. + * + * @param image the source image. + * @throws TextureCreationException if the texture could not be loaded from the image. + */ + public final void loadFromImage(Image image) throws TextureCreationException { + loadFromImage(image, IntRect.EMPTY); + } + + private native long nativeGetSize(); + + private void updateSize() { + size = IntercomHelper.decodeVector2i(nativeGetSize()); + } + + /** + * Gets the dimensions of the texture. + * + * @return the dimensions of the texture. + */ + public Vector2i getSize() { + return size; + } + + private native long nativeCopyToImage(); + + @Override + public Image copyToImage() { + Image image = new Image(nativeCopyToImage()); + UnsafeOperations.manageSFMLObject(image, true); + + return image; + } + + private native void nativeUpdate(Image image, int x, int y); + + /** + * Updates a part of the texture from an image. + * + * @param image the image to update from. + * @param x the X offset inside the texture. + * @param y the Y offset inside the texture. + */ + public void update(Image image, int x, int y) { + image.commit(); + nativeUpdate(image, x, y); + } + + private native void nativeUpdate(Window window, int x, int y); + + /** + * Updates a part of the texture from the contents of a window. + * + * @param window the window to update from. + * @param x the X offset inside the texture. + * @param y the Y offset inside the texture. + */ + public void update(Window window, int x, int y) { + nativeUpdate(Objects.requireNonNull(window), x, y); + } + + /** + * Updates the texture from the contents of a window. + * + * @param window the window to update from. + */ + public final void update(Window window) { + update(window, 0, 0); + } + + private native void nativeSetSmooth(boolean smooth); + + /** + * Enables or disables the smooth filter. + *

      + * The smooth filter is disabled by default. + * + * @param smooth {@code true} to enable, {@code false} to disable. + */ + public void setSmooth(boolean smooth) { + nativeSetSmooth(smooth); + this.smooth = smooth; + } + + private native boolean nativeIsSmooth(); + + @Override + public boolean isSmooth() { + return smooth; + } + + private native void nativeSetRepeated(boolean repeated); + + /** + * Enables or disables texture repeating. + *

      + * Texture repeating is disabled by default. + * + * @param repeated {@code true} to enable, {@code false} to disable. + */ + public void setRepeated(boolean repeated) { + nativeSetRepeated(repeated); + this.repeated = repeated; + } + + private native boolean nativeIsRepeated(); + + @Override + public boolean isRepeated() { + return repeated; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/TextureCreationException.java b/lib/jsfml/src/java/org/jsfml/graphics/TextureCreationException.java new file mode 100644 index 00000000..3dec5e47 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/TextureCreationException.java @@ -0,0 +1,17 @@ +package org.jsfml.graphics; + +/** + * Thrown if a texture failed to be created. + */ +public class TextureCreationException extends Exception { + private static final long serialVersionUID = -3423733954575177518L; + + /** + * Constructs a new texture creation exception with the specified message. + * + * @param message the detail message. + */ + public TextureCreationException(String message) { + super(message); + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/Transform.java b/lib/jsfml/src/java/org/jsfml/graphics/Transform.java new file mode 100644 index 00000000..b5a301ac --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/Transform.java @@ -0,0 +1,371 @@ +/* + This class uses direct C++ to Java translations from SFML source code, hence the following notice: + + //////////////////////////////////////////////////////////// + // + // SFML - Simple and Fast Multimedia Library + // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) + // + // This software is provided 'as-is', without any express or implied warranty. + // In no event will the authors be held liable for any damages arising from the use of this software. + // + // Permission is granted to anyone to use this software for any purpose, + // including commercial applications, and to alter it and redistribute it freely, + // subject to the following restrictions: + // + // 1. The origin of this software must not be misrepresented; + // you must not claim that you wrote the original software. + // If you use this software in a product, an acknowledgment + // in the product documentation would be appreciated but is not required. + // + // 2. Altered source versions must be plainly marked as such, + // and must not be misrepresented as being the original software. + // + // 3. This notice may not be removed or altered from any source distribution. + // + //////////////////////////////////////////////////////////// +*/ + +package org.jsfml.graphics; + +import org.jsfml.system.Vector2f; + +import java.io.Serializable; +import java.util.Arrays; + +/** + * Defines a 3x3 transformation matrix for 2D transformations. + */ +public final strictfp class Transform implements Serializable { + private static final long serialVersionUID = 3796964163848107663L; + + /** + * The identity transformation, maps any vector to itself and therefore + * "does nothing". + */ + public final static Transform IDENTITY = new Transform(); + + /** + * Combines two transformation matrices by multiplying them. + * + * @param t1 the first transformation matrix. + * @param t2 the second transformation matrix. + * @return the product of the two given matrices. + */ + public static Transform combine(Transform t1, Transform t2) { + float[] a = t1.data; + float[] b = t2.data; + + return new Transform( + a[0] * b[0] + a[4] * b[1] + a[12] * b[3], + a[0] * b[4] + a[4] * b[5] + a[12] * b[7], + a[0] * b[12] + a[4] * b[13] + a[12] * b[15], + a[1] * b[0] + a[5] * b[1] + a[13] * b[3], + a[1] * b[4] + a[5] * b[5] + a[13] * b[7], + a[1] * b[12] + a[5] * b[13] + a[13] * b[15], + a[3] * b[0] + a[7] * b[1] + a[15] * b[3], + a[3] * b[4] + a[7] * b[5] + a[15] * b[7], + a[3] * b[12] + a[7] * b[13] + a[15] * b[15]); + } + + /** + * Adds a translation by a 2D vector to a transformation. + * + * @param t the transformation to apply the translation on. + * @param x the X coordinate of the translation vector. + * @param y the Y coordinate of the translation vector. + * @return a new transformation matrix with the translation applied. + */ + public static Transform translate(Transform t, float x, float y) { + return combine(t, new Transform( + 1, 0, x, + 0, 1, y, + 0, 0, 1)); + } + + /** + * Adds a translation by a 2D vector to a transformation. + * + * @param t the transformation to apply the translation to. + * @param v the translation vector. + * @return a new transformation matrix with the translation applied. + */ + public static Transform translate(Transform t, Vector2f v) { + return translate(t, v.x, v.y); + } + + /** + * Adds a rotation around the origin to a transformation. + * + * @param t the transformation to apply the rotation on. + * @param angle the rotation angle in degrees. + * @return a new transformation with the rotation applied + */ + public static Transform rotate(Transform t, float angle) { + double rad = Math.toRadians(angle); + float cos = (float) Math.cos(rad); + float sin = (float) Math.sin(rad); + + return combine(t, new Transform( + cos, -sin, 0, + sin, cos, 0, + 0, 0, 1)); + } + + /** + * Adds a rotation around an arbitrary center to this transformation. + * + * @param t the transformation to apply the rotation on. + * @param angle the rotation angle in degrees. + * @param centerX the X coordinate of the rotation center. + * @param centerY the Y coordinate of the rotation center. + * @return a new transformation with the rotation applied. + */ + public static Transform rotate(Transform t, float angle, float centerX, float centerY) { + double rad = Math.toRadians(angle); + float cos = (float) Math.cos(rad); + float sin = (float) Math.sin(rad); + + return combine(t, new Transform( + cos, -sin, centerX * (1 - cos) + centerY * sin, + sin, cos, centerY * (1 - cos) - centerX * sin, + 0, 0, 1)); + } + + /** + * Adds a rotation around an arbitrary center to this transformation. + * + * @param t the transformation to apply the rotation on. + * @param angle the rotation angle in degrees. + * @param center the rotation center. + * @return a new transformation with the rotation applied. + */ + public static Transform rotate(Transform t, float angle, Vector2f center) { + return rotate(t, angle, center.x, center.y); + } + + /** + * Adds a scaling operation from the origin to a transformation. + * + * @param t the transform to apply the scaling on. + * @param scaleX the X factor of the scaling operation. + * @param scaleY the Y factor of the scaling operation. + * @return a new transformation with the scaling applied. + */ + public static Transform scale(Transform t, float scaleX, float scaleY) { + return combine(t, new Transform( + scaleX, 0, 0, + 0, scaleY, 0, + 0, 0, 1)); + } + + /** + * Adds a scaling operation from the origin to a transformation. + * + * @param t the transform to apply the scaling on. + * @param factors the factors of the scaling operation. + * @return a new transformation with the scaling applied. + */ + public static Transform scale(Transform t, Vector2f factors) { + return scale(t, factors.x, factors.y); + } + + /** + * Adds a scaling operation from an arbitrary center to a transformation. + * + * @param t the transform to apply the scaling on. + * @param scaleX the X factor of the scaling operation. + * @param scaleY the Y factor of the scaling operation. + * @param centerX the X coordinate of the scaling center. + * @param centerY the Y coordinate of the scaling center. + * @return a new transformation with the scaling applied. + */ + public static Transform scale(Transform t, float scaleX, float scaleY, float centerX, float centerY) { + return combine(t, new Transform( + scaleX, 0, centerX * (1 - scaleX), + 0, scaleY, centerY * (1 - scaleY), + 0, 0, 1)); + } + + /** + * Adds a scaling operation from an arbitrary center to a transformation. + * + * @param t the transform to apply the scaling on. + * @param factors the factors of the scaling operation. + * @param center the scaling center. + * @return a new transformation with the scaling applied. + */ + public static Transform scale(Transform t, Vector2f factors, Vector2f center) { + return scale(t, factors.x, factors.y, center.x, center.y); + } + + private final float[] data = new float[16]; + + /** + * Constructs an identity transformation. + */ + public Transform() { + data[0] = 1.0f; + data[5] = 1.0f; + data[10] = 1.0f; + data[15] = 1.0f; + } + + /** + * Constructs a new transformation from a 3x3 matrix of the following format: + *

      a00, a01, a02,
      +     * a10, a11, a12,
      +     * a20, a21, a22
      + * + * @param a00 Matrix component. + * @param a01 Matrix component. + * @param a02 Matrix component. + * @param a10 Matrix component. + * @param a11 Matrix component. + * @param a12 Matrix component. + * @param a20 Matrix component. + * @param a21 Matrix component. + * @param a22 Matrix component. + */ + public Transform( + float a00, float a01, float a02, + float a10, float a11, float a12, + float a20, float a21, float a22) { + data[0] = a00; + data[1] = a10; + data[3] = a20; + data[4] = a01; + data[5] = a11; + data[7] = a21; + data[10] = 1.f; + data[12] = a02; + data[11] = 0.f; + data[13] = a12; + data[15] = a22; + } + + /** + * Constructs a new transformation by copying another transformation. + * + * @param t the transformation to copy. + */ + public Transform(Transform t) { + System.arraycopy(t.data, 0, data, 0, 16); + } + + /** + * Gets a copy of the underlying 4x4 3D transformation matrix. + * + * @return a copy of the underlying 4x4 3D transformation matrix. + */ + public float[] getMatrix() { + float[] m = new float[16]; + System.arraycopy(data, 0, m, 0, 16); + return m; + } + + /** + * Returns the inverse transformation. + * + * @return the inverse transformation, + * or the identity transformation if the matrix cannot be inverted. + */ + public Transform getInverse() { + float det = data[0] * (data[15] * data[5] - data[7] * data[13]) - + data[1] * (data[15] * data[4] - data[7] * data[12]) + + data[3] * (data[13] * data[4] - data[5] * data[12]); + + if (det != 0.f) { + return new Transform( + (data[15] * data[5] - data[7] * data[13]) / det, + -(data[15] * data[4] - data[7] * data[12]) / det, + (data[13] * data[4] - data[5] * data[12]) / det, + -(data[15] * data[1] - data[3] * data[13]) / det, + (data[15] * data[0] - data[3] * data[12]) / det, + -(data[13] * data[0] - data[1] * data[12]) / det, + (data[7] * data[1] - data[3] * data[5]) / det, + -(data[7] * data[0] - data[3] * data[4]) / det, + (data[5] * data[0] - data[1] * data[4]) / det); + } else { + return new Transform(); + } + } + + /** + * Transforms a 2D point using the transformation matrix. + * + * @param x the X coordinate of the point. + * @param y the Y coordinate of the point. + * @return a new 2D vector, representing the transformed point. + */ + public Vector2f transformPoint(float x, float y) { + return new Vector2f( + data[0] * x + data[4] * y + data[12], + data[1] * x + data[5] * y + data[13]); + } + + /** + * Transforms a 2D point using the transformation matrix. + * + * @param v the point to transform. + * @return a new 2D vector, representing the transformed point. + */ + public final Vector2f transformPoint(Vector2f v) { + return transformPoint(v.x, v.y); + } + + /** + * Transforms a rectangle and returns the axis-aligned bounding rectangle. + * + * @param rectangle the rectangle to transform. + * @return the axis-aligned bounding rectangle of the rotated rectangle. + */ + public FloatRect transformRect(FloatRect rectangle) { + // Transform the 4 corners of the rectangle + Vector2f points[] = new Vector2f[]{ + transformPoint(rectangle.left, rectangle.top), + transformPoint(rectangle.left, rectangle.top + rectangle.height), + transformPoint(rectangle.left + rectangle.width, rectangle.top), + transformPoint(rectangle.left + rectangle.width, rectangle.top + rectangle.height)}; + + // Compute the bounding rectangle of the transformed points + float left = points[0].x; + float top = points[0].y; + float right = points[0].x; + float bottom = points[0].y; + + for (int i = 1; i < 4; ++i) { + if (points[i].x < left) left = points[i].x; + else if (points[i].x > right) right = points[i].x; + if (points[i].y < top) top = points[i].y; + else if (points[i].y > bottom) bottom = points[i].y; + } + + return new FloatRect(left, top, right - left, bottom - top); + } + + @Override + public boolean equals(Object o) { + return (o instanceof Transform && Arrays.equals(data, ((Transform) o).data)); + } + + @Override + public int hashCode() { + return Arrays.hashCode(data); + } + + @Override + public String toString() { + StringBuilder str = new StringBuilder(); + str.append("Transform{data=\n"); + int i = 0; + for (int y = 0; y < 4; y++) { + for (int x = 0; x < 4; x++) { + str.append(Float.toString(data[i++])).append(" "); + } + str.append("\n"); + } + str.append("}"); + return str.toString(); + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/Transformable.java b/lib/jsfml/src/java/org/jsfml/graphics/Transformable.java new file mode 100644 index 00000000..26616106 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/Transformable.java @@ -0,0 +1,142 @@ +package org.jsfml.graphics; + +import org.jsfml.system.Vector2f; + +/** + * Interface for transformable objects that can be positioned in the scene and + * rotated and scaled around an origin. + *

      + * An implementation of this interface is provided by the {@link BasicTransformable} class. + */ +public interface Transformable { + /** + * Sets the position of this object in the scene so that its origin will be exactly on it. + * + * @param x the new X coordinate. + * @param y the new Y coordinate. + */ + public void setPosition(float x, float y); + + /** + * Sets the position of this object in the scene so that its origin will be exactly on it. + * + * @param v the new position. + */ + public void setPosition(Vector2f v); + + /** + * Sets the rotation of this object around its origin. + * + * @param angle the new rotation angle in degrees. + */ + public void setRotation(float angle); + + /** + * Sets the scaling of this object, using its origin as the scaling center. + * + * @param x the new X scaling factor. + * @param y the new Y scaling factor. + */ + public void setScale(float x, float y); + + /** + * Sets the scaling of this object, using its origin as the scaling center. + * + * @param factors the new scaling factors. + */ + public void setScale(Vector2f factors); + + /** + * Sets the rotation, scaling and drawing origin of this object. + * + * @param x the new X coordinate of the origin. + * @param y the new Y coordinate of the origin. + */ + public void setOrigin(float x, float y); + + /** + * Sets the rotation, scaling and drawing origin of this object. + * + * @param v the new origin. + */ + public void setOrigin(Vector2f v); + + /** + * Gets the position of this object. + * + * @return the current position. + */ + public Vector2f getPosition(); + + /** + * Gets the rotation angle of this object. + * + * @return the current rotation angle in degrees. + */ + public float getRotation(); + + /** + * Gets the scaling of this object. + * + * @return the current scaling factors. + */ + public Vector2f getScale(); + + /** + * Gets the origin of this object. + * + * @return the current origin. + */ + public Vector2f getOrigin(); + + /** + * Moves this object. + * + * @param x the X offset added to the current position. + * @param y the Y offset added to the current position. + */ + public void move(float x, float y); + + /** + * Moves the object. + * + * @param v the offset vector added to the current position. + */ + public void move(Vector2f v); + + /** + * Rotates this object around its origin. + * + * @param angle the rotation angle in degrees. + */ + public void rotate(float angle); + + /** + * Scales the object, using its origin as the scaling center. + * + * @param x the X scaling factor. + * @param y the Y scaling factor. + */ + public void scale(float x, float y); + + /** + * Scales the object, using its origin as the scaling center. + * + * @param factors the scaling factors. + */ + public void scale(Vector2f factors); + + /** + * Gets the current transformation matrix. + * + * @return the current transformation. + */ + public Transform getTransform(); + + /** + * Gets the inverse of the current transformation matrix. + * + * @return the inverse of the current transform. + */ + public Transform getInverseTransform(); +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/Vertex.java b/lib/jsfml/src/java/org/jsfml/graphics/Vertex.java new file mode 100644 index 00000000..9c453db9 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/Vertex.java @@ -0,0 +1,73 @@ +package org.jsfml.graphics; + +import org.jsfml.system.Vector2f; + +import java.io.Serializable; + +/** + * Defines a shape point with position, color and texture coordinates information. + */ +public final class Vertex implements Serializable { + private static final long serialVersionUID = -5749297453247575018L; + + /** + * The vertex position. + */ + public final Vector2f position; + + /** + * The vertex color. + */ + public final Color color; + + /** + * The vertex texture coordinates. + *

      + * The unit space this information is measured in depends on the way the respective + * texture will be bound. By the default, the {@link Texture.CoordinateType#NORMALIZED} + * coordinate type is used. + */ + public final Vector2f texCoords; + + /** + * Constructs a new vertex at the specified position with white color. + * + * @param position the vertex' position. + */ + public Vertex(Vector2f position) { + this(position, Color.WHITE, Vector2f.ZERO); + } + + /** + * Constructs a new vertex with the specified position and color. + * + * @param position the vertex' position. + * @param color the vertex' color. + */ + public Vertex(Vector2f position, Color color) { + this(position, color, Vector2f.ZERO); + } + + /** + * Constructs a new vertex with the specified position and texture coordinates, with white color. + * + * @param position the vertex' position. + * @param texCoords the vertex' texture coordinates. + */ + public Vertex(Vector2f position, Vector2f texCoords) { + this(position, Color.WHITE, texCoords); + } + + /** + * Constructs a new vertex with the specified parameters. + * + * @param position the vertex' position. + * @param color the vertex' color. + * @param texCoords the vertex' texture coordinates. + */ + public Vertex(Vector2f position, Color color, Vector2f texCoords) { + this.position = position; + this.color = color; + this.texCoords = texCoords; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/VertexArray.java b/lib/jsfml/src/java/org/jsfml/graphics/VertexArray.java new file mode 100644 index 00000000..a6bac347 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/VertexArray.java @@ -0,0 +1,90 @@ +package org.jsfml.graphics; + +import org.jsfml.system.Vector2f; + +import java.util.ArrayList; + +/** + * Defines a drawable set of one or multiple 2D primitives. + */ +public class VertexArray extends ArrayList implements Drawable { + private static final long serialVersionUID = 4656221909265000727L; + + private PrimitiveType primitiveType; + + /** + * Constructs a new empty vertex array using the {@link PrimitiveType#POINTS} type. + */ + public VertexArray() { + this(PrimitiveType.POINTS); + } + + /** + * Constructs a new empty vertex array. + * + * @param primitiveType The type of primitives drawn by this vertex array. + */ + public VertexArray(PrimitiveType primitiveType) { + super(4); + + this.primitiveType = primitiveType; + } + + /** + * Gets the type of primitives drawn by this vertex array. + * + * @return the type of primitives drawn by this vertex array. + */ + public PrimitiveType getPrimitiveType() { + return primitiveType; + } + + /** + * Sets the type of primitives drawn by this vertex array. + * + * @param primitiveType the type of primitives drawn by this vertex array. + */ + public void setPrimitiveType(PrimitiveType primitiveType) { + this.primitiveType = primitiveType; + } + + /** + * Computes the axis-aligned bounding box of this vertex array. + * + * @return the axis-aligned bounding box of this vertex array. + */ + public FloatRect getBounds() { + if (!isEmpty()) { + Vector2f v = get(0).position; + float left = v.x; + float top = v.y; + float right = v.x; + float bottom = v.y; + + for (int i = 1; i < size(); i++) { + v = get(i).position; + + if (v.x < left) + left = v.x; + else if (v.x > right) + right = v.x; + + if (v.y < top) + top = v.y; + else if (v.y > bottom) + bottom = v.y; + } + + return new FloatRect(left, top, right - left, bottom - top); + } else { + return FloatRect.EMPTY; + } + } + + @Override + public void draw(RenderTarget target, RenderStates states) { + if (!isEmpty()) { + target.draw(toArray(new Vertex[size()]), primitiveType, states); + } + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/View.java b/lib/jsfml/src/java/org/jsfml/graphics/View.java new file mode 100644 index 00000000..83b76909 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/View.java @@ -0,0 +1,264 @@ +package org.jsfml.graphics; + +import org.jsfml.internal.IntercomHelper; +import org.jsfml.internal.SFMLNativeObject; +import org.jsfml.system.Vector2f; + +import java.nio.Buffer; + +/** + * Represents a 2D camera which defines the region of the scene that is visible. + */ +public class View extends SFMLNativeObject implements ConstView { + //Cache + private Vector2f size = new Vector2f(1000, 1000); + private Vector2f center = new Vector2f(500, 500); + private float rotation = 0; + private FloatRect viewport = new FloatRect(0, 0, 1, 1); + + private boolean transformNeedsUpdate = true; + private Transform transformCache = null; + private Transform inverseTransformCache = null; + + /** + * Constructs a new view for the area of (0, 0, 1000, 1000). + */ + public View() { + super(); + } + + @SuppressWarnings("deprecation") + View(long wrap) { + super(wrap); + sync(); + } + + /** + * Constructs a new view for the specified area. + * + * @param rect the area visible by this view. + */ + public View(FloatRect rect) { + this(); + reset(rect); + } + + /** + * Constructs a view for the specified area. + * + * @param center the center of the view. + * @param size the size of the view. + */ + public View(Vector2f center, Vector2f size) { + this(); + setCenter(center); + setSize(size); + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected final native long nativeCreate(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected void nativeSetExPtr() { + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeDelete(); + + private native void nativeSetCenter(float x, float y); + + /** + * Sets the center of the view. + * + * @param x the new X coordinate of the view's center. + * @param y the new Y coordinate of the view's center. + */ + public final void setCenter(float x, float y) { + setCenter(new Vector2f(x, y)); + } + + /** + * Sets the center of the view. + * + * @param v the new center of the view. + */ + public void setCenter(Vector2f v) { + nativeSetCenter(v.x, v.y); + this.center = v; + transformNeedsUpdate = true; + } + + private native void nativeSetSize(float width, float height); + + /** + * Sets the dimensions of the view. + * + * @param width the new width of the view in pixels. + * @param height the new height of the view in pixels. + */ + public void setSize(float width, float height) { + setSize(new Vector2f(width, height)); + } + + /** + * Sets the dimensions of the view. + * + * @param v the new size of the view in pixels. + */ + public void setSize(Vector2f v) { + nativeSetSize(v.x, v.y); + this.size = v; + transformNeedsUpdate = true; + } + + private native void nativeSetRotation(float angle); + + /** + * Sets the rotation of the view around its center. + * + * @param angle the new rotation angle in degrees. + */ + public void setRotation(float angle) { + nativeSetRotation(angle); + this.rotation = angle; + transformNeedsUpdate = true; + } + + private native void nativeSetViewport(Buffer buffer); + + /** + * Sets the viewport rectangle of this view. + *

      + * The viewport defines which portion of the render target is used by this view and is + * expressed using factors between 0 and 1 (percentage of the target's width and height). + *

      + * The default viewport rectangle is (0, 0, 1, 1). + * + * @param rect the new viewport rectangle. + */ + public void setViewport(FloatRect rect) { + nativeSetViewport(IntercomHelper.encodeFloatRect(rect)); + this.viewport = rect; + } + + private native void nativeReset(Buffer buffer); + + /** + * Resets the view to a certain viewport rectangle, resetting the rotation angle in the process. + * + * @param rect the viewport rectangle. + */ + public void reset(FloatRect rect) { + nativeReset(IntercomHelper.encodeFloatRect(rect)); + sync(); + } + + private native void nativeGetViewport(Buffer buffer); + + private native long nativeGetSize(); + + private native long nativeGetCenter(); + + private native float nativeGetRotation(); + + private void sync() { + nativeGetViewport(IntercomHelper.getBuffer()); + this.viewport = IntercomHelper.decodeFloatRect(); + this.size = IntercomHelper.decodeVector2f(nativeGetSize()); + this.center = IntercomHelper.decodeVector2f(nativeGetCenter()); + this.rotation = nativeGetRotation(); + transformNeedsUpdate = true; + } + + @Override + public Vector2f getCenter() { + return center; + } + + @Override + public Vector2f getSize() { + return size; + } + + @Override + public float getRotation() { + return rotation; + } + + @Override + public FloatRect getViewport() { + return viewport; + } + + /** + * Rotates the view around its center. + * + * @param angle the angle to rotate by, in degrees. + */ + public final void rotate(float angle) { + setRotation(rotation + angle); + } + + /** + * Moves the center of the view. + * + * @param x the X offset to move the view's center by. + * @param y the Y offset to move the view's center by. + */ + public final void move(float x, float y) { + setCenter(new Vector2f(center.x + x, center.y + y)); + } + + /** + * Moves the center of the view. + * + * @param v the offset vector to move the view's center by. + */ + public final void move(Vector2f v) { + move(v.x, v.y); + } + + /** + * Resizes the view. + * + * @param factor the zoom factor. + */ + public final void zoom(float factor) { + setSize(size.x * factor, size.y * factor); + } + + private native void nativeGetTransform(Buffer buf); + + private void updateTransform() { + if (transformNeedsUpdate) { + nativeGetTransform(IntercomHelper.getBuffer()); + transformCache = IntercomHelper.decodeTransform(); + inverseTransformCache = transformCache.getInverse(); + transformNeedsUpdate = false; + } + } + + @Override + public Transform getTransform() { + if (transformNeedsUpdate) { + updateTransform(); + } + + return transformCache; + } + + @Override + public Transform getInverseTransform() { + if (transformNeedsUpdate) { + updateTransform(); + } + + return inverseTransformCache; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/graphics/package-info.java b/lib/jsfml/src/java/org/jsfml/graphics/package-info.java new file mode 100644 index 00000000..ff700a22 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/graphics/package-info.java @@ -0,0 +1,5 @@ +/** + * Contains classes related to graphics, representing drawable and transformable objects + * that can be made visible on a render target. + */ +package org.jsfml.graphics; diff --git a/lib/jsfml/src/java/org/jsfml/internal/Const.java b/lib/jsfml/src/java/org/jsfml/internal/Const.java new file mode 100644 index 00000000..1de635b3 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/internal/Const.java @@ -0,0 +1,14 @@ +package org.jsfml.internal; + +/** + * Interface for read-only objects. + *

      + * This interface is JSFML's way to map C++ const references to Java. Subinterfaces will + * be specific to a certain JSFML type and provide methods to read from them only. + *

      + * The subinterfaces may be used freely outside of the JSFML API itself, however, it is not + * recommended to implement them, because in certain cases, they are expected to be implemented + * by a certain JSFML class. + */ +public interface Const { +} diff --git a/lib/jsfml/src/java/org/jsfml/internal/ExPtr.java b/lib/jsfml/src/java/org/jsfml/internal/ExPtr.java new file mode 100644 index 00000000..d37dfc21 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/internal/ExPtr.java @@ -0,0 +1,43 @@ +package org.jsfml.internal; + +/** + * Holds index definitions for the {@link SFMLNativeObject#exPtr} array. + */ +@Intercom +final class ExPtr { + //Total amount of exPtr fields. + @Intercom + static final int NUM = 3; + + //Pointer to sf::Drawable. + @Intercom + static final int DRAWABLE = 0; + + //Pointer to sf::Transformable. + @Intercom + static final int TRANSFORMABLE = 1; + + //Pointer to sf::Shape. + @Intercom + static final int SHAPE = 2; + + //Pointer to sf::RenderTarget. + @Intercom + static final int RENDER_TARGET = 0; + + //Pointer to sf::Window. + @Intercom + static final int WINDOW = 1; + + //Pointer to sf::SoundSource. + @Intercom + static final int SOUND_SOURCE = 0; + + //Pointer to sf::SoundStream. + @Intercom + static final int SOUND_STREAM = 1; + + //Pointer to sf::SoundRecorder. + @Intercom + static final int SOUND_RECORDER = 0; +} diff --git a/lib/jsfml/src/java/org/jsfml/internal/Intercom.java b/lib/jsfml/src/java/org/jsfml/internal/Intercom.java new file mode 100644 index 00000000..92e07867 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/internal/Intercom.java @@ -0,0 +1,15 @@ +package org.jsfml.internal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +/** + * Annotation for intercom-critical types, fields, methods and constructors. + *

      + * This annotation is purely for informational purposes and provides no actual functionality. + * Elements annotated by this annotation must not be refactored without altering + * the respective native (C++) sources. + */ +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR}) +public @interface Intercom { +} diff --git a/lib/jsfml/src/java/org/jsfml/internal/IntercomHelper.java b/lib/jsfml/src/java/org/jsfml/internal/IntercomHelper.java new file mode 100644 index 00000000..b3b9ae88 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/internal/IntercomHelper.java @@ -0,0 +1,201 @@ +package org.jsfml.internal; + +import org.jsfml.graphics.*; +import org.jsfml.system.Vector2f; +import org.jsfml.system.Vector2i; + +import java.nio.*; + +/** + * Provides functionality to encode and decode data structures used + * for intercom methods. + */ +public final class IntercomHelper { + private static final ThreadLocal BUFFER = + new ThreadLocal() { + @Override + protected ByteBuffer initialValue() { + return ByteBuffer.allocateDirect(256).order(ByteOrder.nativeOrder()); + } + }; + + /** + * Gets the current thread-local buffer. + * + * @return the current thread-local buffer. + */ + public static ByteBuffer getBuffer() { + return BUFFER.get(); + } + + /** + * Encodes a color into a 32-bit integer. + * + * @param color the color to encode. + * @return the encoded color. + */ + public static int encodeColor(Color color) { + return (color.a << 24) | (color.b << 16) | (color.g << 8) | color.r; + } + + /** + * Decodes a color from a 32-bit integer. + * + * @param code the encoded color. + * @return the decoded color. + */ + public static Color decodeColor(int code) { + final int a = (code >> 24) & 0xFF; + final int b = (code >> 16) & 0xFF; + final int g = (code >> 8) & 0xFF; + final int r = code & 0xFF; + return new Color(r, g, b, a); + } + + /** + * Encodes an integer vector into a 64-bit integer. + * + * @param vec the vector. + * @return the encoded vector. + */ + public static long encodeVector2i(Vector2i vec) { + long v = ((long) vec.y) << 32; + v |= vec.x; + return v; + } + + /** + * Encodes a float vector into a 64-bit integer. + * + * @param vec the vector. + * @return the encoded vector. + */ + public static long encodeVector2f(Vector2f vec) { + long v = ((long) Float.floatToIntBits(vec.y)) << 32; + v |= Float.floatToIntBits(vec.x); + return v; + } + + /** + * Decodes an integer vector from a 64-bit integer. + * + * @param vec the encoded vector. + * @return the decoded vector. + */ + public static Vector2i decodeVector2i(long vec) { + if (vec == 0) { + return Vector2i.ZERO; + } else { + return new Vector2i((int) vec, (int) (vec >> 32)); + } + } + + /** + * Decodes a float vector from a 64-bit integer. + * + * @param vec the encoded vector. + * @return the decoded vector. + */ + public static Vector2f decodeVector2f(long vec) { + return new Vector2f( + Float.intBitsToFloat((int) vec), + Float.intBitsToFloat((int) (vec >> 32))); + } + + /** + * Decodes an integer rectangle from the current float buffer content. + * + * @return the decoded rectangle. + */ + public static IntRect decodeIntRect() { + final IntBuffer buf = BUFFER.get().asIntBuffer(); + return new IntRect( + buf.get(0), + buf.get(1), + buf.get(2), + buf.get(3)); + } + + /** + * Encodes an integer rectangle into the current integer buffer. + * + * @param r the rectangle to encode. + * @return A reference to the integer buffer. + */ + public static Buffer encodeIntRect(IntRect r) { + final IntBuffer buf = BUFFER.get().asIntBuffer(); + buf.put(0, r.left); + buf.put(1, r.top); + buf.put(2, r.width); + buf.put(3, r.height); + return buf; + } + + /** + * Decodes a float rectangle from the current float buffer content. + * + * @return the decoded rectangle. + */ + public static FloatRect decodeFloatRect() { + final FloatBuffer buf = BUFFER.get().asFloatBuffer(); + return new FloatRect( + buf.get(0), + buf.get(1), + buf.get(2), + buf.get(3)); + } + + /** + * Encodes a float rectangle into the current float buffer. + * + * @param r the float to encode. + * @return A reference to the float buffer. + */ + public static Buffer encodeFloatRect(FloatRect r) { + final FloatBuffer buf = BUFFER.get().asFloatBuffer(); + buf.put(0, r.left); + buf.put(1, r.top); + buf.put(2, r.width); + buf.put(3, r.height); + return buf; + } + + /** + * Decodes a transformation matrix from the current float buffer content. + * + * @return the decoded transformation matrix. + */ + public static Transform decodeTransform() { + final FloatBuffer buf = BUFFER.get().asFloatBuffer(); + return new Transform( + buf.get(0), buf.get(1), buf.get(2), + buf.get(3), buf.get(4), buf.get(5), + buf.get(6), buf.get(7), buf.get(8) + ); + } + + /** + * Encodes a transformation matrix into the current float buffer. + * + * @param xform the transformation matrix to encode. + * @return A reference to the float buffer. + */ + public static Buffer encodeTransform(Transform xform) { + final FloatBuffer buf = BUFFER.get().asFloatBuffer(); + final float[] data = xform.getMatrix(); + + buf.put(0, data[0]); + buf.put(1, data[4]); + buf.put(2, data[12]); + buf.put(3, data[1]); + buf.put(4, data[5]); + buf.put(5, data[13]); + buf.put(6, data[3]); + buf.put(7, data[7]); + buf.put(8, data[15]); + return buf; + } + + private IntercomHelper() { + } +} diff --git a/lib/jsfml/src/java/org/jsfml/internal/JSFMLError.java b/lib/jsfml/src/java/org/jsfml/internal/JSFMLError.java new file mode 100644 index 00000000..5fd66bcc --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/internal/JSFMLError.java @@ -0,0 +1,30 @@ +package org.jsfml.internal; + +/** + * Error class for severe JSFML faults. + *

      + * An error of this type is raised either if JSFML tried to load its native libraries on an unsupported + * platform, or if a platform-specific requirement is violated. + */ +public class JSFMLError extends Error { + private static final long serialVersionUID = -8281004117329430845L; + + /** + * Constructs a JSFML error with the specified message. + * + * @param message the exception's message text. + */ + public JSFMLError(String message) { + super(message); + } + + /** + * Constructs a JSFML error with the specified message and cause. + * + * @param message the exception's message text. + * @param cause the exception's cause, or {@code null} if no cause is known or available. + */ + public JSFMLError(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/lib/jsfml/src/java/org/jsfml/internal/NativeRef.java b/lib/jsfml/src/java/org/jsfml/internal/NativeRef.java new file mode 100644 index 00000000..f14df173 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/internal/NativeRef.java @@ -0,0 +1,78 @@ +package org.jsfml.internal; + +/** + * Helper class for managing Java object references and related native pointers. + * + * @param The type of the related Java object, if any. + */ +@Intercom +public abstract class NativeRef { + private T ref = null; + + @Intercom + private long ptr = 0; + + /** + * Constructs a native reference. + */ + public NativeRef() { + } + + /** + * Initializes a native pointer related to the specified Java object. + * + * @param ref the related Java object, or {@code null} if there is none. + * @return a native pointer, or 0 if none was initialized. + */ + protected abstract long nativeInitialize(T ref); + + /** + * Releases the Java reference, if any, and the managed native pointer, if any. + *

      + * This also is responsible for natively allocated memory being freed. + * + * @param ref the Java object reference, or {@code null} if there is none. + * @param ptr the native pointer, if any. + */ + protected abstract void nativeRelease(T ref, long ptr); + + /** + * Initializes a native reference with the specified Java object. + * + * @param ref the Java object, or {@code null} if none is required. + */ + public void initialize(T ref) { + release(); + + this.ref = ref; + this.ptr = nativeInitialize(ref); + } + + /** + * Releases the managed Java reference, if any, and frees the managed native pointer, + * if any, including freeing any natively allocated memory. + */ + public void release() { + if (ptr != 0) { + nativeRelease(ref, ptr); + ptr = 0; + } + + ref = null; + } + + /** + * Tests whether this reference has a non-zero native pointer. + * + * @return {@code true} if the pointer is non-zero, {@code false} if it is {@code NULL}. + */ + public boolean hasNonZeroPointer() { + return (ptr != 0); + } + + @Override + protected void finalize() throws Throwable { + release(); + super.finalize(); + } +} diff --git a/lib/jsfml/src/java/org/jsfml/internal/SFMLErrorCapture.java b/lib/jsfml/src/java/org/jsfml/internal/SFMLErrorCapture.java new file mode 100644 index 00000000..5ae4bd73 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/internal/SFMLErrorCapture.java @@ -0,0 +1,58 @@ +package org.jsfml.internal; + +import java.util.concurrent.Semaphore; + +/** + * Provides methods to capture output to {@code sf::err()}. + */ +public class SFMLErrorCapture { + private static boolean capturing = false; + private final static Semaphore semaphore = new Semaphore(1); + + private static native void nativeStart(); + + /** + * Starts capturing all output to {@code sf::err()}. + *

      + * This method acquires a semaphore and will block if a capture is currently going, + * therefore the capturing is thread-safe. + *

      + * A capture must be concluded by calling the {@link #finish()} method. + */ + public static void start() { + try { + semaphore.acquire(); + capturing = true; + + nativeStart(); + } catch (InterruptedException ex) { + ex.printStackTrace(); + } + } + + private static native String nativeFinish(); + + /** + * Finishes capturing all output to {@code sf::err()} and returns what was captured. + * + * @return the output that was captured, or {@code null} if capturing was never started using + * {@link #start()}. + */ + public static String finish() { + final String str; + if (capturing) { + str = nativeFinish().trim(); + + capturing = false; + semaphore.release(); + } else { + str = null; + } + + return str; + } + + private SFMLErrorCapture() { + //cannot instantiate + } +} diff --git a/lib/jsfml/src/java/org/jsfml/internal/SFMLInputStream.java b/lib/jsfml/src/java/org/jsfml/internal/SFMLInputStream.java new file mode 100644 index 00000000..4d7d4f97 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/internal/SFMLInputStream.java @@ -0,0 +1,106 @@ +package org.jsfml.internal; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; +import java.util.Objects; + +/** + * Pipe for enabling stream from a Java {@link InputStream} into a {@code sf::InputStream}. + */ +public class SFMLInputStream { + /** + * Native pointer manager for an {@code SFMLInputStream} bound + * natively to an {@code sf::InputStream}. + */ + public static class NativeStreamRef extends NativeRef { + @Override + protected native long nativeInitialize(SFMLInputStream ref); + + @Override + protected native void nativeRelease(SFMLInputStream ref, long ptr); + } + + private final InputStream stream; + private long pos; + + public SFMLInputStream(InputStream stream) { + Objects.requireNonNull(stream); + + if (stream.markSupported()) { + this.stream = stream; + } else { + this.stream = new BufferedInputStream(stream); + } + + //Mark the current position as zero + this.stream.mark(Integer.MAX_VALUE); + pos = 0; + } + + //As defined in sf::InputStream. + long read(ByteBuffer buffer, long n) { + try { + byte[] b = new byte[buffer.capacity()]; + long num = (long) stream.read(b); + if (num == -1) { + return 0; + } else { + buffer.put(b); + } + + pos += num; + return num; + } catch (IOException ex) { + pos = -1; + return 0; + } + } + + //As defined in sf::InputStream. + long seek(long n) { + try { + if (n > pos) { + long skipped = stream.skip(n - pos); + pos += skipped; + } else { + stream.reset(); + pos = 0; + + if (n > 0) { + pos = stream.skip(n); + } + } + + return (pos == n) ? pos : -1; + } catch (IOException ex) { + pos = -1; + return -1; + } + } + + //As defined in sf::InputStream. + long tell() { + return pos; + } + + //As defined in sf::InputStream. + long getSize() { + try { + long n = (long) stream.available(); + return n; + } catch (IOException ex) { + return -1; + } + } + + //Called by the destructor. + void close() { + try { + stream.close(); + } catch (IOException ex) { + // + } + } +} diff --git a/lib/jsfml/src/java/org/jsfml/internal/SFMLNative.java b/lib/jsfml/src/java/org/jsfml/internal/SFMLNative.java new file mode 100644 index 00000000..51f852e6 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/internal/SFMLNative.java @@ -0,0 +1,227 @@ +package org.jsfml.internal; + +import java.awt.*; +import java.io.*; +import java.nio.file.FileAlreadyExistsException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.LinkedList; + +/** + * Native library loader. + *

      + * This class contains the "self-containedness" functionality of JSFML. + * + * @see #loadNativeLibraries() for more information. + */ +public final class SFMLNative { + private static final Path JSFML_USER_HOME = Paths.get(System.getProperty("user.home"), ".jsfml"); + + private static final String JSFML_BIN_RESOURCE_PATH = "/bin/"; + + private static final String MD5_EXT = ".MD5"; + private static final int MD5_LENGTH = 32; + + /** + * The substring of the {@code os.name} system property + * to look for to detect Windows systems. + */ + public static final String OS_NAME_WINDOWS = "Windows"; + + /** + * The substring of the {@code os.name} system property + * to look for to detect Linux systems. + */ + public static final String OS_NAME_LINUX = "Linux"; + + /** + * The substring of the {@code os.name} system property + * to look for to detect Mac OS X systems. + */ + public static final String OS_NAME_MACOSX = "Mac OS X"; + + private static native void nativeInit(); + + private static boolean loaded = false; + + private static String readMD5File(InputStream in) throws IOException { + byte[] buffer = new byte[MD5_LENGTH]; + int n = in.read(buffer); + + if (n != MD5_LENGTH) + throw new IOException("Error reading MD5 file."); + + return new String(buffer); + } + + private static String readMD5File(Path path) throws IOException { + try (final InputStream fis = Files.newInputStream(path)) { + return readMD5File(fis); + } + } + + /** + * Loads the native JSFML libraries if it has not been done yet. + *

      + * This must be done before any SFML class representations can be used. All affected classes + * will call this method when they are loaded, so this does not have to be done manually. + *

      + * This method will scan the {@code os.name} and {@code os.arch} system properties and + * compile a list of libraries to load if the platform is supported. The libraries will + * then be looked for in the classpath, extracted to the user directory and loaded. + *

      + * The libraries will be extracted to {@code ~/.jsfml}. If the files already exist, their MD5 + * hashes (which are provided in separate files) will be tested against the ones in the + * classpath. If the MD5 hashes differ, the existing file in the user directory will + * be overridden. + *

      + * If loading the native libraries fails, a {@link JSFMLError} will be raised with + * a brief description of what went wrong. + */ + public static void loadNativeLibraries() { + if (!loaded) { + loaded = true; + + //Get operating system information + final String osName = System.getProperty("os.name"); + final String osArch = System.getProperty("os.arch"); + + String arch = null; + + final LinkedList nativeLibs = new LinkedList<>(); + + if (osName.contains(OS_NAME_WINDOWS)) { + switch (osArch) { + case "x86": + arch = "windows_x86"; + break; + + case "amd64": + arch = "windows_x64"; + break; + } + + nativeLibs.add("libsndfile-1.dll"); + nativeLibs.add("openal32.dll"); + nativeLibs.add("sfml-system-2.dll"); + nativeLibs.add("sfml-window-2.dll"); + nativeLibs.add("sfml-audio-2.dll"); + nativeLibs.add("sfml-graphics-2.dll"); + nativeLibs.add("jsfml.dll"); + } else if (osName.contains(OS_NAME_LINUX)) { + switch (osArch) { + case "x86": + case "i386": + arch = "linux_x86"; + break; + + case "amd64": + arch = "linux_x64"; + break; + } + + nativeLibs.add("libsfml-system.so"); + nativeLibs.add("libsfml-window.so"); + nativeLibs.add("libsfml-graphics.so"); + nativeLibs.add("libsfml-audio.so"); + nativeLibs.add("libjsfml.so"); + } else if (osName.contains(OS_NAME_MACOSX)) { + arch = "macosx_universal"; + + nativeLibs.add("libfreetype.dylib"); + nativeLibs.add("libsndfile.dylib"); + nativeLibs.add("libsfml-system.dylib"); + nativeLibs.add("libsfml-window.dylib"); + nativeLibs.add("libsfml-graphics.dylib"); + nativeLibs.add("libsfml-audio.dylib"); + nativeLibs.add("libjsfml.jnilib"); + } + + //Check if the current platform is supported + if (arch == null) { + throw new JSFMLError("Unsupported platform: " + osName + " " + osArch); + } + + //Extract native libraries + final String nativeResourcePath = JSFML_BIN_RESOURCE_PATH + arch + "/"; + final Path nativeLibPath = JSFML_USER_HOME.resolve(arch); + + try { + Files.createDirectories(nativeLibPath); + } catch (FileAlreadyExistsException ex) { + //nevermind + } catch (IOException ex) { + throw new JSFMLError("Failed to create native library directory: " + + nativeLibPath.toString(), ex); + } + + for (String lib : nativeLibs) { + final Path libFile = nativeLibPath.resolve(lib); + + //Check MD5 hash, don't extract if not necessary + boolean md5Equal = false; + + final String md5FileName = lib + MD5_EXT; + + try (final InputStream md5InputStream = + SFMLNative.class.getResourceAsStream(nativeResourcePath + md5FileName)) { + + final String md5Jar = readMD5File(md5InputStream); + final Path md5File = nativeLibPath.resolve(md5FileName); + + if (Files.isRegularFile(libFile) && Files.isRegularFile(md5File)) { + md5Equal = readMD5File(md5File).equals(md5Jar); + } + + if (!md5Equal) { + try (final OutputStream out = Files.newOutputStream(md5File)) { + out.write(md5Jar.getBytes()); + } catch (IOException ex) { + ex.printStackTrace(); //write to stderr + } + } + } catch (IOException ex) { + ex.printStackTrace(); //write to stderr + } + + if (!md5Equal) { + try (final InputStream in = SFMLNative.class.getResourceAsStream( + nativeResourcePath + lib)) { + + if (in != null) { + StreamUtil.streamToFile(in, libFile); + } else { + throw new JSFMLError( + "Could not find native library in the classpath: " + nativeResourcePath + lib); + } + } catch (IOException ex) { + throw new JSFMLError( + "Failed to extract native library: " + libFile.toString(), ex); + } + } else { + //MD5 hashes are equal, no need to extract + } + } + + //On Linux, add SFML's default install path as a fallback + for (String lib : nativeLibs) { + System.load(nativeLibPath.resolve(lib).toAbsolutePath().toString()); + } + + //Initialize + nativeInit(); + } + } + + /** + * Ensures that a display is available on this system. + *

      + * If that is not the case, a {@link HeadlessException} is thrown to indicate that the desired + * JSFML feature is not available. + */ + public static void ensureDisplay() { + if (GraphicsEnvironment.isHeadless()) + throw new HeadlessException("This JSFML feature is not available in a headless environment"); + } +} diff --git a/lib/jsfml/src/java/org/jsfml/internal/SFMLNativeObject.java b/lib/jsfml/src/java/org/jsfml/internal/SFMLNativeObject.java new file mode 100644 index 00000000..149bb6eb --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/internal/SFMLNativeObject.java @@ -0,0 +1,129 @@ +package org.jsfml.internal; + +import java.nio.ByteBuffer; +import java.nio.LongBuffer; + +/** + * Abstract base class for classes bound to SFML C++ objects. + *

      + * This class serves as a communication interface between native SFML objects and their Java + * representations by linking the Java object to the object's native pointer. + *

      + * There should be no reason whatsoever to use this class outside of + * JSFML itself. + */ +@Intercom +public abstract class SFMLNativeObject { + /** + * Pointer to the underlying SFML object. + */ + @Intercom + private long ptr = 0; + + /** + * "Extra Pointers". + *

      + * These are pointers dynamically cast to abstract supertypes of the same SFML object. + *

      + * Holding these is necessary, because all the C++ type information gets lost in the + * process of storing a pointer in a Java long field. When casting them back + * to SFML object pointers, the correct virtual table offset has to be used + * for calls to methods of abstract types. + */ + @Intercom + private final LongBuffer exPtr = + ByteBuffer.allocateDirect(ExPtr.NUM << 3).asLongBuffer(); + + /** + * If this is {@code true}, the underlying object is merely "wrapped" and not + * "managed" by JSFML. + *

      + * If an object is managed by JSFML, it will be deleted using the delete + * operator when the Java object is finalized. Wrapped objects are expected + * to be cleaned up by SFML and will simply be abandoned upon finalization. + */ + private boolean wrapped; + + /** + * Constructs a JSFML native object by invoking the {@link #nativeCreate()} + * method and retrieving a pointer to the SFML object in the JVM heap. + */ + @SuppressWarnings("deprecation") + protected SFMLNativeObject() { + SFMLNative.loadNativeLibraries(); + + ptr = nativeCreate(); + + if (ptr == 0) + throw new JSFMLError("nativeCreate() yielded a NULL pointer: " + this); + + nativeSetExPtr(); + + wrapped = false; + } + + /** + * Wraps an JSFML native object around an already existing native SFML object. + * + * @param wrap the pointer to the native SFML object in the JNI heap. + * @deprecated Use of this constructor may cause undefined behaviour and is not supported. + */ + @Deprecated + @SuppressWarnings("deprecation") + protected SFMLNativeObject(long wrap) { + SFMLNative.loadNativeLibraries(); + + if (wrap == 0) + throw new JSFMLError("Tried to wrap around a NULL pointer: " + this); + + ptr = wrap; + nativeSetExPtr(); + + wrapped = true; + } + + final void setJavaManaged(boolean javaManaged) { + wrapped = !javaManaged; + } + + /** + * Creates a new native SFML object of the represented SFML class in the JVM memory heap. + * + * @return the pointer to the newly created native SFML object. + * @deprecated Use of this method may cause undefined behaviour and is not supported. + */ + @Deprecated + protected abstract long nativeCreate(); + + /** + * This method is expected to fill the extra pointers array, if any. + *

      + * It is called after the object has been created or wrapped around an already + * existing pointer. + * + * @deprecated Use of this method may cause undefined behaviour and is not supported. + */ + @Deprecated + protected abstract void nativeSetExPtr(); + + /** + * Deletes the underlying SFML object. + * + * @deprecated Use of this method may cause undefined behaviour and is not supported. + */ + @Deprecated + protected abstract void nativeDelete(); + + @Override + @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + if (!wrapped && ptr != 0) + nativeDelete(); + + ptr = 0; + for (int i = 0; i < ExPtr.NUM; i++) + exPtr.put(i, 0); + + super.finalize(); + } +} diff --git a/lib/jsfml/src/java/org/jsfml/internal/StreamUtil.java b/lib/jsfml/src/java/org/jsfml/internal/StreamUtil.java new file mode 100644 index 00000000..208a0b3d --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/internal/StreamUtil.java @@ -0,0 +1,65 @@ +package org.jsfml.internal; + +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Path; + +/** + * Provides stream utility functions used by JSFML-internal file reading and writing methods. + */ +public class StreamUtil { + private final static int BUFFER_SIZE = 16384; + + /** + * Fully reads an input stream into a byte array. + *

      + * This method does not close the stream when done. + * + * @param inputStream the input stream to read. + * @return the bytes read from the stream. + * @throws IOException if an error occurs in the process. + */ + public static byte[] readStream(InputStream inputStream) throws IOException { + byte[] buffer = new byte[BUFFER_SIZE]; + ByteArrayOutputStream out = new ByteArrayOutputStream(BUFFER_SIZE); + + for (int n = inputStream.read(buffer); n > 0; n = inputStream.read(buffer)) + out.write(buffer, 0, n); + + return out.toByteArray(); + } + + /** + * Fully reads a file into a byte array. + * + * @param path the path to the file to read. + * @return the bytes read from the file. + * @throws IOException if an error occurs in the process. + */ + public static byte[] readFile(Path path) throws IOException { + try (final InputStream in = Files.newInputStream(path)) { + return readStream(in); + } + } + + /** + * Fully streams an input stream into a file. + *

      + * This method does not close the stream when done. + * + * @param inputStream the input stream to read. + * @param path the file to write to. + * @throws IOException if an error occurs in the process. + */ + public static void streamToFile(InputStream inputStream, Path path) throws IOException { + if (inputStream == null) + throw new IOException("The input stream is null"); + + final byte[] buffer = new byte[BUFFER_SIZE]; + try (final OutputStream out = Files.newOutputStream(path)) { + for (int n = inputStream.read(buffer); n > 0; n = inputStream.read(buffer)) { + out.write(buffer, 0, n); + } + } + } +} diff --git a/lib/jsfml/src/java/org/jsfml/internal/UnsafeOperations.java b/lib/jsfml/src/java/org/jsfml/internal/UnsafeOperations.java new file mode 100644 index 00000000..6ccd5c26 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/internal/UnsafeOperations.java @@ -0,0 +1,30 @@ +package org.jsfml.internal; + +/** + * Provides inherently unsafe operations on native SFML objects. + *

      + * These need to be public in order to maintain JSFML's package structure, but should by no means + * used outside of JSFML. + */ +public final class UnsafeOperations { + /** + * Flags an SFML object as Java managed or unmanaged. Java managed objects will be destroyed using the + * {@link SFMLNativeObject#nativeDelete()} method when this object gets finalized. + *

      + * This is used for JSFML to differentiate between explicitly self-constructed SFML objects + * (using {@code new}) and SFML objects that are managed by other SFML objects, but require + * a Java representation. + *

      + * Wrong use of this method will make the application prone to crashes and memory leaks, + * so handle with extreme care. + * + * @param object The SFML object wrapper. + * @param managed Whether or not this object is managed by JSFML. + */ + public static void manageSFMLObject(SFMLNativeObject object, boolean managed) { + object.setJavaManaged(managed); + } + + private UnsafeOperations() { + } +} diff --git a/lib/jsfml/src/java/org/jsfml/internal/package-info.java b/lib/jsfml/src/java/org/jsfml/internal/package-info.java new file mode 100644 index 00000000..bfe21980 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/internal/package-info.java @@ -0,0 +1,4 @@ +/** + * Contains classes, interfaces and annotations meant for internal use only. + */ +package org.jsfml.internal; diff --git a/lib/jsfml/src/java/org/jsfml/system/Clock.java b/lib/jsfml/src/java/org/jsfml/system/Clock.java new file mode 100644 index 00000000..7991db17 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/system/Clock.java @@ -0,0 +1,36 @@ +package org.jsfml.system; + +/** + * Provides functionality for time measurement. + */ +public class Clock { + private long t0; + + /** + * Constructs a clock and starts it. + */ + public Clock() { + t0 = System.nanoTime(); + } + + /** + * Gets the elapsed time since the clock was created or last restarted. + * + * @return the elapsed time since the clock was created or last restarted. + */ + public Time getElapsedTime() { + long dt = System.nanoTime() - t0; + return Time.getMicroseconds(dt / 1000L); + } + + /** + * Yields the elapsed time and restarts the clock. + * + * @return the elapsed time since the clock was created or last restarted. + */ + public final Time restart() { + Time dt = getElapsedTime(); + t0 = System.nanoTime(); + return dt; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/system/Time.java b/lib/jsfml/src/java/org/jsfml/system/Time.java new file mode 100644 index 00000000..949eb603 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/system/Time.java @@ -0,0 +1,156 @@ +package org.jsfml.system; + +import java.io.Serializable; + +/** + * Represents a time period and provides functionality to convert between + * various time units, as well as arithmetic operations on time intervals. + */ +public final strictfp class Time implements Comparable

      + * The fractions of the coordinates will be zero. + * + * @param v the vector to convert. + */ + public Vector2f(Vector2i v) { + this((float) v.x, (float) v.y); + } + + @Override + public boolean equals(Object o) { + return (o instanceof Vector2f && ((Vector2f) o).x == x && ((Vector2f) o).y == y); + } + + @Override + public int hashCode() { + int result = (x != +0.0f ? Float.floatToIntBits(x) : 0); + result = 31 * result + (y != +0.0f ? Float.floatToIntBits(y) : 0); + return result; + } + + @Override + public String toString() { + return "Vector2f{" + + "x=" + x + + ", y=" + y + + '}'; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/system/Vector2i.java b/lib/jsfml/src/java/org/jsfml/system/Vector2i.java new file mode 100644 index 00000000..a835604b --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/system/Vector2i.java @@ -0,0 +1,145 @@ +package org.jsfml.system; + +import java.io.Serializable; + +/** + * Represents two-dimensional vectors using integer coordinates and provides + * arithmetic operations on integral 2D vectors. + */ +public final class Vector2i implements Serializable { + private static final long serialVersionUID = 4059550337913883695L; + + /** + * The zero vector. + */ + public static final Vector2i ZERO = new Vector2i(0, 0); + + /** + * Adds two vectors. + * + * @param a the first vector. + * @param b the second vector. + * @return a new vector, representing the sum of the two vectors. + */ + public static Vector2i add(Vector2i a, Vector2i b) { + return new Vector2i(a.x + b.x, a.y + b.y); + } + + /** + * Subtracts two vectors. + * + * @param a The first vector. + * @param b The second vector. + * @return a new vector, representing the difference between the two vectors. + */ + public static Vector2i sub(Vector2i a, Vector2i b) { + return new Vector2i(a.x - b.x, a.y - b.y); + } + + + /** + * Performs a component-wise multiplication of two vectors. + * + * @param a the left vector. + * @param b the right vector. + * @return a new vector, representing the "product" of the two vectors. + */ + public static Vector2i componentwiseMul(Vector2i a, Vector2i b) { + return new Vector2i(a.x * b.x, a.y * b.y); + } + + /** + * Performs a component-wise division of two vectors. + * + * @param a the left vector. + * @param b the right vector. + * @return a new vector, representing the "quotient" of the two vectors. + */ + public static Vector2i componentwiseDiv(Vector2i a, Vector2i b) { + return new Vector2i(a.x / b.x, a.y / b.y); + } + + /** + * Multiplies a vector by a scalar. + * + * @param a the vector. + * @param s the scalar. + * @return a new vector, representing the scaled vector. + */ + public static Vector2i mul(Vector2i a, int s) { + return new Vector2i(a.x * s, a.y * s); + } + + /** + * Multiplies a vector by the inverse of a scalar. + * + * @param a the vector. + * @param s the scalar to multiply by. + * @return a new vector, representing the scaled vector. + */ + public static Vector2i div(Vector2i a, int s) { + return new Vector2i(a.x / s, a.y / s); + } + + /** + * Computes the negation of a vector. + * + * @param v the vector. + * @return a new vector, representing the negation of the given vector. + */ + public static Vector2i neg(Vector2i v) { + return new Vector2i(-v.x, -v.y); + } + + /** + * The vector's X coordinate. + */ + public final int x; + + /** + * The vector's Y coordinate. + */ + public final int y; + + /** + * Constructs a new vector with the given coordinates. + * + * @param x the X coordinate. + * @param y the Y coordinate. + */ + public Vector2i(int x, int y) { + this.x = x; + this.y = y; + } + + /** + * Constructs a new vector by converting a floating point vector. + *

      + * The fractions of the coordinates will be cut off. + * + * @param v the vector to convert. + */ + public Vector2i(Vector2f v) { + this((int) v.x, (int) v.y); + } + + @Override + public boolean equals(Object o) { + return (o instanceof Vector2i && ((Vector2i) o).x == x && ((Vector2i) o).y == y); + } + + @Override + public int hashCode() { + int result = (x != +0.0f ? Float.floatToIntBits(x) : 0); + result = 31 * result + (y != +0.0f ? Float.floatToIntBits(y) : 0); + return result; + } + + @Override + public String toString() { + return "Vector2i{" + + "x=" + x + + ", y=" + y + + '}'; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/system/Vector3f.java b/lib/jsfml/src/java/org/jsfml/system/Vector3f.java new file mode 100644 index 00000000..4bd8ab88 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/system/Vector3f.java @@ -0,0 +1,172 @@ +package org.jsfml.system; + +import java.io.Serializable; + +/** + * Represents three-dimensional vectors using floating point coordinates and provides + * arithmetic operations on floating point 3D vectors. + */ +public final strictfp class Vector3f implements Serializable { + private static final long serialVersionUID = -2176250005619169432L; + + /** + * The zero vector. + */ + public static final Vector3f ZERO = new Vector3f(0, 0, 0); + + /** + * Adds two vectors. + * + * @param a the first vector. + * @param b the second vector. + * @return a new vector, representing the sum of the two vectors. + */ + public static Vector3f add(Vector3f a, Vector3f b) { + return new Vector3f( + a.x + b.x, + a.y + b.y, + a.z + b.z); + } + + /** + * Subtracts two vectors. + * + * @param a the first vector. + * @param b the second vector. + * @return a new vector, representing the difference between the two vectors. + */ + public static Vector3f sub(Vector3f a, Vector3f b) { + return new Vector3f( + a.x - b.x, + a.y - b.y, + a.z - b.z); + } + + /** + * Performs a component-wise multiplication of two vectors. + * + * @param a the first vector. + * @param b the second vector. + * @return a new vector, representing the "product" of the two vectors. + */ + public static Vector3f componentwiseMul(Vector3f a, Vector3f b) { + return new Vector3f( + a.x * b.x, + a.y * b.y, + a.z * b.z); + } + + /** + * Performs a component-wise division of two vectors. + * + * @param a the first vector. + * @param b the second vector. + * @return a new vector, representing the "quotient" of the two vectors. + */ + public static Vector3f componentwiseDiv(Vector3f a, Vector3f b) { + return new Vector3f( + a.x / b.x, + a.y / b.y, + a.z / b.z); + } + + /** + * Multiplies a vector by a scalar. + * + * @param a the vector. + * @param s the scalar to multiply by. + * @return a new vector, representing the scaled vector. + */ + public static Vector3f mul(Vector3f a, float s) { + return new Vector3f( + a.x * s, + a.y * s, + a.z * s); + } + + /** + * Multiplies a vector by the inverse of a scalar. + * + * @param a the vector. + * @param s the scalar to divide by. + * @return a new vector, representing the scaled vector. + */ + public static Vector3f div(Vector3f a, float s) { + return new Vector3f( + a.x / s, + a.y / s, + a.z / s); + } + + /** + * Computes the negation of a vector. + * + * @param v the vector. + * @return a new vector, representing the negation of the given vector. + */ + public static Vector3f neg(Vector3f v) { + return new Vector3f(-v.x, -v.y, -v.z); + } + + /** + * The vector's X coordinate. + */ + public final float x; + + /** + * The vector's Y coordinate. + */ + public final float y; + + /** + * The vector's Z coordinate. + */ + public final float z; + + /** + * Constructs a new vector with the given coordinates. + * + * @param x the X coordinate. + * @param y the Y coordinate. + * @param z the Z coordinate. + */ + public Vector3f(float x, float y, float z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** + * Constructs a new vector by converting an integral vector. + *

      + * The fractions of the coordinates will be zero. + * + * @param v the vector to convert. + */ + public Vector3f(Vector3i v) { + this((float) v.x, (float) v.y, (float) v.z); + } + + @Override + public boolean equals(Object o) { + return (o instanceof Vector3f && + ((Vector3f) o).x == x && ((Vector3f) o).y == y && ((Vector3f) o).z == z); + } + + @Override + public int hashCode() { + int result = (x != +0.0f ? Float.floatToIntBits(x) : 0); + result = 31 * result + (y != +0.0f ? Float.floatToIntBits(y) : 0); + result = 31 * result + (z != +0.0f ? Float.floatToIntBits(z) : 0); + return result; + } + + @Override + public String toString() { + return "Vector3f{" + + "x=" + x + + ", y=" + y + + ", z=" + z + + '}'; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/system/Vector3i.java b/lib/jsfml/src/java/org/jsfml/system/Vector3i.java new file mode 100644 index 00000000..667be312 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/system/Vector3i.java @@ -0,0 +1,172 @@ +package org.jsfml.system; + +import java.io.Serializable; + +/** + * Represents three-dimensional vectors using integer coordinates and provides + * arithmetic operations on integral 3D vectors. + */ +public final class Vector3i implements Serializable { + private static final long serialVersionUID = -2260992069088589367L; + + /** + * The zero vector. + */ + public static final Vector3i ZERO = new Vector3i(0, 0, 0); + + /** + * Adds two vectors. + * + * @param a the first vector. + * @param b the second vector. + * @return a new vector, representing the sum of the two vectors. + */ + public static Vector3i add(Vector3i a, Vector3i b) { + return new Vector3i( + a.x + b.x, + a.y + b.y, + a.z + b.z); + } + + /** + * Subtracts two vectors. + * + * @param a the first vector. + * @param b the second vector. + * @return a new vector, representing the difference between the two vectors. + */ + public static Vector3i sub(Vector3i a, Vector3i b) { + return new Vector3i( + a.x - b.x, + a.y - b.y, + a.z - b.z); + } + + /** + * Performs a component-wise multiplication of two vectors. + * + * @param a the first vector. + * @param b the second vector. + * @return a new vector, representing the "product" of the two vectors. + */ + public static Vector3i componentwiseMul(Vector3i a, Vector3i b) { + return new Vector3i( + a.x * b.x, + a.y * b.y, + a.z * b.z); + } + + /** + * Performs a component-wise division of two vectors. + * + * @param a the first vector. + * @param b the second vector. + * @return a new vector, representing the "quotient" of the two vectors. + */ + public static Vector3i componentwiseDiv(Vector3i a, Vector3i b) { + return new Vector3i( + a.x / b.x, + a.y / b.y, + a.z / b.z); + } + + /** + * Multiplies a vector by a scalar. + * + * @param a the vector. + * @param s the scalar to multiply by. + * @return a new vector, representing the scaled vector. + */ + public static Vector3i mul(Vector3i a, int s) { + return new Vector3i( + a.x * s, + a.y * s, + a.z * s); + } + + /** + * Performs an integer division on each component of the vector by a scalar. + * + * @param a the vector. + * @param s the scalar. + * @return a new vector, representing the scaled vector. + */ + public static Vector3i div(Vector3i a, int s) { + return new Vector3i( + a.x / s, + a.y / s, + a.z / s); + } + + /** + * Computes the negation of a vector. + * + * @param v the vector. + * @return a new vector, representing the negation of the given vector. + */ + public static Vector3i neg(Vector3i v) { + return new Vector3i(-v.x, -v.y, -v.z); + } + + /** + * The vector's X coordinate. + */ + public final int x; + + /** + * The vector's Y coordinate. + */ + public final int y; + + /** + * The vector's Z coordinate. + */ + public final int z; + + /** + * Constructs a new vector with the given coordinates. + * + * @param x the X coordinate. + * @param y the Y coordinate. + * @param z the Z coordinate. + */ + public Vector3i(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** + * Constructs a new vector by converting a floating point vector. + *

      + * The fractions of the coordinates will be cut off. + * + * @param v the vector to convert. + */ + public Vector3i(Vector3f v) { + this((int) v.x, (int) v.y, (int) v.z); + } + + @Override + public boolean equals(Object o) { + return (o instanceof Vector3f && + ((Vector3f) o).x == x && ((Vector3f) o).y == y && ((Vector3f) o).z == z); + } + + @Override + public int hashCode() { + int result = x; + result = 31 * result + y; + result = 31 * result + z; + return result; + } + + @Override + public String toString() { + return "Vector3f{" + + "x=" + x + + ", y=" + y + + ", z=" + z + + '}'; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/system/package-info.java b/lib/jsfml/src/java/org/jsfml/system/package-info.java new file mode 100644 index 00000000..fce1e449 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/system/package-info.java @@ -0,0 +1,4 @@ +/** + * Contains classes that provide core functionality and common data types. + */ +package org.jsfml.system; diff --git a/lib/jsfml/src/java/org/jsfml/window/Context.java b/lib/jsfml/src/java/org/jsfml/window/Context.java new file mode 100644 index 00000000..9d65f039 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/window/Context.java @@ -0,0 +1,76 @@ +package org.jsfml.window; + +import org.jsfml.internal.SFMLNative; +import org.jsfml.internal.SFMLNativeObject; + +/** + * Holds a valid OpenGL drawing context. + *

      + * For every OpenGL call, a valid context is required. Using this class, by creating + * an instance, you can obtain a valid context. + *

      + * This is only required if you do not have an active window that provides an OpenGL context. + */ +public final class Context extends SFMLNativeObject { + private static final ThreadLocal threadContext = new ThreadLocal<>(); + + /** + * Creates and activates a valid OpenGL context on the current thread. + *

      + * If there already is a context in the current thread, + * it will simply be activated. + * + * @return the activated OpenGL context. + */ + public static Context getContext() { + Context context = threadContext.get(); + if (context != null) { + try { + context.setActive(true); + } catch (ContextActivationException ex) { + // + } + } else { + context = new Context(); + threadContext.set(context); + } + + return context; + } + + private Context() { + SFMLNative.ensureDisplay(); + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native long nativeCreate(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected void nativeSetExPtr() { + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeDelete(); + + private native boolean nativeSetActive(boolean active); + + /** + * Explictly activates or deactivates the OpenGL context. + * + * @param active {@code true} to activate, {@code false} to deactivate. + * @throws ContextActivationException if activating or deactivating the context failed. + */ + public void setActive(boolean active) throws ContextActivationException { + if (!nativeSetActive(active)) { + throw new ContextActivationException("Failed to " + + (active ? "activate" : "deactivate") + + " the context."); + } + } +} diff --git a/lib/jsfml/src/java/org/jsfml/window/ContextActivationException.java b/lib/jsfml/src/java/org/jsfml/window/ContextActivationException.java new file mode 100644 index 00000000..36838a05 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/window/ContextActivationException.java @@ -0,0 +1,18 @@ +package org.jsfml.window; + +/** + * Thrown when activating or deactivating an OpenGL fails + * using {@link Context#setActive(boolean)} or {@link Window#setActive(boolean)}. + */ +public final class ContextActivationException extends Exception { + private static final long serialVersionUID = -9207950728636532244L; + + /** + * Constructs a context activation exception with the specified message. + * + * @param message the detail message. + */ + public ContextActivationException(String message) { + super(message); + } +} diff --git a/lib/jsfml/src/java/org/jsfml/window/ContextSettings.java b/lib/jsfml/src/java/org/jsfml/window/ContextSettings.java new file mode 100644 index 00000000..cf768af5 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/window/ContextSettings.java @@ -0,0 +1,136 @@ +package org.jsfml.window; + +import java.io.Serializable; + +/** + * Holds the settings for an OpenGL context attached to a window. + *

      + * Unless you need anti-aliasing for primitives or require your window to hold an OpenGL context + * for a specific OpenGL version (e.g. for custom OpenGL rendering), you will most likely not + * need this. + *

      + * All settings provided by this class are handled as hints to the created OpenGL context. If a + * feature is not supported by the hardware, the respective setting will be ignored and a supported + * default is used instead. + */ +public final class ContextSettings implements Serializable { + private static final long serialVersionUID = -3658200233541780345L; + + /** + * The amount of depth buffer bits. + */ + public final int depthBits; + + /** + * The amount of stencil buffer bits. + */ + public final int stencilBits; + + /** + * The level of anti-aliasing. + */ + public final int antialiasingLevel; + + /** + * The desired major OpenGL version number. + */ + public final int majorVersion; + + /** + * The desired minor OpenGL version number. + */ + public final int minorVersion; + + /** + * Constructs new context settings with default values (OpenGL 2.0, no depth or stencil bits, + * no anti-aliasing). + */ + public ContextSettings() { + this(0, 0, 0, 2, 0); + } + + /** + * Constructs new context settings with the specified level of anti-aliasing and OpenGL 2.0, + * no depth or stencil bits. + * + * @param antialiasingLevel the level of anti-aliasing. + */ + public ContextSettings(int antialiasingLevel) { + this(0, 0, antialiasingLevel, 2, 0); + } + + /** + * Constructs new context settings with the specified OpenGL version, no depth or stencil + * bits and no anti-aliasing. + * + * @param majorVersion the desired major OpenGL version number. + * @param minorVersion the desired minor OpenGL version number. + */ + public ContextSettings(int majorVersion, int minorVersion) { + this(0, 0, 0, majorVersion, minorVersion); + } + + /** + * Constructs new context settings with the specified OpenGL version and anti-aliasing level and + * no depth or stencil bits. + * + * @param antialiasingLevel the level of anti-aliasing. + * @param majorVersion the desired major OpenGL version number. + * @param minorVersion the desired minor OpenGL version number. + */ + public ContextSettings(int antialiasingLevel, int majorVersion, int minorVersion) { + this(0, 0, antialiasingLevel, majorVersion, minorVersion); + } + + /** + * Constructs new context settings. + * + * @param depthBits the amount of depth buffer bits. + * @param stencilBits the amount of stencil buffer bits. + * @param antialiasingLevel the level of anti-aliasing. + * @param majorVersion the desired major OpenGL version number. + * @param minorVersion the desired minor OpenGL version number. + */ + public ContextSettings(int depthBits, int stencilBits, int antialiasingLevel, int majorVersion, int minorVersion) { + this.depthBits = depthBits; + this.stencilBits = stencilBits; + this.antialiasingLevel = antialiasingLevel; + this.majorVersion = majorVersion; + this.minorVersion = minorVersion; + } + + @Override + public boolean equals(Object o) { + if (o instanceof ContextSettings) { + ContextSettings c = (ContextSettings) o; + return (c.antialiasingLevel == antialiasingLevel && + c.depthBits == depthBits && + c.majorVersion == majorVersion && + c.minorVersion == minorVersion && + c.stencilBits == stencilBits); + } else { + return false; + } + } + + @Override + public int hashCode() { + int result = depthBits; + result = 31 * result + stencilBits; + result = 31 * result + antialiasingLevel; + result = 31 * result + majorVersion; + result = 31 * result + minorVersion; + return result; + } + + @Override + public String toString() { + return "ContextSettings{" + + "depthBits=" + depthBits + + ", stencilBits=" + stencilBits + + ", antialiasingLevel=" + antialiasingLevel + + ", majorVersion=" + majorVersion + + ", minorVersion=" + minorVersion + + '}'; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/window/Joystick.java b/lib/jsfml/src/java/org/jsfml/window/Joystick.java new file mode 100644 index 00000000..52f8ede4 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/window/Joystick.java @@ -0,0 +1,190 @@ +package org.jsfml.window; + +import org.jsfml.internal.SFMLNative; + +/** + * Provides access to the the real-time states of joysticks and gamepads. + *

      + * The methods in this class provide direct access to the joystick state, that means + * that they work independently of a window's focus. In order to react to window + * based events, use the {@link org.jsfml.window.Window#pollEvents()} method instead. + */ +public final class Joystick { + static { + SFMLNative.loadNativeLibraries(); + } + + /** + * The maximum amount of supported joysticks and gamepads. + *

      + * Joystick identifiers are guaranteed to be smaller than this value. + */ + public static final int JOYSTICK_COUNT = 8; + + /** + * The maximum amount of supported joystick and gamepad buttons. + *

      + * Joystick button indices are guaranteed to be smaller than this value. + */ + public static final int BUTTON_COUNT = 32; + + /** + * Enumeration of supported joystick and gamepad axes. + *

      + * The axes in this enumeration are named after common standards. Their + * representation on a joystick or gamepad may be specific to it. Generally, + * the earlier an axis appears in this enumeration, the more likely it is + * supported by a joystick or gamepad. + */ + public static enum Axis { + /** + * The X axis. + */ + X, + + /** + * The Y axis. + */ + Y, + + /** + * The Z axis. + */ + Z, + + /** + * The R axis. + */ + R, + + /** + * The U axis. + */ + U, + + /** + * The V axis. + */ + V, + + /** + * The X axis on the point-of-view hat. + */ + POV_X, + + /** + * The Y axis on the point-of-view hat. + */ + POV_Y + } + + private static native boolean nativeIsConnected(int joystick); + + /** + * Checks if a joystick or gamepad is currently connected. + * + * @param joystick the index of the joystick to check. + * This value must range between 0 (inclusive) and + * {@code #JOYSTICK_COUNT} (exclusive). + * @return {@code true} if the joystick or gamepad is currently connected, + * {@code false} otherwise. + */ + public static boolean isConnected(int joystick) { + if (joystick < 0 || joystick >= JOYSTICK_COUNT) + throw new IllegalArgumentException("joystick must be between 0 and " + JOYSTICK_COUNT); + + return nativeIsConnected(joystick); + } + + private static native int nativeGetButtonCount(int joystick); + + /** + * Retrieves the amount of buttons of a joystick or gamepad. + * + * @param joystick the index of the joystick in question. + * This value must range between 0 (inclusive) and + * {@code #JOYSTICK_COUNT} (exclusive). + * @return the amount of buttons of the joystick. + */ + public static int getButtonCount(int joystick) { + if (joystick < 0 || joystick >= JOYSTICK_COUNT) + throw new IllegalArgumentException("joystick must be between 0 and " + JOYSTICK_COUNT); + + return nativeGetButtonCount(joystick); + } + + private static native boolean nativeHasAxis(int joystick, int axis); + + /** + * Checks whether a joystick or gamepad supports the specified axis. + * + * @param joystick the index of the joystick in question. + * This value must range between 0 (inclusive) and + * {@code #JOYSTICK_COUNT} (exclusive). + * @param axis the axis to look for. + * @return {@code true} if the joystick or gamepad supports the given axis, + * {@code false} otherwise. + */ + public static boolean hasAxis(int joystick, Axis axis) { + if (joystick < 0 || joystick >= JOYSTICK_COUNT) + throw new IllegalArgumentException("joystick must be between 0 and " + JOYSTICK_COUNT); + + return nativeHasAxis(joystick, axis.ordinal()); + } + + private static native boolean nativeIsButtonPressed(int joystick, int button); + + /** + * Checks whether the specified button is currently pressed on a joystick or gamepad. + * + * @param joystick the index of the joystick in question. + * This value must range between 0 (inclusive) and + * {@code #JOYSTICK_COUNT} (exclusive). + * @param button the index of the button to check. + * This value must range between 0 (inclusive) and + * {@code #BUTTON_COUNT} (exclusive). + * @return {@code true} if the button is currently pressed on the joystick or gamepad, + * {@code false} otherwise. + */ + public static boolean isButtonPressed(int joystick, int button) { + if (joystick < 0 || joystick >= JOYSTICK_COUNT) + throw new IllegalArgumentException("joystick must be between 0 and " + JOYSTICK_COUNT); + + if (button < 0 || button >= BUTTON_COUNT) + throw new IllegalArgumentException("button must be between 0 and " + BUTTON_COUNT); + + return nativeIsButtonPressed(joystick, button); + } + + private static native float nativeGetAxisPosition(int joystick, int axis); + + /** + * Retrieves the current position of the specified axis of a joystick or gamepad. + * + * @param joystick the index of the joystick in question. + * This value must range between 0 (inclusive) and + * {@code #JOYSTICK_COUNT} (exclusive). + * @param axis the axis in question. + * @return a floating point number ranging between -100 and 100, + * denoting the current position of the axis. If the joystick or gamepad is + * not connected or does not support the specified axis, 0 is returned. + */ + public static float getAxisPosition(int joystick, Axis axis) { + if (joystick < 0 || joystick >= JOYSTICK_COUNT) + throw new IllegalArgumentException("joystick must be between 0 and " + JOYSTICK_COUNT); + + return nativeGetAxisPosition(joystick, axis.ordinal()); + } + + /** + * Forces an update of the states of all joysticks and gamepads. + *

      + * This method is only required if the joystick state needs to be known before a window has been + * created. Once there is a window, the states will be automatically updated in regular periods. + */ + public static native void update(); + + //cannot instantiate + private Joystick() { + } +} diff --git a/lib/jsfml/src/java/org/jsfml/window/Keyboard.java b/lib/jsfml/src/java/org/jsfml/window/Keyboard.java new file mode 100644 index 00000000..b1160f23 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/window/Keyboard.java @@ -0,0 +1,579 @@ +package org.jsfml.window; + +import org.jsfml.internal.SFMLNative; + +/** + * Provides access to the the real-time state of the keyboard. + *

      + * The methods in this class provide direct access to the keyboard state, that means + * that they work independently of a window's focus. In order to react to window + * based events, use the {@link org.jsfml.window.Window#pollEvents()} method instead. + */ +public final class Keyboard { + static { + SFMLNative.loadNativeLibraries(); + } + + /** + * Enumeration of supported keys. + *

      + * The keys in this enumeration are named after the standard QWERTY + * keyboard layout. Their locations and labels may vary on different keyboard + * layouts, even though the scan codes, and therefore their representation + * in this enumeration, are the same. + *

      + * There may be some non-standard keys on certain keyboards that are + * mapped to unknown scan codes. Those special keys will be represented + * by {@link Key#UNKNOWN}. + */ + public static enum Key { + /** + * A keyboard specific key which maps to an unknown scan code. + */ + UNKNOWN, + /** + * The {@code A} key. + */ + A, + + /** + * The {@code B} key. + */ + B, + + /** + * The {@code C} key. + */ + C, + + /** + * The {@code D} key. + */ + D, + + /** + * The {@code E} key. + */ + E, + + /** + * The {@code F} key. + */ + F, + + /** + * The {@code G} key. + */ + G, + + /** + * The {@code H} key. + */ + H, + + /** + * The {@code I} key. + */ + I, + + /** + * The {@code J} key. + */ + J, + + /** + * The {@code K} key. + */ + K, + + /** + * The {@code L} key. + */ + L, + + /** + * The {@code M} key. + */ + M, + + /** + * The {@code N} key. + */ + N, + + /** + * The {@code O} key. + */ + O, + + /** + * The {@code P} key. + */ + P, + + /** + * The {@code Q} key. + */ + Q, + + /** + * The {@code R} key. + */ + R, + + /** + * The {@code S} key. + */ + S, + + /** + * The {@code T} key. + */ + T, + + /** + * The {@code U} key. + */ + U, + + /** + * The {@code V} key. + */ + V, + + /** + * The {@code W} key. + */ + W, + + /** + * The {@code X} key. + */ + X, + + /** + * The {@code Y} key. + */ + Y, + + /** + * The {@code Z} key. + */ + Z, + + /** + * The {@code 0} key. + * For the {@code 0} key on the numeric keypad, see {@link #NUMPAD0}. + */ + NUM0, + + /** + * The {@code 1} key. + * For the {@code 1} key on the numeric keypad, see {@link #NUMPAD1}. + */ + NUM1, + + /** + * The {@code 2} key. + * For the {@code 2} key on the numeric keypad, see {@link #NUMPAD2}. + */ + NUM2, + + /** + * The {@code 3} key. + * For the {@code 3} key on the numeric keypad, see {@link #NUMPAD3}. + */ + NUM3, + + /** + * The {@code 4} key. + * For the {@code 4} key on the numeric keypad, see {@link #NUMPAD4}. + */ + NUM4, + + /** + * The {@code 5} key. + * For the {@code 5} key on the numeric keypad, see {@link #NUMPAD5}. + */ + NUM5, + + /** + * The {@code 6} key. + * For the {@code 6} key on the numeric keypad, see {@link #NUMPAD6}. + */ + NUM6, + + /** + * The {@code 7} key. + * For the {@code 7} key on the numeric keypad, see {@link #NUMPAD7}. + */ + NUM7, + + /** + * The {@code 8} key. + * For the {@code 8} key on the numeric keypad, see {@link #NUMPAD8}. + */ + NUM8, + + /** + * The {@code 9} key. + * For the {@code 9} key on the numeric keypad, see {@link #NUMPAD9}. + */ + NUM9, + + /** + * The escape key. + */ + ESCAPE, + + /** + * The left Ctrl key. + */ + LCONTROL, + + /** + * The left Shift key. + */ + LSHIFT, + + /** + * The left Alt key. + */ + LALT, + + /** + * The left system key. + * This is commonly known as the Windows logo key or the Apple key. + */ + LSYSTEM, + + /** + * The right Ctrl key. + */ + RCONTROL, + + /** + * The right Shift key. + */ + RSHIFT, + + /** + * The right Alt key. + */ + RALT, + + /** + * The right system key. + * This is commonly known as the Windows logo key or the Apple key. + */ + RSYSTEM, + + /** + * The menu key. + */ + MENU, + + /** + * The {@code [} key. + */ + LBRACKET, + + /** + * The {@code ]} key. + */ + RBRACKET, + + /** + * The {@code ;} key. + */ + SEMICOLON, + + /** + * The {@code ,} key. + */ + COMMA, + + /** + * {@code .} key. + */ + PERIOD, + + /** + * The {@code '} key. + */ + QUOTE, + + /** + * The {@code /} key. + */ + SLASH, + + /** + * The {@code \} key. + */ + BACKSLASH, + + /** + * The {@code ~} key. + */ + TILDE, + + /** + * The {@code =} key. + */ + EQUAL, + + /** + * The {@code -} key. + */ + DASH, + + /** + * The Space key. + */ + SPACE, + + /** + * The Return key or the Enter key on the numeric keypad. + * Both keys send the same scancode and can therefore not be distinguished. + */ + RETURN, + + /** + * The Backspace key. + */ + BACKSPACE, + + /** + * The Tab key. + */ + TAB, + + /** + * The Page up key. + */ + PAGEUP, + + /** + * The Page down key. + */ + PAGEDOWN, + + /** + * The End key. + */ + END, + + /** + * The Home key. + */ + HOME, + + /** + * The Insert key. + */ + INSERT, + + /** + * The Delete key. + */ + DELETE, + + /** + * The {@code +} (addition) key on the numeric keypad. + */ + ADD, + + /** + * The {@code -} (subtraction) key on the numeric keypad. + */ + SUBTRACT, + + /** + * The {@code *} (multiplication) key on the numeric keypad. + */ + MULTIPLY, + + /** + * The {@code /} (division) key on the numeric keypad. + */ + DIVIDE, + + /** + * The left arrow key. + */ + LEFT, + + /** + * The right arrow key. + */ + RIGHT, + + /** + * The up arrow key. + */ + UP, + + /** + * The down arrow key. + */ + DOWN, + + /** + * The {@code 0} key on the numeric keypad. + * For the regular {@code 0} key, see {@link #NUM0}. + */ + NUMPAD0, + + /** + * The {@code 1} key on the numeric keypad. + * For the regular {@code 1} key, see {@link #NUM1}. + */ + NUMPAD1, + + /** + * The {@code 2} key on the numeric keypad. + * For the regular {@code 2} key, see {@link #NUM2}. + */ + NUMPAD2, + + /** + * The {@code 3} key on the numeric keypad. + * For the regular {@code 3} key, see {@link #NUM3}. + */ + NUMPAD3, + + /** + * The {@code 4} key on the numeric keypad. + * For the regular {@code 4} key, see {@link #NUM4}. + */ + NUMPAD4, + + /** + * The {@code 5} key on the numeric keypad. + * For the regular {@code 5} key, see {@link #NUM5}. + */ + NUMPAD5, + + /** + * The {@code 6} key on the numeric keypad. + * For the regular {@code 6} key, see {@link #NUM6}. + */ + NUMPAD6, + + /** + * The {@code 7} key on the numeric keypad. + * For the regular {@code 7} key, see {@link #NUM7}. + */ + NUMPAD7, + + /** + * The {@code 8} key on the numeric keypad. + * For the regular {@code 8} key, see {@link #NUM8}. + */ + NUMPAD8, + + /** + * The {@code 9} key on the numeric keypad. + * For the regular {@code 9} key, see {@link #NUM9}. + */ + NUMPAD9, + + /** + * The {@code F1} key. + */ + F1, + + /** + * The {@code F2} key. + */ + F2, + + /** + * The {@code F3} key. + */ + F3, + + /** + * The {@code F4} key. + */ + F4, + + /** + * The {@code F5} key. + */ + F5, + + /** + * The {@code F6} key. + */ + F6, + + /** + * The {@code F7} key. + */ + F7, + + /** + * The {@code F8} key. + */ + F8, + + /** + * The {@code F9} key. + */ + F9, + + /** + * The {@code F10} key. + */ + F10, + + /** + * The {@code F11} key. + */ + F11, + + /** + * The {@code F12} key. + */ + F12, + + /** + * The {@code F13} key, where available. + */ + F13, + + /** + * The {@code F14} key, where available. + */ + F14, + + /** + * The {@code F15} key, where available. + */ + F15, + + /** + * The Pause key. + */ + PAUSE + } + + private static native boolean nativeIsKeyPressed(int key); + + /** + * Checks if a certain key is currently pressed on the keyboard. + * + * @param key the key in question. + * @return {@code true} if the key is currently being pressed, + * {@code false} otherwise. + */ + public static boolean isKeyPressed(Key key) { + return nativeIsKeyPressed(key.ordinal() - 1); + } + + //cannot instantiate + private Keyboard() { + } +} diff --git a/lib/jsfml/src/java/org/jsfml/window/Mouse.java b/lib/jsfml/src/java/org/jsfml/window/Mouse.java new file mode 100644 index 00000000..76494c0c --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/window/Mouse.java @@ -0,0 +1,117 @@ +package org.jsfml.window; + +import org.jsfml.internal.IntercomHelper; +import org.jsfml.internal.SFMLNative; +import org.jsfml.system.Vector2i; + +import java.util.Objects; + +/** + * Provides access to the the real-time state of the mouse. + *

      + * The methods in this class provide direct access to the mouse state, that means + * that they work independently of a window's focus. In order to react to window + * based events, use the {@link org.jsfml.window.Window#pollEvents()} method instead. + */ +public final class Mouse { + static { + SFMLNative.loadNativeLibraries(); + } + + /** + * Enumeration of supported mouse buttons. + */ + public static enum Button { + /** + * The left mouse button. + */ + LEFT, + + /** + * The right mouse button. + */ + RIGHT, + + /** + * The middle mouse button, or mouse wheel on many mouses, if available. + */ + MIDDLE, + + /** + * The first extra mouse button, if available. + */ + XBUTTON1, + + /** + * The second extra mouse button, if available. + */ + XBUTTON2, + } + + private static native boolean nativeIsButtonPressed(int button); + + /** + * Checks if a mouse button is currently pressed. + * + * @param button the mouse button in question. + * @return {@code true} if the button is currently being pressed, + * {@code false} otherwise. + */ + public static boolean isButtonPressed(Button button) { + return nativeIsButtonPressed(button.ordinal()); + } + + private static native long nativeGetPosition(); + + /** + * Retrieves the absolute position of the mouse cursor on the screen. + * + * @return the absolute position of the mouse cursor on the screen. + */ + public static Vector2i getPosition() { + return IntercomHelper.decodeVector2i(nativeGetPosition()); + } + + private static native long nativeGetPosition(Window relativeTo); + + /** + * Retrieves the position of the mouse cursor relative to a window. + * + * @param relativeTo the window in question. + * @return the position of the mouse cursor relative to the window's top left corner. + */ + public static Vector2i getPosition(Window relativeTo) { + return IntercomHelper.decodeVector2i( + nativeGetPosition(Objects.requireNonNull(relativeTo))); + } + + private static native void nativeSetPosition(long position); + + /** + * Sets the absolute position of the mouse cursor on the screen. + * + * @param position the new absolute position of the mouse cursor on the screen. + */ + public static void setPosition(Vector2i position) { + nativeSetPosition(IntercomHelper.encodeVector2i(position)); + } + + private static native void nativeSetPosition(long position, Window relativeTo); + + /** + * Sets the position of the mouse cursor relative to a window. + * + * @param position the new position of the mouse cursor relative + * to the window's top left corner. + * @param relativeTo the window in question. + */ + public static void setPosition(Vector2i position, Window relativeTo) { + nativeSetPosition( + IntercomHelper.encodeVector2i(position), + Objects.requireNonNull(relativeTo)); + } + + //cannot instantiate + private Mouse() { + } +} diff --git a/lib/jsfml/src/java/org/jsfml/window/VideoMode.java b/lib/jsfml/src/java/org/jsfml/window/VideoMode.java new file mode 100644 index 00000000..02013400 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/window/VideoMode.java @@ -0,0 +1,163 @@ +package org.jsfml.window; + +import org.jsfml.internal.Intercom; +import org.jsfml.internal.IntercomHelper; +import org.jsfml.internal.SFMLNative; + +import java.io.Serializable; +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.IntBuffer; +import java.util.HashSet; +import java.util.Set; + +/** + * Represents a video mode (width, height and bits per pixel). + *

      + * It defines the width, height and pixel depth of a window and must be + * supported by the monitor hardware in order to be used in fullscreen. + * + * @see Window#create(VideoMode, String, int) + */ +public final class VideoMode implements Serializable { + private static final long serialVersionUID = 8608938390916786270L; + + //cache + private static VideoMode desktopMode = null; + private static Set fullscreenModes = null; + + static { + SFMLNative.loadNativeLibraries(); + } + + private static native void nativeGetDesktopMode(Buffer buffer); + + /** + * Retrieves the desktop's current video mode / screen resolution. + * + * @return the desktop's current video mode. + */ + public static VideoMode getDesktopMode() { + if (desktopMode == null) { + final IntBuffer buffer = IntercomHelper.getBuffer().asIntBuffer(); + nativeGetDesktopMode(buffer); + desktopMode = new VideoMode(buffer.get(0), buffer.get(1), buffer.get(2)); + } + + return desktopMode; + } + + private static native int nativeGetFullscreenModeCount(); + + private static native void nativeGetFullscreenModes(Buffer buffer); + + private static Set getFullscreenModeSet() { + if (fullscreenModes == null) { + final int num = nativeGetFullscreenModeCount(); + final IntBuffer buffer = ByteBuffer.allocateDirect(12 * num).order( + ByteOrder.nativeOrder()).asIntBuffer(); + + nativeGetFullscreenModes(buffer); + + fullscreenModes = new HashSet<>(num); + for (int i = 0; i < num; i++) { + fullscreenModes.add(new VideoMode( + buffer.get(3 * i), + buffer.get(3 * i + 1), + buffer.get(3 * i + 2))); + } + } + + return fullscreenModes; + } + + /** + * Retrieves the list of supported fullscreen video modes. + * + * @return the list of supported fullscreen video modes. + */ + public static VideoMode[] getFullscreenModes() { + final Set modes = getFullscreenModeSet(); + return modes.toArray(new VideoMode[modes.size()]); + } + + /** + * The width of the video mode, in pixels. + */ + public final int width; + + /** + * The height of the video mode, in pixels. + */ + public final int height; + + /** + * The pixel depth, in bits per pixel, of the video mode. + */ + public final int bitsPerPixel; + + /** + * Constructs a new video mode. + * + * @param width the width, in pixels. + * @param height the height, in pixels. + * @param bitsPerPixel the pixel depth, in bits per pixel. + */ + @Intercom + public VideoMode(int width, int height, int bitsPerPixel) { + this.width = width; + this.height = height; + this.bitsPerPixel = bitsPerPixel; + } + + /** + * Constructs a new video mode with a pixel depth of 32 bits per pixel. + * + * @param width the width, in pixels. + * @param height the height, in pixels. + */ + public VideoMode(int width, int height) { + this(width, height, 32); + } + + /** + * Checks whether this display mode is a valid fullscreen mode, ie whether + * the current monitor supports it for fullscreen. + * + * @return {@code true} if this video mode is a valid fullscreen mode, + * {@code false} otherwise. + */ + public boolean isValid() { + return getFullscreenModeSet().contains(this); + } + + @Override + public boolean equals(Object o) { + if (o instanceof VideoMode) { + VideoMode v = (VideoMode) o; + return (v.width == width && + v.height == height && + v.bitsPerPixel == bitsPerPixel); + } else { + return false; + } + } + + @Override + public int hashCode() { + int result = width; + result = 31 * result + height; + result = 31 * result + bitsPerPixel; + return result; + } + + @Override + public String toString() { + return "VideoMode{" + + "width=" + width + + ", height=" + height + + ", bitsPerPixel=" + bitsPerPixel + + '}'; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/window/Window.java b/lib/jsfml/src/java/org/jsfml/window/Window.java new file mode 100644 index 00000000..11f62ba5 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/window/Window.java @@ -0,0 +1,548 @@ +package org.jsfml.window; + +import org.jsfml.graphics.Image; +import org.jsfml.internal.IntercomHelper; +import org.jsfml.internal.JSFMLError; +import org.jsfml.internal.SFMLNative; +import org.jsfml.internal.SFMLNativeObject; +import org.jsfml.system.Vector2i; +import org.jsfml.window.event.*; + +import java.nio.Buffer; +import java.nio.IntBuffer; +import java.util.Iterator; +import java.util.Objects; + +/** + * A basic window that provides an OpenGL context. + *

      + * This class implements the {@code WindowStyle} interface for quick access + * to the constants provided by it. + */ +public class Window extends SFMLNativeObject implements WindowStyle { + private static Event decodeEvent(IntBuffer ints) { + final Event e; + final int typeId = ints.get(0); + if (typeId >= 0) { + final Event.Type type = Event.Type.values()[typeId]; + switch (type) { + case CLOSED: + case GAINED_FOCUS: + case LOST_FOCUS: + e = new Event(typeId); + break; + + case RESIZED: + e = new SizeEvent(typeId, ints.get(1), ints.get(2)); + break; + + case TEXT_ENTERED: + e = new TextEvent(typeId, ints.get(1)); + break; + + case KEY_PRESSED: + case KEY_RELEASED: + final int keyCode = ints.get(1); + final int flags = ints.get(2); + e = new KeyEvent(typeId, keyCode, + (flags & 0x01) != 0, + (flags & 0x02) != 0, + (flags & 0x04) != 0, + (flags & 0x08) != 0); + + break; + + case MOUSE_WHEEL_MOVED: + e = new MouseWheelEvent(typeId, ints.get(1), ints.get(2), ints.get(3)); + break; + + case MOUSE_BUTTON_PRESSED: + case MOUSE_BUTTON_RELEASED: + e = new MouseButtonEvent(typeId, ints.get(1), ints.get(2), ints.get(3)); + break; + + case MOUSE_MOVED: + case MOUSE_LEFT: + case MOUSE_ENTERED: + e = new MouseEvent(typeId, ints.get(1), ints.get(2)); + break; + + case JOYSTICK_BUTTON_PRESSED: + case JOYSTICK_BUTTON_RELEASED: + e = new JoystickButtonEvent(typeId, ints.get(1), ints.get(2)); + break; + + case JOYSTICK_MOVED: + e = new JoystickMoveEvent(typeId, ints.get(1), ints.get(2), + Float.intBitsToFloat(ints.get(3))); + break; + + case JOYSTICK_CONNECETED: + case JOYSTICK_DISCONNECTED: + e = new JoystickEvent(typeId, ints.get(1)); + break; + + default: + e = null; + break; + } + } else { + e = null; + } + + return e; + } + + /** + * The current window icon image. + *

      + * A reference to it must be maintained in order to assure that the image will not be + * garbage-collected. + */ + private Image icon = null; + + /** + * Constructs a new window without actually creating it (making it visible). + * + * @see Window#create(org.jsfml.window.VideoMode, String, int, org.jsfml.window.ContextSettings) + */ + public Window() { + super(); + SFMLNative.ensureDisplay(); + } + + /** + * Constructs a new window within the specified parent window. + * + * @param ptr the window handle of the parent window. + * @deprecated Use of this method may cause undefined behaviour and is not supported. + */ + @Deprecated + @SuppressWarnings("deprecation") + protected Window(long ptr) { + super(ptr); + } + + /** + * Constructs a new window and creates it with the specified settings. + * + * @param mode the window's video mode. + * @param title the window title. + * @param style the window style. + * @param settings the settings for the OpenGL context. + * @see #create(VideoMode, String, int, ContextSettings) + */ + public Window(VideoMode mode, String title, int style, ContextSettings settings) { + this(); + create(mode, title, style, settings); + } + + /** + * Constructs a new window and creates it with the specified settings and default + * context settings.. + * + * @param mode the window's video mode. + * @param title the window title. + * @param style the window style. + */ + public Window(VideoMode mode, String title, int style) { + this(); + create(mode, title, style, new ContextSettings()); + } + + /** + * Constructs a new window and creates it with the specified settings and default + * context settings and window style. + * + * @param mode the window's video mode. + * @param title the window title. + */ + public Window(VideoMode mode, String title) { + this(); + create(mode, title, WindowStyle.DEFAULT, new ContextSettings()); + } + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native long nativeCreate(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeSetExPtr(); + + @Override + @Deprecated + @SuppressWarnings("deprecation") + protected native void nativeDelete(); + + private native void nativeCreateWindow(Buffer buffer, String title); + + /** + * Checks whether the current native thread is eligibile for creating a window. + *

      + * This will always be the case on Windows or Linux, but on Mac OS X, it will check whether + * the JVM was started in the main thread using the {@code -XstartOnFirstThread} command + * line parameter. + * + * @return {@code true} if the current native thread may create a window, + * {@code false} otherwise. + */ + public static native boolean isLegalWindowThread(); + + /** + * Creates and opens a window or re-creates it if it was already opened. + * + * @param mode the video mode that determines the window's size. + * This must be a valid video mode in case {@link WindowStyle#FULLSCREEN} is set. + * @param title the window title. + * @param style the style of the window. + * This should be a combination (using {@code OR} of the style flags + * {@link WindowStyle#TITLEBAR}, {@link WindowStyle#RESIZE}, {@link WindowStyle#CLOSE} and + * {@link WindowStyle#FULLSCREEN}, or {@link WindowStyle#NONE} for no style. + * {@link WindowStyle#DEFAULT} provides a default combination of style flags. + * @param settings the context settings for the created OpenGL context. + * @see org.jsfml.window.VideoMode#isValid() + * @see WindowStyle + * @see ContextSettings + */ + public void create(VideoMode mode, String title, int style, ContextSettings settings) { + if (!isLegalWindowThread()) { + throw new JSFMLError("This thread is not allowed to create a window on this system. " + + "If you are running on Mac OS X, you MUST run your " + + "application with the -XstartOnFirstThread command line argument!"); + } + + if ((style & FULLSCREEN) != 0 && !mode.isValid()) + throw new IllegalArgumentException("Invalid video mode for a fullscreen window."); + + title = Objects.requireNonNull(title); + + final IntBuffer params = IntercomHelper.getBuffer().asIntBuffer(); + params.put(0, mode.width); + params.put(1, mode.height); + params.put(2, mode.bitsPerPixel); + params.put(3, style); + params.put(4, settings.depthBits); + params.put(5, settings.stencilBits); + params.put(6, settings.antialiasingLevel); + params.put(7, settings.majorVersion); + params.put(8, settings.minorVersion); + nativeCreateWindow(params, title); + } + + /** + * Creates and opens a window or re-creates it if it was already opened. + * The default context settings will be used for the OpenGL context. + * + * @param mode the video mode that determines the window's size. + * This must be a valid video mode in case {@link WindowStyle#FULLSCREEN} is set. + * @param title the window title. + * @param style the style of the window. + * This should be a combination (using {@code OR} of the style flags + * {@link WindowStyle#TITLEBAR}, {@link WindowStyle#RESIZE}, {@link WindowStyle#CLOSE} and + * {@link WindowStyle#FULLSCREEN}, or {@link WindowStyle#NONE} for no style. + * {@link WindowStyle#DEFAULT} provides a default combination of style flags. + * @see org.jsfml.window.VideoMode#isValid() + * @see WindowStyle + */ + public final void create(VideoMode mode, String title, int style) { + create(mode, title, style, new ContextSettings()); + } + + /** + * Creates and opens a window or re-creates it if it was already opened. + * The {@link WindowStyle#DEFAULT} window style will be applied and default + * context settings will be used for the OpenGL context. + * + * @param mode the video mode that determines the window's size. + * @param title the window title. + */ + public final void create(VideoMode mode, String title) { + create(mode, title, DEFAULT, new ContextSettings()); + } + + /** + * Closes the window and destroys all attached resources, + * including the OpenGL context provided by it. + */ + public native void close(); + + /** + * Checks if the window has been created and is opened. + *

      + * Note that the open state is not directly affected by the user clicking + * the window's close button, if available. In order to accomplish that, + * listen to an event of type {@link org.jsfml.window.event.Event.Type#CLOSED} and use + * the {@link #close()} method. + * + * @return {@code true} if the window has been created and is currently open. + */ + public native boolean isOpen(); + + private native long nativeGetPosition(); + + /** + * Gets the absolute position of the window's top left corner on the screen. + * + * @return the absolute position of the window's top left corner on the screen. + */ + public Vector2i getPosition() { + return IntercomHelper.decodeVector2i(nativeGetPosition()); + } + + private native void nativeSetPosition(int x, int y); + + /** + * Sets the absolute position of the window's top left corner on the screen. + * + * @param position the new absolute position of the window's top left corner on the screen. + */ + public void setPosition(Vector2i position) { + nativeSetPosition(position.x, position.y); + } + + private native long nativeGetSize(); + + /** + * Gets the size of the window. + * + * @return the size of the window. + */ + public Vector2i getSize() { + return IntercomHelper.decodeVector2i(nativeGetSize()); + } + + private native void nativeSetSize(int x, int y); + + /** + * Sets the size of the window. + * + * @param size the new size of the window. + */ + public void setSize(Vector2i size) { + nativeSetPosition(size.x, size.y); + } + + private native void nativeGetSettings(Buffer buffer); + + /** + * Retrieves the context settings for the window's OpenGL context. + * + * @return the context settings for the window's OpenGL context. + */ + public ContextSettings getSettings() { + final IntBuffer settings = IntercomHelper.getBuffer().asIntBuffer(); + nativeGetSettings(settings); + + return new ContextSettings( + settings.get(0), + settings.get(1), + settings.get(2), + settings.get(3), + settings.get(4)); + } + + private native void nativePollEvent(Buffer buffer); + + /** + * Pops the event on top of the event stack, if any, and returns it. + *

      + * This method needs to be called regularly in order to process pending events. If this is + * not done, the window will be unresponsive. + * + * @return the event currently on top of the event stack, or {@code null} if there is none. + * @see #waitEvent() + */ + public Event pollEvent() { + final IntBuffer buffer = IntercomHelper.getBuffer().asIntBuffer(); + nativePollEvent(buffer); + return decodeEvent(buffer); + } + + private native void nativeWaitEvent(Buffer buffer); + + /** + * Pops the event on top of the event stack and returns it, or, if there is none, + * waits until an event occurs and then returns it. + *

      + * This method will block the program flow until an event is returned. + * + * @return the event currently on top of the event stack, or the next event that will occur. + * @see #pollEvent() + */ + public Event waitEvent() { + final IntBuffer buffer = IntercomHelper.getBuffer().asIntBuffer(); + nativeWaitEvent(buffer); + return decodeEvent(buffer); + } + + /** + * Returns an {@link Iterable} that consecutively calls {@link #pollEvent()} and + * can be used to process all pending events. + * + * @return an {@code Iterable} over all pending events. + * @see #pollEvent() + */ + public Iterable pollEvents() { + return new Iterable() { + @Override + public Iterator iterator() { + return new Iterator() { + private Event nextEvent = pollEvent(); + + @Override + public boolean hasNext() { + return (nextEvent != null); + } + + @Override + public Event next() { + Event currentEvent = nextEvent; + nextEvent = pollEvent(); + return currentEvent; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } + }; + } + + /** + * Enables or disables vertical synchronization (VSync). + *

      + * Activating vertical synchronization will limit the number of frames displayed + * to the refresh rate of the monitor. This can avoid some visual artifacts, + * and limit the framerate to a good value (but not constant across different computers). + *

      + * This should not be used in combination with {@link #setFramerateLimit(int)}, + * as these two will conflict with one another. + *

      + * By default, vertical synchronization is disabled. + * + * @param enable {@code true} to enable vertical synchronization, {@code false} to disable. + */ + public native void setVerticalSyncEnabled(boolean enable); + + /** + * Determines whether the mouse cursor, if moved over the window, is visible or not. + * + * @param show {@code true} to make the cursor visible, {@code false} to hide it. + */ + public native void setMouseCursorVisible(boolean show); + + private native void nativeSetTitle(String title); + + /** + * Sets the window's title. + * + * @param title the window's new title. + */ + public void setTitle(String title) { + nativeSetTitle(Objects.requireNonNull(title)); + } + + /** + * Shows or hides the window. + * + * @param show {@code true} to show the window, {@code false} to hide it. + */ + public native void setVisible(boolean show); + + /** + * Determines whether automatic key repeat is enabled. + *

      + * If enabled, multiple key press events will be fired when a key stays pressed + * (much like in a text field). + *

      + * Key repeat is enabled by default. + * + * @param enable {@code true} to enable, {@code false} to disabled. + */ + public native void setKeyRepeatEnabled(boolean enable); + + private native void nativeSetIcon(Image image); + + /** + * Sets the icon of the window. + * + * @param icon the icon image. + */ + public void setIcon(Image icon) { + this.icon = Objects.requireNonNull(icon); //keep a local reference + nativeSetIcon(icon); + } + + private native boolean nativeSetActive(boolean active); + + /** + * Activates or deactivates the window as the current OpenGL rendering target. + *

      + * If a window gets activated, all other windows operating in the same thread will + * automatically be deactivated. + * + * @param active {@code true} to activate, {@code false} to deactivate. + * @throws ContextActivationException in case window activation fails. + */ + public void setActive(boolean active) throws ContextActivationException { + if (!nativeSetActive(active)) { + throw new ContextActivationException("Failed to " + + (active ? "activate" : "deactivate") + + " the window's context."); + } + } + + /** + * Activates the window as the current OpenGL rendering target. + *

      + * If a window gets activated, all other windows operating in the same thread will + * automatically be deactivated. + * + * @throws ContextActivationException in case window activation fails. + */ + public final void setActive() throws ContextActivationException { + setActive(true); + } + + /** + * Flushes the OpenGL pixel buffer to the screen. + *

      + * This should be called every frame after everything has been drawn in order to + * make the changes visible in the window. + */ + public native void display(); + + /** + * Sets the maximum frame rate in frames per second. + *

      + * If a limit is set, the {@link #display()} method will block for a short delay time + * after flushing the buffer in order to possibly maintain a constant frame rate. + *

      + * This should not be used in combination with + * {@link #setVerticalSyncEnabled(boolean)} } as these two will conflict with one another. + *

      + * By default, there is no frame rate limit. + * + * @param flimit the maximum frame rate in frames per second, or {@code 0} to disable + * the frame rate limit. + */ + public native void setFramerateLimit(int flimit); + + /** + * Sets the joystick treshold. + *

      + * Joystick axis movements with a magnitude smaller than this treshold will not + * fire a joystick event. + *

      + * The default joystick treshold is 0.1. + * + * @param treshold the joystick treshold, ranging between 0 and 100. + * @see org.jsfml.window.event.JoystickMoveEvent + */ + public native void setJoystickTreshold(float treshold); +} diff --git a/lib/jsfml/src/java/org/jsfml/window/WindowStyle.java b/lib/jsfml/src/java/org/jsfml/window/WindowStyle.java new file mode 100644 index 00000000..89722ea3 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/window/WindowStyle.java @@ -0,0 +1,43 @@ +package org.jsfml.window; + +/** + * Provides window style constants. + *

      + * These constants can be combined using an arithmetic {@code OR} operation to define + * the style settings for a {@code Window}. For instance, the {@code DEFAULT} style is defined + * as {@code TITLEBAR | RESIZE | CLOSE}. + * + * @see Window#create(VideoMode, String, int) + */ +public interface WindowStyle { + /** + * Undecorated, non-resizable window. + */ + public static final int NONE = 0; + + /** + * Adds a title bar and a fixed border to the window. + */ + public static final int TITLEBAR = 0x01; + + /** + * Makes the window resizable. + */ + public static final int RESIZE = 0x02; + + /** + * Adds a close button to the window. + */ + public static final int CLOSE = 0x04; + + /** + * Makes the window a fullscreen window. + * If this flag is set, the other flags will be ignored. + */ + public static final int FULLSCREEN = 0x08; + + /** + * The default style, a resizable and closeable window with a title bar. + */ + public static final int DEFAULT = TITLEBAR | RESIZE | CLOSE; +} diff --git a/lib/jsfml/src/java/org/jsfml/window/event/Event.java b/lib/jsfml/src/java/org/jsfml/window/event/Event.java new file mode 100644 index 00000000..435db79b --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/window/event/Event.java @@ -0,0 +1,274 @@ +package org.jsfml.window.event; + +/** + * Base class for window events. + *

      + * Window events must be polled from a window on a regular basis to keep + * the window responsive. + *

      + * Events are of a certain type, some of which provide additional data. For + * various special types, subclasses of this class exist. This class provides + * convenience methods to cast {@code Event} objects to one of these special + * subclasses (e.g. {@link #asKeyEvent()}, which will cast the event to a {@code KeyEvent}, + * if possible). + * + * @see org.jsfml.window.Window#pollEvents() + * @see Type + */ +public class Event { + /** + * Enumeration of available window event types. + */ + public static enum Type { + /** + * Fired when the user clicked on the window's close button. + */ + CLOSED, + + /** + * Fired when the window was resized. + */ + RESIZED, + + /** + * Fired when the window lost focus. + */ + LOST_FOCUS, + + /** + * Fired when the window gained focus. + */ + GAINED_FOCUS, + + /** + * Fired when a text character was entered using the keyboard while the + * window had focus. + *

      + * Events of this type can be cast to {@link TextEvent} using the + * {@link #asTextEvent()} method. + */ + TEXT_ENTERED, + + /** + * Fired when a keyboard key was pressed while the window had focus. + *

      + * Events of this type can be cast to {@link KeyEvent} using the + * {@link #asKeyEvent()} method. + */ + KEY_PRESSED, + + /** + * Fired when a keyboard key was released while the window had focus. + *

      + * Events of this type can be cast to {@link KeyEvent} using the + * {@link #asKeyEvent()} method. + */ + KEY_RELEASED, + + /** + * Fired when the mouse wheel was moved while the window had focus. + *

      + * Events of this type can be cast to {@link MouseWheelEvent} using the + * {@link #asMouseWheelEvent()} method. + */ + MOUSE_WHEEL_MOVED, + + /** + * Fired when a mouse button was pressed while the window had focus. + *

      + * Events of this type can be cast to {@link MouseButtonEvent} using the + * {@link #asMouseButtonEvent()} method. + */ + MOUSE_BUTTON_PRESSED, + + /** + * Fired when a mouse button was released while the window had focus. + *

      + * Events of this type can be cast to {@link MouseButtonEvent} using the + * {@link #asMouseButtonEvent()} method. + */ + MOUSE_BUTTON_RELEASED, + + /** + * Fired when the mouse cursor was moved within the window's boundaries. + *

      + * Events of this type can be cast to {@link MouseEvent} using the + * {@link #asMouseEvent()} method. + */ + MOUSE_MOVED, + + /** + * Fired when the mouse cursor entered the window's boundaries. + *

      + * Events of this type can be cast to {@link MouseEvent} using the + * {@link #asMouseEvent()} method. + */ + MOUSE_ENTERED, + + /** + * Fired when the mouse cursor left the window's boundaries. + *

      + * Events of this type can be cast to {@link MouseEvent} using the + * {@link #asMouseEvent()} method. + */ + MOUSE_LEFT, + + /** + * Fired when a joystick or gamepad button was pressed while the window + * had focus. + *

      + * Events of this type can be cast to {@link JoystickButtonEvent} using the + * {@link #asJoystickButtonEvent()} method. + */ + JOYSTICK_BUTTON_PRESSED, + + /** + * Fired when a joystick or gamepad button was released while the window + * had focus. + *

      + * Events of this type can be cast to {@link JoystickButtonEvent} using the + * {@link #asJoystickButtonEvent()} method. + */ + JOYSTICK_BUTTON_RELEASED, + + /** + * Fired when a joystick or gamepad axis was moved while the window + * had focus. + *

      + * Events of this type can be cast to {@link JoystickMoveEvent} using the + * {@link #asJoystickMoveEvent()} method. + */ + JOYSTICK_MOVED, + + /** + * Fired when a joystick or gamepad was connected. + *

      + * Events of this type can be cast to {@link JoystickEvent} using the + * {@link #asJoystickEvent()} method. + */ + JOYSTICK_CONNECETED, + + /** + * Fired when a joystick or gamepad was disconnected. + *

      + * Events of this type can be cast to {@link JoystickEvent} using the + * {@link #asJoystickEvent()} method. + */ + JOYSTICK_DISCONNECTED + } + + /** + * The type of the window event. + * + * @see Type + */ + public final Type type; + + /** + * Constructs a new event. + * + * @param type the type of the event. + * This must be a valid ordinal in the {@link Event.Type} enumeration. + */ + public Event(int type) { + this.type = Type.values()[type]; + } + + /** + * Attempts to cast this event to a {@link JoystickButtonEvent}. + * + * @return the event cast to a {@code JoystickButtonEvent} if its type is either + * {@link Type#JOYSTICK_BUTTON_PRESSED} or {@link Type#JOYSTICK_BUTTON_RELEASED}, + * {@code null} otherwise. + */ + public JoystickButtonEvent asJoystickButtonEvent() { + return null; + } + + /** + * Attempts to cast this event to a {@link JoystickEvent}. + * + * @return the event cast to a {@code JoystickEvent} if its type is one of + * {@link Type#JOYSTICK_CONNECETED}, {@link Type#JOYSTICK_DISCONNECTED}, + * {@link Type#JOYSTICK_BUTTON_PRESSED}, {@link Type#JOYSTICK_BUTTON_RELEASED} or + * {@link Type#JOYSTICK_MOVED}, {@code null} otherwise. + */ + public JoystickEvent asJoystickEvent() { + return null; + } + + /** + * Attempts to cast this event to a {@link JoystickMoveEvent}. + * + * @return the event cast to a {@code JoystickButtonEvent} if its type is + * {@link Type#JOYSTICK_MOVED}, {@code null} otherwise. + */ + public JoystickMoveEvent asJoystickMoveEvent() { + return null; + } + + /** + * Attempts to cast this event to a {@link KeyEvent}. + * + * @return the event cast to a {@code KeyEvent} if its type is either + * {@link Type#KEY_PRESSED} or {@link Type#KEY_RELEASED}, + * {@code null} otherwise. + */ + public KeyEvent asKeyEvent() { + return null; + } + + /** + * Attempts to cast this event to a {@link MouseButtonEvent}. + * + * @return the event cast to a {@code MouseButtonEvent} if its type is either + * {@link Type#MOUSE_BUTTON_PRESSED} or {@link Type#MOUSE_BUTTON_RELEASED}, + * {@code null} otherwise. + */ + public MouseButtonEvent asMouseButtonEvent() { + return null; + } + + /** + * Attempts to cast this event to a {@link MouseEvent}. + * + * @return the event cast to a {@code MouseEvent} if its type is one of + * {@link Type#MOUSE_ENTERED}, {@link Type#MOUSE_MOVED}, + * {@link Type#MOUSE_LEFT}, {@link Type#MOUSE_BUTTON_PRESSED}, + * {@link Type#MOUSE_BUTTON_RELEASED} or {@link Type#MOUSE_WHEEL_MOVED}, + * {@code null} otherwise. + */ + public MouseEvent asMouseEvent() { + return null; + } + + /** + * Attempts to cast this event to a {@link MouseWheelEvent}. + * + * @return the event cast to a {@code MouseWheelEvent} if its type is + * {@link Type#MOUSE_WHEEL_MOVED}, {@code null} otherwise. + */ + public MouseWheelEvent asMouseWheelEvent() { + return null; + } + + /** + * Attempts to cast this event to a {@link SizeEvent}. + * + * @return the event cast to a {@code SizeEvent} if its type is + * {@link Type#RESIZED}, {@code null} otherwise. + */ + public SizeEvent asSizeEvent() { + return null; + } + + /** + * Attempts to cast this event to a {@link TextEvent}. + * + * @return the event cast to a {@code TextEvent} if its type is + * {@link Type#TEXT_ENTERED}, {@code null} otherwise. + */ + public TextEvent asTextEvent() { + return null; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/window/event/JoystickButtonEvent.java b/lib/jsfml/src/java/org/jsfml/window/event/JoystickButtonEvent.java new file mode 100644 index 00000000..fac6dc19 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/window/event/JoystickButtonEvent.java @@ -0,0 +1,36 @@ +package org.jsfml.window.event; + +/** + * Represents joystick or gamepad button events. + *

      + * Objects of this class are created for events of type + * {@link Event.Type#JOYSTICK_BUTTON_PRESSED} or + * {@link Event.Type#JOYSTICK_BUTTON_RELEASED}. + */ +public final class JoystickButtonEvent extends JoystickEvent { + /** + * The index of the button that was pressed or released. + *

      + * The value is guaranteed to range between 0 (inclusive) and + * {@link org.jsfml.window.Joystick#BUTTON_COUNT} (exclusive). + */ + public final int button; + + /** + * Constructs a new joystick button event. + * + * @param type the type of the event. + * This must be a valid ordinal in the {@link Event.Type} enumeration. + * @param joystickId the joystick ID. + * @param button the index of the button that was pressed. + */ + public JoystickButtonEvent(int type, int joystickId, int button) { + super(type, joystickId); + this.button = button; + } + + @Override + public JoystickButtonEvent asJoystickButtonEvent() { + return this; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/window/event/JoystickEvent.java b/lib/jsfml/src/java/org/jsfml/window/event/JoystickEvent.java new file mode 100644 index 00000000..2670d070 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/window/event/JoystickEvent.java @@ -0,0 +1,38 @@ +package org.jsfml.window.event; + +/** + * Represents generic joystick or gamepad events. + *

      + * Objects of this class are created for events of type + * {@link Event.Type#JOYSTICK_CONNECETED}, + * {@link Event.Type#JOYSTICK_DISCONNECTED}, + * {@link Event.Type#JOYSTICK_BUTTON_PRESSED}, + * {@link Event.Type#JOYSTICK_BUTTON_RELEASED} or + * {@link Event.Type#JOYSTICK_MOVED}. + */ +public class JoystickEvent extends Event { + /** + * The index of the joystick that caused this event. + *

      + * The value is guaranteed to range between 0 (inclusive) and + * {@link org.jsfml.window.Joystick#JOYSTICK_COUNT} (exclusive). + */ + public final int joystickId; + + /** + * Constructs a new joystick event. + * + * @param type the type of the event. + * This must be a valid ordinal in the {@link Event.Type} enumeration. + * @param joystickId the joystick ID. + */ + public JoystickEvent(int type, int joystickId) { + super(type); + this.joystickId = joystickId; + } + + @Override + public JoystickEvent asJoystickEvent() { + return this; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/window/event/JoystickMoveEvent.java b/lib/jsfml/src/java/org/jsfml/window/event/JoystickMoveEvent.java new file mode 100644 index 00000000..9285db1e --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/window/event/JoystickMoveEvent.java @@ -0,0 +1,43 @@ +package org.jsfml.window.event; + +import org.jsfml.window.Joystick; + +/** + * Represents joystick or gamepad axis movement events. + *

      + * Objects of this class are created for events of type + * {@link Event.Type#JOYSTICK_MOVED}. + */ +public final class JoystickMoveEvent extends JoystickEvent { + /** + * The joystick or gamepad axis that was moved. + */ + public final Joystick.Axis joyAxis; + + /** + * The position that the axis was moved to, ranging between -100 and 100. + */ + public final float position; + + /** + * Constructs a new joystick axis event. + * + * @param type the type of the event. + * This must be a valid ordinal in the {@link Event.Type} enumeration. + * @param joystickId the joystick ID. + * @param joyAxis the joystick axis that was moved. + * This must be a valid ordinal in the {@link org.jsfml.window.Joystick.Axis} + * enumeration. + * @param position the position that the axis was moved to. + */ + public JoystickMoveEvent(int type, int joystickId, int joyAxis, float position) { + super(type, joystickId); + this.joyAxis = Joystick.Axis.values()[joyAxis]; + this.position = position; + } + + @Override + public JoystickMoveEvent asJoystickMoveEvent() { + return this; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/window/event/KeyEvent.java b/lib/jsfml/src/java/org/jsfml/window/event/KeyEvent.java new file mode 100644 index 00000000..1e9300c2 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/window/event/KeyEvent.java @@ -0,0 +1,68 @@ +package org.jsfml.window.event; + +import org.jsfml.window.Keyboard; + +/** + * Represents keyboard key events. + *

      + * Objects of this class are created for events of type + * {@link Event.Type#KEY_PRESSED} or + * {@link Event.Type#KEY_RELEASED}. + */ +public final class KeyEvent extends Event { + /** + * The code of the key that was pressed or released. + */ + public final Keyboard.Key key; + + /** + * {@code true} if an {@code ALT} key (left or right) was pressed when the event occured, + * {@code false} if not. + */ + public final boolean alt; + + /** + * {@code true} if a {@code SHIFT} key (left or right) was pressed when the event occured, + * {@code false} if not. + */ + public final boolean shift; + + /** + * {@code true} if a {@code CTRL} key (left or right) was pressed when the event occured, + * {@code false} if not. + */ + public final boolean control; + + /** + * {@code true} if a system key was pressed when the event occured, + * {@code false} if not. + */ + public final boolean system; + + /** + * Constructs a new key event. + * + * @param type the type of the event. + * This must be a valid ordinal in the {@link Event.Type} enumeration. + * @param keyCode the code of the key that was pressed. + * This must be a valid ordinal in the {@link org.jsfml.window.Keyboard.Key} + * enumeration. + * @param alt {@code true} to indicate that an {@code ALT} key was pressed. + * @param shift {@code true} to indicate that a {@code SHIFT} key was pressed. + * @param control {@code true} to indicate that a {@code CTRL} key was pressed. + * @param system {@code true} to indicate that a system key was pressed. + */ + public KeyEvent(int type, int keyCode, boolean alt, boolean shift, boolean control, boolean system) { + super(type); + this.key = Keyboard.Key.values()[keyCode + 1]; + this.alt = alt; + this.shift = shift; + this.control = control; + this.system = system; + } + + @Override + public KeyEvent asKeyEvent() { + return this; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/window/event/MouseButtonEvent.java b/lib/jsfml/src/java/org/jsfml/window/event/MouseButtonEvent.java new file mode 100644 index 00000000..701feaab --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/window/event/MouseButtonEvent.java @@ -0,0 +1,38 @@ +package org.jsfml.window.event; + +import org.jsfml.window.Mouse; + +/** + * Represents mouse button events. + *

      + * Objects of this class are created for events of type + * {@link Event.Type#MOUSE_BUTTON_PRESSED} or + * {@link Event.Type#MOUSE_BUTTON_RELEASED}. + */ +public final class MouseButtonEvent extends MouseEvent { + /** + * The mouse button that was pressed or released. + */ + public final Mouse.Button button; + + /** + * Constructs a new mouse button event. + * + * @param type the type of the event. + * This must be a valid ordinal in the {@link Event.Type} enumeration. + * @param x the X coordinate of the mouse cursor relative to the window. + * @param y the Y coordinate of the mouse cursor relative to the window. + * @param button the button that was pressed. + * This must be a valid ordinal in the {@link org.jsfml.window.Mouse.Button} + * enumeration. + */ + public MouseButtonEvent(int type, int x, int y, int button) { + super(type, x, y); + this.button = Mouse.Button.values()[button]; + } + + @Override + public MouseButtonEvent asMouseButtonEvent() { + return this; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/window/event/MouseEvent.java b/lib/jsfml/src/java/org/jsfml/window/event/MouseEvent.java new file mode 100644 index 00000000..711af584 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/window/event/MouseEvent.java @@ -0,0 +1,40 @@ +package org.jsfml.window.event; + +import org.jsfml.system.Vector2i; + +/** + * Represents generic mouse events. + *

      + * Objects of this class are created for events of type + * {@link Event.Type#MOUSE_ENTERED}, + * {@link Event.Type#MOUSE_MOVED}, + * {@link Event.Type#MOUSE_LEFT}, + * {@link Event.Type#MOUSE_WHEEL_MOVED}, + * {@link Event.Type#MOUSE_BUTTON_PRESSED} or + * {@link Event.Type#MOUSE_BUTTON_RELEASED}. + */ +public class MouseEvent extends Event { + /** + * The position of the mouse pointer in pixels, relative to the window's top left corner. + */ + public final Vector2i position; + + /** + * /** + * Constructs a new mouse button event. + * + * @param type the type of the event. + * This must be a valid ordinal in the {@link Event.Type} enumeration. + * @param x the X coordinate of the mouse cursor relative to the window. + * @param y the Y coordinate of the mouse cursor relative to the window. + */ + public MouseEvent(int type, int x, int y) { + super(type); + this.position = new Vector2i(x, y); + } + + @Override + public MouseEvent asMouseEvent() { + return this; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/window/event/MouseWheelEvent.java b/lib/jsfml/src/java/org/jsfml/window/event/MouseWheelEvent.java new file mode 100644 index 00000000..07ec5908 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/window/event/MouseWheelEvent.java @@ -0,0 +1,33 @@ +package org.jsfml.window.event; + +/** + * Represents mouse wheel movement events. + *

      + * Objects of this class are created for events of type + * {@link Event.Type#MOUSE_WHEEL_MOVED}. + */ +public final class MouseWheelEvent extends MouseEvent { + /** + * The amount of ticks that the mouse wheel was moved. + */ + public final int delta; + + /** + * Constructs a new mouse wheel event. + * + * @param type the type of the event. + * This must be a valid ordinal in the {@link Event.Type} enumeration. + * @param x the X coordinate of the mouse cursor relative to the window. + * @param y the Y coordinate of the mouse cursor relative to the window. + * @param delta the amount of ticks that the mouse wheel was moved. + */ + public MouseWheelEvent(int type, int x, int y, int delta) { + super(type, x, y); + this.delta = delta; + } + + @Override + public MouseWheelEvent asMouseWheelEvent() { + return this; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/window/event/SizeEvent.java b/lib/jsfml/src/java/org/jsfml/window/event/SizeEvent.java new file mode 100644 index 00000000..ba280b3b --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/window/event/SizeEvent.java @@ -0,0 +1,34 @@ +package org.jsfml.window.event; + +import org.jsfml.system.Vector2i; + +/** + * Represents window resize events. + *

      + * Objects of this class are created for events of type + * {@link Event.Type#RESIZED}. + */ +public final class SizeEvent extends Event { + /** + * The new size of the window in pixels. + */ + public final Vector2i size; + + /** + * Constructs a new window resize event. + * + * @param type the type of the event. + * This must be a valid ordinal in the {@link Event.Type} enumeration. + * @param width the new width of the window in pixels. + * @param height the new height of the window in pixels. + */ + public SizeEvent(int type, int width, int height) { + super(type); + this.size = new Vector2i(width, height); + } + + @Override + public SizeEvent asSizeEvent() { + return this; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/window/event/TextEvent.java b/lib/jsfml/src/java/org/jsfml/window/event/TextEvent.java new file mode 100644 index 00000000..da554a43 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/window/event/TextEvent.java @@ -0,0 +1,50 @@ +package org.jsfml.window.event; + +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.Charset; + +/** + * Represents text enter events. + *

      + * Objects of this class are created for events of type + * {@link Event.Type#TEXT_ENTERED}. + */ +public final class TextEvent extends Event { + private final static Charset utf32 = Charset.forName("UTF-32"); + + /** + * The UTF-32 code of the character that was entered. + */ + public final int unicode; + + /** + * The Java representation of the character that was entered. + */ + public final char character; + + /** + * Constructs a new text event. + * + * @param type the type of the event. + * This must be a valid ordinal in the {@link Event.Type} enumeration. + * @param unicode the UTF-32 code of the character that was entered. + */ + public TextEvent(int type, int unicode) { + super(type); + + this.unicode = unicode; + + final ByteBuffer unicodeBuffer = ByteBuffer.allocate(4); + unicodeBuffer.putInt(unicode); + unicodeBuffer.flip(); + + final CharBuffer chars = utf32.decode(unicodeBuffer); + character = chars.get(); + } + + @Override + public TextEvent asTextEvent() { + return this; + } +} diff --git a/lib/jsfml/src/java/org/jsfml/window/event/package-info.java b/lib/jsfml/src/java/org/jsfml/window/event/package-info.java new file mode 100644 index 00000000..73b65bff --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/window/event/package-info.java @@ -0,0 +1,4 @@ +/** + * Contains window event classes. + */ +package org.jsfml.window.event; diff --git a/lib/jsfml/src/java/org/jsfml/window/package-info.java b/lib/jsfml/src/java/org/jsfml/window/package-info.java new file mode 100644 index 00000000..f6debea9 --- /dev/null +++ b/lib/jsfml/src/java/org/jsfml/window/package-info.java @@ -0,0 +1,4 @@ +/** + * Contains classes related to windows, their OpenGL context and system-wide input. + */ +package org.jsfml.window; diff --git a/lib/json-20210307.jar b/lib/json-20210307.jar new file mode 100644 index 00000000..6583ea56 Binary files /dev/null and b/lib/json-20210307.jar differ diff --git a/src/com/rubynaxela/kyanite/game/Game.java b/src/com/rubynaxela/kyanite/game/Game.java new file mode 100644 index 00000000..d9dc5e4d --- /dev/null +++ b/src/com/rubynaxela/kyanite/game/Game.java @@ -0,0 +1,21 @@ +package com.rubynaxela.kyanite.game; + +public abstract class Game { + + private final GameContext context = GameContext.getInstance(); + + /** + * Starts the game clock and the window loop + */ + public final void start() { + context.getClock().tryStart(); + context.getWindow().startLoop(); + } + + /** + * @return the reference to the game context + */ + public GameContext getContext() { + return context; + } +} diff --git a/src/com/rubynaxela/kyanite/game/GameContext.java b/src/com/rubynaxela/kyanite/game/GameContext.java new file mode 100644 index 00000000..870e88ab --- /dev/null +++ b/src/com/rubynaxela/kyanite/game/GameContext.java @@ -0,0 +1,106 @@ +package com.rubynaxela.kyanite.game; + +import com.rubynaxela.kyanite.game.assets.AssetsBundle; +import com.rubynaxela.kyanite.system.Clock; +import com.rubynaxela.kyanite.util.Vec2; +import com.rubynaxela.kyanite.window.Window; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jsfml.system.Vector2i; +import org.jsfml.window.VideoMode; + +/** + * Provides a set of references to the basic objects used by the game. The instance of this class can be accessed via the + * {@link GameContext#getInstance} method. Only one {@code GameContext} instance can exist in a single game instance. + */ +public final class GameContext { + + private static final GameContext instance = new GameContext(); + private final AssetsBundle assetsBundle; + private final Clock clock; + private Window window; + + private GameContext() { + assetsBundle = new AssetsBundle(); + clock = new Clock(false); + } + + /** + * @return reference to the instance of the game context + */ + public static GameContext getInstance() { + return instance; + } + + /** + * Sets the window size and title. This has to be called before the window is used. + * + * @param size the window size + * @param title the window title + * @return the reference to the window + */ + @Contract("_, _ -> new") + public Window setupWindow(@NotNull Vector2i size, @NotNull String title) { + if (window != null) throw new IllegalStateException("The window has been already initialized"); + return window = new Window(new VideoMode(size.x, size.y), title); + } + + /** + * Sets the window size and title. This has to be called before the window is used. + * + * @param width the window width + * @param height the window height + * @param title the window title + * @return the reference to the window + */ + @Contract("_, _, _ -> new") + public Window setupWindow(int width, int height, @NotNull String title) { + return setupWindow(Vec2.i(width, height), title); + } + + /** + * Sets the window size. This has to be called before the window is used. + * + * @param size the window size + * @return the reference to the window + */ + @Contract("_ -> new") + public Window setupWindow(@NotNull Vector2i size) { + return setupWindow(size, ""); + } + + /** + * Sets the window size. This has to be called before the window is used. + * + * @param width the window width + * @param height the window height + * @return the reference to the window + */ + @Contract("_, _ -> new") + public Window setupWindow(int width, int height) { + return setupWindow(Vec2.i(width, height), ""); + } + + /** + * @return reference to the game window + */ + public Window getWindow() { + return window; + } + + /** + * @return reference to the game assets bundle + */ + @NotNull + public AssetsBundle getAssetsBundle() { + return assetsBundle; + } + + /** + * @return reference to the game clock + */ + @NotNull + public Clock getClock() { + return clock; + } +} diff --git a/src/com/rubynaxela/kyanite/game/Scene.java b/src/com/rubynaxela/kyanite/game/Scene.java new file mode 100644 index 00000000..fbb6259c --- /dev/null +++ b/src/com/rubynaxela/kyanite/game/Scene.java @@ -0,0 +1,378 @@ +package com.rubynaxela.kyanite.game; + +import com.rubynaxela.kyanite.game.assets.Texture; +import com.rubynaxela.kyanite.game.entities.AnimatedEntity; +import com.rubynaxela.kyanite.system.Clock; +import com.rubynaxela.kyanite.util.Vec2; +import com.rubynaxela.kyanite.window.Window; +import org.jetbrains.annotations.NotNull; +import org.jsfml.graphics.Color; +import org.jsfml.graphics.Drawable; +import org.jsfml.graphics.RectangleShape; +import org.jsfml.system.Time; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.*; +import java.util.function.Consumer; +import java.util.function.Predicate; +import java.util.function.UnaryOperator; + +/** + * Provides a scene that can be given a custom behavior and displayed on a {@link com.rubynaxela.kyanite.window.Window}. + */ +public abstract class Scene implements Iterable { + + private final GameContext context = GameContext.getInstance(); + private final Clock clock = context.getClock(); + private final List drawables = new LinkedList<>(); + private boolean ready = false; + private Time previousFrameTime, currentFrameTime; + private Color backgroundColor = Color.BLACK; + private RectangleShape background; + + /** + * This method is executed when this scene is assigned to a window. + */ + protected abstract void init(); + + /** + * Performs the full scene initialization, i.a. starts the global clock and calls the {@link Scene#init} method. + * + * @param window the window that the scene has to be displayed on + */ + public final void fullInit(@NotNull Window window) { + if (!ready) { + ready = true; + clock.tryStart(); + previousFrameTime = clock.getTime(); + currentFrameTime = previousFrameTime; + init(); + } else throw new IllegalStateException("This scene has been already initialized"); + } + + /** + * This method is executed every frame by the window it belongs to. + */ + protected abstract void loop(); + + /** + * Calls the {@link Scene#loop} method and then every entity is animated (if it implements {@link AnimatedEntity}) + * and drawn on the game window. This method is automatically executed every frame by the window it belongs to. + * + * @param window the window that the scene has to be displayed on + */ + public final void fullLoop(@NotNull Window window) { + loop(); + if (background != null) window.draw(background); + forEach(object -> { + if (object instanceof AnimatedEntity) ((AnimatedEntity) object).animate(getDeltaTime(), clock.getTime()); + window.draw(object); + }); + previousFrameTime = currentFrameTime; + currentFrameTime = clock.getTime(); + } + + /** + * @return the reference to the game context + */ + public GameContext getContext() { + return context; + } + + /** + * Gets the time that has passed between the previous and the current frame. + * + * @return the elapsed time since the clock was created or this function was last called. + * @apiNote Calling this method during the first frame of the scene will return time estimated + * by the window framerate limit as there was no previous frame time to compute the difference + */ + public Time getDeltaTime() { + try { + final Constructor