-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from knighthat/development
Update version 0.0.3 | Big update with many new features and changes
- Loading branch information
Showing
113 changed files
with
3,562 additions
and
4,230 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/me/knighthat/interactivedeck/component/Flexible.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (c) 2023. Knight Hat | ||
* All rights reserved. | ||
* 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. | ||
*/ | ||
|
||
package me.knighthat.interactivedeck.component; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
|
||
public interface Flexible { | ||
|
||
default void setDimension( @NotNull JComponent component, int width, int height ) { | ||
Dimension dimension = new Dimension( width, height ); | ||
component.setMinimumSize( dimension ); | ||
component.setMaximumSize( dimension ); | ||
component.setPreferredSize( dimension ); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/me/knighthat/interactivedeck/component/InputFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (c) 2023. Knight Hat | ||
* All rights reserved. | ||
* 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. | ||
*/ | ||
|
||
package me.knighthat.interactivedeck.component; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import javax.swing.text.AttributeSet; | ||
import javax.swing.text.BadLocationException; | ||
import javax.swing.text.Document; | ||
import javax.swing.text.DocumentFilter; | ||
|
||
public abstract class InputFilter extends DocumentFilter { | ||
|
||
protected abstract boolean test( @NotNull CharSequence chars ); | ||
|
||
private StringBuilder getStringBuilder( @NotNull FilterBypass fb ) throws BadLocationException { | ||
Document document = fb.getDocument(); | ||
StringBuilder builder = new StringBuilder(); | ||
builder.append( document.getText( 0, document.getLength() ) ); | ||
return builder; | ||
} | ||
|
||
@Override | ||
public void insertString( FilterBypass fb, int offset, String string, AttributeSet attr ) throws BadLocationException { | ||
StringBuilder builder = getStringBuilder( fb ); | ||
builder.insert( offset, string ); | ||
if (test( builder )) | ||
super.insertString( fb, offset, string, attr ); | ||
} | ||
|
||
@Override | ||
public void replace( FilterBypass fb, int offset, int length, String text, AttributeSet attrs ) throws BadLocationException { | ||
StringBuilder builder = getStringBuilder( fb ); | ||
builder.replace( offset, offset + length, text ); | ||
if (test( builder )) | ||
super.replace( fb, offset, length, text, attrs ); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/me/knighthat/interactivedeck/component/IntegerFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (c) 2023. Knight Hat | ||
* All rights reserved. | ||
* 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. | ||
*/ | ||
|
||
package me.knighthat.interactivedeck.component; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class IntegerFilter extends InputFilter { | ||
|
||
private final int min; | ||
private final int max; | ||
|
||
public IntegerFilter( int min, int max ) { | ||
this.min = min; | ||
this.max = max; | ||
} | ||
|
||
public IntegerFilter() { | ||
this( Integer.MIN_VALUE, Integer.MAX_VALUE ); | ||
} | ||
|
||
@Override | ||
protected boolean test( @NotNull CharSequence chars ) { | ||
try { | ||
int value = Integer.parseInt( chars.toString() ); | ||
return value >= min & value <= max; | ||
} catch (NumberFormatException e) { | ||
return false; | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/me/knighthat/interactivedeck/component/IpAddressFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2023. Knight Hat | ||
* All rights reserved. | ||
* 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. | ||
*/ | ||
|
||
package me.knighthat.interactivedeck.component; | ||
|
||
/** | ||
* Only accepts value from 0 to 255.<br> | ||
* Denies input if value is outside of this range. | ||
*/ | ||
public class IpAddressFilter extends IntegerFilter { | ||
|
||
public IpAddressFilter() { | ||
super( 0x0, 0xff ); | ||
} | ||
} |
Oops, something went wrong.