Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Commit

Permalink
Format and version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
DeflatedPickle committed Nov 1, 2020
1 parent ad80274 commit 3cbf6a3
Show file tree
Hide file tree
Showing 57 changed files with 240 additions and 152 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ Before submitting a pull request, if you are adding a new plugin, make sure you

If you decide to close your pull request for a new plugin as you would rather have it in a different repository, please comment on the issue with a reference to its new home, so it may be added to the README.

Should you decide you want your code removed in the future, if there isn't code elsewhere in this repository that depends on it, it will be removed from future releases.
Should you decide you want your code removed in the future, if there isn't code elsewhere in this repository that depends on it, it will be removed from future releases.
If your removed code was a plugin, and it has a new home, please submit an issue with a reference to it so it may be added to the README.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ This program uses the [haruhi](https://github.com/DeflatedPickle/haruhi) framewo
Though there isn't an official way to develop external plugins, there are two routes I can think of;

1. Clone this repository and develop your plugin as a submodule
- **Pro:** Easier to debug
- **Con:** Harder to distribute
- **Pro:** Easier to debug
- **Con:** Harder to distribute
2. Develop your plugin in its own repository, then build it and place the build in your install of Quiver's `/plugins` directory when you want to test it
- **Pro:** Doesn't require the Quiver source
- **Con:** Harder to test
- **Pro:** Doesn't require the Quiver source
- **Con:** Harder to test
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
}

group 'com.deflatedpickle'
version '1.4.1'
version '1.5.0'

allprojects {
apply plugin: 'org.jetbrains.kotlin.jvm'
Expand All @@ -25,7 +25,7 @@ allprojects {
}

spotless {
ratchetFrom 'origin/rewrite'
// ratchetFrom 'origin/rewrite'

java {
importOrder()
Expand Down
41 changes: 21 additions & 20 deletions core/src/main/java/so/madprogrammer/PatternFilter.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package so.madprogrammer;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.DocumentFilter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

// https://stackoverflow.com/a/28790963
public class PatternFilter extends DocumentFilter {
private final Pattern pattern;
private final Pattern pattern;

public PatternFilter(String pat) {
pattern = Pattern.compile(pat);
}
public PatternFilter(String pat) {
pattern = Pattern.compile(pat);
}

public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr)
throws BadLocationException {
String newStr = fb.getDocument().getText(0, fb.getDocument().getLength()) + string;
Matcher m = pattern.matcher(newStr);
if (m.matches()) {
super.insertString(fb, offset, string, attr);
}
public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr)
throws BadLocationException {
String newStr = fb.getDocument().getText(0, fb.getDocument().getLength()) + string;
Matcher m = pattern.matcher(newStr);
if (m.matches()) {
super.insertString(fb, offset, string, attr);
}
}

public void replace(FilterBypass fb, int offset,
int length, String string, AttributeSet attr)
throws BadLocationException {
if (length > 0) fb.remove(offset, length);
insertString(fb, offset, string, attr);
}
}
public void replace(FilterBypass fb, int offset, int length, String string, AttributeSet attr)
throws BadLocationException {
if (length > 0) fb.remove(offset, length);
insertString(fb, offset, string, attr);
}
}
36 changes: 19 additions & 17 deletions core/src/main/java/so/madprogrammer/ScaleUtil.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package so.madprogrammer;

import java.awt.*;

public class ScaleUtil {
static public double getScaleFactor(int iMasterSize, int iTargetSize) {
return (double) iTargetSize / (double) iMasterSize;
}

static public double getScaleFactorToFit(Dimension original, Dimension toFit) {
double dScale = 1d;
public static double getScaleFactor(int iMasterSize, int iTargetSize) {
return (double) iTargetSize / (double) iMasterSize;
}

if (original != null && toFit != null) {
double dScaleWidth = getScaleFactor(original.width, toFit.width);
double dScaleHeight = getScaleFactor(original.height, toFit.height);
public static double getScaleFactorToFit(Dimension original, Dimension toFit) {
double dScale = 1d;

dScale = Math.min(dScaleHeight, dScaleWidth);
}
if (original != null && toFit != null) {
double dScaleWidth = getScaleFactor(original.width, toFit.width);
double dScaleHeight = getScaleFactor(original.height, toFit.height);

return dScale;
dScale = Math.min(dScaleHeight, dScaleWidth);
}

public static double getScaleFactorToFill(Dimension masterSize, Dimension targetSize) {
double dScaleWidth = getScaleFactor(masterSize.width, targetSize.width);
double dScaleHeight = getScaleFactor(masterSize.height, targetSize.height);
return dScale;
}

return Math.max(dScaleHeight, dScaleWidth);
}
public static double getScaleFactorToFill(Dimension masterSize, Dimension targetSize) {
double dScaleWidth = getScaleFactor(masterSize.width, targetSize.width);
double dScaleHeight = getScaleFactor(masterSize.height, targetSize.height);

return Math.max(dScaleHeight, dScaleWidth);
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.quiver.backend.api

import javax.swing.JComponent
Expand All @@ -8,4 +10,4 @@ interface Viewer<T : Any> {

fun getComponent(): JComponent
fun getScroller(): JScrollPane
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.quiver.backend.event

import com.deflatedpickle.haruhi.api.event.AbstractEvent
import java.io.File

object EventOpenFile : AbstractEvent<File>()
object EventOpenFile : AbstractEvent<File>()
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.quiver.backend.event

import com.deflatedpickle.haruhi.api.event.AbstractEvent
import java.io.File

object EventSearchFile : AbstractEvent<File>()
object EventSearchFile : AbstractEvent<File>()
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.quiver.backend.event

import com.deflatedpickle.haruhi.api.event.AbstractEvent
import java.io.File

object EventSearchFolder : AbstractEvent<File>()
object EventSearchFolder : AbstractEvent<File>()
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.quiver.backend.event

import com.deflatedpickle.haruhi.api.event.AbstractEvent
import java.io.File

object EventSelectFile : AbstractEvent<File>()
object EventSelectFile : AbstractEvent<File>()
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.quiver.backend.event

import com.deflatedpickle.haruhi.api.event.AbstractEvent
import java.io.File

object EventSelectFolder : AbstractEvent<File>()
object EventSelectFolder : AbstractEvent<File>()
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.quiver.backend.extension

import java.awt.Dimension
Expand All @@ -9,4 +11,4 @@ operator fun Dimension.compareTo(size: Dimension): Int =
-1
} else {
0
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.quiver.backend.util

import java.io.File

object DocumentUtil {
var current: File? = null
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.quiver.backend.util

import so.madprogrammer.PatternFilter

object Filters {
val FILE = PatternFilter("[^\\./:*?\"<>|]*")
val PATH = PatternFilter("[A-Za-z]:[^:*?\"<>|]*")
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.quiver.backend.util

enum class PackType {
EMPTY_PACK,
DEFAULT_PACK
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.quiver.backend.util

class Version(
Expand Down Expand Up @@ -77,7 +79,7 @@ class VersionIterator(
class VersionProgression(
override val start: Version,
override val endInclusive: Version
): Iterable<Version>, ClosedRange<Version> {
) : Iterable<Version>, ClosedRange<Version> {
override fun toString(): String = "$start - $endInclusive"
override fun iterator(): Iterator<Version> = VersionIterator(start, endInclusive)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.quiver.backend.util

object VersionUtil {
val RELEASE = Regex("""\d+\.\d+(\.\d+)?""")
val ALPHA = Regex("""\d+w\d+a""")
val BETA = Regex("""\d+w\d+b""")
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.rawky.ui.constraints

import java.awt.GridBagConstraints
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.rawky.ui.constraints

import java.awt.GridBagConstraints
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.rawky.ui.constraints

import java.awt.GridBagConstraints
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.rawky.ui.constraints

import java.awt.GridBagConstraints
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.rawky.ui.constraints

import java.awt.GridBagConstraints
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.rawky.ui.constraints

import java.awt.GridBagConstraints
Expand All @@ -6,4 +8,4 @@ object StickCenter : GridBagConstraints() {
init {
anchor = CENTER
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.rawky.ui.constraints

import java.awt.GridBagConstraints
Expand All @@ -7,4 +9,4 @@ object StickCenterFinishLine : GridBagConstraints() {
anchor = CENTER
gridwidth = REMAINDER
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.rawky.ui.constraints

import java.awt.GridBagConstraints
Expand All @@ -6,4 +8,4 @@ object StickEast : GridBagConstraints() {
init {
anchor = EAST
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.rawky.ui.constraints

import java.awt.GridBagConstraints
Expand All @@ -8,4 +10,4 @@ object StickEastFillHorizontal : GridBagConstraints() {
fill = HORIZONTAL
weightx = 1.0
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.rawky.ui.constraints

import java.awt.GridBagConstraints
Expand All @@ -7,4 +9,4 @@ object StickEastFinishLine : GridBagConstraints() {
anchor = EAST
gridwidth = REMAINDER
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Copyright (c) 2020 DeflatedPickle under the MIT license */

package com.deflatedpickle.rawky.ui.constraints

import java.awt.GridBagConstraints
Expand All @@ -6,4 +8,4 @@ object StickWest : GridBagConstraints() {
init {
anchor = WEST
}
}
}
Loading

0 comments on commit 3cbf6a3

Please sign in to comment.