No |
Features |
|
|
|
Post text and multimedia content |
||||
1 | post text | y | y | limited characters |
2 | post text & multimedia | y (up to 10 multimedia) | y (up to 10 multimedia) | 1 multimedia |
3 | edit text post | y | y | edit with premium |
4 | hashtag | y (number not known) |
y maximum 30 hashtag |
y limited by characters |
Add reply by others or owner |
||||
1 | reply text | y | y | y |
2 | reply text & multimedia | 1 multimedia | text only |
1 multimedia |
re-post a content |
||||
1 | re-post | y | n | y *re-twit |
2 | last update included in re-post | y | not available | y |
3 | re-post included comments | n | not available | y |
Real | ||||
1 | hashtag | y (number not known) | y (maximum 10) | not available |
Youtube | ||||
1 | share video directly | y | depend on dimension | y |
Wednesday, October 16, 2024
Compare Media Social: Facebook, Instagram and twitter
Friday, September 27, 2024
android java: google admob policy collected data checklist
This checklist may be in google play console: App content -> Data Safety!
User property | Type | Description |
---|---|---|
Age | Text | Identifies users by six categories: 18-24, 25-34, 35-44, 45-54, 55-64, and 65+. |
App Store | Text | The store from which the app was downloaded and installed. |
App Version | Text | The versionName (Android) or the Bundle version (iOS). |
Country | Text | The country the user resides in. |
Device Brand | Text | The brand name of the mobile device (e.g., Motorola, LG, or Samsung). |
Device Category | Text | The category of the mobile device (e.g., mobile or tablet). |
Device Model | Text | The mobile device model name (e.g., iPhone 5s or SM-J500M). |
First Open Time | Number | The time (in milliseconds, UTC) at which the user first opened the app, rounded up to the next hour. |
Gender | Text | Identifies users as either male or female. |
Interests | Text | Lists the interests of the user (e.g., "Arts & Entertainment, Games, Sports"). |
Language | Text | The language setting of the device OS (e.g., en-us or pt-br). |
New/Established | N/A | New: First opened the app within the last 7 days. Established: First opened the app more than 7 days ago. |
OS Version | Text | The version of the device OS (e.g., 9.3.2 or 5.1.1). |
NOTE: this checklist may change without notice!
Reference: https://support.google.com/admob/answer/9755590?hl=en
Wednesday, September 4, 2024
Java Swing Layout Manager
The BoxLayout respects the components' requested maximum sizes and also lets you align components.
For many cases flexible Layout:
- GridBagLayout
- SpringLayout
- BoxLayout
Friday, August 23, 2024
Java Swing without Layout Manager
JPanelTest.java
import java.awt.Color;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;
public class JPanelTest extends JPanel {
private static final long serialVersionUID = 1L;
/**
* Create the panel.
*/
public JPanelTest(int x, int y, int width, int height) {
setBorder(new LineBorder(Color.BLACK));
setBounds(x, y, width, height);
JLabel lbl = new JLabel("Test");
add(lbl);
addMouseListener(ma);
}
MouseAdapter ma = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
System.out.println(e.getX()+" "+e.getY()); // relatif to JPanel (0,0)
}
};
}
UISusah.java
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.FlowLayout;
import javax.swing.border.LineBorder;
import java.awt.Color;
public class UISusah extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel contentPane;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UISusah frame = new UISusah();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
private int width = 530 ; // 85+350+85 = 520 -> 530
private int height = 495 ; // 85+290+85 = 460 -> 495
/**
* Create the frame.
*/
public UISusah() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(width, height);
contentPane = new JPanel();
setContentPane(contentPane);
contentPane.setLayout(null);
/*
JPanel panel = new JPanel();
FlowLayout flowLayout = (FlowLayout) panel.getLayout();
flowLayout.setVgap(0);
flowLayout.setHgap(0);
panel.setBounds(0, 0, 85, 85);
contentPane.add(panel);
*/
// 1
JPanelTest panel = new JPanelTest(0, 0, 85, 85);
contentPane.add(panel);
// 2
JPanel panel1 = new JPanel();
panel1.setBorder(new LineBorder(Color.BLACK));
FlowLayout flowLayout_1 = (FlowLayout) panel1.getLayout();
flowLayout_1.setVgap(0);
flowLayout_1.setHgap(0);
panel1.setBounds(85-1, 0, 350, 85);
contentPane.add(panel1);
/*
JPanel panel2 = new JPanel();
panel2.setBorder(new LineBorder(Color.BLACK));
FlowLayout flowLayout_2 = (FlowLayout) panel2.getLayout();
flowLayout_2.setVgap(0);
flowLayout_2.setHgap(0);
panel2.setBounds(350+85-2, 0, 85, 85);
contentPane.add(panel2);
*/
// 3
JPanelTest panel2 = new JPanelTest(350+85-2, 0, 85, 85);
contentPane.add(panel2);
// 4
JPanel panel3 = new JPanel();
panel3.setBorder(new LineBorder(Color.BLACK));
FlowLayout flowLayout_3 = (FlowLayout) panel3.getLayout();
flowLayout_3.setVgap(0);
flowLayout_3.setHgap(0);
panel3.setBounds(0, 85-1, 85, 290);
contentPane.add(panel3);
// 5
JPanel panel4 = new JPanel();
panel4.setBorder(new LineBorder(Color.BLACK));
FlowLayout flowLayout_4 = (FlowLayout) panel4.getLayout();
flowLayout_4.setVgap(0);
flowLayout_4.setHgap(0);
panel4.setBounds(85-1, 85-1, 350, 290);
contentPane.add(panel4);
// 6
JPanel panel5 = new JPanel();
panel5.setBorder(new LineBorder(Color.BLACK));
FlowLayout flowLayout_5 = (FlowLayout) panel5.getLayout();
flowLayout_5.setVgap(0);
flowLayout_5.setHgap(0);
panel5.setBounds(350+85-2, 85-1, 85, 290);
contentPane.add(panel5);
// 7
JPanel panel6 = new JPanel();
panel6.setBorder(new LineBorder(Color.BLACK));
FlowLayout flowLayout_6 = (FlowLayout) panel6.getLayout();
flowLayout_6.setVgap(0);
flowLayout_6.setHgap(0);
panel6.setBounds(0, 290+85-2, 85, 85);
contentPane.add(panel6);
// 8
JPanel panel7 = new JPanel();
panel7.setBorder(new LineBorder(Color.BLACK));
FlowLayout flowLayout_7 = (FlowLayout) panel7.getLayout();
flowLayout_7.setVgap(0);
flowLayout_7.setHgap(0);
panel7.setBounds(85-1, 290+85-2, 350, 85);
contentPane.add(panel7);
// 9
JPanel panel8 = new JPanel();
panel8.setBorder(new LineBorder(Color.BLACK));
FlowLayout flowLayout_8 = (FlowLayout) panel8.getLayout();
flowLayout_8.setVgap(0);
flowLayout_8.setHgap(0);
panel8.setBounds(350+85-2, 290+85-2, 85, 85);
contentPane.add(panel8);
}
}
Wednesday, August 21, 2024
Java swing UI for Bridge playing card
BidImage.java
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JComponent;
public class BidImage extends JComponent {
private static final long serialVersionUID = 5119262068248858764L;
public String bidName=null;
public Dimension dimBidBox=new Dimension(40,20); // width 40 height 20
// PASS width 60 height 20
public int mPadding = 3;
int xP=0,yP=0; // position of screen
public int fontSize=18;
boolean isEnable = true;
String club = String.valueOf('\u2663'); // black 2663 white 2667
String diamond = String.valueOf('\u2666'); // black 2666 white 2662
String hearth = String.valueOf('\u2665'); // black 2665 white 2661
String spade = String.valueOf('\u2660'); // black 2660 white 2664
/*
* bidName
* dimBidBox dimension contains width and height
*/
public BidImage(String bidName) {
this.bidName = bidName;
if (bidName.equals("PASS") || bidName.equals("X") || bidName.equals("XX") ) {
dimBidBox = new Dimension(60,20);
}
}
public void setEnable(boolean isEnable) {
this.isEnable = isEnable;
}
public void setPosition(int x, int y) {
xP=x;
yP=y;
}
public boolean isSelected(int x, int y) {
return (x>=xP && x<=xP+dimBidBox.width
&& y>=yP && y<=yP+dimBidBox.height
&& isEnable);
}
public void drawMe(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
// draw rectangle first
if (isEnable) {
// fill color red
g2d.setColor(Color.GREEN);
g2d.fillRect(xP, yP, dimBidBox.width, dimBidBox.height);
g2d.setColor(Color.BLACK);
g2d.drawRect(xP, yP, dimBidBox.width, dimBidBox.height);
} else {
// fill color gray
g2d.setColor(Color.GRAY);
g2d.fillRect(xP, yP, dimBidBox.width, dimBidBox.height);
g2d.setColor(Color.BLACK);
g2d.drawRect(xP, yP, dimBidBox.width, dimBidBox.height);
}
// draw string
Font font = new Font("Courier", Font.PLAIN, fontSize);
g2d.setFont(font);
g2d.setColor(Color.BLACK);
if (!bidName.endsWith("T")
&& !bidName.equals("PASS")
&& !bidName.equals("X")
&& !bidName.equals("XX") ) {
char lastChar = bidName.charAt(1);
char firstChar = bidName.charAt(0);
String s2Show="";
switch (lastChar) {
case 'C':
s2Show = firstChar+club;
break;
case 'D':
s2Show = firstChar+diamond;
break;
case 'H':
s2Show = firstChar+hearth;
break;
case 'S':
s2Show = firstChar+spade;
break;
}
g2d.drawString(s2Show, xP+mPadding, yP+dimBidBox.height-mPadding);
} else {
g2d.drawString(bidName, xP+mPadding, yP+dimBidBox.height-mPadding);
}
}
}
CardImage.java
import java.awt.BasicStroke;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JComponent;
public class CardImage extends JComponent {
private static final long serialVersionUID = -8665119518202165791L;
BufferedImage bImg;
String cardName;
int strokeImg=1; // card separator
int widthImg=100, heightImg=150; // card dimension
public CardImage(String cardName) {
this.cardName = cardName;
// Load image and add stroke as separator
bImg = new BufferedImage(widthImg,
heightImg, BufferedImage.TYPE_INT_BGR);
Graphics2D g2d = bImg.createGraphics();
g2d.setStroke(new BasicStroke(1)); // 1 pixel
// https://stackoverflow.com/questions/31152233/opening-image-asset-java-jdk-8
String sFName = "/images/"+cardName+".png";
//System.out.println(sFName); // debug
BufferedImage img;
try {
img = ImageIO.read(getClass().getResource(sFName));
g2d.drawImage(img, strokeImg, strokeImg, widthImg-(2*strokeImg),
heightImg-(2*strokeImg), null);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
int x0=0, x1=0, y0=0, y1=0;
private void setClickArea(int x, int y) {
x0=x;
y0=y;
x1=x0+widthImg;
y1=y0+heightImg;
//System.out.println(x0+","+y0+" "+x1+","+y1); // debug
}
public boolean isSelected(int x, int y) {
return x>=x0 && x<=x1 && y>=y0 && y<=y1;
}
/*
* x position horizontal relatif to panel
* y position vertical to panel
*/
public void drawMe(Graphics g, int x, int y, ImageObserver o) {
setClickArea(x,y);
//System.out.println(x0+","+y0+","+x1+","+y1);
g.drawImage(bImg, x, y, o);
}
/*
* 90 degree only, keep on position top left
*/
public void drawMe90(Graphics g, int x, int y, ImageObserver o) {
double rotationAngle=90*Math.PI/180;
AffineTransform transform = new AffineTransform();
transform.rotate(rotationAngle, x, y);
// yCenter-heightImg = horizontal position
// xCenter: vertical position
transform.translate(x, y-heightImg);
Graphics2D g2d = (Graphics2D) g;
g2d.drawImage(bImg, transform, o);
}
}
JPanelCenter.java
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class JPanelCenter extends JPanel {
private static final long serialVersionUID = 1L;
BidImage bI;
public final static String[] S_BIDS = {
"1C", // 0
"1D", // 1
"1H", // 2
"1S", // 3
"1NT", // 4
"2C", // 5
"2D", // 6
"2H", // 7
"2S", // 8
"2NT", // 9
"3C", // 10
"3D", // 11
"3H", // 12
"3S", // 13
"3NT", // 14
"4C", // 15
"4D", // 16
"4H", // 17
"4S", // 18
"4NT", // 19
"5C", // 20
"5D", // 21
"5H", // 22
"5S", // 23
"5NT", // 24
"6C", // 25
"6D", // 26
"6H", // 27
"6S", // 28
"6NT", // 29
"7C", // 30
"7D", // 31
"7H", // 32
"7S", // 33
"7NT" // 34
};
ArrayList<BidImage> bids = new ArrayList<>();
/**
* Create the panel.
*/
public JPanelCenter() {
setPreferredSize(new Dimension(350,290));
JLabel lblNewLabel = new JLabel("Center");
add(lblNewLabel);
bI = new BidImage("7NT");
//bI = new BidImage("1S");
int x=30;
int y=30;
for (int i=0;i<7;i++) {
for (int j=0;j<5;j++) {
int pos=i*5+j;
BidImage tmp = new BidImage(S_BIDS[pos]);
tmp.setPosition(x+(i*tmp.dimBidBox.width), y+(j*tmp.dimBidBox.height));
//tmp.setEnable(false);
bids.add(tmp);
}
}
BidImage pass = new BidImage("PASS");
pass.setPosition(100, 140);
bids.add(pass);
pass = new BidImage("X");
pass.setPosition(100+pass.dimBidBox.width, 140);
bids.add(pass);
pass = new BidImage("XX");
pass.setPosition(100+(2*pass.dimBidBox.width), 140);
bids.add(pass);
addMouseListener(mListener);
}
@Override
protected void paintComponent(Graphics g) {
//bI.setPosition(30, 30);
//bI.drawMe(g);
for (int i=0;i<bids.size();i++) {
BidImage tmp = bids.get(i);
tmp.drawMe(g);
}
}
/*
* position x,y relatif to JPanel
*/
MouseAdapter mListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
System.out.println(e.getX()+" "+e.getY());
for (int i=0;i<bids.size();i++) {
BidImage cI = bids.get(i);
if (cI.isSelected(e.getX(), e.getY())) {
System.out.println(cI.bidName);
break;
}
}
}
};
}
JPanelEast.java
import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.Graphics;
import java.util.ArrayList;
import javax.swing.JLabel;
public class JPanelEast extends JPanel {
private static final long serialVersionUID = 1L;
int panelWidth=85, panelHeight=290;
ArrayList<CardImage> cards = new ArrayList<>();
/**
* Create the panel.
*/
public JPanelEast() {
setPreferredSize(new Dimension(panelWidth,panelHeight));
JLabel lblNewLabel = new JLabel("East");
add(lblNewLabel);
initCards();
}
private void initCards() {
for (int i=0;i<13;i++) {
CardImage cI = new CardImage("RED");
cards.add(cI);
}
}
@Override
protected void paintComponent(Graphics g) {
int x = 0;
int y = 0;
for (int i=0;i<13;i++) {
CardImage cI=cards.get(i);
cI.drawMe90(g, x, y+(i*10), this);
}
}
}
JPanelNorth.java
import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import javax.swing.JLabel;
public class JPanelNorth extends JPanel {
private static final long serialVersionUID = 1L;
int panelWidth=520, panelHeight=85;
ArrayList<CardImage> cards;
/**
* Create the panel.
*/
public JPanelNorth() {
setPreferredSize(new Dimension(panelWidth,panelHeight));
JLabel lblNewLabel = new JLabel("North");
add(lblNewLabel);
addMouseListener(mListener);
initCards();
}
private void initCards() {
String[] S_CLUB = {
"2C",
"3C",
"4C",
"5C",
"6C",
"7C",
"8C",
"9C",
"10C",
"JC",
"QC",
"KC",
"AC"
};
cards= new ArrayList<>();
for (int i=0;i<S_CLUB.length;i++) {
CardImage cI = new CardImage(S_CLUB[i]);
cards.add(cI);
}
}
@Override
protected void paintComponent(Graphics g) {
/*
int x=0,y=-70;
for (int i=0;i<cards.size();i++) {
CardImage cI=cards.get(i);
cI.drawMe(g, x+((i-1)*15), y, this);
}
*/
int x=300,y=-70;
for (int i=0;i<cards.size();i++) {
CardImage cI=cards.get(i);
cI.drawMe(g, x-((i-1)*15), y, this); // 15 gap between cards
}
}
/*
* position x,y relatif to JPanel
*/
MouseAdapter mListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
System.out.println(e.getX()+" "+e.getY());
// reverse from last draw
for (int i=cards.size()-1;i>=0;i--) {
CardImage cI = cards.get(i);
if (cI.isSelected(e.getX(), e.getY())) {
System.out.println(cI.cardName);
break;
}
}
}
};
}
JPanelSouth.java
import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import javax.swing.JLabel;
public class JPanelSouth extends JPanel {
private static final long serialVersionUID = 1L;
int panelWidth=520, panelHeight=85;
ArrayList<CardImage> cards;
/**
* Create the panel.
*/
public JPanelSouth() {
setPreferredSize(new Dimension(panelWidth,panelHeight));
JLabel lblNewLabel = new JLabel("South");
add(lblNewLabel);
addMouseListener(mListener);
initCards();
}
private void initCards() {
String[] S_DIAMOND = {
"2D",
"3D",
"4D",
"5D",
"6D",
"7D",
"8D",
"9D",
"10D",
"JD",
"QD",
"KD",
"AD"
};
cards= new ArrayList<>();
for (int i=0;i<S_DIAMOND.length;i++) {
CardImage cI = new CardImage(S_DIAMOND[i]);
cards.add(cI);
}
}
@Override
protected void paintComponent(Graphics g) {
/*
int x=0,y=-70;
for (int i=0;i<cards.size();i++) {
CardImage cI=cards.get(i);
cI.drawMe(g, x+((i-1)*15), y, this);
}
*/
int x=100,y=5;
for (int i=0;i<cards.size();i++) {
CardImage cI=cards.get(i);
cI.drawMe(g, x+((i-1)*15), y, this);
}
/*
* test ok
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Color.BLACK);
g2d.drawRect(100, 50, 30, 30);
g2d.drawString("TEST", 100, 50);
*/
}
/*
* position x,y relatif to JPanel
*/
MouseAdapter mListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
System.out.println(e.getX()+" "+e.getY());
// reverse from last draw
for (int i=cards.size()-1;i>=0;i--) {
CardImage cI = cards.get(i);
if (cI.isSelected(e.getX(), e.getY())) {
System.out.println(cI.cardName);
break;
}
}
}
};
}
JPanelWest.java
import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.Graphics;
import java.util.ArrayList;
import javax.swing.JLabel;
public class JPanelWest extends JPanel {
private static final long serialVersionUID = 1L;
int panelWidth=85, panelHeight=290;
ArrayList<CardImage> cards = new ArrayList<>();
/**
* Create the panel.
*/
public JPanelWest() {
setPreferredSize(new Dimension(panelWidth,panelHeight));
JLabel lblNewLabel = new JLabel("West");
add(lblNewLabel);
initCards();
}
private void initCards() {
for (int i=0;i<13;i++) {
CardImage cI = new CardImage("BLUE");
cards.add(cI);
}
}
@Override
protected void paintComponent(Graphics g) {
int x = -70;
int y = 0;
for (int i=0;i<13;i++) {
CardImage cI=cards.get(i);
cI.drawMe90(g, x, y+(i*10), this);
}
}
}
BridgeUI.java
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
public class BridgeUI extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel contentPane;
private int width = 520 ; // 85+350+85
private int height = 460 ; // 85+290+85
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
BridgeUI frame = new BridgeUI();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public BridgeUI() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(width, height);
setResizable(false);
contentPane = new JPanel();
contentPane.setLayout(new BorderLayout());
JPanelWest pWest = new JPanelWest();
contentPane.add(pWest,BorderLayout.WEST);
JPanelNorth pNorth = new JPanelNorth();
contentPane.add(pNorth,BorderLayout.NORTH);
JPanelEast pEast = new JPanelEast();
contentPane.add(pEast,BorderLayout.EAST);
JPanelCenter pCenter = new JPanelCenter();
contentPane.add(pCenter,BorderLayout.CENTER);
JPanelSouth pSouth = new JPanelSouth();
contentPane.add(pSouth,BorderLayout.SOUTH);
setContentPane(contentPane);
}
}
Note:
- to place images, follow link
- image name's in this code use upper case with extension .png, e.q 2C.png, RED.png
Friday, August 16, 2024
Istilah-istilah di kompresor angin
Kompresor Udara Bertekanan Rendah: di bawah 145 PSI (atau 10 bar) Kompresor Udara Bertekanan Sedang: antara 145 dan 1.160 PSI (atau 10 hingga 80 bar) Kompresor Udara Bertekanan Tinggi: antara 1.160 dan 15.000 PSI (80 dan 1.000 bar) Hyper -Kompresor Udara Bertekanan dan Sangat Tinggi: lebih dari 15.000 PSI (1.000 bar).
Pada spray gun ini jarak dan tekanan udara sangat mempengaruhi hasil dari pelapisan yang dilakukan, jarak spray yang terjadi pada umumnya adalah 152,4 mm – 300 mm serta besar tekanan udara yang baik agar spray gun dapat beratomasi dengan baik sebesar 2 - 5 bar [3].
Tekanan yang dihasilkan di dalam tangki kompresor udara diukur dalam bar dan pound per inci persegi, atau PSI. Kebanyakan kompresor memiliki tekanan kerja 8 bar atau 115 PSI, yang lebih dari cukup untuk peralatan udara DIY dan hobi (biasanya sekitar 90 PSI).
Namun sebaiknya Anda memiliki kompresor yang menghasilkan PSI lebih tinggi dari yang Anda perlukan karena tekanan udara akan turun seiring penggunaan. Aturan praktis yang baik adalah memiliki setidaknya 35% lebih banyak dari 90 PSI yang diperlukan untuk alat tersebut, atau sekitar 120 PSI . Dengan cara ini, Anda akan yakin akan tekanan yang konsisten.
1/2 HP ~ 7 BAR ~ 101.5 PSI s/d 8 BAR ~ 116 PSI
3/4 HP ~ 10 BAR ~ 145 PSI
Friday, August 9, 2024
java: graphics2d and rotation test
import java.awt.BasicStroke;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
public class JFrameRotate extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel contentPane;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
JFrameRotate frame = new JFrameRotate();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
int panelWidth=600, panelHeight=600;
/**
* Create the frame.
*/
public JFrameRotate() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(0, 0, panelWidth, panelHeight);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
loadCard();
}
// JFrame: public void paint(Graphics g)
// JPanel: protected void paintComponent(Graphics g)
@Override
public void paint(Graphics g) {
if (bImg!=null) {
//g.drawImage(bImg, xCenter, yCenter, this);
// draw the image
Graphics2D g2d = (Graphics2D) g;
g2d.drawImage(bImg, rotate(10), contentPane);
g2d.drawImage(bImg, rotate(45), contentPane);
g2d.drawImage(bImg, rotate(90), contentPane);
g2d.drawImage(bImg, rotate90(), contentPane);
}
}
int strokeImg =1, widthImg=100, heightImg=150;
int xCenter=200, yCenter=300;
BufferedImage bImg;
private void loadCard() {
bImg = new BufferedImage(widthImg,
heightImg, BufferedImage.TYPE_INT_BGR);
Graphics2D g2d = bImg.createGraphics();
g2d.setStroke(new BasicStroke(1)); // 1 pixel
// https://stackoverflow.com/questions/31152233/opening-image-asset-java-jdk-8
String sFName = "/images/KC.png"; // See here to setup image resources
BufferedImage img;
try {
img = ImageIO.read(getClass().getResource(sFName));
g2d.drawImage(img, strokeImg, strokeImg, widthImg-(2*strokeImg),
heightImg-(2*strokeImg), this);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private AffineTransform rotate(int degree) {
double rotationAngle=degree*Math.PI/180;
AffineTransform transform = new AffineTransform();
transform.rotate(rotationAngle, xCenter, yCenter);
//transform.rotate(rotationAngle);
transform.translate(xCenter, yCenter);
return transform;
}
/*
* 90 degree only, keep on position top left
*/
private AffineTransform rotate90() {
double rotationAngle=90*Math.PI/180;
AffineTransform transform = new AffineTransform();
transform.rotate(rotationAngle, xCenter, yCenter);
// yCenter-heightImg = horizontal position
// xCenter: vertical position
transform.translate(xCenter, yCenter-heightImg);
return transform;
}
}
Wednesday, August 7, 2024
Eclipse: how to read images from resources
Create resources folder
- create "res" folder via "Package Explorer".
- right click on "res" folder -> "Build Path" -> "Use as Source Folder". "res" will be root of your resource.
- create "images" folder inside "res" folder. Copy your images into this folder. Path your file becomes "/images/example.jpg".
Accessing images from the "images" folder, use this piece of code into your java source code:
String cName = "example.jpg";
String sFName = "/images/"+cName;
BufferedImage img = ImageIO.read(this.getClass().getResource(sFName));
References:
https://stackoverflow.com/questions/31152233/opening-image-asset-java-jdk-8
Monday, August 5, 2024
windows: disable fast start for multiple OS (dual boot)
Hibernation saves an image of your work and shuts down your computer or put your computer into sleep mode.
Fast Startup only saves an image of the system kernel and loaded drivers to reduce boot time.
Fast Startup may not suitable for System:
- multiple os except you never access/share data between multiple os.
- maintenance
- hardware change
Step to disable fast startup
- Search -> Choose a power plan -> Choose what the power buttons do -> Change settings that are currently unavailable
- uncheck "Turn on fast start (recommendation)"
- save change and restart
Wednesday, July 17, 2024
Debian: using Festival to generate voice from text (Text To Speech/TTS) - AI TTS
folder voice
$ ls /usr/share/festival/voices/english/
Using command interpreter:
$ festival
...
festival> (voice.list)
(kal_diphone)
festival> (SayText "Hello")
#<Utterance 0x7f8747f99ef0>
festival> (quit)
Load text from file output direct to sound
$ festival --tts ./hello.txt
Load text from file output direct to file
$ text2wave ./hello.txt -o text1.wav
Monday, July 8, 2024
java 17: shuffle 52 playing cards and sort the order base on bridge playing game
This is the code to shuffle 52 playing cards for 4 players and re order each hand cards. I provide to order card base on trump (at right side).
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class Test {
/*
* TODO how to repesent card
*/
public final static String[] S_CLUB = {
"2C",
"3C",
"4C",
"5C",
"6C",
"7C",
"8C",
"9C",
"10C",
"JC", //JC
"QC", //QC
"KC", //KC
"AC" //AC
};
public final static String[] S_DIAMOND = {
"2D",
"3D",
"4D",
"5D",
"6D",
"7D",
"8D",
"9D",
"10D",
"JD",
"QD",
"KD",
"AD"
};
public final static String[] S_HEART = {
"2H",
"3H",
"4H",
"5H",
"6H",
"7H",
"8H",
"9H",
"10H",
"JH",
"QH",
"KH",
"AH"
};
public final static String[] S_SPADE = {
"2S",
"3S",
"4S",
"5S",
"6S",
"7S",
"8S",
"9S",
"10S",
"JS",
"QS",
"KS",
"AS"
};
public static void main(String[] args) {
long startTime = System.nanoTime();
shuffleCard();
long endTime = System.nanoTime();
System.out.println("North");
for (int i=0;i<13;i++) {
System.out.print(north[i]+" ");
}
System.out.println();
System.out.println("After Sorting");
ArrayList<String> tmp = sortEnd2Begin(north);
tmp.forEach((String myCard) ->{
System.out.print(myCard+" ");
});
System.out.println();
System.out.println("EAST");
for (int i=0;i<13;i++) {
System.out.print(east[i]+" ");
}
System.out.println();
System.out.println("After Sorting");
tmp = sortEnd2Begin(east);
tmp.forEach((String myCard) ->{
System.out.print(myCard+" ");
});
System.out.println();
System.out.println("South");
for (int i=0;i<13;i++) {
System.out.print(south[i]+" ");
}
System.out.println();
System.out.println("After Sorting");
tmp = sortEnd2Begin(south);
tmp.forEach((String myCard) ->{
System.out.print(myCard+" ");
});
System.out.println();
System.out.println("West");
for (int i=0;i<13;i++) {
System.out.print(west[i]+" ");
}
System.out.println();
System.out.println("After Sorting");
tmp = sortEnd2Begin(west);
tmp.forEach((String myCard) ->{
System.out.print(myCard+" ");
});
System.out.println();
System.out.println((endTime-startTime)%1000000+" mili"); // time_ms % 1E+3 + " MicroSeconds, "
}
static String[] north = new String[13];
static String[] east = new String[13];
static String[] south = new String[13];
static String[] west = new String[13];
private static void shuffleCard() {
//TODO
ArrayList<String> cards = new ArrayList<>();
List<String> listCard = Arrays.asList(S_CLUB);
cards.addAll(listCard);
listCard = Arrays.asList(S_DIAMOND);
cards.addAll(listCard);
listCard = Arrays.asList(S_HEART);
cards.addAll(listCard);
listCard = Arrays.asList(S_SPADE);
cards.addAll(listCard);
//System.out.println("card number: "+cards.size()); // debug
cards = shuffle(1,cards);
//System.out.println("Distribution "+cards.size());
int topPosition = cards.size()-1;
for (int i=0;i<13;i++) {
//System.out.println("north "+i+" "+topPosition); // debug
String tmp = cards.get(topPosition);
cards.remove(topPosition);
topPosition --;
north[i] = tmp;
//System.out.println("east "+i+" "+topPosition); // debug
tmp = cards.get(topPosition);
cards.remove(topPosition);
topPosition --;
east[i] = tmp;
//System.out.println("south "+i+" "+topPosition); // debug
tmp = cards.get(topPosition);
cards.remove(topPosition);
topPosition --;
south[i] = tmp;
//System.out.println("west "+i+" "+topPosition); // debug
tmp = cards.get(topPosition);
cards.remove(topPosition);
topPosition --;
west[i] = tmp;
}
}
static Random rand = new Random();
private static ArrayList<String> shuffle(int numSuffle, ArrayList<String> cards) {
//System.out.println("Suffle: "+numSuffle); // debug
Collections.shuffle(cards, rand);
//System.out.println("Card size "+cards.size()); // debug
if (numSuffle>0) {
shuffle(numSuffle-1, cards);
}
return cards;
}
private static ArrayList<String> sortEnd2Begin(String[] myCards) {
ArrayList<String> myNewCards = new ArrayList<>();
myNewCards.add(myCards[0]);
for (int i=1;i<myCards.length;i++) {
// loop for unordered myCards
String card2Sort = myCards[i];
for (int j=0;j<myNewCards.size();j++) {
// loop for ordered myNewCards
// find until card2Sort equal or bigger then existing list
String cardIterate = myNewCards.get(j);
//int posCard = beforeOrAfter(card2Sort, cardIterate, 0, iterMax);
int posCard = beforeOrAfter2(card2Sort, cardIterate);
if (posCard<=0) {
myNewCards.add(j, card2Sort);
break;
} else {
//System.out.println(j); // debug
if (j+1==myNewCards.size()) {
// end of list
myNewCards.add(card2Sort);
break;
}
}
}
}
return myNewCards;
}
/* -1 wordA before wordB
* 0 wordA equal wordB
* 1 wordA after wordB
* suite order less C D H S higher
* value suit less 0 1 2 3 4 5 6 7 8 9 A J K Q
* map 10 to A
* J to B
* Q to C
* K to D
* A to E
*/
private static int beforeOrAfter2(String wordA, String wordB) {
//System.out.print("word "+wordA+" "+wordB+" "); // debug
char charA = wordA.charAt(wordA.length()-1);
char charB = wordB.charAt(wordB.length()-1);
//System.out.println(wordA+" "+wordB+" End "+charA+" "+charB+" "); // debug
if (charA<charB) {
return -1;
} else if (charA>charB) {
return 1;
} else {
// equal
charA = wordA.charAt(wordA.length()-2);
charB = wordB.charAt(wordB.length()-2);
// mapping charA to correct order
if (charA=='0') {
charA='A';
} else if (charA=='J') {
charA='B';
} else if (charA=='Q') {
charA='C';
} else if (charA=='K') {
charA='D';
} else if (charA=='A') {
charA='E';
}
// mapping charB to correct order
if (charB=='0') {
charB='A';
} else if (charB=='J') {
charB='B';
} else if (charB=='Q') {
charB='C';
} else if (charB=='K') {
charB='D';
} else if (charB=='A') {
charB='E';
}
//System.out.println(" First "+charA+" "+charB); // debug
if (charA<charB) {
return -1;
} else if (charA>charB) {
return 1;
}
}
return 0;
}
public static ArrayList<String> sortCardsWithTrump(ArrayList<String> myCards, char trump) {
ArrayList<String> myNewCards = new ArrayList<>();
myNewCards.add(myCards.get(0));
for (int i=1;i<myCards.size();i++) {
// loop for unordered myCards
String card2Sort = myCards.get(i);
for (int j=0;j<myNewCards.size();j++) {
// loop for ordered myNewCards
// find until card2Sort equal or bigger then existing list
String cardIterate = myNewCards.get(j);
//int posCard = beforeOrAfter(card2Sort, cardIterate, 0, iterMax);
int posCard = beforeOrAfter2Trump(card2Sort, cardIterate, trump);
if (posCard<=0) {
myNewCards.add(j, card2Sort);
break;
} else {
//System.out.println(j); // debug
if (j+1==myNewCards.size()) {
// end of list
myNewCards.add(card2Sort);
break;
}
}
}
}
return myNewCards;
}
/* -1 wordA before wordB
* 0 wordA equal wordB
* 1 wordA after wordB
* NO TRUMP CDHS
* TRUMP Map to Z for trump
* suite order less C D H S higher
* value suit less 0 1 2 3 4 5 6 7 8 9 A J K Q
* map 10 to A
* J to B
* Q to C
* K to D
* A to E
*/
private static int beforeOrAfter2Trump(String wordA, String wordB, char trump) {
//System.out.print("word "+wordA+" "+wordB+" "); // debug
char charA = wordA.charAt(wordA.length()-1);
char charB = wordB.charAt(wordB.length()-1);
//System.out.println(wordA+" "+wordB+" End "+charA+" "+charB+" "); // debug
// remap char for TRUMP
// mapping charA to correct order
if (charA==trump) {
charA='Z';
}
// mapping charB to correct order
if (charB==trump) {
charB='Z';
}
if (charA<charB) {
return -1;
} else if (charA>charB) {
return 1;
} else {
// equal
charA = wordA.charAt(wordA.length()-2);
charB = wordB.charAt(wordB.length()-2);
// mapping charA to correct order
if (charA=='0') {
charA='A';
} else if (charA=='J') {
charA='B';
} else if (charA=='Q') {
charA='C';
} else if (charA=='K') {
charA='D';
} else if (charA=='A') {
charA='E';
}
// mapping charB to correct order
if (charB=='0') {
charB='A';
} else if (charB=='J') {
charB='B';
} else if (charB=='Q') {
charB='C';
} else if (charB=='K') {
charB='D';
} else if (charB=='A') {
charB='E';
}
//System.out.println(" First "+charA+" "+charB); // debug
if (charA<charB) {
return -1;
} else if (charA>charB) {
return 1;
}
}
return 0;
}
}