blob_id
stringlengths 40
40
| __id__
int64 225
39,780B
| directory_id
stringlengths 40
40
| path
stringlengths 6
313
| content_id
stringlengths 40
40
| detected_licenses
list | license_type
stringclasses 2
values | repo_name
stringlengths 6
132
| repo_url
stringlengths 25
151
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
70
| visit_date
timestamp[ns] | revision_date
timestamp[ns] | committer_date
timestamp[ns] | github_id
int64 7.28k
689M
⌀ | star_events_count
int64 0
131k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 23
values | gha_fork
bool 2
classes | gha_event_created_at
timestamp[ns] | gha_created_at
timestamp[ns] | gha_updated_at
timestamp[ns] | gha_pushed_at
timestamp[ns] | gha_size
int64 0
40.4M
⌀ | gha_stargazers_count
int32 0
112k
⌀ | gha_forks_count
int32 0
39.4k
⌀ | gha_open_issues_count
int32 0
11k
⌀ | gha_language
stringlengths 1
21
⌀ | gha_archived
bool 2
classes | gha_disabled
bool 1
class | content
stringlengths 7
4.37M
| src_encoding
stringlengths 3
16
| language
stringclasses 1
value | length_bytes
int64 7
4.37M
| extension
stringclasses 24
values | filename
stringlengths 4
174
| language_id
stringclasses 1
value | entities
list | contaminating_dataset
stringclasses 0
values | malware_signatures
list | redacted_content
stringlengths 7
4.37M
| redacted_length_bytes
int64 7
4.37M
| alphanum_fraction
float32 0.25
0.94
| alpha_fraction
float32 0.25
0.94
| num_lines
int32 1
84k
| avg_line_length
float32 0.76
99.9
| std_line_length
float32 0
220
| max_line_length
int32 5
998
| is_vendor
bool 2
classes | is_generated
bool 1
class | max_hex_length
int32 0
319
| hex_fraction
float32 0
0.38
| max_unicode_length
int32 0
408
| unicode_fraction
float32 0
0.36
| max_base64_length
int32 0
506
| base64_fraction
float32 0
0.5
| avg_csv_sep_count
float32 0
4
| is_autogen_header
bool 1
class | is_empty_html
bool 1
class | shard
stringclasses 16
values |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4c96dc4aa4399300689151ee714cd5b5dde09697
| 12,644,383,777,444 |
47e2fa047571096dec2fdfd05d7f468f00ef21c9
|
/src/additional/EvalRPN.java
|
96360a15a93155cca08c7933f53c0224a38aa10c
|
[] |
no_license
|
xsh857104167/intermediateAlgorithm
|
https://github.com/xsh857104167/intermediateAlgorithm
|
4eab328bd3875ecaa34e53f4c9bda168d5ae41d7
|
7ecca8d93926776943b78706845c2c68b68cae0d
|
refs/heads/master
| 2023-08-17T07:42:22.177000 | 2021-09-28T08:41:00 | 2021-09-28T08:41:00 | 393,368,323 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package additional;
import org.junit.Test;
import java.util.Deque;
import java.util.LinkedList;
/**
* 150. 逆波兰表达式求值
* @author Murphy Xu
* @create 2021-09-13 14:44
*/
public class EvalRPN {
/**
* 栈
* 5ms, 92.96%; 38 MB,78.16%
* @param tokens
* @return
*/
public int evalRPN(String[] tokens) {
Deque<Integer> stack = new LinkedList<>();
int n = tokens.length;
for (int i = 0; i < n; i++) {
String token = tokens[i];
if (isNumber(token)) {
stack.push(Integer.parseInt(token));
}else {
int num2 = stack.pop();
int num1 = stack.pop();
switch (token){
case "+":
stack.push(num1 + num2);
break;
case "-":
stack.push(num1 - num2);
break;
case "*":
stack.push(num1 * num2);
break;
case "/":
stack.push(num1 / num2);
break;
}
}
}
return stack.pop();
}
private boolean isNumber(String token) {
return !("+".equals(token) || "-".equals(token)
|| "*".equals(token) || "/".equals(token));
}
@Test
public void test(){
String[] tokens = {"2","1","+","3","*"};
System.out.println(evalRPN(tokens));
}
}
|
UTF-8
|
Java
| 1,542 |
java
|
EvalRPN.java
|
Java
|
[
{
"context": ".util.LinkedList;\n\n/**\n * 150. 逆波兰表达式求值\n * @author Murphy Xu\n * @create 2021-09-13 14:44\n */\npublic class Eval",
"end": 140,
"score": 0.9998029470443726,
"start": 131,
"tag": "NAME",
"value": "Murphy Xu"
}
] | null |
[] |
package additional;
import org.junit.Test;
import java.util.Deque;
import java.util.LinkedList;
/**
* 150. 逆波兰表达式求值
* @author <NAME>
* @create 2021-09-13 14:44
*/
public class EvalRPN {
/**
* 栈
* 5ms, 92.96%; 38 MB,78.16%
* @param tokens
* @return
*/
public int evalRPN(String[] tokens) {
Deque<Integer> stack = new LinkedList<>();
int n = tokens.length;
for (int i = 0; i < n; i++) {
String token = tokens[i];
if (isNumber(token)) {
stack.push(Integer.parseInt(token));
}else {
int num2 = stack.pop();
int num1 = stack.pop();
switch (token){
case "+":
stack.push(num1 + num2);
break;
case "-":
stack.push(num1 - num2);
break;
case "*":
stack.push(num1 * num2);
break;
case "/":
stack.push(num1 / num2);
break;
}
}
}
return stack.pop();
}
private boolean isNumber(String token) {
return !("+".equals(token) || "-".equals(token)
|| "*".equals(token) || "/".equals(token));
}
@Test
public void test(){
String[] tokens = {"2","1","+","3","*"};
System.out.println(evalRPN(tokens));
}
}
| 1,539 | 0.411417 | 0.385171 | 60 | 24.4 | 16.372946 | 55 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.616667 | false | false |
12
|
ab60873ee1752270e7deadd10a06fa64378f852d
| 12,644,383,779,194 |
0063802a206312b0f2e5437d4aa33678178ff5c1
|
/src/main/java/controladvanced/duplicates/Duplicates.java
|
54cd760d73d6550a860dc89da80e9dbf237f639f
|
[] |
no_license
|
pszilveszter/training-solutions
|
https://github.com/pszilveszter/training-solutions
|
df1eb07887b5d3ec81a67ee0b3605c93ac6e4d2f
|
f2ee478783bd35bce8455867bcbd5cb8f1f16a39
|
refs/heads/master
| 2023-03-20T10:24:30.880000 | 2021-03-16T13:14:32 | 2021-03-16T13:14:32 | 307,976,294 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package controladvanced.duplicates;
import java.util.ArrayList;
import java.util.List;
public class Duplicates {
public List<Integer> find(List<Integer> numbers) {
List<Integer> duplications = new ArrayList<>();
for (int indexUp = 1; indexUp < numbers.size(); indexUp++) {
for (int indexDown = 0; indexDown < indexUp; indexDown++) {
if (numbers.get(indexUp).equals(numbers.get(indexDown))) {
duplications.add(numbers.get(indexUp));
break;
}
}
}
return duplications;
}
}
|
UTF-8
|
Java
| 614 |
java
|
Duplicates.java
|
Java
|
[] | null |
[] |
package controladvanced.duplicates;
import java.util.ArrayList;
import java.util.List;
public class Duplicates {
public List<Integer> find(List<Integer> numbers) {
List<Integer> duplications = new ArrayList<>();
for (int indexUp = 1; indexUp < numbers.size(); indexUp++) {
for (int indexDown = 0; indexDown < indexUp; indexDown++) {
if (numbers.get(indexUp).equals(numbers.get(indexDown))) {
duplications.add(numbers.get(indexUp));
break;
}
}
}
return duplications;
}
}
| 614 | 0.565147 | 0.561889 | 25 | 23.559999 | 25.119045 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.44 | false | false |
12
|
461740e86721c0eaf8f8bb9f9c2f6083b33916c5
| 8,392,366,118,010 |
eb07749b55fd04a55bc14110561b3808166a3d97
|
/Final_TermProject/src/Main_GUI.java
|
9c964bb05b15e1d3d880eed3e5fe8b1fc5f3b602
|
[] |
no_license
|
scroogeElevator/Elevator-scrooge
|
https://github.com/scroogeElevator/Elevator-scrooge
|
a1e2a84ce2090f6d00bb6059904d6902608a14f3
|
62e6e03408e2fa941114fb0948b0844037e524b1
|
refs/heads/master
| 2021-06-16T22:48:53.356000 | 2017-06-10T16:21:17 | 2017-06-10T16:21:17 | 92,706,366 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.awt.Button;
import java.awt.Choice;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Random;
import java.util.Scanner;
import javax.swing.*;
import javax.swing.border.MatteBorder;
import javax.swing.border.LineBorder;
import javax.swing.border.Border;
/* Class of Main Frame that shows Total GUI */
class Main_GUI extends JFrame {
public static final int x[] = { 210, 330, 450, 570, 570 }; // X point of Nth Elevator
private static final int floor_height = 88; // interval between floors
private static final int first_floor = 592; // Y point of 1st floor
public int floor[] = // Y point of each floor
{ first_floor, first_floor - floor_height, first_floor - floor_height*2,
first_floor - floor_height * 3 + 8, first_floor - floor_height * 4 + 8,
first_floor - floor_height * 5 + 8, first_floor - floor_height * 6 + 10,
first_floor - floor_height * 7 + 14 };
public JLabel ele[] = new JLabel[5]; // for showing elevator image
public int input; // input value of departure floor
public int des; // input value of destination floor
public int numC = 5;
public int mode = 2;
/* Objects of other classes */
scheduler mysch;
Container content;
eleb obele[] = new eleb[5];
mover mov;
/* Image Sources */
ImageIcon imageIcon = new ImageIcon(init.elevator_src + ".png");
ImageIcon outp = new ImageIcon("out.png");
ImageIcon b = new ImageIcon(init.background_src + ".png");
ImageIcon Scrooge_mode = new ImageIcon(init.scrooge + ".png");
ImageIcon Normal_mode = new ImageIcon(init.normal + ".png");
GridBagConstraints c; // Constraints for Gridbag Layout
/* Panels */
public JLayeredPane lp = new JLayeredPane(); // Main Panel Layered
private JPanel p2 = new JPanel(); // Panel for customized input
private JPanel p3 = new JPanel(); // Panel for inner of 1st Elevator
private JPanel p4 = new JPanel(); // Panel for inner of 2nd Elevator
private JPanel p5 = new JPanel(); // Panel for inner of 3rd Elevator
private JPanel p6 = new JPanel(); // Panel for inner of 4th Elevator
private JPanel p7 = new JPanel(); // Panel for Mode Changer
private JPanel p8 = new JPanel();
private JPanel p9 = new JPanel(); // Panel for inner of 5th Elevator
JLabel b_title = new JLabel(); // Bottom Title
JLabel floor_in = new JLabel();
JLabel floor_out = new JLabel();
Choice choice, choice_2; // Normal Mode, Scrooge Mode
JButton change; // Mode Changer
client jdbc = new client(); // for using Database MySQL
public Main_GUI(scheduler obj)
{
/* initialize frame */
super("Elevator_term");
mysch = obj;
setSize(1360, 720);
setResizable(false);
choice = new Choice();
choice_2 = new Choice();
init.lp = this.lp;
change = new JButton(new ImageIcon(init.normal + ".png"));
Button Enter_Button = new Button(" E n t e r ");
Button Random = new Button(" R a n d o m ");
Button auto = new Button(" A u t o ");
Button fileinput = new Button(" F i l e ");
MouseHandler handler = new MouseHandler();
/* GridBag Layout */
GridBagLayout gridbag = new GridBagLayout();
setLayout(gridbag);
c = new GridBagConstraints();
c.weightx = 0.0;
c.weighty = 0.0;
lp.setPreferredSize(new Dimension(860, 690));
p2.setPreferredSize(new Dimension(460, 100));
p3.setPreferredSize(new Dimension(230, 250));
p4.setPreferredSize(new Dimension(230, 250));
p5.setPreferredSize(new Dimension(230, 250));
p6.setPreferredSize(new Dimension(230, 250));
p7.setPreferredSize(new Dimension(460, 90));
p9.setPreferredSize(new Dimension(230, 250));
layout(lp, 0, 0, 12, 10);
layout(p2, 12, 8, 6, 2);
layout(p3, 12, 5, 3, 3);
layout(p4, 15, 5, 3, 3);
layout(p5, 12, 2, 3, 3);
layout(p6, 15, 2, 3, 3);
layout(p7, 12, 0, 6, 2);
/* for opening Inner of Elevator */
p4.addMouseListener(handler);
p4.addMouseMotionListener(handler);
elevator_inner.init(p3, p4, p5, p6, p9); // initialize 5 panels for inner of elevator
b_title.setText(" User can control the person's entrance and outdoor floor. ");
floor_in.setText("Floor in : ");
floor_out.setText(" Floor out : ");
/* Checkbox for input */
choice.add("1");
choice.add("2");
choice.add("3");
choice.add("4");
choice.add("5");
choice.add("6");
choice.add("7");
choice.add("8");
choice_2.add("1");
choice_2.add("2");
choice_2.add("3");
choice_2.add("4");
choice_2.add("5");
choice_2.add("6");
choice_2.add("7");
choice_2.add("8");
/* Mode Changer */
change.setPreferredSize(new Dimension(470, 90));
change.setBackground(Color.white);
p7.add(change);
change.addActionListener(new MyActionListener_3());
/* Panel for Customized Input */
p2.add(b_title);
p2.add(floor_in);
p2.add(choice);
p2.add(floor_out);
p2.add(choice_2);
p2.add(Enter_Button);
p2.add(Random);
p2.add(auto);
p2.add(fileinput);
Enter_Button.addActionListener(new MyActionListener());
Random.addActionListener(new MyActionListener_2());
auto.addActionListener(new MyActionListener_4());
fileinput.addActionListener(new MyActionListener_5());
Scanner keyboard = new Scanner(System.in);
JLabel a3 = new JLabel(b, JLabel.LEFT);
a3.setBounds(0, 0, init.frame_width, init.frame_height);
lp.add(a3, new Integer(0));
JPanel back = new JPanel();
back.setSize(init.background_width, init.background_height);
/* Initialize Elevator Label */
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 8; j++) {
JLabel backElv = new JLabel(new ImageIcon(init.elevator_src + "_temp.png"), JLabel.LEFT);
backElv.setBounds(x[i], floor[j], 230, 120);
backElv.setLayout(null);
backElv.setOpaque(false);
lp.add(backElv, new Integer(2));
backElv.setBounds(x[i], floor[j], 230, 120);
}
}
for (int i = 0; i <= 3; i++) {
ele[i] = new JLabel(imageIcon, JLabel.LEFT);
ele[i].setBounds(x[i], floor[0], 230, 120);
ele[i].setLayout(null);
ele[i].setOpaque(false);
lp.add(ele[i], new Integer(3));
ele[i].setBounds(x[i], floor[0], 230, 120);
}
ele[4] = new JLabel(imageIcon, JLabel.LEFT);
ele[4].setBounds(x[3], floor[4], 230, 120);
ele[4].setLayout(null);
ele[4].setOpaque(false);
lp.add(ele[4], new Integer(3));
ele[4].setBounds(x[3], floor[4], 230, 120);
JLabel trash = new JLabel();
lp.add(trash);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
for (int i = 0; i < 4; i++) {
obele[i] = new eleb(jdbc.callToServer(i), floor[0], ele[i], x[i], i);
}
obele[4] = new eleb(jdbc.callToServer(4), floor[4], ele[4], x[4], 4);
mysch.mov = new mover(obele, mysch);
mysch.mov.start();
setVisible(true);
}
/* Getter method for Inner of 5th Elevator */
private JPanel get5th() {
return this.p9;
}
private class MyActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
input = (choice.getSelectedIndex() + 1);
des = (choice_2.getSelectedIndex() + 1);
Random generator = new Random();
int ran = generator.nextInt(200);
if (mysch.mode == 2) {
if (ran % 2 == 0)
mysch.scheduling(input, des, 350 + ran);
else
mysch.scheduling(input, des, 350 - ran);
}
else
{
if(ran%2 == 0)
mysch.nomalscheduling(input, des, 350 + ran);
else
mysch.nomalscheduling(input, des, 350 - ran);
}
}
}
/* Random Input Value */
private class MyActionListener_2 implements ActionListener {
public void actionPerformed(ActionEvent e) {
randomInput r;
r = new randomInput();
Random generator = new Random();
input = r.input;
des = r.des;
int ran = generator.nextInt(200);
if (mysch.mode == 2) {
if (ran % 2 == 0)
mysch.scheduling(input, des, 350 + ran);
else
mysch.scheduling(input, des, 350 - ran);
}
else
{
if(ran%2 == 0)
mysch.nomalscheduling(input, des, 350 + ran);
else
mysch.nomalscheduling(input, des, 350 - ran);
}
}
}
/* Mode Changer */
private class MyActionListener_3 implements ActionListener {
public void actionPerformed(ActionEvent e) {
if (mysch.mode == 1) {
change.setIcon(Scrooge_mode);
mysch.mode = 2;
} else {
change.setIcon(Normal_mode);
mysch.mode = 1;
}
}
}
/* Auto Input Value */
private class MyActionListener_4 implements ActionListener {
public void actionPerformed(ActionEvent e) {
autoInput autos = new autoInput(mysch);
autos.start();
}
}
/* File Input Value */
private class MyActionListener_5 implements ActionListener {
public void actionPerformed(ActionEvent e) {
// autoinput = 0;
FileInput files = new FileInput(mysch);
files.start();
}
}
/* Shows Inner of 5th Elevator */
private class MouseHandler implements MouseListener, MouseMotionListener {
public void mouseClicked(MouseEvent event) {
Elevator_5 e = new Elevator_5(elevator_inner.get5th());
}
public void mouseDragged(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseMoved(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mousePressed(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
}
}
/* For Gridbag Layout */
public void layout(Component obj, int x, int y, int width, int height) {
c.gridx = x; // X point
c.gridy = y; // Y point
c.gridwidth = width; // Width
c.gridheight = height; // Height
add(obj, c);
}
}
|
UTF-8
|
Java
| 10,471 |
java
|
Main_GUI.java
|
Java
|
[] | null |
[] |
import java.awt.Button;
import java.awt.Choice;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Random;
import java.util.Scanner;
import javax.swing.*;
import javax.swing.border.MatteBorder;
import javax.swing.border.LineBorder;
import javax.swing.border.Border;
/* Class of Main Frame that shows Total GUI */
class Main_GUI extends JFrame {
public static final int x[] = { 210, 330, 450, 570, 570 }; // X point of Nth Elevator
private static final int floor_height = 88; // interval between floors
private static final int first_floor = 592; // Y point of 1st floor
public int floor[] = // Y point of each floor
{ first_floor, first_floor - floor_height, first_floor - floor_height*2,
first_floor - floor_height * 3 + 8, first_floor - floor_height * 4 + 8,
first_floor - floor_height * 5 + 8, first_floor - floor_height * 6 + 10,
first_floor - floor_height * 7 + 14 };
public JLabel ele[] = new JLabel[5]; // for showing elevator image
public int input; // input value of departure floor
public int des; // input value of destination floor
public int numC = 5;
public int mode = 2;
/* Objects of other classes */
scheduler mysch;
Container content;
eleb obele[] = new eleb[5];
mover mov;
/* Image Sources */
ImageIcon imageIcon = new ImageIcon(init.elevator_src + ".png");
ImageIcon outp = new ImageIcon("out.png");
ImageIcon b = new ImageIcon(init.background_src + ".png");
ImageIcon Scrooge_mode = new ImageIcon(init.scrooge + ".png");
ImageIcon Normal_mode = new ImageIcon(init.normal + ".png");
GridBagConstraints c; // Constraints for Gridbag Layout
/* Panels */
public JLayeredPane lp = new JLayeredPane(); // Main Panel Layered
private JPanel p2 = new JPanel(); // Panel for customized input
private JPanel p3 = new JPanel(); // Panel for inner of 1st Elevator
private JPanel p4 = new JPanel(); // Panel for inner of 2nd Elevator
private JPanel p5 = new JPanel(); // Panel for inner of 3rd Elevator
private JPanel p6 = new JPanel(); // Panel for inner of 4th Elevator
private JPanel p7 = new JPanel(); // Panel for Mode Changer
private JPanel p8 = new JPanel();
private JPanel p9 = new JPanel(); // Panel for inner of 5th Elevator
JLabel b_title = new JLabel(); // Bottom Title
JLabel floor_in = new JLabel();
JLabel floor_out = new JLabel();
Choice choice, choice_2; // Normal Mode, Scrooge Mode
JButton change; // Mode Changer
client jdbc = new client(); // for using Database MySQL
public Main_GUI(scheduler obj)
{
/* initialize frame */
super("Elevator_term");
mysch = obj;
setSize(1360, 720);
setResizable(false);
choice = new Choice();
choice_2 = new Choice();
init.lp = this.lp;
change = new JButton(new ImageIcon(init.normal + ".png"));
Button Enter_Button = new Button(" E n t e r ");
Button Random = new Button(" R a n d o m ");
Button auto = new Button(" A u t o ");
Button fileinput = new Button(" F i l e ");
MouseHandler handler = new MouseHandler();
/* GridBag Layout */
GridBagLayout gridbag = new GridBagLayout();
setLayout(gridbag);
c = new GridBagConstraints();
c.weightx = 0.0;
c.weighty = 0.0;
lp.setPreferredSize(new Dimension(860, 690));
p2.setPreferredSize(new Dimension(460, 100));
p3.setPreferredSize(new Dimension(230, 250));
p4.setPreferredSize(new Dimension(230, 250));
p5.setPreferredSize(new Dimension(230, 250));
p6.setPreferredSize(new Dimension(230, 250));
p7.setPreferredSize(new Dimension(460, 90));
p9.setPreferredSize(new Dimension(230, 250));
layout(lp, 0, 0, 12, 10);
layout(p2, 12, 8, 6, 2);
layout(p3, 12, 5, 3, 3);
layout(p4, 15, 5, 3, 3);
layout(p5, 12, 2, 3, 3);
layout(p6, 15, 2, 3, 3);
layout(p7, 12, 0, 6, 2);
/* for opening Inner of Elevator */
p4.addMouseListener(handler);
p4.addMouseMotionListener(handler);
elevator_inner.init(p3, p4, p5, p6, p9); // initialize 5 panels for inner of elevator
b_title.setText(" User can control the person's entrance and outdoor floor. ");
floor_in.setText("Floor in : ");
floor_out.setText(" Floor out : ");
/* Checkbox for input */
choice.add("1");
choice.add("2");
choice.add("3");
choice.add("4");
choice.add("5");
choice.add("6");
choice.add("7");
choice.add("8");
choice_2.add("1");
choice_2.add("2");
choice_2.add("3");
choice_2.add("4");
choice_2.add("5");
choice_2.add("6");
choice_2.add("7");
choice_2.add("8");
/* Mode Changer */
change.setPreferredSize(new Dimension(470, 90));
change.setBackground(Color.white);
p7.add(change);
change.addActionListener(new MyActionListener_3());
/* Panel for Customized Input */
p2.add(b_title);
p2.add(floor_in);
p2.add(choice);
p2.add(floor_out);
p2.add(choice_2);
p2.add(Enter_Button);
p2.add(Random);
p2.add(auto);
p2.add(fileinput);
Enter_Button.addActionListener(new MyActionListener());
Random.addActionListener(new MyActionListener_2());
auto.addActionListener(new MyActionListener_4());
fileinput.addActionListener(new MyActionListener_5());
Scanner keyboard = new Scanner(System.in);
JLabel a3 = new JLabel(b, JLabel.LEFT);
a3.setBounds(0, 0, init.frame_width, init.frame_height);
lp.add(a3, new Integer(0));
JPanel back = new JPanel();
back.setSize(init.background_width, init.background_height);
/* Initialize Elevator Label */
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 8; j++) {
JLabel backElv = new JLabel(new ImageIcon(init.elevator_src + "_temp.png"), JLabel.LEFT);
backElv.setBounds(x[i], floor[j], 230, 120);
backElv.setLayout(null);
backElv.setOpaque(false);
lp.add(backElv, new Integer(2));
backElv.setBounds(x[i], floor[j], 230, 120);
}
}
for (int i = 0; i <= 3; i++) {
ele[i] = new JLabel(imageIcon, JLabel.LEFT);
ele[i].setBounds(x[i], floor[0], 230, 120);
ele[i].setLayout(null);
ele[i].setOpaque(false);
lp.add(ele[i], new Integer(3));
ele[i].setBounds(x[i], floor[0], 230, 120);
}
ele[4] = new JLabel(imageIcon, JLabel.LEFT);
ele[4].setBounds(x[3], floor[4], 230, 120);
ele[4].setLayout(null);
ele[4].setOpaque(false);
lp.add(ele[4], new Integer(3));
ele[4].setBounds(x[3], floor[4], 230, 120);
JLabel trash = new JLabel();
lp.add(trash);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
for (int i = 0; i < 4; i++) {
obele[i] = new eleb(jdbc.callToServer(i), floor[0], ele[i], x[i], i);
}
obele[4] = new eleb(jdbc.callToServer(4), floor[4], ele[4], x[4], 4);
mysch.mov = new mover(obele, mysch);
mysch.mov.start();
setVisible(true);
}
/* Getter method for Inner of 5th Elevator */
private JPanel get5th() {
return this.p9;
}
private class MyActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
input = (choice.getSelectedIndex() + 1);
des = (choice_2.getSelectedIndex() + 1);
Random generator = new Random();
int ran = generator.nextInt(200);
if (mysch.mode == 2) {
if (ran % 2 == 0)
mysch.scheduling(input, des, 350 + ran);
else
mysch.scheduling(input, des, 350 - ran);
}
else
{
if(ran%2 == 0)
mysch.nomalscheduling(input, des, 350 + ran);
else
mysch.nomalscheduling(input, des, 350 - ran);
}
}
}
/* Random Input Value */
private class MyActionListener_2 implements ActionListener {
public void actionPerformed(ActionEvent e) {
randomInput r;
r = new randomInput();
Random generator = new Random();
input = r.input;
des = r.des;
int ran = generator.nextInt(200);
if (mysch.mode == 2) {
if (ran % 2 == 0)
mysch.scheduling(input, des, 350 + ran);
else
mysch.scheduling(input, des, 350 - ran);
}
else
{
if(ran%2 == 0)
mysch.nomalscheduling(input, des, 350 + ran);
else
mysch.nomalscheduling(input, des, 350 - ran);
}
}
}
/* Mode Changer */
private class MyActionListener_3 implements ActionListener {
public void actionPerformed(ActionEvent e) {
if (mysch.mode == 1) {
change.setIcon(Scrooge_mode);
mysch.mode = 2;
} else {
change.setIcon(Normal_mode);
mysch.mode = 1;
}
}
}
/* Auto Input Value */
private class MyActionListener_4 implements ActionListener {
public void actionPerformed(ActionEvent e) {
autoInput autos = new autoInput(mysch);
autos.start();
}
}
/* File Input Value */
private class MyActionListener_5 implements ActionListener {
public void actionPerformed(ActionEvent e) {
// autoinput = 0;
FileInput files = new FileInput(mysch);
files.start();
}
}
/* Shows Inner of 5th Elevator */
private class MouseHandler implements MouseListener, MouseMotionListener {
public void mouseClicked(MouseEvent event) {
Elevator_5 e = new Elevator_5(elevator_inner.get5th());
}
public void mouseDragged(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseMoved(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mousePressed(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
}
}
/* For Gridbag Layout */
public void layout(Component obj, int x, int y, int width, int height) {
c.gridx = x; // X point
c.gridy = y; // Y point
c.gridwidth = width; // Width
c.gridheight = height; // Height
add(obj, c);
}
}
| 10,471 | 0.636424 | 0.60319 | 353 | 27.668554 | 22.07778 | 131 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.614731 | false | false |
12
|
7f8b47f9ce59b6cda38ebb7ea58655d86e42252a
| 18,141,941,893,713 |
9ceae4b069d355f040596b13ab21ddb96841d205
|
/collector/src/main/java/task/hdfs/MonitorTask.java
|
8257cb809e9a641f047a16e5c43ae30d485de555
|
[] |
no_license
|
lhwsgxka/spark
|
https://github.com/lhwsgxka/spark
|
ce28c39d46e1b6a14a2a687a8c6701e259324d1f
|
84352cf59d75d53da7b091f9e12e06fdac2133bf
|
refs/heads/master
| 2020-04-29T14:26:37.792000 | 2019-03-18T03:14:57 | 2019-03-18T03:14:57 | 176,196,507 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package task.hdfs;
import org.apache.commons.configuration.Configuration;
public interface MonitorTask extends Runnable {
void init(Configuration conf);
void clean();
}
|
UTF-8
|
Java
| 180 |
java
|
MonitorTask.java
|
Java
|
[] | null |
[] |
package task.hdfs;
import org.apache.commons.configuration.Configuration;
public interface MonitorTask extends Runnable {
void init(Configuration conf);
void clean();
}
| 180 | 0.766667 | 0.766667 | 9 | 19 | 20.127373 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.444444 | false | false |
12
|
c88263a7a0abdae89dc62577c665500ea631fc1b
| 12,970,801,275,353 |
e10ef76fc05019263111f652fff4951c4e57d9ad
|
/src/chapter1/Que7.java
|
ea78b5ff83dae973720672f83050a8e94d40bef7
|
[] |
no_license
|
dspatel28/CTCI
|
https://github.com/dspatel28/CTCI
|
3297be7719ac74f952d98dd57cb76685f22b40b7
|
4441691b47026f88ef2f6b8fa2fa7c07a37e2172
|
refs/heads/master
| 2021-05-31T19:27:23.980000 | 2016-04-29T01:18:43 | 2016-04-29T01:18:43 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package chapter1;
public class Que7
{
public static void main(String[] args)
{
int ip[][] = {{1,2,3}, {4,5,6},{7,8,9}};
ip = rotateMatrix(ip,3);
System.out.println("");
}
public static int[][] rotateMatrix(int[][] ip, int n)
{
for(int layer=0; layer<n/2; layer++)
{
int last = n-1-layer;
for(int i=layer; i<last; i++)
{
ip[layer][i] = ip[last+layer-i][layer];
}
}
return ip;
}
}
|
UTF-8
|
Java
| 418 |
java
|
Que7.java
|
Java
|
[] | null |
[] |
package chapter1;
public class Que7
{
public static void main(String[] args)
{
int ip[][] = {{1,2,3}, {4,5,6},{7,8,9}};
ip = rotateMatrix(ip,3);
System.out.println("");
}
public static int[][] rotateMatrix(int[][] ip, int n)
{
for(int layer=0; layer<n/2; layer++)
{
int last = n-1-layer;
for(int i=layer; i<last; i++)
{
ip[layer][i] = ip[last+layer-i][layer];
}
}
return ip;
}
}
| 418 | 0.555024 | 0.519139 | 24 | 16.416666 | 16.730503 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.416667 | false | false |
12
|
9a3cb8a51bed5eafb316523a60df7f0b263b9ad9
| 30,193,620,126,657 |
622950f343e37a46ab11cb853440d419b88fc832
|
/lab5MPP/src/assignment1/DocListener.java
|
955df0c9963e980f97483f1e040e45dfc84efe7c
|
[] |
no_license
|
itimotin/MPP
|
https://github.com/itimotin/MPP
|
73ae26c072bd930f89ea8d91311dc3bb26cc45f0
|
3b26b4e7d72e2e2b5b4b3cc6188eaccd908f81d3
|
refs/heads/master
| 2020-03-28T11:13:50.744000 | 2018-09-10T17:26:13 | 2018-09-10T17:26:13 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package assignment1;
public class DocListener {
}
|
UTF-8
|
Java
| 52 |
java
|
DocListener.java
|
Java
|
[] | null |
[] |
package assignment1;
public class DocListener {
}
| 52 | 0.769231 | 0.75 | 5 | 9.4 | 11.271202 | 26 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | false | false |
12
|
297390e86d70585970706390061abb8a25b044e5
| 25,701,084,337,554 |
9cfcb31c0c2949b528734f7071b5da7fecd6cbd0
|
/FirstAndsecondHalfEqualSumSubstring.java
|
77b7639c4824d8405c93f717dee053a1264d4a9d
|
[] |
no_license
|
mukeshsureshsaini/data-structure-coreman-examples
|
https://github.com/mukeshsureshsaini/data-structure-coreman-examples
|
1960355491c84db1ae80a4bfd1b4cb165827d72d
|
855cc9de45664421120dd4e6323caedc01c7bbf1
|
refs/heads/master
| 2022-11-22T23:22:57.859000 | 2022-11-13T05:11:10 | 2022-11-13T05:11:10 | 85,578,582 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.recursion.dp;
// @formatter:off
// given a string of digits , find the substring such that sum of first half of substring is equal to sum of second half of substring
// eg 670341 -> 7034 , sum of first half 7+0 , sum of second half 3+4
// @formatter:on
class BruteForceMethod {
private String str;
private String equalSumSubstring = "";
public BruteForceMethod(String str) {
this.str = str;
preprocess(this.str, str.length());
}
private void preprocess(String str, int strLen) {
for (int i = 0; i < strLen; i++) {
for (int j = i + 1; j < strLen; j += 2) { // why j+2 because we need equals half hence we always need to be
// even
int substringlength = j - i + 1;
if (equalSumSubstring.length() > substringlength) {
continue;
} else {
int lsum = 0, rsum = 0;
for (int k = 0; k < substringlength / 2; k++) {
lsum += this.str.charAt(i + k);
rsum += this.str.charAt(i + k + substringlength / 2);
}
if (lsum == rsum) {
equalSumSubstring = this.str.substring(i, j + 1);
}
}
}
}
}
public String getEqualSumSubstring() {
return this.equalSumSubstring;
}
}
class DynamicProgrammingMethod {
private String str;
private int maxLen;
public DynamicProgrammingMethod(String str) {
this.str = str;
preprocessDyPro(str, this.str.length());
}
public void preprocessDyPro(String str, int n) {
int cache[][] = new int[n][n];
for (int x = 0; x < n; x++)
cache[x][x] = str.charAt(x); // sum of length 1
for (int len = 2; len <= n; len++) { // try for len 2,3,4,....
for (int i = 0; i < n - len + 1; i++) { // start with ith index
// we have length of substring and start index of substring we can find end
// index and mid index of substring
int j = i + len - 1; // end index
int k = (i + j) / 2; // mid index for given i and j
cache[i][j] = cache[i][k] + cache[k + 1][j];
if (len % 2 == 0 && (cache[i][k] == cache[k + 1][j]) && (len > maxLen)) {
maxLen = len;
}
}
}
}
public int getEqualSumSubstringLength() {
return this.maxLen;
}
}
public class FirstAndsecondHalfEqualSumSubstring {
public static void main(String[] args) {
// BruteForceMethod m = new BruteForceMethod("67034");
DynamicProgrammingMethod m = new DynamicProgrammingMethod("67043");
System.out.println(m.getEqualSumSubstringLength());
}
}
|
UTF-8
|
Java
| 2,407 |
java
|
FirstAndsecondHalfEqualSumSubstring.java
|
Java
|
[] | null |
[] |
package com.recursion.dp;
// @formatter:off
// given a string of digits , find the substring such that sum of first half of substring is equal to sum of second half of substring
// eg 670341 -> 7034 , sum of first half 7+0 , sum of second half 3+4
// @formatter:on
class BruteForceMethod {
private String str;
private String equalSumSubstring = "";
public BruteForceMethod(String str) {
this.str = str;
preprocess(this.str, str.length());
}
private void preprocess(String str, int strLen) {
for (int i = 0; i < strLen; i++) {
for (int j = i + 1; j < strLen; j += 2) { // why j+2 because we need equals half hence we always need to be
// even
int substringlength = j - i + 1;
if (equalSumSubstring.length() > substringlength) {
continue;
} else {
int lsum = 0, rsum = 0;
for (int k = 0; k < substringlength / 2; k++) {
lsum += this.str.charAt(i + k);
rsum += this.str.charAt(i + k + substringlength / 2);
}
if (lsum == rsum) {
equalSumSubstring = this.str.substring(i, j + 1);
}
}
}
}
}
public String getEqualSumSubstring() {
return this.equalSumSubstring;
}
}
class DynamicProgrammingMethod {
private String str;
private int maxLen;
public DynamicProgrammingMethod(String str) {
this.str = str;
preprocessDyPro(str, this.str.length());
}
public void preprocessDyPro(String str, int n) {
int cache[][] = new int[n][n];
for (int x = 0; x < n; x++)
cache[x][x] = str.charAt(x); // sum of length 1
for (int len = 2; len <= n; len++) { // try for len 2,3,4,....
for (int i = 0; i < n - len + 1; i++) { // start with ith index
// we have length of substring and start index of substring we can find end
// index and mid index of substring
int j = i + len - 1; // end index
int k = (i + j) / 2; // mid index for given i and j
cache[i][j] = cache[i][k] + cache[k + 1][j];
if (len % 2 == 0 && (cache[i][k] == cache[k + 1][j]) && (len > maxLen)) {
maxLen = len;
}
}
}
}
public int getEqualSumSubstringLength() {
return this.maxLen;
}
}
public class FirstAndsecondHalfEqualSumSubstring {
public static void main(String[] args) {
// BruteForceMethod m = new BruteForceMethod("67034");
DynamicProgrammingMethod m = new DynamicProgrammingMethod("67043");
System.out.println(m.getEqualSumSubstringLength());
}
}
| 2,407 | 0.615289 | 0.594931 | 107 | 21.495327 | 26.383362 | 133 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.093458 | false | false |
12
|
fd4994452b588417d0046b7bf24a58d36395fdf1
| 23,270,132,857,037 |
b729349ccb4eae504dfb51207c6acb6a88cbc629
|
/design-pattern/src/main/java/com/mzc/BehavioralModel/TemplateMethodPattern/HummerH1Model.java
|
097895103167c2c7bd80db1e8f319ed6a2a7b585
|
[] |
no_license
|
jikeMisma/javaFamilyDemo
|
https://github.com/jikeMisma/javaFamilyDemo
|
3f42cdef704a35a23dced540c5f5610536996dff
|
f2f94254f3fb19227adacac25bda8ee24adf4ea0
|
refs/heads/master
| 2023-07-17T16:47:05.869000 | 2021-07-31T14:55:20 | 2021-07-31T14:55:20 | 331,947,510 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.mzc.BehavioralModel.TemplateMethodPattern;
/**
* 文件描述
*
* @ProductName: Hundsun HEP
* @ProjectName: design-pattern
* @Package: com.mzc.BehavioralModel.TemplateMethodPattern
* @Description: note
* @Author: mazc35591
* @CreateDate: 2021/4/2 8:59
* @UpdateUser: mazc35591
* @UpdateDate: 2021/4/2 8:59
* @UpdateRemark: The modified content
* @Version: 1.0
* Copyright © 2021 Hundsun Technologies Inc. All Rights Reserved
**/
public class HummerH1Model extends HummerModel {
private boolean alarmFlag = true;//要响喇叭
@Override
protected void start() {
System.out.println("悍马H1发动...");
}
@Override
protected void stop() {
System.out.println("悍马H1停车...");
}
@Override
protected void alarm() {
System.out.println("悍马H1鸣笛...");
}
@Override
protected void engineBoom() {
System.out.println("悍马H1的引擎声音是这样的...");
}
protected boolean isAlarm() {
return this.alarmFlag;
}
public void setAlarm(boolean isAlarm) {
this.alarmFlag = isAlarm;
}
}
|
UTF-8
|
Java
| 1,137 |
java
|
HummerH1Model.java
|
Java
|
[
{
"context": "ateMethodPattern\n * @Description: note\n * @Author: mazc35591\n * @CreateDate: 2021/4/2 8:59\n * @UpdateUser: maz",
"end": 234,
"score": 0.9995952248573303,
"start": 225,
"tag": "USERNAME",
"value": "mazc35591"
},
{
"context": "5591\n * @CreateDate: 2021/4/2 8:59\n * @UpdateUser: mazc35591\n * @UpdateDate: 2021/4/2 8:59\n * @UpdateRemark: T",
"end": 290,
"score": 0.9995431900024414,
"start": 281,
"tag": "USERNAME",
"value": "mazc35591"
}
] | null |
[] |
package com.mzc.BehavioralModel.TemplateMethodPattern;
/**
* 文件描述
*
* @ProductName: Hundsun HEP
* @ProjectName: design-pattern
* @Package: com.mzc.BehavioralModel.TemplateMethodPattern
* @Description: note
* @Author: mazc35591
* @CreateDate: 2021/4/2 8:59
* @UpdateUser: mazc35591
* @UpdateDate: 2021/4/2 8:59
* @UpdateRemark: The modified content
* @Version: 1.0
* Copyright © 2021 Hundsun Technologies Inc. All Rights Reserved
**/
public class HummerH1Model extends HummerModel {
private boolean alarmFlag = true;//要响喇叭
@Override
protected void start() {
System.out.println("悍马H1发动...");
}
@Override
protected void stop() {
System.out.println("悍马H1停车...");
}
@Override
protected void alarm() {
System.out.println("悍马H1鸣笛...");
}
@Override
protected void engineBoom() {
System.out.println("悍马H1的引擎声音是这样的...");
}
protected boolean isAlarm() {
return this.alarmFlag;
}
public void setAlarm(boolean isAlarm) {
this.alarmFlag = isAlarm;
}
}
| 1,137 | 0.647114 | 0.610801 | 48 | 21.395834 | 17.996225 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.166667 | false | false |
12
|
f6d22577febd392c9dd478252fe8adb1f7a97408
| 5,961,414,653,964 |
9c36f7a8e84c35d446fbaac1777cd0e20855ea99
|
/app/src/main/java/com/romellfudi/callbacks/interfaces/ParseCallback.java
|
ea50a877b0614120a58d27ff5f4b57ffa86a405b
|
[
"Apache-2.0"
] |
permissive
|
romellfudi/CallbacksSample
|
https://github.com/romellfudi/CallbacksSample
|
abbe0d7cadf81081a52468a8f14bc3dd0d021138
|
cb451857ed1801978bd044cf6107d40ee23052ff
|
refs/heads/main
| 2021-06-13T01:22:14.386000 | 2021-04-02T14:10:09 | 2021-04-02T14:10:09 | 142,793,663 | 3 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.romellfudi.callbacks.interfaces;
import java.text.ParseException;
/**
* Created by romelldominguez on 9/19/16.
*/
public interface ParseCallback {
void onParse(ParseException exception, Object... objects);
}
|
UTF-8
|
Java
| 228 |
java
|
ParseCallback.java
|
Java
|
[
{
"context": "mport java.text.ParseException;\n\n/**\n * Created by romelldominguez on 9/19/16.\n */\npublic interface ParseCallback {\n",
"end": 113,
"score": 0.9995501637458801,
"start": 98,
"tag": "USERNAME",
"value": "romelldominguez"
}
] | null |
[] |
package com.romellfudi.callbacks.interfaces;
import java.text.ParseException;
/**
* Created by romelldominguez on 9/19/16.
*/
public interface ParseCallback {
void onParse(ParseException exception, Object... objects);
}
| 228 | 0.758772 | 0.736842 | 10 | 21.799999 | 21.853146 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false |
12
|
d2186c32f0e97bb5308c53dafcb8cf77529a29ab
| 5,961,414,653,262 |
2137540e15235edd282be79f44989ba81c2709fb
|
/src/main/java/grondag/canvas/buffer/input/VertexCollector.java
|
f069d3abd3fc3d1bf80d915c6fb7dfafea20ef5f
|
[
"LGPL-3.0-only",
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] |
permissive
|
PepperCode1/canvas
|
https://github.com/PepperCode1/canvas
|
f6a419c59655111401fcc142d9bc820f1d33aadb
|
026ace4c427657a4ce39d408fb0653136927491b
|
refs/heads/1.17
| 2023-08-15T12:58:57.648000 | 2021-10-16T21:10:36 | 2021-10-16T21:10:36 | 390,942,916 | 1 | 0 |
Apache-2.0
| true | 2021-07-30T05:32:13 | 2021-07-30T05:32:12 | 2021-07-30T02:53:40 | 2021-07-29T22:21:14 | 7,131 | 0 | 0 | 0 | null | false | false |
/*
* Copyright © Contributing Authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser 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 Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional copyright and licensing notices may apply for content that was
* included from other projects. For more information, see ATTRIBUTION.md.
*/
package grondag.canvas.buffer.input;
/**
* Thin access layer to vertex buffer/mapped memory range.
* Caller must know vertex format, boundaries, etc.
* NOT THREAD SAFE.
*/
public interface VertexCollector {
int allocate(int size);
default int allocate(int size, int bucketIndex) {
return allocate(size);
}
/**
* Must be called AFTER #allocate() and before any other allocations happen.
*/
int[] data();
}
|
UTF-8
|
Java
| 1,286 |
java
|
VertexCollector.java
|
Java
|
[] | null |
[] |
/*
* Copyright © Contributing Authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser 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 Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional copyright and licensing notices may apply for content that was
* included from other projects. For more information, see ATTRIBUTION.md.
*/
package grondag.canvas.buffer.input;
/**
* Thin access layer to vertex buffer/mapped memory range.
* Caller must know vertex format, boundaries, etc.
* NOT THREAD SAFE.
*/
public interface VertexCollector {
int allocate(int size);
default int allocate(int size, int bucketIndex) {
return allocate(size);
}
/**
* Must be called AFTER #allocate() and before any other allocations happen.
*/
int[] data();
}
| 1,286 | 0.737743 | 0.736965 | 39 | 31.948717 | 29.611111 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.564103 | false | false |
12
|
3f4a7eec6d2a0158360d56dd6ae1044db094c332
| 7,868,380,138,999 |
f945102d95298ee27c95f13ccc6ab3a2356564e5
|
/Selenium/src/actiTimePOMclass/Login2Page.java
|
17dac19de99aea11a8a9957011908eadd57229e0
|
[] |
no_license
|
sumanth946/QSP-QCSM13
|
https://github.com/sumanth946/QSP-QCSM13
|
bd81de7979b989a9ca020a9ae1a0c23295d48094
|
e22a76381fb6de6af922cb304eeda482f72c266b
|
refs/heads/master
| 2023-08-29T01:18:16.824000 | 2021-11-03T06:02:51 | 2021-11-03T06:02:51 | 424,101,611 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package actiTimePOMclass;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
public class Login2Page {
// HARD CODING
// USING BUSINESS LOGIC
public Login2Page(WebDriver driver) {
PageFactory.initElements(driver, this);
}
@FindBy(id = "username")
private WebElement usernameTextField;
@FindBy(name = "pwd")
private WebElement passwordTextField;
@FindBy(xpath = "//div[text()='Login ']")
private WebElement loginButton;
public void login(String username, String password) {
usernameTextField.sendKeys(username);
passwordTextField.sendKeys(password);
loginButton.click();
}
}
|
UTF-8
|
Java
| 754 |
java
|
Login2Page.java
|
Java
|
[
{
"context": "initElements(driver, this);\r\n\t}\r\n\r\n\t@FindBy(id = \"username\")\r\n\tprivate WebElement usernameTextField;\r\n\r\n\t@Fi",
"end": 389,
"score": 0.6916477084159851,
"start": 381,
"tag": "USERNAME",
"value": "username"
},
{
"context": " String password) {\r\n\t\tusernameTextField.sendKeys(username);\r\n\t\tpasswordTextField.sendKeys(password);\r\n\t\tlog",
"end": 674,
"score": 0.9934509992599487,
"start": 666,
"tag": "USERNAME",
"value": "username"
},
{
"context": "sendKeys(username);\r\n\t\tpasswordTextField.sendKeys(password);\r\n\t\tloginButton.click();\r\n\r\n\t}\r\n\r\n}\r\n",
"end": 715,
"score": 0.9976392388343811,
"start": 707,
"tag": "PASSWORD",
"value": "password"
}
] | null |
[] |
package actiTimePOMclass;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
public class Login2Page {
// HARD CODING
// USING BUSINESS LOGIC
public Login2Page(WebDriver driver) {
PageFactory.initElements(driver, this);
}
@FindBy(id = "username")
private WebElement usernameTextField;
@FindBy(name = "pwd")
private WebElement passwordTextField;
@FindBy(xpath = "//div[text()='Login ']")
private WebElement loginButton;
public void login(String username, String password) {
usernameTextField.sendKeys(username);
passwordTextField.sendKeys(<PASSWORD>);
loginButton.click();
}
}
| 756 | 0.730769 | 0.728117 | 33 | 20.848484 | 18.136053 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.030303 | false | false |
12
|
5448cc4f6801fc0badc40400fc8a7180934b629b
| 6,296,422,114,542 |
c67f6f4fe793cdb48b462e8637711ab1ffb4a74f
|
/src/test/java/lexicon/DrinksTest.java
|
0a327e74a332876c54d0abb8804ec6e920d0693d
|
[] |
no_license
|
Accapelo/Vendingmachine
|
https://github.com/Accapelo/Vendingmachine
|
706c1ac8bad02f0bfaec2443dc18368ae869f183
|
53b9e0d7ee43cdb0444e609c3c98a5415a03d0dc
|
refs/heads/master
| 2021-07-20T18:47:49.153000 | 2019-11-22T12:13:02 | 2019-11-22T12:13:02 | 223,396,110 | 0 | 0 | null | false | 2020-10-13T17:40:19 | 2019-11-22T12:13:16 | 2019-11-22T12:13:25 | 2020-10-13T17:40:17 | 11 | 0 | 0 | 1 |
Java
| false | false |
package lexicon;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class DrinksTest {
@Test
public void consumeDrinkTest(){
Drinks hotChocolate = new Drinks("Hot Chocolate",10,100,3);
String eat = hotChocolate.consume();
assertEquals("Hot Chocolate was consumed.", eat);
}
@Test
public void showInfoDrinkTest(){
Drinks hotChocolate = new Drinks("Hot Chocolate",10,100,3);
String eat = hotChocolate.showProductInfo();
assertEquals("Hot Chocolate, 10kr, 100c.", eat);
}
}
|
UTF-8
|
Java
| 576 |
java
|
DrinksTest.java
|
Java
|
[] | null |
[] |
package lexicon;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class DrinksTest {
@Test
public void consumeDrinkTest(){
Drinks hotChocolate = new Drinks("Hot Chocolate",10,100,3);
String eat = hotChocolate.consume();
assertEquals("Hot Chocolate was consumed.", eat);
}
@Test
public void showInfoDrinkTest(){
Drinks hotChocolate = new Drinks("Hot Chocolate",10,100,3);
String eat = hotChocolate.showProductInfo();
assertEquals("Hot Chocolate, 10kr, 100c.", eat);
}
}
| 576 | 0.657986 | 0.628472 | 26 | 21.153847 | 23.536701 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.730769 | false | false |
12
|
41a4714b12117b20b6f551dbd80339a5beffcdf6
| 9,603,546,889,143 |
87806f10d6befae06874e2f18327be1b7ef0c91c
|
/app/src/main/java/com/elijahbosley/textclockwidget/SettingsActivity.java
|
08b0ea10c0adf166f87ad73f8add6a32f6967a03
|
[] |
no_license
|
jrocharodrigues/NeloClockWidget
|
https://github.com/jrocharodrigues/NeloClockWidget
|
0e198c5934301d96652fc32e969d88edcbce2860
|
de3e4593587f492bf76b82b78845fcc3c1cada9e
|
refs/heads/master
| 2020-09-03T17:22:06.491000 | 2017-11-21T10:00:30 | 2017-11-21T10:00:30 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.elijahbosley.textclockwidget;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
/**
* Created by ekbos on 7/17/2016.
*/
public class SettingsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getFragmentManager().beginTransaction().replace(android.R.id.content, new MyPreferenceFragment()).commit();
try {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}catch (NullPointerException ex) {
System.out.println("no home");
}
}
@Override
public void onBackPressed() {
super.onBackPressed();
}
public static class MyPreferenceFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
PreferenceManager.getDefaultSharedPreferences(this.getActivity()).registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
System.out.println("key was: " + key);
if (key.equals("extra_spaces") || key.equals("caps_mode")) {
Intent updateWidgetIntent = new Intent(getActivity().getApplicationContext(), TextClockWidget.class);
updateWidgetIntent.setAction(TextClockWidget.COM_ELIJAHBOSLEY_TEXTCLOCK_UPDATE);
getActivity().getApplicationContext().sendBroadcast(updateWidgetIntent);
}
}
}
}
|
UTF-8
|
Java
| 1,925 |
java
|
SettingsActivity.java
|
Java
|
[
{
"context": "pport.v7.app.AppCompatActivity;\n\n/**\n * Created by ekbos on 7/17/2016.\n */\npublic class SettingsActivity e",
"end": 306,
"score": 0.9996767640113831,
"start": 301,
"tag": "USERNAME",
"value": "ekbos"
},
{
"context": "n(\"key was: \" + key);\n if (key.equals(\"extra_spaces\") || key.equals(\"caps_mode\")) {\n I",
"end": 1556,
"score": 0.8096909523010254,
"start": 1544,
"tag": "KEY",
"value": "extra_spaces"
},
{
"context": " if (key.equals(\"extra_spaces\") || key.equals(\"caps_mode\")) {\n Intent updateWidgetIntent = ",
"end": 1583,
"score": 0.8034985661506653,
"start": 1574,
"tag": "KEY",
"value": "caps_mode"
}
] | null |
[] |
package com.elijahbosley.textclockwidget;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
/**
* Created by ekbos on 7/17/2016.
*/
public class SettingsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getFragmentManager().beginTransaction().replace(android.R.id.content, new MyPreferenceFragment()).commit();
try {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}catch (NullPointerException ex) {
System.out.println("no home");
}
}
@Override
public void onBackPressed() {
super.onBackPressed();
}
public static class MyPreferenceFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
PreferenceManager.getDefaultSharedPreferences(this.getActivity()).registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
System.out.println("key was: " + key);
if (key.equals("extra_spaces") || key.equals("caps_mode")) {
Intent updateWidgetIntent = new Intent(getActivity().getApplicationContext(), TextClockWidget.class);
updateWidgetIntent.setAction(TextClockWidget.COM_ELIJAHBOSLEY_TEXTCLOCK_UPDATE);
getActivity().getApplicationContext().sendBroadcast(updateWidgetIntent);
}
}
}
}
| 1,925 | 0.705974 | 0.701818 | 52 | 36.01923 | 36.332066 | 135 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.461538 | false | false |
12
|
2c764bc5a6206eb14776744139d1ca806f491ccc
| 4,389,456,595,951 |
73bb3a192a9c9718cb9fdad1e15573b9b29007bc
|
/PhoneBookAPI/src/test/java/APITests/TestTwoPOSTPUTDELETE.java
|
1561eead7f42fe0ce0faa11dd9d51ea7f05dbee9
|
[] |
no_license
|
cromox1/Selenium_Java
|
https://github.com/cromox1/Selenium_Java
|
e0c026ac0ab94922b72b30dd3de81f0441c28d5f
|
d4e0b4142a1cdaea2d1bda59d6cd87887d875ab5
|
refs/heads/master
| 2023-05-29T10:53:55.063000 | 2020-10-14T11:24:34 | 2020-10-14T11:24:34 | 177,633,236 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package APITests;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import static org.junit.Assert.assertEquals;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestTwoPOSTPUTDELETE {
private static void testingString(String actual, String expected) {
assertEquals(expected, actual);
}
private static void testingInteger(int actual, int expected) { assertEquals(expected, actual); }
static String user1 = "testone";
@Test
public void test1POSTuser() {
String firstname = "Cubaan";
String inputPOST = "{ \"nickname\": \"" + user1 + "\", \"password\": \"" + user1 + "\", \"firstName\": \"" + firstname + "\" }";
testingInteger(RESTUtil.RESTPOSTName(inputPOST), 200);
}
@Test
public void test2GETuserAnonymous() {
testingString(RESTUtil.RESTGetNameAnonymous(user1), user1);
}
@Test
public void test3PUTuser() {
String firstname = "Testing";
String inputPOST = "{ \"nickname\": \"" + user1 + "\", \"password\": \"test123\", \"firstName\": \"" + firstname + "\" }";
testingInteger(RESTUtil.RESTPUTName(inputPOST, user1), 200);
}
@Test
public void test4GETmodifyuser() {
String firstname = "Testing";
testingString(RESTUtil.RESTGetFirstname(user1), firstname);
}
@Test
public void test5DELETEuser() {
testingInteger(RESTUtil.RESTDELETEuser(user1), 200);
}
}
|
UTF-8
|
Java
| 1,484 |
java
|
TestTwoPOSTPUTDELETE.java
|
Java
|
[
{
"context": "(expected, actual); }\n\n static String user1 = \"testone\";\n\n @Test\n public void test1POSTuser() {\n ",
"end": 499,
"score": 0.9994998574256897,
"start": 492,
"tag": "USERNAME",
"value": "testone"
},
{
"context": "nickname\\\": \\\"\" + user1 + \"\\\", \\\"password\\\": \\\"\" + user1 + \"\\\", \\\"firstName\\\": \\\"\" + firstname + \"\\\" }\";\n",
"end": 671,
"score": 0.5491482019424438,
"start": 667,
"tag": "PASSWORD",
"value": "user"
},
{
"context": " \\\"nickname\\\": \\\"\" + user1 + \"\\\", \\\"password\\\": \\\"test123\\\", \\\"firstName\\\": \\\"\" + firstname + \"\\\" }\";\n ",
"end": 1085,
"score": 0.9987422227859497,
"start": 1078,
"tag": "PASSWORD",
"value": "test123"
}
] | null |
[] |
package APITests;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import static org.junit.Assert.assertEquals;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestTwoPOSTPUTDELETE {
private static void testingString(String actual, String expected) {
assertEquals(expected, actual);
}
private static void testingInteger(int actual, int expected) { assertEquals(expected, actual); }
static String user1 = "testone";
@Test
public void test1POSTuser() {
String firstname = "Cubaan";
String inputPOST = "{ \"nickname\": \"" + user1 + "\", \"password\": \"" + <PASSWORD>1 + "\", \"firstName\": \"" + firstname + "\" }";
testingInteger(RESTUtil.RESTPOSTName(inputPOST), 200);
}
@Test
public void test2GETuserAnonymous() {
testingString(RESTUtil.RESTGetNameAnonymous(user1), user1);
}
@Test
public void test3PUTuser() {
String firstname = "Testing";
String inputPOST = "{ \"nickname\": \"" + user1 + "\", \"password\": \"<PASSWORD>\", \"firstName\": \"" + firstname + "\" }";
testingInteger(RESTUtil.RESTPUTName(inputPOST, user1), 200);
}
@Test
public void test4GETmodifyuser() {
String firstname = "Testing";
testingString(RESTUtil.RESTGetFirstname(user1), firstname);
}
@Test
public void test5DELETEuser() {
testingInteger(RESTUtil.RESTDELETEuser(user1), 200);
}
}
| 1,493 | 0.648922 | 0.631402 | 49 | 29.285715 | 32.523773 | 136 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.653061 | false | false |
12
|
2f70e223b8a5ae662e14f4c8871ff4775a3a60be
| 4,853,313,064,085 |
0b0702a3653687386de043b4d81b7414abce6cc9
|
/Assignment1/ExtraCredit.java
|
ac17b4973c75ed98afa1f87ce17d04faa6902b34
|
[] |
no_license
|
dsangal/Fall-2019
|
https://github.com/dsangal/Fall-2019
|
3dd338d447da084426dfb556c92ab5e64b4bc102
|
2b1421420628cb0fb61adac63e7a6c62f43113eb
|
refs/heads/master
| 2020-07-10T08:04:37.712000 | 2020-02-03T06:27:42 | 2020-02-03T06:27:42 | 204,213,145 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.util.Scanner;
public class ExtraCredit
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
double usr_input;
System.out.print("Insert dollar amount (e.g 12.56):");
usr_input=input.nextDouble() * 100; //converting to cents
double ten_dollar = (usr_input)/1000;
System.out.println("Number of $10 dollar bills = " + (int)ten_dollar);
usr_input = (usr_input) % 1000;
double temp = usr_input/100;
double five_dollar = temp / 5;
double one_dollar = temp % 5;
System.out.println("Number of $5 dollar bills = " + (int)five_dollar);
System.out.println("Number of $1 dollar bills = " + (int)one_dollar);
usr_input = (usr_input) % 100;
if (usr_input > 50) {
double fifty_cents = usr_input / 50;
usr_input = (usr_input) % 50;
System.out.println("Number of 50 cents = " + (int)fifty_cents);
}
if (usr_input > 25) {
double quarter = usr_input / 25;
usr_input = (usr_input) % 25;
System.out.println("Number of Quarters = " + (int)quarter);
}
if (usr_input > 10) {
double dime = usr_input / 10;
usr_input = (usr_input) % 10;
System.out.println("Number of Dimes = " + (int)dime);
}
double pennies = usr_input;
System.out.println("Number of Pennies = " + (int)pennies);
}
}
|
UTF-8
|
Java
| 1,405 |
java
|
ExtraCredit.java
|
Java
|
[] | null |
[] |
import java.util.Scanner;
public class ExtraCredit
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
double usr_input;
System.out.print("Insert dollar amount (e.g 12.56):");
usr_input=input.nextDouble() * 100; //converting to cents
double ten_dollar = (usr_input)/1000;
System.out.println("Number of $10 dollar bills = " + (int)ten_dollar);
usr_input = (usr_input) % 1000;
double temp = usr_input/100;
double five_dollar = temp / 5;
double one_dollar = temp % 5;
System.out.println("Number of $5 dollar bills = " + (int)five_dollar);
System.out.println("Number of $1 dollar bills = " + (int)one_dollar);
usr_input = (usr_input) % 100;
if (usr_input > 50) {
double fifty_cents = usr_input / 50;
usr_input = (usr_input) % 50;
System.out.println("Number of 50 cents = " + (int)fifty_cents);
}
if (usr_input > 25) {
double quarter = usr_input / 25;
usr_input = (usr_input) % 25;
System.out.println("Number of Quarters = " + (int)quarter);
}
if (usr_input > 10) {
double dime = usr_input / 10;
usr_input = (usr_input) % 10;
System.out.println("Number of Dimes = " + (int)dime);
}
double pennies = usr_input;
System.out.println("Number of Pennies = " + (int)pennies);
}
}
| 1,405 | 0.580071 | 0.546619 | 47 | 28.914894 | 23.766443 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.787234 | false | false |
12
|
a121e918ba6dce7172db372e5c1ac56e8e15d8df
| 6,571,299,984,908 |
4ccc7e7d24d63ec053f2ea584c411963104596f9
|
/src/main/java/stepdefinitions/HomePageSteps.java
|
f737ebec06c6cb440e8764062c32ea6fa3b8226e
|
[] |
no_license
|
YuliiaSikorska/Yuliia_Sikorska_Lviv_FinalTask
|
https://github.com/YuliiaSikorska/Yuliia_Sikorska_Lviv_FinalTask
|
a73e5be8135e7c3b1a1808b07d68752ccd70b677
|
ee30b86c9a5d5103f0920258a66e7f573f9c6283
|
refs/heads/master
| 2023-08-07T09:10:07.082000 | 2021-09-21T20:36:53 | 2021-09-21T20:36:53 | 408,966,187 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package stepdefinitions;
import io.cucumber.java.en.And;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import pages.HomePage;
import pages.PreferencesPage;
import static org.junit.Assert.assertTrue;
import static stepdefinitions.BasePageSteps.DEFAULT_TIMEOUT;
public class HomePageSteps {
HomePage homePage = new HomePage();
PreferencesPage preferencesPage = new PreferencesPage();
@Given("User opens {string} page")
public void openHomePage(final String url) {
homePage.openHomePage(url);
}
@When("User checks header visibility")
public void userChecksHeaderVisibility() {
homePage.waitForPageLoadComplete(DEFAULT_TIMEOUT);
assertTrue(homePage.isHeaderVisible());
}
@And("User checks footer visibility")
public void userChecksFooterVisibility() {
assertTrue(homePage.isFooterVisible());
}
@And("User checks search field visibility")
public void userChecksSearchFieldVisibility() {
assertTrue(homePage.isSearchFieldVisible());
}
@And("User checks My account icon visibility")
public void userChecksMyAccountIconVisibility() {
assertTrue(homePage.isMyAccountIconVisible());
}
@When("User clicks My account icon in header")
public void userClicksMyAccountIconInHeader() {
homePage.clickMyAccountIcon();
}
@And("User checks that My account popup is visible")
public void userChecksThatMyAccountPopupIsVisible() {
assertTrue(homePage.isMyAccountPopupVisible());
}
@And("User checks Saved items icon visibility")
public void userChecksSavedItemsIconVisibility() {
assertTrue(homePage.isSavedItemsIconVisible());
}
@And("User checks Bag icon visibility")
public void userChecksBagIconVisibility() {
assertTrue(homePage.isBagIconVisible());
}
@And("User checks Preferences button visibility")
public void userChecksPreferencesButtonVisibility() {
assertTrue(homePage.isPreferencesIconVisible());
}
@And("User clicks Preferences button")
public void userClicksPreferencesButton() {
homePage.clickPreferencesIcon();
}
@Then("User checks that Preferences popup is visible")
public void userChecksThatPreferencesPopupIsVisible() {
preferencesPage.waitVisibilityOfElement(30, preferencesPage.getPreferencesPopup());
assertTrue(preferencesPage.isPreferencesPopupVisible());
}
@And("User checks that country dropdown is visible on Preferences popup")
public void userChecksThatCountryDropdownIsVisible() {
assertTrue(preferencesPage.isCountryDropdownVisible());
}
@Then("User checks that currency dropdown is visible on Preferences popup")
public void userChecksThatCurrencyDropdownIsVisible() {
assertTrue(preferencesPage.isCurrencyDropdownVisible());
}
@Then("User clicks logo icon")
public void userClicksLogoIcon() {
homePage.waitForAjaxToComplete(30);
homePage.clickLogoAsos();
}
}
|
UTF-8
|
Java
| 3,076 |
java
|
HomePageSteps.java
|
Java
|
[] | null |
[] |
package stepdefinitions;
import io.cucumber.java.en.And;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import pages.HomePage;
import pages.PreferencesPage;
import static org.junit.Assert.assertTrue;
import static stepdefinitions.BasePageSteps.DEFAULT_TIMEOUT;
public class HomePageSteps {
HomePage homePage = new HomePage();
PreferencesPage preferencesPage = new PreferencesPage();
@Given("User opens {string} page")
public void openHomePage(final String url) {
homePage.openHomePage(url);
}
@When("User checks header visibility")
public void userChecksHeaderVisibility() {
homePage.waitForPageLoadComplete(DEFAULT_TIMEOUT);
assertTrue(homePage.isHeaderVisible());
}
@And("User checks footer visibility")
public void userChecksFooterVisibility() {
assertTrue(homePage.isFooterVisible());
}
@And("User checks search field visibility")
public void userChecksSearchFieldVisibility() {
assertTrue(homePage.isSearchFieldVisible());
}
@And("User checks My account icon visibility")
public void userChecksMyAccountIconVisibility() {
assertTrue(homePage.isMyAccountIconVisible());
}
@When("User clicks My account icon in header")
public void userClicksMyAccountIconInHeader() {
homePage.clickMyAccountIcon();
}
@And("User checks that My account popup is visible")
public void userChecksThatMyAccountPopupIsVisible() {
assertTrue(homePage.isMyAccountPopupVisible());
}
@And("User checks Saved items icon visibility")
public void userChecksSavedItemsIconVisibility() {
assertTrue(homePage.isSavedItemsIconVisible());
}
@And("User checks Bag icon visibility")
public void userChecksBagIconVisibility() {
assertTrue(homePage.isBagIconVisible());
}
@And("User checks Preferences button visibility")
public void userChecksPreferencesButtonVisibility() {
assertTrue(homePage.isPreferencesIconVisible());
}
@And("User clicks Preferences button")
public void userClicksPreferencesButton() {
homePage.clickPreferencesIcon();
}
@Then("User checks that Preferences popup is visible")
public void userChecksThatPreferencesPopupIsVisible() {
preferencesPage.waitVisibilityOfElement(30, preferencesPage.getPreferencesPopup());
assertTrue(preferencesPage.isPreferencesPopupVisible());
}
@And("User checks that country dropdown is visible on Preferences popup")
public void userChecksThatCountryDropdownIsVisible() {
assertTrue(preferencesPage.isCountryDropdownVisible());
}
@Then("User checks that currency dropdown is visible on Preferences popup")
public void userChecksThatCurrencyDropdownIsVisible() {
assertTrue(preferencesPage.isCurrencyDropdownVisible());
}
@Then("User clicks logo icon")
public void userClicksLogoIcon() {
homePage.waitForAjaxToComplete(30);
homePage.clickLogoAsos();
}
}
| 3,076 | 0.724317 | 0.723017 | 94 | 31.734043 | 24.542267 | 91 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.319149 | false | false |
12
|
e95da5f3b1884f912b0aede99224bbe31846b58c
| 6,571,299,986,209 |
16eab91eab2ead13fbf0e0fc5e0829ad357da221
|
/minirpc/minirpc-protocol/src/main/java/com/adlun/minirpc/protocol/protocol/MsgType.java
|
f661349ed2aa00c48e09629e47ad44f2ac5e91e1
|
[] |
no_license
|
adlun/minirpc
|
https://github.com/adlun/minirpc
|
c81d04ee93c0ceb560df0c1b45ab05503fb4e37b
|
6969eb33a11c0efb8a029ea5aa46389f87bb1606
|
refs/heads/main
| 2023-06-01T01:45:05.779000 | 2021-07-11T09:11:07 | 2021-07-11T09:11:07 | 384,903,188 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.adlun.minirpc.protocol.protocol;
import lombok.Getter;
public enum MsgType {
REQUEST((byte) 0),
RESPONSE((byte) 1),
HEARTBEAT((byte) 2);
@Getter
private byte type;
MsgType(byte type) {
this.type = type;
}
public static MsgType findByType(byte msgType) {
MsgType[] msgTypes = MsgType.values();
for (MsgType type : msgTypes) {
if (type.getType() == msgType) {
return type;
}
}
return null;
}
}
|
UTF-8
|
Java
| 528 |
java
|
MsgType.java
|
Java
|
[] | null |
[] |
package com.adlun.minirpc.protocol.protocol;
import lombok.Getter;
public enum MsgType {
REQUEST((byte) 0),
RESPONSE((byte) 1),
HEARTBEAT((byte) 2);
@Getter
private byte type;
MsgType(byte type) {
this.type = type;
}
public static MsgType findByType(byte msgType) {
MsgType[] msgTypes = MsgType.values();
for (MsgType type : msgTypes) {
if (type.getType() == msgType) {
return type;
}
}
return null;
}
}
| 528 | 0.549242 | 0.543561 | 29 | 17.206896 | 15.961979 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.344828 | false | false |
12
|
05160496e152c4a5ec5072eb8506ddb50a0c7b50
| 29,815,662,987,784 |
a8c0a71f7782c8fb35f360ff5ed9164e1eb28edb
|
/june-demo-practice/src/main/java/com/june/demo/guava/collection/GuavaCollectionTest.java
|
3860c458f7d38d5a9a9edd4546b6f99673ffac10
|
[] |
no_license
|
hzchengchen1/june-demo
|
https://github.com/hzchengchen1/june-demo
|
5d025cdb3278170c7d6e3a8bdf21dd951429d7ea
|
b9b7b735ecf5b68de83b3557b257367eaacb9220
|
refs/heads/master
| 2020-04-03T15:56:36.922000 | 2018-12-17T13:02:30 | 2018-12-17T13:02:30 | 155,384,095 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.june.demo.guava.collection;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.Table;
/**
* Reference: https://www.yiibai.com/guava/
*
* @author think
*/
public class GuavaCollectionTest {
/**
* com.google.common.collect.BiMap demo
* BiMap: confirm with distinct value in map.
* support for querying map key by inverse function.
*/
private static void biMapDemo() {
BiMap<String, Object> biMap = HashBiMap.create();
biMap.put("a", 1);
biMap.put("a", 7);
biMap.put("b", 2);
biMap.put("c", 3);
biMap.forcePut("e", 2);
System.out.println(biMap.toString());
System.out.println(biMap.inverse());
System.out.println(biMap.inverse().get(3));
biMap.put("d", 3);
System.out.println(biMap.toString());
}
/**
* com.google.common.collect.Table demo
* <b>Table<rowKey, columnKey, value></b>
*/
private static void tableDemo() {
Table<String, Integer, Object> table = HashBasedTable.create();
table.put("row1", 1, "1.1");
table.put("row1", 2, "1.2");
table.put("row2", 1, "2.1");
table.put("row2", 2, "2.2");
System.out.println(table);
System.out.println(table.row("row2"));
System.out.println(table.rowKeySet());
}
public static void main(String[] args) {
tableDemo();
biMapDemo();
}
}
|
UTF-8
|
Java
| 1,544 |
java
|
GuavaCollectionTest.java
|
Java
|
[
{
"context": "rence: https://www.yiibai.com/guava/\n *\n * @author think\n */\npublic class GuavaCollectionTest {\n\n /**\n ",
"end": 282,
"score": 0.987670361995697,
"start": 277,
"tag": "USERNAME",
"value": "think"
}
] | null |
[] |
package com.june.demo.guava.collection;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.Table;
/**
* Reference: https://www.yiibai.com/guava/
*
* @author think
*/
public class GuavaCollectionTest {
/**
* com.google.common.collect.BiMap demo
* BiMap: confirm with distinct value in map.
* support for querying map key by inverse function.
*/
private static void biMapDemo() {
BiMap<String, Object> biMap = HashBiMap.create();
biMap.put("a", 1);
biMap.put("a", 7);
biMap.put("b", 2);
biMap.put("c", 3);
biMap.forcePut("e", 2);
System.out.println(biMap.toString());
System.out.println(biMap.inverse());
System.out.println(biMap.inverse().get(3));
biMap.put("d", 3);
System.out.println(biMap.toString());
}
/**
* com.google.common.collect.Table demo
* <b>Table<rowKey, columnKey, value></b>
*/
private static void tableDemo() {
Table<String, Integer, Object> table = HashBasedTable.create();
table.put("row1", 1, "1.1");
table.put("row1", 2, "1.2");
table.put("row2", 1, "2.1");
table.put("row2", 2, "2.2");
System.out.println(table);
System.out.println(table.row("row2"));
System.out.println(table.rowKeySet());
}
public static void main(String[] args) {
tableDemo();
biMapDemo();
}
}
| 1,544 | 0.59715 | 0.581606 | 53 | 28.132076 | 18.858997 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.849057 | false | false |
12
|
38b37e83e218f2239200accc22f3b3ee12e570ff
| 20,753,281,989,561 |
d4d43514d9da6cf99c2910f34464a884156e5844
|
/Banco/src/br/com/caelum/contas/modelo/Conta.java
|
7bf48039c90490d7218b33dd279d9f3c051a509b
|
[] |
no_license
|
rodrigohs16/FJ11
|
https://github.com/rodrigohs16/FJ11
|
cacab9a2f324910c46ae8eb137d5a31bbc0fcee0
|
9753a98343b077b67e6d3785399201eb35d9a3ee
|
refs/heads/master
| 2021-09-09T22:31:55.186000 | 2018-03-20T02:12:06 | 2018-03-20T02:12:06 | 125,648,038 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package br.com.caelum.contas.modelo;
/**
*
* @author Rodrigo Salinas
*
*/
public abstract class Conta {
public abstract String getTipo();// {
// return "Conta";
// }
private int numero;
private String agencia;
private String titular;
protected double saldo;
private double limite;
private Data dataDeAbertura;
// Numero
public void setNumero(int numero) {
this.numero = numero;
}
public int getNumero() {
return numero;
}
// Agencia
public void setAgencia(String agencia) {
this.agencia = agencia;
}
public String getAgencia() {
return agencia;
}
// Titular
public void setTitular(String titular) {
this.titular = titular;
}
public String getTitular() {
return titular;
}
// Não vamos usar o setSaldo, pois o usuario pode mudar saldo.
/*
* public void setSaldo(double saldo){ this.saldo = saldo; }
*/
// Saldo
public double getSaldo() {
return saldo;
}
// Limite
public void setLimite(double limite) {
this.limite = limite;
}
public double getLimite() {
return limite;
}
// Data
public void setDataDeAbertura(Data dataDeAbertura) {
this.dataDeAbertura = dataDeAbertura;
}
public Data getDataDeAbertura() {
return dataDeAbertura;
}
// Construtor - Segundo JavaBeans, deve criar um construtor vazio, ou seja,
// sem parâmetro.
public Conta() {
limite = 1000;
}
// Construtor passando como parâmetro o Titular, ou seja, obrigando que
// tenha o Titular quando a conta seja criada.
public Conta(String titular) {
this.titular = titular;
}
/**
*
* @param valor
* Valor a ser sacado da conta
* @return true se sacou
*/
public boolean saca(double valor) {
// saldo + limite >= valor - foi criado desta forma para que quando
// tentar sacar um valor negativo, não deva ficar com saldo positivo, ou
// seja, menos com menos = mais.
if (valor > 0 && saldo + limite >= valor) {
saldo -= valor;
return true;
}
return false;
}
public void deposita(double valor) {
if (valor < 0) {
throw new IllegalArgumentException("Voce tentou depositar " + valor + ". Favor depositar valor positivo");
} else {
saldo += valor;
}
}
public double calculaRendimento() {
double calcula;
calcula = saldo * 0.1;
return calcula;
// return saldo * 0.1 - poderia fazer assim também. Mais sucinto.
}
String recuperaDadosParaImpressao() {
String dados = "Titular: " + titular;
dados += "\nSaldo: " + saldo;
dados += "\n" + dataDeAbertura.formataData();
dados += "\n-------------";
return dados;
}
public void transfere(Conta destino, double valor) {
if (saca(valor)) {
destino.deposita(valor);
}
}
/*
* public void transfere(double valor, Conta conta){ this.saca(valor);
* conta.deposita(valor); }
*/
}
|
UTF-8
|
Java
| 2,770 |
java
|
Conta.java
|
Java
|
[
{
"context": "e br.com.caelum.contas.modelo;\n\n/**\n * \n * @author Rodrigo Salinas\n *\n */\npublic abstract class Conta {\n\n\tpublic abs",
"end": 72,
"score": 0.9997045397758484,
"start": 57,
"tag": "NAME",
"value": "Rodrigo Salinas"
}
] | null |
[] |
package br.com.caelum.contas.modelo;
/**
*
* @author <NAME>
*
*/
public abstract class Conta {
public abstract String getTipo();// {
// return "Conta";
// }
private int numero;
private String agencia;
private String titular;
protected double saldo;
private double limite;
private Data dataDeAbertura;
// Numero
public void setNumero(int numero) {
this.numero = numero;
}
public int getNumero() {
return numero;
}
// Agencia
public void setAgencia(String agencia) {
this.agencia = agencia;
}
public String getAgencia() {
return agencia;
}
// Titular
public void setTitular(String titular) {
this.titular = titular;
}
public String getTitular() {
return titular;
}
// Não vamos usar o setSaldo, pois o usuario pode mudar saldo.
/*
* public void setSaldo(double saldo){ this.saldo = saldo; }
*/
// Saldo
public double getSaldo() {
return saldo;
}
// Limite
public void setLimite(double limite) {
this.limite = limite;
}
public double getLimite() {
return limite;
}
// Data
public void setDataDeAbertura(Data dataDeAbertura) {
this.dataDeAbertura = dataDeAbertura;
}
public Data getDataDeAbertura() {
return dataDeAbertura;
}
// Construtor - Segundo JavaBeans, deve criar um construtor vazio, ou seja,
// sem parâmetro.
public Conta() {
limite = 1000;
}
// Construtor passando como parâmetro o Titular, ou seja, obrigando que
// tenha o Titular quando a conta seja criada.
public Conta(String titular) {
this.titular = titular;
}
/**
*
* @param valor
* Valor a ser sacado da conta
* @return true se sacou
*/
public boolean saca(double valor) {
// saldo + limite >= valor - foi criado desta forma para que quando
// tentar sacar um valor negativo, não deva ficar com saldo positivo, ou
// seja, menos com menos = mais.
if (valor > 0 && saldo + limite >= valor) {
saldo -= valor;
return true;
}
return false;
}
public void deposita(double valor) {
if (valor < 0) {
throw new IllegalArgumentException("Voce tentou depositar " + valor + ". Favor depositar valor positivo");
} else {
saldo += valor;
}
}
public double calculaRendimento() {
double calcula;
calcula = saldo * 0.1;
return calcula;
// return saldo * 0.1 - poderia fazer assim também. Mais sucinto.
}
String recuperaDadosParaImpressao() {
String dados = "Titular: " + titular;
dados += "\nSaldo: " + saldo;
dados += "\n" + dataDeAbertura.formataData();
dados += "\n-------------";
return dados;
}
public void transfere(Conta destino, double valor) {
if (saca(valor)) {
destino.deposita(valor);
}
}
/*
* public void transfere(double valor, Conta conta){ this.saca(valor);
* conta.deposita(valor); }
*/
}
| 2,761 | 0.663653 | 0.660036 | 139 | 18.899281 | 20.486982 | 109 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.438849 | false | false |
12
|
006ab38d37052b28ac57701063d31577f8802f36
| 8,873,402,457,345 |
dd6f21e83d58363215a7cfed80e7d92e1a28a931
|
/sound-common/src/main/java/com/sound/model/BigVAlbum.java
|
d56be47121f4b7d7e5983ebe4b6b1d955d182002
|
[] |
no_license
|
huang054/sound
|
https://github.com/huang054/sound
|
b8fea7c054bdf4852604e64ffbb8ca3b30218d87
|
194c62008b7071fd80e3aecc2e553fd04b94c401
|
refs/heads/master
| 2020-03-29T05:05:46.421000 | 2018-10-15T08:16:40 | 2018-10-15T08:16:40 | 149,566,189 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.sound.model;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import io.swagger.annotations.ApiModelProperty;
@Entity(name ="BigVAlbum")
@Table(name = "big_v_album")
public class BigVAlbum implements Serializable{
/**
* 大V专辑
*/
private static final long serialVersionUID = 1L;
@ApiModelProperty(hidden = true)
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private long id;
@Column(columnDefinition="varchar(64) DEFAULT ''")
private String bigVName;
@Column(columnDefinition="varchar(64) DEFAULT ''")
private String bigVUrl;
@Column(columnDefinition="bigint(20) DEFAULT 0")
private long hearingNumber;
@Column(columnDefinition="varchar(255) DEFAULT ''")
private String context;
@Column(columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
private Date createTime;
@Column(columnDefinition="tinyint(1) default 0")
private boolean isRecommended;
/* @OneToMany(mappedBy = "albumId",cascade=CascadeType.ALL,fetch=FetchType.LAZY)
private List<AudioModel> audios;*/
public boolean isRecommended() {
return isRecommended;
}
public void setRecommended(boolean isRecommended) {
this.isRecommended = isRecommended;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getBigVName() {
return bigVName;
}
public void setBigVName(String bigVName) {
this.bigVName = bigVName;
}
public String getBigVUrl() {
return bigVUrl;
}
public void setBigVUrl(String bigVUrl) {
this.bigVUrl = bigVUrl;
}
public long getHearingNumber() {
return hearingNumber;
}
public void setHearingNumber(long hearingNumber) {
this.hearingNumber = hearingNumber;
}
public String getContext() {
return context;
}
public void setContext(String context) {
this.context = context;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/*public List<AudioModel> getAudios() {
return audios;
}
public void setAudios(List<AudioModel> audios) {
this.audios = audios;
}*/
@Override
public String toString() {
return "BigVAlbum [id=" + id + ", bigVName=" + bigVName + ", bigVUrl=" + bigVUrl + ", hearingNumber="
+ hearingNumber + ", context=" + context + ", createTime=" + createTime + ", isRecommended="
+ isRecommended + "]";
}
}
|
UTF-8
|
Java
| 2,694 |
java
|
BigVAlbum.java
|
Java
|
[] | null |
[] |
package com.sound.model;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import io.swagger.annotations.ApiModelProperty;
@Entity(name ="BigVAlbum")
@Table(name = "big_v_album")
public class BigVAlbum implements Serializable{
/**
* 大V专辑
*/
private static final long serialVersionUID = 1L;
@ApiModelProperty(hidden = true)
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private long id;
@Column(columnDefinition="varchar(64) DEFAULT ''")
private String bigVName;
@Column(columnDefinition="varchar(64) DEFAULT ''")
private String bigVUrl;
@Column(columnDefinition="bigint(20) DEFAULT 0")
private long hearingNumber;
@Column(columnDefinition="varchar(255) DEFAULT ''")
private String context;
@Column(columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
private Date createTime;
@Column(columnDefinition="tinyint(1) default 0")
private boolean isRecommended;
/* @OneToMany(mappedBy = "albumId",cascade=CascadeType.ALL,fetch=FetchType.LAZY)
private List<AudioModel> audios;*/
public boolean isRecommended() {
return isRecommended;
}
public void setRecommended(boolean isRecommended) {
this.isRecommended = isRecommended;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getBigVName() {
return bigVName;
}
public void setBigVName(String bigVName) {
this.bigVName = bigVName;
}
public String getBigVUrl() {
return bigVUrl;
}
public void setBigVUrl(String bigVUrl) {
this.bigVUrl = bigVUrl;
}
public long getHearingNumber() {
return hearingNumber;
}
public void setHearingNumber(long hearingNumber) {
this.hearingNumber = hearingNumber;
}
public String getContext() {
return context;
}
public void setContext(String context) {
this.context = context;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/*public List<AudioModel> getAudios() {
return audios;
}
public void setAudios(List<AudioModel> audios) {
this.audios = audios;
}*/
@Override
public String toString() {
return "BigVAlbum [id=" + id + ", bigVName=" + bigVName + ", bigVUrl=" + bigVUrl + ", hearingNumber="
+ hearingNumber + ", context=" + context + ", createTime=" + createTime + ", isRecommended="
+ isRecommended + "]";
}
}
| 2,694 | 0.738095 | 0.733259 | 105 | 24.6 | 20.729826 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.447619 | false | false |
12
|
81bd9067ec4c7adcf7a4b18bed5b1ff532eb93f2
| 12,412,455,511,539 |
23dbb45d9d81dfd8be9053b90f3d7f7bedd77ee1
|
/fluentgen/src/main/java/com/azure/autorest/fluent/template/FluentResourceModelInterfaceDefinitionTemplate.java
|
7103c6f0242b1f6881f3f2346dff41510e2a002a
|
[
"MIT",
"LicenseRef-scancode-generic-cla"
] |
permissive
|
Azure/autorest.java
|
https://github.com/Azure/autorest.java
|
aa15d03b3024938305ea8eaf5f441c7928410f13
|
6d3a0b853cdaffa269231eeb1c2cb581161888cc
|
refs/heads/main
| 2023-09-03T07:10:13.771000 | 2023-09-01T02:53:08 | 2023-09-01T02:53:08 | 100,315,700 | 34 | 81 |
MIT
| false | 2023-09-14T07:04:49 | 2017-08-14T22:53:39 | 2023-08-24T20:21:59 | 2023-09-14T07:04:47 | 203,551 | 29 | 78 | 124 |
Java
| false | false |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.autorest.fluent.template;
import com.azure.autorest.fluent.model.clientmodel.ModelNaming;
import com.azure.autorest.fluent.model.clientmodel.fluentmodel.method.FluentMethod;
import com.azure.autorest.fluent.model.clientmodel.fluentmodel.create.DefinitionStage;
import com.azure.autorest.fluent.model.clientmodel.fluentmodel.create.ResourceCreate;
import com.azure.autorest.model.javamodel.JavaInterface;
import com.azure.autorest.template.IJavaTemplate;
import java.util.List;
import java.util.stream.Collectors;
public class FluentResourceModelInterfaceDefinitionTemplate implements IJavaTemplate<ResourceCreate, JavaInterface> {
@Override
public void write(ResourceCreate resourceCreate, JavaInterface interfaceBlock) {
List<DefinitionStage> definitionStages = resourceCreate.getDefinitionStages();
final String modelName = resourceCreate.getResourceModel().getInterfaceType().getName();
// Definition interface
interfaceBlock.javadocComment(commentBlock -> {
commentBlock.description(String.format("The entirety of the %1$s definition.", modelName));
});
String definitionInterfaceSignature = String.format("%1$s extends %2$s",
ModelNaming.MODEL_FLUENT_INTERFACE_DEFINITION,
definitionStages.stream()
.filter(DefinitionStage::isMandatoryStage)
.map(s -> String.format("%1$s.%2$s", ModelNaming.MODEL_FLUENT_INTERFACE_DEFINITION_STAGES, s.getName()))
.collect(Collectors.joining(", ")));
interfaceBlock.interfaceBlock(definitionInterfaceSignature, block1 -> {
});
// DefinitionStages interface
interfaceBlock.javadocComment(commentBlock -> {
commentBlock.description(String.format("The %1$s definition stages.", modelName));
});
interfaceBlock.interfaceBlock(ModelNaming.MODEL_FLUENT_INTERFACE_DEFINITION_STAGES, block1 -> {
for (DefinitionStage stage : definitionStages) {
block1.javadocComment(commentBlock -> {
commentBlock.description(stage.getDescription(modelName));
});
String interfaceSignature = stage.getName();
if (stage.getExtendStages() != null) {
interfaceSignature += " extends " + stage.getExtendStages();
}
block1.interfaceBlock(interfaceSignature, block2 -> {
for (FluentMethod method : stage.getMethods()) {
block2.javadocComment(method::writeJavadoc);
block2.publicMethod(method.getInterfaceMethodSignature());
}
});
}
});
}
}
|
UTF-8
|
Java
| 2,878 |
java
|
FluentResourceModelInterfaceDefinitionTemplate.java
|
Java
|
[] | null |
[] |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.autorest.fluent.template;
import com.azure.autorest.fluent.model.clientmodel.ModelNaming;
import com.azure.autorest.fluent.model.clientmodel.fluentmodel.method.FluentMethod;
import com.azure.autorest.fluent.model.clientmodel.fluentmodel.create.DefinitionStage;
import com.azure.autorest.fluent.model.clientmodel.fluentmodel.create.ResourceCreate;
import com.azure.autorest.model.javamodel.JavaInterface;
import com.azure.autorest.template.IJavaTemplate;
import java.util.List;
import java.util.stream.Collectors;
public class FluentResourceModelInterfaceDefinitionTemplate implements IJavaTemplate<ResourceCreate, JavaInterface> {
@Override
public void write(ResourceCreate resourceCreate, JavaInterface interfaceBlock) {
List<DefinitionStage> definitionStages = resourceCreate.getDefinitionStages();
final String modelName = resourceCreate.getResourceModel().getInterfaceType().getName();
// Definition interface
interfaceBlock.javadocComment(commentBlock -> {
commentBlock.description(String.format("The entirety of the %1$s definition.", modelName));
});
String definitionInterfaceSignature = String.format("%1$s extends %2$s",
ModelNaming.MODEL_FLUENT_INTERFACE_DEFINITION,
definitionStages.stream()
.filter(DefinitionStage::isMandatoryStage)
.map(s -> String.format("%1$s.%2$s", ModelNaming.MODEL_FLUENT_INTERFACE_DEFINITION_STAGES, s.getName()))
.collect(Collectors.joining(", ")));
interfaceBlock.interfaceBlock(definitionInterfaceSignature, block1 -> {
});
// DefinitionStages interface
interfaceBlock.javadocComment(commentBlock -> {
commentBlock.description(String.format("The %1$s definition stages.", modelName));
});
interfaceBlock.interfaceBlock(ModelNaming.MODEL_FLUENT_INTERFACE_DEFINITION_STAGES, block1 -> {
for (DefinitionStage stage : definitionStages) {
block1.javadocComment(commentBlock -> {
commentBlock.description(stage.getDescription(modelName));
});
String interfaceSignature = stage.getName();
if (stage.getExtendStages() != null) {
interfaceSignature += " extends " + stage.getExtendStages();
}
block1.interfaceBlock(interfaceSignature, block2 -> {
for (FluentMethod method : stage.getMethods()) {
block2.javadocComment(method::writeJavadoc);
block2.publicMethod(method.getInterfaceMethodSignature());
}
});
}
});
}
}
| 2,878 | 0.664698 | 0.660181 | 59 | 47.779659 | 34.834751 | 128 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.627119 | false | false |
12
|
7370f8d1c59739ffec48290843f49d68e96dae47
| 12,910,671,722,198 |
39accc3d716c22a24ffab702a06db27773f5dc8e
|
/model/src/main/java/com/cubearrow/model/rewriting/patterns/GenericPatternVariable.java
|
ca931dfaea417dbc17a1694dcdaf29d90021dedb
|
[
"MIT"
] |
permissive
|
xCubeArrow/EquationSolver
|
https://github.com/xCubeArrow/EquationSolver
|
f0fb0f9545fb581cda603b77917b0f48c39d7bd2
|
f1f813059b3e49f54a9fdc2b28e037b66932a4ca
|
refs/heads/master
| 2020-09-28T05:24:43.991000 | 2020-05-31T15:41:30 | 2020-05-31T15:41:30 | 226,699,512 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.cubearrow.model.rewriting.patterns;
import com.cubearrow.model.tree.Node;
public class GenericPatternVariable extends Node implements GenericPattern{
private final int patternIndex;
public GenericPatternVariable(int patternIndex, Node parent) {
super(null, null, parent);
this.patternIndex = patternIndex;
}
public int getPatternIndex() {
return patternIndex;
}
@Override
public String toString() {
return "$var" + patternIndex;
}
}
|
UTF-8
|
Java
| 515 |
java
|
GenericPatternVariable.java
|
Java
|
[] | null |
[] |
package com.cubearrow.model.rewriting.patterns;
import com.cubearrow.model.tree.Node;
public class GenericPatternVariable extends Node implements GenericPattern{
private final int patternIndex;
public GenericPatternVariable(int patternIndex, Node parent) {
super(null, null, parent);
this.patternIndex = patternIndex;
}
public int getPatternIndex() {
return patternIndex;
}
@Override
public String toString() {
return "$var" + patternIndex;
}
}
| 515 | 0.695146 | 0.695146 | 22 | 22.40909 | 22.388428 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.454545 | false | false |
12
|
13bd3a010c4ce78eb07afe6ca6523c949b9b9592
| 6,227,702,603,148 |
ae0eb425aa35a5d5a89db80ab66250f877dc126f
|
/app/src/main/java/comt/leo/picker/moreaboutview/adapter/ImpressWordAdapter.java
|
f7a23f89c709ce8c761e92b8487192253be69e7b
|
[] |
no_license
|
lihangleo2/More-AboutView
|
https://github.com/lihangleo2/More-AboutView
|
fa710bce41535925a4050b7325a472a39057d99f
|
64b583a9e7a89b61bdc0e3150def90cc18d1e509
|
refs/heads/master
| 2021-07-07T13:02:12.272000 | 2020-07-29T11:51:31 | 2020-07-29T11:51:31 | 161,316,540 | 6 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package comt.leo.picker.moreaboutview.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagAdapter;
import com.zhy.view.flowlayout.TagFlowLayout;
import java.util.ArrayList;
import comt.leo.picker.moreaboutview.R;
import comt.leo.picker.moreaboutview.bean.ImpressSonBean;
import comt.leo.picker.moreaboutview.bean.NewImpressItemBean;
/**
* Created by lihang on 2016/4/18.
*/
public class ImpressWordAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private ArrayList<NewImpressItemBean> impressList;
private Context context;
private LayoutInflater inflate;
private View.OnClickListener listener;
public static final int TYPE_1 = 0;//显示第一印象 // 第一印象和展开的现在是统一个
public static final int TYPE_2 = 1;//显示我对Ta的印象
public ImpressWordAdapter(Context context, View.OnClickListener listener) {
this.context = context;
inflate = LayoutInflater.from(context);
this.listener = listener;
}
public void setData(ArrayList<NewImpressItemBean> impressList) {
this.impressList = impressList;
}
@Override
public int getItemViewType(int position) {
if (impressList.get(position).getCode().equals("flag")) {//第一印象
return TYPE_1;
} else {
return TYPE_2;
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
RecyclerView.ViewHolder holder = null;
View v;
switch (viewType) {
case TYPE_1://第一印象
v = inflate.inflate(R.layout.item_new_impress_, null);
holder = new FirstImpressHolder(v);
break;
case TYPE_2:
v = inflate.inflate(R.layout.item_impress_zhank, null);
holder = new ZhankHolder(v);
break;
}
return holder;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
final NewImpressItemBean itemBean = impressList.get(position);
if (holder instanceof FirstImpressHolder) {//第一印象
final FirstImpressHolder firstImpressHolder = (FirstImpressHolder) holder;
//初始化适配器
TagAdapter tagAdapter = new TagAdapter<ImpressSonBean>(itemBean.getTagList()) {
@Override
public View getView(FlowLayout parent, int position, ImpressSonBean s) {
RelativeLayout tv = (RelativeLayout) inflate.inflate(R.layout.item_leo_flag,
firstImpressHolder.tagFlowLayout, false);
TextView text_content = (TextView) tv.findViewById(R.id.text_content);//标签内容
TextView text_point_num = tv.findViewById(R.id.text_point_num);//小圆点数字
text_content.setText("#" + s.getTitle() + "#");
if (s.getTagCount() > 1) {
text_point_num.setVisibility(View.VISIBLE);
text_point_num.setText(s.getTagCount() + "");
} else {
text_point_num.setVisibility(View.GONE);
}
return tv;
}
};
firstImpressHolder.tagFlowLayout.setAdapter(tagAdapter);
} else if (holder instanceof ZhankHolder) {
ZhankHolder zhankHolder = (ZhankHolder) holder;
zhankHolder.text_zhankItem.setText(itemBean.getRemark());
zhankHolder.text_zhankItem.setTag(itemBean);
zhankHolder.text_zhankItem.setOnClickListener(listener);
}
}
@Override
public int getItemCount() {
return impressList == null ? 0 : impressList.size();
}
class FirstImpressHolder extends RecyclerView.ViewHolder {//第一印象
TagFlowLayout tagFlowLayout;
public FirstImpressHolder(View itemView) {
super(itemView);
tagFlowLayout = itemView.findViewById(R.id.tagFlowLayout);
}
}
class ZhankHolder extends RecyclerView.ViewHolder {//展开的那个条目
TextView text_zhankItem;
public ZhankHolder(View itemView) {
super(itemView);
text_zhankItem = itemView.findViewById(R.id.text_zhankItem);
}
}
}
|
UTF-8
|
Java
| 4,812 |
java
|
ImpressWordAdapter.java
|
Java
|
[
{
"context": "w.bean.NewImpressItemBean;\r\n\r\n\r\n/**\r\n * Created by lihang on 2016/4/18.\r\n */\r\npublic class ImpressWordAdapt",
"end": 665,
"score": 0.998429536819458,
"start": 659,
"tag": "USERNAME",
"value": "lihang"
}
] | null |
[] |
package comt.leo.picker.moreaboutview.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagAdapter;
import com.zhy.view.flowlayout.TagFlowLayout;
import java.util.ArrayList;
import comt.leo.picker.moreaboutview.R;
import comt.leo.picker.moreaboutview.bean.ImpressSonBean;
import comt.leo.picker.moreaboutview.bean.NewImpressItemBean;
/**
* Created by lihang on 2016/4/18.
*/
public class ImpressWordAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private ArrayList<NewImpressItemBean> impressList;
private Context context;
private LayoutInflater inflate;
private View.OnClickListener listener;
public static final int TYPE_1 = 0;//显示第一印象 // 第一印象和展开的现在是统一个
public static final int TYPE_2 = 1;//显示我对Ta的印象
public ImpressWordAdapter(Context context, View.OnClickListener listener) {
this.context = context;
inflate = LayoutInflater.from(context);
this.listener = listener;
}
public void setData(ArrayList<NewImpressItemBean> impressList) {
this.impressList = impressList;
}
@Override
public int getItemViewType(int position) {
if (impressList.get(position).getCode().equals("flag")) {//第一印象
return TYPE_1;
} else {
return TYPE_2;
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
RecyclerView.ViewHolder holder = null;
View v;
switch (viewType) {
case TYPE_1://第一印象
v = inflate.inflate(R.layout.item_new_impress_, null);
holder = new FirstImpressHolder(v);
break;
case TYPE_2:
v = inflate.inflate(R.layout.item_impress_zhank, null);
holder = new ZhankHolder(v);
break;
}
return holder;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
final NewImpressItemBean itemBean = impressList.get(position);
if (holder instanceof FirstImpressHolder) {//第一印象
final FirstImpressHolder firstImpressHolder = (FirstImpressHolder) holder;
//初始化适配器
TagAdapter tagAdapter = new TagAdapter<ImpressSonBean>(itemBean.getTagList()) {
@Override
public View getView(FlowLayout parent, int position, ImpressSonBean s) {
RelativeLayout tv = (RelativeLayout) inflate.inflate(R.layout.item_leo_flag,
firstImpressHolder.tagFlowLayout, false);
TextView text_content = (TextView) tv.findViewById(R.id.text_content);//标签内容
TextView text_point_num = tv.findViewById(R.id.text_point_num);//小圆点数字
text_content.setText("#" + s.getTitle() + "#");
if (s.getTagCount() > 1) {
text_point_num.setVisibility(View.VISIBLE);
text_point_num.setText(s.getTagCount() + "");
} else {
text_point_num.setVisibility(View.GONE);
}
return tv;
}
};
firstImpressHolder.tagFlowLayout.setAdapter(tagAdapter);
} else if (holder instanceof ZhankHolder) {
ZhankHolder zhankHolder = (ZhankHolder) holder;
zhankHolder.text_zhankItem.setText(itemBean.getRemark());
zhankHolder.text_zhankItem.setTag(itemBean);
zhankHolder.text_zhankItem.setOnClickListener(listener);
}
}
@Override
public int getItemCount() {
return impressList == null ? 0 : impressList.size();
}
class FirstImpressHolder extends RecyclerView.ViewHolder {//第一印象
TagFlowLayout tagFlowLayout;
public FirstImpressHolder(View itemView) {
super(itemView);
tagFlowLayout = itemView.findViewById(R.id.tagFlowLayout);
}
}
class ZhankHolder extends RecyclerView.ViewHolder {//展开的那个条目
TextView text_zhankItem;
public ZhankHolder(View itemView) {
super(itemView);
text_zhankItem = itemView.findViewById(R.id.text_zhankItem);
}
}
}
| 4,812 | 0.612986 | 0.609141 | 142 | 30.97183 | 28.412689 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.478873 | false | false |
12
|
681193db375e8f965baa34a228ae113abdf240fd
| 2,980,707,322,426 |
878a2f4f4c425ed22bf5452adb5c3705fafb258b
|
/Aula11/src/testepainel.java
|
0868192849c69e79b952704458a032d9ac25fece
|
[] |
no_license
|
AndrePS2021/Serratec-Programacao-Orientada-Objeto
|
https://github.com/AndrePS2021/Serratec-Programacao-Orientada-Objeto
|
4a620fc2ac2be4239da7f9dd52dda56c20d019d8
|
fb88613ff17ba3750bf18d4e09d344842e0b62de
|
refs/heads/main
| 2023-08-22T13:40:35.373000 | 2021-10-13T12:29:33 | 2021-10-13T12:29:33 | 415,423,279 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package Painel;
import javax.swing.JOptionPane;
public class testepainel {
public static void main(String[] args) {
JOptionPane.showInputDialog(null, "mensagem aki", "aki o tipo de mensagem: informação - erro - pergunta");
String[] opcoes = {"Fechar", "Sair"};
JOptionPane.showOptionDialog(null, "TEXTO", "TITULO!", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, opcoes, opcoes[0]);
}
}
|
ISO-8859-1
|
Java
| 427 |
java
|
testepainel.java
|
Java
|
[] | null |
[] |
package Painel;
import javax.swing.JOptionPane;
public class testepainel {
public static void main(String[] args) {
JOptionPane.showInputDialog(null, "mensagem aki", "aki o tipo de mensagem: informação - erro - pergunta");
String[] opcoes = {"Fechar", "Sair"};
JOptionPane.showOptionDialog(null, "TEXTO", "TITULO!", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, opcoes, opcoes[0]);
}
}
| 427 | 0.712941 | 0.710588 | 13 | 30.692308 | 42.20533 | 138 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.538462 | false | false |
12
|
3f2f0306b1543afcf43817aa2fa6206ff998f764
| 30,915,174,658,077 |
0347165879f6e2e4c5dacab830ab55fe90817a53
|
/LeetCode/020 - Valid Parentheses.java
|
9d6d11eb6fe8c482a9722413f20d9226fd346e1e
|
[] |
no_license
|
ArthurFRamos/InterviewPreparation
|
https://github.com/ArthurFRamos/InterviewPreparation
|
094e7a79ded4b783fbe4d2606fbcb11d064a019c
|
bf91f1a91322972e823d51245a6561127f150e1e
|
refs/heads/master
| 2021-01-13T00:54:01.464000 | 2018-10-03T23:55:54 | 2018-10-03T23:55:54 | 44,847,058 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class Solution {
public boolean isValid(String s) {
if(s.length() == 0)
return true;
LinkedList<Character> stack = new LinkedList<>();
for(int i = 0; i < s.length(); i++)
{
char temp = s.charAt(i);
if(temp == ']' || temp == '}' || temp == ')')
{
if(stack.isEmpty())
return false;
char current = stack.pop();
if(temp == ']' && current != '[')
return false;
if(temp == '}' && current != '{')
return false;
if(temp == ')' && current != '(')
return false;
}
else
stack.push(temp);
}
return stack.isEmpty();
}
}
|
UTF-8
|
Java
| 906 |
java
|
020 - Valid Parentheses.java
|
Java
|
[] | null |
[] |
public class Solution {
public boolean isValid(String s) {
if(s.length() == 0)
return true;
LinkedList<Character> stack = new LinkedList<>();
for(int i = 0; i < s.length(); i++)
{
char temp = s.charAt(i);
if(temp == ']' || temp == '}' || temp == ')')
{
if(stack.isEmpty())
return false;
char current = stack.pop();
if(temp == ']' && current != '[')
return false;
if(temp == '}' && current != '{')
return false;
if(temp == ')' && current != '(')
return false;
}
else
stack.push(temp);
}
return stack.isEmpty();
}
}
| 906 | 0.33223 | 0.330022 | 31 | 27.225807 | 16.063803 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.516129 | false | false |
12
|
ff3983d8054828e2d228d1430bfc2052d25ec8d6
| 32,341,103,747,600 |
aee949f758d23b81457ca1efd9f0273c7106a02c
|
/test-expert/src/test/java/nl/carpago/testexpert/PeoplePerson.java
|
f547fec10132ce6eb9816fea62cda95ce09a2fab
|
[
"BSD-3-Clause"
] |
permissive
|
carpago/test-expert
|
https://github.com/carpago/test-expert
|
65f2e23e1e9d4599756e4b051d936c3134af3d9e
|
9e2dd1731929a4348f11bfd8ab3ca7edec766d7b
|
refs/heads/master
| 2016-09-06T21:36:39.523000 | 2015-03-23T13:29:49 | 2015-03-23T13:29:49 | 20,476,747 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package nl.carpago.testexpert;
public class PeoplePerson {
private int leeftijd;
private String voornaam;
public PeoplePerson(int leeftijd, String voornaam) {
this.leeftijd = leeftijd;
}
}
|
UTF-8
|
Java
| 204 |
java
|
PeoplePerson.java
|
Java
|
[] | null |
[] |
package nl.carpago.testexpert;
public class PeoplePerson {
private int leeftijd;
private String voornaam;
public PeoplePerson(int leeftijd, String voornaam) {
this.leeftijd = leeftijd;
}
}
| 204 | 0.740196 | 0.740196 | 13 | 14.692307 | 16.363113 | 53 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.153846 | false | false |
12
|
0e63bdc735fd602c61ae9aa5680dde36dc8833f8
| 11,905,649,392,620 |
f5f6dce835eccc438f1157ad5528ed4feefac7c7
|
/src/main/java/com/example/demo/service/AirportService.java
|
aa79dab23209b48ee85c8c43e9b5d85154959372
|
[] |
no_license
|
drxaos-edu/instrumenting-profiler
|
https://github.com/drxaos-edu/instrumenting-profiler
|
5be80a6370619b488ca477fbfa8ae86e8651b49a
|
29d71d090c27ea5ff182ea3af4abfb84368d0364
|
refs/heads/master
| 2021-05-01T12:04:28.731000 | 2018-03-14T12:42:26 | 2018-03-14T12:42:26 | 121,056,750 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.demo.service;
import com.example.demo.domain.air.Airport;
import com.example.demo.domain.air.AirportsRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class AirportService {
@Autowired
AirportsRepository airportsRepository;
@Autowired
FlightService flightService;
@Transactional
public List<String> getAirportsByPassenger(String fullName, String id) {
List<Integer> flights = flightService.getFlightsByPassenger(fullName, id);
List<String> airportCodes = new ArrayList<>();
for (Integer flight : flights) {
if (!airportCodes.contains(flightService.getFlightAirportCode(flight))) {
airportCodes.add(flightService.getFlightAirportCode(flight));
}
}
airportCodes.sort(String::compareTo);
return airportCodes;
}
@Transactional
public Map<String, String> getAirportInfos(List<String> airportCodes) {
Map<String, String> infos = new HashMap<>();
for (String code : airportCodes) {
infos.put(code, getAirportInfo(code));
}
return infos;
}
public String getAirportInfo(String airportCode) {
Airport airport = airportsRepository.findByAirportCode(airportCode);
return airportCode + " (" + (airport.getAirportName().equals(airport.getCity()) ? "" : airport.getAirportName() + "/") + airport.getCity() + ")";
}
}
|
UTF-8
|
Java
| 1,682 |
java
|
AirportService.java
|
Java
|
[] | null |
[] |
package com.example.demo.service;
import com.example.demo.domain.air.Airport;
import com.example.demo.domain.air.AirportsRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class AirportService {
@Autowired
AirportsRepository airportsRepository;
@Autowired
FlightService flightService;
@Transactional
public List<String> getAirportsByPassenger(String fullName, String id) {
List<Integer> flights = flightService.getFlightsByPassenger(fullName, id);
List<String> airportCodes = new ArrayList<>();
for (Integer flight : flights) {
if (!airportCodes.contains(flightService.getFlightAirportCode(flight))) {
airportCodes.add(flightService.getFlightAirportCode(flight));
}
}
airportCodes.sort(String::compareTo);
return airportCodes;
}
@Transactional
public Map<String, String> getAirportInfos(List<String> airportCodes) {
Map<String, String> infos = new HashMap<>();
for (String code : airportCodes) {
infos.put(code, getAirportInfo(code));
}
return infos;
}
public String getAirportInfo(String airportCode) {
Airport airport = airportsRepository.findByAirportCode(airportCode);
return airportCode + " (" + (airport.getAirportName().equals(airport.getCity()) ? "" : airport.getAirportName() + "/") + airport.getCity() + ")";
}
}
| 1,682 | 0.698573 | 0.698573 | 53 | 30.735849 | 31.134008 | 153 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.509434 | false | false |
12
|
9b4b0a2f8e39f9fb71be995e948bc7eacefe9383
| 21,423,296,880,013 |
1211ad4c61933d809971e02c7860bd0986be287c
|
/lab-model/src/main/java/pl/edu/agh/kis/soa/dao/StudentDao.java
|
17f1214e0a0d33bcc95eae97d55d81fc984a5f1d
|
[] |
no_license
|
matewydm/lab-soa
|
https://github.com/matewydm/lab-soa
|
b616b4ee54b4c84df14b1f236b8e6fc8c035fa9f
|
3d147e006b9d766b74a703c9fc94a19d695be4f1
|
refs/heads/master
| 2021-01-21T17:28:10.940000 | 2017-05-30T06:42:32 | 2017-05-30T06:42:32 | 91,952,800 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package pl.edu.agh.kis.soa.dao;
import pl.edu.agh.kis.soa.model.db.StudentEntity;
import javax.ejb.Local;
import java.util.List;
public interface StudentDao {
void save(StudentEntity student);
void update(StudentEntity student);
void delete(StudentEntity student);
List<StudentEntity> getAll();
StudentEntity get(Integer index);
String getStudentName(Integer index);
byte[] getPictureByIndex(Integer index);
}
|
UTF-8
|
Java
| 448 |
java
|
StudentDao.java
|
Java
|
[] | null |
[] |
package pl.edu.agh.kis.soa.dao;
import pl.edu.agh.kis.soa.model.db.StudentEntity;
import javax.ejb.Local;
import java.util.List;
public interface StudentDao {
void save(StudentEntity student);
void update(StudentEntity student);
void delete(StudentEntity student);
List<StudentEntity> getAll();
StudentEntity get(Integer index);
String getStudentName(Integer index);
byte[] getPictureByIndex(Integer index);
}
| 448 | 0.736607 | 0.736607 | 23 | 18.47826 | 18.474117 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.478261 | false | false |
12
|
f64090a99f8394c4e6777a7e712ee529f546f4c3
| 30,399,778,572,170 |
bfe7ebfe848ef5a059d20e942d8cdf1960520043
|
/trainingmanagementsystem (1)/src/main/java/com/virtusa/trainingmanagementsystem/services/FeedbackService.java
|
227f8cdb78c72dce8550a54a9644806bfc9bd259
|
[] |
no_license
|
rakshi98/2ndPhase
|
https://github.com/rakshi98/2ndPhase
|
83b7610fc0f044088080ea413cd0c45d55df4c40
|
21534f91406e0c0bfe24e0d657881ea54db42016
|
refs/heads/master
| 2022-11-22T05:29:17.711000 | 2019-10-15T01:33:28 | 2019-10-15T01:33:28 | 215,141,519 | 0 | 0 | null | false | 2022-11-16T06:29:48 | 2019-10-14T20:43:00 | 2019-10-15T01:33:30 | 2022-11-16T06:29:46 | 1,794 | 0 | 0 | 1 |
Java
| false | false |
package com.virtusa.trainingmanagementsystem.services;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.virtusa.trainingmanagementsystem.models.Employee;
import com.virtusa.trainingmanagementsystem.models.Feedback;
import com.virtusa.trainingmanagementsystem.models.Nomination;
import com.virtusa.trainingmanagementsystem.models.Topic;
import com.virtusa.trainingmanagementsystem.repositories.FeedbackRepository;
@Service
public class FeedbackService {
@Autowired
private FeedbackRepository feedbackRepository;
@Autowired
NominationService nominationService;
@Autowired
ScheduleService scheduleService;
@Autowired
EmployeeService employeeService;
public List<Feedback> getAllFeedbacks() {
return feedbackRepository.findAll();
}
public List<Feedback> getAllTopics()
{
return feedbackRepository.findAll();
}
public Feedback saveFeedback(Feedback feedback,int scheduleId,int employeeId) {
// TODO Auto-generated method stub
Employee employee=employeeService.getEmployeeById(employeeId);
feedback.setEmployee(employee);
feedback.setSchedule(scheduleService.getScheduleById(scheduleId));
return feedbackRepository.save(feedback);
}
}
|
UTF-8
|
Java
| 1,379 |
java
|
FeedbackService.java
|
Java
|
[] | null |
[] |
package com.virtusa.trainingmanagementsystem.services;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.virtusa.trainingmanagementsystem.models.Employee;
import com.virtusa.trainingmanagementsystem.models.Feedback;
import com.virtusa.trainingmanagementsystem.models.Nomination;
import com.virtusa.trainingmanagementsystem.models.Topic;
import com.virtusa.trainingmanagementsystem.repositories.FeedbackRepository;
@Service
public class FeedbackService {
@Autowired
private FeedbackRepository feedbackRepository;
@Autowired
NominationService nominationService;
@Autowired
ScheduleService scheduleService;
@Autowired
EmployeeService employeeService;
public List<Feedback> getAllFeedbacks() {
return feedbackRepository.findAll();
}
public List<Feedback> getAllTopics()
{
return feedbackRepository.findAll();
}
public Feedback saveFeedback(Feedback feedback,int scheduleId,int employeeId) {
// TODO Auto-generated method stub
Employee employee=employeeService.getEmployeeById(employeeId);
feedback.setEmployee(employee);
feedback.setSchedule(scheduleService.getScheduleById(scheduleId));
return feedbackRepository.save(feedback);
}
}
| 1,379 | 0.762872 | 0.762872 | 57 | 22.192982 | 24.891651 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.596491 | false | false |
12
|
7d3cbd0b5b98f4d6fd78e20b0028f9645cbcf77d
| 30,399,778,569,957 |
98ff3a1ae27e59d90af051f14d1ed1c15b209f4e
|
/AdditionalTasks/MovieDatabase/src/com/javastart/movieDatabase/fileController/SerializableDatabaseWriter.java
|
d4e2a081518bb38bf0f8c821cb553e830722d52c
|
[] |
no_license
|
PaulinaGrabska/Javastart
|
https://github.com/PaulinaGrabska/Javastart
|
e7a67562b59c0b58dad61f5a6eaef422d3796db9
|
d172dfb435f3e93faef7731c28e93da7f9516c54
|
refs/heads/master
| 2020-05-19T09:05:10.043000 | 2019-07-12T11:22:31 | 2019-07-12T11:22:31 | 184,938,357 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.javastart.movieDatabase.fileController;
public class SerializableDatabaseWriter {
}
|
UTF-8
|
Java
| 97 |
java
|
SerializableDatabaseWriter.java
|
Java
|
[] | null |
[] |
package com.javastart.movieDatabase.fileController;
public class SerializableDatabaseWriter {
}
| 97 | 0.85567 | 0.85567 | 4 | 23.25 | 23.025801 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false |
12
|
83e5ab9b9c1384ad25b90b9e167ed5838efa04fb
| 8,211,977,534,761 |
fceba1e7cf2cb721fc032bbc4a58c8ec833e40fa
|
/src/com/practice/oops/Person.java
|
44e8105981cadc2b809b3dea8a78be5ffb65a501
|
[] |
no_license
|
sandeeppeddinti/test
|
https://github.com/sandeeppeddinti/test
|
84958b517b39669519670b9af75c51ad908f3344
|
182752297fdca70c7bbd38cd7469b3f83718e6c0
|
refs/heads/master
| 2021-01-19T19:39:29.710000 | 2017-04-16T18:55:42 | 2017-04-16T18:55:42 | 88,432,725 | 0 | 0 | null | false | 2017-04-16T18:55:42 | 2017-04-16T18:00:22 | 2017-04-16T18:19:41 | 2017-04-16T18:55:42 | 0 | 0 | 0 | 0 |
Java
| null | null |
package com.practice.oops;
public abstract class Person {
String name;
int Age;
int Height;
int weight;
String EyeColor;
String Gender;
public String sendName(String inputName){
name = "Hi "+inputName;
return name;
}
public abstract void displayEmpSal();
}
|
UTF-8
|
Java
| 303 |
java
|
Person.java
|
Java
|
[] | null |
[] |
package com.practice.oops;
public abstract class Person {
String name;
int Age;
int Height;
int weight;
String EyeColor;
String Gender;
public String sendName(String inputName){
name = "Hi "+inputName;
return name;
}
public abstract void displayEmpSal();
}
| 303 | 0.653465 | 0.653465 | 18 | 14.833333 | 13.04373 | 43 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.388889 | false | false |
12
|
afbd6535666ee09dff2e503125000b73ecca2bcc
| 1,992,864,841,335 |
ab7946c03b32cfb953d65645ea7aec9397492012
|
/tratorweb/src/main/java/com/agrofauna/tratorweb/model/Login.java
|
1a86d63ca859c712c9e42e86611138bcb49bfe25
|
[] |
no_license
|
wesleyhsm/Loja-Virtual-Trator
|
https://github.com/wesleyhsm/Loja-Virtual-Trator
|
d0877977573eb5b38b1902af3b155c487d0d68d0
|
f0cd0876282066b475878128040fb631b00ead53
|
refs/heads/master
| 2021-01-20T09:54:52.409000 | 2017-05-04T19:38:23 | 2017-05-04T19:38:23 | 90,299,682 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.agrofauna.tratorweb.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.NamedQueries;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.NotBlank;
/**
* The persistent class for the login database table.
*
*/
@Entity
@Table(name="login")
@NamedQueries({
@NamedQuery(name="Login.findAll", query="SELECT l FROM Login l"),
@NamedQuery(name="Login.tipo1", query="SELECT l FROM Login l WHERE l.nmLogin=:login AND l.snStatus=1"),
@NamedQuery(name="Login.tipo2", query="SELECT l FROM Login l WHERE l.pessoa.nmCnpjCpf=:login AND l.snStatus=1")
})
public class Login implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id_login")
private long idLogin;
@NotNull
@Temporal(TemporalType.TIMESTAMP)
@Column(name="dt_criacao")
private Date dtCriacao;
@NotBlank
@Column(name="nm_login")
private String nmLogin;
@NotBlank
@Column(name="nm_senha")
private String nmSenha;
@NotNull
@Column(name="sn_status")
private int snStatus;
//bi-directional many-to-one association to Pessoa
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name="id_pessoa")
private Pessoa pessoa;
public long getIdLogin() {
return idLogin;
}
public void setIdLogin(long idLogin) {
this.idLogin = idLogin;
}
public Date getDtCriacao() {
return dtCriacao;
}
public void setDtCriacao(Date dtCriacao) {
this.dtCriacao = dtCriacao;
}
public String getNmLogin() {
return nmLogin;
}
public void setNmLogin(String nmLogin) {
this.nmLogin = nmLogin;
}
public String getNmSenha() {
return nmSenha;
}
public void setNmSenha(String nmSenha) {
this.nmSenha = nmSenha;
}
public int getSnStatus() {
return snStatus;
}
public void setSnStatus(int snStatus) {
this.snStatus = snStatus;
}
public Pessoa getPessoa() {
return pessoa;
}
public void setPessoa(Pessoa pessoa) {
this.pessoa = pessoa;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (int) (idLogin ^ (idLogin >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Login other = (Login) obj;
if (idLogin != other.idLogin)
return false;
return true;
}
}
|
UTF-8
|
Java
| 2,874 |
java
|
Login.java
|
Java
|
[] | null |
[] |
package com.agrofauna.tratorweb.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.NamedQueries;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.NotBlank;
/**
* The persistent class for the login database table.
*
*/
@Entity
@Table(name="login")
@NamedQueries({
@NamedQuery(name="Login.findAll", query="SELECT l FROM Login l"),
@NamedQuery(name="Login.tipo1", query="SELECT l FROM Login l WHERE l.nmLogin=:login AND l.snStatus=1"),
@NamedQuery(name="Login.tipo2", query="SELECT l FROM Login l WHERE l.pessoa.nmCnpjCpf=:login AND l.snStatus=1")
})
public class Login implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id_login")
private long idLogin;
@NotNull
@Temporal(TemporalType.TIMESTAMP)
@Column(name="dt_criacao")
private Date dtCriacao;
@NotBlank
@Column(name="nm_login")
private String nmLogin;
@NotBlank
@Column(name="nm_senha")
private String nmSenha;
@NotNull
@Column(name="sn_status")
private int snStatus;
//bi-directional many-to-one association to Pessoa
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name="id_pessoa")
private Pessoa pessoa;
public long getIdLogin() {
return idLogin;
}
public void setIdLogin(long idLogin) {
this.idLogin = idLogin;
}
public Date getDtCriacao() {
return dtCriacao;
}
public void setDtCriacao(Date dtCriacao) {
this.dtCriacao = dtCriacao;
}
public String getNmLogin() {
return nmLogin;
}
public void setNmLogin(String nmLogin) {
this.nmLogin = nmLogin;
}
public String getNmSenha() {
return nmSenha;
}
public void setNmSenha(String nmSenha) {
this.nmSenha = nmSenha;
}
public int getSnStatus() {
return snStatus;
}
public void setSnStatus(int snStatus) {
this.snStatus = snStatus;
}
public Pessoa getPessoa() {
return pessoa;
}
public void setPessoa(Pessoa pessoa) {
this.pessoa = pessoa;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (int) (idLogin ^ (idLogin >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Login other = (Login) obj;
if (idLogin != other.idLogin)
return false;
return true;
}
}
| 2,874 | 0.730689 | 0.727209 | 136 | 20.139706 | 19.515896 | 114 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.25 | false | false |
12
|
b4ba2877da14cd64b2b95b60056a795e021b2c8b
| 5,342,939,384,423 |
49d2470d5cd15ddf3579e8127a41d25c52495efe
|
/src/main/java/com/egs/shop/service/RateService.java
|
16a7b22251d17487b57d0967426c1467a4456824
|
[] |
no_license
|
mnazarizadeh/egs-shop
|
https://github.com/mnazarizadeh/egs-shop
|
55ce7a90c69723b13d1b5d00c57398fac8b5808c
|
2eb216d10faf1fae12c2769bf3f0e36274745501
|
refs/heads/main
| 2023-07-17T01:45:11.897000 | 2021-08-29T08:05:19 | 2021-08-29T08:05:19 | 399,588,707 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.egs.shop.service;
import com.egs.shop.model.dto.RateDTO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
public interface RateService {
RateDTO createRate(RateDTO rateDTO);
RateDTO updateRate(RateDTO rateDTO);
Page<RateDTO> getAllRates(Pageable pageable);
Page<RateDTO> getMyRates(Pageable pageable);
RateDTO getRate(Long id);
RateDTO getMyRate(Long id);
void deleteById(Long id);
void deleteMineById(Long id);
Page<RateDTO> getAllRatesByProductId(Long id, Pageable pageable);
Page<RateDTO> getEnabledRatesByProductId(Long id, Pageable pageable);
}
|
UTF-8
|
Java
| 660 |
java
|
RateService.java
|
Java
|
[] | null |
[] |
package com.egs.shop.service;
import com.egs.shop.model.dto.RateDTO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
public interface RateService {
RateDTO createRate(RateDTO rateDTO);
RateDTO updateRate(RateDTO rateDTO);
Page<RateDTO> getAllRates(Pageable pageable);
Page<RateDTO> getMyRates(Pageable pageable);
RateDTO getRate(Long id);
RateDTO getMyRate(Long id);
void deleteById(Long id);
void deleteMineById(Long id);
Page<RateDTO> getAllRatesByProductId(Long id, Pageable pageable);
Page<RateDTO> getEnabledRatesByProductId(Long id, Pageable pageable);
}
| 660 | 0.754545 | 0.754545 | 29 | 21.758621 | 23.061619 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.551724 | false | false |
12
|
93291245e93e34977c8db13f7e461721d7ff3950
| 6,528,350,318,187 |
c91ec62aef35cf3e3a6b6f8b6f00481bd92099a7
|
/Geometria/src/modelo/Circulo.java
|
b96fb9a6d3c29e6c712e1f4b4dc59eec1a381e56
|
[] |
no_license
|
aperez536/Ejercicio-java-unla
|
https://github.com/aperez536/Ejercicio-java-unla
|
f3e793571acc52d78ddb73f299f943dc4f48d5b0
|
5e97b43c6bff2fb2a984f9730f484ad9573956a5
|
refs/heads/master
| 2020-03-28T21:36:53.646000 | 2019-01-05T18:49:35 | 2019-01-05T18:49:35 | 149,169,558 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package modelo;
public class Circulo {
private Punto origen;
private double radio;
public Circulo(Punto origen, double radio) {
super();
this.origen = origen;
this.radio = radio;
}
public Circulo(Punto origen, Punto radio) {
super();
this.origen = origen;
this.setRadio(radio);
}
public Punto getOrigen() {
return origen;
}
public void setOrigen(Punto origen) {
this.origen = origen;
}
public double getRadio() {
return radio;
}
public void setRadio(double radio) {
this.radio = radio;
}
public void setRadio(Punto radio){
this.radio = origen.calcularDistancia(radio);
}
public String toString(){
return "("+origen+","+radio+")";
}
public boolean equals(Circulo c){
return ((origen==c.getOrigen())&&(radio==c.getRadio()));
}
public double calcularPerimetro(){
double perimetro=2*Math.PI*radio;
return perimetro;
}
public double calcularArea(){
double area=Math.PI*Math.pow(radio,2);
return area;
}
public double calcularDistancia(Circulo c){
double valor1=this.origen.calcularDistancia(c.getOrigen());
double valor2=this.radio+c.getRadio();
return valor2-valor1;
}
public void mover(double desplazamientoX,double desplazamientoY){
Punto nuevoOrigen=new Punto(origen.getX(),origen.getY());
origen=nuevoOrigen;
origen.mover(desplazamientoX, desplazamientoY);
}
}
|
UTF-8
|
Java
| 1,363 |
java
|
Circulo.java
|
Java
|
[] | null |
[] |
package modelo;
public class Circulo {
private Punto origen;
private double radio;
public Circulo(Punto origen, double radio) {
super();
this.origen = origen;
this.radio = radio;
}
public Circulo(Punto origen, Punto radio) {
super();
this.origen = origen;
this.setRadio(radio);
}
public Punto getOrigen() {
return origen;
}
public void setOrigen(Punto origen) {
this.origen = origen;
}
public double getRadio() {
return radio;
}
public void setRadio(double radio) {
this.radio = radio;
}
public void setRadio(Punto radio){
this.radio = origen.calcularDistancia(radio);
}
public String toString(){
return "("+origen+","+radio+")";
}
public boolean equals(Circulo c){
return ((origen==c.getOrigen())&&(radio==c.getRadio()));
}
public double calcularPerimetro(){
double perimetro=2*Math.PI*radio;
return perimetro;
}
public double calcularArea(){
double area=Math.PI*Math.pow(radio,2);
return area;
}
public double calcularDistancia(Circulo c){
double valor1=this.origen.calcularDistancia(c.getOrigen());
double valor2=this.radio+c.getRadio();
return valor2-valor1;
}
public void mover(double desplazamientoX,double desplazamientoY){
Punto nuevoOrigen=new Punto(origen.getX(),origen.getY());
origen=nuevoOrigen;
origen.mover(desplazamientoX, desplazamientoY);
}
}
| 1,363 | 0.699193 | 0.694791 | 71 | 18.197184 | 18.346907 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.661972 | false | false |
12
|
0e1b2d3694e9b0c02542baa2ed13a26b47bfdcee
| 19,885,698,593,855 |
e53a2390cf8f3fcb96152011215d5926270a574a
|
/mainPackage/GrrrrException.java
|
eeb8b6d9abbf1a7448af34a01e1f0cb6c4d243e4
|
[] |
no_license
|
dariopassarello/superTextBattleRoyale
|
https://github.com/dariopassarello/superTextBattleRoyale
|
90845648687d1ad03f74c96592897daf3a0c934d
|
f06215b33e3eec2395a99e8558f8b03cad4a5418
|
refs/heads/master
| 2020-04-07T23:26:35.625000 | 2018-11-24T11:06:06 | 2018-11-24T11:06:06 | 158,812,873 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package daryx77.superTextBattleRoyale.mainPackage;
public class GrrrrException extends Exception
{
/**
*
*/
public GrrrrException()
{
super("GRRRRR");
}
}
|
UTF-8
|
Java
| 171 |
java
|
GrrrrException.java
|
Java
|
[
{
"context": "package daryx77.superTextBattleRoyale.mainPackage;\n\npublic class ",
"end": 15,
"score": 0.9347893595695496,
"start": 8,
"tag": "USERNAME",
"value": "daryx77"
}
] | null |
[] |
package daryx77.superTextBattleRoyale.mainPackage;
public class GrrrrException extends Exception
{
/**
*
*/
public GrrrrException()
{
super("GRRRRR");
}
}
| 171 | 0.690058 | 0.678363 | 14 | 11.214286 | 16.506184 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.785714 | false | false |
12
|
88804382806609dfd9d7013a1566eb906184f4eb
| 2,216,203,193,788 |
8c085f12963e120be684f8a049175f07d0b8c4e5
|
/castor/tags/TAG_0_9_9_M2/castor/src/tests/jdo/TestLazyPayRoll.java
|
b316951fad8e7f737a58d02542e8a7ba88a1829d
|
[] |
no_license
|
alam93mahboob/castor
|
https://github.com/alam93mahboob/castor
|
9963d4110126b8f4ef81d82adfe62bab8c5f5bce
|
974f853be5680427a195a6b8ae3ce63a65a309b6
|
refs/heads/master
| 2020-05-17T08:03:26.321000 | 2014-01-01T20:48:45 | 2014-01-01T20:48:45 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package jdo;
public class TestLazyPayRoll {
private int _id;
private int _holiday;
private int _hourlyRate;
private TestLazyEmployee _employee;
public void setId( int id ) {
_id = id;
}
public int getId() {
return _id;
}
public void setHoliday( int holiday ) {
_holiday = holiday;
}
public int getHoliday() {
return _holiday;
}
public void setHourlyRate( int rate ) {
_hourlyRate = rate;
}
public int getHourlyRate() {
return _hourlyRate;
}
public void setEmployee( TestLazyEmployee employee ) {
_employee = employee;
}
public TestLazyEmployee getEmployee() {
return _employee;
}
}
|
UTF-8
|
Java
| 704 |
java
|
TestLazyPayRoll.java
|
Java
|
[] | null |
[] |
package jdo;
public class TestLazyPayRoll {
private int _id;
private int _holiday;
private int _hourlyRate;
private TestLazyEmployee _employee;
public void setId( int id ) {
_id = id;
}
public int getId() {
return _id;
}
public void setHoliday( int holiday ) {
_holiday = holiday;
}
public int getHoliday() {
return _holiday;
}
public void setHourlyRate( int rate ) {
_hourlyRate = rate;
}
public int getHourlyRate() {
return _hourlyRate;
}
public void setEmployee( TestLazyEmployee employee ) {
_employee = employee;
}
public TestLazyEmployee getEmployee() {
return _employee;
}
}
| 704 | 0.607955 | 0.607955 | 35 | 19.085714 | 14.84659 | 55 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.628571 | false | false |
12
|
4199cab6ef03b3bcf5a3da18b2e76ab5775eca17
| 27,943,057,293,445 |
77fc25369090ba6290d070d6326724c03aad54ec
|
/app/src/main/java/com/xczn/smos/ui/fragment/home/analysis/AnalysisFragment.java
|
9e31a4be5e61bb41d986c1218ddcfd49bd317d7e
|
[] |
no_license
|
LifeisYou/Smos-admin
|
https://github.com/LifeisYou/Smos-admin
|
dc1af87b9e85c659fe956f9ff008e95918d9f2c2
|
947232ab350d86ebe2efd3102924cdb80a6e5fbd
|
refs/heads/master
| 2020-03-23T09:01:41.082000 | 2018-07-19T08:08:42 | 2018-07-19T08:08:42 | 141,362,677 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.xczn.smos.ui.fragment.home.analysis;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Spinner;
import com.github.mikephil.charting.charts.LineChart;
import com.xczn.smos.R;
import com.xczn.smos.adapter.EquipmentSpinnerAdapter;
import com.xczn.smos.adapter.FactorySpinnerAdapter;
import com.xczn.smos.adapter.IntervalSpinnerAdapter;
import com.xczn.smos.base.BaseBackFragment;
import com.xczn.smos.entity.Equipment2Tree;
import com.xczn.smos.request.EquipmentService;
import java.util.ArrayList;
import java.util.List;
/**
* @Author zhangxiao
* @Date 2018/4/23 0023
* @Comment
*/
public class AnalysisFragment extends BaseBackFragment implements View.OnClickListener{
public static AnalysisFragment newInstance() {
return new AnalysisFragment();
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_analysis, container, false);
initView(view);
return view;
}
private void initView(View view) {
Toolbar mToolbar = view.findViewById(R.id.toolbar);
mToolbar.setTitle("数据报表");
initToolbarNav(mToolbar);
Button btnChartDay = view.findViewById(R.id.btn_chart_day);
btnChartDay.setOnClickListener(this);
Button btnChartMonth = view.findViewById(R.id.btn_chart_month);
btnChartMonth.setOnClickListener(this);
Button btnChartYear = view.findViewById(R.id.btn_chart_year);
btnChartYear.setOnClickListener(this);
}
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.btn_chart_day:
start(ChartDayFragment.newInstance());
break;
case R.id.btn_chart_month:
start(ChartMonthFragment.newInstance());
break;
case R.id.btn_chart_year:
start(ChartYearFragment.newInstance());
break;
default:
break;
}
}
}
|
UTF-8
|
Java
| 2,494 |
java
|
AnalysisFragment.java
|
Java
|
[
{
"context": "import android.widget.Spinner;\n\nimport com.github.mikephil.charting.charts.LineChart;\nimport com.xczn.smos.R",
"end": 386,
"score": 0.8642770051956177,
"start": 378,
"tag": "USERNAME",
"value": "mikephil"
},
{
"context": ".ArrayList;\nimport java.util.List;\n\n/**\n * @Author zhangxiao\n * @Date 2018/4/23 0023\n * @Comment\n */\n\npublic c",
"end": 809,
"score": 0.9975576996803284,
"start": 800,
"tag": "USERNAME",
"value": "zhangxiao"
}
] | null |
[] |
package com.xczn.smos.ui.fragment.home.analysis;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Spinner;
import com.github.mikephil.charting.charts.LineChart;
import com.xczn.smos.R;
import com.xczn.smos.adapter.EquipmentSpinnerAdapter;
import com.xczn.smos.adapter.FactorySpinnerAdapter;
import com.xczn.smos.adapter.IntervalSpinnerAdapter;
import com.xczn.smos.base.BaseBackFragment;
import com.xczn.smos.entity.Equipment2Tree;
import com.xczn.smos.request.EquipmentService;
import java.util.ArrayList;
import java.util.List;
/**
* @Author zhangxiao
* @Date 2018/4/23 0023
* @Comment
*/
public class AnalysisFragment extends BaseBackFragment implements View.OnClickListener{
public static AnalysisFragment newInstance() {
return new AnalysisFragment();
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_analysis, container, false);
initView(view);
return view;
}
private void initView(View view) {
Toolbar mToolbar = view.findViewById(R.id.toolbar);
mToolbar.setTitle("数据报表");
initToolbarNav(mToolbar);
Button btnChartDay = view.findViewById(R.id.btn_chart_day);
btnChartDay.setOnClickListener(this);
Button btnChartMonth = view.findViewById(R.id.btn_chart_month);
btnChartMonth.setOnClickListener(this);
Button btnChartYear = view.findViewById(R.id.btn_chart_year);
btnChartYear.setOnClickListener(this);
}
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.btn_chart_day:
start(ChartDayFragment.newInstance());
break;
case R.id.btn_chart_month:
start(ChartMonthFragment.newInstance());
break;
case R.id.btn_chart_year:
start(ChartYearFragment.newInstance());
break;
default:
break;
}
}
}
| 2,494 | 0.693081 | 0.687852 | 80 | 30.075001 | 24.719818 | 132 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5625 | false | false |
12
|
6b696343dda4ac32cd42be0a6d44eb7aacda0b0c
| 31,318,901,580,222 |
a3b684f79fc5727e8feaaee094d201ffe8be631d
|
/elara-core/src/main/java/org/tools4j/elara/factory/DefaultProcessorFactory.java
|
6ca8fc0ecb8065191ef238b3134c3f93df197c2a
|
[
"MIT"
] |
permissive
|
bellmit/elara
|
https://github.com/bellmit/elara
|
c2308c1645279219aa607a4d10dbab92a2463402
|
cdc9e3600ab023931dfce15224b8eeab4a1e58b2
|
refs/heads/master
| 2023-09-05T15:04:46.279000 | 2021-11-19T11:31:30 | 2021-11-19T11:31:30 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* The MIT License (MIT)
*
* Copyright (c) 2020-2021 tools4j.org (Marco Terzer, Anton Anufriev)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.tools4j.elara.factory;
import org.tools4j.elara.application.CommandProcessor;
import org.tools4j.elara.command.CompositeCommandProcessor;
import org.tools4j.elara.handler.CommandHandler;
import org.tools4j.elara.handler.CommandPollerHandler;
import org.tools4j.elara.handler.DefaultCommandHandler;
import org.tools4j.elara.init.CommandLogMode;
import org.tools4j.elara.init.Configuration;
import org.tools4j.elara.log.MessageLog.Poller;
import org.tools4j.elara.loop.CommandPollerStep;
import org.tools4j.elara.plugin.base.BaseState;
import org.tools4j.elara.route.DefaultEventRouter;
import org.tools4j.nobark.loop.Step;
import java.util.Arrays;
import java.util.function.Supplier;
import static java.util.Objects.requireNonNull;
public class DefaultProcessorFactory implements ProcessorFactory {
private final Configuration configuration;
private final Supplier<? extends Singletons> singletons;
public DefaultProcessorFactory(final Configuration configuration, final Supplier<? extends Singletons> singletons) {
this.configuration = requireNonNull(configuration);
this.singletons = requireNonNull(singletons);
}
@Override
public CommandProcessor commandProcessor() {
final CommandProcessor commandProcessor = configuration.commandProcessor();
final org.tools4j.elara.plugin.api.Plugin.Configuration[] plugins = singletons.get().plugins();
if (plugins.length == 0) {
return commandProcessor;
}
final BaseState baseState = singletons.get().baseState();
final CommandProcessor[] processors = new CommandProcessor[plugins.length + 1];
int count = 1;
for (final org.tools4j.elara.plugin.api.Plugin.Configuration plugin : plugins) {
processors[count] = plugin.commandProcessor(baseState);
if (processors[count] != CommandProcessor.NOOP) {
count++;
}
}
if (count == 1) {
return commandProcessor;
}
processors[0] = commandProcessor;//application processor first
return new CompositeCommandProcessor(
count == processors.length ? processors : Arrays.copyOf(processors, count)
);
}
@Override
public CommandHandler commandHandler() {
return new DefaultCommandHandler(
singletons.get().baseState(),
new DefaultEventRouter(configuration.eventLog().appender(), singletons.get().eventHandler()),
singletons.get().commandProcessor(),
configuration.exceptionHandler(),
configuration.duplicateHandler()
);
}
@Override
public Step commandPollerStep() {
final Poller commandLogPoller;
switch (configuration.commandLogMode()) {
case REPLAY_ALL:
commandLogPoller = configuration.commandLog().poller();
break;
case FROM_LAST:
commandLogPoller = configuration.commandLog().poller(CommandLogMode.DEFAULT_POLLER_ID);
break;
case FROM_END:
commandLogPoller = configuration.commandLog().poller();
commandLogPoller.moveToEnd();
break;
default:
throw new IllegalArgumentException("Unsupported command log mode: " + configuration.commandLogMode());
}
return new CommandPollerStep(commandLogPoller, new CommandPollerHandler(singletons.get().commandHandler()));
}
}
|
UTF-8
|
Java
| 4,715 |
java
|
DefaultProcessorFactory.java
|
Java
|
[
{
"context": " (MIT)\n *\n * Copyright (c) 2020-2021 tools4j.org (Marco Terzer, Anton Anufriev)\n *\n * Permission is hereby grant",
"end": 83,
"score": 0.9998688101768494,
"start": 71,
"tag": "NAME",
"value": "Marco Terzer"
},
{
"context": "Copyright (c) 2020-2021 tools4j.org (Marco Terzer, Anton Anufriev)\n *\n * Permission is hereby granted, free of char",
"end": 99,
"score": 0.9998703002929688,
"start": 85,
"tag": "NAME",
"value": "Anton Anufriev"
}
] | null |
[] |
/*
* The MIT License (MIT)
*
* Copyright (c) 2020-2021 tools4j.org (<NAME>, <NAME>)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.tools4j.elara.factory;
import org.tools4j.elara.application.CommandProcessor;
import org.tools4j.elara.command.CompositeCommandProcessor;
import org.tools4j.elara.handler.CommandHandler;
import org.tools4j.elara.handler.CommandPollerHandler;
import org.tools4j.elara.handler.DefaultCommandHandler;
import org.tools4j.elara.init.CommandLogMode;
import org.tools4j.elara.init.Configuration;
import org.tools4j.elara.log.MessageLog.Poller;
import org.tools4j.elara.loop.CommandPollerStep;
import org.tools4j.elara.plugin.base.BaseState;
import org.tools4j.elara.route.DefaultEventRouter;
import org.tools4j.nobark.loop.Step;
import java.util.Arrays;
import java.util.function.Supplier;
import static java.util.Objects.requireNonNull;
public class DefaultProcessorFactory implements ProcessorFactory {
private final Configuration configuration;
private final Supplier<? extends Singletons> singletons;
public DefaultProcessorFactory(final Configuration configuration, final Supplier<? extends Singletons> singletons) {
this.configuration = requireNonNull(configuration);
this.singletons = requireNonNull(singletons);
}
@Override
public CommandProcessor commandProcessor() {
final CommandProcessor commandProcessor = configuration.commandProcessor();
final org.tools4j.elara.plugin.api.Plugin.Configuration[] plugins = singletons.get().plugins();
if (plugins.length == 0) {
return commandProcessor;
}
final BaseState baseState = singletons.get().baseState();
final CommandProcessor[] processors = new CommandProcessor[plugins.length + 1];
int count = 1;
for (final org.tools4j.elara.plugin.api.Plugin.Configuration plugin : plugins) {
processors[count] = plugin.commandProcessor(baseState);
if (processors[count] != CommandProcessor.NOOP) {
count++;
}
}
if (count == 1) {
return commandProcessor;
}
processors[0] = commandProcessor;//application processor first
return new CompositeCommandProcessor(
count == processors.length ? processors : Arrays.copyOf(processors, count)
);
}
@Override
public CommandHandler commandHandler() {
return new DefaultCommandHandler(
singletons.get().baseState(),
new DefaultEventRouter(configuration.eventLog().appender(), singletons.get().eventHandler()),
singletons.get().commandProcessor(),
configuration.exceptionHandler(),
configuration.duplicateHandler()
);
}
@Override
public Step commandPollerStep() {
final Poller commandLogPoller;
switch (configuration.commandLogMode()) {
case REPLAY_ALL:
commandLogPoller = configuration.commandLog().poller();
break;
case FROM_LAST:
commandLogPoller = configuration.commandLog().poller(CommandLogMode.DEFAULT_POLLER_ID);
break;
case FROM_END:
commandLogPoller = configuration.commandLog().poller();
commandLogPoller.moveToEnd();
break;
default:
throw new IllegalArgumentException("Unsupported command log mode: " + configuration.commandLogMode());
}
return new CommandPollerStep(commandLogPoller, new CommandPollerHandler(singletons.get().commandHandler()));
}
}
| 4,701 | 0.699258 | 0.693107 | 111 | 41.477478 | 31.671127 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.657658 | false | false |
12
|
6a5612dd424f6ca28f1711a96c18ed0dd54ad742
| 1,700,807,050,840 |
c173832fd576d45c875063a1a480672fbd59ca04
|
/seguridad/tags/release-1.0/modulos/apps/localgismezcla/src/com/geopista/app/printer/CDocument.java
|
dc45214ff9ccd7279472a605d796282c556ab1ef
|
[] |
no_license
|
jormaral/allocalgis
|
https://github.com/jormaral/allocalgis
|
1308616b0f3ac8aa68fb0820a7dfa89d5a64d0e6
|
bd5b454b9c2e8ee24f70017ae597a32301364a54
|
refs/heads/master
| 2021-01-16T18:08:36.542000 | 2016-04-12T11:43:18 | 2016-04-12T11:43:18 | 50,914,723 | 0 | 0 | null | true | 2016-02-02T11:04:27 | 2016-02-02T11:04:27 | 2016-01-21T09:50:03 | 2016-01-28T13:15:00 | 519,283 | 0 | 0 | 0 | null | null | null |
package com.geopista.app.printer;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.net.URL;
import java.net.MalformedURLException;
/**
* This class is the painter for the document content.
*/
public class CDocument extends Component implements Printable {
private final static int POINTS_PER_INCH = 72;
private static String _nombreFichero = "";
private static java.awt.Image image;
public CDocument(java.awt.Image image){
super();
this.image=image;
//_nombreFichero=nombreFichero;
}
/**
* Method: print <p>
*
* @param g a value of type Graphics
* @param pageFormat a value of type PageFormat
* @param page a value of type int
* @return a value of type int
*/
public int print(Graphics g, PageFormat pageFormat, int page) {
System.out.println("page: "+page);
try {
Graphics2D g2d = (Graphics2D) g;
g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
g2d.setPaint(Color.black);
/*
MediaTracker mediaTracker = new MediaTracker(this);
URL imageURL1 = new URL(_nombreFichero);
Image image = Toolkit.getDefaultToolkit().getImage(imageURL1);
mediaTracker.addImage(image, 0);
mediaTracker.waitForID(0);
*/
System.out.println("[Document.print()] pageFormat.getWidth(): "+pageFormat.getWidth());
System.out.println("[Document.print()] pageFormat.getHeight(): "+pageFormat.getHeight());
CImagen imagen=new CImagen(image.getWidth(this),image.getHeight(this));
imagen.escalarImagen((float)pageFormat.getWidth(),(float)pageFormat.getHeight());
imagen.centrarImagen((float)pageFormat.getWidth(),(float)pageFormat.getHeight());
g2d.drawImage(image, Math.round(imagen.getCoordenadaOrigenX()), Math.round(imagen.getCoordenadaOrigenY()), Math.round(imagen.getImageWidth()) ,Math.round(imagen.getImageHeight()) , this);
} catch (Exception ex) {
ex.printStackTrace();
}
//--- Validate the page
return (PAGE_EXISTS);
}
}
|
UTF-8
|
Java
| 2,096 |
java
|
CDocument.java
|
Java
|
[] | null |
[] |
package com.geopista.app.printer;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.net.URL;
import java.net.MalformedURLException;
/**
* This class is the painter for the document content.
*/
public class CDocument extends Component implements Printable {
private final static int POINTS_PER_INCH = 72;
private static String _nombreFichero = "";
private static java.awt.Image image;
public CDocument(java.awt.Image image){
super();
this.image=image;
//_nombreFichero=nombreFichero;
}
/**
* Method: print <p>
*
* @param g a value of type Graphics
* @param pageFormat a value of type PageFormat
* @param page a value of type int
* @return a value of type int
*/
public int print(Graphics g, PageFormat pageFormat, int page) {
System.out.println("page: "+page);
try {
Graphics2D g2d = (Graphics2D) g;
g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
g2d.setPaint(Color.black);
/*
MediaTracker mediaTracker = new MediaTracker(this);
URL imageURL1 = new URL(_nombreFichero);
Image image = Toolkit.getDefaultToolkit().getImage(imageURL1);
mediaTracker.addImage(image, 0);
mediaTracker.waitForID(0);
*/
System.out.println("[Document.print()] pageFormat.getWidth(): "+pageFormat.getWidth());
System.out.println("[Document.print()] pageFormat.getHeight(): "+pageFormat.getHeight());
CImagen imagen=new CImagen(image.getWidth(this),image.getHeight(this));
imagen.escalarImagen((float)pageFormat.getWidth(),(float)pageFormat.getHeight());
imagen.centrarImagen((float)pageFormat.getWidth(),(float)pageFormat.getHeight());
g2d.drawImage(image, Math.round(imagen.getCoordenadaOrigenX()), Math.round(imagen.getCoordenadaOrigenY()), Math.round(imagen.getImageWidth()) ,Math.round(imagen.getImageHeight()) , this);
} catch (Exception ex) {
ex.printStackTrace();
}
//--- Validate the page
return (PAGE_EXISTS);
}
}
| 2,096 | 0.693225 | 0.687023 | 67 | 29.283583 | 32.508003 | 191 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.791045 | false | false |
12
|
1dff84acebdd1741217521c2dd0d975c8bd30ecf
| 7,473,243,154,240 |
87c616e8dbfd2b95393029245682535620ef0b45
|
/Mage.Tests/src/test/java/org/mage/test/cards/single/OmniscienceTest.java
|
088b01789cdfde55e13ff46e08b519101119b5c5
|
[] |
no_license
|
PedroTav/mage
|
https://github.com/PedroTav/mage
|
c625378af8d966b3c0852dfd66dcaf9171a33f23
|
2e551a971cb3fe71bf73e9b01766b1caf394ef10
|
refs/heads/master
| 2021-01-24T11:44:18.685000 | 2016-12-18T15:08:00 | 2016-12-18T15:08:00 | 70,226,202 | 1 | 2 | null | true | 2016-10-14T08:09:23 | 2016-10-07T07:55:50 | 2016-10-07T08:43:23 | 2016-10-14T08:09:22 | 452,372 | 1 | 1 | 0 |
Java
| null | null |
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package org.mage.test.cards.single;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class OmniscienceTest extends CardTestPlayerBase {
/**
* Omniscience {7}{U}{U}{U}
*
* Enchantment You may cast nonland cards from your hand without paying
* their mana costs.
*
*/
@Test
public void testCastingCreature() {
addCard(Zone.BATTLEFIELD, playerA, "Omniscience");
/* player.getPlayable does not take alternate
casting costs in account, so for the test the mana has to be available
but won't be used
*/
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
addCard(Zone.HAND, playerA, "Silvercoat Lion");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Silvercoat Lion");
setChoice(playerA, "Yes");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertPermanentCount(playerA, "Silvercoat Lion", 1);
assertTapped("Plains", false);
}
@Test
public void testCastingSplitCards() {
addCard(Zone.BATTLEFIELD, playerA, "Omniscience");
addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
// Fire deals 2 damage divided as you choose among one or two target creatures and/or players.
addCard(Zone.HAND, playerA, "Fire // Ice");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Fire", playerB);
setChoice(playerA, "Yes");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, "Fire // Ice", 1);
assertLife(playerA, 20);
assertLife(playerB, 18);
assertTapped("Island", false);
assertTapped("Mountain", false);
}
@Test
public void testCastingShrapnelBlast() {
addCard(Zone.BATTLEFIELD, playerA, "Omniscience");
/* player.getPlayable does not take alternate
casting costs in account, so for the test the mana has to be available
but won't be used
*/
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
addCard(Zone.BATTLEFIELD, playerA, "Ornithopter", 1);
addCard(Zone.HAND, playerA, "Shrapnel Blast", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Shrapnel Blast");
setChoice(playerA, "Yes");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 15);
assertGraveyardCount(playerA, "Ornithopter", 1);
assertTapped("Mountain", false);
}
/**
* Spell get cast for 0 if Omniscience is being in play. But with
* Trinisphere it costs at least {3}. Cost/alternate cost (Omniscience) +
* additional costs - cost reductions + minimum cost (Trinishpere) = total
* cost.
*/
@Test
public void testCastingWithTrinisphere() {
addCard(Zone.BATTLEFIELD, playerA, "Omniscience");
addCard(Zone.HAND, playerA, "Silvercoat Lion", 1);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 3);
// As long as Trinisphere is untapped, each spell that would cost less than three mana
// to cast costs three mana to cast. (Additional mana in the cost may be paid with any
// color of mana or colorless mana. For example, a spell that would cost {1}{B} to cast
// costs {2}{B} to cast instead.)
addCard(Zone.BATTLEFIELD, playerB, "Trinisphere", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Silvercoat Lion");
setChoice(playerA, "Yes");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertPermanentCount(playerA, "Silvercoat Lion", 1);
assertTapped("Plains", true); // plains have to be tapped because {3} have to be paid
}
/**
* Omniscience is not allowing me to cast spells for free. I'm playing a
* Commander game against the Computer, if that helps.
*
* Edit: It's not letting me cast fused spells for free. Others seems to be
* working.
*/
@Test
@Ignore // targeting of fused/split spells not supported by testplayer
public void testCastingFusedSpell() {
addCard(Zone.BATTLEFIELD, playerA, "Omniscience");
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3);
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion");
addCard(Zone.BATTLEFIELD, playerB, "Pillarfield Ox");
/*
* Instant
* Far {1}{U} Return target creature to its owner's hand.
* Away{2}{B} Target player sacrifices a creature.
* Fuse (You may cast one or both halves of this card from your hand.)
*/
addCard(Zone.HAND, playerA, "Far // Away");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "fused Far // Away", "Silvercoat Lion^targetPlayer=PlayerB");
playerB.addTarget("Pillarfield Ox");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertHandCount(playerA, 1);
assertHandCount(playerB, 0);
assertGraveyardCount(playerA, "Far // Away", 1);
assertPermanentCount(playerB, "Pillarfield Ox", 0);
assertGraveyardCount(playerB, "Pillarfield Ox", 1);
}
/**
* If another effect (e.g. Future Sight) allows you to cast nonland cards
* from zones other than your hand, Xmage incorrectly lets you cast those
* cards without paying their mana costs. Omniscience only lets you cast
* spells from your hand without paying their mana costs.
*/
@Test
public void testCastingWithFutureSight() {
// You may cast nonland cards from your hand without paying their mana costs.
addCard(Zone.BATTLEFIELD, playerA, "Omniscience");
// Play with the top card of your library revealed.
// You may play the top card of your library.
addCard(Zone.BATTLEFIELD, playerA, "Future Sight", 1);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
addCard(Zone.LIBRARY, playerA, "Silvercoat Lion", 1);
skipInitShuffling();
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Silvercoat Lion");
setChoice(playerA, "Yes");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertPermanentCount(playerA, "Silvercoat Lion", 1);
assertTapped("Plains", true); // plains have to be tapped because {2} have to be paid
}
/**
* If a spell has an additional cost (optional or mandatory, e.g. Entwine),
* Omniscience incorrectly allows you cast the spell as if that cost had
* been paid without paying that spell's mana cost. 117.9d If an alternative
* cost is being paid to cast a spell, any additional costs, cost increases,
* and cost reductions that affect that spell are applied to that
* alternative cost. (See rule 601.2f.)
*/
@Test
public void testCastingWithCyclonicRiftWithOverload() {
// You may cast nonland cards from your hand without paying their mana costs.
addCard(Zone.BATTLEFIELD, playerA, "Omniscience");
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
// Choose one - Barbed Lightning deals 3 damage to target creature; or Barbed Lightning deals 3 damage to target player.
// Entwine {2} (Choose both if you pay the entwine cost.)
addCard(Zone.HAND, playerA, "Barbed Lightning", 1);
// Creature - 3/3 Swampwalk
addCard(Zone.BATTLEFIELD, playerB, "Bog Wraith", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Barbed Lightning", "Bog Wraith");
addTarget(playerA, playerB);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, "Barbed Lightning", 1);
assertGraveyardCount(playerB, "Bog Wraith", 1);
assertLife(playerA, 20);
assertLife(playerB, 17);
assertTapped("Plains", true); // plains have to be tapped because {2} from Entwine have to be paid
}
/**
* If a spell has an unpayable cost (e.g. Ancestral Vision, which has no
* mana cost), Omniscience should allow you to cast that spell without
* paying its mana cost. In the case of Ancestral Vision, for example, Xmage
* only gives you the option to suspend Ancestral Vision. 117.6a If an
* unpayable cost is increased by an effect or an additional cost is
* imposed, the cost is still unpayable. If an alternative cost is applied
* to an unpayable cost, including an effect that allows a player to cast a
* spell without paying its mana cost, the alternative cost may be paid.
*/
@Test
public void testCastingUnpayableCost() {
// You may cast nonland cards from your hand without paying their mana costs.
addCard(Zone.BATTLEFIELD, playerA, "Omniscience");
// Suspend 4-{U}
// Target player draws three cards.
addCard(Zone.HAND, playerA, "Ancestral Vision", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Ancestral Vision", playerA);
addTarget(playerA, playerB);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, "Ancestral Vision", 1);
assertHandCount(playerA, 3);
assertLife(playerA, 20);
assertLife(playerB, 20);
}
}
|
UTF-8
|
Java
| 11,353 |
java
|
OmniscienceTest.java
|
Java
|
[
{
"context": "erside.base.CardTestPlayerBase;\n\n/**\n *\n * @author LevelX2\n */\npublic class OmniscienceTest extends CardTest",
"end": 1880,
"score": 0.9993703961372375,
"start": 1873,
"tag": "USERNAME",
"value": "LevelX2"
}
] | null |
[] |
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package org.mage.test.cards.single;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class OmniscienceTest extends CardTestPlayerBase {
/**
* Omniscience {7}{U}{U}{U}
*
* Enchantment You may cast nonland cards from your hand without paying
* their mana costs.
*
*/
@Test
public void testCastingCreature() {
addCard(Zone.BATTLEFIELD, playerA, "Omniscience");
/* player.getPlayable does not take alternate
casting costs in account, so for the test the mana has to be available
but won't be used
*/
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
addCard(Zone.HAND, playerA, "Silvercoat Lion");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Silvercoat Lion");
setChoice(playerA, "Yes");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertPermanentCount(playerA, "Silvercoat Lion", 1);
assertTapped("Plains", false);
}
@Test
public void testCastingSplitCards() {
addCard(Zone.BATTLEFIELD, playerA, "Omniscience");
addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
// Fire deals 2 damage divided as you choose among one or two target creatures and/or players.
addCard(Zone.HAND, playerA, "Fire // Ice");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Fire", playerB);
setChoice(playerA, "Yes");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, "Fire // Ice", 1);
assertLife(playerA, 20);
assertLife(playerB, 18);
assertTapped("Island", false);
assertTapped("Mountain", false);
}
@Test
public void testCastingShrapnelBlast() {
addCard(Zone.BATTLEFIELD, playerA, "Omniscience");
/* player.getPlayable does not take alternate
casting costs in account, so for the test the mana has to be available
but won't be used
*/
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
addCard(Zone.BATTLEFIELD, playerA, "Ornithopter", 1);
addCard(Zone.HAND, playerA, "Shrapnel Blast", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Shrapnel Blast");
setChoice(playerA, "Yes");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 15);
assertGraveyardCount(playerA, "Ornithopter", 1);
assertTapped("Mountain", false);
}
/**
* Spell get cast for 0 if Omniscience is being in play. But with
* Trinisphere it costs at least {3}. Cost/alternate cost (Omniscience) +
* additional costs - cost reductions + minimum cost (Trinishpere) = total
* cost.
*/
@Test
public void testCastingWithTrinisphere() {
addCard(Zone.BATTLEFIELD, playerA, "Omniscience");
addCard(Zone.HAND, playerA, "Silvercoat Lion", 1);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 3);
// As long as Trinisphere is untapped, each spell that would cost less than three mana
// to cast costs three mana to cast. (Additional mana in the cost may be paid with any
// color of mana or colorless mana. For example, a spell that would cost {1}{B} to cast
// costs {2}{B} to cast instead.)
addCard(Zone.BATTLEFIELD, playerB, "Trinisphere", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Silvercoat Lion");
setChoice(playerA, "Yes");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertPermanentCount(playerA, "Silvercoat Lion", 1);
assertTapped("Plains", true); // plains have to be tapped because {3} have to be paid
}
/**
* Omniscience is not allowing me to cast spells for free. I'm playing a
* Commander game against the Computer, if that helps.
*
* Edit: It's not letting me cast fused spells for free. Others seems to be
* working.
*/
@Test
@Ignore // targeting of fused/split spells not supported by testplayer
public void testCastingFusedSpell() {
addCard(Zone.BATTLEFIELD, playerA, "Omniscience");
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3);
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion");
addCard(Zone.BATTLEFIELD, playerB, "Pillarfield Ox");
/*
* Instant
* Far {1}{U} Return target creature to its owner's hand.
* Away{2}{B} Target player sacrifices a creature.
* Fuse (You may cast one or both halves of this card from your hand.)
*/
addCard(Zone.HAND, playerA, "Far // Away");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "fused Far // Away", "Silvercoat Lion^targetPlayer=PlayerB");
playerB.addTarget("Pillarfield Ox");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertHandCount(playerA, 1);
assertHandCount(playerB, 0);
assertGraveyardCount(playerA, "Far // Away", 1);
assertPermanentCount(playerB, "Pillarfield Ox", 0);
assertGraveyardCount(playerB, "Pillarfield Ox", 1);
}
/**
* If another effect (e.g. Future Sight) allows you to cast nonland cards
* from zones other than your hand, Xmage incorrectly lets you cast those
* cards without paying their mana costs. Omniscience only lets you cast
* spells from your hand without paying their mana costs.
*/
@Test
public void testCastingWithFutureSight() {
// You may cast nonland cards from your hand without paying their mana costs.
addCard(Zone.BATTLEFIELD, playerA, "Omniscience");
// Play with the top card of your library revealed.
// You may play the top card of your library.
addCard(Zone.BATTLEFIELD, playerA, "Future Sight", 1);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
addCard(Zone.LIBRARY, playerA, "Silvercoat Lion", 1);
skipInitShuffling();
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Silvercoat Lion");
setChoice(playerA, "Yes");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertPermanentCount(playerA, "Silvercoat Lion", 1);
assertTapped("Plains", true); // plains have to be tapped because {2} have to be paid
}
/**
* If a spell has an additional cost (optional or mandatory, e.g. Entwine),
* Omniscience incorrectly allows you cast the spell as if that cost had
* been paid without paying that spell's mana cost. 117.9d If an alternative
* cost is being paid to cast a spell, any additional costs, cost increases,
* and cost reductions that affect that spell are applied to that
* alternative cost. (See rule 601.2f.)
*/
@Test
public void testCastingWithCyclonicRiftWithOverload() {
// You may cast nonland cards from your hand without paying their mana costs.
addCard(Zone.BATTLEFIELD, playerA, "Omniscience");
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
// Choose one - Barbed Lightning deals 3 damage to target creature; or Barbed Lightning deals 3 damage to target player.
// Entwine {2} (Choose both if you pay the entwine cost.)
addCard(Zone.HAND, playerA, "Barbed Lightning", 1);
// Creature - 3/3 Swampwalk
addCard(Zone.BATTLEFIELD, playerB, "Bog Wraith", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Barbed Lightning", "Bog Wraith");
addTarget(playerA, playerB);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, "Barbed Lightning", 1);
assertGraveyardCount(playerB, "Bog Wraith", 1);
assertLife(playerA, 20);
assertLife(playerB, 17);
assertTapped("Plains", true); // plains have to be tapped because {2} from Entwine have to be paid
}
/**
* If a spell has an unpayable cost (e.g. Ancestral Vision, which has no
* mana cost), Omniscience should allow you to cast that spell without
* paying its mana cost. In the case of Ancestral Vision, for example, Xmage
* only gives you the option to suspend Ancestral Vision. 117.6a If an
* unpayable cost is increased by an effect or an additional cost is
* imposed, the cost is still unpayable. If an alternative cost is applied
* to an unpayable cost, including an effect that allows a player to cast a
* spell without paying its mana cost, the alternative cost may be paid.
*/
@Test
public void testCastingUnpayableCost() {
// You may cast nonland cards from your hand without paying their mana costs.
addCard(Zone.BATTLEFIELD, playerA, "Omniscience");
// Suspend 4-{U}
// Target player draws three cards.
addCard(Zone.HAND, playerA, "Ancestral Vision", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Ancestral Vision", playerA);
addTarget(playerA, playerB);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, "Ancestral Vision", 1);
assertHandCount(playerA, 3);
assertLife(playerA, 20);
assertLife(playerB, 20);
}
}
| 11,353 | 0.66194 | 0.652074 | 295 | 37.484745 | 31.947292 | 128 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.074576 | false | false |
12
|
44fb5a6fb4fcb1160d9631aa10a31ff475a1e22c
| 7,980,049,256,118 |
b59eb879116d608e9c7df70a16a189e270dcb94f
|
/app/src/main/java/com/annimon/hotarufx/bundles/BundleLoader.java
|
abd56718ea5583e27f09fc3467f37c6e7e34a36e
|
[
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
aNNiMON/HotaruFX
|
https://github.com/aNNiMON/HotaruFX
|
9672491b3c26e5e0b221eed561ee2237908a213b
|
691064bb5e2277c6484ab5397385b1512d753fe7
|
refs/heads/master
| 2022-12-11T01:03:19.756000 | 2020-08-27T22:02:33 | 2020-08-27T22:02:33 | 103,023,961 | 12 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.annimon.hotarufx.bundles;
import com.annimon.hotarufx.lib.Context;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
public final class BundleLoader {
public static List<Class<? extends Bundle>> runtimeBundles() {
return Arrays.asList(
CompositionBundle.class,
NodesBundle.class,
NodeUtilsBundle.class,
InterpolatorsBundle.class,
FontBundle.class
);
}
public static void loadSingle(Context context, Class<? extends Bundle> clazz) {
load(context, Collections.singletonList(clazz));
}
public static Map<String, FunctionType> functions() {
final var functions = new HashMap<String, FunctionType>();
apply(runtimeBundles(), functions, ((bundle, map) -> map.putAll(bundle.functions())));
return functions;
}
public static void load(Context context, List<Class<? extends Bundle>> bundles) {
apply(bundles, context, Bundle::load);
}
private static <T> void apply(List<Class<? extends Bundle>> bundles,
T obj, BiConsumer<Bundle, T> action) {
if (action == null || bundles == null || bundles.isEmpty()) {
return;
}
for (Class<? extends Bundle> clazz : bundles) {
try {
final var ctor = clazz.getDeclaredConstructor();
final var bundle = ctor.newInstance();
action.accept(bundle, obj);
} catch (IllegalAccessException | InstantiationException
| NoSuchMethodException | InvocationTargetException ignore) {}
}
}
}
|
UTF-8
|
Java
| 1,834 |
java
|
BundleLoader.java
|
Java
|
[] | null |
[] |
package com.annimon.hotarufx.bundles;
import com.annimon.hotarufx.lib.Context;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
public final class BundleLoader {
public static List<Class<? extends Bundle>> runtimeBundles() {
return Arrays.asList(
CompositionBundle.class,
NodesBundle.class,
NodeUtilsBundle.class,
InterpolatorsBundle.class,
FontBundle.class
);
}
public static void loadSingle(Context context, Class<? extends Bundle> clazz) {
load(context, Collections.singletonList(clazz));
}
public static Map<String, FunctionType> functions() {
final var functions = new HashMap<String, FunctionType>();
apply(runtimeBundles(), functions, ((bundle, map) -> map.putAll(bundle.functions())));
return functions;
}
public static void load(Context context, List<Class<? extends Bundle>> bundles) {
apply(bundles, context, Bundle::load);
}
private static <T> void apply(List<Class<? extends Bundle>> bundles,
T obj, BiConsumer<Bundle, T> action) {
if (action == null || bundles == null || bundles.isEmpty()) {
return;
}
for (Class<? extends Bundle> clazz : bundles) {
try {
final var ctor = clazz.getDeclaredConstructor();
final var bundle = ctor.newInstance();
action.accept(bundle, obj);
} catch (IllegalAccessException | InstantiationException
| NoSuchMethodException | InvocationTargetException ignore) {}
}
}
}
| 1,834 | 0.622683 | 0.622683 | 53 | 33.603775 | 27.183748 | 94 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.830189 | false | false |
12
|
79c0ab3fa90edb33201ccb961f270a6d8f39842a
| 11,055,245,841,603 |
164f8ef0cdb499c022bcbcad418e78b36f12b782
|
/DM/src/hicamp/DataShow/ReaderShow/Reader.java
|
1e399286998ca90f52e56da587fb9ff2d2487131
|
[] |
no_license
|
zhpmatrix/DataMining
|
https://github.com/zhpmatrix/DataMining
|
779946e500294db0d2fa9d0d2b68574cb5fa2c77
|
538147da2a59ddc746d8b59b7846eb39d50e6f79
|
refs/heads/master
| 2016-02-28T02:27:34.759000 | 2013-11-03T14:57:28 | 2013-11-03T14:57:28 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/**
*
*/
package hicamp.DataShow.ReaderShow;
/**
* @author matrix
* @date:2013-10-29 下午04:18:15
* @version:
*
*/
public class Reader {
public static final int PAGE_SIZE = 6;
private String id;
private String pwd;
private String ins;
private String maj;
private String sex;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
public String getIns() {
return ins;
}
public void setIns(String ins) {
this.ins = ins;
}
public String getMaj() {
return maj;
}
public void setMaj(String maj) {
this.maj = maj;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
}
|
UTF-8
|
Java
| 848 |
java
|
Reader.java
|
Java
|
[
{
"context": "ckage hicamp.DataShow.ReaderShow;\r\n/**\r\n * @author matrix\r\n * @date:2013-10-29 下午04:18:15\r\n * @version:\r\n *",
"end": 74,
"score": 0.8064064979553223,
"start": 68,
"tag": "USERNAME",
"value": "matrix"
}
] | null |
[] |
/**
*
*/
package hicamp.DataShow.ReaderShow;
/**
* @author matrix
* @date:2013-10-29 下午04:18:15
* @version:
*
*/
public class Reader {
public static final int PAGE_SIZE = 6;
private String id;
private String pwd;
private String ins;
private String maj;
private String sex;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
public String getIns() {
return ins;
}
public void setIns(String ins) {
this.ins = ins;
}
public String getMaj() {
return maj;
}
public void setMaj(String maj) {
this.maj = maj;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
}
| 848 | 0.591232 | 0.57346 | 50 | 14.88 | 11.61833 | 39 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.28 | false | false |
12
|
def761354002bcd335cc95075efd0e73703455b5
| 420,906,799,466 |
8a91f5ed5ba3763f7ce827abff65005f7e0302dd
|
/src/main/java/com/iotek/service/AdminService.java
|
d57ac119d6bce9f5436eb3eeca26eeec34920079
|
[] |
no_license
|
120720127suncheng/maven_shopping
|
https://github.com/120720127suncheng/maven_shopping
|
a35cac43ef80783134df45aa0cc79e89325cdeae
|
2b8dd23347a065c6324b66b0117f91042f56db67
|
refs/heads/master
| 2021-04-03T05:54:00.973000 | 2018-03-22T15:19:58 | 2018-03-22T15:19:58 | 124,633,712 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.iotek.service;
import com.iotek.po.Admin;
/**
* com.iotek.service
*
* @author <Author Administrator>
* @date 2018/3/19 22:58
*/
public interface AdminService {
boolean addAdmin(Admin admin);
Admin findAdminByPassword(Admin admin);
boolean updateAdmin(Admin admin);
boolean updateAdminAfterLogin(Admin admin);
Admin findAdminByAId(Admin admin);
}
|
UTF-8
|
Java
| 384 |
java
|
AdminService.java
|
Java
|
[
{
"context": "n;\n\n/**\n * com.iotek.service\n *\n * @author <Author Administrator>\n * @date 2018/3/19 22:58\n */\npublic interface Ad",
"end": 116,
"score": 0.8868205547332764,
"start": 103,
"tag": "NAME",
"value": "Administrator"
}
] | null |
[] |
package com.iotek.service;
import com.iotek.po.Admin;
/**
* com.iotek.service
*
* @author <Author Administrator>
* @date 2018/3/19 22:58
*/
public interface AdminService {
boolean addAdmin(Admin admin);
Admin findAdminByPassword(Admin admin);
boolean updateAdmin(Admin admin);
boolean updateAdminAfterLogin(Admin admin);
Admin findAdminByAId(Admin admin);
}
| 384 | 0.726563 | 0.697917 | 17 | 21.647058 | 16.200731 | 47 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.411765 | false | false |
12
|
f85730776ce51aaad94b4141d5e6b43f4aa0c029
| 24,472,723,661,246 |
91adad30d19b142195418ae556052fc5949042cf
|
/src/main/java/com/taiji/app/service/TAppInfoService.java
|
0c12c7285ccf89445a82bef6b603b2e94d271764
|
[] |
no_license
|
star-storm/sw-view
|
https://github.com/star-storm/sw-view
|
735799618d50f71833fac76f7278dae7a19e744e
|
7ef97e5ea568ff66599c3d2b63b85e29485a5fdc
|
refs/heads/master
| 2022-12-15T20:16:11.488000 | 2020-09-11T02:25:40 | 2020-09-11T02:25:40 | 293,401,404 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/**
*
*/
package com.taiji.app.service;
import java.util.List;
import com.taiji.admin.common.LogMsgInfo;
import com.taiji.admin.common.PageInfo;
import com.taiji.admin.model.SUser;
import com.taiji.app.model.TAppInfo;
/**
*
* sw-view com.taiji.app.service TAppInfoService.java
*
* @author hsl
*
* 2020年5月9日 下午4:39:29
*
* desc:
*/
public interface TAppInfoService {
/**
* 计数
*/
long count(String name, SUser host);
/**
* 列表
*/
List<TAppInfo> appInfoPage(PageInfo pageInfo, String name, SUser host);
/**
* 基本信息
*/
TAppInfo getAppInfo(Integer id);
/**
* 查询全部
*/
List<TAppInfo> members();
/**
* 更新:新建,编辑
*/
public String updateAppInfo(Integer id, String name, String code, String url, String owner, String pid, SUser host);
/**
* 删除
*/
boolean delAppInfo(Integer id, SUser host);
/**
* 批量删除组织
*/
LogMsgInfo delBatch(String ids, SUser host);
}
|
UTF-8
|
Java
| 976 |
java
|
TAppInfoService.java
|
Java
|
[
{
"context": "iji.app.service TAppInfoService.java\n *\n * @author hsl\n *\n * 2020年5月9日 下午4:39:29\n *\n * desc:\n */\npublic ",
"end": 303,
"score": 0.999524712562561,
"start": 300,
"tag": "USERNAME",
"value": "hsl"
}
] | null |
[] |
/**
*
*/
package com.taiji.app.service;
import java.util.List;
import com.taiji.admin.common.LogMsgInfo;
import com.taiji.admin.common.PageInfo;
import com.taiji.admin.model.SUser;
import com.taiji.app.model.TAppInfo;
/**
*
* sw-view com.taiji.app.service TAppInfoService.java
*
* @author hsl
*
* 2020年5月9日 下午4:39:29
*
* desc:
*/
public interface TAppInfoService {
/**
* 计数
*/
long count(String name, SUser host);
/**
* 列表
*/
List<TAppInfo> appInfoPage(PageInfo pageInfo, String name, SUser host);
/**
* 基本信息
*/
TAppInfo getAppInfo(Integer id);
/**
* 查询全部
*/
List<TAppInfo> members();
/**
* 更新:新建,编辑
*/
public String updateAppInfo(Integer id, String name, String code, String url, String owner, String pid, SUser host);
/**
* 删除
*/
boolean delAppInfo(Integer id, SUser host);
/**
* 批量删除组织
*/
LogMsgInfo delBatch(String ids, SUser host);
}
| 976 | 0.651648 | 0.63956 | 60 | 14.166667 | 21.023136 | 117 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.95 | false | false |
12
|
25767681fe30ba778a1be91675763d4dcd807736
| 32,762,010,538,272 |
4bbb3ece3857c7ac905091c2c01e5439e6a99780
|
/dede/src/main/java/net/frank/dede/rowmapper/DedeMtypesRowMapper.java
|
254bcd25648b78c56d97d19dd9f314148f7c9a4b
|
[] |
no_license
|
frankzhf/dream
|
https://github.com/frankzhf/dream
|
b98d77de2ea13209aed52a0499cced0be7b99d3c
|
c90edbdd8dcdb4b0e7c8c22c1fccdefadeb85791
|
refs/heads/master
| 2022-12-22T12:20:29.710000 | 2020-10-13T02:41:37 | 2020-10-13T02:41:37 | 38,374,538 | 0 | 1 | null | false | 2022-12-16T01:03:37 | 2015-07-01T14:06:19 | 2020-10-13T02:43:04 | 2022-12-16T01:03:33 | 82,177 | 0 | 1 | 70 |
JavaScript
| false | false |
package net.frank.dede.rowmapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import net.frank.dede.bean.DedeMtypes;
import org.springframework.jdbc.core.RowMapper;
public final class DedeMtypesRowMapper implements RowMapper<DedeMtypes> {
@Override
public DedeMtypes mapRow(ResultSet rs, int index)
throws SQLException {
DedeMtypes to = new DedeMtypes();
to.setMtypeid(rs.getInt("mtypeid"));
to.setMtypename(rs.getString("mtypename"));
to.setChannelid(rs.getInt("channelid"));
to.setMid(rs.getInt("mid"));
return to;
}
}
|
UTF-8
|
Java
| 579 |
java
|
DedeMtypesRowMapper.java
|
Java
|
[] | null |
[] |
package net.frank.dede.rowmapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import net.frank.dede.bean.DedeMtypes;
import org.springframework.jdbc.core.RowMapper;
public final class DedeMtypesRowMapper implements RowMapper<DedeMtypes> {
@Override
public DedeMtypes mapRow(ResultSet rs, int index)
throws SQLException {
DedeMtypes to = new DedeMtypes();
to.setMtypeid(rs.getInt("mtypeid"));
to.setMtypename(rs.getString("mtypename"));
to.setChannelid(rs.getInt("channelid"));
to.setMid(rs.getInt("mid"));
return to;
}
}
| 579 | 0.73057 | 0.73057 | 22 | 24.318182 | 20.516926 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.363636 | false | false |
12
|
65c041021a847fbf6982a2a220f335ef166deb9c
| 9,148,280,352,892 |
bb78cd9387bb51b1dc32fb7eee6cd9b72cb57b55
|
/mobile/build/tmp/kapt3/stubs/debug/com/google/samples/apps/iosched/ui/signin/SignInEvent.java
|
4aedc128e60839d1e99109c8442a7e24bf833550
|
[
"Apache-2.0"
] |
permissive
|
IgorGolubenkov/qa_task_city_mobil
|
https://github.com/IgorGolubenkov/qa_task_city_mobil
|
25db6fe5c61c05adb3a0fd8b4ba967a98cb62b9f
|
6a296bd44fd991e3140e847c785c2669e8d641cb
|
refs/heads/master
| 2020-12-11T14:07:19.752000 | 2020-01-14T14:39:16 | 2020-01-14T14:39:16 | 233,859,471 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.google.samples.apps.iosched.ui.signin;
import java.lang.System;
@kotlin.Metadata(mv = {1, 1, 15}, bv = {1, 0, 3}, k = 1, d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0010\u0010\n\u0002\b\u0004\b\u0086\u0001\u0018\u00002\b\u0012\u0004\u0012\u00020\u00000\u0001B\u0007\b\u0002\u00a2\u0006\u0002\u0010\u0002j\u0002\b\u0003j\u0002\b\u0004\u00a8\u0006\u0005"}, d2 = {"Lcom/google/samples/apps/iosched/ui/signin/SignInEvent;", "", "(Ljava/lang/String;I)V", "RequestSignIn", "RequestSignOut", "mobile_debug"})
public enum SignInEvent {
/*public static final*/ RequestSignIn /* = new RequestSignIn() */,
/*public static final*/ RequestSignOut /* = new RequestSignOut() */;
SignInEvent() {
}
}
|
UTF-8
|
Java
| 719 |
java
|
SignInEvent.java
|
Java
|
[] | null |
[] |
package com.google.samples.apps.iosched.ui.signin;
import java.lang.System;
@kotlin.Metadata(mv = {1, 1, 15}, bv = {1, 0, 3}, k = 1, d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0010\u0010\n\u0002\b\u0004\b\u0086\u0001\u0018\u00002\b\u0012\u0004\u0012\u00020\u00000\u0001B\u0007\b\u0002\u00a2\u0006\u0002\u0010\u0002j\u0002\b\u0003j\u0002\b\u0004\u00a8\u0006\u0005"}, d2 = {"Lcom/google/samples/apps/iosched/ui/signin/SignInEvent;", "", "(Ljava/lang/String;I)V", "RequestSignIn", "RequestSignOut", "mobile_debug"})
public enum SignInEvent {
/*public static final*/ RequestSignIn /* = new RequestSignIn() */,
/*public static final*/ RequestSignOut /* = new RequestSignOut() */;
SignInEvent() {
}
}
| 719 | 0.698192 | 0.499305 | 12 | 59 | 116.997154 | 438 | false | false | 0 | 0 | 36 | 0.150209 | 0 | 0 | 1.583333 | false | false |
12
|
578c782c35c9b1c829f0625c1e531a119144cf79
| 21,878,563,434,377 |
9b7fee1eab11c55fa17458531a60a695acfc8821
|
/src/main/java/com/athena/backend/platform/dto/users/UserSettingsDTO.java
|
1f428df23c1f847c90ac1c7db414e29524cbe967
|
[] |
no_license
|
myteksp/athena-platform
|
https://github.com/myteksp/athena-platform
|
ccb522678fc1bf9e11e909463363bf61372353f9
|
0521a969aff2c7bfe362465ce0ea7d531f06aa0e
|
refs/heads/master
| 2021-01-22T00:36:42.835000 | 2019-04-16T11:17:57 | 2019-04-16T11:17:57 | 102,191,188 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.athena.backend.platform.dto.users;
import com.gf.util.string.JSON;
public final class UserSettingsDTO {
public HomeSceenWidget homeWidget;
public String homeWidgetParam;
public String homeWidgetImageUrl;
public static enum HomeSceenWidget{
NONE, MINIGAME, APP_PAGE
}
@Override
public final int hashCode() {
return this.toString().hashCode();
}
@Override
public final boolean equals(final Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final UserSettingsDTO other = (UserSettingsDTO) obj;
return this.toString().equals(other.toString());
}
@Override
public final String toString() {
return JSON.toJson(this);
}
}
|
UTF-8
|
Java
| 744 |
java
|
UserSettingsDTO.java
|
Java
|
[] | null |
[] |
package com.athena.backend.platform.dto.users;
import com.gf.util.string.JSON;
public final class UserSettingsDTO {
public HomeSceenWidget homeWidget;
public String homeWidgetParam;
public String homeWidgetImageUrl;
public static enum HomeSceenWidget{
NONE, MINIGAME, APP_PAGE
}
@Override
public final int hashCode() {
return this.toString().hashCode();
}
@Override
public final boolean equals(final Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final UserSettingsDTO other = (UserSettingsDTO) obj;
return this.toString().equals(other.toString());
}
@Override
public final String toString() {
return JSON.toJson(this);
}
}
| 744 | 0.724462 | 0.724462 | 33 | 21.545454 | 16.542124 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.636364 | false | false |
12
|
08ad472afdcbc3040134f228afe7075e806185ea
| 13,280,038,886,974 |
3d8bf2ce9adfe8c5ed704c0b8695eb8bdc0df4d2
|
/src/main/java/net/blay09/mods/cookingbook/client/model/ModelSmallFridge.java
|
60e17b9240beb5ac1f452d6a2fff7fc64090f823
|
[
"MIT"
] |
permissive
|
CannibalVox/CookingForBlockheads
|
https://github.com/CannibalVox/CookingForBlockheads
|
bcd1fd9acc9b3f39a7a4d4b0a9bf096dac333eb5
|
c7274a3b532982313f64f6e776a0184f923980cf
|
refs/heads/master
| 2021-01-15T16:41:22.905000 | 2015-08-23T17:53:27 | 2015-08-23T17:53:27 | 41,258,612 | 1 | 0 | null | true | 2015-08-23T17:01:01 | 2015-08-23T17:01:00 | 2015-07-24T10:29:31 | 2015-08-19T15:44:36 | 488 | 0 | 0 | 0 | null | null | null |
package net.blay09.mods.cookingbook.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import org.lwjgl.opengl.GL11;
/**
* Small Fridge - Blay & Zero
* Created using Tabula 5.1.0
*/
public class ModelSmallFridge extends ModelBase {
public ModelRenderer Shelf;
public ModelRenderer Door;
public ModelRenderer DoorHandle;
public ModelRenderer TopHinge;
public ModelRenderer BottemHinge;
public ModelRenderer RightSeal;
public ModelRenderer LeftSeal;
public ModelRenderer TopSeal;
public ModelRenderer BottemSeal;
public ModelRenderer RightWall;
public ModelRenderer LeftWall;
public ModelRenderer Backwall;
public ModelRenderer Bottom;
public ModelRenderer Top;
public ModelRenderer PlugThingy;
public ModelRenderer BackLeftFoot;
public ModelRenderer BackRightFoot;
public ModelRenderer FrontLeftFoot;
public ModelRenderer FrontRightFoot;
public ModelSmallFridge() {
this.textureWidth = 126;
this.textureHeight = 43;
this.TopSeal = new ModelRenderer(this, 80, 0);
this.TopSeal.setRotationPoint(-5.5F, 9.200000000000001F, -5.8F);
this.TopSeal.addBox(0.0F, 0.0F, 0.0F, 11, 1, 1, 0.0F);
this.Backwall = new ModelRenderer(this, 16, 12);
this.Backwall.setRotationPoint(-6.0F, 9.700000000000001F, 5.7F);
this.Backwall.addBox(1.0F, 1.0F, 0.0F, 10, 11, 1, 0.0F);
this.Bottom = new ModelRenderer(this, 28, 16);
this.Bottom.setRotationPoint(-6.0F, 22.699999999999996F, -7.0F);
this.Bottom.addBox(1.0F, -1.0F, 2.0F, 10, 2, 12, 0.0F);
this.Top = new ModelRenderer(this, 60, 29);
this.Top.setRotationPoint(-6.0F, 8.700000000000001F, -7.0F);
this.Top.addBox(1.0F, 0.0F, 2.0F, 10, 2, 12, 0.0F);
this.DoorHandle = new ModelRenderer(this, 0, 0);
this.DoorHandle.setRotationPoint(-6.3F, 9.5F, -5.3F);
this.DoorHandle.addBox(11.1F, 5.8F, -2.0F, 1, 2, 1, 0.0F);
this.LeftWall = new ModelRenderer(this, 0, 12);
this.LeftWall.setRotationPoint(6.0F, 8.700000000000001F, -7.0F);
this.LeftWall.addBox(-1.0F, 0.0F, 2.0F, 2, 15, 12, 0.0F);
this.BottemSeal = new ModelRenderer(this, 103, 1);
this.BottemSeal.setRotationPoint(-5.5F, 22.199999999999996F, -5.8F);
this.BottemSeal.addBox(0.0F, 0.0F, 0.0F, 11, 1, 1, 0.0F);
this.PlugThingy = new ModelRenderer(this, 35, 0);
this.PlugThingy.setRotationPoint(-5.0F, 20.7F, 5.9F);
this.PlugThingy.addBox(0.0F, 0.0F, 0.0F, 2, 1, 1, 0.0F);
this.RightSeal = new ModelRenderer(this, 72, 0);
this.RightSeal.setRotationPoint(-6.5F, 9.200000000000001F, -5.8F);
this.RightSeal.addBox(0.0F, 0.0F, 0.0F, 1, 14, 1, 0.0F);
this.TopHinge = new ModelRenderer(this, 4, 0);
this.TopHinge.setRotationPoint(-6.8F, 8.9F, -6.0F);
this.TopHinge.addBox(0.0F, 0.0F, 0.0F, 1, 1, 1, 0.0F);
this.Door = new ModelRenderer(this, 42, 0);
this.Door.setRotationPoint(-6.3F, 9.5F, -5.3F);
this.Door.addBox(-0.7F, -0.8F, -1.5F, 14, 15, 1, 0.0F);
this.Shelf = new ModelRenderer(this, 0, 0);
this.Shelf.setRotationPoint(-6.0F, 15.8F, -4.0F);
this.Shelf.addBox(1.0F, 0.0F, -1.0F, 10, 1, 11, 0.0F);
this.FrontLeftFoot = new ModelRenderer(this, 4, 3);
this.FrontLeftFoot.setRotationPoint(-6.0F, 23.0F, 5.0F);
this.FrontLeftFoot.addBox(0.0F, 0.0F, 0.0F, 1, 1, 1, 0.0F);
this.BackRightFoot = new ModelRenderer(this, 0, 5);
this.BackRightFoot.setRotationPoint(5.0F, 23.0F, -4.0F);
this.BackRightFoot.addBox(0.0F, 0.0F, 0.0F, 1, 1, 1, 0.0F);
this.BottemHinge = new ModelRenderer(this, 31, 0);
this.BottemHinge.setRotationPoint(-6.8F, 22.499999999999996F, -6.0F);
this.BottemHinge.addBox(0.0F, 0.0F, 0.0F, 1, 1, 1, 0.0F);
this.BackLeftFoot = new ModelRenderer(this, 4, 5);
this.BackLeftFoot.setRotationPoint(-6.0F, 23.0F, -4.0F);
this.BackLeftFoot.addBox(0.0F, 0.0F, 0.0F, 1, 1, 1, 0.0F);
this.RightWall = new ModelRenderer(this, 80, 2);
this.RightWall.setRotationPoint(-7.0F, 8.700000000000001F, -7.0F);
this.RightWall.addBox(0.0F, 0.0F, 2.0F, 2, 15, 12, 0.0F);
this.LeftSeal = new ModelRenderer(this, 76, 0);
this.LeftSeal.setRotationPoint(5.5F, 9.200000000000001F, -5.8F);
this.LeftSeal.addBox(0.0F, 0.0F, 0.0F, 1, 14, 1, 0.0F);
this.FrontRightFoot = new ModelRenderer(this, 0, 3);
this.FrontRightFoot.setRotationPoint(5.0F, 23.0F, 5.0F);
this.FrontRightFoot.addBox(0.0F, 0.0F, 0.0F, 1, 1, 1, 0.0F);
}
@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
this.RightWall.render(f5);
this.Shelf.render(f5);
this.LeftSeal.render(f5);
this.Bottom.render(f5);
this.PlugThingy.render(f5);
this.Top.render(f5);
this.LeftWall.render(f5);
this.TopHinge.render(f5);
this.BottemHinge.render(f5);
this.RightSeal.render(f5);
this.DoorHandle.render(f5);
this.BackRightFoot.render(f5);
this.Door.render(f5);
this.FrontRightFoot.render(f5);
this.BottemSeal.render(f5);
this.BackLeftFoot.render(f5);
this.Backwall.render(f5);
this.FrontLeftFoot.render(f5);
this.TopSeal.render(f5);
}
/**
* This is a helper function from Tabula to set the rotation of model parts
*/
public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) {
modelRenderer.rotateAngleX = x;
modelRenderer.rotateAngleY = y;
modelRenderer.rotateAngleZ = z;
}
public void renderInterior() {
float f5 = 0.0625f;
this.Shelf.render(f5);
}
public void renderUncolored() {
float f5 = 0.0625f;
this.PlugThingy.render(f5);
this.LeftSeal.render(f5);
this.RightSeal.render(f5);
this.BottemSeal.render(f5);
this.TopSeal.render(f5);
this.TopHinge.render(f5);
this.BottemHinge.render(f5);
this.DoorHandle.render(f5);
this.BackRightFoot.render(f5);
this.FrontRightFoot.render(f5);
this.BackLeftFoot.render(f5);
this.FrontLeftFoot.render(f5);
}
public void renderColored() {
float f5 = 0.0625f;
this.RightWall.render(f5);
this.Bottom.render(f5);
this.Top.render(f5);
this.LeftWall.render(f5);
this.Door.render(f5);
this.Backwall.render(f5);
}
}
|
UTF-8
|
Java
| 6,698 |
java
|
ModelSmallFridge.java
|
Java
|
[] | null |
[] |
package net.blay09.mods.cookingbook.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import org.lwjgl.opengl.GL11;
/**
* Small Fridge - Blay & Zero
* Created using Tabula 5.1.0
*/
public class ModelSmallFridge extends ModelBase {
public ModelRenderer Shelf;
public ModelRenderer Door;
public ModelRenderer DoorHandle;
public ModelRenderer TopHinge;
public ModelRenderer BottemHinge;
public ModelRenderer RightSeal;
public ModelRenderer LeftSeal;
public ModelRenderer TopSeal;
public ModelRenderer BottemSeal;
public ModelRenderer RightWall;
public ModelRenderer LeftWall;
public ModelRenderer Backwall;
public ModelRenderer Bottom;
public ModelRenderer Top;
public ModelRenderer PlugThingy;
public ModelRenderer BackLeftFoot;
public ModelRenderer BackRightFoot;
public ModelRenderer FrontLeftFoot;
public ModelRenderer FrontRightFoot;
public ModelSmallFridge() {
this.textureWidth = 126;
this.textureHeight = 43;
this.TopSeal = new ModelRenderer(this, 80, 0);
this.TopSeal.setRotationPoint(-5.5F, 9.200000000000001F, -5.8F);
this.TopSeal.addBox(0.0F, 0.0F, 0.0F, 11, 1, 1, 0.0F);
this.Backwall = new ModelRenderer(this, 16, 12);
this.Backwall.setRotationPoint(-6.0F, 9.700000000000001F, 5.7F);
this.Backwall.addBox(1.0F, 1.0F, 0.0F, 10, 11, 1, 0.0F);
this.Bottom = new ModelRenderer(this, 28, 16);
this.Bottom.setRotationPoint(-6.0F, 22.699999999999996F, -7.0F);
this.Bottom.addBox(1.0F, -1.0F, 2.0F, 10, 2, 12, 0.0F);
this.Top = new ModelRenderer(this, 60, 29);
this.Top.setRotationPoint(-6.0F, 8.700000000000001F, -7.0F);
this.Top.addBox(1.0F, 0.0F, 2.0F, 10, 2, 12, 0.0F);
this.DoorHandle = new ModelRenderer(this, 0, 0);
this.DoorHandle.setRotationPoint(-6.3F, 9.5F, -5.3F);
this.DoorHandle.addBox(11.1F, 5.8F, -2.0F, 1, 2, 1, 0.0F);
this.LeftWall = new ModelRenderer(this, 0, 12);
this.LeftWall.setRotationPoint(6.0F, 8.700000000000001F, -7.0F);
this.LeftWall.addBox(-1.0F, 0.0F, 2.0F, 2, 15, 12, 0.0F);
this.BottemSeal = new ModelRenderer(this, 103, 1);
this.BottemSeal.setRotationPoint(-5.5F, 22.199999999999996F, -5.8F);
this.BottemSeal.addBox(0.0F, 0.0F, 0.0F, 11, 1, 1, 0.0F);
this.PlugThingy = new ModelRenderer(this, 35, 0);
this.PlugThingy.setRotationPoint(-5.0F, 20.7F, 5.9F);
this.PlugThingy.addBox(0.0F, 0.0F, 0.0F, 2, 1, 1, 0.0F);
this.RightSeal = new ModelRenderer(this, 72, 0);
this.RightSeal.setRotationPoint(-6.5F, 9.200000000000001F, -5.8F);
this.RightSeal.addBox(0.0F, 0.0F, 0.0F, 1, 14, 1, 0.0F);
this.TopHinge = new ModelRenderer(this, 4, 0);
this.TopHinge.setRotationPoint(-6.8F, 8.9F, -6.0F);
this.TopHinge.addBox(0.0F, 0.0F, 0.0F, 1, 1, 1, 0.0F);
this.Door = new ModelRenderer(this, 42, 0);
this.Door.setRotationPoint(-6.3F, 9.5F, -5.3F);
this.Door.addBox(-0.7F, -0.8F, -1.5F, 14, 15, 1, 0.0F);
this.Shelf = new ModelRenderer(this, 0, 0);
this.Shelf.setRotationPoint(-6.0F, 15.8F, -4.0F);
this.Shelf.addBox(1.0F, 0.0F, -1.0F, 10, 1, 11, 0.0F);
this.FrontLeftFoot = new ModelRenderer(this, 4, 3);
this.FrontLeftFoot.setRotationPoint(-6.0F, 23.0F, 5.0F);
this.FrontLeftFoot.addBox(0.0F, 0.0F, 0.0F, 1, 1, 1, 0.0F);
this.BackRightFoot = new ModelRenderer(this, 0, 5);
this.BackRightFoot.setRotationPoint(5.0F, 23.0F, -4.0F);
this.BackRightFoot.addBox(0.0F, 0.0F, 0.0F, 1, 1, 1, 0.0F);
this.BottemHinge = new ModelRenderer(this, 31, 0);
this.BottemHinge.setRotationPoint(-6.8F, 22.499999999999996F, -6.0F);
this.BottemHinge.addBox(0.0F, 0.0F, 0.0F, 1, 1, 1, 0.0F);
this.BackLeftFoot = new ModelRenderer(this, 4, 5);
this.BackLeftFoot.setRotationPoint(-6.0F, 23.0F, -4.0F);
this.BackLeftFoot.addBox(0.0F, 0.0F, 0.0F, 1, 1, 1, 0.0F);
this.RightWall = new ModelRenderer(this, 80, 2);
this.RightWall.setRotationPoint(-7.0F, 8.700000000000001F, -7.0F);
this.RightWall.addBox(0.0F, 0.0F, 2.0F, 2, 15, 12, 0.0F);
this.LeftSeal = new ModelRenderer(this, 76, 0);
this.LeftSeal.setRotationPoint(5.5F, 9.200000000000001F, -5.8F);
this.LeftSeal.addBox(0.0F, 0.0F, 0.0F, 1, 14, 1, 0.0F);
this.FrontRightFoot = new ModelRenderer(this, 0, 3);
this.FrontRightFoot.setRotationPoint(5.0F, 23.0F, 5.0F);
this.FrontRightFoot.addBox(0.0F, 0.0F, 0.0F, 1, 1, 1, 0.0F);
}
@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
this.RightWall.render(f5);
this.Shelf.render(f5);
this.LeftSeal.render(f5);
this.Bottom.render(f5);
this.PlugThingy.render(f5);
this.Top.render(f5);
this.LeftWall.render(f5);
this.TopHinge.render(f5);
this.BottemHinge.render(f5);
this.RightSeal.render(f5);
this.DoorHandle.render(f5);
this.BackRightFoot.render(f5);
this.Door.render(f5);
this.FrontRightFoot.render(f5);
this.BottemSeal.render(f5);
this.BackLeftFoot.render(f5);
this.Backwall.render(f5);
this.FrontLeftFoot.render(f5);
this.TopSeal.render(f5);
}
/**
* This is a helper function from Tabula to set the rotation of model parts
*/
public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) {
modelRenderer.rotateAngleX = x;
modelRenderer.rotateAngleY = y;
modelRenderer.rotateAngleZ = z;
}
public void renderInterior() {
float f5 = 0.0625f;
this.Shelf.render(f5);
}
public void renderUncolored() {
float f5 = 0.0625f;
this.PlugThingy.render(f5);
this.LeftSeal.render(f5);
this.RightSeal.render(f5);
this.BottemSeal.render(f5);
this.TopSeal.render(f5);
this.TopHinge.render(f5);
this.BottemHinge.render(f5);
this.DoorHandle.render(f5);
this.BackRightFoot.render(f5);
this.FrontRightFoot.render(f5);
this.BackLeftFoot.render(f5);
this.FrontLeftFoot.render(f5);
}
public void renderColored() {
float f5 = 0.0625f;
this.RightWall.render(f5);
this.Bottom.render(f5);
this.Top.render(f5);
this.LeftWall.render(f5);
this.Door.render(f5);
this.Backwall.render(f5);
}
}
| 6,698 | 0.633174 | 0.540908 | 157 | 41.662422 | 20.973915 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.076433 | false | false |
12
|
43f5c915f00244584e662b2e0fca745b37019e1e
| 17,824,114,282,092 |
0339a2bd13d4ced5498bf45e9037ff923f88aca9
|
/app/src/main/java/com/example/legible/seguridadargusapp/View/Activity/Captura/AsistioActivity.java
|
257275da82c05873443185e58d8458950ab89807
|
[] |
no_license
|
SergioSilvaL/ArgusSeguridadApp
|
https://github.com/SergioSilvaL/ArgusSeguridadApp
|
bc1f6168fd7be54fbf0863c946bb2cd0ba97452c
|
34ae1cb05b861f3d590ffb031eef51ae0de99c91
|
refs/heads/master
| 2021-01-19T13:41:22.881000 | 2017-08-10T18:12:54 | 2017-08-10T18:12:54 | 82,410,015 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.legible.seguridadargusapp.View.Activity.Captura;
import android.os.Bundle;
import android.view.View;
import com.example.legible.seguridadargusapp.R;
import java.util.HashMap;
import java.util.Map;
public class AsistioActivity extends CapturaActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Todo: set Guardia Name
setContentView("sadf");
btnCapturar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Todo Set Guardia Key
capturarContenido("asdffffff");
}
});
}
private void setContentView(String header){
setContentView(R.layout.activity_signature);
setHeading(header);
setBtnCancelar();
setBtnCapturar();
setProgressDialog(this);
setSignaturePad();
setBtnCancelar();
}
@Override
protected void capturarContenido(String guardiaKey) {
super.capturarContenido(guardiaKey);
progressDialog.show();
setBitacoraDatabaseReferenceBasicValues(null, null, null, null, guardiaKey);
uploadMediaContent(TipoCaptura.Asistencia);
capturarAsistencia(getUploadMediaContentStringUrl(), true, guardiaKey);
progressDialog.dismiss();
}
private void capturarAsistencia(String url, boolean status, String key){
Map<String, Object> childUpdates = new HashMap<>();
childUpdates.put("/firma", url);
childUpdates.put("/asistio", status);
BitacoraDatabaseReference(key).updateChildren(childUpdates);
}
}
|
UTF-8
|
Java
| 1,699 |
java
|
AsistioActivity.java
|
Java
|
[] | null |
[] |
package com.example.legible.seguridadargusapp.View.Activity.Captura;
import android.os.Bundle;
import android.view.View;
import com.example.legible.seguridadargusapp.R;
import java.util.HashMap;
import java.util.Map;
public class AsistioActivity extends CapturaActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Todo: set Guardia Name
setContentView("sadf");
btnCapturar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Todo Set Guardia Key
capturarContenido("asdffffff");
}
});
}
private void setContentView(String header){
setContentView(R.layout.activity_signature);
setHeading(header);
setBtnCancelar();
setBtnCapturar();
setProgressDialog(this);
setSignaturePad();
setBtnCancelar();
}
@Override
protected void capturarContenido(String guardiaKey) {
super.capturarContenido(guardiaKey);
progressDialog.show();
setBitacoraDatabaseReferenceBasicValues(null, null, null, null, guardiaKey);
uploadMediaContent(TipoCaptura.Asistencia);
capturarAsistencia(getUploadMediaContentStringUrl(), true, guardiaKey);
progressDialog.dismiss();
}
private void capturarAsistencia(String url, boolean status, String key){
Map<String, Object> childUpdates = new HashMap<>();
childUpdates.put("/firma", url);
childUpdates.put("/asistio", status);
BitacoraDatabaseReference(key).updateChildren(childUpdates);
}
}
| 1,699 | 0.66804 | 0.66804 | 60 | 27.316668 | 24.218788 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.633333 | false | false |
12
|
5fde9c97caa87f5ccc7c7699b6596cfa19b8854a
| 26,268,019,990,628 |
c4b170b2b75c5b33c85d95bb250fb56b4433ceb4
|
/health_web/src/main/java/com/jd/health/controller/CheckItemController.java
|
3f8d0760d890bc0e72578adb4a32a10f6062352c
|
[] |
no_license
|
hello-8848/001jk
|
https://github.com/hello-8848/001jk
|
b08aedd5e27d86cdd1604f5aba47f532d0e0585d
|
ae9b0fca68f609585d175d34c8d1c11ea623b84c
|
refs/heads/master
| 2023-02-17T13:27:21.711000 | 2021-01-16T09:06:27 | 2021-01-16T09:06:29 | 330,114,921 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.jd.health.controller;
import com.alibaba.dubbo.config.annotation.Reference;
import com.jd.health.constant.MessageConstant;
import com.jd.health.entity.PageResult;
import com.jd.health.entity.Result;
import com.jd.health.pojo.CheckItem;
import com.jd.health.pojo.QueryPageBean;
import com.jd.health.service.CheckItemService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Auther lxy
* @Date
*/
@RestController
@RequestMapping("/checkitem")
public class CheckItemController {
// 订阅 treeCache
///dubbo/ 接口包名/provides/ 解析 ip:port 接口 方法
// forPath("/dubbo/com.itheim..CheckItemService/providers") ip:port findAll
/*Proxy.newProxyInstance(CheckItemController.class.getClassLoader(), new Class[]{CheckItemService.class}, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// 连接服务提供方
Socket socket = new Socket(ip,port);
socket.getOutputStream().write("findByAll".getBytes());
InputStream inputStream = socket.getInputStream();
inputStream.read() 字符流 // 获取服务端响应的结果
// 反序列化
return list;
}
});*/
//注入service
@Reference
private CheckItemService checkItemService;
//查询所有的方法
@GetMapping("/findAll")
public Result findAll() {
List<CheckItem> checkItemList = checkItemService.findAll();
//封装返回结果
return new Result(true, MessageConstant.QUERY_CHECKITEM_SUCCESS, checkItemList);
}
//新增检查项的方法
@PostMapping("/add")
@PreAuthorize("hasAuthority('CHECKITEM_ADD')")
public Result add(@RequestBody CheckItem checkItem){
checkItemService.add(checkItem);
//返回结果
return new Result(true, MessageConstant.ADD_CHECKITEM_SUCCESS);
}
/* //分页查询
@PostMapping("/findPage")
public Result findPage(@RequestBody QueryPageBean queryPageBean) {
PageResult<CheckItem> pageResult=checkItemService.findPage(queryPageBean);
return new Result(true, MessageConstant.QUERY_CHECKGROUP_SUCCESS, pageResult);
}
*/
//分页查询
@PostMapping("/findPage")
// @PreAuthorize("hasAuthority('CHECKITEM_QUERY')")
public Result findPage(@RequestBody QueryPageBean queryPageBean) {
PageResult<CheckItem> pageResult = checkItemService.findPage(queryPageBean);
//响应前端
return new Result(true, MessageConstant.QUERY_CHECKITEM_SUCCESS, pageResult);
}
//删除检查项
@GetMapping("/deleteById")
public Result deleteById(int id) {
checkItemService.deleteById(id);
//响应
return new Result(true, MessageConstant.DELETE_CHECKITEM_SUCCESS);
}
//根据id查询检查项
@GetMapping("/findById")
public Result findById(int id) {
CheckItem checkItem=checkItemService.findById(id);
//响应
return new Result(true, MessageConstant.QUERY_CHECKITEM_SUCCESS, checkItem);
}
//修改检查项
@PostMapping("/update")
public Result update(@Validated @RequestBody CheckItem checkItem) {
checkItemService.update(checkItem);
//响应
return new Result(true, MessageConstant.EDIT_CHECKITEM_SUCCESS);
}
}
|
UTF-8
|
Java
| 3,573 |
java
|
CheckItemController.java
|
Java
|
[
{
"context": "otation.*;\n\nimport java.util.List;\n\n/**\n * @Auther lxy\n * @Date\n */\n@RestController\n@RequestMapping(\"/ch",
"end": 555,
"score": 0.999539852142334,
"start": 552,
"tag": "USERNAME",
"value": "lxy"
}
] | null |
[] |
package com.jd.health.controller;
import com.alibaba.dubbo.config.annotation.Reference;
import com.jd.health.constant.MessageConstant;
import com.jd.health.entity.PageResult;
import com.jd.health.entity.Result;
import com.jd.health.pojo.CheckItem;
import com.jd.health.pojo.QueryPageBean;
import com.jd.health.service.CheckItemService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Auther lxy
* @Date
*/
@RestController
@RequestMapping("/checkitem")
public class CheckItemController {
// 订阅 treeCache
///dubbo/ 接口包名/provides/ 解析 ip:port 接口 方法
// forPath("/dubbo/com.itheim..CheckItemService/providers") ip:port findAll
/*Proxy.newProxyInstance(CheckItemController.class.getClassLoader(), new Class[]{CheckItemService.class}, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// 连接服务提供方
Socket socket = new Socket(ip,port);
socket.getOutputStream().write("findByAll".getBytes());
InputStream inputStream = socket.getInputStream();
inputStream.read() 字符流 // 获取服务端响应的结果
// 反序列化
return list;
}
});*/
//注入service
@Reference
private CheckItemService checkItemService;
//查询所有的方法
@GetMapping("/findAll")
public Result findAll() {
List<CheckItem> checkItemList = checkItemService.findAll();
//封装返回结果
return new Result(true, MessageConstant.QUERY_CHECKITEM_SUCCESS, checkItemList);
}
//新增检查项的方法
@PostMapping("/add")
@PreAuthorize("hasAuthority('CHECKITEM_ADD')")
public Result add(@RequestBody CheckItem checkItem){
checkItemService.add(checkItem);
//返回结果
return new Result(true, MessageConstant.ADD_CHECKITEM_SUCCESS);
}
/* //分页查询
@PostMapping("/findPage")
public Result findPage(@RequestBody QueryPageBean queryPageBean) {
PageResult<CheckItem> pageResult=checkItemService.findPage(queryPageBean);
return new Result(true, MessageConstant.QUERY_CHECKGROUP_SUCCESS, pageResult);
}
*/
//分页查询
@PostMapping("/findPage")
// @PreAuthorize("hasAuthority('CHECKITEM_QUERY')")
public Result findPage(@RequestBody QueryPageBean queryPageBean) {
PageResult<CheckItem> pageResult = checkItemService.findPage(queryPageBean);
//响应前端
return new Result(true, MessageConstant.QUERY_CHECKITEM_SUCCESS, pageResult);
}
//删除检查项
@GetMapping("/deleteById")
public Result deleteById(int id) {
checkItemService.deleteById(id);
//响应
return new Result(true, MessageConstant.DELETE_CHECKITEM_SUCCESS);
}
//根据id查询检查项
@GetMapping("/findById")
public Result findById(int id) {
CheckItem checkItem=checkItemService.findById(id);
//响应
return new Result(true, MessageConstant.QUERY_CHECKITEM_SUCCESS, checkItem);
}
//修改检查项
@PostMapping("/update")
public Result update(@Validated @RequestBody CheckItem checkItem) {
checkItemService.update(checkItem);
//响应
return new Result(true, MessageConstant.EDIT_CHECKITEM_SUCCESS);
}
}
| 3,573 | 0.684335 | 0.684335 | 101 | 32.435642 | 28.505138 | 135 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.475248 | false | false |
12
|
2df12a624bc1a26b0c200f0faa097a073713ac6d
| 33,621,003,997,558 |
b1b082d13dc6001a9b1836a8ad653ed821f44a89
|
/gtl/src/main/java/com/admin/dao/PtsMrzcjsDaoI.java
|
12f9e79637161479b0b4bc40322106a7eb17397b
|
[] |
no_license
|
zeng95xin/exploit
|
https://github.com/zeng95xin/exploit
|
0a078aad06c16e26e6713a07e3cd86ad18c5bde5
|
1c30051343b168138b0766f00a388b0dece62fe5
|
refs/heads/master
| 2021-09-10T17:31:58.650000 | 2018-03-30T02:23:12 | 2018-03-30T02:23:12 | 115,505,870 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.admin.dao;
import com.admin.model.PtsMrzcjs;
/**
* 用户数据库操作类
*
* @author
*
*/
public interface PtsMrzcjsDaoI extends BaseDaoI<PtsMrzcjs> {
}
|
UTF-8
|
Java
| 178 |
java
|
PtsMrzcjsDaoI.java
|
Java
|
[] | null |
[] |
package com.admin.dao;
import com.admin.model.PtsMrzcjs;
/**
* 用户数据库操作类
*
* @author
*
*/
public interface PtsMrzcjsDaoI extends BaseDaoI<PtsMrzcjs> {
}
| 178 | 0.691358 | 0.691358 | 13 | 11.461538 | 16.923426 | 60 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.153846 | false | false |
12
|
8eab50382c4c95e8812c43ca184b12cff1d4588f
| 21,758,304,342,370 |
c12d1b90d49b64c1dc18a046ad283e67fe650bd0
|
/spring-data-jdbc/src/test/java/org/example/springdatajdbc/config/TestAuditConfig.java
|
833e53c6afa72f91fda638bdd14732ee681abf07
|
[] |
no_license
|
fy8207345/spring-demo
|
https://github.com/fy8207345/spring-demo
|
7c3ad86c85627922ae1ea28f1e932f1eed8bbc04
|
d83876e69737859cdb847410080e0b8f136d308d
|
refs/heads/master
| 2023-07-04T04:49:30.279000 | 2021-08-03T07:29:48 | 2021-08-03T07:29:48 | 362,739,631 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package org.example.springdatajdbc.config;
import lombok.extern.slf4j.Slf4j;
import org.example.springdatajdbc.entity.GeneratedId;
import org.example.springdatajdbc.idgeneration.DefaultGeneratorContext;
import org.example.springdatajdbc.idgeneration.IdGenerationFactory;
import org.example.springdatajdbc.idgeneration.IdGenerator;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
import org.springframework.data.annotation.Id;
import org.springframework.data.jdbc.repository.config.EnableJdbcAuditing;
import org.springframework.data.relational.core.mapping.event.BeforeSaveEvent;
import org.springframework.data.util.ReflectionUtils;
import java.lang.reflect.Field;
@Slf4j
@TestConfiguration
@EnableJdbcAuditing
public class TestAuditConfig {
@Bean
public ApplicationListener<BeforeSaveEvent<?>> beforeSaveEventApplicationListener(){
return event -> {
log.info("beforeSave : {}", event);
Object object = event.getEntity();
if(object instanceof GeneratedId){
GeneratedId generatedId = (GeneratedId) object;
Field idField = ReflectionUtils.findField(object.getClass(), new org.springframework.util.ReflectionUtils.FieldFilter() {
@Override
public boolean matches(Field field) {
return field.getAnnotation(Id.class) != null;
}
});
if(idField != null){
Class<?> type = idField.getType();
IdGenerator<Object, ?> generator = IdGenerationFactory.getGenerator(type);
if(generator != null){
Object generate = generator.generate(new DefaultGeneratorContext(object, idField));
generatedId.setId(generate);
log.info("id type : {}", type);
}
}
}
};
}
}
|
UTF-8
|
Java
| 2,060 |
java
|
TestAuditConfig.java
|
Java
|
[] | null |
[] |
package org.example.springdatajdbc.config;
import lombok.extern.slf4j.Slf4j;
import org.example.springdatajdbc.entity.GeneratedId;
import org.example.springdatajdbc.idgeneration.DefaultGeneratorContext;
import org.example.springdatajdbc.idgeneration.IdGenerationFactory;
import org.example.springdatajdbc.idgeneration.IdGenerator;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
import org.springframework.data.annotation.Id;
import org.springframework.data.jdbc.repository.config.EnableJdbcAuditing;
import org.springframework.data.relational.core.mapping.event.BeforeSaveEvent;
import org.springframework.data.util.ReflectionUtils;
import java.lang.reflect.Field;
@Slf4j
@TestConfiguration
@EnableJdbcAuditing
public class TestAuditConfig {
@Bean
public ApplicationListener<BeforeSaveEvent<?>> beforeSaveEventApplicationListener(){
return event -> {
log.info("beforeSave : {}", event);
Object object = event.getEntity();
if(object instanceof GeneratedId){
GeneratedId generatedId = (GeneratedId) object;
Field idField = ReflectionUtils.findField(object.getClass(), new org.springframework.util.ReflectionUtils.FieldFilter() {
@Override
public boolean matches(Field field) {
return field.getAnnotation(Id.class) != null;
}
});
if(idField != null){
Class<?> type = idField.getType();
IdGenerator<Object, ?> generator = IdGenerationFactory.getGenerator(type);
if(generator != null){
Object generate = generator.generate(new DefaultGeneratorContext(object, idField));
generatedId.setId(generate);
log.info("id type : {}", type);
}
}
}
};
}
}
| 2,060 | 0.659223 | 0.657767 | 48 | 41.916668 | 30.033199 | 137 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.625 | false | false |
12
|
4855bcdff7ccb23cabcf29382d8ae5548137eb2d
| 13,288,628,866,799 |
1828782bc700f0c00b07b53188c6bb87c53fd749
|
/jquery/intranetuserjs/home/all pages/check_out_autocomplete_off.java
|
ab00d3164399fe5da551be59e3d4cc4204a36652
|
[] |
no_license
|
northeast-kansas-library-system/nextcustomizations
|
https://github.com/northeast-kansas-library-system/nextcustomizations
|
b6edd8621cf6890d504c0678842facc5a2f8fc85
|
645e261fe526394bdc425cf17c7c1d3bbf7b793a
|
refs/heads/master
| 2022-11-18T18:37:49.675000 | 2020-07-17T22:19:49 | 2020-07-17T22:19:49 | 267,362,012 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/* This turns off autocomplete in the "Check out" input box in the search header */
/* This may no longer be necessary */
//BEGIN disable autocomplete in checkout box
$("#patronsearch").attr("autocomplete","off")
|
UTF-8
|
Java
| 217 |
java
|
check_out_autocomplete_off.java
|
Java
|
[] | null |
[] |
/* This turns off autocomplete in the "Check out" input box in the search header */
/* This may no longer be necessary */
//BEGIN disable autocomplete in checkout box
$("#patronsearch").attr("autocomplete","off")
| 217 | 0.718894 | 0.718894 | 5 | 42.400002 | 26.469604 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | false | false |
12
|
09e5046ee62dd5cb17837a8bce8dc744da3b72da
| 13,623,636,314,696 |
6f2319d769ddf45600930a5188bae6f2a5b7d56a
|
/framework-import-excel/src/main/java/com/ddd/framework/importexcel/utils/ExcelDataConverter.java
|
edec018f84c960f28b86b68042a7949c4cb8cda7
|
[] |
no_license
|
jzft/framework-code
|
https://github.com/jzft/framework-code
|
f8abf8da1dcdc36311e9d57a6b8ea21e4a3b22f0
|
b602b94ef4b0979a8e1f20284bb57aff52a4c9a0
|
refs/heads/main
| 2023-03-25T20:31:57.124000 | 2021-03-25T16:34:18 | 2021-03-25T16:34:18 | 282,160,813 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* 文件名: DataValidater.java
* 版权:
* 描述:
* 修改人: Zhuang Shao Bin
* 修改时间: 2012-6-27
* 修改内容:
*/
package com.ddd.framework.importexcel.utils;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections.map.LinkedMap;
import org.apache.commons.lang3.StringUtils;
/**
* @author Zhuang Shao Bin
* @version
* @see
* @since
*/
public class ExcelDataConverter extends DataConverter {
public final static int DEFAULT_INCOUNT=500;
public final static String DEFAULT_FORMAT="yyyy-MM-dd";
/**
* 返回 to_date(?,format)
* @author Zhuang Shao Bin
* @version 2012-7-25
* @param format
* @return
* @see
* @since
*/
public static String getSqlToDate(String format){
StringBuffer buffer=new StringBuffer();
buffer.append(" to_date(?, '").
append(format).append("') ");
return buffer.toString();
}
/**
* to_date(?,'yyyy-MM-dd')
* @author Zhuang Shao Bin
* @version 2012-7-25
* @return
* @see
* @since
*/
public static String getSqlToDate(){
return getSqlToDate(DEFAULT_FORMAT);
}
/**
* 加入 -01
* @author Zhuang Shao Bin
* @version 2012-8-2
* @param month
* @return
* @see
* @since
*/
public static String strDateJoin(String month){
final String suffix="-01";
return month+suffix;
}
/**
*
* @author Zhuang Shao Bin
* @version 2012-7-20
* @param list
* @return
* @see
* @since
*/
public static List<Long> toLongList(List list){
List<Long> longList=new ArrayList<Long>();
if(list != null){
for(Object obj:list){
if(!DataValidater.isObjNull(obj)){
longList.add(stringToLong(obj.toString()));
}
}
}
return longList;
}
/**
*
* @author Zhuang Shao Bin
* @version 2012-7-23
* @param array
* @return
* @see
* @since
*/
public static String arrayToString(Object []array){
String strKey=Arrays.toString(array);
strKey=StringUtils.substringBetween(strKey, Constants.LEFT_Z_KUO, Constants.RIGHT_Z_KUO);
return strKey;
}
/**
* 返回 in 条件 字符串
* @author Zhuang Shao Bin
* @version 2012-7-23
* @param ids
* @param columName
* @return
* @see
* @since
*/
public static String getInColumnCondStr(String ids,String columName){
return getInColumnCondStr(ids, columName,false);
}
/**
* 返回 in 条件 字符串
* @author Zhuang Shao Bin
* @version 2012-7-17
* @param ids
* @param columName
* @param withAnd
* @return
* @see
* @since
*/
public static String getInColumnCondStr(String ids,String columName,boolean withAnd){
final String AND=" and ";
StringBuffer buffer=new StringBuffer();
List codeList=ExcelDataConverter.getItems(ids,Constants.DOU_SIGN);
if(DataValidater.isCollectionEmpty(codeList)){
return null;
}
if(withAnd){
buffer.append(AND);
}
buffer.append(ExcelDataConverter.inStringSql(codeList,columName));
return buffer.toString();
}
/**
* 返回 in sql 如果 codeList的值 大于500个时会加入 or in()
* (non-javadoc)
* @seeinStringSql
* @author zsb
* @date Dec 9, 2011 4:13:32 PM
* @版本 V 1.0
* @param codeList
* @param columnName
* @return
*/
public static String inStringSql(List<Object>codeList,String columnName){
final String OR="or";
final String IN=" in ";
StringBuffer codeStB=new StringBuffer();
List<String> strList=listToString(codeList,DEFAULT_INCOUNT);
for(String str:strList){
//codeStB.append(Constants.EMPTY_ONE_STR).append(columnName+" in ( "+str+" ) ").append(OR);
codeStB.append(Constants.EMPTY_ONE_STR).append(columnName).append(IN).
append(Constants.LEFT_X_KUO)
.append(str).append(Constants.RIGHT_X_KUO).append(Constants.EMPTY_ONE_STR).append(OR);
}
if( StringUtils.endsWith(codeStB.toString(),OR)){
codeStB=new StringBuffer(StringUtils.substringBeforeLast(codeStB.toString(),OR));
}
return codeStB.toString();
}
/**
*
* @author Zhuang Shao Bin
* @version 2012-7-23
* @param list
* @param divideCount
* @return
* @see
* @since
*/
public static List<String> listToString(List list,int divideCount){
List<String> divideList=new ArrayList<String>();
List list2=null;
if(list != null){
int listSize=list.size();
int length=listSize/divideCount;
int otherPartLength=listSize-divideCount*length;
if(length == 0){
divideList.add(listToString(list));
}else{
for(int j=0;j<length;j++){
list2=new ArrayList<Integer>();
for(int i=0;i<divideCount;i++){
int index=j*divideCount+i; // ---下标位置;
list2.add(list.get(index));
}
divideList.add(listToString(list2));
}
if(otherPartLength>0){
list2=new ArrayList<Integer>();
for(int j=0;j<otherPartLength;j++){
int index=length*divideCount+j;
list2.add(list.get(index));
}
divideList.add(listToString(list2));
}
}
}
return divideList;
}
/**
* list 转为String 与 逗号分开
* @author zsb
* @date Sep 8, 2010 3:31:57 PM
* @版本 V 1.0
* @param list
* @return
*/
public static String listToString(List list) {
String str = null;
if (list != null && !list.isEmpty()) {
str = Arrays.toString(list.toArray());
}
if (StringUtils.isNotBlank(str)) {
str = StringUtils.substringBetween(str, Constants.LEFT_Z_KUO, Constants.RIGHT_Z_KUO);
}
return str;
}
/**
* 字符串 转为时间
* @author Zhuang Shao Bin
* @version 2012-7-11
* @param dateFormat
* @param dateStr
* @return
* @see
* @since
*/
public static Date fmtStrToDate(String dateFormat, String dateStr) {
DateFormat df = null;
if (dateFormat == null){
df = new SimpleDateFormat(DEFAULT_FORMAT);
}else{
df = new SimpleDateFormat(dateFormat);
}
try {
return df.parse(dateStr);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* 取list中bean属性propertyNames做键值
* author liyongqiang
* 2012-7-3
* @param beanList
* @param propertyNames pname1_pname2
* @return
* @throws Exception
*/
public static Map beanListToMap(List beanList,String propertyNames) throws Exception{
String []pnames = StringUtils.split(propertyNames,Constants.UNDER_SEP);
Map beanMap = null;
if(beanList!=null){
beanMap = new LinkedMap();
}
for(Object bean :beanList){
StringBuffer pvals = new StringBuffer();
for(String pname: pnames){
pvals.append(BeanUtils.getProperty(bean, pname)) ;
pvals.append(Constants.UNDER_SEP);
}
String key = StringUtils.removeEnd(pvals.toString(), Constants.UNDER_SEP);
beanMap.put(key, bean);
}
return beanMap;
}
/**
*
* @author Zhuang Shao Bin
* @version 2012-7-23
* @param list
* @param bacthCount
* @return
* @see
* @since
*/
public static List<String> divideList(List<String> list, int bacthCount) {
int listSize = list.size();
int count = listSize/bacthCount;
if (listSize % bacthCount > 0) {
count ++;
}
List<String> divideList = new ArrayList<String>(count);
for (int i = 0; i < count; i++) {
if (i == count - 1) {
divideList.add(StringUtils.join(list.subList(i*bacthCount, i*bacthCount + listSize % bacthCount), Constants.DOU_SIGN));
} else {
divideList.add(StringUtils.join(list.subList(i*bacthCount, (i+1)*bacthCount),Constants.DOU_SIGN));
}
}
return divideList;
}
public static void main(String[] args) {
// String ids="aa,bb,cc";
// List list=PraiseDataConverter.getItems(ids,Constants.DOU_SIGN);
// System.err.println(list);
// List<Integer> list = new ArrayList<Integer>(3889);
// for (int i = 0; i < 4754; i++) {
// list.add(i);
// }
// int bacthCount = 1000;
// int listSize = list.size();
// int count = listSize/bacthCount;
// if (listSize % bacthCount > 0) {
// count ++;
// }
// List<String> divideList = new ArrayList<String>(count);
// for (int i = 0; i < count; i++) {
// if (i == count - 1) {
// divideList.add(StringUtils.join(list.subList(i*bacthCount, i*bacthCount + listSize % bacthCount), ","));
// } else {
// divideList.add(StringUtils.join(list.subList(i*bacthCount, (i+1)*bacthCount), ","));
// }
// }
}
}
|
UTF-8
|
Java
| 8,596 |
java
|
ExcelDataConverter.java
|
Java
|
[
{
"context": "\n * 文件名: DataValidater.java\n * 版权: \n * 描述:\n * 修改人: Zhuang Shao Bin\n * 修改时间: 2012-6-27\n * 修改内容: \n */\npackage com.ddd.",
"end": 69,
"score": 0.9998569488525391,
"start": 54,
"tag": "NAME",
"value": "Zhuang Shao Bin"
},
{
"context": "apache.commons.lang3.StringUtils;\n\n\n/**\n * @author Zhuang Shao Bin\n * @version\n * @see\n * @since \n */\npublic class E",
"end": 512,
"score": 0.9998568892478943,
"start": 497,
"tag": "NAME",
"value": "Zhuang Shao Bin"
},
{
"context": "\";\n\t\n\t\n\t/**\n\t * 返回 to_date(?,format)\n\t * @author Zhuang Shao Bin\n\t * @version 2012-7-25\n\t * @param format\n\t * @",
"end": 774,
"score": 0.9998522400856018,
"start": 759,
"tag": "NAME",
"value": "Zhuang Shao Bin"
},
{
"context": "\n\t\n\t/**\n\t * to_date(?,'yyyy-MM-dd')\n\t * @author Zhuang Shao Bin\n\t * @version 2012-7-25\n\t * @return\n\t * @see\n\t ",
"end": 1113,
"score": 0.9998603463172913,
"start": 1098,
"tag": "NAME",
"value": "Zhuang Shao Bin"
},
{
"context": "(DEFAULT_FORMAT);\n\t}\n\n\t/**\n\t * 加入 -01\n\t * @author Zhuang Shao Bin\n\t * @version 2012-8-2\n\t * @param month\n\t * @re",
"end": 1303,
"score": 0.9998548030853271,
"start": 1288,
"tag": "NAME",
"value": "Zhuang Shao Bin"
},
{
"context": "\treturn month+suffix;\n\t}\n\t\n\t/**\n\t * \n\t * @author Zhuang Shao Bin\n\t * @version 2012-7-20\n\t * @param list\n\t * @re",
"end": 1530,
"score": 0.9998462796211243,
"start": 1515,
"tag": "NAME",
"value": "Zhuang Shao Bin"
},
{
"context": "\n\t\treturn longList;\n\t}\n\t\n\t\n\t/**\n\t * \n\t * @author Zhuang Shao Bin\n\t * @version 2012-7-23\n\t * @param array\n\t * @r",
"end": 1919,
"score": 0.9998515248298645,
"start": 1904,
"tag": "NAME",
"value": "Zhuang Shao Bin"
},
{
"context": "strKey;\n\t}\n\t\n\t\n\t/**\n\t * 返回 in 条件 字符串\n\t * @author Zhuang Shao Bin\n\t * @version 2012-7-23\n\t * @param ids\n\t * @par",
"end": 2263,
"score": 0.999829113483429,
"start": 2248,
"tag": "NAME",
"value": "Zhuang Shao Bin"
},
{
"context": ",false);\n\t}\n\t\n\t/**\n\t * 返回 in 条件 字符串 \n\t * @author Zhuang Shao Bin\n\t * @version 2012-7-17\n\t * @param ids\n\t * @par",
"end": 2545,
"score": 0.9998540282249451,
"start": 2530,
"tag": "NAME",
"value": "Zhuang Shao Bin"
},
{
"context": "\n\t * (non-javadoc)\n\t * @seeinStringSql\n\t * @author zsb\n\t * @date Dec 9, 2011 4:13:32 PM\n\t * @版本 V 1.0\n\t",
"end": 3212,
"score": 0.9994616508483887,
"start": 3209,
"tag": "USERNAME",
"value": "zsb"
},
{
"context": "odeStB.toString();\n }\t\n\t\n\t/**\n\t * \n\t * @author Zhuang Shao Bin\n\t * @version 2012-7-23\n\t * @param list\n\t * @pa",
"end": 4135,
"score": 0.9997102618217468,
"start": 4120,
"tag": "NAME",
"value": "Zhuang Shao Bin"
},
{
"context": "\t\n\t\n\t /**\n\t * list 转为String 与 逗号分开\n\t * @author zsb\n\t * @date Sep 8, 2010 3:31:57 PM\n\t * @版本 V 1",
"end": 5153,
"score": 0.9991261959075928,
"start": 5150,
"tag": "USERNAME",
"value": "zsb"
},
{
"context": ";\n\t }\n\t \n\t \n\t /**\n\t * 字符串 转为时间\n\t * @author Zhuang Shao Bin\n\t * @version 2012-7-11\n\t * @param dateForma",
"end": 5621,
"score": 0.9995598793029785,
"start": 5606,
"tag": "NAME",
"value": "Zhuang Shao Bin"
},
{
"context": "**\n\t * 取list中bean属性propertyNames做键值\n\t * author liyongqiang\n\t * 2012-7-3\n\t * @param beanList\n\t * @param",
"end": 6161,
"score": 0.9989792108535767,
"start": 6150,
"tag": "USERNAME",
"value": "liyongqiang"
},
{
"context": "turn beanMap;\n\t }\n\t \n\t /**\n\t * \n\t * @author Zhuang Shao Bin\n\t * @version 2012-7-23\n\t * @param list\n\t ",
"end": 6932,
"score": 0.9969452023506165,
"start": 6917,
"tag": "NAME",
"value": "Zhuang Shao Bin"
}
] | null |
[] |
/*
* 文件名: DataValidater.java
* 版权:
* 描述:
* 修改人: <NAME>
* 修改时间: 2012-6-27
* 修改内容:
*/
package com.ddd.framework.importexcel.utils;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections.map.LinkedMap;
import org.apache.commons.lang3.StringUtils;
/**
* @author <NAME>
* @version
* @see
* @since
*/
public class ExcelDataConverter extends DataConverter {
public final static int DEFAULT_INCOUNT=500;
public final static String DEFAULT_FORMAT="yyyy-MM-dd";
/**
* 返回 to_date(?,format)
* @author <NAME>
* @version 2012-7-25
* @param format
* @return
* @see
* @since
*/
public static String getSqlToDate(String format){
StringBuffer buffer=new StringBuffer();
buffer.append(" to_date(?, '").
append(format).append("') ");
return buffer.toString();
}
/**
* to_date(?,'yyyy-MM-dd')
* @author <NAME>
* @version 2012-7-25
* @return
* @see
* @since
*/
public static String getSqlToDate(){
return getSqlToDate(DEFAULT_FORMAT);
}
/**
* 加入 -01
* @author <NAME>
* @version 2012-8-2
* @param month
* @return
* @see
* @since
*/
public static String strDateJoin(String month){
final String suffix="-01";
return month+suffix;
}
/**
*
* @author <NAME>
* @version 2012-7-20
* @param list
* @return
* @see
* @since
*/
public static List<Long> toLongList(List list){
List<Long> longList=new ArrayList<Long>();
if(list != null){
for(Object obj:list){
if(!DataValidater.isObjNull(obj)){
longList.add(stringToLong(obj.toString()));
}
}
}
return longList;
}
/**
*
* @author <NAME>
* @version 2012-7-23
* @param array
* @return
* @see
* @since
*/
public static String arrayToString(Object []array){
String strKey=Arrays.toString(array);
strKey=StringUtils.substringBetween(strKey, Constants.LEFT_Z_KUO, Constants.RIGHT_Z_KUO);
return strKey;
}
/**
* 返回 in 条件 字符串
* @author <NAME>
* @version 2012-7-23
* @param ids
* @param columName
* @return
* @see
* @since
*/
public static String getInColumnCondStr(String ids,String columName){
return getInColumnCondStr(ids, columName,false);
}
/**
* 返回 in 条件 字符串
* @author <NAME>
* @version 2012-7-17
* @param ids
* @param columName
* @param withAnd
* @return
* @see
* @since
*/
public static String getInColumnCondStr(String ids,String columName,boolean withAnd){
final String AND=" and ";
StringBuffer buffer=new StringBuffer();
List codeList=ExcelDataConverter.getItems(ids,Constants.DOU_SIGN);
if(DataValidater.isCollectionEmpty(codeList)){
return null;
}
if(withAnd){
buffer.append(AND);
}
buffer.append(ExcelDataConverter.inStringSql(codeList,columName));
return buffer.toString();
}
/**
* 返回 in sql 如果 codeList的值 大于500个时会加入 or in()
* (non-javadoc)
* @seeinStringSql
* @author zsb
* @date Dec 9, 2011 4:13:32 PM
* @版本 V 1.0
* @param codeList
* @param columnName
* @return
*/
public static String inStringSql(List<Object>codeList,String columnName){
final String OR="or";
final String IN=" in ";
StringBuffer codeStB=new StringBuffer();
List<String> strList=listToString(codeList,DEFAULT_INCOUNT);
for(String str:strList){
//codeStB.append(Constants.EMPTY_ONE_STR).append(columnName+" in ( "+str+" ) ").append(OR);
codeStB.append(Constants.EMPTY_ONE_STR).append(columnName).append(IN).
append(Constants.LEFT_X_KUO)
.append(str).append(Constants.RIGHT_X_KUO).append(Constants.EMPTY_ONE_STR).append(OR);
}
if( StringUtils.endsWith(codeStB.toString(),OR)){
codeStB=new StringBuffer(StringUtils.substringBeforeLast(codeStB.toString(),OR));
}
return codeStB.toString();
}
/**
*
* @author <NAME>
* @version 2012-7-23
* @param list
* @param divideCount
* @return
* @see
* @since
*/
public static List<String> listToString(List list,int divideCount){
List<String> divideList=new ArrayList<String>();
List list2=null;
if(list != null){
int listSize=list.size();
int length=listSize/divideCount;
int otherPartLength=listSize-divideCount*length;
if(length == 0){
divideList.add(listToString(list));
}else{
for(int j=0;j<length;j++){
list2=new ArrayList<Integer>();
for(int i=0;i<divideCount;i++){
int index=j*divideCount+i; // ---下标位置;
list2.add(list.get(index));
}
divideList.add(listToString(list2));
}
if(otherPartLength>0){
list2=new ArrayList<Integer>();
for(int j=0;j<otherPartLength;j++){
int index=length*divideCount+j;
list2.add(list.get(index));
}
divideList.add(listToString(list2));
}
}
}
return divideList;
}
/**
* list 转为String 与 逗号分开
* @author zsb
* @date Sep 8, 2010 3:31:57 PM
* @版本 V 1.0
* @param list
* @return
*/
public static String listToString(List list) {
String str = null;
if (list != null && !list.isEmpty()) {
str = Arrays.toString(list.toArray());
}
if (StringUtils.isNotBlank(str)) {
str = StringUtils.substringBetween(str, Constants.LEFT_Z_KUO, Constants.RIGHT_Z_KUO);
}
return str;
}
/**
* 字符串 转为时间
* @author <NAME>
* @version 2012-7-11
* @param dateFormat
* @param dateStr
* @return
* @see
* @since
*/
public static Date fmtStrToDate(String dateFormat, String dateStr) {
DateFormat df = null;
if (dateFormat == null){
df = new SimpleDateFormat(DEFAULT_FORMAT);
}else{
df = new SimpleDateFormat(dateFormat);
}
try {
return df.parse(dateStr);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* 取list中bean属性propertyNames做键值
* author liyongqiang
* 2012-7-3
* @param beanList
* @param propertyNames pname1_pname2
* @return
* @throws Exception
*/
public static Map beanListToMap(List beanList,String propertyNames) throws Exception{
String []pnames = StringUtils.split(propertyNames,Constants.UNDER_SEP);
Map beanMap = null;
if(beanList!=null){
beanMap = new LinkedMap();
}
for(Object bean :beanList){
StringBuffer pvals = new StringBuffer();
for(String pname: pnames){
pvals.append(BeanUtils.getProperty(bean, pname)) ;
pvals.append(Constants.UNDER_SEP);
}
String key = StringUtils.removeEnd(pvals.toString(), Constants.UNDER_SEP);
beanMap.put(key, bean);
}
return beanMap;
}
/**
*
* @author <NAME>
* @version 2012-7-23
* @param list
* @param bacthCount
* @return
* @see
* @since
*/
public static List<String> divideList(List<String> list, int bacthCount) {
int listSize = list.size();
int count = listSize/bacthCount;
if (listSize % bacthCount > 0) {
count ++;
}
List<String> divideList = new ArrayList<String>(count);
for (int i = 0; i < count; i++) {
if (i == count - 1) {
divideList.add(StringUtils.join(list.subList(i*bacthCount, i*bacthCount + listSize % bacthCount), Constants.DOU_SIGN));
} else {
divideList.add(StringUtils.join(list.subList(i*bacthCount, (i+1)*bacthCount),Constants.DOU_SIGN));
}
}
return divideList;
}
public static void main(String[] args) {
// String ids="aa,bb,cc";
// List list=PraiseDataConverter.getItems(ids,Constants.DOU_SIGN);
// System.err.println(list);
// List<Integer> list = new ArrayList<Integer>(3889);
// for (int i = 0; i < 4754; i++) {
// list.add(i);
// }
// int bacthCount = 1000;
// int listSize = list.size();
// int count = listSize/bacthCount;
// if (listSize % bacthCount > 0) {
// count ++;
// }
// List<String> divideList = new ArrayList<String>(count);
// for (int i = 0; i < count; i++) {
// if (i == count - 1) {
// divideList.add(StringUtils.join(list.subList(i*bacthCount, i*bacthCount + listSize % bacthCount), ","));
// } else {
// divideList.add(StringUtils.join(list.subList(i*bacthCount, (i+1)*bacthCount), ","));
// }
// }
}
}
| 8,488 | 0.633294 | 0.615284 | 352 | 22.974432 | 21.838169 | 123 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.088068 | false | false |
12
|
eb0232730f6b14d99d6c6cba7ff4d626910b0364
| 16,484,084,538,304 |
9aa40a8ce7e461afcba4d775328867ecd598a6b3
|
/Carte.java
|
072573bce07d799fedd00cdb85f5019447a66ed9
|
[] |
no_license
|
projetalgof/projet
|
https://github.com/projetalgof/projet
|
c2c78c1d12a0d047525f5e13553b3723f40decaf
|
2490d2d84d88b45d76f7b5c10f7c3df410516321
|
refs/heads/master
| 2020-05-28T04:03:33.363000 | 2019-06-21T14:58:54 | 2019-06-21T14:58:54 | 188,874,015 | 0 | 1 | null | false | 2019-05-31T16:48:50 | 2019-05-27T16:08:27 | 2019-05-27T16:09:43 | 2019-05-31T16:48:38 | 39 | 0 | 1 | 0 | null | false | false |
import java.util.*;
public class Carte implements Comparable<Carte>
{
protected String declencheur; // String pour gerais les declencheur multiple
protected String nom ;
protected String type ;
protected int cout ;
protected int piece ;
public Carte(String declencheur, String nom, String type,int cout,int piece)
{
this.declencheur = declencheur;
this.nom = nom ;
this.type = type ;
this.cout = cout ;
this.piece = piece ;
}
// constructeur par recopie
public Carte(Carte autreCarte)
{
this.declencheur = autreCarte.declencheur;
this.nom = autreCarte.nom;
this.type = autreCarte.type;
this.cout = autreCarte.cout;
this.piece = autreCarte.piece;
}
//activation de l'effet carte
public void action(Joueur propietaire,Joueur joueurActif,Controleur ctrl){}
public int compareTo(Carte c)
{
return this.nom.compareTo(c.nom);
}
//----------------------------------------------------------------------------------------------------------------
// GET
public String getDeclencheur () { return this.declencheur; }
public int getPiece () { return this.piece ; }
public String getNom () { return this.nom; }
public String getType () { return this.type; }
public int getCout () { return this.cout; }
}
|
UTF-8
|
Java
| 1,423 |
java
|
Carte.java
|
Java
|
[] | null |
[] |
import java.util.*;
public class Carte implements Comparable<Carte>
{
protected String declencheur; // String pour gerais les declencheur multiple
protected String nom ;
protected String type ;
protected int cout ;
protected int piece ;
public Carte(String declencheur, String nom, String type,int cout,int piece)
{
this.declencheur = declencheur;
this.nom = nom ;
this.type = type ;
this.cout = cout ;
this.piece = piece ;
}
// constructeur par recopie
public Carte(Carte autreCarte)
{
this.declencheur = autreCarte.declencheur;
this.nom = autreCarte.nom;
this.type = autreCarte.type;
this.cout = autreCarte.cout;
this.piece = autreCarte.piece;
}
//activation de l'effet carte
public void action(Joueur propietaire,Joueur joueurActif,Controleur ctrl){}
public int compareTo(Carte c)
{
return this.nom.compareTo(c.nom);
}
//----------------------------------------------------------------------------------------------------------------
// GET
public String getDeclencheur () { return this.declencheur; }
public int getPiece () { return this.piece ; }
public String getNom () { return this.nom; }
public String getType () { return this.type; }
public int getCout () { return this.cout; }
}
| 1,423 | 0.56922 | 0.56922 | 46 | 29.934782 | 26.692616 | 115 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.608696 | false | false |
12
|
8319e5d7088ad5373f9dbc8f8197e85516e5878c
| 9,603,546,923,676 |
e279546b0f0d62929da97d1c249de21d4ab02fe1
|
/src/main/java/com/mpls/web2/service/ChatRoomService.java
|
86c00710658dd2ddd1d88a9a17ebd58841fd6d95
|
[] |
no_license
|
M-Pluse/010-server
|
https://github.com/M-Pluse/010-server
|
5f697db9bf602f47cd4ef091fea4067074e60db0
|
03f9473c05ea13ae4e5fccd0d6a020c373f9b411
|
refs/heads/master
| 2018-10-27T23:27:33.298000 | 2018-06-08T11:57:30 | 2018-06-08T11:57:30 | 124,900,284 | 1 | 0 | null | false | 2018-05-16T17:15:58 | 2018-03-12T14:18:40 | 2018-05-16T17:04:46 | 2018-05-16T17:15:57 | 1,175 | 1 | 0 | 0 |
Java
| false | null |
package com.mpls.web2.service;
import com.mpls.web2.dto.ChatRoomIntegerWrapper;
import com.mpls.web2.model.ChatRoom;
import org.springframework.data.domain.Pageable;
import java.security.Principal;
import java.util.List;
public interface ChatRoomService {
ChatRoomIntegerWrapper findOneWithMessagesPageable(Long chatRoomId, Principal principal, Integer count);
ChatRoom findOneAvailable(Long id);
List<ChatRoom> findAllAvailable();
ChatRoom save(ChatRoom chatRoom);
ChatRoomIntegerWrapper update(ChatRoom chatRoom, Principal principal);
Boolean delete(Long id);
List<ChatRoom> findAll();
ChatRoom findOne(Long id);
List<ChatRoom> findAllByUserId(Long id);
ChatRoom createOrFindChatRoom(Long userId, Principal principal);
ChatRoom sendUserCreateChatRoom(ChatRoom chatRoom);
}
|
UTF-8
|
Java
| 833 |
java
|
ChatRoomService.java
|
Java
|
[] | null |
[] |
package com.mpls.web2.service;
import com.mpls.web2.dto.ChatRoomIntegerWrapper;
import com.mpls.web2.model.ChatRoom;
import org.springframework.data.domain.Pageable;
import java.security.Principal;
import java.util.List;
public interface ChatRoomService {
ChatRoomIntegerWrapper findOneWithMessagesPageable(Long chatRoomId, Principal principal, Integer count);
ChatRoom findOneAvailable(Long id);
List<ChatRoom> findAllAvailable();
ChatRoom save(ChatRoom chatRoom);
ChatRoomIntegerWrapper update(ChatRoom chatRoom, Principal principal);
Boolean delete(Long id);
List<ChatRoom> findAll();
ChatRoom findOne(Long id);
List<ChatRoom> findAllByUserId(Long id);
ChatRoom createOrFindChatRoom(Long userId, Principal principal);
ChatRoom sendUserCreateChatRoom(ChatRoom chatRoom);
}
| 833 | 0.779112 | 0.77551 | 33 | 24.242424 | 26.740086 | 108 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.636364 | false | false |
12
|
d23ccd0530a2214fc4753af900057060d108cc57
| 17,643,725,712,616 |
c2ab2108d1c7b9a284212a7d91f97b939e2e3f2b
|
/src/CreditPaymentService.java
|
fe8c7e9072020168bb1bfd249a617419747d53a5
|
[] |
no_license
|
daryamorozova/Task-2.2.3
|
https://github.com/daryamorozova/Task-2.2.3
|
2aaa953f45858b3dffebb19e19c52350ed341264
|
0d3a69bc5f0185e70cf45de5f834bd2ff3f05250
|
refs/heads/master
| 2022-11-20T09:35:59.877000 | 2020-07-17T15:49:24 | 2020-07-17T15:49:24 | 280,465,051 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class CreditPaymentService {
public double calculate(double amount, double periodmonth) {
double ratemonth = 9.99 / 1200;
double annuityfactor = (ratemonth * Math.pow(1 + ratemonth, periodmonth)) / (Math.pow(1 + ratemonth, periodmonth) - 1);
double monthlypay = amount * annuityfactor;
return monthlypay;
}
}
|
UTF-8
|
Java
| 356 |
java
|
CreditPaymentService.java
|
Java
|
[] | null |
[] |
public class CreditPaymentService {
public double calculate(double amount, double periodmonth) {
double ratemonth = 9.99 / 1200;
double annuityfactor = (ratemonth * Math.pow(1 + ratemonth, periodmonth)) / (Math.pow(1 + ratemonth, periodmonth) - 1);
double monthlypay = amount * annuityfactor;
return monthlypay;
}
}
| 356 | 0.671348 | 0.643258 | 8 | 43.5 | 37.309517 | 127 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.875 | false | false |
12
|
fbed3fd0c23dd99c2c484b264da4c263a3687ea9
| 4,707,284,203,715 |
6fbdf9dd952151d8fede1c3be241c992b9e4f7ce
|
/Codechef/PRACTICE/RECIPE.java
|
a1a9b86e98be14989199d0293178bc688f4592db
|
[] |
no_license
|
rahul-953/Codechef
|
https://github.com/rahul-953/Codechef
|
69d3464e54d172354372334e99fec5a010fee00c
|
45728aaed2d5506fc6f5966d72773e6c1fe55f6f
|
refs/heads/master
| 2020-04-05T13:08:52.196000 | 2017-07-17T13:14:02 | 2017-07-17T13:14:02 | 95,121,052 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.util.*;
class RECIPE
{
public static void main(String aarg[])
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0)
{
int n;
n=sc.nextInt();
int a[]=new int[n];
int i,gcd;
for(i=0;i<n;i++)
a[i]=sc.nextInt();
gcd=GCD(a[0],a[1]);
for(i=2;i<n;i++)
gcd=GCD(gcd,a[i]);
for(i=0;i<n;i++)
System.out.print((a[i]/gcd)+" ");
System.out.println();
}
}
private static int GCD(int a,int b)
{
if(b==0)
return a;
else
return GCD(b,a%b);
}
}
|
UTF-8
|
Java
| 571 |
java
|
RECIPE.java
|
Java
|
[] | null |
[] |
import java.util.*;
class RECIPE
{
public static void main(String aarg[])
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0)
{
int n;
n=sc.nextInt();
int a[]=new int[n];
int i,gcd;
for(i=0;i<n;i++)
a[i]=sc.nextInt();
gcd=GCD(a[0],a[1]);
for(i=2;i<n;i++)
gcd=GCD(gcd,a[i]);
for(i=0;i<n;i++)
System.out.print((a[i]/gcd)+" ");
System.out.println();
}
}
private static int GCD(int a,int b)
{
if(b==0)
return a;
else
return GCD(b,a%b);
}
}
| 571 | 0.488616 | 0.476357 | 37 | 13.486486 | 11.272118 | 39 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.72973 | false | false |
12
|
648f33469eb43f3ed822944b0cb8c63bfe27bcc9
| 8,650,064,182,772 |
a02ebaeed2756e0b9c238fe31355b5c86821e401
|
/Module_10/src/test/java/test/keywords/GooglePageKeywords.java
|
0256d5253535feb26a388de488183b6ca5c5cf8c
|
[] |
no_license
|
Vozzhaeva/at-mentoring
|
https://github.com/Vozzhaeva/at-mentoring
|
1a164f0e3c7055479949fb0695e725c93c41cbd1
|
ceff881a31435a3b6cb04f0dcbb68040f637fa2c
|
refs/heads/master
| 2023-02-13T01:00:59.693000 | 2021-01-17T19:56:52 | 2021-01-17T19:56:52 | 330,473,203 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package test.keywords;
import io.cucumber.java.ru.Допустим;
import io.cucumber.java.ru.Если;
import io.cucumber.java.ru.И;
import io.cucumber.java.ru.То;
import org.testng.Assert;
import pages.google.CalculatorCloudGooglePage;
import pages.google.CloudGooglePage;
import pages.google.PricingCloudGooglePage;
import pages.google.ProductsCloudGooglePage;
import java.util.HashSet;
import java.util.Set;
public class GooglePageKeywords extends BaseKeywords {
ProductsCloudGooglePage productsCloudGooglePage;
PricingCloudGooglePage pricingCloudGooglePage;
CalculatorCloudGooglePage calculatorCloudGooglePage;
CloudGooglePage cloudGooglePage;
@Допустим("пользователь открывает страницу браузера и открывает сайт clouds.google")
public void init() {
super.browserSetup();
cloudGooglePage = new CloudGooglePage(super.driver)
.openPage();
}
@Допустим("страница clouds.google успешно открылась")
public void isPageOpen() {
Assert.assertNotNull(driver.getTitle());
}
@Если("открыть страницу калькулятора")
public void openCalculatorPage() {
productsCloudGooglePage = cloudGooglePage
.typeButtonProducts()
.typeButtonSeeAllProducts();
pricingCloudGooglePage = productsCloudGooglePage
.clickPricing();
calculatorCloudGooglePage = pricingCloudGooglePage
.clickCalculators();
}
@Если("заполнить значения в калькуляторе")
public void fillCalculatorValues() {
calculatorCloudGooglePage = calculatorCloudGooglePage
.clickComputeEngine()
.enterNumberOfInstances("4")
.enterOperatingSystem()
.enterVMClass()
.enterMachineType()
.enterGPUs()
.enterSSD()
.enterDatecenterLocation()
.enterCommitedUsage();
}
@Если("нажать кнопку Add to estimate")
public void clickButton() {
calculatorCloudGooglePage.clickAddToEstimate();
}
@То("ожидаемые значения соответствуют заданным")
public void assertResult() {
Set<String> actualResult = calculatorCloudGooglePage
.getResult();
Set<String> expectedResult = new HashSet<String>() {{
add("2,920 total hours per month");
add("VM class: regular");
add("Instance type: n1-standard-8");
add("Region: Frankfurt");
add("Total available local SSD space 2x375 GiB");
add("Commitment term: 1 Year");
add("Estimated Component Cost: USD 1,082.77 per 1 month");
}};
Assert.assertEquals(actualResult, expectedResult);
browserTearDown();
}
}
|
UTF-8
|
Java
| 3,001 |
java
|
GooglePageKeywords.java
|
Java
|
[] | null |
[] |
package test.keywords;
import io.cucumber.java.ru.Допустим;
import io.cucumber.java.ru.Если;
import io.cucumber.java.ru.И;
import io.cucumber.java.ru.То;
import org.testng.Assert;
import pages.google.CalculatorCloudGooglePage;
import pages.google.CloudGooglePage;
import pages.google.PricingCloudGooglePage;
import pages.google.ProductsCloudGooglePage;
import java.util.HashSet;
import java.util.Set;
public class GooglePageKeywords extends BaseKeywords {
ProductsCloudGooglePage productsCloudGooglePage;
PricingCloudGooglePage pricingCloudGooglePage;
CalculatorCloudGooglePage calculatorCloudGooglePage;
CloudGooglePage cloudGooglePage;
@Допустим("пользователь открывает страницу браузера и открывает сайт clouds.google")
public void init() {
super.browserSetup();
cloudGooglePage = new CloudGooglePage(super.driver)
.openPage();
}
@Допустим("страница clouds.google успешно открылась")
public void isPageOpen() {
Assert.assertNotNull(driver.getTitle());
}
@Если("открыть страницу калькулятора")
public void openCalculatorPage() {
productsCloudGooglePage = cloudGooglePage
.typeButtonProducts()
.typeButtonSeeAllProducts();
pricingCloudGooglePage = productsCloudGooglePage
.clickPricing();
calculatorCloudGooglePage = pricingCloudGooglePage
.clickCalculators();
}
@Если("заполнить значения в калькуляторе")
public void fillCalculatorValues() {
calculatorCloudGooglePage = calculatorCloudGooglePage
.clickComputeEngine()
.enterNumberOfInstances("4")
.enterOperatingSystem()
.enterVMClass()
.enterMachineType()
.enterGPUs()
.enterSSD()
.enterDatecenterLocation()
.enterCommitedUsage();
}
@Если("нажать кнопку Add to estimate")
public void clickButton() {
calculatorCloudGooglePage.clickAddToEstimate();
}
@То("ожидаемые значения соответствуют заданным")
public void assertResult() {
Set<String> actualResult = calculatorCloudGooglePage
.getResult();
Set<String> expectedResult = new HashSet<String>() {{
add("2,920 total hours per month");
add("VM class: regular");
add("Instance type: n1-standard-8");
add("Region: Frankfurt");
add("Total available local SSD space 2x375 GiB");
add("Commitment term: 1 Year");
add("Estimated Component Cost: USD 1,082.77 per 1 month");
}};
Assert.assertEquals(actualResult, expectedResult);
browserTearDown();
}
}
| 3,001 | 0.656092 | 0.649243 | 83 | 32.421688 | 20.591915 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.457831 | false | false |
12
|
5ed2b34fa668756a1ca60f2d89432f3ffae53f2a
| 24,438,363,963,105 |
9bf4cb5c50d77130d16852b0ea8e9e97f5f5f52a
|
/homework09-traversingtrav/src/fire.java
|
cd57f04e47c73220eeed8a71e911f65841604f2e
|
[] |
no_license
|
traversingtrav/mini-game1
|
https://github.com/traversingtrav/mini-game1
|
014b37a540b3bf449e751f0f1f1d1e602585bebd
|
43fdec1bf21e90813757614a852f2beedc8ccbeb
|
refs/heads/main
| 2023-08-14T01:17:51.928000 | 2021-09-23T11:30:41 | 2021-09-23T11:30:41 | 409,563,629 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/* Travis Crowell
SWEN-601
homework 09
09/22/2021
*/
/**
* initiates parent class constructors along with attackers attack.
*/
public class fire extends Pokemon {
private int Attacker_attack;
/**
* initiates parent class constructors along with attackers attack.
*/
public fire(String name,String type,int attack, int health,int b) {
super(name,type,attack,health);
this.Attacker_attack = b;
}
/**
* calculates and returns damage if attacker is fire type.
*/
public int fire_damage() {
if (type.equals("water")) {
Attacker_attack = (Attacker_attack / 2);
} else if (type.equals("grass")) {
Attacker_attack = (Attacker_attack * 2);
}
return Attacker_attack;
}
}
|
UTF-8
|
Java
| 825 |
java
|
fire.java
|
Java
|
[
{
"context": "/* Travis Crowell\r\nSWEN-601\r\nhomework 09\r\n09/22/2021\r\n */\r\n/**\r\n * ",
"end": 17,
"score": 0.9996769428253174,
"start": 3,
"tag": "NAME",
"value": "Travis Crowell"
}
] | null |
[] |
/* <NAME>
SWEN-601
homework 09
09/22/2021
*/
/**
* initiates parent class constructors along with attackers attack.
*/
public class fire extends Pokemon {
private int Attacker_attack;
/**
* initiates parent class constructors along with attackers attack.
*/
public fire(String name,String type,int attack, int health,int b) {
super(name,type,attack,health);
this.Attacker_attack = b;
}
/**
* calculates and returns damage if attacker is fire type.
*/
public int fire_damage() {
if (type.equals("water")) {
Attacker_attack = (Attacker_attack / 2);
} else if (type.equals("grass")) {
Attacker_attack = (Attacker_attack * 2);
}
return Attacker_attack;
}
}
| 817 | 0.581818 | 0.563636 | 30 | 25.433332 | 22.461349 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.433333 | false | false |
12
|
a93619cd9d4580daaced69d9c56191a472ad05fa
| 19,078,244,778,918 |
af3c0e7cc993d954eca9d1ddc60ba4ab750db52f
|
/build/generated/jax-wsCache/calcws/WsCalcWebServiceCliente/ObjectFactory.java
|
6738b46bf69b9e30b31868aa5144494ef355c79e
|
[] |
no_license
|
vfbellaver/cliente-ws-calc
|
https://github.com/vfbellaver/cliente-ws-calc
|
ce112c62204066449aa50e6a28b1c233de48cbb8
|
a3c097f39565db6b403315ffb2860b1196de0ee4
|
refs/heads/master
| 2021-05-03T14:42:27.392000 | 2018-02-06T16:59:29 | 2018-02-06T16:59:29 | 120,462,659 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package WsCalcWebServiceCliente;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the WsCalcWebServiceCliente package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {
private final static QName _GetSubtrair_QNAME = new QName("http://calculadoraws/", "getSubtrair");
private final static QName _GetMultiplicaResponse_QNAME = new QName("http://calculadoraws/", "getMultiplicaResponse");
private final static QName _GetDivideResponse_QNAME = new QName("http://calculadoraws/", "getDivideResponse");
private final static QName _GetSomaResponse_QNAME = new QName("http://calculadoraws/", "getSomaResponse");
private final static QName _GetSubtrairResponse_QNAME = new QName("http://calculadoraws/", "getSubtrairResponse");
private final static QName _GetDivide_QNAME = new QName("http://calculadoraws/", "getDivide");
private final static QName _GetSoma_QNAME = new QName("http://calculadoraws/", "getSoma");
private final static QName _GetMultiplica_QNAME = new QName("http://calculadoraws/", "getMultiplica");
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: WsCalcWebServiceCliente
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link GetMultiplica }
*
*/
public GetMultiplica createGetMultiplica() {
return new GetMultiplica();
}
/**
* Create an instance of {@link GetSoma }
*
*/
public GetSoma createGetSoma() {
return new GetSoma();
}
/**
* Create an instance of {@link GetDivide }
*
*/
public GetDivide createGetDivide() {
return new GetDivide();
}
/**
* Create an instance of {@link GetMultiplicaResponse }
*
*/
public GetMultiplicaResponse createGetMultiplicaResponse() {
return new GetMultiplicaResponse();
}
/**
* Create an instance of {@link GetDivideResponse }
*
*/
public GetDivideResponse createGetDivideResponse() {
return new GetDivideResponse();
}
/**
* Create an instance of {@link GetSomaResponse }
*
*/
public GetSomaResponse createGetSomaResponse() {
return new GetSomaResponse();
}
/**
* Create an instance of {@link GetSubtrairResponse }
*
*/
public GetSubtrairResponse createGetSubtrairResponse() {
return new GetSubtrairResponse();
}
/**
* Create an instance of {@link GetSubtrair }
*
*/
public GetSubtrair createGetSubtrair() {
return new GetSubtrair();
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link GetSubtrair }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://calculadoraws/", name = "getSubtrair")
public JAXBElement<GetSubtrair> createGetSubtrair(GetSubtrair value) {
return new JAXBElement<GetSubtrair>(_GetSubtrair_QNAME, GetSubtrair.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link GetMultiplicaResponse }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://calculadoraws/", name = "getMultiplicaResponse")
public JAXBElement<GetMultiplicaResponse> createGetMultiplicaResponse(GetMultiplicaResponse value) {
return new JAXBElement<GetMultiplicaResponse>(_GetMultiplicaResponse_QNAME, GetMultiplicaResponse.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link GetDivideResponse }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://calculadoraws/", name = "getDivideResponse")
public JAXBElement<GetDivideResponse> createGetDivideResponse(GetDivideResponse value) {
return new JAXBElement<GetDivideResponse>(_GetDivideResponse_QNAME, GetDivideResponse.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link GetSomaResponse }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://calculadoraws/", name = "getSomaResponse")
public JAXBElement<GetSomaResponse> createGetSomaResponse(GetSomaResponse value) {
return new JAXBElement<GetSomaResponse>(_GetSomaResponse_QNAME, GetSomaResponse.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link GetSubtrairResponse }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://calculadoraws/", name = "getSubtrairResponse")
public JAXBElement<GetSubtrairResponse> createGetSubtrairResponse(GetSubtrairResponse value) {
return new JAXBElement<GetSubtrairResponse>(_GetSubtrairResponse_QNAME, GetSubtrairResponse.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link GetDivide }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://calculadoraws/", name = "getDivide")
public JAXBElement<GetDivide> createGetDivide(GetDivide value) {
return new JAXBElement<GetDivide>(_GetDivide_QNAME, GetDivide.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link GetSoma }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://calculadoraws/", name = "getSoma")
public JAXBElement<GetSoma> createGetSoma(GetSoma value) {
return new JAXBElement<GetSoma>(_GetSoma_QNAME, GetSoma.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link GetMultiplica }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://calculadoraws/", name = "getMultiplica")
public JAXBElement<GetMultiplica> createGetMultiplica(GetMultiplica value) {
return new JAXBElement<GetMultiplica>(_GetMultiplica_QNAME, GetMultiplica.class, null, value);
}
}
|
UTF-8
|
Java
| 6,419 |
java
|
ObjectFactory.java
|
Java
|
[] | null |
[] |
package WsCalcWebServiceCliente;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the WsCalcWebServiceCliente package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {
private final static QName _GetSubtrair_QNAME = new QName("http://calculadoraws/", "getSubtrair");
private final static QName _GetMultiplicaResponse_QNAME = new QName("http://calculadoraws/", "getMultiplicaResponse");
private final static QName _GetDivideResponse_QNAME = new QName("http://calculadoraws/", "getDivideResponse");
private final static QName _GetSomaResponse_QNAME = new QName("http://calculadoraws/", "getSomaResponse");
private final static QName _GetSubtrairResponse_QNAME = new QName("http://calculadoraws/", "getSubtrairResponse");
private final static QName _GetDivide_QNAME = new QName("http://calculadoraws/", "getDivide");
private final static QName _GetSoma_QNAME = new QName("http://calculadoraws/", "getSoma");
private final static QName _GetMultiplica_QNAME = new QName("http://calculadoraws/", "getMultiplica");
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: WsCalcWebServiceCliente
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link GetMultiplica }
*
*/
public GetMultiplica createGetMultiplica() {
return new GetMultiplica();
}
/**
* Create an instance of {@link GetSoma }
*
*/
public GetSoma createGetSoma() {
return new GetSoma();
}
/**
* Create an instance of {@link GetDivide }
*
*/
public GetDivide createGetDivide() {
return new GetDivide();
}
/**
* Create an instance of {@link GetMultiplicaResponse }
*
*/
public GetMultiplicaResponse createGetMultiplicaResponse() {
return new GetMultiplicaResponse();
}
/**
* Create an instance of {@link GetDivideResponse }
*
*/
public GetDivideResponse createGetDivideResponse() {
return new GetDivideResponse();
}
/**
* Create an instance of {@link GetSomaResponse }
*
*/
public GetSomaResponse createGetSomaResponse() {
return new GetSomaResponse();
}
/**
* Create an instance of {@link GetSubtrairResponse }
*
*/
public GetSubtrairResponse createGetSubtrairResponse() {
return new GetSubtrairResponse();
}
/**
* Create an instance of {@link GetSubtrair }
*
*/
public GetSubtrair createGetSubtrair() {
return new GetSubtrair();
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link GetSubtrair }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://calculadoraws/", name = "getSubtrair")
public JAXBElement<GetSubtrair> createGetSubtrair(GetSubtrair value) {
return new JAXBElement<GetSubtrair>(_GetSubtrair_QNAME, GetSubtrair.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link GetMultiplicaResponse }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://calculadoraws/", name = "getMultiplicaResponse")
public JAXBElement<GetMultiplicaResponse> createGetMultiplicaResponse(GetMultiplicaResponse value) {
return new JAXBElement<GetMultiplicaResponse>(_GetMultiplicaResponse_QNAME, GetMultiplicaResponse.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link GetDivideResponse }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://calculadoraws/", name = "getDivideResponse")
public JAXBElement<GetDivideResponse> createGetDivideResponse(GetDivideResponse value) {
return new JAXBElement<GetDivideResponse>(_GetDivideResponse_QNAME, GetDivideResponse.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link GetSomaResponse }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://calculadoraws/", name = "getSomaResponse")
public JAXBElement<GetSomaResponse> createGetSomaResponse(GetSomaResponse value) {
return new JAXBElement<GetSomaResponse>(_GetSomaResponse_QNAME, GetSomaResponse.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link GetSubtrairResponse }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://calculadoraws/", name = "getSubtrairResponse")
public JAXBElement<GetSubtrairResponse> createGetSubtrairResponse(GetSubtrairResponse value) {
return new JAXBElement<GetSubtrairResponse>(_GetSubtrairResponse_QNAME, GetSubtrairResponse.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link GetDivide }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://calculadoraws/", name = "getDivide")
public JAXBElement<GetDivide> createGetDivide(GetDivide value) {
return new JAXBElement<GetDivide>(_GetDivide_QNAME, GetDivide.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link GetSoma }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://calculadoraws/", name = "getSoma")
public JAXBElement<GetSoma> createGetSoma(GetSoma value) {
return new JAXBElement<GetSoma>(_GetSoma_QNAME, GetSoma.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link GetMultiplica }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://calculadoraws/", name = "getMultiplica")
public JAXBElement<GetMultiplica> createGetMultiplica(GetMultiplica value) {
return new JAXBElement<GetMultiplica>(_GetMultiplica_QNAME, GetMultiplica.class, null, value);
}
}
| 6,419 | 0.677364 | 0.677364 | 178 | 35.056179 | 37.634361 | 137 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.393258 | false | false |
12
|
607abe11b5a07683d65931876135721f4c163281
| 33,389,075,817,212 |
ef0e1362b85daa34db64cdf2e65222cbf32a66b0
|
/app/src/main/java/com/example/triviaapp/Controller/Question3.java
|
0ead315619b0fffa5034a768a2ea17947d8acb54
|
[] |
no_license
|
Jinshadnu/TriviaApp
|
https://github.com/Jinshadnu/TriviaApp
|
c461ef90fb24bb67d5477aa87ddfab8bde892c0d
|
90ef50b81a861ad64fe4eac6edf0b72c11df1ecf
|
refs/heads/master
| 2021-01-15T02:28:47.150000 | 2020-02-24T21:33:24 | 2020-02-24T21:33:24 | 242,848,297 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.triviaapp.Controller;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.RadioButton;
import android.widget.Toast;
import com.example.triviaapp.R;
public class Question3 extends AppCompatActivity {
public Button button_finish;
public CheckBox checkBox_option1,checkBox_option2,checkBox_option3,checkBox_option4;
String option1,option2,option3,option4;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_question3);
checkBox_option1=(CheckBox) findViewById(R.id.option1);
checkBox_option2=(CheckBox) findViewById(R.id.option2);
checkBox_option3=(CheckBox) findViewById(R.id.option3);
checkBox_option4=(CheckBox) findViewById(R.id.option4);
Bundle bundle=getIntent().getExtras();
final String user_name=bundle.getString("name");
final String answer=bundle.getString("answer1");
button_finish=(Button)findViewById(R.id.button_next);
button_finish.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
StringBuilder result=new StringBuilder();
if(checkBox_option1.isChecked()){
result.append("White,");
}
if(checkBox_option2.isChecked()){
result.append("Yellow,");
}
if(checkBox_option3.isChecked()){
result.append("Orange,");
}
if(checkBox_option4.isChecked()){
result.append("Green");
}
Intent intent=new Intent(Question3.this,Summary.class);
intent.putExtra("name",user_name);
intent.putExtra("answer",answer);
intent.putExtra("color",result.toString());
startActivity(intent);
}
});
}
}
|
UTF-8
|
Java
| 2,190 |
java
|
Question3.java
|
Java
|
[] | null |
[] |
package com.example.triviaapp.Controller;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.RadioButton;
import android.widget.Toast;
import com.example.triviaapp.R;
public class Question3 extends AppCompatActivity {
public Button button_finish;
public CheckBox checkBox_option1,checkBox_option2,checkBox_option3,checkBox_option4;
String option1,option2,option3,option4;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_question3);
checkBox_option1=(CheckBox) findViewById(R.id.option1);
checkBox_option2=(CheckBox) findViewById(R.id.option2);
checkBox_option3=(CheckBox) findViewById(R.id.option3);
checkBox_option4=(CheckBox) findViewById(R.id.option4);
Bundle bundle=getIntent().getExtras();
final String user_name=bundle.getString("name");
final String answer=bundle.getString("answer1");
button_finish=(Button)findViewById(R.id.button_next);
button_finish.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
StringBuilder result=new StringBuilder();
if(checkBox_option1.isChecked()){
result.append("White,");
}
if(checkBox_option2.isChecked()){
result.append("Yellow,");
}
if(checkBox_option3.isChecked()){
result.append("Orange,");
}
if(checkBox_option4.isChecked()){
result.append("Green");
}
Intent intent=new Intent(Question3.this,Summary.class);
intent.putExtra("name",user_name);
intent.putExtra("answer",answer);
intent.putExtra("color",result.toString());
startActivity(intent);
}
});
}
}
| 2,190 | 0.630594 | 0.619635 | 57 | 37.421051 | 21.050438 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.842105 | false | false |
12
|
bc30af3834f52bb847d40133c83d97776571efeb
| 11,862,699,708,263 |
6917e1164f9f2da9a22973b2a6487c09bee6e88c
|
/src/main/java/be/vb/storingenmelder/domain/City.java
|
ee66c9073f2497533aeecfd94694bce348ed6851
|
[] |
no_license
|
vincentB23/ov-storingenmelder
|
https://github.com/vincentB23/ov-storingenmelder
|
7b1c4e4b5c5f2b0dbd53d01404be3e376f3f71a5
|
5b3144370d333251b13c25b0a0692d42b53edcfd
|
refs/heads/master
| 2022-04-07T20:37:58.382000 | 2020-03-13T20:31:31 | 2020-03-13T20:31:31 | 245,028,307 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package be.vb.storingenmelder.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import lombok.Data;
import javax.persistence.*;
@Data
@Entity
public class City {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "CityId")
private Long id;
@Column(name = "CityNumber")
private int number;
@Column(name = "CityName")
private String name;
@ManyToOne(fetch = FetchType.EAGER, optional = false)
@JoinColumn(name = "ProvinceId", nullable = false)
private Province province;
public City() {
}
public City(int number, String name, Province province) {
this.number = number;
this.name = name;
this.province = province;
}
public Province getProvince() {
return province;
}
}
|
UTF-8
|
Java
| 920 |
java
|
City.java
|
Java
|
[] | null |
[] |
package be.vb.storingenmelder.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import lombok.Data;
import javax.persistence.*;
@Data
@Entity
public class City {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "CityId")
private Long id;
@Column(name = "CityNumber")
private int number;
@Column(name = "CityName")
private String name;
@ManyToOne(fetch = FetchType.EAGER, optional = false)
@JoinColumn(name = "ProvinceId", nullable = false)
private Province province;
public City() {
}
public City(int number, String name, Province province) {
this.number = number;
this.name = name;
this.province = province;
}
public Province getProvince() {
return province;
}
}
| 920 | 0.688043 | 0.688043 | 37 | 23.864864 | 19.47023 | 61 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.486486 | false | false |
12
|
bb06c49a6acbf0238f0fae11760f70654fc12fe7
| 5,119,601,057,978 |
b61ba3bc6e27a70379ae5261a4af1e7d58cb3cb7
|
/Ejercicios de Porti/src/Bucles Ampliación/Ejercicio17.java
|
7e2ebc59ef072df78dfddda11c32433f4761262f
|
[] |
no_license
|
PortiDGZ/Programacion
|
https://github.com/PortiDGZ/Programacion
|
f31bbe08b45bbf7f60b2642ec425cc4ac8f17192
|
5f7d17f0127509246c6a6ad90b19683a40d546c2
|
refs/heads/master
| 2020-12-08T20:16:46.226000 | 2020-10-04T16:51:51 | 2020-10-04T16:51:51 | 233,083,052 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package Ejercicio5;
import java.util.Scanner;
public class Ejercicio17 {
public static void main(String[] args) {
int N = 0;
int i;
char resp;
int cont = 0;
int suma = 0;
Scanner entrada = new Scanner(System.in);
do {
System.out.print("Introduce un número: ");
N = entrada.nextInt();
if(N >=0) {
for(i=1; i<=N; i++) {
cont = (i*3) + cont;
}
}
System.out.println("La suma es: " + cont);
System.out.print("¿Quiere ejecutar el programa de nuevo? (S/N): ");
resp = entrada.next().toUpperCase().charAt(0);
if(resp == 'S') {
cont = 0;
}
}while(resp == 'S');
}
}
|
ISO-8859-1
|
Java
| 699 |
java
|
Ejercicio17.java
|
Java
|
[] | null |
[] |
package Ejercicio5;
import java.util.Scanner;
public class Ejercicio17 {
public static void main(String[] args) {
int N = 0;
int i;
char resp;
int cont = 0;
int suma = 0;
Scanner entrada = new Scanner(System.in);
do {
System.out.print("Introduce un número: ");
N = entrada.nextInt();
if(N >=0) {
for(i=1; i<=N; i++) {
cont = (i*3) + cont;
}
}
System.out.println("La suma es: " + cont);
System.out.print("¿Quiere ejecutar el programa de nuevo? (S/N): ");
resp = entrada.next().toUpperCase().charAt(0);
if(resp == 'S') {
cont = 0;
}
}while(resp == 'S');
}
}
| 699 | 0.509326 | 0.493544 | 53 | 12.150944 | 15.589542 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.509434 | false | false |
12
|
a7894a8623c0a3fc77395fd367030e4f6e7067e1
| 33,139,967,687,296 |
ef13c8832e179d78922c989024cb1b465dc6b6c0
|
/marylove/src/marylove/vista/FormaAgregarAgresores.java
|
ec7c544f9c1de6e363be7c2f7253e877ceef5281
|
[] |
no_license
|
desarrollotds/marylove
|
https://github.com/desarrollotds/marylove
|
16c67f9d624a80e983b7aeaf4a7b7f6debe20d7b
|
5b7ee301e98a725c18d5cbba6a6ab92f6e274791
|
refs/heads/master
| 2021-07-11T08:50:04.817000 | 2020-09-28T22:59:46 | 2020-09-28T22:59:46 | 218,843,116 | 6 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package marylove.vista;
import com.toedter.calendar.JDateChooser;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTextField;
/**
*
* @author usuario
*/
public class FormaAgregarAgresores extends javax.swing.JFrame {
/**
* Creates new form FormaAgregarAgresores
*/
public FormaAgregarAgresores() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
btnGuardar = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
btnCancelar = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
txtNombre = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
txtDireccionTrabajo = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
dcFechanacimiento = new com.toedter.calendar.JDateChooser();
jLabel12 = new javax.swing.JLabel();
cbxNacionalidad = new javax.swing.JComboBox<>();
cbxParentesco = new javax.swing.JComboBox<>();
cbxEstadomigra = new javax.swing.JComboBox<>();
cbxNivelacad = new javax.swing.JComboBox<>();
jLabel13 = new javax.swing.JLabel();
txtCalle = new javax.swing.JTextField();
jLabel14 = new javax.swing.JLabel();
lavel = new javax.swing.JLabel();
txtNCasa = new javax.swing.JTextField();
jLabel15 = new javax.swing.JLabel();
txtBarrio = new javax.swing.JTextField();
lavel2 = new javax.swing.JLabel();
txtParroquia = new javax.swing.JTextField();
jLabel16 = new javax.swing.JLabel();
txtCiudad = new javax.swing.JTextField();
jLabel17 = new javax.swing.JLabel();
txtReferencia = new javax.swing.JTextField();
jLabel18 = new javax.swing.JLabel();
txtProvincia = new javax.swing.JTextField();
jLabel19 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
txtTelefono = new javax.swing.JTextField();
txtInterseccion = new javax.swing.JTextField();
txtCelular = new javax.swing.JTextField();
jSeparator1 = new javax.swing.JSeparator();
jSeparator2 = new javax.swing.JSeparator();
jSeparator3 = new javax.swing.JSeparator();
txtCedula = new javax.swing.JTextField();
lac = new javax.swing.JLabel();
cbxOcupacion = new javax.swing.JComboBox<>();
jLabel20 = new javax.swing.JLabel();
TxtinstruccionOtros = new javax.swing.JTextField();
cbxPais = new javax.swing.JComboBox<>();
txtApellido = new javax.swing.JTextField();
jLabel21 = new javax.swing.JLabel();
cbxSexo = new javax.swing.JComboBox<>();
btnBuscar = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setUndecorated(true);
jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
btnGuardar.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
btnGuardar.setText("Guardar");
jLabel1.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("AGREGAR AGRESORES");
btnCancelar.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
btnCancelar.setText("Cancelar");
jLabel2.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel2.setText("Nombres:");
txtNombre.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel4.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel4.setText("<html>Parentesco/ relación<br>con la víctima:");
jLabel5.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel5.setText("Nacionalidad:");
jLabel6.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel6.setText("Estado Migratorio:");
jLabel7.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel7.setText("Nivel de Educación: ");
jLabel8.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel8.setText("DIRECCION");
jLabel9.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel9.setText("<html>Dirección del lugar<br>de trabajo:");
txtDireccionTrabajo.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel10.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel10.setText("Teléfono: ");
jLabel11.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel11.setText("Apellidos:");
jLabel12.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel12.setText("Fecha Nacimiento:");
cbxNacionalidad.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
cbxParentesco.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
cbxEstadomigra.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
cbxNivelacad.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel13.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel13.setText("Calle:");
txtCalle.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel14.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel14.setText("Intersección:");
lavel.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
lavel.setText("N. Casa:");
txtNCasa.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel15.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel15.setText("Barrio:");
txtBarrio.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
lavel2.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
lavel2.setText("Parroquia:");
txtParroquia.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel16.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel16.setText("Ciudad:");
txtCiudad.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel17.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel17.setText("Referencia:");
txtReferencia.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel18.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel18.setText("Provincia:");
txtProvincia.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel19.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel19.setText("País:");
jLabel3.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel3.setText("Celular:");
txtTelefono.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 16)); // NOI18N
txtInterseccion.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
txtCelular.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 16)); // NOI18N
txtCedula.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
lac.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
lac.setText("Cédula:");
cbxOcupacion.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel20.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel20.setText("Ocupacion:");
TxtinstruccionOtros.setEditable(false);
TxtinstruccionOtros.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 16)); // NOI18N
cbxPais.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
txtApellido.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel21.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel21.setText("Sexo:");
cbxSexo.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
cbxSexo.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "F", "M", "?" }));
btnBuscar.setText("Buscar");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 843, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(28, 28, 28)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 809, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(38, 38, 38)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lac)
.addComponent(jLabel2)
.addComponent(jLabel11)
.addComponent(jLabel12))
.addGap(37, 37, 37)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(txtCedula, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(10, 10, 10)
.addComponent(btnBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtApellido, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(dcFechanacimiento, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(40, 40, 40)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10)
.addComponent(jLabel3))
.addGap(51, 51, 51)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(1, 1, 1)
.addComponent(txtDireccionTrabajo, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtCelular, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(38, 38, 38)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(27, 27, 27)
.addComponent(cbxParentesco, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(83, 83, 83)
.addComponent(jLabel7)
.addGap(42, 42, 42)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cbxNivelacad, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(TxtinstruccionOtros, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(38, 38, 38)
.addComponent(jLabel5)
.addGap(65, 65, 65)
.addComponent(cbxNacionalidad, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(83, 83, 83)
.addComponent(jLabel6)
.addGap(55, 55, 55)
.addComponent(cbxEstadomigra, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(38, 38, 38)
.addComponent(jLabel20)
.addGap(78, 78, 78)
.addComponent(cbxOcupacion, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(83, 83, 83)
.addComponent(jLabel21)
.addGap(126, 126, 126)
.addComponent(cbxSexo, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 843, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(79, 79, 79)
.addComponent(jLabel8))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(79, 79, 79)
.addComponent(jLabel13)
.addGap(58, 58, 58)
.addComponent(txtCalle, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(66, 66, 66)
.addComponent(jLabel14)
.addGap(54, 54, 54)
.addComponent(txtInterseccion, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(79, 79, 79)
.addComponent(lavel)
.addGap(43, 43, 43)
.addComponent(txtNCasa, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(66, 66, 66)
.addComponent(jLabel15)
.addGap(88, 88, 88)
.addComponent(txtBarrio, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(79, 79, 79)
.addComponent(lavel2)
.addGap(33, 33, 33)
.addComponent(txtParroquia, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(66, 66, 66)
.addComponent(jLabel16)
.addGap(81, 81, 81)
.addComponent(txtCiudad, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(79, 79, 79)
.addComponent(jLabel17)
.addGap(26, 26, 26)
.addComponent(txtReferencia, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(64, 64, 64)
.addComponent(jLabel18)
.addGap(70, 70, 70)
.addComponent(txtProvincia, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(79, 79, 79)
.addComponent(jLabel19)
.addGap(64, 64, 64)
.addComponent(cbxPais, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 843, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(31, 31, 31)
.addComponent(btnCancelar)
.addGap(18, 18, 18)
.addComponent(btnGuardar))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(14, 14, 14)
.addComponent(jLabel1)
.addGap(13, 13, 13)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(4, 4, 4)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(lac)
.addGap(24, 24, 24)
.addComponent(jLabel2)
.addGap(24, 24, 24)
.addComponent(jLabel11)
.addGap(14, 14, 14)
.addComponent(jLabel12))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtCedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnBuscar))
.addGap(15, 15, 15)
.addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(16, 16, 16)
.addComponent(txtApellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(16, 16, 16)
.addComponent(dcFechanacimiento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(20, 20, 20)
.addComponent(jLabel10)
.addGap(26, 26, 26)
.addComponent(jLabel3))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(7, 7, 7)
.addComponent(txtDireccionTrabajo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(28, 28, 28)
.addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(16, 16, 16)
.addComponent(txtCelular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(9, 9, 9)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(cbxParentesco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(3, 3, 3)
.addComponent(jLabel7))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(cbxNivelacad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(7, 7, 7)
.addComponent(TxtinstruccionOtros, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(10, 10, 10)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(jLabel5))
.addComponent(cbxNacionalidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(2, 2, 2)
.addComponent(jLabel6))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(3, 3, 3)
.addComponent(cbxEstadomigra, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(jLabel20))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(5, 5, 5)
.addComponent(cbxOcupacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(2, 2, 2)
.addComponent(jLabel21))
.addComponent(cbxSexo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(11, 11, 11)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel8)
.addGap(24, 24, 24)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(11, 11, 11)
.addComponent(jLabel13))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(8, 8, 8)
.addComponent(txtCalle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(11, 11, 11)
.addComponent(jLabel14))
.addComponent(txtInterseccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(20, 20, 20)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(lavel))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(3, 3, 3)
.addComponent(txtNCasa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(jLabel15))
.addComponent(txtBarrio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(15, 15, 15)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(11, 11, 11)
.addComponent(lavel2))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(8, 8, 8)
.addComponent(txtParroquia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(11, 11, 11)
.addComponent(jLabel16))
.addComponent(txtCiudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(23, 23, 23)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtReferencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtProvincia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(3, 3, 3)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel17)
.addComponent(jLabel18))))
.addGap(29, 29, 29)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(3, 3, 3)
.addComponent(jLabel19))
.addComponent(cbxPais, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(31, 31, 31)
.addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(7, 7, 7)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnCancelar)
.addComponent(btnGuardar)))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
public JButton getBtnBuscar() {
return btnBuscar;
}
public void setBtnBuscar(JButton btnBuscar) {
this.btnBuscar = btnBuscar;
}
public JComboBox<String> getCbxSexo() {
return cbxSexo;
}
public void setCbxSexo(JComboBox<String> cbxSexo) {
this.cbxSexo = cbxSexo;
}
public JButton getBtnCancelar() {
return btnCancelar;
}
public void setBtnCancelar(JButton btnCancelar) {
this.btnCancelar = btnCancelar;
}
public JButton getBtnGuardar() {
return btnGuardar;
}
public void setBtnGuardar(JButton btnGuardar) {
this.btnGuardar = btnGuardar;
}
public JTextField getTxtCedula() {
return txtCedula;
}
public void setTxtCedula(JTextField txtCedula) {
this.txtCedula = txtCedula;
}
public JComboBox<String> getCbxOcupacion() {
return cbxOcupacion;
}
public void setCbxOcupacion(JComboBox<String> cbxOcupacion) {
this.cbxOcupacion = cbxOcupacion;
}
public JTextField getTxtinstruccionOtros() {
return TxtinstruccionOtros;
}
public void setTxtinstruccionOtros(JTextField TxtinstruccionOtros) {
this.TxtinstruccionOtros = TxtinstruccionOtros;
}
public JTextField getTxtDireccionTrabajo() {
return txtDireccionTrabajo;
}
public void setTxtDireccionTrabajo(JTextField txtDireccionTrabajo) {
this.txtDireccionTrabajo = txtDireccionTrabajo;
}
public JComboBox<String> getCbxEstadomigra() {
return cbxEstadomigra;
}
public void setCbxEstadomigra(JComboBox<String> cbxEstadomigra) {
this.cbxEstadomigra = cbxEstadomigra;
}
public JComboBox<String> getCbxNacionalidad() {
return cbxNacionalidad;
}
public void setCbxNacionalidad(JComboBox<String> cbxNacionalidad) {
this.cbxNacionalidad = cbxNacionalidad;
}
public JComboBox<String> getCbxNivelacad() {
return cbxNivelacad;
}
public void setCbxNivelacad(JComboBox<String> cbxNivelacad) {
this.cbxNivelacad = cbxNivelacad;
}
public JComboBox<String> getCbxParentesco() {
return cbxParentesco;
}
public void setCbxParentesco(JComboBox<String> cbxParentesco) {
this.cbxParentesco = cbxParentesco;
}
public JDateChooser getDcFechanacimiento() {
return dcFechanacimiento;
}
public void setDcFechanacimiento(JDateChooser dcFechanacimiento) {
this.dcFechanacimiento = dcFechanacimiento;
}
public JTextField getTxtApellido() {
return txtApellido;
}
public void setTxtApellido(JTextField txtApellido) {
this.txtApellido = txtApellido;
}
public JTextField getTxtBarrio() {
return txtBarrio;
}
public void setTxtBarrio(JTextField txtBarrio) {
this.txtBarrio = txtBarrio;
}
public JTextField getTxtCalle() {
return txtCalle;
}
public void setTxtCalle(JTextField txtCalle) {
this.txtCalle = txtCalle;
}
public JTextField getTxtCelular() {
return txtCelular;
}
public void setTxtCelular(JTextField txtCelular) {
this.txtCelular = txtCelular;
}
public JTextField getTxtCiudad() {
return txtCiudad;
}
public void setTxtCiudad(JTextField txtCiudad) {
this.txtCiudad = txtCiudad;
}
public JTextField getTxtInterseccion() {
return txtInterseccion;
}
public void setTxtInterseccion(JTextField txtInterseccion) {
this.txtInterseccion = txtInterseccion;
}
public JTextField getTxtNCasa() {
return txtNCasa;
}
public void setTxtNCasa(JTextField txtNCasa) {
this.txtNCasa = txtNCasa;
}
public JComboBox<String> getCbxPais() {
return cbxPais;
}
public void setCbxPais(JComboBox<String> cbxPais) {
this.cbxPais = cbxPais;
}
public JTextField getTxtParroquia() {
return txtParroquia;
}
public void setTxtParroquia(JTextField txtParroquia) {
this.txtParroquia = txtParroquia;
}
public JTextField getTxtProvincia() {
return txtProvincia;
}
public void setTxtProvincia(JTextField txtProvincia) {
this.txtProvincia = txtProvincia;
}
public JTextField getTxtReferencia() {
return txtReferencia;
}
public void setTxtReferencia(JTextField txtReferencia) {
this.txtReferencia = txtReferencia;
}
public JTextField getTxtNombre() {
return txtNombre;
}
public void setTxtNombre(JTextField txtNombre) {
this.txtNombre = txtNombre;
}
public JTextField getTxtTelefono() {
return txtTelefono;
}
public void setTxtTelefono(JTextField txtTelefono) {
this.txtTelefono = txtTelefono;
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(FormaAgregarAgresores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(FormaAgregarAgresores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(FormaAgregarAgresores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(FormaAgregarAgresores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new FormaAgregarAgresores().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField TxtinstruccionOtros;
private javax.swing.JButton btnBuscar;
private javax.swing.JButton btnCancelar;
private javax.swing.JButton btnGuardar;
private javax.swing.JComboBox<String> cbxEstadomigra;
private javax.swing.JComboBox<String> cbxNacionalidad;
private javax.swing.JComboBox<String> cbxNivelacad;
private javax.swing.JComboBox<String> cbxOcupacion;
private javax.swing.JComboBox<String> cbxPais;
private javax.swing.JComboBox<String> cbxParentesco;
private javax.swing.JComboBox<String> cbxSexo;
private com.toedter.calendar.JDateChooser dcFechanacimiento;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel21;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JSeparator jSeparator3;
private javax.swing.JLabel lac;
private javax.swing.JLabel lavel;
private javax.swing.JLabel lavel2;
private javax.swing.JTextField txtApellido;
private javax.swing.JTextField txtBarrio;
private javax.swing.JTextField txtCalle;
private javax.swing.JTextField txtCedula;
private javax.swing.JTextField txtCelular;
private javax.swing.JTextField txtCiudad;
private javax.swing.JTextField txtDireccionTrabajo;
private javax.swing.JTextField txtInterseccion;
private javax.swing.JTextField txtNCasa;
private javax.swing.JTextField txtNombre;
private javax.swing.JTextField txtParroquia;
private javax.swing.JTextField txtProvincia;
private javax.swing.JTextField txtReferencia;
private javax.swing.JTextField txtTelefono;
// End of variables declaration//GEN-END:variables
}
|
UTF-8
|
Java
| 38,610 |
java
|
FormaAgregarAgresores.java
|
Java
|
[
{
"context": "\nimport javax.swing.JTextField;\n\n/**\n *\n * @author usuario\n */\npublic class FormaAgregarAgresores extends jav",
"end": 394,
"score": 0.9387600421905518,
"start": 387,
"tag": "USERNAME",
"value": "usuario"
},
{
"context": ".SwingConstants.CENTER);\n jLabel1.setText(\"AGREGAR AGRESORES\");\n\n btnCancelar.setFont(ne",
"end": 4141,
"score": 0.8119779229164124,
"start": 4139,
"tag": "NAME",
"value": "AG"
},
{
"context": "onstants.CENTER);\n jLabel1.setText(\"AGREGAR AGRESORES\");\n\n btnCancelar.setFont(new java.",
"end": 4148,
"score": 0.5159337520599365,
"start": 4147,
"tag": "NAME",
"value": "A"
},
{
"context": "nts.CENTER);\n jLabel1.setText(\"AGREGAR AGRESORES\");\n\n btnCancelar.setFont(new java.awt.F",
"end": 4153,
"score": 0.5309812426567078,
"start": 4151,
"tag": "NAME",
"value": "SO"
}
] | null |
[] |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package marylove.vista;
import com.toedter.calendar.JDateChooser;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTextField;
/**
*
* @author usuario
*/
public class FormaAgregarAgresores extends javax.swing.JFrame {
/**
* Creates new form FormaAgregarAgresores
*/
public FormaAgregarAgresores() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
btnGuardar = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
btnCancelar = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
txtNombre = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
txtDireccionTrabajo = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
dcFechanacimiento = new com.toedter.calendar.JDateChooser();
jLabel12 = new javax.swing.JLabel();
cbxNacionalidad = new javax.swing.JComboBox<>();
cbxParentesco = new javax.swing.JComboBox<>();
cbxEstadomigra = new javax.swing.JComboBox<>();
cbxNivelacad = new javax.swing.JComboBox<>();
jLabel13 = new javax.swing.JLabel();
txtCalle = new javax.swing.JTextField();
jLabel14 = new javax.swing.JLabel();
lavel = new javax.swing.JLabel();
txtNCasa = new javax.swing.JTextField();
jLabel15 = new javax.swing.JLabel();
txtBarrio = new javax.swing.JTextField();
lavel2 = new javax.swing.JLabel();
txtParroquia = new javax.swing.JTextField();
jLabel16 = new javax.swing.JLabel();
txtCiudad = new javax.swing.JTextField();
jLabel17 = new javax.swing.JLabel();
txtReferencia = new javax.swing.JTextField();
jLabel18 = new javax.swing.JLabel();
txtProvincia = new javax.swing.JTextField();
jLabel19 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
txtTelefono = new javax.swing.JTextField();
txtInterseccion = new javax.swing.JTextField();
txtCelular = new javax.swing.JTextField();
jSeparator1 = new javax.swing.JSeparator();
jSeparator2 = new javax.swing.JSeparator();
jSeparator3 = new javax.swing.JSeparator();
txtCedula = new javax.swing.JTextField();
lac = new javax.swing.JLabel();
cbxOcupacion = new javax.swing.JComboBox<>();
jLabel20 = new javax.swing.JLabel();
TxtinstruccionOtros = new javax.swing.JTextField();
cbxPais = new javax.swing.JComboBox<>();
txtApellido = new javax.swing.JTextField();
jLabel21 = new javax.swing.JLabel();
cbxSexo = new javax.swing.JComboBox<>();
btnBuscar = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setUndecorated(true);
jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
btnGuardar.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
btnGuardar.setText("Guardar");
jLabel1.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("AGREGAR AGRESORES");
btnCancelar.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
btnCancelar.setText("Cancelar");
jLabel2.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel2.setText("Nombres:");
txtNombre.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel4.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel4.setText("<html>Parentesco/ relación<br>con la víctima:");
jLabel5.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel5.setText("Nacionalidad:");
jLabel6.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel6.setText("Estado Migratorio:");
jLabel7.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel7.setText("Nivel de Educación: ");
jLabel8.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel8.setText("DIRECCION");
jLabel9.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel9.setText("<html>Dirección del lugar<br>de trabajo:");
txtDireccionTrabajo.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel10.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel10.setText("Teléfono: ");
jLabel11.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel11.setText("Apellidos:");
jLabel12.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel12.setText("Fecha Nacimiento:");
cbxNacionalidad.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
cbxParentesco.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
cbxEstadomigra.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
cbxNivelacad.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel13.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel13.setText("Calle:");
txtCalle.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel14.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel14.setText("Intersección:");
lavel.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
lavel.setText("N. Casa:");
txtNCasa.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel15.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel15.setText("Barrio:");
txtBarrio.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
lavel2.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
lavel2.setText("Parroquia:");
txtParroquia.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel16.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel16.setText("Ciudad:");
txtCiudad.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel17.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel17.setText("Referencia:");
txtReferencia.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel18.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel18.setText("Provincia:");
txtProvincia.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel19.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel19.setText("País:");
jLabel3.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel3.setText("Celular:");
txtTelefono.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 16)); // NOI18N
txtInterseccion.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
txtCelular.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 16)); // NOI18N
txtCedula.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
lac.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
lac.setText("Cédula:");
cbxOcupacion.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel20.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel20.setText("Ocupacion:");
TxtinstruccionOtros.setEditable(false);
TxtinstruccionOtros.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 16)); // NOI18N
cbxPais.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
txtApellido.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel21.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
jLabel21.setText("Sexo:");
cbxSexo.setFont(new java.awt.Font("Nirmala UI Semilight", 0, 13)); // NOI18N
cbxSexo.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "F", "M", "?" }));
btnBuscar.setText("Buscar");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 843, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(28, 28, 28)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 809, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(38, 38, 38)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lac)
.addComponent(jLabel2)
.addComponent(jLabel11)
.addComponent(jLabel12))
.addGap(37, 37, 37)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(txtCedula, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(10, 10, 10)
.addComponent(btnBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtApellido, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(dcFechanacimiento, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(40, 40, 40)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10)
.addComponent(jLabel3))
.addGap(51, 51, 51)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(1, 1, 1)
.addComponent(txtDireccionTrabajo, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtCelular, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(38, 38, 38)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(27, 27, 27)
.addComponent(cbxParentesco, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(83, 83, 83)
.addComponent(jLabel7)
.addGap(42, 42, 42)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cbxNivelacad, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(TxtinstruccionOtros, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(38, 38, 38)
.addComponent(jLabel5)
.addGap(65, 65, 65)
.addComponent(cbxNacionalidad, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(83, 83, 83)
.addComponent(jLabel6)
.addGap(55, 55, 55)
.addComponent(cbxEstadomigra, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(38, 38, 38)
.addComponent(jLabel20)
.addGap(78, 78, 78)
.addComponent(cbxOcupacion, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(83, 83, 83)
.addComponent(jLabel21)
.addGap(126, 126, 126)
.addComponent(cbxSexo, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 843, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(79, 79, 79)
.addComponent(jLabel8))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(79, 79, 79)
.addComponent(jLabel13)
.addGap(58, 58, 58)
.addComponent(txtCalle, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(66, 66, 66)
.addComponent(jLabel14)
.addGap(54, 54, 54)
.addComponent(txtInterseccion, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(79, 79, 79)
.addComponent(lavel)
.addGap(43, 43, 43)
.addComponent(txtNCasa, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(66, 66, 66)
.addComponent(jLabel15)
.addGap(88, 88, 88)
.addComponent(txtBarrio, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(79, 79, 79)
.addComponent(lavel2)
.addGap(33, 33, 33)
.addComponent(txtParroquia, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(66, 66, 66)
.addComponent(jLabel16)
.addGap(81, 81, 81)
.addComponent(txtCiudad, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(79, 79, 79)
.addComponent(jLabel17)
.addGap(26, 26, 26)
.addComponent(txtReferencia, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(64, 64, 64)
.addComponent(jLabel18)
.addGap(70, 70, 70)
.addComponent(txtProvincia, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(79, 79, 79)
.addComponent(jLabel19)
.addGap(64, 64, 64)
.addComponent(cbxPais, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 843, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(31, 31, 31)
.addComponent(btnCancelar)
.addGap(18, 18, 18)
.addComponent(btnGuardar))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(14, 14, 14)
.addComponent(jLabel1)
.addGap(13, 13, 13)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(4, 4, 4)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(lac)
.addGap(24, 24, 24)
.addComponent(jLabel2)
.addGap(24, 24, 24)
.addComponent(jLabel11)
.addGap(14, 14, 14)
.addComponent(jLabel12))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtCedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnBuscar))
.addGap(15, 15, 15)
.addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(16, 16, 16)
.addComponent(txtApellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(16, 16, 16)
.addComponent(dcFechanacimiento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(20, 20, 20)
.addComponent(jLabel10)
.addGap(26, 26, 26)
.addComponent(jLabel3))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(7, 7, 7)
.addComponent(txtDireccionTrabajo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(28, 28, 28)
.addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(16, 16, 16)
.addComponent(txtCelular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(9, 9, 9)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(cbxParentesco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(3, 3, 3)
.addComponent(jLabel7))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(cbxNivelacad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(7, 7, 7)
.addComponent(TxtinstruccionOtros, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(10, 10, 10)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(jLabel5))
.addComponent(cbxNacionalidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(2, 2, 2)
.addComponent(jLabel6))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(3, 3, 3)
.addComponent(cbxEstadomigra, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(jLabel20))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(5, 5, 5)
.addComponent(cbxOcupacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(2, 2, 2)
.addComponent(jLabel21))
.addComponent(cbxSexo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(11, 11, 11)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel8)
.addGap(24, 24, 24)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(11, 11, 11)
.addComponent(jLabel13))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(8, 8, 8)
.addComponent(txtCalle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(11, 11, 11)
.addComponent(jLabel14))
.addComponent(txtInterseccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(20, 20, 20)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(lavel))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(3, 3, 3)
.addComponent(txtNCasa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(jLabel15))
.addComponent(txtBarrio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(15, 15, 15)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(11, 11, 11)
.addComponent(lavel2))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(8, 8, 8)
.addComponent(txtParroquia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(11, 11, 11)
.addComponent(jLabel16))
.addComponent(txtCiudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(23, 23, 23)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtReferencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtProvincia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(3, 3, 3)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel17)
.addComponent(jLabel18))))
.addGap(29, 29, 29)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(3, 3, 3)
.addComponent(jLabel19))
.addComponent(cbxPais, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(31, 31, 31)
.addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(7, 7, 7)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnCancelar)
.addComponent(btnGuardar)))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
public JButton getBtnBuscar() {
return btnBuscar;
}
public void setBtnBuscar(JButton btnBuscar) {
this.btnBuscar = btnBuscar;
}
public JComboBox<String> getCbxSexo() {
return cbxSexo;
}
public void setCbxSexo(JComboBox<String> cbxSexo) {
this.cbxSexo = cbxSexo;
}
public JButton getBtnCancelar() {
return btnCancelar;
}
public void setBtnCancelar(JButton btnCancelar) {
this.btnCancelar = btnCancelar;
}
public JButton getBtnGuardar() {
return btnGuardar;
}
public void setBtnGuardar(JButton btnGuardar) {
this.btnGuardar = btnGuardar;
}
public JTextField getTxtCedula() {
return txtCedula;
}
public void setTxtCedula(JTextField txtCedula) {
this.txtCedula = txtCedula;
}
public JComboBox<String> getCbxOcupacion() {
return cbxOcupacion;
}
public void setCbxOcupacion(JComboBox<String> cbxOcupacion) {
this.cbxOcupacion = cbxOcupacion;
}
public JTextField getTxtinstruccionOtros() {
return TxtinstruccionOtros;
}
public void setTxtinstruccionOtros(JTextField TxtinstruccionOtros) {
this.TxtinstruccionOtros = TxtinstruccionOtros;
}
public JTextField getTxtDireccionTrabajo() {
return txtDireccionTrabajo;
}
public void setTxtDireccionTrabajo(JTextField txtDireccionTrabajo) {
this.txtDireccionTrabajo = txtDireccionTrabajo;
}
public JComboBox<String> getCbxEstadomigra() {
return cbxEstadomigra;
}
public void setCbxEstadomigra(JComboBox<String> cbxEstadomigra) {
this.cbxEstadomigra = cbxEstadomigra;
}
public JComboBox<String> getCbxNacionalidad() {
return cbxNacionalidad;
}
public void setCbxNacionalidad(JComboBox<String> cbxNacionalidad) {
this.cbxNacionalidad = cbxNacionalidad;
}
public JComboBox<String> getCbxNivelacad() {
return cbxNivelacad;
}
public void setCbxNivelacad(JComboBox<String> cbxNivelacad) {
this.cbxNivelacad = cbxNivelacad;
}
public JComboBox<String> getCbxParentesco() {
return cbxParentesco;
}
public void setCbxParentesco(JComboBox<String> cbxParentesco) {
this.cbxParentesco = cbxParentesco;
}
public JDateChooser getDcFechanacimiento() {
return dcFechanacimiento;
}
public void setDcFechanacimiento(JDateChooser dcFechanacimiento) {
this.dcFechanacimiento = dcFechanacimiento;
}
public JTextField getTxtApellido() {
return txtApellido;
}
public void setTxtApellido(JTextField txtApellido) {
this.txtApellido = txtApellido;
}
public JTextField getTxtBarrio() {
return txtBarrio;
}
public void setTxtBarrio(JTextField txtBarrio) {
this.txtBarrio = txtBarrio;
}
public JTextField getTxtCalle() {
return txtCalle;
}
public void setTxtCalle(JTextField txtCalle) {
this.txtCalle = txtCalle;
}
public JTextField getTxtCelular() {
return txtCelular;
}
public void setTxtCelular(JTextField txtCelular) {
this.txtCelular = txtCelular;
}
public JTextField getTxtCiudad() {
return txtCiudad;
}
public void setTxtCiudad(JTextField txtCiudad) {
this.txtCiudad = txtCiudad;
}
public JTextField getTxtInterseccion() {
return txtInterseccion;
}
public void setTxtInterseccion(JTextField txtInterseccion) {
this.txtInterseccion = txtInterseccion;
}
public JTextField getTxtNCasa() {
return txtNCasa;
}
public void setTxtNCasa(JTextField txtNCasa) {
this.txtNCasa = txtNCasa;
}
public JComboBox<String> getCbxPais() {
return cbxPais;
}
public void setCbxPais(JComboBox<String> cbxPais) {
this.cbxPais = cbxPais;
}
public JTextField getTxtParroquia() {
return txtParroquia;
}
public void setTxtParroquia(JTextField txtParroquia) {
this.txtParroquia = txtParroquia;
}
public JTextField getTxtProvincia() {
return txtProvincia;
}
public void setTxtProvincia(JTextField txtProvincia) {
this.txtProvincia = txtProvincia;
}
public JTextField getTxtReferencia() {
return txtReferencia;
}
public void setTxtReferencia(JTextField txtReferencia) {
this.txtReferencia = txtReferencia;
}
public JTextField getTxtNombre() {
return txtNombre;
}
public void setTxtNombre(JTextField txtNombre) {
this.txtNombre = txtNombre;
}
public JTextField getTxtTelefono() {
return txtTelefono;
}
public void setTxtTelefono(JTextField txtTelefono) {
this.txtTelefono = txtTelefono;
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(FormaAgregarAgresores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(FormaAgregarAgresores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(FormaAgregarAgresores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(FormaAgregarAgresores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new FormaAgregarAgresores().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField TxtinstruccionOtros;
private javax.swing.JButton btnBuscar;
private javax.swing.JButton btnCancelar;
private javax.swing.JButton btnGuardar;
private javax.swing.JComboBox<String> cbxEstadomigra;
private javax.swing.JComboBox<String> cbxNacionalidad;
private javax.swing.JComboBox<String> cbxNivelacad;
private javax.swing.JComboBox<String> cbxOcupacion;
private javax.swing.JComboBox<String> cbxPais;
private javax.swing.JComboBox<String> cbxParentesco;
private javax.swing.JComboBox<String> cbxSexo;
private com.toedter.calendar.JDateChooser dcFechanacimiento;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel21;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JSeparator jSeparator3;
private javax.swing.JLabel lac;
private javax.swing.JLabel lavel;
private javax.swing.JLabel lavel2;
private javax.swing.JTextField txtApellido;
private javax.swing.JTextField txtBarrio;
private javax.swing.JTextField txtCalle;
private javax.swing.JTextField txtCedula;
private javax.swing.JTextField txtCelular;
private javax.swing.JTextField txtCiudad;
private javax.swing.JTextField txtDireccionTrabajo;
private javax.swing.JTextField txtInterseccion;
private javax.swing.JTextField txtNCasa;
private javax.swing.JTextField txtNombre;
private javax.swing.JTextField txtParroquia;
private javax.swing.JTextField txtProvincia;
private javax.swing.JTextField txtReferencia;
private javax.swing.JTextField txtTelefono;
// End of variables declaration//GEN-END:variables
}
| 38,610 | 0.636599 | 0.608259 | 806 | 46.893299 | 39.636887 | 178 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.914392 | false | false |
12
|
7d5f5e32f2ba9ef092a2cd5db852677947de316e
| 13,623,636,302,817 |
52223c145801e1352a811f8053e2b747e9788aee
|
/src/main/java/School.java
|
8951ffe7d103240a1384a02fa237dee7d309bb33
|
[] |
no_license
|
JelenaDinere/mySchoolProject
|
https://github.com/JelenaDinere/mySchoolProject
|
d5c729a57dc872fc7ad9ef1efccbca175d755db8
|
69bea52b15100c06fb1b1de477d6c6af107f60d6
|
refs/heads/main
| 2023-08-04T09:25:10.031000 | 2021-09-23T08:55:29 | 2021-09-23T08:55:29 | 409,517,828 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.util.ArrayList;
public class School {
private ArrayList<Teacher>teachers;
private ArrayList<Student>students;
private static int totalMoneyEarned;
private static int totalMoneySpent;
private static int balance;
School(){
teachers = new ArrayList<>();
students = new ArrayList<>();
totalMoneySpent = 0;
totalMoneyEarned = 0;
balance = totalMoneyEarned-totalMoneySpent;
}
public ArrayList<Teacher> getTeachers() {
return teachers;
}
public ArrayList<Student> getStudents() {
return students;
}
public int getTotalMoneyEarned() {
School.updateTotalMoneyEarned(totalMoneyEarned);
return totalMoneyEarned;
}
public int getTotalMoneySpent() {
return totalMoneySpent;
}
public static int getBalance() {
return balance;
}
public void addTeacher(Teacher teacher){
this.teachers.add(teacher);
}
public void addStudent(Student student){
this.students.add(student);
}
public static void updateTotalMoneyEarned(int moneyEarned){
totalMoneyEarned += moneyEarned;
}
public static void updateTotalMoneySpent(int moneySpent){
totalMoneySpent +=moneySpent;
}
}
|
UTF-8
|
Java
| 1,280 |
java
|
School.java
|
Java
|
[] | null |
[] |
import java.util.ArrayList;
public class School {
private ArrayList<Teacher>teachers;
private ArrayList<Student>students;
private static int totalMoneyEarned;
private static int totalMoneySpent;
private static int balance;
School(){
teachers = new ArrayList<>();
students = new ArrayList<>();
totalMoneySpent = 0;
totalMoneyEarned = 0;
balance = totalMoneyEarned-totalMoneySpent;
}
public ArrayList<Teacher> getTeachers() {
return teachers;
}
public ArrayList<Student> getStudents() {
return students;
}
public int getTotalMoneyEarned() {
School.updateTotalMoneyEarned(totalMoneyEarned);
return totalMoneyEarned;
}
public int getTotalMoneySpent() {
return totalMoneySpent;
}
public static int getBalance() {
return balance;
}
public void addTeacher(Teacher teacher){
this.teachers.add(teacher);
}
public void addStudent(Student student){
this.students.add(student);
}
public static void updateTotalMoneyEarned(int moneyEarned){
totalMoneyEarned += moneyEarned;
}
public static void updateTotalMoneySpent(int moneySpent){
totalMoneySpent +=moneySpent;
}
}
| 1,280 | 0.660156 | 0.658594 | 51 | 24.09804 | 18.671835 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.411765 | false | false |
12
|
fc73bfe475d8bc9a79d06ca9e2923b5f0126ce3d
| 17,188,459,170,346 |
fbd02f58e0df2740e4e9e8ffbb5ad84bd6c68855
|
/src/helper/Settings.java
|
200405239f38058840315fb3eabba960a329e63c
|
[] |
no_license
|
danbax/3D-modeling-of-diamond-inclusions
|
https://github.com/danbax/3D-modeling-of-diamond-inclusions
|
a954a4fe4c79525e676d8c05d392e516003e6998
|
d80c962441bc8c875dac7a98451031dbc85a49b3
|
refs/heads/master
| 2023-02-19T07:30:44.471000 | 2021-01-06T23:05:19 | 2021-01-06T23:05:19 | 180,599,485 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package helper;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
import org.json.*;
public class Settings
{
private String settingsString;
private String settingsFolderLocation = "C:\\diamondsModelingData";
private String settingsFileName = "settings.json";
String basicData = "{\"numberOfImages\":0,\"imagesFolder\":\"C:/\"}";
public Settings() throws IOException {
settingsString = "";
File myDir = new File(settingsFolderLocation);
myDir.mkdir();
File myFile = new File(settingsFolderLocation + "\\" + settingsFileName);
myFile.createNewFile();
}
// get settings.json contents
public String getSettingString() throws IOException {
// pass the path to the file as a parameter
File settingsFile = new File(settingsFolderLocation + "\\" + settingsFileName);
Scanner sc = new Scanner(settingsFile);
while (sc.hasNextLine())
settingsString += sc.nextLine();
// initialize file content if empty
if(settingsString.isEmpty() || settingsString == null || settingsString == "") {
this.putSettingsString(basicData);
settingsString = basicData;
}
sc.close();
//settingsString = settingsString.substring(13);
return settingsString;
}
// overwrite settings.json content
public void putSettingsString(String settings) throws IOException {
File settingsFile = new File(settingsFolderLocation + "\\" + settingsFileName);
if (settingsFile.exists() && settingsFile.isFile())
settingsFile.delete();
FileWriter settingsWriter = new FileWriter(settingsFile, false); // true to append
// false to overwrite.
settingsWriter.write(settings);
settingsWriter.close();
}
// get settings.json content as object
public JSONObject getSettingsJsonObject() throws JSONException, IOException {
final JSONObject obj = new JSONObject(this.getSettingString());
return obj;
}
// update folderLocation in settings
public void setFolderLocation(String folder) throws JSONException, IOException {
JSONObject settings = this.getSettingsJsonObject();
settings.remove("imagesFolder");
settings.put("imagesFolder", folder);
this.putSettingsString(settings.toString());
}
// retrieve folder Location from settings
public String getFolderLocation() throws JSONException, IOException {
JSONObject JSONObject = getSettingsJsonObject();
return JSONObject.getString("imagesFolder");
}
}
|
UTF-8
|
Java
| 2,589 |
java
|
Settings.java
|
Java
|
[] | null |
[] |
package helper;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
import org.json.*;
public class Settings
{
private String settingsString;
private String settingsFolderLocation = "C:\\diamondsModelingData";
private String settingsFileName = "settings.json";
String basicData = "{\"numberOfImages\":0,\"imagesFolder\":\"C:/\"}";
public Settings() throws IOException {
settingsString = "";
File myDir = new File(settingsFolderLocation);
myDir.mkdir();
File myFile = new File(settingsFolderLocation + "\\" + settingsFileName);
myFile.createNewFile();
}
// get settings.json contents
public String getSettingString() throws IOException {
// pass the path to the file as a parameter
File settingsFile = new File(settingsFolderLocation + "\\" + settingsFileName);
Scanner sc = new Scanner(settingsFile);
while (sc.hasNextLine())
settingsString += sc.nextLine();
// initialize file content if empty
if(settingsString.isEmpty() || settingsString == null || settingsString == "") {
this.putSettingsString(basicData);
settingsString = basicData;
}
sc.close();
//settingsString = settingsString.substring(13);
return settingsString;
}
// overwrite settings.json content
public void putSettingsString(String settings) throws IOException {
File settingsFile = new File(settingsFolderLocation + "\\" + settingsFileName);
if (settingsFile.exists() && settingsFile.isFile())
settingsFile.delete();
FileWriter settingsWriter = new FileWriter(settingsFile, false); // true to append
// false to overwrite.
settingsWriter.write(settings);
settingsWriter.close();
}
// get settings.json content as object
public JSONObject getSettingsJsonObject() throws JSONException, IOException {
final JSONObject obj = new JSONObject(this.getSettingString());
return obj;
}
// update folderLocation in settings
public void setFolderLocation(String folder) throws JSONException, IOException {
JSONObject settings = this.getSettingsJsonObject();
settings.remove("imagesFolder");
settings.put("imagesFolder", folder);
this.putSettingsString(settings.toString());
}
// retrieve folder Location from settings
public String getFolderLocation() throws JSONException, IOException {
JSONObject JSONObject = getSettingsJsonObject();
return JSONObject.getString("imagesFolder");
}
}
| 2,589 | 0.691387 | 0.690228 | 88 | 27.397728 | 26.029503 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.693182 | false | false |
12
|
b8c9144c04baac950c394efea9fce8a19d514995
| 1,468,878,865,846 |
2eaad2b275846b5619cab5245172c2321333064c
|
/src/main/java/cnam/medimage/bean/UsageUser.java
|
1860d78a4c74f38da8fe315dd60d8e73c83480c7
|
[] |
no_license
|
nikolaiRetamal/medimage
|
https://github.com/nikolaiRetamal/medimage
|
f633dbcd77f71317b97788a012d68d308df8804e
|
278ae4be499c59aa722d02ea426b7a40f5505896
|
refs/heads/master
| 2020-07-02T04:03:01.223000 | 2015-06-18T07:41:05 | 2015-06-18T07:41:05 | 22,201,694 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package cnam.medimage.bean;
import java.io.Serializable;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import org.easycassandra.Index;
@Entity(name = "usage_user")
public class UsageUser implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
private UUID id;
@Column
private UUID id_usage;
@Column
@Index
private UUID id_user;
public UsageUser() {
super();
// TODO Auto-generated constructor stub
}
public UsageUser(UUID id, UUID id_usage, UUID id_user) {
super();
this.id = id;
this.id_usage = id_usage;
this.id_user = id_user;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public UUID getId_usage() {
return id_usage;
}
public void setId_usage(UUID id_usage) {
this.id_usage = id_usage;
}
public UUID getId_user() {
return id_user;
}
public void setId_user(UUID id_user) {
this.id_user = id_user;
}
}
|
UTF-8
|
Java
| 1,078 |
java
|
UsageUser.java
|
Java
|
[] | null |
[] |
package cnam.medimage.bean;
import java.io.Serializable;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import org.easycassandra.Index;
@Entity(name = "usage_user")
public class UsageUser implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
private UUID id;
@Column
private UUID id_usage;
@Column
@Index
private UUID id_user;
public UsageUser() {
super();
// TODO Auto-generated constructor stub
}
public UsageUser(UUID id, UUID id_usage, UUID id_user) {
super();
this.id = id;
this.id_usage = id_usage;
this.id_user = id_user;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public UUID getId_usage() {
return id_usage;
}
public void setId_usage(UUID id_usage) {
this.id_usage = id_usage;
}
public UUID getId_user() {
return id_user;
}
public void setId_user(UUID id_user) {
this.id_user = id_user;
}
}
| 1,078 | 0.641002 | 0.640074 | 63 | 15.111111 | 14.857109 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.253968 | false | false |
12
|
c9f8ce2f1ad2e099ca36f8af12d4b6f1407a6b6d
| 30,159,260,393,673 |
022be1596843705a02435ac06224783380411d9c
|
/src/main/java/util/ServerCommands.java
|
4972fb78d5a996caed1e0e077809de583fa7318f
|
[] |
no_license
|
MinchukSergei/KBRS
|
https://github.com/MinchukSergei/KBRS
|
af0e7401c7203a0deac88bdf9b09dcf8b0b0e975
|
8c9abf167d2533671e18cdd1dd371bddc21a77bb
|
refs/heads/master
| 2021-05-01T02:05:39.176000 | 2016-11-19T19:09:30 | 2016-11-19T19:09:30 | 68,807,322 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package util;
/**
* Created by USER on 24.09.2016.
*/
public enum ServerCommands {
SEND_ENCODED_SESSION_KEY(0),
SEND_ENCODED_FILE(1),
SEND_EOF(2),
SEND_SESSION_TOKEN(3),
// FILE SENDING CONSTANTS
FILE_EXISTS(10),
FILE_NOT_FOUND(11),
END_OF_FILE(13),
SESSION_KEY_IS_NULL(21),
PUBLIC_KEY_IS_NULL(23),
PUBLIC_KEY_IS_CORRECT(24),
// CONStANTS
SERVER_PART_FILE_LENGTH(128),
SERVER_PART_FILE_ENC_LENGTH(144),
SESSION_ENC_KEY_BYTE_LENGTH(256),
//CREDENTIALS
CORRECT_SIGN(51),
INCORRECT_SIGN(52),
CORRECT_CREDENTIALS(53),
INCORRECT_CREDENTIALS(54),
INCORRECT_TOKEN(55),
CORRECT_TOKEN(56);
ServerCommands(int value) {
this.value = value;
}
private int value;
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
public static ServerCommands getCommandByValue(int value) {
for (ServerCommands c: ServerCommands.values()) {
if (c.getValue() == value) {
return c;
}
}
return null;
}
}
|
UTF-8
|
Java
| 1,140 |
java
|
ServerCommands.java
|
Java
|
[] | null |
[] |
package util;
/**
* Created by USER on 24.09.2016.
*/
public enum ServerCommands {
SEND_ENCODED_SESSION_KEY(0),
SEND_ENCODED_FILE(1),
SEND_EOF(2),
SEND_SESSION_TOKEN(3),
// FILE SENDING CONSTANTS
FILE_EXISTS(10),
FILE_NOT_FOUND(11),
END_OF_FILE(13),
SESSION_KEY_IS_NULL(21),
PUBLIC_KEY_IS_NULL(23),
PUBLIC_KEY_IS_CORRECT(24),
// CONStANTS
SERVER_PART_FILE_LENGTH(128),
SERVER_PART_FILE_ENC_LENGTH(144),
SESSION_ENC_KEY_BYTE_LENGTH(256),
//CREDENTIALS
CORRECT_SIGN(51),
INCORRECT_SIGN(52),
CORRECT_CREDENTIALS(53),
INCORRECT_CREDENTIALS(54),
INCORRECT_TOKEN(55),
CORRECT_TOKEN(56);
ServerCommands(int value) {
this.value = value;
}
private int value;
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
public static ServerCommands getCommandByValue(int value) {
for (ServerCommands c: ServerCommands.values()) {
if (c.getValue() == value) {
return c;
}
}
return null;
}
}
| 1,140 | 0.586842 | 0.547368 | 55 | 19.727272 | 14.522027 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.472727 | false | false |
12
|
70e25d0a33be91fedf5469e59fb9e0e3876ea6f1
| 25,039,659,384,419 |
4b7205cf3c1ac3629c15e3541f3f272f47730bad
|
/src/main/java/com/fantasyworks/util/FilesUtil.java
|
c0eca2da94197810073df185efc92530b887288c
|
[] |
no_license
|
christopheryang/FanGraphsParser
|
https://github.com/christopheryang/FanGraphsParser
|
a4513c9493773eade046b3b4d2f3f92caf1a99a7
|
17258625cb11854f8fa4c23e19e54d418026e4bb
|
refs/heads/master
| 2021-01-10T13:08:24.040000 | 2016-02-15T23:54:25 | 2016-02-15T23:54:25 | 51,601,097 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.fantasyworks.util;
import java.io.File;
import java.io.IOException;
import com.google.common.base.Charsets;
import com.google.common.io.Files;
public class FilesUtil {
public static void writeToFile(String fileName, String content){
writeToFile(new File(fileName), content);
}
public static void writeToFile(File file, String content){
try{
Files.write(content, file, Charsets.UTF_8);
}
catch(IOException ex){
throw new RuntimeException(ex);
}
}
public static String readFileToString(String fileName){
return readFileToString(new File(fileName));
}
public static String readFileToString(File file){
try{
String result = Files.toString(file, Charsets.UTF_8);
return result;
}
catch(IOException ex){
throw new RuntimeException(ex);
}
}
public static boolean isExistingFile(String fileName){
File file = new File(fileName);
return file.exists();
}
}
|
UTF-8
|
Java
| 921 |
java
|
FilesUtil.java
|
Java
|
[] | null |
[] |
package com.fantasyworks.util;
import java.io.File;
import java.io.IOException;
import com.google.common.base.Charsets;
import com.google.common.io.Files;
public class FilesUtil {
public static void writeToFile(String fileName, String content){
writeToFile(new File(fileName), content);
}
public static void writeToFile(File file, String content){
try{
Files.write(content, file, Charsets.UTF_8);
}
catch(IOException ex){
throw new RuntimeException(ex);
}
}
public static String readFileToString(String fileName){
return readFileToString(new File(fileName));
}
public static String readFileToString(File file){
try{
String result = Files.toString(file, Charsets.UTF_8);
return result;
}
catch(IOException ex){
throw new RuntimeException(ex);
}
}
public static boolean isExistingFile(String fileName){
File file = new File(fileName);
return file.exists();
}
}
| 921 | 0.731813 | 0.729642 | 42 | 20.928572 | 20.687462 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.761905 | false | false |
12
|
f9a783072a3dc8fb3b6a3d3ece401ba07d41b6fe
| 25,039,659,386,890 |
773ef441d96512d806b564132575a690cf3aa0c7
|
/desenvolvimento-agil-com-java-avancado/forum/src/main/java/controller/InsereTopicoController.java
|
58538264be9d18daaf92a7056fb8c77a15222bbd
|
[] |
no_license
|
paulovitor/coursera
|
https://github.com/paulovitor/coursera
|
7b08d96224207845cae3da593781d487e11a1caa
|
93a268460f5d01fa23f77cc090259ec253962d50
|
refs/heads/master
| 2020-05-21T15:05:15.968000 | 2019-03-31T03:22:50 | 2019-03-31T03:22:50 | 57,310,246 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class InsereTopicoController implements Controller {
@Override
public void executar(HttpServletRequest request, HttpServletResponse response) throws Exception {
request.getRequestDispatcher("/WEB-INF/jsp/insere-topico.jsp").forward(request, response);
}
}
|
UTF-8
|
Java
| 399 |
java
|
InsereTopicoController.java
|
Java
|
[] | null |
[] |
package controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class InsereTopicoController implements Controller {
@Override
public void executar(HttpServletRequest request, HttpServletResponse response) throws Exception {
request.getRequestDispatcher("/WEB-INF/jsp/insere-topico.jsp").forward(request, response);
}
}
| 399 | 0.794486 | 0.794486 | 12 | 32.25 | 35.942371 | 101 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false |
12
|
7ebc3ea3ddbde732f28c3eee6c7dea9af886aa29
| 27,032,524,210,290 |
e69a7ba3e413aeaff47a0f416003ed7e96bf4643
|
/src/Transformations/Scale.java
|
92dee67b3e05d47bb20fe9879dab9e01268c8343
|
[] |
no_license
|
Zkaron/Graphics2D
|
https://github.com/Zkaron/Graphics2D
|
6928cc484bfef8c0fd4b9f73a6af73600f16f2ef
|
e312623d666a47be40d9d03ea156ed74d91de1dc
|
refs/heads/master
| 2021-08-17T08:32:57.647000 | 2017-11-08T16:00:11 | 2017-11-08T16:00:11 | 96,690,173 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package Transformations;
import Figures.*;
import Lines.AbstractLine;
import Lines.BresenhamLine;
import java.awt.*;
import java.util.LinkedList;
/**
* Created by Erik on 9/22/2017.
*/
public class Scale {
public Scale() {
}
/**
* For lines and rectangles
* @param p0
* @param p1
* @return
*/
public LinkedList<Point> scale(Point p0, Point p1, double scaleWidth, double scaleHeight) {
LinkedList<Point> scaledPoint = new LinkedList<>();
if(scaleWidth != 1 || scaleHeight != 1) {
int startX = p0.x < p1.x ? p0.x : p1.x;
int startY = p0.y < p1.y ? p0.y : p1.y;
p0 = new Point((int)Math.round(p0.x * scaleWidth),(int)Math.round(p0.y * scaleHeight));
p1 = new Point((int)Math.round(p1.x * scaleWidth), (int)Math.round(p1.y * scaleHeight));
// p0.x += startX;
// p0.y += startY;
// p1.x += startX;
// p1.y += startY;
}
scaledPoint.add(p0);
scaledPoint.add(p1);
return scaledPoint;
}
/**
* For single Point
* @param point
* @param scaleRatioX
* @param scaleRatioY
* @return
*/
public Point scale(Point point, double scaleRatioX, double scaleRatioY) {
Point scaledPoint = new Point(point);
scaledPoint.setLocation(point.x * scaleRatioX, point.y * scaleRatioY);
return scaledPoint;
}
}
|
UTF-8
|
Java
| 1,496 |
java
|
Scale.java
|
Java
|
[
{
"context": "import java.util.LinkedList;\r\n\r\n/**\r\n * Created by Erik on 9/22/2017.\r\n */\r\npublic class Scale {\r\n\r\n\r\n ",
"end": 181,
"score": 0.9968122839927673,
"start": 177,
"tag": "NAME",
"value": "Erik"
}
] | null |
[] |
package Transformations;
import Figures.*;
import Lines.AbstractLine;
import Lines.BresenhamLine;
import java.awt.*;
import java.util.LinkedList;
/**
* Created by Erik on 9/22/2017.
*/
public class Scale {
public Scale() {
}
/**
* For lines and rectangles
* @param p0
* @param p1
* @return
*/
public LinkedList<Point> scale(Point p0, Point p1, double scaleWidth, double scaleHeight) {
LinkedList<Point> scaledPoint = new LinkedList<>();
if(scaleWidth != 1 || scaleHeight != 1) {
int startX = p0.x < p1.x ? p0.x : p1.x;
int startY = p0.y < p1.y ? p0.y : p1.y;
p0 = new Point((int)Math.round(p0.x * scaleWidth),(int)Math.round(p0.y * scaleHeight));
p1 = new Point((int)Math.round(p1.x * scaleWidth), (int)Math.round(p1.y * scaleHeight));
// p0.x += startX;
// p0.y += startY;
// p1.x += startX;
// p1.y += startY;
}
scaledPoint.add(p0);
scaledPoint.add(p1);
return scaledPoint;
}
/**
* For single Point
* @param point
* @param scaleRatioX
* @param scaleRatioY
* @return
*/
public Point scale(Point point, double scaleRatioX, double scaleRatioY) {
Point scaledPoint = new Point(point);
scaledPoint.setLocation(point.x * scaleRatioX, point.y * scaleRatioY);
return scaledPoint;
}
}
| 1,496 | 0.54746 | 0.525401 | 56 | 24.714285 | 25.252804 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.553571 | false | false |
12
|
de614f403fd59b38e0ea0421f2f80a0e0bb3f7d7
| 27,101,243,688,729 |
209554fd9c2f00580f494a8f32db6581cc6c6ddc
|
/src/main/java/com/cheer/result/ShopLocationResult.java
|
264c0c3f3fe0e9e41bf36b101ff39b331e356003
|
[] |
no_license
|
sweetanran/cheer-sgcc
|
https://github.com/sweetanran/cheer-sgcc
|
73cb904250a2ec66867213a5150127d473d52ba1
|
a9f2d700bd65840baa505b1d2a4fe65b83023eba
|
refs/heads/master
| 2020-04-05T20:30:54.858000 | 2018-11-28T02:41:00 | 2018-11-28T02:41:00 | 157,183,670 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.cheer.result;
/**
* @author cheer
*/
public class ShopLocationResult {
private String name;
private String value;
public String getName() {
return name;
}
public ShopLocationResult setName(String name) {
this.name = name;
return this;
}
public String getValue() {
return value;
}
public ShopLocationResult setValue(String value) {
this.value = value;
return this;
}
}
|
UTF-8
|
Java
| 477 |
java
|
ShopLocationResult.java
|
Java
|
[
{
"context": "package com.cheer.result;\n\n/**\n * @author cheer\n */\npublic class ShopLocationResult {\n\n privat",
"end": 47,
"score": 0.9988714456558228,
"start": 42,
"tag": "USERNAME",
"value": "cheer"
}
] | null |
[] |
package com.cheer.result;
/**
* @author cheer
*/
public class ShopLocationResult {
private String name;
private String value;
public String getName() {
return name;
}
public ShopLocationResult setName(String name) {
this.name = name;
return this;
}
public String getValue() {
return value;
}
public ShopLocationResult setValue(String value) {
this.value = value;
return this;
}
}
| 477 | 0.599581 | 0.599581 | 29 | 15.448276 | 15.228345 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.310345 | false | false |
12
|
09830ce86631b988ec7c6f113118624301a27172
| 755,914,308,058 |
b49a3e3d98dee389335275ce98872aac139c321e
|
/CS-101/Source Code/Chapter_12/Example12_46_47_48/PlayTreasureHunt.java
|
d0d8d93e5c75852b0ce22aa993d1ae89d125a2f5
|
[] |
no_license
|
DRK-512/Java_Projects
|
https://github.com/DRK-512/Java_Projects
|
164f834c22a294f2f9999d4497bb49b3f694d1e9
|
3705a8e4df11c6a60e6135ba5f4198ab4351fd04
|
refs/heads/master
| 2023-05-07T23:07:52.508000 | 2023-01-25T04:33:54 | 2023-01-25T04:33:54 | 288,883,164 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/* PlayTreasureHunt class
Anderson, Franceschi
*/
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class PlayTreasureHunt extends Application
{
private final int GAME_SIZE = 500;
@Override
public void start( Stage stage )
{
TreasureHunt th = new TreasureHunt( GAME_SIZE );
TreasureHuntViewController root =
new TreasureHuntViewController( th, GAME_SIZE, GAME_SIZE );
Scene scene = new Scene( root, GAME_SIZE, GAME_SIZE );
stage.setTitle( "Play !!" );
stage.setScene( scene );
stage.show( );
}
public static void main( String [] args )
{
launch( args );
}
}
|
UTF-8
|
Java
| 673 |
java
|
PlayTreasureHunt.java
|
Java
|
[
{
"context": "/* PlayTreasureHunt class\n Anderson, Franceschi\n*/\n\nimport javafx.application.Application;\nimport",
"end": 49,
"score": 0.9986114501953125,
"start": 29,
"tag": "NAME",
"value": "Anderson, Franceschi"
}
] | null |
[] |
/* PlayTreasureHunt class
<NAME>
*/
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class PlayTreasureHunt extends Application
{
private final int GAME_SIZE = 500;
@Override
public void start( Stage stage )
{
TreasureHunt th = new TreasureHunt( GAME_SIZE );
TreasureHuntViewController root =
new TreasureHuntViewController( th, GAME_SIZE, GAME_SIZE );
Scene scene = new Scene( root, GAME_SIZE, GAME_SIZE );
stage.setTitle( "Play !!" );
stage.setScene( scene );
stage.show( );
}
public static void main( String [] args )
{
launch( args );
}
}
| 659 | 0.679049 | 0.674591 | 30 | 21.433332 | 19.393614 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.533333 | false | false |
0
|
5641777130c7e89ccc5c92940f55125fcfc517ae
| 24,429,773,982,671 |
ff991f15e5938e3787788e0897e5e904b3eb0d19
|
/user-service/src/main/java/com/record/thelife/request/UserRequest.java
|
66c8bb95f1a52391fabad111b6a2eda4830d1dc8
|
[] |
no_license
|
wangyouxiu/thelife
|
https://github.com/wangyouxiu/thelife
|
84645a6399182495a1150759d06620093a954237
|
8f49d5ad3829be4780a23184fc33d7c82cc058aa
|
refs/heads/master
| 2022-07-12T05:38:52.466000 | 2019-11-17T15:37:01 | 2019-11-17T15:37:01 | 222,211,032 | 0 | 0 | null | false | 2022-06-21T02:15:09 | 2019-11-17T07:11:39 | 2019-11-17T15:37:36 | 2022-06-21T02:15:08 | 11,944 | 0 | 0 | 1 |
Java
| false | false |
package com.record.thelife.request;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class UserRequest implements Serializable {
/**
* 用户Id
*/
private Integer id;
/**
* 昵称
*/
private String nickName;
/**
* 真实姓名
*/
private String realName;
/**
* 密码
*/
private String pwd;
/**
* 电话
*/
private String phone;
/**
* 头像
*/
private String photo;
private Date createTime;
private Date modifiedTime;
}
|
UTF-8
|
Java
| 579 |
java
|
UserRequest.java
|
Java
|
[] | null |
[] |
package com.record.thelife.request;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class UserRequest implements Serializable {
/**
* 用户Id
*/
private Integer id;
/**
* 昵称
*/
private String nickName;
/**
* 真实姓名
*/
private String realName;
/**
* 密码
*/
private String pwd;
/**
* 电话
*/
private String phone;
/**
* 头像
*/
private String photo;
private Date createTime;
private Date modifiedTime;
}
| 579 | 0.555354 | 0.555354 | 39 | 13.128205 | 11.736814 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.307692 | false | false |
0
|
011178a7b9459cd052b35e0277ffdf43b6e12bad
| 30,717,606,110,831 |
2200daa9b012c9395885e91d498013e6bff0e608
|
/app/src/main/java/cn/bgs/breakpointresume/util/DownLoadUtil.java
|
a7ebaff7f210108d908b2e24360518ff9d387b88
|
[] |
no_license
|
NanKe165/BreakpointResume
|
https://github.com/NanKe165/BreakpointResume
|
b6bfe058e6d0190d28ffb9948e7bda1526d85312
|
e9caccf7645a6d29d78d02fe649839bde49d881a
|
refs/heads/master
| 2021-05-11T04:11:12.372000 | 2018-01-18T04:56:31 | 2018-01-18T04:56:31 | 117,934,376 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package cn.bgs.breakpointresume.util;
import android.content.Context;
import android.content.Intent;
import android.os.Environment;
import org.apache.http.HttpStatus;
import java.io.File;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import cn.bgs.breakpointresume.bean.DownLoadFile;
import cn.bgs.breakpointresume.dao.ThreadDAO;
import cn.bgs.breakpointresume.dao.ThreadDAOImpl;
/**
* Created by Vincent on 2018/1/4.
*/
public class DownLoadUtil {
private int finished;
private boolean isPause=false;
ThreadDAO threadDAO;
DownLoadFile fileInfo;
Context context;
private String DOWNLOAD_PATH= Environment.getExternalStorageDirectory()+"/breakPoint/";
private String FILE_NAME="breakPoint.apk";
private String ACTION_UPDATE="ACTION_UPDATE";
//构造方法略
public void download(){
List<DownLoadFile> lists = threadDAO.get(fileInfo.getUrl());
DownLoadFile info = null;
if(lists.size() == 0){
//第一次下载,创建子线程下载
new MyThread(fileInfo).start();
}else{
//中间开始的
info = lists.get(0);
new MyThread(info).start();
}
}
public DownLoadUtil(Context context, DownLoadFile file){
this.context=context;
fileInfo=file;
this.threadDAO=new ThreadDAOImpl(context);
}
class MyThread extends Thread{
private DownLoadFile info = null;
public MyThread(DownLoadFile threadInfo) {
this.info = threadInfo;
}
@Override
public void run() {
//向数据库添加线程信息
if(!threadDAO.isExits(info.getUrl())){
threadDAO.insert(info);
}
HttpURLConnection urlConnection = null;
RandomAccessFile randomFile =null;
InputStream inputStream = null;
try {
URL url = new URL(info.getUrl());
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setConnectTimeout(3000);
urlConnection.setRequestMethod("GET");
//设置下载位置
int start = info.getStart() + info.getNow();
urlConnection.setRequestProperty("Range","bytes=" + start + "-" + info.getLength());
//设置文件写入位置
File file = new File(DOWNLOAD_PATH,FILE_NAME);
randomFile = new RandomAccessFile(file, "rwd");
randomFile.seek(start);
//向Activity发广播
Intent intent = new Intent(ACTION_UPDATE);
intent.putExtra("length",info.getLength());
context.sendBroadcast(intent);
finished += info.getNow();
Intent intent1 = new Intent(ACTION_UPDATE);
if (urlConnection.getResponseCode() == HttpStatus.SC_PARTIAL_CONTENT) {
//获得文件流
inputStream = urlConnection.getInputStream();
byte[] buffer = new byte[512];
int len = -1;
long time = System.currentTimeMillis();
while ((len = inputStream.read(buffer))!= -1){
//写入文件
randomFile.write(buffer,0,len);
//把进度发送给Activity
finished += len;
//看时间间隔,时间间隔大于500ms再发
if(System.currentTimeMillis() - time >500){
time = System.currentTimeMillis();
intent1.putExtra("now",finished );
context.sendBroadcast(intent1);
}
//判断是否是暂停状态
if(isPause){
threadDAO.update(info.getUrl(),finished);
return; //结束循环
}
}
//删除线程信息
threadDAO.delete(info.getUrl());
}
}catch (Exception e){
e.printStackTrace();
}finally {//回收工作略
}
}
}
public void setPause(Boolean isPause){
this.isPause=isPause;
}
public void cancel(String url){
//TODO 删除本地文件
threadDAO.delete(url);
}
}
|
UTF-8
|
Java
| 4,608 |
java
|
DownLoadUtil.java
|
Java
|
[
{
"context": "kpointresume.dao.ThreadDAOImpl;\n\n/**\n * Created by Vincent on 2018/1/4.\n */\n\npublic class DownLoadUtil {\n ",
"end": 504,
"score": 0.9873858094215393,
"start": 497,
"tag": "NAME",
"value": "Vincent"
}
] | null |
[] |
package cn.bgs.breakpointresume.util;
import android.content.Context;
import android.content.Intent;
import android.os.Environment;
import org.apache.http.HttpStatus;
import java.io.File;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import cn.bgs.breakpointresume.bean.DownLoadFile;
import cn.bgs.breakpointresume.dao.ThreadDAO;
import cn.bgs.breakpointresume.dao.ThreadDAOImpl;
/**
* Created by Vincent on 2018/1/4.
*/
public class DownLoadUtil {
private int finished;
private boolean isPause=false;
ThreadDAO threadDAO;
DownLoadFile fileInfo;
Context context;
private String DOWNLOAD_PATH= Environment.getExternalStorageDirectory()+"/breakPoint/";
private String FILE_NAME="breakPoint.apk";
private String ACTION_UPDATE="ACTION_UPDATE";
//构造方法略
public void download(){
List<DownLoadFile> lists = threadDAO.get(fileInfo.getUrl());
DownLoadFile info = null;
if(lists.size() == 0){
//第一次下载,创建子线程下载
new MyThread(fileInfo).start();
}else{
//中间开始的
info = lists.get(0);
new MyThread(info).start();
}
}
public DownLoadUtil(Context context, DownLoadFile file){
this.context=context;
fileInfo=file;
this.threadDAO=new ThreadDAOImpl(context);
}
class MyThread extends Thread{
private DownLoadFile info = null;
public MyThread(DownLoadFile threadInfo) {
this.info = threadInfo;
}
@Override
public void run() {
//向数据库添加线程信息
if(!threadDAO.isExits(info.getUrl())){
threadDAO.insert(info);
}
HttpURLConnection urlConnection = null;
RandomAccessFile randomFile =null;
InputStream inputStream = null;
try {
URL url = new URL(info.getUrl());
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setConnectTimeout(3000);
urlConnection.setRequestMethod("GET");
//设置下载位置
int start = info.getStart() + info.getNow();
urlConnection.setRequestProperty("Range","bytes=" + start + "-" + info.getLength());
//设置文件写入位置
File file = new File(DOWNLOAD_PATH,FILE_NAME);
randomFile = new RandomAccessFile(file, "rwd");
randomFile.seek(start);
//向Activity发广播
Intent intent = new Intent(ACTION_UPDATE);
intent.putExtra("length",info.getLength());
context.sendBroadcast(intent);
finished += info.getNow();
Intent intent1 = new Intent(ACTION_UPDATE);
if (urlConnection.getResponseCode() == HttpStatus.SC_PARTIAL_CONTENT) {
//获得文件流
inputStream = urlConnection.getInputStream();
byte[] buffer = new byte[512];
int len = -1;
long time = System.currentTimeMillis();
while ((len = inputStream.read(buffer))!= -1){
//写入文件
randomFile.write(buffer,0,len);
//把进度发送给Activity
finished += len;
//看时间间隔,时间间隔大于500ms再发
if(System.currentTimeMillis() - time >500){
time = System.currentTimeMillis();
intent1.putExtra("now",finished );
context.sendBroadcast(intent1);
}
//判断是否是暂停状态
if(isPause){
threadDAO.update(info.getUrl(),finished);
return; //结束循环
}
}
//删除线程信息
threadDAO.delete(info.getUrl());
}
}catch (Exception e){
e.printStackTrace();
}finally {//回收工作略
}
}
}
public void setPause(Boolean isPause){
this.isPause=isPause;
}
public void cancel(String url){
//TODO 删除本地文件
threadDAO.delete(url);
}
}
| 4,608 | 0.535096 | 0.528943 | 129 | 33.015503 | 21.383898 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.573643 | false | false |
0
|
9150054b9ea462696996edfffb6cde8b72c7f618
| 1,305,670,120,039 |
30c830a9e93e566652aa0a39511dd9aa7fefb41a
|
/mpbasekit/src/main/java/com/mp/basekit/util/ImageUtils.java
|
dd88bc7e2b3309681011054ceb821f5b9629f957
|
[] |
no_license
|
Huanjun/BaseKit
|
https://github.com/Huanjun/BaseKit
|
9d7ed104d10936df390a4718d1c4b66aed38bd3b
|
7837afaf1346fee0e860e3c12c9266e8246bb527
|
refs/heads/main
| 2023-01-02T05:35:46.896000 | 2020-10-28T03:36:39 | 2020-10-28T03:36:39 | 303,889,935 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.mp.basekit.util;
import android.annotation.TargetApi;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.LinearGradient;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.media.ExifInterface;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.ParcelFileDescriptor;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.ScriptIntrinsicBlur;
import android.util.Base64;
import android.util.Log;
import android.view.View;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.FloatRange;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat;
import com.mp.basekit.core.MPApplication;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2016/08/12
* desc : utils about image
* </pre>
*/
public final class ImageUtils {
private ImageUtils() {
throw new UnsupportedOperationException("u can't instantiate me...");
}
/**
* String to bitmap.
*
* @param string
* @return
*/
public static Bitmap string2Bitmap(String string) {
//将字符串转换成Bitmap类型
Bitmap bitmap = null;
try {
byte[] bitmapArray;
bitmapArray = Base64.decode(string, Base64.DEFAULT);
bitmap = BitmapFactory.decodeByteArray(bitmapArray, 0, bitmapArray.length);
} catch (Exception e) {
e.printStackTrace();
}
return bitmap;
}
/**
* Bitmap to bytes.
*
* @param bitmap The bitmap.
* @param format The format of bitmap.
* @return bytes
*/
public static byte[] bitmap2Bytes(final Bitmap bitmap, final CompressFormat format) {
if (bitmap == null) return null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(format, 100, baos);
return baos.toByteArray();
}
/**
* Bytes to bitmap.
*
* @param bytes The bytes.
* @return bitmap
*/
public static Bitmap bytes2Bitmap(final byte[] bytes) {
return (bytes == null || bytes.length == 0)
? null
: BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
}
/**
* Drawable to bitmap.
*
* @param drawable The drawable.
* @return bitmap
*/
public static Bitmap drawable2Bitmap(final Drawable drawable) {
if (drawable instanceof BitmapDrawable) {
BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
if (bitmapDrawable.getBitmap() != null) {
return bitmapDrawable.getBitmap();
}
}
Bitmap bitmap;
if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
bitmap = Bitmap.createBitmap(1, 1,
drawable.getOpacity() != PixelFormat.OPAQUE
? Bitmap.Config.ARGB_8888
: Bitmap.Config.RGB_565);
} else {
bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(),
drawable.getOpacity() != PixelFormat.OPAQUE
? Bitmap.Config.ARGB_8888
: Bitmap.Config.RGB_565);
}
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
return bitmap;
}
/**
* Bitmap to drawable.
*
* @param bitmap The bitmap.
* @return drawable
*/
public static Drawable bitmap2Drawable(final Bitmap bitmap) {
return bitmap == null ? null : new BitmapDrawable(MPUtils.getApp().getResources(), bitmap);
}
/**
* Drawable to bytes.
*
* @param drawable The drawable.
* @param format The format of bitmap.
* @return bytes
*/
public static byte[] drawable2Bytes(final Drawable drawable, final CompressFormat format) {
return drawable == null ? null : bitmap2Bytes(drawable2Bitmap(drawable), format);
}
/**
* Bytes to drawable.
*
* @param bytes The bytes.
* @return drawable
*/
public static Drawable bytes2Drawable(final byte[] bytes) {
return bitmap2Drawable(bytes2Bitmap(bytes));
}
/**
* View to bitmap.
*
* @param view The view.
* @return bitmap
*/
public static Bitmap view2Bitmap(final View view) {
if (view == null) return null;
Bitmap ret = Bitmap.createBitmap(view.getWidth(),
view.getHeight(),
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(ret);
// Drawable bgDrawable = view.getBackground();
// if (bgDrawable != null) {
// bgDrawable.draw(canvas);
// } else {
// canvas.drawColor(Color.WHITE);
// }
view.draw(canvas);
return ret;
}
/**
* Return bitmap.
*
* @param file The file.
* @return bitmap
*/
public static Bitmap getBitmap(final File file) {
if (file == null) return null;
return BitmapFactory.decodeFile(file.getAbsolutePath());
}
/**
* Return bitmap.
*
* @param file The file.
* @param maxWidth The maximum width.
* @param maxHeight The maximum height.
* @return bitmap
*/
public static Bitmap getBitmap(final File file, final int maxWidth, final int maxHeight) {
if (file == null) return null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
options.inSampleSize = calculateInSampleSize(options, maxWidth, maxHeight);
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(file.getAbsolutePath(), options);
}
/**
* Return bitmap.
*
* @param filePath The path of file.
* @return bitmap
*/
public static Bitmap getBitmap(final String filePath) {
if (isSpace(filePath)) return null;
return getBitmap(getImageContentUri(filePath));
}
// 通过uri加载图片
public static Bitmap getBitmap(Uri uri) {
try {
ParcelFileDescriptor parcelFileDescriptor =
MPApplication.getAppContext().getContentResolver().openFileDescriptor(uri, "r");
FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
Bitmap image = BitmapFactory.decodeFileDescriptor(fileDescriptor);
parcelFileDescriptor.close();
return image;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* Return bitmap.
*
* @param filePath The path of file.
* @param maxWidth The maximum width.
* @param maxHeight The maximum height.
* @return bitmap
*/
public static Bitmap getBitmap(final String filePath, final int maxWidth, final int maxHeight) {
if (isSpace(filePath)) return null;
return getBitmap(getImageContentUri(filePath));
}
public static Uri getImageContentUri(String path) {
Context context = MPApplication.getAppContext();
Cursor cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String[]{MediaStore.Images.Media._ID}, MediaStore.Images.Media.DATA + "=? ",
new String[]{path}, null);
if (cursor != null && cursor.moveToFirst()) {
int id = cursor.getInt(cursor.getColumnIndex(MediaStore.MediaColumns._ID));
Uri baseUri = Uri.parse("content://media/external/images/media");
return Uri.withAppendedPath(baseUri, "" + id);
} else {
// 如果图片不在手机的共享图片数据库,就先把它插入。
if (new File(path).exists()) {
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.DATA, path);
return context.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
} else {
return null;
}
}
}
/**
* Return bitmap.
*
* @param is The input stream.
* @return bitmap
*/
public static Bitmap getBitmap(final InputStream is) {
if (is == null) return null;
return BitmapFactory.decodeStream(is);
}
/**
* Return bitmap.
*
* @param is The input stream.
* @param maxWidth The maximum width.
* @param maxHeight The maximum height.
* @return bitmap
*/
public static Bitmap getBitmap(final InputStream is, final int maxWidth, final int maxHeight) {
if (is == null) return null;
byte[] bytes = input2Byte(is);
return getBitmap(bytes, 0, maxWidth, maxHeight);
}
/**
* Return bitmap.
*
* @param data The data.
* @param offset The offset.
* @return bitmap
*/
public static Bitmap getBitmap(final byte[] data, final int offset) {
if (data.length == 0) return null;
return BitmapFactory.decodeByteArray(data, offset, data.length);
}
/**
* Return bitmap.
*
* @param data The data.
* @param offset The offset.
* @param maxWidth The maximum width.
* @param maxHeight The maximum height.
* @return bitmap
*/
public static Bitmap getBitmap(final byte[] data,
final int offset,
final int maxWidth,
final int maxHeight) {
if (data.length == 0) return null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeByteArray(data, offset, data.length, options);
options.inSampleSize = calculateInSampleSize(options, maxWidth, maxHeight);
options.inJustDecodeBounds = false;
return BitmapFactory.decodeByteArray(data, offset, data.length, options);
}
/**
* Return bitmap.
*
* @param resId The resource id.
* @return bitmap
*/
public static Bitmap getBitmap(@DrawableRes final int resId) {
Drawable drawable = ContextCompat.getDrawable(MPUtils.getApp(), resId);
Canvas canvas = new Canvas();
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(),
Bitmap.Config.ARGB_8888);
canvas.setBitmap(bitmap);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
drawable.draw(canvas);
return bitmap;
}
/**
* Return bitmap.
*
* @param resId The resource id.
* @param maxWidth The maximum width.
* @param maxHeight The maximum height.
* @return bitmap
*/
public static Bitmap getBitmap(@DrawableRes final int resId,
final int maxWidth,
final int maxHeight) {
BitmapFactory.Options options = new BitmapFactory.Options();
final Resources resources = MPUtils.getApp().getResources();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(resources, resId, options);
options.inSampleSize = calculateInSampleSize(options, maxWidth, maxHeight);
options.inJustDecodeBounds = false;
return BitmapFactory.decodeResource(resources, resId, options);
}
/**
* Return bitmap.
*
* @param fd The file descriptor.
* @return bitmap
*/
public static Bitmap getBitmap(final FileDescriptor fd) {
if (fd == null) return null;
return BitmapFactory.decodeFileDescriptor(fd);
}
/**
* Return bitmap.
*
* @param fd The file descriptor
* @param maxWidth The maximum width.
* @param maxHeight The maximum height.
* @return bitmap
*/
public static Bitmap getBitmap(final FileDescriptor fd,
final int maxWidth,
final int maxHeight) {
if (fd == null) return null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFileDescriptor(fd, null, options);
options.inSampleSize = calculateInSampleSize(options, maxWidth, maxHeight);
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFileDescriptor(fd, null, options);
}
/**
* Return the bitmap with the specified color.
*
* @param src The source of bitmap.
* @param color The color.
* @return the bitmap with the specified color
*/
public static Bitmap drawColor(@NonNull final Bitmap src, @ColorInt final int color) {
return drawColor(src, color, false);
}
/**
* Return the bitmap with the specified color.
*
* @param src The source of bitmap.
* @param color The color.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the bitmap with the specified color
*/
public static Bitmap drawColor(@NonNull final Bitmap src,
@ColorInt final int color,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
Bitmap ret = recycle ? src : src.copy(src.getConfig(), true);
Canvas canvas = new Canvas(ret);
canvas.drawColor(color, PorterDuff.Mode.DARKEN);
return ret;
}
/**
* Return the scaled bitmap.
*
* @param src The source of bitmap.
* @param newWidth The new width.
* @param newHeight The new height.
* @return the scaled bitmap
*/
public static Bitmap scale(final Bitmap src, final int newWidth, final int newHeight) {
return scale(src, newWidth, newHeight, false);
}
/**
* Return the scaled bitmap.
*
* @param src The source of bitmap.
* @param newWidth The new width.
* @param newHeight The new height.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the scaled bitmap
*/
public static Bitmap scale(final Bitmap src,
final int newWidth,
final int newHeight,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
Bitmap ret = Bitmap.createScaledBitmap(src, newWidth, newHeight, true);
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the scaled bitmap
*
* @param src The source of bitmap.
* @param scaleWidth The scale of width.
* @param scaleHeight The scale of height.
* @return the scaled bitmap
*/
public static Bitmap scale(final Bitmap src, final float scaleWidth, final float scaleHeight) {
return scale(src, scaleWidth, scaleHeight, false);
}
/**
* Return the scaled bitmap
*
* @param src The source of bitmap.
* @param scaleWidth The scale of width.
* @param scaleHeight The scale of height.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the scaled bitmap
*/
public static Bitmap scale(final Bitmap src,
final float scaleWidth,
final float scaleHeight,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
Matrix matrix = new Matrix();
matrix.setScale(scaleWidth, scaleHeight);
Bitmap ret = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the clipped bitmap.
*
* @param src The source of bitmap.
* @param x The x coordinate of the first pixel.
* @param y The y coordinate of the first pixel.
* @param width The width.
* @param height The height.
* @return the clipped bitmap
*/
public static Bitmap clip(final Bitmap src,
final int x,
final int y,
final int width,
final int height) {
return clip(src, x, y, width, height, false);
}
/**
* Return the clipped bitmap.
*
* @param src The source of bitmap.
* @param x The x coordinate of the first pixel.
* @param y The y coordinate of the first pixel.
* @param width The width.
* @param height The height.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the clipped bitmap
*/
public static Bitmap clip(final Bitmap src,
final int x,
final int y,
final int width,
final int height,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
Bitmap ret = Bitmap.createBitmap(src, x, y, width, height);
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the skewed bitmap.
*
* @param src The source of bitmap.
* @param kx The skew factor of x.
* @param ky The skew factor of y.
* @return the skewed bitmap
*/
public static Bitmap skew(final Bitmap src, final float kx, final float ky) {
return skew(src, kx, ky, 0, 0, false);
}
/**
* Return the skewed bitmap.
*
* @param src The source of bitmap.
* @param kx The skew factor of x.
* @param ky The skew factor of y.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the skewed bitmap
*/
public static Bitmap skew(final Bitmap src,
final float kx,
final float ky,
final boolean recycle) {
return skew(src, kx, ky, 0, 0, recycle);
}
/**
* Return the skewed bitmap.
*
* @param src The source of bitmap.
* @param kx The skew factor of x.
* @param ky The skew factor of y.
* @param px The x coordinate of the pivot point.
* @param py The y coordinate of the pivot point.
* @return the skewed bitmap
*/
public static Bitmap skew(final Bitmap src,
final float kx,
final float ky,
final float px,
final float py) {
return skew(src, kx, ky, px, py, false);
}
/**
* Return the skewed bitmap.
*
* @param src The source of bitmap.
* @param kx The skew factor of x.
* @param ky The skew factor of y.
* @param px The x coordinate of the pivot point.
* @param py The y coordinate of the pivot point.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the skewed bitmap
*/
public static Bitmap skew(final Bitmap src,
final float kx,
final float ky,
final float px,
final float py,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
Matrix matrix = new Matrix();
matrix.setSkew(kx, ky, px, py);
Bitmap ret = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the rotated bitmap.
*
* @param src The source of bitmap.
* @param degrees The number of degrees.
* @param px The x coordinate of the pivot point.
* @param py The y coordinate of the pivot point.
* @return the rotated bitmap
*/
public static Bitmap rotate(final Bitmap src,
final int degrees,
final float px,
final float py) {
return rotate(src, degrees, px, py, false);
}
/**
* Return the rotated bitmap.
*
* @param src The source of bitmap.
* @param degrees The number of degrees.
* @param px The x coordinate of the pivot point.
* @param py The y coordinate of the pivot point.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the rotated bitmap
*/
public static Bitmap rotate(final Bitmap src,
final int degrees,
final float px,
final float py,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
if (degrees == 0) return src;
Matrix matrix = new Matrix();
matrix.setRotate(degrees, px, py);
Bitmap ret = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the rotated degree.
*
* @param filePath The path of file.
* @return the rotated degree
*/
public static int getRotateDegree(final String filePath) {
try {
ExifInterface exifInterface = new ExifInterface(filePath);
int orientation = exifInterface.getAttributeInt(
ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_NORMAL
);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
return 90;
case ExifInterface.ORIENTATION_ROTATE_180:
return 180;
case ExifInterface.ORIENTATION_ROTATE_270:
return 270;
default:
return 0;
}
} catch (IOException e) {
e.printStackTrace();
return -1;
}
}
/**
* Return the round bitmap.
*
* @param src The source of bitmap.
* @return the round bitmap
*/
public static Bitmap toRound(final Bitmap src) {
return toRound(src, 0, 0, false);
}
/**
* Return the round bitmap.
*
* @param src The source of bitmap.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the round bitmap
*/
public static Bitmap toRound(final Bitmap src, final boolean recycle) {
return toRound(src, 0, 0, recycle);
}
/**
* Return the round bitmap.
*
* @param src The source of bitmap.
* @param borderSize The size of border.
* @param borderColor The color of border.
* @return the round bitmap
*/
public static Bitmap toRound(final Bitmap src,
@IntRange(from = 0) int borderSize,
@ColorInt int borderColor) {
return toRound(src, borderSize, borderColor, false);
}
/**
* Return the round bitmap.
*
* @param src The source of bitmap.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @param borderSize The size of border.
* @param borderColor The color of border.
* @return the round bitmap
*/
public static Bitmap toRound(final Bitmap src,
@IntRange(from = 0) int borderSize,
@ColorInt int borderColor,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
int width = src.getWidth();
int height = src.getHeight();
int size = Math.min(width, height);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
Bitmap ret = Bitmap.createBitmap(width, height, src.getConfig());
float center = size / 2f;
RectF rectF = new RectF(0, 0, width, height);
rectF.inset((width - size) / 2f, (height - size) / 2f);
Matrix matrix = new Matrix();
matrix.setTranslate(rectF.left, rectF.top);
matrix.preScale((float) size / width, (float) size / height);
BitmapShader shader = new BitmapShader(src, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
shader.setLocalMatrix(matrix);
paint.setShader(shader);
Canvas canvas = new Canvas(ret);
canvas.drawRoundRect(rectF, center, center, paint);
if (borderSize > 0) {
paint.setShader(null);
paint.setColor(borderColor);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(borderSize);
float radius = center - borderSize / 2f;
canvas.drawCircle(width / 2f, height / 2f, radius, paint);
}
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the round corner bitmap.
*
* @param src The source of bitmap.
* @param radius The radius of corner.
* @return the round corner bitmap
*/
public static Bitmap toRoundCorner(final Bitmap src, final float radius) {
return toRoundCorner(src, radius, 0, 0, false);
}
/**
* Return the round corner bitmap.
*
* @param src The source of bitmap.
* @param radius The radius of corner.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the round corner bitmap
*/
public static Bitmap toRoundCorner(final Bitmap src,
final float radius,
final boolean recycle) {
return toRoundCorner(src, radius, 0, 0, recycle);
}
/**
* Return the round corner bitmap.
*
* @param src The source of bitmap.
* @param radius The radius of corner.
* @param borderSize The size of border.
* @param borderColor The color of border.
* @return the round corner bitmap
*/
public static Bitmap toRoundCorner(final Bitmap src,
final float radius,
@IntRange(from = 0) int borderSize,
@ColorInt int borderColor) {
return toRoundCorner(src, radius, borderSize, borderColor, false);
}
/**
* Return the round corner bitmap.
*
* @param src The source of bitmap.
* @param radius The radius of corner.
* @param borderSize The size of border.
* @param borderColor The color of border.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the round corner bitmap
*/
public static Bitmap toRoundCorner(final Bitmap src,
final float radius,
@IntRange(from = 0) int borderSize,
@ColorInt int borderColor,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
int width = src.getWidth();
int height = src.getHeight();
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
Bitmap ret = Bitmap.createBitmap(width, height, src.getConfig());
BitmapShader shader = new BitmapShader(src, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
paint.setShader(shader);
Canvas canvas = new Canvas(ret);
RectF rectF = new RectF(0, 0, width, height);
float halfBorderSize = borderSize / 2f;
rectF.inset(halfBorderSize, halfBorderSize);
canvas.drawRoundRect(rectF, radius, radius, paint);
if (borderSize > 0) {
paint.setShader(null);
paint.setColor(borderColor);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(borderSize);
paint.setStrokeCap(Paint.Cap.ROUND);
canvas.drawRoundRect(rectF, radius, radius, paint);
}
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the round corner bitmap with border.
*
* @param src The source of bitmap.
* @param borderSize The size of border.
* @param color The color of border.
* @param cornerRadius The radius of corner.
* @return the round corner bitmap with border
*/
public static Bitmap addCornerBorder(final Bitmap src,
@IntRange(from = 1) final int borderSize,
@ColorInt final int color,
@FloatRange(from = 0) final float cornerRadius) {
return addBorder(src, borderSize, color, false, cornerRadius, false);
}
/**
* Return the round corner bitmap with border.
*
* @param src The source of bitmap.
* @param borderSize The size of border.
* @param color The color of border.
* @param cornerRadius The radius of corner.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the round corner bitmap with border
*/
public static Bitmap addCornerBorder(final Bitmap src,
@IntRange(from = 1) final int borderSize,
@ColorInt final int color,
@FloatRange(from = 0) final float cornerRadius,
final boolean recycle) {
return addBorder(src, borderSize, color, false, cornerRadius, recycle);
}
/**
* Return the round bitmap with border.
*
* @param src The source of bitmap.
* @param borderSize The size of border.
* @param color The color of border.
* @return the round bitmap with border
*/
public static Bitmap addCircleBorder(final Bitmap src,
@IntRange(from = 1) final int borderSize,
@ColorInt final int color) {
return addBorder(src, borderSize, color, true, 0, false);
}
/**
* Return the round bitmap with border.
*
* @param src The source of bitmap.
* @param borderSize The size of border.
* @param color The color of border.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the round bitmap with border
*/
public static Bitmap addCircleBorder(final Bitmap src,
@IntRange(from = 1) final int borderSize,
@ColorInt final int color,
final boolean recycle) {
return addBorder(src, borderSize, color, true, 0, recycle);
}
/**
* Return the bitmap with border.
*
* @param src The source of bitmap.
* @param borderSize The size of border.
* @param color The color of border.
* @param isCircle True to draw circle, false to draw corner.
* @param cornerRadius The radius of corner.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the bitmap with border
*/
private static Bitmap addBorder(final Bitmap src,
@IntRange(from = 1) final int borderSize,
@ColorInt final int color,
final boolean isCircle,
final float cornerRadius,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
Bitmap ret = recycle ? src : src.copy(src.getConfig(), true);
int width = ret.getWidth();
int height = ret.getHeight();
Canvas canvas = new Canvas(ret);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(color);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(borderSize);
if (isCircle) {
float radius = Math.min(width, height) / 2f - borderSize / 2f;
canvas.drawCircle(width / 2f, height / 2f, radius, paint);
} else {
int halfBorderSize = borderSize >> 1;
RectF rectF = new RectF(halfBorderSize, halfBorderSize,
width - halfBorderSize, height - halfBorderSize);
canvas.drawRoundRect(rectF, cornerRadius, cornerRadius, paint);
}
return ret;
}
/**
* Return the bitmap with reflection.
*
* @param src The source of bitmap.
* @param reflectionHeight The height of reflection.
* @return the bitmap with reflection
*/
public static Bitmap addReflection(final Bitmap src, final int reflectionHeight) {
return addReflection(src, reflectionHeight, false);
}
/**
* Return the bitmap with reflection.
*
* @param src The source of bitmap.
* @param reflectionHeight The height of reflection.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the bitmap with reflection
*/
public static Bitmap addReflection(final Bitmap src,
final int reflectionHeight,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
final int REFLECTION_GAP = 0;
int srcWidth = src.getWidth();
int srcHeight = src.getHeight();
Matrix matrix = new Matrix();
matrix.preScale(1, -1);
Bitmap reflectionBitmap = Bitmap.createBitmap(src, 0, srcHeight - reflectionHeight,
srcWidth, reflectionHeight, matrix, false);
Bitmap ret = Bitmap.createBitmap(srcWidth, srcHeight + reflectionHeight, src.getConfig());
Canvas canvas = new Canvas(ret);
canvas.drawBitmap(src, 0, 0, null);
canvas.drawBitmap(reflectionBitmap, 0, srcHeight + REFLECTION_GAP, null);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
LinearGradient shader = new LinearGradient(
0, srcHeight,
0, ret.getHeight() + REFLECTION_GAP,
0x70FFFFFF,
0x00FFFFFF,
Shader.TileMode.MIRROR);
paint.setShader(shader);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
canvas.drawRect(0, srcHeight + REFLECTION_GAP, srcWidth, ret.getHeight(), paint);
if (!reflectionBitmap.isRecycled()) reflectionBitmap.recycle();
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the bitmap with text watermarking.
*
* @param src The source of bitmap.
* @param content The content of text.
* @param textSize The size of text.
* @param color The color of text.
* @param x The x coordinate of the first pixel.
* @param y The y coordinate of the first pixel.
* @return the bitmap with text watermarking
*/
public static Bitmap addTextWatermark(final Bitmap src,
final String content,
final int textSize,
@ColorInt final int color,
final float x,
final float y) {
return addTextWatermark(src, content, textSize, color, x, y, false);
}
/**
* Return the bitmap with text watermarking.
*
* @param src The source of bitmap.
* @param content The content of text.
* @param textSize The size of text.
* @param color The color of text.
* @param x The x coordinate of the first pixel.
* @param y The y coordinate of the first pixel.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the bitmap with text watermarking
*/
public static Bitmap addTextWatermark(final Bitmap src,
final String content,
final float textSize,
@ColorInt final int color,
final float x,
final float y,
final boolean recycle) {
if (isEmptyBitmap(src) || content == null) return null;
Bitmap ret = src.copy(src.getConfig(), true);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
Canvas canvas = new Canvas(ret);
paint.setColor(color);
paint.setTextSize(textSize);
Rect bounds = new Rect();
paint.getTextBounds(content, 0, content.length(), bounds);
canvas.drawText(content, x, y + textSize, paint);
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the bitmap with image watermarking.
*
* @param src The source of bitmap.
* @param watermark The image watermarking.
* @param x The x coordinate of the first pixel.
* @param y The y coordinate of the first pixel.
* @param alpha The alpha of watermark.
* @return the bitmap with image watermarking
*/
public static Bitmap addImageWatermark(final Bitmap src,
final Bitmap watermark,
final int x, final int y,
final int alpha) {
return addImageWatermark(src, watermark, x, y, alpha, false);
}
/**
* Return the bitmap with image watermarking.
*
* @param src The source of bitmap.
* @param watermark The image watermarking.
* @param x The x coordinate of the first pixel.
* @param y The y coordinate of the first pixel.
* @param alpha The alpha of watermark.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the bitmap with image watermarking
*/
public static Bitmap addImageWatermark(final Bitmap src,
final Bitmap watermark,
final int x,
final int y,
final int alpha,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
Bitmap ret = src.copy(src.getConfig(), true);
if (!isEmptyBitmap(watermark)) {
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
Canvas canvas = new Canvas(ret);
paint.setAlpha(alpha);
canvas.drawBitmap(watermark, x, y, paint);
}
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the alpha bitmap.
*
* @param src The source of bitmap.
* @return the alpha bitmap
*/
public static Bitmap toAlpha(final Bitmap src) {
return toAlpha(src, false);
}
/**
* Return the alpha bitmap.
*
* @param src The source of bitmap.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the alpha bitmap
*/
public static Bitmap toAlpha(final Bitmap src, final Boolean recycle) {
if (isEmptyBitmap(src)) return null;
Bitmap ret = src.extractAlpha();
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the gray bitmap.
*
* @param src The source of bitmap.
* @return the gray bitmap
*/
public static Bitmap toGray(final Bitmap src) {
return toGray(src, false);
}
/**
* Return the gray bitmap.
*
* @param src The source of bitmap.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the gray bitmap
*/
public static Bitmap toGray(final Bitmap src, final boolean recycle) {
if (isEmptyBitmap(src)) return null;
Bitmap ret = Bitmap.createBitmap(src.getWidth(), src.getHeight(), src.getConfig());
Canvas canvas = new Canvas(ret);
Paint paint = new Paint();
ColorMatrix colorMatrix = new ColorMatrix();
colorMatrix.setSaturation(0);
ColorMatrixColorFilter colorMatrixColorFilter = new ColorMatrixColorFilter(colorMatrix);
paint.setColorFilter(colorMatrixColorFilter);
canvas.drawBitmap(src, 0, 0, paint);
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the blur bitmap fast.
* <p>zoom out, blur, zoom in</p>
*
* @param src The source of bitmap.
* @param scale The scale(0...1).
* @param radius The radius(0...25).
* @return the blur bitmap
*/
public static Bitmap fastBlur(final Bitmap src,
@FloatRange(
from = 0, to = 1, fromInclusive = false
) final float scale,
@FloatRange(
from = 0, to = 25, fromInclusive = false
) final float radius) {
return fastBlur(src, scale, radius, false);
}
/**
* Return the blur bitmap fast.
* <p>zoom out, blur, zoom in</p>
*
* @param src The source of bitmap.
* @param scale The scale(0...1).
* @param radius The radius(0...25).
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the blur bitmap
*/
public static Bitmap fastBlur(final Bitmap src,
@FloatRange(
from = 0, to = 1, fromInclusive = false
) final float scale,
@FloatRange(
from = 0, to = 25, fromInclusive = false
) final float radius,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
int width = src.getWidth();
int height = src.getHeight();
Matrix matrix = new Matrix();
matrix.setScale(scale, scale);
Bitmap scaleBitmap =
Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);
Canvas canvas = new Canvas();
PorterDuffColorFilter filter = new PorterDuffColorFilter(
Color.TRANSPARENT, PorterDuff.Mode.SRC_ATOP);
paint.setColorFilter(filter);
canvas.scale(scale, scale);
canvas.drawBitmap(scaleBitmap, 0, 0, paint);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
scaleBitmap = renderScriptBlur(scaleBitmap, radius, recycle);
} else {
scaleBitmap = stackBlur(scaleBitmap, (int) radius, recycle);
}
if (scale == 1) {
if (recycle && !src.isRecycled()) src.recycle();
return scaleBitmap;
}
Bitmap ret = Bitmap.createScaledBitmap(scaleBitmap, width, height, true);
if (!scaleBitmap.isRecycled()) scaleBitmap.recycle();
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the blur bitmap using render script.
*
* @param src The source of bitmap.
* @param radius The radius(0...25).
* @return the blur bitmap
*/
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static Bitmap renderScriptBlur(final Bitmap src,
@FloatRange(
from = 0, to = 25, fromInclusive = false
) final float radius) {
return renderScriptBlur(src, radius, false);
}
/**
* Return the blur bitmap using render script.
*
* @param src The source of bitmap.
* @param radius The radius(0...25).
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the blur bitmap
*/
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static Bitmap renderScriptBlur(final Bitmap src,
@FloatRange(
from = 0, to = 25, fromInclusive = false
) final float radius,
final boolean recycle) {
RenderScript rs = null;
Bitmap ret = recycle ? src : src.copy(src.getConfig(), true);
try {
rs = RenderScript.create(MPUtils.getApp());
rs.setMessageHandler(new RenderScript.RSMessageHandler());
Allocation input = Allocation.createFromBitmap(rs,
ret,
Allocation.MipmapControl.MIPMAP_NONE,
Allocation.USAGE_SCRIPT);
Allocation output = Allocation.createTyped(rs, input.getType());
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
blurScript.setInput(input);
blurScript.setRadius(radius);
blurScript.forEach(output);
output.copyTo(ret);
} finally {
if (rs != null) {
rs.destroy();
}
}
return ret;
}
/**
* Return the blur bitmap using stack.
*
* @param src The source of bitmap.
* @param radius The radius(0...25).
* @return the blur bitmap
*/
public static Bitmap stackBlur(final Bitmap src, final int radius) {
return stackBlur(src, radius, false);
}
/**
* Return the blur bitmap using stack.
*
* @param src The source of bitmap.
* @param radius The radius(0...25).
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the blur bitmap
*/
public static Bitmap stackBlur(final Bitmap src, int radius, final boolean recycle) {
Bitmap ret = recycle ? src : src.copy(src.getConfig(), true);
if (radius < 1) {
radius = 1;
}
int w = ret.getWidth();
int h = ret.getHeight();
int[] pix = new int[w * h];
ret.getPixels(pix, 0, w, 0, 0, w, h);
int wm = w - 1;
int hm = h - 1;
int wh = w * h;
int div = radius + radius + 1;
int r[] = new int[wh];
int g[] = new int[wh];
int b[] = new int[wh];
int rsum, gsum, bsum, x, y, i, p, yp, yi, yw;
int vmin[] = new int[Math.max(w, h)];
int divsum = (div + 1) >> 1;
divsum *= divsum;
int dv[] = new int[256 * divsum];
for (i = 0; i < 256 * divsum; i++) {
dv[i] = (i / divsum);
}
yw = yi = 0;
int[][] stack = new int[div][3];
int stackpointer;
int stackstart;
int[] sir;
int rbs;
int r1 = radius + 1;
int routsum, goutsum, boutsum;
int rinsum, ginsum, binsum;
for (y = 0; y < h; y++) {
rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
for (i = -radius; i <= radius; i++) {
p = pix[yi + Math.min(wm, Math.max(i, 0))];
sir = stack[i + radius];
sir[0] = (p & 0xff0000) >> 16;
sir[1] = (p & 0x00ff00) >> 8;
sir[2] = (p & 0x0000ff);
rbs = r1 - Math.abs(i);
rsum += sir[0] * rbs;
gsum += sir[1] * rbs;
bsum += sir[2] * rbs;
if (i > 0) {
rinsum += sir[0];
ginsum += sir[1];
binsum += sir[2];
} else {
routsum += sir[0];
goutsum += sir[1];
boutsum += sir[2];
}
}
stackpointer = radius;
for (x = 0; x < w; x++) {
r[yi] = dv[rsum];
g[yi] = dv[gsum];
b[yi] = dv[bsum];
rsum -= routsum;
gsum -= goutsum;
bsum -= boutsum;
stackstart = stackpointer - radius + div;
sir = stack[stackstart % div];
routsum -= sir[0];
goutsum -= sir[1];
boutsum -= sir[2];
if (y == 0) {
vmin[x] = Math.min(x + radius + 1, wm);
}
p = pix[yw + vmin[x]];
sir[0] = (p & 0xff0000) >> 16;
sir[1] = (p & 0x00ff00) >> 8;
sir[2] = (p & 0x0000ff);
rinsum += sir[0];
ginsum += sir[1];
binsum += sir[2];
rsum += rinsum;
gsum += ginsum;
bsum += binsum;
stackpointer = (stackpointer + 1) % div;
sir = stack[(stackpointer) % div];
routsum += sir[0];
goutsum += sir[1];
boutsum += sir[2];
rinsum -= sir[0];
ginsum -= sir[1];
binsum -= sir[2];
yi++;
}
yw += w;
}
for (x = 0; x < w; x++) {
rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
yp = -radius * w;
for (i = -radius; i <= radius; i++) {
yi = Math.max(0, yp) + x;
sir = stack[i + radius];
sir[0] = r[yi];
sir[1] = g[yi];
sir[2] = b[yi];
rbs = r1 - Math.abs(i);
rsum += r[yi] * rbs;
gsum += g[yi] * rbs;
bsum += b[yi] * rbs;
if (i > 0) {
rinsum += sir[0];
ginsum += sir[1];
binsum += sir[2];
} else {
routsum += sir[0];
goutsum += sir[1];
boutsum += sir[2];
}
if (i < hm) {
yp += w;
}
}
yi = x;
stackpointer = radius;
for (y = 0; y < h; y++) {
// Preserve alpha channel: ( 0xff000000 & pix[yi] )
pix[yi] = (0xff000000 & pix[yi]) | (dv[rsum] << 16) | (dv[gsum] << 8) | dv[bsum];
rsum -= routsum;
gsum -= goutsum;
bsum -= boutsum;
stackstart = stackpointer - radius + div;
sir = stack[stackstart % div];
routsum -= sir[0];
goutsum -= sir[1];
boutsum -= sir[2];
if (x == 0) {
vmin[y] = Math.min(y + r1, hm) * w;
}
p = x + vmin[y];
sir[0] = r[p];
sir[1] = g[p];
sir[2] = b[p];
rinsum += sir[0];
ginsum += sir[1];
binsum += sir[2];
rsum += rinsum;
gsum += ginsum;
bsum += binsum;
stackpointer = (stackpointer + 1) % div;
sir = stack[stackpointer];
routsum += sir[0];
goutsum += sir[1];
boutsum += sir[2];
rinsum -= sir[0];
ginsum -= sir[1];
binsum -= sir[2];
yi += w;
}
}
ret.setPixels(pix, 0, w, 0, 0, w, h);
return ret;
}
/**
* Save the bitmap.
*
* @param src The source of bitmap.
* @param filePath The path of file.
* @param format The format of the image.
* @return {@code true}: success<br>{@code false}: fail
*/
public static boolean save(final Bitmap src,
final String filePath,
final CompressFormat format) {
return save(src, getFileByPath(filePath), format, false);
}
/**
* Save the bitmap.
*
* @param src The source of bitmap.
* @param file The file.
* @param format The format of the image.
* @return {@code true}: success<br>{@code false}: fail
*/
public static boolean save(final Bitmap src, final File file, final CompressFormat format) {
return save(src, file, format, false);
}
/**
* Save the bitmap.
*
* @param src The source of bitmap.
* @param filePath The path of file.
* @param format The format of the image.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return {@code true}: success<br>{@code false}: fail
*/
public static boolean save(final Bitmap src,
final String filePath,
final CompressFormat format,
final boolean recycle) {
return save(src, getFileByPath(filePath), format, recycle);
}
/**
* Save the bitmap.
*
* @param src The source of bitmap.
* @param file The file.
* @param format The format of the image.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return {@code true}: success<br>{@code false}: fail
*/
public static boolean save(final Bitmap src,
final File file,
final CompressFormat format,
final boolean recycle) {
if (isEmptyBitmap(src) || !createFileByDeleteOldFile(file)) return false;
OutputStream os = null;
boolean ret = false;
try {
os = new BufferedOutputStream(new FileOutputStream(file));
ret = src.compress(format, 100, os);
if (recycle && !src.isRecycled()) src.recycle();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (os != null) {
os.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return ret;
}
/**
* Return whether it is a image according to the file name.
*
* @param file The file.
* @return {@code true}: yes<br>{@code false}: no
*/
public static boolean isImage(final File file) {
return file != null && isImage(file.getPath());
}
/**
* Return whether it is a image according to the file name.
*
* @param filePath The path of file.
* @return {@code true}: yes<br>{@code false}: no
*/
public static boolean isImage(final String filePath) {
String path = filePath.toUpperCase();
return path.endsWith(".PNG") || path.endsWith(".JPG")
|| path.endsWith(".JPEG") || path.endsWith(".BMP")
|| path.endsWith(".GIF") || path.endsWith(".WEBP");
}
/**
* Return the type of image.
*
* @param filePath The path of file.
* @return the type of image
*/
public static String getImageType(final String filePath) {
return getImageType(getFileByPath(filePath));
}
/**
* Return the type of image.
*
* @param file The file.
* @return the type of image
*/
public static String getImageType(final File file) {
if (file == null) return "";
InputStream is = null;
try {
is = new FileInputStream(file);
String type = getImageType(is);
if (type != null) {
return type;
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (is != null) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return getFileExtension(file.getAbsolutePath()).toUpperCase();
}
private static String getFileExtension(final String filePath) {
if (isSpace(filePath)) return filePath;
int lastPoi = filePath.lastIndexOf('.');
int lastSep = filePath.lastIndexOf(File.separator);
if (lastPoi == -1 || lastSep >= lastPoi) return "";
return filePath.substring(lastPoi + 1);
}
private static String getImageType(final InputStream is) {
if (is == null) return null;
try {
byte[] bytes = new byte[8];
return is.read(bytes, 0, 8) != -1 ? getImageType(bytes) : null;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
private static String getImageType(final byte[] bytes) {
if (isJPEG(bytes)) return "JPEG";
if (isGIF(bytes)) return "GIF";
if (isPNG(bytes)) return "PNG";
if (isBMP(bytes)) return "BMP";
return null;
}
private static boolean isJPEG(final byte[] b) {
return b.length >= 2
&& (b[0] == (byte) 0xFF) && (b[1] == (byte) 0xD8);
}
private static boolean isGIF(final byte[] b) {
return b.length >= 6
&& b[0] == 'G' && b[1] == 'I'
&& b[2] == 'F' && b[3] == '8'
&& (b[4] == '7' || b[4] == '9') && b[5] == 'a';
}
private static boolean isPNG(final byte[] b) {
return b.length >= 8
&& (b[0] == (byte) 137 && b[1] == (byte) 80
&& b[2] == (byte) 78 && b[3] == (byte) 71
&& b[4] == (byte) 13 && b[5] == (byte) 10
&& b[6] == (byte) 26 && b[7] == (byte) 10);
}
private static boolean isBMP(final byte[] b) {
return b.length >= 2
&& (b[0] == 0x42) && (b[1] == 0x4d);
}
private static boolean isEmptyBitmap(final Bitmap src) {
return src == null || src.getWidth() == 0 || src.getHeight() == 0;
}
///////////////////////////////////////////////////////////////////////////
// about compress
///////////////////////////////////////////////////////////////////////////
/**
* Return the compressed bitmap using scale.
*
* @param src The source of bitmap.
* @param newWidth The new width.
* @param newHeight The new height.
* @return the compressed bitmap
*/
public static Bitmap compressByScale(final Bitmap src,
final int newWidth,
final int newHeight) {
return scale(src, newWidth, newHeight, false);
}
/**
* Return the compressed bitmap using scale.
*
* @param src The source of bitmap.
* @param newWidth The new width.
* @param newHeight The new height.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the compressed bitmap
*/
public static Bitmap compressByScale(final Bitmap src,
final int newWidth,
final int newHeight,
final boolean recycle) {
return scale(src, newWidth, newHeight, recycle);
}
/**
* Return the compressed bitmap using scale.
*
* @param src The source of bitmap.
* @param scaleWidth The scale of width.
* @param scaleHeight The scale of height.
* @return the compressed bitmap
*/
public static Bitmap compressByScale(final Bitmap src,
final float scaleWidth,
final float scaleHeight) {
return scale(src, scaleWidth, scaleHeight, false);
}
/**
* Return the compressed bitmap using scale.
*
* @param src The source of bitmap.
* @param scaleWidth The scale of width.
* @param scaleHeight The scale of height.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return he compressed bitmap
*/
public static Bitmap compressByScale(final Bitmap src,
final float scaleWidth,
final float scaleHeight,
final boolean recycle) {
return scale(src, scaleWidth, scaleHeight, recycle);
}
/**
* Return the compressed bitmap using quality.
*
* @param src The source of bitmap.
* @param quality The quality.
* @return the compressed bitmap
*/
public static Bitmap compressByQuality(final Bitmap src,
@IntRange(from = 0, to = 100) final int quality) {
return compressByQuality(src, quality, false);
}
/**
* Return the compressed bitmap using quality.
*
* @param src The source of bitmap.
* @param quality The quality.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the compressed bitmap
*/
public static Bitmap compressByQuality(final Bitmap src,
@IntRange(from = 0, to = 100) final int quality,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
src.compress(CompressFormat.JPEG, quality, baos);
byte[] bytes = baos.toByteArray();
if (recycle && !src.isRecycled()) src.recycle();
return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
}
/**
* Return the compressed bitmap using quality.
*
* @param src The source of bitmap.
* @param maxByteSize The maximum size of byte.
* @return the compressed bitmap
*/
public static Bitmap compressByQuality(final Bitmap src, final long maxByteSize) {
return compressByQuality(src, maxByteSize, false);
}
/**
* Return the compressed bitmap using quality.
*
* @param src The source of bitmap.
* @param maxByteSize The maximum size of byte.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the compressed bitmap
*/
public static Bitmap compressByQuality(final Bitmap src,
final long maxByteSize,
final boolean recycle) {
if (isEmptyBitmap(src) || maxByteSize <= 0) return null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
src.compress(CompressFormat.JPEG, 100, baos);
byte[] bytes;
if (baos.size() <= maxByteSize) {
bytes = baos.toByteArray();
} else {
baos.reset();
src.compress(CompressFormat.JPEG, 0, baos);
if (baos.size() >= maxByteSize) {
bytes = baos.toByteArray();
} else {
// find the best quality using binary search
int st = 0;
int end = 100;
int mid = 0;
while (st < end) {
mid = (st + end) / 2;
baos.reset();
src.compress(CompressFormat.JPEG, mid, baos);
int len = baos.size();
if (len == maxByteSize) {
break;
} else if (len > maxByteSize) {
end = mid - 1;
} else {
st = mid + 1;
}
}
if (end == mid - 1) {
baos.reset();
src.compress(CompressFormat.JPEG, st, baos);
}
bytes = baos.toByteArray();
}
}
if (recycle && !src.isRecycled()) src.recycle();
return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
}
/**
* Return the compressed bitmap using sample size.
*
* @param src The source of bitmap.
* @param sampleSize The sample size.
* @return the compressed bitmap
*/
public static Bitmap compressBySampleSize(final Bitmap src, final int sampleSize) {
return compressBySampleSize(src, sampleSize, false);
}
/**
* Return the compressed bitmap using sample size.
*
* @param src The source of bitmap.
* @param sampleSize The sample size.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the compressed bitmap
*/
public static Bitmap compressBySampleSize(final Bitmap src,
final int sampleSize,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = sampleSize;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
src.compress(CompressFormat.JPEG, 100, baos);
byte[] bytes = baos.toByteArray();
if (recycle && !src.isRecycled()) src.recycle();
return BitmapFactory.decodeByteArray(bytes, 0, bytes.length, options);
}
/**
* Return the compressed bitmap using sample size.
*
* @param src The source of bitmap.
* @param maxWidth The maximum width.
* @param maxHeight The maximum height.
* @return the compressed bitmap
*/
public static Bitmap compressBySampleSize(final Bitmap src,
final int maxWidth,
final int maxHeight) {
return compressBySampleSize(src, maxWidth, maxHeight, false);
}
/**
* Return the compressed bitmap using sample size.
*
* @param src The source of bitmap.
* @param maxWidth The maximum width.
* @param maxHeight The maximum height.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the compressed bitmap
*/
public static Bitmap compressBySampleSize(final Bitmap src,
final int maxWidth,
final int maxHeight,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
src.compress(CompressFormat.JPEG, 100, baos);
byte[] bytes = baos.toByteArray();
BitmapFactory.decodeByteArray(bytes, 0, bytes.length, options);
options.inSampleSize = calculateInSampleSize(options, maxWidth, maxHeight);
options.inJustDecodeBounds = false;
if (recycle && !src.isRecycled()) src.recycle();
return BitmapFactory.decodeByteArray(bytes, 0, bytes.length, options);
}
/**
* Return the sample size.
*
* @param options The options.
* @param maxWidth The maximum width.
* @param maxHeight The maximum height.
* @return the sample size
*/
private static int calculateInSampleSize(final BitmapFactory.Options options,
final int maxWidth,
final int maxHeight) {
int height = options.outHeight;
int width = options.outWidth;
int inSampleSize = 1;
while ((width >>= 1) >= maxWidth && (height >>= 1) >= maxHeight) {
inSampleSize <<= 1;
}
return inSampleSize;
}
///////////////////////////////////////////////////////////////////////////
// other utils methods
///////////////////////////////////////////////////////////////////////////
private static File getFileByPath(final String filePath) {
return isSpace(filePath) ? null : new File(filePath);
}
private static boolean createFileByDeleteOldFile(final File file) {
if (file == null) return false;
if (file.exists() && !file.delete()) return false;
if (!createOrExistsDir(file.getParentFile())) return false;
try {
return file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
private static boolean createOrExistsDir(final File file) {
return file != null && (file.exists() ? file.isDirectory() : file.mkdirs());
}
private static boolean isSpace(final String s) {
if (s == null) return true;
for (int i = 0, len = s.length(); i < len; ++i) {
if (!Character.isWhitespace(s.charAt(i))) {
return false;
}
}
return true;
}
private static byte[] input2Byte(final InputStream is) {
if (is == null) return null;
try {
ByteArrayOutputStream os = new ByteArrayOutputStream();
byte[] b = new byte[1024];
int len;
while ((len = is.read(b, 0, 1024)) != -1) {
os.write(b, 0, len);
}
return os.toByteArray();
} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@TargetApi(19)
public static String getImageAbsolutePath(Context context, Uri imageUri) {
if (context == null || imageUri == null)
return null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && DocumentsContract.isDocumentUri(context, imageUri)) {
if (isExternalStorageDocument(imageUri)) {
String docId = DocumentsContract.getDocumentId(imageUri);
String[] split = docId.split(":");
String type = split[0];
if ("primary".equalsIgnoreCase(type)) {
return Environment.getExternalStorageDirectory() + "/" + split[1];
}
} else if (isDownloadsDocument(imageUri)) {
String id = DocumentsContract.getDocumentId(imageUri);
Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
return getDataColumn(context, contentUri, null, null);
} else if (isMediaDocument(imageUri)) {
String docId = DocumentsContract.getDocumentId(imageUri);
String[] split = docId.split(":");
String type = split[0];
Uri contentUri = null;
if ("image".equals(type)) {
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
} else if ("video".equals(type)) {
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
} else if ("audio".equals(type)) {
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
}
String selection = MediaStore.Images.Media._ID + "=?";
String[] selectionArgs = new String[]{split[1]};
return getDataColumn(context, contentUri, selection, selectionArgs);
}
} // MediaStore (and general)
else if ("content".equalsIgnoreCase(imageUri.getScheme())) {
// Return the remote address
if (isGooglePhotosUri(imageUri))
return imageUri.getLastPathSegment();
return getDataColumn(context, imageUri, null, null);
}
// File
else if ("file".equalsIgnoreCase(imageUri.getScheme())) {
return imageUri.getPath();
}
return null;
}
public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {
Cursor cursor = null;
String column = MediaStore.Images.Media.DATA;
String[] projection = {column};
try {
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
if (cursor != null && cursor.moveToFirst()) {
int index = cursor.getColumnIndexOrThrow(column);
return cursor.getString(index);
}
} finally {
if (cursor != null)
cursor.close();
}
return null;
}
/**
* @param uri The Uri to check.
* @return Whether the Uri authority is ExternalStorageProvider.
*/
public static boolean isExternalStorageDocument(Uri uri) {
return "com.android.externalstorage.documents".equals(uri.getAuthority());
}
/**
* @param uri The Uri to check.
* @return Whether the Uri authority is DownloadsProvider.
*/
public static boolean isDownloadsDocument(Uri uri) {
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
}
/**
* @param uri The Uri to check.
* @return Whether the Uri authority is MediaProvider.
*/
public static boolean isMediaDocument(Uri uri) {
return "com.android.providers.media.documents".equals(uri.getAuthority());
}
/**
* @param uri The Uri to check.
* @return Whether the Uri authority is Google Photos.
*/
public static boolean isGooglePhotosUri(Uri uri) {
return "com.google.android.apps.photos.content".equals(uri.getAuthority());
}
//byte数组到图片
public static void byte2image(byte[] data, String path) {
if (data.length < 3 || path.equals("")) return;
try {
FileOutputStream imageOutput = new FileOutputStream(new File(path));
imageOutput.write(data, 0, data.length);
imageOutput.close();
System.out.println("Make Picture success,Please find image in " + path);
} catch (Exception ex) {
System.out.println("Exception: " + ex);
ex.printStackTrace();
}
}
/**
* Store bitmap into specified image path
*
* @param bitmap
* @param outPath
* @throws FileNotFoundException
*/
public static void storeImage(Context context, Bitmap bitmap, String outPath) {
File f = new File(outPath);
if (f.exists()) {
f.delete();
}
try {
FileOutputStream out = new FileOutputStream(f);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.flush();
out.close();
LogUtils.d("storeImage", "已经保存");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
Uri data = Uri.fromFile(new File(outPath));
mediaScanIntent.setData(data);
context.sendBroadcast(mediaScanIntent);
}
/**
* Store bitmap into specified image path
*
* @param bitmap
* @param outPath
* @throws FileNotFoundException
*/
public static void storeImage(Context context, byte[] bitmap, String outPath) {
File f = new File(outPath);
if (f.exists()) {
f.delete();
}
try {
File file = new File(outPath);
FileOutputStream fops = new FileOutputStream(file);
fops.write(bitmap);
fops.flush();
fops.close();
LogUtils.d("storeImage", "已经保存");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
Uri data = Uri.fromFile(new File(outPath));
mediaScanIntent.setData(data);
context.sendBroadcast(mediaScanIntent);
}
/**
* Store bitmap into specified image path
*
* @param bitmap
* @param outPath
* @throws FileNotFoundException
*/
public static void storeImage(Bitmap bitmap, String outPath) {
File f = new File(outPath);
try {
FileOutputStream out = new FileOutputStream(f);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
out.flush();
out.close();
LogUtils.d("storeImage", "已经保存");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Compress image by pixel, this will modify image width/height.
* Used to get thumbnail
*
* @param imgPath image path
* @param pixelW target pixel of width
* @param pixelH target pixel of height
* @return
*/
public static Bitmap ratio(String imgPath, float pixelW, float pixelH) {
BitmapFactory.Options newOpts = new BitmapFactory.Options();
// 开始读入图片,此时把options.inJustDecodeBounds 设回true,即只读边不读内容
newOpts.inJustDecodeBounds = true;
newOpts.inPreferredConfig = Bitmap.Config.RGB_565;
// Get bitmap info, but notice that bitmap is null now
Bitmap bitmap = BitmapFactory.decodeFile(imgPath, newOpts);
newOpts.inJustDecodeBounds = false;
int w = newOpts.outWidth;
int h = newOpts.outHeight;
// 想要缩放的目标尺寸
float hh = pixelH;// 设置高度为240f时,可以明显看到图片缩小了
float ww = pixelW;// 设置宽度为120f,可以明显看到图片缩小了
// 缩放比。由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可
int be = 1;//be=1表示不缩放
if (w > h && w > ww) {//如果宽度大的话根据宽度固定大小缩放
be = (int) (newOpts.outWidth / ww);
} else if (w < h && h > hh) {//如果高度高的话根据宽度固定大小缩放
be = (int) (newOpts.outHeight / hh);
}
if (be <= 0) be = 1;
newOpts.inSampleSize = be;//设置缩放比例
// 开始压缩图片,注意此时已经把options.inJustDecodeBounds 设回false了
bitmap = BitmapFactory.decodeFile(imgPath, newOpts);
// 压缩好比例大小后再进行质量压缩
// return compress(bitmap, maxSize); // 这里再进行质量压缩的意义不大,反而耗资源,删除
return bitmap;
}
/**
* Compress image by size, this will modify image width/height.
* Used to get thumbnail
*
* @param image
* @param pixelW target pixel of width
* @param pixelH target pixel of height
* @return
*/
public static Bitmap ratio(Bitmap image, float pixelW, float pixelH) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 100, os);
if (os.toByteArray().length / 1024 > 1024) {//判断如果图片大于1M,进行压缩避免在生成图片(BitmapFactory.decodeStream)时溢出
os.reset();//重置baos即清空baos
image.compress(Bitmap.CompressFormat.JPEG, 50, os);//这里压缩50%,把压缩后的数据存放到baos中
}
ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
BitmapFactory.Options newOpts = new BitmapFactory.Options();
//开始读入图片,此时把options.inJustDecodeBounds 设回true了
newOpts.inJustDecodeBounds = true;
newOpts.inPreferredConfig = Bitmap.Config.RGB_565;
Bitmap bitmap = BitmapFactory.decodeStream(is, null, newOpts);
newOpts.inJustDecodeBounds = false;
int w = newOpts.outWidth;
int h = newOpts.outHeight;
float hh = pixelH;// 设置高度为240f时,可以明显看到图片缩小了
float ww = pixelW;// 设置宽度为120f,可以明显看到图片缩小了
//缩放比。由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可
int be = 1;//be=1表示不缩放
if (w > h && w > ww) {//如果宽度大的话根据宽度固定大小缩放
be = (int) (newOpts.outWidth / ww);
} else if (w < h && h > hh) {//如果高度高的话根据宽度固定大小缩放
be = (int) (newOpts.outHeight / hh);
}
if (be <= 0) be = 1;
newOpts.inSampleSize = be;//设置缩放比例
//重新读入图片,注意此时已经把options.inJustDecodeBounds 设回false了
is = new ByteArrayInputStream(os.toByteArray());
bitmap = BitmapFactory.decodeStream(is, null, newOpts);
//压缩好比例大小后再进行质量压缩
// return compress(bitmap, maxSize); // 这里再进行质量压缩的意义不大,反而耗资源,删除
return bitmap;
}
/**
* Compress by quality, and generate image to the path specified
*
* @param image
* @param outPath
* @param maxSize target will be compressed to be smaller than this size.(kb)
* @throws IOException
*/
public static void compressAndGenImage(Bitmap image, String outPath, int maxSize) throws IOException {
ByteArrayOutputStream os = new ByteArrayOutputStream();
// scale
int options = 100;
// Store the bitmap into output stream(no compress)
image.compress(Bitmap.CompressFormat.JPEG, options, os);
// Compress by loop
while (os.toByteArray().length / 1024 > maxSize) {
// Clean up os
os.reset();
// interval 10
options -= 10;
Log.e("options", "options : " + options);
if (options < 10) {
return;
}
image.compress(Bitmap.CompressFormat.JPEG, options, os);
}
// Generate compressed image file
FileOutputStream fos = new FileOutputStream(outPath);
fos.write(os.toByteArray());
fos.flush();
fos.close();
}
private static int compressRatio(int currentKb, int targetKb) {
int ratio;
ratio = (int) Math.max(10, currentKb / Math.sqrt((double) currentKb / targetKb));
return ratio;
}
/**
* Compress by quality, and generate image to the path specified
*
* @param imgPath
* @param outPath
* @param maxSize target will be compressed to be smaller than this size.(kb)
* @param needsDelete Whether delete original file after compress
* @throws IOException
*/
public static void compressAndGenImage(String imgPath, String outPath, int maxSize, boolean needsDelete) throws IOException {
compressAndGenImage(getBitmap(imgPath), outPath, maxSize);
// Delete original file
if (needsDelete) {
File file = new File(imgPath);
if (file.exists()) {
file.delete();
}
}
}
/**
* Ratio and generate thumb to the path specified
*
* @param image
* @param outPath
* @param pixelW target pixel of width
* @param pixelH target pixel of height
* @throws FileNotFoundException
*/
public static void ratioAndGenThumb(Bitmap image, String outPath, float pixelW, float pixelH) throws FileNotFoundException {
Bitmap bitmap = ratio(image, pixelW, pixelH);
storeImage(bitmap, outPath);
}
/**
* Ratio and generate thumb to the path specified
*
* @param imgPath
* @param outPath
* @param pixelW target pixel of width
* @param pixelH target pixel of height
* @param needsDelete Whether delete original file after compress
* @throws FileNotFoundException
*/
public static void ratioAndGenThumb(String imgPath, String outPath, float pixelW, float pixelH, boolean needsDelete) throws FileNotFoundException {
Bitmap bitmap = ratio(imgPath, pixelW, pixelH);
storeImage(bitmap, outPath);
// Delete original file
if (needsDelete) {
File file = new File(imgPath);
if (file.exists()) {
file.delete();
}
}
}
public static String getRealPathFromContentURI(Context ctx, Uri contentUri) {
String result = "";
if (null != contentUri && !"".equals(contentUri.toString())) {
String scheme = contentUri.getScheme();
if (ContentResolver.SCHEME_FILE.equals(scheme)) {
result = contentUri.getPath();
} else if (ContentResolver.SCHEME_CONTENT.equals(scheme)) {
String[] proj = {MediaStore.Images.Media.DATA};
Cursor cursor = null;
try {
cursor = ctx.getContentResolver().query(contentUri, proj, null, null, null);
int column_index = 0;
if (cursor != null) {
column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
if (cursor.getCount() > 0) {
cursor.moveToFirst();
result = cursor.getString(column_index);
} else {
result = "";
}
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
if (cursor != null) {
cursor.close();
}
}
} else {
result = contentUri.toString();
}
}
return result;
}
public static void savePhotoToSysAlbum(Context context, String path) {
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
Uri data = Uri.fromFile(new File(path));
mediaScanIntent.setData(data);
context.sendBroadcast(mediaScanIntent);
}
public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId,
int reqWidth, int reqHeight) {
// First decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(res, resId, options);
// Calculate inSampleSize
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
return BitmapFactory.decodeResource(res, resId, options);
}
public static Bitmap decodeBitmapFromFile(String path) {
// First decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, options);
// Calculate inSampleSize
options.inSampleSize = 1;
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(path, options);
}
public static Bitmap decodeSampledBitmapFromFile(String path,
int reqWidth, int reqHeight) {
// First decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, options);
// Calculate inSampleSize
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(path, options);
}
public static Bitmap decodeSampledBitmapFromBytes(byte[] data,
int reqWidth, int reqHeight) {
// First decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeByteArray(data, 0, data.length, options);
// Calculate inSampleSize
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
return BitmapFactory.decodeByteArray(data, 0, data.length, options);
}
public static Bitmap compressBitmap(Bitmap image, int maxKb) {
byte[] data = compressImage(image, maxKb);
LogUtils.e("bitmap " + data.length);
ByteArrayInputStream isBm = new ByteArrayInputStream(data);//把压缩后的数据baos存放到ByteArrayInputStream中
return BitmapFactory.decodeStream(isBm, null, null);//把ByteArrayInputStream数据生成图片
}
public static byte[] compressImage(Bitmap image, int maxKb) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int options = 100;
image.compress(Bitmap.CompressFormat.JPEG, options, baos);//质量压缩方法,这里100表示不压缩,把压缩后的数据存放到baos中
while (baos.toByteArray().length / 1024 > maxKb && options > 10) { //循环判断如果压缩后图片是否大于maxKb,大于继续压缩
int de = Math.min(options / 2, 10);
options -= de;
baos.reset();//重置baos即清空baos
image.compress(Bitmap.CompressFormat.JPEG, options, baos);//这里压缩options%,把压缩后的数据存放到baos中
}
return baos.toByteArray();
}
private static byte[] compress(Bitmap image, int resw, int resh) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 100, baos);
if (baos.toByteArray().length / 1024 > 1024) {//判断如果图片大于1M,进行压缩避免在生成图片(BitmapFactory.decodeStream)时溢出
baos.reset();//重置baos即清空baos
image.compress(Bitmap.CompressFormat.JPEG, 50, baos);//这里压缩50%,把压缩后的数据存放到baos中
}
ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray());
BitmapFactory.Options newOpts = new BitmapFactory.Options();
//开始读入图片,此时把options.inJustDecodeBounds 设回true了
newOpts.inJustDecodeBounds = true;
Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, newOpts);
newOpts.inJustDecodeBounds = false;
int w = newOpts.outWidth;
int h = newOpts.outHeight;
//现在主流手机比较多是800*480分辨率,所以高和宽我们设置为
int hh = resh;//这里设置高度为800f
int ww = resw;//这里设置宽度为480f
//缩放比。由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可
int be = 1;//be=1表示不缩放
if (w > h && w > ww) {//如果宽度大的话根据宽度固定大小缩放
be = (int) (newOpts.outWidth / ww);
} else if (w < h && h > hh) {//如果高度高的话根据宽度固定大小缩放
be = (int) (newOpts.outHeight / hh);
}
if (be <= 0)
be = 1;
newOpts.inSampleSize = be;//设置缩放比例
//重新读入图片,注意此时已经把options.inJustDecodeBounds 设回false了
isBm = new ByteArrayInputStream(baos.toByteArray());
bitmap = BitmapFactory.decodeStream(isBm, null, newOpts);
return compressImage(bitmap, 100);//压缩好比例大小后再进行质量压缩
}
/**
* 计算文件大小
*
* @param path
* @return
*/
public static int checkFileSize(String path) {
File filenew = new File(path);
int file_size = Integer.parseInt(String.valueOf(filenew.length() / 1024));
return file_size;
}
public static String getFileType(String filePath) {
return filePath.substring(filePath.lastIndexOf('.') + 1, filePath.length());
}
/**
* 根据给定的宽进行缩放
*
* @param origin 原图
* @param newWidth 新图的宽
* @return new Bitmap
*/
public static Bitmap scaleBitmap(Bitmap origin, int newWidth) {
if (origin == null) {
return null;
}
int width = origin.getWidth();
if (newWidth > width) {
return origin;
}
int height = origin.getHeight();
int newHeight = newWidth * height / width;
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);// 使用后乘
Bitmap newBM = Bitmap.createBitmap(origin, 0, 0, width, height, matrix, false);
if (!origin.isRecycled()) {
origin.recycle();
}
return newBM;
}
}
|
UTF-8
|
Java
| 95,949 |
java
|
ImageUtils.java
|
Java
|
[
{
"context": "java.io.OutputStream;\n\n/**\n * <pre>\n * author: Blankj\n * blog : http://blankj.com\n * time : 2",
"end": 2257,
"score": 0.9996933341026306,
"start": 2251,
"tag": "USERNAME",
"value": "Blankj"
}
] | null |
[] |
package com.mp.basekit.util;
import android.annotation.TargetApi;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.LinearGradient;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.media.ExifInterface;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.ParcelFileDescriptor;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.ScriptIntrinsicBlur;
import android.util.Base64;
import android.util.Log;
import android.view.View;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.FloatRange;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat;
import com.mp.basekit.core.MPApplication;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2016/08/12
* desc : utils about image
* </pre>
*/
public final class ImageUtils {
private ImageUtils() {
throw new UnsupportedOperationException("u can't instantiate me...");
}
/**
* String to bitmap.
*
* @param string
* @return
*/
public static Bitmap string2Bitmap(String string) {
//将字符串转换成Bitmap类型
Bitmap bitmap = null;
try {
byte[] bitmapArray;
bitmapArray = Base64.decode(string, Base64.DEFAULT);
bitmap = BitmapFactory.decodeByteArray(bitmapArray, 0, bitmapArray.length);
} catch (Exception e) {
e.printStackTrace();
}
return bitmap;
}
/**
* Bitmap to bytes.
*
* @param bitmap The bitmap.
* @param format The format of bitmap.
* @return bytes
*/
public static byte[] bitmap2Bytes(final Bitmap bitmap, final CompressFormat format) {
if (bitmap == null) return null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(format, 100, baos);
return baos.toByteArray();
}
/**
* Bytes to bitmap.
*
* @param bytes The bytes.
* @return bitmap
*/
public static Bitmap bytes2Bitmap(final byte[] bytes) {
return (bytes == null || bytes.length == 0)
? null
: BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
}
/**
* Drawable to bitmap.
*
* @param drawable The drawable.
* @return bitmap
*/
public static Bitmap drawable2Bitmap(final Drawable drawable) {
if (drawable instanceof BitmapDrawable) {
BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
if (bitmapDrawable.getBitmap() != null) {
return bitmapDrawable.getBitmap();
}
}
Bitmap bitmap;
if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
bitmap = Bitmap.createBitmap(1, 1,
drawable.getOpacity() != PixelFormat.OPAQUE
? Bitmap.Config.ARGB_8888
: Bitmap.Config.RGB_565);
} else {
bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(),
drawable.getOpacity() != PixelFormat.OPAQUE
? Bitmap.Config.ARGB_8888
: Bitmap.Config.RGB_565);
}
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
return bitmap;
}
/**
* Bitmap to drawable.
*
* @param bitmap The bitmap.
* @return drawable
*/
public static Drawable bitmap2Drawable(final Bitmap bitmap) {
return bitmap == null ? null : new BitmapDrawable(MPUtils.getApp().getResources(), bitmap);
}
/**
* Drawable to bytes.
*
* @param drawable The drawable.
* @param format The format of bitmap.
* @return bytes
*/
public static byte[] drawable2Bytes(final Drawable drawable, final CompressFormat format) {
return drawable == null ? null : bitmap2Bytes(drawable2Bitmap(drawable), format);
}
/**
* Bytes to drawable.
*
* @param bytes The bytes.
* @return drawable
*/
public static Drawable bytes2Drawable(final byte[] bytes) {
return bitmap2Drawable(bytes2Bitmap(bytes));
}
/**
* View to bitmap.
*
* @param view The view.
* @return bitmap
*/
public static Bitmap view2Bitmap(final View view) {
if (view == null) return null;
Bitmap ret = Bitmap.createBitmap(view.getWidth(),
view.getHeight(),
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(ret);
// Drawable bgDrawable = view.getBackground();
// if (bgDrawable != null) {
// bgDrawable.draw(canvas);
// } else {
// canvas.drawColor(Color.WHITE);
// }
view.draw(canvas);
return ret;
}
/**
* Return bitmap.
*
* @param file The file.
* @return bitmap
*/
public static Bitmap getBitmap(final File file) {
if (file == null) return null;
return BitmapFactory.decodeFile(file.getAbsolutePath());
}
/**
* Return bitmap.
*
* @param file The file.
* @param maxWidth The maximum width.
* @param maxHeight The maximum height.
* @return bitmap
*/
public static Bitmap getBitmap(final File file, final int maxWidth, final int maxHeight) {
if (file == null) return null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
options.inSampleSize = calculateInSampleSize(options, maxWidth, maxHeight);
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(file.getAbsolutePath(), options);
}
/**
* Return bitmap.
*
* @param filePath The path of file.
* @return bitmap
*/
public static Bitmap getBitmap(final String filePath) {
if (isSpace(filePath)) return null;
return getBitmap(getImageContentUri(filePath));
}
// 通过uri加载图片
public static Bitmap getBitmap(Uri uri) {
try {
ParcelFileDescriptor parcelFileDescriptor =
MPApplication.getAppContext().getContentResolver().openFileDescriptor(uri, "r");
FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
Bitmap image = BitmapFactory.decodeFileDescriptor(fileDescriptor);
parcelFileDescriptor.close();
return image;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* Return bitmap.
*
* @param filePath The path of file.
* @param maxWidth The maximum width.
* @param maxHeight The maximum height.
* @return bitmap
*/
public static Bitmap getBitmap(final String filePath, final int maxWidth, final int maxHeight) {
if (isSpace(filePath)) return null;
return getBitmap(getImageContentUri(filePath));
}
public static Uri getImageContentUri(String path) {
Context context = MPApplication.getAppContext();
Cursor cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String[]{MediaStore.Images.Media._ID}, MediaStore.Images.Media.DATA + "=? ",
new String[]{path}, null);
if (cursor != null && cursor.moveToFirst()) {
int id = cursor.getInt(cursor.getColumnIndex(MediaStore.MediaColumns._ID));
Uri baseUri = Uri.parse("content://media/external/images/media");
return Uri.withAppendedPath(baseUri, "" + id);
} else {
// 如果图片不在手机的共享图片数据库,就先把它插入。
if (new File(path).exists()) {
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.DATA, path);
return context.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
} else {
return null;
}
}
}
/**
* Return bitmap.
*
* @param is The input stream.
* @return bitmap
*/
public static Bitmap getBitmap(final InputStream is) {
if (is == null) return null;
return BitmapFactory.decodeStream(is);
}
/**
* Return bitmap.
*
* @param is The input stream.
* @param maxWidth The maximum width.
* @param maxHeight The maximum height.
* @return bitmap
*/
public static Bitmap getBitmap(final InputStream is, final int maxWidth, final int maxHeight) {
if (is == null) return null;
byte[] bytes = input2Byte(is);
return getBitmap(bytes, 0, maxWidth, maxHeight);
}
/**
* Return bitmap.
*
* @param data The data.
* @param offset The offset.
* @return bitmap
*/
public static Bitmap getBitmap(final byte[] data, final int offset) {
if (data.length == 0) return null;
return BitmapFactory.decodeByteArray(data, offset, data.length);
}
/**
* Return bitmap.
*
* @param data The data.
* @param offset The offset.
* @param maxWidth The maximum width.
* @param maxHeight The maximum height.
* @return bitmap
*/
public static Bitmap getBitmap(final byte[] data,
final int offset,
final int maxWidth,
final int maxHeight) {
if (data.length == 0) return null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeByteArray(data, offset, data.length, options);
options.inSampleSize = calculateInSampleSize(options, maxWidth, maxHeight);
options.inJustDecodeBounds = false;
return BitmapFactory.decodeByteArray(data, offset, data.length, options);
}
/**
* Return bitmap.
*
* @param resId The resource id.
* @return bitmap
*/
public static Bitmap getBitmap(@DrawableRes final int resId) {
Drawable drawable = ContextCompat.getDrawable(MPUtils.getApp(), resId);
Canvas canvas = new Canvas();
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(),
Bitmap.Config.ARGB_8888);
canvas.setBitmap(bitmap);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
drawable.draw(canvas);
return bitmap;
}
/**
* Return bitmap.
*
* @param resId The resource id.
* @param maxWidth The maximum width.
* @param maxHeight The maximum height.
* @return bitmap
*/
public static Bitmap getBitmap(@DrawableRes final int resId,
final int maxWidth,
final int maxHeight) {
BitmapFactory.Options options = new BitmapFactory.Options();
final Resources resources = MPUtils.getApp().getResources();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(resources, resId, options);
options.inSampleSize = calculateInSampleSize(options, maxWidth, maxHeight);
options.inJustDecodeBounds = false;
return BitmapFactory.decodeResource(resources, resId, options);
}
/**
* Return bitmap.
*
* @param fd The file descriptor.
* @return bitmap
*/
public static Bitmap getBitmap(final FileDescriptor fd) {
if (fd == null) return null;
return BitmapFactory.decodeFileDescriptor(fd);
}
/**
* Return bitmap.
*
* @param fd The file descriptor
* @param maxWidth The maximum width.
* @param maxHeight The maximum height.
* @return bitmap
*/
public static Bitmap getBitmap(final FileDescriptor fd,
final int maxWidth,
final int maxHeight) {
if (fd == null) return null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFileDescriptor(fd, null, options);
options.inSampleSize = calculateInSampleSize(options, maxWidth, maxHeight);
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFileDescriptor(fd, null, options);
}
/**
* Return the bitmap with the specified color.
*
* @param src The source of bitmap.
* @param color The color.
* @return the bitmap with the specified color
*/
public static Bitmap drawColor(@NonNull final Bitmap src, @ColorInt final int color) {
return drawColor(src, color, false);
}
/**
* Return the bitmap with the specified color.
*
* @param src The source of bitmap.
* @param color The color.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the bitmap with the specified color
*/
public static Bitmap drawColor(@NonNull final Bitmap src,
@ColorInt final int color,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
Bitmap ret = recycle ? src : src.copy(src.getConfig(), true);
Canvas canvas = new Canvas(ret);
canvas.drawColor(color, PorterDuff.Mode.DARKEN);
return ret;
}
/**
* Return the scaled bitmap.
*
* @param src The source of bitmap.
* @param newWidth The new width.
* @param newHeight The new height.
* @return the scaled bitmap
*/
public static Bitmap scale(final Bitmap src, final int newWidth, final int newHeight) {
return scale(src, newWidth, newHeight, false);
}
/**
* Return the scaled bitmap.
*
* @param src The source of bitmap.
* @param newWidth The new width.
* @param newHeight The new height.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the scaled bitmap
*/
public static Bitmap scale(final Bitmap src,
final int newWidth,
final int newHeight,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
Bitmap ret = Bitmap.createScaledBitmap(src, newWidth, newHeight, true);
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the scaled bitmap
*
* @param src The source of bitmap.
* @param scaleWidth The scale of width.
* @param scaleHeight The scale of height.
* @return the scaled bitmap
*/
public static Bitmap scale(final Bitmap src, final float scaleWidth, final float scaleHeight) {
return scale(src, scaleWidth, scaleHeight, false);
}
/**
* Return the scaled bitmap
*
* @param src The source of bitmap.
* @param scaleWidth The scale of width.
* @param scaleHeight The scale of height.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the scaled bitmap
*/
public static Bitmap scale(final Bitmap src,
final float scaleWidth,
final float scaleHeight,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
Matrix matrix = new Matrix();
matrix.setScale(scaleWidth, scaleHeight);
Bitmap ret = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the clipped bitmap.
*
* @param src The source of bitmap.
* @param x The x coordinate of the first pixel.
* @param y The y coordinate of the first pixel.
* @param width The width.
* @param height The height.
* @return the clipped bitmap
*/
public static Bitmap clip(final Bitmap src,
final int x,
final int y,
final int width,
final int height) {
return clip(src, x, y, width, height, false);
}
/**
* Return the clipped bitmap.
*
* @param src The source of bitmap.
* @param x The x coordinate of the first pixel.
* @param y The y coordinate of the first pixel.
* @param width The width.
* @param height The height.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the clipped bitmap
*/
public static Bitmap clip(final Bitmap src,
final int x,
final int y,
final int width,
final int height,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
Bitmap ret = Bitmap.createBitmap(src, x, y, width, height);
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the skewed bitmap.
*
* @param src The source of bitmap.
* @param kx The skew factor of x.
* @param ky The skew factor of y.
* @return the skewed bitmap
*/
public static Bitmap skew(final Bitmap src, final float kx, final float ky) {
return skew(src, kx, ky, 0, 0, false);
}
/**
* Return the skewed bitmap.
*
* @param src The source of bitmap.
* @param kx The skew factor of x.
* @param ky The skew factor of y.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the skewed bitmap
*/
public static Bitmap skew(final Bitmap src,
final float kx,
final float ky,
final boolean recycle) {
return skew(src, kx, ky, 0, 0, recycle);
}
/**
* Return the skewed bitmap.
*
* @param src The source of bitmap.
* @param kx The skew factor of x.
* @param ky The skew factor of y.
* @param px The x coordinate of the pivot point.
* @param py The y coordinate of the pivot point.
* @return the skewed bitmap
*/
public static Bitmap skew(final Bitmap src,
final float kx,
final float ky,
final float px,
final float py) {
return skew(src, kx, ky, px, py, false);
}
/**
* Return the skewed bitmap.
*
* @param src The source of bitmap.
* @param kx The skew factor of x.
* @param ky The skew factor of y.
* @param px The x coordinate of the pivot point.
* @param py The y coordinate of the pivot point.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the skewed bitmap
*/
public static Bitmap skew(final Bitmap src,
final float kx,
final float ky,
final float px,
final float py,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
Matrix matrix = new Matrix();
matrix.setSkew(kx, ky, px, py);
Bitmap ret = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the rotated bitmap.
*
* @param src The source of bitmap.
* @param degrees The number of degrees.
* @param px The x coordinate of the pivot point.
* @param py The y coordinate of the pivot point.
* @return the rotated bitmap
*/
public static Bitmap rotate(final Bitmap src,
final int degrees,
final float px,
final float py) {
return rotate(src, degrees, px, py, false);
}
/**
* Return the rotated bitmap.
*
* @param src The source of bitmap.
* @param degrees The number of degrees.
* @param px The x coordinate of the pivot point.
* @param py The y coordinate of the pivot point.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the rotated bitmap
*/
public static Bitmap rotate(final Bitmap src,
final int degrees,
final float px,
final float py,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
if (degrees == 0) return src;
Matrix matrix = new Matrix();
matrix.setRotate(degrees, px, py);
Bitmap ret = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the rotated degree.
*
* @param filePath The path of file.
* @return the rotated degree
*/
public static int getRotateDegree(final String filePath) {
try {
ExifInterface exifInterface = new ExifInterface(filePath);
int orientation = exifInterface.getAttributeInt(
ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_NORMAL
);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
return 90;
case ExifInterface.ORIENTATION_ROTATE_180:
return 180;
case ExifInterface.ORIENTATION_ROTATE_270:
return 270;
default:
return 0;
}
} catch (IOException e) {
e.printStackTrace();
return -1;
}
}
/**
* Return the round bitmap.
*
* @param src The source of bitmap.
* @return the round bitmap
*/
public static Bitmap toRound(final Bitmap src) {
return toRound(src, 0, 0, false);
}
/**
* Return the round bitmap.
*
* @param src The source of bitmap.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the round bitmap
*/
public static Bitmap toRound(final Bitmap src, final boolean recycle) {
return toRound(src, 0, 0, recycle);
}
/**
* Return the round bitmap.
*
* @param src The source of bitmap.
* @param borderSize The size of border.
* @param borderColor The color of border.
* @return the round bitmap
*/
public static Bitmap toRound(final Bitmap src,
@IntRange(from = 0) int borderSize,
@ColorInt int borderColor) {
return toRound(src, borderSize, borderColor, false);
}
/**
* Return the round bitmap.
*
* @param src The source of bitmap.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @param borderSize The size of border.
* @param borderColor The color of border.
* @return the round bitmap
*/
public static Bitmap toRound(final Bitmap src,
@IntRange(from = 0) int borderSize,
@ColorInt int borderColor,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
int width = src.getWidth();
int height = src.getHeight();
int size = Math.min(width, height);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
Bitmap ret = Bitmap.createBitmap(width, height, src.getConfig());
float center = size / 2f;
RectF rectF = new RectF(0, 0, width, height);
rectF.inset((width - size) / 2f, (height - size) / 2f);
Matrix matrix = new Matrix();
matrix.setTranslate(rectF.left, rectF.top);
matrix.preScale((float) size / width, (float) size / height);
BitmapShader shader = new BitmapShader(src, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
shader.setLocalMatrix(matrix);
paint.setShader(shader);
Canvas canvas = new Canvas(ret);
canvas.drawRoundRect(rectF, center, center, paint);
if (borderSize > 0) {
paint.setShader(null);
paint.setColor(borderColor);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(borderSize);
float radius = center - borderSize / 2f;
canvas.drawCircle(width / 2f, height / 2f, radius, paint);
}
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the round corner bitmap.
*
* @param src The source of bitmap.
* @param radius The radius of corner.
* @return the round corner bitmap
*/
public static Bitmap toRoundCorner(final Bitmap src, final float radius) {
return toRoundCorner(src, radius, 0, 0, false);
}
/**
* Return the round corner bitmap.
*
* @param src The source of bitmap.
* @param radius The radius of corner.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the round corner bitmap
*/
public static Bitmap toRoundCorner(final Bitmap src,
final float radius,
final boolean recycle) {
return toRoundCorner(src, radius, 0, 0, recycle);
}
/**
* Return the round corner bitmap.
*
* @param src The source of bitmap.
* @param radius The radius of corner.
* @param borderSize The size of border.
* @param borderColor The color of border.
* @return the round corner bitmap
*/
public static Bitmap toRoundCorner(final Bitmap src,
final float radius,
@IntRange(from = 0) int borderSize,
@ColorInt int borderColor) {
return toRoundCorner(src, radius, borderSize, borderColor, false);
}
/**
* Return the round corner bitmap.
*
* @param src The source of bitmap.
* @param radius The radius of corner.
* @param borderSize The size of border.
* @param borderColor The color of border.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the round corner bitmap
*/
public static Bitmap toRoundCorner(final Bitmap src,
final float radius,
@IntRange(from = 0) int borderSize,
@ColorInt int borderColor,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
int width = src.getWidth();
int height = src.getHeight();
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
Bitmap ret = Bitmap.createBitmap(width, height, src.getConfig());
BitmapShader shader = new BitmapShader(src, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
paint.setShader(shader);
Canvas canvas = new Canvas(ret);
RectF rectF = new RectF(0, 0, width, height);
float halfBorderSize = borderSize / 2f;
rectF.inset(halfBorderSize, halfBorderSize);
canvas.drawRoundRect(rectF, radius, radius, paint);
if (borderSize > 0) {
paint.setShader(null);
paint.setColor(borderColor);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(borderSize);
paint.setStrokeCap(Paint.Cap.ROUND);
canvas.drawRoundRect(rectF, radius, radius, paint);
}
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the round corner bitmap with border.
*
* @param src The source of bitmap.
* @param borderSize The size of border.
* @param color The color of border.
* @param cornerRadius The radius of corner.
* @return the round corner bitmap with border
*/
public static Bitmap addCornerBorder(final Bitmap src,
@IntRange(from = 1) final int borderSize,
@ColorInt final int color,
@FloatRange(from = 0) final float cornerRadius) {
return addBorder(src, borderSize, color, false, cornerRadius, false);
}
/**
* Return the round corner bitmap with border.
*
* @param src The source of bitmap.
* @param borderSize The size of border.
* @param color The color of border.
* @param cornerRadius The radius of corner.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the round corner bitmap with border
*/
public static Bitmap addCornerBorder(final Bitmap src,
@IntRange(from = 1) final int borderSize,
@ColorInt final int color,
@FloatRange(from = 0) final float cornerRadius,
final boolean recycle) {
return addBorder(src, borderSize, color, false, cornerRadius, recycle);
}
/**
* Return the round bitmap with border.
*
* @param src The source of bitmap.
* @param borderSize The size of border.
* @param color The color of border.
* @return the round bitmap with border
*/
public static Bitmap addCircleBorder(final Bitmap src,
@IntRange(from = 1) final int borderSize,
@ColorInt final int color) {
return addBorder(src, borderSize, color, true, 0, false);
}
/**
* Return the round bitmap with border.
*
* @param src The source of bitmap.
* @param borderSize The size of border.
* @param color The color of border.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the round bitmap with border
*/
public static Bitmap addCircleBorder(final Bitmap src,
@IntRange(from = 1) final int borderSize,
@ColorInt final int color,
final boolean recycle) {
return addBorder(src, borderSize, color, true, 0, recycle);
}
/**
* Return the bitmap with border.
*
* @param src The source of bitmap.
* @param borderSize The size of border.
* @param color The color of border.
* @param isCircle True to draw circle, false to draw corner.
* @param cornerRadius The radius of corner.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the bitmap with border
*/
private static Bitmap addBorder(final Bitmap src,
@IntRange(from = 1) final int borderSize,
@ColorInt final int color,
final boolean isCircle,
final float cornerRadius,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
Bitmap ret = recycle ? src : src.copy(src.getConfig(), true);
int width = ret.getWidth();
int height = ret.getHeight();
Canvas canvas = new Canvas(ret);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(color);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(borderSize);
if (isCircle) {
float radius = Math.min(width, height) / 2f - borderSize / 2f;
canvas.drawCircle(width / 2f, height / 2f, radius, paint);
} else {
int halfBorderSize = borderSize >> 1;
RectF rectF = new RectF(halfBorderSize, halfBorderSize,
width - halfBorderSize, height - halfBorderSize);
canvas.drawRoundRect(rectF, cornerRadius, cornerRadius, paint);
}
return ret;
}
/**
* Return the bitmap with reflection.
*
* @param src The source of bitmap.
* @param reflectionHeight The height of reflection.
* @return the bitmap with reflection
*/
public static Bitmap addReflection(final Bitmap src, final int reflectionHeight) {
return addReflection(src, reflectionHeight, false);
}
/**
* Return the bitmap with reflection.
*
* @param src The source of bitmap.
* @param reflectionHeight The height of reflection.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the bitmap with reflection
*/
public static Bitmap addReflection(final Bitmap src,
final int reflectionHeight,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
final int REFLECTION_GAP = 0;
int srcWidth = src.getWidth();
int srcHeight = src.getHeight();
Matrix matrix = new Matrix();
matrix.preScale(1, -1);
Bitmap reflectionBitmap = Bitmap.createBitmap(src, 0, srcHeight - reflectionHeight,
srcWidth, reflectionHeight, matrix, false);
Bitmap ret = Bitmap.createBitmap(srcWidth, srcHeight + reflectionHeight, src.getConfig());
Canvas canvas = new Canvas(ret);
canvas.drawBitmap(src, 0, 0, null);
canvas.drawBitmap(reflectionBitmap, 0, srcHeight + REFLECTION_GAP, null);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
LinearGradient shader = new LinearGradient(
0, srcHeight,
0, ret.getHeight() + REFLECTION_GAP,
0x70FFFFFF,
0x00FFFFFF,
Shader.TileMode.MIRROR);
paint.setShader(shader);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
canvas.drawRect(0, srcHeight + REFLECTION_GAP, srcWidth, ret.getHeight(), paint);
if (!reflectionBitmap.isRecycled()) reflectionBitmap.recycle();
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the bitmap with text watermarking.
*
* @param src The source of bitmap.
* @param content The content of text.
* @param textSize The size of text.
* @param color The color of text.
* @param x The x coordinate of the first pixel.
* @param y The y coordinate of the first pixel.
* @return the bitmap with text watermarking
*/
public static Bitmap addTextWatermark(final Bitmap src,
final String content,
final int textSize,
@ColorInt final int color,
final float x,
final float y) {
return addTextWatermark(src, content, textSize, color, x, y, false);
}
/**
* Return the bitmap with text watermarking.
*
* @param src The source of bitmap.
* @param content The content of text.
* @param textSize The size of text.
* @param color The color of text.
* @param x The x coordinate of the first pixel.
* @param y The y coordinate of the first pixel.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the bitmap with text watermarking
*/
public static Bitmap addTextWatermark(final Bitmap src,
final String content,
final float textSize,
@ColorInt final int color,
final float x,
final float y,
final boolean recycle) {
if (isEmptyBitmap(src) || content == null) return null;
Bitmap ret = src.copy(src.getConfig(), true);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
Canvas canvas = new Canvas(ret);
paint.setColor(color);
paint.setTextSize(textSize);
Rect bounds = new Rect();
paint.getTextBounds(content, 0, content.length(), bounds);
canvas.drawText(content, x, y + textSize, paint);
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the bitmap with image watermarking.
*
* @param src The source of bitmap.
* @param watermark The image watermarking.
* @param x The x coordinate of the first pixel.
* @param y The y coordinate of the first pixel.
* @param alpha The alpha of watermark.
* @return the bitmap with image watermarking
*/
public static Bitmap addImageWatermark(final Bitmap src,
final Bitmap watermark,
final int x, final int y,
final int alpha) {
return addImageWatermark(src, watermark, x, y, alpha, false);
}
/**
* Return the bitmap with image watermarking.
*
* @param src The source of bitmap.
* @param watermark The image watermarking.
* @param x The x coordinate of the first pixel.
* @param y The y coordinate of the first pixel.
* @param alpha The alpha of watermark.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the bitmap with image watermarking
*/
public static Bitmap addImageWatermark(final Bitmap src,
final Bitmap watermark,
final int x,
final int y,
final int alpha,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
Bitmap ret = src.copy(src.getConfig(), true);
if (!isEmptyBitmap(watermark)) {
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
Canvas canvas = new Canvas(ret);
paint.setAlpha(alpha);
canvas.drawBitmap(watermark, x, y, paint);
}
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the alpha bitmap.
*
* @param src The source of bitmap.
* @return the alpha bitmap
*/
public static Bitmap toAlpha(final Bitmap src) {
return toAlpha(src, false);
}
/**
* Return the alpha bitmap.
*
* @param src The source of bitmap.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the alpha bitmap
*/
public static Bitmap toAlpha(final Bitmap src, final Boolean recycle) {
if (isEmptyBitmap(src)) return null;
Bitmap ret = src.extractAlpha();
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the gray bitmap.
*
* @param src The source of bitmap.
* @return the gray bitmap
*/
public static Bitmap toGray(final Bitmap src) {
return toGray(src, false);
}
/**
* Return the gray bitmap.
*
* @param src The source of bitmap.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the gray bitmap
*/
public static Bitmap toGray(final Bitmap src, final boolean recycle) {
if (isEmptyBitmap(src)) return null;
Bitmap ret = Bitmap.createBitmap(src.getWidth(), src.getHeight(), src.getConfig());
Canvas canvas = new Canvas(ret);
Paint paint = new Paint();
ColorMatrix colorMatrix = new ColorMatrix();
colorMatrix.setSaturation(0);
ColorMatrixColorFilter colorMatrixColorFilter = new ColorMatrixColorFilter(colorMatrix);
paint.setColorFilter(colorMatrixColorFilter);
canvas.drawBitmap(src, 0, 0, paint);
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the blur bitmap fast.
* <p>zoom out, blur, zoom in</p>
*
* @param src The source of bitmap.
* @param scale The scale(0...1).
* @param radius The radius(0...25).
* @return the blur bitmap
*/
public static Bitmap fastBlur(final Bitmap src,
@FloatRange(
from = 0, to = 1, fromInclusive = false
) final float scale,
@FloatRange(
from = 0, to = 25, fromInclusive = false
) final float radius) {
return fastBlur(src, scale, radius, false);
}
/**
* Return the blur bitmap fast.
* <p>zoom out, blur, zoom in</p>
*
* @param src The source of bitmap.
* @param scale The scale(0...1).
* @param radius The radius(0...25).
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the blur bitmap
*/
public static Bitmap fastBlur(final Bitmap src,
@FloatRange(
from = 0, to = 1, fromInclusive = false
) final float scale,
@FloatRange(
from = 0, to = 25, fromInclusive = false
) final float radius,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
int width = src.getWidth();
int height = src.getHeight();
Matrix matrix = new Matrix();
matrix.setScale(scale, scale);
Bitmap scaleBitmap =
Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);
Canvas canvas = new Canvas();
PorterDuffColorFilter filter = new PorterDuffColorFilter(
Color.TRANSPARENT, PorterDuff.Mode.SRC_ATOP);
paint.setColorFilter(filter);
canvas.scale(scale, scale);
canvas.drawBitmap(scaleBitmap, 0, 0, paint);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
scaleBitmap = renderScriptBlur(scaleBitmap, radius, recycle);
} else {
scaleBitmap = stackBlur(scaleBitmap, (int) radius, recycle);
}
if (scale == 1) {
if (recycle && !src.isRecycled()) src.recycle();
return scaleBitmap;
}
Bitmap ret = Bitmap.createScaledBitmap(scaleBitmap, width, height, true);
if (!scaleBitmap.isRecycled()) scaleBitmap.recycle();
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
/**
* Return the blur bitmap using render script.
*
* @param src The source of bitmap.
* @param radius The radius(0...25).
* @return the blur bitmap
*/
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static Bitmap renderScriptBlur(final Bitmap src,
@FloatRange(
from = 0, to = 25, fromInclusive = false
) final float radius) {
return renderScriptBlur(src, radius, false);
}
/**
* Return the blur bitmap using render script.
*
* @param src The source of bitmap.
* @param radius The radius(0...25).
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the blur bitmap
*/
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static Bitmap renderScriptBlur(final Bitmap src,
@FloatRange(
from = 0, to = 25, fromInclusive = false
) final float radius,
final boolean recycle) {
RenderScript rs = null;
Bitmap ret = recycle ? src : src.copy(src.getConfig(), true);
try {
rs = RenderScript.create(MPUtils.getApp());
rs.setMessageHandler(new RenderScript.RSMessageHandler());
Allocation input = Allocation.createFromBitmap(rs,
ret,
Allocation.MipmapControl.MIPMAP_NONE,
Allocation.USAGE_SCRIPT);
Allocation output = Allocation.createTyped(rs, input.getType());
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
blurScript.setInput(input);
blurScript.setRadius(radius);
blurScript.forEach(output);
output.copyTo(ret);
} finally {
if (rs != null) {
rs.destroy();
}
}
return ret;
}
/**
* Return the blur bitmap using stack.
*
* @param src The source of bitmap.
* @param radius The radius(0...25).
* @return the blur bitmap
*/
public static Bitmap stackBlur(final Bitmap src, final int radius) {
return stackBlur(src, radius, false);
}
/**
* Return the blur bitmap using stack.
*
* @param src The source of bitmap.
* @param radius The radius(0...25).
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the blur bitmap
*/
public static Bitmap stackBlur(final Bitmap src, int radius, final boolean recycle) {
Bitmap ret = recycle ? src : src.copy(src.getConfig(), true);
if (radius < 1) {
radius = 1;
}
int w = ret.getWidth();
int h = ret.getHeight();
int[] pix = new int[w * h];
ret.getPixels(pix, 0, w, 0, 0, w, h);
int wm = w - 1;
int hm = h - 1;
int wh = w * h;
int div = radius + radius + 1;
int r[] = new int[wh];
int g[] = new int[wh];
int b[] = new int[wh];
int rsum, gsum, bsum, x, y, i, p, yp, yi, yw;
int vmin[] = new int[Math.max(w, h)];
int divsum = (div + 1) >> 1;
divsum *= divsum;
int dv[] = new int[256 * divsum];
for (i = 0; i < 256 * divsum; i++) {
dv[i] = (i / divsum);
}
yw = yi = 0;
int[][] stack = new int[div][3];
int stackpointer;
int stackstart;
int[] sir;
int rbs;
int r1 = radius + 1;
int routsum, goutsum, boutsum;
int rinsum, ginsum, binsum;
for (y = 0; y < h; y++) {
rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
for (i = -radius; i <= radius; i++) {
p = pix[yi + Math.min(wm, Math.max(i, 0))];
sir = stack[i + radius];
sir[0] = (p & 0xff0000) >> 16;
sir[1] = (p & 0x00ff00) >> 8;
sir[2] = (p & 0x0000ff);
rbs = r1 - Math.abs(i);
rsum += sir[0] * rbs;
gsum += sir[1] * rbs;
bsum += sir[2] * rbs;
if (i > 0) {
rinsum += sir[0];
ginsum += sir[1];
binsum += sir[2];
} else {
routsum += sir[0];
goutsum += sir[1];
boutsum += sir[2];
}
}
stackpointer = radius;
for (x = 0; x < w; x++) {
r[yi] = dv[rsum];
g[yi] = dv[gsum];
b[yi] = dv[bsum];
rsum -= routsum;
gsum -= goutsum;
bsum -= boutsum;
stackstart = stackpointer - radius + div;
sir = stack[stackstart % div];
routsum -= sir[0];
goutsum -= sir[1];
boutsum -= sir[2];
if (y == 0) {
vmin[x] = Math.min(x + radius + 1, wm);
}
p = pix[yw + vmin[x]];
sir[0] = (p & 0xff0000) >> 16;
sir[1] = (p & 0x00ff00) >> 8;
sir[2] = (p & 0x0000ff);
rinsum += sir[0];
ginsum += sir[1];
binsum += sir[2];
rsum += rinsum;
gsum += ginsum;
bsum += binsum;
stackpointer = (stackpointer + 1) % div;
sir = stack[(stackpointer) % div];
routsum += sir[0];
goutsum += sir[1];
boutsum += sir[2];
rinsum -= sir[0];
ginsum -= sir[1];
binsum -= sir[2];
yi++;
}
yw += w;
}
for (x = 0; x < w; x++) {
rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
yp = -radius * w;
for (i = -radius; i <= radius; i++) {
yi = Math.max(0, yp) + x;
sir = stack[i + radius];
sir[0] = r[yi];
sir[1] = g[yi];
sir[2] = b[yi];
rbs = r1 - Math.abs(i);
rsum += r[yi] * rbs;
gsum += g[yi] * rbs;
bsum += b[yi] * rbs;
if (i > 0) {
rinsum += sir[0];
ginsum += sir[1];
binsum += sir[2];
} else {
routsum += sir[0];
goutsum += sir[1];
boutsum += sir[2];
}
if (i < hm) {
yp += w;
}
}
yi = x;
stackpointer = radius;
for (y = 0; y < h; y++) {
// Preserve alpha channel: ( 0xff000000 & pix[yi] )
pix[yi] = (0xff000000 & pix[yi]) | (dv[rsum] << 16) | (dv[gsum] << 8) | dv[bsum];
rsum -= routsum;
gsum -= goutsum;
bsum -= boutsum;
stackstart = stackpointer - radius + div;
sir = stack[stackstart % div];
routsum -= sir[0];
goutsum -= sir[1];
boutsum -= sir[2];
if (x == 0) {
vmin[y] = Math.min(y + r1, hm) * w;
}
p = x + vmin[y];
sir[0] = r[p];
sir[1] = g[p];
sir[2] = b[p];
rinsum += sir[0];
ginsum += sir[1];
binsum += sir[2];
rsum += rinsum;
gsum += ginsum;
bsum += binsum;
stackpointer = (stackpointer + 1) % div;
sir = stack[stackpointer];
routsum += sir[0];
goutsum += sir[1];
boutsum += sir[2];
rinsum -= sir[0];
ginsum -= sir[1];
binsum -= sir[2];
yi += w;
}
}
ret.setPixels(pix, 0, w, 0, 0, w, h);
return ret;
}
/**
* Save the bitmap.
*
* @param src The source of bitmap.
* @param filePath The path of file.
* @param format The format of the image.
* @return {@code true}: success<br>{@code false}: fail
*/
public static boolean save(final Bitmap src,
final String filePath,
final CompressFormat format) {
return save(src, getFileByPath(filePath), format, false);
}
/**
* Save the bitmap.
*
* @param src The source of bitmap.
* @param file The file.
* @param format The format of the image.
* @return {@code true}: success<br>{@code false}: fail
*/
public static boolean save(final Bitmap src, final File file, final CompressFormat format) {
return save(src, file, format, false);
}
/**
* Save the bitmap.
*
* @param src The source of bitmap.
* @param filePath The path of file.
* @param format The format of the image.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return {@code true}: success<br>{@code false}: fail
*/
public static boolean save(final Bitmap src,
final String filePath,
final CompressFormat format,
final boolean recycle) {
return save(src, getFileByPath(filePath), format, recycle);
}
/**
* Save the bitmap.
*
* @param src The source of bitmap.
* @param file The file.
* @param format The format of the image.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return {@code true}: success<br>{@code false}: fail
*/
public static boolean save(final Bitmap src,
final File file,
final CompressFormat format,
final boolean recycle) {
if (isEmptyBitmap(src) || !createFileByDeleteOldFile(file)) return false;
OutputStream os = null;
boolean ret = false;
try {
os = new BufferedOutputStream(new FileOutputStream(file));
ret = src.compress(format, 100, os);
if (recycle && !src.isRecycled()) src.recycle();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (os != null) {
os.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return ret;
}
/**
* Return whether it is a image according to the file name.
*
* @param file The file.
* @return {@code true}: yes<br>{@code false}: no
*/
public static boolean isImage(final File file) {
return file != null && isImage(file.getPath());
}
/**
* Return whether it is a image according to the file name.
*
* @param filePath The path of file.
* @return {@code true}: yes<br>{@code false}: no
*/
public static boolean isImage(final String filePath) {
String path = filePath.toUpperCase();
return path.endsWith(".PNG") || path.endsWith(".JPG")
|| path.endsWith(".JPEG") || path.endsWith(".BMP")
|| path.endsWith(".GIF") || path.endsWith(".WEBP");
}
/**
* Return the type of image.
*
* @param filePath The path of file.
* @return the type of image
*/
public static String getImageType(final String filePath) {
return getImageType(getFileByPath(filePath));
}
/**
* Return the type of image.
*
* @param file The file.
* @return the type of image
*/
public static String getImageType(final File file) {
if (file == null) return "";
InputStream is = null;
try {
is = new FileInputStream(file);
String type = getImageType(is);
if (type != null) {
return type;
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (is != null) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return getFileExtension(file.getAbsolutePath()).toUpperCase();
}
private static String getFileExtension(final String filePath) {
if (isSpace(filePath)) return filePath;
int lastPoi = filePath.lastIndexOf('.');
int lastSep = filePath.lastIndexOf(File.separator);
if (lastPoi == -1 || lastSep >= lastPoi) return "";
return filePath.substring(lastPoi + 1);
}
private static String getImageType(final InputStream is) {
if (is == null) return null;
try {
byte[] bytes = new byte[8];
return is.read(bytes, 0, 8) != -1 ? getImageType(bytes) : null;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
private static String getImageType(final byte[] bytes) {
if (isJPEG(bytes)) return "JPEG";
if (isGIF(bytes)) return "GIF";
if (isPNG(bytes)) return "PNG";
if (isBMP(bytes)) return "BMP";
return null;
}
private static boolean isJPEG(final byte[] b) {
return b.length >= 2
&& (b[0] == (byte) 0xFF) && (b[1] == (byte) 0xD8);
}
private static boolean isGIF(final byte[] b) {
return b.length >= 6
&& b[0] == 'G' && b[1] == 'I'
&& b[2] == 'F' && b[3] == '8'
&& (b[4] == '7' || b[4] == '9') && b[5] == 'a';
}
private static boolean isPNG(final byte[] b) {
return b.length >= 8
&& (b[0] == (byte) 137 && b[1] == (byte) 80
&& b[2] == (byte) 78 && b[3] == (byte) 71
&& b[4] == (byte) 13 && b[5] == (byte) 10
&& b[6] == (byte) 26 && b[7] == (byte) 10);
}
private static boolean isBMP(final byte[] b) {
return b.length >= 2
&& (b[0] == 0x42) && (b[1] == 0x4d);
}
private static boolean isEmptyBitmap(final Bitmap src) {
return src == null || src.getWidth() == 0 || src.getHeight() == 0;
}
///////////////////////////////////////////////////////////////////////////
// about compress
///////////////////////////////////////////////////////////////////////////
/**
* Return the compressed bitmap using scale.
*
* @param src The source of bitmap.
* @param newWidth The new width.
* @param newHeight The new height.
* @return the compressed bitmap
*/
public static Bitmap compressByScale(final Bitmap src,
final int newWidth,
final int newHeight) {
return scale(src, newWidth, newHeight, false);
}
/**
* Return the compressed bitmap using scale.
*
* @param src The source of bitmap.
* @param newWidth The new width.
* @param newHeight The new height.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the compressed bitmap
*/
public static Bitmap compressByScale(final Bitmap src,
final int newWidth,
final int newHeight,
final boolean recycle) {
return scale(src, newWidth, newHeight, recycle);
}
/**
* Return the compressed bitmap using scale.
*
* @param src The source of bitmap.
* @param scaleWidth The scale of width.
* @param scaleHeight The scale of height.
* @return the compressed bitmap
*/
public static Bitmap compressByScale(final Bitmap src,
final float scaleWidth,
final float scaleHeight) {
return scale(src, scaleWidth, scaleHeight, false);
}
/**
* Return the compressed bitmap using scale.
*
* @param src The source of bitmap.
* @param scaleWidth The scale of width.
* @param scaleHeight The scale of height.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return he compressed bitmap
*/
public static Bitmap compressByScale(final Bitmap src,
final float scaleWidth,
final float scaleHeight,
final boolean recycle) {
return scale(src, scaleWidth, scaleHeight, recycle);
}
/**
* Return the compressed bitmap using quality.
*
* @param src The source of bitmap.
* @param quality The quality.
* @return the compressed bitmap
*/
public static Bitmap compressByQuality(final Bitmap src,
@IntRange(from = 0, to = 100) final int quality) {
return compressByQuality(src, quality, false);
}
/**
* Return the compressed bitmap using quality.
*
* @param src The source of bitmap.
* @param quality The quality.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the compressed bitmap
*/
public static Bitmap compressByQuality(final Bitmap src,
@IntRange(from = 0, to = 100) final int quality,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
src.compress(CompressFormat.JPEG, quality, baos);
byte[] bytes = baos.toByteArray();
if (recycle && !src.isRecycled()) src.recycle();
return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
}
/**
* Return the compressed bitmap using quality.
*
* @param src The source of bitmap.
* @param maxByteSize The maximum size of byte.
* @return the compressed bitmap
*/
public static Bitmap compressByQuality(final Bitmap src, final long maxByteSize) {
return compressByQuality(src, maxByteSize, false);
}
/**
* Return the compressed bitmap using quality.
*
* @param src The source of bitmap.
* @param maxByteSize The maximum size of byte.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the compressed bitmap
*/
public static Bitmap compressByQuality(final Bitmap src,
final long maxByteSize,
final boolean recycle) {
if (isEmptyBitmap(src) || maxByteSize <= 0) return null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
src.compress(CompressFormat.JPEG, 100, baos);
byte[] bytes;
if (baos.size() <= maxByteSize) {
bytes = baos.toByteArray();
} else {
baos.reset();
src.compress(CompressFormat.JPEG, 0, baos);
if (baos.size() >= maxByteSize) {
bytes = baos.toByteArray();
} else {
// find the best quality using binary search
int st = 0;
int end = 100;
int mid = 0;
while (st < end) {
mid = (st + end) / 2;
baos.reset();
src.compress(CompressFormat.JPEG, mid, baos);
int len = baos.size();
if (len == maxByteSize) {
break;
} else if (len > maxByteSize) {
end = mid - 1;
} else {
st = mid + 1;
}
}
if (end == mid - 1) {
baos.reset();
src.compress(CompressFormat.JPEG, st, baos);
}
bytes = baos.toByteArray();
}
}
if (recycle && !src.isRecycled()) src.recycle();
return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
}
/**
* Return the compressed bitmap using sample size.
*
* @param src The source of bitmap.
* @param sampleSize The sample size.
* @return the compressed bitmap
*/
public static Bitmap compressBySampleSize(final Bitmap src, final int sampleSize) {
return compressBySampleSize(src, sampleSize, false);
}
/**
* Return the compressed bitmap using sample size.
*
* @param src The source of bitmap.
* @param sampleSize The sample size.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the compressed bitmap
*/
public static Bitmap compressBySampleSize(final Bitmap src,
final int sampleSize,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = sampleSize;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
src.compress(CompressFormat.JPEG, 100, baos);
byte[] bytes = baos.toByteArray();
if (recycle && !src.isRecycled()) src.recycle();
return BitmapFactory.decodeByteArray(bytes, 0, bytes.length, options);
}
/**
* Return the compressed bitmap using sample size.
*
* @param src The source of bitmap.
* @param maxWidth The maximum width.
* @param maxHeight The maximum height.
* @return the compressed bitmap
*/
public static Bitmap compressBySampleSize(final Bitmap src,
final int maxWidth,
final int maxHeight) {
return compressBySampleSize(src, maxWidth, maxHeight, false);
}
/**
* Return the compressed bitmap using sample size.
*
* @param src The source of bitmap.
* @param maxWidth The maximum width.
* @param maxHeight The maximum height.
* @param recycle True to recycle the source of bitmap, false otherwise.
* @return the compressed bitmap
*/
public static Bitmap compressBySampleSize(final Bitmap src,
final int maxWidth,
final int maxHeight,
final boolean recycle) {
if (isEmptyBitmap(src)) return null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
src.compress(CompressFormat.JPEG, 100, baos);
byte[] bytes = baos.toByteArray();
BitmapFactory.decodeByteArray(bytes, 0, bytes.length, options);
options.inSampleSize = calculateInSampleSize(options, maxWidth, maxHeight);
options.inJustDecodeBounds = false;
if (recycle && !src.isRecycled()) src.recycle();
return BitmapFactory.decodeByteArray(bytes, 0, bytes.length, options);
}
/**
* Return the sample size.
*
* @param options The options.
* @param maxWidth The maximum width.
* @param maxHeight The maximum height.
* @return the sample size
*/
private static int calculateInSampleSize(final BitmapFactory.Options options,
final int maxWidth,
final int maxHeight) {
int height = options.outHeight;
int width = options.outWidth;
int inSampleSize = 1;
while ((width >>= 1) >= maxWidth && (height >>= 1) >= maxHeight) {
inSampleSize <<= 1;
}
return inSampleSize;
}
///////////////////////////////////////////////////////////////////////////
// other utils methods
///////////////////////////////////////////////////////////////////////////
private static File getFileByPath(final String filePath) {
return isSpace(filePath) ? null : new File(filePath);
}
private static boolean createFileByDeleteOldFile(final File file) {
if (file == null) return false;
if (file.exists() && !file.delete()) return false;
if (!createOrExistsDir(file.getParentFile())) return false;
try {
return file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
private static boolean createOrExistsDir(final File file) {
return file != null && (file.exists() ? file.isDirectory() : file.mkdirs());
}
private static boolean isSpace(final String s) {
if (s == null) return true;
for (int i = 0, len = s.length(); i < len; ++i) {
if (!Character.isWhitespace(s.charAt(i))) {
return false;
}
}
return true;
}
private static byte[] input2Byte(final InputStream is) {
if (is == null) return null;
try {
ByteArrayOutputStream os = new ByteArrayOutputStream();
byte[] b = new byte[1024];
int len;
while ((len = is.read(b, 0, 1024)) != -1) {
os.write(b, 0, len);
}
return os.toByteArray();
} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@TargetApi(19)
public static String getImageAbsolutePath(Context context, Uri imageUri) {
if (context == null || imageUri == null)
return null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && DocumentsContract.isDocumentUri(context, imageUri)) {
if (isExternalStorageDocument(imageUri)) {
String docId = DocumentsContract.getDocumentId(imageUri);
String[] split = docId.split(":");
String type = split[0];
if ("primary".equalsIgnoreCase(type)) {
return Environment.getExternalStorageDirectory() + "/" + split[1];
}
} else if (isDownloadsDocument(imageUri)) {
String id = DocumentsContract.getDocumentId(imageUri);
Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
return getDataColumn(context, contentUri, null, null);
} else if (isMediaDocument(imageUri)) {
String docId = DocumentsContract.getDocumentId(imageUri);
String[] split = docId.split(":");
String type = split[0];
Uri contentUri = null;
if ("image".equals(type)) {
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
} else if ("video".equals(type)) {
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
} else if ("audio".equals(type)) {
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
}
String selection = MediaStore.Images.Media._ID + "=?";
String[] selectionArgs = new String[]{split[1]};
return getDataColumn(context, contentUri, selection, selectionArgs);
}
} // MediaStore (and general)
else if ("content".equalsIgnoreCase(imageUri.getScheme())) {
// Return the remote address
if (isGooglePhotosUri(imageUri))
return imageUri.getLastPathSegment();
return getDataColumn(context, imageUri, null, null);
}
// File
else if ("file".equalsIgnoreCase(imageUri.getScheme())) {
return imageUri.getPath();
}
return null;
}
public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {
Cursor cursor = null;
String column = MediaStore.Images.Media.DATA;
String[] projection = {column};
try {
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
if (cursor != null && cursor.moveToFirst()) {
int index = cursor.getColumnIndexOrThrow(column);
return cursor.getString(index);
}
} finally {
if (cursor != null)
cursor.close();
}
return null;
}
/**
* @param uri The Uri to check.
* @return Whether the Uri authority is ExternalStorageProvider.
*/
public static boolean isExternalStorageDocument(Uri uri) {
return "com.android.externalstorage.documents".equals(uri.getAuthority());
}
/**
* @param uri The Uri to check.
* @return Whether the Uri authority is DownloadsProvider.
*/
public static boolean isDownloadsDocument(Uri uri) {
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
}
/**
* @param uri The Uri to check.
* @return Whether the Uri authority is MediaProvider.
*/
public static boolean isMediaDocument(Uri uri) {
return "com.android.providers.media.documents".equals(uri.getAuthority());
}
/**
* @param uri The Uri to check.
* @return Whether the Uri authority is Google Photos.
*/
public static boolean isGooglePhotosUri(Uri uri) {
return "com.google.android.apps.photos.content".equals(uri.getAuthority());
}
//byte数组到图片
public static void byte2image(byte[] data, String path) {
if (data.length < 3 || path.equals("")) return;
try {
FileOutputStream imageOutput = new FileOutputStream(new File(path));
imageOutput.write(data, 0, data.length);
imageOutput.close();
System.out.println("Make Picture success,Please find image in " + path);
} catch (Exception ex) {
System.out.println("Exception: " + ex);
ex.printStackTrace();
}
}
/**
* Store bitmap into specified image path
*
* @param bitmap
* @param outPath
* @throws FileNotFoundException
*/
public static void storeImage(Context context, Bitmap bitmap, String outPath) {
File f = new File(outPath);
if (f.exists()) {
f.delete();
}
try {
FileOutputStream out = new FileOutputStream(f);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.flush();
out.close();
LogUtils.d("storeImage", "已经保存");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
Uri data = Uri.fromFile(new File(outPath));
mediaScanIntent.setData(data);
context.sendBroadcast(mediaScanIntent);
}
/**
* Store bitmap into specified image path
*
* @param bitmap
* @param outPath
* @throws FileNotFoundException
*/
public static void storeImage(Context context, byte[] bitmap, String outPath) {
File f = new File(outPath);
if (f.exists()) {
f.delete();
}
try {
File file = new File(outPath);
FileOutputStream fops = new FileOutputStream(file);
fops.write(bitmap);
fops.flush();
fops.close();
LogUtils.d("storeImage", "已经保存");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
Uri data = Uri.fromFile(new File(outPath));
mediaScanIntent.setData(data);
context.sendBroadcast(mediaScanIntent);
}
/**
* Store bitmap into specified image path
*
* @param bitmap
* @param outPath
* @throws FileNotFoundException
*/
public static void storeImage(Bitmap bitmap, String outPath) {
File f = new File(outPath);
try {
FileOutputStream out = new FileOutputStream(f);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
out.flush();
out.close();
LogUtils.d("storeImage", "已经保存");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Compress image by pixel, this will modify image width/height.
* Used to get thumbnail
*
* @param imgPath image path
* @param pixelW target pixel of width
* @param pixelH target pixel of height
* @return
*/
public static Bitmap ratio(String imgPath, float pixelW, float pixelH) {
BitmapFactory.Options newOpts = new BitmapFactory.Options();
// 开始读入图片,此时把options.inJustDecodeBounds 设回true,即只读边不读内容
newOpts.inJustDecodeBounds = true;
newOpts.inPreferredConfig = Bitmap.Config.RGB_565;
// Get bitmap info, but notice that bitmap is null now
Bitmap bitmap = BitmapFactory.decodeFile(imgPath, newOpts);
newOpts.inJustDecodeBounds = false;
int w = newOpts.outWidth;
int h = newOpts.outHeight;
// 想要缩放的目标尺寸
float hh = pixelH;// 设置高度为240f时,可以明显看到图片缩小了
float ww = pixelW;// 设置宽度为120f,可以明显看到图片缩小了
// 缩放比。由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可
int be = 1;//be=1表示不缩放
if (w > h && w > ww) {//如果宽度大的话根据宽度固定大小缩放
be = (int) (newOpts.outWidth / ww);
} else if (w < h && h > hh) {//如果高度高的话根据宽度固定大小缩放
be = (int) (newOpts.outHeight / hh);
}
if (be <= 0) be = 1;
newOpts.inSampleSize = be;//设置缩放比例
// 开始压缩图片,注意此时已经把options.inJustDecodeBounds 设回false了
bitmap = BitmapFactory.decodeFile(imgPath, newOpts);
// 压缩好比例大小后再进行质量压缩
// return compress(bitmap, maxSize); // 这里再进行质量压缩的意义不大,反而耗资源,删除
return bitmap;
}
/**
* Compress image by size, this will modify image width/height.
* Used to get thumbnail
*
* @param image
* @param pixelW target pixel of width
* @param pixelH target pixel of height
* @return
*/
public static Bitmap ratio(Bitmap image, float pixelW, float pixelH) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 100, os);
if (os.toByteArray().length / 1024 > 1024) {//判断如果图片大于1M,进行压缩避免在生成图片(BitmapFactory.decodeStream)时溢出
os.reset();//重置baos即清空baos
image.compress(Bitmap.CompressFormat.JPEG, 50, os);//这里压缩50%,把压缩后的数据存放到baos中
}
ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
BitmapFactory.Options newOpts = new BitmapFactory.Options();
//开始读入图片,此时把options.inJustDecodeBounds 设回true了
newOpts.inJustDecodeBounds = true;
newOpts.inPreferredConfig = Bitmap.Config.RGB_565;
Bitmap bitmap = BitmapFactory.decodeStream(is, null, newOpts);
newOpts.inJustDecodeBounds = false;
int w = newOpts.outWidth;
int h = newOpts.outHeight;
float hh = pixelH;// 设置高度为240f时,可以明显看到图片缩小了
float ww = pixelW;// 设置宽度为120f,可以明显看到图片缩小了
//缩放比。由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可
int be = 1;//be=1表示不缩放
if (w > h && w > ww) {//如果宽度大的话根据宽度固定大小缩放
be = (int) (newOpts.outWidth / ww);
} else if (w < h && h > hh) {//如果高度高的话根据宽度固定大小缩放
be = (int) (newOpts.outHeight / hh);
}
if (be <= 0) be = 1;
newOpts.inSampleSize = be;//设置缩放比例
//重新读入图片,注意此时已经把options.inJustDecodeBounds 设回false了
is = new ByteArrayInputStream(os.toByteArray());
bitmap = BitmapFactory.decodeStream(is, null, newOpts);
//压缩好比例大小后再进行质量压缩
// return compress(bitmap, maxSize); // 这里再进行质量压缩的意义不大,反而耗资源,删除
return bitmap;
}
/**
* Compress by quality, and generate image to the path specified
*
* @param image
* @param outPath
* @param maxSize target will be compressed to be smaller than this size.(kb)
* @throws IOException
*/
public static void compressAndGenImage(Bitmap image, String outPath, int maxSize) throws IOException {
ByteArrayOutputStream os = new ByteArrayOutputStream();
// scale
int options = 100;
// Store the bitmap into output stream(no compress)
image.compress(Bitmap.CompressFormat.JPEG, options, os);
// Compress by loop
while (os.toByteArray().length / 1024 > maxSize) {
// Clean up os
os.reset();
// interval 10
options -= 10;
Log.e("options", "options : " + options);
if (options < 10) {
return;
}
image.compress(Bitmap.CompressFormat.JPEG, options, os);
}
// Generate compressed image file
FileOutputStream fos = new FileOutputStream(outPath);
fos.write(os.toByteArray());
fos.flush();
fos.close();
}
private static int compressRatio(int currentKb, int targetKb) {
int ratio;
ratio = (int) Math.max(10, currentKb / Math.sqrt((double) currentKb / targetKb));
return ratio;
}
/**
* Compress by quality, and generate image to the path specified
*
* @param imgPath
* @param outPath
* @param maxSize target will be compressed to be smaller than this size.(kb)
* @param needsDelete Whether delete original file after compress
* @throws IOException
*/
public static void compressAndGenImage(String imgPath, String outPath, int maxSize, boolean needsDelete) throws IOException {
compressAndGenImage(getBitmap(imgPath), outPath, maxSize);
// Delete original file
if (needsDelete) {
File file = new File(imgPath);
if (file.exists()) {
file.delete();
}
}
}
/**
* Ratio and generate thumb to the path specified
*
* @param image
* @param outPath
* @param pixelW target pixel of width
* @param pixelH target pixel of height
* @throws FileNotFoundException
*/
public static void ratioAndGenThumb(Bitmap image, String outPath, float pixelW, float pixelH) throws FileNotFoundException {
Bitmap bitmap = ratio(image, pixelW, pixelH);
storeImage(bitmap, outPath);
}
/**
* Ratio and generate thumb to the path specified
*
* @param imgPath
* @param outPath
* @param pixelW target pixel of width
* @param pixelH target pixel of height
* @param needsDelete Whether delete original file after compress
* @throws FileNotFoundException
*/
public static void ratioAndGenThumb(String imgPath, String outPath, float pixelW, float pixelH, boolean needsDelete) throws FileNotFoundException {
Bitmap bitmap = ratio(imgPath, pixelW, pixelH);
storeImage(bitmap, outPath);
// Delete original file
if (needsDelete) {
File file = new File(imgPath);
if (file.exists()) {
file.delete();
}
}
}
public static String getRealPathFromContentURI(Context ctx, Uri contentUri) {
String result = "";
if (null != contentUri && !"".equals(contentUri.toString())) {
String scheme = contentUri.getScheme();
if (ContentResolver.SCHEME_FILE.equals(scheme)) {
result = contentUri.getPath();
} else if (ContentResolver.SCHEME_CONTENT.equals(scheme)) {
String[] proj = {MediaStore.Images.Media.DATA};
Cursor cursor = null;
try {
cursor = ctx.getContentResolver().query(contentUri, proj, null, null, null);
int column_index = 0;
if (cursor != null) {
column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
if (cursor.getCount() > 0) {
cursor.moveToFirst();
result = cursor.getString(column_index);
} else {
result = "";
}
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
if (cursor != null) {
cursor.close();
}
}
} else {
result = contentUri.toString();
}
}
return result;
}
public static void savePhotoToSysAlbum(Context context, String path) {
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
Uri data = Uri.fromFile(new File(path));
mediaScanIntent.setData(data);
context.sendBroadcast(mediaScanIntent);
}
public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId,
int reqWidth, int reqHeight) {
// First decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(res, resId, options);
// Calculate inSampleSize
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
return BitmapFactory.decodeResource(res, resId, options);
}
public static Bitmap decodeBitmapFromFile(String path) {
// First decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, options);
// Calculate inSampleSize
options.inSampleSize = 1;
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(path, options);
}
public static Bitmap decodeSampledBitmapFromFile(String path,
int reqWidth, int reqHeight) {
// First decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, options);
// Calculate inSampleSize
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(path, options);
}
public static Bitmap decodeSampledBitmapFromBytes(byte[] data,
int reqWidth, int reqHeight) {
// First decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeByteArray(data, 0, data.length, options);
// Calculate inSampleSize
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
return BitmapFactory.decodeByteArray(data, 0, data.length, options);
}
public static Bitmap compressBitmap(Bitmap image, int maxKb) {
byte[] data = compressImage(image, maxKb);
LogUtils.e("bitmap " + data.length);
ByteArrayInputStream isBm = new ByteArrayInputStream(data);//把压缩后的数据baos存放到ByteArrayInputStream中
return BitmapFactory.decodeStream(isBm, null, null);//把ByteArrayInputStream数据生成图片
}
public static byte[] compressImage(Bitmap image, int maxKb) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int options = 100;
image.compress(Bitmap.CompressFormat.JPEG, options, baos);//质量压缩方法,这里100表示不压缩,把压缩后的数据存放到baos中
while (baos.toByteArray().length / 1024 > maxKb && options > 10) { //循环判断如果压缩后图片是否大于maxKb,大于继续压缩
int de = Math.min(options / 2, 10);
options -= de;
baos.reset();//重置baos即清空baos
image.compress(Bitmap.CompressFormat.JPEG, options, baos);//这里压缩options%,把压缩后的数据存放到baos中
}
return baos.toByteArray();
}
private static byte[] compress(Bitmap image, int resw, int resh) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 100, baos);
if (baos.toByteArray().length / 1024 > 1024) {//判断如果图片大于1M,进行压缩避免在生成图片(BitmapFactory.decodeStream)时溢出
baos.reset();//重置baos即清空baos
image.compress(Bitmap.CompressFormat.JPEG, 50, baos);//这里压缩50%,把压缩后的数据存放到baos中
}
ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray());
BitmapFactory.Options newOpts = new BitmapFactory.Options();
//开始读入图片,此时把options.inJustDecodeBounds 设回true了
newOpts.inJustDecodeBounds = true;
Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, newOpts);
newOpts.inJustDecodeBounds = false;
int w = newOpts.outWidth;
int h = newOpts.outHeight;
//现在主流手机比较多是800*480分辨率,所以高和宽我们设置为
int hh = resh;//这里设置高度为800f
int ww = resw;//这里设置宽度为480f
//缩放比。由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可
int be = 1;//be=1表示不缩放
if (w > h && w > ww) {//如果宽度大的话根据宽度固定大小缩放
be = (int) (newOpts.outWidth / ww);
} else if (w < h && h > hh) {//如果高度高的话根据宽度固定大小缩放
be = (int) (newOpts.outHeight / hh);
}
if (be <= 0)
be = 1;
newOpts.inSampleSize = be;//设置缩放比例
//重新读入图片,注意此时已经把options.inJustDecodeBounds 设回false了
isBm = new ByteArrayInputStream(baos.toByteArray());
bitmap = BitmapFactory.decodeStream(isBm, null, newOpts);
return compressImage(bitmap, 100);//压缩好比例大小后再进行质量压缩
}
/**
* 计算文件大小
*
* @param path
* @return
*/
public static int checkFileSize(String path) {
File filenew = new File(path);
int file_size = Integer.parseInt(String.valueOf(filenew.length() / 1024));
return file_size;
}
public static String getFileType(String filePath) {
return filePath.substring(filePath.lastIndexOf('.') + 1, filePath.length());
}
/**
* 根据给定的宽进行缩放
*
* @param origin 原图
* @param newWidth 新图的宽
* @return new Bitmap
*/
public static Bitmap scaleBitmap(Bitmap origin, int newWidth) {
if (origin == null) {
return null;
}
int width = origin.getWidth();
if (newWidth > width) {
return origin;
}
int height = origin.getHeight();
int newHeight = newWidth * height / width;
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);// 使用后乘
Bitmap newBM = Bitmap.createBitmap(origin, 0, 0, width, height, matrix, false);
if (!origin.isRecycled()) {
origin.recycle();
}
return newBM;
}
}
| 95,949 | 0.551352 | 0.545057 | 2,579 | 35.587437 | 24.904276 | 151 | false | false | 0 | 0 | 0 | 0 | 77 | 0.003243 | 0.647926 | false | false |
0
|
5db2770be01a180f0728748c6287fb072495f94b
| 8,375,186,261,874 |
42e94aa09fe8d979f77449e08c67fa7175a3e6eb
|
/src/net/Mg.java
|
f2426e93c000469233846c61e94419c5a2036e41
|
[
"Unlicense"
] |
permissive
|
HausemasterIssue/novoline
|
https://github.com/HausemasterIssue/novoline
|
6fa90b89d5ebf6b7ae8f1d1404a80a057593ea91
|
9146c4add3aa518d9aa40560158e50be1b076cf0
|
refs/heads/main
| 2023-09-05T00:20:17.943000 | 2021-11-26T02:35:25 | 2021-11-26T02:35:25 | 432,312,803 | 1 | 0 |
Unlicense
| true | 2021-11-26T22:12:46 | 2021-11-26T22:12:45 | 2021-11-26T21:05:48 | 2021-11-26T02:35:25 | 13,795 | 0 | 0 | 0 | null | false | false |
package net;
import cc.novoline.modules.configurations.property.object.BooleanProperty;
import cc.novoline.modules.visual.Camera;
import com.google.gson.JsonObject;
public class Mg {
public static JsonObject c(Camera var0) {
return var0.getJsonObject();
}
public static boolean b(Camera var0) {
return var0.isEnabled();
}
public static BooleanProperty e(Camera var0) {
return var0.getNoHurtCam();
}
public static BooleanProperty a(Camera var0) {
return var0.getViewClip();
}
public static boolean d(Camera var0) {
return var0.f();
}
}
|
UTF-8
|
Java
| 601 |
java
|
Mg.java
|
Java
|
[] | null |
[] |
package net;
import cc.novoline.modules.configurations.property.object.BooleanProperty;
import cc.novoline.modules.visual.Camera;
import com.google.gson.JsonObject;
public class Mg {
public static JsonObject c(Camera var0) {
return var0.getJsonObject();
}
public static boolean b(Camera var0) {
return var0.isEnabled();
}
public static BooleanProperty e(Camera var0) {
return var0.getNoHurtCam();
}
public static BooleanProperty a(Camera var0) {
return var0.getViewClip();
}
public static boolean d(Camera var0) {
return var0.f();
}
}
| 601 | 0.695507 | 0.678869 | 27 | 21.25926 | 20.527475 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false |
0
|
f77e4e11044fbfe85034048c36afbb242ba805b8
| 18,013,092,840,774 |
2ba030b419ab944199f32b7c40863d29aa99f262
|
/Department/src/department/Record.java
|
b03c6bd3c65f5d3f6c28736e23a2f9a0e46df697
|
[] |
no_license
|
Kareemkhaled617/Javafx_Dept
|
https://github.com/Kareemkhaled617/Javafx_Dept
|
fc5d7c01bc0b41177423439057012b6fd9954463
|
acf07f4492989e2f0e155f14c4531481a40119e9
|
refs/heads/main
| 2023-03-25T23:51:25.107000 | 2021-03-20T17:28:13 | 2021-03-20T17:28:13 | 349,790,879 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package department;
public class Record {
private int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
private String Dept_name;
private int Age;
private String Address;
public String getDept_name() {
return Dept_name;
}
public void setDept_name(String Dept_name) {
this.Dept_name = Dept_name;
}
public int getAge() {
return Age;
}
public void setAge(int Age) {
this.Age = Age;
}
public String getAddress() {
return Address;
}
public void setAddress(String Address) {
this.Address = Address;
}
}
|
UTF-8
|
Java
| 747 |
java
|
Record.java
|
Java
|
[] | null |
[] |
package department;
public class Record {
private int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
private String Dept_name;
private int Age;
private String Address;
public String getDept_name() {
return Dept_name;
}
public void setDept_name(String Dept_name) {
this.Dept_name = Dept_name;
}
public int getAge() {
return Age;
}
public void setAge(int Age) {
this.Age = Age;
}
public String getAddress() {
return Address;
}
public void setAddress(String Address) {
this.Address = Address;
}
}
| 747 | 0.514056 | 0.514056 | 45 | 14.555555 | 13.786556 | 48 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.288889 | false | false |
0
|
daf47a9daa2e1506fc003529f0a052d3e522f414
| 32,530,082,332,295 |
7f68d13e28a5965688f4ab960754b7f88f8bcb09
|
/app/src/main/java/com/grability/appstore/utils/IntentUtil.java
|
fd5d4452149c868faf0ab3106362ff77fb29aeda
|
[
"CC-BY-3.0",
"Apache-2.0"
] |
permissive
|
wilsoncastiblanco/appstore
|
https://github.com/wilsoncastiblanco/appstore
|
a8780da12b8a19df0c40b83a4284d80bac7bfb23
|
7ac721fa79db8deba494e45752df57066a7295c2
|
refs/heads/master
| 2021-01-10T02:18:37.245000 | 2016-04-11T19:05:29 | 2016-04-11T19:05:29 | 55,615,208 | 1 | 0 | null | false | 2016-04-11T07:20:53 | 2016-04-06T14:57:31 | 2016-04-06T15:02:45 | 2016-04-11T07:20:53 | 389 | 0 | 0 | 0 |
Java
| null | null |
package com.grability.appstore.utils;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.grability.appstore.R;
import com.grability.appstore.models.ApplicationEntry;
import com.grability.appstore.modules.apps.AppsActivity;
import com.grability.appstore.modules.apps.detail.AppDetailActivity;
import com.grability.appstore.modules.apps.detail.AppDetailActivityFragment;
import com.grability.appstore.modules.categories.CategoriesActivity;
import com.grability.appstore.modules.loader.LoaderActivity;
public class IntentUtil {
public static final String KEY_DATA = "key_data";
public static final String KEY_AUX = "key_aux";
public static void startActivity(Context context, Class<?> cls) {
context.startActivity(new Intent(context, cls));
}
public static void startLoaderActivity(Activity activity){
startActivity(activity, LoaderActivity.class);
}
public static void startCategoriesActivity(Activity activity){
startActivity(activity, CategoriesActivity.class);
}
public static void startAppsActivity(Activity activity, String categoryId, String categoryName){
Intent intent = new Intent(activity, AppsActivity.class);
intent.putExtra(KEY_DATA, categoryId);
intent.putExtra(KEY_AUX, categoryName);
activity.startActivity(intent);
}
public static void startAppDetailActivity(Activity activity, ApplicationEntry applicationEntry){
Intent intent = new Intent(activity, AppDetailActivity.class);
intent.putExtra(KEY_DATA, new Gson().toJson(applicationEntry));
activity.startActivity(intent);
}
public static void replaceAppDetailFragment(AppCompatActivity activity, ApplicationEntry applicationEntry){
Bundle arguments = new Bundle();
arguments.putString(IntentUtil.KEY_DATA, new Gson().toJson(applicationEntry));
AppDetailActivityFragment fragment = new AppDetailActivityFragment();
fragment.setArguments(arguments);
activity.getSupportFragmentManager().beginTransaction().replace(R.id.itemDetailContainer, fragment).commit();
}
}
|
UTF-8
|
Java
| 2,221 |
java
|
IntentUtil.java
|
Java
|
[] | null |
[] |
package com.grability.appstore.utils;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.grability.appstore.R;
import com.grability.appstore.models.ApplicationEntry;
import com.grability.appstore.modules.apps.AppsActivity;
import com.grability.appstore.modules.apps.detail.AppDetailActivity;
import com.grability.appstore.modules.apps.detail.AppDetailActivityFragment;
import com.grability.appstore.modules.categories.CategoriesActivity;
import com.grability.appstore.modules.loader.LoaderActivity;
public class IntentUtil {
public static final String KEY_DATA = "key_data";
public static final String KEY_AUX = "key_aux";
public static void startActivity(Context context, Class<?> cls) {
context.startActivity(new Intent(context, cls));
}
public static void startLoaderActivity(Activity activity){
startActivity(activity, LoaderActivity.class);
}
public static void startCategoriesActivity(Activity activity){
startActivity(activity, CategoriesActivity.class);
}
public static void startAppsActivity(Activity activity, String categoryId, String categoryName){
Intent intent = new Intent(activity, AppsActivity.class);
intent.putExtra(KEY_DATA, categoryId);
intent.putExtra(KEY_AUX, categoryName);
activity.startActivity(intent);
}
public static void startAppDetailActivity(Activity activity, ApplicationEntry applicationEntry){
Intent intent = new Intent(activity, AppDetailActivity.class);
intent.putExtra(KEY_DATA, new Gson().toJson(applicationEntry));
activity.startActivity(intent);
}
public static void replaceAppDetailFragment(AppCompatActivity activity, ApplicationEntry applicationEntry){
Bundle arguments = new Bundle();
arguments.putString(IntentUtil.KEY_DATA, new Gson().toJson(applicationEntry));
AppDetailActivityFragment fragment = new AppDetailActivityFragment();
fragment.setArguments(arguments);
activity.getSupportFragmentManager().beginTransaction().replace(R.id.itemDetailContainer, fragment).commit();
}
}
| 2,221 | 0.794237 | 0.793787 | 59 | 36.64407 | 31.520649 | 113 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.79661 | false | false |
0
|
827e496afd324e1887dc77e4cce36a0c5c8fe43a
| 29,875,792,511,823 |
82f8612f24ba932524398c79a16f6f072277ac05
|
/diboot-modules/diboot-message/src/main/java/com/diboot/message/channel/SimpleEmailChannel.java
|
9889b153c4cb1d7c54ff940e8a78c91a4c79e7cc
|
[
"Apache-2.0"
] |
permissive
|
lezengcai/diboot-cloud
|
https://github.com/lezengcai/diboot-cloud
|
a87a121f5dd2f3b6f23d9b7973dafcb878fb1bc1
|
24dac4a373b4828659603c22d1192ea0ba9a32ba
|
refs/heads/main
| 2023-07-15T16:34:14.356000 | 2021-08-10T09:17:22 | 2021-08-10T09:17:22 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* Copyright (c) 2015-2021, www.dibo.ltd (service@dibo.ltd).
* <p>
* 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
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.diboot.message.channel;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.diboot.core.util.JSON;
import com.diboot.core.util.V;
import com.diboot.message.config.Cons;
import com.diboot.message.entity.Message;
import com.diboot.message.service.MessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.scheduling.annotation.Async;
import java.util.Date;
/**
* 简单邮件发送通道
* <p>
* 只支持发送文本,其他自行扩展
*
* @author : uu
* @version : v1.0
* @Date 2021/2/20 15:45
* @Copyright © diboot.com
*/
@Slf4j
public class SimpleEmailChannel implements ChannelStrategy {
@Autowired(required = false)
private JavaMailSender javaMailSender;
@Autowired
private MessageService messageService;
@Override
@Async
public void send(Message message) {
log.debug("[开始发送邮件]:邮件内容:{}", JSON.stringify(message));
String result = "success";
String status = Cons.MESSAGE_STATUS.DELIVERY.getItemValue();
try {
// 构建一个邮件对象
SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
// 设置邮件主题
simpleMailMessage.setSubject(message.getTitle());
// 设置发送人
simpleMailMessage.setFrom(message.getSender());
// 优先设置Receivers
if (V.notEmpty(message.getReceivers())) {
simpleMailMessage.setTo(message.getReceivers());
} else {
simpleMailMessage.setTo(message.getReceiver());
}
// 设置抄送人
simpleMailMessage.setCc(message.getCcEmails());
// 设置隐秘抄送人
simpleMailMessage.setBcc(message.getBccEmails());
// 设置邮件发送日期
simpleMailMessage.setSentDate(new Date());
// 设置邮件内容
simpleMailMessage.setText(message.getContent());
// 发送邮件
javaMailSender.send(simpleMailMessage);
} catch (Exception e) {
log.error("[发送邮件失败]:信息为: {} , 异常", message, e);
result = e.getMessage();
status = Cons.MESSAGE_STATUS.EXCEPTION.getItemValue();
}
// 更新结果
messageService.updateEntity(
Wrappers.<Message>lambdaUpdate()
.set(Message::getResult, result)
.set(Message::getStatus, status)
.eq(Message::getId, message.getId())
);
}
}
|
UTF-8
|
Java
| 3,420 |
java
|
SimpleEmailChannel.java
|
Java
|
[
{
"context": "/*\n * Copyright (c) 2015-2021, www.dibo.ltd (service@dibo.ltd).\n * <p>\n * Licensed under the Apache License, Ve",
"end": 61,
"score": 0.9999250769615173,
"start": 45,
"tag": "EMAIL",
"value": "service@dibo.ltd"
},
{
"context": " 简单邮件发送通道\n * <p>\n * 只支持发送文本,其他自行扩展\n *\n * @author : uu\n * @version : v1.0\n * @Date 2021/2/20 15:45\n * @",
"end": 1268,
"score": 0.9960659146308899,
"start": 1266,
"tag": "USERNAME",
"value": "uu"
}
] | null |
[] |
/*
* Copyright (c) 2015-2021, www.dibo.ltd (<EMAIL>).
* <p>
* 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
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.diboot.message.channel;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.diboot.core.util.JSON;
import com.diboot.core.util.V;
import com.diboot.message.config.Cons;
import com.diboot.message.entity.Message;
import com.diboot.message.service.MessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.scheduling.annotation.Async;
import java.util.Date;
/**
* 简单邮件发送通道
* <p>
* 只支持发送文本,其他自行扩展
*
* @author : uu
* @version : v1.0
* @Date 2021/2/20 15:45
* @Copyright © diboot.com
*/
@Slf4j
public class SimpleEmailChannel implements ChannelStrategy {
@Autowired(required = false)
private JavaMailSender javaMailSender;
@Autowired
private MessageService messageService;
@Override
@Async
public void send(Message message) {
log.debug("[开始发送邮件]:邮件内容:{}", JSON.stringify(message));
String result = "success";
String status = Cons.MESSAGE_STATUS.DELIVERY.getItemValue();
try {
// 构建一个邮件对象
SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
// 设置邮件主题
simpleMailMessage.setSubject(message.getTitle());
// 设置发送人
simpleMailMessage.setFrom(message.getSender());
// 优先设置Receivers
if (V.notEmpty(message.getReceivers())) {
simpleMailMessage.setTo(message.getReceivers());
} else {
simpleMailMessage.setTo(message.getReceiver());
}
// 设置抄送人
simpleMailMessage.setCc(message.getCcEmails());
// 设置隐秘抄送人
simpleMailMessage.setBcc(message.getBccEmails());
// 设置邮件发送日期
simpleMailMessage.setSentDate(new Date());
// 设置邮件内容
simpleMailMessage.setText(message.getContent());
// 发送邮件
javaMailSender.send(simpleMailMessage);
} catch (Exception e) {
log.error("[发送邮件失败]:信息为: {} , 异常", message, e);
result = e.getMessage();
status = Cons.MESSAGE_STATUS.EXCEPTION.getItemValue();
}
// 更新结果
messageService.updateEntity(
Wrappers.<Message>lambdaUpdate()
.set(Message::getResult, result)
.set(Message::getStatus, status)
.eq(Message::getId, message.getId())
);
}
}
| 3,411 | 0.644659 | 0.635939 | 94 | 33.159573 | 24.217236 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.478723 | false | false |
0
|
ac97793ba2a0202dd2133bbfb812ddd20dfa6de8
| 4,028,679,325,121 |
338c60094f63019bd6f6846e67a6dc93733e8ade
|
/ICSSMS/src/main/java/com/androidproductions/ics/sms/data/Contact.java
|
3666ffa14085b7adf1ad136b180cc566ed18d167
|
[
"Apache-2.0"
] |
permissive
|
azurenightwalker/icssms
|
https://github.com/azurenightwalker/icssms
|
42f530078afc2357cb526496119abeeb8529ed1c
|
7c44d3863a6760112c7978a30edf11cfa78091c3
|
refs/heads/master
| 2021-01-01T15:18:54.218000 | 2013-09-09T16:49:08 | 2013-09-09T16:49:09 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.androidproductions.ics.sms.data;
import android.database.Cursor;
import android.provider.ContactsContract;
class Contact {
private final String displayName;
private final String phoneNumber;
public Contact(final String name, final String number)
{
displayName = name;
phoneNumber = number;
}
public Contact(final Cursor cur)
{
displayName = cur.getString(cur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
phoneNumber = cur.getString(cur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
}
public String getDisplayName() {
return displayName;
}
public String getPhoneNumber() {
return phoneNumber;
}
}
|
UTF-8
|
Java
| 753 |
java
|
Contact.java
|
Java
|
[] | null |
[] |
package com.androidproductions.ics.sms.data;
import android.database.Cursor;
import android.provider.ContactsContract;
class Contact {
private final String displayName;
private final String phoneNumber;
public Contact(final String name, final String number)
{
displayName = name;
phoneNumber = number;
}
public Contact(final Cursor cur)
{
displayName = cur.getString(cur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
phoneNumber = cur.getString(cur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
}
public String getDisplayName() {
return displayName;
}
public String getPhoneNumber() {
return phoneNumber;
}
}
| 753 | 0.705179 | 0.705179 | 29 | 24.965517 | 27.784246 | 109 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.413793 | false | false |
0
|
62a31e2734eb02f42d6194431381cfb33182236d
| 29,970,281,860,430 |
8b7069ad5629bb29c831133e5f0e7d0d1e7271c5
|
/app/src/main/java/com/example/zhang1ks/mywallet/TabFg1.java
|
b4660b724de52c45c2cd354617fc828d014ad1c9
|
[] |
no_license
|
zhang1ks/MyWallet
|
https://github.com/zhang1ks/MyWallet
|
ff9706637cb88124106aed69aed7d6d455cf64c7
|
b0ada5d7617907661149ead28b84769b24aad79b
|
refs/heads/master
| 2020-12-30T13:46:34.966000 | 2017-05-14T15:50:17 | 2017-05-14T15:50:17 | 91,254,291 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.zhang1ks.mywallet;
import android.content.ClipData;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.DragEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.VideoView;
/**
* Created by yuge on 11/14/2016.
*/
public class TabFg1 extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fg1_tab, container, false);
//Set LongClickListener and DragListener to all image views of payment cards
view.findViewById(R.id.card1).setOnLongClickListener(listenClick);
view.findViewById(R.id.card1).setOnDragListener(listenDrag);
view.findViewById(R.id.card2).setOnLongClickListener(listenClick);
view.findViewById(R.id.card2).setOnDragListener(listenDrag);
view.findViewById(R.id.card3).setOnLongClickListener(listenClick);
view.findViewById(R.id.card3).setOnDragListener(listenDrag);
view.findViewById(R.id.card4).setOnLongClickListener(listenClick);
view.findViewById(R.id.card4).setOnDragListener(listenDrag);
view.findViewById(R.id.card5).setOnLongClickListener(listenClick);
view.findViewById(R.id.card5).setOnDragListener(listenDrag);
return view;
}
//Define LongClickListener
View.OnLongClickListener listenClick = new View.OnLongClickListener()
{
@Override
public boolean onLongClick(View v)
{
ClipData data = ClipData.newPlainText("","");
DragShadow dragShadow = new DragShadow(v);//Shadow generated once long pressed.
v.startDrag(data, dragShadow, v, 0);
return false;
}
};
//Define DragListener
View.OnDragListener listenDrag = new View.OnDragListener() {
@Override
public boolean onDrag(View v, DragEvent event)
{
int dragEvent = event.getAction();
switch (dragEvent)
{
//Once an item dragged...log it.
case DragEvent.ACTION_DRAG_ENTERED:
Log.i("Drag Event", "Entered");
break;
//Cancel drag operation and log it.
case DragEvent.ACTION_DRAG_EXITED:
Log.i("Drag Event", "Exited");
break;
//Drag an item onto another and drop to replace it.
//Make dragged item and target item take the place of each other.
case DragEvent.ACTION_DROP:
ImageView target = (ImageView) v;
ImageView dragged = (ImageView) event.getLocalState();
Drawable target_draw = target.getDrawable();
Drawable dragged_draw = dragged.getDrawable();
dragged.setImageDrawable(target_draw);
target.setImageDrawable(dragged_draw);
break;
}
return true;
}
};
//Build the shadow animation while an item is dragged
private class DragShadow extends View.DragShadowBuilder
{
ColorDrawable greyBox;
public DragShadow(View view)
{
super(view);
greyBox = new ColorDrawable(Color.LTGRAY);
}
@Override
public void onDrawShadow(Canvas canvas)
{
greyBox.draw(canvas);
}
@Override
public void onProvideShadowMetrics(Point shadowSize,
Point shadowTouchPoint)
{
View v = getView();
int height = v.getHeight();
int width = v.getWidth();
greyBox.setBounds(0, 0, width, height);
//Shadow has the same size of dragged item.
shadowSize.set(width, height);
//Set touch point of the shadow to its center
shadowTouchPoint.set(width/2, height/2);
}
}
}
|
UTF-8
|
Java
| 4,622 |
java
|
TabFg1.java
|
Java
|
[
{
"context": "package com.example.zhang1ks.mywallet;\n\nimport android.content.ClipData;\nimpor",
"end": 28,
"score": 0.8945427536964417,
"start": 20,
"tag": "USERNAME",
"value": "zhang1ks"
},
{
"context": "mport android.widget.VideoView;\n\n/**\n * Created by yuge on 11/14/2016.\n */\n\npublic class TabFg1 extends F",
"end": 803,
"score": 0.9996633529663086,
"start": 799,
"tag": "USERNAME",
"value": "yuge"
}
] | null |
[] |
package com.example.zhang1ks.mywallet;
import android.content.ClipData;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.DragEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.VideoView;
/**
* Created by yuge on 11/14/2016.
*/
public class TabFg1 extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fg1_tab, container, false);
//Set LongClickListener and DragListener to all image views of payment cards
view.findViewById(R.id.card1).setOnLongClickListener(listenClick);
view.findViewById(R.id.card1).setOnDragListener(listenDrag);
view.findViewById(R.id.card2).setOnLongClickListener(listenClick);
view.findViewById(R.id.card2).setOnDragListener(listenDrag);
view.findViewById(R.id.card3).setOnLongClickListener(listenClick);
view.findViewById(R.id.card3).setOnDragListener(listenDrag);
view.findViewById(R.id.card4).setOnLongClickListener(listenClick);
view.findViewById(R.id.card4).setOnDragListener(listenDrag);
view.findViewById(R.id.card5).setOnLongClickListener(listenClick);
view.findViewById(R.id.card5).setOnDragListener(listenDrag);
return view;
}
//Define LongClickListener
View.OnLongClickListener listenClick = new View.OnLongClickListener()
{
@Override
public boolean onLongClick(View v)
{
ClipData data = ClipData.newPlainText("","");
DragShadow dragShadow = new DragShadow(v);//Shadow generated once long pressed.
v.startDrag(data, dragShadow, v, 0);
return false;
}
};
//Define DragListener
View.OnDragListener listenDrag = new View.OnDragListener() {
@Override
public boolean onDrag(View v, DragEvent event)
{
int dragEvent = event.getAction();
switch (dragEvent)
{
//Once an item dragged...log it.
case DragEvent.ACTION_DRAG_ENTERED:
Log.i("Drag Event", "Entered");
break;
//Cancel drag operation and log it.
case DragEvent.ACTION_DRAG_EXITED:
Log.i("Drag Event", "Exited");
break;
//Drag an item onto another and drop to replace it.
//Make dragged item and target item take the place of each other.
case DragEvent.ACTION_DROP:
ImageView target = (ImageView) v;
ImageView dragged = (ImageView) event.getLocalState();
Drawable target_draw = target.getDrawable();
Drawable dragged_draw = dragged.getDrawable();
dragged.setImageDrawable(target_draw);
target.setImageDrawable(dragged_draw);
break;
}
return true;
}
};
//Build the shadow animation while an item is dragged
private class DragShadow extends View.DragShadowBuilder
{
ColorDrawable greyBox;
public DragShadow(View view)
{
super(view);
greyBox = new ColorDrawable(Color.LTGRAY);
}
@Override
public void onDrawShadow(Canvas canvas)
{
greyBox.draw(canvas);
}
@Override
public void onProvideShadowMetrics(Point shadowSize,
Point shadowTouchPoint)
{
View v = getView();
int height = v.getHeight();
int width = v.getWidth();
greyBox.setBounds(0, 0, width, height);
//Shadow has the same size of dragged item.
shadowSize.set(width, height);
//Set touch point of the shadow to its center
shadowTouchPoint.set(width/2, height/2);
}
}
}
| 4,622 | 0.630679 | 0.624838 | 146 | 30.664383 | 26.58671 | 123 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.547945 | false | false |
0
|
72cba65c3c0af82db713711e49f6850c65a0ecf2
| 19,069,654,805,138 |
5f2be2df1592121fb4b383b3bfdf30d903a6d074
|
/app/src/main/java/com/netglue/ngtmobile/model/AssetPushItem.java
|
ffd98be44260c729cf035440a05939a4e2ede0db
|
[] |
no_license
|
waterflower124/android-event-notice-app
|
https://github.com/waterflower124/android-event-notice-app
|
6f037e58ebe87360fae23171282a58f028c2e3ef
|
0b8c4a9d5d67e33a8964181d57a6ccde4faf47cf
|
refs/heads/main
| 2023-05-07T03:44:37.833000 | 2021-05-27T02:11:02 | 2021-05-27T02:11:02 | 371,220,023 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.netglue.ngtmobile.model;
import java.util.ArrayList;
public class AssetPushItem {
private String assets_id;
private ArrayList<Integer> alarm_id_list;
public AssetPushItem(String assets_id, ArrayList<Integer> alarm_id_list) {
this.assets_id = assets_id;
this.alarm_id_list = alarm_id_list;
}
public String getAssets_id() {
return assets_id;
}
public void setAssets_id(String assets_id) {
this.assets_id = assets_id;
}
public ArrayList<Integer> getAlarm_id_list() {
return alarm_id_list;
}
public void setAlarm_id_list(ArrayList<Integer> alarm_id_list) {
this.alarm_id_list = alarm_id_list;
}
}
|
UTF-8
|
Java
| 709 |
java
|
AssetPushItem.java
|
Java
|
[] | null |
[] |
package com.netglue.ngtmobile.model;
import java.util.ArrayList;
public class AssetPushItem {
private String assets_id;
private ArrayList<Integer> alarm_id_list;
public AssetPushItem(String assets_id, ArrayList<Integer> alarm_id_list) {
this.assets_id = assets_id;
this.alarm_id_list = alarm_id_list;
}
public String getAssets_id() {
return assets_id;
}
public void setAssets_id(String assets_id) {
this.assets_id = assets_id;
}
public ArrayList<Integer> getAlarm_id_list() {
return alarm_id_list;
}
public void setAlarm_id_list(ArrayList<Integer> alarm_id_list) {
this.alarm_id_list = alarm_id_list;
}
}
| 709 | 0.650212 | 0.650212 | 30 | 22.633333 | 22.147209 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.366667 | false | false |
0
|
24b1c9afb77412e6ef3435c1b5dfdd9b54f98ab2
| 11,982,958,784,344 |
6a4253e0fc0df8a8273f07b4dfcfed0d1dedf6fa
|
/src/wanghang/java/JavaDemo.java
|
a59fd47c6528a9ec3ae39000f99a8cb155587be8
|
[] |
no_license
|
wanghang88/wanghang_JDK1.8
|
https://github.com/wanghang88/wanghang_JDK1.8
|
486ba127c3a2fda2cca9ab03d4e41d0ee73bbc3b
|
f2db5725ac70930577b1aa533310dff4d02c3758
|
refs/heads/master
| 2023-09-02T23:14:30.891000 | 2021-11-16T10:27:39 | 2021-11-16T10:27:39 | 361,565,358 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package wanghang.java;
/**
*
vovo关于使用java语言的总结(
1:关于多线程上下文传递
2:JMM和volatile
3:java8的Stream原理
4:字节码原理及实战
5:java的spi机制
)
https://mp.weixin.qq.com/mp/appmsgalbum?action=getalbum&album_id=1500551436353503236&__biz=MzI4NjY4MTU5Nw==#wechat_redirect
*/
public class JavaDemo {
}
|
UTF-8
|
Java
| 370 |
java
|
JavaDemo.java
|
Java
|
[] | null |
[] |
package wanghang.java;
/**
*
vovo关于使用java语言的总结(
1:关于多线程上下文传递
2:JMM和volatile
3:java8的Stream原理
4:字节码原理及实战
5:java的spi机制
)
https://mp.weixin.qq.com/mp/appmsgalbum?action=getalbum&album_id=1500551436353503236&__biz=MzI4NjY4MTU5Nw==#wechat_redirect
*/
public class JavaDemo {
}
| 370 | 0.744828 | 0.648276 | 22 | 12.181818 | 25.659725 | 124 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.045455 | false | false |
0
|
9cfd47fafb79af7e87210b80097c83509ae86661
| 33,105,607,930,159 |
8dd943facb256c1cb248246cdb0b23ba3e285100
|
/service-pb/src/main/java/com/bit/module/pb/service/impl/StudyRecordServiceImpl.java
|
543e6c20e4ee0f240e317bbff8cd80710173e04c
|
[] |
no_license
|
ouyangcode/WisdomTown
|
https://github.com/ouyangcode/WisdomTown
|
6a121be9d23e565246b41c7c29716f3035d86992
|
5176a7cd0f92d47ffee6c5b4976aa8d185025bd9
|
refs/heads/master
| 2023-09-02T06:54:37.124000 | 2020-07-09T02:29:59 | 2020-07-09T02:29:59 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.bit.module.pb.service.impl;
import com.bit.base.dto.UserInfo;
import com.bit.base.exception.BusinessException;
import com.bit.base.service.BaseService;
import com.bit.base.vo.BaseVo;
import com.bit.common.Const;
import com.bit.common.enumerate.StudySituationEnum;
import com.bit.common.enumerate.StudyUserTypeEnum;
import com.bit.module.pb.bean.PartyMember;
import com.bit.module.pb.bean.Study;
import com.bit.module.pb.bean.StudyRecord;
import com.bit.module.pb.dao.PartyMemberDao;
import com.bit.module.pb.dao.StudyDao;
import com.bit.module.pb.dao.StudyRecordDao;
import com.bit.module.pb.service.StudyRecordService;
import com.bit.module.pb.vo.StudyRecordVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @author chenduo
* @create 2019-01-25 15:15
*/
@Service("studyRecordService")
public class StudyRecordServiceImpl extends BaseService implements StudyRecordService {
@Autowired
private StudyRecordDao studyRecordDao;
@Autowired
private PartyMemberDao partyMemberDao;
@Autowired
private StudyDao studyDao;
/**
* 学习记录查询
* @param studyRecordVO
* @return
*/
@Override
public BaseVo listPage(StudyRecordVO studyRecordVO) {
PageHelper.startPage(studyRecordVO.getPageNum(),studyRecordVO.getPageSize());
UserInfo userInfo = getCurrentUserInfo();
if (userInfo!=null){
String idcard = userInfo.getIdcard();
PartyMember byIdCard = partyMemberDao.findByIdCardAndStatus(idcard);
if (byIdCard!=null){
studyRecordVO.setUserId(byIdCard.getId());
}else {
throwBusinessException("此人信息不存在");
}
}else {
throwBusinessException("请重新登录");
}
List<StudyRecord> records = studyRecordDao.listPage(studyRecordVO);
PageInfo<StudyRecord> pageInfo = new PageInfo<>(records);
BaseVo baseVo = new BaseVo();
baseVo.setData(pageInfo);
return baseVo;
}
/**
* 更新学习记录时间
* @param studyRecord
* @return
*/
@Override
@Transactional
public BaseVo updateStudyTime(StudyRecord studyRecord) {
Study study = studyDao.queryById(studyRecord.getStudyId());
if (study==null){
throwBusinessException("无此学习计划");
}
UserInfo userInfo = getCurrentUserInfo();
String cardId = userInfo.getIdcard();
//根据身份证查询党员id
PartyMember byIdCardAndStatus = partyMemberDao.findByIdCardAndStatus(cardId);
if (byIdCardAndStatus!=null){
StudyRecord temp = new StudyRecord();
temp.setUserId(byIdCardAndStatus.getId());
temp.setStudyId(studyRecord.getStudyId());
List<StudyRecord> studyRecords = studyRecordDao.queryByParam(temp);
if (studyRecords!=null && studyRecords.size()>1){
throwBusinessException("学习记录异常");
}
//20190831 添加自学人员
if (CollectionUtils.isEmpty(studyRecords)){
//如果学习记录为空 就新增一条
StudyRecord obj = new StudyRecord();
obj.setStudyId(studyRecord.getStudyId());
obj.setStudyTime(studyRecord.getStudyTime());
obj.setStudySituation(StudySituationEnum.YES.getCode());
obj.setUserId(byIdCardAndStatus.getId());
obj.setUserType(StudyUserTypeEnum.OPTIONAL.getCode());
studyRecordDao.add(obj);
}
if (studyRecords!=null && studyRecords.size() == 1){
Long id = studyRecords.get(0).getId();
StudyRecord obj = new StudyRecord();
obj.setId(id);
obj.setStudyTime(studyRecord.getStudyTime());
obj.setStudySituation(StudySituationEnum.YES.getCode());
studyRecordDao.update(obj);
}
}
return new BaseVo();
}
}
|
UTF-8
|
Java
| 4,334 |
java
|
StudyRecordServiceImpl.java
|
Java
|
[
{
"context": "sactional;\n\nimport java.util.List;\n\n/**\n * @author chenduo\n * @create 2019-01-25 15:15\n */\n@Service(\"studyRe",
"end": 1033,
"score": 0.9995971322059631,
"start": 1026,
"tag": "USERNAME",
"value": "chenduo"
}
] | null |
[] |
package com.bit.module.pb.service.impl;
import com.bit.base.dto.UserInfo;
import com.bit.base.exception.BusinessException;
import com.bit.base.service.BaseService;
import com.bit.base.vo.BaseVo;
import com.bit.common.Const;
import com.bit.common.enumerate.StudySituationEnum;
import com.bit.common.enumerate.StudyUserTypeEnum;
import com.bit.module.pb.bean.PartyMember;
import com.bit.module.pb.bean.Study;
import com.bit.module.pb.bean.StudyRecord;
import com.bit.module.pb.dao.PartyMemberDao;
import com.bit.module.pb.dao.StudyDao;
import com.bit.module.pb.dao.StudyRecordDao;
import com.bit.module.pb.service.StudyRecordService;
import com.bit.module.pb.vo.StudyRecordVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @author chenduo
* @create 2019-01-25 15:15
*/
@Service("studyRecordService")
public class StudyRecordServiceImpl extends BaseService implements StudyRecordService {
@Autowired
private StudyRecordDao studyRecordDao;
@Autowired
private PartyMemberDao partyMemberDao;
@Autowired
private StudyDao studyDao;
/**
* 学习记录查询
* @param studyRecordVO
* @return
*/
@Override
public BaseVo listPage(StudyRecordVO studyRecordVO) {
PageHelper.startPage(studyRecordVO.getPageNum(),studyRecordVO.getPageSize());
UserInfo userInfo = getCurrentUserInfo();
if (userInfo!=null){
String idcard = userInfo.getIdcard();
PartyMember byIdCard = partyMemberDao.findByIdCardAndStatus(idcard);
if (byIdCard!=null){
studyRecordVO.setUserId(byIdCard.getId());
}else {
throwBusinessException("此人信息不存在");
}
}else {
throwBusinessException("请重新登录");
}
List<StudyRecord> records = studyRecordDao.listPage(studyRecordVO);
PageInfo<StudyRecord> pageInfo = new PageInfo<>(records);
BaseVo baseVo = new BaseVo();
baseVo.setData(pageInfo);
return baseVo;
}
/**
* 更新学习记录时间
* @param studyRecord
* @return
*/
@Override
@Transactional
public BaseVo updateStudyTime(StudyRecord studyRecord) {
Study study = studyDao.queryById(studyRecord.getStudyId());
if (study==null){
throwBusinessException("无此学习计划");
}
UserInfo userInfo = getCurrentUserInfo();
String cardId = userInfo.getIdcard();
//根据身份证查询党员id
PartyMember byIdCardAndStatus = partyMemberDao.findByIdCardAndStatus(cardId);
if (byIdCardAndStatus!=null){
StudyRecord temp = new StudyRecord();
temp.setUserId(byIdCardAndStatus.getId());
temp.setStudyId(studyRecord.getStudyId());
List<StudyRecord> studyRecords = studyRecordDao.queryByParam(temp);
if (studyRecords!=null && studyRecords.size()>1){
throwBusinessException("学习记录异常");
}
//20190831 添加自学人员
if (CollectionUtils.isEmpty(studyRecords)){
//如果学习记录为空 就新增一条
StudyRecord obj = new StudyRecord();
obj.setStudyId(studyRecord.getStudyId());
obj.setStudyTime(studyRecord.getStudyTime());
obj.setStudySituation(StudySituationEnum.YES.getCode());
obj.setUserId(byIdCardAndStatus.getId());
obj.setUserType(StudyUserTypeEnum.OPTIONAL.getCode());
studyRecordDao.add(obj);
}
if (studyRecords!=null && studyRecords.size() == 1){
Long id = studyRecords.get(0).getId();
StudyRecord obj = new StudyRecord();
obj.setId(id);
obj.setStudyTime(studyRecord.getStudyTime());
obj.setStudySituation(StudySituationEnum.YES.getCode());
studyRecordDao.update(obj);
}
}
return new BaseVo();
}
}
| 4,334 | 0.657068 | 0.651594 | 116 | 35.224136 | 22.76457 | 87 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.543103 | false | false |
0
|
99f783e6872429afa65c93ed86da7008820204e1
| 12,257,836,675,254 |
f7436c6beb1e31c833e038a3412f115f51682062
|
/app/src/main/java/com/example/dailyarticle/BookCase/ArticleActivity.java
|
60c98ce6211e95414340a2c5410c1f94ef345c05
|
[
"Apache-2.0"
] |
permissive
|
jianjiandeme/Daily
|
https://github.com/jianjiandeme/Daily
|
9c21681709d3d30cec367b12fc6c00697e00d5e3
|
2af43221024c2d8c119f6790fc83e4914bee4a43
|
refs/heads/master
| 2018-02-08T02:30:59.099000 | 2017-10-19T12:22:15 | 2017-10-19T12:22:15 | 95,943,339 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.dailyarticle.BookCase;
import android.content.Intent;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
import com.example.dailyarticle.R;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import static com.example.dailyarticle.utils.MyApplication.getContext;
public class ArticleActivity extends AppCompatActivity {
String name;
String address;
String authorName;
StringBuffer article = new StringBuffer();
TextView Name, Author, Article;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_article);
Intent intent = getIntent();
//从上一层获得文章标题和地址
name = intent.getStringExtra("articleName");
address = intent.getStringExtra("articleAddress");
//设置文章标题
Name = (TextView) findViewById(R.id.articleName);
Name.setText(name);
Author = (TextView) findViewById(R.id.articleAuthor);
Article = (TextView) findViewById(R.id.article);
//异步解析网页
MyTask task = new MyTask();
task.execute("http://book.meiriyiwen.com/" + address);
}
class MyTask extends AsyncTask<String, Void, Boolean> {
@Override
protected Boolean doInBackground(String... params) {
try {
Document doc = Jsoup.connect(params[0]).get();
Elements sections = doc.getElementsByTag("p");
for (Element section : sections) {
//文章段落拼接
article.append("\t\t\t\t" + section.text() + "\n");
}
Elements authors = doc.getElementsByClass("book-author");
for (Element author : authors) {
//作者
authorName = author.text();
}
} catch (
Exception e) {
e.printStackTrace();
return false;
}
return true;
}
@Override
protected void onPostExecute(Boolean bool) {
if (bool) {
//设置作者和内容
Author.setText(authorName);
Article.setText(article);
} else {
Toast.makeText(getContext(), "未知错误", Toast.LENGTH_SHORT).show();
}
}
}
}
|
UTF-8
|
Java
| 2,630 |
java
|
ArticleActivity.java
|
Java
|
[] | null |
[] |
package com.example.dailyarticle.BookCase;
import android.content.Intent;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
import com.example.dailyarticle.R;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import static com.example.dailyarticle.utils.MyApplication.getContext;
public class ArticleActivity extends AppCompatActivity {
String name;
String address;
String authorName;
StringBuffer article = new StringBuffer();
TextView Name, Author, Article;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_article);
Intent intent = getIntent();
//从上一层获得文章标题和地址
name = intent.getStringExtra("articleName");
address = intent.getStringExtra("articleAddress");
//设置文章标题
Name = (TextView) findViewById(R.id.articleName);
Name.setText(name);
Author = (TextView) findViewById(R.id.articleAuthor);
Article = (TextView) findViewById(R.id.article);
//异步解析网页
MyTask task = new MyTask();
task.execute("http://book.meiriyiwen.com/" + address);
}
class MyTask extends AsyncTask<String, Void, Boolean> {
@Override
protected Boolean doInBackground(String... params) {
try {
Document doc = Jsoup.connect(params[0]).get();
Elements sections = doc.getElementsByTag("p");
for (Element section : sections) {
//文章段落拼接
article.append("\t\t\t\t" + section.text() + "\n");
}
Elements authors = doc.getElementsByClass("book-author");
for (Element author : authors) {
//作者
authorName = author.text();
}
} catch (
Exception e) {
e.printStackTrace();
return false;
}
return true;
}
@Override
protected void onPostExecute(Boolean bool) {
if (bool) {
//设置作者和内容
Author.setText(authorName);
Article.setText(article);
} else {
Toast.makeText(getContext(), "未知错误", Toast.LENGTH_SHORT).show();
}
}
}
}
| 2,630 | 0.587726 | 0.586939 | 81 | 30.395061 | 21.226398 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.567901 | false | false |
0
|
1b8e30364011143e5d6f39574571a41959d6e2dd
| 12,094,627,920,085 |
888b30007dadd4f0e870ecb5b48db07992dbfdf9
|
/HospitalSytem/src/System/Main.java
|
73e0b9e6e22772cf0c4998726582fe5003279115
|
[] |
no_license
|
ninjerie/Hospital-System
|
https://github.com/ninjerie/Hospital-System
|
956835120a016f47000ec11386a015fda9604abf
|
0449bbe46e74ff7cad60098b2135349eece2ebfc
|
refs/heads/master
| 2020-11-24T16:52:52.963000 | 2020-01-28T13:29:53 | 2020-01-28T13:29:53 | 228,257,947 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package System;
import System.Database;
import UserData.*;
import Controllers.*;
/**
*
* @author Geri
*/
public class Main {
public static AccessController accessController = new AccessController();
public static DoctorController doctorController = new DoctorController();
public static PatientController patientController = new PatientController();
public static SecretaryController secretaryController = new SecretaryController();
public static AdminController adminController = new AdminController();
public static Database data = new Database();
public static void main(String args[]) {
data.GenerateDatabase();
accessController.newView();
}
}
|
UTF-8
|
Java
| 910 |
java
|
Main.java
|
Java
|
[
{
"context": "erData.*;\nimport Controllers.*;\n\n/**\n *\n * @author Geri\n */\npublic class Main {\n public static AccessC",
"end": 290,
"score": 0.9995281100273132,
"start": 286,
"tag": "NAME",
"value": "Geri"
}
] | null |
[] |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package System;
import System.Database;
import UserData.*;
import Controllers.*;
/**
*
* @author Geri
*/
public class Main {
public static AccessController accessController = new AccessController();
public static DoctorController doctorController = new DoctorController();
public static PatientController patientController = new PatientController();
public static SecretaryController secretaryController = new SecretaryController();
public static AdminController adminController = new AdminController();
public static Database data = new Database();
public static void main(String args[]) {
data.GenerateDatabase();
accessController.newView();
}
}
| 910 | 0.723077 | 0.723077 | 31 | 28.354839 | 29.010063 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.483871 | false | false |
0
|
64e8639aca845886b2e1c82190fd84a845d17eec
| 2,095,944,061,248 |
d7f2c48b058bf8d76546e338c40f02838bd14a64
|
/app/src/main/java/com/sergeivasilenko/exemplary/Application.java
|
44ed36ae7214e9f198a15e6e4d38d77b2335a5e1
|
[] |
no_license
|
SergeiVasilenko/ExemplaryApp-android
|
https://github.com/SergeiVasilenko/ExemplaryApp-android
|
4a2ce199da4232cc6c1734bd5a368452646086b8
|
b20a674429969f9adc15cb721935d2524f49a800
|
refs/heads/master
| 2020-04-07T04:42:20.347000 | 2018-11-18T09:31:29 | 2018-11-18T09:31:29 | 158,068,254 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.sergeivasilenko.exemplary;
import android.app.Activity;
import com.sergeivasilenko.exemplary.di.AppInjector;
import javax.inject.Inject;
import dagger.android.AndroidInjector;
import dagger.android.DispatchingAndroidInjector;
import dagger.android.HasActivityInjector;
/**
* Created on 17/09/2018.
*
* @author Sergey Vasilenko (vasilenko.sn@gmail.com)
*/
public class Application extends android.app.Application implements HasActivityInjector {
public static final String ID = "1";
@Inject
DispatchingAndroidInjector<Activity> mDispatchingAndroidInjector;
@Override
public void onCreate() {
super.onCreate();
AppInjector.init(this);
}
@Override
public AndroidInjector<Activity> activityInjector() {
return mDispatchingAndroidInjector;
}
}
|
UTF-8
|
Java
| 779 |
java
|
Application.java
|
Java
|
[
{
"context": "ctor;\n\n/**\n * Created on 17/09/2018.\n *\n * @author Sergey Vasilenko (vasilenko.sn@gmail.com)\n */\npublic class Applica",
"end": 346,
"score": 0.9998149871826172,
"start": 330,
"tag": "NAME",
"value": "Sergey Vasilenko"
},
{
"context": "ed on 17/09/2018.\n *\n * @author Sergey Vasilenko (vasilenko.sn@gmail.com)\n */\npublic class Application extends android.app",
"end": 370,
"score": 0.9999344944953918,
"start": 348,
"tag": "EMAIL",
"value": "vasilenko.sn@gmail.com"
}
] | null |
[] |
package com.sergeivasilenko.exemplary;
import android.app.Activity;
import com.sergeivasilenko.exemplary.di.AppInjector;
import javax.inject.Inject;
import dagger.android.AndroidInjector;
import dagger.android.DispatchingAndroidInjector;
import dagger.android.HasActivityInjector;
/**
* Created on 17/09/2018.
*
* @author <NAME> (<EMAIL>)
*/
public class Application extends android.app.Application implements HasActivityInjector {
public static final String ID = "1";
@Inject
DispatchingAndroidInjector<Activity> mDispatchingAndroidInjector;
@Override
public void onCreate() {
super.onCreate();
AppInjector.init(this);
}
@Override
public AndroidInjector<Activity> activityInjector() {
return mDispatchingAndroidInjector;
}
}
| 754 | 0.792041 | 0.780488 | 35 | 21.257143 | 23.06555 | 89 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.771429 | false | false |
0
|
8eb67abc2997d35bed04d980c175be43d34d2f29
| 32,392,643,363,293 |
a5ab4060eb660a0d0dbebea727c7560ef4e55be1
|
/user-service/src/main/java/com/rbouklab/microdemo/model/Borrowing.java
|
7dba9ed2a233de2d528f90d0adc60c38e65d4686
|
[] |
no_license
|
raoufbouklab/spring-cloud-eureka-hystrix-zipkin-zuul
|
https://github.com/raoufbouklab/spring-cloud-eureka-hystrix-zipkin-zuul
|
5d44d0cddacf5c05a79fd00d8ae5d94bf9c48313
|
49044b261b16f0f6b903792ac721b678c16acca5
|
refs/heads/main
| 2023-08-26T07:00:14.711000 | 2021-11-05T12:39:48 | 2021-11-05T12:39:48 | 424,943,307 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.rbouklab.microdemo.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.time.LocalDate;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "borrowings")
public class Borrowing {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private Long userId;
private Long bookId;
private LocalDate borrowingDate;
private LocalDate returnDate;
public Borrowing(Long userId, Long bookId, LocalDate borrowingDate, LocalDate returnDate) {
this.userId = userId;
this.bookId = bookId;
this.borrowingDate = borrowingDate;
this.returnDate = returnDate;
}
}
|
UTF-8
|
Java
| 740 |
java
|
Borrowing.java
|
Java
|
[] | null |
[] |
package com.rbouklab.microdemo.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.time.LocalDate;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "borrowings")
public class Borrowing {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private Long userId;
private Long bookId;
private LocalDate borrowingDate;
private LocalDate returnDate;
public Borrowing(Long userId, Long bookId, LocalDate borrowingDate, LocalDate returnDate) {
this.userId = userId;
this.bookId = bookId;
this.borrowingDate = borrowingDate;
this.returnDate = returnDate;
}
}
| 740 | 0.732432 | 0.732432 | 31 | 22.870968 | 19.416889 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.580645 | false | false |
0
|
6c2b5b06b5564206c9cd19ab2250a9f5fd289b9a
| 18,021,682,790,123 |
5a73d80b2c1ff535f7da940bb895d5c703f753fa
|
/src/week1/ex7_SortNum.java
|
6492f561ef7b5ff7b9d94ceb3e41499cf346ada3
|
[] |
no_license
|
CocMap/INTE2512_oop
|
https://github.com/CocMap/INTE2512_oop
|
44ae30092961119a39d9255de965ae0676c9bfc8
|
9bb381e96d668fbb8b65b1063209f531c9cd2b22
|
refs/heads/master
| 2021-09-02T11:52:39.793000 | 2018-01-02T09:56:40 | 2018-01-02T09:56:40 | 108,257,743 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
Exercise 7 - The integers are entered from the input dialogs and stored in variables
num1, num2, and num3. The program sorts the numbers so that num1 ≤ num2 ≤ num3
*/
package week1;
import java.util.Arrays;
import java.util.Scanner;
public class ex7_SortNum {
public static void main(String[] args) {
System.out.printf("Enter three number: ");
Scanner input = new Scanner(System.in);
String[] strInput = input.nextLine().split(" ");
int[] arrNum = new int[3];
//parse input into arrNum[]
for(int i = 0; i < strInput.length; i++){
arrNum[i] = Integer.parseInt(strInput[i]);
}
System.out.println("The initial array is: " + Arrays.toString(arrNum));
for(int i = 0; i < 3; i++){
for(int j = i + 1; j < 3; j++) {
if(arrNum[i] > arrNum[j]) { //swap position
int temp = arrNum[i];
arrNum[i] = arrNum[j];
arrNum[j] = temp;
}
}
}
System.out.println("Tne sorted array is: " + Arrays.toString(arrNum));
}
}
|
UTF-8
|
Java
| 1,142 |
java
|
ex7_SortNum.java
|
Java
|
[] | null |
[] |
/*
Exercise 7 - The integers are entered from the input dialogs and stored in variables
num1, num2, and num3. The program sorts the numbers so that num1 ≤ num2 ≤ num3
*/
package week1;
import java.util.Arrays;
import java.util.Scanner;
public class ex7_SortNum {
public static void main(String[] args) {
System.out.printf("Enter three number: ");
Scanner input = new Scanner(System.in);
String[] strInput = input.nextLine().split(" ");
int[] arrNum = new int[3];
//parse input into arrNum[]
for(int i = 0; i < strInput.length; i++){
arrNum[i] = Integer.parseInt(strInput[i]);
}
System.out.println("The initial array is: " + Arrays.toString(arrNum));
for(int i = 0; i < 3; i++){
for(int j = i + 1; j < 3; j++) {
if(arrNum[i] > arrNum[j]) { //swap position
int temp = arrNum[i];
arrNum[i] = arrNum[j];
arrNum[j] = temp;
}
}
}
System.out.println("Tne sorted array is: " + Arrays.toString(arrNum));
}
}
| 1,142 | 0.536028 | 0.522847 | 36 | 30.611111 | 26.037663 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.583333 | false | false |
0
|
346d7f3d69444a12e60d9f6be59b24ab1293b60c
| 18,021,682,789,106 |
0c6e21b398408be241575bf735f8dbfb9c62eb0a
|
/app/src/main/java/lk/gov/arogya/nearbypeopletracker/ContactReportFragment.java
|
5470e5754c0f7b317912c1cc130eff5c6087a111
|
[
"MIT"
] |
permissive
|
AnjanaSenanayake/Arogya
|
https://github.com/AnjanaSenanayake/Arogya
|
2e74573c65c4e4440d55fd71c3fb56b98e0bc64b
|
d9b8d2df1ad173d1aa84ce3c850073f07d090d3d
|
refs/heads/master
| 2022-06-05T08:35:11.955000 | 2020-04-30T17:22:44 | 2020-04-30T17:22:44 | 255,518,286 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package lk.gov.arogya.nearbypeopletracker;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.CircleOptions;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import lk.gov.arogya.R;
import lk.gov.arogya.models.EpidemicAlert;
/**
* A simple {@link Fragment} subclass.
*/
public class ContactReportFragment extends BottomSheetDialogFragment implements OnMapReadyCallback {
static ContactReportFragment newInstance(Context context, EpidemicAlert epidemicAlert) {
return new ContactReportFragment(context, epidemicAlert);
}
private ContactReportFragment(Context context, EpidemicAlert epidemicAlert) {
this.mContext = context;
this.mEpidemicAlert = epidemicAlert;
}
private TextView tvEpidemicName;
private TextView tvContactedDate;
private LatLng coordinates;
private Context mContext;
private EpidemicAlert mEpidemicAlert;
@Override
public void onMapReady(final GoogleMap googleMap) {
googleMap.setMinZoomPreference(16);
CircleOptions options = new CircleOptions()
.radius(20)
.strokeWidth(3)
.center(coordinates);
googleMap.addMarker(new MarkerOptions().position(coordinates).title("Contacted Location"));
googleMap.moveCamera(CameraUpdateFactory.newLatLng(coordinates));
googleMap.addCircle(options);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_contact_report, container, false);
tvEpidemicName = view.findViewById(R.id.tv_epidemic_name);
tvContactedDate = view.findViewById(R.id.tv_contacted_date);
tvEpidemicName.setText(mEpidemicAlert.getEpidemic());
tvContactedDate.setText(mEpidemicAlert.getContactDate());
coordinates = new LatLng(Double.valueOf(mEpidemicAlert.getLatitude()),
Double.valueOf(mEpidemicAlert.getLongitude()));
// Gets the MapView from the XML layout and creates it
MapView mapView = view.findViewById(R.id.map_view);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
return view;
}
}
|
UTF-8
|
Java
| 2,783 |
java
|
ContactReportFragment.java
|
Java
|
[] | null |
[] |
package lk.gov.arogya.nearbypeopletracker;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.CircleOptions;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import lk.gov.arogya.R;
import lk.gov.arogya.models.EpidemicAlert;
/**
* A simple {@link Fragment} subclass.
*/
public class ContactReportFragment extends BottomSheetDialogFragment implements OnMapReadyCallback {
static ContactReportFragment newInstance(Context context, EpidemicAlert epidemicAlert) {
return new ContactReportFragment(context, epidemicAlert);
}
private ContactReportFragment(Context context, EpidemicAlert epidemicAlert) {
this.mContext = context;
this.mEpidemicAlert = epidemicAlert;
}
private TextView tvEpidemicName;
private TextView tvContactedDate;
private LatLng coordinates;
private Context mContext;
private EpidemicAlert mEpidemicAlert;
@Override
public void onMapReady(final GoogleMap googleMap) {
googleMap.setMinZoomPreference(16);
CircleOptions options = new CircleOptions()
.radius(20)
.strokeWidth(3)
.center(coordinates);
googleMap.addMarker(new MarkerOptions().position(coordinates).title("Contacted Location"));
googleMap.moveCamera(CameraUpdateFactory.newLatLng(coordinates));
googleMap.addCircle(options);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_contact_report, container, false);
tvEpidemicName = view.findViewById(R.id.tv_epidemic_name);
tvContactedDate = view.findViewById(R.id.tv_contacted_date);
tvEpidemicName.setText(mEpidemicAlert.getEpidemic());
tvContactedDate.setText(mEpidemicAlert.getContactDate());
coordinates = new LatLng(Double.valueOf(mEpidemicAlert.getLatitude()),
Double.valueOf(mEpidemicAlert.getLongitude()));
// Gets the MapView from the XML layout and creates it
MapView mapView = view.findViewById(R.id.map_view);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
return view;
}
}
| 2,783 | 0.73949 | 0.737693 | 77 | 35.142857 | 27.768391 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.636364 | false | false |
0
|
0c524a420cfd886283748fa31ffebffda9f1ac2d
| 3,934,190,062,211 |
2e8e1ba5881034f69e9b14440903d88e8133a4bd
|
/RelationBN-2/app/src/main/java/com/dickies/android/relationbn/registerlogin/RegisterActivity.java
|
2429d9250d4b89d56a64058568363de59441b4e2
|
[] |
no_license
|
dickiep/relationAndroid
|
https://github.com/dickiep/relationAndroid
|
26a8de82f9d06d79e82717203b769e06ebcc3be9
|
f0007c2e482f08351b266f5b6665b4445879113b
|
refs/heads/master
| 2023-03-11T22:26:11.524000 | 2021-03-04T17:41:41 | 2021-03-04T17:41:41 | 344,558,646 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.dickies.android.relationbn.registerlogin;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.AppCompatButton;
import android.view.View;
import android.widget.EditText;
import com.dickies.android.relationbn.R;
/**
* Created by Phil on 30/09/2018.
*/
public class RegisterActivity extends AppCompatActivity implements View.OnClickListener {
EditText editTextEmail;
EditText editTextPassword;
AppCompatButton buttonRegister;
String email, password;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
//Initializing views
editTextEmail = (EditText) findViewById(R.id.editTextEmail);
editTextPassword = (EditText) findViewById(R.id.editTextPassword);
buttonRegister = (AppCompatButton) findViewById(R.id.buttonRegister);
//Adding click listener
buttonRegister.setOnClickListener(this);
}
@Override
public void onClick(View view) {
email = editTextEmail.getText().toString();
password = editTextPassword.getText().toString();
String method = "register";
com.dickies.android.relationbn.registerlogin.BackgroundTask backgroundTask = new com.dickies.android.relationbn.registerlogin.BackgroundTask(this);
backgroundTask.execute(method, email, password);
finish();
}
}
|
UTF-8
|
Java
| 1,485 |
java
|
RegisterActivity.java
|
Java
|
[
{
"context": "m.dickies.android.relationbn.R;\n\n/**\n * Created by Phil on 30/09/2018.\n */\n\npublic class RegisterActivity",
"end": 303,
"score": 0.9944638609886169,
"start": 299,
"tag": "NAME",
"value": "Phil"
}
] | null |
[] |
package com.dickies.android.relationbn.registerlogin;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.AppCompatButton;
import android.view.View;
import android.widget.EditText;
import com.dickies.android.relationbn.R;
/**
* Created by Phil on 30/09/2018.
*/
public class RegisterActivity extends AppCompatActivity implements View.OnClickListener {
EditText editTextEmail;
EditText editTextPassword;
AppCompatButton buttonRegister;
String email, password;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
//Initializing views
editTextEmail = (EditText) findViewById(R.id.editTextEmail);
editTextPassword = (EditText) findViewById(R.id.editTextPassword);
buttonRegister = (AppCompatButton) findViewById(R.id.buttonRegister);
//Adding click listener
buttonRegister.setOnClickListener(this);
}
@Override
public void onClick(View view) {
email = editTextEmail.getText().toString();
password = editTextPassword.getText().toString();
String method = "register";
com.dickies.android.relationbn.registerlogin.BackgroundTask backgroundTask = new com.dickies.android.relationbn.registerlogin.BackgroundTask(this);
backgroundTask.execute(method, email, password);
finish();
}
}
| 1,485 | 0.731313 | 0.724579 | 47 | 30.595745 | 30.531921 | 155 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.553191 | false | false |
0
|
5ef6f6450bd86f033308284d1d417bd987002a63
| 4,544,075,419,876 |
f087aa0290ec8d725f15cec59b07c57f8b906221
|
/ground/src/main/java/com/crewfactory/main/service/BlogService.java
|
8a35c3451b2514de4c5ec591f19b3104cd12ec17
|
[] |
no_license
|
crewfactory/ground
|
https://github.com/crewfactory/ground
|
d9db809488de0a23ab29eb2592a60aea7a848117
|
e0c73c67aeb599a8b7849a861fb7050efc4f5824
|
refs/heads/master
| 2022-12-25T22:52:43.572000 | 2020-10-08T02:26:37 | 2020-10-08T02:26:37 | 301,635,623 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.crewfactory.main.service;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.crewfactory.main.dao.BlogDao;
import com.crewfactory.main.domain.BlogDomain;
import com.crewfactory.main.domain.SearchDomain;
import com.crewfactory.main.util.Pageable;
import com.crewfactory.main.util.Utility;
@Service
public class BlogService {
@Autowired
BlogDao dao;
@Autowired
private Pageable pageable;
public List <BlogDomain> selectBlogByHome () throws Exception {
return dao.selectBlogByHome();
}
public List <BlogDomain> select (SearchDomain sdomain) throws Exception {
return dao.select(sdomain);
}
public int selectBlogByWebTotal(Map<String, Object> paramMap) throws Exception {
return dao.selectBolgByWebTotal(paramMap);
}
public int selectMomentByWebTotal(Map<String, Object> paramMap) throws Exception {
return dao.selectMomentByWebTotal(paramMap);
}
public int selectMomentByWebTotalIncheon(Map<String, Object> paramMap) throws Exception {
return dao.selectMomentByWebTotalIncheon(paramMap);
}
public List <BlogDomain> selectBlogByWeb(Map<String, Object> paramMap, int startPage, int visiblePages) throws Exception {
Map<String, Object> tmpSearchMap = pageable.getRowBounds(startPage, visiblePages);
paramMap.put("start", tmpSearchMap.get("start"));
paramMap.put("end", tmpSearchMap.get("end"));
return dao.selectBlogByWeb(paramMap);
}
public List <BlogDomain> selectMomentByWeb(Map<String, Object> paramMap, int startPage, int visiblePages) throws Exception {
Map<String, Object> tmpSearchMap = pageable.getRowBounds(startPage, visiblePages);
paramMap.put("start", tmpSearchMap.get("start"));
paramMap.put("end", tmpSearchMap.get("end"));
return dao.selectMomentByWeb(paramMap);
}
public List <BlogDomain> selectMomentByWebIncheon(Map<String, Object> paramMap, int startPage, int visiblePages) throws Exception {
Map<String, Object> tmpSearchMap = pageable.getRowBounds(startPage, visiblePages);
paramMap.put("start", tmpSearchMap.get("start"));
paramMap.put("end", tmpSearchMap.get("end"));
return dao.selectMomentByWebIncheon(paramMap);
}
public List <BlogDomain> selectTopBlogByWeb (Map<String, Object> paramMap) throws Exception {
return dao.selectTopBlogByWeb(paramMap);
}
public List <BlogDomain> selectTopBlog (SearchDomain search) throws Exception {
return dao.selectTopBlog(search);
}
public BlogDomain view (int idx) throws Exception {
return dao.view(idx);
}
public BlogDomain viewMoment (int idx) throws Exception {
return dao.viewMoment(idx);
}
public BlogDomain viewMomentIncheon (int idx) throws Exception {
return dao.viewMomentIncheon(idx);
}
public void insert(BlogDomain domain) throws Exception {
Utility util = new Utility();
//String pureText = util.limitText(util.removeTag(domain.getContent()), 800);
//domain.setDescription(pureText);
String convertPath = util.modifyEditorTxt(domain.getContent());
domain.setContent(convertPath);
dao.insert(domain);
}
public void update(BlogDomain domain) throws Exception {
Utility util = new Utility();
String convertPath = util.modifyEditorTxt(domain.getContent());
domain.setContent(convertPath);
dao.update(domain);
}
public void delete(int idx) throws Exception {
dao.delete(idx);
}
public List <BlogDomain> selectMomentByHome () throws Exception {
return dao.selectMomentByHome();
}
}
|
UTF-8
|
Java
| 3,669 |
java
|
BlogService.java
|
Java
|
[] | null |
[] |
package com.crewfactory.main.service;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.crewfactory.main.dao.BlogDao;
import com.crewfactory.main.domain.BlogDomain;
import com.crewfactory.main.domain.SearchDomain;
import com.crewfactory.main.util.Pageable;
import com.crewfactory.main.util.Utility;
@Service
public class BlogService {
@Autowired
BlogDao dao;
@Autowired
private Pageable pageable;
public List <BlogDomain> selectBlogByHome () throws Exception {
return dao.selectBlogByHome();
}
public List <BlogDomain> select (SearchDomain sdomain) throws Exception {
return dao.select(sdomain);
}
public int selectBlogByWebTotal(Map<String, Object> paramMap) throws Exception {
return dao.selectBolgByWebTotal(paramMap);
}
public int selectMomentByWebTotal(Map<String, Object> paramMap) throws Exception {
return dao.selectMomentByWebTotal(paramMap);
}
public int selectMomentByWebTotalIncheon(Map<String, Object> paramMap) throws Exception {
return dao.selectMomentByWebTotalIncheon(paramMap);
}
public List <BlogDomain> selectBlogByWeb(Map<String, Object> paramMap, int startPage, int visiblePages) throws Exception {
Map<String, Object> tmpSearchMap = pageable.getRowBounds(startPage, visiblePages);
paramMap.put("start", tmpSearchMap.get("start"));
paramMap.put("end", tmpSearchMap.get("end"));
return dao.selectBlogByWeb(paramMap);
}
public List <BlogDomain> selectMomentByWeb(Map<String, Object> paramMap, int startPage, int visiblePages) throws Exception {
Map<String, Object> tmpSearchMap = pageable.getRowBounds(startPage, visiblePages);
paramMap.put("start", tmpSearchMap.get("start"));
paramMap.put("end", tmpSearchMap.get("end"));
return dao.selectMomentByWeb(paramMap);
}
public List <BlogDomain> selectMomentByWebIncheon(Map<String, Object> paramMap, int startPage, int visiblePages) throws Exception {
Map<String, Object> tmpSearchMap = pageable.getRowBounds(startPage, visiblePages);
paramMap.put("start", tmpSearchMap.get("start"));
paramMap.put("end", tmpSearchMap.get("end"));
return dao.selectMomentByWebIncheon(paramMap);
}
public List <BlogDomain> selectTopBlogByWeb (Map<String, Object> paramMap) throws Exception {
return dao.selectTopBlogByWeb(paramMap);
}
public List <BlogDomain> selectTopBlog (SearchDomain search) throws Exception {
return dao.selectTopBlog(search);
}
public BlogDomain view (int idx) throws Exception {
return dao.view(idx);
}
public BlogDomain viewMoment (int idx) throws Exception {
return dao.viewMoment(idx);
}
public BlogDomain viewMomentIncheon (int idx) throws Exception {
return dao.viewMomentIncheon(idx);
}
public void insert(BlogDomain domain) throws Exception {
Utility util = new Utility();
//String pureText = util.limitText(util.removeTag(domain.getContent()), 800);
//domain.setDescription(pureText);
String convertPath = util.modifyEditorTxt(domain.getContent());
domain.setContent(convertPath);
dao.insert(domain);
}
public void update(BlogDomain domain) throws Exception {
Utility util = new Utility();
String convertPath = util.modifyEditorTxt(domain.getContent());
domain.setContent(convertPath);
dao.update(domain);
}
public void delete(int idx) throws Exception {
dao.delete(idx);
}
public List <BlogDomain> selectMomentByHome () throws Exception {
return dao.selectMomentByHome();
}
}
| 3,669 | 0.73644 | 0.735623 | 110 | 31.354546 | 31.782667 | 132 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.681818 | false | false |
0
|
422aa58f9e31bb7cee2366cff68fa26506cc6c77
| 14,010,183,354,382 |
5876140c0e48ac932ea739234287b366147695b2
|
/app/src/main/java/com/wzdq/fengcai/Obserable/IObserver.java
|
f4fac2822a5aafbe815b307492debb6002cc3456
|
[] |
no_license
|
ps130183/FengCai
|
https://github.com/ps130183/FengCai
|
91fd0b0ddc390cadc7f0ecc5f0f94127231c44a2
|
6bda4c1abc3071caa4d50a613c92703d224dff9c
|
refs/heads/master
| 2020-04-09T11:36:45.462000 | 2018-12-04T10:25:32 | 2018-12-04T10:25:32 | 160,316,758 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.wzdq.fengcai.Obserable;
/**
* Created by PengSong on 18/11/26.
*/
public interface IObserver {
void subscribe(Object ... params);
}
|
UTF-8
|
Java
| 154 |
java
|
IObserver.java
|
Java
|
[
{
"context": "age com.wzdq.fengcai.Obserable;\n\n/**\n * Created by PengSong on 18/11/26.\n */\n\npublic interface IObserver ",
"end": 59,
"score": 0.9884949326515198,
"start": 55,
"tag": "NAME",
"value": "Peng"
},
{
"context": "om.wzdq.fengcai.Obserable;\n\n/**\n * Created by PengSong on 18/11/26.\n */\n\npublic interface IObserver {\n\n ",
"end": 63,
"score": 0.5450742840766907,
"start": 59,
"tag": "USERNAME",
"value": "Song"
}
] | null |
[] |
package com.wzdq.fengcai.Obserable;
/**
* Created by PengSong on 18/11/26.
*/
public interface IObserver {
void subscribe(Object ... params);
}
| 154 | 0.675325 | 0.636364 | 11 | 13 | 16.062378 | 38 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.181818 | false | false |
0
|
8ef57fe633ce2aa089eaebe2e3dce22154616e2e
| 6,665,789,255,887 |
4f582daf55f75412d4736d2e6645bc1bc9daab58
|
/web/src/main/java/ch/ethz/globis/isk/web/model/SimpleJournalDto.java
|
b93ca112ea9e78cfbde49057c3e048fb16252b34
|
[] |
no_license
|
vdemotz/InfSystemsTask7
|
https://github.com/vdemotz/InfSystemsTask7
|
7110a0694df04c854213f444a028970031832f71
|
e4757bee7ab7c7a3e5818f698a01615cd0a20dbf
|
refs/heads/master
| 2021-01-22T02:40:00.855000 | 2015-05-19T12:20:44 | 2015-05-19T12:20:44 | 35,600,875 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package ch.ethz.globis.isk.web.model;
import ch.ethz.globis.isk.domain.Journal;
import ch.ethz.globis.isk.web.utils.EncodingUtils;
import com.fasterxml.jackson.annotation.JsonProperty;
public class SimpleJournalDto extends DTO<Journal> {
@JsonProperty("name")
private String name;
@JsonProperty("id")
private String id;
public SimpleJournalDto() {
}
public SimpleJournalDto(Journal journal) {
this.id = EncodingUtils.encode(journal.getId());
this.name = journal.getName();
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public DTO<Journal> convert(Journal entity) {
return new SimpleJournalDto(entity);
}
}
|
UTF-8
|
Java
| 895 |
java
|
SimpleJournalDto.java
|
Java
|
[] | null |
[] |
package ch.ethz.globis.isk.web.model;
import ch.ethz.globis.isk.domain.Journal;
import ch.ethz.globis.isk.web.utils.EncodingUtils;
import com.fasterxml.jackson.annotation.JsonProperty;
public class SimpleJournalDto extends DTO<Journal> {
@JsonProperty("name")
private String name;
@JsonProperty("id")
private String id;
public SimpleJournalDto() {
}
public SimpleJournalDto(Journal journal) {
this.id = EncodingUtils.encode(journal.getId());
this.name = journal.getName();
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public DTO<Journal> convert(Journal entity) {
return new SimpleJournalDto(entity);
}
}
| 895 | 0.642458 | 0.642458 | 43 | 19.813953 | 18.486017 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.302326 | false | false |
0
|
58cce89c2db766c4a92d278d50ceb229c4fffd61
| 13,675,175,914,345 |
c7314a37e7912736e222d97b2f8913dfc5ef62d7
|
/src/pdsu/hrms/model/History.java
|
a0604d240d15a765486d68a60a98284c785bac56
|
[] |
no_license
|
xiaomeiqiu007/JAVA-JFrame
|
https://github.com/xiaomeiqiu007/JAVA-JFrame
|
efbecd1c0ff070444e20604714a206c33899bbc6
|
3460501a84bcf143c6b52b511b1e8dd18f0cfffb
|
refs/heads/master
| 2020-04-18T02:23:25.856000 | 2019-01-23T10:10:47 | 2019-01-23T10:10:47 | 167,160,370 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package pdsu.hrms.model;
public class History {
long hisId;
private String hisType;
private String oldInfo;
private String newInfo;
private String chgDtate;
private long chgNum;
private long personId;
//ÍØÕ¹ÊôÐÔ
private String name;
public long getHisId() {
return hisId;
}
public void setHisId(long hisId) {
this.hisId = hisId;
}
public String getHisType() {
return hisType;
}
public void setHisType(String hisType) {
this.hisType = hisType;
}
public String getOldInfo() {
return oldInfo;
}
public void setOldInfo(String oldInfo) {
this.oldInfo = oldInfo;
}
public String getNewInfo() {
return newInfo;
}
public void setNewInfo(String newInfo) {
this.newInfo = newInfo;
}
public String getChgDtate() {
return chgDtate;
}
public void setChgDtate(String chgDtate) {
this.chgDtate = chgDtate;
}
public long getChgNum() {
return chgNum;
}
public void setChgNum(long chgNum) {
this.chgNum = chgNum;
}
public long getPersonId() {
return personId;
}
public void setPersonId(long personId) {
this.personId = personId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
|
WINDOWS-1252
|
Java
| 1,154 |
java
|
History.java
|
Java
|
[] | null |
[] |
package pdsu.hrms.model;
public class History {
long hisId;
private String hisType;
private String oldInfo;
private String newInfo;
private String chgDtate;
private long chgNum;
private long personId;
//ÍØÕ¹ÊôÐÔ
private String name;
public long getHisId() {
return hisId;
}
public void setHisId(long hisId) {
this.hisId = hisId;
}
public String getHisType() {
return hisType;
}
public void setHisType(String hisType) {
this.hisType = hisType;
}
public String getOldInfo() {
return oldInfo;
}
public void setOldInfo(String oldInfo) {
this.oldInfo = oldInfo;
}
public String getNewInfo() {
return newInfo;
}
public void setNewInfo(String newInfo) {
this.newInfo = newInfo;
}
public String getChgDtate() {
return chgDtate;
}
public void setChgDtate(String chgDtate) {
this.chgDtate = chgDtate;
}
public long getChgNum() {
return chgNum;
}
public void setChgNum(long chgNum) {
this.chgNum = chgNum;
}
public long getPersonId() {
return personId;
}
public void setPersonId(long personId) {
this.personId = personId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
| 1,154 | 0.733857 | 0.732984 | 79 | 13.50633 | 13.349133 | 42 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.518987 | false | false |
0
|
274ab19add04ffa0138f611d490aa75dd5cf3f2c
| 32,495,722,566,842 |
8f07067667f131b29c0eade5c724970e6ef65dce
|
/src/test/java/ru/netology/RadioTest.java
|
6e5e727d05c15a0686a63e1b1028a86013252fd2
|
[] |
no_license
|
rabmail/DZ_Radio
|
https://github.com/rabmail/DZ_Radio
|
d5b872d4436a8e88f8aa2ecfdaa4693aa0a3f0c6
|
33eccd56f235439fa37e842f0783ac87f72623cb
|
refs/heads/master
| 2023-03-03T10:08:47.922000 | 2021-02-06T07:59:46 | 2021-02-06T07:59:46 | 335,733,716 | 0 | 0 | null | false | 2021-02-15T16:59:26 | 2021-02-03T19:33:50 | 2021-02-06T07:59:55 | 2021-02-15T16:56:30 | 5 | 0 | 0 | 2 |
Java
| false | false |
package ru.netology;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class RadioTest {
@Test
public void setCurrentStation() {
Radio radio = new Radio();
assertEquals(0, radio.getCurrentStation());
radio.setMaxStation(9);
radio.setMinStation(0);
radio.setCurrentStation(4);
assertEquals(4, radio.getCurrentStation());
}
@Test
public void setCurrentStationMax() {
Radio radio = new Radio();
assertEquals(0, radio.getCurrentStation());
radio.setMaxStation(9);
radio.setMinStation(0);
radio.setCurrentStation(10);
assertEquals(0, radio.getCurrentStation());
}
@Test
public void setCurrentStationMin() {
Radio radio = new Radio();
assertEquals(0, radio.getCurrentStation());
radio.setMaxStation(9);
radio.setMinStation(0);
radio.setCurrentStation(-1);
assertEquals(0, radio.getCurrentStation());
}
@Test
public void setCurrentVolume() {
Radio radio = new Radio();
assertEquals(0, radio.getCurrentVolume());
radio.setMaxVolume(10);
radio.setMinVolume(0);
radio.setCurrentVolume(5);
assertEquals(5, radio.getCurrentVolume());
}
@Test
public void setCurrentVolumeMax() {
Radio radio = new Radio();
assertEquals(0, radio.getCurrentVolume());
radio.setMaxVolume(10);
radio.setMinVolume(0);
radio.setCurrentVolume(11);
assertEquals(0, radio.getCurrentVolume());
}
@Test
public void setCurrentVolumeMin() {
Radio radio = new Radio();
assertEquals(0, radio.getCurrentVolume());
radio.setMaxVolume(10);
radio.setMinVolume(0);
radio.setCurrentVolume(-1);
assertEquals(0, radio.getCurrentVolume());
}
@Test
public void nextStation() {
Radio radio = new Radio();
radio.setMinStation(0);
radio.setMaxStation(9);
radio.setCurrentStation(4);
radio.NextStation();
assertEquals(5, radio.getCurrentStation());
}
@Test
public void nextStationMax() {
Radio radio = new Radio();
radio.setMinStation(0);
radio.setMaxStation(9);
radio.setCurrentStation(9);
radio.NextStation();
assertEquals(0, radio.getCurrentStation());
}
@Test
public void nextVolume() {
Radio radio = new Radio();
radio.setMinVolume(0);
radio.setMaxVolume(10);
radio.setCurrentVolume(4);
radio.NextVolume();
assertEquals(5, radio.getCurrentVolume());
}
@Test
public void nextVolumeMax() {
Radio radio = new Radio();
radio.setMinVolume(0);
radio.setMaxVolume(10);
radio.setCurrentVolume(10);
radio.NextVolume();
assertEquals(10, radio.getCurrentVolume());
}
@Test
public void previousStation() {
Radio radio = new Radio();
radio.setMinStation(0);
radio.setMaxStation(9);
radio.setCurrentStation(6);
radio.PreviousStation();
assertEquals(5, radio.getCurrentStation());
}
@Test
public void previousStationMin() {
Radio radio = new Radio();
radio.setMinStation(0);
radio.setMaxStation(9);
radio.setCurrentStation(5);
radio.PreviousStation();
assertEquals(4, radio.getCurrentStation());
}
@Test
public void previousVolume() {
Radio radio = new Radio();
radio.setMinVolume(0);
radio.setMaxVolume(10);
radio.setCurrentVolume(5);
radio.PreviousVolume();
assertEquals(4, radio.getCurrentVolume());
}
@Test
public void previousVolumeMin() {
Radio radio = new Radio();
radio.setMinVolume(0);
radio.setMaxVolume(10);
radio.setCurrentVolume(0);
radio.PreviousVolume();
assertEquals(0, radio.getCurrentVolume());
}
@Test
public void RadioOff() {
Radio radio = new Radio();
radio.RadioOff(false);
assertEquals(false, radio.RadioOff());
}
@Test
public void RadioOnn() {
Radio radio = new Radio();
radio.RadioOff(true);
assertEquals(true, radio.RadioOff());
}
}
|
UTF-8
|
Java
| 4,362 |
java
|
RadioTest.java
|
Java
|
[] | null |
[] |
package ru.netology;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class RadioTest {
@Test
public void setCurrentStation() {
Radio radio = new Radio();
assertEquals(0, radio.getCurrentStation());
radio.setMaxStation(9);
radio.setMinStation(0);
radio.setCurrentStation(4);
assertEquals(4, radio.getCurrentStation());
}
@Test
public void setCurrentStationMax() {
Radio radio = new Radio();
assertEquals(0, radio.getCurrentStation());
radio.setMaxStation(9);
radio.setMinStation(0);
radio.setCurrentStation(10);
assertEquals(0, radio.getCurrentStation());
}
@Test
public void setCurrentStationMin() {
Radio radio = new Radio();
assertEquals(0, radio.getCurrentStation());
radio.setMaxStation(9);
radio.setMinStation(0);
radio.setCurrentStation(-1);
assertEquals(0, radio.getCurrentStation());
}
@Test
public void setCurrentVolume() {
Radio radio = new Radio();
assertEquals(0, radio.getCurrentVolume());
radio.setMaxVolume(10);
radio.setMinVolume(0);
radio.setCurrentVolume(5);
assertEquals(5, radio.getCurrentVolume());
}
@Test
public void setCurrentVolumeMax() {
Radio radio = new Radio();
assertEquals(0, radio.getCurrentVolume());
radio.setMaxVolume(10);
radio.setMinVolume(0);
radio.setCurrentVolume(11);
assertEquals(0, radio.getCurrentVolume());
}
@Test
public void setCurrentVolumeMin() {
Radio radio = new Radio();
assertEquals(0, radio.getCurrentVolume());
radio.setMaxVolume(10);
radio.setMinVolume(0);
radio.setCurrentVolume(-1);
assertEquals(0, radio.getCurrentVolume());
}
@Test
public void nextStation() {
Radio radio = new Radio();
radio.setMinStation(0);
radio.setMaxStation(9);
radio.setCurrentStation(4);
radio.NextStation();
assertEquals(5, radio.getCurrentStation());
}
@Test
public void nextStationMax() {
Radio radio = new Radio();
radio.setMinStation(0);
radio.setMaxStation(9);
radio.setCurrentStation(9);
radio.NextStation();
assertEquals(0, radio.getCurrentStation());
}
@Test
public void nextVolume() {
Radio radio = new Radio();
radio.setMinVolume(0);
radio.setMaxVolume(10);
radio.setCurrentVolume(4);
radio.NextVolume();
assertEquals(5, radio.getCurrentVolume());
}
@Test
public void nextVolumeMax() {
Radio radio = new Radio();
radio.setMinVolume(0);
radio.setMaxVolume(10);
radio.setCurrentVolume(10);
radio.NextVolume();
assertEquals(10, radio.getCurrentVolume());
}
@Test
public void previousStation() {
Radio radio = new Radio();
radio.setMinStation(0);
radio.setMaxStation(9);
radio.setCurrentStation(6);
radio.PreviousStation();
assertEquals(5, radio.getCurrentStation());
}
@Test
public void previousStationMin() {
Radio radio = new Radio();
radio.setMinStation(0);
radio.setMaxStation(9);
radio.setCurrentStation(5);
radio.PreviousStation();
assertEquals(4, radio.getCurrentStation());
}
@Test
public void previousVolume() {
Radio radio = new Radio();
radio.setMinVolume(0);
radio.setMaxVolume(10);
radio.setCurrentVolume(5);
radio.PreviousVolume();
assertEquals(4, radio.getCurrentVolume());
}
@Test
public void previousVolumeMin() {
Radio radio = new Radio();
radio.setMinVolume(0);
radio.setMaxVolume(10);
radio.setCurrentVolume(0);
radio.PreviousVolume();
assertEquals(0, radio.getCurrentVolume());
}
@Test
public void RadioOff() {
Radio radio = new Radio();
radio.RadioOff(false);
assertEquals(false, radio.RadioOff());
}
@Test
public void RadioOnn() {
Radio radio = new Radio();
radio.RadioOff(true);
assertEquals(true, radio.RadioOff());
}
}
| 4,362 | 0.600183 | 0.583448 | 169 | 24.816568 | 16.786039 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.680473 | false | false |
0
|
935ea3c56ca4666a64efafb4e8a4864f2b6cc0ff
| 12,077,448,101,250 |
f004cdfec2f243a25351d92704c601a5b2a0f294
|
/005-Distributed/001-Auth/src/main/java/com/bjpowernode/model/entity/Auth.java
|
8199e2cbf4c60461634239eaaf384105b721fa4d
|
[] |
no_license
|
ClearPlume/JavaStudy
|
https://github.com/ClearPlume/JavaStudy
|
2c6a74da0459e8cade00b7563a2ae042ac5e9ae3
|
028f7ad8a3e2c0ec84e36590932c2a9ec406d613
|
refs/heads/master
| 2023-02-10T20:52:38.638000 | 2021-01-02T08:02:11 | 2021-01-02T08:02:11 | 302,613,025 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.bjpowernode.model.entity;
public class Auth {
private Integer authId;
private String authName;
private String authCode;
private String authUrl;
private Integer authStatus;
public Integer getAuthId() {
return authId;
}
public void setAuthId(Integer authId) {
this.authId = authId;
}
public String getAuthName() {
return authName;
}
public void setAuthName(String authName) {
this.authName = authName == null ? null : authName.trim();
}
public String getAuthCode() {
return authCode;
}
public void setAuthCode(String authCode) {
this.authCode = authCode == null ? null : authCode.trim();
}
public String getAuthUrl() {
return authUrl;
}
public void setAuthUrl(String authUrl) {
this.authUrl = authUrl == null ? null : authUrl.trim();
}
public Integer getAuthStatus() {
return authStatus;
}
public void setAuthStatus(Integer authStatus) {
this.authStatus = authStatus;
}
}
|
UTF-8
|
Java
| 1,076 |
java
|
Auth.java
|
Java
|
[] | null |
[] |
package com.bjpowernode.model.entity;
public class Auth {
private Integer authId;
private String authName;
private String authCode;
private String authUrl;
private Integer authStatus;
public Integer getAuthId() {
return authId;
}
public void setAuthId(Integer authId) {
this.authId = authId;
}
public String getAuthName() {
return authName;
}
public void setAuthName(String authName) {
this.authName = authName == null ? null : authName.trim();
}
public String getAuthCode() {
return authCode;
}
public void setAuthCode(String authCode) {
this.authCode = authCode == null ? null : authCode.trim();
}
public String getAuthUrl() {
return authUrl;
}
public void setAuthUrl(String authUrl) {
this.authUrl = authUrl == null ? null : authUrl.trim();
}
public Integer getAuthStatus() {
return authStatus;
}
public void setAuthStatus(Integer authStatus) {
this.authStatus = authStatus;
}
}
| 1,076 | 0.622677 | 0.622677 | 53 | 19.320755 | 19.452675 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.301887 | false | false |
0
|
74b53007885ba738934a0ee5d7bbdd517282f430
| 7,859,790,178,449 |
7df7d3f150e39f0065ec04f3274613f22eec7187
|
/media/livestream/src/main/java/com/example/livestream/GetAsset.java
|
4af70039e82bf52332148e28b524e9977866dac2
|
[
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] |
permissive
|
GoogleCloudPlatform/java-docs-samples
|
https://github.com/GoogleCloudPlatform/java-docs-samples
|
b8bacddd582697c307a85d6aa740fa2a71cdbf00
|
f166f36a595c35dbc32bc49cf16e598e5812f43a
|
refs/heads/main
| 2023-09-03T04:07:37.538000 | 2023-08-31T23:16:36 | 2023-08-31T23:16:36 | 32,895,424 | 1,771 | 3,440 |
Apache-2.0
| false | 2023-09-14T20:25:30 | 2015-03-25T22:48:38 | 2023-09-13T09:19:21 | 2023-09-13T09:40:00 | 100,325 | 1,606 | 2,825 | 28 |
Java
| false | false |
/*
* Copyright 2023 Google LLC
*
* 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.example.livestream;
// [START livestream_get_asset]
import com.google.cloud.video.livestream.v1.Asset;
import com.google.cloud.video.livestream.v1.AssetName;
import com.google.cloud.video.livestream.v1.LivestreamServiceClient;
import java.io.IOException;
public class GetAsset {
public static void main(String[] args) throws Exception {
// TODO(developer): Replace these variables before running the sample.
String projectId = "my-project-id";
String location = "us-central1";
String assetId = "my-asset-id";
getAsset(projectId, location, assetId);
}
public static void getAsset(String projectId, String location, String assetId)
throws IOException {
// Initialize client that will be used to send requests. This client only needs to be created
// once, and can be reused for multiple requests. In this example, try-with-resources is used
// which automatically calls close() on the client to clean up resources.
try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) {
AssetName name = AssetName.of(projectId, location, assetId);
Asset response = livestreamServiceClient.getAsset(name);
System.out.println("Asset: " + response.getName());
}
}
}
// [END livestream_get_asset]
|
UTF-8
|
Java
| 1,891 |
java
|
GetAsset.java
|
Java
|
[] | null |
[] |
/*
* Copyright 2023 Google LLC
*
* 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.example.livestream;
// [START livestream_get_asset]
import com.google.cloud.video.livestream.v1.Asset;
import com.google.cloud.video.livestream.v1.AssetName;
import com.google.cloud.video.livestream.v1.LivestreamServiceClient;
import java.io.IOException;
public class GetAsset {
public static void main(String[] args) throws Exception {
// TODO(developer): Replace these variables before running the sample.
String projectId = "my-project-id";
String location = "us-central1";
String assetId = "my-asset-id";
getAsset(projectId, location, assetId);
}
public static void getAsset(String projectId, String location, String assetId)
throws IOException {
// Initialize client that will be used to send requests. This client only needs to be created
// once, and can be reused for multiple requests. In this example, try-with-resources is used
// which automatically calls close() on the client to clean up resources.
try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) {
AssetName name = AssetName.of(projectId, location, assetId);
Asset response = livestreamServiceClient.getAsset(name);
System.out.println("Asset: " + response.getName());
}
}
}
// [END livestream_get_asset]
| 1,891 | 0.740349 | 0.734003 | 49 | 37.591835 | 30.771652 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.510204 | false | false |
0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.