repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
ase34/flyingblocksapi
plugin/src/main/java/de/ase34/flyingblocksapi/FlyingBlocksPlugin.java
// Path: plugin/src/main/java/de/ase34/flyingblocksapi/commands/ExamplesCommandExecutor.java // public class ExamplesCommandExecutor implements CommandExecutor { // // @Override // public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { // if (args.length < 1) { // return false; // } // // String example = args[0]; // CommandExecutor executor; // // if (example.equalsIgnoreCase("flag")) { // executor = new FlagCommandExecutor(); // } else if (example.equalsIgnoreCase("rising")) { // executor = new RisingBlockCommandExecutor(); // } else if (example.equalsIgnoreCase("static")) { // executor = new StaticBlockCommandExecutor(); // } else if (example.equalsIgnoreCase("sinewave")) { // executor = new SineWaveBlockCommandExecutor(); // } else { // return false; // } // // String[] newargs = Arrays.copyOfRange(args, 1, args.length); // return executor.onCommand(sender, command, label, newargs); // // } // // } // // Path: plugin/src/main/java/de/ase34/flyingblocksapi/commands/RemoveAllCommandExecutor.java // public class RemoveAllCommandExecutor implements CommandExecutor { // // private FlyingBlocksPlugin plugin; // // public RemoveAllCommandExecutor(FlyingBlocksPlugin plugin) { // this.plugin = plugin; // } // // @Override // public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { // int counter = 0; // // for (World world : Bukkit.getWorlds()) { // counter += plugin.removeFlyingBlocks(world).size(); // } // // // 3 entities per moving block // counter = counter / 3; // sender.sendMessage(ChatColor.GRAY + "" + counter + " flying " // + (counter == 1 ? "block was" : "blocks were") + " removed!"); // return true; // } // // } // // Path: api/src/main/java/de/ase34/flyingblocksapi/natives/api/NativesAPI.java // public abstract class NativesAPI { // // protected static NativesAPI singleton; // // public static NativesAPI getSingleton() { // return singleton; // } // // public static void setSingleton(NativesAPI singleton) { // NativesAPI.singleton = singleton; // } // // public abstract List<Entity> removeFlyingBlocks(World world); // // public abstract void initialize(); // // public abstract NativeFlyingBlockHandler createFlyingBlockHandler(FlyingBlock flyingBlock); // // }
import java.util.List; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Entity; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.world.WorldUnloadEvent; import org.bukkit.plugin.java.JavaPlugin; import de.ase34.flyingblocksapi.commands.ExamplesCommandExecutor; import de.ase34.flyingblocksapi.commands.RemoveAllCommandExecutor; import de.ase34.flyingblocksapi.natives.api.NativesAPI;
/** * flyingblocksapi Copyright (C) 2014 ase34 and contributors * * 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 3 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, see * <http://www.gnu.org/licenses/>. */ package de.ase34.flyingblocksapi; public class FlyingBlocksPlugin extends JavaPlugin implements Listener { private NativesAPI nativesAPI; @Override public void onEnable() { createNativesAPI(); nativesAPI.initialize(); NativesAPI.setSingleton(nativesAPI);
// Path: plugin/src/main/java/de/ase34/flyingblocksapi/commands/ExamplesCommandExecutor.java // public class ExamplesCommandExecutor implements CommandExecutor { // // @Override // public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { // if (args.length < 1) { // return false; // } // // String example = args[0]; // CommandExecutor executor; // // if (example.equalsIgnoreCase("flag")) { // executor = new FlagCommandExecutor(); // } else if (example.equalsIgnoreCase("rising")) { // executor = new RisingBlockCommandExecutor(); // } else if (example.equalsIgnoreCase("static")) { // executor = new StaticBlockCommandExecutor(); // } else if (example.equalsIgnoreCase("sinewave")) { // executor = new SineWaveBlockCommandExecutor(); // } else { // return false; // } // // String[] newargs = Arrays.copyOfRange(args, 1, args.length); // return executor.onCommand(sender, command, label, newargs); // // } // // } // // Path: plugin/src/main/java/de/ase34/flyingblocksapi/commands/RemoveAllCommandExecutor.java // public class RemoveAllCommandExecutor implements CommandExecutor { // // private FlyingBlocksPlugin plugin; // // public RemoveAllCommandExecutor(FlyingBlocksPlugin plugin) { // this.plugin = plugin; // } // // @Override // public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { // int counter = 0; // // for (World world : Bukkit.getWorlds()) { // counter += plugin.removeFlyingBlocks(world).size(); // } // // // 3 entities per moving block // counter = counter / 3; // sender.sendMessage(ChatColor.GRAY + "" + counter + " flying " // + (counter == 1 ? "block was" : "blocks were") + " removed!"); // return true; // } // // } // // Path: api/src/main/java/de/ase34/flyingblocksapi/natives/api/NativesAPI.java // public abstract class NativesAPI { // // protected static NativesAPI singleton; // // public static NativesAPI getSingleton() { // return singleton; // } // // public static void setSingleton(NativesAPI singleton) { // NativesAPI.singleton = singleton; // } // // public abstract List<Entity> removeFlyingBlocks(World world); // // public abstract void initialize(); // // public abstract NativeFlyingBlockHandler createFlyingBlockHandler(FlyingBlock flyingBlock); // // } // Path: plugin/src/main/java/de/ase34/flyingblocksapi/FlyingBlocksPlugin.java import java.util.List; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Entity; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.world.WorldUnloadEvent; import org.bukkit.plugin.java.JavaPlugin; import de.ase34.flyingblocksapi.commands.ExamplesCommandExecutor; import de.ase34.flyingblocksapi.commands.RemoveAllCommandExecutor; import de.ase34.flyingblocksapi.natives.api.NativesAPI; /** * flyingblocksapi Copyright (C) 2014 ase34 and contributors * * 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 3 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, see * <http://www.gnu.org/licenses/>. */ package de.ase34.flyingblocksapi; public class FlyingBlocksPlugin extends JavaPlugin implements Listener { private NativesAPI nativesAPI; @Override public void onEnable() { createNativesAPI(); nativesAPI.initialize(); NativesAPI.setSingleton(nativesAPI);
getCommand("flyingblocks-removeall").setExecutor(new RemoveAllCommandExecutor(this));
ase34/flyingblocksapi
plugin/src/main/java/de/ase34/flyingblocksapi/FlyingBlocksPlugin.java
// Path: plugin/src/main/java/de/ase34/flyingblocksapi/commands/ExamplesCommandExecutor.java // public class ExamplesCommandExecutor implements CommandExecutor { // // @Override // public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { // if (args.length < 1) { // return false; // } // // String example = args[0]; // CommandExecutor executor; // // if (example.equalsIgnoreCase("flag")) { // executor = new FlagCommandExecutor(); // } else if (example.equalsIgnoreCase("rising")) { // executor = new RisingBlockCommandExecutor(); // } else if (example.equalsIgnoreCase("static")) { // executor = new StaticBlockCommandExecutor(); // } else if (example.equalsIgnoreCase("sinewave")) { // executor = new SineWaveBlockCommandExecutor(); // } else { // return false; // } // // String[] newargs = Arrays.copyOfRange(args, 1, args.length); // return executor.onCommand(sender, command, label, newargs); // // } // // } // // Path: plugin/src/main/java/de/ase34/flyingblocksapi/commands/RemoveAllCommandExecutor.java // public class RemoveAllCommandExecutor implements CommandExecutor { // // private FlyingBlocksPlugin plugin; // // public RemoveAllCommandExecutor(FlyingBlocksPlugin plugin) { // this.plugin = plugin; // } // // @Override // public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { // int counter = 0; // // for (World world : Bukkit.getWorlds()) { // counter += plugin.removeFlyingBlocks(world).size(); // } // // // 3 entities per moving block // counter = counter / 3; // sender.sendMessage(ChatColor.GRAY + "" + counter + " flying " // + (counter == 1 ? "block was" : "blocks were") + " removed!"); // return true; // } // // } // // Path: api/src/main/java/de/ase34/flyingblocksapi/natives/api/NativesAPI.java // public abstract class NativesAPI { // // protected static NativesAPI singleton; // // public static NativesAPI getSingleton() { // return singleton; // } // // public static void setSingleton(NativesAPI singleton) { // NativesAPI.singleton = singleton; // } // // public abstract List<Entity> removeFlyingBlocks(World world); // // public abstract void initialize(); // // public abstract NativeFlyingBlockHandler createFlyingBlockHandler(FlyingBlock flyingBlock); // // }
import java.util.List; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Entity; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.world.WorldUnloadEvent; import org.bukkit.plugin.java.JavaPlugin; import de.ase34.flyingblocksapi.commands.ExamplesCommandExecutor; import de.ase34.flyingblocksapi.commands.RemoveAllCommandExecutor; import de.ase34.flyingblocksapi.natives.api.NativesAPI;
/** * flyingblocksapi Copyright (C) 2014 ase34 and contributors * * 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 3 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, see * <http://www.gnu.org/licenses/>. */ package de.ase34.flyingblocksapi; public class FlyingBlocksPlugin extends JavaPlugin implements Listener { private NativesAPI nativesAPI; @Override public void onEnable() { createNativesAPI(); nativesAPI.initialize(); NativesAPI.setSingleton(nativesAPI); getCommand("flyingblocks-removeall").setExecutor(new RemoveAllCommandExecutor(this));
// Path: plugin/src/main/java/de/ase34/flyingblocksapi/commands/ExamplesCommandExecutor.java // public class ExamplesCommandExecutor implements CommandExecutor { // // @Override // public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { // if (args.length < 1) { // return false; // } // // String example = args[0]; // CommandExecutor executor; // // if (example.equalsIgnoreCase("flag")) { // executor = new FlagCommandExecutor(); // } else if (example.equalsIgnoreCase("rising")) { // executor = new RisingBlockCommandExecutor(); // } else if (example.equalsIgnoreCase("static")) { // executor = new StaticBlockCommandExecutor(); // } else if (example.equalsIgnoreCase("sinewave")) { // executor = new SineWaveBlockCommandExecutor(); // } else { // return false; // } // // String[] newargs = Arrays.copyOfRange(args, 1, args.length); // return executor.onCommand(sender, command, label, newargs); // // } // // } // // Path: plugin/src/main/java/de/ase34/flyingblocksapi/commands/RemoveAllCommandExecutor.java // public class RemoveAllCommandExecutor implements CommandExecutor { // // private FlyingBlocksPlugin plugin; // // public RemoveAllCommandExecutor(FlyingBlocksPlugin plugin) { // this.plugin = plugin; // } // // @Override // public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { // int counter = 0; // // for (World world : Bukkit.getWorlds()) { // counter += plugin.removeFlyingBlocks(world).size(); // } // // // 3 entities per moving block // counter = counter / 3; // sender.sendMessage(ChatColor.GRAY + "" + counter + " flying " // + (counter == 1 ? "block was" : "blocks were") + " removed!"); // return true; // } // // } // // Path: api/src/main/java/de/ase34/flyingblocksapi/natives/api/NativesAPI.java // public abstract class NativesAPI { // // protected static NativesAPI singleton; // // public static NativesAPI getSingleton() { // return singleton; // } // // public static void setSingleton(NativesAPI singleton) { // NativesAPI.singleton = singleton; // } // // public abstract List<Entity> removeFlyingBlocks(World world); // // public abstract void initialize(); // // public abstract NativeFlyingBlockHandler createFlyingBlockHandler(FlyingBlock flyingBlock); // // } // Path: plugin/src/main/java/de/ase34/flyingblocksapi/FlyingBlocksPlugin.java import java.util.List; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Entity; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.world.WorldUnloadEvent; import org.bukkit.plugin.java.JavaPlugin; import de.ase34.flyingblocksapi.commands.ExamplesCommandExecutor; import de.ase34.flyingblocksapi.commands.RemoveAllCommandExecutor; import de.ase34.flyingblocksapi.natives.api.NativesAPI; /** * flyingblocksapi Copyright (C) 2014 ase34 and contributors * * 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 3 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, see * <http://www.gnu.org/licenses/>. */ package de.ase34.flyingblocksapi; public class FlyingBlocksPlugin extends JavaPlugin implements Listener { private NativesAPI nativesAPI; @Override public void onEnable() { createNativesAPI(); nativesAPI.initialize(); NativesAPI.setSingleton(nativesAPI); getCommand("flyingblocks-removeall").setExecutor(new RemoveAllCommandExecutor(this));
getCommand("flyingblocks-examples").setExecutor(new ExamplesCommandExecutor());
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/scenario/ScenarioControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/scenario/BeaconDoesNotHaveScenarioException.java // public class BeaconDoesNotHaveScenarioException extends NullPointerException { // public BeaconDoesNotHaveScenarioException(Long beaconId, Long scenarioId) { // super("The beacon with ID " + beaconId + " is not part of scenario with ID " + scenarioId + ". No modifications have been made."); // } // } // // Path: src/main/java/com/aemreunal/exception/scenario/BeaconHasScenarioException.java // public class BeaconHasScenarioException extends IllegalStateException { // public BeaconHasScenarioException(Long beaconId, Long scenarioId) { // super("The beacon with ID " + beaconId + " is part of scenario with ID " + scenarioId + ". No modifications have been made."); // } // } // // Path: src/main/java/com/aemreunal/exception/scenario/ScenarioNotFoundException.java // public class ScenarioNotFoundException extends NullPointerException { // public ScenarioNotFoundException(Long scenarioId) { // super("The requested Scenario with ID " + scenarioId + " can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.scenario.BeaconDoesNotHaveScenarioException; import com.aemreunal.exception.scenario.BeaconHasScenarioException; import com.aemreunal.exception.scenario.ScenarioNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.scenario; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class ScenarioControllerAdvice {
// Path: src/main/java/com/aemreunal/exception/scenario/BeaconDoesNotHaveScenarioException.java // public class BeaconDoesNotHaveScenarioException extends NullPointerException { // public BeaconDoesNotHaveScenarioException(Long beaconId, Long scenarioId) { // super("The beacon with ID " + beaconId + " is not part of scenario with ID " + scenarioId + ". No modifications have been made."); // } // } // // Path: src/main/java/com/aemreunal/exception/scenario/BeaconHasScenarioException.java // public class BeaconHasScenarioException extends IllegalStateException { // public BeaconHasScenarioException(Long beaconId, Long scenarioId) { // super("The beacon with ID " + beaconId + " is part of scenario with ID " + scenarioId + ". No modifications have been made."); // } // } // // Path: src/main/java/com/aemreunal/exception/scenario/ScenarioNotFoundException.java // public class ScenarioNotFoundException extends NullPointerException { // public ScenarioNotFoundException(Long scenarioId) { // super("The requested Scenario with ID " + scenarioId + " can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/scenario/ScenarioControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.scenario.BeaconDoesNotHaveScenarioException; import com.aemreunal.exception.scenario.BeaconHasScenarioException; import com.aemreunal.exception.scenario.ScenarioNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.scenario; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class ScenarioControllerAdvice {
@ExceptionHandler(ScenarioNotFoundException.class)
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/scenario/ScenarioControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/scenario/BeaconDoesNotHaveScenarioException.java // public class BeaconDoesNotHaveScenarioException extends NullPointerException { // public BeaconDoesNotHaveScenarioException(Long beaconId, Long scenarioId) { // super("The beacon with ID " + beaconId + " is not part of scenario with ID " + scenarioId + ". No modifications have been made."); // } // } // // Path: src/main/java/com/aemreunal/exception/scenario/BeaconHasScenarioException.java // public class BeaconHasScenarioException extends IllegalStateException { // public BeaconHasScenarioException(Long beaconId, Long scenarioId) { // super("The beacon with ID " + beaconId + " is part of scenario with ID " + scenarioId + ". No modifications have been made."); // } // } // // Path: src/main/java/com/aemreunal/exception/scenario/ScenarioNotFoundException.java // public class ScenarioNotFoundException extends NullPointerException { // public ScenarioNotFoundException(Long scenarioId) { // super("The requested Scenario with ID " + scenarioId + " can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.scenario.BeaconDoesNotHaveScenarioException; import com.aemreunal.exception.scenario.BeaconHasScenarioException; import com.aemreunal.exception.scenario.ScenarioNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.scenario; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class ScenarioControllerAdvice { @ExceptionHandler(ScenarioNotFoundException.class) public ResponseEntity<JSONObject> scenarioNotFoundExceptionHandler(ScenarioNotFoundException ex) {
// Path: src/main/java/com/aemreunal/exception/scenario/BeaconDoesNotHaveScenarioException.java // public class BeaconDoesNotHaveScenarioException extends NullPointerException { // public BeaconDoesNotHaveScenarioException(Long beaconId, Long scenarioId) { // super("The beacon with ID " + beaconId + " is not part of scenario with ID " + scenarioId + ". No modifications have been made."); // } // } // // Path: src/main/java/com/aemreunal/exception/scenario/BeaconHasScenarioException.java // public class BeaconHasScenarioException extends IllegalStateException { // public BeaconHasScenarioException(Long beaconId, Long scenarioId) { // super("The beacon with ID " + beaconId + " is part of scenario with ID " + scenarioId + ". No modifications have been made."); // } // } // // Path: src/main/java/com/aemreunal/exception/scenario/ScenarioNotFoundException.java // public class ScenarioNotFoundException extends NullPointerException { // public ScenarioNotFoundException(Long scenarioId) { // super("The requested Scenario with ID " + scenarioId + " can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/scenario/ScenarioControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.scenario.BeaconDoesNotHaveScenarioException; import com.aemreunal.exception.scenario.BeaconHasScenarioException; import com.aemreunal.exception.scenario.ScenarioNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.scenario; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class ScenarioControllerAdvice { @ExceptionHandler(ScenarioNotFoundException.class) public ResponseEntity<JSONObject> scenarioNotFoundExceptionHandler(ScenarioNotFoundException ex) {
JSONObject responseBody = JsonBuilderFactory.object().add("reason", "scenario")
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/scenario/ScenarioControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/scenario/BeaconDoesNotHaveScenarioException.java // public class BeaconDoesNotHaveScenarioException extends NullPointerException { // public BeaconDoesNotHaveScenarioException(Long beaconId, Long scenarioId) { // super("The beacon with ID " + beaconId + " is not part of scenario with ID " + scenarioId + ". No modifications have been made."); // } // } // // Path: src/main/java/com/aemreunal/exception/scenario/BeaconHasScenarioException.java // public class BeaconHasScenarioException extends IllegalStateException { // public BeaconHasScenarioException(Long beaconId, Long scenarioId) { // super("The beacon with ID " + beaconId + " is part of scenario with ID " + scenarioId + ". No modifications have been made."); // } // } // // Path: src/main/java/com/aemreunal/exception/scenario/ScenarioNotFoundException.java // public class ScenarioNotFoundException extends NullPointerException { // public ScenarioNotFoundException(Long scenarioId) { // super("The requested Scenario with ID " + scenarioId + " can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.scenario.BeaconDoesNotHaveScenarioException; import com.aemreunal.exception.scenario.BeaconHasScenarioException; import com.aemreunal.exception.scenario.ScenarioNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.scenario; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class ScenarioControllerAdvice { @ExceptionHandler(ScenarioNotFoundException.class) public ResponseEntity<JSONObject> scenarioNotFoundExceptionHandler(ScenarioNotFoundException ex) { JSONObject responseBody = JsonBuilderFactory.object().add("reason", "scenario") .add("error", ex.getLocalizedMessage()) .build(); return new ResponseEntity<JSONObject>(responseBody, HttpStatus.NOT_FOUND); }
// Path: src/main/java/com/aemreunal/exception/scenario/BeaconDoesNotHaveScenarioException.java // public class BeaconDoesNotHaveScenarioException extends NullPointerException { // public BeaconDoesNotHaveScenarioException(Long beaconId, Long scenarioId) { // super("The beacon with ID " + beaconId + " is not part of scenario with ID " + scenarioId + ". No modifications have been made."); // } // } // // Path: src/main/java/com/aemreunal/exception/scenario/BeaconHasScenarioException.java // public class BeaconHasScenarioException extends IllegalStateException { // public BeaconHasScenarioException(Long beaconId, Long scenarioId) { // super("The beacon with ID " + beaconId + " is part of scenario with ID " + scenarioId + ". No modifications have been made."); // } // } // // Path: src/main/java/com/aemreunal/exception/scenario/ScenarioNotFoundException.java // public class ScenarioNotFoundException extends NullPointerException { // public ScenarioNotFoundException(Long scenarioId) { // super("The requested Scenario with ID " + scenarioId + " can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/scenario/ScenarioControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.scenario.BeaconDoesNotHaveScenarioException; import com.aemreunal.exception.scenario.BeaconHasScenarioException; import com.aemreunal.exception.scenario.ScenarioNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.scenario; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class ScenarioControllerAdvice { @ExceptionHandler(ScenarioNotFoundException.class) public ResponseEntity<JSONObject> scenarioNotFoundExceptionHandler(ScenarioNotFoundException ex) { JSONObject responseBody = JsonBuilderFactory.object().add("reason", "scenario") .add("error", ex.getLocalizedMessage()) .build(); return new ResponseEntity<JSONObject>(responseBody, HttpStatus.NOT_FOUND); }
@ExceptionHandler(BeaconHasScenarioException.class)
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/scenario/ScenarioControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/scenario/BeaconDoesNotHaveScenarioException.java // public class BeaconDoesNotHaveScenarioException extends NullPointerException { // public BeaconDoesNotHaveScenarioException(Long beaconId, Long scenarioId) { // super("The beacon with ID " + beaconId + " is not part of scenario with ID " + scenarioId + ". No modifications have been made."); // } // } // // Path: src/main/java/com/aemreunal/exception/scenario/BeaconHasScenarioException.java // public class BeaconHasScenarioException extends IllegalStateException { // public BeaconHasScenarioException(Long beaconId, Long scenarioId) { // super("The beacon with ID " + beaconId + " is part of scenario with ID " + scenarioId + ". No modifications have been made."); // } // } // // Path: src/main/java/com/aemreunal/exception/scenario/ScenarioNotFoundException.java // public class ScenarioNotFoundException extends NullPointerException { // public ScenarioNotFoundException(Long scenarioId) { // super("The requested Scenario with ID " + scenarioId + " can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.scenario.BeaconDoesNotHaveScenarioException; import com.aemreunal.exception.scenario.BeaconHasScenarioException; import com.aemreunal.exception.scenario.ScenarioNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.scenario; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class ScenarioControllerAdvice { @ExceptionHandler(ScenarioNotFoundException.class) public ResponseEntity<JSONObject> scenarioNotFoundExceptionHandler(ScenarioNotFoundException ex) { JSONObject responseBody = JsonBuilderFactory.object().add("reason", "scenario") .add("error", ex.getLocalizedMessage()) .build(); return new ResponseEntity<JSONObject>(responseBody, HttpStatus.NOT_FOUND); } @ExceptionHandler(BeaconHasScenarioException.class) public ResponseEntity<JSONObject> beaconHasScenarioExceptionHandler(BeaconHasScenarioException ex) { JSONObject responseBody = JsonBuilderFactory.object().add("reason", "scenario") .add("error", ex.getLocalizedMessage()) .build(); return new ResponseEntity<JSONObject>(responseBody, HttpStatus.BAD_REQUEST); }
// Path: src/main/java/com/aemreunal/exception/scenario/BeaconDoesNotHaveScenarioException.java // public class BeaconDoesNotHaveScenarioException extends NullPointerException { // public BeaconDoesNotHaveScenarioException(Long beaconId, Long scenarioId) { // super("The beacon with ID " + beaconId + " is not part of scenario with ID " + scenarioId + ". No modifications have been made."); // } // } // // Path: src/main/java/com/aemreunal/exception/scenario/BeaconHasScenarioException.java // public class BeaconHasScenarioException extends IllegalStateException { // public BeaconHasScenarioException(Long beaconId, Long scenarioId) { // super("The beacon with ID " + beaconId + " is part of scenario with ID " + scenarioId + ". No modifications have been made."); // } // } // // Path: src/main/java/com/aemreunal/exception/scenario/ScenarioNotFoundException.java // public class ScenarioNotFoundException extends NullPointerException { // public ScenarioNotFoundException(Long scenarioId) { // super("The requested Scenario with ID " + scenarioId + " can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/scenario/ScenarioControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.scenario.BeaconDoesNotHaveScenarioException; import com.aemreunal.exception.scenario.BeaconHasScenarioException; import com.aemreunal.exception.scenario.ScenarioNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.scenario; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class ScenarioControllerAdvice { @ExceptionHandler(ScenarioNotFoundException.class) public ResponseEntity<JSONObject> scenarioNotFoundExceptionHandler(ScenarioNotFoundException ex) { JSONObject responseBody = JsonBuilderFactory.object().add("reason", "scenario") .add("error", ex.getLocalizedMessage()) .build(); return new ResponseEntity<JSONObject>(responseBody, HttpStatus.NOT_FOUND); } @ExceptionHandler(BeaconHasScenarioException.class) public ResponseEntity<JSONObject> beaconHasScenarioExceptionHandler(BeaconHasScenarioException ex) { JSONObject responseBody = JsonBuilderFactory.object().add("reason", "scenario") .add("error", ex.getLocalizedMessage()) .build(); return new ResponseEntity<JSONObject>(responseBody, HttpStatus.BAD_REQUEST); }
@ExceptionHandler(BeaconDoesNotHaveScenarioException.class)
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/GeneralControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/MalformedRequestException.java // public class MalformedRequestException /*extends Throwable*/ extends RuntimeException { // // // http://normanmaurer.me/blog/2013/11/09/The-hidden-performance-costs-of-instantiating-Throwables/ // // public MalformedRequestException() { // // super("Your request is malformed. Please try again.", null, true, false); // // } // // public MalformedRequestException() { // super("Your request is malformed. Please try again."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonArrayBuilder.java // public class JsonArrayBuilder { // private ArrayList<Object> jsonList = new ArrayList<>(); // // JsonArrayBuilder() { // } // // public JsonArrayBuilder add(Object item) { // jsonList.add(item); // return this; // } // // public JsonArrayBuilder addAll(Collection items) { // jsonList.addAll(items); // return this; // } // // public JSONArray build() { // JSONArray array = new JSONArray(); // array.addAll(jsonList); // return array; // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONArray; import net.minidev.json.JSONObject; import java.util.Set; import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolationException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.MalformedRequestException; import com.aemreunal.helper.json.JsonArrayBuilder; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class GeneralControllerAdvice {
// Path: src/main/java/com/aemreunal/exception/MalformedRequestException.java // public class MalformedRequestException /*extends Throwable*/ extends RuntimeException { // // // http://normanmaurer.me/blog/2013/11/09/The-hidden-performance-costs-of-instantiating-Throwables/ // // public MalformedRequestException() { // // super("Your request is malformed. Please try again.", null, true, false); // // } // // public MalformedRequestException() { // super("Your request is malformed. Please try again."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonArrayBuilder.java // public class JsonArrayBuilder { // private ArrayList<Object> jsonList = new ArrayList<>(); // // JsonArrayBuilder() { // } // // public JsonArrayBuilder add(Object item) { // jsonList.add(item); // return this; // } // // public JsonArrayBuilder addAll(Collection items) { // jsonList.addAll(items); // return this; // } // // public JSONArray build() { // JSONArray array = new JSONArray(); // array.addAll(jsonList); // return array; // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/GeneralControllerAdvice.java import net.minidev.json.JSONArray; import net.minidev.json.JSONObject; import java.util.Set; import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolationException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.MalformedRequestException; import com.aemreunal.helper.json.JsonArrayBuilder; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class GeneralControllerAdvice {
@ExceptionHandler(MalformedRequestException.class)
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/GeneralControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/MalformedRequestException.java // public class MalformedRequestException /*extends Throwable*/ extends RuntimeException { // // // http://normanmaurer.me/blog/2013/11/09/The-hidden-performance-costs-of-instantiating-Throwables/ // // public MalformedRequestException() { // // super("Your request is malformed. Please try again.", null, true, false); // // } // // public MalformedRequestException() { // super("Your request is malformed. Please try again."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonArrayBuilder.java // public class JsonArrayBuilder { // private ArrayList<Object> jsonList = new ArrayList<>(); // // JsonArrayBuilder() { // } // // public JsonArrayBuilder add(Object item) { // jsonList.add(item); // return this; // } // // public JsonArrayBuilder addAll(Collection items) { // jsonList.addAll(items); // return this; // } // // public JSONArray build() { // JSONArray array = new JSONArray(); // array.addAll(jsonList); // return array; // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONArray; import net.minidev.json.JSONObject; import java.util.Set; import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolationException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.MalformedRequestException; import com.aemreunal.helper.json.JsonArrayBuilder; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class GeneralControllerAdvice { @ExceptionHandler(MalformedRequestException.class) public ResponseEntity<JSONObject> malformedRequestExceptionHandler(MalformedRequestException ex) {
// Path: src/main/java/com/aemreunal/exception/MalformedRequestException.java // public class MalformedRequestException /*extends Throwable*/ extends RuntimeException { // // // http://normanmaurer.me/blog/2013/11/09/The-hidden-performance-costs-of-instantiating-Throwables/ // // public MalformedRequestException() { // // super("Your request is malformed. Please try again.", null, true, false); // // } // // public MalformedRequestException() { // super("Your request is malformed. Please try again."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonArrayBuilder.java // public class JsonArrayBuilder { // private ArrayList<Object> jsonList = new ArrayList<>(); // // JsonArrayBuilder() { // } // // public JsonArrayBuilder add(Object item) { // jsonList.add(item); // return this; // } // // public JsonArrayBuilder addAll(Collection items) { // jsonList.addAll(items); // return this; // } // // public JSONArray build() { // JSONArray array = new JSONArray(); // array.addAll(jsonList); // return array; // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/GeneralControllerAdvice.java import net.minidev.json.JSONArray; import net.minidev.json.JSONObject; import java.util.Set; import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolationException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.MalformedRequestException; import com.aemreunal.helper.json.JsonArrayBuilder; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class GeneralControllerAdvice { @ExceptionHandler(MalformedRequestException.class) public ResponseEntity<JSONObject> malformedRequestExceptionHandler(MalformedRequestException ex) {
JSONObject responseBody = JsonBuilderFactory.object().add("reason", "request")
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/GeneralControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/MalformedRequestException.java // public class MalformedRequestException /*extends Throwable*/ extends RuntimeException { // // // http://normanmaurer.me/blog/2013/11/09/The-hidden-performance-costs-of-instantiating-Throwables/ // // public MalformedRequestException() { // // super("Your request is malformed. Please try again.", null, true, false); // // } // // public MalformedRequestException() { // super("Your request is malformed. Please try again."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonArrayBuilder.java // public class JsonArrayBuilder { // private ArrayList<Object> jsonList = new ArrayList<>(); // // JsonArrayBuilder() { // } // // public JsonArrayBuilder add(Object item) { // jsonList.add(item); // return this; // } // // public JsonArrayBuilder addAll(Collection items) { // jsonList.addAll(items); // return this; // } // // public JSONArray build() { // JSONArray array = new JSONArray(); // array.addAll(jsonList); // return array; // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONArray; import net.minidev.json.JSONObject; import java.util.Set; import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolationException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.MalformedRequestException; import com.aemreunal.helper.json.JsonArrayBuilder; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class GeneralControllerAdvice { @ExceptionHandler(MalformedRequestException.class) public ResponseEntity<JSONObject> malformedRequestExceptionHandler(MalformedRequestException ex) { JSONObject responseBody = JsonBuilderFactory.object().add("reason", "request") .add("error", ex.getLocalizedMessage()) .build(); return new ResponseEntity<JSONObject>(responseBody, HttpStatus.BAD_REQUEST); } @ExceptionHandler(ConstraintViolationException.class) public ResponseEntity<JSONObject> constraintViolationExceptionHandler(ConstraintViolationException ex) { JSONObject responseBody = JsonBuilderFactory.object().add("error", "Constraint violation error occurred! Unable to save entity.") .add("violations", formatViolations(ex.getConstraintViolations())) .build(); return new ResponseEntity<JSONObject>(responseBody, HttpStatus.BAD_REQUEST); } private JSONArray formatViolations(Set<ConstraintViolation<?>> violations) {
// Path: src/main/java/com/aemreunal/exception/MalformedRequestException.java // public class MalformedRequestException /*extends Throwable*/ extends RuntimeException { // // // http://normanmaurer.me/blog/2013/11/09/The-hidden-performance-costs-of-instantiating-Throwables/ // // public MalformedRequestException() { // // super("Your request is malformed. Please try again.", null, true, false); // // } // // public MalformedRequestException() { // super("Your request is malformed. Please try again."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonArrayBuilder.java // public class JsonArrayBuilder { // private ArrayList<Object> jsonList = new ArrayList<>(); // // JsonArrayBuilder() { // } // // public JsonArrayBuilder add(Object item) { // jsonList.add(item); // return this; // } // // public JsonArrayBuilder addAll(Collection items) { // jsonList.addAll(items); // return this; // } // // public JSONArray build() { // JSONArray array = new JSONArray(); // array.addAll(jsonList); // return array; // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/GeneralControllerAdvice.java import net.minidev.json.JSONArray; import net.minidev.json.JSONObject; import java.util.Set; import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolationException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.MalformedRequestException; import com.aemreunal.helper.json.JsonArrayBuilder; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class GeneralControllerAdvice { @ExceptionHandler(MalformedRequestException.class) public ResponseEntity<JSONObject> malformedRequestExceptionHandler(MalformedRequestException ex) { JSONObject responseBody = JsonBuilderFactory.object().add("reason", "request") .add("error", ex.getLocalizedMessage()) .build(); return new ResponseEntity<JSONObject>(responseBody, HttpStatus.BAD_REQUEST); } @ExceptionHandler(ConstraintViolationException.class) public ResponseEntity<JSONObject> constraintViolationExceptionHandler(ConstraintViolationException ex) { JSONObject responseBody = JsonBuilderFactory.object().add("error", "Constraint violation error occurred! Unable to save entity.") .add("violations", formatViolations(ex.getConstraintViolations())) .build(); return new ResponseEntity<JSONObject>(responseBody, HttpStatus.BAD_REQUEST); } private JSONArray formatViolations(Set<ConstraintViolation<?>> violations) {
JsonArrayBuilder arrayBuilder = JsonBuilderFactory.array();
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/region/RegionControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/imageStorage/ImageDeleteException.java // public class ImageDeleteException extends Exception { // public ImageDeleteException(Long projectId, Long regionId) { // super("Unable to delete the image file of project " + projectId + ", region " + regionId + "!"); // } // } // // Path: src/main/java/com/aemreunal/exception/imageStorage/ImageLoadException.java // public class ImageLoadException extends Exception { // public ImageLoadException(Long projectId, Long regionId) { // super(getExceptionMessage(projectId, regionId)); // } // // private static String getExceptionMessage(Long projectId, Long regionId) { // if (regionId == null) { // return "Unable to load the image file of project " + projectId + "!"; // } else { // return "Unable to load the image file of project " + projectId + ", region " + regionId + "!"; // } // } // } // // Path: src/main/java/com/aemreunal/exception/imageStorage/ImageSaveException.java // public class ImageSaveException extends Exception { // public ImageSaveException(Long projectId, Long regionId) { // super(createCauseMessage(projectId, regionId)); // } // // public static String createCauseMessage(Long projectId, Long regionId) { // String message = "Unable to save "; // if (regionId != null) { // return message + "map image of project " + projectId + ", region " + regionId + "!"; // } else { // return message + "a navigation image of project " + projectId + "!"; // } // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.multipart.MultipartException; import com.aemreunal.exception.imageStorage.ImageDeleteException; import com.aemreunal.exception.imageStorage.ImageLoadException; import com.aemreunal.exception.imageStorage.ImageSaveException; import com.aemreunal.exception.region.*; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.region; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class RegionControllerAdvice { @ExceptionHandler(RegionNotFoundException.class) public ResponseEntity<JSONObject> regionNotFoundExceptionHandler(RegionNotFoundException ex) { return new ResponseEntity<JSONObject>(getErrorResponseBody(ex), HttpStatus.NOT_FOUND); }
// Path: src/main/java/com/aemreunal/exception/imageStorage/ImageDeleteException.java // public class ImageDeleteException extends Exception { // public ImageDeleteException(Long projectId, Long regionId) { // super("Unable to delete the image file of project " + projectId + ", region " + regionId + "!"); // } // } // // Path: src/main/java/com/aemreunal/exception/imageStorage/ImageLoadException.java // public class ImageLoadException extends Exception { // public ImageLoadException(Long projectId, Long regionId) { // super(getExceptionMessage(projectId, regionId)); // } // // private static String getExceptionMessage(Long projectId, Long regionId) { // if (regionId == null) { // return "Unable to load the image file of project " + projectId + "!"; // } else { // return "Unable to load the image file of project " + projectId + ", region " + regionId + "!"; // } // } // } // // Path: src/main/java/com/aemreunal/exception/imageStorage/ImageSaveException.java // public class ImageSaveException extends Exception { // public ImageSaveException(Long projectId, Long regionId) { // super(createCauseMessage(projectId, regionId)); // } // // public static String createCauseMessage(Long projectId, Long regionId) { // String message = "Unable to save "; // if (regionId != null) { // return message + "map image of project " + projectId + ", region " + regionId + "!"; // } else { // return message + "a navigation image of project " + projectId + "!"; // } // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/region/RegionControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.multipart.MultipartException; import com.aemreunal.exception.imageStorage.ImageDeleteException; import com.aemreunal.exception.imageStorage.ImageLoadException; import com.aemreunal.exception.imageStorage.ImageSaveException; import com.aemreunal.exception.region.*; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.region; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class RegionControllerAdvice { @ExceptionHandler(RegionNotFoundException.class) public ResponseEntity<JSONObject> regionNotFoundExceptionHandler(RegionNotFoundException ex) { return new ResponseEntity<JSONObject>(getErrorResponseBody(ex), HttpStatus.NOT_FOUND); }
@ExceptionHandler({ ImageSaveException.class, ImageLoadException.class, ImageDeleteException.class })
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/region/RegionControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/imageStorage/ImageDeleteException.java // public class ImageDeleteException extends Exception { // public ImageDeleteException(Long projectId, Long regionId) { // super("Unable to delete the image file of project " + projectId + ", region " + regionId + "!"); // } // } // // Path: src/main/java/com/aemreunal/exception/imageStorage/ImageLoadException.java // public class ImageLoadException extends Exception { // public ImageLoadException(Long projectId, Long regionId) { // super(getExceptionMessage(projectId, regionId)); // } // // private static String getExceptionMessage(Long projectId, Long regionId) { // if (regionId == null) { // return "Unable to load the image file of project " + projectId + "!"; // } else { // return "Unable to load the image file of project " + projectId + ", region " + regionId + "!"; // } // } // } // // Path: src/main/java/com/aemreunal/exception/imageStorage/ImageSaveException.java // public class ImageSaveException extends Exception { // public ImageSaveException(Long projectId, Long regionId) { // super(createCauseMessage(projectId, regionId)); // } // // public static String createCauseMessage(Long projectId, Long regionId) { // String message = "Unable to save "; // if (regionId != null) { // return message + "map image of project " + projectId + ", region " + regionId + "!"; // } else { // return message + "a navigation image of project " + projectId + "!"; // } // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.multipart.MultipartException; import com.aemreunal.exception.imageStorage.ImageDeleteException; import com.aemreunal.exception.imageStorage.ImageLoadException; import com.aemreunal.exception.imageStorage.ImageSaveException; import com.aemreunal.exception.region.*; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.region; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class RegionControllerAdvice { @ExceptionHandler(RegionNotFoundException.class) public ResponseEntity<JSONObject> regionNotFoundExceptionHandler(RegionNotFoundException ex) { return new ResponseEntity<JSONObject>(getErrorResponseBody(ex), HttpStatus.NOT_FOUND); }
// Path: src/main/java/com/aemreunal/exception/imageStorage/ImageDeleteException.java // public class ImageDeleteException extends Exception { // public ImageDeleteException(Long projectId, Long regionId) { // super("Unable to delete the image file of project " + projectId + ", region " + regionId + "!"); // } // } // // Path: src/main/java/com/aemreunal/exception/imageStorage/ImageLoadException.java // public class ImageLoadException extends Exception { // public ImageLoadException(Long projectId, Long regionId) { // super(getExceptionMessage(projectId, regionId)); // } // // private static String getExceptionMessage(Long projectId, Long regionId) { // if (regionId == null) { // return "Unable to load the image file of project " + projectId + "!"; // } else { // return "Unable to load the image file of project " + projectId + ", region " + regionId + "!"; // } // } // } // // Path: src/main/java/com/aemreunal/exception/imageStorage/ImageSaveException.java // public class ImageSaveException extends Exception { // public ImageSaveException(Long projectId, Long regionId) { // super(createCauseMessage(projectId, regionId)); // } // // public static String createCauseMessage(Long projectId, Long regionId) { // String message = "Unable to save "; // if (regionId != null) { // return message + "map image of project " + projectId + ", region " + regionId + "!"; // } else { // return message + "a navigation image of project " + projectId + "!"; // } // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/region/RegionControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.multipart.MultipartException; import com.aemreunal.exception.imageStorage.ImageDeleteException; import com.aemreunal.exception.imageStorage.ImageLoadException; import com.aemreunal.exception.imageStorage.ImageSaveException; import com.aemreunal.exception.region.*; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.region; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class RegionControllerAdvice { @ExceptionHandler(RegionNotFoundException.class) public ResponseEntity<JSONObject> regionNotFoundExceptionHandler(RegionNotFoundException ex) { return new ResponseEntity<JSONObject>(getErrorResponseBody(ex), HttpStatus.NOT_FOUND); }
@ExceptionHandler({ ImageSaveException.class, ImageLoadException.class, ImageDeleteException.class })
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/region/RegionControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/imageStorage/ImageDeleteException.java // public class ImageDeleteException extends Exception { // public ImageDeleteException(Long projectId, Long regionId) { // super("Unable to delete the image file of project " + projectId + ", region " + regionId + "!"); // } // } // // Path: src/main/java/com/aemreunal/exception/imageStorage/ImageLoadException.java // public class ImageLoadException extends Exception { // public ImageLoadException(Long projectId, Long regionId) { // super(getExceptionMessage(projectId, regionId)); // } // // private static String getExceptionMessage(Long projectId, Long regionId) { // if (regionId == null) { // return "Unable to load the image file of project " + projectId + "!"; // } else { // return "Unable to load the image file of project " + projectId + ", region " + regionId + "!"; // } // } // } // // Path: src/main/java/com/aemreunal/exception/imageStorage/ImageSaveException.java // public class ImageSaveException extends Exception { // public ImageSaveException(Long projectId, Long regionId) { // super(createCauseMessage(projectId, regionId)); // } // // public static String createCauseMessage(Long projectId, Long regionId) { // String message = "Unable to save "; // if (regionId != null) { // return message + "map image of project " + projectId + ", region " + regionId + "!"; // } else { // return message + "a navigation image of project " + projectId + "!"; // } // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.multipart.MultipartException; import com.aemreunal.exception.imageStorage.ImageDeleteException; import com.aemreunal.exception.imageStorage.ImageLoadException; import com.aemreunal.exception.imageStorage.ImageSaveException; import com.aemreunal.exception.region.*; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.region; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class RegionControllerAdvice { @ExceptionHandler(RegionNotFoundException.class) public ResponseEntity<JSONObject> regionNotFoundExceptionHandler(RegionNotFoundException ex) { return new ResponseEntity<JSONObject>(getErrorResponseBody(ex), HttpStatus.NOT_FOUND); }
// Path: src/main/java/com/aemreunal/exception/imageStorage/ImageDeleteException.java // public class ImageDeleteException extends Exception { // public ImageDeleteException(Long projectId, Long regionId) { // super("Unable to delete the image file of project " + projectId + ", region " + regionId + "!"); // } // } // // Path: src/main/java/com/aemreunal/exception/imageStorage/ImageLoadException.java // public class ImageLoadException extends Exception { // public ImageLoadException(Long projectId, Long regionId) { // super(getExceptionMessage(projectId, regionId)); // } // // private static String getExceptionMessage(Long projectId, Long regionId) { // if (regionId == null) { // return "Unable to load the image file of project " + projectId + "!"; // } else { // return "Unable to load the image file of project " + projectId + ", region " + regionId + "!"; // } // } // } // // Path: src/main/java/com/aemreunal/exception/imageStorage/ImageSaveException.java // public class ImageSaveException extends Exception { // public ImageSaveException(Long projectId, Long regionId) { // super(createCauseMessage(projectId, regionId)); // } // // public static String createCauseMessage(Long projectId, Long regionId) { // String message = "Unable to save "; // if (regionId != null) { // return message + "map image of project " + projectId + ", region " + regionId + "!"; // } else { // return message + "a navigation image of project " + projectId + "!"; // } // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/region/RegionControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.multipart.MultipartException; import com.aemreunal.exception.imageStorage.ImageDeleteException; import com.aemreunal.exception.imageStorage.ImageLoadException; import com.aemreunal.exception.imageStorage.ImageSaveException; import com.aemreunal.exception.region.*; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.region; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class RegionControllerAdvice { @ExceptionHandler(RegionNotFoundException.class) public ResponseEntity<JSONObject> regionNotFoundExceptionHandler(RegionNotFoundException ex) { return new ResponseEntity<JSONObject>(getErrorResponseBody(ex), HttpStatus.NOT_FOUND); }
@ExceptionHandler({ ImageSaveException.class, ImageLoadException.class, ImageDeleteException.class })
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/region/RegionControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/imageStorage/ImageDeleteException.java // public class ImageDeleteException extends Exception { // public ImageDeleteException(Long projectId, Long regionId) { // super("Unable to delete the image file of project " + projectId + ", region " + regionId + "!"); // } // } // // Path: src/main/java/com/aemreunal/exception/imageStorage/ImageLoadException.java // public class ImageLoadException extends Exception { // public ImageLoadException(Long projectId, Long regionId) { // super(getExceptionMessage(projectId, regionId)); // } // // private static String getExceptionMessage(Long projectId, Long regionId) { // if (regionId == null) { // return "Unable to load the image file of project " + projectId + "!"; // } else { // return "Unable to load the image file of project " + projectId + ", region " + regionId + "!"; // } // } // } // // Path: src/main/java/com/aemreunal/exception/imageStorage/ImageSaveException.java // public class ImageSaveException extends Exception { // public ImageSaveException(Long projectId, Long regionId) { // super(createCauseMessage(projectId, regionId)); // } // // public static String createCauseMessage(Long projectId, Long regionId) { // String message = "Unable to save "; // if (regionId != null) { // return message + "map image of project " + projectId + ", region " + regionId + "!"; // } else { // return message + "a navigation image of project " + projectId + "!"; // } // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.multipart.MultipartException; import com.aemreunal.exception.imageStorage.ImageDeleteException; import com.aemreunal.exception.imageStorage.ImageLoadException; import com.aemreunal.exception.imageStorage.ImageSaveException; import com.aemreunal.exception.region.*; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.region; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class RegionControllerAdvice { @ExceptionHandler(RegionNotFoundException.class) public ResponseEntity<JSONObject> regionNotFoundExceptionHandler(RegionNotFoundException ex) { return new ResponseEntity<JSONObject>(getErrorResponseBody(ex), HttpStatus.NOT_FOUND); } @ExceptionHandler({ ImageSaveException.class, ImageLoadException.class, ImageDeleteException.class }) public ResponseEntity<JSONObject> internalErrorExceptionHandler(Exception ex) { return new ResponseEntity<JSONObject>(getErrorResponseBody(ex), HttpStatus.INTERNAL_SERVER_ERROR); } @ExceptionHandler({ MultipartException.class, MultipartFileReadException.class }) public ResponseEntity<JSONObject> multipartRequestExceptionHandler(MultipartException ex) { return new ResponseEntity<JSONObject>(getErrorResponseBody(ex), HttpStatus.BAD_REQUEST); } @ExceptionHandler(WrongFileTypeSubmittedException.class) public ResponseEntity<JSONObject> wrongFileTypeSubmittedExceptionHandler(WrongFileTypeSubmittedException ex) { return new ResponseEntity<JSONObject>(getErrorResponseBody(ex), HttpStatus.UNSUPPORTED_MEDIA_TYPE); } private JSONObject getErrorResponseBody(Exception ex) {
// Path: src/main/java/com/aemreunal/exception/imageStorage/ImageDeleteException.java // public class ImageDeleteException extends Exception { // public ImageDeleteException(Long projectId, Long regionId) { // super("Unable to delete the image file of project " + projectId + ", region " + regionId + "!"); // } // } // // Path: src/main/java/com/aemreunal/exception/imageStorage/ImageLoadException.java // public class ImageLoadException extends Exception { // public ImageLoadException(Long projectId, Long regionId) { // super(getExceptionMessage(projectId, regionId)); // } // // private static String getExceptionMessage(Long projectId, Long regionId) { // if (regionId == null) { // return "Unable to load the image file of project " + projectId + "!"; // } else { // return "Unable to load the image file of project " + projectId + ", region " + regionId + "!"; // } // } // } // // Path: src/main/java/com/aemreunal/exception/imageStorage/ImageSaveException.java // public class ImageSaveException extends Exception { // public ImageSaveException(Long projectId, Long regionId) { // super(createCauseMessage(projectId, regionId)); // } // // public static String createCauseMessage(Long projectId, Long regionId) { // String message = "Unable to save "; // if (regionId != null) { // return message + "map image of project " + projectId + ", region " + regionId + "!"; // } else { // return message + "a navigation image of project " + projectId + "!"; // } // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/region/RegionControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.multipart.MultipartException; import com.aemreunal.exception.imageStorage.ImageDeleteException; import com.aemreunal.exception.imageStorage.ImageLoadException; import com.aemreunal.exception.imageStorage.ImageSaveException; import com.aemreunal.exception.region.*; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.region; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class RegionControllerAdvice { @ExceptionHandler(RegionNotFoundException.class) public ResponseEntity<JSONObject> regionNotFoundExceptionHandler(RegionNotFoundException ex) { return new ResponseEntity<JSONObject>(getErrorResponseBody(ex), HttpStatus.NOT_FOUND); } @ExceptionHandler({ ImageSaveException.class, ImageLoadException.class, ImageDeleteException.class }) public ResponseEntity<JSONObject> internalErrorExceptionHandler(Exception ex) { return new ResponseEntity<JSONObject>(getErrorResponseBody(ex), HttpStatus.INTERNAL_SERVER_ERROR); } @ExceptionHandler({ MultipartException.class, MultipartFileReadException.class }) public ResponseEntity<JSONObject> multipartRequestExceptionHandler(MultipartException ex) { return new ResponseEntity<JSONObject>(getErrorResponseBody(ex), HttpStatus.BAD_REQUEST); } @ExceptionHandler(WrongFileTypeSubmittedException.class) public ResponseEntity<JSONObject> wrongFileTypeSubmittedExceptionHandler(WrongFileTypeSubmittedException ex) { return new ResponseEntity<JSONObject>(getErrorResponseBody(ex), HttpStatus.UNSUPPORTED_MEDIA_TYPE); } private JSONObject getErrorResponseBody(Exception ex) {
return JsonBuilderFactory.object().add("reason", "region")
aemreunal/iBeaconServer
src/main/java/com/aemreunal/domain/Beacon.java
// Path: src/main/java/com/aemreunal/helper/json/JsonArrayBuilder.java // public class JsonArrayBuilder { // private ArrayList<Object> jsonList = new ArrayList<>(); // // JsonArrayBuilder() { // } // // public JsonArrayBuilder add(Object item) { // jsonList.add(item); // return this; // } // // public JsonArrayBuilder addAll(Collection items) { // jsonList.addAll(items); // return this; // } // // public JSONArray build() { // JSONArray array = new JSONArray(); // array.addAll(jsonList); // return array; // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import net.minidev.json.JSONArray; import net.minidev.json.JSONObject; import java.io.Serializable; import java.util.Date; import java.util.LinkedHashSet; import java.util.Set; import javax.persistence.*; import javax.validation.constraints.Size; import org.springframework.hateoas.ResourceSupport; import org.springframework.web.bind.annotation.ResponseBody; import com.aemreunal.helper.json.JsonArrayBuilder; import com.aemreunal.helper.json.JsonBuilderFactory; import com.fasterxml.jackson.annotation.JsonIgnore;
public Beacon() { // Empty constructor for Spring & Hibernate } /* * END: Constructors *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Helpers */ public void addConnection(Connection connection) { this.getConnections().add(connection); } public void removeConnection(Connection connection) { this.getConnections().remove(connection); } @JsonSerialize public boolean hasLocationInfo() { return getLocationInfoTextFileName() != null; } // Weird stuff: when this method is named something like 'getConnectionsJson', // 'getConnectionsList', 'getConnectionsAsList', Jackson tries to use it and // causes a LazyInit exception. @JsonIgnore public JSONArray getConnsAsJson() {
// Path: src/main/java/com/aemreunal/helper/json/JsonArrayBuilder.java // public class JsonArrayBuilder { // private ArrayList<Object> jsonList = new ArrayList<>(); // // JsonArrayBuilder() { // } // // public JsonArrayBuilder add(Object item) { // jsonList.add(item); // return this; // } // // public JsonArrayBuilder addAll(Collection items) { // jsonList.addAll(items); // return this; // } // // public JSONArray build() { // JSONArray array = new JSONArray(); // array.addAll(jsonList); // return array; // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/domain/Beacon.java import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import net.minidev.json.JSONArray; import net.minidev.json.JSONObject; import java.io.Serializable; import java.util.Date; import java.util.LinkedHashSet; import java.util.Set; import javax.persistence.*; import javax.validation.constraints.Size; import org.springframework.hateoas.ResourceSupport; import org.springframework.web.bind.annotation.ResponseBody; import com.aemreunal.helper.json.JsonArrayBuilder; import com.aemreunal.helper.json.JsonBuilderFactory; import com.fasterxml.jackson.annotation.JsonIgnore; public Beacon() { // Empty constructor for Spring & Hibernate } /* * END: Constructors *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Helpers */ public void addConnection(Connection connection) { this.getConnections().add(connection); } public void removeConnection(Connection connection) { this.getConnections().remove(connection); } @JsonSerialize public boolean hasLocationInfo() { return getLocationInfoTextFileName() != null; } // Weird stuff: when this method is named something like 'getConnectionsJson', // 'getConnectionsList', 'getConnectionsAsList', Jackson tries to use it and // causes a LazyInit exception. @JsonIgnore public JSONArray getConnsAsJson() {
JsonArrayBuilder connArray = JsonBuilderFactory.array();
aemreunal/iBeaconServer
src/main/java/com/aemreunal/domain/Beacon.java
// Path: src/main/java/com/aemreunal/helper/json/JsonArrayBuilder.java // public class JsonArrayBuilder { // private ArrayList<Object> jsonList = new ArrayList<>(); // // JsonArrayBuilder() { // } // // public JsonArrayBuilder add(Object item) { // jsonList.add(item); // return this; // } // // public JsonArrayBuilder addAll(Collection items) { // jsonList.addAll(items); // return this; // } // // public JSONArray build() { // JSONArray array = new JSONArray(); // array.addAll(jsonList); // return array; // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import net.minidev.json.JSONArray; import net.minidev.json.JSONObject; import java.io.Serializable; import java.util.Date; import java.util.LinkedHashSet; import java.util.Set; import javax.persistence.*; import javax.validation.constraints.Size; import org.springframework.hateoas.ResourceSupport; import org.springframework.web.bind.annotation.ResponseBody; import com.aemreunal.helper.json.JsonArrayBuilder; import com.aemreunal.helper.json.JsonBuilderFactory; import com.fasterxml.jackson.annotation.JsonIgnore;
public Beacon() { // Empty constructor for Spring & Hibernate } /* * END: Constructors *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Helpers */ public void addConnection(Connection connection) { this.getConnections().add(connection); } public void removeConnection(Connection connection) { this.getConnections().remove(connection); } @JsonSerialize public boolean hasLocationInfo() { return getLocationInfoTextFileName() != null; } // Weird stuff: when this method is named something like 'getConnectionsJson', // 'getConnectionsList', 'getConnectionsAsList', Jackson tries to use it and // causes a LazyInit exception. @JsonIgnore public JSONArray getConnsAsJson() {
// Path: src/main/java/com/aemreunal/helper/json/JsonArrayBuilder.java // public class JsonArrayBuilder { // private ArrayList<Object> jsonList = new ArrayList<>(); // // JsonArrayBuilder() { // } // // public JsonArrayBuilder add(Object item) { // jsonList.add(item); // return this; // } // // public JsonArrayBuilder addAll(Collection items) { // jsonList.addAll(items); // return this; // } // // public JSONArray build() { // JSONArray array = new JSONArray(); // array.addAll(jsonList); // return array; // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/domain/Beacon.java import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import net.minidev.json.JSONArray; import net.minidev.json.JSONObject; import java.io.Serializable; import java.util.Date; import java.util.LinkedHashSet; import java.util.Set; import javax.persistence.*; import javax.validation.constraints.Size; import org.springframework.hateoas.ResourceSupport; import org.springframework.web.bind.annotation.ResponseBody; import com.aemreunal.helper.json.JsonArrayBuilder; import com.aemreunal.helper.json.JsonBuilderFactory; import com.fasterxml.jackson.annotation.JsonIgnore; public Beacon() { // Empty constructor for Spring & Hibernate } /* * END: Constructors *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Helpers */ public void addConnection(Connection connection) { this.getConnections().add(connection); } public void removeConnection(Connection connection) { this.getConnections().remove(connection); } @JsonSerialize public boolean hasLocationInfo() { return getLocationInfoTextFileName() != null; } // Weird stuff: when this method is named something like 'getConnectionsJson', // 'getConnectionsList', 'getConnectionsAsList', Jackson tries to use it and // causes a LazyInit exception. @JsonIgnore public JSONArray getConnsAsJson() {
JsonArrayBuilder connArray = JsonBuilderFactory.array();
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/project/ProjectControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/project/ProjectNotFoundException.java // public class ProjectNotFoundException extends NullPointerException { // public ProjectNotFoundException() { // super("The requested project can not be found."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.project.ProjectNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.project; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class ProjectControllerAdvice {
// Path: src/main/java/com/aemreunal/exception/project/ProjectNotFoundException.java // public class ProjectNotFoundException extends NullPointerException { // public ProjectNotFoundException() { // super("The requested project can not be found."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/project/ProjectControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.project.ProjectNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.project; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class ProjectControllerAdvice {
@ExceptionHandler(ProjectNotFoundException.class)
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/project/ProjectControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/project/ProjectNotFoundException.java // public class ProjectNotFoundException extends NullPointerException { // public ProjectNotFoundException() { // super("The requested project can not be found."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.project.ProjectNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.project; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class ProjectControllerAdvice { @ExceptionHandler(ProjectNotFoundException.class) public ResponseEntity<JSONObject> projectNotFoundExceptionHandler(ProjectNotFoundException ex) {
// Path: src/main/java/com/aemreunal/exception/project/ProjectNotFoundException.java // public class ProjectNotFoundException extends NullPointerException { // public ProjectNotFoundException() { // super("The requested project can not be found."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/project/ProjectControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.project.ProjectNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.project; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class ProjectControllerAdvice { @ExceptionHandler(ProjectNotFoundException.class) public ResponseEntity<JSONObject> projectNotFoundExceptionHandler(ProjectNotFoundException ex) {
JSONObject responseBody = JsonBuilderFactory.object().add("reason", "project")
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/user/UserControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/user/InvalidUsernameException.java // public class InvalidUsernameException extends IllegalArgumentException { // public InvalidUsernameException(String causingUsername, String reason) { // super("Username \'" + causingUsername + "\' is invalid! " + reason); // } // } // // Path: src/main/java/com/aemreunal/exception/user/UserNotFoundException.java // public class UserNotFoundException extends NullPointerException { // public UserNotFoundException() { // super("The requested user can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/exception/user/UsernameClashException.java // public class UsernameClashException extends IllegalArgumentException { // public UsernameClashException(String causingUsername) { // super("Username \'" + causingUsername + "\' is already taken. Please choose another username."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.user.InvalidUsernameException; import com.aemreunal.exception.user.UserNotFoundException; import com.aemreunal.exception.user.UsernameClashException; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.user; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class UserControllerAdvice {
// Path: src/main/java/com/aemreunal/exception/user/InvalidUsernameException.java // public class InvalidUsernameException extends IllegalArgumentException { // public InvalidUsernameException(String causingUsername, String reason) { // super("Username \'" + causingUsername + "\' is invalid! " + reason); // } // } // // Path: src/main/java/com/aemreunal/exception/user/UserNotFoundException.java // public class UserNotFoundException extends NullPointerException { // public UserNotFoundException() { // super("The requested user can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/exception/user/UsernameClashException.java // public class UsernameClashException extends IllegalArgumentException { // public UsernameClashException(String causingUsername) { // super("Username \'" + causingUsername + "\' is already taken. Please choose another username."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/user/UserControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.user.InvalidUsernameException; import com.aemreunal.exception.user.UserNotFoundException; import com.aemreunal.exception.user.UsernameClashException; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.user; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class UserControllerAdvice {
@ExceptionHandler(UsernameClashException.class)
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/user/UserControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/user/InvalidUsernameException.java // public class InvalidUsernameException extends IllegalArgumentException { // public InvalidUsernameException(String causingUsername, String reason) { // super("Username \'" + causingUsername + "\' is invalid! " + reason); // } // } // // Path: src/main/java/com/aemreunal/exception/user/UserNotFoundException.java // public class UserNotFoundException extends NullPointerException { // public UserNotFoundException() { // super("The requested user can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/exception/user/UsernameClashException.java // public class UsernameClashException extends IllegalArgumentException { // public UsernameClashException(String causingUsername) { // super("Username \'" + causingUsername + "\' is already taken. Please choose another username."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.user.InvalidUsernameException; import com.aemreunal.exception.user.UserNotFoundException; import com.aemreunal.exception.user.UsernameClashException; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.user; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class UserControllerAdvice { @ExceptionHandler(UsernameClashException.class) public ResponseEntity<JSONObject> usernameClashExceptionHandler(UsernameClashException ex) {
// Path: src/main/java/com/aemreunal/exception/user/InvalidUsernameException.java // public class InvalidUsernameException extends IllegalArgumentException { // public InvalidUsernameException(String causingUsername, String reason) { // super("Username \'" + causingUsername + "\' is invalid! " + reason); // } // } // // Path: src/main/java/com/aemreunal/exception/user/UserNotFoundException.java // public class UserNotFoundException extends NullPointerException { // public UserNotFoundException() { // super("The requested user can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/exception/user/UsernameClashException.java // public class UsernameClashException extends IllegalArgumentException { // public UsernameClashException(String causingUsername) { // super("Username \'" + causingUsername + "\' is already taken. Please choose another username."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/user/UserControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.user.InvalidUsernameException; import com.aemreunal.exception.user.UserNotFoundException; import com.aemreunal.exception.user.UsernameClashException; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.user; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class UserControllerAdvice { @ExceptionHandler(UsernameClashException.class) public ResponseEntity<JSONObject> usernameClashExceptionHandler(UsernameClashException ex) {
JSONObject responseBody = JsonBuilderFactory.object().add("reason", "username")
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/user/UserControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/user/InvalidUsernameException.java // public class InvalidUsernameException extends IllegalArgumentException { // public InvalidUsernameException(String causingUsername, String reason) { // super("Username \'" + causingUsername + "\' is invalid! " + reason); // } // } // // Path: src/main/java/com/aemreunal/exception/user/UserNotFoundException.java // public class UserNotFoundException extends NullPointerException { // public UserNotFoundException() { // super("The requested user can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/exception/user/UsernameClashException.java // public class UsernameClashException extends IllegalArgumentException { // public UsernameClashException(String causingUsername) { // super("Username \'" + causingUsername + "\' is already taken. Please choose another username."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.user.InvalidUsernameException; import com.aemreunal.exception.user.UserNotFoundException; import com.aemreunal.exception.user.UsernameClashException; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.user; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class UserControllerAdvice { @ExceptionHandler(UsernameClashException.class) public ResponseEntity<JSONObject> usernameClashExceptionHandler(UsernameClashException ex) { JSONObject responseBody = JsonBuilderFactory.object().add("reason", "username") .add("error", ex.getLocalizedMessage()) .build(); return new ResponseEntity<JSONObject>(responseBody, HttpStatus.BAD_REQUEST); }
// Path: src/main/java/com/aemreunal/exception/user/InvalidUsernameException.java // public class InvalidUsernameException extends IllegalArgumentException { // public InvalidUsernameException(String causingUsername, String reason) { // super("Username \'" + causingUsername + "\' is invalid! " + reason); // } // } // // Path: src/main/java/com/aemreunal/exception/user/UserNotFoundException.java // public class UserNotFoundException extends NullPointerException { // public UserNotFoundException() { // super("The requested user can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/exception/user/UsernameClashException.java // public class UsernameClashException extends IllegalArgumentException { // public UsernameClashException(String causingUsername) { // super("Username \'" + causingUsername + "\' is already taken. Please choose another username."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/user/UserControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.user.InvalidUsernameException; import com.aemreunal.exception.user.UserNotFoundException; import com.aemreunal.exception.user.UsernameClashException; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.user; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class UserControllerAdvice { @ExceptionHandler(UsernameClashException.class) public ResponseEntity<JSONObject> usernameClashExceptionHandler(UsernameClashException ex) { JSONObject responseBody = JsonBuilderFactory.object().add("reason", "username") .add("error", ex.getLocalizedMessage()) .build(); return new ResponseEntity<JSONObject>(responseBody, HttpStatus.BAD_REQUEST); }
@ExceptionHandler(InvalidUsernameException.class)
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/user/UserControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/user/InvalidUsernameException.java // public class InvalidUsernameException extends IllegalArgumentException { // public InvalidUsernameException(String causingUsername, String reason) { // super("Username \'" + causingUsername + "\' is invalid! " + reason); // } // } // // Path: src/main/java/com/aemreunal/exception/user/UserNotFoundException.java // public class UserNotFoundException extends NullPointerException { // public UserNotFoundException() { // super("The requested user can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/exception/user/UsernameClashException.java // public class UsernameClashException extends IllegalArgumentException { // public UsernameClashException(String causingUsername) { // super("Username \'" + causingUsername + "\' is already taken. Please choose another username."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.user.InvalidUsernameException; import com.aemreunal.exception.user.UserNotFoundException; import com.aemreunal.exception.user.UsernameClashException; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.user; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class UserControllerAdvice { @ExceptionHandler(UsernameClashException.class) public ResponseEntity<JSONObject> usernameClashExceptionHandler(UsernameClashException ex) { JSONObject responseBody = JsonBuilderFactory.object().add("reason", "username") .add("error", ex.getLocalizedMessage()) .build(); return new ResponseEntity<JSONObject>(responseBody, HttpStatus.BAD_REQUEST); } @ExceptionHandler(InvalidUsernameException.class) public ResponseEntity<JSONObject> invalidUsernameExceptionHandler(InvalidUsernameException ex) { JSONObject responseBody = JsonBuilderFactory.object().add("reason", "username") .add("error", ex.getLocalizedMessage()) .build(); return new ResponseEntity<JSONObject>(responseBody, HttpStatus.BAD_REQUEST); }
// Path: src/main/java/com/aemreunal/exception/user/InvalidUsernameException.java // public class InvalidUsernameException extends IllegalArgumentException { // public InvalidUsernameException(String causingUsername, String reason) { // super("Username \'" + causingUsername + "\' is invalid! " + reason); // } // } // // Path: src/main/java/com/aemreunal/exception/user/UserNotFoundException.java // public class UserNotFoundException extends NullPointerException { // public UserNotFoundException() { // super("The requested user can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/exception/user/UsernameClashException.java // public class UsernameClashException extends IllegalArgumentException { // public UsernameClashException(String causingUsername) { // super("Username \'" + causingUsername + "\' is already taken. Please choose another username."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/user/UserControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.user.InvalidUsernameException; import com.aemreunal.exception.user.UserNotFoundException; import com.aemreunal.exception.user.UsernameClashException; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.user; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class UserControllerAdvice { @ExceptionHandler(UsernameClashException.class) public ResponseEntity<JSONObject> usernameClashExceptionHandler(UsernameClashException ex) { JSONObject responseBody = JsonBuilderFactory.object().add("reason", "username") .add("error", ex.getLocalizedMessage()) .build(); return new ResponseEntity<JSONObject>(responseBody, HttpStatus.BAD_REQUEST); } @ExceptionHandler(InvalidUsernameException.class) public ResponseEntity<JSONObject> invalidUsernameExceptionHandler(InvalidUsernameException ex) { JSONObject responseBody = JsonBuilderFactory.object().add("reason", "username") .add("error", ex.getLocalizedMessage()) .build(); return new ResponseEntity<JSONObject>(responseBody, HttpStatus.BAD_REQUEST); }
@ExceptionHandler(UserNotFoundException.class)
aemreunal/iBeaconServer
src/main/java/com/aemreunal/domain/Project.java
// Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import java.io.Serializable; import java.util.Date; import java.util.LinkedHashSet; import java.util.Set; import javax.persistence.*; import javax.validation.constraints.Size; import org.springframework.hateoas.ResourceSupport; import org.springframework.web.bind.annotation.ResponseBody; import com.aemreunal.helper.json.JsonBuilderFactory; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
* BEGIN: Project 'secret' attribute * * TODO add resetting secret */ @Column(name = "project_secret", nullable = false, unique = false) @Size(min = BCRYPT_HASH_LENGTH, max = BCRYPT_HASH_LENGTH) @Access(AccessType.PROPERTY) private String projectSecret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; /* * END: Project 'secret' attribute *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Constructors */ public Project() { // Empty constructor for Spring & Hibernate } /* * END: Constructors *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Helpers */ public JSONObject getCreateResponse(String projectSecret) {
// Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/domain/Project.java import net.minidev.json.JSONObject; import java.io.Serializable; import java.util.Date; import java.util.LinkedHashSet; import java.util.Set; import javax.persistence.*; import javax.validation.constraints.Size; import org.springframework.hateoas.ResourceSupport; import org.springframework.web.bind.annotation.ResponseBody; import com.aemreunal.helper.json.JsonBuilderFactory; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; * BEGIN: Project 'secret' attribute * * TODO add resetting secret */ @Column(name = "project_secret", nullable = false, unique = false) @Size(min = BCRYPT_HASH_LENGTH, max = BCRYPT_HASH_LENGTH) @Access(AccessType.PROPERTY) private String projectSecret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; /* * END: Project 'secret' attribute *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Constructors */ public Project() { // Empty constructor for Spring & Hibernate } /* * END: Constructors *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Helpers */ public JSONObject getCreateResponse(String projectSecret) {
return JsonBuilderFactory.object()
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/api/APIControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/scenario/NoScenarioForQueryException.java // public class NoScenarioForQueryException extends NullPointerException { // public NoScenarioForQueryException(String uuid, Integer major, Integer minor) { // super("Beacon with UUID: " + uuid + ", Major: " + major + ", Minor: " + minor + " doesn't have an associated scenario!"); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.scenario.NoScenarioForQueryException; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.api; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class APIControllerAdvice {
// Path: src/main/java/com/aemreunal/exception/scenario/NoScenarioForQueryException.java // public class NoScenarioForQueryException extends NullPointerException { // public NoScenarioForQueryException(String uuid, Integer major, Integer minor) { // super("Beacon with UUID: " + uuid + ", Major: " + major + ", Minor: " + minor + " doesn't have an associated scenario!"); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/api/APIControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.scenario.NoScenarioForQueryException; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.api; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class APIControllerAdvice {
@ExceptionHandler(NoScenarioForQueryException.class)
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/api/APIControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/scenario/NoScenarioForQueryException.java // public class NoScenarioForQueryException extends NullPointerException { // public NoScenarioForQueryException(String uuid, Integer major, Integer minor) { // super("Beacon with UUID: " + uuid + ", Major: " + major + ", Minor: " + minor + " doesn't have an associated scenario!"); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.scenario.NoScenarioForQueryException; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.api; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class APIControllerAdvice { @ExceptionHandler(NoScenarioForQueryException.class) public ResponseEntity<JSONObject> beaconDoesntHaveScenarioExceptionHandler(NoScenarioForQueryException ex) {
// Path: src/main/java/com/aemreunal/exception/scenario/NoScenarioForQueryException.java // public class NoScenarioForQueryException extends NullPointerException { // public NoScenarioForQueryException(String uuid, Integer major, Integer minor) { // super("Beacon with UUID: " + uuid + ", Major: " + major + ", Minor: " + minor + " doesn't have an associated scenario!"); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/api/APIControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.scenario.NoScenarioForQueryException; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.api; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class APIControllerAdvice { @ExceptionHandler(NoScenarioForQueryException.class) public ResponseEntity<JSONObject> beaconDoesntHaveScenarioExceptionHandler(NoScenarioForQueryException ex) {
JSONObject responseBody = JsonBuilderFactory.object().add("reason", "scenario")
aemreunal/iBeaconServer
src/main/java/com/aemreunal/domain/Region.java
// Path: src/main/java/com/aemreunal/helper/ImageProperties.java // public class ImageProperties { // private final String imageFileName; // private final int imageWidth; // private final int imageHeight; // // public ImageProperties(String imageFileName, int imageWidth, int imageHeight) { // this.imageFileName = imageFileName; // this.imageWidth = imageWidth; // this.imageHeight = imageHeight; // } // // public String getImageFileName() { // return imageFileName; // } // // public int getImageWidth() { // return imageWidth; // } // // public int getImageHeight() { // return imageHeight; // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import java.io.Serializable; import java.util.Date; import java.util.LinkedHashSet; import java.util.Set; import javax.persistence.*; import javax.validation.constraints.Size; import org.springframework.hateoas.ResourceSupport; import org.springframework.web.bind.annotation.ResponseBody; import com.aemreunal.helper.ImageProperties; import com.aemreunal.helper.json.JsonBuilderFactory; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
/* *------------------------------------------------------------ * BEGIN: Region 'lastUpdateDate' attribute */ @Column(name = "last_update_date", nullable = false) @Access(AccessType.PROPERTY) private Date lastUpdatedDate = null; // @LastModifiedDate /* * END: Region 'lastUpdateDate' attribute *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Constructors */ public Region() { // Empty constructor for Spring & Hibernate } /* * END: Constructors *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Helpers */
// Path: src/main/java/com/aemreunal/helper/ImageProperties.java // public class ImageProperties { // private final String imageFileName; // private final int imageWidth; // private final int imageHeight; // // public ImageProperties(String imageFileName, int imageWidth, int imageHeight) { // this.imageFileName = imageFileName; // this.imageWidth = imageWidth; // this.imageHeight = imageHeight; // } // // public String getImageFileName() { // return imageFileName; // } // // public int getImageWidth() { // return imageWidth; // } // // public int getImageHeight() { // return imageHeight; // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/domain/Region.java import net.minidev.json.JSONObject; import java.io.Serializable; import java.util.Date; import java.util.LinkedHashSet; import java.util.Set; import javax.persistence.*; import javax.validation.constraints.Size; import org.springframework.hateoas.ResourceSupport; import org.springframework.web.bind.annotation.ResponseBody; import com.aemreunal.helper.ImageProperties; import com.aemreunal.helper.json.JsonBuilderFactory; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; /* *------------------------------------------------------------ * BEGIN: Region 'lastUpdateDate' attribute */ @Column(name = "last_update_date", nullable = false) @Access(AccessType.PROPERTY) private Date lastUpdatedDate = null; // @LastModifiedDate /* * END: Region 'lastUpdateDate' attribute *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Constructors */ public Region() { // Empty constructor for Spring & Hibernate } /* * END: Constructors *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Helpers */
public void setImageProperties(ImageProperties imageProperties) {
aemreunal/iBeaconServer
src/main/java/com/aemreunal/domain/Region.java
// Path: src/main/java/com/aemreunal/helper/ImageProperties.java // public class ImageProperties { // private final String imageFileName; // private final int imageWidth; // private final int imageHeight; // // public ImageProperties(String imageFileName, int imageWidth, int imageHeight) { // this.imageFileName = imageFileName; // this.imageWidth = imageWidth; // this.imageHeight = imageHeight; // } // // public String getImageFileName() { // return imageFileName; // } // // public int getImageWidth() { // return imageWidth; // } // // public int getImageHeight() { // return imageHeight; // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import java.io.Serializable; import java.util.Date; import java.util.LinkedHashSet; import java.util.Set; import javax.persistence.*; import javax.validation.constraints.Size; import org.springframework.hateoas.ResourceSupport; import org.springframework.web.bind.annotation.ResponseBody; import com.aemreunal.helper.ImageProperties; import com.aemreunal.helper.json.JsonBuilderFactory; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
// Empty constructor for Spring & Hibernate } /* * END: Constructors *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Helpers */ public void setImageProperties(ImageProperties imageProperties) { this.setMapImageFileName(imageProperties.getImageFileName()); this.setRegionWidth(imageProperties.getImageWidth()); this.setRegionHeight(imageProperties.getImageHeight()); } public boolean beaconCoordsAreValid(Beacon beacon) { Integer beaconX = beacon.getxCoordinate(); Integer beaconY = beacon.getyCoordinate(); boolean xIsValid = beaconX >= 0 && beaconX < this.getRegionWidth(); boolean yIsValid = beaconY >= 0 && beaconY < this.getRegionHeight(); return xIsValid && yIsValid; } public void markAsUpdated() { setLastUpdatedDate(new Date()); } public JSONObject getQueryResponse() {
// Path: src/main/java/com/aemreunal/helper/ImageProperties.java // public class ImageProperties { // private final String imageFileName; // private final int imageWidth; // private final int imageHeight; // // public ImageProperties(String imageFileName, int imageWidth, int imageHeight) { // this.imageFileName = imageFileName; // this.imageWidth = imageWidth; // this.imageHeight = imageHeight; // } // // public String getImageFileName() { // return imageFileName; // } // // public int getImageWidth() { // return imageWidth; // } // // public int getImageHeight() { // return imageHeight; // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/domain/Region.java import net.minidev.json.JSONObject; import java.io.Serializable; import java.util.Date; import java.util.LinkedHashSet; import java.util.Set; import javax.persistence.*; import javax.validation.constraints.Size; import org.springframework.hateoas.ResourceSupport; import org.springframework.web.bind.annotation.ResponseBody; import com.aemreunal.helper.ImageProperties; import com.aemreunal.helper.json.JsonBuilderFactory; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; // Empty constructor for Spring & Hibernate } /* * END: Constructors *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Helpers */ public void setImageProperties(ImageProperties imageProperties) { this.setMapImageFileName(imageProperties.getImageFileName()); this.setRegionWidth(imageProperties.getImageWidth()); this.setRegionHeight(imageProperties.getImageHeight()); } public boolean beaconCoordsAreValid(Beacon beacon) { Integer beaconX = beacon.getxCoordinate(); Integer beaconY = beacon.getyCoordinate(); boolean xIsValid = beaconX >= 0 && beaconX < this.getRegionWidth(); boolean yIsValid = beaconY >= 0 && beaconY < this.getRegionHeight(); return xIsValid && yIsValid; } public void markAsUpdated() { setLastUpdatedDate(new Date()); } public JSONObject getQueryResponse() {
return JsonBuilderFactory.object()
aemreunal/iBeaconServer
src/main/java/com/aemreunal/domain/Connection.java
// Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONArray; import net.minidev.json.JSONObject; import java.io.Serializable; import java.util.LinkedHashSet; import java.util.Set; import java.util.stream.Collectors; import javax.persistence.*; import javax.validation.constraints.Size; import org.springframework.hateoas.ResourceSupport; import org.springframework.web.bind.annotation.ResponseBody; import com.aemreunal.helper.json.JsonBuilderFactory; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
* END: Connection 'beacons' attribute *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Connection 'project' attribute */ @ManyToOne(targetEntity = Project.class, optional = false, fetch = FetchType.LAZY) @JoinTable(name = "projects_to_connections", joinColumns = @JoinColumn(name = "connection_id"), inverseJoinColumns = @JoinColumn(name = "project_id")) @Access(AccessType.PROPERTY) private Project project; /* * END: Connection 'project' attribute *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Helpers */ public void addBeacon(Beacon beacon) { this.getBeacons().add(beacon); } public JSONArray getBeaconIdsAsJson() {
// Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/domain/Connection.java import net.minidev.json.JSONArray; import net.minidev.json.JSONObject; import java.io.Serializable; import java.util.LinkedHashSet; import java.util.Set; import java.util.stream.Collectors; import javax.persistence.*; import javax.validation.constraints.Size; import org.springframework.hateoas.ResourceSupport; import org.springframework.web.bind.annotation.ResponseBody; import com.aemreunal.helper.json.JsonBuilderFactory; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; * END: Connection 'beacons' attribute *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Connection 'project' attribute */ @ManyToOne(targetEntity = Project.class, optional = false, fetch = FetchType.LAZY) @JoinTable(name = "projects_to_connections", joinColumns = @JoinColumn(name = "connection_id"), inverseJoinColumns = @JoinColumn(name = "project_id")) @Access(AccessType.PROPERTY) private Project project; /* * END: Connection 'project' attribute *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Helpers */ public void addBeacon(Beacon beacon) { this.getBeacons().add(beacon); } public JSONArray getBeaconIdsAsJson() {
return JsonBuilderFactory.array()
aemreunal/iBeaconServer
src/main/java/com/aemreunal/domain/Scenario.java
// Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonObjectBuilder.java // public class JsonObjectBuilder { // private Map<String, Object> jsonMap = new HashMap<>(); // // JsonObjectBuilder() { // } // // public JsonObjectBuilder add(String key, Object value) { // jsonMap.put(key, value); // return this; // } // // public JSONObject build() { // return new JSONObject(jsonMap); // } // }
import net.minidev.json.JSONObject; import java.io.Serializable; import java.util.Date; import java.util.LinkedHashSet; import java.util.Set; import javax.persistence.*; import javax.validation.constraints.Size; import org.springframework.hateoas.ResourceSupport; import org.springframework.web.bind.annotation.ResponseBody; import com.aemreunal.helper.json.JsonBuilderFactory; import com.aemreunal.helper.json.JsonObjectBuilder; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
* BEGIN: Scenario 'url' attribute * * This value is to be used as the notification string. */ @Column(name = "url", nullable = false, length = URL_MAX_LENGTH) @Size(min = 0, max = URL_MAX_LENGTH) @Access(AccessType.PROPERTY) private String url = ""; /* * END: Scenario 'url' attribute *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Constructors */ public Scenario() { // Empty constructor for Spring & Hibernate } /* * END: Constructors *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Helpers */ public JSONObject generateQueryResponse() {
// Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonObjectBuilder.java // public class JsonObjectBuilder { // private Map<String, Object> jsonMap = new HashMap<>(); // // JsonObjectBuilder() { // } // // public JsonObjectBuilder add(String key, Object value) { // jsonMap.put(key, value); // return this; // } // // public JSONObject build() { // return new JSONObject(jsonMap); // } // } // Path: src/main/java/com/aemreunal/domain/Scenario.java import net.minidev.json.JSONObject; import java.io.Serializable; import java.util.Date; import java.util.LinkedHashSet; import java.util.Set; import javax.persistence.*; import javax.validation.constraints.Size; import org.springframework.hateoas.ResourceSupport; import org.springframework.web.bind.annotation.ResponseBody; import com.aemreunal.helper.json.JsonBuilderFactory; import com.aemreunal.helper.json.JsonObjectBuilder; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; * BEGIN: Scenario 'url' attribute * * This value is to be used as the notification string. */ @Column(name = "url", nullable = false, length = URL_MAX_LENGTH) @Size(min = 0, max = URL_MAX_LENGTH) @Access(AccessType.PROPERTY) private String url = ""; /* * END: Scenario 'url' attribute *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Constructors */ public Scenario() { // Empty constructor for Spring & Hibernate } /* * END: Constructors *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Helpers */ public JSONObject generateQueryResponse() {
JsonObjectBuilder builder = JsonBuilderFactory.object();
aemreunal/iBeaconServer
src/main/java/com/aemreunal/domain/Scenario.java
// Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonObjectBuilder.java // public class JsonObjectBuilder { // private Map<String, Object> jsonMap = new HashMap<>(); // // JsonObjectBuilder() { // } // // public JsonObjectBuilder add(String key, Object value) { // jsonMap.put(key, value); // return this; // } // // public JSONObject build() { // return new JSONObject(jsonMap); // } // }
import net.minidev.json.JSONObject; import java.io.Serializable; import java.util.Date; import java.util.LinkedHashSet; import java.util.Set; import javax.persistence.*; import javax.validation.constraints.Size; import org.springframework.hateoas.ResourceSupport; import org.springframework.web.bind.annotation.ResponseBody; import com.aemreunal.helper.json.JsonBuilderFactory; import com.aemreunal.helper.json.JsonObjectBuilder; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
* BEGIN: Scenario 'url' attribute * * This value is to be used as the notification string. */ @Column(name = "url", nullable = false, length = URL_MAX_LENGTH) @Size(min = 0, max = URL_MAX_LENGTH) @Access(AccessType.PROPERTY) private String url = ""; /* * END: Scenario 'url' attribute *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Constructors */ public Scenario() { // Empty constructor for Spring & Hibernate } /* * END: Constructors *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Helpers */ public JSONObject generateQueryResponse() {
// Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonObjectBuilder.java // public class JsonObjectBuilder { // private Map<String, Object> jsonMap = new HashMap<>(); // // JsonObjectBuilder() { // } // // public JsonObjectBuilder add(String key, Object value) { // jsonMap.put(key, value); // return this; // } // // public JSONObject build() { // return new JSONObject(jsonMap); // } // } // Path: src/main/java/com/aemreunal/domain/Scenario.java import net.minidev.json.JSONObject; import java.io.Serializable; import java.util.Date; import java.util.LinkedHashSet; import java.util.Set; import javax.persistence.*; import javax.validation.constraints.Size; import org.springframework.hateoas.ResourceSupport; import org.springframework.web.bind.annotation.ResponseBody; import com.aemreunal.helper.json.JsonBuilderFactory; import com.aemreunal.helper.json.JsonObjectBuilder; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; * BEGIN: Scenario 'url' attribute * * This value is to be used as the notification string. */ @Column(name = "url", nullable = false, length = URL_MAX_LENGTH) @Size(min = 0, max = URL_MAX_LENGTH) @Access(AccessType.PROPERTY) private String url = ""; /* * END: Scenario 'url' attribute *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Constructors */ public Scenario() { // Empty constructor for Spring & Hibernate } /* * END: Constructors *------------------------------------------------------------ */ /* *------------------------------------------------------------ * BEGIN: Helpers */ public JSONObject generateQueryResponse() {
JsonObjectBuilder builder = JsonBuilderFactory.object();
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/beacon/BeaconControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/beacon/BeaconAlreadyExistsException.java // public class BeaconAlreadyExistsException extends IllegalArgumentException { // // public BeaconAlreadyExistsException(Beacon beacon) { // super("Beacon with UUID:'" + beacon.getUuid() + "', Major:'" + beacon.getMajor() + "', Minor:'" + beacon.getMinor() + "' already exists!"); // } // } // // Path: src/main/java/com/aemreunal/exception/beacon/BeaconNotFoundException.java // public class BeaconNotFoundException extends NullPointerException { // public BeaconNotFoundException() { // super("The requested Beacon can not be found!"); // } // // public BeaconNotFoundException(Long beaconId) { // super("The requested Beacon with ID " + beaconId + " can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotPossibleException.java // public class ConnectionNotPossibleException extends Exception { // public ConnectionNotPossibleException(Long beaconId) { // super("Unable to create connection, beacon " + beaconId + " is not a designated beacon!"); // } // // public ConnectionNotPossibleException() { // super("Unable to create connection, a beacon can't be connected to itself!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionExistsException.java // public class ConnectionExistsException extends Exception { // public ConnectionExistsException(Long beaconOneId, Long beaconTwoId) { // super("There already is a connection between Beacon " + beaconOneId + " and Beacon " + beaconTwoId + "!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotFoundException.java // public class ConnectionNotFoundException extends Exception { // public ConnectionNotFoundException() { // super("The requested connection can not be found."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.beacon.BeaconAlreadyExistsException; import com.aemreunal.exception.beacon.BeaconNotFoundException; import com.aemreunal.exception.connection.ConnectionNotPossibleException; import com.aemreunal.exception.connection.ConnectionExistsException; import com.aemreunal.exception.connection.ConnectionNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.beacon; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class BeaconControllerAdvice {
// Path: src/main/java/com/aemreunal/exception/beacon/BeaconAlreadyExistsException.java // public class BeaconAlreadyExistsException extends IllegalArgumentException { // // public BeaconAlreadyExistsException(Beacon beacon) { // super("Beacon with UUID:'" + beacon.getUuid() + "', Major:'" + beacon.getMajor() + "', Minor:'" + beacon.getMinor() + "' already exists!"); // } // } // // Path: src/main/java/com/aemreunal/exception/beacon/BeaconNotFoundException.java // public class BeaconNotFoundException extends NullPointerException { // public BeaconNotFoundException() { // super("The requested Beacon can not be found!"); // } // // public BeaconNotFoundException(Long beaconId) { // super("The requested Beacon with ID " + beaconId + " can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotPossibleException.java // public class ConnectionNotPossibleException extends Exception { // public ConnectionNotPossibleException(Long beaconId) { // super("Unable to create connection, beacon " + beaconId + " is not a designated beacon!"); // } // // public ConnectionNotPossibleException() { // super("Unable to create connection, a beacon can't be connected to itself!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionExistsException.java // public class ConnectionExistsException extends Exception { // public ConnectionExistsException(Long beaconOneId, Long beaconTwoId) { // super("There already is a connection between Beacon " + beaconOneId + " and Beacon " + beaconTwoId + "!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotFoundException.java // public class ConnectionNotFoundException extends Exception { // public ConnectionNotFoundException() { // super("The requested connection can not be found."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/beacon/BeaconControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.beacon.BeaconAlreadyExistsException; import com.aemreunal.exception.beacon.BeaconNotFoundException; import com.aemreunal.exception.connection.ConnectionNotPossibleException; import com.aemreunal.exception.connection.ConnectionExistsException; import com.aemreunal.exception.connection.ConnectionNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.beacon; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class BeaconControllerAdvice {
@ExceptionHandler(BeaconNotFoundException.class)
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/beacon/BeaconControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/beacon/BeaconAlreadyExistsException.java // public class BeaconAlreadyExistsException extends IllegalArgumentException { // // public BeaconAlreadyExistsException(Beacon beacon) { // super("Beacon with UUID:'" + beacon.getUuid() + "', Major:'" + beacon.getMajor() + "', Minor:'" + beacon.getMinor() + "' already exists!"); // } // } // // Path: src/main/java/com/aemreunal/exception/beacon/BeaconNotFoundException.java // public class BeaconNotFoundException extends NullPointerException { // public BeaconNotFoundException() { // super("The requested Beacon can not be found!"); // } // // public BeaconNotFoundException(Long beaconId) { // super("The requested Beacon with ID " + beaconId + " can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotPossibleException.java // public class ConnectionNotPossibleException extends Exception { // public ConnectionNotPossibleException(Long beaconId) { // super("Unable to create connection, beacon " + beaconId + " is not a designated beacon!"); // } // // public ConnectionNotPossibleException() { // super("Unable to create connection, a beacon can't be connected to itself!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionExistsException.java // public class ConnectionExistsException extends Exception { // public ConnectionExistsException(Long beaconOneId, Long beaconTwoId) { // super("There already is a connection between Beacon " + beaconOneId + " and Beacon " + beaconTwoId + "!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotFoundException.java // public class ConnectionNotFoundException extends Exception { // public ConnectionNotFoundException() { // super("The requested connection can not be found."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.beacon.BeaconAlreadyExistsException; import com.aemreunal.exception.beacon.BeaconNotFoundException; import com.aemreunal.exception.connection.ConnectionNotPossibleException; import com.aemreunal.exception.connection.ConnectionExistsException; import com.aemreunal.exception.connection.ConnectionNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.beacon; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class BeaconControllerAdvice { @ExceptionHandler(BeaconNotFoundException.class) public ResponseEntity<JSONObject> beaconNotFoundExceptionHandler(BeaconNotFoundException ex) { return getResponse(ex, "beacon", HttpStatus.NOT_FOUND); }
// Path: src/main/java/com/aemreunal/exception/beacon/BeaconAlreadyExistsException.java // public class BeaconAlreadyExistsException extends IllegalArgumentException { // // public BeaconAlreadyExistsException(Beacon beacon) { // super("Beacon with UUID:'" + beacon.getUuid() + "', Major:'" + beacon.getMajor() + "', Minor:'" + beacon.getMinor() + "' already exists!"); // } // } // // Path: src/main/java/com/aemreunal/exception/beacon/BeaconNotFoundException.java // public class BeaconNotFoundException extends NullPointerException { // public BeaconNotFoundException() { // super("The requested Beacon can not be found!"); // } // // public BeaconNotFoundException(Long beaconId) { // super("The requested Beacon with ID " + beaconId + " can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotPossibleException.java // public class ConnectionNotPossibleException extends Exception { // public ConnectionNotPossibleException(Long beaconId) { // super("Unable to create connection, beacon " + beaconId + " is not a designated beacon!"); // } // // public ConnectionNotPossibleException() { // super("Unable to create connection, a beacon can't be connected to itself!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionExistsException.java // public class ConnectionExistsException extends Exception { // public ConnectionExistsException(Long beaconOneId, Long beaconTwoId) { // super("There already is a connection between Beacon " + beaconOneId + " and Beacon " + beaconTwoId + "!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotFoundException.java // public class ConnectionNotFoundException extends Exception { // public ConnectionNotFoundException() { // super("The requested connection can not be found."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/beacon/BeaconControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.beacon.BeaconAlreadyExistsException; import com.aemreunal.exception.beacon.BeaconNotFoundException; import com.aemreunal.exception.connection.ConnectionNotPossibleException; import com.aemreunal.exception.connection.ConnectionExistsException; import com.aemreunal.exception.connection.ConnectionNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.beacon; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class BeaconControllerAdvice { @ExceptionHandler(BeaconNotFoundException.class) public ResponseEntity<JSONObject> beaconNotFoundExceptionHandler(BeaconNotFoundException ex) { return getResponse(ex, "beacon", HttpStatus.NOT_FOUND); }
@ExceptionHandler(BeaconAlreadyExistsException.class)
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/beacon/BeaconControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/beacon/BeaconAlreadyExistsException.java // public class BeaconAlreadyExistsException extends IllegalArgumentException { // // public BeaconAlreadyExistsException(Beacon beacon) { // super("Beacon with UUID:'" + beacon.getUuid() + "', Major:'" + beacon.getMajor() + "', Minor:'" + beacon.getMinor() + "' already exists!"); // } // } // // Path: src/main/java/com/aemreunal/exception/beacon/BeaconNotFoundException.java // public class BeaconNotFoundException extends NullPointerException { // public BeaconNotFoundException() { // super("The requested Beacon can not be found!"); // } // // public BeaconNotFoundException(Long beaconId) { // super("The requested Beacon with ID " + beaconId + " can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotPossibleException.java // public class ConnectionNotPossibleException extends Exception { // public ConnectionNotPossibleException(Long beaconId) { // super("Unable to create connection, beacon " + beaconId + " is not a designated beacon!"); // } // // public ConnectionNotPossibleException() { // super("Unable to create connection, a beacon can't be connected to itself!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionExistsException.java // public class ConnectionExistsException extends Exception { // public ConnectionExistsException(Long beaconOneId, Long beaconTwoId) { // super("There already is a connection between Beacon " + beaconOneId + " and Beacon " + beaconTwoId + "!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotFoundException.java // public class ConnectionNotFoundException extends Exception { // public ConnectionNotFoundException() { // super("The requested connection can not be found."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.beacon.BeaconAlreadyExistsException; import com.aemreunal.exception.beacon.BeaconNotFoundException; import com.aemreunal.exception.connection.ConnectionNotPossibleException; import com.aemreunal.exception.connection.ConnectionExistsException; import com.aemreunal.exception.connection.ConnectionNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.beacon; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class BeaconControllerAdvice { @ExceptionHandler(BeaconNotFoundException.class) public ResponseEntity<JSONObject> beaconNotFoundExceptionHandler(BeaconNotFoundException ex) { return getResponse(ex, "beacon", HttpStatus.NOT_FOUND); } @ExceptionHandler(BeaconAlreadyExistsException.class) public ResponseEntity<JSONObject> beaconAlreadyExistsExceptionHandler(BeaconAlreadyExistsException ex) { return getResponse(ex, "beacon", HttpStatus.BAD_REQUEST); }
// Path: src/main/java/com/aemreunal/exception/beacon/BeaconAlreadyExistsException.java // public class BeaconAlreadyExistsException extends IllegalArgumentException { // // public BeaconAlreadyExistsException(Beacon beacon) { // super("Beacon with UUID:'" + beacon.getUuid() + "', Major:'" + beacon.getMajor() + "', Minor:'" + beacon.getMinor() + "' already exists!"); // } // } // // Path: src/main/java/com/aemreunal/exception/beacon/BeaconNotFoundException.java // public class BeaconNotFoundException extends NullPointerException { // public BeaconNotFoundException() { // super("The requested Beacon can not be found!"); // } // // public BeaconNotFoundException(Long beaconId) { // super("The requested Beacon with ID " + beaconId + " can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotPossibleException.java // public class ConnectionNotPossibleException extends Exception { // public ConnectionNotPossibleException(Long beaconId) { // super("Unable to create connection, beacon " + beaconId + " is not a designated beacon!"); // } // // public ConnectionNotPossibleException() { // super("Unable to create connection, a beacon can't be connected to itself!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionExistsException.java // public class ConnectionExistsException extends Exception { // public ConnectionExistsException(Long beaconOneId, Long beaconTwoId) { // super("There already is a connection between Beacon " + beaconOneId + " and Beacon " + beaconTwoId + "!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotFoundException.java // public class ConnectionNotFoundException extends Exception { // public ConnectionNotFoundException() { // super("The requested connection can not be found."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/beacon/BeaconControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.beacon.BeaconAlreadyExistsException; import com.aemreunal.exception.beacon.BeaconNotFoundException; import com.aemreunal.exception.connection.ConnectionNotPossibleException; import com.aemreunal.exception.connection.ConnectionExistsException; import com.aemreunal.exception.connection.ConnectionNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.beacon; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class BeaconControllerAdvice { @ExceptionHandler(BeaconNotFoundException.class) public ResponseEntity<JSONObject> beaconNotFoundExceptionHandler(BeaconNotFoundException ex) { return getResponse(ex, "beacon", HttpStatus.NOT_FOUND); } @ExceptionHandler(BeaconAlreadyExistsException.class) public ResponseEntity<JSONObject> beaconAlreadyExistsExceptionHandler(BeaconAlreadyExistsException ex) { return getResponse(ex, "beacon", HttpStatus.BAD_REQUEST); }
@ExceptionHandler(ConnectionExistsException.class)
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/beacon/BeaconControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/beacon/BeaconAlreadyExistsException.java // public class BeaconAlreadyExistsException extends IllegalArgumentException { // // public BeaconAlreadyExistsException(Beacon beacon) { // super("Beacon with UUID:'" + beacon.getUuid() + "', Major:'" + beacon.getMajor() + "', Minor:'" + beacon.getMinor() + "' already exists!"); // } // } // // Path: src/main/java/com/aemreunal/exception/beacon/BeaconNotFoundException.java // public class BeaconNotFoundException extends NullPointerException { // public BeaconNotFoundException() { // super("The requested Beacon can not be found!"); // } // // public BeaconNotFoundException(Long beaconId) { // super("The requested Beacon with ID " + beaconId + " can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotPossibleException.java // public class ConnectionNotPossibleException extends Exception { // public ConnectionNotPossibleException(Long beaconId) { // super("Unable to create connection, beacon " + beaconId + " is not a designated beacon!"); // } // // public ConnectionNotPossibleException() { // super("Unable to create connection, a beacon can't be connected to itself!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionExistsException.java // public class ConnectionExistsException extends Exception { // public ConnectionExistsException(Long beaconOneId, Long beaconTwoId) { // super("There already is a connection between Beacon " + beaconOneId + " and Beacon " + beaconTwoId + "!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotFoundException.java // public class ConnectionNotFoundException extends Exception { // public ConnectionNotFoundException() { // super("The requested connection can not be found."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.beacon.BeaconAlreadyExistsException; import com.aemreunal.exception.beacon.BeaconNotFoundException; import com.aemreunal.exception.connection.ConnectionNotPossibleException; import com.aemreunal.exception.connection.ConnectionExistsException; import com.aemreunal.exception.connection.ConnectionNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.beacon; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class BeaconControllerAdvice { @ExceptionHandler(BeaconNotFoundException.class) public ResponseEntity<JSONObject> beaconNotFoundExceptionHandler(BeaconNotFoundException ex) { return getResponse(ex, "beacon", HttpStatus.NOT_FOUND); } @ExceptionHandler(BeaconAlreadyExistsException.class) public ResponseEntity<JSONObject> beaconAlreadyExistsExceptionHandler(BeaconAlreadyExistsException ex) { return getResponse(ex, "beacon", HttpStatus.BAD_REQUEST); } @ExceptionHandler(ConnectionExistsException.class) public ResponseEntity<JSONObject> connectionExistsExceptionHandler(ConnectionExistsException ex) { return getResponse(ex, "connection", HttpStatus.BAD_REQUEST); }
// Path: src/main/java/com/aemreunal/exception/beacon/BeaconAlreadyExistsException.java // public class BeaconAlreadyExistsException extends IllegalArgumentException { // // public BeaconAlreadyExistsException(Beacon beacon) { // super("Beacon with UUID:'" + beacon.getUuid() + "', Major:'" + beacon.getMajor() + "', Minor:'" + beacon.getMinor() + "' already exists!"); // } // } // // Path: src/main/java/com/aemreunal/exception/beacon/BeaconNotFoundException.java // public class BeaconNotFoundException extends NullPointerException { // public BeaconNotFoundException() { // super("The requested Beacon can not be found!"); // } // // public BeaconNotFoundException(Long beaconId) { // super("The requested Beacon with ID " + beaconId + " can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotPossibleException.java // public class ConnectionNotPossibleException extends Exception { // public ConnectionNotPossibleException(Long beaconId) { // super("Unable to create connection, beacon " + beaconId + " is not a designated beacon!"); // } // // public ConnectionNotPossibleException() { // super("Unable to create connection, a beacon can't be connected to itself!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionExistsException.java // public class ConnectionExistsException extends Exception { // public ConnectionExistsException(Long beaconOneId, Long beaconTwoId) { // super("There already is a connection between Beacon " + beaconOneId + " and Beacon " + beaconTwoId + "!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotFoundException.java // public class ConnectionNotFoundException extends Exception { // public ConnectionNotFoundException() { // super("The requested connection can not be found."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/beacon/BeaconControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.beacon.BeaconAlreadyExistsException; import com.aemreunal.exception.beacon.BeaconNotFoundException; import com.aemreunal.exception.connection.ConnectionNotPossibleException; import com.aemreunal.exception.connection.ConnectionExistsException; import com.aemreunal.exception.connection.ConnectionNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.beacon; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class BeaconControllerAdvice { @ExceptionHandler(BeaconNotFoundException.class) public ResponseEntity<JSONObject> beaconNotFoundExceptionHandler(BeaconNotFoundException ex) { return getResponse(ex, "beacon", HttpStatus.NOT_FOUND); } @ExceptionHandler(BeaconAlreadyExistsException.class) public ResponseEntity<JSONObject> beaconAlreadyExistsExceptionHandler(BeaconAlreadyExistsException ex) { return getResponse(ex, "beacon", HttpStatus.BAD_REQUEST); } @ExceptionHandler(ConnectionExistsException.class) public ResponseEntity<JSONObject> connectionExistsExceptionHandler(ConnectionExistsException ex) { return getResponse(ex, "connection", HttpStatus.BAD_REQUEST); }
@ExceptionHandler(ConnectionNotFoundException.class)
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/beacon/BeaconControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/beacon/BeaconAlreadyExistsException.java // public class BeaconAlreadyExistsException extends IllegalArgumentException { // // public BeaconAlreadyExistsException(Beacon beacon) { // super("Beacon with UUID:'" + beacon.getUuid() + "', Major:'" + beacon.getMajor() + "', Minor:'" + beacon.getMinor() + "' already exists!"); // } // } // // Path: src/main/java/com/aemreunal/exception/beacon/BeaconNotFoundException.java // public class BeaconNotFoundException extends NullPointerException { // public BeaconNotFoundException() { // super("The requested Beacon can not be found!"); // } // // public BeaconNotFoundException(Long beaconId) { // super("The requested Beacon with ID " + beaconId + " can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotPossibleException.java // public class ConnectionNotPossibleException extends Exception { // public ConnectionNotPossibleException(Long beaconId) { // super("Unable to create connection, beacon " + beaconId + " is not a designated beacon!"); // } // // public ConnectionNotPossibleException() { // super("Unable to create connection, a beacon can't be connected to itself!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionExistsException.java // public class ConnectionExistsException extends Exception { // public ConnectionExistsException(Long beaconOneId, Long beaconTwoId) { // super("There already is a connection between Beacon " + beaconOneId + " and Beacon " + beaconTwoId + "!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotFoundException.java // public class ConnectionNotFoundException extends Exception { // public ConnectionNotFoundException() { // super("The requested connection can not be found."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.beacon.BeaconAlreadyExistsException; import com.aemreunal.exception.beacon.BeaconNotFoundException; import com.aemreunal.exception.connection.ConnectionNotPossibleException; import com.aemreunal.exception.connection.ConnectionExistsException; import com.aemreunal.exception.connection.ConnectionNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.beacon; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class BeaconControllerAdvice { @ExceptionHandler(BeaconNotFoundException.class) public ResponseEntity<JSONObject> beaconNotFoundExceptionHandler(BeaconNotFoundException ex) { return getResponse(ex, "beacon", HttpStatus.NOT_FOUND); } @ExceptionHandler(BeaconAlreadyExistsException.class) public ResponseEntity<JSONObject> beaconAlreadyExistsExceptionHandler(BeaconAlreadyExistsException ex) { return getResponse(ex, "beacon", HttpStatus.BAD_REQUEST); } @ExceptionHandler(ConnectionExistsException.class) public ResponseEntity<JSONObject> connectionExistsExceptionHandler(ConnectionExistsException ex) { return getResponse(ex, "connection", HttpStatus.BAD_REQUEST); } @ExceptionHandler(ConnectionNotFoundException.class) public ResponseEntity<JSONObject> connectionNotFoundExceptionHandler(ConnectionNotFoundException ex) { return getResponse(ex, "connection", HttpStatus.NOT_FOUND); }
// Path: src/main/java/com/aemreunal/exception/beacon/BeaconAlreadyExistsException.java // public class BeaconAlreadyExistsException extends IllegalArgumentException { // // public BeaconAlreadyExistsException(Beacon beacon) { // super("Beacon with UUID:'" + beacon.getUuid() + "', Major:'" + beacon.getMajor() + "', Minor:'" + beacon.getMinor() + "' already exists!"); // } // } // // Path: src/main/java/com/aemreunal/exception/beacon/BeaconNotFoundException.java // public class BeaconNotFoundException extends NullPointerException { // public BeaconNotFoundException() { // super("The requested Beacon can not be found!"); // } // // public BeaconNotFoundException(Long beaconId) { // super("The requested Beacon with ID " + beaconId + " can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotPossibleException.java // public class ConnectionNotPossibleException extends Exception { // public ConnectionNotPossibleException(Long beaconId) { // super("Unable to create connection, beacon " + beaconId + " is not a designated beacon!"); // } // // public ConnectionNotPossibleException() { // super("Unable to create connection, a beacon can't be connected to itself!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionExistsException.java // public class ConnectionExistsException extends Exception { // public ConnectionExistsException(Long beaconOneId, Long beaconTwoId) { // super("There already is a connection between Beacon " + beaconOneId + " and Beacon " + beaconTwoId + "!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotFoundException.java // public class ConnectionNotFoundException extends Exception { // public ConnectionNotFoundException() { // super("The requested connection can not be found."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/beacon/BeaconControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.beacon.BeaconAlreadyExistsException; import com.aemreunal.exception.beacon.BeaconNotFoundException; import com.aemreunal.exception.connection.ConnectionNotPossibleException; import com.aemreunal.exception.connection.ConnectionExistsException; import com.aemreunal.exception.connection.ConnectionNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.beacon; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class BeaconControllerAdvice { @ExceptionHandler(BeaconNotFoundException.class) public ResponseEntity<JSONObject> beaconNotFoundExceptionHandler(BeaconNotFoundException ex) { return getResponse(ex, "beacon", HttpStatus.NOT_FOUND); } @ExceptionHandler(BeaconAlreadyExistsException.class) public ResponseEntity<JSONObject> beaconAlreadyExistsExceptionHandler(BeaconAlreadyExistsException ex) { return getResponse(ex, "beacon", HttpStatus.BAD_REQUEST); } @ExceptionHandler(ConnectionExistsException.class) public ResponseEntity<JSONObject> connectionExistsExceptionHandler(ConnectionExistsException ex) { return getResponse(ex, "connection", HttpStatus.BAD_REQUEST); } @ExceptionHandler(ConnectionNotFoundException.class) public ResponseEntity<JSONObject> connectionNotFoundExceptionHandler(ConnectionNotFoundException ex) { return getResponse(ex, "connection", HttpStatus.NOT_FOUND); }
@ExceptionHandler(ConnectionNotPossibleException.class)
aemreunal/iBeaconServer
src/main/java/com/aemreunal/controller/beacon/BeaconControllerAdvice.java
// Path: src/main/java/com/aemreunal/exception/beacon/BeaconAlreadyExistsException.java // public class BeaconAlreadyExistsException extends IllegalArgumentException { // // public BeaconAlreadyExistsException(Beacon beacon) { // super("Beacon with UUID:'" + beacon.getUuid() + "', Major:'" + beacon.getMajor() + "', Minor:'" + beacon.getMinor() + "' already exists!"); // } // } // // Path: src/main/java/com/aemreunal/exception/beacon/BeaconNotFoundException.java // public class BeaconNotFoundException extends NullPointerException { // public BeaconNotFoundException() { // super("The requested Beacon can not be found!"); // } // // public BeaconNotFoundException(Long beaconId) { // super("The requested Beacon with ID " + beaconId + " can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotPossibleException.java // public class ConnectionNotPossibleException extends Exception { // public ConnectionNotPossibleException(Long beaconId) { // super("Unable to create connection, beacon " + beaconId + " is not a designated beacon!"); // } // // public ConnectionNotPossibleException() { // super("Unable to create connection, a beacon can't be connected to itself!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionExistsException.java // public class ConnectionExistsException extends Exception { // public ConnectionExistsException(Long beaconOneId, Long beaconTwoId) { // super("There already is a connection between Beacon " + beaconOneId + " and Beacon " + beaconTwoId + "!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotFoundException.java // public class ConnectionNotFoundException extends Exception { // public ConnectionNotFoundException() { // super("The requested connection can not be found."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // }
import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.beacon.BeaconAlreadyExistsException; import com.aemreunal.exception.beacon.BeaconNotFoundException; import com.aemreunal.exception.connection.ConnectionNotPossibleException; import com.aemreunal.exception.connection.ConnectionExistsException; import com.aemreunal.exception.connection.ConnectionNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory;
package com.aemreunal.controller.beacon; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class BeaconControllerAdvice { @ExceptionHandler(BeaconNotFoundException.class) public ResponseEntity<JSONObject> beaconNotFoundExceptionHandler(BeaconNotFoundException ex) { return getResponse(ex, "beacon", HttpStatus.NOT_FOUND); } @ExceptionHandler(BeaconAlreadyExistsException.class) public ResponseEntity<JSONObject> beaconAlreadyExistsExceptionHandler(BeaconAlreadyExistsException ex) { return getResponse(ex, "beacon", HttpStatus.BAD_REQUEST); } @ExceptionHandler(ConnectionExistsException.class) public ResponseEntity<JSONObject> connectionExistsExceptionHandler(ConnectionExistsException ex) { return getResponse(ex, "connection", HttpStatus.BAD_REQUEST); } @ExceptionHandler(ConnectionNotFoundException.class) public ResponseEntity<JSONObject> connectionNotFoundExceptionHandler(ConnectionNotFoundException ex) { return getResponse(ex, "connection", HttpStatus.NOT_FOUND); } @ExceptionHandler(ConnectionNotPossibleException.class) public ResponseEntity<JSONObject> beaconIsNotDesignatedExceptionHandler(ConnectionNotPossibleException ex) { return getResponse(ex, "connection", HttpStatus.BAD_REQUEST); } private ResponseEntity<JSONObject> getResponse(Exception ex, String reason, HttpStatus status) {
// Path: src/main/java/com/aemreunal/exception/beacon/BeaconAlreadyExistsException.java // public class BeaconAlreadyExistsException extends IllegalArgumentException { // // public BeaconAlreadyExistsException(Beacon beacon) { // super("Beacon with UUID:'" + beacon.getUuid() + "', Major:'" + beacon.getMajor() + "', Minor:'" + beacon.getMinor() + "' already exists!"); // } // } // // Path: src/main/java/com/aemreunal/exception/beacon/BeaconNotFoundException.java // public class BeaconNotFoundException extends NullPointerException { // public BeaconNotFoundException() { // super("The requested Beacon can not be found!"); // } // // public BeaconNotFoundException(Long beaconId) { // super("The requested Beacon with ID " + beaconId + " can not be found!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotPossibleException.java // public class ConnectionNotPossibleException extends Exception { // public ConnectionNotPossibleException(Long beaconId) { // super("Unable to create connection, beacon " + beaconId + " is not a designated beacon!"); // } // // public ConnectionNotPossibleException() { // super("Unable to create connection, a beacon can't be connected to itself!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionExistsException.java // public class ConnectionExistsException extends Exception { // public ConnectionExistsException(Long beaconOneId, Long beaconTwoId) { // super("There already is a connection between Beacon " + beaconOneId + " and Beacon " + beaconTwoId + "!"); // } // } // // Path: src/main/java/com/aemreunal/exception/connection/ConnectionNotFoundException.java // public class ConnectionNotFoundException extends Exception { // public ConnectionNotFoundException() { // super("The requested connection can not be found."); // } // } // // Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java // public class JsonBuilderFactory { // public static JsonObjectBuilder object() { // return new JsonObjectBuilder(); // } // // public static JsonArrayBuilder array() { // return new JsonArrayBuilder(); // } // } // Path: src/main/java/com/aemreunal/controller/beacon/BeaconControllerAdvice.java import net.minidev.json.JSONObject; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import com.aemreunal.exception.beacon.BeaconAlreadyExistsException; import com.aemreunal.exception.beacon.BeaconNotFoundException; import com.aemreunal.exception.connection.ConnectionNotPossibleException; import com.aemreunal.exception.connection.ConnectionExistsException; import com.aemreunal.exception.connection.ConnectionNotFoundException; import com.aemreunal.helper.json.JsonBuilderFactory; package com.aemreunal.controller.beacon; /* * *********************** * * Copyright (c) 2015 * * * * This code belongs to: * * * * @author Ahmet Emre Ünal * * S001974 * * * * aemreunal@gmail.com * * emre.unal@ozu.edu.tr * * * * aemreunal.com * * *********************** * */ @ControllerAdvice public class BeaconControllerAdvice { @ExceptionHandler(BeaconNotFoundException.class) public ResponseEntity<JSONObject> beaconNotFoundExceptionHandler(BeaconNotFoundException ex) { return getResponse(ex, "beacon", HttpStatus.NOT_FOUND); } @ExceptionHandler(BeaconAlreadyExistsException.class) public ResponseEntity<JSONObject> beaconAlreadyExistsExceptionHandler(BeaconAlreadyExistsException ex) { return getResponse(ex, "beacon", HttpStatus.BAD_REQUEST); } @ExceptionHandler(ConnectionExistsException.class) public ResponseEntity<JSONObject> connectionExistsExceptionHandler(ConnectionExistsException ex) { return getResponse(ex, "connection", HttpStatus.BAD_REQUEST); } @ExceptionHandler(ConnectionNotFoundException.class) public ResponseEntity<JSONObject> connectionNotFoundExceptionHandler(ConnectionNotFoundException ex) { return getResponse(ex, "connection", HttpStatus.NOT_FOUND); } @ExceptionHandler(ConnectionNotPossibleException.class) public ResponseEntity<JSONObject> beaconIsNotDesignatedExceptionHandler(ConnectionNotPossibleException ex) { return getResponse(ex, "connection", HttpStatus.BAD_REQUEST); } private ResponseEntity<JSONObject> getResponse(Exception ex, String reason, HttpStatus status) {
JSONObject responseBody = JsonBuilderFactory.object().add("reason", reason)
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/datamodel/CV4JImage.java
// Path: desktop/src/main/java/com/cv4j/exception/CV4JException.java // public class CV4JException extends RuntimeException { // // private static final long serialVersionUID = -2565764903880816387L; // // public CV4JException(String message) { // super(message); // } // // public CV4JException(Throwable throwable) { // super(throwable); // } // // public CV4JException(String message, Throwable throwable) { // super(message, throwable); // } // }
import java.awt.image.BufferedImage; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.Serializable; import javax.imageio.ImageIO; import com.cv4j.exception.CV4JException;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel; public class CV4JImage implements ImageData, Serializable{ private static final long serialVersionUID = -8832812623741546452L; private int width; private int height; private ImageProcessor processor; private BufferedImage bitmap; public CV4JImage(ImageProcessor processor) { if(processor == null) {
// Path: desktop/src/main/java/com/cv4j/exception/CV4JException.java // public class CV4JException extends RuntimeException { // // private static final long serialVersionUID = -2565764903880816387L; // // public CV4JException(String message) { // super(message); // } // // public CV4JException(Throwable throwable) { // super(throwable); // } // // public CV4JException(String message, Throwable throwable) { // super(message, throwable); // } // } // Path: desktop/src/main/java/com/cv4j/core/datamodel/CV4JImage.java import java.awt.image.BufferedImage; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.Serializable; import javax.imageio.ImageIO; import com.cv4j.exception.CV4JException; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel; public class CV4JImage implements ImageData, Serializable{ private static final long serialVersionUID = -8832812623741546452L; private int width; private int height; private ImageProcessor processor; private BufferedImage bitmap; public CV4JImage(ImageProcessor processor) { if(processor == null) {
throw new CV4JException("processor is null");
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/hist/CompareHist.java
// Path: desktop/src/main/java/com/cv4j/exception/CV4JException.java // public class CV4JException extends RuntimeException { // // private static final long serialVersionUID = -2565764903880816387L; // // public CV4JException(String message) { // super(message); // } // // public CV4JException(Throwable throwable) { // super(throwable); // } // // public CV4JException(String message, Throwable throwable) { // super(message, throwable); // } // }
import com.cv4j.exception.CV4JException;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.hist; public class CompareHist { /** * 0 到 1 之间取值 * @param source * @param target * @return */ public double bhattacharyya(int[] source, int[] target) { if(source.length != target.length) {
// Path: desktop/src/main/java/com/cv4j/exception/CV4JException.java // public class CV4JException extends RuntimeException { // // private static final long serialVersionUID = -2565764903880816387L; // // public CV4JException(String message) { // super(message); // } // // public CV4JException(Throwable throwable) { // super(throwable); // } // // public CV4JException(String message, Throwable throwable) { // super(message, throwable); // } // } // Path: desktop/src/main/java/com/cv4j/core/hist/CompareHist.java import com.cv4j.exception.CV4JException; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.hist; public class CompareHist { /** * 0 到 1 之间取值 * @param source * @param target * @return */ public double bhattacharyya(int[] source, int[] target) { if(source.length != target.length) {
throw new CV4JException("number of histogram bins is not same...");
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/filters/GammaFilter.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageProcessor.java // public interface ImageProcessor { // // /** Returns the width of this image in pixels. */ // int getWidth(); // // /** Returns the height of this image in pixels. */ // int getHeight(); // // /** Returns the channels of this image. */ // int getChannels(); // // void getPixel(int row, int col, byte[] rgb); // // /** get all pixels */ // int[] getPixels(); // // ImageData getImage(); // // /** Returns float array with one channel of image by index*/ // float[] toFloat(int index); // // /** Returns int array with one channel of image by index*/ // int[] toInt(int index); // // /** Returns byte array with one channel of image by index*/ // byte[] toByte(int index); // // }
import com.cv4j.core.datamodel.ImageProcessor;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.filters; public class GammaFilter extends BaseFilter { private int[] lut; private double gamma; public GammaFilter() { this.lut = new int[256]; this.gamma = 0.5; } @Override
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageProcessor.java // public interface ImageProcessor { // // /** Returns the width of this image in pixels. */ // int getWidth(); // // /** Returns the height of this image in pixels. */ // int getHeight(); // // /** Returns the channels of this image. */ // int getChannels(); // // void getPixel(int row, int col, byte[] rgb); // // /** get all pixels */ // int[] getPixels(); // // ImageData getImage(); // // /** Returns float array with one channel of image by index*/ // float[] toFloat(int index); // // /** Returns int array with one channel of image by index*/ // int[] toInt(int index); // // /** Returns byte array with one channel of image by index*/ // byte[] toByte(int index); // // } // Path: desktop/src/main/java/com/cv4j/core/filters/GammaFilter.java import com.cv4j.core.datamodel.ImageProcessor; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.filters; public class GammaFilter extends BaseFilter { private int[] lut; private double gamma; public GammaFilter() { this.lut = new int[256]; this.gamma = 0.5; } @Override
public ImageProcessor doFilter(ImageProcessor src) {
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/binary/HoughLinesP.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ByteProcessor.java // public class ByteProcessor implements ImageProcessor { // private int width; // private int height; // // private byte[] GRAY; // private int[] hist; // private ImageData image; // // public ByteProcessor(int width, int height) { // this.width = width; // this.height = height; // this.GRAY = new byte[width*height]; // } // // public ByteProcessor(byte[] data, int width, int height) { // this.width = width; // this.height = height; // this.GRAY = data; // // setup hist // hist = new int[256]; // for(int i=0; i<data.length; i++) { // hist[data[i]&0xff]++; // } // } // // protected void setCallBack(ImageData data) { // this.image = data; // } // // @Override // public int getChannels() { // return 1; // } // // public void getPixel(int row, int col, byte[] rgb) { // int index = row*width + col; // if(rgb != null && rgb.length == 1) { // rgb[0] = GRAY[index]; // } // } // // public byte[] getGray() { // return GRAY; // } // // public void putGray(byte[] gray) { // System.arraycopy(gray, 0, GRAY, 0, gray.length); // } // // public int[] histogram() { // return new int[0]; // } // // public int[] getPixels() { // int size = width * height; // int[] pixels = new int[size]; // for (int i=0; i < size; i++) // pixels[i] = 0xff000000 | ((GRAY[i]&0xff)<<16) | ((GRAY[i]&0xff)<<8) | GRAY[i]&0xff; // return pixels; // } // // @Override // public float[] toFloat(int index) { // float[] data = new float[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public int[] toInt(int index) { // int[] data = new int[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public byte[] toByte(int index) { // return GRAY; // } // // @Override // public int getWidth() { // return width; // } // // @Override // public int getHeight() { // return height; // } // // @Override // public ImageData getImage() { // // return image; // } // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Line.java // public class Line { // public int x1 = 0; // public int y1 = 0; // public int x2 = 0; // public int y2 = 0; // // public Line(int x1, int y1, int x2, int y2) { // this.x1 = x1; // this.y1 = y1; // this.x2 = x2; // this.y2 = y2; // } // // public Line() {} // // public double getSlope() { // double dy = y2 - y1; // double dx = x2 - x1; // if(dx == 0) { // return Double.NaN; // } // return (dy/dx); // } // // public Point getPoint1() { // return new Point(x1, y1); // } // // public Point getPoint2() { // return new Point(x2, y2); // } // // }
import com.cv4j.core.datamodel.ByteProcessor; import com.cv4j.core.datamodel.Line; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.binary; public class HoughLinesP { private double[] coslut; private double[] sinlut; private int accSize; private int width; private int height; private int accThreshold; public HoughLinesP() { setupCosLUT(); setupSinLUT(); } /** * 1. 初始化霍夫变换空间 * 2. 将图像的2D空间转换到霍夫空间,每个像素坐标都要转换到霍夫极坐标的对应强度值 * 3. 找出霍夫极坐标空间的最大强度值 * 4. 根据最大强度值归一化,范围为0 ~ 255 * 5. 根据输入前accSize值,画出前accSize个信号最强的直线 * * @return */
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ByteProcessor.java // public class ByteProcessor implements ImageProcessor { // private int width; // private int height; // // private byte[] GRAY; // private int[] hist; // private ImageData image; // // public ByteProcessor(int width, int height) { // this.width = width; // this.height = height; // this.GRAY = new byte[width*height]; // } // // public ByteProcessor(byte[] data, int width, int height) { // this.width = width; // this.height = height; // this.GRAY = data; // // setup hist // hist = new int[256]; // for(int i=0; i<data.length; i++) { // hist[data[i]&0xff]++; // } // } // // protected void setCallBack(ImageData data) { // this.image = data; // } // // @Override // public int getChannels() { // return 1; // } // // public void getPixel(int row, int col, byte[] rgb) { // int index = row*width + col; // if(rgb != null && rgb.length == 1) { // rgb[0] = GRAY[index]; // } // } // // public byte[] getGray() { // return GRAY; // } // // public void putGray(byte[] gray) { // System.arraycopy(gray, 0, GRAY, 0, gray.length); // } // // public int[] histogram() { // return new int[0]; // } // // public int[] getPixels() { // int size = width * height; // int[] pixels = new int[size]; // for (int i=0; i < size; i++) // pixels[i] = 0xff000000 | ((GRAY[i]&0xff)<<16) | ((GRAY[i]&0xff)<<8) | GRAY[i]&0xff; // return pixels; // } // // @Override // public float[] toFloat(int index) { // float[] data = new float[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public int[] toInt(int index) { // int[] data = new int[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public byte[] toByte(int index) { // return GRAY; // } // // @Override // public int getWidth() { // return width; // } // // @Override // public int getHeight() { // return height; // } // // @Override // public ImageData getImage() { // // return image; // } // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Line.java // public class Line { // public int x1 = 0; // public int y1 = 0; // public int x2 = 0; // public int y2 = 0; // // public Line(int x1, int y1, int x2, int y2) { // this.x1 = x1; // this.y1 = y1; // this.x2 = x2; // this.y2 = y2; // } // // public Line() {} // // public double getSlope() { // double dy = y2 - y1; // double dx = x2 - x1; // if(dx == 0) { // return Double.NaN; // } // return (dy/dx); // } // // public Point getPoint1() { // return new Point(x1, y1); // } // // public Point getPoint2() { // return new Point(x2, y2); // } // // } // Path: desktop/src/main/java/com/cv4j/core/binary/HoughLinesP.java import com.cv4j.core.datamodel.ByteProcessor; import com.cv4j.core.datamodel.Line; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.binary; public class HoughLinesP { private double[] coslut; private double[] sinlut; private int accSize; private int width; private int height; private int accThreshold; public HoughLinesP() { setupCosLUT(); setupSinLUT(); } /** * 1. 初始化霍夫变换空间 * 2. 将图像的2D空间转换到霍夫空间,每个像素坐标都要转换到霍夫极坐标的对应强度值 * 3. 找出霍夫极坐标空间的最大强度值 * 4. 根据最大强度值归一化,范围为0 ~ 255 * 5. 根据输入前accSize值,画出前accSize个信号最强的直线 * * @return */
public void process(ByteProcessor binary, int accSize, int minGap, int minAcc, List<Line> lines) {
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/binary/HoughLinesP.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ByteProcessor.java // public class ByteProcessor implements ImageProcessor { // private int width; // private int height; // // private byte[] GRAY; // private int[] hist; // private ImageData image; // // public ByteProcessor(int width, int height) { // this.width = width; // this.height = height; // this.GRAY = new byte[width*height]; // } // // public ByteProcessor(byte[] data, int width, int height) { // this.width = width; // this.height = height; // this.GRAY = data; // // setup hist // hist = new int[256]; // for(int i=0; i<data.length; i++) { // hist[data[i]&0xff]++; // } // } // // protected void setCallBack(ImageData data) { // this.image = data; // } // // @Override // public int getChannels() { // return 1; // } // // public void getPixel(int row, int col, byte[] rgb) { // int index = row*width + col; // if(rgb != null && rgb.length == 1) { // rgb[0] = GRAY[index]; // } // } // // public byte[] getGray() { // return GRAY; // } // // public void putGray(byte[] gray) { // System.arraycopy(gray, 0, GRAY, 0, gray.length); // } // // public int[] histogram() { // return new int[0]; // } // // public int[] getPixels() { // int size = width * height; // int[] pixels = new int[size]; // for (int i=0; i < size; i++) // pixels[i] = 0xff000000 | ((GRAY[i]&0xff)<<16) | ((GRAY[i]&0xff)<<8) | GRAY[i]&0xff; // return pixels; // } // // @Override // public float[] toFloat(int index) { // float[] data = new float[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public int[] toInt(int index) { // int[] data = new int[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public byte[] toByte(int index) { // return GRAY; // } // // @Override // public int getWidth() { // return width; // } // // @Override // public int getHeight() { // return height; // } // // @Override // public ImageData getImage() { // // return image; // } // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Line.java // public class Line { // public int x1 = 0; // public int y1 = 0; // public int x2 = 0; // public int y2 = 0; // // public Line(int x1, int y1, int x2, int y2) { // this.x1 = x1; // this.y1 = y1; // this.x2 = x2; // this.y2 = y2; // } // // public Line() {} // // public double getSlope() { // double dy = y2 - y1; // double dx = x2 - x1; // if(dx == 0) { // return Double.NaN; // } // return (dy/dx); // } // // public Point getPoint1() { // return new Point(x1, y1); // } // // public Point getPoint2() { // return new Point(x2, y2); // } // // }
import com.cv4j.core.datamodel.ByteProcessor; import com.cv4j.core.datamodel.Line; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.binary; public class HoughLinesP { private double[] coslut; private double[] sinlut; private int accSize; private int width; private int height; private int accThreshold; public HoughLinesP() { setupCosLUT(); setupSinLUT(); } /** * 1. 初始化霍夫变换空间 * 2. 将图像的2D空间转换到霍夫空间,每个像素坐标都要转换到霍夫极坐标的对应强度值 * 3. 找出霍夫极坐标空间的最大强度值 * 4. 根据最大强度值归一化,范围为0 ~ 255 * 5. 根据输入前accSize值,画出前accSize个信号最强的直线 * * @return */
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ByteProcessor.java // public class ByteProcessor implements ImageProcessor { // private int width; // private int height; // // private byte[] GRAY; // private int[] hist; // private ImageData image; // // public ByteProcessor(int width, int height) { // this.width = width; // this.height = height; // this.GRAY = new byte[width*height]; // } // // public ByteProcessor(byte[] data, int width, int height) { // this.width = width; // this.height = height; // this.GRAY = data; // // setup hist // hist = new int[256]; // for(int i=0; i<data.length; i++) { // hist[data[i]&0xff]++; // } // } // // protected void setCallBack(ImageData data) { // this.image = data; // } // // @Override // public int getChannels() { // return 1; // } // // public void getPixel(int row, int col, byte[] rgb) { // int index = row*width + col; // if(rgb != null && rgb.length == 1) { // rgb[0] = GRAY[index]; // } // } // // public byte[] getGray() { // return GRAY; // } // // public void putGray(byte[] gray) { // System.arraycopy(gray, 0, GRAY, 0, gray.length); // } // // public int[] histogram() { // return new int[0]; // } // // public int[] getPixels() { // int size = width * height; // int[] pixels = new int[size]; // for (int i=0; i < size; i++) // pixels[i] = 0xff000000 | ((GRAY[i]&0xff)<<16) | ((GRAY[i]&0xff)<<8) | GRAY[i]&0xff; // return pixels; // } // // @Override // public float[] toFloat(int index) { // float[] data = new float[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public int[] toInt(int index) { // int[] data = new int[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public byte[] toByte(int index) { // return GRAY; // } // // @Override // public int getWidth() { // return width; // } // // @Override // public int getHeight() { // return height; // } // // @Override // public ImageData getImage() { // // return image; // } // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Line.java // public class Line { // public int x1 = 0; // public int y1 = 0; // public int x2 = 0; // public int y2 = 0; // // public Line(int x1, int y1, int x2, int y2) { // this.x1 = x1; // this.y1 = y1; // this.x2 = x2; // this.y2 = y2; // } // // public Line() {} // // public double getSlope() { // double dy = y2 - y1; // double dx = x2 - x1; // if(dx == 0) { // return Double.NaN; // } // return (dy/dx); // } // // public Point getPoint1() { // return new Point(x1, y1); // } // // public Point getPoint2() { // return new Point(x2, y2); // } // // } // Path: desktop/src/main/java/com/cv4j/core/binary/HoughLinesP.java import com.cv4j.core.datamodel.ByteProcessor; import com.cv4j.core.datamodel.Line; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.binary; public class HoughLinesP { private double[] coslut; private double[] sinlut; private int accSize; private int width; private int height; private int accThreshold; public HoughLinesP() { setupCosLUT(); setupSinLUT(); } /** * 1. 初始化霍夫变换空间 * 2. 将图像的2D空间转换到霍夫空间,每个像素坐标都要转换到霍夫极坐标的对应强度值 * 3. 找出霍夫极坐标空间的最大强度值 * 4. 根据最大强度值归一化,范围为0 ~ 255 * 5. 根据输入前accSize值,画出前accSize个信号最强的直线 * * @return */
public void process(ByteProcessor binary, int accSize, int minGap, int minAcc, List<Line> lines) {
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/datamodel/ColorProcessor.java
// Path: desktop/src/main/java/com/cv4j/exception/CV4JException.java // public class CV4JException extends RuntimeException { // // private static final long serialVersionUID = -2565764903880816387L; // // public CV4JException(String message) { // super(message); // } // // public CV4JException(Throwable throwable) { // super(throwable); // } // // public CV4JException(String message, Throwable throwable) { // super(message, throwable); // } // }
import com.cv4j.exception.CV4JException;
this.image = data; } public ImageData getImage() { return this.image; } @Override public float[] toFloat(int index) { if(index == 0) { float[] data = new float[R.length]; int length = data.length; for(int i=0; i<length; i++) data[i] = R[i]&0xff; return data; } else if(index == 1) { float[] data = new float[G.length]; int length = data.length; for(int i=0; i<length; i++) data[i] = G[i]&0xff; return data; } else if(index == 2) { float[] data = new float[B.length]; int length = data.length; for(int i=0; i<length; i++) data[i] = B[i]&0xff; return data; } else {
// Path: desktop/src/main/java/com/cv4j/exception/CV4JException.java // public class CV4JException extends RuntimeException { // // private static final long serialVersionUID = -2565764903880816387L; // // public CV4JException(String message) { // super(message); // } // // public CV4JException(Throwable throwable) { // super(throwable); // } // // public CV4JException(String message, Throwable throwable) { // super(message, throwable); // } // } // Path: desktop/src/main/java/com/cv4j/core/datamodel/ColorProcessor.java import com.cv4j.exception.CV4JException; this.image = data; } public ImageData getImage() { return this.image; } @Override public float[] toFloat(int index) { if(index == 0) { float[] data = new float[R.length]; int length = data.length; for(int i=0; i<length; i++) data[i] = R[i]&0xff; return data; } else if(index == 1) { float[] data = new float[G.length]; int length = data.length; for(int i=0; i<length; i++) data[i] = G[i]&0xff; return data; } else if(index == 2) { float[] data = new float[B.length]; int length = data.length; for(int i=0; i<length; i++) data[i] = B[i]&0xff; return data; } else {
throw new CV4JException("invalid argument...");
imageprocessor/cv4j-desktop
desktop-demo/src/main/java/example/com/cv4j/example/controller/DefaultController.java
// Path: desktop-demo/src/main/java/example/com/cv4j/example/model/EventData.java // public class EventData { // private Map<String, Object> data; // // public EventData() { // data = new HashMap<>(); // } // // public void putData(String name, Object obj) { // data.put(name, obj); // } // // public Object getData(String name) { // return data.get(name); // } // // public String getString(String name) { // return (String)data.get(name); // } // // public boolean getFileOpen(String name) { // String cmd = (String)data.get(name); // return cmd == null ? false: cmd.equals(MenuConstants.FILE_OPEN); // } // // public int getInt(String name) { // Integer i = (Integer)data.get(name); // return i==null? 0: i.intValue(); // } // // public double getDouble(String name) { // Double i = (Double)data.get(name); // return i==null? 0: i.doubleValue(); // } // // public float getFloat(String name) { // Float i = (Float)data.get(name); // return i==null? 0: i.floatValue(); // } // // }
import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import example.com.cv4j.example.model.EventData;
package example.com.cv4j.example.controller; /** * Created by zhigang on 2018/1/2. */ public class DefaultController implements ActionListener { private EventHandler eventHandler; public DefaultController(EventHandler handler) { this.eventHandler = handler; } @Override public void actionPerformed(ActionEvent cmd) {
// Path: desktop-demo/src/main/java/example/com/cv4j/example/model/EventData.java // public class EventData { // private Map<String, Object> data; // // public EventData() { // data = new HashMap<>(); // } // // public void putData(String name, Object obj) { // data.put(name, obj); // } // // public Object getData(String name) { // return data.get(name); // } // // public String getString(String name) { // return (String)data.get(name); // } // // public boolean getFileOpen(String name) { // String cmd = (String)data.get(name); // return cmd == null ? false: cmd.equals(MenuConstants.FILE_OPEN); // } // // public int getInt(String name) { // Integer i = (Integer)data.get(name); // return i==null? 0: i.intValue(); // } // // public double getDouble(String name) { // Double i = (Double)data.get(name); // return i==null? 0: i.doubleValue(); // } // // public float getFloat(String name) { // Float i = (Float)data.get(name); // return i==null? 0: i.floatValue(); // } // // } // Path: desktop-demo/src/main/java/example/com/cv4j/example/controller/DefaultController.java import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import example.com.cv4j.example.model.EventData; package example.com.cv4j.example.controller; /** * Created by zhigang on 2018/1/2. */ public class DefaultController implements ActionListener { private EventHandler eventHandler; public DefaultController(EventHandler handler) { this.eventHandler = handler; } @Override public void actionPerformed(ActionEvent cmd) {
EventData ed = new EventData();
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/spatial/conv/ConvolutionHVFilter.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageProcessor.java // public interface ImageProcessor { // // /** Returns the width of this image in pixels. */ // int getWidth(); // // /** Returns the height of this image in pixels. */ // int getHeight(); // // /** Returns the channels of this image. */ // int getChannels(); // // void getPixel(int row, int col, byte[] rgb); // // /** get all pixels */ // int[] getPixels(); // // ImageData getImage(); // // /** Returns float array with one channel of image by index*/ // float[] toFloat(int index); // // /** Returns int array with one channel of image by index*/ // int[] toInt(int index); // // /** Returns byte array with one channel of image by index*/ // byte[] toByte(int index); // // } // // Path: desktop/src/main/java/com/cv4j/core/filters/BaseFilter.java // public abstract class BaseFilter implements CommonFilter { // // protected int width; // protected int height; // protected byte[] R; // protected byte[] G; // protected byte[] B; // // @Override // public ImageProcessor filter(ImageProcessor src) { // // if (src == null) return null; // // if (!(src instanceof ColorProcessor)) return src; // // width = src.getWidth(); // height = src.getHeight(); // R = ((ColorProcessor)src).getRed(); // G = ((ColorProcessor)src).getGreen(); // B = ((ColorProcessor)src).getBlue(); // // return doFilter(src); // } // // public abstract ImageProcessor doFilter(ImageProcessor src); // }
import com.cv4j.core.datamodel.ImageProcessor; import com.cv4j.core.filters.BaseFilter;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.spatial.conv; /** * can iteration this operation multiple, make it more blur */ public class ConvolutionHVFilter extends BaseFilter { @Override
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageProcessor.java // public interface ImageProcessor { // // /** Returns the width of this image in pixels. */ // int getWidth(); // // /** Returns the height of this image in pixels. */ // int getHeight(); // // /** Returns the channels of this image. */ // int getChannels(); // // void getPixel(int row, int col, byte[] rgb); // // /** get all pixels */ // int[] getPixels(); // // ImageData getImage(); // // /** Returns float array with one channel of image by index*/ // float[] toFloat(int index); // // /** Returns int array with one channel of image by index*/ // int[] toInt(int index); // // /** Returns byte array with one channel of image by index*/ // byte[] toByte(int index); // // } // // Path: desktop/src/main/java/com/cv4j/core/filters/BaseFilter.java // public abstract class BaseFilter implements CommonFilter { // // protected int width; // protected int height; // protected byte[] R; // protected byte[] G; // protected byte[] B; // // @Override // public ImageProcessor filter(ImageProcessor src) { // // if (src == null) return null; // // if (!(src instanceof ColorProcessor)) return src; // // width = src.getWidth(); // height = src.getHeight(); // R = ((ColorProcessor)src).getRed(); // G = ((ColorProcessor)src).getGreen(); // B = ((ColorProcessor)src).getBlue(); // // return doFilter(src); // } // // public abstract ImageProcessor doFilter(ImageProcessor src); // } // Path: desktop/src/main/java/com/cv4j/core/spatial/conv/ConvolutionHVFilter.java import com.cv4j.core.datamodel.ImageProcessor; import com.cv4j.core.filters.BaseFilter; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.spatial.conv; /** * can iteration this operation multiple, make it more blur */ public class ConvolutionHVFilter extends BaseFilter { @Override
public ImageProcessor doFilter(ImageProcessor src) {
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/binary/MorphGradient.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ByteProcessor.java // public class ByteProcessor implements ImageProcessor { // private int width; // private int height; // // private byte[] GRAY; // private int[] hist; // private ImageData image; // // public ByteProcessor(int width, int height) { // this.width = width; // this.height = height; // this.GRAY = new byte[width*height]; // } // // public ByteProcessor(byte[] data, int width, int height) { // this.width = width; // this.height = height; // this.GRAY = data; // // setup hist // hist = new int[256]; // for(int i=0; i<data.length; i++) { // hist[data[i]&0xff]++; // } // } // // protected void setCallBack(ImageData data) { // this.image = data; // } // // @Override // public int getChannels() { // return 1; // } // // public void getPixel(int row, int col, byte[] rgb) { // int index = row*width + col; // if(rgb != null && rgb.length == 1) { // rgb[0] = GRAY[index]; // } // } // // public byte[] getGray() { // return GRAY; // } // // public void putGray(byte[] gray) { // System.arraycopy(gray, 0, GRAY, 0, gray.length); // } // // public int[] histogram() { // return new int[0]; // } // // public int[] getPixels() { // int size = width * height; // int[] pixels = new int[size]; // for (int i=0; i < size; i++) // pixels[i] = 0xff000000 | ((GRAY[i]&0xff)<<16) | ((GRAY[i]&0xff)<<8) | GRAY[i]&0xff; // return pixels; // } // // @Override // public float[] toFloat(int index) { // float[] data = new float[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public int[] toInt(int index) { // int[] data = new int[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public byte[] toByte(int index) { // return GRAY; // } // // @Override // public int getWidth() { // return width; // } // // @Override // public int getHeight() { // return height; // } // // @Override // public ImageData getImage() { // // return image; // } // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Size.java // public class Size { // public int cols; // public int rows; // // public Size(int num) { // this.cols = num; // this.rows = num; // } // // public Size(int width, int height) { // this.cols = width; // this.rows = height; // } // } // // Path: desktop/src/main/java/com/cv4j/exception/CV4JException.java // public class CV4JException extends RuntimeException { // // private static final long serialVersionUID = -2565764903880816387L; // // public CV4JException(String message) { // super(message); // } // // public CV4JException(Throwable throwable) { // super(throwable); // } // // public CV4JException(String message, Throwable throwable) { // super(message, throwable); // } // }
import com.cv4j.core.datamodel.ByteProcessor; import com.cv4j.core.datamodel.Size; import com.cv4j.exception.CV4JException;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.binary; public class MorphGradient { public static final int INTERNAL_GRADIENT = 1; public static final int EXTERNAL_GRADIENT = 2; public static final int BASIC_GRADIENT = 3; /*** * * @param gray * @param structureElement - 3, 5, 7 must be odd * @param gradientType */
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ByteProcessor.java // public class ByteProcessor implements ImageProcessor { // private int width; // private int height; // // private byte[] GRAY; // private int[] hist; // private ImageData image; // // public ByteProcessor(int width, int height) { // this.width = width; // this.height = height; // this.GRAY = new byte[width*height]; // } // // public ByteProcessor(byte[] data, int width, int height) { // this.width = width; // this.height = height; // this.GRAY = data; // // setup hist // hist = new int[256]; // for(int i=0; i<data.length; i++) { // hist[data[i]&0xff]++; // } // } // // protected void setCallBack(ImageData data) { // this.image = data; // } // // @Override // public int getChannels() { // return 1; // } // // public void getPixel(int row, int col, byte[] rgb) { // int index = row*width + col; // if(rgb != null && rgb.length == 1) { // rgb[0] = GRAY[index]; // } // } // // public byte[] getGray() { // return GRAY; // } // // public void putGray(byte[] gray) { // System.arraycopy(gray, 0, GRAY, 0, gray.length); // } // // public int[] histogram() { // return new int[0]; // } // // public int[] getPixels() { // int size = width * height; // int[] pixels = new int[size]; // for (int i=0; i < size; i++) // pixels[i] = 0xff000000 | ((GRAY[i]&0xff)<<16) | ((GRAY[i]&0xff)<<8) | GRAY[i]&0xff; // return pixels; // } // // @Override // public float[] toFloat(int index) { // float[] data = new float[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public int[] toInt(int index) { // int[] data = new int[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public byte[] toByte(int index) { // return GRAY; // } // // @Override // public int getWidth() { // return width; // } // // @Override // public int getHeight() { // return height; // } // // @Override // public ImageData getImage() { // // return image; // } // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Size.java // public class Size { // public int cols; // public int rows; // // public Size(int num) { // this.cols = num; // this.rows = num; // } // // public Size(int width, int height) { // this.cols = width; // this.rows = height; // } // } // // Path: desktop/src/main/java/com/cv4j/exception/CV4JException.java // public class CV4JException extends RuntimeException { // // private static final long serialVersionUID = -2565764903880816387L; // // public CV4JException(String message) { // super(message); // } // // public CV4JException(Throwable throwable) { // super(throwable); // } // // public CV4JException(String message, Throwable throwable) { // super(message, throwable); // } // } // Path: desktop/src/main/java/com/cv4j/core/binary/MorphGradient.java import com.cv4j.core.datamodel.ByteProcessor; import com.cv4j.core.datamodel.Size; import com.cv4j.exception.CV4JException; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.binary; public class MorphGradient { public static final int INTERNAL_GRADIENT = 1; public static final int EXTERNAL_GRADIENT = 2; public static final int BASIC_GRADIENT = 3; /*** * * @param gray * @param structureElement - 3, 5, 7 must be odd * @param gradientType */
public void process(ByteProcessor gray, Size structureElement, int gradientType) {
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/binary/MorphGradient.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ByteProcessor.java // public class ByteProcessor implements ImageProcessor { // private int width; // private int height; // // private byte[] GRAY; // private int[] hist; // private ImageData image; // // public ByteProcessor(int width, int height) { // this.width = width; // this.height = height; // this.GRAY = new byte[width*height]; // } // // public ByteProcessor(byte[] data, int width, int height) { // this.width = width; // this.height = height; // this.GRAY = data; // // setup hist // hist = new int[256]; // for(int i=0; i<data.length; i++) { // hist[data[i]&0xff]++; // } // } // // protected void setCallBack(ImageData data) { // this.image = data; // } // // @Override // public int getChannels() { // return 1; // } // // public void getPixel(int row, int col, byte[] rgb) { // int index = row*width + col; // if(rgb != null && rgb.length == 1) { // rgb[0] = GRAY[index]; // } // } // // public byte[] getGray() { // return GRAY; // } // // public void putGray(byte[] gray) { // System.arraycopy(gray, 0, GRAY, 0, gray.length); // } // // public int[] histogram() { // return new int[0]; // } // // public int[] getPixels() { // int size = width * height; // int[] pixels = new int[size]; // for (int i=0; i < size; i++) // pixels[i] = 0xff000000 | ((GRAY[i]&0xff)<<16) | ((GRAY[i]&0xff)<<8) | GRAY[i]&0xff; // return pixels; // } // // @Override // public float[] toFloat(int index) { // float[] data = new float[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public int[] toInt(int index) { // int[] data = new int[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public byte[] toByte(int index) { // return GRAY; // } // // @Override // public int getWidth() { // return width; // } // // @Override // public int getHeight() { // return height; // } // // @Override // public ImageData getImage() { // // return image; // } // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Size.java // public class Size { // public int cols; // public int rows; // // public Size(int num) { // this.cols = num; // this.rows = num; // } // // public Size(int width, int height) { // this.cols = width; // this.rows = height; // } // } // // Path: desktop/src/main/java/com/cv4j/exception/CV4JException.java // public class CV4JException extends RuntimeException { // // private static final long serialVersionUID = -2565764903880816387L; // // public CV4JException(String message) { // super(message); // } // // public CV4JException(Throwable throwable) { // super(throwable); // } // // public CV4JException(String message, Throwable throwable) { // super(message, throwable); // } // }
import com.cv4j.core.datamodel.ByteProcessor; import com.cv4j.core.datamodel.Size; import com.cv4j.exception.CV4JException;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.binary; public class MorphGradient { public static final int INTERNAL_GRADIENT = 1; public static final int EXTERNAL_GRADIENT = 2; public static final int BASIC_GRADIENT = 3; /*** * * @param gray * @param structureElement - 3, 5, 7 must be odd * @param gradientType */
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ByteProcessor.java // public class ByteProcessor implements ImageProcessor { // private int width; // private int height; // // private byte[] GRAY; // private int[] hist; // private ImageData image; // // public ByteProcessor(int width, int height) { // this.width = width; // this.height = height; // this.GRAY = new byte[width*height]; // } // // public ByteProcessor(byte[] data, int width, int height) { // this.width = width; // this.height = height; // this.GRAY = data; // // setup hist // hist = new int[256]; // for(int i=0; i<data.length; i++) { // hist[data[i]&0xff]++; // } // } // // protected void setCallBack(ImageData data) { // this.image = data; // } // // @Override // public int getChannels() { // return 1; // } // // public void getPixel(int row, int col, byte[] rgb) { // int index = row*width + col; // if(rgb != null && rgb.length == 1) { // rgb[0] = GRAY[index]; // } // } // // public byte[] getGray() { // return GRAY; // } // // public void putGray(byte[] gray) { // System.arraycopy(gray, 0, GRAY, 0, gray.length); // } // // public int[] histogram() { // return new int[0]; // } // // public int[] getPixels() { // int size = width * height; // int[] pixels = new int[size]; // for (int i=0; i < size; i++) // pixels[i] = 0xff000000 | ((GRAY[i]&0xff)<<16) | ((GRAY[i]&0xff)<<8) | GRAY[i]&0xff; // return pixels; // } // // @Override // public float[] toFloat(int index) { // float[] data = new float[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public int[] toInt(int index) { // int[] data = new int[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public byte[] toByte(int index) { // return GRAY; // } // // @Override // public int getWidth() { // return width; // } // // @Override // public int getHeight() { // return height; // } // // @Override // public ImageData getImage() { // // return image; // } // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Size.java // public class Size { // public int cols; // public int rows; // // public Size(int num) { // this.cols = num; // this.rows = num; // } // // public Size(int width, int height) { // this.cols = width; // this.rows = height; // } // } // // Path: desktop/src/main/java/com/cv4j/exception/CV4JException.java // public class CV4JException extends RuntimeException { // // private static final long serialVersionUID = -2565764903880816387L; // // public CV4JException(String message) { // super(message); // } // // public CV4JException(Throwable throwable) { // super(throwable); // } // // public CV4JException(String message, Throwable throwable) { // super(message, throwable); // } // } // Path: desktop/src/main/java/com/cv4j/core/binary/MorphGradient.java import com.cv4j.core.datamodel.ByteProcessor; import com.cv4j.core.datamodel.Size; import com.cv4j.exception.CV4JException; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.binary; public class MorphGradient { public static final int INTERNAL_GRADIENT = 1; public static final int EXTERNAL_GRADIENT = 2; public static final int BASIC_GRADIENT = 3; /*** * * @param gray * @param structureElement - 3, 5, 7 must be odd * @param gradientType */
public void process(ByteProcessor gray, Size structureElement, int gradientType) {
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/binary/MorphGradient.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ByteProcessor.java // public class ByteProcessor implements ImageProcessor { // private int width; // private int height; // // private byte[] GRAY; // private int[] hist; // private ImageData image; // // public ByteProcessor(int width, int height) { // this.width = width; // this.height = height; // this.GRAY = new byte[width*height]; // } // // public ByteProcessor(byte[] data, int width, int height) { // this.width = width; // this.height = height; // this.GRAY = data; // // setup hist // hist = new int[256]; // for(int i=0; i<data.length; i++) { // hist[data[i]&0xff]++; // } // } // // protected void setCallBack(ImageData data) { // this.image = data; // } // // @Override // public int getChannels() { // return 1; // } // // public void getPixel(int row, int col, byte[] rgb) { // int index = row*width + col; // if(rgb != null && rgb.length == 1) { // rgb[0] = GRAY[index]; // } // } // // public byte[] getGray() { // return GRAY; // } // // public void putGray(byte[] gray) { // System.arraycopy(gray, 0, GRAY, 0, gray.length); // } // // public int[] histogram() { // return new int[0]; // } // // public int[] getPixels() { // int size = width * height; // int[] pixels = new int[size]; // for (int i=0; i < size; i++) // pixels[i] = 0xff000000 | ((GRAY[i]&0xff)<<16) | ((GRAY[i]&0xff)<<8) | GRAY[i]&0xff; // return pixels; // } // // @Override // public float[] toFloat(int index) { // float[] data = new float[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public int[] toInt(int index) { // int[] data = new int[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public byte[] toByte(int index) { // return GRAY; // } // // @Override // public int getWidth() { // return width; // } // // @Override // public int getHeight() { // return height; // } // // @Override // public ImageData getImage() { // // return image; // } // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Size.java // public class Size { // public int cols; // public int rows; // // public Size(int num) { // this.cols = num; // this.rows = num; // } // // public Size(int width, int height) { // this.cols = width; // this.rows = height; // } // } // // Path: desktop/src/main/java/com/cv4j/exception/CV4JException.java // public class CV4JException extends RuntimeException { // // private static final long serialVersionUID = -2565764903880816387L; // // public CV4JException(String message) { // super(message); // } // // public CV4JException(Throwable throwable) { // super(throwable); // } // // public CV4JException(String message, Throwable throwable) { // super(message, throwable); // } // }
import com.cv4j.core.datamodel.ByteProcessor; import com.cv4j.core.datamodel.Size; import com.cv4j.exception.CV4JException;
continue; } offset = (row+i)*width; max = Math.max(max, data[offset+col]&0xff); } dil[row*width+col] = (byte)max; } } // calculate gradient int c = 0; if(gradientType == BASIC_GRADIENT) { for(int i=0; i<data.length; i++) { c = (dil[i]&0xff - ero[i]&0xff); data[i] = (byte) ((c > 0) ? 255 : 0); } gray.putGray(data); } else if(gradientType == EXTERNAL_GRADIENT) { data = gray.getGray(); for(int i=0; i<data.length; i++) { data[i] = (byte)(dil[i]&0xff - data[i]&0xff); } } else if(gradientType == INTERNAL_GRADIENT) { data = gray.getGray(); for(int i=0; i<data.length; i++) { data[i] = (byte)(data[i]&0xff - ero[i]&0xff); } } else {
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ByteProcessor.java // public class ByteProcessor implements ImageProcessor { // private int width; // private int height; // // private byte[] GRAY; // private int[] hist; // private ImageData image; // // public ByteProcessor(int width, int height) { // this.width = width; // this.height = height; // this.GRAY = new byte[width*height]; // } // // public ByteProcessor(byte[] data, int width, int height) { // this.width = width; // this.height = height; // this.GRAY = data; // // setup hist // hist = new int[256]; // for(int i=0; i<data.length; i++) { // hist[data[i]&0xff]++; // } // } // // protected void setCallBack(ImageData data) { // this.image = data; // } // // @Override // public int getChannels() { // return 1; // } // // public void getPixel(int row, int col, byte[] rgb) { // int index = row*width + col; // if(rgb != null && rgb.length == 1) { // rgb[0] = GRAY[index]; // } // } // // public byte[] getGray() { // return GRAY; // } // // public void putGray(byte[] gray) { // System.arraycopy(gray, 0, GRAY, 0, gray.length); // } // // public int[] histogram() { // return new int[0]; // } // // public int[] getPixels() { // int size = width * height; // int[] pixels = new int[size]; // for (int i=0; i < size; i++) // pixels[i] = 0xff000000 | ((GRAY[i]&0xff)<<16) | ((GRAY[i]&0xff)<<8) | GRAY[i]&0xff; // return pixels; // } // // @Override // public float[] toFloat(int index) { // float[] data = new float[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public int[] toInt(int index) { // int[] data = new int[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public byte[] toByte(int index) { // return GRAY; // } // // @Override // public int getWidth() { // return width; // } // // @Override // public int getHeight() { // return height; // } // // @Override // public ImageData getImage() { // // return image; // } // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Size.java // public class Size { // public int cols; // public int rows; // // public Size(int num) { // this.cols = num; // this.rows = num; // } // // public Size(int width, int height) { // this.cols = width; // this.rows = height; // } // } // // Path: desktop/src/main/java/com/cv4j/exception/CV4JException.java // public class CV4JException extends RuntimeException { // // private static final long serialVersionUID = -2565764903880816387L; // // public CV4JException(String message) { // super(message); // } // // public CV4JException(Throwable throwable) { // super(throwable); // } // // public CV4JException(String message, Throwable throwable) { // super(message, throwable); // } // } // Path: desktop/src/main/java/com/cv4j/core/binary/MorphGradient.java import com.cv4j.core.datamodel.ByteProcessor; import com.cv4j.core.datamodel.Size; import com.cv4j.exception.CV4JException; continue; } offset = (row+i)*width; max = Math.max(max, data[offset+col]&0xff); } dil[row*width+col] = (byte)max; } } // calculate gradient int c = 0; if(gradientType == BASIC_GRADIENT) { for(int i=0; i<data.length; i++) { c = (dil[i]&0xff - ero[i]&0xff); data[i] = (byte) ((c > 0) ? 255 : 0); } gray.putGray(data); } else if(gradientType == EXTERNAL_GRADIENT) { data = gray.getGray(); for(int i=0; i<data.length; i++) { data[i] = (byte)(dil[i]&0xff - data[i]&0xff); } } else if(gradientType == INTERNAL_GRADIENT) { data = gray.getGray(); for(int i=0; i<data.length; i++) { data[i] = (byte)(data[i]&0xff - ero[i]&0xff); } } else {
throw new CV4JException("Unknown Gradient type, not supported...");
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/filters/SinCityFilter.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageData.java // public interface ImageData { // // int[] SQRT_LUT = new int[] { // 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, // 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, // 1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936, 2025, 2116, 2209, 2304, // 2401, 2500, 2601, 2704, 2809, 2916, 3025, 3136, 3249, 3364, 3481, 3600, 3721, 3844, // 3969, 4096, 4225, 4356, 4489, 4624, 4761, 4900, 5041, 5184, 5329, 5476, 5625, 5776, // 5929, 6084, 6241, 6400, 6561, 6724, 6889, 7056, 7225, 7396, 7569, 7744, 7921, 8100, // 8281, 8464, 8649, 8836, 9025, 9216, 9409, 9604, 9801, 10000, 10201, 10404, 10609, // 10816, 11025, 11236, 11449, 11664, 11881, 12100, 12321, 12544, 12769, 12996, 13225, // 13456, 13689, 13924, 14161, 14400, 14641, 14884, 15129, 15376, 15625, 15876, 16129, // 16384, 16641, 16900, 17161, 17424, 17689, 17956, 18225, 18496, 18769, 19044, 19321, // 19600, 19881, 20164, 20449, 20736, 21025, 21316, 21609, 21904, 22201, 22500, 22801, // 23104, 23409, 23716, 24025, 24336, 24649, 24964, 25281, 25600, 25921, 26244, 26569, // 26896, 27225, 27556, 27889, 28224, 28561, 28900, 29241, 29584, 29929, 30276, 30625, // 30976, 31329, 31684, 32041, 32400, 32761, 33124, 33489, 33856, 34225, 34596, 34969, // 35344, 35721, 36100, 36481, 36864, 37249, 37636, 38025, 38416, 38809, 39204, 39601, // 40000, 40401, 40804, 41209, 41616, 42025, 42436, 42849, 43264, 43681, 44100, 44521, // 44944, 45369, 45796, 46225, 46656, 47089, 47524, 47961, 48400, 48841, 49284, 49729, // 50176, 50625, 51076, 51529, 51984, 52441, 52900, 53361, 53824, 54289, 54756, 55225, // 55696, 56169, 56644, 57121, 57600, 58081, 58564, 59049, 59536, 60025, 60516, 61009, // 61504, 62001, 62500, 63001, 63504, 64009, 64516, 65025, // }; // // int CV4J_IMAGE_TYPE_RGB = 0; // int CV4J_IMAGE_TYPE_GRAY = 2; // int CV4J_IMAGE_TYPE_HSV = 4; // int CV4J_IMAGE_TYPE_BINARY = 8; // // ImageProcessor getProcessor(); // // CV4JImage convert2Gray(); // // BufferedImage toBitmap(); // // void setBitmap(BufferedImage bitmap); // // void resetBitmap(); // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageProcessor.java // public interface ImageProcessor { // // /** Returns the width of this image in pixels. */ // int getWidth(); // // /** Returns the height of this image in pixels. */ // int getHeight(); // // /** Returns the channels of this image. */ // int getChannels(); // // void getPixel(int row, int col, byte[] rgb); // // /** get all pixels */ // int[] getPixels(); // // ImageData getImage(); // // /** Returns float array with one channel of image by index*/ // float[] toFloat(int index); // // /** Returns int array with one channel of image by index*/ // int[] toInt(int index); // // /** Returns byte array with one channel of image by index*/ // byte[] toByte(int index); // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Scalar.java // public class Scalar { // public int red; // public int green; // public int blue; // public int alpha; // public Scalar(int red, int green, int blue) { // this.red = red; // this.green = green; // this.blue = blue; // this.alpha = 255; // } // // public static Scalar argb(int alpha, int red, int green, int blue){ // return new Scalar(red, green, blue); // } // // public static Scalar rgb(int red, int green, int blue){ // return new Scalar(red, green, blue); // } // // public Scalar() { // red = 0; // green = 0; // blue = 0; // alpha = 255; // } // // }
import com.cv4j.core.datamodel.ImageData; import com.cv4j.core.datamodel.ImageProcessor; import com.cv4j.core.datamodel.Scalar;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.filters; public class SinCityFilter extends BaseFilter { private double threshold = 200; // default value
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageData.java // public interface ImageData { // // int[] SQRT_LUT = new int[] { // 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, // 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, // 1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936, 2025, 2116, 2209, 2304, // 2401, 2500, 2601, 2704, 2809, 2916, 3025, 3136, 3249, 3364, 3481, 3600, 3721, 3844, // 3969, 4096, 4225, 4356, 4489, 4624, 4761, 4900, 5041, 5184, 5329, 5476, 5625, 5776, // 5929, 6084, 6241, 6400, 6561, 6724, 6889, 7056, 7225, 7396, 7569, 7744, 7921, 8100, // 8281, 8464, 8649, 8836, 9025, 9216, 9409, 9604, 9801, 10000, 10201, 10404, 10609, // 10816, 11025, 11236, 11449, 11664, 11881, 12100, 12321, 12544, 12769, 12996, 13225, // 13456, 13689, 13924, 14161, 14400, 14641, 14884, 15129, 15376, 15625, 15876, 16129, // 16384, 16641, 16900, 17161, 17424, 17689, 17956, 18225, 18496, 18769, 19044, 19321, // 19600, 19881, 20164, 20449, 20736, 21025, 21316, 21609, 21904, 22201, 22500, 22801, // 23104, 23409, 23716, 24025, 24336, 24649, 24964, 25281, 25600, 25921, 26244, 26569, // 26896, 27225, 27556, 27889, 28224, 28561, 28900, 29241, 29584, 29929, 30276, 30625, // 30976, 31329, 31684, 32041, 32400, 32761, 33124, 33489, 33856, 34225, 34596, 34969, // 35344, 35721, 36100, 36481, 36864, 37249, 37636, 38025, 38416, 38809, 39204, 39601, // 40000, 40401, 40804, 41209, 41616, 42025, 42436, 42849, 43264, 43681, 44100, 44521, // 44944, 45369, 45796, 46225, 46656, 47089, 47524, 47961, 48400, 48841, 49284, 49729, // 50176, 50625, 51076, 51529, 51984, 52441, 52900, 53361, 53824, 54289, 54756, 55225, // 55696, 56169, 56644, 57121, 57600, 58081, 58564, 59049, 59536, 60025, 60516, 61009, // 61504, 62001, 62500, 63001, 63504, 64009, 64516, 65025, // }; // // int CV4J_IMAGE_TYPE_RGB = 0; // int CV4J_IMAGE_TYPE_GRAY = 2; // int CV4J_IMAGE_TYPE_HSV = 4; // int CV4J_IMAGE_TYPE_BINARY = 8; // // ImageProcessor getProcessor(); // // CV4JImage convert2Gray(); // // BufferedImage toBitmap(); // // void setBitmap(BufferedImage bitmap); // // void resetBitmap(); // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageProcessor.java // public interface ImageProcessor { // // /** Returns the width of this image in pixels. */ // int getWidth(); // // /** Returns the height of this image in pixels. */ // int getHeight(); // // /** Returns the channels of this image. */ // int getChannels(); // // void getPixel(int row, int col, byte[] rgb); // // /** get all pixels */ // int[] getPixels(); // // ImageData getImage(); // // /** Returns float array with one channel of image by index*/ // float[] toFloat(int index); // // /** Returns int array with one channel of image by index*/ // int[] toInt(int index); // // /** Returns byte array with one channel of image by index*/ // byte[] toByte(int index); // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Scalar.java // public class Scalar { // public int red; // public int green; // public int blue; // public int alpha; // public Scalar(int red, int green, int blue) { // this.red = red; // this.green = green; // this.blue = blue; // this.alpha = 255; // } // // public static Scalar argb(int alpha, int red, int green, int blue){ // return new Scalar(red, green, blue); // } // // public static Scalar rgb(int red, int green, int blue){ // return new Scalar(red, green, blue); // } // // public Scalar() { // red = 0; // green = 0; // blue = 0; // alpha = 255; // } // // } // Path: desktop/src/main/java/com/cv4j/core/filters/SinCityFilter.java import com.cv4j.core.datamodel.ImageData; import com.cv4j.core.datamodel.ImageProcessor; import com.cv4j.core.datamodel.Scalar; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.filters; public class SinCityFilter extends BaseFilter { private double threshold = 200; // default value
private Scalar mainColor = Scalar.argb(255, 255, 0, 0);
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/filters/SinCityFilter.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageData.java // public interface ImageData { // // int[] SQRT_LUT = new int[] { // 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, // 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, // 1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936, 2025, 2116, 2209, 2304, // 2401, 2500, 2601, 2704, 2809, 2916, 3025, 3136, 3249, 3364, 3481, 3600, 3721, 3844, // 3969, 4096, 4225, 4356, 4489, 4624, 4761, 4900, 5041, 5184, 5329, 5476, 5625, 5776, // 5929, 6084, 6241, 6400, 6561, 6724, 6889, 7056, 7225, 7396, 7569, 7744, 7921, 8100, // 8281, 8464, 8649, 8836, 9025, 9216, 9409, 9604, 9801, 10000, 10201, 10404, 10609, // 10816, 11025, 11236, 11449, 11664, 11881, 12100, 12321, 12544, 12769, 12996, 13225, // 13456, 13689, 13924, 14161, 14400, 14641, 14884, 15129, 15376, 15625, 15876, 16129, // 16384, 16641, 16900, 17161, 17424, 17689, 17956, 18225, 18496, 18769, 19044, 19321, // 19600, 19881, 20164, 20449, 20736, 21025, 21316, 21609, 21904, 22201, 22500, 22801, // 23104, 23409, 23716, 24025, 24336, 24649, 24964, 25281, 25600, 25921, 26244, 26569, // 26896, 27225, 27556, 27889, 28224, 28561, 28900, 29241, 29584, 29929, 30276, 30625, // 30976, 31329, 31684, 32041, 32400, 32761, 33124, 33489, 33856, 34225, 34596, 34969, // 35344, 35721, 36100, 36481, 36864, 37249, 37636, 38025, 38416, 38809, 39204, 39601, // 40000, 40401, 40804, 41209, 41616, 42025, 42436, 42849, 43264, 43681, 44100, 44521, // 44944, 45369, 45796, 46225, 46656, 47089, 47524, 47961, 48400, 48841, 49284, 49729, // 50176, 50625, 51076, 51529, 51984, 52441, 52900, 53361, 53824, 54289, 54756, 55225, // 55696, 56169, 56644, 57121, 57600, 58081, 58564, 59049, 59536, 60025, 60516, 61009, // 61504, 62001, 62500, 63001, 63504, 64009, 64516, 65025, // }; // // int CV4J_IMAGE_TYPE_RGB = 0; // int CV4J_IMAGE_TYPE_GRAY = 2; // int CV4J_IMAGE_TYPE_HSV = 4; // int CV4J_IMAGE_TYPE_BINARY = 8; // // ImageProcessor getProcessor(); // // CV4JImage convert2Gray(); // // BufferedImage toBitmap(); // // void setBitmap(BufferedImage bitmap); // // void resetBitmap(); // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageProcessor.java // public interface ImageProcessor { // // /** Returns the width of this image in pixels. */ // int getWidth(); // // /** Returns the height of this image in pixels. */ // int getHeight(); // // /** Returns the channels of this image. */ // int getChannels(); // // void getPixel(int row, int col, byte[] rgb); // // /** get all pixels */ // int[] getPixels(); // // ImageData getImage(); // // /** Returns float array with one channel of image by index*/ // float[] toFloat(int index); // // /** Returns int array with one channel of image by index*/ // int[] toInt(int index); // // /** Returns byte array with one channel of image by index*/ // byte[] toByte(int index); // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Scalar.java // public class Scalar { // public int red; // public int green; // public int blue; // public int alpha; // public Scalar(int red, int green, int blue) { // this.red = red; // this.green = green; // this.blue = blue; // this.alpha = 255; // } // // public static Scalar argb(int alpha, int red, int green, int blue){ // return new Scalar(red, green, blue); // } // // public static Scalar rgb(int red, int green, int blue){ // return new Scalar(red, green, blue); // } // // public Scalar() { // red = 0; // green = 0; // blue = 0; // alpha = 255; // } // // }
import com.cv4j.core.datamodel.ImageData; import com.cv4j.core.datamodel.ImageProcessor; import com.cv4j.core.datamodel.Scalar;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.filters; public class SinCityFilter extends BaseFilter { private double threshold = 200; // default value private Scalar mainColor = Scalar.argb(255, 255, 0, 0); public void setMainColor(Scalar argb) { this.mainColor = argb; } @Override
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageData.java // public interface ImageData { // // int[] SQRT_LUT = new int[] { // 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, // 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, // 1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936, 2025, 2116, 2209, 2304, // 2401, 2500, 2601, 2704, 2809, 2916, 3025, 3136, 3249, 3364, 3481, 3600, 3721, 3844, // 3969, 4096, 4225, 4356, 4489, 4624, 4761, 4900, 5041, 5184, 5329, 5476, 5625, 5776, // 5929, 6084, 6241, 6400, 6561, 6724, 6889, 7056, 7225, 7396, 7569, 7744, 7921, 8100, // 8281, 8464, 8649, 8836, 9025, 9216, 9409, 9604, 9801, 10000, 10201, 10404, 10609, // 10816, 11025, 11236, 11449, 11664, 11881, 12100, 12321, 12544, 12769, 12996, 13225, // 13456, 13689, 13924, 14161, 14400, 14641, 14884, 15129, 15376, 15625, 15876, 16129, // 16384, 16641, 16900, 17161, 17424, 17689, 17956, 18225, 18496, 18769, 19044, 19321, // 19600, 19881, 20164, 20449, 20736, 21025, 21316, 21609, 21904, 22201, 22500, 22801, // 23104, 23409, 23716, 24025, 24336, 24649, 24964, 25281, 25600, 25921, 26244, 26569, // 26896, 27225, 27556, 27889, 28224, 28561, 28900, 29241, 29584, 29929, 30276, 30625, // 30976, 31329, 31684, 32041, 32400, 32761, 33124, 33489, 33856, 34225, 34596, 34969, // 35344, 35721, 36100, 36481, 36864, 37249, 37636, 38025, 38416, 38809, 39204, 39601, // 40000, 40401, 40804, 41209, 41616, 42025, 42436, 42849, 43264, 43681, 44100, 44521, // 44944, 45369, 45796, 46225, 46656, 47089, 47524, 47961, 48400, 48841, 49284, 49729, // 50176, 50625, 51076, 51529, 51984, 52441, 52900, 53361, 53824, 54289, 54756, 55225, // 55696, 56169, 56644, 57121, 57600, 58081, 58564, 59049, 59536, 60025, 60516, 61009, // 61504, 62001, 62500, 63001, 63504, 64009, 64516, 65025, // }; // // int CV4J_IMAGE_TYPE_RGB = 0; // int CV4J_IMAGE_TYPE_GRAY = 2; // int CV4J_IMAGE_TYPE_HSV = 4; // int CV4J_IMAGE_TYPE_BINARY = 8; // // ImageProcessor getProcessor(); // // CV4JImage convert2Gray(); // // BufferedImage toBitmap(); // // void setBitmap(BufferedImage bitmap); // // void resetBitmap(); // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageProcessor.java // public interface ImageProcessor { // // /** Returns the width of this image in pixels. */ // int getWidth(); // // /** Returns the height of this image in pixels. */ // int getHeight(); // // /** Returns the channels of this image. */ // int getChannels(); // // void getPixel(int row, int col, byte[] rgb); // // /** get all pixels */ // int[] getPixels(); // // ImageData getImage(); // // /** Returns float array with one channel of image by index*/ // float[] toFloat(int index); // // /** Returns int array with one channel of image by index*/ // int[] toInt(int index); // // /** Returns byte array with one channel of image by index*/ // byte[] toByte(int index); // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Scalar.java // public class Scalar { // public int red; // public int green; // public int blue; // public int alpha; // public Scalar(int red, int green, int blue) { // this.red = red; // this.green = green; // this.blue = blue; // this.alpha = 255; // } // // public static Scalar argb(int alpha, int red, int green, int blue){ // return new Scalar(red, green, blue); // } // // public static Scalar rgb(int red, int green, int blue){ // return new Scalar(red, green, blue); // } // // public Scalar() { // red = 0; // green = 0; // blue = 0; // alpha = 255; // } // // } // Path: desktop/src/main/java/com/cv4j/core/filters/SinCityFilter.java import com.cv4j.core.datamodel.ImageData; import com.cv4j.core.datamodel.ImageProcessor; import com.cv4j.core.datamodel.Scalar; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.filters; public class SinCityFilter extends BaseFilter { private double threshold = 200; // default value private Scalar mainColor = Scalar.argb(255, 255, 0, 0); public void setMainColor(Scalar argb) { this.mainColor = argb; } @Override
public ImageProcessor doFilter(ImageProcessor src) {
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/binary/GeoMoments.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/MeasureData.java // public class MeasureData { // // private Point cp; // center x of the contour and center y of the contour // private double angle; // angle of the contour rotated // private double area; // measure the area of contour // private double roundness; // measure the possible circle of the contour // // @Override // public String toString() { // // NumberFormat format = new DecimalFormat("#.00"); // StringBuilder sb = new StringBuilder(); // sb.append("Point:").append(cp.x).append(",").append(cp.y).append("\n") // .append("angle:").append((Math.abs(angle) == 0 ? 0.0 :format.format(angle))).append("\n") // .append("area:").append((int)area).append("\n") // .append("roundness:").append(format.format(roundness)); // return sb.toString(); // } // // public Point getCp() { // return cp; // } // // public void setCp(Point cp) { // this.cp = cp; // } // // public double getAngle() { // return angle; // } // // public void setAngle(double angle) { // this.angle = angle; // } // // public double getArea() { // return area; // } // // public void setArea(double area) { // this.area = area; // } // // public double getRoundness() { // return roundness; // } // // public void setRoundness(double roundness) { // this.roundness = roundness; // } // // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Point.java // public class Point { // // public int x; // public int y; // // public Point(int x, int y) { // this.x = x; // this.y = y; // } // // public Point() { // this.x = 0; // this.y = 0; // } // }
import com.cv4j.core.datamodel.MeasureData; import com.cv4j.core.datamodel.Point; import java.util.List;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.binary; public class GeoMoments { /*** * * @param pixelList - the tagged pixel of this contours * @return some benchmark data for the contour */ public MeasureData calculate(List<PixelNode> pixelList) { MeasureData measures = new MeasureData(); measures.setArea(pixelList.size()); measures.setCp(getCenterPoint(pixelList)); double m11 = centralMoments(pixelList, 1, 1); double m02 = centralMoments(pixelList, 0, 2); double m20 = centralMoments(pixelList, 2, 0); double m112 = m11 * m11; double dd = Math.pow((m20-m02), 2); double sum1 = Math.sqrt(dd + 4*m112); double sum2 = m02 + m20; double a1 = sum2 + sum1; double a2 = sum2 - sum1; double ra = Math.sqrt((2*a1)/Math.abs(pixelList.size())); double rb = Math.sqrt((2*a2)/Math.abs(pixelList.size())); double angle = ((m20 - m02) == 0) ? Math.PI/4.0 : Math.atan((2*m11)/(m20 - m02))/2.0; measures.setAngle(angle); measures.setRoundness(rb == 0? Double.MAX_VALUE : ra/rb); return measures; }
// Path: desktop/src/main/java/com/cv4j/core/datamodel/MeasureData.java // public class MeasureData { // // private Point cp; // center x of the contour and center y of the contour // private double angle; // angle of the contour rotated // private double area; // measure the area of contour // private double roundness; // measure the possible circle of the contour // // @Override // public String toString() { // // NumberFormat format = new DecimalFormat("#.00"); // StringBuilder sb = new StringBuilder(); // sb.append("Point:").append(cp.x).append(",").append(cp.y).append("\n") // .append("angle:").append((Math.abs(angle) == 0 ? 0.0 :format.format(angle))).append("\n") // .append("area:").append((int)area).append("\n") // .append("roundness:").append(format.format(roundness)); // return sb.toString(); // } // // public Point getCp() { // return cp; // } // // public void setCp(Point cp) { // this.cp = cp; // } // // public double getAngle() { // return angle; // } // // public void setAngle(double angle) { // this.angle = angle; // } // // public double getArea() { // return area; // } // // public void setArea(double area) { // this.area = area; // } // // public double getRoundness() { // return roundness; // } // // public void setRoundness(double roundness) { // this.roundness = roundness; // } // // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Point.java // public class Point { // // public int x; // public int y; // // public Point(int x, int y) { // this.x = x; // this.y = y; // } // // public Point() { // this.x = 0; // this.y = 0; // } // } // Path: desktop/src/main/java/com/cv4j/core/binary/GeoMoments.java import com.cv4j.core.datamodel.MeasureData; import com.cv4j.core.datamodel.Point; import java.util.List; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.binary; public class GeoMoments { /*** * * @param pixelList - the tagged pixel of this contours * @return some benchmark data for the contour */ public MeasureData calculate(List<PixelNode> pixelList) { MeasureData measures = new MeasureData(); measures.setArea(pixelList.size()); measures.setCp(getCenterPoint(pixelList)); double m11 = centralMoments(pixelList, 1, 1); double m02 = centralMoments(pixelList, 0, 2); double m20 = centralMoments(pixelList, 2, 0); double m112 = m11 * m11; double dd = Math.pow((m20-m02), 2); double sum1 = Math.sqrt(dd + 4*m112); double sum2 = m02 + m20; double a1 = sum2 + sum1; double a2 = sum2 - sum1; double ra = Math.sqrt((2*a1)/Math.abs(pixelList.size())); double rb = Math.sqrt((2*a2)/Math.abs(pixelList.size())); double angle = ((m20 - m02) == 0) ? Math.PI/4.0 : Math.atan((2*m11)/(m20 - m02))/2.0; measures.setAngle(angle); measures.setRoundness(rb == 0? Double.MAX_VALUE : ra/rb); return measures; }
private Point getCenterPoint(List<PixelNode> pixelList)
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/hist/ProjectionHist.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ByteProcessor.java // public class ByteProcessor implements ImageProcessor { // private int width; // private int height; // // private byte[] GRAY; // private int[] hist; // private ImageData image; // // public ByteProcessor(int width, int height) { // this.width = width; // this.height = height; // this.GRAY = new byte[width*height]; // } // // public ByteProcessor(byte[] data, int width, int height) { // this.width = width; // this.height = height; // this.GRAY = data; // // setup hist // hist = new int[256]; // for(int i=0; i<data.length; i++) { // hist[data[i]&0xff]++; // } // } // // protected void setCallBack(ImageData data) { // this.image = data; // } // // @Override // public int getChannels() { // return 1; // } // // public void getPixel(int row, int col, byte[] rgb) { // int index = row*width + col; // if(rgb != null && rgb.length == 1) { // rgb[0] = GRAY[index]; // } // } // // public byte[] getGray() { // return GRAY; // } // // public void putGray(byte[] gray) { // System.arraycopy(gray, 0, GRAY, 0, gray.length); // } // // public int[] histogram() { // return new int[0]; // } // // public int[] getPixels() { // int size = width * height; // int[] pixels = new int[size]; // for (int i=0; i < size; i++) // pixels[i] = 0xff000000 | ((GRAY[i]&0xff)<<16) | ((GRAY[i]&0xff)<<8) | GRAY[i]&0xff; // return pixels; // } // // @Override // public float[] toFloat(int index) { // float[] data = new float[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public int[] toInt(int index) { // int[] data = new int[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public byte[] toByte(int index) { // return GRAY; // } // // @Override // public int getWidth() { // return width; // } // // @Override // public int getHeight() { // return height; // } // // @Override // public ImageData getImage() { // // return image; // } // // }
import com.cv4j.core.datamodel.ByteProcessor;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.hist; public class ProjectionHist { public final static int X_DIRECTION = 1; public final static int Y_DIRECTION = 2; /*** * * @param src - binary image * @param direction - X or Y direction * @param bins - number of bins * @param output */
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ByteProcessor.java // public class ByteProcessor implements ImageProcessor { // private int width; // private int height; // // private byte[] GRAY; // private int[] hist; // private ImageData image; // // public ByteProcessor(int width, int height) { // this.width = width; // this.height = height; // this.GRAY = new byte[width*height]; // } // // public ByteProcessor(byte[] data, int width, int height) { // this.width = width; // this.height = height; // this.GRAY = data; // // setup hist // hist = new int[256]; // for(int i=0; i<data.length; i++) { // hist[data[i]&0xff]++; // } // } // // protected void setCallBack(ImageData data) { // this.image = data; // } // // @Override // public int getChannels() { // return 1; // } // // public void getPixel(int row, int col, byte[] rgb) { // int index = row*width + col; // if(rgb != null && rgb.length == 1) { // rgb[0] = GRAY[index]; // } // } // // public byte[] getGray() { // return GRAY; // } // // public void putGray(byte[] gray) { // System.arraycopy(gray, 0, GRAY, 0, gray.length); // } // // public int[] histogram() { // return new int[0]; // } // // public int[] getPixels() { // int size = width * height; // int[] pixels = new int[size]; // for (int i=0; i < size; i++) // pixels[i] = 0xff000000 | ((GRAY[i]&0xff)<<16) | ((GRAY[i]&0xff)<<8) | GRAY[i]&0xff; // return pixels; // } // // @Override // public float[] toFloat(int index) { // float[] data = new float[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public int[] toInt(int index) { // int[] data = new int[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public byte[] toByte(int index) { // return GRAY; // } // // @Override // public int getWidth() { // return width; // } // // @Override // public int getHeight() { // return height; // } // // @Override // public ImageData getImage() { // // return image; // } // // } // Path: desktop/src/main/java/com/cv4j/core/hist/ProjectionHist.java import com.cv4j.core.datamodel.ByteProcessor; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.hist; public class ProjectionHist { public final static int X_DIRECTION = 1; public final static int Y_DIRECTION = 2; /*** * * @param src - binary image * @param direction - X or Y direction * @param bins - number of bins * @param output */
public void projection(ByteProcessor src, int direction, int bins, double[] output) {
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/binary/CourtEdge.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ByteProcessor.java // public class ByteProcessor implements ImageProcessor { // private int width; // private int height; // // private byte[] GRAY; // private int[] hist; // private ImageData image; // // public ByteProcessor(int width, int height) { // this.width = width; // this.height = height; // this.GRAY = new byte[width*height]; // } // // public ByteProcessor(byte[] data, int width, int height) { // this.width = width; // this.height = height; // this.GRAY = data; // // setup hist // hist = new int[256]; // for(int i=0; i<data.length; i++) { // hist[data[i]&0xff]++; // } // } // // protected void setCallBack(ImageData data) { // this.image = data; // } // // @Override // public int getChannels() { // return 1; // } // // public void getPixel(int row, int col, byte[] rgb) { // int index = row*width + col; // if(rgb != null && rgb.length == 1) { // rgb[0] = GRAY[index]; // } // } // // public byte[] getGray() { // return GRAY; // } // // public void putGray(byte[] gray) { // System.arraycopy(gray, 0, GRAY, 0, gray.length); // } // // public int[] histogram() { // return new int[0]; // } // // public int[] getPixels() { // int size = width * height; // int[] pixels = new int[size]; // for (int i=0; i < size; i++) // pixels[i] = 0xff000000 | ((GRAY[i]&0xff)<<16) | ((GRAY[i]&0xff)<<8) | GRAY[i]&0xff; // return pixels; // } // // @Override // public float[] toFloat(int index) { // float[] data = new float[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public int[] toInt(int index) { // int[] data = new int[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public byte[] toByte(int index) { // return GRAY; // } // // @Override // public int getWidth() { // return width; // } // // @Override // public int getHeight() { // return height; // } // // @Override // public ImageData getImage() { // // return image; // } // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Size.java // public class Size { // public int cols; // public int rows; // // public Size(int num) { // this.cols = num; // this.rows = num; // } // // public Size(int width, int height) { // this.cols = width; // this.rows = height; // } // }
import com.cv4j.core.datamodel.ByteProcessor; import com.cv4j.core.datamodel.Size;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.binary; public class CourtEdge { public void process(ByteProcessor binary) { int width = binary.getWidth(); int height = binary.getHeight(); byte[] input1 = new byte[width*height]; System.arraycopy(binary.getGray(), 0, input1, 0, input1.length); Erode erode = new Erode();
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ByteProcessor.java // public class ByteProcessor implements ImageProcessor { // private int width; // private int height; // // private byte[] GRAY; // private int[] hist; // private ImageData image; // // public ByteProcessor(int width, int height) { // this.width = width; // this.height = height; // this.GRAY = new byte[width*height]; // } // // public ByteProcessor(byte[] data, int width, int height) { // this.width = width; // this.height = height; // this.GRAY = data; // // setup hist // hist = new int[256]; // for(int i=0; i<data.length; i++) { // hist[data[i]&0xff]++; // } // } // // protected void setCallBack(ImageData data) { // this.image = data; // } // // @Override // public int getChannels() { // return 1; // } // // public void getPixel(int row, int col, byte[] rgb) { // int index = row*width + col; // if(rgb != null && rgb.length == 1) { // rgb[0] = GRAY[index]; // } // } // // public byte[] getGray() { // return GRAY; // } // // public void putGray(byte[] gray) { // System.arraycopy(gray, 0, GRAY, 0, gray.length); // } // // public int[] histogram() { // return new int[0]; // } // // public int[] getPixels() { // int size = width * height; // int[] pixels = new int[size]; // for (int i=0; i < size; i++) // pixels[i] = 0xff000000 | ((GRAY[i]&0xff)<<16) | ((GRAY[i]&0xff)<<8) | GRAY[i]&0xff; // return pixels; // } // // @Override // public float[] toFloat(int index) { // float[] data = new float[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public int[] toInt(int index) { // int[] data = new int[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public byte[] toByte(int index) { // return GRAY; // } // // @Override // public int getWidth() { // return width; // } // // @Override // public int getHeight() { // return height; // } // // @Override // public ImageData getImage() { // // return image; // } // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Size.java // public class Size { // public int cols; // public int rows; // // public Size(int num) { // this.cols = num; // this.rows = num; // } // // public Size(int width, int height) { // this.cols = width; // this.rows = height; // } // } // Path: desktop/src/main/java/com/cv4j/core/binary/CourtEdge.java import com.cv4j.core.datamodel.ByteProcessor; import com.cv4j.core.datamodel.Size; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.binary; public class CourtEdge { public void process(ByteProcessor binary) { int width = binary.getWidth(); int height = binary.getHeight(); byte[] input1 = new byte[width*height]; System.arraycopy(binary.getGray(), 0, input1, 0, input1.length); Erode erode = new Erode();
erode.process(binary, new Size(3, 3));
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/image/util/Tools.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/Point.java // public class Point { // // public int x; // public int y; // // public Point(int x, int y) { // this.x = x; // this.y = y; // } // // public Point() { // this.x = 0; // this.y = 0; // } // }
import java.awt.image.BufferedImage; import java.io.BufferedReader; import java.io.StringReader; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; import java.util.Vector; import com.cv4j.core.datamodel.Point;
double[] minAndMax = new double[2]; minAndMax[0] = min; minAndMax[1] = max; return minAndMax; } public static double[] getMinMax(final float[] a) { double min = Double.MAX_VALUE; double max = -Double.MAX_VALUE; double value; for (float anA : a) { value = anA; if (value < min) min = value; if (value > max) max = value; } double[] minAndMax = new double[2]; minAndMax[0] = min; minAndMax[1] = max; return minAndMax; } /** * 获取图中最大与最小值的位置信息, 0 - 最小值位置, 1 - 最大值位置 * @param a * @param width * @param height * @return */
// Path: desktop/src/main/java/com/cv4j/core/datamodel/Point.java // public class Point { // // public int x; // public int y; // // public Point(int x, int y) { // this.x = x; // this.y = y; // } // // public Point() { // this.x = 0; // this.y = 0; // } // } // Path: desktop/src/main/java/com/cv4j/image/util/Tools.java import java.awt.image.BufferedImage; import java.io.BufferedReader; import java.io.StringReader; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; import java.util.Vector; import com.cv4j.core.datamodel.Point; double[] minAndMax = new double[2]; minAndMax[0] = min; minAndMax[1] = max; return minAndMax; } public static double[] getMinMax(final float[] a) { double min = Double.MAX_VALUE; double max = -Double.MAX_VALUE; double value; for (float anA : a) { value = anA; if (value < min) min = value; if (value > max) max = value; } double[] minAndMax = new double[2]; minAndMax[0] = min; minAndMax[1] = max; return minAndMax; } /** * 获取图中最大与最小值的位置信息, 0 - 最小值位置, 1 - 最大值位置 * @param a * @param width * @param height * @return */
public static Point[] getMinMaxLoc(final float[] a, int width, int height) {
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/binary/ConnectedAreaLabel.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ByteProcessor.java // public class ByteProcessor implements ImageProcessor { // private int width; // private int height; // // private byte[] GRAY; // private int[] hist; // private ImageData image; // // public ByteProcessor(int width, int height) { // this.width = width; // this.height = height; // this.GRAY = new byte[width*height]; // } // // public ByteProcessor(byte[] data, int width, int height) { // this.width = width; // this.height = height; // this.GRAY = data; // // setup hist // hist = new int[256]; // for(int i=0; i<data.length; i++) { // hist[data[i]&0xff]++; // } // } // // protected void setCallBack(ImageData data) { // this.image = data; // } // // @Override // public int getChannels() { // return 1; // } // // public void getPixel(int row, int col, byte[] rgb) { // int index = row*width + col; // if(rgb != null && rgb.length == 1) { // rgb[0] = GRAY[index]; // } // } // // public byte[] getGray() { // return GRAY; // } // // public void putGray(byte[] gray) { // System.arraycopy(gray, 0, GRAY, 0, gray.length); // } // // public int[] histogram() { // return new int[0]; // } // // public int[] getPixels() { // int size = width * height; // int[] pixels = new int[size]; // for (int i=0; i < size; i++) // pixels[i] = 0xff000000 | ((GRAY[i]&0xff)<<16) | ((GRAY[i]&0xff)<<8) | GRAY[i]&0xff; // return pixels; // } // // @Override // public float[] toFloat(int index) { // float[] data = new float[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public int[] toInt(int index) { // int[] data = new int[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public byte[] toByte(int index) { // return GRAY; // } // // @Override // public int getWidth() { // return width; // } // // @Override // public int getHeight() { // return height; // } // // @Override // public ImageData getImage() { // // return image; // } // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Rect.java // public class Rect { // // public int x; // public int y; // public int width; // public int height; // public int labelIdx; // just use it for ccl // // public Point tl() { // return new Point(x, y); // } // // public Point br() { // return new Point(x+width, y+height); // } // }
import com.cv4j.core.datamodel.ByteProcessor; import com.cv4j.core.datamodel.Rect; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map;
/* * Copyright (c) 2017 - present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.binary; /** * It is very easy way to filter some minimum noise block by number of pixel; * default settings: <p> * - mNumOfPixels = 100 <br> * - mFilterNoise = false */ public class ConnectedAreaLabel { /** * default number of pixels */ private static final int DEFAULT_PIXEL_NUM = 100; private static final boolean DEFAULT_FILTER_NOISE = false; private int mNumOfPixels; private boolean mFilterNoise; public ConnectedAreaLabel() { mNumOfPixels = DEFAULT_PIXEL_NUM; mFilterNoise = DEFAULT_FILTER_NOISE; } /** * init object with number of pixels and whether filter noise * @param numOfPixels the number of pixels, default value is 100 * @param filterNoise whether to filter the noise of picture */ public ConnectedAreaLabel(int numOfPixels, Boolean filterNoise) { mNumOfPixels = numOfPixels; mFilterNoise = filterNoise; } public void setNoiseArea(int numOfPixels) { this.mNumOfPixels = numOfPixels; } public void setFilterNoise(boolean filterNoise) { this.mFilterNoise = filterNoise; } /** * @param binary - binary image data * @param labelMask - label for each pixel point * @return int - total labels of image */
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ByteProcessor.java // public class ByteProcessor implements ImageProcessor { // private int width; // private int height; // // private byte[] GRAY; // private int[] hist; // private ImageData image; // // public ByteProcessor(int width, int height) { // this.width = width; // this.height = height; // this.GRAY = new byte[width*height]; // } // // public ByteProcessor(byte[] data, int width, int height) { // this.width = width; // this.height = height; // this.GRAY = data; // // setup hist // hist = new int[256]; // for(int i=0; i<data.length; i++) { // hist[data[i]&0xff]++; // } // } // // protected void setCallBack(ImageData data) { // this.image = data; // } // // @Override // public int getChannels() { // return 1; // } // // public void getPixel(int row, int col, byte[] rgb) { // int index = row*width + col; // if(rgb != null && rgb.length == 1) { // rgb[0] = GRAY[index]; // } // } // // public byte[] getGray() { // return GRAY; // } // // public void putGray(byte[] gray) { // System.arraycopy(gray, 0, GRAY, 0, gray.length); // } // // public int[] histogram() { // return new int[0]; // } // // public int[] getPixels() { // int size = width * height; // int[] pixels = new int[size]; // for (int i=0; i < size; i++) // pixels[i] = 0xff000000 | ((GRAY[i]&0xff)<<16) | ((GRAY[i]&0xff)<<8) | GRAY[i]&0xff; // return pixels; // } // // @Override // public float[] toFloat(int index) { // float[] data = new float[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public int[] toInt(int index) { // int[] data = new int[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public byte[] toByte(int index) { // return GRAY; // } // // @Override // public int getWidth() { // return width; // } // // @Override // public int getHeight() { // return height; // } // // @Override // public ImageData getImage() { // // return image; // } // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Rect.java // public class Rect { // // public int x; // public int y; // public int width; // public int height; // public int labelIdx; // just use it for ccl // // public Point tl() { // return new Point(x, y); // } // // public Point br() { // return new Point(x+width, y+height); // } // } // Path: desktop/src/main/java/com/cv4j/core/binary/ConnectedAreaLabel.java import com.cv4j.core.datamodel.ByteProcessor; import com.cv4j.core.datamodel.Rect; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; /* * Copyright (c) 2017 - present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.binary; /** * It is very easy way to filter some minimum noise block by number of pixel; * default settings: <p> * - mNumOfPixels = 100 <br> * - mFilterNoise = false */ public class ConnectedAreaLabel { /** * default number of pixels */ private static final int DEFAULT_PIXEL_NUM = 100; private static final boolean DEFAULT_FILTER_NOISE = false; private int mNumOfPixels; private boolean mFilterNoise; public ConnectedAreaLabel() { mNumOfPixels = DEFAULT_PIXEL_NUM; mFilterNoise = DEFAULT_FILTER_NOISE; } /** * init object with number of pixels and whether filter noise * @param numOfPixels the number of pixels, default value is 100 * @param filterNoise whether to filter the noise of picture */ public ConnectedAreaLabel(int numOfPixels, Boolean filterNoise) { mNumOfPixels = numOfPixels; mFilterNoise = filterNoise; } public void setNoiseArea(int numOfPixels) { this.mNumOfPixels = numOfPixels; } public void setFilterNoise(boolean filterNoise) { this.mFilterNoise = filterNoise; } /** * @param binary - binary image data * @param labelMask - label for each pixel point * @return int - total labels of image */
public int process(ByteProcessor binary, int[] labelMask) {
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/binary/ConnectedAreaLabel.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ByteProcessor.java // public class ByteProcessor implements ImageProcessor { // private int width; // private int height; // // private byte[] GRAY; // private int[] hist; // private ImageData image; // // public ByteProcessor(int width, int height) { // this.width = width; // this.height = height; // this.GRAY = new byte[width*height]; // } // // public ByteProcessor(byte[] data, int width, int height) { // this.width = width; // this.height = height; // this.GRAY = data; // // setup hist // hist = new int[256]; // for(int i=0; i<data.length; i++) { // hist[data[i]&0xff]++; // } // } // // protected void setCallBack(ImageData data) { // this.image = data; // } // // @Override // public int getChannels() { // return 1; // } // // public void getPixel(int row, int col, byte[] rgb) { // int index = row*width + col; // if(rgb != null && rgb.length == 1) { // rgb[0] = GRAY[index]; // } // } // // public byte[] getGray() { // return GRAY; // } // // public void putGray(byte[] gray) { // System.arraycopy(gray, 0, GRAY, 0, gray.length); // } // // public int[] histogram() { // return new int[0]; // } // // public int[] getPixels() { // int size = width * height; // int[] pixels = new int[size]; // for (int i=0; i < size; i++) // pixels[i] = 0xff000000 | ((GRAY[i]&0xff)<<16) | ((GRAY[i]&0xff)<<8) | GRAY[i]&0xff; // return pixels; // } // // @Override // public float[] toFloat(int index) { // float[] data = new float[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public int[] toInt(int index) { // int[] data = new int[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public byte[] toByte(int index) { // return GRAY; // } // // @Override // public int getWidth() { // return width; // } // // @Override // public int getHeight() { // return height; // } // // @Override // public ImageData getImage() { // // return image; // } // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Rect.java // public class Rect { // // public int x; // public int y; // public int width; // public int height; // public int labelIdx; // just use it for ccl // // public Point tl() { // return new Point(x, y); // } // // public Point br() { // return new Point(x+width, y+height); // } // }
import com.cv4j.core.datamodel.ByteProcessor; import com.cv4j.core.datamodel.Rect; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map;
/* * Copyright (c) 2017 - present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.binary; /** * It is very easy way to filter some minimum noise block by number of pixel; * default settings: <p> * - mNumOfPixels = 100 <br> * - mFilterNoise = false */ public class ConnectedAreaLabel { /** * default number of pixels */ private static final int DEFAULT_PIXEL_NUM = 100; private static final boolean DEFAULT_FILTER_NOISE = false; private int mNumOfPixels; private boolean mFilterNoise; public ConnectedAreaLabel() { mNumOfPixels = DEFAULT_PIXEL_NUM; mFilterNoise = DEFAULT_FILTER_NOISE; } /** * init object with number of pixels and whether filter noise * @param numOfPixels the number of pixels, default value is 100 * @param filterNoise whether to filter the noise of picture */ public ConnectedAreaLabel(int numOfPixels, Boolean filterNoise) { mNumOfPixels = numOfPixels; mFilterNoise = filterNoise; } public void setNoiseArea(int numOfPixels) { this.mNumOfPixels = numOfPixels; } public void setFilterNoise(boolean filterNoise) { this.mFilterNoise = filterNoise; } /** * @param binary - binary image data * @param labelMask - label for each pixel point * @return int - total labels of image */ public int process(ByteProcessor binary, int[] labelMask) { return this._process(binary, labelMask, null, false); } /** * process noise block with labels * @param binary - binary image data * @param labelMask - label for each pixel point * @param rectangles - rectangles area list want to return * @param drawBounding - whether draw bounding * @return int - total labels of image */
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ByteProcessor.java // public class ByteProcessor implements ImageProcessor { // private int width; // private int height; // // private byte[] GRAY; // private int[] hist; // private ImageData image; // // public ByteProcessor(int width, int height) { // this.width = width; // this.height = height; // this.GRAY = new byte[width*height]; // } // // public ByteProcessor(byte[] data, int width, int height) { // this.width = width; // this.height = height; // this.GRAY = data; // // setup hist // hist = new int[256]; // for(int i=0; i<data.length; i++) { // hist[data[i]&0xff]++; // } // } // // protected void setCallBack(ImageData data) { // this.image = data; // } // // @Override // public int getChannels() { // return 1; // } // // public void getPixel(int row, int col, byte[] rgb) { // int index = row*width + col; // if(rgb != null && rgb.length == 1) { // rgb[0] = GRAY[index]; // } // } // // public byte[] getGray() { // return GRAY; // } // // public void putGray(byte[] gray) { // System.arraycopy(gray, 0, GRAY, 0, gray.length); // } // // public int[] histogram() { // return new int[0]; // } // // public int[] getPixels() { // int size = width * height; // int[] pixels = new int[size]; // for (int i=0; i < size; i++) // pixels[i] = 0xff000000 | ((GRAY[i]&0xff)<<16) | ((GRAY[i]&0xff)<<8) | GRAY[i]&0xff; // return pixels; // } // // @Override // public float[] toFloat(int index) { // float[] data = new float[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public int[] toInt(int index) { // int[] data = new int[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public byte[] toByte(int index) { // return GRAY; // } // // @Override // public int getWidth() { // return width; // } // // @Override // public int getHeight() { // return height; // } // // @Override // public ImageData getImage() { // // return image; // } // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/Rect.java // public class Rect { // // public int x; // public int y; // public int width; // public int height; // public int labelIdx; // just use it for ccl // // public Point tl() { // return new Point(x, y); // } // // public Point br() { // return new Point(x+width, y+height); // } // } // Path: desktop/src/main/java/com/cv4j/core/binary/ConnectedAreaLabel.java import com.cv4j.core.datamodel.ByteProcessor; import com.cv4j.core.datamodel.Rect; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; /* * Copyright (c) 2017 - present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.binary; /** * It is very easy way to filter some minimum noise block by number of pixel; * default settings: <p> * - mNumOfPixels = 100 <br> * - mFilterNoise = false */ public class ConnectedAreaLabel { /** * default number of pixels */ private static final int DEFAULT_PIXEL_NUM = 100; private static final boolean DEFAULT_FILTER_NOISE = false; private int mNumOfPixels; private boolean mFilterNoise; public ConnectedAreaLabel() { mNumOfPixels = DEFAULT_PIXEL_NUM; mFilterNoise = DEFAULT_FILTER_NOISE; } /** * init object with number of pixels and whether filter noise * @param numOfPixels the number of pixels, default value is 100 * @param filterNoise whether to filter the noise of picture */ public ConnectedAreaLabel(int numOfPixels, Boolean filterNoise) { mNumOfPixels = numOfPixels; mFilterNoise = filterNoise; } public void setNoiseArea(int numOfPixels) { this.mNumOfPixels = numOfPixels; } public void setFilterNoise(boolean filterNoise) { this.mFilterNoise = filterNoise; } /** * @param binary - binary image data * @param labelMask - label for each pixel point * @return int - total labels of image */ public int process(ByteProcessor binary, int[] labelMask) { return this._process(binary, labelMask, null, false); } /** * process noise block with labels * @param binary - binary image data * @param labelMask - label for each pixel point * @param rectangles - rectangles area list want to return * @param drawBounding - whether draw bounding * @return int - total labels of image */
public int process(ByteProcessor binary, int[] labelMask, List<Rect> rectangles,
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/pixels/ClusterCenter.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/Scalar.java // public class Scalar { // public int red; // public int green; // public int blue; // public int alpha; // public Scalar(int red, int green, int blue) { // this.red = red; // this.green = green; // this.blue = blue; // this.alpha = 255; // } // // public static Scalar argb(int alpha, int red, int green, int blue){ // return new Scalar(red, green, blue); // } // // public static Scalar rgb(int red, int green, int blue){ // return new Scalar(red, green, blue); // } // // public Scalar() { // red = 0; // green = 0; // blue = 0; // alpha = 255; // } // // }
import com.cv4j.core.datamodel.Scalar;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.pixels; public class ClusterCenter { protected double x; protected double y;
// Path: desktop/src/main/java/com/cv4j/core/datamodel/Scalar.java // public class Scalar { // public int red; // public int green; // public int blue; // public int alpha; // public Scalar(int red, int green, int blue) { // this.red = red; // this.green = green; // this.blue = blue; // this.alpha = 255; // } // // public static Scalar argb(int alpha, int red, int green, int blue){ // return new Scalar(red, green, blue); // } // // public static Scalar rgb(int red, int green, int blue){ // return new Scalar(red, green, blue); // } // // public Scalar() { // red = 0; // green = 0; // blue = 0; // alpha = 255; // } // // } // Path: desktop/src/main/java/com/cv4j/core/pixels/ClusterCenter.java import com.cv4j.core.datamodel.Scalar; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.pixels; public class ClusterCenter { protected double x; protected double y;
protected Scalar color;
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/binary/ChainCode.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ByteProcessor.java // public class ByteProcessor implements ImageProcessor { // private int width; // private int height; // // private byte[] GRAY; // private int[] hist; // private ImageData image; // // public ByteProcessor(int width, int height) { // this.width = width; // this.height = height; // this.GRAY = new byte[width*height]; // } // // public ByteProcessor(byte[] data, int width, int height) { // this.width = width; // this.height = height; // this.GRAY = data; // // setup hist // hist = new int[256]; // for(int i=0; i<data.length; i++) { // hist[data[i]&0xff]++; // } // } // // protected void setCallBack(ImageData data) { // this.image = data; // } // // @Override // public int getChannels() { // return 1; // } // // public void getPixel(int row, int col, byte[] rgb) { // int index = row*width + col; // if(rgb != null && rgb.length == 1) { // rgb[0] = GRAY[index]; // } // } // // public byte[] getGray() { // return GRAY; // } // // public void putGray(byte[] gray) { // System.arraycopy(gray, 0, GRAY, 0, gray.length); // } // // public int[] histogram() { // return new int[0]; // } // // public int[] getPixels() { // int size = width * height; // int[] pixels = new int[size]; // for (int i=0; i < size; i++) // pixels[i] = 0xff000000 | ((GRAY[i]&0xff)<<16) | ((GRAY[i]&0xff)<<8) | GRAY[i]&0xff; // return pixels; // } // // @Override // public float[] toFloat(int index) { // float[] data = new float[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public int[] toInt(int index) { // int[] data = new int[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public byte[] toByte(int index) { // return GRAY; // } // // @Override // public int getWidth() { // return width; // } // // @Override // public int getHeight() { // return height; // } // // @Override // public ImageData getImage() { // // return image; // } // // } // // Path: desktop/src/main/java/com/cv4j/exception/CV4JException.java // public class CV4JException extends RuntimeException { // // private static final long serialVersionUID = -2565764903880816387L; // // public CV4JException(String message) { // super(message); // } // // public CV4JException(Throwable throwable) { // super(throwable); // } // // public CV4JException(String message, Throwable throwable) { // super(message, throwable); // } // }
import com.cv4j.core.datamodel.ByteProcessor; import com.cv4j.exception.CV4JException; import java.util.Arrays;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.binary; public class ChainCode extends CourtEdge { public void process(ByteProcessor binary, int[] codeMap) { super.process(binary); int width = binary.getWidth(); int height = binary.getHeight(); if(codeMap.length != (width*height)) {
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ByteProcessor.java // public class ByteProcessor implements ImageProcessor { // private int width; // private int height; // // private byte[] GRAY; // private int[] hist; // private ImageData image; // // public ByteProcessor(int width, int height) { // this.width = width; // this.height = height; // this.GRAY = new byte[width*height]; // } // // public ByteProcessor(byte[] data, int width, int height) { // this.width = width; // this.height = height; // this.GRAY = data; // // setup hist // hist = new int[256]; // for(int i=0; i<data.length; i++) { // hist[data[i]&0xff]++; // } // } // // protected void setCallBack(ImageData data) { // this.image = data; // } // // @Override // public int getChannels() { // return 1; // } // // public void getPixel(int row, int col, byte[] rgb) { // int index = row*width + col; // if(rgb != null && rgb.length == 1) { // rgb[0] = GRAY[index]; // } // } // // public byte[] getGray() { // return GRAY; // } // // public void putGray(byte[] gray) { // System.arraycopy(gray, 0, GRAY, 0, gray.length); // } // // public int[] histogram() { // return new int[0]; // } // // public int[] getPixels() { // int size = width * height; // int[] pixels = new int[size]; // for (int i=0; i < size; i++) // pixels[i] = 0xff000000 | ((GRAY[i]&0xff)<<16) | ((GRAY[i]&0xff)<<8) | GRAY[i]&0xff; // return pixels; // } // // @Override // public float[] toFloat(int index) { // float[] data = new float[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public int[] toInt(int index) { // int[] data = new int[GRAY.length]; // for(int i=0; i<data.length; i++) // data[i] = GRAY[i]&0xff; // return data; // } // // @Override // public byte[] toByte(int index) { // return GRAY; // } // // @Override // public int getWidth() { // return width; // } // // @Override // public int getHeight() { // return height; // } // // @Override // public ImageData getImage() { // // return image; // } // // } // // Path: desktop/src/main/java/com/cv4j/exception/CV4JException.java // public class CV4JException extends RuntimeException { // // private static final long serialVersionUID = -2565764903880816387L; // // public CV4JException(String message) { // super(message); // } // // public CV4JException(Throwable throwable) { // super(throwable); // } // // public CV4JException(String message, Throwable throwable) { // super(message, throwable); // } // } // Path: desktop/src/main/java/com/cv4j/core/binary/ChainCode.java import com.cv4j.core.datamodel.ByteProcessor; import com.cv4j.exception.CV4JException; import java.util.Arrays; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.binary; public class ChainCode extends CourtEdge { public void process(ByteProcessor binary, int[] codeMap) { super.process(binary); int width = binary.getWidth(); int height = binary.getHeight(); if(codeMap.length != (width*height)) {
throw new CV4JException("chain code map length assert failure");
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/filters/WhiteImageFilter.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageProcessor.java // public interface ImageProcessor { // // /** Returns the width of this image in pixels. */ // int getWidth(); // // /** Returns the height of this image in pixels. */ // int getHeight(); // // /** Returns the channels of this image. */ // int getChannels(); // // void getPixel(int row, int col, byte[] rgb); // // /** get all pixels */ // int[] getPixels(); // // ImageData getImage(); // // /** Returns float array with one channel of image by index*/ // float[] toFloat(int index); // // /** Returns int array with one channel of image by index*/ // int[] toInt(int index); // // /** Returns byte array with one channel of image by index*/ // byte[] toByte(int index); // // }
import com.cv4j.core.datamodel.ImageProcessor;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.filters; public class WhiteImageFilter extends BaseFilter { private double beta; public WhiteImageFilter() { this.beta = 1.1; } public double getBeta() { return beta; } public void setBeta(double beta) { this.beta = beta; } @Override
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageProcessor.java // public interface ImageProcessor { // // /** Returns the width of this image in pixels. */ // int getWidth(); // // /** Returns the height of this image in pixels. */ // int getHeight(); // // /** Returns the channels of this image. */ // int getChannels(); // // void getPixel(int row, int col, byte[] rgb); // // /** get all pixels */ // int[] getPixels(); // // ImageData getImage(); // // /** Returns float array with one channel of image by index*/ // float[] toFloat(int index); // // /** Returns int array with one channel of image by index*/ // int[] toInt(int index); // // /** Returns byte array with one channel of image by index*/ // byte[] toByte(int index); // // } // Path: desktop/src/main/java/com/cv4j/core/filters/WhiteImageFilter.java import com.cv4j.core.datamodel.ImageProcessor; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.filters; public class WhiteImageFilter extends BaseFilter { private double beta; public WhiteImageFilter() { this.beta = 1.1; } public double getBeta() { return beta; } public void setBeta(double beta) { this.beta = beta; } @Override
public ImageProcessor doFilter(ImageProcessor src) {
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageProcessor.java // public interface ImageProcessor { // // /** Returns the width of this image in pixels. */ // int getWidth(); // // /** Returns the height of this image in pixels. */ // int getHeight(); // // /** Returns the channels of this image. */ // int getChannels(); // // void getPixel(int row, int col, byte[] rgb); // // /** get all pixels */ // int[] getPixels(); // // ImageData getImage(); // // /** Returns float array with one channel of image by index*/ // float[] toFloat(int index); // // /** Returns int array with one channel of image by index*/ // int[] toInt(int index); // // /** Returns byte array with one channel of image by index*/ // byte[] toByte(int index); // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java // public class LUT { // // public static int[][] getColorFilterLUT(int style) { // // switch(style) { // case AUTUMN_STYLE: // return AutumnLUT.AUTUMN_LUT; // // case BONE_STYLE: // return BoneLUT.BONE_LUT; // // case COOL_STYLE: // return CoolLUT.COOL_LUT; // // case HOT_STYLE: // return HotLUT.HOT_LUT; // // case HSV_STYLE: // return HsvLUT.HSV_LUT; // // case JET_STYLE: // return JetLUT.JET_LUT; // // case OCEAN_STYLE: // return OceanLUT.OCEAN_LUT; // // case PINK_STYLE: // return PinkLUT.PINK_LUT; // // case RAINBOW_STYLE: // return RainbowLUT.RAINBOW_LUT; // // case SPRING_STYLE: // return SpringLUT.SPRING_LUT; // // case SUMMER_STYLE: // return SummerLUT.SUMMER_LUT; // // case WINTER_STYLE: // return WinterLUT.WINTER_LUT; // // default: // return AutumnLUT.AUTUMN_LUT; // } // } // }
import com.cv4j.core.datamodel.ImageProcessor; import com.cv4j.core.datamodel.lut.LUT;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.filters; public class ColorFilter extends BaseFilter { public static final int AUTUMN_STYLE = 0; public static final int BONE_STYLE = 1; public static final int COOL_STYLE = 2; public static final int HOT_STYLE = 3; public static final int HSV_STYLE = 4; public static final int JET_STYLE = 5; public static final int OCEAN_STYLE = 6; public static final int PINK_STYLE = 7; public static final int RAINBOW_STYLE = 8; public static final int SPRING_STYLE = 9; public static final int SUMMER_STYLE = 10; public static final int WINTER_STYLE = 11; private int style; public ColorFilter() { style = AUTUMN_STYLE; } public void setStyle(int style) { this.style = style; } @Override
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageProcessor.java // public interface ImageProcessor { // // /** Returns the width of this image in pixels. */ // int getWidth(); // // /** Returns the height of this image in pixels. */ // int getHeight(); // // /** Returns the channels of this image. */ // int getChannels(); // // void getPixel(int row, int col, byte[] rgb); // // /** get all pixels */ // int[] getPixels(); // // ImageData getImage(); // // /** Returns float array with one channel of image by index*/ // float[] toFloat(int index); // // /** Returns int array with one channel of image by index*/ // int[] toInt(int index); // // /** Returns byte array with one channel of image by index*/ // byte[] toByte(int index); // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java // public class LUT { // // public static int[][] getColorFilterLUT(int style) { // // switch(style) { // case AUTUMN_STYLE: // return AutumnLUT.AUTUMN_LUT; // // case BONE_STYLE: // return BoneLUT.BONE_LUT; // // case COOL_STYLE: // return CoolLUT.COOL_LUT; // // case HOT_STYLE: // return HotLUT.HOT_LUT; // // case HSV_STYLE: // return HsvLUT.HSV_LUT; // // case JET_STYLE: // return JetLUT.JET_LUT; // // case OCEAN_STYLE: // return OceanLUT.OCEAN_LUT; // // case PINK_STYLE: // return PinkLUT.PINK_LUT; // // case RAINBOW_STYLE: // return RainbowLUT.RAINBOW_LUT; // // case SPRING_STYLE: // return SpringLUT.SPRING_LUT; // // case SUMMER_STYLE: // return SummerLUT.SUMMER_LUT; // // case WINTER_STYLE: // return WinterLUT.WINTER_LUT; // // default: // return AutumnLUT.AUTUMN_LUT; // } // } // } // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java import com.cv4j.core.datamodel.ImageProcessor; import com.cv4j.core.datamodel.lut.LUT; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.filters; public class ColorFilter extends BaseFilter { public static final int AUTUMN_STYLE = 0; public static final int BONE_STYLE = 1; public static final int COOL_STYLE = 2; public static final int HOT_STYLE = 3; public static final int HSV_STYLE = 4; public static final int JET_STYLE = 5; public static final int OCEAN_STYLE = 6; public static final int PINK_STYLE = 7; public static final int RAINBOW_STYLE = 8; public static final int SPRING_STYLE = 9; public static final int SUMMER_STYLE = 10; public static final int WINTER_STYLE = 11; private int style; public ColorFilter() { style = AUTUMN_STYLE; } public void setStyle(int style) { this.style = style; } @Override
public ImageProcessor doFilter(ImageProcessor src) {
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageProcessor.java // public interface ImageProcessor { // // /** Returns the width of this image in pixels. */ // int getWidth(); // // /** Returns the height of this image in pixels. */ // int getHeight(); // // /** Returns the channels of this image. */ // int getChannels(); // // void getPixel(int row, int col, byte[] rgb); // // /** get all pixels */ // int[] getPixels(); // // ImageData getImage(); // // /** Returns float array with one channel of image by index*/ // float[] toFloat(int index); // // /** Returns int array with one channel of image by index*/ // int[] toInt(int index); // // /** Returns byte array with one channel of image by index*/ // byte[] toByte(int index); // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java // public class LUT { // // public static int[][] getColorFilterLUT(int style) { // // switch(style) { // case AUTUMN_STYLE: // return AutumnLUT.AUTUMN_LUT; // // case BONE_STYLE: // return BoneLUT.BONE_LUT; // // case COOL_STYLE: // return CoolLUT.COOL_LUT; // // case HOT_STYLE: // return HotLUT.HOT_LUT; // // case HSV_STYLE: // return HsvLUT.HSV_LUT; // // case JET_STYLE: // return JetLUT.JET_LUT; // // case OCEAN_STYLE: // return OceanLUT.OCEAN_LUT; // // case PINK_STYLE: // return PinkLUT.PINK_LUT; // // case RAINBOW_STYLE: // return RainbowLUT.RAINBOW_LUT; // // case SPRING_STYLE: // return SpringLUT.SPRING_LUT; // // case SUMMER_STYLE: // return SummerLUT.SUMMER_LUT; // // case WINTER_STYLE: // return WinterLUT.WINTER_LUT; // // default: // return AutumnLUT.AUTUMN_LUT; // } // } // }
import com.cv4j.core.datamodel.ImageProcessor; import com.cv4j.core.datamodel.lut.LUT;
public ColorFilter() { style = AUTUMN_STYLE; } public void setStyle(int style) { this.style = style; } @Override public ImageProcessor doFilter(ImageProcessor src) { int tr=0; int tg=0; int tb=0; int[][] lut = getStyleLUT(style); int size = R.length; for(int i=0; i<size; i++) { tr = R[i] & 0xff; tg = G[i] & 0xff; tb = B[i] & 0xff; R[i] = (byte)lut[tr][0]; G[i] = (byte)lut[tg][1]; B[i] = (byte)lut[tb][2]; } return src; } private int[][] getStyleLUT(int style) {
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageProcessor.java // public interface ImageProcessor { // // /** Returns the width of this image in pixels. */ // int getWidth(); // // /** Returns the height of this image in pixels. */ // int getHeight(); // // /** Returns the channels of this image. */ // int getChannels(); // // void getPixel(int row, int col, byte[] rgb); // // /** get all pixels */ // int[] getPixels(); // // ImageData getImage(); // // /** Returns float array with one channel of image by index*/ // float[] toFloat(int index); // // /** Returns int array with one channel of image by index*/ // int[] toInt(int index); // // /** Returns byte array with one channel of image by index*/ // byte[] toByte(int index); // // } // // Path: desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java // public class LUT { // // public static int[][] getColorFilterLUT(int style) { // // switch(style) { // case AUTUMN_STYLE: // return AutumnLUT.AUTUMN_LUT; // // case BONE_STYLE: // return BoneLUT.BONE_LUT; // // case COOL_STYLE: // return CoolLUT.COOL_LUT; // // case HOT_STYLE: // return HotLUT.HOT_LUT; // // case HSV_STYLE: // return HsvLUT.HSV_LUT; // // case JET_STYLE: // return JetLUT.JET_LUT; // // case OCEAN_STYLE: // return OceanLUT.OCEAN_LUT; // // case PINK_STYLE: // return PinkLUT.PINK_LUT; // // case RAINBOW_STYLE: // return RainbowLUT.RAINBOW_LUT; // // case SPRING_STYLE: // return SpringLUT.SPRING_LUT; // // case SUMMER_STYLE: // return SummerLUT.SUMMER_LUT; // // case WINTER_STYLE: // return WinterLUT.WINTER_LUT; // // default: // return AutumnLUT.AUTUMN_LUT; // } // } // } // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java import com.cv4j.core.datamodel.ImageProcessor; import com.cv4j.core.datamodel.lut.LUT; public ColorFilter() { style = AUTUMN_STYLE; } public void setStyle(int style) { this.style = style; } @Override public ImageProcessor doFilter(ImageProcessor src) { int tr=0; int tg=0; int tb=0; int[][] lut = getStyleLUT(style); int size = R.length; for(int i=0; i<size; i++) { tr = R[i] & 0xff; tg = G[i] & 0xff; tb = B[i] & 0xff; R[i] = (byte)lut[tr][0]; G[i] = (byte)lut[tg][1]; B[i] = (byte)lut[tb][2]; } return src; } private int[][] getStyleLUT(int style) {
return LUT.getColorFilterLUT(style);
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/spatial/conv/SAPNoiseFilter.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageProcessor.java // public interface ImageProcessor { // // /** Returns the width of this image in pixels. */ // int getWidth(); // // /** Returns the height of this image in pixels. */ // int getHeight(); // // /** Returns the channels of this image. */ // int getChannels(); // // void getPixel(int row, int col, byte[] rgb); // // /** get all pixels */ // int[] getPixels(); // // ImageData getImage(); // // /** Returns float array with one channel of image by index*/ // float[] toFloat(int index); // // /** Returns int array with one channel of image by index*/ // int[] toInt(int index); // // /** Returns byte array with one channel of image by index*/ // byte[] toByte(int index); // // } // // Path: desktop/src/main/java/com/cv4j/core/filters/BaseFilter.java // public abstract class BaseFilter implements CommonFilter { // // protected int width; // protected int height; // protected byte[] R; // protected byte[] G; // protected byte[] B; // // @Override // public ImageProcessor filter(ImageProcessor src) { // // if (src == null) return null; // // if (!(src instanceof ColorProcessor)) return src; // // width = src.getWidth(); // height = src.getHeight(); // R = ((ColorProcessor)src).getRed(); // G = ((ColorProcessor)src).getGreen(); // B = ((ColorProcessor)src).getBlue(); // // return doFilter(src); // } // // public abstract ImageProcessor doFilter(ImageProcessor src); // }
import com.cv4j.core.datamodel.ImageProcessor; import com.cv4j.core.filters.BaseFilter; import java.util.Random;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.spatial.conv; public class SAPNoiseFilter extends BaseFilter { private float precent; public SAPNoiseFilter() { precent = 0.01f; } public float getPrecent() { return precent; } public void setPrecent(float precent) { this.precent = precent; } @Override
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageProcessor.java // public interface ImageProcessor { // // /** Returns the width of this image in pixels. */ // int getWidth(); // // /** Returns the height of this image in pixels. */ // int getHeight(); // // /** Returns the channels of this image. */ // int getChannels(); // // void getPixel(int row, int col, byte[] rgb); // // /** get all pixels */ // int[] getPixels(); // // ImageData getImage(); // // /** Returns float array with one channel of image by index*/ // float[] toFloat(int index); // // /** Returns int array with one channel of image by index*/ // int[] toInt(int index); // // /** Returns byte array with one channel of image by index*/ // byte[] toByte(int index); // // } // // Path: desktop/src/main/java/com/cv4j/core/filters/BaseFilter.java // public abstract class BaseFilter implements CommonFilter { // // protected int width; // protected int height; // protected byte[] R; // protected byte[] G; // protected byte[] B; // // @Override // public ImageProcessor filter(ImageProcessor src) { // // if (src == null) return null; // // if (!(src instanceof ColorProcessor)) return src; // // width = src.getWidth(); // height = src.getHeight(); // R = ((ColorProcessor)src).getRed(); // G = ((ColorProcessor)src).getGreen(); // B = ((ColorProcessor)src).getBlue(); // // return doFilter(src); // } // // public abstract ImageProcessor doFilter(ImageProcessor src); // } // Path: desktop/src/main/java/com/cv4j/core/spatial/conv/SAPNoiseFilter.java import com.cv4j.core.datamodel.ImageProcessor; import com.cv4j.core.filters.BaseFilter; import java.util.Random; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.spatial.conv; public class SAPNoiseFilter extends BaseFilter { private float precent; public SAPNoiseFilter() { precent = 0.01f; } public float getPrecent() { return precent; } public void setPrecent(float precent) { this.precent = precent; } @Override
public ImageProcessor doFilter(ImageProcessor src) {
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/filters/SpotlightFilter.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageProcessor.java // public interface ImageProcessor { // // /** Returns the width of this image in pixels. */ // int getWidth(); // // /** Returns the height of this image in pixels. */ // int getHeight(); // // /** Returns the channels of this image. */ // int getChannels(); // // void getPixel(int row, int col, byte[] rgb); // // /** get all pixels */ // int[] getPixels(); // // ImageData getImage(); // // /** Returns float array with one channel of image by index*/ // float[] toFloat(int index); // // /** Returns int array with one channel of image by index*/ // int[] toInt(int index); // // /** Returns byte array with one channel of image by index*/ // byte[] toByte(int index); // // }
import com.cv4j.core.datamodel.ImageProcessor;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.filters; public class SpotlightFilter extends BaseFilter { // attenuation coefficient, default is 1 means line decrease... private int factor; public SpotlightFilter() { factor = 1; } public void setFactor(int coefficient) { this.factor = coefficient; } @Override
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageProcessor.java // public interface ImageProcessor { // // /** Returns the width of this image in pixels. */ // int getWidth(); // // /** Returns the height of this image in pixels. */ // int getHeight(); // // /** Returns the channels of this image. */ // int getChannels(); // // void getPixel(int row, int col, byte[] rgb); // // /** get all pixels */ // int[] getPixels(); // // ImageData getImage(); // // /** Returns float array with one channel of image by index*/ // float[] toFloat(int index); // // /** Returns int array with one channel of image by index*/ // int[] toInt(int index); // // /** Returns byte array with one channel of image by index*/ // byte[] toByte(int index); // // } // Path: desktop/src/main/java/com/cv4j/core/filters/SpotlightFilter.java import com.cv4j.core.datamodel.ImageProcessor; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.filters; public class SpotlightFilter extends BaseFilter { // attenuation coefficient, default is 1 means line decrease... private int factor; public SpotlightFilter() { factor = 1; } public void setFactor(int coefficient) { this.factor = coefficient; } @Override
public ImageProcessor doFilter(ImageProcessor src){
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/filters/ExposureFilter.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageProcessor.java // public interface ImageProcessor { // // /** Returns the width of this image in pixels. */ // int getWidth(); // // /** Returns the height of this image in pixels. */ // int getHeight(); // // /** Returns the channels of this image. */ // int getChannels(); // // void getPixel(int row, int col, byte[] rgb); // // /** get all pixels */ // int[] getPixels(); // // ImageData getImage(); // // /** Returns float array with one channel of image by index*/ // float[] toFloat(int index); // // /** Returns int array with one channel of image by index*/ // int[] toInt(int index); // // /** Returns byte array with one channel of image by index*/ // byte[] toByte(int index); // // }
import com.cv4j.core.datamodel.ImageProcessor;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.filters; public class ExposureFilter extends BaseFilter { @Override
// Path: desktop/src/main/java/com/cv4j/core/datamodel/ImageProcessor.java // public interface ImageProcessor { // // /** Returns the width of this image in pixels. */ // int getWidth(); // // /** Returns the height of this image in pixels. */ // int getHeight(); // // /** Returns the channels of this image. */ // int getChannels(); // // void getPixel(int row, int col, byte[] rgb); // // /** get all pixels */ // int[] getPixels(); // // ImageData getImage(); // // /** Returns float array with one channel of image by index*/ // float[] toFloat(int index); // // /** Returns int array with one channel of image by index*/ // int[] toInt(int index); // // /** Returns byte array with one channel of image by index*/ // byte[] toByte(int index); // // } // Path: desktop/src/main/java/com/cv4j/core/filters/ExposureFilter.java import com.cv4j.core.datamodel.ImageProcessor; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.filters; public class ExposureFilter extends BaseFilter { @Override
public ImageProcessor doFilter(ImageProcessor src) {
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11;
import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) {
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11; // Path: desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) {
case AUTUMN_STYLE:
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11;
import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT;
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11; // Path: desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT;
case BONE_STYLE:
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11;
import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT; case BONE_STYLE: return BoneLUT.BONE_LUT;
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11; // Path: desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT; case BONE_STYLE: return BoneLUT.BONE_LUT;
case COOL_STYLE:
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11;
import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT; case BONE_STYLE: return BoneLUT.BONE_LUT; case COOL_STYLE: return CoolLUT.COOL_LUT;
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11; // Path: desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT; case BONE_STYLE: return BoneLUT.BONE_LUT; case COOL_STYLE: return CoolLUT.COOL_LUT;
case HOT_STYLE:
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11;
import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT; case BONE_STYLE: return BoneLUT.BONE_LUT; case COOL_STYLE: return CoolLUT.COOL_LUT; case HOT_STYLE: return HotLUT.HOT_LUT;
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11; // Path: desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT; case BONE_STYLE: return BoneLUT.BONE_LUT; case COOL_STYLE: return CoolLUT.COOL_LUT; case HOT_STYLE: return HotLUT.HOT_LUT;
case HSV_STYLE:
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11;
import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT; case BONE_STYLE: return BoneLUT.BONE_LUT; case COOL_STYLE: return CoolLUT.COOL_LUT; case HOT_STYLE: return HotLUT.HOT_LUT; case HSV_STYLE: return HsvLUT.HSV_LUT;
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11; // Path: desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT; case BONE_STYLE: return BoneLUT.BONE_LUT; case COOL_STYLE: return CoolLUT.COOL_LUT; case HOT_STYLE: return HotLUT.HOT_LUT; case HSV_STYLE: return HsvLUT.HSV_LUT;
case JET_STYLE:
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11;
import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT; case BONE_STYLE: return BoneLUT.BONE_LUT; case COOL_STYLE: return CoolLUT.COOL_LUT; case HOT_STYLE: return HotLUT.HOT_LUT; case HSV_STYLE: return HsvLUT.HSV_LUT; case JET_STYLE: return JetLUT.JET_LUT;
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11; // Path: desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT; case BONE_STYLE: return BoneLUT.BONE_LUT; case COOL_STYLE: return CoolLUT.COOL_LUT; case HOT_STYLE: return HotLUT.HOT_LUT; case HSV_STYLE: return HsvLUT.HSV_LUT; case JET_STYLE: return JetLUT.JET_LUT;
case OCEAN_STYLE:
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11;
import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT; case BONE_STYLE: return BoneLUT.BONE_LUT; case COOL_STYLE: return CoolLUT.COOL_LUT; case HOT_STYLE: return HotLUT.HOT_LUT; case HSV_STYLE: return HsvLUT.HSV_LUT; case JET_STYLE: return JetLUT.JET_LUT; case OCEAN_STYLE: return OceanLUT.OCEAN_LUT;
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11; // Path: desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT; case BONE_STYLE: return BoneLUT.BONE_LUT; case COOL_STYLE: return CoolLUT.COOL_LUT; case HOT_STYLE: return HotLUT.HOT_LUT; case HSV_STYLE: return HsvLUT.HSV_LUT; case JET_STYLE: return JetLUT.JET_LUT; case OCEAN_STYLE: return OceanLUT.OCEAN_LUT;
case PINK_STYLE:
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11;
import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT; case BONE_STYLE: return BoneLUT.BONE_LUT; case COOL_STYLE: return CoolLUT.COOL_LUT; case HOT_STYLE: return HotLUT.HOT_LUT; case HSV_STYLE: return HsvLUT.HSV_LUT; case JET_STYLE: return JetLUT.JET_LUT; case OCEAN_STYLE: return OceanLUT.OCEAN_LUT; case PINK_STYLE: return PinkLUT.PINK_LUT;
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11; // Path: desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT; case BONE_STYLE: return BoneLUT.BONE_LUT; case COOL_STYLE: return CoolLUT.COOL_LUT; case HOT_STYLE: return HotLUT.HOT_LUT; case HSV_STYLE: return HsvLUT.HSV_LUT; case JET_STYLE: return JetLUT.JET_LUT; case OCEAN_STYLE: return OceanLUT.OCEAN_LUT; case PINK_STYLE: return PinkLUT.PINK_LUT;
case RAINBOW_STYLE:
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11;
import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT; case BONE_STYLE: return BoneLUT.BONE_LUT; case COOL_STYLE: return CoolLUT.COOL_LUT; case HOT_STYLE: return HotLUT.HOT_LUT; case HSV_STYLE: return HsvLUT.HSV_LUT; case JET_STYLE: return JetLUT.JET_LUT; case OCEAN_STYLE: return OceanLUT.OCEAN_LUT; case PINK_STYLE: return PinkLUT.PINK_LUT; case RAINBOW_STYLE: return RainbowLUT.RAINBOW_LUT;
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11; // Path: desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT; case BONE_STYLE: return BoneLUT.BONE_LUT; case COOL_STYLE: return CoolLUT.COOL_LUT; case HOT_STYLE: return HotLUT.HOT_LUT; case HSV_STYLE: return HsvLUT.HSV_LUT; case JET_STYLE: return JetLUT.JET_LUT; case OCEAN_STYLE: return OceanLUT.OCEAN_LUT; case PINK_STYLE: return PinkLUT.PINK_LUT; case RAINBOW_STYLE: return RainbowLUT.RAINBOW_LUT;
case SPRING_STYLE:
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11;
import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT; case BONE_STYLE: return BoneLUT.BONE_LUT; case COOL_STYLE: return CoolLUT.COOL_LUT; case HOT_STYLE: return HotLUT.HOT_LUT; case HSV_STYLE: return HsvLUT.HSV_LUT; case JET_STYLE: return JetLUT.JET_LUT; case OCEAN_STYLE: return OceanLUT.OCEAN_LUT; case PINK_STYLE: return PinkLUT.PINK_LUT; case RAINBOW_STYLE: return RainbowLUT.RAINBOW_LUT; case SPRING_STYLE: return SpringLUT.SPRING_LUT;
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11; // Path: desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT; case BONE_STYLE: return BoneLUT.BONE_LUT; case COOL_STYLE: return CoolLUT.COOL_LUT; case HOT_STYLE: return HotLUT.HOT_LUT; case HSV_STYLE: return HsvLUT.HSV_LUT; case JET_STYLE: return JetLUT.JET_LUT; case OCEAN_STYLE: return OceanLUT.OCEAN_LUT; case PINK_STYLE: return PinkLUT.PINK_LUT; case RAINBOW_STYLE: return RainbowLUT.RAINBOW_LUT; case SPRING_STYLE: return SpringLUT.SPRING_LUT;
case SUMMER_STYLE:
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11;
import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT; case BONE_STYLE: return BoneLUT.BONE_LUT; case COOL_STYLE: return CoolLUT.COOL_LUT; case HOT_STYLE: return HotLUT.HOT_LUT; case HSV_STYLE: return HsvLUT.HSV_LUT; case JET_STYLE: return JetLUT.JET_LUT; case OCEAN_STYLE: return OceanLUT.OCEAN_LUT; case PINK_STYLE: return PinkLUT.PINK_LUT; case RAINBOW_STYLE: return RainbowLUT.RAINBOW_LUT; case SPRING_STYLE: return SpringLUT.SPRING_LUT; case SUMMER_STYLE: return SummerLUT.SUMMER_LUT;
// Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int AUTUMN_STYLE = 0; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int BONE_STYLE = 1; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int COOL_STYLE = 2; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HOT_STYLE = 3; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int HSV_STYLE = 4; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int JET_STYLE = 5; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int OCEAN_STYLE = 6; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int PINK_STYLE = 7; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int RAINBOW_STYLE = 8; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SPRING_STYLE = 9; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int SUMMER_STYLE = 10; // // Path: desktop/src/main/java/com/cv4j/core/filters/ColorFilter.java // public static final int WINTER_STYLE = 11; // Path: desktop/src/main/java/com/cv4j/core/datamodel/lut/LUT.java import static com.cv4j.core.filters.ColorFilter.AUTUMN_STYLE; import static com.cv4j.core.filters.ColorFilter.BONE_STYLE; import static com.cv4j.core.filters.ColorFilter.COOL_STYLE; import static com.cv4j.core.filters.ColorFilter.HOT_STYLE; import static com.cv4j.core.filters.ColorFilter.HSV_STYLE; import static com.cv4j.core.filters.ColorFilter.JET_STYLE; import static com.cv4j.core.filters.ColorFilter.OCEAN_STYLE; import static com.cv4j.core.filters.ColorFilter.PINK_STYLE; import static com.cv4j.core.filters.ColorFilter.RAINBOW_STYLE; import static com.cv4j.core.filters.ColorFilter.SPRING_STYLE; import static com.cv4j.core.filters.ColorFilter.SUMMER_STYLE; import static com.cv4j.core.filters.ColorFilter.WINTER_STYLE; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.datamodel.lut; public class LUT { public static int[][] getColorFilterLUT(int style) { switch(style) { case AUTUMN_STYLE: return AutumnLUT.AUTUMN_LUT; case BONE_STYLE: return BoneLUT.BONE_LUT; case COOL_STYLE: return CoolLUT.COOL_LUT; case HOT_STYLE: return HotLUT.HOT_LUT; case HSV_STYLE: return HsvLUT.HSV_LUT; case JET_STYLE: return JetLUT.JET_LUT; case OCEAN_STYLE: return OceanLUT.OCEAN_LUT; case PINK_STYLE: return PinkLUT.PINK_LUT; case RAINBOW_STYLE: return RainbowLUT.RAINBOW_LUT; case SPRING_STYLE: return SpringLUT.SPRING_LUT; case SUMMER_STYLE: return SummerLUT.SUMMER_LUT;
case WINTER_STYLE:
imageprocessor/cv4j-desktop
desktop/src/main/java/com/cv4j/core/pixels/ClusterPoint.java
// Path: desktop/src/main/java/com/cv4j/core/datamodel/Scalar.java // public class Scalar { // public int red; // public int green; // public int blue; // public int alpha; // public Scalar(int red, int green, int blue) { // this.red = red; // this.green = green; // this.blue = blue; // this.alpha = 255; // } // // public static Scalar argb(int alpha, int red, int green, int blue){ // return new Scalar(red, green, blue); // } // // public static Scalar rgb(int red, int green, int blue){ // return new Scalar(red, green, blue); // } // // public Scalar() { // red = 0; // green = 0; // blue = 0; // alpha = 255; // } // // }
import com.cv4j.core.datamodel.Scalar;
/* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.pixels; public class ClusterPoint { protected double x; protected double y;
// Path: desktop/src/main/java/com/cv4j/core/datamodel/Scalar.java // public class Scalar { // public int red; // public int green; // public int blue; // public int alpha; // public Scalar(int red, int green, int blue) { // this.red = red; // this.green = green; // this.blue = blue; // this.alpha = 255; // } // // public static Scalar argb(int alpha, int red, int green, int blue){ // return new Scalar(red, green, blue); // } // // public static Scalar rgb(int red, int green, int blue){ // return new Scalar(red, green, blue); // } // // public Scalar() { // red = 0; // green = 0; // blue = 0; // alpha = 255; // } // // } // Path: desktop/src/main/java/com/cv4j/core/pixels/ClusterPoint.java import com.cv4j.core.datamodel.Scalar; /* * Copyright (c) 2017-present, CV4J Contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cv4j.core.pixels; public class ClusterPoint { protected double x; protected double y;
protected Scalar pixelColor;
JuliaSoft/BeeDeeDee
src/com/juliasoft/beedeedee/factories/ResizingAndGarbageCollectedUniqueTable.java
// Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface GarbageCollectionListener { // // /** // * Called when a garbage collection operation is about to start. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStart(int num, int size, int free, long totalTime); // // /** // * Called when a garbage collection operation has been performed. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param time the time required for the garbage collection // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStop(int num, int size, int free, long time, long totalTime); // } // // Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface ResizeListener { // // /** // * Called when a resize operation is about to start. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param totalTime the cumulative resize time up to now // */ // // public void onStart(int num, int oldSize, int newSize, long totalTime); // // /** // * Called when a resize operation has been performed. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param time the time required for the resize // * @param totalTime the cumulative resize time up to now // */ // // public void onStop(int num, int oldSize, int newSize, long time, long totalTime); // }
import java.util.concurrent.ExecutionException; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.ReentrantLock; import java.util.stream.IntStream; import com.juliasoft.beedeedee.factories.Factory.GarbageCollectionListener; import com.juliasoft.beedeedee.factories.Factory.ResizeListener;
/* Copyright 2014 Julia s.r.l. This file is part of BeeDeeDee. BeeDeeDee 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 3 of the License, or (at your option) any later version. BeeDeeDee 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 BeeDeeDee. If not, see <http://www.gnu.org/licenses/>. */ package com.juliasoft.beedeedee.factories; public class ResizingAndGarbageCollectedUniqueTable extends SimpleUniqueTable { private final ForkJoinPool pool = new ForkJoinPool(Runtime.getRuntime().availableProcessors()); /** * The maximal number of nodes that is added at each resize operation. */ private volatile int maxIncrease = 1000000; /** * The factor by which the table of nodes gets increased at each resize. */ private volatile double increaseFactor = 2; /** * The cache ratio for the operator caches. When the node table grows, * operator caches will also grow to maintain the ratio. */ private volatile double cacheRatio = 0.5; /** * The minimum percentage of nodes to be reclaimed after a garbage collection. * If this percentage is not reclaimed, the node table will be grown. * The range for this value is 0..1. */ private volatile double minFreeNodes = 0.2; private final Factory factory; private long totalResizeTime; private final AtomicInteger hashCodeAuxCounter = new AtomicInteger(); /** * The number of resize operations performed so far. */ private int numOfResizes; private long totalGCTime; /** * The number of garbage collections performed so far. */ private int numOfGCs; /** * The garbage collection listener, if any. */
// Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface GarbageCollectionListener { // // /** // * Called when a garbage collection operation is about to start. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStart(int num, int size, int free, long totalTime); // // /** // * Called when a garbage collection operation has been performed. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param time the time required for the garbage collection // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStop(int num, int size, int free, long time, long totalTime); // } // // Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface ResizeListener { // // /** // * Called when a resize operation is about to start. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param totalTime the cumulative resize time up to now // */ // // public void onStart(int num, int oldSize, int newSize, long totalTime); // // /** // * Called when a resize operation has been performed. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param time the time required for the resize // * @param totalTime the cumulative resize time up to now // */ // // public void onStop(int num, int oldSize, int newSize, long time, long totalTime); // } // Path: src/com/juliasoft/beedeedee/factories/ResizingAndGarbageCollectedUniqueTable.java import java.util.concurrent.ExecutionException; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.ReentrantLock; import java.util.stream.IntStream; import com.juliasoft.beedeedee.factories.Factory.GarbageCollectionListener; import com.juliasoft.beedeedee.factories.Factory.ResizeListener; /* Copyright 2014 Julia s.r.l. This file is part of BeeDeeDee. BeeDeeDee 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 3 of the License, or (at your option) any later version. BeeDeeDee 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 BeeDeeDee. If not, see <http://www.gnu.org/licenses/>. */ package com.juliasoft.beedeedee.factories; public class ResizingAndGarbageCollectedUniqueTable extends SimpleUniqueTable { private final ForkJoinPool pool = new ForkJoinPool(Runtime.getRuntime().availableProcessors()); /** * The maximal number of nodes that is added at each resize operation. */ private volatile int maxIncrease = 1000000; /** * The factor by which the table of nodes gets increased at each resize. */ private volatile double increaseFactor = 2; /** * The cache ratio for the operator caches. When the node table grows, * operator caches will also grow to maintain the ratio. */ private volatile double cacheRatio = 0.5; /** * The minimum percentage of nodes to be reclaimed after a garbage collection. * If this percentage is not reclaimed, the node table will be grown. * The range for this value is 0..1. */ private volatile double minFreeNodes = 0.2; private final Factory factory; private long totalResizeTime; private final AtomicInteger hashCodeAuxCounter = new AtomicInteger(); /** * The number of resize operations performed so far. */ private int numOfResizes; private long totalGCTime; /** * The number of garbage collections performed so far. */ private int numOfGCs; /** * The garbage collection listener, if any. */
private GarbageCollectionListener gcListener;
JuliaSoft/BeeDeeDee
src/com/juliasoft/beedeedee/factories/ResizingAndGarbageCollectedUniqueTable.java
// Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface GarbageCollectionListener { // // /** // * Called when a garbage collection operation is about to start. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStart(int num, int size, int free, long totalTime); // // /** // * Called when a garbage collection operation has been performed. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param time the time required for the garbage collection // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStop(int num, int size, int free, long time, long totalTime); // } // // Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface ResizeListener { // // /** // * Called when a resize operation is about to start. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param totalTime the cumulative resize time up to now // */ // // public void onStart(int num, int oldSize, int newSize, long totalTime); // // /** // * Called when a resize operation has been performed. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param time the time required for the resize // * @param totalTime the cumulative resize time up to now // */ // // public void onStop(int num, int oldSize, int newSize, long time, long totalTime); // }
import java.util.concurrent.ExecutionException; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.ReentrantLock; import java.util.stream.IntStream; import com.juliasoft.beedeedee.factories.Factory.GarbageCollectionListener; import com.juliasoft.beedeedee.factories.Factory.ResizeListener;
/* Copyright 2014 Julia s.r.l. This file is part of BeeDeeDee. BeeDeeDee 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 3 of the License, or (at your option) any later version. BeeDeeDee 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 BeeDeeDee. If not, see <http://www.gnu.org/licenses/>. */ package com.juliasoft.beedeedee.factories; public class ResizingAndGarbageCollectedUniqueTable extends SimpleUniqueTable { private final ForkJoinPool pool = new ForkJoinPool(Runtime.getRuntime().availableProcessors()); /** * The maximal number of nodes that is added at each resize operation. */ private volatile int maxIncrease = 1000000; /** * The factor by which the table of nodes gets increased at each resize. */ private volatile double increaseFactor = 2; /** * The cache ratio for the operator caches. When the node table grows, * operator caches will also grow to maintain the ratio. */ private volatile double cacheRatio = 0.5; /** * The minimum percentage of nodes to be reclaimed after a garbage collection. * If this percentage is not reclaimed, the node table will be grown. * The range for this value is 0..1. */ private volatile double minFreeNodes = 0.2; private final Factory factory; private long totalResizeTime; private final AtomicInteger hashCodeAuxCounter = new AtomicInteger(); /** * The number of resize operations performed so far. */ private int numOfResizes; private long totalGCTime; /** * The number of garbage collections performed so far. */ private int numOfGCs; /** * The garbage collection listener, if any. */ private GarbageCollectionListener gcListener; /** * The resize collection listener, if any. */
// Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface GarbageCollectionListener { // // /** // * Called when a garbage collection operation is about to start. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStart(int num, int size, int free, long totalTime); // // /** // * Called when a garbage collection operation has been performed. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param time the time required for the garbage collection // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStop(int num, int size, int free, long time, long totalTime); // } // // Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface ResizeListener { // // /** // * Called when a resize operation is about to start. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param totalTime the cumulative resize time up to now // */ // // public void onStart(int num, int oldSize, int newSize, long totalTime); // // /** // * Called when a resize operation has been performed. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param time the time required for the resize // * @param totalTime the cumulative resize time up to now // */ // // public void onStop(int num, int oldSize, int newSize, long time, long totalTime); // } // Path: src/com/juliasoft/beedeedee/factories/ResizingAndGarbageCollectedUniqueTable.java import java.util.concurrent.ExecutionException; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.ReentrantLock; import java.util.stream.IntStream; import com.juliasoft.beedeedee.factories.Factory.GarbageCollectionListener; import com.juliasoft.beedeedee.factories.Factory.ResizeListener; /* Copyright 2014 Julia s.r.l. This file is part of BeeDeeDee. BeeDeeDee 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 3 of the License, or (at your option) any later version. BeeDeeDee 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 BeeDeeDee. If not, see <http://www.gnu.org/licenses/>. */ package com.juliasoft.beedeedee.factories; public class ResizingAndGarbageCollectedUniqueTable extends SimpleUniqueTable { private final ForkJoinPool pool = new ForkJoinPool(Runtime.getRuntime().availableProcessors()); /** * The maximal number of nodes that is added at each resize operation. */ private volatile int maxIncrease = 1000000; /** * The factor by which the table of nodes gets increased at each resize. */ private volatile double increaseFactor = 2; /** * The cache ratio for the operator caches. When the node table grows, * operator caches will also grow to maintain the ratio. */ private volatile double cacheRatio = 0.5; /** * The minimum percentage of nodes to be reclaimed after a garbage collection. * If this percentage is not reclaimed, the node table will be grown. * The range for this value is 0..1. */ private volatile double minFreeNodes = 0.2; private final Factory factory; private long totalResizeTime; private final AtomicInteger hashCodeAuxCounter = new AtomicInteger(); /** * The number of resize operations performed so far. */ private int numOfResizes; private long totalGCTime; /** * The number of garbage collections performed so far. */ private int numOfGCs; /** * The garbage collection listener, if any. */ private GarbageCollectionListener gcListener; /** * The resize collection listener, if any. */
private ResizeListener resizeListener;
JuliaSoft/BeeDeeDee
src/com/juliasoft/beedeedee/factories/EquivalenceRelation.java
// Path: src/com/juliasoft/beedeedee/bdd/Assignment.java // public interface Assignment { // // /** // * Determines if the given BDD variable holds in this assignment. // * // * @param var the variable // * @return true if and only if {@code var} holds in this assignment // * @throws IndexOutOfBoundsException if the variable does not belong to this // * assignment. This means that the variable can be assigned any // * value // */ // public boolean holds(BDD var) throws IndexOutOfBoundsException; // // /** // * Determines if the given BDD variable holds in this assignment. // * // * @param i the variable index // * @return true if and only if the variable indexed by {@code i} holds in // * this assignment // * @throws IndexOutOfBoundsException if the variable does not belong to this // * assignment. This means that the variable can be assigned any // * value // */ // public boolean holds(int i); // // /** // * @return a <em>minterm</em> representation of the assignment // */ // public BDD toBDD(); // // /** // * Adds a mapping for the given variable. // * // * @param var the variable index // * @param value the value to assign to the variable in this assignment // */ // public void put(int var, boolean value); // // }
import java.util.ArrayList; import java.util.Arrays; import java.util.BitSet; import java.util.Collection; import java.util.Comparator; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import com.juliasoft.beedeedee.bdd.Assignment;
Arrays.equals(((EquivalenceRelation) obj).equivalenceClasses, equivalenceClasses); } @Override public int hashCode() { return hashCode; } private int hashCodeAux() { return Arrays.hashCode(equivalenceClasses); } @Override public String toString() { return Arrays.toString(equivalenceClasses); } public int maxVar() { int max = 0; for (BitSet eqClass: equivalenceClasses) max = Math.max(max, eqClass.length() - 1); return max; } /** * Updates the given assignment with information on equivalent variables. * * @param a the assignment to update */
// Path: src/com/juliasoft/beedeedee/bdd/Assignment.java // public interface Assignment { // // /** // * Determines if the given BDD variable holds in this assignment. // * // * @param var the variable // * @return true if and only if {@code var} holds in this assignment // * @throws IndexOutOfBoundsException if the variable does not belong to this // * assignment. This means that the variable can be assigned any // * value // */ // public boolean holds(BDD var) throws IndexOutOfBoundsException; // // /** // * Determines if the given BDD variable holds in this assignment. // * // * @param i the variable index // * @return true if and only if the variable indexed by {@code i} holds in // * this assignment // * @throws IndexOutOfBoundsException if the variable does not belong to this // * assignment. This means that the variable can be assigned any // * value // */ // public boolean holds(int i); // // /** // * @return a <em>minterm</em> representation of the assignment // */ // public BDD toBDD(); // // /** // * Adds a mapping for the given variable. // * // * @param var the variable index // * @param value the value to assign to the variable in this assignment // */ // public void put(int var, boolean value); // // } // Path: src/com/juliasoft/beedeedee/factories/EquivalenceRelation.java import java.util.ArrayList; import java.util.Arrays; import java.util.BitSet; import java.util.Collection; import java.util.Comparator; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import com.juliasoft.beedeedee.bdd.Assignment; Arrays.equals(((EquivalenceRelation) obj).equivalenceClasses, equivalenceClasses); } @Override public int hashCode() { return hashCode; } private int hashCodeAux() { return Arrays.hashCode(equivalenceClasses); } @Override public String toString() { return Arrays.toString(equivalenceClasses); } public int maxVar() { int max = 0; for (BitSet eqClass: equivalenceClasses) max = Math.max(max, eqClass.length() - 1); return max; } /** * Updates the given assignment with information on equivalent variables. * * @param a the assignment to update */
void updateAssignment(Assignment a) {
JuliaSoft/BeeDeeDee
src/com/juliasoft/beedeedee/factories/EquivCache.java
// Path: src/com/juliasoft/beedeedee/factories/ERFactory.java // public static class EquivResult { // private BitSet entailed; // private BitSet disentailed; // private ArrayList<Pair> equiv; // private final static EquivResult emptyEquivResult = new EquivResult(); // // private EquivResult() { // this(new BitSet(), new BitSet(), new ArrayList<Pair>()); // } // // private EquivResult(EquivResult parent) { // this(parent.entailed, parent.disentailed, parent.equiv); // } // // private EquivResult(BitSet entailed, BitSet disentailed, ArrayList<Pair> equiv) { // this.entailed = entailed; // this.disentailed = disentailed; // this.equiv = equiv; // } // }
import java.util.Arrays; import com.juliasoft.beedeedee.factories.ERFactory.EquivResult;
package com.juliasoft.beedeedee.factories; public class EquivCache { private final int[] bdds;
// Path: src/com/juliasoft/beedeedee/factories/ERFactory.java // public static class EquivResult { // private BitSet entailed; // private BitSet disentailed; // private ArrayList<Pair> equiv; // private final static EquivResult emptyEquivResult = new EquivResult(); // // private EquivResult() { // this(new BitSet(), new BitSet(), new ArrayList<Pair>()); // } // // private EquivResult(EquivResult parent) { // this(parent.entailed, parent.disentailed, parent.equiv); // } // // private EquivResult(BitSet entailed, BitSet disentailed, ArrayList<Pair> equiv) { // this.entailed = entailed; // this.disentailed = disentailed; // this.equiv = equiv; // } // } // Path: src/com/juliasoft/beedeedee/factories/EquivCache.java import java.util.Arrays; import com.juliasoft.beedeedee.factories.ERFactory.EquivResult; package com.juliasoft.beedeedee.factories; public class EquivCache { private final int[] bdds;
private final EquivResult[] results;
JuliaSoft/BeeDeeDee
src/com/juliasoft/beedeedee/factories/JavaBDDAdapterFactory.java
// Path: src/com/juliasoft/beedeedee/bdd/Assignment.java // public interface Assignment { // // /** // * Determines if the given BDD variable holds in this assignment. // * // * @param var the variable // * @return true if and only if {@code var} holds in this assignment // * @throws IndexOutOfBoundsException if the variable does not belong to this // * assignment. This means that the variable can be assigned any // * value // */ // public boolean holds(BDD var) throws IndexOutOfBoundsException; // // /** // * Determines if the given BDD variable holds in this assignment. // * // * @param i the variable index // * @return true if and only if the variable indexed by {@code i} holds in // * this assignment // * @throws IndexOutOfBoundsException if the variable does not belong to this // * assignment. This means that the variable can be assigned any // * value // */ // public boolean holds(int i); // // /** // * @return a <em>minterm</em> representation of the assignment // */ // public BDD toBDD(); // // /** // * Adds a mapping for the given variable. // * // * @param var the variable index // * @param value the value to assign to the variable in this assignment // */ // public void put(int var, boolean value); // // } // // Path: src/com/juliasoft/beedeedee/bdd/ReplacementWithExistingVarException.java // @SuppressWarnings("serial") // public class ReplacementWithExistingVarException extends RuntimeException { // // private final int varNum; // // public ReplacementWithExistingVarException(int varNum) { // this.varNum = varNum; // } // // public int getVarNum() { // return varNum; // } // // @Override // public String toString() { // return "trying to replace with variable " + varNum + " which is already in the BDD"; // } // } // // Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface GarbageCollectionListener { // // /** // * Called when a garbage collection operation is about to start. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStart(int num, int size, int free, long totalTime); // // /** // * Called when a garbage collection operation has been performed. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param time the time required for the garbage collection // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStop(int num, int size, int free, long time, long totalTime); // } // // Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface ResizeListener { // // /** // * Called when a resize operation is about to start. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param totalTime the cumulative resize time up to now // */ // // public void onStart(int num, int oldSize, int newSize, long totalTime); // // /** // * Called when a resize operation has been performed. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param time the time required for the resize // * @param totalTime the cumulative resize time up to now // */ // // public void onStop(int num, int oldSize, int newSize, long time, long totalTime); // }
import net.sf.javabdd.BDDException; import net.sf.javabdd.BDDFactory; import net.sf.javabdd.BDDPairing; import com.juliasoft.beedeedee.bdd.Assignment; import com.juliasoft.beedeedee.bdd.ReplacementWithExistingVarException; import com.juliasoft.beedeedee.factories.Factory.GarbageCollectionListener; import com.juliasoft.beedeedee.factories.Factory.ResizeListener; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.math.BigInteger; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import net.sf.javabdd.BDD; import net.sf.javabdd.BDDBitVector; import net.sf.javabdd.BDDDomain;
@Override public double setMinFreeNodes(double x) { return factory.setMinFreeNodes(x); } @Override public int setMaxIncrease(int maxIncrease) { return factory.setMaxIncrease(maxIncrease); } @Override public double setIncreaseFactor(double increaseFactor) { return factory.setIncreaseFactor(increaseFactor); } @Override public double setCacheRatio(double cacheRatio) { return factory.setCacheRatio(cacheRatio); } /** * Register a callback that is called when garbage collection starts or stops. * * @param o the object whose method is called * @param m the method that gets called */ @Override public void registerGCCallback(final Object o, final Method m) {
// Path: src/com/juliasoft/beedeedee/bdd/Assignment.java // public interface Assignment { // // /** // * Determines if the given BDD variable holds in this assignment. // * // * @param var the variable // * @return true if and only if {@code var} holds in this assignment // * @throws IndexOutOfBoundsException if the variable does not belong to this // * assignment. This means that the variable can be assigned any // * value // */ // public boolean holds(BDD var) throws IndexOutOfBoundsException; // // /** // * Determines if the given BDD variable holds in this assignment. // * // * @param i the variable index // * @return true if and only if the variable indexed by {@code i} holds in // * this assignment // * @throws IndexOutOfBoundsException if the variable does not belong to this // * assignment. This means that the variable can be assigned any // * value // */ // public boolean holds(int i); // // /** // * @return a <em>minterm</em> representation of the assignment // */ // public BDD toBDD(); // // /** // * Adds a mapping for the given variable. // * // * @param var the variable index // * @param value the value to assign to the variable in this assignment // */ // public void put(int var, boolean value); // // } // // Path: src/com/juliasoft/beedeedee/bdd/ReplacementWithExistingVarException.java // @SuppressWarnings("serial") // public class ReplacementWithExistingVarException extends RuntimeException { // // private final int varNum; // // public ReplacementWithExistingVarException(int varNum) { // this.varNum = varNum; // } // // public int getVarNum() { // return varNum; // } // // @Override // public String toString() { // return "trying to replace with variable " + varNum + " which is already in the BDD"; // } // } // // Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface GarbageCollectionListener { // // /** // * Called when a garbage collection operation is about to start. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStart(int num, int size, int free, long totalTime); // // /** // * Called when a garbage collection operation has been performed. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param time the time required for the garbage collection // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStop(int num, int size, int free, long time, long totalTime); // } // // Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface ResizeListener { // // /** // * Called when a resize operation is about to start. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param totalTime the cumulative resize time up to now // */ // // public void onStart(int num, int oldSize, int newSize, long totalTime); // // /** // * Called when a resize operation has been performed. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param time the time required for the resize // * @param totalTime the cumulative resize time up to now // */ // // public void onStop(int num, int oldSize, int newSize, long time, long totalTime); // } // Path: src/com/juliasoft/beedeedee/factories/JavaBDDAdapterFactory.java import net.sf.javabdd.BDDException; import net.sf.javabdd.BDDFactory; import net.sf.javabdd.BDDPairing; import com.juliasoft.beedeedee.bdd.Assignment; import com.juliasoft.beedeedee.bdd.ReplacementWithExistingVarException; import com.juliasoft.beedeedee.factories.Factory.GarbageCollectionListener; import com.juliasoft.beedeedee.factories.Factory.ResizeListener; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.math.BigInteger; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import net.sf.javabdd.BDD; import net.sf.javabdd.BDDBitVector; import net.sf.javabdd.BDDDomain; @Override public double setMinFreeNodes(double x) { return factory.setMinFreeNodes(x); } @Override public int setMaxIncrease(int maxIncrease) { return factory.setMaxIncrease(maxIncrease); } @Override public double setIncreaseFactor(double increaseFactor) { return factory.setIncreaseFactor(increaseFactor); } @Override public double setCacheRatio(double cacheRatio) { return factory.setCacheRatio(cacheRatio); } /** * Register a callback that is called when garbage collection starts or stops. * * @param o the object whose method is called * @param m the method that gets called */ @Override public void registerGCCallback(final Object o, final Method m) {
factory.setGarbageCollectionListener(new GarbageCollectionListener() {
JuliaSoft/BeeDeeDee
src/com/juliasoft/beedeedee/factories/JavaBDDAdapterFactory.java
// Path: src/com/juliasoft/beedeedee/bdd/Assignment.java // public interface Assignment { // // /** // * Determines if the given BDD variable holds in this assignment. // * // * @param var the variable // * @return true if and only if {@code var} holds in this assignment // * @throws IndexOutOfBoundsException if the variable does not belong to this // * assignment. This means that the variable can be assigned any // * value // */ // public boolean holds(BDD var) throws IndexOutOfBoundsException; // // /** // * Determines if the given BDD variable holds in this assignment. // * // * @param i the variable index // * @return true if and only if the variable indexed by {@code i} holds in // * this assignment // * @throws IndexOutOfBoundsException if the variable does not belong to this // * assignment. This means that the variable can be assigned any // * value // */ // public boolean holds(int i); // // /** // * @return a <em>minterm</em> representation of the assignment // */ // public BDD toBDD(); // // /** // * Adds a mapping for the given variable. // * // * @param var the variable index // * @param value the value to assign to the variable in this assignment // */ // public void put(int var, boolean value); // // } // // Path: src/com/juliasoft/beedeedee/bdd/ReplacementWithExistingVarException.java // @SuppressWarnings("serial") // public class ReplacementWithExistingVarException extends RuntimeException { // // private final int varNum; // // public ReplacementWithExistingVarException(int varNum) { // this.varNum = varNum; // } // // public int getVarNum() { // return varNum; // } // // @Override // public String toString() { // return "trying to replace with variable " + varNum + " which is already in the BDD"; // } // } // // Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface GarbageCollectionListener { // // /** // * Called when a garbage collection operation is about to start. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStart(int num, int size, int free, long totalTime); // // /** // * Called when a garbage collection operation has been performed. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param time the time required for the garbage collection // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStop(int num, int size, int free, long time, long totalTime); // } // // Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface ResizeListener { // // /** // * Called when a resize operation is about to start. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param totalTime the cumulative resize time up to now // */ // // public void onStart(int num, int oldSize, int newSize, long totalTime); // // /** // * Called when a resize operation has been performed. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param time the time required for the resize // * @param totalTime the cumulative resize time up to now // */ // // public void onStop(int num, int oldSize, int newSize, long time, long totalTime); // }
import net.sf.javabdd.BDDException; import net.sf.javabdd.BDDFactory; import net.sf.javabdd.BDDPairing; import com.juliasoft.beedeedee.bdd.Assignment; import com.juliasoft.beedeedee.bdd.ReplacementWithExistingVarException; import com.juliasoft.beedeedee.factories.Factory.GarbageCollectionListener; import com.juliasoft.beedeedee.factories.Factory.ResizeListener; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.math.BigInteger; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import net.sf.javabdd.BDD; import net.sf.javabdd.BDDBitVector; import net.sf.javabdd.BDDDomain;
void defaultGCCallback(int x, BDDFactory.GCStats stats) { // we only print something at the end of the garbage collection if (x == 0) System.out.println(stats); } /** * This is the default method that is called every time a resize operation is performed on the * set of binary decision nodes. * * @param oldSize * the old size of the table of nodes * @param newSize * the new size of the table of nodes */ void defaultResizeCallback(int oldSize, int newSize) { System.out.println("Resizing node table from " + oldSize + " to " + newSize); } /** * Register a callback that is called when resize has been performed. * * @param o the object whose method is called * @param m the method that gets called */ @Override public void registerResizeCallback(Object o, Method m) {
// Path: src/com/juliasoft/beedeedee/bdd/Assignment.java // public interface Assignment { // // /** // * Determines if the given BDD variable holds in this assignment. // * // * @param var the variable // * @return true if and only if {@code var} holds in this assignment // * @throws IndexOutOfBoundsException if the variable does not belong to this // * assignment. This means that the variable can be assigned any // * value // */ // public boolean holds(BDD var) throws IndexOutOfBoundsException; // // /** // * Determines if the given BDD variable holds in this assignment. // * // * @param i the variable index // * @return true if and only if the variable indexed by {@code i} holds in // * this assignment // * @throws IndexOutOfBoundsException if the variable does not belong to this // * assignment. This means that the variable can be assigned any // * value // */ // public boolean holds(int i); // // /** // * @return a <em>minterm</em> representation of the assignment // */ // public BDD toBDD(); // // /** // * Adds a mapping for the given variable. // * // * @param var the variable index // * @param value the value to assign to the variable in this assignment // */ // public void put(int var, boolean value); // // } // // Path: src/com/juliasoft/beedeedee/bdd/ReplacementWithExistingVarException.java // @SuppressWarnings("serial") // public class ReplacementWithExistingVarException extends RuntimeException { // // private final int varNum; // // public ReplacementWithExistingVarException(int varNum) { // this.varNum = varNum; // } // // public int getVarNum() { // return varNum; // } // // @Override // public String toString() { // return "trying to replace with variable " + varNum + " which is already in the BDD"; // } // } // // Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface GarbageCollectionListener { // // /** // * Called when a garbage collection operation is about to start. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStart(int num, int size, int free, long totalTime); // // /** // * Called when a garbage collection operation has been performed. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param time the time required for the garbage collection // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStop(int num, int size, int free, long time, long totalTime); // } // // Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface ResizeListener { // // /** // * Called when a resize operation is about to start. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param totalTime the cumulative resize time up to now // */ // // public void onStart(int num, int oldSize, int newSize, long totalTime); // // /** // * Called when a resize operation has been performed. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param time the time required for the resize // * @param totalTime the cumulative resize time up to now // */ // // public void onStop(int num, int oldSize, int newSize, long time, long totalTime); // } // Path: src/com/juliasoft/beedeedee/factories/JavaBDDAdapterFactory.java import net.sf.javabdd.BDDException; import net.sf.javabdd.BDDFactory; import net.sf.javabdd.BDDPairing; import com.juliasoft.beedeedee.bdd.Assignment; import com.juliasoft.beedeedee.bdd.ReplacementWithExistingVarException; import com.juliasoft.beedeedee.factories.Factory.GarbageCollectionListener; import com.juliasoft.beedeedee.factories.Factory.ResizeListener; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.math.BigInteger; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import net.sf.javabdd.BDD; import net.sf.javabdd.BDDBitVector; import net.sf.javabdd.BDDDomain; void defaultGCCallback(int x, BDDFactory.GCStats stats) { // we only print something at the end of the garbage collection if (x == 0) System.out.println(stats); } /** * This is the default method that is called every time a resize operation is performed on the * set of binary decision nodes. * * @param oldSize * the old size of the table of nodes * @param newSize * the new size of the table of nodes */ void defaultResizeCallback(int oldSize, int newSize) { System.out.println("Resizing node table from " + oldSize + " to " + newSize); } /** * Register a callback that is called when resize has been performed. * * @param o the object whose method is called * @param m the method that gets called */ @Override public void registerResizeCallback(Object o, Method m) {
factory.setResizeListener(new ResizeListener() {
JuliaSoft/BeeDeeDee
src/com/juliasoft/beedeedee/factories/JavaBDDAdapterFactory.java
// Path: src/com/juliasoft/beedeedee/bdd/Assignment.java // public interface Assignment { // // /** // * Determines if the given BDD variable holds in this assignment. // * // * @param var the variable // * @return true if and only if {@code var} holds in this assignment // * @throws IndexOutOfBoundsException if the variable does not belong to this // * assignment. This means that the variable can be assigned any // * value // */ // public boolean holds(BDD var) throws IndexOutOfBoundsException; // // /** // * Determines if the given BDD variable holds in this assignment. // * // * @param i the variable index // * @return true if and only if the variable indexed by {@code i} holds in // * this assignment // * @throws IndexOutOfBoundsException if the variable does not belong to this // * assignment. This means that the variable can be assigned any // * value // */ // public boolean holds(int i); // // /** // * @return a <em>minterm</em> representation of the assignment // */ // public BDD toBDD(); // // /** // * Adds a mapping for the given variable. // * // * @param var the variable index // * @param value the value to assign to the variable in this assignment // */ // public void put(int var, boolean value); // // } // // Path: src/com/juliasoft/beedeedee/bdd/ReplacementWithExistingVarException.java // @SuppressWarnings("serial") // public class ReplacementWithExistingVarException extends RuntimeException { // // private final int varNum; // // public ReplacementWithExistingVarException(int varNum) { // this.varNum = varNum; // } // // public int getVarNum() { // return varNum; // } // // @Override // public String toString() { // return "trying to replace with variable " + varNum + " which is already in the BDD"; // } // } // // Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface GarbageCollectionListener { // // /** // * Called when a garbage collection operation is about to start. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStart(int num, int size, int free, long totalTime); // // /** // * Called when a garbage collection operation has been performed. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param time the time required for the garbage collection // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStop(int num, int size, int free, long time, long totalTime); // } // // Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface ResizeListener { // // /** // * Called when a resize operation is about to start. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param totalTime the cumulative resize time up to now // */ // // public void onStart(int num, int oldSize, int newSize, long totalTime); // // /** // * Called when a resize operation has been performed. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param time the time required for the resize // * @param totalTime the cumulative resize time up to now // */ // // public void onStop(int num, int oldSize, int newSize, long time, long totalTime); // }
import net.sf.javabdd.BDDException; import net.sf.javabdd.BDDFactory; import net.sf.javabdd.BDDPairing; import com.juliasoft.beedeedee.bdd.Assignment; import com.juliasoft.beedeedee.bdd.ReplacementWithExistingVarException; import com.juliasoft.beedeedee.factories.Factory.GarbageCollectionListener; import com.juliasoft.beedeedee.factories.Factory.ResizeListener; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.math.BigInteger; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import net.sf.javabdd.BDD; import net.sf.javabdd.BDDBitVector; import net.sf.javabdd.BDDDomain;
public BDD applyUni(BDD that, BDDOp opr, BDD var) { throw new UnsupportedOperationException(); } @Override public BDD satOne() { return new JavaBDDAdapterBDD(bdd.anySat().toBDD()); } /** * Unsupported operation. */ @Override public BDD fullSatOne() { throw new UnsupportedOperationException(); } /** * Unsupported operation. */ @Override public BDD satOne(BDD var, boolean pol) { throw new UnsupportedOperationException(); } @Override public List<BDD> allsat() { ArrayList<BDD> list = new ArrayList<BDD>();
// Path: src/com/juliasoft/beedeedee/bdd/Assignment.java // public interface Assignment { // // /** // * Determines if the given BDD variable holds in this assignment. // * // * @param var the variable // * @return true if and only if {@code var} holds in this assignment // * @throws IndexOutOfBoundsException if the variable does not belong to this // * assignment. This means that the variable can be assigned any // * value // */ // public boolean holds(BDD var) throws IndexOutOfBoundsException; // // /** // * Determines if the given BDD variable holds in this assignment. // * // * @param i the variable index // * @return true if and only if the variable indexed by {@code i} holds in // * this assignment // * @throws IndexOutOfBoundsException if the variable does not belong to this // * assignment. This means that the variable can be assigned any // * value // */ // public boolean holds(int i); // // /** // * @return a <em>minterm</em> representation of the assignment // */ // public BDD toBDD(); // // /** // * Adds a mapping for the given variable. // * // * @param var the variable index // * @param value the value to assign to the variable in this assignment // */ // public void put(int var, boolean value); // // } // // Path: src/com/juliasoft/beedeedee/bdd/ReplacementWithExistingVarException.java // @SuppressWarnings("serial") // public class ReplacementWithExistingVarException extends RuntimeException { // // private final int varNum; // // public ReplacementWithExistingVarException(int varNum) { // this.varNum = varNum; // } // // public int getVarNum() { // return varNum; // } // // @Override // public String toString() { // return "trying to replace with variable " + varNum + " which is already in the BDD"; // } // } // // Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface GarbageCollectionListener { // // /** // * Called when a garbage collection operation is about to start. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStart(int num, int size, int free, long totalTime); // // /** // * Called when a garbage collection operation has been performed. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param time the time required for the garbage collection // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStop(int num, int size, int free, long time, long totalTime); // } // // Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface ResizeListener { // // /** // * Called when a resize operation is about to start. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param totalTime the cumulative resize time up to now // */ // // public void onStart(int num, int oldSize, int newSize, long totalTime); // // /** // * Called when a resize operation has been performed. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param time the time required for the resize // * @param totalTime the cumulative resize time up to now // */ // // public void onStop(int num, int oldSize, int newSize, long time, long totalTime); // } // Path: src/com/juliasoft/beedeedee/factories/JavaBDDAdapterFactory.java import net.sf.javabdd.BDDException; import net.sf.javabdd.BDDFactory; import net.sf.javabdd.BDDPairing; import com.juliasoft.beedeedee.bdd.Assignment; import com.juliasoft.beedeedee.bdd.ReplacementWithExistingVarException; import com.juliasoft.beedeedee.factories.Factory.GarbageCollectionListener; import com.juliasoft.beedeedee.factories.Factory.ResizeListener; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.math.BigInteger; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import net.sf.javabdd.BDD; import net.sf.javabdd.BDDBitVector; import net.sf.javabdd.BDDDomain; public BDD applyUni(BDD that, BDDOp opr, BDD var) { throw new UnsupportedOperationException(); } @Override public BDD satOne() { return new JavaBDDAdapterBDD(bdd.anySat().toBDD()); } /** * Unsupported operation. */ @Override public BDD fullSatOne() { throw new UnsupportedOperationException(); } /** * Unsupported operation. */ @Override public BDD satOne(BDD var, boolean pol) { throw new UnsupportedOperationException(); } @Override public List<BDD> allsat() { ArrayList<BDD> list = new ArrayList<BDD>();
for (Assignment a : bdd.allSat()) {
JuliaSoft/BeeDeeDee
src/com/juliasoft/beedeedee/factories/JavaBDDAdapterFactory.java
// Path: src/com/juliasoft/beedeedee/bdd/Assignment.java // public interface Assignment { // // /** // * Determines if the given BDD variable holds in this assignment. // * // * @param var the variable // * @return true if and only if {@code var} holds in this assignment // * @throws IndexOutOfBoundsException if the variable does not belong to this // * assignment. This means that the variable can be assigned any // * value // */ // public boolean holds(BDD var) throws IndexOutOfBoundsException; // // /** // * Determines if the given BDD variable holds in this assignment. // * // * @param i the variable index // * @return true if and only if the variable indexed by {@code i} holds in // * this assignment // * @throws IndexOutOfBoundsException if the variable does not belong to this // * assignment. This means that the variable can be assigned any // * value // */ // public boolean holds(int i); // // /** // * @return a <em>minterm</em> representation of the assignment // */ // public BDD toBDD(); // // /** // * Adds a mapping for the given variable. // * // * @param var the variable index // * @param value the value to assign to the variable in this assignment // */ // public void put(int var, boolean value); // // } // // Path: src/com/juliasoft/beedeedee/bdd/ReplacementWithExistingVarException.java // @SuppressWarnings("serial") // public class ReplacementWithExistingVarException extends RuntimeException { // // private final int varNum; // // public ReplacementWithExistingVarException(int varNum) { // this.varNum = varNum; // } // // public int getVarNum() { // return varNum; // } // // @Override // public String toString() { // return "trying to replace with variable " + varNum + " which is already in the BDD"; // } // } // // Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface GarbageCollectionListener { // // /** // * Called when a garbage collection operation is about to start. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStart(int num, int size, int free, long totalTime); // // /** // * Called when a garbage collection operation has been performed. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param time the time required for the garbage collection // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStop(int num, int size, int free, long time, long totalTime); // } // // Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface ResizeListener { // // /** // * Called when a resize operation is about to start. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param totalTime the cumulative resize time up to now // */ // // public void onStart(int num, int oldSize, int newSize, long totalTime); // // /** // * Called when a resize operation has been performed. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param time the time required for the resize // * @param totalTime the cumulative resize time up to now // */ // // public void onStop(int num, int oldSize, int newSize, long time, long totalTime); // }
import net.sf.javabdd.BDDException; import net.sf.javabdd.BDDFactory; import net.sf.javabdd.BDDPairing; import com.juliasoft.beedeedee.bdd.Assignment; import com.juliasoft.beedeedee.bdd.ReplacementWithExistingVarException; import com.juliasoft.beedeedee.factories.Factory.GarbageCollectionListener; import com.juliasoft.beedeedee.factories.Factory.ResizeListener; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.math.BigInteger; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import net.sf.javabdd.BDD; import net.sf.javabdd.BDDBitVector; import net.sf.javabdd.BDDDomain;
*/ @Override public BDD fullSatOne() { throw new UnsupportedOperationException(); } /** * Unsupported operation. */ @Override public BDD satOne(BDD var, boolean pol) { throw new UnsupportedOperationException(); } @Override public List<BDD> allsat() { ArrayList<BDD> list = new ArrayList<BDD>(); for (Assignment a : bdd.allSat()) { list.add(new JavaBDDAdapterBDD(a.toBDD())); } return list; } @Override public BDD replace(BDDPairing pair) { try { return new JavaBDDAdapterBDD(bdd.replace(((JavaBDDAdapterBDDPairing)pair).renaming));
// Path: src/com/juliasoft/beedeedee/bdd/Assignment.java // public interface Assignment { // // /** // * Determines if the given BDD variable holds in this assignment. // * // * @param var the variable // * @return true if and only if {@code var} holds in this assignment // * @throws IndexOutOfBoundsException if the variable does not belong to this // * assignment. This means that the variable can be assigned any // * value // */ // public boolean holds(BDD var) throws IndexOutOfBoundsException; // // /** // * Determines if the given BDD variable holds in this assignment. // * // * @param i the variable index // * @return true if and only if the variable indexed by {@code i} holds in // * this assignment // * @throws IndexOutOfBoundsException if the variable does not belong to this // * assignment. This means that the variable can be assigned any // * value // */ // public boolean holds(int i); // // /** // * @return a <em>minterm</em> representation of the assignment // */ // public BDD toBDD(); // // /** // * Adds a mapping for the given variable. // * // * @param var the variable index // * @param value the value to assign to the variable in this assignment // */ // public void put(int var, boolean value); // // } // // Path: src/com/juliasoft/beedeedee/bdd/ReplacementWithExistingVarException.java // @SuppressWarnings("serial") // public class ReplacementWithExistingVarException extends RuntimeException { // // private final int varNum; // // public ReplacementWithExistingVarException(int varNum) { // this.varNum = varNum; // } // // public int getVarNum() { // return varNum; // } // // @Override // public String toString() { // return "trying to replace with variable " + varNum + " which is already in the BDD"; // } // } // // Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface GarbageCollectionListener { // // /** // * Called when a garbage collection operation is about to start. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStart(int num, int size, int free, long totalTime); // // /** // * Called when a garbage collection operation has been performed. // * // * @param num the progressive number of the garbage collection operation // * @param size the number of nodes in the garbage collected table // * @param free the number of free nodes after the operation // * @param time the time required for the garbage collection // * @param totalTime the cumulative garbage collection time up to now // */ // // public void onStop(int num, int size, int free, long time, long totalTime); // } // // Path: src/com/juliasoft/beedeedee/factories/Factory.java // public static interface ResizeListener { // // /** // * Called when a resize operation is about to start. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param totalTime the cumulative resize time up to now // */ // // public void onStart(int num, int oldSize, int newSize, long totalTime); // // /** // * Called when a resize operation has been performed. // * // * @param num the progressive number of the resize operation // * @param oldSize the old size of the table // * @param newSize the new size of the table // * @param time the time required for the resize // * @param totalTime the cumulative resize time up to now // */ // // public void onStop(int num, int oldSize, int newSize, long time, long totalTime); // } // Path: src/com/juliasoft/beedeedee/factories/JavaBDDAdapterFactory.java import net.sf.javabdd.BDDException; import net.sf.javabdd.BDDFactory; import net.sf.javabdd.BDDPairing; import com.juliasoft.beedeedee.bdd.Assignment; import com.juliasoft.beedeedee.bdd.ReplacementWithExistingVarException; import com.juliasoft.beedeedee.factories.Factory.GarbageCollectionListener; import com.juliasoft.beedeedee.factories.Factory.ResizeListener; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.math.BigInteger; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import net.sf.javabdd.BDD; import net.sf.javabdd.BDDBitVector; import net.sf.javabdd.BDDDomain; */ @Override public BDD fullSatOne() { throw new UnsupportedOperationException(); } /** * Unsupported operation. */ @Override public BDD satOne(BDD var, boolean pol) { throw new UnsupportedOperationException(); } @Override public List<BDD> allsat() { ArrayList<BDD> list = new ArrayList<BDD>(); for (Assignment a : bdd.allSat()) { list.add(new JavaBDDAdapterBDD(a.toBDD())); } return list; } @Override public BDD replace(BDDPairing pair) { try { return new JavaBDDAdapterBDD(bdd.replace(((JavaBDDAdapterBDDPairing)pair).renaming));
} catch (ReplacementWithExistingVarException e) {
rkkr/simple-keyboard
app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/SettingsActivity.java
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/utils/FragmentUtils.java // public class FragmentUtils { // private static final HashSet<String> sLatinImeFragments = new HashSet<>(); // static { // sLatinImeFragments.add(PreferencesSettingsFragment.class.getName()); // sLatinImeFragments.add(KeyPressSettingsFragment.class.getName()); // sLatinImeFragments.add(AppearanceSettingsFragment.class.getName()); // sLatinImeFragments.add(ThemeSettingsFragment.class.getName()); // sLatinImeFragments.add(SettingsFragment.class.getName()); // sLatinImeFragments.add(LanguagesSettingsFragment.class.getName()); // sLatinImeFragments.add(SingleLanguageSettingsFragment.class.getName()); // } // // public static boolean isValidFragment(String fragmentName) { // return sLatinImeFragments.contains(fragmentName); // } // }
import android.app.ActionBar; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.preference.PreferenceActivity; import android.util.Log; import android.view.MenuItem; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodManager; import rkr.simplekeyboard.inputmethod.R; import rkr.simplekeyboard.inputmethod.latin.utils.FragmentUtils;
super.onCreate(savedState); final ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); } } @Override public boolean onOptionsItemSelected(final MenuItem item) { if (item.getItemId() == android.R.id.home) { super.onBackPressed(); return true; } return super.onOptionsItemSelected(item); } @Override public Intent getIntent() { final Intent intent = super.getIntent(); final String fragment = intent.getStringExtra(EXTRA_SHOW_FRAGMENT); if (fragment == null) { intent.putExtra(EXTRA_SHOW_FRAGMENT, DEFAULT_FRAGMENT); } intent.putExtra(EXTRA_NO_HEADERS, true); return intent; } @Override public boolean isValidFragment(final String fragmentName) {
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/utils/FragmentUtils.java // public class FragmentUtils { // private static final HashSet<String> sLatinImeFragments = new HashSet<>(); // static { // sLatinImeFragments.add(PreferencesSettingsFragment.class.getName()); // sLatinImeFragments.add(KeyPressSettingsFragment.class.getName()); // sLatinImeFragments.add(AppearanceSettingsFragment.class.getName()); // sLatinImeFragments.add(ThemeSettingsFragment.class.getName()); // sLatinImeFragments.add(SettingsFragment.class.getName()); // sLatinImeFragments.add(LanguagesSettingsFragment.class.getName()); // sLatinImeFragments.add(SingleLanguageSettingsFragment.class.getName()); // } // // public static boolean isValidFragment(String fragmentName) { // return sLatinImeFragments.contains(fragmentName); // } // } // Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/SettingsActivity.java import android.app.ActionBar; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.preference.PreferenceActivity; import android.util.Log; import android.view.MenuItem; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodManager; import rkr.simplekeyboard.inputmethod.R; import rkr.simplekeyboard.inputmethod.latin.utils.FragmentUtils; super.onCreate(savedState); final ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); } } @Override public boolean onOptionsItemSelected(final MenuItem item) { if (item.getItemId() == android.R.id.home) { super.onBackPressed(); return true; } return super.onOptionsItemSelected(item); } @Override public Intent getIntent() { final Intent intent = super.getIntent(); final String fragment = intent.getStringExtra(EXTRA_SHOW_FRAGMENT); if (fragment == null) { intent.putExtra(EXTRA_SHOW_FRAGMENT, DEFAULT_FRAGMENT); } intent.putExtra(EXTRA_NO_HEADERS, true); return intent; } @Override public boolean isValidFragment(final String fragmentName) {
return FragmentUtils.isValidFragment(fragmentName);
rkkr/simple-keyboard
app/src/main/java/rkr/simplekeyboard/inputmethod/compat/ViewOutlineProviderCompatUtilsLXX.java
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/compat/ViewOutlineProviderCompatUtils.java // public interface InsetsUpdater { // void setInsets(final InputMethodService.Insets insets); // }
import android.annotation.TargetApi; import android.graphics.Outline; import android.inputmethodservice.InputMethodService; import android.os.Build; import android.view.View; import android.view.ViewOutlineProvider; import rkr.simplekeyboard.inputmethod.compat.ViewOutlineProviderCompatUtils.InsetsUpdater;
/* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package rkr.simplekeyboard.inputmethod.compat; @TargetApi(Build.VERSION_CODES.LOLLIPOP) class ViewOutlineProviderCompatUtilsLXX { private ViewOutlineProviderCompatUtilsLXX() { // This utility class is not publicly instantiable. }
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/compat/ViewOutlineProviderCompatUtils.java // public interface InsetsUpdater { // void setInsets(final InputMethodService.Insets insets); // } // Path: app/src/main/java/rkr/simplekeyboard/inputmethod/compat/ViewOutlineProviderCompatUtilsLXX.java import android.annotation.TargetApi; import android.graphics.Outline; import android.inputmethodservice.InputMethodService; import android.os.Build; import android.view.View; import android.view.ViewOutlineProvider; import rkr.simplekeyboard.inputmethod.compat.ViewOutlineProviderCompatUtils.InsetsUpdater; /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package rkr.simplekeyboard.inputmethod.compat; @TargetApi(Build.VERSION_CODES.LOLLIPOP) class ViewOutlineProviderCompatUtilsLXX { private ViewOutlineProviderCompatUtilsLXX() { // This utility class is not publicly instantiable. }
static InsetsUpdater setInsetsOutlineProvider(final View view) {
rkkr/simple-keyboard
app/src/main/java/rkr/simplekeyboard/inputmethod/latin/utils/ResourceUtils.java
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/SettingsValues.java // public class SettingsValues { // public static final float DEFAULT_SIZE_SCALE = 1.0f; // 100% // // // From resources: // public final SpacingAndPunctuations mSpacingAndPunctuations; // // From configuration: // public final boolean mHasHardwareKeyboard; // public final int mDisplayOrientation; // // From preferences, in the same order as xml/prefs.xml: // public final boolean mAutoCap; // public final boolean mVibrateOn; // public final boolean mSoundOn; // public final boolean mKeyPreviewPopupOn; // public final boolean mShowsLanguageSwitchKey; // public final boolean mImeSwitchEnabled; // public final int mKeyLongpressTimeout; // public final boolean mHideSpecialChars; // public final boolean mShowNumberRow; // public final boolean mSpaceSwipeEnabled; // public final boolean mDeleteSwipeEnabled; // public final boolean mUseMatchingNavbarColor; // // // From the input box // public final InputAttributes mInputAttributes; // // // Deduced settings // public final int mKeypressVibrationDuration; // public final float mKeypressSoundVolume; // public final int mKeyPreviewPopupDismissDelay; // // // Debug settings // public final float mKeyboardHeightScale; // // public SettingsValues(final SharedPreferences prefs, final Resources res, // final InputAttributes inputAttributes) { // // Get the resources // mSpacingAndPunctuations = new SpacingAndPunctuations(res); // // // Store the input attributes // mInputAttributes = inputAttributes; // // // Get the settings preferences // mAutoCap = prefs.getBoolean(Settings.PREF_AUTO_CAP, true); // mVibrateOn = Settings.readVibrationEnabled(prefs, res); // mSoundOn = Settings.readKeypressSoundEnabled(prefs, res); // mKeyPreviewPopupOn = Settings.readKeyPreviewPopupEnabled(prefs, res); // mShowsLanguageSwitchKey = Settings.readShowLanguageSwitchKey(prefs); // mImeSwitchEnabled = Settings.readEnableImeSwitch(prefs); // mHasHardwareKeyboard = Settings.readHasHardwareKeyboard(res.getConfiguration()); // // // Compute other readable settings // mKeyLongpressTimeout = Settings.readKeyLongpressTimeout(prefs, res); // mKeypressVibrationDuration = Settings.readKeypressVibrationDuration(prefs, res); // mKeypressSoundVolume = Settings.readKeypressSoundVolume(prefs, res); // mKeyPreviewPopupDismissDelay = res.getInteger(R.integer.config_key_preview_linger_timeout); // mKeyboardHeightScale = Settings.readKeyboardHeight(prefs, DEFAULT_SIZE_SCALE); // mDisplayOrientation = res.getConfiguration().orientation; // mHideSpecialChars = Settings.readHideSpecialChars(prefs); // mShowNumberRow = Settings.readShowNumberRow(prefs); // mSpaceSwipeEnabled = Settings.readSpaceSwipeEnabled(prefs); // mDeleteSwipeEnabled = Settings.readDeleteSwipeEnabled(prefs); // mUseMatchingNavbarColor = Settings.readUseMatchingNavbarColor(prefs); // } // // public boolean isWordSeparator(final int code) { // return mSpacingAndPunctuations.isWordSeparator(code); // } // // public boolean isLanguageSwitchKeyDisabled() { // return !mShowsLanguageSwitchKey; // } // // public boolean isSameInputType(final EditorInfo editorInfo) { // return mInputAttributes.isSameInputType(editorInfo); // } // // public boolean hasSameOrientation(final Configuration configuration) { // return mDisplayOrientation == configuration.orientation; // } // }
import rkr.simplekeyboard.inputmethod.latin.settings.SettingsValues; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Color; import android.os.Build; import android.text.TextUtils; import android.util.DisplayMetrics; import android.util.Log; import android.util.TypedValue; import java.util.ArrayList; import java.util.HashMap; import java.util.regex.PatternSyntaxException; import rkr.simplekeyboard.inputmethod.R;
} private static boolean fulfillsCondition(final HashMap<String,String> keyValuePairs, final String condition) throws DeviceOverridePatternSyntaxError { final String[] patterns = condition.split(":"); // Check all patterns in a condition are true boolean matchedAll = true; for (final String pattern : patterns) { final int posEqual = pattern.indexOf('='); if (posEqual < 0) { throw new DeviceOverridePatternSyntaxError("Pattern has no '='", condition); } final String key = pattern.substring(0, posEqual); final String value = keyValuePairs.get(key); if (value == null) { throw new DeviceOverridePatternSyntaxError("Unknown key", condition); } final String patternRegexpValue = pattern.substring(posEqual + 1); try { if (!value.matches(patternRegexpValue)) { matchedAll = false; // And continue walking through all patterns. } } catch (final PatternSyntaxException e) { throw new DeviceOverridePatternSyntaxError("Syntax error", condition, e); } } return matchedAll; }
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/SettingsValues.java // public class SettingsValues { // public static final float DEFAULT_SIZE_SCALE = 1.0f; // 100% // // // From resources: // public final SpacingAndPunctuations mSpacingAndPunctuations; // // From configuration: // public final boolean mHasHardwareKeyboard; // public final int mDisplayOrientation; // // From preferences, in the same order as xml/prefs.xml: // public final boolean mAutoCap; // public final boolean mVibrateOn; // public final boolean mSoundOn; // public final boolean mKeyPreviewPopupOn; // public final boolean mShowsLanguageSwitchKey; // public final boolean mImeSwitchEnabled; // public final int mKeyLongpressTimeout; // public final boolean mHideSpecialChars; // public final boolean mShowNumberRow; // public final boolean mSpaceSwipeEnabled; // public final boolean mDeleteSwipeEnabled; // public final boolean mUseMatchingNavbarColor; // // // From the input box // public final InputAttributes mInputAttributes; // // // Deduced settings // public final int mKeypressVibrationDuration; // public final float mKeypressSoundVolume; // public final int mKeyPreviewPopupDismissDelay; // // // Debug settings // public final float mKeyboardHeightScale; // // public SettingsValues(final SharedPreferences prefs, final Resources res, // final InputAttributes inputAttributes) { // // Get the resources // mSpacingAndPunctuations = new SpacingAndPunctuations(res); // // // Store the input attributes // mInputAttributes = inputAttributes; // // // Get the settings preferences // mAutoCap = prefs.getBoolean(Settings.PREF_AUTO_CAP, true); // mVibrateOn = Settings.readVibrationEnabled(prefs, res); // mSoundOn = Settings.readKeypressSoundEnabled(prefs, res); // mKeyPreviewPopupOn = Settings.readKeyPreviewPopupEnabled(prefs, res); // mShowsLanguageSwitchKey = Settings.readShowLanguageSwitchKey(prefs); // mImeSwitchEnabled = Settings.readEnableImeSwitch(prefs); // mHasHardwareKeyboard = Settings.readHasHardwareKeyboard(res.getConfiguration()); // // // Compute other readable settings // mKeyLongpressTimeout = Settings.readKeyLongpressTimeout(prefs, res); // mKeypressVibrationDuration = Settings.readKeypressVibrationDuration(prefs, res); // mKeypressSoundVolume = Settings.readKeypressSoundVolume(prefs, res); // mKeyPreviewPopupDismissDelay = res.getInteger(R.integer.config_key_preview_linger_timeout); // mKeyboardHeightScale = Settings.readKeyboardHeight(prefs, DEFAULT_SIZE_SCALE); // mDisplayOrientation = res.getConfiguration().orientation; // mHideSpecialChars = Settings.readHideSpecialChars(prefs); // mShowNumberRow = Settings.readShowNumberRow(prefs); // mSpaceSwipeEnabled = Settings.readSpaceSwipeEnabled(prefs); // mDeleteSwipeEnabled = Settings.readDeleteSwipeEnabled(prefs); // mUseMatchingNavbarColor = Settings.readUseMatchingNavbarColor(prefs); // } // // public boolean isWordSeparator(final int code) { // return mSpacingAndPunctuations.isWordSeparator(code); // } // // public boolean isLanguageSwitchKeyDisabled() { // return !mShowsLanguageSwitchKey; // } // // public boolean isSameInputType(final EditorInfo editorInfo) { // return mInputAttributes.isSameInputType(editorInfo); // } // // public boolean hasSameOrientation(final Configuration configuration) { // return mDisplayOrientation == configuration.orientation; // } // } // Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/utils/ResourceUtils.java import rkr.simplekeyboard.inputmethod.latin.settings.SettingsValues; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Color; import android.os.Build; import android.text.TextUtils; import android.util.DisplayMetrics; import android.util.Log; import android.util.TypedValue; import java.util.ArrayList; import java.util.HashMap; import java.util.regex.PatternSyntaxException; import rkr.simplekeyboard.inputmethod.R; } private static boolean fulfillsCondition(final HashMap<String,String> keyValuePairs, final String condition) throws DeviceOverridePatternSyntaxError { final String[] patterns = condition.split(":"); // Check all patterns in a condition are true boolean matchedAll = true; for (final String pattern : patterns) { final int posEqual = pattern.indexOf('='); if (posEqual < 0) { throw new DeviceOverridePatternSyntaxError("Pattern has no '='", condition); } final String key = pattern.substring(0, posEqual); final String value = keyValuePairs.get(key); if (value == null) { throw new DeviceOverridePatternSyntaxError("Unknown key", condition); } final String patternRegexpValue = pattern.substring(posEqual + 1); try { if (!value.matches(patternRegexpValue)) { matchedAll = false; // And continue walking through all patterns. } } catch (final PatternSyntaxException e) { throw new DeviceOverridePatternSyntaxError("Syntax error", condition, e); } } return matchedAll; }
public static int getKeyboardHeight(final Resources res, final SettingsValues settingsValues) {
rkkr/simple-keyboard
app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/SubScreenFragment.java
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/compat/PreferenceManagerCompat.java // public class PreferenceManagerCompat { // public static Context getDeviceContext(Context context) { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { // return context.createDeviceProtectedStorageContext(); // } // // return context; // } // // public static SharedPreferences getDeviceSharedPreferences(Context context) { // return PreferenceManager.getDefaultSharedPreferences(getDeviceContext(context)); // } // }
import android.app.backup.BackupManager; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Build; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceFragment; import android.preference.PreferenceScreen; import android.util.Log; import rkr.simplekeyboard.inputmethod.compat.PreferenceManagerCompat;
/* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package rkr.simplekeyboard.inputmethod.latin.settings; /** * A base abstract class for a {@link PreferenceFragment} that implements a nested * {@link PreferenceScreen} of the main preference screen. */ public abstract class SubScreenFragment extends PreferenceFragment implements OnSharedPreferenceChangeListener { private OnSharedPreferenceChangeListener mSharedPreferenceChangeListener; static void setPreferenceEnabled(final String prefKey, final boolean enabled, final PreferenceScreen screen) { final Preference preference = screen.findPreference(prefKey); if (preference != null) { preference.setEnabled(enabled); } } static void removePreference(final String prefKey, final PreferenceScreen screen) { final Preference preference = screen.findPreference(prefKey); if (preference != null) { screen.removePreference(preference); } } final void setPreferenceEnabled(final String prefKey, final boolean enabled) { setPreferenceEnabled(prefKey, enabled, getPreferenceScreen()); } final void removePreference(final String prefKey) { removePreference(prefKey, getPreferenceScreen()); } final SharedPreferences getSharedPreferences() {
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/compat/PreferenceManagerCompat.java // public class PreferenceManagerCompat { // public static Context getDeviceContext(Context context) { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { // return context.createDeviceProtectedStorageContext(); // } // // return context; // } // // public static SharedPreferences getDeviceSharedPreferences(Context context) { // return PreferenceManager.getDefaultSharedPreferences(getDeviceContext(context)); // } // } // Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/SubScreenFragment.java import android.app.backup.BackupManager; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Build; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceFragment; import android.preference.PreferenceScreen; import android.util.Log; import rkr.simplekeyboard.inputmethod.compat.PreferenceManagerCompat; /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package rkr.simplekeyboard.inputmethod.latin.settings; /** * A base abstract class for a {@link PreferenceFragment} that implements a nested * {@link PreferenceScreen} of the main preference screen. */ public abstract class SubScreenFragment extends PreferenceFragment implements OnSharedPreferenceChangeListener { private OnSharedPreferenceChangeListener mSharedPreferenceChangeListener; static void setPreferenceEnabled(final String prefKey, final boolean enabled, final PreferenceScreen screen) { final Preference preference = screen.findPreference(prefKey); if (preference != null) { preference.setEnabled(enabled); } } static void removePreference(final String prefKey, final PreferenceScreen screen) { final Preference preference = screen.findPreference(prefKey); if (preference != null) { screen.removePreference(preference); } } final void setPreferenceEnabled(final String prefKey, final boolean enabled) { setPreferenceEnabled(prefKey, enabled, getPreferenceScreen()); } final void removePreference(final String prefKey) { removePreference(prefKey, getPreferenceScreen()); } final SharedPreferences getSharedPreferences() {
return PreferenceManagerCompat.getDeviceSharedPreferences(getActivity());
rkkr/simple-keyboard
app/src/main/java/rkr/simplekeyboard/inputmethod/event/InputTransaction.java
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/SettingsValues.java // public class SettingsValues { // public static final float DEFAULT_SIZE_SCALE = 1.0f; // 100% // // // From resources: // public final SpacingAndPunctuations mSpacingAndPunctuations; // // From configuration: // public final boolean mHasHardwareKeyboard; // public final int mDisplayOrientation; // // From preferences, in the same order as xml/prefs.xml: // public final boolean mAutoCap; // public final boolean mVibrateOn; // public final boolean mSoundOn; // public final boolean mKeyPreviewPopupOn; // public final boolean mShowsLanguageSwitchKey; // public final boolean mImeSwitchEnabled; // public final int mKeyLongpressTimeout; // public final boolean mHideSpecialChars; // public final boolean mShowNumberRow; // public final boolean mSpaceSwipeEnabled; // public final boolean mDeleteSwipeEnabled; // public final boolean mUseMatchingNavbarColor; // // // From the input box // public final InputAttributes mInputAttributes; // // // Deduced settings // public final int mKeypressVibrationDuration; // public final float mKeypressSoundVolume; // public final int mKeyPreviewPopupDismissDelay; // // // Debug settings // public final float mKeyboardHeightScale; // // public SettingsValues(final SharedPreferences prefs, final Resources res, // final InputAttributes inputAttributes) { // // Get the resources // mSpacingAndPunctuations = new SpacingAndPunctuations(res); // // // Store the input attributes // mInputAttributes = inputAttributes; // // // Get the settings preferences // mAutoCap = prefs.getBoolean(Settings.PREF_AUTO_CAP, true); // mVibrateOn = Settings.readVibrationEnabled(prefs, res); // mSoundOn = Settings.readKeypressSoundEnabled(prefs, res); // mKeyPreviewPopupOn = Settings.readKeyPreviewPopupEnabled(prefs, res); // mShowsLanguageSwitchKey = Settings.readShowLanguageSwitchKey(prefs); // mImeSwitchEnabled = Settings.readEnableImeSwitch(prefs); // mHasHardwareKeyboard = Settings.readHasHardwareKeyboard(res.getConfiguration()); // // // Compute other readable settings // mKeyLongpressTimeout = Settings.readKeyLongpressTimeout(prefs, res); // mKeypressVibrationDuration = Settings.readKeypressVibrationDuration(prefs, res); // mKeypressSoundVolume = Settings.readKeypressSoundVolume(prefs, res); // mKeyPreviewPopupDismissDelay = res.getInteger(R.integer.config_key_preview_linger_timeout); // mKeyboardHeightScale = Settings.readKeyboardHeight(prefs, DEFAULT_SIZE_SCALE); // mDisplayOrientation = res.getConfiguration().orientation; // mHideSpecialChars = Settings.readHideSpecialChars(prefs); // mShowNumberRow = Settings.readShowNumberRow(prefs); // mSpaceSwipeEnabled = Settings.readSpaceSwipeEnabled(prefs); // mDeleteSwipeEnabled = Settings.readDeleteSwipeEnabled(prefs); // mUseMatchingNavbarColor = Settings.readUseMatchingNavbarColor(prefs); // } // // public boolean isWordSeparator(final int code) { // return mSpacingAndPunctuations.isWordSeparator(code); // } // // public boolean isLanguageSwitchKeyDisabled() { // return !mShowsLanguageSwitchKey; // } // // public boolean isSameInputType(final EditorInfo editorInfo) { // return mInputAttributes.isSameInputType(editorInfo); // } // // public boolean hasSameOrientation(final Configuration configuration) { // return mDisplayOrientation == configuration.orientation; // } // }
import rkr.simplekeyboard.inputmethod.latin.settings.SettingsValues;
/* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package rkr.simplekeyboard.inputmethod.event; /** * An object encapsulating a single transaction for input. */ public class InputTransaction { // UPDATE_LATER is stronger than UPDATE_NOW. The reason for this is, if we have to update later, // it's because something will change that we can't evaluate now, which means that even if we // re-evaluate now we'll have to do it again later. The only case where that wouldn't apply // would be if we needed to update now to find out the new state right away, but then we // can't do it with this deferred mechanism anyway. public static final int SHIFT_NO_UPDATE = 0; public static final int SHIFT_UPDATE_NOW = 1; public static final int SHIFT_UPDATE_LATER = 2; // Initial conditions
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/SettingsValues.java // public class SettingsValues { // public static final float DEFAULT_SIZE_SCALE = 1.0f; // 100% // // // From resources: // public final SpacingAndPunctuations mSpacingAndPunctuations; // // From configuration: // public final boolean mHasHardwareKeyboard; // public final int mDisplayOrientation; // // From preferences, in the same order as xml/prefs.xml: // public final boolean mAutoCap; // public final boolean mVibrateOn; // public final boolean mSoundOn; // public final boolean mKeyPreviewPopupOn; // public final boolean mShowsLanguageSwitchKey; // public final boolean mImeSwitchEnabled; // public final int mKeyLongpressTimeout; // public final boolean mHideSpecialChars; // public final boolean mShowNumberRow; // public final boolean mSpaceSwipeEnabled; // public final boolean mDeleteSwipeEnabled; // public final boolean mUseMatchingNavbarColor; // // // From the input box // public final InputAttributes mInputAttributes; // // // Deduced settings // public final int mKeypressVibrationDuration; // public final float mKeypressSoundVolume; // public final int mKeyPreviewPopupDismissDelay; // // // Debug settings // public final float mKeyboardHeightScale; // // public SettingsValues(final SharedPreferences prefs, final Resources res, // final InputAttributes inputAttributes) { // // Get the resources // mSpacingAndPunctuations = new SpacingAndPunctuations(res); // // // Store the input attributes // mInputAttributes = inputAttributes; // // // Get the settings preferences // mAutoCap = prefs.getBoolean(Settings.PREF_AUTO_CAP, true); // mVibrateOn = Settings.readVibrationEnabled(prefs, res); // mSoundOn = Settings.readKeypressSoundEnabled(prefs, res); // mKeyPreviewPopupOn = Settings.readKeyPreviewPopupEnabled(prefs, res); // mShowsLanguageSwitchKey = Settings.readShowLanguageSwitchKey(prefs); // mImeSwitchEnabled = Settings.readEnableImeSwitch(prefs); // mHasHardwareKeyboard = Settings.readHasHardwareKeyboard(res.getConfiguration()); // // // Compute other readable settings // mKeyLongpressTimeout = Settings.readKeyLongpressTimeout(prefs, res); // mKeypressVibrationDuration = Settings.readKeypressVibrationDuration(prefs, res); // mKeypressSoundVolume = Settings.readKeypressSoundVolume(prefs, res); // mKeyPreviewPopupDismissDelay = res.getInteger(R.integer.config_key_preview_linger_timeout); // mKeyboardHeightScale = Settings.readKeyboardHeight(prefs, DEFAULT_SIZE_SCALE); // mDisplayOrientation = res.getConfiguration().orientation; // mHideSpecialChars = Settings.readHideSpecialChars(prefs); // mShowNumberRow = Settings.readShowNumberRow(prefs); // mSpaceSwipeEnabled = Settings.readSpaceSwipeEnabled(prefs); // mDeleteSwipeEnabled = Settings.readDeleteSwipeEnabled(prefs); // mUseMatchingNavbarColor = Settings.readUseMatchingNavbarColor(prefs); // } // // public boolean isWordSeparator(final int code) { // return mSpacingAndPunctuations.isWordSeparator(code); // } // // public boolean isLanguageSwitchKeyDisabled() { // return !mShowsLanguageSwitchKey; // } // // public boolean isSameInputType(final EditorInfo editorInfo) { // return mInputAttributes.isSameInputType(editorInfo); // } // // public boolean hasSameOrientation(final Configuration configuration) { // return mDisplayOrientation == configuration.orientation; // } // } // Path: app/src/main/java/rkr/simplekeyboard/inputmethod/event/InputTransaction.java import rkr.simplekeyboard.inputmethod.latin.settings.SettingsValues; /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package rkr.simplekeyboard.inputmethod.event; /** * An object encapsulating a single transaction for input. */ public class InputTransaction { // UPDATE_LATER is stronger than UPDATE_NOW. The reason for this is, if we have to update later, // it's because something will change that we can't evaluate now, which means that even if we // re-evaluate now we'll have to do it again later. The only case where that wouldn't apply // would be if we needed to update now to find out the new state right away, but then we // can't do it with this deferred mechanism anyway. public static final int SHIFT_NO_UPDATE = 0; public static final int SHIFT_UPDATE_NOW = 1; public static final int SHIFT_UPDATE_LATER = 2; // Initial conditions
public final SettingsValues mSettingsValues;
rkkr/simple-keyboard
app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/AppearanceSettingsFragment.java
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/keyboard/KeyboardTheme.java // public final class KeyboardTheme { // private static final String TAG = KeyboardTheme.class.getSimpleName(); // // static final String KEYBOARD_THEME_KEY = "pref_keyboard_theme_20140509"; // // // These should be aligned with Keyboard.themeId and Keyboard.Case.keyboardTheme // // attributes' values in attrs.xml. // public static final int THEME_ID_LIGHT_BORDER = 1; // public static final int THEME_ID_DARK_BORDER = 2; // public static final int THEME_ID_LIGHT = 3; // public static final int THEME_ID_DARK = 4; // public static final int THEME_ID_SYSTEM = 5; // public static final int THEME_ID_SYSTEM_BORDER = 6; // public static final int DEFAULT_THEME_ID = THEME_ID_LIGHT; // // /* package private for testing */ // static final KeyboardTheme[] KEYBOARD_THEMES = { // new KeyboardTheme(THEME_ID_LIGHT, "LXXLight", R.style.KeyboardTheme_LXX_Light), // new KeyboardTheme(THEME_ID_DARK, "LXXDark", R.style.KeyboardTheme_LXX_Dark), // new KeyboardTheme(THEME_ID_LIGHT_BORDER, "LXXLightBorder", R.style.KeyboardTheme_LXX_Light_Border), // new KeyboardTheme(THEME_ID_DARK_BORDER, "LXXDarkBorder", R.style.KeyboardTheme_LXX_Dark_Border), // new KeyboardTheme(THEME_ID_SYSTEM, "LXXSystem", R.style.KeyboardTheme_LXX_System), // new KeyboardTheme(THEME_ID_SYSTEM_BORDER, "LXXSystemBorder", R.style.KeyboardTheme_LXX_System_Border), // }; // // public final int mThemeId; // public final int mStyleId; // public final String mThemeName; // // // Note: The themeId should be aligned with "themeId" attribute of Keyboard style // // in values/themes-<style>.xml. // private KeyboardTheme(final int themeId, final String themeName, final int styleId) { // mThemeId = themeId; // mThemeName = themeName; // mStyleId = styleId; // } // // @Override // public boolean equals(final Object o) { // if (o == this) return true; // return (o instanceof KeyboardTheme) && ((KeyboardTheme)o).mThemeId == mThemeId; // } // // @Override // public int hashCode() { // return mThemeId; // } // // /* package private for testing */ // static KeyboardTheme searchKeyboardThemeById(final int themeId) { // // TODO: This search algorithm isn't optimal if there are many themes. // for (final KeyboardTheme theme : KEYBOARD_THEMES) { // if (theme.mThemeId == themeId) { // return theme; // } // } // return null; // } // // /* package private for testing */ // static KeyboardTheme getDefaultKeyboardTheme() { // return searchKeyboardThemeById(DEFAULT_THEME_ID); // } // // public static String getKeyboardThemeName(final int themeId) { // final KeyboardTheme theme = searchKeyboardThemeById(themeId); // Log.i("Getting theme ID", Integer.toString(themeId)); // return theme.mThemeName; // } // // public static void saveKeyboardThemeId(final int themeId, final SharedPreferences prefs) { // prefs.edit().putString(KEYBOARD_THEME_KEY, Integer.toString(themeId)).apply(); // } // // public static KeyboardTheme getKeyboardTheme(final Context context) { // final SharedPreferences prefs = PreferenceManagerCompat.getDeviceSharedPreferences(context); // return getKeyboardTheme(prefs); // } // // public static KeyboardTheme getKeyboardTheme(final SharedPreferences prefs) { // final String themeIdString = prefs.getString(KEYBOARD_THEME_KEY, null); // if (themeIdString == null) { // return searchKeyboardThemeById(THEME_ID_LIGHT); // } // try { // final int themeId = Integer.parseInt(themeIdString); // final KeyboardTheme theme = searchKeyboardThemeById(themeId); // if (theme != null) { // return theme; // } // Log.w(TAG, "Unknown keyboard theme in preference: " + themeIdString); // } catch (final NumberFormatException e) { // Log.w(TAG, "Illegal keyboard theme in preference: " + themeIdString, e); // } // // Remove preference that contains unknown or illegal theme id. // prefs.edit().remove(KEYBOARD_THEME_KEY).remove(Settings.PREF_KEYBOARD_COLOR).apply(); // return getDefaultKeyboardTheme(); // } // }
import android.content.Context; import android.content.SharedPreferences; import android.content.res.Resources; import android.os.Build; import android.os.Bundle; import rkr.simplekeyboard.inputmethod.R; import rkr.simplekeyboard.inputmethod.keyboard.KeyboardTheme;
/* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package rkr.simplekeyboard.inputmethod.latin.settings; /** * "Appearance" settings sub screen. */ public final class AppearanceSettingsFragment extends SubScreenFragment { @Override public void onCreate(final Bundle icicle) { super.onCreate(icicle); addPreferencesFromResource(R.xml.prefs_screen_appearance); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) { removePreference(Settings.PREF_MATCHING_NAVBAR_COLOR); } setupKeyboardHeightSettings(); setupKeyboardColorSettings(); } @Override public void onResume() { super.onResume(); refreshSettings(); } @Override public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) { refreshSettings(); } private void refreshSettings() { ThemeSettingsFragment.updateKeyboardThemeSummary(findPreference(Settings.SCREEN_THEME)); final SharedPreferences prefs = getSharedPreferences();
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/keyboard/KeyboardTheme.java // public final class KeyboardTheme { // private static final String TAG = KeyboardTheme.class.getSimpleName(); // // static final String KEYBOARD_THEME_KEY = "pref_keyboard_theme_20140509"; // // // These should be aligned with Keyboard.themeId and Keyboard.Case.keyboardTheme // // attributes' values in attrs.xml. // public static final int THEME_ID_LIGHT_BORDER = 1; // public static final int THEME_ID_DARK_BORDER = 2; // public static final int THEME_ID_LIGHT = 3; // public static final int THEME_ID_DARK = 4; // public static final int THEME_ID_SYSTEM = 5; // public static final int THEME_ID_SYSTEM_BORDER = 6; // public static final int DEFAULT_THEME_ID = THEME_ID_LIGHT; // // /* package private for testing */ // static final KeyboardTheme[] KEYBOARD_THEMES = { // new KeyboardTheme(THEME_ID_LIGHT, "LXXLight", R.style.KeyboardTheme_LXX_Light), // new KeyboardTheme(THEME_ID_DARK, "LXXDark", R.style.KeyboardTheme_LXX_Dark), // new KeyboardTheme(THEME_ID_LIGHT_BORDER, "LXXLightBorder", R.style.KeyboardTheme_LXX_Light_Border), // new KeyboardTheme(THEME_ID_DARK_BORDER, "LXXDarkBorder", R.style.KeyboardTheme_LXX_Dark_Border), // new KeyboardTheme(THEME_ID_SYSTEM, "LXXSystem", R.style.KeyboardTheme_LXX_System), // new KeyboardTheme(THEME_ID_SYSTEM_BORDER, "LXXSystemBorder", R.style.KeyboardTheme_LXX_System_Border), // }; // // public final int mThemeId; // public final int mStyleId; // public final String mThemeName; // // // Note: The themeId should be aligned with "themeId" attribute of Keyboard style // // in values/themes-<style>.xml. // private KeyboardTheme(final int themeId, final String themeName, final int styleId) { // mThemeId = themeId; // mThemeName = themeName; // mStyleId = styleId; // } // // @Override // public boolean equals(final Object o) { // if (o == this) return true; // return (o instanceof KeyboardTheme) && ((KeyboardTheme)o).mThemeId == mThemeId; // } // // @Override // public int hashCode() { // return mThemeId; // } // // /* package private for testing */ // static KeyboardTheme searchKeyboardThemeById(final int themeId) { // // TODO: This search algorithm isn't optimal if there are many themes. // for (final KeyboardTheme theme : KEYBOARD_THEMES) { // if (theme.mThemeId == themeId) { // return theme; // } // } // return null; // } // // /* package private for testing */ // static KeyboardTheme getDefaultKeyboardTheme() { // return searchKeyboardThemeById(DEFAULT_THEME_ID); // } // // public static String getKeyboardThemeName(final int themeId) { // final KeyboardTheme theme = searchKeyboardThemeById(themeId); // Log.i("Getting theme ID", Integer.toString(themeId)); // return theme.mThemeName; // } // // public static void saveKeyboardThemeId(final int themeId, final SharedPreferences prefs) { // prefs.edit().putString(KEYBOARD_THEME_KEY, Integer.toString(themeId)).apply(); // } // // public static KeyboardTheme getKeyboardTheme(final Context context) { // final SharedPreferences prefs = PreferenceManagerCompat.getDeviceSharedPreferences(context); // return getKeyboardTheme(prefs); // } // // public static KeyboardTheme getKeyboardTheme(final SharedPreferences prefs) { // final String themeIdString = prefs.getString(KEYBOARD_THEME_KEY, null); // if (themeIdString == null) { // return searchKeyboardThemeById(THEME_ID_LIGHT); // } // try { // final int themeId = Integer.parseInt(themeIdString); // final KeyboardTheme theme = searchKeyboardThemeById(themeId); // if (theme != null) { // return theme; // } // Log.w(TAG, "Unknown keyboard theme in preference: " + themeIdString); // } catch (final NumberFormatException e) { // Log.w(TAG, "Illegal keyboard theme in preference: " + themeIdString, e); // } // // Remove preference that contains unknown or illegal theme id. // prefs.edit().remove(KEYBOARD_THEME_KEY).remove(Settings.PREF_KEYBOARD_COLOR).apply(); // return getDefaultKeyboardTheme(); // } // } // Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/AppearanceSettingsFragment.java import android.content.Context; import android.content.SharedPreferences; import android.content.res.Resources; import android.os.Build; import android.os.Bundle; import rkr.simplekeyboard.inputmethod.R; import rkr.simplekeyboard.inputmethod.keyboard.KeyboardTheme; /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package rkr.simplekeyboard.inputmethod.latin.settings; /** * "Appearance" settings sub screen. */ public final class AppearanceSettingsFragment extends SubScreenFragment { @Override public void onCreate(final Bundle icicle) { super.onCreate(icicle); addPreferencesFromResource(R.xml.prefs_screen_appearance); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) { removePreference(Settings.PREF_MATCHING_NAVBAR_COLOR); } setupKeyboardHeightSettings(); setupKeyboardColorSettings(); } @Override public void onResume() { super.onResume(); refreshSettings(); } @Override public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) { refreshSettings(); } private void refreshSettings() { ThemeSettingsFragment.updateKeyboardThemeSummary(findPreference(Settings.SCREEN_THEME)); final SharedPreferences prefs = getSharedPreferences();
final KeyboardTheme theme = KeyboardTheme.getKeyboardTheme(prefs);
rkkr/simple-keyboard
app/src/main/java/rkr/simplekeyboard/inputmethod/keyboard/internal/KeyStylesSet.java
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/utils/XmlParseUtils.java // public final class XmlParseUtils { // private XmlParseUtils() { // // This utility class is not publicly instantiable. // } // // @SuppressWarnings("serial") // public static class ParseException extends XmlPullParserException { // public ParseException(final String msg) { // super(msg); // } // public ParseException(final String msg, final XmlPullParser parser) { // super(msg + " at " + parser.getPositionDescription()); // } // } // // @SuppressWarnings("serial") // public static final class IllegalStartTag extends ParseException { // public IllegalStartTag(final XmlPullParser parser, final String tag, final String parent) { // super("Illegal start tag " + tag + " in " + parent, parser); // } // } // // @SuppressWarnings("serial") // public static final class IllegalEndTag extends ParseException { // public IllegalEndTag(final XmlPullParser parser, final String tag, final String parent) { // super("Illegal end tag " + tag + " in " + parent, parser); // } // } // // @SuppressWarnings("serial") // public static final class IllegalAttribute extends ParseException { // public IllegalAttribute(final XmlPullParser parser, final String tag, // final String attribute) { // super("Tag " + tag + " has illegal attribute " + attribute, parser); // } // } // // @SuppressWarnings("serial") // public static final class NonEmptyTag extends ParseException{ // public NonEmptyTag(final XmlPullParser parser, final String tag) { // super(tag + " must be empty tag", parser); // } // } // // public static void checkEndTag(final String tag, final XmlPullParser parser) // throws XmlPullParserException, IOException { // if (parser.next() == XmlPullParser.END_TAG && tag.equals(parser.getName())) // return; // throw new NonEmptyTag(parser, tag); // } // // public static void checkAttributeExists(final TypedArray attr, final int attrId, // final String attrName, final String tag, final XmlPullParser parser) // throws XmlPullParserException { // if (attr.hasValue(attrId)) { // return; // } // throw new ParseException( // "No " + attrName + " attribute found in <" + tag + "/>", parser); // } // }
import android.content.res.TypedArray; import android.util.Log; import android.util.SparseArray; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import java.util.Arrays; import java.util.HashMap; import rkr.simplekeyboard.inputmethod.R; import rkr.simplekeyboard.inputmethod.latin.utils.XmlParseUtils;
if (a.hasValue(index)) { mStyleAttributes.put(index, parseString(a, index)); } } private void readInt(final TypedArray a, final int index) { if (a.hasValue(index)) { mStyleAttributes.put(index, a.getInt(index, 0)); } } private void readFlags(final TypedArray a, final int index) { if (a.hasValue(index)) { final Integer value = (Integer)mStyleAttributes.get(index); final int styleFlags = value != null ? value : 0; mStyleAttributes.put(index, a.getInt(index, 0) | styleFlags); } } private void readStringArray(final TypedArray a, final int index) { if (a.hasValue(index)) { mStyleAttributes.put(index, parseStringArray(a, index)); } } } public void parseKeyStyleAttributes(final TypedArray keyStyleAttr, final TypedArray keyAttrs, final XmlPullParser parser) throws XmlPullParserException { final String styleName = keyStyleAttr.getString(R.styleable.Keyboard_KeyStyle_styleName); if (styleName == null) {
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/utils/XmlParseUtils.java // public final class XmlParseUtils { // private XmlParseUtils() { // // This utility class is not publicly instantiable. // } // // @SuppressWarnings("serial") // public static class ParseException extends XmlPullParserException { // public ParseException(final String msg) { // super(msg); // } // public ParseException(final String msg, final XmlPullParser parser) { // super(msg + " at " + parser.getPositionDescription()); // } // } // // @SuppressWarnings("serial") // public static final class IllegalStartTag extends ParseException { // public IllegalStartTag(final XmlPullParser parser, final String tag, final String parent) { // super("Illegal start tag " + tag + " in " + parent, parser); // } // } // // @SuppressWarnings("serial") // public static final class IllegalEndTag extends ParseException { // public IllegalEndTag(final XmlPullParser parser, final String tag, final String parent) { // super("Illegal end tag " + tag + " in " + parent, parser); // } // } // // @SuppressWarnings("serial") // public static final class IllegalAttribute extends ParseException { // public IllegalAttribute(final XmlPullParser parser, final String tag, // final String attribute) { // super("Tag " + tag + " has illegal attribute " + attribute, parser); // } // } // // @SuppressWarnings("serial") // public static final class NonEmptyTag extends ParseException{ // public NonEmptyTag(final XmlPullParser parser, final String tag) { // super(tag + " must be empty tag", parser); // } // } // // public static void checkEndTag(final String tag, final XmlPullParser parser) // throws XmlPullParserException, IOException { // if (parser.next() == XmlPullParser.END_TAG && tag.equals(parser.getName())) // return; // throw new NonEmptyTag(parser, tag); // } // // public static void checkAttributeExists(final TypedArray attr, final int attrId, // final String attrName, final String tag, final XmlPullParser parser) // throws XmlPullParserException { // if (attr.hasValue(attrId)) { // return; // } // throw new ParseException( // "No " + attrName + " attribute found in <" + tag + "/>", parser); // } // } // Path: app/src/main/java/rkr/simplekeyboard/inputmethod/keyboard/internal/KeyStylesSet.java import android.content.res.TypedArray; import android.util.Log; import android.util.SparseArray; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import java.util.Arrays; import java.util.HashMap; import rkr.simplekeyboard.inputmethod.R; import rkr.simplekeyboard.inputmethod.latin.utils.XmlParseUtils; if (a.hasValue(index)) { mStyleAttributes.put(index, parseString(a, index)); } } private void readInt(final TypedArray a, final int index) { if (a.hasValue(index)) { mStyleAttributes.put(index, a.getInt(index, 0)); } } private void readFlags(final TypedArray a, final int index) { if (a.hasValue(index)) { final Integer value = (Integer)mStyleAttributes.get(index); final int styleFlags = value != null ? value : 0; mStyleAttributes.put(index, a.getInt(index, 0) | styleFlags); } } private void readStringArray(final TypedArray a, final int index) { if (a.hasValue(index)) { mStyleAttributes.put(index, parseStringArray(a, index)); } } } public void parseKeyStyleAttributes(final TypedArray keyStyleAttr, final TypedArray keyAttrs, final XmlPullParser parser) throws XmlPullParserException { final String styleName = keyStyleAttr.getString(R.styleable.Keyboard_KeyStyle_styleName); if (styleName == null) {
throw new XmlParseUtils.ParseException(
rkkr/simple-keyboard
app/src/main/java/rkr/simplekeyboard/inputmethod/latin/utils/DebugLogUtils.java
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/define/DebugFlags.java // public final class DebugFlags { // public static final boolean DEBUG_ENABLED = false; // // private DebugFlags() { // // This class is not publicly instantiable. // } // // @SuppressWarnings("unused") // public static void init(final SharedPreferences prefs) { // } // }
import android.util.Log; import rkr.simplekeyboard.inputmethod.latin.define.DebugFlags;
/* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package rkr.simplekeyboard.inputmethod.latin.utils; /** * A class for logging and debugging utility methods. */ public final class DebugLogUtils { private final static String TAG = DebugLogUtils.class.getSimpleName();
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/define/DebugFlags.java // public final class DebugFlags { // public static final boolean DEBUG_ENABLED = false; // // private DebugFlags() { // // This class is not publicly instantiable. // } // // @SuppressWarnings("unused") // public static void init(final SharedPreferences prefs) { // } // } // Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/utils/DebugLogUtils.java import android.util.Log; import rkr.simplekeyboard.inputmethod.latin.define.DebugFlags; /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package rkr.simplekeyboard.inputmethod.latin.utils; /** * A class for logging and debugging utility methods. */ public final class DebugLogUtils { private final static String TAG = DebugLogUtils.class.getSimpleName();
private final static boolean sDBG = DebugFlags.DEBUG_ENABLED;
rkkr/simple-keyboard
app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/KeyPressSettingsFragment.java
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/AudioAndHapticFeedbackManager.java // public final class AudioAndHapticFeedbackManager { // private AudioManager mAudioManager; // private Vibrator mVibrator; // // private SettingsValues mSettingsValues; // private boolean mSoundOn; // // private static final AudioAndHapticFeedbackManager sInstance = // new AudioAndHapticFeedbackManager(); // // public static AudioAndHapticFeedbackManager getInstance() { // return sInstance; // } // // private AudioAndHapticFeedbackManager() { // // Intentional empty constructor for singleton. // } // // public static void init(final Context context) { // sInstance.initInternal(context); // } // // private void initInternal(final Context context) { // mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); // mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); // } // // public boolean hasVibrator() { // return mVibrator != null && mVibrator.hasVibrator(); // } // // public void vibrate(final long milliseconds) { // if (mVibrator == null) { // return; // } // mVibrator.vibrate(milliseconds); // } // // private boolean reevaluateIfSoundIsOn() { // if (mSettingsValues == null || !mSettingsValues.mSoundOn || mAudioManager == null) { // return false; // } // return mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL; // } // // public void performAudioFeedback(final int code) { // // if mAudioManager is null, we can't play a sound anyway, so return // if (mAudioManager == null) { // return; // } // if (!mSoundOn) { // return; // } // final int sound; // switch (code) { // case Constants.CODE_DELETE: // sound = AudioManager.FX_KEYPRESS_DELETE; // break; // case Constants.CODE_ENTER: // sound = AudioManager.FX_KEYPRESS_RETURN; // break; // case Constants.CODE_SPACE: // sound = AudioManager.FX_KEYPRESS_SPACEBAR; // break; // default: // sound = AudioManager.FX_KEYPRESS_STANDARD; // break; // } // mAudioManager.playSoundEffect(sound, mSettingsValues.mKeypressSoundVolume); // } // // public void performHapticFeedback(final View viewToPerformHapticFeedbackOn) { // if (!mSettingsValues.mVibrateOn) { // return; // } // if (mSettingsValues.mKeypressVibrationDuration >= 0) { // vibrate(mSettingsValues.mKeypressVibrationDuration); // return; // } // // Go ahead with the system default // if (viewToPerformHapticFeedbackOn != null) { // viewToPerformHapticFeedbackOn.performHapticFeedback( // HapticFeedbackConstants.KEYBOARD_TAP, // HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); // } // } // // public void onSettingsChanged(final SettingsValues settingsValues) { // mSettingsValues = settingsValues; // mSoundOn = reevaluateIfSoundIsOn(); // } // // public void onRingerModeChanged() { // mSoundOn = reevaluateIfSoundIsOn(); // } // }
import android.content.Context; import android.content.SharedPreferences; import android.content.res.Resources; import android.media.AudioManager; import android.os.Bundle; import rkr.simplekeyboard.inputmethod.R; import rkr.simplekeyboard.inputmethod.latin.AudioAndHapticFeedbackManager;
/* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package rkr.simplekeyboard.inputmethod.latin.settings; /** * "Preferences" settings sub screen. * * This settings sub screen handles the following input preferences. * - Vibrate on keypress * - Keypress vibration duration * - Sound on keypress * - Keypress sound volume * - Popup on keypress * - Key long press delay */ public final class KeyPressSettingsFragment extends SubScreenFragment { @Override public void onCreate(final Bundle icicle) { super.onCreate(icicle); addPreferencesFromResource(R.xml.prefs_screen_key_press); final Context context = getActivity(); // When we are called from the Settings application but we are not already running, some // singleton and utility classes may not have been initialized. We have to call // initialization method of these classes here. See {@link LatinIME#onCreate()}.
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/AudioAndHapticFeedbackManager.java // public final class AudioAndHapticFeedbackManager { // private AudioManager mAudioManager; // private Vibrator mVibrator; // // private SettingsValues mSettingsValues; // private boolean mSoundOn; // // private static final AudioAndHapticFeedbackManager sInstance = // new AudioAndHapticFeedbackManager(); // // public static AudioAndHapticFeedbackManager getInstance() { // return sInstance; // } // // private AudioAndHapticFeedbackManager() { // // Intentional empty constructor for singleton. // } // // public static void init(final Context context) { // sInstance.initInternal(context); // } // // private void initInternal(final Context context) { // mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); // mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); // } // // public boolean hasVibrator() { // return mVibrator != null && mVibrator.hasVibrator(); // } // // public void vibrate(final long milliseconds) { // if (mVibrator == null) { // return; // } // mVibrator.vibrate(milliseconds); // } // // private boolean reevaluateIfSoundIsOn() { // if (mSettingsValues == null || !mSettingsValues.mSoundOn || mAudioManager == null) { // return false; // } // return mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL; // } // // public void performAudioFeedback(final int code) { // // if mAudioManager is null, we can't play a sound anyway, so return // if (mAudioManager == null) { // return; // } // if (!mSoundOn) { // return; // } // final int sound; // switch (code) { // case Constants.CODE_DELETE: // sound = AudioManager.FX_KEYPRESS_DELETE; // break; // case Constants.CODE_ENTER: // sound = AudioManager.FX_KEYPRESS_RETURN; // break; // case Constants.CODE_SPACE: // sound = AudioManager.FX_KEYPRESS_SPACEBAR; // break; // default: // sound = AudioManager.FX_KEYPRESS_STANDARD; // break; // } // mAudioManager.playSoundEffect(sound, mSettingsValues.mKeypressSoundVolume); // } // // public void performHapticFeedback(final View viewToPerformHapticFeedbackOn) { // if (!mSettingsValues.mVibrateOn) { // return; // } // if (mSettingsValues.mKeypressVibrationDuration >= 0) { // vibrate(mSettingsValues.mKeypressVibrationDuration); // return; // } // // Go ahead with the system default // if (viewToPerformHapticFeedbackOn != null) { // viewToPerformHapticFeedbackOn.performHapticFeedback( // HapticFeedbackConstants.KEYBOARD_TAP, // HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); // } // } // // public void onSettingsChanged(final SettingsValues settingsValues) { // mSettingsValues = settingsValues; // mSoundOn = reevaluateIfSoundIsOn(); // } // // public void onRingerModeChanged() { // mSoundOn = reevaluateIfSoundIsOn(); // } // } // Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/KeyPressSettingsFragment.java import android.content.Context; import android.content.SharedPreferences; import android.content.res.Resources; import android.media.AudioManager; import android.os.Bundle; import rkr.simplekeyboard.inputmethod.R; import rkr.simplekeyboard.inputmethod.latin.AudioAndHapticFeedbackManager; /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package rkr.simplekeyboard.inputmethod.latin.settings; /** * "Preferences" settings sub screen. * * This settings sub screen handles the following input preferences. * - Vibrate on keypress * - Keypress vibration duration * - Sound on keypress * - Keypress sound volume * - Popup on keypress * - Key long press delay */ public final class KeyPressSettingsFragment extends SubScreenFragment { @Override public void onCreate(final Bundle icicle) { super.onCreate(icicle); addPreferencesFromResource(R.xml.prefs_screen_key_press); final Context context = getActivity(); // When we are called from the Settings application but we are not already running, some // singleton and utility classes may not have been initialized. We have to call // initialization method of these classes here. See {@link LatinIME#onCreate()}.
AudioAndHapticFeedbackManager.init(context);
rkkr/simple-keyboard
app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/SettingsFragment.java
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/utils/ApplicationUtils.java // public final class ApplicationUtils { // private static final String TAG = ApplicationUtils.class.getSimpleName(); // // private ApplicationUtils() { // // This utility class is not publicly instantiable. // } // // public static int getActivityTitleResId(final Context context, // final Class<? extends Activity> cls) { // final ComponentName cn = new ComponentName(context, cls); // try { // final ActivityInfo ai = context.getPackageManager().getActivityInfo(cn, 0); // if (ai != null) { // return ai.labelRes; // } // } catch (final NameNotFoundException e) { // Log.e(TAG, "Failed to get settings activity title res id.", e); // } // return 0; // } // // /** // * A utility method to get the application's PackageInfo.versionName // * @return the application's PackageInfo.versionName // */ // public static String getVersionName(final Context context) { // try { // if (context == null) { // return ""; // } // final String packageName = context.getPackageName(); // final PackageInfo info = context.getPackageManager().getPackageInfo(packageName, 0); // return info.versionName; // } catch (final NameNotFoundException e) { // Log.e(TAG, "Could not find version info.", e); // } // return ""; // } // // /** // * A utility method to get the application's PackageInfo.versionCode // * @return the application's PackageInfo.versionCode // */ // public static int getVersionCode(final Context context) { // try { // if (context == null) { // return 0; // } // final String packageName = context.getPackageName(); // final PackageInfo info = context.getPackageManager().getPackageInfo(packageName, 0); // return info.versionCode; // } catch (final NameNotFoundException e) { // Log.e(TAG, "Could not find version info.", e); // } // return 0; // } // }
import android.os.Bundle; import android.preference.PreferenceScreen; import rkr.simplekeyboard.inputmethod.R; import rkr.simplekeyboard.inputmethod.latin.utils.ApplicationUtils;
/* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package rkr.simplekeyboard.inputmethod.latin.settings; public final class SettingsFragment extends InputMethodSettingsFragment { @Override public void onCreate(final Bundle icicle) { super.onCreate(icicle); setHasOptionsMenu(true); addPreferencesFromResource(R.xml.prefs); final PreferenceScreen preferenceScreen = getPreferenceScreen(); preferenceScreen.setTitle(
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/utils/ApplicationUtils.java // public final class ApplicationUtils { // private static final String TAG = ApplicationUtils.class.getSimpleName(); // // private ApplicationUtils() { // // This utility class is not publicly instantiable. // } // // public static int getActivityTitleResId(final Context context, // final Class<? extends Activity> cls) { // final ComponentName cn = new ComponentName(context, cls); // try { // final ActivityInfo ai = context.getPackageManager().getActivityInfo(cn, 0); // if (ai != null) { // return ai.labelRes; // } // } catch (final NameNotFoundException e) { // Log.e(TAG, "Failed to get settings activity title res id.", e); // } // return 0; // } // // /** // * A utility method to get the application's PackageInfo.versionName // * @return the application's PackageInfo.versionName // */ // public static String getVersionName(final Context context) { // try { // if (context == null) { // return ""; // } // final String packageName = context.getPackageName(); // final PackageInfo info = context.getPackageManager().getPackageInfo(packageName, 0); // return info.versionName; // } catch (final NameNotFoundException e) { // Log.e(TAG, "Could not find version info.", e); // } // return ""; // } // // /** // * A utility method to get the application's PackageInfo.versionCode // * @return the application's PackageInfo.versionCode // */ // public static int getVersionCode(final Context context) { // try { // if (context == null) { // return 0; // } // final String packageName = context.getPackageName(); // final PackageInfo info = context.getPackageManager().getPackageInfo(packageName, 0); // return info.versionCode; // } catch (final NameNotFoundException e) { // Log.e(TAG, "Could not find version info.", e); // } // return 0; // } // } // Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/SettingsFragment.java import android.os.Bundle; import android.preference.PreferenceScreen; import rkr.simplekeyboard.inputmethod.R; import rkr.simplekeyboard.inputmethod.latin.utils.ApplicationUtils; /* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package rkr.simplekeyboard.inputmethod.latin.settings; public final class SettingsFragment extends InputMethodSettingsFragment { @Override public void onCreate(final Bundle icicle) { super.onCreate(icicle); setHasOptionsMenu(true); addPreferencesFromResource(R.xml.prefs); final PreferenceScreen preferenceScreen = getPreferenceScreen(); preferenceScreen.setTitle(
ApplicationUtils.getActivityTitleResId(getActivity(), SettingsActivity.class));
rkkr/simple-keyboard
app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/InputMethodSettingsFragment.java
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/compat/PreferenceManagerCompat.java // public class PreferenceManagerCompat { // public static Context getDeviceContext(Context context) { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { // return context.createDeviceProtectedStorageContext(); // } // // return context; // } // // public static SharedPreferences getDeviceSharedPreferences(Context context) { // return PreferenceManager.getDefaultSharedPreferences(getDeviceContext(context)); // } // }
import android.content.Context; import android.os.Bundle; import android.preference.PreferenceFragment; import rkr.simplekeyboard.inputmethod.compat.PreferenceManagerCompat;
/* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package rkr.simplekeyboard.inputmethod.latin.settings; /** * This is a helper class for an IME's settings preference fragment. It's recommended for every * IME to have its own settings preference fragment which inherits this class. */ public abstract class InputMethodSettingsFragment extends PreferenceFragment { private final InputMethodSettingsImpl mSettings = new InputMethodSettingsImpl(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Context context = getActivity(); setPreferenceScreen(getPreferenceManager().createPreferenceScreen(
// Path: app/src/main/java/rkr/simplekeyboard/inputmethod/compat/PreferenceManagerCompat.java // public class PreferenceManagerCompat { // public static Context getDeviceContext(Context context) { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { // return context.createDeviceProtectedStorageContext(); // } // // return context; // } // // public static SharedPreferences getDeviceSharedPreferences(Context context) { // return PreferenceManager.getDefaultSharedPreferences(getDeviceContext(context)); // } // } // Path: app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/InputMethodSettingsFragment.java import android.content.Context; import android.os.Bundle; import android.preference.PreferenceFragment; import rkr.simplekeyboard.inputmethod.compat.PreferenceManagerCompat; /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package rkr.simplekeyboard.inputmethod.latin.settings; /** * This is a helper class for an IME's settings preference fragment. It's recommended for every * IME to have its own settings preference fragment which inherits this class. */ public abstract class InputMethodSettingsFragment extends PreferenceFragment { private final InputMethodSettingsImpl mSettings = new InputMethodSettingsImpl(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Context context = getActivity(); setPreferenceScreen(getPreferenceManager().createPreferenceScreen(
PreferenceManagerCompat.getDeviceContext(context)));
andrus/bootique-graphql
bootique-graphql/src/test/java/org/objectstyle/graphql/it/fixture/cayenne/auto/_E1.java
// Path: bootique-graphql/src/test/java/org/objectstyle/graphql/it/fixture/cayenne/E2.java // public class E2 extends _E2 { // // private static final long serialVersionUID = 1L; // // }
import java.util.List; import org.apache.cayenne.CayenneDataObject; import org.apache.cayenne.exp.Property; import org.objectstyle.graphql.it.fixture.cayenne.E2;
package org.objectstyle.graphql.it.fixture.cayenne.auto; /** * Class _E1 was generated by Cayenne. * It is probably a good idea to avoid changing this class manually, * since it may be overwritten next time code is regenerated. * If you need to make any customizations, please use subclass. */ public abstract class _E1 extends CayenneDataObject { private static final long serialVersionUID = 1L; public static final String ID_PK_COLUMN = "id"; public static final Property<String> NAME = new Property<String>("name");
// Path: bootique-graphql/src/test/java/org/objectstyle/graphql/it/fixture/cayenne/E2.java // public class E2 extends _E2 { // // private static final long serialVersionUID = 1L; // // } // Path: bootique-graphql/src/test/java/org/objectstyle/graphql/it/fixture/cayenne/auto/_E1.java import java.util.List; import org.apache.cayenne.CayenneDataObject; import org.apache.cayenne.exp.Property; import org.objectstyle.graphql.it.fixture.cayenne.E2; package org.objectstyle.graphql.it.fixture.cayenne.auto; /** * Class _E1 was generated by Cayenne. * It is probably a good idea to avoid changing this class manually, * since it may be overwritten next time code is regenerated. * If you need to make any customizations, please use subclass. */ public abstract class _E1 extends CayenneDataObject { private static final long serialVersionUID = 1L; public static final String ID_PK_COLUMN = "id"; public static final Property<String> NAME = new Property<String>("name");
public static final Property<List<E2>> E2S = new Property<List<E2>>("e2s");
andrus/bootique-graphql
bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/provider/BQGraphQLRestExceptionMapper.java
// Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/BQGraphQLRestException.java // public class BQGraphQLRestException extends RuntimeException { // // private static final long serialVersionUID = -1228276457093874409L; // // private Status status; // // public BQGraphQLRestException() { // this(Status.INTERNAL_SERVER_ERROR); // } // // public BQGraphQLRestException(Status status) { // this(status, null, null); // } // // public BQGraphQLRestException(Status status, String message) { // this(status, message, null); // } // // public BQGraphQLRestException(Status status, String message, Throwable cause) { // super(message, cause); // this.status = status; // } // // public Status getStatus() { // return status; // } // } // // Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/MessageResponse.java // public class MessageResponse { // // private String message; // // public MessageResponse(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // }
import javax.inject.Singleton; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.Provider; import org.objectstyle.bootique.graphql.jaxrs.BQGraphQLRestException; import org.objectstyle.bootique.graphql.jaxrs.MessageResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
package org.objectstyle.bootique.graphql.jaxrs.provider; @Provider @Singleton
// Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/BQGraphQLRestException.java // public class BQGraphQLRestException extends RuntimeException { // // private static final long serialVersionUID = -1228276457093874409L; // // private Status status; // // public BQGraphQLRestException() { // this(Status.INTERNAL_SERVER_ERROR); // } // // public BQGraphQLRestException(Status status) { // this(status, null, null); // } // // public BQGraphQLRestException(Status status, String message) { // this(status, message, null); // } // // public BQGraphQLRestException(Status status, String message, Throwable cause) { // super(message, cause); // this.status = status; // } // // public Status getStatus() { // return status; // } // } // // Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/MessageResponse.java // public class MessageResponse { // // private String message; // // public MessageResponse(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // } // Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/provider/BQGraphQLRestExceptionMapper.java import javax.inject.Singleton; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.Provider; import org.objectstyle.bootique.graphql.jaxrs.BQGraphQLRestException; import org.objectstyle.bootique.graphql.jaxrs.MessageResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; package org.objectstyle.bootique.graphql.jaxrs.provider; @Provider @Singleton
public class BQGraphQLRestExceptionMapper implements ExceptionMapper<BQGraphQLRestException> {
andrus/bootique-graphql
bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/provider/BQGraphQLRestExceptionMapper.java
// Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/BQGraphQLRestException.java // public class BQGraphQLRestException extends RuntimeException { // // private static final long serialVersionUID = -1228276457093874409L; // // private Status status; // // public BQGraphQLRestException() { // this(Status.INTERNAL_SERVER_ERROR); // } // // public BQGraphQLRestException(Status status) { // this(status, null, null); // } // // public BQGraphQLRestException(Status status, String message) { // this(status, message, null); // } // // public BQGraphQLRestException(Status status, String message, Throwable cause) { // super(message, cause); // this.status = status; // } // // public Status getStatus() { // return status; // } // } // // Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/MessageResponse.java // public class MessageResponse { // // private String message; // // public MessageResponse(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // }
import javax.inject.Singleton; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.Provider; import org.objectstyle.bootique.graphql.jaxrs.BQGraphQLRestException; import org.objectstyle.bootique.graphql.jaxrs.MessageResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
package org.objectstyle.bootique.graphql.jaxrs.provider; @Provider @Singleton public class BQGraphQLRestExceptionMapper implements ExceptionMapper<BQGraphQLRestException> { private static final Logger LOGGER = LoggerFactory.getLogger(BQGraphQLRestExceptionMapper.class); @Override public Response toResponse(BQGraphQLRestException exception) { String message = exception.getMessage(); Status status = exception.getStatus(); if (LOGGER.isInfoEnabled()) { StringBuilder log = new StringBuilder(); log.append(status.getStatusCode()).append(" ").append(status.getReasonPhrase()); if (message != null) { log.append(" (").append(message).append(")"); } if (exception.getCause() != null && exception.getCause().getMessage() != null) { log.append(" [cause: ").append(exception.getCause().getMessage()).append("]"); } // include stack trace in debug mode... if (LOGGER.isDebugEnabled()) { LOGGER.debug(log.toString(), exception); } else { LOGGER.info(log.toString()); } }
// Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/BQGraphQLRestException.java // public class BQGraphQLRestException extends RuntimeException { // // private static final long serialVersionUID = -1228276457093874409L; // // private Status status; // // public BQGraphQLRestException() { // this(Status.INTERNAL_SERVER_ERROR); // } // // public BQGraphQLRestException(Status status) { // this(status, null, null); // } // // public BQGraphQLRestException(Status status, String message) { // this(status, message, null); // } // // public BQGraphQLRestException(Status status, String message, Throwable cause) { // super(message, cause); // this.status = status; // } // // public Status getStatus() { // return status; // } // } // // Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/MessageResponse.java // public class MessageResponse { // // private String message; // // public MessageResponse(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // } // Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/provider/BQGraphQLRestExceptionMapper.java import javax.inject.Singleton; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.Provider; import org.objectstyle.bootique.graphql.jaxrs.BQGraphQLRestException; import org.objectstyle.bootique.graphql.jaxrs.MessageResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; package org.objectstyle.bootique.graphql.jaxrs.provider; @Provider @Singleton public class BQGraphQLRestExceptionMapper implements ExceptionMapper<BQGraphQLRestException> { private static final Logger LOGGER = LoggerFactory.getLogger(BQGraphQLRestExceptionMapper.class); @Override public Response toResponse(BQGraphQLRestException exception) { String message = exception.getMessage(); Status status = exception.getStatus(); if (LOGGER.isInfoEnabled()) { StringBuilder log = new StringBuilder(); log.append(status.getStatusCode()).append(" ").append(status.getReasonPhrase()); if (message != null) { log.append(" (").append(message).append(")"); } if (exception.getCause() != null && exception.getCause().getMessage() != null) { log.append(" [cause: ").append(exception.getCause().getMessage()).append("]"); } // include stack trace in debug mode... if (LOGGER.isDebugEnabled()) { LOGGER.debug(log.toString(), exception); } else { LOGGER.info(log.toString()); } }
return Response.status(status).entity(new MessageResponse(message)).type(MediaType.APPLICATION_JSON_TYPE)
andrus/bootique-graphql
bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/provider/ExecutionResultWriter.java
// Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/json/JsonWriter.java // public interface JsonWriter { // // void write(OutputStream out, JacksonWriterDelegate delegate); // }
import java.io.IOException; import java.io.OutputStream; import java.lang.annotation.Annotation; import java.lang.reflect.Type; import javax.inject.Singleton; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.ext.MessageBodyWriter; import javax.ws.rs.ext.Provider; import org.objectstyle.bootique.graphql.json.JsonWriter; import com.google.inject.Inject; import graphql.ExecutionResult;
package org.objectstyle.bootique.graphql.jaxrs.provider; @Provider @Singleton public class ExecutionResultWriter implements MessageBodyWriter<ExecutionResult> { @Inject
// Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/json/JsonWriter.java // public interface JsonWriter { // // void write(OutputStream out, JacksonWriterDelegate delegate); // } // Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/provider/ExecutionResultWriter.java import java.io.IOException; import java.io.OutputStream; import java.lang.annotation.Annotation; import java.lang.reflect.Type; import javax.inject.Singleton; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.ext.MessageBodyWriter; import javax.ws.rs.ext.Provider; import org.objectstyle.bootique.graphql.json.JsonWriter; import com.google.inject.Inject; import graphql.ExecutionResult; package org.objectstyle.bootique.graphql.jaxrs.provider; @Provider @Singleton public class ExecutionResultWriter implements MessageBodyWriter<ExecutionResult> { @Inject
private JsonWriter writer;
andrus/bootique-graphql
bootique-graphql/src/test/java/org/objectstyle/graphql/it/fixture/cayenne/auto/_E2.java
// Path: bootique-graphql/src/test/java/org/objectstyle/graphql/it/fixture/cayenne/E1.java // public class E1 extends _E1 { // // private static final long serialVersionUID = 1L; // // }
import org.apache.cayenne.CayenneDataObject; import org.apache.cayenne.exp.Property; import org.objectstyle.graphql.it.fixture.cayenne.E1;
package org.objectstyle.graphql.it.fixture.cayenne.auto; /** * Class _E2 was generated by Cayenne. * It is probably a good idea to avoid changing this class manually, * since it may be overwritten next time code is regenerated. * If you need to make any customizations, please use subclass. */ public abstract class _E2 extends CayenneDataObject { private static final long serialVersionUID = 1L; public static final String ID_PK_COLUMN = "id"; public static final Property<String> NAME = new Property<String>("name");
// Path: bootique-graphql/src/test/java/org/objectstyle/graphql/it/fixture/cayenne/E1.java // public class E1 extends _E1 { // // private static final long serialVersionUID = 1L; // // } // Path: bootique-graphql/src/test/java/org/objectstyle/graphql/it/fixture/cayenne/auto/_E2.java import org.apache.cayenne.CayenneDataObject; import org.apache.cayenne.exp.Property; import org.objectstyle.graphql.it.fixture.cayenne.E1; package org.objectstyle.graphql.it.fixture.cayenne.auto; /** * Class _E2 was generated by Cayenne. * It is probably a good idea to avoid changing this class manually, * since it may be overwritten next time code is regenerated. * If you need to make any customizations, please use subclass. */ public abstract class _E2 extends CayenneDataObject { private static final long serialVersionUID = 1L; public static final String ID_PK_COLUMN = "id"; public static final Property<String> NAME = new Property<String>("name");
public static final Property<E1> E1 = new Property<E1>("e1");
andrus/bootique-graphql
bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/json/JacksonReaderWriter.java
// Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/BQGraphQLRestException.java // public class BQGraphQLRestException extends RuntimeException { // // private static final long serialVersionUID = -1228276457093874409L; // // private Status status; // // public BQGraphQLRestException() { // this(Status.INTERNAL_SERVER_ERROR); // } // // public BQGraphQLRestException(Status status) { // this(status, null, null); // } // // public BQGraphQLRestException(Status status, String message) { // this(status, message, null); // } // // public BQGraphQLRestException(Status status, String message, Throwable cause) { // super(message, cause); // this.status = status; // } // // public Status getStatus() { // return status; // } // }
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Objects; import javax.ws.rs.core.Response.Status; import org.objectstyle.bootique.graphql.jaxrs.BQGraphQLRestException; import com.fasterxml.jackson.core.JsonEncoding; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator.Feature; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.node.TreeTraversingParser;
package org.objectstyle.bootique.graphql.json; public class JacksonReaderWriter implements JsonReader, JsonWriter { private ObjectMapper sharedMapper; private JsonFactory sharedFactory; public JacksonReaderWriter() { // fun Jackson API with circular dependencies ... so we create a mapper // first, and grab implicitly created factory from it this.sharedMapper = new ObjectMapper(); this.sharedFactory = sharedMapper.getFactory(); // make sure mapper does not attempt closing streams it does not // manage... why is this even a default in jackson? sharedFactory.disable(Feature.AUTO_CLOSE_TARGET); // do not flush every time. why would we want to do that? // this is having a HUGE impact on extrest serializers (5x speedup) sharedMapper.disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE); } private JsonNode parseJson(InputStream jsonStream) { Objects.requireNonNull(jsonStream); try { com.fasterxml.jackson.core.JsonParser parser = sharedFactory.createParser(jsonStream); return new ObjectMapper().readTree(parser); } catch (IOException e) {
// Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/BQGraphQLRestException.java // public class BQGraphQLRestException extends RuntimeException { // // private static final long serialVersionUID = -1228276457093874409L; // // private Status status; // // public BQGraphQLRestException() { // this(Status.INTERNAL_SERVER_ERROR); // } // // public BQGraphQLRestException(Status status) { // this(status, null, null); // } // // public BQGraphQLRestException(Status status, String message) { // this(status, message, null); // } // // public BQGraphQLRestException(Status status, String message, Throwable cause) { // super(message, cause); // this.status = status; // } // // public Status getStatus() { // return status; // } // } // Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/json/JacksonReaderWriter.java import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Objects; import javax.ws.rs.core.Response.Status; import org.objectstyle.bootique.graphql.jaxrs.BQGraphQLRestException; import com.fasterxml.jackson.core.JsonEncoding; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator.Feature; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.node.TreeTraversingParser; package org.objectstyle.bootique.graphql.json; public class JacksonReaderWriter implements JsonReader, JsonWriter { private ObjectMapper sharedMapper; private JsonFactory sharedFactory; public JacksonReaderWriter() { // fun Jackson API with circular dependencies ... so we create a mapper // first, and grab implicitly created factory from it this.sharedMapper = new ObjectMapper(); this.sharedFactory = sharedMapper.getFactory(); // make sure mapper does not attempt closing streams it does not // manage... why is this even a default in jackson? sharedFactory.disable(Feature.AUTO_CLOSE_TARGET); // do not flush every time. why would we want to do that? // this is having a HUGE impact on extrest serializers (5x speedup) sharedMapper.disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE); } private JsonNode parseJson(InputStream jsonStream) { Objects.requireNonNull(jsonStream); try { com.fasterxml.jackson.core.JsonParser parser = sharedFactory.createParser(jsonStream); return new ObjectMapper().readTree(parser); } catch (IOException e) {
throw new BQGraphQLRestException(Status.BAD_REQUEST, "Error parsing JSON", e);