1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License
15  */
16 
17 package com.android.framebufferizer;
18 
19 import com.android.framebufferizer.utils.Config;
20 import com.android.framebufferizer.utils.FrameBufferBuffer;
21 
22 import java.awt.*;
23 import java.util.Random;
24 
25 import javax.swing.*;
26 
27 public class Main {
28     static private FrameBufferBuffer theFramebuffer;
29     static private JFrame theFrame;
30     static private Random random;
31 
createAndShowUI()32     private static void createAndShowUI() {
33         theFrame = new JFrame("TeeuiFramebufferizer");
34         theFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
35         theFramebuffer = new FrameBufferBuffer();
36         theFramebuffer.setFrame(theFrame);
37         FrameBufferBuffer.MagnifiedView magnifiedView = theFramebuffer.getMagnifiedView();
38         FrameBufferBuffer.ConfigSelector configSelector = theFramebuffer.getConfigSelector();
39         magnifiedView.setPreferredSize(new Dimension(100, 100));
40         magnifiedView.setMinimumSize(new Dimension(100, 100));
41         magnifiedView.setMaximumSize(new Dimension(100, 100));
42         theFrame.getContentPane().add(magnifiedView, BorderLayout.EAST);
43         theFrame.getContentPane().add(theFramebuffer, BorderLayout.CENTER);
44         theFrame.getContentPane().add(configSelector, BorderLayout.NORTH);
45         theFrame.pack();
46         theFrame.setVisible(true);
47     }
48 
main(String[] args)49     public static void main(String[] args) {
50         random = new Random();
51         if(Config.getInstance().createLockFile()) {
52             javax.swing.SwingUtilities.invokeLater(new Runnable() {
53                 @Override
54                 public void run() {
55                     createAndShowUI();
56                 }
57             });
58         }
59     }
60 }
61